From 3f8ffd20e5e0eab79ad48912955df18fc40ff5b8 Mon Sep 17 00:00:00 2001 From: "zed-zippy[bot]" <234243425+zed-zippy[bot]@users.noreply.github.com> Date: Tue, 21 Apr 2026 02:43:34 +0000 Subject: [PATCH] sidebar: Improve hover in history view thread items (#54370) (cherry-pick to preview) (#54377) Cherry-pick of #54370 to preview ---- This PR improves the hover state in thread items within the history view by making them more stable. There were other thread events calling a refresh, which would clear the hover state even though I'd still be hovering the item, making the buttons that only appear on hover feel unstable and disappear. Release Notes: - Agent: Improve hover state stability on thread items within the sidebar's history view. Co-authored-by: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> --- crates/agent_ui/src/threads_archive_view.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/agent_ui/src/threads_archive_view.rs b/crates/agent_ui/src/threads_archive_view.rs index b86d19f2013442690ebc3ca80afb71ae8b576e0e..333a2d8e68c734a3bc440544901ccfd6b65e7043 100644 --- a/crates/agent_ui/src/threads_archive_view.rs +++ b/crates/agent_ui/src/threads_archive_view.rs @@ -325,9 +325,7 @@ impl ThreadsArchiveView { self.list_state.reset(items.len()); self.items = items; - if !preserve { - self.hovered_index = None; - } else if let Some(ix) = self.hovered_index { + if let Some(ix) = self.hovered_index { if ix >= self.items.len() || !self.is_selectable_item(ix) { self.hovered_index = None; } @@ -649,12 +647,15 @@ impl ThreadsArchiveView { .focused(is_focused) .hovered(is_hovered) .on_hover(cx.listener(move |this, is_hovered, _window, cx| { - if *is_hovered { - this.hovered_index = Some(ix); - } else if this.hovered_index == Some(ix) { - this.hovered_index = None; + let previously_hovered = this.hovered_index; + this.hovered_index = if *is_hovered { + Some(ix) + } else { + previously_hovered.filter(|&i| i != ix) + }; + if this.hovered_index != previously_hovered { + cx.notify(); } - cx.notify(); })); if is_restoring {