Skip to content

Commit 7cd2c6e

Browse files
committed
fix: sometimes ai edits doesnt work as it cant find the corect string to replace
1 parent 7e56866 commit 7cd2c6e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src-node/claude-code-agent.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,21 +269,26 @@ async function _runQuery(requestId, prompt, projectPath, model, signal, locale)
269269
newText: input.tool_input.new_string
270270
};
271271
editCount++;
272+
let editResult;
272273
try {
273-
await nodeConnector.execPeer("applyEditToBuffer", edit);
274+
editResult = await nodeConnector.execPeer("applyEditToBuffer", edit);
274275
} catch (err) {
275276
console.warn("[Phoenix AI] Failed to apply edit to buffer:", err.message);
277+
editResult = { applied: false, error: err.message };
276278
}
277279
nodeConnector.triggerPeer("aiToolEdit", {
278280
requestId: requestId,
279281
toolId: myToolId,
280282
edit: edit
281283
});
284+
const reason = (editResult && editResult.applied === false)
285+
? "Edit FAILED: " + (editResult.error || "unknown error")
286+
: "Edit applied successfully via Phoenix editor.";
282287
return {
283288
hookSpecificOutput: {
284289
hookEventName: "PreToolUse",
285290
permissionDecision: "deny",
286-
permissionDecisionReason: "Edit applied successfully via Phoenix editor."
291+
permissionDecisionReason: reason
287292
}
288293
};
289294
}

0 commit comments

Comments
 (0)