Repository navigation
fix(native-chat): a message sent after Stop runs ahead of the paused cards - #28652
brennanb2025 wants to merge 4 commits into
Conversation
…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.
|
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 differencesThe 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.
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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
|
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. |






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
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, andstructured-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
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