Skip to content

[Bug]: Worktree thread launch sends placeholder base ref "(unknown)" for a project registered while its clone was still checking out #37036

Closed

Description

@nthewara

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web (the client sends the bad value), with a hardening gap in apps/server

Steps to reproduce

  1. Clone a GitHub repository through T3 Code and let it register as a project (here: a small private repo, my-repo, default branch main).
  2. In the server trace, the project is registered at 10:36:11.725 (+08:00). The clone's checkout only finishes at 10:36:13 (reflog clone: entry and mtimes of .git/HEAD and .git/packed-refs). So T3 reads the repo during those ~2 seconds while it still has no commits.
  3. Wait a few minutes. Background VCS status polling for the project now succeeds every ~30s (currentBranch, resolveDefaultBranchName).
  4. Start a new thread on the project in Worktree mode without touching the base-branch picker, and send it.

I have not yet confirmed a deterministic repro beyond this one occurrence (2 failed launches). The race window in step 2 is my best explanation, based on the traces below.

Expected behavior

The worktree launch uses the project's real default branch (main / origin/main). If the client has no known base branch, it either resolves one before launch or blocks the launch with a clear "pick a base branch" prompt. It should never send a display placeholder.

Actual behavior

The launch fails with:

Base ref "(unknown)" does not resolve to a commit in project "my-repo" (~/code/my-repo).

ThreadLaunchService.checkWorktreeBase receives strategy.baseRef === "(unknown)". That is a literal placeholder, not a ref. hasCommit, resolveWorktreeBaseRemote / fetchWorktreeBaseCommit and hasRefNamed all fail on it, so it ends in ThreadLaunchBaseRefError.

The repository itself is healthy at launch time:

$ git status          -> On branch main, up to date with 'origin/main', clean
$ git rev-parse HEAD  -> <commit on main>
$ git symbolic-ref refs/remotes/origin/HEAD -> refs/remotes/origin/main
$ git worktree list   -> only the main checkout

Timeline from server.trace.ndjson (UTC, git spans for this project):

02:36:11  listRefs.defaultRef, resolveDefaultBranchName     Success
02:36:11  review.emptyTree (x2)                             Success   <- repo read as unborn
02:36:12  getReviewDiffPreview.unbornStat (x2)              Success   <- repo read as unborn
02:36:12  GitWorkflowService.currentBranch                  Failure   "Failed to read the checked-out branch." (VcsStatusBroadcaster.readRemoteStatus)
02:36:13  clone checkout completes (reflog)
02:36:13 - 02:39:50  currentBranch / resolveDefaultBranchName  Success every ~30s
02:38:18  listRefs.currentBranch, listRefs.defaultRef       Success
02:39:54  GitWorkflowService.hasCommit                      Success (returns false for "(unknown)")
02:39:54  ws.rpc.orchestration.launchThread                 Failure   ThreadLaunchBaseRefError
02:40:13  ws.rpc.orchestration.launchThread (retry)         Failure   same error

So the server knew the correct branch for more than 3 minutes before the launch. The client still sent "(unknown)".

Two problems, as far as I can tell:

  1. Client (apps/web): the new-thread base-branch state seems to be captured while the repo is unborn and never refreshed, even though later status polls return main. The placeholder label then goes out as workspaceStrategy.baseRef. I couldn't find the literal "(unknown)" in the shipped client bundle, so I haven't confirmed where it is produced.
  2. Server (apps/server): checkWorktreeBase / launchThread accept any string as baseRef. A guard could reject known placeholders, or fall back to the resolved default branch when the client sends no usable ref. Either would turn this into a recoverable launch.

A related cause: the project is registered and VCS-probed before git clone has finished the checkout. Registering only after the clone completes would close the race at its source.

Impact

Major degradation or frequent failure (worktree threads can't start on a freshly cloned project, and the error doesn't tell the user what to do)

Version or commit

T3 Code (Nightly) 0.1.10-nightly.20261114.4709

Environment

  • macOS 26.7.3 (Darwin 25.6.0), Apple Silicon
  • git 2.54.0 (Apple Git-157)
  • Desktop app, local environment, Claude agent provider
  • Remote: GitHub over HTTPS

Logs or stack traces

OrchestrationV2ThreadLaunchError: Base ref "(unknown)" does not resolve to a commit in project "my-repo" (~/code/my-repo).
    at Object.ThreadLaunchBaseRefError (apps/server/dist/server-D3YlHvls.mjs:76002:41)
    at apps/server/dist/Schema-DXsMz4_8.mjs:11148:28
    at ws.rpc.orchestration.launchThread (Nightly)
    at server.runServerCommand (apps/server/dist/binCli-J-OM7gVL.mjs:10612:16)
    at server.runDefaultServerCommand (apps/server/dist/binCli-J-OM7gVL.mjs:3639:82)

ThreadLaunchBaseRefError: Base ref "(unknown)" does not resolve to a commit in project "my-repo" (~/code/my-repo).
    at Object.<anonymous> (apps/server/dist/runtimeLayer-C-6tA-Wf.mjs:103841:55)
    at ThreadLaunchService.checkWorktreeBase (apps/server/dist/server-D3YlHvls.mjs:75948:55)
    at server.runServerCommand (apps/server/dist/binCli-J-OM7gVL.mjs:10612:16)

GitCommandError: Git command failed in GitWorkflowService.currentBranch (~/code/my-repo): Failed to read the checked-out branch.
    at Object.<anonymous> (apps/server/dist/runtimeLayer-C-6tA-Wf.mjs:46165:18)
    at GitWorkflowService.currentBranch (Nightly)
    at VcsStatusBroadcaster.readRemoteStatus (Nightly)

Trace IDs: launch cdf051a0ba17a7c09ba9b18bc193f4fe, command id 03558ddd-dc6a-432f-9ef8-2a0ac68b6857.

Workaround

Not yet verified. Candidates: pick main explicitly in the base-branch picker, reload the window so branch state refreshes, or launch in Local mode, which skips the base-ref check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions