Skip to content

[Bug]: Typing or sending in the draft during a pull request checkout moves you to a second draft #43484

Done

Description

@johannesscheibe

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

  1. Open a pull request in the pull request panel.
  2. Click Check out → In a separate worktree.
  3. While the worktree setup runs, type a prompt into the draft that opens.
  4. 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:

  1. newThread(projectRef) opens the draft (line 441).
  2. prepareThread.run creates the worktree and runs setup. The composer stays usable during this step.
  3. 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 the opened draft with setDraftThreadContext(opened.draftId, { branch, worktreePath, envMode }), not with a second newThread call.
  • 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.

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