agent2: always finalize diffs from the edit tool

There were cases before where we would exit after creating the diff and
wouldn't finalize it
This commit is contained in:
Ben Brandt 2025-08-25 23:37:51 -07:00
parent 64b14ef848
commit afd2c3aa76
No known key found for this signature in database
GPG key ID: D4618C5D3B500571

View file

@ -272,6 +272,7 @@ impl AgentTool for EditFileTool {
.await?;
let diff = cx.new(|cx| Diff::new(buffer.clone(), cx))?;
let result = async {
event_stream.update_diff(diff.clone());
let old_snapshot = buffer.read_with(cx, |buffer, _cx| buffer.snapshot())?;
@ -389,8 +390,6 @@ impl AgentTool for EditFileTool {
})
.await;
diff.update(cx, |diff, cx| diff.finalize(cx)).ok();
let input_path = input.path.display();
if unified_diff.is_empty() {
anyhow::ensure!(
@ -425,6 +424,12 @@ impl AgentTool for EditFileTool {
diff: unified_diff,
edit_agent_output,
})
}.await;
// Always finalize the diff, regardless of whether the operation succeeded or failed
diff.update(cx, |diff, cx| diff.finalize(cx)).ok();
result
})
}