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

Closes AI-404

This PR fixes a flicker that was happening when clicking on an empty
draft thread item in the sidebar, given we were going through the whole
regular activation flow despite the thread already being active. So, the
fix here was just extracting a boolean so we can identify whether the
thread is active in the workspace and if so, not doing nothing in the
on_click handler of the thread item.

Release Notes:

- Sidebar: Fixed a flicker when clicking on an empty draft thread.
This commit is contained in:
Danilo Leal authored and GitHub committed 2026-06-15 21:19:16 +00:00
1 parent 4e04617329
commit 1b3ff5ea73
1 file changed
+19
+19
View File
@@ -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.