Repository navigation
fix(native-chat): send typed question answers as structured answers, not an option id - #22793
Conversation
…not an option id A typed "Other" answer was packed into the `optionId` of agentSession.respondToQuestion, a field capped at 1024 characters, so a long answer failed with "Invalid option id" and never reached the agent. respondToQuestion now carries per-question `answers` in their own field, bounded like a typed answer, and a host advertises agent-session.question-answers.v1 when it takes them. Clients fall back to the packed option id for older hosts. The host reads either form once into a typed response, records the structured answers on the resolution (and keeps the packed form older clients read), and the Claude and Codex adapters build their reply from the typed answers before the journal commits, so an answer the agent cannot take is refused rather than recorded unanswered. Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Wire:
agentSession.respondToQuestionnow takes structuredanswersthrough a newRespondToQuestionParams(exactly one ofoptionId/answers), whilerespondToApprovalkeepsRespondParams. The host'sreadPromptChoicereads the choice once and unpacks a legacy packedoptionIdinto answers. - Negotiation: new
agent-session.question-answers.v1capability; the desktop client probes it and otherwise packs the answer intooptionIdfor hosts that predate it. - Providers: Claude's
buildClaudePromptReplyand Codex'sprepareCodexPromptAnswervalidate and build the reply before the journal commit, so an answer the provider cannot take is refused before anything is recorded. Claude's unreachable per-question accumulation and thequestionIdForItembinding are removed. - Journal/receipt: optional
resolution.answersadded (schema is non-strict, so old readers ignore it); receipts prefer recorded answers and fall back to the packedselectedOptionIdfor rows written earlier.
I traced the mixed-version matrix and the removed Claude piecewise path, and both hold: no producer ever mints a per-question Claude item, and canonicalize drops undefined on both peers so the client/host operation digests stay equal when one of optionId/answers is absent. Focused suites pass; the cross-version wire suite could not run in this sandbox (shallow clone has no release tags).
ℹ️ Residuals you already scoped
Mobile still packs into optionId, so its long typed answers remain bounded by the 1024-char option-id limit until the follow-up, and the desktop fallback packs without a byte check, so a transient capability-probe failure on a new host can hit that same limit. Both are fail-closed and surfaced as refusals rather than silent drops, so nothing here needs to change for this PR — just flagging that the capability is advertised but not yet consumed by mobile.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
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 (4)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe change adds structured question-answer responses across the renderer, shared RPC contracts, the session host, and Claude and Codex prompt handlers. Hosts advertise support through a runtime capability. The renderer sends structured answers when supported and uses legacy option IDs otherwise. The host validates and resolves both formats, records structured answers alongside packed selections, and passes typed responses to provider adapters. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to No confirmed issue prevents merging after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The new answer format allows longer responses to be recorded and delivered. Existing identity and choice checks remain in place, but cross-version behavior and incomplete coverage leave limited residual risk. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 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 |
Typing an answer deselects a picked option, and picking an option leaves the typed text in the field without sending it, so the card never shows two answers while sending one. Multi-select still sends picked options and typed text together.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Single-select cards now hold one answer: typing clears a picked option and picking an option keeps the text in the field but no longer sends it.
typedAnswerChosenmakes the two mutually exclusive; the pencil swaps to a check and the stray text is muted to show it won't be delivered. - Removed the redundant session-side drop:
NativeChatStructuredSessionno longer rewritesoptionIdsto[]whenotheris present, because the card now guarantees a single-select answer carries exactly one of the two. - Added card tests for the replace-on-type, keep-but-don't-send, re-choose-on-focus, and multi-select cases.
I confirmed the tests are load-bearing: reverting NativeChatQuestionCard.tsx to the pre-commit version makes three of the new tests fail (the aria-pressed assertions and the single-select payload assertion). The change is also necessary for correctness, not just polish — the host's isValidAgentSessionQuestionAnswers requires a non-multi-select answer to have optionIds.length + (other ? 1 : 0) === 1, so without this the pick-then-type combination would have been refused. Focused suites pass (card, receipt, structured session, the new question-answers hook test, interactive-prompt, delivery). The prior review left no inline threads, so nothing to resolve.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
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: 661cf6e1-ef66-4407-9969-e3b11707c218
📒 Files selected for processing (3)
src/renderer/src/components/native-chat/NativeChatQuestionCard.test.tsxsrc/renderer/src/components/native-chat/NativeChatQuestionCard.tsxsrc/renderer/src/components/native-chat/NativeChatStructuredSession.tsx
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
…er; accept untrimmed question ids Clicking or typing in the answer field chooses the typed answer; focus alone no longer does, so tabbing to Submit keeps the option the user picked. A question id is matched exactly by the host, so the wire no longer rejects agent-written ids with edge spaces, which older builds accepted.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Moved the single-select card's "choose the typed text" trigger from
onFocustoonPointerDown, so tabbing through the answer field toward Submit no longer replaces the option the user just picked; clicking the field still re-chooses the retained text. A new test covers both the pointer and keyboard paths, and it fails if the handler is reverted toonFocus. - Accepted untrimmed question ids on
agentSession.respondToQuestion:QuestionAnswer.questionIdis now a plain bounded string instead of the trimmedIdentifier, because Codex model-written ids can carry edge whitespace and the host matches them exactly. The new wire test is load-bearing — reverting the schema makes it returnok:false.
I traced both fixes and they hold. For the question id, the untrimmed value surfaces as a single-question Codex freeTextQuestionId (codexJournalPromptIdPart passes it through raw when ≤256 bytes), and isValidAgentSessionQuestionAnswers does an exact map lookup, so accepting it cannot create a silent mismatch — only the previously rejected legitimate answer now goes through. optionIds still requires trimmed ids, which is correct because those are Orca-generated.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the two commits pushed since the prior pullfrog review (e0364db).
- Re-choose trigger moved from
pointerdowntoclick: the card's answer field now re-chooses the retained typed text ononClick, so a field that is disabled while the answer is sending (React suppresses the synthetic click on disabled form controls) or a scroll drag that starts on the field cannot silently replace a picked option. - Added a disabled-field test and updated the "kept typed text" test to dispatch
click. I verified both are load-bearing in place: revertingNativeChatQuestionCard.tsxtoonPointerDownfails them (2 failed / 11 passed), and the card suite passes on the current head (13/13).
The full diff has no Pullfrog-originated review threads open, so there was nothing to retire.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…stion card Choosing the typed answer is now an entry in the question's selection, set by typing or clicking the field and replaced by picking an option, instead of being inferred from an empty selection. Unpicking an option no longer silently chooses kept text.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the one commit pushed since the prior pullfrog review (08252be).
- Typed answer is now an explicit choice:
NativeChatQuestionCardrecords the typed answer as aTYPED_ANSWER = -1sentinel inside the question's selection, set by typing or clicking the field and replaced by picking an option.typedAnswerChosennow checks that sentinel instead of inferring the answer from an empty selection, andpickedOptionsfilters the sentinel out of every emitted payload. - Unpicking an option leaves nothing chosen: toggling off a picked option no longer silently re-chooses the retained text. This is the behavior the open CodeRabbit thread asked for; the thread is already marked resolved.
- Tests: a new test pins the unpick behavior (it fails on the pre-commit card, where the retained text becomes the chosen answer again), and the multi-select test now clears and retypes the answer.
I traced the sentinel through both emit paths (answerFor, submitAll) and buildAskAnswerKeys, and -1 cannot reach indices. For single-select the selection is [], [optionIndex], or [TYPED_ANSWER], so the answer count stays ≤ 1 and still satisfies the host's isValidAgentSessionQuestionAnswers. The card suite passes (14/14), as do the related NativeChatStructuredSession (18), use-structured-agent-session-question-answers (3), and native-chat-interactive-prompt (26) suites. No prior Pullfrog-originated inline threads were open, so nothing needed retiring.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Review status: ready for review (head
|

ELI5
When an agent in a chat asks you a question, you can type your own answer instead of picking an option. If that typed answer was long (about a paragraph), pressing Submit showed a red "Invalid option id" and the answer never reached the agent. The app was stuffing your typed text into a field meant for a short option name, and that field has a size limit. Now your answer is sent as an answer, in its own field, so long answers go through. The question card also now holds one answer per single-choice question: typing your own answer unpicks the option you had clicked, and clicking an option leaves your typed text in the box but doesn't send it, so what the card shows is what gets sent.
What Changed
Before: a structured Claude or Codex chat question with a typed answer of roughly 1,000+ characters (about 340 for non-English text, which grows when encoded) failed with "Invalid option id", and the question card stayed open.
After: the answer is submitted, the card closes, the receipt shows what you answered, and the agent receives the full text. A typed answer can be up to 64 KiB per question.
Also before: on a single-choice question you could click an option and type an answer, and the card showed both as your answer, but only one was sent (Claude cards kept the text, Codex cards kept the option). After: a single-choice question has exactly one answer. Typing, or clicking back into the answer box, chooses the typed answer and unpicks the option. Clicking an option chooses it and leaves the typed text in the box, greyed and unsent. Moving through the card with Tab doesn't change the choice. Multiple-choice questions still send the picked options and the typed text together.
Mechanism:
agentSession.respondToQuestiontakesanswers— one entry per question with the chosen option ids and optional typed text — instead of packing them intooptionId.respondToApprovalis unchanged: it still takes a short decision id.agent-session.question-answers.v1. The desktop client checks it before building the request (the same pattern as prompt cancel) and sendsanswersto a host that has it, or the old packedoptionIdto a host that does not.answersand also keeps the packedselectedOptionId, because older desktop clients render their answer receipt only from that field.answersare taken exactly as the agent wrote them. Codex question ids are written by the model and may carry edge spaces; the host matches them exactly, and older builds accepted them insideoptionId.Why
The bug is the shape of the data, not the size of the limit. Raising the cap on
optionIdwould have kept typed text inside an id and left every reader parsing it back out. Answers now travel and are stored as answers, the way an approval decision already travels as a decision. The packed form stays only where older peers need it: sent to hosts that predate the field, and written for receipts on older clients.Deliberate deviations and limits:
selectedOptionId.answersin a separate follow-up PR.Linked Issue
Reported directly (no issue filed).
Visual Proof
Same long typed answer (a 1,530-character paragraph) in a real structured Claude chat.
Before (main): Submit shows "Invalid option id" under the card, and the question stays open.
After (this branch): the same long answer typed into a two-question card...
...submits with no error. The answer card shows the full text, and Claude echoes the picked option and the first eight words of the typed answer.
One answer per single-choice question (final build). Clicked "Beta", then typed an answer: Beta is unpicked and the typed answer carries the check.
Typed "Green", then clicked "Blue": Blue is chosen, and "Green" stays in the box, greyed and unsent.
Typed "Medium", clicked "Small", clicked "Small" again: nothing is chosen and the button reads Skip, rather than silently choosing the kept text.
Final build, end to end: "Large" picked on question 1; on question 2 "Circle" was clicked, then a 1,559-character answer typed. Claude replies "Large" and reports the answer's length as 1559, so it received all of it.
Testing
Live: the fix build launched from source in the background on macOS, driven over the DevTools protocol with a real structured Claude chat; the before shot is main with the same long answer.
Wire: long
answersaccepted; sending bothoptionIdandanswers, or neither, refused; a typed answer over 64 KiB (counted in bytes, so multi-byte text is covered) refused; approvals still refuse long ids.Cross-version: the structured agent-session wire suite now also checks that each build accepts
answersexactly when it advertises the capability (current build against the latest release).Host: an older client's packed answer is unpacked into the same structured answer; a long structured answer resolves and is recorded in both forms; mismatched answers are refused without reaching the provider.
Claude and Codex: replies built from typed answers, including a long typed answer; an answer the provider cannot take is refused before the journal commit.
Client: a capable host gets
answers, an older host gets the packed id, approvals send no probe; the receipt prefers recorded answers.Card: typing replaces a picked option; picking an option keeps the text unsent; clicking the box re-chooses it; keyboard focus passing through the box doesn't; a click on the disabled box while sending does nothing; unpicking an option over kept text leaves nothing chosen; multiple-choice sends both. A question id with edge spaces is accepted.
Live on the final build (structured Claude chat, launched from source in the background): all of the card orders above, Tab from a picked option through the box to Next, and a 1,559-character answer delivered in full.
Each new test was checked against the code without its part of the fix (wire schema, host read, Claude and Codex before-commit order, client negotiation, receipt) and fails there.
pnpm tc, changed-code quality gate, React Doctor, rpc params catalog check, and the affected suites (1,892 files) pass.I manually tested these changes locally
Automated tests added/updated, or explained why not below
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
Remote and SSH: the host owns reading the answer, and the new field is negotiated per host, so a paired or SSH host on an older build keeps working with the old form. Mixed versions are covered in both directions. No platform-specific code.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)