Uh oh!
There was an error while loading. Please reload this page.
feat(mcp): let agents change thread workspaces - #8680
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 Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Warning Your free Security trial is over. An organization admin can activate Security or dismiss this notice. Comment |
Thread transfer impact
This comment will update automatically after the next completed run. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR adds a substantial destructive MCP workflow that can switch branches, create or reuse worktrees, update durable thread bindings, and detach or restart provider sessions. Its cross-component concurrency, rollback, and lifecycle behavior is too broad for automatic approval despite extensive test coverage. You can add or adjust custom eligibility rules. Learn more. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
03d0e2b to
4453207CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
4453207 to
1d54579CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
76ccdb2 to
69afd25CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Effect service conventions review of the new WorktreeMcpService.checkout path: service tag, inline interface, make/layer, subpath namespace imports, dependency acquisition (yield* Foo.Foo), and error construction all follow the conventions. One test-organization issue noted inline.
Posted via Macroscope — Effect Service Conventions
Uh oh!
There was an error while loading. Please reload this page.
1ed8ca4 to
d653ad1CompareUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Bugbot Autofix is ON, but a cloud agent failed to start.
Reviewed by Cursor Bugbot for commit d653ad1. Configure here.
Uh oh!
There was an error while loading. Please reload this page.

Problem
Existing threads cannot safely move between their project root, branches, and worktrees through MCP. Updating only the recorded branch can leave durable thread state out of sync with Git, and a workspace change can detach the caller before follow-up work is queued.
Change
t3_thread_checkouttargets for branch switch/create, canonical inventory worktree reuse, project-root return, and new-worktree creationBehavior
Workspace path changes queue an optional continuation after the binding commits and before the calling provider session detaches. Same-workspace retries are idempotent. Failures report whether Git changed, whether the binding committed, and whether rollback completed, failed, or was unsafe. Unknown, unattested, or concurrently changed Git state is preserved. The workflow never stashes or drops files, removes existing worktrees, or implements retention, pruning, or revival.
Validation
vp test run apps/server/src/mcp/WorktreeMcpService.test.ts(107 tests)vp test run apps/server/src/vcs/GitVcsDriverCore.test.ts(59 tests)Dependency
Upper member of native stack #8711. Depends on workspace inventory PR #8685 and remains independent of lifecycle PR #5589.
Implemented by GPT-5.6-Sol via Codex in T3 Code.
Note
Medium Risk
Large changes to Git mutation, durable thread bindings, and concurrency guards in MCP worktree paths; incorrect rollback or binding logic could leave Git and recorded thread state diverged, though scope is limited to worktree MCP tooling rather than core auth or data stores.
Overview
Adds
t3_thread_checkoutso MCP agents can move a thread between the project root, an existing listed worktree, a branch switch/create (including remote refs), or a new worktree—mutating Git first, then updating durable thread metadata only after ref/commit verification. Workspace moves can queue a continuation before the provider session detaches.Handoff is aligned with the same model: attached threads can hand off to another worktree, transitions are serialized per thread and per physical checkout, cross-project ownership is checked via canonical Git identity, and failures can return
partial_failurewith rollback hints instead of always tearing down created worktrees/branches.Orchestrator
thread.metadata.updatenow supports compare-and-set viaexpectedBranchandexpectedArchived(alongside existing worktree expectations).GitWorkflowService.resolveCommitis exposed for HEAD/ref verification during these flows.Reviewed by Cursor Bugbot for commit 0e3839f. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add
t3_thread_checkoutMCP tool to let agents switch thread workspacesWorktreeMcpService.checkoutand thet3_thread_checkoutMCP tool, enabling agents to move a thread to an existing branch, return to the project root, reuse or create a worktree, and create-and-switch new branchesexpectedBranch,expectedArchived) to thethread.metadata.updatecommand in Orchestrator.ts; the dispatch fails withOrchestratorDispatchErrorwhen expectations don't match current thread stateworkspaceTransitionsInFlight) in WorktreeMcpService.ts to prevent concurrent mutations to the same checkoutgitWorkflow.createRefin GitVcsDriverCore.ts to validate branch names viagit check-ref-formatand usegit branch -- <name>so option-like names are rejectedtransitionIdskey format changes (binding/continuationsuffixes replaceworktree-handoffvalues), affectingcommandId/messageIdidentifiers emitted during metadata updates and continuations; status handler now treats a non-repo path with an existing workspace inventory as an error rather than benignMacroscope summarized 0e3839f.