Start tracking edits performed by the agent (#27064)

Release Notes:

- N/A

---------

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
Co-authored-by: Agus Zubiaga <hi@aguz.me>
This commit is contained in:
Antonio Scandurra 2025-03-19 14:07:25 +01:00 committed by GitHub
parent 23686aa394
commit ac5dafc6b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 1423 additions and 344 deletions

View file

@ -274,7 +274,17 @@ impl EditToolRequest {
self.bad_searches.push(invalid_replace);
}
DiffResult::Diff(diff) => {
let _clock = buffer.update(cx, |buffer, cx| buffer.apply_diff(diff, cx))?;
let edit_ids = buffer.update(cx, |buffer, cx| {
buffer.finalize_last_transaction();
buffer.apply_diff(diff, cx);
let transaction = buffer.finalize_last_transaction();
transaction.map_or(Vec::new(), |transaction| transaction.edit_ids.clone())
})?;
self.action_log
.update(cx, |log, cx| {
log.buffer_edited(buffer.clone(), edit_ids, cx)
})?
.await?;
write!(&mut self.output, "\n\n{}", source)?;
self.changed_buffers.insert(buffer);
@ -322,10 +332,6 @@ impl EditToolRequest {
.await?;
}
self.action_log
.update(cx, |log, cx| log.buffer_edited(self.changed_buffers, cx))
.log_err();
let errors = self.parser.errors();
if errors.is_empty() && self.bad_searches.is_empty() {