fix: rollback now correctly extracts file path from tool arguments
The rollback system was failing because it looked for `file_path` (snake_case) but the write/edit tools use `filePath` (camelCase). Now checks both formats when extracting the file path for rollback tracking. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -373,10 +373,12 @@ const executeTool = async (
|
||||
const rollbackType = ROLLBACK_CAPABLE_TOOLS[toolCall.name];
|
||||
let originalState: { filePath: string; content: string } | null = null;
|
||||
|
||||
// Extract file path - tools use filePath (camelCase), not file_path
|
||||
const toolFilePath = (toolCall.arguments.filePath ?? toolCall.arguments.file_path) as string | undefined;
|
||||
|
||||
if (rollbackType && (rollbackType === "file_edit" || rollbackType === "file_delete")) {
|
||||
const filePath = toolCall.arguments.file_path as string | undefined;
|
||||
if (filePath) {
|
||||
originalState = await captureFileState(filePath);
|
||||
if (toolFilePath) {
|
||||
originalState = await captureFileState(toolFilePath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -386,11 +388,10 @@ const executeTool = async (
|
||||
|
||||
// Record action for rollback if successful and modifying
|
||||
if (result.success && rollbackType) {
|
||||
const filePath = toolCall.arguments.file_path as string | undefined;
|
||||
state.executionControl.recordAction({
|
||||
type: rollbackType,
|
||||
description: `${toolCall.name}: ${filePath ?? "unknown file"}`,
|
||||
originalState: originalState ?? (filePath ? { filePath, content: "" } : undefined),
|
||||
description: `${toolCall.name}: ${toolFilePath ?? "unknown file"}`,
|
||||
originalState: originalState ?? (toolFilePath ? { filePath: toolFilePath, content: "" } : undefined),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user