feat(desktop): preview image diffs in SCM pane

Merged
TH
2mo ago
+162-21

Summary

  • Render inline previews for supported image files in the desktop Changes pane, using the same placeholder layout as the deferred-diff and binary states (icon, text line, Open file).
  • Reuse the existing image extension and MIME-type helpers and the workspace filesystem.readFile procedure with a 10MB cap.
  • Keep the Open file action and the binary-file fallback for unsupported, deleted, failed, or oversized files.
  • Refetch a preview when git reports that path changed; unrelated edits leave previews alone.
  • Draw transparent images on the same checkerboard the file pane's ImageView uses.

How to run and test

  1. Run ./.superset/setup.local.sh once in a workspace.
  2. Run bun run dev.
  3. Open a workspace with staged or unstaged image changes.
  4. Open the Changes pane and select the image diff.
  5. Confirm PNG/JPEG previews render inline and Open file still works.
  6. Replace the image on disk and confirm the preview updates; delete a tracked image and confirm it falls back to "Binary file hidden".

Validation

  • bun run lint
  • bun run --cwd apps/desktop typecheck
  • bun run check:i18n (one new string, "Loading image…", translated in all 16 locales)
  • bun test for the DiffPane folder
  • Verified in the dev desktop app: added and modified PNGs preview, an on-disk replacement refetches, a deleted image falls back to the binary placeholder without Open file.

Image example

image

Scope note

The preview reads the current worktree bytes, so it is shown for working-tree and against-base diffs only. Commit refs keep the plain binary placeholder, since the worktree may no longer hold the commit's version of the file. A true old-vs-new visual comparison is left for a follow-up.

https://claude.ai/code/session_01NAmSwAu95MUWMncyMeBTfa