Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
agent: Display keybindings for "Reject All" and "Keep All" (#28620)
Danilo Leald1ffda9bfecc
diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.jsonindex 5b6e410ae94..9c4a4d1f504 100644--- a/assets/keymaps/default-linux.json+++ b/assets/keymaps/default-linux.json@@ -150,7 +150,9 @@"context": "AgentDiff","bindings": {"ctrl-y": "agent::Keep",- "ctrl-n": "agent::Reject"+ "ctrl-n": "agent::Reject",+ "ctrl-shift-y": "agent::KeepAll",+ "ctrl-shift-n": "agent::RejectAll"}},{diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.jsonindex 4b59db20a51..ee24d9deb72 100644--- a/assets/keymaps/default-macos.json+++ b/assets/keymaps/default-macos.json@@ -242,7 +242,9 @@"use_key_equivalents": true,"bindings": {"cmd-y": "agent::Keep",- "cmd-n": "agent::Reject"+ "cmd-n": "agent::Reject",+ "cmd-shift-y": "agent::KeepAll",+ "cmd-shift-n": "agent::RejectAll"}},{diff --git a/crates/agent/src/agent_diff.rs b/crates/agent/src/agent_diff.rsindex c3bc120ead5..13f2f991fb5 100644--- a/crates/agent/src/agent_diff.rs+++ b/crates/agent/src/agent_diff.rs@@ -1,4 +1,4 @@-use crate::{Keep, Reject, Thread, ThreadEvent};+use crate::{Keep, KeepAll, Reject, RejectAll, Thread, ThreadEvent};use anyhow::Result;use buffer_diff::DiffHunkStatus;use collections::HashSet;@@ -843,7 +843,7 @@ impl ToolbarItemView for AgentDiffToolbar {}impl Render for AgentDiffToolbar {- fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {+ fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {let agent_diff = match self.agent_diff(cx) {Some(ad) => ad,None => return div(),@@ -855,6 +855,8 @@ impl Render for AgentDiffToolbar {return div();}+ let focus_handle = agent_diff.focus_handle(cx);+h_group_xl().my_neg_1().items_center()@@ -864,15 +866,25 @@ impl Render for AgentDiffToolbar {.child(h_group_sm().child(- Button::new("reject-all", "Reject All").on_click(cx.listener(- |this, _, window, cx| {- this.dispatch_action(&crate::RejectAll, window, cx)- },- )),+ Button::new("reject-all", "Reject All")+ .key_binding({+ KeyBinding::for_action_in(&RejectAll, &focus_handle, window, cx)+ .map(|kb| kb.size(rems_from_px(12.)))+ })+ .on_click(cx.listener(|this, _, window, cx| {+ this.dispatch_action(&RejectAll, window, cx)+ })),)- .child(Button::new("keep-all", "Keep All").on_click(cx.listener(- |this, _, window, cx| this.dispatch_action(&crate::KeepAll, window, cx),- ))),+ .child(+ Button::new("keep-all", "Keep All")+ .key_binding({+ KeyBinding::for_action_in(&KeepAll, &focus_handle, window, cx)+ .map(|kb| kb.size(rems_from_px(12.)))+ })+ .on_click(cx.listener(|this, _, window, cx| {+ this.dispatch_action(&KeepAll, window, cx)+ })),+ ),)}}