Miscellaneous UX fixes for agent2 (#36591)

Release Notes:

- N/A
This commit is contained in:
Antonio Scandurra 2025-08-20 15:56:39 +02:00 committed by GitHub
parent 85865fc950
commit eaf6b56163
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 123 additions and 18 deletions

View file

@ -2398,7 +2398,6 @@ impl AcpThreadView {
})
.when(!changed_buffers.is_empty(), |this| {
this.child(self.render_edits_summary(
action_log,
&changed_buffers,
self.edits_expanded,
pending_edits,
@ -2550,7 +2549,6 @@ impl AcpThreadView {
fn render_edits_summary(
&self,
action_log: &Entity<ActionLog>,
changed_buffers: &BTreeMap<Entity<Buffer>, Entity<BufferDiff>>,
expanded: bool,
pending_edits: bool,
@ -2661,14 +2659,9 @@ impl AcpThreadView {
)
.map(|kb| kb.size(rems_from_px(10.))),
)
.on_click({
let action_log = action_log.clone();
cx.listener(move |_, _, _, cx| {
action_log.update(cx, |action_log, cx| {
action_log.reject_all_edits(cx).detach();
})
})
}),
.on_click(cx.listener(move |this, _, window, cx| {
this.reject_all(&RejectAll, window, cx);
})),
)
.child(
Button::new("keep-all-changes", "Keep All")
@ -2681,14 +2674,9 @@ impl AcpThreadView {
KeyBinding::for_action_in(&KeepAll, &focus_handle, window, cx)
.map(|kb| kb.size(rems_from_px(10.))),
)
.on_click({
let action_log = action_log.clone();
cx.listener(move |_, _, _, cx| {
action_log.update(cx, |action_log, cx| {
action_log.keep_all_edits(cx);
})
})
}),
.on_click(cx.listener(move |this, _, window, cx| {
this.keep_all(&KeepAll, window, cx);
})),
),
)
}
@ -3014,6 +3002,24 @@ impl AcpThreadView {
});
}
fn keep_all(&mut self, _: &KeepAll, _window: &mut Window, cx: &mut Context<Self>) {
let Some(thread) = self.thread() else {
return;
};
let action_log = thread.read(cx).action_log().clone();
action_log.update(cx, |action_log, cx| action_log.keep_all_edits(cx));
}
fn reject_all(&mut self, _: &RejectAll, _window: &mut Window, cx: &mut Context<Self>) {
let Some(thread) = self.thread() else {
return;
};
let action_log = thread.read(cx).action_log().clone();
action_log
.update(cx, |action_log, cx| action_log.reject_all_edits(cx))
.detach();
}
fn render_burn_mode_toggle(&self, cx: &mut Context<Self>) -> Option<AnyElement> {
let thread = self.as_native_thread(cx)?.read(cx);
@ -3952,6 +3958,8 @@ impl Render for AcpThreadView {
.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))
.bg(cx.theme().colors().panel_background)
.child(match &self.thread_state {
ThreadState::Unauthenticated {