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.

Fix a bug where the draft thread was being spuriously dropped from the sidebar (#52936)

Mikayla Makibbde01ae3bea
diff --git a/crates/sidebar/src/sidebar.rs b/crates/sidebar/src/sidebar.rs
index e09ee3e8809..cd9bfb4d7ab 100644
--- a/crates/sidebar/src/sidebar.rs
+++ b/crates/sidebar/src/sidebar.rs
@@ -709,19 +709,25 @@ impl Sidebar {
// Derive active_entry from the active workspace's agent panel.
// Draft is checked first because a conversation can have a session_id
// before any messages are sent. However, a thread that's still loading
- // also appears as a "draft" (no messages yet), so when we already have
- // an eager Thread write for this workspace we preserve it. A session_id
- // on a non-draft is a positive Thread signal. The remaining case
- // (conversation exists, not draft, no session_id) is a genuine
- // mid-load — keep the previous value.
+ // also appears as a "draft" (no messages yet).
if let Some(active_ws) = &active_workspace {
if let Some(panel) = active_ws.read(cx).panel::<AgentPanel>(cx) {
if panel.read(cx).active_thread_is_draft(cx)
|| panel.read(cx).active_conversation_view().is_none()
{
+ let conversation_parent_id = panel
+ .read(cx)
+ .active_conversation_view()
+ .and_then(|cv| cv.read(cx).parent_id(cx));
let preserving_thread =
- matches!(&self.active_entry, Some(ActiveEntry::Thread { .. }))
- && self.active_entry_workspace() == Some(active_ws);
+ if let Some(ActiveEntry::Thread { session_id, .. }) = &self.active_entry {
+ self.active_entry_workspace() == Some(active_ws)
+ && conversation_parent_id
+ .as_ref()
+ .is_some_and(|id| id == session_id)
+ } else {
+ false
+ };
if !preserving_thread {
self.active_entry = Some(ActiveEntry::Draft(active_ws.clone()));
}