From d1ffda9bfeccfdf9bea3f76251350bf9cf7f6e1b Mon Sep 17 00:00:00 2001
From: Danilo Leal <67129314+danilo-leal@users.noreply.github.com>
Date: Fri, 11 Apr 2025 22:36:26 -0300
Subject: [PATCH] agent: Display keybindings for "Reject All" and "Keep All"
(#28620)
Release Notes:
- N/A
---
assets/keymaps/default-linux.json | 4 +++-
assets/keymaps/default-macos.json | 4 +++-
crates/agent/src/agent_diff.rs | 32 +++++++++++++++++++++----------
3 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json
index 5b6e410ae9..9c4a4d1f50 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.json
index 4b59db20a5..ee24d9deb7 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.rs
index c3bc120ead..13f2f991fb 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) -> impl IntoElement {
+ fn render(&mut self, window: &mut Window, cx: &mut Context) -> 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)
+ })),
+ ),
)
}
}