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
Clicking a changed file in the desktop Git Changes sidebar shows the correct +N -M stats in the header, but the diff content area is completely blank. CLI git diff renders the same diff correctly, so the repository data is fine.
Environment
opencode version: 2.1.4 (desktop app, OpenCode.exe product version 2.1.4.0)
OS: Windows_NT 10.0.26200 (Windows 11, win32 x64)
Terminal: Unavailable: not a terminal session (OpenCode desktop app)
Shell: Unavailable: $ComSpec not set in this environment
Active plugins: none found (no opencode.json(c), no .opencode/ in project, no global ~/.config/opencode/opencode.json)
Reproduction
Open a project in OpenCode desktop 2.1.4 on Windows 11.
Rewrite README.md (~11 insertions, 16 deletions).
Open the "Git changes" sidebar and click README.md.
Header shows README.md +11 -16, but the diff pane stays empty (blank even after switching between diff views).
So far only README.md has shown this; other files were not affected (small sample).
Expected Behavior
The pane shows the unified diff with removed/added lines, as git diff does.
Actual Behavior
The pane is blank. The stats in the header are correct, which suggests the diff is computed fine but the renderer produces nothing.
Additional Context
git diff -- README.md outputs the full patch correctly (1 file changed, 11 insertions(+), 16 deletions(-)).
Line endings ruled out as a trigger: byte-level check confirms both the HEAD blob (1762 bytes) and the modified worktree file (860 bytes) are LF-only, no CR bytes present. (core.autocrlf is true, but neither version contains CRLF.)
Thanks for the detailed report! I think this is a duplicate of #57441, which reports the same blank diff pane with correct +/- stats in Desktop 2.x on Windows 11, also in a repo with core.autocrlf=true and LF working-tree files.
Possible duplicates and related issues, ordered from most to least likely:
It would help to add your details to #57441: it still happens on 2.1.4, the HEAD blob has CRLF while the working-tree file is LF-only, and only README.md is affected. Any DevTools console errors or a small sample patch would help there too.
The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.
The blank pane is not a renderer/syntax-highlighting failure — GET /api/vcs/diff?mode=working returns a structurally invalid patch for affected files. The frontend patch parser silently rejects it (hence no console errors), while the +/- stats are computed elsewhere and stay correct.
Evidence
For README.md in my repro repo, git diff produces one valid hunk:
@@ -1,39 +1,34 @@ (1 hunk, `git apply --stat` OK)
The API returns the same diff as 12 overlapping hunks, all starting at line 1:
Hunks 4–12 are also internally inconsistent (declare 35 old lines but contain 34).
Not file- or encoding-specific
Test matrix on a second 5-line ASCII file (.github/workflows/README.md), all via the same endpoint, comparing against git diff ground truth:
Change
API hunks
git apply --stat
Edit line 1 only
1
OK
Append text → 1 new final line
1
OK
Add blank line + text at EOF (ASCII)
2 overlapping
corrupt patch at line 25
Same, keeping trailing LF
2 overlapping
corrupt
Cyrillic line at EOF
2 overlapping
corrupt
Line-1 edit + lines at EOF
2 overlapping
corrupt
hexlet-check.yml: 3 edits, no EOF change
1 (merged)
OK
README.md (original report)
12 overlapping
corrupt patch at line 150
So: not encoding-related (pure ASCII corrupts too), not about the number of changed regions (3 regions in hexlet-check.yml merged into one valid hunk). The reliable trigger observed is changes that add multiple lines at end-of-file; each changed group appears to emit its own full-context hunk, all with -1 as the old start, so they overlap and their declared counts don't match their content.
This looks related to the structuredPatch calls with context: Number.MAX_SAFE_INTEGER / Infinity mentioned in #29768 — hunks with full-file context are being concatenated instead of merged (or are being generated against different base line counts).
Minimal reproduction
# Take a 5-line file ending with LF and append two lines:$content= [System.IO.File]::ReadAllText("probe.txt")
[System.IO.File]::WriteAllText("probe.txt",$content+"`nnew ascii line at eof`n")
# Query the endpoint (opencode-cli.exe ships with the desktop app):&opencode-cli.exe api get "/api/vcs/diff?mode=working&location[directory]=C:\path\to\repo"> diff.json
# .data[0].patch contains: "@@ -1,3 +1,7 @@" followed by "@@ -1,5 +1,7 @@"# (overlapping, both starting at old line 1). Validate it:
git apply --stat patch.txt
# -> error: corrupt patch at line 25, exit 128
Sanity check with plain git on the same file: git diff → single hunk @@ -3,3 +3,5 @@, applies fine.
Environment: OpenCode Desktop 2.1.4, Windows 11 (10.0.26200), no plugins. Reproduced deterministically ~6/6 times. Console shows no errors (the failure is silent).
Follow-up to my previous comment: traced this through the OpenCode source into git itself. The blank pane is a Windows-only integer overflow in git's xdiff, triggered by OpenCode passing INT_MAX as the diff context.
The chain
The desktop Git changes pane calls the endpoint without a context — packages/gui-extensions/src/review/model.ts:184
xdemitconf_t.ctxlen is a long — 32-bit on Windows (LLP64), 64-bit on Linux/macOS. So 2 × 2147483647 wraps to -2, making distance > max_common always true: every change group is emitted as its own hunk, and s1 clamps each hunk's start to line 1. Result: N overlapping whole-file hunks whose declared line counts don't match their content.
Evidence
Experiment
Result
API patch vs. git diff --patch --no-ext-diff --no-renames --unified=2147483647
byte-identical (12,479 bytes)
--unified threshold (binary search)
OK at 1073741823, broken at 1073741824 = 2³⁰ — exactly where 2 × ctxlen overflows int32
Change groups in README.md vs. hunks in corrupt patch
12 groups → 12 hunks (and 3 groups → 3 hunks for another file)
Same command in WSL (Linux, 64-bit long, git 2.43)
valid patch, git apply --stat exit 0
git apply --stat on the API's patch
error: corrupt patch at line 150, exit 128
Why the pane is blank while +11 -16 is correct
The stats come from a separategit diff --numstat call (plugin/vcs/git.ts), which is unaffected by the overflow — so the header numbers are right. The patch itself fails in the client's patch parser, and the failure is swallowed: the only handler is a console.debug (review/model.ts:186), which is why the DevTools console shows nothing.
This also explains why only some files go blank: a file's overflowed hunks happen to keep self-consistent counts when its old and new line counts are equal (reproduced: a 3-change file stayed parseable, while README.md with 39 → 34 lines did not).
Scope
packages/core/src/session/diff.ts:146 uses the same sentinel for session/timeline diffs, so those are exposed to the same failure.
Because the API accepts any non-negative context (packages/protocol/src/groups/vcs.ts:31), a caller-supplied value above 2³⁰ reproduces the same corruption independently of the default.
The 2 * ctxlen overflow in xdl_get_hunk() looks like an upstream git bug worth reporting: with --unified ≥ 2³⁰, git's own git apply rejects git's own diff output.
Closing this as a duplicate of #57441, since there hasn't been a reply in the past day saying how it's different. Please follow #57441 for updates. It would help a lot if you added your details there: it still happens on 2.1.4, the HEAD blob has CRLF while the working-tree file is LF-only, and so far only README.md is affected. DevTools console errors or a small sample patch would help too. If this turns out to be a different problem, reply here and it can be reopened. Thanks again for the detailed report!
Closing as a duplicate of #57441: same empty diff pane with correct +/- stats on Windows. Please follow that issue for updates and add any extra details there.
Activity
opencode-agent commentedon Oct 25, 2026
Thanks for the detailed report! I think this is a duplicate of #57441, which reports the same blank diff pane with correct
+/-stats in Desktop 2.x on Windows 11, also in a repo withcore.autocrlf=trueand LF working-tree files.Possible duplicates and related issues, ordered from most to least likely:
core.autocrlf=true; still open.texfiles on v1, where render errors seemed to be swallowed with no plain-text fallback; closedIt would help to add your details to #57441: it still happens on 2.1.4, the HEAD blob has CRLF while the working-tree file is LF-only, and only
README.mdis affected. Any DevTools console errors or a small sample patch would help there too.The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.
crraay commentedon Oct 26, 2026
Root cause found: server returns a corrupt patch
The blank pane is not a renderer/syntax-highlighting failure —
GET /api/vcs/diff?mode=workingreturns a structurally invalid patch for affected files. The frontend patch parser silently rejects it (hence no console errors), while the+/-stats are computed elsewhere and stay correct.Evidence
For
README.mdin my repro repo,git diffproduces one valid hunk:The API returns the same diff as 12 overlapping hunks, all starting at line 1:
git applyrejects it:Hunks 4–12 are also internally inconsistent (declare 35 old lines but contain 34).
Not file- or encoding-specific
Test matrix on a second 5-line ASCII file (
.github/workflows/README.md), all via the same endpoint, comparing againstgit diffground truth:git apply --statcorrupt patch at line 25hexlet-check.yml: 3 edits, no EOF changeREADME.md(original report)corrupt patch at line 150So: not encoding-related (pure ASCII corrupts too), not about the number of changed regions (3 regions in
hexlet-check.ymlmerged into one valid hunk). The reliable trigger observed is changes that add multiple lines at end-of-file; each changed group appears to emit its own full-context hunk, all with-1as the old start, so they overlap and their declared counts don't match their content.This looks related to the
structuredPatchcalls withcontext: Number.MAX_SAFE_INTEGER/Infinitymentioned in #29768 — hunks with full-file context are being concatenated instead of merged (or are being generated against different base line counts).Minimal reproduction
Sanity check with plain git on the same file:
git diff→ single hunk@@ -3,3 +3,5 @@, applies fine.Environment: OpenCode Desktop 2.1.4, Windows 11 (10.0.26200), no plugins. Reproduced deterministically ~6/6 times. Console shows no errors (the failure is silent).
crraay commentedon Oct 26, 2026
Root cause identified
Follow-up to my previous comment: traced this through the OpenCode source into git itself. The blank pane is a Windows-only integer overflow in git's xdiff, triggered by OpenCode passing
INT_MAXas the diff context.The chain
context—packages/gui-extensions/src/review/model.ts:184packages/protocol/src/groups/vcs.ts:31(NonNegativeInt, optional)packages/core/src/vcs.ts:239packages/core/src/vcs/patch.ts:6packages/core/src/plugin/vcs/git.ts:The overflow inside git
xdiff/xemit.c,xdl_get_hunk():xdemitconf_t.ctxlenis along— 32-bit on Windows (LLP64), 64-bit on Linux/macOS. So2 × 2147483647wraps to-2, makingdistance > max_commonalways true: every change group is emitted as its own hunk, ands1clamps each hunk's start to line 1. Result: N overlapping whole-file hunks whose declared line counts don't match their content.Evidence
git diff --patch --no-ext-diff --no-renames --unified=2147483647--unifiedthreshold (binary search)1073741823, broken at1073741824= 2³⁰ — exactly where2 × ctxlenoverflows int32README.mdvs. hunks in corrupt patchlong, git 2.43)git apply --statexit 0git apply --staton the API's patcherror: corrupt patch at line 150, exit 128Why the pane is blank while
+11 -16is correctThe stats come from a separate
git diff --numstatcall (plugin/vcs/git.ts), which is unaffected by the overflow — so the header numbers are right. The patch itself fails in the client's patch parser, and the failure is swallowed: the only handler is aconsole.debug(review/model.ts:186), which is why the DevTools console shows nothing.This also explains why only some files go blank: a file's overflowed hunks happen to keep self-consistent counts when its old and new line counts are equal (reproduced: a 3-change file stayed parseable, while
README.mdwith 39 → 34 lines did not).Scope
packages/core/src/session/diff.ts:146uses the same sentinel for session/timeline diffs, so those are exposed to the same failure.context(packages/protocol/src/groups/vcs.ts:31), a caller-supplied value above 2³⁰ reproduces the same corruption independently of the default.2 * ctxlenoverflow inxdl_get_hunk()looks like an upstream git bug worth reporting: with--unified≥ 2³⁰, git's owngit applyrejects git's owndiffoutput.opencode-agent commentedon Oct 26, 2026
Closing this as a duplicate of #57441, since there hasn't been a reply in the past day saying how it's different. Please follow #57441 for updates. It would help a lot if you added your details there: it still happens on 2.1.4, the HEAD blob has CRLF while the working-tree file is LF-only, and so far only
README.mdis affected. DevTools console errors or a small sample patch would help too. If this turns out to be a different problem, reply here and it can be reopened. Thanks again for the detailed report!neriousy commentedon Nov 23, 2026
Closing as a duplicate of #57441: same empty diff pane with correct +/- stats on Windows. Please follow that issue for updates and add any extra details there.