Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

sidebar: Fix click flicker on empty draft thread (#59342)

Danilo Leal50b2f63cfe35
diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rs
index 303f591d567..1cb3ace4acc 100644
--- a/crates/sidebar/src/sidebar.rs
+++ b/crates/sidebar/src/sidebar.rs
@@ -3690,6 +3690,18 @@ impl Sidebar {
.detach_and_log_err(cx);
}
+ fn is_thread_active_in_workspace(
+ &self,
+ thread_id: &ThreadId,
+ workspace: &Entity<Workspace>,
+ cx: &App,
+ ) -> bool {
+ self.active_workspace(cx).as_ref() == Some(workspace)
+ && self.active_entry.as_ref().is_some_and(|entry| {
+ entry.is_active_thread(thread_id) && entry.workspace() == workspace
+ })
+ }
+
fn activate_thread_locally(
&mut self,
metadata: &ThreadMetadata,
@@ -3702,6 +3714,13 @@ impl Sidebar {
return;
};
+ if self.is_thread_active_in_workspace(&metadata.thread_id, workspace, cx) {
+ workspace.update(cx, |workspace, cx| {
+ workspace.focus_panel::<AgentPanel>(window, cx);
+ });
+ return;
+ }
+
// Set active_entry eagerly so the sidebar highlight updates
// immediately, rather than waiting for a deferred AgentPanel
// event which can race with ActiveWorkspaceChanged clearing it.