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
|
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 introduces a new user-facing feature: a toggle in the diff panel allowing users to switch between session-based diffs and git working tree diffs. While well-structured and self-contained, new features with user-facing behavior changes warrant human review. The author is also new to the primary files being modified. You can customize Macroscope's approvability policy. Learn more. |
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
37ac2f5 to
a17b919
Compare
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
git.workingTreeDiffWebSocket RPC endpoint, backed byreadWorkingTreeDiffin GitCore.ts, which runsgit diff HEADorgit diff --cacheddepending on whether commits exist.WORKING_TREE_DIFF_MAX_OUTPUT_BYTES). The diff is automatically re-fetched on git status changes.diffScopesearch param, parsed and validated in diffRouteSearch.ts.Macroscope summarized a17b919.