Repository navigation
fix(native-chat): a Codex chat is Working only while Codex holds the send - #29922
Conversation
…send Working read 'a send still pending delivery', so any echo or idle signal that never arrived (a hook-blocked prompt, an answer naming no turn, idle before a timed-out send was written) kept the chat Working, Stop up, the queue frozen and /compact refused until the agent exited. Codex now reports which sends it still holds: unanswered, answered into a turn that has not ended, or answered into none while a status read after that answer says the thread runs. Replies and statuses are ordered as they are read, so a stale status cannot release a newer send. The host reads that set (plus the short window while it hands a send over) for Working, publishes a send the child stopped holding as in doubt on every page and frame so older clients agree, and republishes when the set changes with no row. The Codex idle latch and its release are removed.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
…at's work; run the held-sends test with the database runtime
…ecycle-codex-held # Conflicts: # src/main/native-chat/agent-session-wire/structured-agent-session-command-turn.ts # src/main/native-chat/agent-session-wire/structured-agent-session-delivery-loop.ts # src/main/native-chat/agent-session-wire/structured-agent-session-host-delivery.ts
|
A Codex chat could keep showing Working after Codex finished because Orca counted a missing message confirmation as unfinished execution. This change reads the work Codex still owns separately from delivery, so the chat becomes idle, queued work can proceed and The review found and fixed three problems: unloading an idle thread could restore Working, phone updates could exceed the subscription frame limit, and command handover could report Merged-head verification, 2026-10-17: Merged-head real Electron QA used qa-gate ticket 189 on macOS, with signed-in Codex and Claude. Codex drove all six cases after Grok stalled during setup. This was a PR-arm-only recheck against round two's PR results, with no new main arm: a minute-long Codex turn, normal compact and a follow-up, immediate compact, active-shell Stop then compact, a Claude turn, and final status all matched. For immediate compact, Enter was requested 114 ms after observed Done and the keypress finished at 214 ms; compact cleared its composer and completed without an error or unconfirmed-command notice. Stop removed the control promptly, background monitoring settled between 119.503–119.702 seconds, and subsequent compact succeeded. Every chat finished Done or idle. The earlier limits below remain: no live no-echo reproduction, queue/card Steer, indexed native-session-list status or phone proof. The notification-permission warning recurred on the PR and remains unattributed against main. The new fixture has no setup script, so its “Add a setup script” card is a fixture difference; setup was not retested. All owned rig/driver processes and listeners were verified stopped and ticket 189 was released. Protected hooks/settings/Orca files and authentication metadata remained unchanged; the same shared-machine Codex/Claude bookkeeping categories changed with no established writer. Earlier full comparison on
All rig/driver processes and allocated-port listeners were verified stopped. Hooks, Claude settings and Orca settings hashes stayed unchanged; Codex authentication metadata stayed unchanged. Codex configuration and Claude bookkeeping changed on the shared machine, with coordinator approval and no established writer; this is not a claim that every real-home file was unchanged. Deferred concerns: repeated reconstruction of the bounded ownership set has no measured latency impact; the existing restart marker can select an older send when child work remains, with no wrong continuation established. Individually oversized legacy submission records and aggregate phone backpressure remain unverified residual cases. No new stored field or protocol operation was added. The intentional host ownership window supports multiple clients and SSH; other providers' ownership and the existing Codex correlation cap remain temporary differences described in the PR. For Brennan's review Merged-head recheck:
Earlier main-versus-PR comparison (before the main merge): Main and PR whole-window comparisons follow. Different reply wording, transcript lengths and sampled tool phases are not controlled; the rapid compact boundary was measured on the PR only. Three places where judgment matters: the execution-ownership rule, the short host handover window and complete bounded updates to older clients. The three judgment points are the ownership rule, command handover, and bounded updates. |
…ecycle-codex-held Takes main's cross-version harness fix (#30000) in place of this branch's copy.
























ELI5
A Codex chat could stay on "Working" forever after Codex had finished: Stop stayed up, every session list said Working, queued messages never sent, and
/compactwas refused. It only cleared when the Codex process exited. This happened whenever Orca was waiting for a signal about a message that never came. Now "Working" means only what it should: Codex is running a turn, or Codex still has a message it hasn't finished with.What Changed
Before (what you saw): you send a message to a Codex chat. A hook refuses it (or Codex answers without naming a turn, or the send times out and Codex goes idle before Orca records that). Codex is done, but the chat keeps showing Working, the Stop button stays, the queue never drains, and
/compactsays the chat is busy. Restarting the agent was the only way out. Orca has fixed this one case at a time at least nine times since September.After: the chat stops showing Working as soon as Codex no longer holds the message, on the desktop, the phone and every session list, including older desktop and phone versions. Nothing about delivery changes: a message whose fate is unknown still reads as an ordinary sent message, and Codex's own echo still marks it delivered if it comes later. Nothing is resent.
One case changes visibly beyond the stuck state: if Orca's request to start a Codex turn times out while Codex is idle, the chat no longer stays on Working with a Stop button that ends the agent. It reads as not working, with the message shown as sent (Orca can't confirm it, as today). If Codex does start that turn later, the chat shows Working again and Stop works as usual.
Mechanism. The root cause was one rule: a chat was Working while any message was still "pending delivery", so every missed or late event kept it Working. This PR separates "is the agent working?" from "was the message delivered?":
heldSends): ones Codex hasn't answered yet, ones it answered into a turn that hasn't ended, and ones it answered into no turn while a status Codex reported after that answer says the thread is running. A turn that ends releases its messages whether or not their echo came.onReplystamp on the request), so a status Codex sent before it answered can never release a newer message.unknown,recovered) on every page and frame, so older clients that compute Working themselves agree, and the host republishes whenever the held set changes without a journal row.Why
This is the first step of a planned refactor of how native chats track sends, which has had the same class of stuck-Working bug fixed repeatedly. The common pattern in other chat clients keeps "the agent is running" (driven by turn start and end) separate from "this input was confirmed" (an exact receipt), and never lets a missing confirmation keep the agent running. This PR adopts that separation for Codex. Claude, Pi and ACP agents keep today's rule until the next step, which moves them onto the same
heldSendsquestion (labelled temporary below).Alternatives considered:
thread/read) when in doubt: rejected. Codex only marks a thread running once it handles the turn's start, so a read in the normal window between Codex's answer and the turn starting reads idle and would release a message Codex is about to run.Linked Issue
Tracked in #28630 (closed in favour of this series).
Visual Proof
Merged-head verification, 2026-10-17:
5c53b0aef9408198c87ca08d1bfe9e0ee1268408is the previously reviewedcaa4616f33fdb973b1cd93ccad1b1c9474837bc4plus a clean merge of main98d8257b02d52a6d93e3bde4eebed2a4308d828e. Narrow merge review found no P0/P1: changes within this PR's prior files are main's queue-publication projection, existing-method typing and main's compatibility-test version. The queue projection runs before phone frame sizing and tracks canonical queue identity independently; it does not change execution ownership, the command handover window, or bounded submission restatements. The full PR workflow, including PR checks passed, is green on this exact head; GitHub reports CLEAN, out of draft and no unresolved threads.Merged-head real Electron QA used qa-gate ticket 189 on macOS, with signed-in Codex and Claude. Codex drove all six cases after Grok stalled during setup. This was a PR-arm-only recheck against round two's PR results, with no new main arm: a minute-long Codex turn, normal compact and a follow-up, immediate compact, active-shell Stop then compact, a Claude turn, and final status all matched. For immediate compact, Enter was requested 114 ms after observed Done and the keypress finished at 214 ms; compact cleared its composer and completed without an error or unconfirmed-command notice. Stop removed the control promptly, background monitoring settled between 119.503–119.702 seconds, and subsequent compact succeeded. Every chat finished Done or idle.
The earlier limits below remain: no live no-echo reproduction, queue/card Steer, indexed native-session-list status or phone proof. The notification-permission warning recurred on the PR and remains unattributed against main. The new fixture has no setup script, so its “Add a setup script” card is a fixture difference; setup was not retested. All owned rig/driver processes and listeners were verified stopped and ticket 189 was released. Protected hooks/settings/Orca files and authentication metadata remained unchanged; the same shared-machine Codex/Claude bookkeeping categories changed with no established writer.
Earlier main-versus-PR comparison, before the main merge:
Real Electron QA on the final head and frozen main used signed-in Codex and Claude with Grok on qa-gate ticket 140 (macOS). Ordinary turns, Enter steering, active-tool Stop, compact including the observed 198ms completion boundary, setup/default tabs and Claude succeeded. The original no-echo failure was not reproduced live; queue controls were absent, indexed history status was not proven, and phone was not run. Main also compacted successfully. A notification-permission warning seen on the PR remains unattributed after an inconclusive main recheck. These are qualified regression results, not live proof of the original failure.
Testing
structured-agent-session-codex-held-sends.test.ts(new): through the real host, journal and Codex adapter with a fake Codex child. A turn completes without echoing the prompt: the chat stops Working with no delivery row written, and a client that was already subscribed is sent the message as undecided (so an older client also stops reading Working). A normal send stays Working until its turn ends, and its echo still marks it delivered.codex-structured-dispatch-echo.test.ts: the hold rule. Held from the write until the turn it was answered into ends, echo or not; a message answered into no turn is held only while a status read after its answer says running; a status read before the answer decides nothing.Removed the tests of the deleted idle latch.
CI runs lint, typecheck and the full test suite.
Real Electron QA completed on the final head (coverage and limits above)
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
workingfield.Checklist