Skip to content

feat: add three-mode diff view - #35

Merged
sam-phinizy merged 11 commits into
mainfrom
feat/diff-view
Mar 24, 2026
Merged

feat: add three-mode diff view#35
sam-phinizy merged 11 commits into
mainfrom
feat/diff-view

Conversation

@sam-phinizy

Copy link
Copy Markdown
Contributor

Summary

  • Adds diff viewing with three modes: Split (side-by-side), Unified (inline additions/deletions with dual gutters), and Highlights (additions-only overlay on existing editor)
  • Rust backend computes diffs via similar crate with Patience (default) and Myers algorithms, resolves git refs via git2
  • Always-visible diff mode toggle in the editor toolbar — click to enter/exit diff mode
  • Ref picker with branch/tag/commit dropdowns and swap button
  • Diff commands in command palette (Cmd+K)
  • Auto-collapse file tree in split mode, re-diff on file switch
  • Annotation blocking on delete lines in unified mode
  • "No changes" message when files are identical between refs

New files

  • src-tauri/src/commands/diff.rscompute_diff and list_refs Tauri commands
  • src/lib/stores/diff.svelte.ts — Diff state store
  • src/lib/codemirror/diff.ts — CodeMirror decorations, ghost lines, dual gutters, scroll sync
  • src/components/DiffEditor.svelte — Prop-driven CodeMirror instance for diff views
  • src/components/DiffModeToggle.svelte — Segmented control for split/unified/highlights
  • src/components/DiffRefPicker.svelte — Base/target ref dropdowns with swap

Test plan

  • Open a file with uncommitted changes, click Split/Unified/Highlights in toolbar
  • Verify split mode shows two side-by-side editors with scroll sync
  • Verify unified mode shows inline diff with dual line number gutters
  • Verify highlights mode overlays green on added lines in the existing editor
  • Switch refs via ref picker, verify diff recomputes
  • Click swap button, verify refs swap and diff updates
  • Switch files while in diff mode, verify diff recomputes
  • Click active mode to exit diff, verify normal editor restores
  • Open identical file, verify "No changes" message appears

🤖 Generated with Claude Code

sam-phinizy and others added 11 commits March 24, 2026 09:30
Spec for three-mode diff viewing (split, unified, highlights) with
CodeMirror 6 integration, Rust-side diff computation via similar crate,
and ref picker UI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- CodeMirror diff decorations (highlights, unified, split modes)
- DiffEditor: prop-driven CodeMirror instance for diff views
- DiffModeToggle: segmented control for split/unified/highlights
- DiffRefPicker: base/target ref dropdowns with swap
- Diff commands in command palette (Cmd+K)
- App.svelte: diff context, auto-collapse tree, re-diff on file switch
- EditorPane: conditional diff rendering for all three modes
- Editor: highlights mode via Compartment
- Annotation blocking on delete lines in unified mode

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… message

- Fix effect_update_depth_exceeded: remove $state from DiffEditor view,
  wrap computeDiff/dispatch in untrack(), add dedup guard for re-diff
- Always show diff mode toggle in editor toolbar
- Clicking active mode exits diff, clicking inactive enters it
- Show "No changes" message when files are identical
- Show ref picker only when diff is active

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sam-phinizy
sam-phinizy merged commit 2c9c042 into main Mar 24, 2026
0 of 2 checks passed
@sam-phinizy
sam-phinizy deleted the feat/diff-view branch March 24, 2026 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant