From faa1136651c10d0eeed59ec6aefb29ad5d798f6a Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Mon, 17 Nov 2025 15:05:38 -0300 Subject: [PATCH] agent_ui: Don't create a new terminal when hitting the new thread binding from the terminal (#42898) Closes https://github.com/zed-industries/zed/issues/32701 Release Notes: - agent: Fixed a bug where hitting the `NewThread` keybinding when focused inside a terminal within the agent panel would create a new terminal tab instead of a new thread. --- crates/agent_ui/src/acp/thread_view.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index f4c76b10573dd2e36e797c20230739d6d6a77e46..82237d86ba9f66b5d68321e03092660dea29d65d 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -51,7 +51,7 @@ use ui::{ PopoverMenuHandle, SpinnerLabel, TintColor, Tooltip, WithScrollbar, prelude::*, }; use util::{ResultExt, size::format_file_size, time::duration_alt_display}; -use workspace::{CollaboratorId, Workspace}; +use workspace::{CollaboratorId, NewTerminal, Workspace}; use zed_actions::agent::{Chat, ToggleModelSelector}; use zed_actions::assistant::OpenRulesLibrary; @@ -69,8 +69,8 @@ use crate::ui::{ }; use crate::{ AgentDiffPane, AgentPanel, AllowAlways, AllowOnce, ContinueThread, ContinueWithBurnMode, - CycleModeSelector, ExpandMessageEditor, Follow, KeepAll, OpenAgentDiff, OpenHistory, RejectAll, - RejectOnce, ToggleBurnMode, ToggleProfileSelector, + CycleModeSelector, ExpandMessageEditor, Follow, KeepAll, NewThread, OpenAgentDiff, OpenHistory, + RejectAll, RejectOnce, ToggleBurnMode, ToggleProfileSelector, }; #[derive(Copy, Clone, Debug, PartialEq, Eq)] @@ -3144,7 +3144,7 @@ impl AcpThreadView { .text_ui_sm(cx) .h_full() .children(terminal_view.map(|terminal_view| { - if terminal_view + let element = if terminal_view .read(cx) .content_mode(window, cx) .is_scrollable() @@ -3152,7 +3152,15 @@ impl AcpThreadView { div().h_72().child(terminal_view).into_any_element() } else { terminal_view.into_any_element() - } + }; + + div() + .on_action(cx.listener(|_this, _: &NewTerminal, window, cx| { + window.dispatch_action(NewThread.boxed_clone(), cx); + cx.stop_propagation(); + })) + .child(element) + .into_any_element() })), ) })