Repository navigation
fix(coding-agent): show the edit diff a failed call already applied - #340
Merged
Merged
Conversation
An edit whose file write landed can still be reported as a failed call: a cancelled `then_run` raises `ToolExecutionError` with the change receipt, and a result-preparation failure keeps the details while flagging the call. The edit renderer dropped the diff in both cases, so a change nothing could undo from the card looked like it never happened. Read the diff from the result details regardless of the call's own status. A failure before the write records no detail at all, so it still shows only its error. A Step card test pins the default presentation, where a stale args-based preview error was shown instead of the recorded change.
liuedcson
requested review from
MelodyVAR,
Uking-xxx and
ZouR-Ma
as code owners
November 2, 2026 09:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
An
editwhose file write landed can still be reported as a failed call:then_runraisesToolExecutionErrorcarrying the change receipt;The edit renderer read the diff only when the call succeeded, so an applied change disappeared from the card. On the Step presentation the args-based preview had already been recomputed against the changed file, so the card instead showed a stale "Could not find the exact text" error.
Refs #337.
Change
packages/coding-agent/src/core/tools/edit.ts: readdetails.diffregardless ofcontext.isError. A failure before the write records no details at all, so it still shows only its error.packages/coding-agent/test/step-then-run-command-parity.test.ts: cancel the embedded check for real, then assert the raisedToolExecutionErrorcarriesisErrorwith the exactdiff/patch, and that rendering the failed call shows both sides of the diff.apps/cli/test/edit-tool-no-full-redraw.test.ts: pin the default Step presentation — the recorded diff replaces the stale preview error and the card still reads as failed; and a failed call with no change record shows no diff.Validation
packages/coding-agent:pnpm exec vitest --run test/step-then-run-command-parity.test.ts test/tools.test.ts— 89 passed.apps/cli:pnpm exec vitest --run test/edit-tool-no-full-redraw.test.ts— 5 passed.pnpm run check— passed.Not covered
A call cancelled in the narrow window after the write but before the receipt is built (
edit.tswrite followed bythrowIfAborted()) throws a plain error with no details, so there is nothing for the renderer to read. That needs the receipt to be constructed before the abort check, in the kernel, and is left out of this change.