You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(native-chat): Skip and agent messages agree with the Codex question card - #42946
When Codex asks you a question in a chat without stopping its work, the chat shows "waiting on you" until you answer. Two things were wrong with that. Pressing Skip on the question only hid it on the screen you pressed it on, so the chat kept saying "waiting". And a message from another agent (a coordinator) cleared "waiting" even though the question was still open. Now Skip counts everywhere, and only your own answer or your Skip ends the wait.
Skip on a Codex async question card hid the card on that one screen. The tab and sidebar dot, worktree ps and the phone kept showing "waiting". The card came back after a reload, and the phone still showed it.
A message another agent sent to the chat turned the dot green ("done") while the card stayed open.
After:
Skip is saved on the chat's host. The dot goes to done on every device, the card is hidden on desktop and phone, and it stays hidden after a reload or a restart.
Another agent's message no longer touches the wait. The dot and the card agree.
Mechanism:
Skip is a host fact.agentSession.skipAsyncQuestions {sessionId, itemId} is modelled on agentSession.cancelUsageLimitContinue.
It saves asyncQuestionsSkippedThrough (the newest question row the card showed) on the chat's record and republishes status.
The status summary carries that row. The host folds it into awaitsAnswer: the chat waits only while the newest open question is not the skipped one.
Desktop (use-native-chat-async-questions.ts) and phone (use-mobile-native-chat-prompts.ts) hide every question up to that row, using the same shared helper (asyncQuestionsAfterSkip).
The saved row only ever moves forward, by journal position. A device that hasn't loaded the newest question can't bring it back.
Gated by agent-session.skip-async-questions.v1, and allowed from phones. Older hosts keep today's hide on that screen only.
The read stays bounded. It was cheap before only because it stopped at the first agent message. To keep it cheap:
Two partial indexes are created in the journal SQL worker on open, with no user_version bump: rows naming request_user_input_async, and the person's own messages ($.body.from absent, json_valid-guarded).
The read takes the newest question from the first index and stops at once when there is none.
Otherwise it walks only the person's messages after that question, oldest first, from the second index.
Why
Codex keeps an unanswered async question only in its own TUI, and Skip there just drops it locally. In Orca the host plays that role for every device, so the Skip has to live on the host. A per-screen hide can't make the dot and the card agree.
Follow-ups listed in the Risk section of #42459 (Fixes#42008 there). This PR has no issue of its own.
Visual Proof
Real Codex 0.167.2 app-server (temp HOME/CODEX_HOME) talking to a local fake model that calls request_user_input_async. Hidden desktop build, same profile, A/B by rebuilding from main.
Another agent's message while the question is open
Before (main): card open, dot done (green)
After: card open, dot waiting
After pressing Skip
Before (main): card gone, dot still waiting
After: card gone, dot done
Testing
Live, desktop build from this branch (worktree ps via the CLI against the same runtime):
Question asked: waiting, card open.
An orchestration message from another agent is delivered and Codex answers it: still waiting, card still open. On main this read done.
Skip on the desktop card: done at once. After a page reload the card stays gone. After an app restart the chat is still done. On main the restarted chat was back to waiting.
Phone route: a second question was skipped by calling agentSession.skipAsyncQuestions over RPC, as the phone does. The desktop card disappeared live, and ps went to done.
Both indexes exist in the chat database after open, and user_version stays 2.
Per-commit status read (readJournalSqlStatusState, ms per read, 200 reads, seeded journals):
Chat
main
this PR
short, 20 exchanges, question open
0.54
0.47
coordinator-driven, 1,500 agent messages / 3,000 replies, no question
2.74
1.81
same, question asked early and still open
2.42 (wrongly done)
1.73
same, question asked early and answered early
2.86
1.80
One-time index build: on a seeded 3.31 GB journal (1.9M rows, real-shaped payloads), building both indexes took 3.2 s. This happens once, in the journal worker on first open after upgrade, so chats load about that much later once. The main thread doesn't block. Later opens take 0.03 ms. EXPLAIN QUERY PLAN shows both queries searching their index.
Automated:
journal-domain-status-reads.test.ts: the question stays open across another agent's message and closes on the person's.
New structured-agent-session-skip-async-questions.test.ts: Skip on a chat the host has closed saves, and an unknown row is ignored. It hangs on the round-1 version of this branch.
Ran every test file that depends on the changed modules (140 files, plus 5 mobile files), mobile typecheck and typecheck:tests, and pnpm check:changed. macOS only; the change is shared and main-process code with no platform branches.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Risk
Riskiest part: the two new indexes.
They're added without a version bump, so an older Orca opens the database normally. SQLite maintains both indexes on that build's writes too.
The person-message index runs a json_valid-guarded json_extract on each prompt row's insert, so a malformed row can't fail a write.
First open after upgrade spends about 1 s per GB of journal building them, in the worker.
Behaviour changes:
A skipped question stays skipped after reload and restart. Before, the card came back.
asyncQuestionsSkippedThrough is optional on the record and the summary. Older clients ignore it. Older hosts lack the capability, so newer clients keep the hide on that screen only.
Known limits (follow-ups):
If two journal rows carry the same async callId, the host can name a different open row than the card, so Skip may leave the host waiting.
While a queued answer that quotes an already-skipped question is still pending delivery, an older question can show again until that answer lands.
Back out: a plain revert. The indexes stay in existing databases, harmlessly.
Level: Medium
AI Disclosure
Review
Two review rounds (Codex and Claude).
Round 1:
The person-message walk still parsed agent rows, which led to the second index.
Skip saved a question a queued answer had hidden, so it now saves the newest question shown.
A lagging device could move Skip backwards, so it now only moves forward.
The saved Skip was ignored while the phone reconnected.
Round 2: found that Skip on a chat the host had idle-closed deadlocked that chat's task queue, because the open and the write queued on the same key. The chat now opens before the write takes its slot, and the new host test covers it.
Rejected: "worker chats stay waiting while working" is the intended card rule, see Risk. The two edge cases above are left as follow-ups.
CodeRabbit: Skip from a phone now also needs the paired desktop to relay the method (the useRouteRelaysCapability gate rewind and goal already use). A failed save now shows only its own card again.
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Remote/SSH: the record, the indexes and the status read all live on the executing host. Remote desktops and paired phones get the same row and call the same method.
Unrelated moves, to stay under the file line limits:AgentSessionForkedFrom moved to its own file and is re-exported. A dead agentDefinitions host member was removed.
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
The change identifies open async questions by journal row and replaces the prior boolean status with a row identifier. The host can save a skipped-through row and publish it in session status. Renderer and mobile prompts use that position to filter questions, and dismissal attempts to save the newest displayed row. If the save fails, the prompts restore their locally hidden occurrences.
Severity of issue fixed: Medium
Merge Risk: Low · up to 210c8
Skip can sometimes fail to stick or briefly reappear when a save is rejected or the host does not support it. The impact is limited to the prompt UI and is recoverable. It is mergeable with these known follow-ups.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the two behaviors the PR changes: Skip and agent-message handling for the Codex async question card. The changeset adds a saved host-side skip position, a skip RPC, and a status read t…
Description check
The description follows the repository template. It includes ELI5, What Changed (before/after and mechanism), Why (alternatives considered), Linked Issue, Visual Proof with before/after images, Testin…
Linked Issues check
The only directly linked issue, #42008, is closed and completed. It supplies historical context only. No active directly linked target remains, so no linked-issue coding requirements apply. The PR des…
Out of Scope Changes check
No active linked-issue requirements exist. The scope is therefore the PR's stated purpose: Skip on a Codex async question persists on the chat host, and the status read follows the person-message rule…
Full details: Title check
Explanation
The title names the two behaviors the PR changes: Skip and agent-message handling for the Codex async question card. The changeset adds a saved host-side skip position, a skip RPC, and a status read that ignores agent messages, so the title matches the main change. It is a conventional-commit title of 76 characters, which is within a reasonable length. It does not name the host-side persistence or the new indexes, but it does not need to cover every detail.
Full details: Description check
Explanation
The description follows the repository template. It includes ELI5, What Changed (before/after and mechanism), Why (alternatives considered), Linked Issue, Visual Proof with before/after images, Testing with checkboxes, Risk with a level, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. The Linked Issue section has no issue of its own. It cites #42459 as the predecessor, and the template asks for a linked issue for outside contributors. The Risk section is detailed and includes a back-out plan. The AI Disclosure section is empty, and the final checklist item for pnpm lint, typecheck, test, and build is unchecked. These are minor gaps and do not make the description largely incomplete.
Full details: Linked Issues check
Explanation
The only directly linked issue, #42008, is closed and completed. It supplies historical context only. No active directly linked target remains, so no linked-issue coding requirements apply. The PR description cites follow-ups to #42459 (which fixed #42008 there). That issue is background only and is not assessed here.
Full details: Out of Scope Changes check
Explanation
No active linked-issue requirements exist. The scope is therefore the PR's stated purpose: Skip on a Codex async question persists on the chat host, and the status read follows the person-message rule from #35758. The whole-PR summary maps the changes to that purpose: the agentSession.skipAsyncQuestions RPC and capability gate; the asyncQuestionsSkippedThrough record field and status summary; desktop and phone Skip wiring with the shared asyncQuestionsAfterSkip helper; the bounded status read (readJournalSqlOpenAsyncQuestion) and its two partial indexes; the turn-completion feed change that uses the new awaits-answer rule; and the tests. The PR discloses two housekeeping moves: AgentSessionForkedFrom moved to its own file and is re-exported, and the unused agentDefinitions host member was removed. Both occur in files this change already edits, and both are small. The generated file src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by the ignored-file rule. Its contents were not inspected. This does not affect the verdict because the file is generated registry output and the RPC method it would list is in the reviewed sources. This assessment relies on the whole-PR summary. No focused code inspection was performed for this incremental review.
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Roll back only the occurrences that the rejected Skip hid.
forgetAsync(scopeKey) removes every hidden occurrence in the scope. If an earlier Skip save rejects while a newer Skip is still pending, the newer question reappears until its own save settles. Its occurrence IDs were dropped with the rejected request.
Remove only the IDs that the failed Skip added, for example through an ID-aware rollback in the store. Keep the scope-wide clear for the layout-effect cleanup.
…uestion card
Skip on a Codex async question card now saves the skipped row on the chat's host
record (agentSession.skipAsyncQuestions, modelled on cancelUsageLimitContinue), so
the status, the desktop card and the phone card all honour it. The host status read
no longer ends at another agent's message, matching the card's rule from #35758;
two partial indexes, created without a schema version bump, keep that read bounded.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Scope the save rollback to its own dismissal.
When a save fails, the rollback restores the IDs it hid. It does not check whether a later dismissal in the same scope hid the same IDs. If the scope remounts and hides an ID again while the first save is pending, the first rejection can restore that ID while the second save is still pending. The rollback does not check owner or generation, so it cannot tell the two dismissals apart.
Give each dismissal a token, and make the rollback remove IDs only while that token is still current. Alternatively, skip the restore when the owner has changed since the dismissal started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When Codex asks you a question in a chat without stopping its work, the chat shows "waiting on you" until you answer. Two things were wrong with that. Pressing Skip on the question only hid it on the screen you pressed it on, so the chat kept saying "waiting". And a message from another agent (a coordinator) cleared "waiting" even though the question was still open. Now Skip counts everywhere, and only your own answer or your Skip ends the wait.
What Changed
Follow-ups to #42459.
Before:
worktree psand the phone kept showing "waiting". The card came back after a reload, and the phone still showed it.After:
Mechanism:
agentSession.skipAsyncQuestions {sessionId, itemId}is modelled onagentSession.cancelUsageLimitContinue.asyncQuestionsSkippedThrough(the newest question row the card showed) on the chat's record and republishes status.awaitsAnswer: the chat waits only while the newest open question is not the skipped one.use-native-chat-async-questions.ts) and phone (use-mobile-native-chat-prompts.ts) hide every question up to that row, using the same shared helper (asyncQuestionsAfterSkip).agent-session.skip-async-questions.v1, and allowed from phones. Older hosts keep today's hide on that screen only.isHumanSendrule @brennanb2025 set for the card in Keep async question controls available after agent notices #35758. The old agent-message cut-off (endsStructuredAgentSessionAsyncQuestionRead), which CodeRabbit flagged on fix(native-chat): show a Codex chat with an open async question as waiting on you #42459, is gone.user_versionbump: rows namingrequest_user_input_async, and the person's own messages ($.body.fromabsent,json_valid-guarded).Why
Linked Issue
Follow-ups listed in the Risk section of #42459 (Fixes #42008 there). This PR has no issue of its own.
Visual Proof
Real Codex 0.167.2 app-server (temp
HOME/CODEX_HOME) talking to a local fake model that callsrequest_user_input_async. Hidden desktop build, same profile, A/B by rebuilding from main.Another agent's message while the question is open
After pressing Skip
Testing
Live, desktop build from this branch (
worktree psvia the CLI against the same runtime):waiting, card open.waiting, card still open. On main this readdone.doneat once. After a page reload the card stays gone. After an app restart the chat is stilldone. On main the restarted chat was back towaiting.agentSession.skipAsyncQuestionsover RPC, as the phone does. The desktop card disappeared live, andpswent todone.user_versionstays2.Per-commit status read (
readJournalSqlStatusState, ms per read, 200 reads, seeded journals):done)One-time index build: on a seeded 3.31 GB journal (1.9M rows, real-shaped payloads), building both indexes took 3.2 s. This happens once, in the journal worker on first open after upgrade, so chats load about that much later once. The main thread doesn't block. Later opens take 0.03 ms.
EXPLAIN QUERY PLANshows both queries searching their index.Automated:
journal-domain-status-reads.test.ts: the question stays open across another agent's message and closes on the person's.New
structured-agent-session-skip-async-questions.test.ts: Skip on a chat the host has closed saves, and an unknown row is ignored. It hangs on the round-1 version of this branch.Ran every test file that depends on the changed modules (140 files, plus 5 mobile files), mobile
typecheckandtypecheck:tests, andpnpm check:changed. macOS only; the change is shared and main-process code with no platform branches.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Every added test fails without this change and avoids the test anti-patterns
Risk
Riskiest part: the two new indexes.
json_valid-guardedjson_extracton each prompt row's insert, so a malformed row can't fail a write.Behaviour changes:
Mixed versions:
asyncQuestionsSkippedThroughis optional on the record and the summary. Older clients ignore it. Older hosts lack the capability, so newer clients keep the hide on that screen only.Known limits (follow-ups):
callId, the host can name a different open row than the card, so Skip may leave the host waiting.Back out: a plain revert. The indexes stay in existing databases, harmlessly.
Level: Medium
AI Disclosure
Review
Two review rounds (Codex and Claude).
useRouteRelaysCapabilitygate rewind and goal already use). A failed save now shows only its own card again.Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
AgentSessionForkedFrommoved to its own file and is re-exported. A deadagentDefinitionshost member was removed.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)