fix(web): construct apply_patch metadata before requesting permission (#10422)

This commit is contained in:
Britt
2026-01-24 13:00:21 -05:00
committed by GitHub
parent e3c1861a3e
commit f4cf3f4976
3 changed files with 81 additions and 16 deletions

View File

@@ -158,6 +158,19 @@ export const ApplyPatchTool = Tool.define("apply_patch", {
}
}
// Build per-file metadata for UI rendering (used for both permission and result)
const files = fileChanges.map((change) => ({
filePath: change.filePath,
relativePath: path.relative(Instance.worktree, change.movePath ?? change.filePath),
type: change.type,
diff: change.diff,
before: change.oldContent,
after: change.newContent,
additions: change.additions,
deletions: change.deletions,
movePath: change.movePath,
}))
// Check permissions if needed
const relativePaths = fileChanges.map((c) => path.relative(Instance.worktree, c.filePath))
await ctx.ask({
@@ -167,6 +180,7 @@ export const ApplyPatchTool = Tool.define("apply_patch", {
metadata: {
filepath: relativePaths.join(", "),
diff: totalDiff,
files,
},
})
@@ -253,19 +267,6 @@ export const ApplyPatchTool = Tool.define("apply_patch", {
}
}
// Build per-file metadata for UI rendering
const files = fileChanges.map((change) => ({
filePath: change.filePath,
relativePath: path.relative(Instance.worktree, change.movePath ?? change.filePath),
type: change.type,
diff: change.diff,
before: change.oldContent,
after: change.newContent,
additions: change.additions,
deletions: change.deletions,
movePath: change.movePath,
}))
return {
title: output,
metadata: {