Skip to content

Questions: a choice longer than 200 characters can be picked - #1888

Merged
backnotprop merged 2 commits into
mainfrom
fix/inbox-long-choice-pick
Oct 12, 2026
Merged

backnotprop merged 2 commits into
mainfrom
fix/inbox-long-choice-pick

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

The bug

In the Inbox (0.28.17), picking a long choice failed with:

questions[0].answer: "Spike first. Find out what the sign-in grants (… ) …; the placeholder stays off the produ" is not one of the question's choices

Root cause

parseQuestionAnswer (packages/core/question-block.ts) cut every selected label to MAX_QUESTION_CHOICE_LABEL_CHARS (200). The parser only shortens plain-bullet labels to 200 (capChoiceLabel). Task-list labels (- [ ]) are never cut, by design (#1699). So a task-list choice whose label (the text before any — / -, or the whole line when there is none) is longer than 200 characters had a label the answer could never hold:

  • Inbox: the card sent the whole label. checkInboxAnswer ran parseQuestionAnswer, which cut it to 200, then checked it against the stored whole label. The pick was refused (the window and the phone door alike, since both use the same route).
  • Plan review: the pick was saved, but the answer was read back through parseQuestionAnswer, so the card never showed it picked. The export printed the cut label.

Nothing in the client cut or reworded the label. The card sends choice.label as parsed. The "Spike first - find out…" wording in the report was a paraphrase: the cut text matches the label's first 200 characters exactly.

Fix

  • New MAX_QUESTION_SELECTED_CHARS = MAX_QUESTION_BODY_CHARS (20,000). parseQuestionAnswer caps each selected label at this value. A choice lives in a block body of at most that size, so any label round-trips whole. The answer stays bounded.
  • canonicalQuestionAnswer also maps a label an older build cut at 200 back to the one choice whose label (or alias) starts with those 200 characters. When two choices share their first 200 characters, the label stays as stored. So answers saved by older builds show their pick again.
  • These do not change: the parser, choice labels, the — / - split, MAX_QUESTION_CHOICE_LABEL_CHARS (still the plain-bullet cut), questionKey, and the wire (still the same fields). A stored Inbox record keeps its whole labels, so the owner's existing thread can now be picked once this ships.
  • Rendering: the card already shows the whole label (it wraps, it is not cut), so no CSS change was needed.

Workspaces parity

The grammar does not change, so the Workspaces parser needs nothing. A Workspaces validator that checks a pick against the question's choices must not cut picked labels shorter than the labels it compares them with. Its answer cap must be at least the body cap, or it must compare against labels cut to the same cap. The iPhone app sends choice.label from the wire through the door. It now goes through, and needs no change.

Tests

Each test failed before the fix and passes after it:

  • packages/core/question-block.test.ts: long task-list labels with no separator, … - why, and … — why round-trip through parseQuestionAnswer, questionStatus, and the export. The short-lead - split is unchanged. An answer cut at 200 maps back to its choice, and is left as stored when the cut is ambiguous. selected is still bounded.
  • packages/shared/inbox/store-long-choice.test.ts: on a real store, savePicks and sendReply keep the whole label for all three forms, and a replay agrees. An older window's cut answer is stored as the whole label.
  • packages/server/inbox-long-choice.test.ts: a real server. The window's /picks and /reply routes, and a paired phone's door /picks.
  • packages/ui/components/blocks/QuestionBlock.test.tsx (DOM): a click on the long choice saves the whole label, the card shows it picked, and the annotation text is the whole label.

Runs: bun test packages/core packages/shared/inbox (494 pass), bun test packages/server/inbox (214 pass), DOM_TESTS=1 bun test --isolate packages/inbox (228 pass), the question-related ui/editor/archive tests with DOM and --isolate (155 pass), and bun run typecheck. The guides.show viewer manifest is unchanged.

parseQuestionAnswer cut every selected label to 200 characters, while
task-list choice labels are never cut by the parser. A long task-list
choice could therefore never be picked: the Inbox refused it with
"<first 200 chars> is not one of the question's choices", and plan
review's card never showed it picked.

Selected labels are now capped at MAX_QUESTION_SELECTED_CHARS (the
block body cap), so any label round-trips whole. canonicalQuestionAnswer
maps an answer an older build cut at 200 back to its one choice. The
parser, labels and question keys are unchanged.
Review follow-ups on the long-choice fix:
- questionExportItems (and the Inbox's exportItem) pass choices when a
  label is over 200 characters, so an answer an older build cut prints
  the full label in the export (questionChoicesNeedCanonicalLabels).
- canonicalQuestionAnswer keeps its early behavior for questions without
  aliases: a long label only adds an exact lookup of its 200-character
  cut, never case or punctuation matching.
- QuestionBlock DOM test: one card per test, cleaned up by afterEach.
@backnotprop

Copy link
Copy Markdown
Owner Author

Review follow-ups in dbf89c2:

  • The export now prints the full label for an answer an older build cut at 200 characters. questionExportItems and the Inbox's exportItem pass the choices whenever a label is over 200 characters (questionChoicesNeedCanonicalLabels). Covered by a core test and a test of the Inbox reply body.
  • canonicalQuestionAnswer behaves as it did on main for questions without aliases. A long label adds only an exact lookup of its 200-character cut, never case or punctuation matching. A test shows that ship it now. and an uppercased cut stay as stored.
  • QuestionBlock DOM test: one card per test, cleaned up by afterEach.
    Suites: core + shared/inbox 497 pass, server/inbox 214 pass, inbox DOM (--isolate) 228 pass, question-related ui/editor/archive (DOM, --isolate) 157 pass, typecheck passes.

@backnotprop
backnotprop merged commit 722b1fa into main Oct 12, 2026
32 checks passed
@backnotprop
backnotprop deleted the fix/inbox-long-choice-pick branch October 12, 2026 22:22
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.

1 participant