Skip to content

Render Codex async question cards in desktop native chat - #22513

Closed
lorenzozanee wants to merge 1 commit into
stablyai:mainfrom
lorenzozanee:fix/codex-async-question-cards
Closed

lorenzozanee wants to merge 1 commit into
stablyai:mainfrom
lorenzozanee:fix/codex-async-question-cards

Conversation

@lorenzozanee

Copy link
Copy Markdown
Contributor

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

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

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, and git diff --check passed. 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

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Cross-platform and SSH behavior was considered; the changed paths are platform-neutral and no transport or wire contract was changed.
  • Hosted CI and the exact installed build from the Issue report remain unverified.

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)
  • 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)

@pullfrog pullfrog 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.

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 — parseCanonicalQuestionsInput gains an async mode that reads title (falling back to question) and stamps delivery: 'async'; parseToolInput routes request_user_input_async through it.
  • Acknowledgement-aware pending state — extractPendingAsk keeps an async ask open when its tool result is {"accepted":true}, retiring it only on the next user turn; isAsyncQuestionAcknowledgement factors out that check. nativeChatAskRunBlocks mirrors it so the row stays unanswered.
  • Codex hook classification — async PreToolUse stays working (excluded from isUserInputPreTool), unlike sync which maps to waiting, while deriveInteractivePrompt now forwards a serialized arguments string verbatim instead of double-encoding it.
  • Desktop answer delivery — use-native-chat-interactive-send.ts skips the digit/Enter selector when prompt.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?

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The 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 3eb97

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning 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 checkl… Attach before-and-after screenshots or a video showing the Codex asynchronous question card behavior. If visual proof cannot be provided, obtain repository-specific approval for the exception and document it clearly.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 14 functions across 12 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: rendering Codex asynchronous question cards in desktop native chat.
Linked Issues check ✅ Passed The changes satisfy the coding requirements in #22485. parseCanonicalQuestionsInput supports async title values, string options, and title-only questions, and marks the prompt with `delivery: 'asy…
Out of Scope Changes check ✅ Passed The changes stay within #22485. Production changes are limited to async Codex tool recognition, prompt parsing, acknowledgement handling, pending-card state, and answer delivery. The added tests cover…
Full details: Description check

Explanation

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.

  • Fix all pre-merge checks with AI

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

Comment @coderabbitai help to get the list of available commands.

@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

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: b65d446c-908a-4065-9768-894fb2df408a

📥 Commits

Reviewing files that changed from the base of the PR and between 563dd54 and 3eb9733.

📒 Files selected for processing (12)
  • src/main/native-chat/transcript-reader-codex-history-mode.test.ts
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.test.tsx
  • src/renderer/src/components/native-chat/use-native-chat-interactive-send.ts
  • src/shared/agent-hook-listener-interactive-prompts.test.ts
  • src/shared/agent-hook-listener/interactive-tool.ts
  • src/shared/agent-hook-listener/providers/codex-events.ts
  • src/shared/agent-question-answered-intent.ts
  • src/shared/native-chat-ask-row.test.ts
  • src/shared/native-chat-ask-row.ts
  • src/shared/native-chat-ask-types.ts
  • src/shared/native-chat-ask.test.ts
  • src/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))) {

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.

🎯 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.ts

Repository: 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 260

Repository: 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.

@miguel93041

Copy link
Copy Markdown

@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.

@nwparker

Copy link
Copy Markdown
Contributor

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.

@nwparker nwparker closed this Oct 24, 2026
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]: Desktop native chat omits Codex async question cards

3 participants