From e12106e025b3fa09bf65284e57d5cca5fab1772f Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Wed, 28 May 2025 15:24:58 -0300 Subject: [PATCH] agent: Move focus to the panel after dismissing a user message edit (#31611) Previously, when you clicked on a previous message to edit it and then dismissed it, your focus would jump to the buffer. This caught me several times as the most obvious place to return to for me was the agent panel main message editor, so I can continue prompting something else. And this is what this PR changes. Release Notes: - agent: Improved previous message editing UX by returning focus to the main panel's text area after dismissing it. --- crates/agent/src/active_thread.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/agent/src/active_thread.rs b/crates/agent/src/active_thread.rs index 46f924c153ed5d3d82466d444ceb1431e57f372c..de8553e1ccf4f3d1502a2d933c039c6c29787f7c 100644 --- a/crates/agent/src/active_thread.rs +++ b/crates/agent/src/active_thread.rs @@ -1533,9 +1533,22 @@ impl ActiveThread { }); } - fn cancel_editing_message(&mut self, _: &menu::Cancel, _: &mut Window, cx: &mut Context) { + fn cancel_editing_message( + &mut self, + _: &menu::Cancel, + window: &mut Window, + cx: &mut Context, + ) { self.editing_message.take(); cx.notify(); + + if let Some(workspace) = self.workspace.upgrade() { + workspace.update(cx, |workspace, cx| { + if let Some(panel) = workspace.panel::(cx) { + panel.focus_handle(cx).focus(window); + } + }); + } } fn confirm_editing_message(