agent: Save files when model uses rename tool (#57228)

Release Notes:

- N/A
This commit is contained in:
Bennet Bo Fenner 2026-05-20 10:36:32 +02:00 committed by GitHub
parent 5656f3eb3f
commit 80d41375e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2,6 +2,7 @@ use std::fmt::Write;
use std::sync::Arc; use std::sync::Arc;
use agent_client_protocol::schema as acp; use agent_client_protocol::schema as acp;
use collections::HashSet;
use gpui::{App, Entity, SharedString, Task}; use gpui::{App, Entity, SharedString, Task};
use project::Project; use project::Project;
use schemars::JsonSchema; use schemars::JsonSchema;
@ -95,6 +96,12 @@ impl AgentTool for RenameTool {
)); ));
} }
let buffers = transaction.0.keys().cloned().collect::<HashSet<_>>();
project
.update(cx, |project, cx| project.save_buffers(buffers, cx))
.await
.map_err(|e| format!("Rename succeeded, but failed to save renamed files: {e}"))?;
let mut output = format!( let mut output = format!(
"Renamed `{}` to `{}` in {} file(s):\n", "Renamed `{}` to `{}` in {} file(s):\n",
input.symbol.symbol_name, input.symbol.symbol_name,