Allow reviewing of agent changes without Git (#27668)

Release Notes:

- N/A
This commit is contained in:
Antonio Scandurra 2025-03-28 19:58:53 +01:00 committed by GitHub
parent 8a307e7b89
commit 94ed0b7767
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
27 changed files with 2271 additions and 1095 deletions

View file

@ -70,7 +70,7 @@ impl Tool for CreateFileTool {
input: serde_json::Value,
_messages: &[LanguageModelRequestMessage],
project: Entity<Project>,
_action_log: Entity<ActionLog>,
action_log: Entity<ActionLog>,
cx: &mut App,
) -> Task<Result<String>> {
let input = match serde_json::from_value::<CreateFileToolInput>(input) {
@ -85,24 +85,20 @@ impl Tool for CreateFileTool {
let destination_path: Arc<str> = input.path.as_str().into();
cx.spawn(async move |cx| {
project
.update(cx, |project, cx| {
project.create_entry(project_path.clone(), false, cx)
})?
.await
.map_err(|err| anyhow!("Unable to create {destination_path}: {err}"))?;
let buffer = project
.update(cx, |project, cx| {
project.open_buffer(project_path.clone(), cx)
})?
.await
.map_err(|err| anyhow!("Unable to open buffer for {destination_path}: {err}"))?;
buffer.update(cx, |buffer, cx| {
buffer.set_text(contents, cx);
let edit_id = buffer.update(cx, |buffer, cx| buffer.set_text(contents, cx))?;
action_log.update(cx, |action_log, cx| {
action_log.will_create_buffer(buffer.clone(), edit_id, cx)
})?;
project
.update(cx, |project, cx| project.save_buffer(buffer.clone(), cx))?
.update(cx, |project, cx| project.save_buffer(buffer, cx))?
.await
.map_err(|err| anyhow!("Unable to save buffer for {destination_path}: {err}"))?;