Repository navigation
fix(native-chat): list every question of a terminal-chat ask, with known answers - #23455
brennanb2025 wants to merge 7 commits into
Conversation
A cancelled or pending structured ask with several questions showed only "Asked: 2 questions", and its questions appeared nowhere in the transcript. The row's subject now carries the question texts instead of a count, and the row unfolds them as a list below its toggle unless the record already lists them with their answers.
…stion A pending Codex group is keyed by its first question, which becomes its own row once answered. Opening the list left that row expanded, and folding it could drop the toggle under the pointer. The list and a lone question now remember their open state separately.
…own answers The "Asked" row in terminal-based chats named only "N questions" for a grouped ask, and never showed what the reader answered. It now opens to list every question, and each answer wherever the agent recorded it as data: Claude's AskUserQuestion result keeps its answers beside the prose, keyed by question text, and Codex's request_user_input output is JSON keyed by question id. Prose-only results (Grok, Pi, refusals, aborts) and secret questions show the questions alone.
…script wires Both payload bounds rebuild a tool result by replacing only its output, so the new answers field rode through unclipped, and in worker transcripts unredacted. Neither reader draws answers, and the output already carries them bounded.
There was a problem hiding this comment.
ℹ️ No critical issues — one verification ask on the secret-answer guard's reachability.
Reviewed changes
- Shared row model —
NativeChatAskRowSubjectquestions become{ id?, text, answer? },nativeChatAskRunBlocksreturns paired{ call, result }asks, andaskCallQuestionsresolves each question's id/secrecy plus a recorded answer (Claude by exact question text, Codex by id). - Codex answer reader — new
src/shared/native-chat-ask-answers.tsparses{"answers":{"<id>":{"answers":[...]}}}, strips theuser_note:marker, and decodes the call payload. - Claude decoder —
claudeAskAnswerscopiestoolUseResult.{questions,answers}onto the tool result asaskAnswers;withEditPatchgeneralized towithResultData. - Renderer — the awaiting row shows each question's answer beneath it and toggles whenever it hides a list, a clipped question, or a known answer;
NativeChatToolRunno longer forceslistsQuestions={false}, so grouped transcript asks now expand.
I verified both external contracts against upstream. Claude's toolUseResult carrying a questions array plus a text-keyed answers map (string or string[]) is confirmed by the official SDK docs and third-party parsers, so the decoder guard is sound. Codex's result/id/isSecret/user_note: shapes are real too — but see the inline note: isSecret lives on the protocol type, not in the model-facing tool schema Orca decodes.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No new issues in the incremental changes; nothing actionable in the delta.
Reviewed changes
Incremental delta since 506d013 (the prior review) — commit 725f182, which keeps the new answers off the constrained wires:
- Mobile wire —
sanitizeNativeChatRpcBlocknow stripsaskAnswersfrom mobiletool-resultblocks, so the new field can't bypass the 4000-char mobile output cap. This is the single mobile choke point (native-chat.ts:31viasanitizeMessage, reached byreadSessionand everysubscribeframe), andruntime/unknown clients keep the field. - Worker transcript —
boundWorkerTranscriptMessages/TaildropaskAnswersbefore clipping and thedcap_redaction, so recorded answers can't skip either; the answers remain in the tooloutputthe agent reads. Both functions route throughboundBlock, so the strip covers the head and tail paths. - Tests — exact-equality assertions pin the mobile strip, the keep-on-runtime behavior, and the worker strip.
Not approving only because the earlier secret-guard question from the prior review remains open; the delta itself is sound.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…it received Claude records a note the reader typed beside the chosen option in `annotations`, and writes the stand-in "(notes only)" as the answer when no option was chosen. The row showed that stand-in and dropped every note. An idle timeout's unsubmitted picks, and answers replaced by a typed response, were shown as answers the agent never received.
There was a problem hiding this comment.
ℹ️ No new issues in the incremental changes. The delta's field assumptions are now verified against the shipped CLI, and nothing in it is actionable.
Reviewed changes
Incremental delta since 725f182 — commit d595c27, which teaches the Claude decoder to read a typed note and to keep answers only where the agent actually received them:
- Typed notes —
claudeAskAnswersnow appendsannotations[question].notesafter the chosen labels, and drops Claude's(notes only)stand-in when the reader picked no option. - Answers the agent never received — the decoder records no answers when
afkTimeoutMsis set (AFK auto-continue) or when a free-textresponseis present withoutfollowUp. - Question order — entries are built by iterating
result.questionsper question instead ofObject.entries(answers), so order follows the prompt and stray answer keys are ignored. - Tests — synthetic records cover note-beside-a-choice, note-only, AFK, free-text, and follow-up cases; each fails if its guard is removed.
I also verified the fields this delta leans on, since the earlier reviews only confirmed questions/answers. The official @anthropic-ai/[email protected] sdk-tools.d.ts AskUserQuestionOutput declares response?, annotations? ({ preview?, notes? }, keyed by question text), and afkTimeoutMs?. The shipped linux-x64 bundle additionally confirms followUp (schema text: "Set when the user asked for another round of questions instead of (or after partially) answering."), the literal "(notes only)", and groups ["answers","annotations","response","followUp"] together. So the guards are real rather than dead code, they match the semantics claimed in the PR body, and they fail safe (drop answers) if a future release renames a field.
Not approving only because the earlier Codex isSecret reachability question from the first review remains open and is untouched by this commit.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…rca recognizes Claude and Codex answers were read by rejecting the shapes known to be wrong, so a result of any new shape could still show an answer. Each reader now accepts only the keys, ids and value types its agent is known to write, and anything else shows the questions alone. - Claude: the result's keys, each note's keys, every answer's question and every answer's type must be recognized. - Codex: every answer's id must be one the call asked, and each entry must hold only a list of text. - The Codex reader is chosen by the call's tool name, not by the Claude field being absent. - The Claude rules move next to the Codex rules in shared code; the answer separator is shared with the resolved-prompt receipt. - Fixtures copy the structure of recorded Claude and Codex results with synthetic text.
There was a problem hiding this comment.
ℹ️ No new issues in the incremental strictness hardening. The earlier Codex
isSecretreachability thread remains open and unchanged, so this is not an approval.
Reviewed changes
Incremental delta since d595c27 — commit 2fbccd0, which makes each answer reader accept only the shapes its agent is known to write:
- Strict shape validation —
claudeAskAnswersandcodexAskAnswersnow reject any result whose keys, question ids, or answer value types fall outside the agent's known set, so an unrecognized shape shows the questions alone instead of a guessed answer. - Codex reader gated by tool name —
codexAskAnswersis selected bycall.name === 'request_user_input'rather than by the Claude field being absent, and every answer id must be one the call asked. - Shared Claude reader —
claudeAskAnswersmoved beside the Codex rules insrc/shared/native-chat-ask-answers.ts, takingtoolUseResultdirectly; the decoder calls it withrecord.toolUseResult. - Shared separator —
NATIVE_CHAT_ANSWER_PART_SEPARATORreplaces the duplicated' · 'literal in the ask row and the resolved-prompt receipt. - Fixtures — real-derived Claude and Codex fixtures replace inline synthetic records, and the reader, row, and decoder tests read from them.
The stricter readers fail safe in the direction the PR intends (no answers rather than a wrong one), and each new guard is pinned by an exact-equality test. I re-ran the reader, row, and decoder test files (49 tests) and they pass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Review status: ready for review (stacked on #23451)Head: What this fixes. In terminal-based chats (the agent runs as its normal CLI and Orca renders its transcript as a chat), a multi-question ask left a row reading "Asked: 2 questions". The questions and answers were shown nowhere. The row now opens to list every question in full. Under each question it shows the answer, but only when the agent's own result record matches a shape Orca recognizes. Otherwise it shows the questions alone, so an unfamiliar format never produces a wrong answer:
Review loops. Five review loops plus one architecture challenge.
Readiness checks. Start and end both passed. The end check found no issues. Live QA, on a background dev build of this head on a second Mac with an isolated profile, using real terminal-backed Claude and Grok chats. Passed:
Screenshots are in the PR body. Codex was blocked: the CLI on that machine never produced a question, because its account was near its usage limit. Codex answers are covered by tests only. Two gaps QA found. Both are unchanged from main, and neither is caused by this PR:
Other known behaviour:
Not caused by this PR (follow-ups):
|
…hat-multi-question-terminal # Conflicts: # src/renderer/src/components/native-chat/NativeChatAwaitingInputRow.tsx # src/renderer/src/components/native-chat/NativeChatResolutionReceipt.tsx # src/shared/native-chat-ask-row.test.ts # src/shared/native-chat-ask-row.ts
|
| return blocks.map((block) => { | ||
| if (attached || block.type !== 'tool-result') { | ||
| return block | ||
| } | ||
| attached = true | ||
| return { ...block, editPatch: patch } | ||
| return { ...block, ...data } |
There was a problem hiding this comment.
| (part): part is string => | ||
| typeof part === 'string' && part.trim().length > 0 && part !== CLAUDE_NOTES_ONLY_ANSWER | ||
| ) | ||
| if (parts.length > 0) { |
There was a problem hiding this comment.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (17)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughThe change adds Claude and Codex answer parsing and carries recorded answers in native-chat tool-result data. Ask-row aggregation matches answers to questions, and the renderer displays recorded answers in expandable rows. Transcript bounding and mobile RPC sanitization omit answer data. Tests cover parsing, decoding, sanitization, aggregation, and display. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to Expanded ask rows now show every question, with recorded answers when the agent's result matches a known format. Phone and worker payloads omit the new field. No concrete merge-blocking risk was found. Security Architecture ReviewSecurity architecture risk: 🟡 Moderate · up to Recorded answers can now appear in chat history. Mobile and worker payloads exclude the new answer field, and secret questions have a display guard. However, if results arrive out of order or are replayed, an answer could appear under the wrong question, potentially under a non-secret question. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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.
✅ No new issues found.
Reviewed changes
Incremental delta since 2fbccd0 — commit 461fcd2, a merge of origin/main. No file owned by this PR changed; the merge added unrelated main work (a journalPosition strip in worker-transcript-payload.ts, an AgentSessionFailureFact on text blocks) and left the terminal-ask behavior identical.
- Prior open thread resolved — the Codex
isSecretreachability ask is withdrawn. Codex'sRequestUserInputQuestiondoes defineisSecret(codex-rs/protocol/src/request_user_input.rs), but every producer copies it from the model arguments and nothing sets it true, and the transcript records the raw model-authoredfunction_call.arguments. Sosource?.isSecret === truefires only on a model-authored field and fails safe otherwise. The thread is resolved and answered inline. - Strip placements survived the merge — the PR-owned
askAnswersremoval inboundBlock(worker-transcript-payload.ts:127) and the mobile branch (native-chat-rpc-block-sanitize.ts:54) are intact; the merge's extrajournalPositionstrip is orthogonal.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
When an agent in a terminal-based chat asks you several questions at once, the chat used to leave behind a line that only said "Asked: 3 questions". You could not see what the questions were or what you answered. Now that line opens to list every question, and under each one the answer you gave, but only when the agent saved that answer in a form Orca recognizes. When Orca is not sure, it shows the questions alone, never a guessed answer.
What Changed
Before: in chats that Orca draws by reading the agent's transcript file (Claude, Codex, Grok and others), a grouped ask showed "Asked: N questions" with nothing to open. A single question could be opened only when it was too long for its line, and no row ever showed an answer.
After: the "Asked" row opens whenever it hides something: a question list, a clipped question, or a known answer. Each question is shown in full, with its answer on the line below in muted text. A single short question that has a known answer can now be opened to see that answer.
The rule for every agent: an answer is shown only when the agent's result matches a recognized shape; otherwise the questions are shown alone. Each agent's reader lists exactly the keys, ids and value types it accepts, and anything outside that list, including a shape a future release adds, means no answers rather than a best guess. Both readers live in one shared file,
src/shared/native-chat-ask-answers.ts.Claude: Claude's transcript stores the answers as data next to the text it hands the model, keyed by each question's exact text. The Claude transcript decoder (main process) now copies those answers onto the tool-result block as a new optional
askAnswersfield (question text plus the parts of the reply), the same way it already copies edit hunks aseditPatch. The decoder calls the shared Claude reader, which accepts a result only when its keys are amongquestions,answers,annotations,response,followUpandafkTimeoutMs, each note holds onlypreviewornotes, every answer sits under the exact text of a question that was asked, and every answer is text or a list of text. A text answer is kept whole, never split on commas, because typed replies can contain commas. A note the reader typed beside their choice follows it, and when they typed only a note, the note is shown instead of the placeholder Claude records in that case. A list of labels, and a label with its note, are joined with " · ", the same separator constant the answered-prompt receipt now uses.Claude records two results whose answers the agent never received as answers: a prompt that timed out while the reader was away (their picks were never submitted), and a free-text reply sent in place of the answers. Those show the questions without answers. The prose text is never parsed, because its wording changes between releases and it does not escape quotes.
Codex: Codex already stores its answers as JSON in the tool output, keyed by each question's id, and Orca already keeps that output on the block. Shared code now reads it and matches each answer to its question by id. The Codex reader runs only for Codex's question tool (
request_user_input), chosen by the call's tool name, so a result from another agent is never read as Codex's. It accepts the output only when it holds nothing butanswers, every id is one the call asked, and each entry holds only a list of text. So Codex needed no decoder change and no second copy of the data. The prefix Codex adds to typed notes is removed. "None of the above" is shown as chosen, followed by the note typed in its place. A question marked secret never shows its answer.Grok, Pi, refusals, aborts, and anything that is not structured data show the questions without answers.
The row now uses one model for every question: its text, an optional id, and an optional answer. List items are keyed by the id when the agent gives one, otherwise by the text.
The answered-prompt receipt used by structured chats behaves exactly as before. It still lists answers below the row itself, so it passes questions without answers.
Why
The row may be the only place the questions are still visible once the ask is answered, so it should show all of them.
Answers are shown only where the agent recorded them as data in a shape Orca recognizes. Guessing them from prose, or reading a shape Orca has not seen, could show the wrong answer, which is worse than showing none. Accepting only known shapes makes that the default: a change in a future agent release shows the questions alone until Orca learns the new shape.
Where this differs from structured chats: a structured chat shows the answer Orca itself recorded when you answered in Orca. A terminal chat has no such record, because you answer inside the agent's own screen, so Orca reads the answer from the agent's own result record instead. That is why the terminal row trusts only shapes it recognizes.
Claude's answers are matched by question text because that is the only key Claude records. Codex's are matched by id because Codex records ids.
The Claude answers are normalized once, in the decoder, into what they mean (which question, what reply). The decoder does not pass a raw copy of the transcript record along, so readers never depend on the transcript's format.
Compatibility:
Remote hosts:
askAnswersis a new optional field on an existing block. A client paired with an older host gets no field, and its Claude rows show questions only. Codex answers still appear, because they come from the output the host already sends. An older client ignores the field.Mobile: mobile draws its own tool rows and does not use this row, so it looks the same. The phone payload drops the new field, because the phone never reads it and it would otherwise skip the size cap that trims the tool output. Older and newer phones see the same payload as before.
Worker transcripts (what an orchestrating agent reads back from a worker): the new field is dropped there too. Its answers already appear in the tool output, which that payload trims and scrubs of dispatch tokens, while the field would have skipped both.
Session history: when a terminal session's history is imported into a structured session, a tool result that is its message's only block loses its extra fields, as
editPatchalready does; Claude always writes an answered ask that way. So imported Claude asks show questions only there. The source transcript is unchanged.Not in this PR (already true on the base branch): a Codex refusal or abort, and a Grok failure, show as an "Asked" row, because those results carry no error flag.
Linked Issue
None. Follow-up to #22941 and #23451 (merged); now based on main.
Visual Proof
Checked live in a background dev build of this branch (head
2fbccd01a7) on a second Mac, with an isolated profile and real terminal-backed Claude and Grok chats. Before this change these rows read "Asked: 2 questions" with no way to open them, and a short answered question showed no answer anywhere.Claude, two questions, one answered with an option and one with typed text; the list shows each answer, typed text verbatim and selectable:

A short single question becomes a toggle once it has an answer:

Grok records no structured answer, so its list shows the questions only:

Keyboard focus, and still open with answers after scrolling away and back:

A single long question still unfolds:

Codex could not be checked live: on the test machine the Codex CLI never produced a question (its account was near its usage limit). The Codex answer paths are covered by the tests below.
Testing
Real-derived fixtures: the Claude and Codex fixtures copy the exact structure and key sets of results recorded on a developer machine, with every question, option, answer, id and path replaced by synthetic text. Claude: an answered pair where a multi-select answer is a list, a typed answer in place of an option, an answer whose option had a preview, and both recorded forms of a declined prompt. Codex: an answered one-question call, and its recorded refusal and abort outputs.
Synthetic fixtures: no recorded result showed a note, a note with no option chosen, a follow-up request, a typed response in place of answers, or an idle timeout. Those are written to Claude's published result type, plus the optional
followUpflag the Claude command-line tool records.Fail-safe tests: for Claude, an unknown top-level key, an unknown note key, an answer under a question that was not asked, and an answer that is a number each yield no answers. For Codex, an extra key (beside
answers, or inside an entry), an id the call did not ask, and a non-text item each yield no answers. Row tests check that another agent's Codex-shaped output is not read as Codex's, and that a Codex call never reads the Claude field.Real-record check: every question result in the local session history of a developer machine was run through the two readers. All 270 answered Claude results (Claude Code 2.1) and all 4 answered Codex results yield their answers; the 65 declined Claude results, the 352 Codex refusals and aborts, and every other tool's result in those Claude sessions yield none. The Claude key allowlist matches the full result type in the current Claude command-line tool, and the Codex one matches Codex's own answer type.
Other tests: the Claude reader's notes, "(notes only)", idle timeout, typed response and follow-up rules; Codex notes, "None of the above" and unanswered questions; matching answers to questions for both agents; secret questions; prose-only agents; the phone and worker-transcript payloads dropping the field; and renderer tests for answered, unanswered and older-host rows. The receipt tests from #23451 pass unchanged.
Each new test was checked by removing the code it covers (committed first, then removed and restored): it fails without that code.
pnpm tc,pnpm run check:code-quality:changed,pnpm run check:react-doctor:changed, and fulloxlinton the touched files pass. The native-chat renderer, shared, main, RPC and worker-transcript tests pass (378 files); two timing tests outside this change failed once under heavy machine load and pass on rerun.AI Disclosure
Review
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
Security: a Codex question marked secret never shows its answer.
Cross-platform: no platform-specific code.
Remote SSH: see Compatibility under Why.
Mobile: no visual change and no payload change, see Compatibility under Why.
Backward compatibility: the new field is optional, and readers treat it as optional.
Performance: the row's question list is memoized with its tool run, and the Codex output is parsed only for answered question calls.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)