Skip to content

Keep the queue when a fresh turn fails preflight (#924) - #1652

Merged
currentbits merged 2 commits into
mainfrom
coder/manual-run-preflight-failures-permanentl-1bb91e
Oct 16, 2026
Merged

currentbits merged 2 commits into
mainfrom
coder/manual-run-preflight-failures-permanentl-1bb91e

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Fixes #924.

Problem

startRun took the idle queue (takeQueued) and folded it into a new user turn before the budget gate, the provider-binary check and worktree setup. When any of those threw, the queued text and attachments were gone, and they were gone on disk too.

Fix (electron/runner.js)

  • startRun is now a thin wrapper around the old body (startRunFolded). The body records the queue it took in fold.taken. On any throw before the turn is accepted, the wrapper calls the existing restoreQueuedHead, which puts the queue back in front of anything queued in the meantime.
  • The turn counts as accepted, and fold.taken is cleared, at three points: the orchestrator fork launches, the turn is parked in the run queue (enqueueRun holds the combined prompt), or the user message is about to be appended. This keeps delivery to exactly once.
  • A worktree setup failure now records only the turn's own prompt in the failed user row. Otherwise Retry plus the restored queue would deliver the queued text twice.

Tests (electron/test/queued-drain.test.js, real Store + createRunner)

  • Budget rejection, missing provider binary, worktree setup failure: the queue is preserved with its attachments, and still there after saveNow and a fresh Store load.
  • A follow-up queued during a failing start ends up behind the restored queue.
  • An accepted turn consumes the queue exactly once, and it stays consumed after a reload.

Cases 1–4 fail on the unfixed runner. Full electron suite in a CI-like env (CODER_* unset, minimal PATH): 4745 pass, 2 fail. Both failures are in provider-usage.test.js; that file passes 22/22 when run alone, so they look like timing failures under load.

🤖 Generated with Claude Code

startRun folded the idle queue into a new user turn before the budget,
provider and worktree gates, so a rejected start dropped the queued text
and attachments on disk. Restore the taken queue (in front of anything
queued since) on any throw before the turn is accepted, and record only
the turn's own prompt on a worktree failure so Retry cannot deliver the
queue twice.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-16T08:00:02.651150Z d86bd50 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@currentbits
currentbits merged commit 3363f42 into main Oct 16, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Manual run preflight failures permanently discard an existing queued prompt

1 participant