feat: add git working tree diff toggle in diff panel#1809
feat: add git working tree diff toggle in diff panel#1809D3OXY wants to merge 1 commit intopingdotgg:mainfrom
Conversation
Add a toggle in the diff panel header that switches between session (checkpoint-based turn diffs) and git (live working tree diff) modes. Closes pingdotgg#1590
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review This PR adds a new user-facing feature: a toggle to switch between session checkpoint diffs and git working tree diffs in the diff panel. It introduces new backend functionality, a new RPC endpoint, and new UI controls. New features with user-facing behavior changes warrant human review regardless of implementation quality. You can customize Macroscope's approvability policy. Learn more. |
Closes #1590
Summary
Adds a toggle in the diff panel header that switches between two modes:
git diff HEADoutput showing all staged + unstaged changes on tracked files.This gives visibility into changes made outside the agent (manual edits, IDE refactors, other tools) and provides a reliability fallback when checkpoint-based diffs are incomplete or unavailable.
What changed
Contracts (
packages/contracts)GitWorkingTreeDiffInput/GitWorkingTreeDiffResultschemas ingit.tsgit.workingTreeDiffRPC method definition inrpc.tsworkingTreeDiffto theNativeApi.gitinterface inipc.tsServer (
apps/server)readWorkingTreeDiffto theGitCoreShapeservice interfacegit diff HEAD --patch --minimal --no-color, with a fallback togit diff --cachedfor repos with no commits yet. Output capped at 512KB with truncation.git.workingTreeDiffRPC handler inws.tsWeb (
apps/web)gitWorkingTreeDiffQueryOptionsReact Query helper ingitReactQuery.tsworkingTreeDiffto the RPC client and NativeApi wiringdiffScope: "session" | "git"URL search param indiffRouteSearch.tsDiffPanel.tsx:Tests
diffScopeparsing indiffRouteSearch.test.tsUI
Design decisions
subscribeGitStatusstream. When the server broadcasts a git status change, the diff query is invalidated and refetches. Zero polling overhead.[truncated]marker. Larger thanreadRangeContext's 59KB cap since working tree diffs tend to be bigger, but still bounded.git diff --cachedto handle initial-add scenarios gracefully.git diff HEADcovers staged + unstaged changes on tracked files. Untracked files are excluded (consistent with checkpoint diffs).diffScopeis stored in the URL search params so the mode survives navigation and can be deep-linked.Test plan
diffScope=gitpersists in URL across navigationNote
Add git working tree diff toggle to the diff panel
readWorkingTreeDiffmethod in GitCore.ts that diffs against HEAD when commits exist, or against staged changes when there are none; output is capped at 512KB.git.workingTreeDiffWebSocket RPC, wired through contracts, the WS server, and the native API client.diffScopequery param is parsed and validated in diffRouteSearch.ts; it is stripped when the diff panel is closed or the value is invalid.Macroscope summarized 37ac2f5.