From 1ddf754b8b2fe80156c3e9beede4a322f0755940 Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Tue, 14 Jan 2025 18:15:24 +0100 Subject: [PATCH] zeta: Rework displaying paths in completion rating modal (#23129) 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 | |--------|--------| | Screenshot 2025-01-14 at 16 09 05 | Screenshot 2025-01-14 at 16 17 52 | Release Notes: - N/A --- crates/zeta/src/rate_completion_modal.rs | 9 ++++++++- crates/zeta/src/zeta.rs | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/zeta/src/rate_completion_modal.rs b/crates/zeta/src/rate_completion_modal.rs index 75e1e10b3e4098f893c84e748311c74a21b8a324..cf7d3f34e92f51faa9ee851a044301a9082de336 100644 --- a/crates/zeta/src/rate_completion_modal.rs +++ b/crates/zeta/src/rate_completion_modal.rs @@ -495,6 +495,9 @@ impl Render for RateCompletionModal { (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) @@ -511,7 +514,11 @@ impl Render for RateCompletionModal { ) .child( v_flex() - .child(Label::new(completion.path.to_string_lossy().to_string()).size(LabelSize::Small)) + .child( + h_flex().gap_2() + .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) diff --git a/crates/zeta/src/zeta.rs b/crates/zeta/src/zeta.rs index 7c74d1f716ff293c4a65da2b6b084d0f9b07e3d8..e7f61a9309d3358fde5c3c8c68adf4f22261730c 100644 --- a/crates/zeta/src/zeta.rs +++ b/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();