feat(desktop): render binary diffs with the file pane's registry views
Merged
KI
2mo ago+829+829+012345678901234567890123456789-194-194-012345678901234567890123456789
Follows #7035, which is merged.
Summary
- The Changes pane's binary placeholder now uses the FilePane registry view that would open the file in a tab (ImageView, VideoView, PdfView), so anything the file pane can show, the diff pane shows too.
- Modified files render Before and After side by side. The unstaged "after" side comes from the shared file document store, same as an open tab; every other side is read as a git blob by a new
git.readDiffSideFileprocedure at the ref the text diff compares (index, HEAD, merge-base, or the commit). Staged, against-base and commit diffs therefore show the versions their hunks describe, not the worktree. - Video and PDF wait behind a Preview button, like generated files wait behind Load diff, so a changeset full of them does not mount a player per row. Images decode eagerly.
- Views take an
embeddedprop; ImageView skips its pan/zoom wheel handler there so it cannot capture the pane's scroll. - Git-object sides refetch on
git:changedfor the reported paths. The read runs as a host worker task (gitDiffSideBlobTask), resolves the spec to an object id before sizing and reading, and capsmaxBytesserver-side.
How to test
- In a workspace, modify a tracked PNG, stage a second one, add an untracked one, delete a fourth, and drop in a binary PDF or MP4.
- Open the Changes pane: modified files show Before/After, added and deleted show one side, the PDF shows a Preview button that mounts the viewer.
- Commit the staged change: it moves to Against base and still shows merge-base vs HEAD.
Validation
bun run --cwd apps/desktop typecheck,bun run --cwd packages/host-service typecheckbun testfor the DiffPane and FilePane registry folders, the document store, anddiff-side-blob.test.ts(real temp repo: bytes round-trip, size cap, missing spec)bun run check:i18n(two new strings, Before and After, translated in 16 locales)- Verified in the dev app over CDP for all five states plus the against-base transition.
https://claude.ai/code/session_01NAmSwAu95MUWMncyMeBTfa
Summary by cubic
Renders binary diffs in the Changes pane with the FilePane's registry views, so images, videos, and PDFs preview inline instead of the old placeholder with an "Open file" button. Modified files show Before and After side by side: the unstaged after side reads from the shared file document store like an open tab, and every other side is read as a git blob by the new git.readDiffSideFile procedure, so staged, against-base, and commit diffs show the versions their hunks compare rather than the worktree.
New Features
- Video and PDF previews wait behind a Preview button, gated per side so a rename from an image to a PDF still defers; images decode eagerly.
- Views accept an
embeddedprop; ImageView skips its pan/zoom wheel handler there so it can't capture the pane's scroll. - Git-object sides refetch on
git:changedevents for the reported paths, keying their revision on the payload hash so identical refetches don't remount the view. - Renamed files resolve the Before side's view from the old path, so an extension change doesn't reuse the wrong renderer.
Migration
- Hosts without
git.readDiffSideFilenow show "Unable to load diff" instead of a wrong worktree image. - Blob reads run as a worker task off the event loop with a 10MB server-side cap; the object id is resolved before sizing so a moving HEAD or index can't bypass the cap, and larger files show "File is too large to preview".
Summary by CodeRabbit
-
New Features
- Added binary file previews to the Changes pane with side-by-side “Before” and “After” views.
- Added previews for binary content from Git history, including renamed files.
- Added loading, missing-file, error, and file-size limit states.
- Binary previews now refresh when files change.
-
Bug Fixes
- Improved embedded image previews with a static, scroll-friendly display.
- Prevented unchanged previews from unnecessarily remounting.
-
Localization
- Added translations for “Before” and “After” across supported languages.