Repository navigation
fix(mobile): send typed question answers as structured answers - #23458
Conversation
The phone packed a typed answer into agentSession.respondToQuestion's `optionId`, a field capped at 1024 characters, so a long typed answer was refused and never reached the agent. The phone now builds per-question answers for single and grouped questions and sends them as `answers` when the host advertises agent-session.question-answers.v1, falling back to the packed `optionId` for older hosts. An answer too long to pack is sent as `answers` while the host's support is still unknown, and on a host known to predate the field the phone asks the user to update the computer instead of sending an answer the host must refuse. The host features the phone negotiates for structured sessions (prompt cancel, question answers) travel as one required object from the shared capability probe instead of one optional boolean each.
… default question id
|
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 (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe mobile session hooks now track prompt-cancellation and question-answer support in one host-support object. Question prompts and grouped submissions now produce structured answer values. The response hook sends structured answers when supported, uses a packed legacy option ID when possible, and handles oversized responses according to whether host support is known. The shared option-ID limit is set in one exported constant and used by the RPC contract. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to No newly established issue blocks merging after normal checks. The legacy multi-select path remains unverified. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 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 — full read of the mobile structured-question answer path (18 files), cross-checked against the host handler, the desktop client, and the RPC schema.
- Structured
answerson mobile —structuredQuestionResponseTargetnow yields a per-questionAgentSessionQuestionAnswer, single-question option tokens carry aquestionId, andsendAnswerspicksanswersvs. the legacy packedoptionIdfrom the cached host capability, refusing with an update message when a known-old host cannot take the long form. - Host capability object — the per-feature
agentSessionPromptCancelSupportedboolean is replaced by onestructuredAgentSessionHostSupport(capabilities)object (promptCancel,questionAnswers), threaded through the session lane/controller instead of several flags. - Shared option-id bound —
AGENT_SESSION_RESPONSE_OPTION_ID_MAX_LENGTHmoves intoagent-session-question-answer.tsandMAX_RESPONSE_OPTION_ID_LENGTHaliases it (value unchanged). - Tests — new exact-wire assertions for long/short typed answers, option taps, grouped submits, the update message, and the
q1default; route-parity pins refreshed.
Verified that the single-question packer round-trips through legacyAgentSessionQuestionAnswers, that questionId matches the host's agentSessionPromptQuestions derivation for both freeTextQuestionId and the q1 default, that the new tests assert exact fields (not loose truthiness), and that a schema rejection from an old host in the pre-probe window still surfaces through mutate's onSendError. The connection-window and mixed-version tradeoffs are documented in the PR body.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…e step that overflows Packed grouped answers only grow, so an overflow on an earlier step could never reach an older host. Refusing it only at the final submit left the long text folded into the draft with no way to shorten it short of cancelling the question.
There was a problem hiding this comment.
✅ No blocking issues — the new commit closes the earlier-step overflow cleanly.
Reviewed changes — incremental delta since the prior pullfrog review at 521fc5e8 (commit 1faefb8), read against the full 18-file PR diff.
- Refuse a grouped answer while its text is still editable —
respondQuestionnow stops on the grouped advance step whose accumulated answers first pack over the 1,024-char option-id cap for a known-old host, shows the update message, and leaves the draft unset so the typed text can be shortened there. - Shared message + helper — the update message is extracted to
ANSWER_TOO_LONG_FOR_HOSTand apackedAnswerTooLonghelper now backs both the advance-step guard and the existing submit-time refusal. - Test — pins the early refusal: no mutation sent, no draft stored, update message shown.
ℹ️ The advance-step guard can still leave a grouped question unsolvable
The guard refuses the first step whose accumulated pack exceeds the cap, but when earlier stored answers already leave less than one answer's worth of room (or the first overflow lands on an option-only final question), no answer on the current step can fit, so the user gets the update message with no reachable way to shorten the earlier text. This is pre-existing on main and the commit is a net improvement, so it is not blocking — worth confirming whether the residual is intended.
Technical details
# Grouped overflow guard can still dead-end
## Affected sites
- `mobile/src/session/use-mobile-structured-prompt-responses.ts:133` — advance-step refusal
- `mobile/src/session/use-mobile-structured-prompt-responses.ts:105` — submit-time refusal in `sendAnswers`
## Detail
`packedAnswerTooLong` refuses the first advance step whose accumulated pack exceeds 1,024. The group's
JSON grows with each answer, so an earlier step can be stored with a pack within ~one answer's overhead
of the cap (`L(k-1)` above ~975). Every later required answer then overflows, and since the current
step's text is the only editable part, it may not be shortenable enough to get under the cap. The same
happens when the first overflow lands on the final step and that question is option-only. In both the
user sees "Update Orca on your computer…" and cannot edit the bulk that caused it.
## Required outcome
- Confirm the residual is acceptable, or give the user a way to recover.
## Open questions for the human
- Should the guard leave headroom for the remaining questions, or is this boundary case acceptable?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: 86bfc65b-1f6d-418e-80fe-5d8c31d629d7
📒 Files selected for processing (2)
mobile/src/session/use-mobile-structured-prompt-responses.test.tsxmobile/src/session/use-mobile-structured-prompt-responses.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| // Refuse while this step's text is still editable, not on a later step that cannot fit. | ||
| if ( | ||
| questionAnswersSupported === false && | ||
| packedGroupCannotFit(prompt.body.questions, grouped.draft.answers) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect capability updates and grouped-draft navigation without running repository code.
rg -n -C 5 'questionAnswersSupported|groupedDraft|setCollected' mobile/src/sessionRepository: stablyai/orca
Length of output: 33311
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- hook ---'
sed -n '1,240p' mobile/src/session/use-mobile-structured-prompt-responses.ts
printf '%s\n' '--- grouped projection and navigation ---'
sed -n '1,280p' mobile/src/session/mobile-structured-agent-prompts.ts
printf '%s\n' '--- host support references ---'
rg -n -C 8 'hostSupport|questionAnswers|capabilit' mobile/src/session/use-mobile-structured-agent-session.ts mobile/src/session mobile/src | head -n 320
printf '%s\n' '--- focused tests ---'
sed -n '1,520p' mobile/src/session/use-mobile-structured-prompt-responses.test.tsxRepository: stablyai/orca
Length of output: 42342
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- host support type and producers ---'
rg -n -C 10 'StructuredAgentSessionHostSupport|hostSupport\s*:|useMobileStructuredAgentSession\(' mobile src --glob '!**/*.test.*' | head -n 400
printf '%s\n' '--- grouped helper ---'
wc -l mobile/src/session/mobile-structured-grouped-question.ts
cat -n mobile/src/session/mobile-structured-grouped-question.ts
printf '%s\n' '--- grouped question UI consumers ---'
rg -n -C 8 'projectGroupedQuestion|groupedDraft|multiSelect|freeTextToken|optionTokens' mobile/src --glob '!**/use-mobile-structured-prompt-responses.test.tsx' | head -n 400Repository: stablyai/orca
Length of output: 41910
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- grouped helper exact ---'
cat -n mobile/src/session/mobile-structured-grouped-question.ts
printf '%s\n' '--- capability state update ---'
sed -n '30,180p' mobile/src/session/use-mobile-session-feedback-capabilities.ts
printf '%s\n' '--- capability probe references ---'
rg -n -C 12 'setAgentSessionHostSupport|structuredAgentSessionHostSupport\(' mobile/src --glob '!**/*.test.*'
printf '%s\n' '--- native question response contract ---'
cat -n mobile/src/session/mobile-native-chat-question.ts | sed -n '1,220p'Repository: stablyai/orca
Length of output: 37184
Allow editing of earlier grouped answers after legacy support is detected.
If questionAnswersSupported changes from null to false while a grouped draft is open, the existing draft is retained. The UI then shows only the next unanswered question. The final legacy submission can reject the packed answers as too long, with no path to shorten the earlier answer.
Reset the draft to the first question, or provide prior-step editing, when the capability change makes the draft exceed the legacy limit.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — incremental delta since the prior pullfrog review at 1faefb8a (commits 4c0f544 and 581f42c), read against the full 18-file PR diff.
- Packed answer length checked once, at send — the grouped advance-step guard (
packedGroupCannotFit/shortestPackedAnswer) was removed fromrespondQuestion;sendAnswersnow owns the length check, and since a submit-time refusal never callssetCollected, the overflowing step's card stays shown and its text stays answerable. - Update message reworded — "Update Orca on your computer to send an answer this long" is now "…send answers this long", carrying the structured-answers framing for both single and grouped questions.
- Tests restructured — a new
answer wireblock pins the exact RPC fields for long/short typed answers, option taps, grouped submits, the update message, and theq1default, including a test that a grouped draft a known-old host cannot take is retained and lands asanswersonce the capability flips true.
The simplification is sound: the submit branch never stores the advanced draft, so the send-time refusal reproduces the guard's "text stays editable" property without a second length calculation. The residual dead-end for pre-answers hosts (an option-only overflowing step) is unchanged in kind from what the guard narrowed and is documented in the PR body.
ℹ️ The PR description still describes the removed guard
The "What Changed" and "Testing" sections describe the grouped advance-step guard and its dedicated test, both removed by 581f42c, and quote the old message text.
Technical details
# Stale PR description after the guard removal
## Affected sites
- PR body "What Changed", bullet 2: "In a group of questions this happens on the step whose answer leaves no room for even the shortest answers to the questions still to come, so that text can still be shortened there instead of the card getting stuck on a later step." — `packedGroupCannotFit` and that step-selection logic no longer exist.
- PR body "Testing": "one more test, for a grouped step that leaves no room for the next question, fails without the room check." — that test was deleted.
- PR body "What Changed", bullet 1: quotes "Update Orca on your computer to send an answer this long" — the string is now "…send answers this long".
## Required outcome
- Refresh the description so it matches the shipped behavior: the length check happens once in `sendAnswers` at submit, and the refusal message is the "answers" wording.
## Open questions for the human
- Is the guard removal intended as final? If so, the residual dead-end note in "Notes" (pre-answers host, option-only overflow step) should probably stay and the guard paragraph should go.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏






ELI5
When an agent in a phone chat asks you a question, you can type your own answer instead of picking an option. A long typed answer (about a paragraph or more) was refused and never reached the agent, because the phone squeezed your text into a field meant for a short option name. #22793 gave the desktop and the computer running the agent a proper answer field. This PR makes the phone use it too, so long answers typed on the phone go through.
What Changed
Before: on the phone, answering a Claude or Codex chat question with a long typed answer (roughly 750 to 1,000 characters or more, depending on the agent and the text, because the phone packed the answer into a field limited to 1,024 characters after escaping) showed a red "Invalid option id" under the question, and the question stayed open. The agent never got the answer.
After: the phone sends the typed answer as an answer. The question closes and the agent receives the full text. This works for a single question and for a group of questions answered one step at a time. Answers are limited to the same 64 KB per question as on desktop.
How it works:
agent-session.question-answers.v1), the phone sendsanswers. When the computer is known to be older, the phone sends the old packedoptionIdbuilt by the same shared function the desktop uses, so older computers get exactly what the phone sent before. An answer too long for the packed form cannot reach an older computer at all, so the phone shows "Update Orca on your computer to send answers this long" and keeps the typed text instead of sending something that must be refused. The length is checked once, when the answer is sent. For a group of questions that means the last step: on computers older than v1.4.214, a grouped question whose combined answers are too long is refused at the last step with the update message, the answers stay on the card, and Cancel stays available. That is the same shape as before this PR, where the last step showed "Invalid option id".answers(the only form that can work).Why
This mirrors #22793 on the phone: answers travel as answers, and the packed form is kept only for computers that predate the answer field. Computers on current main already accept both forms, so this changes only what the phone sends and when.
Reusing the phone's existing capability check avoids a second cache of what the computer supports. The alternative, another true/false value threaded beside the prompt-stop one, would have grown the plumbing each time a new chat feature is negotiated.
One difference from desktop, on purpose: desktop asks the computer at send time, while the phone reads the capability check it already runs once per connection. The phone's version also refuses up front, with an update message, the one case an older computer is certain to reject.
Linked Issue
Follow-up to #22793 (reported directly, no issue filed).
Visual Proof
Android emulator, phone app from origin/main (before) and from this branch (after), paired to the same Orca dev build running a real Claude chat. The typed answer is 1,545 characters and ends with
END-MARKER-7731. Claude was asked to reply with the first words of the answer, its last word, and how many times "replacement" appears (18).END-MARKER-7731, and18.Beta,END-MARKER-7731,18.Re-run on the final head (581f42c), including a computer older than the answer field (v1.4.212):
Testing
Live phone check on an Android emulator (Android 16 image) against an Orca dev build on macOS, with a real Claude chat, three scenarios on each side:
answers.Beta/END-MARKER-7731/18.Automated tests pin exactly what the phone sends for a single question and a grouped question, with the computer supporting the answer field, not supporting it, and not yet known: long typed answers, short typed answers, option taps, the update message, and the default question id. One test pins the older-computer group case: the long answer on step 1 moves on, the last step shows the update message and keeps the answers, and if the phone then learns the computer supports answers, the same last step sends both answers. Reverting the phone's answer building and sending to main fails 13 of these tests.
Mobile typecheck, mobile session tests (1,821; one unrelated image-upload test timed out under heavy machine load and passes when rerun with a longer timeout),
pnpm tc,pnpm run check:code-quality:changed, and oxlint on every changed file pass.verify:rpc-params-catalogis unchanged.Final head (581f42c), same rig: the single and grouped long answers and the option-only answer were delivered again, and a phone paired to Orca v1.4.212 (before the answer field) showed the update message with the typed text kept, while an option tap on that card still went through.
Not run live: Codex chats (covered by the same tests; Codex questions take the single-question path).
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
Mixed versions: a new phone on an older computer sends the old packed form for answers that fit (unchanged behavior) and shows an update message for answers that cannot; an old phone on a new computer keeps sending the packed form, which the computer still accepts. In the brief moment after connecting, before the phone knows what the computer supports, an answer too long to pack sent to an older computer is refused with that computer's own error, and the typed text stays in the card. The option tokens whose format changed exist only while a card is on screen and are never stored. No platform-specific code; SSH and relay computers negotiate the same way as local ones. No new requests or polling: the phone reuses its existing capability check.
Not changed here: after a question is answered, the phone shows the question with its options but not which option or text was chosen. That is the same on main.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)