agent: Display keybindings for "Reject All" and "Keep All" (#28620)

<img
src="https://github.com/user-attachments/assets/2cdc5121-dd7b-4f46-8d43-88d5152c77ea"
width="550" />


Release Notes:

- N/A
This commit is contained in:
Danilo Leal 2025-04-11 22:36:26 -03:00 committed by GitHub
parent 8ffa58414d
commit d1ffda9bfe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 28 additions and 12 deletions

View file

@ -150,7 +150,9 @@
"context": "AgentDiff", "context": "AgentDiff",
"bindings": { "bindings": {
"ctrl-y": "agent::Keep", "ctrl-y": "agent::Keep",
"ctrl-n": "agent::Reject" "ctrl-n": "agent::Reject",
"ctrl-shift-y": "agent::KeepAll",
"ctrl-shift-n": "agent::RejectAll"
} }
}, },
{ {

View file

@ -242,7 +242,9 @@
"use_key_equivalents": true, "use_key_equivalents": true,
"bindings": { "bindings": {
"cmd-y": "agent::Keep", "cmd-y": "agent::Keep",
"cmd-n": "agent::Reject" "cmd-n": "agent::Reject",
"cmd-shift-y": "agent::KeepAll",
"cmd-shift-n": "agent::RejectAll"
} }
}, },
{ {

View file

@ -1,4 +1,4 @@
use crate::{Keep, Reject, Thread, ThreadEvent}; use crate::{Keep, KeepAll, Reject, RejectAll, Thread, ThreadEvent};
use anyhow::Result; use anyhow::Result;
use buffer_diff::DiffHunkStatus; use buffer_diff::DiffHunkStatus;
use collections::HashSet; use collections::HashSet;
@ -843,7 +843,7 @@ impl ToolbarItemView for AgentDiffToolbar {
} }
impl Render 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) { let agent_diff = match self.agent_diff(cx) {
Some(ad) => ad, Some(ad) => ad,
None => return div(), None => return div(),
@ -855,6 +855,8 @@ impl Render for AgentDiffToolbar {
return div(); return div();
} }
let focus_handle = agent_diff.focus_handle(cx);
h_group_xl() h_group_xl()
.my_neg_1() .my_neg_1()
.items_center() .items_center()
@ -864,15 +866,25 @@ impl Render for AgentDiffToolbar {
.child( .child(
h_group_sm() h_group_sm()
.child( .child(
Button::new("reject-all", "Reject All").on_click(cx.listener( Button::new("reject-all", "Reject All")
|this, _, window, cx| { .key_binding({
this.dispatch_action(&crate::RejectAll, window, cx) 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( .child(
|this, _, window, cx| this.dispatch_action(&crate::KeepAll, window, cx), 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)
})),
),
) )
} }
} }