From bf6e7cb6ee0ff61b4362582c0a14f2370d668675 Mon Sep 17 00:00:00 2001 From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com> Date: Thu, 3 Apr 2025 12:32:02 -0300 Subject: [PATCH] agent: Add button to continue iterating once all reviews are done (#28027) This PR adds a button on the review tab empty state that toggles the focus back to the agent panel so that users can keep iterating on the thread that's active in the panel. Release Notes: - N/A --- assets/icons/forward_arrow.svg | 1 + crates/agent/src/agent_diff.rs | 46 +++++++++++++++++++++++++--------- crates/icons/src/icons.rs | 1 + 3 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 assets/icons/forward_arrow.svg diff --git a/assets/icons/forward_arrow.svg b/assets/icons/forward_arrow.svg new file mode 100644 index 0000000000000000000000000000000000000000..0a7b71993f740ad99245497a9409a903e91c1646 --- /dev/null +++ b/assets/icons/forward_arrow.svg @@ -0,0 +1 @@ + diff --git a/crates/agent/src/agent_diff.rs b/crates/agent/src/agent_diff.rs index 69e770edc1cd2eb80ee39be9f347215d6b741f19..ccbe1b437b840c7bb5b8837b1b83b42603236e8c 100644 --- a/crates/agent/src/agent_diff.rs +++ b/crates/agent/src/agent_diff.rs @@ -1,4 +1,4 @@ -use crate::{Thread, ThreadEvent}; +use crate::{Keep, Reject, Thread, ThreadEvent}; use anyhow::Result; use buffer_diff::DiffHunkStatus; use collections::HashSet; @@ -26,6 +26,7 @@ use workspace::{ item::{BreadcrumbText, ItemEvent, TabContentParams}, searchable::SearchableItemHandle, }; +use zed_actions::assistant::ToggleFocus; pub struct AgentDiff { multibuffer: Entity, @@ -553,11 +554,12 @@ impl Item for AgentDiff { } impl Render for AgentDiff { - fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { + fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { let is_empty = self.multibuffer.read(cx).is_empty(); + let focus_handle = &self.focus_handle; div() - .track_focus(&self.focus_handle) + .track_focus(focus_handle) .key_context(if is_empty { "EmptyPane" } else { "AgentDiff" }) .on_action(cx.listener(Self::keep)) .on_action(cx.listener(Self::reject)) @@ -568,7 +570,32 @@ impl Render for AgentDiff { .items_center() .justify_center() .size_full() - .when(is_empty, |el| el.child("No changes to review")) + .when(is_empty, |el| { + el.child( + v_flex() + .items_center() + .gap_2() + .child("No changes to review") + .child( + Button::new("continue-iterating", "Continue Iterating") + .style(ButtonStyle::Filled) + .icon(IconName::ForwardArrow) + .icon_position(IconPosition::Start) + .icon_size(IconSize::Small) + .icon_color(Color::Muted) + .full_width() + .key_binding(KeyBinding::for_action_in( + &ToggleFocus, + &focus_handle.clone(), + window, + cx, + )) + .on_click(|_event, window, cx| { + window.dispatch_action(ToggleFocus.boxed_clone(), cx) + }), + ), + ) + }) .when(!is_empty, |el| el.child(self.editor.clone())) } } @@ -604,7 +631,7 @@ fn render_diff_hunk_controls( .disabled(is_created_file) .key_binding( KeyBinding::for_action_in( - &crate::Reject, + &Reject, &editor.read(cx).focus_handle(cx), window, cx, @@ -625,13 +652,8 @@ fn render_diff_hunk_controls( }), Button::new(("keep", row as u64), "Keep") .key_binding( - KeyBinding::for_action_in( - &crate::Keep, - &editor.read(cx).focus_handle(cx), - window, - cx, - ) - .map(|kb| kb.size(rems_from_px(12.))), + KeyBinding::for_action_in(&Keep, &editor.read(cx).focus_handle(cx), window, cx) + .map(|kb| kb.size(rems_from_px(12.))), ) .on_click({ let agent_diff = agent_diff.clone(); diff --git a/crates/icons/src/icons.rs b/crates/icons/src/icons.rs index 345a0d5ebfe5fb11f4f556b8438daef7bbfd5f22..f6ec393783486bb1e188bb77d7f95c2224d041ba 100644 --- a/crates/icons/src/icons.rs +++ b/crates/icons/src/icons.rs @@ -122,6 +122,7 @@ pub enum IconName { Font, FontSize, FontWeight, + ForwardArrow, GenericClose, GenericMaximize, GenericMinimize,