From 303c23cf1e7ce6226f99dd989b9173c3799622a2 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 25 Nov 2025 09:34:23 +0200 Subject: [PATCH] Fix first window open not focusing the modals (#43180) 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 --- 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 92765140f5101034a30fc95db675ff335f2cb324..fd0b1eedbdf80d1893760e6182cd2e57d96ef010 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -653,7 +653,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 6ff909389986ec27b998c4554fe2d86115ef1785..22eb11e24a8fd706c80aa65c3dcf5d8ae3876ddc 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -816,6 +816,7 @@ impl AgentPanel { window, cx, ), + true, window, cx, ); @@ -911,7 +912,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); @@ -953,10 +959,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(); } @@ -1012,6 +1018,7 @@ impl AgentPanel { window, cx, ), + true, window, cx, ); @@ -1157,7 +1164,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, @@ -1274,6 +1281,7 @@ impl AgentPanel { fn set_active_view( &mut self, new_view: ActiveView, + focus: bool, window: &mut Window, cx: &mut Context, ) { @@ -1312,7 +1320,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(