Note
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.
Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.
Use the checkboxes below for quick actions:
- ▶️ Resume reviews
- 🔍 Trigger review
Walkthrough
Adds end-to-end Git integration: new contracts and WS API, server & desktop git utilities, renderer IPC and React Query wiring, per-thread branch/worktree state and persistence, BranchToolbar UI, ChatView worktree creation on first message, tests, and build/tooling/script updates.
Changes
| Cohort / File(s) | Summary |
|---|---|
Contracts & WS API packages/contracts/src/git.ts, packages/contracts/src/ipc.ts, packages/contracts/src/ws.ts, packages/contracts/src/index.ts | New zod schemas/types and result types for git operations; added WS method names; extended NativeApi.git with listBranches/createWorktree/removeWorktree/createBranch/checkout/init; re-exported git. |
Server git module & WS handlers apps/server/src/git.ts, apps/server/src/wsServer.ts, apps/server/src/git.test.ts, apps/server/src/wsServer.test.ts | Introduced server-side git utilities (runTerminalCommand, list/create/remove worktree, branch ops, init) and wired them into WS router; added FS-backed integration tests covering branches, worktrees, checkouts, and WS git RPCs. |
Desktop git helpers & tests apps/desktop/src/git.ts, apps/desktop/src/git.test.ts, apps/desktop/src/main.ts, apps/desktop/src/preload.ts | Extracted desktop git helpers into module; main imports module; preload exposes IPC for git operations; added desktop git tests. |
Renderer native bridge apps/web/src/wsNativeApi.ts, apps/desktop/src/preload.ts | Renderer-facing native API gains git.* methods that route to WS / preload IPC. |
Frontend UI & flows apps/web/src/components/BranchToolbar.tsx, apps/web/src/components/ChatView.tsx, apps/web/src/components/Sidebar.tsx, apps/web/src/App.tsx | Added BranchToolbar and integrated it into ChatView; ChatView manages envMode (local |
State, types & persistence apps/web/src/types.ts, apps/web/src/store.ts, apps/web/src/persistenceSchema.ts, apps/web/src/persistenceSchema.test.ts, apps/web/src/store.test.ts | Extended Thread with branch and worktreePath; added SET_THREAD_BRANCH action and reducer handling (clears session when worktreePath changes); persistence schema migrated to include nullable/optional fields; tests updated. |
Web wiring & deps apps/web/src/App.tsx, apps/web/package.json | Added @tanstack/react-query dependency, created QueryClient and wrapped app in QueryClientProvider; thread creation payload extended with new fields. |
Tests & test plan .plans/*, apps/desktop/src/git.test.ts, apps/server/src/git.test.ts, apps/web/src/git-flows.test.ts | Added integration/unit tests and a test plan for Git flows, worktrees, store reducer, and edge cases; factory helpers and comprehensive scenarios included. |
Build/tooling & scripts apps/*/tsdown.config.ts, removed tsup.config.ts, package.json, apps/*/package.json, *.turbo.jsonc, vitest.config.ts | Switched build tooling from tsup→tsdown, updated package scripts to turbo orchestration, adjusted outputs to .mjs/ESM, added turbo configs and vitest alias changes. |
Misc UI/docs/formatting README.md, AGENTS.md, various apps/web/*, apps/server/*, packages/contracts/* | Docs and plan files added/updated; assorted formatting and small non-functional refactors across CSS, tests, and TS files. |
Sequence Diagram
| 1 | sequenceDiagram |
| 2 | participant User as User |
| 3 | participant ChatView as ChatView (UI) |
| 4 | participant BranchToolbar as BranchToolbar (UI) |
| 5 | participant Store as Renderer Store |
| 6 | participant NativeAPI as Native API (preload/WS) |
| 7 | participant WebSocket as WebSocket Transport |
| 8 | participant Server as Server (git module) |
| 9 | |
| 10 | User->>ChatView: open chat / branch controls |
| 11 | ChatView->>BranchToolbar: render (envMode, envLocked) |
| 12 | BranchToolbar->>NativeAPI: git.listBranches({ cwd }) |
| 13 | NativeAPI->>WebSocket: invoke "git:list-branches" |
| 14 | WebSocket->>Server: WS_METHODS.gitListBranches |
| 15 | Server-->>WebSocket: return branches |
| 16 | WebSocket-->>NativeAPI: branches |
| 17 | NativeAPI-->>BranchToolbar: branches list |
| 18 | |
| 19 | User->>ChatView: send first message |
| 20 | alt envMode == "worktree" && no worktreePath |
| 21 | ChatView->>NativeAPI: git.createWorktree({ branch, cwd }) |
| 22 | NativeAPI->>WebSocket: invoke "git:create-worktree" |
| 23 | WebSocket->>Server: WS_METHODS.gitCreateWorktree |
| 24 | Server->>Server: runTerminalCommand("git worktree add ...") |
| 25 | Server-->>WebSocket: { worktreePath, branch } |
| 26 | WebSocket-->>NativeAPI: result |
| 27 | NativeAPI-->>ChatView: worktreePath |
| 28 | ChatView->>Store: dispatch SET_THREAD_BRANCH(threadId, branch, worktreePath) |
| 29 | else |
| 30 | ChatView->>Store: dispatch SET_THREAD_BRANCH(threadId, branch, null) |
| 31 | end |
| 32 | |
| 33 | Store->>Store: update thread.branch & thread.worktreePath |
| 34 | ChatView->>NativeAPI: ensure/start session(cwd = worktreePath ?? project.cwd) |
| 35 | NativeAPI->>WebSocket: start session |
| 36 | WebSocket->>Server: establish session in selected cwd |
| 37 | Server-->>WebSocket: session ready |
| 38 | WebSocket-->>NativeAPI: session active |
| 39 | NativeAPI-->>ChatView: session active |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~60 minutes
🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Out of Scope Changes check | ⚠️ Warning | The PR includes tooling/infrastructure changes (tsup→tsdown migration, Turbo config, Vitest config, package.json restructuring) unrelated to the Git integration feature objectives stated in issue #7. | Extract tooling/build changes into a separate PR. Keep this PR focused on Git feature implementation only—branch picker UI, worktree support, persistence schema updates, and related tests. |
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 12.20% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title 'Git integration: branch picker + worktrees' accurately summarizes the main changes—adding Git branch selection UI and worktree support for thread management. |
| Linked Issues check | ✅ Passed | The PR implements all primary objectives from issue #7: threads associated with local Git branches (current, existing, new), Git worktree-based workspaces, and worktree reuse patterns. Multiple-threads-per-worktree and 'best of N' selection noted as out-of-scope. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
- Commit unit tests in branch
juliusmarminge/git-integration
Comment @coderabbitai help to get the list of available commands and usage tips.