Repository navigation
Render Codex async question cards in desktop native chat - #22513
lorenzozanee wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Important
The parser changes live in shared code that mobile imports, so mobile now surfaces Codex async cards through an answer path that still sends blocking selector keystrokes. Worth settling before merging — please see the section below.
Reviewed changes
- Async question parsing —
parseCanonicalQuestionsInputgains an async mode that readstitle(falling back toquestion) and stampsdelivery: 'async';parseToolInputroutesrequest_user_input_asyncthrough it. - Acknowledgement-aware pending state —
extractPendingAskkeeps an async ask open when its tool result is{"accepted":true}, retiring it only on the next user turn;isAsyncQuestionAcknowledgementfactors out that check.nativeChatAskRunBlocksmirrors it so the row stays unanswered. - Codex hook classification — async
PreToolUsestaysworking(excluded fromisUserInputPreTool), unlike sync which maps towaiting, whilederiveInteractivePromptnow forwards a serializedargumentsstring verbatim instead of double-encoding it. - Desktop answer delivery —
use-native-chat-interactive-send.tsskips the digit/Enter selector whenprompt.delivery === 'async'and sends the answer as a normal message.
⚠️ Async cards reach mobile, which still answers them with blocking selector keys
src/shared/native-chat-ask.ts and native-chat-ask-types.ts are imported directly by the mobile app. After this change mobile's resolveNativeChatAsk surfaces the async prompt from the transcript (its live prompt is cleared by PostToolUse), so the card renders — but useMobileNativeChatAnswerSend has no delivery gate, so it treats the async card as a Codex blocking selector and writes option digits to the PTY. Since Codex is in its working state with no selector open, those digits land in the composer and the answer is never submitted. That contradicts #20073's stated plan (append the selection to the draft / normal composer submission) and leaves mobile worse than the current "no card".
Technical details
# Mobile answers a newly-surfaced async card with the blocking-selector path
## Affected sites
- `src/shared/native-chat-ask.ts:168` — the async acknowledgement retention surfaces the prompt to every `extractPendingAsk` consumer, mobile included.
- `mobile/src/session/use-mobile-native-chat-prompts.ts:65` — `ask` falls back to the transcript-derived ask once the live `interactivePrompt` clears, so the async card is shown on mobile.
- `mobile/src/session/use-mobile-native-chat-answer-send.ts:228` — `shouldStepNativeChatAskAnswer(agentRef.current)` alone picks the branch; for `codex` it runs `buildCodexAskAnswerKeys` and writes raw keystrokes (`:261`–`:283`) with no `prompt.delivery !== 'async'` check.
- Desktop was gated at `src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts:98`; mobile was not.
## Required outcome
- An async answer from mobile must be delivered as an ordinary message (or appended to the draft per #20073), never as blocking selector keystrokes, and the async card must not silently appear on a path that cannot answer it correctly.
## Suggested approach
- Mirror the desktop gate in mobile's `answerAsk` (`prompt.delivery !== 'async'` → `sendMobileNativeChatMessageWithOutcome(formatAskAnswer(...), true)`), or hold the mobile surface until #20073's delivery path lands.
## Open questions for the human
- Is the mobile behavior here intentionally deferred to #20073, or should this PR also prevent the shared change from surfacing the card on mobile until that lands?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThe change adds support for Codex asynchronous user-input prompts. The parser recognizes the async tool, reads title-based questions and JSON-string inputs, and marks prompts with async delivery metadata. Hook events follow the working state path. Pending prompts remain open after acceptance acknowledgements and retire when a later user turn starts. Selecting an option on an async prompt sends its label through the normal message path. Merge Risk: 🟡 Moderate · up to If Codex tool results arrive out of order, an unanswered question can disappear from desktop chat. Resolve result matching before merging. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description is complete and aligned with the template. It explains the user impact, implementation, rationale, linked issue, testing, AI use, review scope, compatibility considerations, and checklist status. However, it marks Visual Proof as N/A even though this is an interaction and UI behavior change, while the template requires before-and-after proof for such changes.
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: b65d446c-908a-4065-9768-894fb2df408a
📒 Files selected for processing (12)
src/main/native-chat/transcript-reader-codex-history-mode.test.tssrc/renderer/src/components/native-chat/use-native-chat-interactive-send.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-interactive-send.tssrc/shared/agent-hook-listener-interactive-prompts.test.tssrc/shared/agent-hook-listener/interactive-tool.tssrc/shared/agent-hook-listener/providers/codex-events.tssrc/shared/agent-question-answered-intent.tssrc/shared/native-chat-ask-row.test.tssrc/shared/native-chat-ask-row.tssrc/shared/native-chat-ask-types.tssrc/shared/native-chat-ask.test.tssrc/shared/native-chat-ask.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| if (pendingDepth === 0) { | ||
| pending = null | ||
| pendingDepth = -1 | ||
| if (!(pending?.delivery === 'async' && isAsyncQuestionAcknowledgement(block.output))) { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect whether decoded Codex results retain call identity or enforce call order.
rg -n -C 3 'function_call_output|tool_use_id|pendingDepth' \
src/main/native-chat src/shared/native-chat-ask.tsRepository: stablyai/orca
Length of output: 12648
🏁 Script executed:
#!/bin/bash
printf '%s\n' '--- src/shared/native-chat-ask.ts ---'
sed -n '1,195p' src/shared/native-chat-ask.ts
printf '%s\n' '--- Codex decoder ---'
sed -n '1,135p' src/main/native-chat/transcript-line-decoders-codex.ts
printf '%s\n' '--- relevant type/block declarations and tests ---'
rg -n -C 5 'type ToolResult|tool-result|call_id|function_call_output|extractPendingAsk|pendingDepth' src/shared src/main/native-chat -g '*.ts' | head -n 260Repository: stablyai/orca
Length of output: 31852
Match the acknowledgement to the async call before retaining its prompt.
extractPendingAsk treats every tool result as FIFO and does not inspect call identity. If tool A precedes the async question and the async {"accepted":true} result is processed first, that result reduces pendingDepth to zero. Tool A's later result then clears pending, so the unanswered card disappears.
Carry Codex's call_id through the result block and match it, or establish that Codex always emits results in call order with a two-call transcript case.
|
@lorenzozanee I've opened #30062 for the same desktop async-question issue, also covering structured chat and mobile. It links this PR as prior work and reuses the existing question controls and ordinary message delivery. Pending questions are reconstructed on the host, independently of the loaded transcript page, and remain available across turn completion and reopening. Delivered replies update the other clients; failed or unconfirmed sends do not resolve the shared set. Cards include an Other field. 384 focused tests and the build pass. Full CI still needs maintainer approval, and live SSH and physical-device checks remain pending. I'd welcome your review of the terminal reply path so we can coordinate the overlapping fixes. |
|
Thank you for this PR. Rendering Codex async question cards has now landed on main via #31652 (desktop and phone), which builds on the same idea. Since this branch is conflicting, we are closing it as superseded. We appreciate the contribution. |

ELI5
Codex can ask a question while continuing other work. Orca previously showed that request as ordinary text instead of an answerable card, so users could not select an option or provide a response from desktop chat.
What Changed
Async Codex questions now use the existing native chat question card, including title-only questions and string options. The card remains available after Codex acknowledges that it was displayed, and submitted answers use the normal message delivery path. Existing synchronous question handling remains unchanged.
Why
The async request has a different payload shape and its accepted result confirms display rather than answering the question. Normalizing that shape into the existing card and preserving it until the user responds fixes the behavior without creating a second question UI or changing synchronous flows.
Linked Issue
Fixes #22485
Visual Proof
N/A. The change affects native chat interaction behavior, but no Electron renderer or live Codex session was available for a screenshot or video. Automated parser, hook, transcript, card, and answer-delivery tests cover the changed paths.
Testing
Focused Vitest coverage passed with 87 tests across parser, ask-row, live hook, Codex event, transcript, sender, and card behavior.
pnpm run check:code-quality:changed,pnpm tc:node,pnpm tc:web, andgit diff --checkpassed. No live Electron renderer, Windows, macOS, SSH, or Codex session was run.AI Disclosure
AI assistance was used for implementation, validation, and this pull request description.
Review
The change is limited to shared question parsing/lifecycle, Codex hook classification, and native chat answer delivery. It preserves synchronous behavior, uses existing message delivery, and does not add platform-specific, SSH, credential, or network behavior.
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)