fix: ensure apply patch tool emits edited events
This commit is contained in:
@@ -12,6 +12,7 @@ import { trimDiff } from "./edit"
|
|||||||
import { LSP } from "../lsp"
|
import { LSP } from "../lsp"
|
||||||
import { Filesystem } from "../util/filesystem"
|
import { Filesystem } from "../util/filesystem"
|
||||||
import DESCRIPTION from "./apply_patch.txt"
|
import DESCRIPTION from "./apply_patch.txt"
|
||||||
|
import { File } from "../file"
|
||||||
|
|
||||||
const PatchParams = z.object({
|
const PatchParams = z.object({
|
||||||
patchText: z.string().describe("The full patch text that describes all changes to be made"),
|
patchText: z.string().describe("The full patch text that describes all changes to be made"),
|
||||||
@@ -171,6 +172,7 @@ export const ApplyPatchTool = Tool.define("apply_patch", {
|
|||||||
const changedFiles: string[] = []
|
const changedFiles: string[] = []
|
||||||
|
|
||||||
for (const change of fileChanges) {
|
for (const change of fileChanges) {
|
||||||
|
const edited = change.type === "delete" ? undefined : change.movePath ?? change.filePath
|
||||||
switch (change.type) {
|
switch (change.type) {
|
||||||
case "add":
|
case "add":
|
||||||
// Create parent directories (recursive: true is safe on existing/root dirs)
|
// Create parent directories (recursive: true is safe on existing/root dirs)
|
||||||
@@ -199,6 +201,12 @@ export const ApplyPatchTool = Tool.define("apply_patch", {
|
|||||||
changedFiles.push(change.filePath)
|
changedFiles.push(change.filePath)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (edited) {
|
||||||
|
await Bus.publish(File.Event.Edited, {
|
||||||
|
file: edited,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Publish file change events
|
// Publish file change events
|
||||||
|
|||||||
Reference in New Issue
Block a user