Describe the bug
When clicking a file in the desktop app's "Git changes" sidebar, the diff view now shows the entire file contents instead of only the changed lines.
Steps to reproduce
- Open OpenCode desktop app
- Make changes to a file in the project
- Open the Git Changes sidebar on the right
- Click on a changed file
Expected: Only changed lines (with a few lines of surrounding context) are shown.
Actual: The entire file contents are displayed.
Root cause
Commit f023c63a6 (fix(app): stabilize virtual session timeline interactions (#28422)) refactored packages/ui/src/components/session-diff.ts and removed the logic that stripped context lines from patches before rendering.
The old code manually parsed patch hunks, extracted only the -/+ lines, and passed those reconstructed before/after strings to parseDiffFromFile — so only changed regions were shown. It also had a patchIsPartial flag that used parsePatchFiles (which respects hunk boundaries) when the patch didn't start from line 1.
The new code always passes the raw patch string directly to parsePatchFiles. Since the backend generates patches with context: Number.MAX_SAFE_INTEGER (packages/opencode/src/snapshot/index.ts:689) and context: Infinity (packages/opencode/src/file/index.ts:558), every line in the file appears as a context line in the patch, causing the full file to render.
Possible fixes
- Backend: Change the
context option in structuredPatch calls from Number.MAX_SAFE_INTEGER/Infinity to a standard value like 3 (the unified diff default).
- Frontend: Restore the hunk-parsing logic in
session-diff.ts that reconstructed before/after content from only the -/+ lines.
Environment
Describe the bug
When clicking a file in the desktop app's "Git changes" sidebar, the diff view now shows the entire file contents instead of only the changed lines.
Steps to reproduce
Expected: Only changed lines (with a few lines of surrounding context) are shown.
Actual: The entire file contents are displayed.
Root cause
Commit
f023c63a6(fix(app): stabilize virtual session timeline interactions (#28422)) refactoredpackages/ui/src/components/session-diff.tsand removed the logic that stripped context lines from patches before rendering.The old code manually parsed patch hunks, extracted only the
-/+lines, and passed those reconstructed before/after strings toparseDiffFromFile— so only changed regions were shown. It also had apatchIsPartialflag that usedparsePatchFiles(which respects hunk boundaries) when the patch didn't start from line 1.The new code always passes the raw patch string directly to
parsePatchFiles. Since the backend generates patches withcontext: Number.MAX_SAFE_INTEGER(packages/opencode/src/snapshot/index.ts:689) andcontext: Infinity(packages/opencode/src/file/index.ts:558), every line in the file appears as a context line in the patch, causing the full file to render.Possible fixes
contextoption instructuredPatchcalls fromNumber.MAX_SAFE_INTEGER/Infinityto a standard value like3(the unified diff default).session-diff.tsthat reconstructed before/after content from only the-/+lines.Environment