Skip to content

fix(native-chat): show a Codex chat with an open async question as waiting on you - #42459

Merged
AmoabaKelvin merged 1 commit into
mainfrom
chat-question-waiting-status
Nov 15, 2026
Merged

AmoabaKelvin merged 1 commit into
mainfrom
chat-question-waiting-status

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

When Codex asks you a question in chat but keeps going (or finishes its turn while still waiting for your reply), the chat's dot turned green ("done") even though the question card was still sitting above the composer. Now the chat shows "waiting for input" until you answer, on desktop and on the phone.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​42 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​42
Prod 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​127 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​118

What Changed

Before: a Codex chat (structured chat, Codex app-server) that asked with request_user_input_async showed working, then done (green) once the turn ended, while the "Which color?" card stayed open. The sidebar, tab, worktree ps and the phone all read that one host status row.

After: the row shows waiting (the same state Codex's async question already gets in terminal-backed chats since #39087) from the moment the question lands until your next delivered message answers it. A blocking Plan-mode question already showed blocked and is unchanged.

Mechanism:

  • Codex's async question is journaled as a request_user_input_async call block on an assistant message (codexAsyncQuestionBlock), not as a pending question item, so the status projection never counted it.
  • New shared rule hasOpenStructuredAgentSessionAsyncQuestion (structured-agent-session-async-questions.ts) runs the card's own scan (scanPendingAsks) over the card's own message projection (projectStructuredAgentSessionMessages), so pending, rejected, withdrawn or queued sends never count as answers. The read starts at the newest delivered message from the person, or the newest message from another agent, so it stays inside the current exchange.
  • The live SQL status read (readJournalSqlAsyncQuestionOpen) walks user rows back to that point, then selects only root assistant rows after it whose payload names the tool (instr(payload_json, 'request_user_input_async') on the existing root_position index), so ordinary replies are never decoded per commit. The in-memory oracle (readJournalStatusState) applies the same rule, and a test pins the SQL read.
  • The host summary gains an optional awaitsAnswer: true. Only the lead-state mapping (structuredAgentSessionAgentStatus) reads it, turning working/done into waiting. Turn status, pending prompt ids, completion and prompt notifications, saved turns, teardown resume offers and mailbox redrive are untouched.

Why

The status is the host's fact, so the fix is in the host's journal status read, which both desktop and phone already consume; no client copy of the rule.

Keeping the turn status as is and flagging only the lead state was chosen after review: an earlier version reported the question as attention, and every consumer that reads attention as "turn still open" then misbehaved (a false "resume interrupted work" offer on quit, the saved turn reading as cancelled after relaunch, completion notifications swallowed, mail redrive skipped).

Options considered for the read:

  • A. An indexed journal column marking async-question rows. Exact and O(1), but bumps the chat database to v3, and an older Orca refuses a newer database, so a downgrade could not open any chat.
  • B. (this PR) No format change. Read back to the last message that answers or bounds the question, and let SQLite's text match pick the candidate rows.
  • C. Show waiting only while the turn runs, as Codex's own TUI does (it drops unanswered async questions at turn end). Doesn't fix the reported green, since the card stays open after the turn.

Linked Issue

Fixes #42008

Visual Proof

Real Codex 0.167.2 app-server, model gpt-6.1-sol, talking to a local fake model server that calls request_user_input_async and then ends the turn. Hidden desktop build, same profile.

Before (main) After (this branch)
before after

Before: the question card is open, but the tab and sidebar show the chat as done/unread. After: the tab and sidebar show it waiting for input ("Needs You: 1").

Phone not captured: the phone's chat tab copies state from the same host row (withStructuredChatStatus), and worktree ps against the same host reported waiting (before: done).

Testing

  • Live, headless orca serve built from this branch with a temp HOME/CODEX_HOME, real Codex 0.167.2 app-server and a fake Responses server (no spend):

    • Question asked, Codex keeps working 20 s, then ends the turn: worktree ps shows waiting throughout (main: working, then done).
    • Answering with a message: back to done.
    • Quitting the serve with the question open: no resume marker written, saved last turn settled/success.
    • Plan-mode blocking request_user_input: still blocked (unchanged).
  • Desktop: hidden build over CDP, screenshots above.

  • journal-domain-status-reads.test.ts: new case, an async question with no text after a finished turn reads awaitsAnswer, and the next message clears it. Fails on main.

  • Ran every test file that imports the changed modules (85 files) and check:code-quality:changed. macOS only; the change is platform-independent shared/main code.

  • 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 extra work in the per-commit status read. It decodes the newest user row (plus any undelivered ones after the last delivered message) and only the assistant rows whose payload names request_user_input_async. SQLite still text-scans the root rows after the last message, so a very long autonomous turn costs a C-level scan per commit instead of nothing.

Known limitations:

  • The card's Skip only hides the card on that screen; the host can't see it, so the chat stays waiting until the next message (the card comes back on reload, as today).
  • A message from another agent after the question ends the read, so in that case the dot clears while the card stays open.
  • An answer the person sends before Codex finishes its turn clears waiting at once, like the card.

Compatibility: awaitsAnswer is an optional summary field. Older clients ignore it and show today's behaviour. Older hosts never send it. No stored data changes. Back out with a plain revert.

Level: Low

AI Disclosure

Review

Two review rounds (Codex and Claude). Round 1 led to the bounded read, delivery-aware answers and the no-text case. Round 2 found that reporting the question as turn attention broke saved turns, teardown, notifications and mail. This version keeps turn status and flags only the lead state.

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

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)

…iting on you

Codex's request_user_input_async question is journaled as a call block on an assistant message, so the structured status never saw it: the chat read working, then done, while its question card stayed open. The host journal reads now flag such a question (awaitsAnswer) by the card's own rule until the person's next delivered message, and the lead state maps it to waiting. Turn status, prompts, notifications, teardown and saved turns are unchanged.
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

Journal status reads now detect open asynchronous questions and add awaitsAnswer to the status summary. Status projections pass that field to agent status, where it maps to the waiting lead state. Summary equality also compares awaitsAnswer. A test verifies that the field is present while a question is unanswered and absent after a subsequent user message.

Severity of issue fixed: Medium

Merge Risk: Low · up to 6bcbd

The change makes a Codex chat with an open asynchronous question show as waiting. In a narrow case, a queued message from an agent could clear that state before it is delivered. This has low impact and is easy to fix, so the change is mergeable with that follow-up.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Codex structured chats with an open async question now show as waiting. It matches the changeset, which adds an awaitsAnswer summary field, an async-question scan, and…
Description check Passed The description follows the repository template closely. It covers ELI5, What Changed (before and after), Why (with alternatives considered), a linked issue (Fixes #42008), Visual Proof with before an…
Linked Issues check Passed Issue #42008 asks that a chat show as waiting on the user, not green/done, when an agent asks a question. The change covers the structured Codex case that the issue describes. The journal status read …
Out of Scope Changes check Passed Every changed area supports the stated objective. The changed areas are: server-ingest-structured.ts (forwards awaitsAnswer); journal status reads, SQL candidate selection, and status items (detect th…
Full details: Title check

Explanation

The title names the main change: Codex structured chats with an open async question now show as waiting. It matches the changeset, which adds an awaitsAnswer summary field, an async-question scan, and a waiting lead state. The title follows the conventional fix(scope) format and stays within one sentence, though at 81 characters it is slightly long.

Full details: Description check

Explanation

The description follows the repository template closely. It covers ELI5, What Changed (before and after), Why (with alternatives considered), a linked issue (Fixes #42008), Visual Proof with before and after images, Testing with checklist items, a Risk section with level and backout plan, and Notes. The AI Disclosure section is blank, which the template permits for internal contributors. Two items are not complete: the final checklist item for lint, typecheck, test, and build is unchecked, and the Testing section lists platform coverage as macOS only.

Full details: Linked Issues check

Explanation

Issue #42008 asks that a chat show as waiting on the user, not green/done, when an agent asks a question. The change covers the structured Codex case that the issue describes. The journal status read (readJournalStatusState and readJournalSqlAsyncQuestionOpen) detects an open request_user_input_async question after the turn ends. It sets summary.awaitsAnswer, and structuredAgentSessionLeadState maps that to waiting. The shared rule hasOpenStructuredAgentSessionAsyncQuestion uses the card's own scan (scanPendingAsks) and projection, so pending, rejected, or withdrawn sends do not clear the question. A new test in journal-domain-status-reads.test.ts covers the unanswered-after-finished-turn case and the clearing on the next message. Blocking Plan-mode questions already map to blocked and are not changed. The issue text has no further acceptance criteria. The evidence in the PR summary and the raw change summary supports this verdict. I did not inspect the source directly. The SQL path and the renderer projection were checked only through their summaries.

Full details: Out of Scope Changes check

Explanation

Every changed area supports the stated objective. The changed areas are: server-ingest-structured.ts (forwards awaitsAnswer); journal status reads, SQL candidate selection, and status items (detect the open question); status-summary equality (compares the new field); renderer status projection (forwards the field); the wire type and projection type (declare the optional field); structured-agent-session-agent-status.ts (lead-state mapping); the shared async-question helper; and the new test. The PR states that turn status, prompt ids, notifications, saved turns, teardown, and mail redrive are unchanged, and the change summaries do not show edits to those paths. No unrelated change appears in the summaries. Source inspection was not performed, so this verdict rests on the summaries.

  • 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2c7913d9-3f4d-4fe2-b7d3-b320b4cfc942
Commits

Reviewing files that changed from the base of the PR and between 65c3de8 and 6bcbdfe.

Files selected for processing: 13

  • src/main/agent-hooks/server/server-ingest-structured.ts
  • src/main/native-chat/agent-session-journal/journal-domain-status-reads.test.ts
  • src/main/native-chat/agent-session-journal/journal-sql-status-async-questions.ts
  • src/main/native-chat/agent-session-journal/journal-sql-status-items.ts
  • src/main/native-chat/agent-session-journal/journal-sql-status-state.ts
  • src/main/native-chat/agent-session-journal/journal-status-items.ts
  • src/main/native-chat/agent-session-journal/journal-status-state.ts
  • src/main/native-chat/agent-session-wire/observations/structured-agent-session-status-summary-equality.ts
  • src/renderer/src/components/native-chat/session/status/structured-agent-session-status-projection.ts
  • src/shared/agent-session/agent-session-wire.ts
  • src/shared/agent-session/view/structured-agent-session-agent-status.ts
  • src/shared/agent-session/view/structured-agent-session-async-questions.ts
  • src/shared/agent-session/view/structured-agent-session-projection.ts

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

export function endsStructuredAgentSessionAsyncQuestionRead(message: NativeChatMessage): boolean {
return (
isDeliveredNativeChatUserMessage(message) ||
(message.role === 'user' && message.from?.kind === 'agent')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Exclude queued agent messages from the async question boundary.

The agent arm on line 17 does not check queued. Line 16 excludes queued messages through isDeliveredNativeChatUserMessage. A queued agent-origin message can therefore end the read before it is delivered. Its row is included in messages with queued: true, and findLastIndex selects it as the boundary. The earlier open question is then left out of the scan. The chat leaves the waiting state before the person receives a message, which conflicts with the rule that the waiting state lasts until the next delivered message.

Add the same queued check to the agent arm. Delivered agent messages still end the read.

Suggested fix

--- "a/src/shared/agent-session/view/structured-agent-session-async-questions.ts"
+++ "b/src/shared/agent-session/view/structured-agent-session-async-questions.ts"
@@ -11,12 +11,12 @@
 
 /** The person's delivered message answers every earlier async question; one from another agent
  *  ends the read too, so a status check stays inside the current exchange. */
 export function endsStructuredAgentSessionAsyncQuestionRead(message: NativeChatMessage): boolean {
   return (
     isDeliveredNativeChatUserMessage(message) ||
-    (message.role === 'user' && message.from?.kind === 'agent')
+    (message.role === 'user' && message.from?.kind === 'agent' && !message.queued)
   )
 }
 
 /** Codex's async question waits for the next delivered message, read the way the chat's question
  *  card reads it. Command entries never reach the agent, so they answer nothing. */
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
(message.role === 'user' && message.from?.kind === 'agent')
(message.role === 'user' && message.from?.kind === 'agent' && !message.queued)

@AmoabaKelvin
AmoabaKelvin merged commit bcf6c70 into main Nov 15, 2026
50 checks passed
Jinwoo-H added a commit that referenced this pull request Nov 15, 2026
…#42818)

Point journal-sql-status-items at the moved codex-async-question-input module (#42620 moved it before #42459 landed with the old path) and inline a one-use callId so structured-agent-session-projection.ts is back under the 300-line limit. No behavior change.
brennanb2025 added a commit that referenced this pull request Nov 16, 2026
…2835)

* fix(native-chat): import the moved Codex async question contract

#42459 imported codex-async-question-input from its pre-#42620 path, which
breaks the orcad template build on main.

* fix(native-chat): keep the status projection within its line limit

#42459's awaitsAnswer field took structured-agent-session-projection.ts to
301 lines; fold the attention early return into the status ternary.
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.

[Bug] Chat mode shows agents as green (“done”) even when they are blocked and asking a question

1 participant