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;