You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When opencode requests permission for an edit, the toolCall.content block (type: "diff") is silently dropped whenever the edited hunk sits entirely inside an indented block. ACP clients (Zed, VS Code extensions, JetBrains, CodeCompanion, etc.) then have no diff to show next to the approval prompt.
The actual edit is not affected — it still applies correctly via the fuzzy replacers in edit.ts. This is a preview-only regression.
Root cause
edit.ts trims common indentation from the unified diff (trimDiff) for readability of the in-TUI diff. Then permission.ts::diffContentForPatch tries to reconstruct the result by re-applying that (now indentation-stripped) patch to the file:
constnext=applyPatch(content,diff)// fails for indented hunksif(next===false)returnundefined// <- no content block emitted
applyPatch returns false because the context lines no longer match the file (their indentation was stripped by trimDiff). With fuzzFactor: 0 (jsdiff default) there is no tolerance, so the hunk can't be located.
Trigger condition (deterministic, not a race)
The bug fires whenever all non-blank lines in the hunk are indented, i.e. the changed line(s) plus the 4-line context window on each side never include a zero-indent line. This is the common case: any edit inside a function/method body more than ~4 lines deep from its signature.
applyPatch(raw): OK
applyPatch(trimmed): FAILED <- no preview
History
trimDiff was added in c1250abdf ("implemented diff trimming") for readability.
diffContentForPatch (the applyPatch reconstruction) was introduced by fix(acp): enrich permission prompts #34079 ("fix(acp): enrich permission prompts"). The two interact badly: trimDiff makes the patch non-applicable, so applyPatch fails.
Bug
When opencode requests permission for an
edit, thetoolCall.contentblock (type: "diff") is silently dropped whenever the edited hunk sits entirely inside an indented block. ACP clients (Zed, VS Code extensions, JetBrains, CodeCompanion, etc.) then have no diff to show next to the approval prompt.The actual edit is not affected — it still applies correctly via the fuzzy replacers in
edit.ts. This is a preview-only regression.Root cause
edit.tstrims common indentation from the unified diff (trimDiff) for readability of the in-TUI diff. Thenpermission.ts::diffContentForPatchtries to reconstruct the result by re-applying that (now indentation-stripped) patch to the file:applyPatchreturnsfalsebecause the context lines no longer match the file (their indentation was stripped bytrimDiff). WithfuzzFactor: 0(jsdiff default) there is no tolerance, so the hunk can't be located.Trigger condition (deterministic, not a race)
The bug fires whenever all non-blank lines in the hunk are indented, i.e. the changed line(s) plus the 4-line context window on each side never include a zero-indent line. This is the common case: any edit inside a function/method body more than ~4 lines deep from its signature.
Standalone repro (no LLM needed)
Output:
History
trimDiffwas added inc1250abdf("implemented diff trimming") for readability.diffContentForPatch(theapplyPatchreconstruction) was introduced by fix(acp): enrich permission prompts #34079 ("fix(acp): enrich permission prompts"). The two interact badly:trimDiffmakes the patch non-applicable, soapplyPatchfails.Related
applyPatchreconstruction (source of the regression)oldString/newStringdirectly; closed in favor of fix(acp): enrich permission prompts #34079trimDiffmakes patches non-applicable