From ad4a53c71ce929c18683cc3e218c30515721a0ce Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Mon, 13 Oct 2025 18:55:31 -0300 Subject: [PATCH] agent: Fix review button not working while not focused in the message editor (#40144) This PR fixes a bug where the review icon button wouldn't properly open the review tab if you weren't focused in the agent panel's message editor. The solution was to register the action also at the workspace level. Release Notes: - agent: Fixed a bug where the review icon button wouldn't work to open the review tab if focus weren't in the panel's message editor. --- crates/agent_ui/src/acp/thread_view.rs | 7 ------- crates/agent_ui/src/agent_panel.rs | 17 ++++++++++++++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs index 490739e075..3868f11d85 100644 --- a/crates/agent_ui/src/acp/thread_view.rs +++ b/crates/agent_ui/src/acp/thread_view.rs @@ -1254,12 +1254,6 @@ impl AcpThreadView { .detach(); } - fn open_agent_diff(&mut self, _: &OpenAgentDiff, window: &mut Window, cx: &mut Context) { - if let Some(thread) = self.thread() { - AgentDiffPane::deploy(thread.clone(), self.workspace.clone(), window, cx).log_err(); - } - } - fn open_edited_buffer( &mut self, buffer: &Entity, @@ -5445,7 +5439,6 @@ impl Render for AcpThreadView { v_flex() .size_full() .key_context("AcpThread") - .on_action(cx.listener(Self::open_agent_diff)) .on_action(cx.listener(Self::toggle_burn_mode)) .on_action(cx.listener(Self::keep_all)) .on_action(cx.listener(Self::reject_all)) diff --git a/crates/agent_ui/src/agent_panel.rs b/crates/agent_ui/src/agent_panel.rs index 480f3a2cd8..eb25ddd9bc 100644 --- a/crates/agent_ui/src/agent_panel.rs +++ b/crates/agent_ui/src/agent_panel.rs @@ -19,9 +19,10 @@ use zed_actions::agent::{OpenClaudeCodeOnboardingModal, ReauthenticateAgent}; use crate::acp::{AcpThreadHistory, ThreadHistoryEvent}; use crate::ui::{AcpOnboardingModal, ClaudeCodeOnboardingModal}; use crate::{ - AddContextServer, DeleteRecentlyOpenThread, Follow, InlineAssistant, NewTextThread, NewThread, - OpenActiveThreadAsMarkdown, OpenHistory, ResetTrialEndUpsell, ResetTrialUpsell, - ToggleNavigationMenu, ToggleNewThreadMenu, ToggleOptionsMenu, + AddContextServer, AgentDiffPane, DeleteRecentlyOpenThread, Follow, InlineAssistant, + NewTextThread, NewThread, OpenActiveThreadAsMarkdown, OpenAgentDiff, OpenHistory, + ResetTrialEndUpsell, ResetTrialUpsell, ToggleNavigationMenu, ToggleNewThreadMenu, + ToggleOptionsMenu, acp::AcpThreadView, agent_configuration::{AgentConfiguration, AssistantConfigurationEvent}, slash_command::SlashCommandCompletionProvider, @@ -140,6 +141,16 @@ pub fn init(cx: &mut App) { .register_action(|workspace, _: &Follow, window, cx| { workspace.follow(CollaboratorId::Agent, window, cx); }) + .register_action(|workspace, _: &OpenAgentDiff, window, cx| { + let thread = workspace + .panel::(cx) + .and_then(|panel| panel.read(cx).active_thread_view().cloned()) + .and_then(|thread_view| thread_view.read(cx).thread().cloned()); + + if let Some(thread) = thread { + AgentDiffPane::deploy_in_workspace(thread, workspace, window, cx); + } + }) .register_action(|workspace, _: &ToggleNavigationMenu, window, cx| { if let Some(panel) = workspace.panel::(cx) { workspace.focus_panel::(window, cx);