Repository navigation
fix(native-chat): Codex async questions show an answer card on desktop and phone - #31652
Conversation
request_user_input_async returns {"accepted":true} at once and takes the
answer as the next user message, so it is pending until then and answered
by an ordinary send.
Fixes #20073
… agent Also routes a pane menu Paste on a question's answer field to that field while the composer stays mounted.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
252f0e08-ddec-4bd4-8aa0-d238b328e7d7
📒 Files selected for processing: 27
mobile/src/session/MobileNativeChatPromptCard.tsxmobile/src/session/use-mobile-native-chat-answer-send.test.tsmobile/src/session/use-mobile-native-chat-answer-send.tsmobile/src/session/use-mobile-native-chat-controller.tsmobile/src/session/use-mobile-native-chat-prompts.test.tsmobile/src/session/use-mobile-native-chat-prompts.tsmobile/src/session/use-mobile-structured-async-question.tssrc/main/codex/codex-structured-async-question.test.tssrc/main/codex/codex-structured-item-translation.tssrc/main/native-chat/transcript-reader-codex-history-mode.test.tssrc/renderer/src/components/native-chat/NativeChatInteractiveCard.tsxsrc/renderer/src/components/native-chat/NativeChatQuestionCard.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredAsyncQuestion.test.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredAsyncQuestion.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredSession.tsxsrc/renderer/src/components/native-chat/native-chat-paste-routing.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-context-menu.tsxsrc/renderer/src/components/native-chat/use-native-chat-interactive-send.test.tsxsrc/renderer/src/components/native-chat/use-native-chat-interactive-send.tssrc/renderer/src/components/native-chat/use-native-chat-paste-bridge.tssrc/renderer/src/lib/native-chat-paste-request.tssrc/shared/codex-async-question-input.tssrc/shared/native-chat-ask-row.spec.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: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| const sendWithOutcome = structured?.sendWithOutcome | ||
| const answer = useCallback( | ||
| async (prompt: AskPrompt, selections: AskAnswerSelection[]) => | ||
| sendWithOutcome !== undefined && | ||
| (await sendWithOutcome(formatAskAnswer(prompt, selections))) !== 'rejected', | ||
| [sendWithOutcome] | ||
| ) | ||
| return { ask, answer: structured ? answer : null } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
rg -n 'onDismissAsk|dismissedAsk|queuedMessageDelete|removeQueued|nativeChatAsk' mobile/src/session mobile/src/components | head -145Repository: stablyai/orca
Length of output: 9264
🏁 Script executed:
set -eu
printf '%s\n' '--- use-mobile-structured-async-question.ts ---'
nl -ba mobile/src/session/use-mobile-structured-async-question.ts | sed -n '1,130p'
printf '%s\n' '--- use-mobile-native-chat-ask-dismiss.ts ---'
nl -ba mobile/src/session/use-mobile-native-chat-ask-dismiss.ts | sed -n '1,220p'
printf '%s\n' '--- use-mobile-native-chat-controller.ts relevant blocks ---'
nl -ba mobile/src/session/use-mobile-native-chat-controller.ts | sed -n '120,190p;280,335p'
printf '%s\n' '--- MobileNativeChatPromptCard.tsx ---'
nl -ba mobile/src/session/MobileNativeChatPromptCard.tsx | sed -n '1,120p'
printf '%s\n' '--- use-mobile-structured-queued-message-controls.ts relevant blocks ---'
nl -ba mobile/src/session/use-mobile-structured-queued-message-controls.ts | sed -n '1,220p'
printf '%s\n' '--- use-mobile-structured-send-with-outcome.ts ---'
nl -ba mobile/src/session/use-mobile-structured-send-with-outcome.ts | sed -n '1,240p'
printf '%s\n' '--- structured async question usages and dismissal tests ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'useMobileStructuredAsyncQuestion' -e 'dismissNativeChatAsk' -e 'queuedMessageDelete' -e 'onDismissAsk' mobile/src/session | sed -n '1,260p'Repository: stablyai/orca
Length of output: 40782
🏁 Script executed:
set -eu
for f in \
mobile/src/session/use-mobile-native-chat-ask-dismiss.ts \
mobile/src/session/use-mobile-structured-async-question.ts \
mobile/src/session/MobileNativeChatPromptCard.tsx \
mobile/src/session/use-mobile-structured-queued-message-controls.ts \
mobile/src/session/use-mobile-structured-send-with-outcome.ts; do
echo "--- $f ---"
nl -ba "$f"
done
echo '--- controller ask wiring ---'
nl -ba mobile/src/session/use-mobile-native-chat-controller.ts | sed -n '135,180p;290,330p'
echo '--- relevant tests ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'dismissNativeChatAsk' -e 'queuedMessageDelete' -e 'onDismissAsk' -e 'useMobileStructuredAsyncQuestion' mobile/src/session | sed -n '1,320p'Repository: stablyai/orca
Length of output: 40674
🏁 Script executed:
set -eu
printf '%s\n' '--- mobile/src/session/use-mobile-native-chat-prompt-dismiss.ts ---'
nl -ba mobile/src/session/use-mobile-native-chat-prompt-dismiss.ts
printf '%s\n' '--- mobile/src/session/use-mobile-native-chat-prompts.ts ---'
nl -ba mobile/src/session/use-mobile-native-chat-prompts.tsRepository: stablyai/orca
Length of output: 8650
🏁 Script executed:
set -eu
printf '%s\n' '--- queue-control call sites ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'useMobileStructuredQueuedMessageControls' -e 'onActionResolved' -e 'queued.delete' -e 'queued.clear' mobile/src/session | sed -n '1,260p'
printf '%s\n' '--- ask component answer behavior ---'
rg -n -F --glob '*.tsx' -e 'export function MobileNativeChatAsk' -e 'onAnswer' mobile/src/session/MobileNativeChatAsk.tsx
nl -ba mobile/src/session/MobileNativeChatAsk.tsx | sed -n '1,260p'Repository: stablyai/orca
Length of output: 13840
Restore the async question after deleting its queued answer.
A queued answer returns success, so the card stores an answered dismissal. The structured prompt remains both observed and pending. Deleting the queued draft does not change that prompt key, so the dismissal is not forgotten. The user then has no question-specific answer or retry control.
Reset the ask dismissal after a successful agentSession.queuedMessageDelete. Use a deletion-specific callback so Send, Edit, and other queue actions keep their current behavior.
| onAnswer={(selections) => { | ||
| if (send(formatAskAnswer(card.prompt, selections), []) !== false) { | ||
| presentation.dismiss() | ||
| } | ||
| }} | ||
| onCancel={presentation.dismiss} |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,105p' src/renderer/src/components/native-chat/NativeChatStructuredAsyncQuestion.tsx
rg -n 'useNativeChat.*Prompt|dismiss:|dismiss\(|queued' src/renderer/src/components/native-chat/NativeChatStructuredAsyncQuestion.tsx src/renderer/src/components/native-chat/use-native-chat-ask-presentation.ts src/renderer/src/components/native-chat/native-chat-composer-types.tsRepository: stablyai/orca
Length of output: 3095
🏁 Script executed:
set -eu
printf '%s\n' '--- presentation hook and related files ---'
rg -n -F --glob '*.ts' --glob '*.tsx' \
-e 'useNativeChatPromptCardPresentation' \
-e 'function useNativeChatPromptCardPresentation' \
-e 'presentation.dismiss' \
src/renderer/src/components/native-chat || test "$?" -eq 1
printf '%s\n' '--- transport send implementations and queued draft handling ---'
rg -n -F --glob '*.ts' --glob '*.tsx' \
-e "return 'queued'" \
-e "=== 'queued'" \
-e "!== false" \
-e 'queued draft' \
-e 'sendWithOutcome' \
src/renderer/src/components/native-chat src/shared || test "$?" -eq 1
printf '%s\n' '--- candidate file list ---'
rg --files src/renderer/src/components/native-chat src/shared | rg 'prompt-card|composer|send|ask'Repository: stablyai/orca
Length of output: 25634
🏁 Script executed:
set -eu
printf '%s\n' '--- prompt presentation ---'
nl -ba src/renderer/src/components/native-chat/use-native-chat-prompt-card-presentation.ts
printf '%s\n' '--- structured composer transport ---'
nl -ba src/renderer/src/components/native-chat/use-native-chat-structured-composer-transport.ts
printf '%s\n' '--- structured composer send and dispatch ---'
nl -ba src/renderer/src/components/native-chat/use-native-chat-structured-composer-send.ts
nl -ba src/renderer/src/components/native-chat/native-chat-structured-composer-dispatch.ts
printf '%s\n' '--- transport type and queued-draft contracts ---'
nl -ba src/renderer/src/components/native-chat/native-chat-composer-types.ts | sed -n '1,155p'
printf '%s\n' '--- queued draft and async-question tests ---'
rg -n -F --glob '*.test.*' -e 'queued' -e 'NativeChatStructuredAsyncQuestion' -e 'async question' src/renderer/src/components/native-chat src/shared || test "$?" -eq 1Repository: stablyai/orca
Length of output: 41603
🏁 Script executed:
set -eu
printf '%s\n' '--- dismissal store ---'
nl -ba src/renderer/src/components/native-chat/native-chat-prompt-dismissals.ts
printf '%s\n' '--- dispatch result contract ---'
nl -ba src/renderer/src/components/native-chat/native-chat-structured-composer-dispatch.ts
printf '%s\n' '--- queued session state and UI references ---'
rg -n -F --glob '*.ts' --glob '*.tsx' \
-e 'queuedMessages' \
-e 'queuedMessage' \
-e 'deleteQueued' \
-e 'steer' \
-e 'queued draft' \
src/renderer/src/components/native-chat/use-structured-agent-session.ts \
src/renderer/src/components/native-chat/NativeChatResolvedView.tsx \
src/renderer/src/components/native-chat/NativeChatComposer.tsx \
src/renderer/src/components/native-chat/structured-agent-session-queued-cards.test.ts \
src/renderer/src/components/native-chat/use-structured-agent-session.queued-gating.test.tsx || test "$?" -eq 1
printf '%s\n' '--- async-question and prompt-presentation tests ---'
rg -n -F --glob '*.test.*' \
-e 'NativeChatStructuredAsyncQuestion' \
-e 'queued answer' \
-e 'dismiss' \
-e 'retry' \
-e 'queued draft' \
src/renderer/src/components/native-chat src/shared/native-chat-ask.test.ts src/shared/native-chat-ask-fifo.test.ts || test "$?" -eq 1Repository: stablyai/orca
Length of output: 39493
🏁 Script executed:
set -eu
printf '%s\n' '--- async question test ---'
nl -ba src/renderer/src/components/native-chat/NativeChatStructuredAsyncQuestion.test.tsx
printf '%s\n' '--- prompt presentation tests ---'
nl -ba src/renderer/src/components/native-chat/use-native-chat-prompt-card-presentation.test.ts | sed -n '1,115p'
printf '%s\n' '--- queued message list and controller bindings ---'
rg -n -F --glob '*.ts' --glob '*.tsx' \
-e 'function NativeChatQueuedMessageList' \
-e 'export function NativeChatQueuedMessageList' \
-e 'steerQueued' \
-e 'deleteQueued' \
-e 'queuedMessages.cards' \
-e 'Press Send to retry' \
src/renderer/src/components/native-chat/NativeChatQueuedMessageList.tsx \
src/renderer/src/components/native-chat/NativeChatComposer.tsx \
src/renderer/src/components/native-chat/use-structured-agent-session.ts \
src/renderer/src/components/native-chat/structured-agent-session-queued-cards.ts || test "$?" -eq 1
printf '%s\n' '--- queued-card contract definitions ---'
nl -ba src/renderer/src/components/native-chat/structured-agent-session-queued-cards.ts | sed -n '1,260p'Repository: stablyai/orca
Length of output: 16213
🏁 Script executed:
set -eu
printf '%s\n' '--- queued message list ---'
nl -ba src/renderer/src/components/native-chat/NativeChatQueuedMessageList.tsx
printf '%s\n' '--- queued controller return and actions ---'
nl -ba src/renderer/src/components/native-chat/use-structured-agent-session.ts | sed -n '120,175p'
nl -ba src/renderer/src/components/native-chat/use-structured-agent-session.ts | sed -n '285,330p'
printf '%s\n' '--- composer queued action wiring ---'
nl -ba src/renderer/src/components/native-chat/NativeChatComposer.tsx | sed -n '45,85p'
nl -ba src/renderer/src/components/native-chat/NativeChatComposer.tsx | sed -n '315,350p'Repository: stablyai/orca
Length of output: 21750
🏁 Script executed:
set -eu
printf '%s\n' '--- queued-message controller ---'
rg -n -F --glob '*.ts' --glob '*.tsx' \
-e 'StructuredAgentSessionQueuedMessagesController' \
-e 'function useStructuredAgentSessionQueuedMessages' \
-e 'const remove' \
-e 'remove:' \
-e 'queuedMessage.remove' \
src/renderer/src/components/native-chat
printf '%s\n' '--- controller source candidates ---'
rg --files src/renderer/src/components/native-chat | rg 'queued-messages'Repository: stablyai/orca
Length of output: 6884
🏁 Script executed:
set -eu
nl -ba src/renderer/src/components/native-chat/use-structured-agent-session-queued-messages.ts | sed -n '1,215p'Repository: stablyai/orca
Length of output: 9865
Keep the question card pending for queued answers.
When send returns 'queued', the answer is accepted as a draft but has not reached the agent. If the user deletes that queued draft, the pending question can remain without its structured retry controls because this handler already recorded the prompt as answered. Dismiss only after a definite true result.
Suggested fix
- if (send(formatAskAnswer(card.prompt, selections), []) !== false) {
+ if (send(formatAskAnswer(card.prompt, selections), []) === true) {
presentation.dismiss()
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| onAnswer={(selections) => { | |
| if (send(formatAskAnswer(card.prompt, selections), []) !== false) { | |
| presentation.dismiss() | |
| } | |
| }} | |
| onCancel={presentation.dismiss} | |
| onAnswer={(selections) => { | |
| if (send(formatAskAnswer(card.prompt, selections), []) === true) { | |
| presentation.dismiss() | |
| } | |
| }} | |
| onCancel={presentation.dismiss} |
ELI5
When Codex asks a question but keeps working (its
request_user_input_asynctool), Orca only showed the question as text. Now desktop and phone show the usual question card, and your answer goes back to Codex as a normal message.What Changed
Before: an async Codex question showed up as prose ("Which color?" with a bulleted list) and nothing else: no choices, no answer field. This happened on desktop and on the phone, in both structured and terminal-backed chats. Its immediate
{"accepted":true}result also counted as an answer, so nothing treated the question as open.Now:
request_user_input_asynccall block on the same assistant message (codexJournalItem). Both clients read it with the shared pending rule and show the existing question card (desktopNativeChatQuestionCard, phoneMobileNativeChatAsk). On desktop the card sits above the composer, because Codex keeps working, so typing and Stop stay available. Picking an answer sends an ordinary message through the structured send:> Which color?followed by a blank line andBlue, the plain reply form Codex's own clients use. Cancel only hides the card.native-chat-ask.ts): the async input shape (titleplus stringoptions) is parsed. Each async question stays open past its display acknowledgement until a user message actually reaches the agent. Queued, unsent or withdrawn sends don't count. Several unanswered async questions are combined into one card, once per call.Why
Codex's own source (rust-v0.163.0,
request_user_input_async.rs,answered_question.rs) shows the tool has no reply op. The answer is just the next user message, so the question stays pending until then. A structured journal question item is a request/response prompt: it holds the send queue, its Cancel interrupts the turn, and answering it needs a server request. Fitting an async question into it would have meant a second lifecycle in the host. A call block on the message needs no wire or schema change, re-imports idempotently, and lets desktop and phone share one rule with the terminal transcript path.Not changed on purpose: the async
PreToolUsehook still maps to "working". Codex doesn't block on this tool, so "Needs You" would only flash.Compatibility: an old phone on a new host shows the prose as today. A new phone on an old host has no call block, so it also shows the prose.
Linked Issue
Fixes #20073
Visual Proof
Real
request_user_input_asynccalls from Codex 0.163.0 (GPT-6.1-Sol) in a structured Codex chat. Before is main, after is this branch.Desktop
Before (prose only): (screenshot removed: contained real product data)
After (card above the composer, pick Blue, type "none", Codex replies "Blue, with no other constraints."): (screenshot removed: contained real product data)
Phone (Android emulator, Orca Mobile 0.0.58, page bundle from each desktop build)
Before: (screenshot removed: contained real product data)
After (tap Blue, the reply goes as a normal message, Codex answers "Blue it is."): (screenshot removed: contained real product data)
Testing
Focused regressions that fail without the fix:
Neighbouring native-chat, codex and mobile suites pass (687 desktop/host and 572 mobile tests, after rebasing on main);
check:code-quality:changedandcheck:react-doctor:changedpass.Live on macOS: hidden dev builds of main and this branch, structured Codex chat, real Codex 0.163.0 turns. On desktop and on the Android emulator, the reply Codex received is in its rollout as
> Which color should the button be?followed byBlue. I did not exercise the terminal-backed route, SSH, Linux, Windows or iOS live.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Agent skill upstream boundary
Notes
No platform-specific code. SSH and headless hosts use the existing journal and send paths. Folder workspaces are unaffected.