Skip to content

feat(desktop): add Git Diff Viewer to context panel#2269

Open
HUQIANTAO wants to merge 1 commit into
esengine:mainfrom
HUQIANTAO:feat/git-diff-viewer
Open

feat(desktop): add Git Diff Viewer to context panel#2269
HUQIANTAO wants to merge 1 commit into
esengine:mainfrom
HUQIANTAO:feat/git-diff-viewer

Conversation

@HUQIANTAO
Copy link
Copy Markdown
Contributor

Summary

Add a "Diffs" tab to the right-side context panel that shows workspace git changes (staged, unstaged, untracked) with expandable inline diffs.

Changes

Rust backend (desktop/src-tauri/src/main.rs)

  • New git_diffs Tauri command — runs git diff --unified=3 HEAD (unstaged), git diff --cached (staged), git ls-files --others (untracked)
  • Returns GitDiffsResult { staged, unstaged, untracked } with FileDiff { file, additions, deletions, patch, status }
  • Follows existing git_status pattern (silent on non-git repos, Windows CREATE_NO_WINDOW)

Frontend (desktop/src/ui/context-panel.tsx)

  • New "diffs" tab in ContextPanelTab union
  • CtxDiffs component: fetches via invoke("git_diffs", { root }), renders 3 sections (Staged / Unstaged / Untracked)
  • Each file is expandable — click to show inline DiffCard (reusing existing component from cards.tsx)
  • parsePatch() helper converts git unified diff patches to DiffLine[] format
  • Refresh button in header

CSS (desktop/src/styles.css)

  • .diff-file-* styles for the file list (compact rows, chevron expand, stats badges, status pills)
  • .ctx-action style for the refresh button

i18n

  • 12 new keys in en.ts and zh-CN.ts
  • de.ts / ja.ts / ru.ts auto-inherit via ...en spread fallback

- Add 'Diffs' tab to the right-side context panel
- Add Rust git_diffs Tauri command (runs git diff/ls-files, returns structured FileDiff[])
- Reuse existing DiffCard component for inline patch rendering
- Show staged, unstaged, and untracked files in 3 sections
- Expandable file entries with +/- stats and status badges
- Refresh button to re-fetch changes
- Graceful empty states for no changes, no workspace, non-git repos
- Add i18n keys (en, zh-CN; de/ja/ru auto-fallback via ...en spread)
Copy link
Copy Markdown
Owner

@esengine esengine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice — clean reuse of the existing DiffCard, Tauri command follows git_status conventions, and the i18n fallback story is correct. Letting CI run.

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.

2 participants