agent_ui: Fix agent UI stealing focus on start up (#46088)

Lukas Wirth created

Release Notes:

- Fixed Zed stealing element focus away briefly after startup,
interrupting user workflows

Change summary

crates/agent_ui/src/acp/thread_view.rs | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

Detailed changes

crates/agent_ui/src/acp/thread_view.rs 🔗

@@ -731,7 +731,9 @@ impl AcpThreadView {
                             })
                         });
 
-                        this.message_editor.focus_handle(cx).focus(window, cx);
+                        if this.focus_handle(cx).is_focused(window) {
+                            this.message_editor.focus_handle(cx).focus(window, cx);
+                        }
 
                         cx.notify();
                     }