Skip to content

fix(app): desktop Git Changes sidebar shows entire file instead of changed lines #29768

Description

@criticalcognition

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

  1. Open OpenCode desktop app
  2. Make changes to a file in the project
  3. Open the Git Changes sidebar on the right
  4. 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

  1. Backend: Change the context option in structuredPatch calls from Number.MAX_SAFE_INTEGER/Infinity to a standard value like 3 (the unified diff default).
  2. Frontend: Restore the hunk-parsing logic in session-diff.ts that reconstructed before/after content from only the -/+ lines.

Environment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions