Repository navigation
Description
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
Steps to reproduce
- Open a pull request in the pull request panel.
- Click Check out → In a separate worktree.
- While the worktree setup runs, type a prompt into the draft that opens.
- Wait for the checkout to finish. Or send the prompt before the checkout finishes.
Expected behavior
The draft with the typed prompt stays open, and it moves to the new worktree and branch. A prompt sent before the checkout finishes waits for the checkout, then starts the thread in the worktree.
Actual behavior
When the checkout finishes, the app opens a second, empty draft on the worktree and navigates to it.
- If the prompt was only typed, it stays behind in the first draft, and that draft is not on the worktree.
- If the prompt was sent, the thread starts in the first draft's workspace, not in the checkout. If new threads default to worktrees, that is a second, new worktree. The app then moves away from that running thread to the empty draft.
I saw the typed case on my machine. The sent case comes from reading the source.
startHandoff in usePullRequestActions.ts calls newThread twice:
newThread(projectRef)opens the draft (line 441).prepareThread.runcreates the worktree and runs setup. The composer stays usable during this step.newThread(projectRef, { branch, worktreePath, envMode })points a draft at the checkout (line 483).
newThread in useHandleNewThread.ts reuses an open draft only when it has no user content and was not sent (lines 286 and 375). After the user types or sends, the third step creates a new draft and navigates to it. Nothing makes a send wait for the checkout. The comment at usePullRequestActions.ts:548 already describes this case: "if the user typed into opened while the checkout ran, that is no longer the draft the user is looking at."
PullRequestDetailPanel.tsx:1138-1172 has a copy of the same sequence and behaves the same way.
A possible fix:
- After
prepareThread.run, update theopeneddraft withsetDraftThreadContext(opened.draftId, { branch, worktreePath, envMode }), not with a secondnewThreadcall. - Make a send from that draft wait until the checkout finishes. A send already waits for a pending workspace default through
readPendingWorkspaceDefault(useComposerSend.ts:1837).
Impact
Minor bug or occasional failure
Version or commit
0.1.13-nightly.20261125.5258 (code read at main @ bf27eb1)
Environment
macOS 27.2.1, desktop app
Workaround
Wait until the checkout finishes before you type. Or copy the prompt from the first draft into the second one.
Related
#26711 is about the same checkout flow and the same two newThread calls. It covers a different problem: an unsent draft leaves its worktree behind.
Filed with Claude (Opus 5.5) in T3 Code, from source reading and the behavior on my machine.
Activity