zeta: Rework displaying paths in completion rating modal (#23129)

Bennet Bo Fenner created

Two issues i ran into while looking at the completion rating modal
- Single-file worktrees file names are not displayed at all
- Hard to see the filename when the path is long (lots of directories)

This PR fixes this by displaying the filename on the left, followed by
the full path (including the worktree name), similar to how we do it in
the file finder/assistant panel /file command
| Before | After |
|--------|--------|
| <img width="1067" alt="Screenshot 2025-01-14 at 16 09 05"
src="https://github.com/user-attachments/assets/628fde18-da9a-4d98-8ddf-ed0ab0cd8d35"
/> | <img width="1161" alt="Screenshot 2025-01-14 at 16 17 52"
src="https://github.com/user-attachments/assets/80c6a4e1-065d-4b0a-b9c0-5f3391af4557"
/> |

Release Notes:

- N/A
# Conflicts:
#	crates/zeta/src/rate_completion_modal.rs

Change summary

crates/zeta/src/rate_completion_modal.rs | 44 ++++++++++++++++++-------
crates/zeta/src/zeta.rs                  |  2 
2 files changed, 32 insertions(+), 14 deletions(-)

Detailed changes

crates/zeta/src/rate_completion_modal.rs 🔗

@@ -491,27 +491,45 @@ impl Render for RateCompletionModal {
                                             let rated =
                                                 self.zeta.read(cx).is_completion_rated(completion.id);
 
+                                            let (icon_name, icon_color, tooltip_text) = match (rated, completion.edits.is_empty()) {
+                                                (true, _) => (IconName::Check, Color::Success, "Rated Completion"),
+                                                (false, true) => (IconName::File, Color::Muted, "No Edits Produced"),
+                                                (false, false) => (IconName::FileDiff, Color::Accent, "Edits Available"),
+                                            };
+
+                                            let file_name = completion.path.file_name().map(|f| f.to_string_lossy().to_string()).unwrap_or("untitled".to_string());
+                                            let file_path = completion.path.parent().map(|p| p.to_string_lossy().to_string());
+
                                             ListItem::new(completion.id)
                                                 .inset(true)
                                                 .spacing(ListItemSpacing::Sparse)
                                                 .focused(index == self.selected_index)
                                                 .toggle_state(selected)
-                                                .start_slot(if rated {
-                                                    Icon::new(IconName::Check).color(Color::Success).size(IconSize::Small)
-                                                } else if completion.edits.is_empty() {
-                                                    Icon::new(IconName::File).color(Color::Muted).size(IconSize::Small)
-                                                } else {
-                                                    Icon::new(IconName::FileDiff).color(Color::Accent).size(IconSize::Small)
-                                                })
                                                 .child(
-                                                    v_flex()
-                                                        .pl_1p5()
-                                                        .child(Label::new(completion.path.to_string_lossy().to_string()).size(LabelSize::Small))
-                                                        .child(Label::new(format!("{} ago, {:.2?}", format_time_ago(completion.response_received_at.elapsed()), completion.latency()))
-                                                            .color(Color::Muted)
-                                                            .size(LabelSize::XSmall)
+                                                    h_flex()
+                                                        .id("completion-content")
+                                                        .gap_3()
+                                                        .child(
+                                                            Icon::new(icon_name)
+                                                                .color(icon_color)
+                                                                .size(IconSize::Small)
+                                                        )
+                                                        .child(
+                                                            v_flex()
+                                                                .child(
+                                                                    h_flex().gap_1()
+                                                                        .child(Label::new(file_name).size(LabelSize::Small))
+                                                                        .when_some(file_path, |this, p| this.child(Label::new(p).size(LabelSize::Small).color(Color::Muted)))
+                                                                )
+                                                                .child(Label::new(format!("{} ago, {:.2?}", format_time_ago(completion.response_received_at.elapsed()), completion.latency()))
+                                                                    .color(Color::Muted)
+                                                                    .size(LabelSize::XSmall)
+                                                                )
                                                         )
                                                 )
+                                                .tooltip(move |cx| {
+                                                    Tooltip::text(tooltip_text, cx)
+                                                })
                                                 .on_click(cx.listener(move |this, _, cx| {
                                                     this.select_completion(Some(completion.clone()), true, cx);
                                                 }))

crates/zeta/src/zeta.rs 🔗

@@ -293,7 +293,7 @@ impl Zeta {
         let events = self.events.clone();
         let path = snapshot
             .file()
-            .map(|f| f.path().clone())
+            .map(|f| Arc::from(f.full_path(cx).as_path()))
             .unwrap_or_else(|| Arc::from(Path::new("untitled")));
 
         let client = self.client.clone();