[Bug]: Creating a thread from a pull request does not link the pull request to the thread #15721
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 thread in a GitHub-backed project.
- Start a thread from a pull request using any of the checkout paths, in worktree (or local) mode:
- the pull request dialog in chat,
- the pull request detail panel's checkout hand-off,
- a pull request hand-off action (e.g. "fix this finding").
- Wait for the checkout to finish and the thread to move onto the PR branch.
- Open the thread's linked pull requests (thread details / PR panel).
Expected behavior#
The pull request the thread was created from is linked to that thread, the same as if it had been linked through the Link pull request dialog or the link_pull_request MCP tool. Linked-PR sync, watching, and the sidebar/thread badges then treat it as the thread's pull request.
Actual behavior#
The worktree is prepared and the thread is pointed at the PR branch, but no link is recorded. The PR must be linked by hand afterwards.
None of the paths that prepare a PR checkout write a link:
- Server:
GitManager.preparePullRequestThread(apps/server/src/git/GitManager.ts) usesthreadIdonly to run the project setup script. - Web: after
preparePullRequestThreadsucceeds, each caller only re-points the thread at{ branch, worktreePath }and never dispatchesthread.pull-request.link:ChatView.tsx→handlePreparedPullRequestThreadpullRequest/PullRequestDetailPanel.tsx(checkout hand-off)pullRequest/usePullRequestActions.ts(usePullRequestHandoffs)
Because the server method already resolves the pull request and receives the threadId, linking there would cover all three web paths plus any other caller with no client changes.
Impact#
Minor bug or occasional failure
Version or commit#
main @ 4ee6bfd50e
Environment#
macOS, T3 Code desktop
Workaround#
Link the pull request manually from the thread's Link pull request dialog after the checkout completes.
juliusmarminge added labelsbug
juliusmarminge added labelsvia-triage
Reproduced in the web dev app on b5a226e49c, using isolated state and a GitHub-backed project. The chat checkout dialog in Local mode and the PR detail panel checkout in a separate worktree both completed. After materializing each draft as a thread, the persisted thread had its PR branch and branchPullRequest reference, but pullRequests remained empty. The visible branch badge therefore does not establish an explicit link. macOS Electron has not been checked.
Fix submitted in #23458. The web draft retains the checkout PR and links each successfully started thread. Focused tests, web typecheck and lint pass. Runtime records cover the original failure and a persisted link after reload; matched browser recordings and Electron verification remain incomplete after environment interruptions.
juliusmarminge closed this
Sign in to join this conversation.
Note
Grok responding on behalf of Julius.
Triage#
Thanks for tracing all three checkout paths, @gertzgal. I didn't find another issue covering this.
What I found#
I checked
mainat4ee6bfd. Checkout prepares the branch and points a thread at it, but it never writes athread.pull-request.link.GitManager.preparePullRequestThreadresolves and returns the pull request. It only usesthreadIdfor the setup script and never dispatches a link. Creating a pull request from a thread does link it, vialinkCreatedPullRequest, because that thread already exists.branchandworktreePathand drops the resolved pull request. That includesPullRequestThreadDialogwithhandlePreparedPullRequestThread,PullRequestDetailPanel, andusePullRequestHandoffs. Several of these pass the id of a draft. Drafts are client state, andthread.pull-request.linkloads an existing server thread, so linking at prepare time would have nothing to attach to.PersistedDraftThreadStatehas no pull request field.ThreadPullRequestServicecan store a discoveredbranchPullRequest, and badges fall back to it (useLinkedThreadPullRequest). The linked list, the pull-requests panel, snapshot sync, stack siblings, and watch all read links, though, so they stay empty until someone links manually.Likely fix area#
thread.pull-request.linkwhen that draft becomes a server thread. All three web callers already haveresult.pullRequest.manual,created,agent,stack, andstack-dismissed. A checkout link might want its own source.A maintainer will decide on the fix direction.