Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

agent_ui: Refine "reject"/"keep" behavior when regenerating previous prompts (#43347)

Danilo Lealeff592c447ba
diff --git a/crates/agent_ui/src/acp/thread_view.rs b/crates/agent_ui/src/acp/thread_view.rs
index 3d387fc87c3..92765140f51 100644
--- a/crates/agent_ui/src/acp/thread_view.rs
+++ b/crates/agent_ui/src/acp/thread_view.rs
@@ -1273,6 +1273,28 @@ impl AcpThreadView {
};
cx.spawn_in(window, async move |this, cx| {
+ // Check if there are any edits from prompts before the one being regenerated.
+ //
+ // If there are, we keep/accept them since we're not regenerating the prompt that created them.
+ //
+ // If editing the prompt that generated the edits, they are auto-rejected
+ // through the `rewind` function in the `acp_thread`.
+ let has_earlier_edits = thread.read_with(cx, |thread, _| {
+ thread
+ .entries()
+ .iter()
+ .take(entry_ix)
+ .any(|entry| entry.diffs().next().is_some())
+ })?;
+
+ if has_earlier_edits {
+ thread.update(cx, |thread, cx| {
+ thread.action_log().update(cx, |action_log, cx| {
+ action_log.keep_all_edits(None, cx);
+ });
+ })?;
+ }
+
thread
.update(cx, |thread, cx| thread.rewind(user_message_id, cx))?
.await?;