Skip to content

fix(web): keep prompts unsent when pull request checkout fails - #43855

Open
StiensWout wants to merge 4 commits into
pingdotgg:mainfrom
StiensWout:wf/find-ca2bf8dc1b80470e82a376b3
Open

StiensWout wants to merge 4 commits into
pingdotgg:mainfrom
StiensWout:wf/find-ca2bf8dc1b80470e82a376b3

Conversation

@StiensWout

Copy link
Copy Markdown
Contributor

Prompts submitted during a pull request checkout stay in the composer if checkout fails. A waiting prompt sends only after checkout is applied to the draft. If a newer checkout takes over the same draft, the superseded handoff clears its loading state without adding its task or reporting success.

Related: #27578, #40350, #40397, #36775, #42828, #43381, #21479

Reproduction on main

Commit 314f59d1e7 (main), in the running web app:

  1. Open the web app on a project whose new threads use that project's own folder, with a model already chosen that can reply.
  2. Open one of that project's pull requests and choose Check out in a separate worktree.
  3. When the new draft appears and the app says it is still preparing the pull request checkout, type a prompt into the composer.
  4. Press Enter to send the prompt before the checkout finishes.
  5. Before the checkout finishes, block access to the git host so the checkout cannot fetch the pull request, while leaving the app running.

An error says the pull request checkout could not be prepared. The composer is cleared, the prompt shows up as a sent message, and the agent starts working in the project's current folder on the branch that was already checked out there. Expected: The prompt stays in the composer after the checkout error, so you can retry the checkout or choose where to send it. The agent does not start in the project's current folder.

The cause is at apps/web/src/components/chat/useComposerSend.ts:1841. Ran pnpm scenarios:prove scripts/scenarios/failed-pr-checkout-keeps-unsent-prompt.e2e.ts --target web with the repro scenario added: it failed in 2 of 2 runs on a clean checkout, with ASSERTION_FAILED: expect.toContainText failed in the output.

Evidence

Environment: The web app in Chromium on Linux x64, a fresh checkout.

Proven: the repro fails at the test commit c14f707b87 and passes on the head 5988462787, both on main 9f96e0d9cb.

Before After
Commit c14f707b87 5988462787
Result ASSERTION_FAILED: expect.toContainText failed passed
failed checkout Before: failed checkout After: failed checkout
failure Before: failure

Before the fix, recorded:

https://pub-b182a4071edc4521829926b34990540b.r2.dev/files/c19ee124-bbbc-4681-a3d9-67e766bce2b1/before-recording.webm

After the fix, recorded:

https://pub-b182a4071edc4521829926b34990540b.r2.dev/files/b8421539-82ea-4aec-9d40-3263d3251b1b/after-recording.webm

Outside view: a person sees it in the running web app by following the steps under Reproduction on main.

Tests

  • c14f707b87 adds the failing test, alone, before the fix.
  • pnpm exec vp run check:changed 9f96e0d9cb52e5c0e1f408c43d81e7a35a80c15f passed on head.

Not in this change

  • The checkout regression fixture can race repository discovery because it adds origin after project registration. Fixing the fixture requires re-establishing the regression baseline with origin configured before registration and waiting for the browser to receive the matching repository identity.

Who did the work

  • Repro written by GPT 6.2 Sol, in Codex
  • Outside view by Grok 4.7, in Grok
  • Duplicate check judged by Claude Opus 5.5, in Claude Code
  • Written by GPT 6.2 Sol, in Codex
  • Trimmed by Claude Opus 5.5, in Claude Code
  • Reviewed by Claude Opus 5.5, in Claude Code, and by GPT 6.2 Sol, in Codex, and by Gemini 4 Neon, in Antigravity
  • Reproduction, checks and proof run by a program on base and head, not by an agent

Made in T3 Code by GPT 6.2 Sol, Claude Opus 5.5, Grok 4.7 and Gemini 4 Neon

StiensWout and others added 4 commits November 27, 2026 01:08
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
… a draft checkout

prepareDraftCheckout already returns false when its checkout is no longer current.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: GPT 6.2 Sol <codex@openai.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Nov 27, 2026
@coderabbitai

coderabbitai Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Checkout tracking now reports whether preparation succeeded and whether it remains current. Handoff processing handles cancelled and stale results, while composer sends stop when workspace-default refresh fails. Browser tests cover overlapping checkouts and prompt retention after checkout failure.

Changes: Draft Checkout Flow

Layer / File(s) Summary
Track checkout readiness and gate sends
apps/web/src/lib/draftWorkspaceDefaults.ts, apps/web/src/components/chat/useComposerSend.ts
Pending checkout tracking now stores a boolean result and returns a predicate for checking whether the checkout remains current. Composer sends stop when workspace-default refresh resolves to false.
Handle checkout outcomes
apps/web/src/components/pullRequest/usePullRequestActions.ts, apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
prepareDraftCheckout can return a cancelled result. Handoff state clears after preparation, and cancellation or stale results exit before success or failure updates.
Validate overlapping and failed checkouts
apps/web/src/components/pullRequest/usePullRequestActions.browser.test.tsx, scripts/scenarios/failed-pr-checkout-keeps-unsent-prompt.e2e.ts
Browser tests cover overlapping checkouts and verify that a failed checkout leaves the submitted prompt in the composer.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant startHandoff
  participant prepareDraftCheckout
  participant trackPendingDraftCheckout
  participant onSendWithRouting
  startHandoff->>prepareDraftCheckout: Prepare draft checkout
  prepareDraftCheckout->>trackPendingDraftCheckout: Track checkout readiness promise
  trackPendingDraftCheckout-->>prepareDraftCheckout: Return current-check predicate
  prepareDraftCheckout-->>startHandoff: Return prepared or cancelled result
  onSendWithRouting->>trackPendingDraftCheckout: Read pending workspace-default status
  trackPendingDraftCheckout-->>onSendWithRouting: Resolve readiness status
  onSendWithRouting->>onSendWithRouting: Stop sending if readiness is false
Loading

Suggested reviewers: juliusmarminge, yash-singh1

Merge Risk: Low · up to 59884

The fix keeps the submitted prompt in the composer when a pull request checkout fails or is superseded. The only remaining concern is that the new end-to-end scenario can occasionally time out because of a known race, which affects test reliability rather than users.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(web): keep prompts unsent when pull request checkout fails" matches the main change. The PR keeps a prompt in the composer when pull request checkout fails, and it sends a waiting promp…
Description check Passed The description follows the template. It has a Problem section (the prompt is sent in the project's current folder after a checkout error), a Change section (prompts stay in the composer, and supersed…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(web): keep prompts unsent when pull request checkout fails" matches the main change. The PR keeps a prompt in the composer when pull request checkout fails, and it sends a waiting prompt only after checkout applies to the draft. The title is conventional, specific, and under 72 characters.

Full details: Description check

Explanation

The description follows the template. It has a Problem section (the prompt is sent in the project's current folder after a checkout error), a Change section (prompts stay in the composer, and superseded handoffs clear loading state), a Scope section that links related issues and explains the bug, and a Verification section with a before/after test result and repro steps. It also names the models and tools used. The Scope section does not clearly state why the fix needs no issue, though the related issue links cover the bug. The Change section does not fully explain the refactor of the current-checkout check, which the commit summary mentions. The description is mostly complete.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9f96e0d and 5988462.

Files selected for processing: 6

  • apps/web/src/components/chat/useComposerSend.ts
  • apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
  • apps/web/src/components/pullRequest/usePullRequestActions.browser.test.tsx
  • apps/web/src/components/pullRequest/usePullRequestActions.ts
  • apps/web/src/lib/draftWorkspaceDefaults.ts
  • scripts/scenarios/failed-pr-checkout-keeps-unsent-prompt.e2e.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 27, 2026

This branch has not been deployed

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

Labels

size:L 100-499 changed lines (additions + deletions). takeover:in-progress A takeover lead is working on this PR vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants