Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): fetch worktree base branch's own remote during bootstrap #9341

ClosedImBIOS(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/9341/headopened View on GitHub

New worktree threads based on upstream/main (or any non-origin remote base) sit with no useful progress for ~1min on remote servers. Fixes #9340 (server half; step-level progress UI tracked there).

The problem: dispatchBootstrapTurnStart hardcoded remoteName: "origin". With base upstream/main it paid for a slow, irrelevant git fetch origin, then checked remoteBranchExists({ refName: "upstream/main", remoteName: "origin" }) — i.e. refs/remotes/origin/upstream/main, a ref that can never exist — so it always fell back to the unfetched local ref. The upstream remote was never fetched, so the worktree could also be based on a stale commit.

How fixed: resolve the fetch target from the base ref. If the segment before the first / names a configured remote, fetch that remote; otherwise keep the existing origin behavior. The existence lookup strips the remote prefix (upstream/main on upstream looks up main), which also repairs literal origin/main bases that previously looked up origin/origin/main. Local-only branches still fall back to the local ref exactly as before.

Verified: new it.effect.each cases in server.test.ts (upstream/main, origin/main) assert fetch/check/resolve/createWorktree args; existing bootstrap tests (including the local-fallback cases) pass unchanged; server typecheck clean.


Note

Medium Risk Touches thread bootstrap git workflow on the server; incorrect remote resolution could still mis-base worktrees, but behavior is narrowed with tests and preserves local-only fallback paths.

Overview Fixes bootstrap worktree preparation when start from remote is enabled but the base branch is not on origin (e.g. upstream/main). Previously the server always fetched origin and probed the wrong remote-tracking ref, so the real remote was never updated and worktrees could hang on stale local SHAs.

ws.ts now derives fetchRemoteName from the prefix before the first / when that remote exists, otherwise keeps the origin fallback. Remote branch checks strip that prefix so lookups hit refs/remotes/upstream/main instead of refs/remotes/origin/upstream/main (and the same fix applies to literal origin/main bases). server.test.ts adds parameterized coverage for upstream/main and origin/main, asserting fetch, branch existence, commit resolution, and worktree creation arguments.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a81f93aa05159523a9ab0b3214b1e75723045643. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Fix worktree bootstrap to fetch base branch's own remote

Adds a parameterized integration test in server.test.ts that verifies the server router bootstrap seam fetches and checks the correct remote for the worktree base branch. The test covers both upstream-qualified and origin-qualified bases, confirming that fetch, remote branch lookup, tracking-commit resolution, and worktree creation receive the expected remote-specific arguments using the unqualified branch name.

Macroscope summarized a81f93a.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at a81f93a

      Macroscope's review found this PR approvable — This is a focused server bug fix that selects and fetches the worktree base branch’s configured remote without altering unrelated bootstrap paths. Parameterized integration coverage verifies upstream-qualified and origin-qualified bases, while the other changed file is test-only.

      Notes:

      • Diff unchanged. Approvability was decided on eligibility alone.
      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Note: GPT-6 on behalf of shivam (@shivamhwp).

      The first-slash split still selects the wrong remote for valid names containing a slash. With remote team/upstream and base team/upstream/main, the code probes team, then fetches origin and leaves the intended base stale. If team also exists, it fetches that shorter remote instead.

      Resolve the longest configured remote prefix before stripping it from the branch name. Keep the existing origin and local-base fallbacks. The issue's step-level progress and cancellation gap remains separate from this fetch correction.

    4. juliusmarminge added labelsmacroscope-review

    5. Note

      Written by claude-opus-5-5 on behalf of Maria

      Hi! We are cleaning up open PRs, and this one does not say which model or harness was used to create it. If this change is really important, we recommend rebuilding the PR with a newer model and noting the model and harness in the PR description.

    6. maria-rcks closed this

Sign in to join this conversation.