Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent: Add tooltip to diff stats (#51448)
Cameron Mcloughlinb8eea31a09b4
diff --git a/crates/ui/src/components/ai/thread_item.rs b/crates/ui/src/components/ai/thread_item.rsindex 13e1db8f483..35aa3487a39 100644--- a/crates/ui/src/components/ai/thread_item.rs+++ b/crates/ui/src/components/ai/thread_item.rs@@ -311,11 +311,10 @@ impl RenderOnce for ThreadItem {this.child(dot_separator())}).when(has_diff_stats, |this| {- this.child(DiffStat::new(- diff_stat_id.clone(),- added_count,- removed_count,- ))+ this.child(+ DiffStat::new(diff_stat_id.clone(), added_count, removed_count)+ .tooltip("Unreviewed changes"),+ )}).when(has_diff_stats && has_timestamp, |this| {this.child(dot_separator())@@ -336,7 +335,10 @@ impl RenderOnce for ThreadItem {.gap_1p5().child(icon_container()) // Icon Spacing.when(has_diff_stats, |this| {- this.child(DiffStat::new(diff_stat_id, added_count, removed_count))+ this.child(+ DiffStat::new(diff_stat_id, added_count, removed_count)+ .tooltip("Unreviewed changes"),+ )}).when(has_diff_stats && has_timestamp, |this| {this.child(dot_separator())diff --git a/crates/ui/src/components/diff_stat.rs b/crates/ui/src/components/diff_stat.rsindex 45539c62869..c2e76b171e7 100644--- a/crates/ui/src/components/diff_stat.rs+++ b/crates/ui/src/components/diff_stat.rs@@ -1,3 +1,4 @@+use crate::Tooltip;use crate::prelude::*;#[derive(IntoElement, RegisterComponent)]@@ -6,6 +7,7 @@ pub struct DiffStat {added: usize,removed: usize,label_size: LabelSize,+ tooltip: Option<SharedString>,}impl DiffStat {@@ -15,6 +17,7 @@ impl DiffStat {added,removed,label_size: LabelSize::Small,+ tooltip: None,}}@@ -22,10 +25,16 @@ impl DiffStat {self.label_size = label_size;self}++ pub fn tooltip(mut self, tooltip: impl Into<SharedString>) -> Self {+ self.tooltip = Some(tooltip.into());+ self+ }}impl RenderOnce for DiffStat {fn render(self, _: &mut Window, _cx: &mut App) -> impl IntoElement {+ let tooltip = self.tooltip;h_flex().id(self.id).gap_1()@@ -39,6 +48,9 @@ impl RenderOnce for DiffStat {.color(Color::Error).size(self.label_size),)+ .when_some(tooltip, |this, tooltip| {+ this.tooltip(Tooltip::text(tooltip))+ })}}