Repository navigation
Questions: a choice longer than 200 characters can be picked - #1888
Merged
Merged
Conversation
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.
Owner
Author
|
Review follow-ups in dbf89c2:
|
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
In the Inbox (0.28.17), picking a long choice failed with:
Root cause
parseQuestionAnswer(packages/core/question-block.ts) cut everyselectedlabel toMAX_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:checkInboxAnswerranparseQuestionAnswer, 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).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.labelas 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
MAX_QUESTION_SELECTED_CHARS=MAX_QUESTION_BODY_CHARS(20,000).parseQuestionAnswercaps eachselectedlabel 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.canonicalQuestionAnsweralso 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.—/-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.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.labelfrom 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… — whyround-trip throughparseQuestionAnswer,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.selectedis still bounded.packages/shared/inbox/store-long-choice.test.ts: on a real store,savePicksandsendReplykeep 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/picksand/replyroutes, 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), andbun run typecheck. The guides.show viewer manifest is unchanged.