fix(server): fall back when new worktrees are unavailable - #6208
Conversation
c7f938b to
e85c7ed
Compare
|
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:
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 |
e85c7ed to
4c9498b
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4c9498be6eeb2e6f47537752478757871168173c. Configure here.
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a localized server bug fix that preflights repository and commit availability before creating a thread, preventing failed worktree setup from leaving unusable thread state. Valid worktree flows remain intact, and the fallback cases are covered by integration tests. You can add or adjust custom eligibility rules. Learn more. |
210bcc5 to
f877402
Compare
## What's Changed * fix(web): offer recovery from missing pages by @shivamhwp in pingdotgg/t3code#11314 * fix(web): retry startup after the server recovers by @shivamhwp in pingdotgg/t3code#11291 * feat(web): add optional compact sidebar rail by @maria-rcks in pingdotgg/t3code#11525 * feat(web): add opt-in in-app thread notifications by @Bil0000 in pingdotgg/t3code#11570 * feat(web): organize connections by environment by @maria-rcks in pingdotgg/t3code#11542 * fix(web): keep sparse sidebar shelves at the bottom by @maria-rcks in pingdotgg/t3code#11595 * fix(cursor): preserve internal agent errors without transport labels by @shivamhwp in pingdotgg/t3code#11365 * fix(server): fall back when new worktrees are unavailable by @tris203 in pingdotgg/t3code#6208 * feat: badge background thread notifications on desktop and web by @Bil0000 in pingdotgg/t3code#11569 * feat(web): add compact thread list mode by @saphid in pingdotgg/t3code#9417 **Full Changelog**: pingdotgg/t3code@v0.0.41-nightly.20260913.1658...v0.0.41-nightly.20260913.1675 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.41-nightly.20260913.1675
…6208) Preflight repository and base commit availability before creating the thread. Fall back to the project checkout for non-Git directories and repositories without a usable base commit, while preserving valid worktree setup.

Problem
When New threads defaults to New worktree, the first message can carry one atomic bootstrap request containing both
createThreadandprepareWorktree.Two project states cannot satisfy that request:
HEAD: Git reports a branch name, but no commit exists forgit worktree addto branch from.The server previously persisted
thread.createbefore attemptinggit worktree add. When worktree creation failed, cleanup deleted the new thread, but event sourcing intentionally retained its ID as a tombstone. The client draft retained that same ID for retry. This produced a confusing sequence:Orchestration command invariant failed (thread.create): Thread '<id>' already exists and cannot be created twice.This could depend on client-side Git status timing, and server bootstrap requests from every client trusted the requested worktree mode without an authoritative preflight.
Fix
The server now preflights worktree bootstrap before persisting the thread:
git rev-parse --verify <ref>^{commit}.Running the preflight before
thread.createprevents deterministic repository/base-ref failures from leaving a thread tombstone behind.Behavior
HEADReproduction
git initwith no commits.Verification
pnpm exec vp test run apps/server/src/server.test.ts— 126 tests passed.pnpm --filter t3 typecheck— passed.Generated with GPT-5.6 Sol in T3 Code using the Codex harness.
Note
Medium Risk
Changes first-message thread bootstrap and Git preflight behavior on the server; mistakes could skip worktrees or mis-route cwd, but fallbacks are narrow and covered by new integration tests.
Overview
Bootstrap worktree creation is now preflighted before
thread.create, so failed worktree setup no longer leaves a thread tombstone that blocks retries with “cannot be created twice.”GitWorkflowServicegainsisRepository(VCS detect → Git only) andhasCommit(git rev-parse --verify <ref>^{commit}with non-zero exit treated as false). In the WebSocket bootstrap path, origin/base resolution still runs when applicable, butcreateWorktreeruns only when the project cwd is a Git repo and the resolved base ref points at a commit. Otherwise the flow creates the thread and starts the turn against the project checkout (no worktree meta update / setup on a missing worktree path).Tests cover the new Git workflow helpers and two server integration cases: non-repository project cwd and unborn-head / missing base commit, plus stubs so existing bootstrap tests satisfy the new
execute/ work-tree checks.Reviewed by Cursor Bugbot for commit 4c83fbf. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Skip worktree creation in
bootstrapProgramfor non-Git repos and missing commitsGitWorkflowService.isRepositoryandGitWorkflowService.hasCommitto detect whether a path is a Git repository and whether a ref resolves to a commit.makeWsRpcLayer.bootstrapProgramin ws.ts now runs these checks before worktree preparation. For non-Git projects or base refs with no commit, it skips origin lookup, remote-base resolution, and worktree creation, then still dispatches the thread and turn.Macroscope summarized 4c83fbf.