Skip to content

[Bug]: New worktree thread on upstream/* base sits with no progress for ~1min on remote (bootstrap hardcodes origin fetch, streams no progress) #9340

Description

@ImBIOS

Before submitting

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

Area

apps/server

Steps to reproduce

  1. Connect to a remote server (remote environment) whose project repo has both origin and upstream remotes.
  2. Set the project new-thread mode to New worktree with Start from origin enabled.
  3. Start a new conversation, set the base branch to upstream/main, type a prompt and submit.

Expected behavior

The client shows what is happening while the worktree is prepared (fetching the base ref, creating the worktree), and the server fetches the base branch's actual remote (upstream) before basing the worktree on it.

Actual behavior

After submit, the new conversation is created but there is no meaningful UI feedback about what is going on for roughly a minute; only then does the status flip to Working.

Root cause (all on main):

  1. apps/server/src/ws.ts:1097-1121 hardcodes remoteName: "origin". With base upstream/main it runs git fetch origin (slow and irrelevant on a remote server), then checks remoteBranchExists({ refName: "upstream/main", remoteName: "origin" }) which tests refs/remotes/origin/upstream/main — a ref that can never exist (apps/server/src/vcs/GitVcsDriverCore.ts:1295-1303 concatenates blindly). So it always falls back to the unfetched local upstream/main string. The upstream remote is never fetched, so the worktree may also be based on a stale commit.
  2. The entire bootstrap (fetch + worktree add (up to 300s timeout, plus recursive submodule update: GitVcsDriverCore.ts:2826-2863) + setup script + turn start) runs inside a single blocking thread.turn.start+bootstrap WS RPC (ws.ts:1093-1143). No thread.activity.append progress is emitted during fetch/worktree creation (unlike the setup-script steps, which do emit setup-script.requested/started), so the client can only show its local optimistic status with no step detail and no way to cancel.

Related: #8191 (same code area, local-only bases — closed), #8922 (generic client-side setup status).

Impact

Major degradation or frequent failure

Version or commit

main @ a81a52a (also observed on recent nightly)

Environment

Remote server environment; repo with origin + upstream remotes; defaultThreadEnvMode: worktree, newWorktreesStartFromOrigin: true.

Logs or stack traces

No error — the operation eventually succeeds; it is just silent for ~1min. Server trace shows the time going to GitVcsDriver.fetchRemote (origin) and GitVcsDriver.createWorktree inside dispatchBootstrapTurnStart.

Activity

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