Skip to content

fix(native-chat): a message sent after Stop runs ahead of the paused cards - #28652

Closed
brennanb2025 wants to merge 4 commits into
mainfrom
brennanb2025/queue-stop-passover
Closed

brennanb2025 wants to merge 4 commits into
mainfrom
brennanb2025/queue-stop-passover

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

After Stop, a new message could get stuck behind the older messages you had paused. Now that new message runs when the agent is free, and the older messages follow it in order once its turn is accepted.

What Changed

With A and B queued, Codex can refuse a Stop before reporting that its old turn ended. A message C sent during that interval becomes another queued card. The old queue selector stopped at paused A, stranding C until you pressed Resume. The selector now passes cards held by the queue's derived pause, so C runs first; its accepted turn releases A and B. The pause row is hidden while such a later card can run. Returned cards and cards being edited remain barriers.

The same approved rule applies to cards kept after reopening or clearing a conversation: a newer queued instruction can run past those held cards, but nothing old runs automatically merely because a chat reopened or Stop finished. Only an accepted later turn or Resume releases them. Ordinary successful Stops already run C, A, B and retain that behavior.

Admission, automatic delivery, and the final transactional claim share the same selector. Main's current-work checks, queued-image support, in-place editing and edit leases are preserved. This changes no saved format, wire field or capability advertisement; user-message queueing remains switched off pending its separate rollout.

Why

Whether your new instruction runs should not depend on whether the old turn's completion arrives a moment before or after it. Reusing the existing pause membership and selector gives admission and delivery the same answer, without another saved flag or Stop-only special case.

Intended differences from the common pattern: failed hand-offs remain barriers until the person acts on them; pauses continue to be derived from existing journal positions rather than stored per card; a newer instruction can pass cards held after a reopen or clear as well as Stop. Existing host authority and mixed-version behavior are preserved: new hosts publish the same fields with the corrected order, older hosts retain their current behavior. The rule applies on local, SSH and WSL execution hosts, and to folder workspaces as well as worktrees.

Linked Issue

Maintainer PR; no separate issue.

Visual Proof

Paired main-versus-branch screenshots and review result cover real signed-in Codex on the M4Air at cd4674f versus integrated main 6fd2172. Ordinary successful Stop/C, Resume, editing and reopened held-card flows passed without regression. The refusal-specific race was not reproduced with a real agent; it is covered by the adapter-level regression test. The comment states the remaining rendered gaps and setup disclosures. Earlier stand-in captures are historical reproduction evidence only.

Testing

  • Automated regression tests cover Codex refusing Stop before delayed turn completion, C/A/B order, reopened cards, pause publication, Resume and transactional selection.
  • Main-versus-branch real-agent rendered QA on the M4Air, with the refusal-specific limitation stated.

After integration with main, 199 tests passed across six named files: structured-agent-session-codex-stop-row.test.ts, structured-agent-session-queued-card-holds.test.ts, journal-queued-message-contracts.test.ts (which now registers the moved pause tests), queued-message-context-clear.test.ts, structured-agent-session-queued-pause-lift.test.ts, and structured-agent-session-queued-stop-row.test.ts. Full CI passed on cd4674f, including static analysis/typecheck, five Node test shards, wire compatibility, managed-SSH end-to-end tests and both packaging jobs. One artifact-upload infrastructure retry passed; no lint or typecheck was run on this Mac.

Review

Three review rounds completed, including a narrow integration review and bounded verification of the edit-held pause display. The mandatory merge pre-commit hook also formatted 34 inherited files; each was verified to match formatter output exactly, with no additional semantic change. Formatting pushed two inherited files over the line limit; a follow-up shortens a local callback binding and states the existing no-argument restoration method signature directly, without changing runtime behavior. One deferred performance observation remains: deriving the displayed pause adds a queue traversal while a pause exists, with no measured lag. No new I/O, processes or timers were added.

Agent skill upstream boundary

  • Not applicable; this change copies no upstream skill code or resources.

Notes

The change runs on the execution host without platform branches. Remote and older clients receive existing publication fields. Rendered QA used macOS and real Codex in a folder workspace. Other agents/platforms, SSH UI, setup/default tabs, returned-card rendering and the refused-Stop race were not exercised; the status comment records those limits.

Checklist

  • Focused on queue ordering after a pause.
  • User-visible before/after and the mechanism are explained.
  • Paired main/branch screenshots attached in the status comment.
  • Source review covers correctness, performance and compatibility.
  • Cross-platform, SSH and folder-workspace impact considered.
  • Full workflow green on cd4674f.

…aused cards

The queue's selector stopped at the first card a pause held, so a message
typed during Stopping waited behind the paused cards, while the same message
sent a second later ran at once. Held cards are now passed over: a returned
card or one being edited still stops the scan, and only an accepted turn or a
Resume releases the held ones, which then follow in order. The paused row is
published only when no card would go past it, so it no longer flashes while
Stopping.
@brennanb2025

brennanb2025 commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

When Codex refuses Stop before reporting its old turn's completion, a newer queued message C can get stuck behind paused A and B. The shared selector now passes older cards held by the queue pause: C runs first, and its accepted turn releases A then B. Returned cards and cards being edited remain barriers. The same approved rule applies after reopening or clearing a chat. Queueing remains unadvertised pending its separate rollout.

Three review rounds are complete, including the narrow main integration review. Its edit-held pause-display mismatch was fixed and verified once: the pause stays visible when an edit blocks delivery. No open correctness finding remains. PERF-01 remains P3 deferred: publishing updates adds queue traversals before subscriber deduplication, with no measured lag; measure or consolidate this before broad activation.

At cd4674f, 199 tests passed across six named files through the queue, and another 72 named tests passed on the QA machine. Full CI passed, including static analysis/typecheck, five Node shards, wire compatibility, both managed-SSH end-to-end jobs and packaging. One artifact-upload infrastructure retry passed. The mandatory pre-commit hook formatted 34 inherited main files; every file matched formatter output exactly. Two resulting line-limit failures were corrected without runtime behavior changes.

Real Electron QA compared integrated main 6fd2172 with this head on the M4Air, using signed-in Codex 0.163.0 and hidden CDP. Comparable greeting, ordinary Stop/C, Stop/Resume, live editing and reopened-held-card flows passed without regression. Successful Stop made C a direct submission, then C,A,B ran on both builds. Reopening sent nothing old automatically; accepting NEW and queueing C produced NEW,A,B,C on both.

The differentiating refusal race was not reproduced with a real agent; it is covered by the Codex adapter-level regression test. These screenshots show normal-path regression checks, not rendered proof of that race. Returned-card rendering and the stopped/edit-held-A plus newer-C combination remain unit-test coverage. A supplemental same-batch UI attempt is not comparable because its branch driver selected a hidden textbox; no product failure or pass is inferred from it. Other agents/platforms, SSH UI, setup/default tabs, native focus and frames below the 200ms sampler were not exercised.

QA setup and observed differences

The same temporary queue capability and fixed hook-port patch was used on both builds and removed afterward. Orca used an isolated profile; an approved wrapper gave only the real Codex process its normal login home, with hooks enabled and no credentials copied. One invalid setup launch was stopped before any qualifying flow. An isolated-home pnpm bootstrap spawned roughly 2,000 owned processes; they were verified and stopped individually by PID, memory recovered, and the named tests then passed through the direct runner. All rig processes stopped and the tracked source diff is clean.

Hooks and Claude settings hashes stayed unchanged; credential contents were never read and the auth file's metadata stayed unchanged. Codex config and Claude's state-file hashes changed; project-trust entries and concurrent agents are expected explanations, but hashes alone cannot prove attribution. Known baseline notices and the shell activity strip after Stop remained. Retained fixture history explains seven main chats versus fourteen branch chats; elapsed times, generated titles and rotating tips differed.

For Brennan's review

All six whole-window screenshots below were personally inspected. The first two rows exercise successful Stop; the third shows a new accepted turn and C queued after reopen.

State Main 6fd2172 Branch cd4674f
C running while A/B wait Main: C running while A/B wait Branch: C running while A/B wait
C, then A, then B completed Main: C, then A, then B completed Branch: C, then A, then B completed
After reopen: NEW running, A/B/C queued Main: After reopen: NEW running, A/B/C queued Branch: After reopen: NEW running, A/B/C queued

Two places for behavior review: the selection rule intentionally permits a newer card to pass any pause-held cards, including after reopen/clear; pause visibility uses the same edit barriers. No saved format or wire operation changed.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 18, 2026 08:21
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 710ff1b0-276d-45e9-830c-940e7227a9cc
📥 Commits

Reviewing files that changed from the base of the PR and between d950c53 and cd4674f.

📒 Files selected for processing: 2
  • src/main/native-chat/transcript-opencode-sqlite-query.ts
  • src/main/runtime/session-tabs/structured-session-create-support.ts
🚧 Files skipped from review as they are similar to previous changes: 1
  • src/main/native-chat/transcript-opencode-sqlite-query.ts

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

📝 Walkthrough

Queue selection now passes over cards held by a pause and considers edit-held cards when determining the next sendable card and whether to publish a resumable pause. Tests cover queue ordering after refused interrupts and the handling of Stop-held cards. Other changes reformat code, comments, and tests across scan progress, transcript handling, session adoption, runtime, renderer, and shared code; their described behavior remains unchanged.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to cd467

Newer messages can proceed past pause-held cards while returned and edit-held cards remain barriers. The inspected behavior presents minimal merge risk.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 33 functions across 43 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
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.
Title check Passed The title clearly and concisely describes the main change: a message sent after Stop can run before cards held by the pause.
Description check Passed The description covers the required sections, including the change, rationale, testing, visual proof, review, and checklist. It identifies the PR as a maintainer contribution, which matches the templa…
Full details: Description check

Explanation

The description covers the required sections, including the change, rationale, testing, visual proof, review, and checklist. It identifies the PR as a maintainer contribution, which matches the template’s issue guidance.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Closing without merging. A direct check against the real Codex app server found that the ordering this PR handles does not occur: in 32 timed Stop attempts, every time Codex answered "no active turn to interrupt" it had already sent the turn's completion first, so Orca has settled the turn before the refusal arrives. The current behaviour (a message sent while a Stop is landing joins the end of the queue and waits with the paused cards until Resume or the next accepted turn) stays, which is the intended rule.

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.

1 participant