From f0477d455010b15a3be59a8c71e7109d254f1bb2 Mon Sep 17 00:00:00 2001 From: "zed-zippy[bot]" <234243425+zed-zippy[bot]@users.noreply.github.com> Date: Tue, 25 Nov 2025 10:12:31 +0000 Subject: [PATCH] Fix first window open not focusing the modals (#43180) (cherry-pick to preview) (#43451) Cherry-pick of #43180 to preview ---- Closes https://github.com/zed-industries/zed/issues/4357 Closes https://github.com/zed-industries/zed/issues/41278 Release Notes: - Fixed modals not getting focus on window reopen --------- Co-authored-by: Conrad Irwin Co-authored-by: Kirill Bulatov Co-authored-by: Conrad Irwin --- crates/agent_ui/src/acp/thread_view.rs | 1 - crates/agent_ui/src/agent_panel.rs | 20 +++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 312ca136a2bf6f8b134a0dae0ab01bb71497a3b2..57454c4feb0f5d5d8dfd27d9581fb80b3cc63625 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -647,7 +647,6 @@ impl AcpThreadView { mode_selector, _subscriptions: subscriptions, }; - this.message_editor.focus_handle(cx).focus(window); this.profile_selector = this.as_native_thread(cx).map(|thread| { cx.new(|cx| { diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index dfc4d27e1153c61dc07c00a807c958f69db77b5a..90cf377d86117e1862b1a806146fd9ecbfa0f37d 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -828,6 +828,7 @@ impl AgentPanel { window, cx, ), + true, window, cx, ); @@ -923,7 +924,12 @@ impl AgentPanel { ) }); - this.set_active_view(ActiveView::ExternalAgentThread { thread_view }, window, cx); + this.set_active_view( + ActiveView::ExternalAgentThread { thread_view }, + !loading, + window, + cx, + ); }) }) .detach_and_log_err(cx); @@ -965,10 +971,10 @@ impl AgentPanel { fn open_history(&mut self, window: &mut Window, cx: &mut Context) { if matches!(self.active_view, ActiveView::History) { if let Some(previous_view) = self.previous_view.take() { - self.set_active_view(previous_view, window, cx); + self.set_active_view(previous_view, true, window, cx); } } else { - self.set_active_view(ActiveView::History, window, cx); + self.set_active_view(ActiveView::History, true, window, cx); } cx.notify(); } @@ -1024,6 +1030,7 @@ impl AgentPanel { window, cx, ), + true, window, cx, ); @@ -1169,7 +1176,7 @@ impl AgentPanel { let context_server_store = self.project.read(cx).context_server_store(); let fs = self.fs.clone(); - self.set_active_view(ActiveView::Configuration, window, cx); + self.set_active_view(ActiveView::Configuration, true, window, cx); self.configuration = Some(cx.new(|cx| { AgentConfiguration::new( fs, @@ -1286,6 +1293,7 @@ impl AgentPanel { fn set_active_view( &mut self, new_view: ActiveView, + focus: bool, window: &mut Window, cx: &mut Context, ) { @@ -1324,7 +1332,9 @@ impl AgentPanel { self.active_view = new_view; } - self.focus_handle(cx).focus(window); + if focus { + self.focus_handle(cx).focus(window); + } } fn populate_recently_opened_menu_section(