From cf69756ddb6690a7c3f4b96d9632147d901d9e71 Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Mon, 13 Apr 2026 18:34:17 +0100 Subject: [PATCH] agent_ui: Fix empty agent panel state after startup (#53823) Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - N/A --- crates/agent_ui/src/agent_panel.rs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index 836b647e2a418312b84efa7461d6eda9ac027287..43f59f1df084ab8cf27ac55d4553e9744a6946e6 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -1041,6 +1041,10 @@ impl AgentPanel { cx, ); }); + } else { + panel.update(cx, |panel, cx| { + panel.show_or_create_empty_draft(window, cx); + }); } panel })?; @@ -5347,8 +5351,8 @@ mod tests { ); }); - // Workspace B should restore its own agent type, with no thread - loaded_b.read_with(cx, |panel, _cx| { + // Workspace B should restore its own agent type and seed an empty draft. + loaded_b.read_with(cx, |panel, cx| { assert_eq!( panel.selected_agent, Agent::Custom { @@ -5357,8 +5361,12 @@ mod tests { "workspace B agent type should be restored" ); assert!( - panel.active_conversation_view().is_none(), - "workspace B should have no active thread" + panel.active_conversation_view().is_some(), + "workspace B should show an empty draft" + ); + assert!( + panel.active_thread_is_draft(cx), + "workspace B should seed a draft in an empty workspace" ); }); } @@ -5420,10 +5428,14 @@ mod tests { .expect("panel load should succeed"); cx.run_until_parked(); - loaded.read_with(cx, |panel, _cx| { + loaded.read_with(cx, |panel, cx| { + assert!( + panel.active_conversation_view().is_some(), + "empty workspaces should still show a draft after load" + ); assert!( - panel.active_conversation_view().is_none(), - "thread without metadata should not be restored" + panel.active_thread_is_draft(cx), + "thread without metadata should not be restored; the panel should fall back to a fresh draft" ); }); } @@ -6377,6 +6389,7 @@ mod tests { ) .await; fs.set_branch_name(Path::new("/project/.git"), Some("main")); + cx.update(|cx| ::set_global(fs.clone(), cx)); let project = Project::test(fs.clone(), [Path::new("/project")], cx).await;