Repository navigation
fix(ChatComposerInput): restore tokens from loaded or recalled drafts through deserialize - #9739
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| ChatComposer | 92.3 kB (+219 B) · 13.6 kB CSS (0) | — | ✗ · ✓ · — |
| ChatComposerTokenElement | 89.4 kB (+218 B) · 12.6 kB CSS (0) | — | ✗ · ✓ · — |
| ChatComposerInput | 89.4 kB (+217 B) · 12.6 kB CSS (0) | — | ✗ · ✓ · — |
17 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| ChatComposerDrawer | 18.6 kB (0) · 4.8 kB CSS (0) | — | ✗ · ✓ · — |
| ChatDictationButton | 69.2 kB (0) · 11.2 kB CSS (0) | — | ✗ · ✓ · — |
| ChatLayout | 92.3 kB (0) · 11.7 kB CSS (0) | — | ✗ · ✓ · — |
| ChatLayoutScrollButton | 69.1 kB (0) · 11.4 kB CSS (0) | — | ✗ · ✓ · — |
| ChatMessage | 17.4 kB (0) · 3.7 kB CSS (0) | — | ✗ · ✓ · ✓ |
| ChatMessageBubble | 7.7 kB (0) · 3.8 kB CSS (0) | — | ✗ · ✓ · ✓ |
| ChatMessageList | 29.0 kB (0) · 7.4 kB CSS (0) | — | ✗ · ✓ · — |
| ChatMessageMetadata | 21.0 kB (0) · 4.2 kB CSS (0) | — | ✗ · ✓ · — |
| ChatSendButton | 69.0 kB (0) · 11.2 kB CSS (0) | — | ✗ · ✓ · — |
| ChatSystemMessage | 7.2 kB (0) · 3.8 kB CSS (0) | — | ✗ · ✓ · — |
| ChatTokenizedText | 7.8 kB (0) · 4.1 kB CSS (0) | — | ✗ · ✓ · — |
| ChatToolCalls | 33.5 kB (0) · 8.8 kB CSS (0) | — | ✗ · ✓ · — |
| Chat | — | — | ✗ · ✓ · — |
| lab/CommentThread | 385.8 kB (+264 B) · 2.4 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 188.9 kB (+234 B) · 1.9 kB CSS (0) | — | — · — · — |
| lab/Comments | 392.6 kB (+231 B) · 2.5 kB CSS (0) | — | — · — · — |
| chat | — | — | — · ✓ · — |
Visual changes: 4 snapshots in 1 component
A change is a question for the reviewer, not a failure.
Inheritance checked against the 6 newest reports of other pull requests.
Package size:
- @astryxdesign/cli 6.33 MB packed (+143 B); no new dependencies
- @astryxdesign/core 8.02 MB packed (+996 B); no new dependencies
Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Approval needs an engineering owner's decision first. Two fixes are also needed whatever that decision is. You're right that deserialize is never called today, and both new tests fail without this change.
Owner decision needed. No current ChatComposerInput spec clause says that loading a value or recalling history should rebuild tokens through deserialize. No clause says which matching rule applies either: this PR passes each whitespace-separated word to deserialize and keeps a token only when its value equals that word. An engineering owner records that decision by adding the clause to the spec or by commenting /approve-spec with the full head SHA (the author may do so if they are an engineering owner); you don't need to write the spec yourself.
Blocking:
restoreValuemakes every restored draft one text node per word, so a multi-word@query typed into a loaded draft no longer opens its menu (FR11), and an@typed after a restored no-break space now opens one (FR10). Please keep each run of plain text in a single text node and add a test for the multi-word case.- The Changeset says inline tokens are restored in general, but only tokens whose serialized value is one whitespace-free word come back, so please narrow the wording to match.
[Automated review]
d8cb611 to
6dc1313
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's decision, and two fixes are needed whatever that decision is; the earlier text-node split and Changeset wording are fixed in this revision.
Owner decision needed. No current ChatComposerInput spec clause says that loading a value or recalling history should rebuild tokens through deserialize, or that only a whitespace-delimited word whose deserialized token keeps the same value comes back as a token. An engineering owner records that decision by adding the clause to the spec or by commenting /approve-spec <full head SHA> on this pull request (the author may do so if they are an engineering owner); you don't need to write the spec yourself.
Blocking:
- Newly live check:
ChatComposerInput.tsx:606writes the latest-valuerestoreValueRefduring render, which the component runtime rules now forbid, so please rebase onmainand write it withuseCommittedRefInto(restoreValueRef, …)instead. - The description says the pull request "remains a draft" while it is open for review, so please mark it as a draft or reword that sentence.
CI has not run on this revision yet; a maintainer adds the ci:run label so it runs.
Claims and files checked
- Claim: recalling a sent mention shows plain text on the base and the token on this branch: verified in code (base restore paths assign
textContent;restoreValuerebuilds tokens) and in the recall test; not executed here. - Claim: loading the same value through
valueloses the token on the base and keeps it here: verified in code and in the load test; not executed here. - Claim: the base restore paths bypass
deserialize: verified (ChatComposerInput.tsxbase lines 556, 741, 792, 800, 806). - Claim: each whitespace-delimited word is offered to the deserializers and kept only on an exact
valuematch: verified (useChatComposerTokens.ts:176-186). - Claim: unmatched text and whitespace stay unchanged, and token values with whitespace stay plain text: verified (split and equality check).
- Claim: each plain-text run stays one text node, keeping multi-word queries and no-break-space boundaries: verified (
useChatComposerTokens.ts:175-205) and covered by two tests. - Claim: controlled echoes do not rebuild the DOM and an external load emits no
onChange: verified (ChatComposerInput.tsx:551-561; load test). - Claim: the mention examples now supply deserializers: verified (every non-test
@trigger in the stories and templates sets one). - Claim: token creation is shared with insertion and restoration stays internal: verified (
createTokenPortal; the internal hook is not exported from a package entry). - Claim: no new public API, styling, story or
.doc.mjschange, and the listed file inventory: verified. - Claim: the current component spec does not define restoration or the matching rule: verified.
- Claim: the pull request remains a draft: false (it is open for review).
- Claim: three of the four tests fail on the base and the first revision broke multi-word and no-break-space queries: consistent with the code; not re-run here.
- Claim: tests, typecheck, build and lint passed: not re-run here.
- Claim: the full-suite stop is in a CLI test this change does not touch: verified (no CLI test or command file changed).
- Changeset: restores a token when a whitespace-delimited word deserializes to a token with the same value, values with whitespace stay plain text, examples include deserializers: verified.
- File
.changeset/fix-chat-composer-deserialize.md: clear. - File
apps/storybook/stories/ChatComposerInput.stories.tsx: clear. - File
apps/storybook/stories/ChatLayout.stories.tsx: clear. - File
packages/cli/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx: non-blocking, thedeserializeparameter hides the component'svaluestate. - File
packages/cli/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.tsx: non-blocking, same shadowing. - File
packages/cli/assets/templates/pages/ai-chat-landing/page.tsx: clear. - File
packages/core/src/Chat/ChatComposerInput.test.tsx: clear. - File
packages/core/src/Chat/ChatComposerInput.tsx: blocking, render-time ref write at line 606. - File
packages/core/src/Chat/useChatComposerTokens.ts: non-blocking, the file header does not mention restoration; otherwise clear.
|
/approve-spec 6dc1313 |
6dc1313 to
9612835
Compare
There was a problem hiding this comment.
Changes requested for one description sentence: an engineering owner has approved restoring tokens through deserialize with the exact-value rule for this revision, and the code has no blocking finding.
Blocking:
- The Evidence section's "so it does not fully close #4655" contains GitHub's closing keyword ("close #4655"), which GitHub reads without the negation, so merging would close #4655 while its own paste-as-token reproduction still fails; rewording it to, for example, "so #4655 stays open for the paste-as-token case" fixes this (the "refs #4655" link is fine).
Non-blocking: the public useChatComposerTokens now also returns the restore function at runtime, and the rewrapped caret comment in ChatComposerInput.tsx could use shorter sentences (see the inline notes). The newest CI run on this revision stopped at admission because CI was full, with no test failure; the earlier run on the same revision passed, so CI needs a re-run before merge.
Claims and files checked
- Claim: on the base, recalling a sent mention with ArrowUp shows plain
@cindyinstead of the badge: verified (the base restore paths write the serialized text directly; the MentionTrigger story recalls plain text on the base) and by the recall test, which fails on the base. - Claim: loading the same value through
valueloses the badge on the base: verified in code and by the load test, which fails on the base. - Claim: both restore paths bypass the trigger's
deserialize: verified (the base never calls it). - Claim: each whitespace-delimited word goes to the deserializers and becomes a token only when the returned
valueequals that word: verified (useChatComposerTokens.ts:176-189). - Claim: unmatched text and whitespace stay unchanged, and token values containing whitespace stay plain text: verified.
- Claim: each plain-text run stays one text node, so multi-word queries and no-break-space boundaries keep working: verified (
useChatComposerTokens.ts:175-205) and covered by two tests. - Claim: controlled echoes do not rebuild the DOM and loading an external value emits no extra
onChange: verified (ChatComposerInput.tsx:552-571) and asserted by the load test. - Claim: the existing mention examples now supply deserializers: verified (all twelve
@triggers in the stories and templates). - Claim: the
deserializedocumentation describes rebuilding tokens when a message is loaded for editing: verified (ChatComposerInput.tsx:172-176). - Claim: the component contract keeps echo handling, boundary-only recall, no-break-space boundaries, multi-word queries and portal cleanup: verified.
- Claim: this repairs the documented
deserializecontract and needs no engineering-owner decision: settled, since an engineering owner approved this revision; the component spec does not state the rule yet. - Claim: the pull request is ready for review: verified (open, not a draft).
- Claim: two implementation files, four test cases, two story files, three templates and one patch Changeset for Core and CLI: verified.
- Claim: the examples only add mention deserializers: verified (one story also names its item list so its deserializer can search it).
- Claim: token creation is shared with insertion and restoration stays internal: verified for the declared types (
createTokenPortal; the internal hook is not exported from a package entry); the public hook's runtime value also carries the restore function (non-blocking note). - Claim: no new public API, styling, story or
.doc.mjschange, and no recordings or media in the diff: verified (the generated API change list for this revision is empty). - Claim: after the change both paths restore the badge while the draft stays
@cindy: verified by the load and recall tests and the MentionTrigger story in Chromium. - Claim: the default paste-as-token badge is not restored and this pull request does not change it: verified (restoration asks only the triggers'
deserialize); the sentence's wording is the blocking finding above. - Claim: selecting and sending a mention, plain text, whitespace, multi-word selection and the no-break-space boundary keep working: verified in code and by the existing and new tests; the recordings were not checked.
- Claim: three of the four tests fail on the base, and the first revision broke multi-word and no-break-space queries: the first part re-run and verified (the no-break-space test passes on the base); the second consistent with the code history, not re-run.
- Claim: the history test uses the real composer with no imperative insertion or private selectors: verified.
- Claim: the attached recordings predate the review follow-up: not checked; they are outside the diff.
- Claim: no new public API, visual representation, default or unrelated interaction model, and no internal context in public text: verified.
- Claim: 502 Chat tests across 25 files, typecheck, build and lint pass: the Chat tests re-run and verified (502 passed in 25 files); typecheck, lint and build passed in CI on this revision.
- Claim: the full-suite stop is in a CLI test this change does not touch: verified (no CLI test or command changed).
- Changeset: restores a token when a whitespace-delimited word of a loaded or recalled draft deserializes to a token with the same value, token values with whitespace stay plain text, and the mention examples include deserializers: verified.
- File
.changeset/fix-chat-composer-deserialize.md: clear. - File
apps/storybook/stories/ChatComposerInput.stories.tsx: clear. - File
apps/storybook/stories/ChatLayout.stories.tsx: clear. - File
packages/cli/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx: clear. - File
packages/cli/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.tsx: clear. - File
packages/cli/assets/templates/pages/ai-chat-landing/page.tsx: clear. - File
packages/core/src/Chat/ChatComposerInput.test.tsx: clear. - File
packages/core/src/Chat/ChatComposerInput.tsx: non-blocking, the rewrapped caret comment keeps a long sentence; otherwise clear. - File
packages/core/src/Chat/useChatComposerTokens.ts: non-blocking, the public hook's runtime value also carries the restore function; otherwise clear.
|
/approve-spec 9612835 |
There was a problem hiding this comment.
Approved pending CI: CI has not finished on this revision yet.
Loaded and recalled drafts rebuild their tokens through each trigger's deserialize with the exact-value rule an engineering owner approved on this pull request, and the restore code is unchanged since that approval. This revision merges main, which brings no change to the restore code or its tests' outcome. Nothing else is required.
Claims and files checked
Review mode: full; reason: author-not-engowner
- Claim: on the base, recalling a sent mention with ArrowUp shows plain
@cindytext instead of the badge: verified (the recall test fails on the base; in Chromium the MentionTrigger story recalls no token on the base). - Claim: loading the same value through
valuealso loses the badge on the base: verified (the load test fails on the base). - Claim: both restore paths write the serialized text directly and bypass
deserialize: verified (every base restore path assignstextContent, and no base code callsdeserialize). - Claim: each whitespace-delimited word goes to the deserializers, and a token is rebuilt only when its returned
valueequals that word: verified (useChatComposerTokens.ts:181-192). - Claim: unmatched text and whitespace stay unchanged, and serialized values containing whitespace stay plain text: verified (
useChatComposerTokens.ts:181-210; the load test). - Claim: each plain-text run stays one text node, so multi-word queries and no-break-space boundaries keep working: verified (two tests pass here and fail on this pull request's first, unbuffered commit).
- Claim: controlled echoes still skip the rebuild, and loading an external value emits no extra
onChange: verified (ChatComposerInput.tsx:556-560; the load test asserts it). - Claim: the existing mention examples now supply deserializers: verified (all twelve
@triggers in the two story files and the three templates). - Claim: the
deserializedocumentation describes rebuilding tokens when a message is loaded for editing: verified (ChatComposerInput.tsx:172-176). - Claim: the component contract keeps echo handling, boundary-only recall, no-break-space boundaries, multi-word queries and portal cleanup: verified against the current contract and the tests.
- Claim: this repairs the documented contract and needs no engineering-owner decision: settled either way, since the component contract has no clause for
deserializeand an engineering owner approved the direction on this pull request. - Claim: two implementation files, four interaction regression tests, two story files, three templates and a patch Changeset for Core and CLI: verified; a fifth test pins the public hook's members.
- Claim: the examples only add mention deserializers: verified (one story also names its item list so its deserializer can search it).
- Claim: token creation is shared with insertion, and restoration stays internal: verified (
createTokenPortal; the public hook strips the restore function,useChatComposerTokens.ts:111-121). - Claim: no new public API, styling, story or
.doc.mjschange, and no recordings or media in the diff: verified (the built public surface matches the base row for row). - Claim: after the change both paths restore the badge while the draft stays
@cindy: verified by the load and recall tests and the MentionTrigger story in Chromium. - Claim: the default paste-as-token badge is not restored, and #4655 stays open for it: verified (restoration asks only the triggers; the description uses no closing keyword).
- Claim: selecting and sending a mention, plain-text recall, unmatched text, whitespace, multi-word selection and the no-break-space boundary keep working: verified by the existing and new tests.
- Claim: three of the four tests fail with the base implementation, and the original unbuffered implementation breaks the multi-word and no-break-space cases: verified (three fail on the base; on this pull request's own first, unbuffered commit the multi-word and no-break-space tests fail, standing in for the commit the description names, which this repository does not hold).
- Claim: the history test uses the real composer with no imperative insertion or private selectors: verified.
- Claim: the recordings' setup, and that they predate the follow-up: not used as evidence, since they are attachments outside the diff; the commit history agrees that the text-run fixes came later, and an independent Chromium run shows the same before and after.
- Claim: no new visual representation, default or unrelated interaction model, and no internal context in public text: verified.
- Claim: tests, typecheck, build and lint pass at the commit the description names: checked at this revision instead, since that commit is no longer in the branch: 504 Chat tests in 25 files pass, Core and CLI typecheck pass, Core and the themes build, and lint reports no error on the changed files.
- Changeset: restores a token when a whitespace-delimited word of a loaded or recalled draft deserializes to a token with the same value; values with whitespace stay plain text; the mention examples include deserializers: verified.
- File
.changeset/fix-chat-composer-deserialize.md: clear. - File
apps/storybook/stories/ChatComposerInput.stories.tsx: clear. - File
apps/storybook/stories/ChatLayout.stories.tsx: clear. - File
packages/cli/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx: clear. - File
packages/cli/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.tsx: clear. - File
packages/cli/assets/templates/pages/ai-chat-landing/page.tsx: clear. - File
packages/core/src/Chat/ChatComposerInput.test.tsx: clear. - File
packages/core/src/Chat/ChatComposerInput.tsx: clear. - File
packages/core/src/Chat/useChatComposerTokens.ts: clear.
|
@cixzhang Thanks for adding |
There was a problem hiding this comment.
Approved pending CI: the build, test and docsite checks are deferred until review passes and have not run on this revision yet.
Loaded and recalled drafts rebuild their tokens through each trigger's deserialize with the exact-value rule an engineering owner approved on this pull request, and the restore code is unchanged since that approval. This revision only merges main, which changes neither the restore code nor the outcome of its tests. Nothing else is required.
Claims and files checked
Review mode: full; reason: author-not-engowner
- Claim: on the base, recalling a sent mention with ArrowUp shows plain
@cindytext instead of the badge: verified (the recall test fails on the base; in Chromium the MentionTrigger story recalls no token on the base). - Claim: loading the same value through
valuealso loses the badge on the base: verified (the load test fails on the base). - Claim: both restore paths write the serialized text directly and bypass
deserialize: verified (every base restore path assignstextContent, and no base code callsdeserialize). - Claim: each whitespace-delimited word goes to the deserializers, and a token is rebuilt only when its returned
valueequals that word: verified (useChatComposerTokens.ts:181-193). - Claim: unmatched text and whitespace stay unchanged, and serialized values containing whitespace stay plain text: verified (
useChatComposerTokens.ts:181-210; the load test). - Claim: each plain-text run stays one text node, so multi-word queries and no-break-space boundaries keep working: verified (both tests pass here and fail on this pull request's first, unbuffered commit).
- Claim: controlled echoes still skip the rebuild, and loading an external value emits no extra
onChange: verified (ChatComposerInput.tsx:556-559; the load test asserts it). - Claim: the existing mention examples now supply deserializers: verified (all twelve
@triggers in the two story files and the three templates). - Claim: the
deserializedocumentation describes rebuilding tokens when a message is loaded for editing: verified (ChatComposerInput.tsx:172-176). - Claim: the component contract keeps echo handling, boundary-only recall, no-break-space boundaries, multi-word queries and portal cleanup: verified against the current contract and the tests.
- Claim: this repairs the documented contract and needs no engineering-owner decision: settled either way, since the component contract has no clause for
deserializeand an engineering owner approved the direction on this pull request. - Claim: two implementation files, four interaction regression tests, two story files, three templates and a patch Changeset for Core and CLI: verified; a fifth test pins the public hook's members.
- Claim: the examples only add mention deserializers: verified (one story also names its item list so its deserializer can search it).
- Claim: token creation is shared with insertion, and restoration stays internal: verified (
createTokenPortal; the public hook strips the restore function,useChatComposerTokens.ts:111-121). - Claim: no new public API, styling, story or
.doc.mjschange, and no recordings or media in the diff: verified (the built public surface matches the base row for row). - Claim: after the change both paths restore the badge while the draft stays
@cindy: verified by the load and recall tests and the MentionTrigger story in Chromium. - Claim: the default paste-as-token badge is not restored, and #4655 stays open for it: verified (restoration asks only the triggers; the description uses no closing keyword).
- Claim: selecting and sending a mention, plain-text recall, unmatched text, whitespace, multi-word selection and the no-break-space boundary keep working: verified by the existing and new tests.
- Claim: three of the four tests fail with the base implementation, and the original unbuffered implementation breaks the multi-word and no-break-space cases: verified (three fail on the base; on this pull request's own first, unbuffered commit the multi-word and no-break-space tests fail, standing in for the earlier commit the description names, which this repository does not hold).
- Claim: the history test uses the real composer with no imperative insertion or private selectors: verified.
- Claim: the recordings' setup, and that they predate the follow-up: not used as evidence, since they are attachments outside the diff; an independent Chromium run at this revision shows the same before and after.
- Claim: no new visual representation, default or unrelated interaction model, and no internal context in public text: verified.
- Claim: tests, typecheck, build and lint pass at the commit the description names: checked at this revision instead, since that commit is no longer in the branch: 516 Chat tests in 27 files pass, Core and CLI typecheck pass, Core and the themes build, lint reports no error on the changed files, and CI's lint and typecheck jobs pass.
- Changeset: restores a token when a whitespace-delimited word of a loaded or recalled draft deserializes to a token with the same value; values with whitespace stay plain text; the mention examples include deserializers: verified.
- File
.changeset/fix-chat-composer-deserialize.md: clear. - File
apps/storybook/stories/ChatComposerInput.stories.tsx: clear. - File
apps/storybook/stories/ChatLayout.stories.tsx: clear. - File
packages/cli/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx: clear. - File
packages/cli/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.tsx: clear. - File
packages/cli/assets/templates/pages/ai-chat-landing/page.tsx: clear. - File
packages/core/src/Chat/ChatComposerInput.test.tsx: clear. - File
packages/core/src/Chat/ChatComposerInput.tsx: clear. - File
packages/core/src/Chat/useChatComposerTokens.ts: clear.
There was a problem hiding this comment.
Approved pending CI: the build, test and docsite checks waited for review and have not finished on this revision yet.
Loaded and recalled drafts rebuild their tokens through each trigger's deserialize with the exact-value rule an engineering owner approved on this pull request, and the restore code is unchanged since that approval. This revision only merges main, which changes none of this pull request's files. Nothing else is required from you; those checks must pass before merge.
Claims and files checked
Review mode: full; reason: author-not-engowner
- Claim: on the base, recalling a sent mention with ArrowUp shows plain
@cindytext instead of the badge: verified (every base recall path assignstextContent, and no base code callsdeserialize; the recall test asserts it). - Claim: loading the same value through
valuealso loses the badge on the base: verified (the base controlled sync assignstextContent; the load test asserts it). - Claim: both restore paths write the serialized text directly and bypass
deserialize: verified (the lines this pull request replaces). - Claim: each whitespace-delimited word goes to the deserializers, and a token is rebuilt only when its returned
valueequals that word: verified (useChatComposerTokens.ts:181-194). - Claim: unmatched text and whitespace stay unchanged, and serialized values containing whitespace stay plain text: verified (
useChatComposerTokens.ts:196-210). - Claim: each plain-text run stays one text node, so multi-word queries and no-break-space boundaries keep working: verified (
useChatComposerTokens.ts:196-210; the multi-word and no-break-space tests). - Claim: controlled echoes still skip the rebuild, and loading an external value emits no extra
onChange: verified (ChatComposerInput.tsx:556-559; the sync at:547-577calls no callback; the load test asserts it). - Claim: the existing mention examples now supply deserializers: verified (all twelve
@triggers in the two story files and the three templates). - Claim: the
deserializedocumentation describes rebuilding tokens when a message is loaded for editing: verified (ChatComposerInput.tsx:172-176). - Claim: the component contract keeps echo handling, boundary-only recall, no-break-space boundaries, multi-word queries and portal cleanup: verified against the current contract and the code.
- Claim: this repairs the documented contract and needs no engineering-owner decision: settled either way, since the component contract has no clause for
deserializeand an engineering owner approved the direction on this pull request. - Claim: two implementation files, four interaction regression tests, two story files, three templates and a patch Changeset for Core and CLI: verified; a fifth test pins the public hook's members.
- Claim: the examples only add mention deserializers: verified (one story also names its item list so its deserializer can search it).
- Claim: token creation is shared with insertion, and restoration stays internal: verified (
createTokenPortal; the public hook strips the restore function,useChatComposerTokens.ts:111-121). - Claim: no new public API, styling, story or
.doc.mjschange, and no recordings or media in the diff: verified from the source diff. - Claim: after the change both paths restore the badge while the draft stays
@cindy: verified in code (a token span serializes back to itsvalue); the load and recall tests assert it and run in the pending test check. - Claim: the default paste-as-token badge is not restored, and #4655 stays open for it: verified (restoration asks only the triggers; the description uses no closing keyword).
- Claim: selecting and sending a mention, plain-text recall, unmatched text, whitespace, multi-word selection and the no-break-space boundary keep working: covered by the existing and new tests, which run in the pending test check.
- Claim: three of the four tests fail with the base implementation, and the original unbuffered implementation breaks the multi-word and no-break-space cases: not re-run on this revision; the base implementation files are identical to the ones earlier runs used.
- Claim: the history test uses the real composer with no imperative insertion or private selectors: verified.
- Claim: the recordings' setup, and that they predate the follow-up: not used as evidence, since they are attachments outside the diff.
- Claim: no new visual representation, default or unrelated interaction model, and no internal context in public text: verified.
- Claim: tests, typecheck, build and lint pass at the commit the description names: that commit is no longer the head; at this revision lint, typecheck and the CLI smoke test pass, and build and test are still running.
- Changeset: restores a token when a whitespace-delimited word of a loaded or recalled draft deserializes to a token with the same value; values with whitespace stay plain text; the mention examples include deserializers: verified.
- File
.changeset/fix-chat-composer-deserialize.md: clear. - File
apps/storybook/stories/ChatComposerInput.stories.tsx: clear. - File
apps/storybook/stories/ChatLayout.stories.tsx: clear. - File
packages/cli/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMentionTrigger.tsx: clear. - File
packages/cli/assets/templates/blocks/components/ChatComposerInput/ChatComposerInputMultipleTriggers.tsx: clear. - File
packages/cli/assets/templates/pages/ai-chat-landing/page.tsx: clear. - File
packages/core/src/Chat/ChatComposerInput.test.tsx: clear. - File
packages/core/src/Chat/ChatComposerInput.tsx: clear. - File
packages/core/src/Chat/useChatComposerTokens.ts: clear.
|
/approve-spec 716b278 |
|
🤖 (Posted by Cindy's agent.) Merged, thank you @korkt-kim! ChatComposerInput now restores tokens when a draft is loaded or recalled, instead of showing their raw text. A maintainer brought the branch up to date with main, with your authorship kept. It ships in the next release, with you credited, and thanks for your patience while it waited. |












User impact
After choosing a mention, sending it, and pressing ↑ to recall it, ChatComposerInput shows plain
@cindytext instead of the blue Cindy Zhang badge. Loading the same serialized value throughvaluealso loses the badge, so editing a saved draft loses the mention's display label and representation.Problem and solution fit
Both restore paths assign the serialized value directly to
textContent, bypassing the trigger's existingdeserializecallback. The stored value is correct; its rendered token is not reconstructed.Restoration passes each whitespace-delimited word to the supplied deserializers and reconstructs a token only when its returned
valueequals that word. Unmatched text and whitespace remain unchanged; serialized token values containing whitespace remain plain text. Each run of plain text stays in one text node, so loading a draft does not break multi-word mention queries or turn a no-break space into a trigger boundary. Controlled echoes still avoid rebuilding the DOM, and loading an external value does not emit an extraonChange.Existing mention examples now supply deserializers so their selected mentions can use the same restoration path.
Expected behavior and authority
The existing
ChatComposerTrigger.deserializedocumentation describes reconstructing serialized tokens when loading a message for editing. The current ChatComposerInput contract preserves controlled echoes (FR4), boundary-only history and pending-draft restoration (FR8), no-break-space trigger boundaries (FR10), multi-word queries (FR11), and token portal cleanup (PR3).This is a defect repair, not a new behavior: the public
deserializecontract above already promises that serialized tokens are reconstructed when a message is loaded for editing, and the composer did not honor it (refs #4655). No engineering-owner decision is needed, and the pull request is ready for review.Smallest restoration
Two implementation files, four user-interaction regression cases in the existing test file, two existing Storybook files, three existing CLI templates, and a patch Changeset for Core and CLI. The examples only add mention deserializers. Token creation is shared with the existing insertion path; restoration remains internal to the composer. No new public API, styling, story, or
.doc.mjschange. Recording fixtures and media remain outside the product diff.Evidence
@cindy, but no token is rendered anddeserializeis never called. External loading has the same outcome.@cindy.deserialize, so a loaded or recalled draft shows that text as plain text. This pull request does not change it, so [Bug] ChatComposerInput: inline tokens are lost on any external value update (deserialize is declared but never called) #4655 stays open for the paste-as-token case.Hellosends and recalls unchanged in the recordings. The current tests also preserve unmatched text, whitespace, multi-word mention selection, and the no-break-space boundary.8b9fbfa754reproduces missing restored mentions in three of the four current cases. Loading the original unbuffered restoration implementation from284a2e8398reproduces the multi-word-query and no-break-space regressions. All four cases pass with the current implementation. The history case uses the real ChatComposer and input: type a query, select a mention, send, recall with ↑, and resend. No imperative token insertion or private token selectors are used by these cases.Historical browser recordings
Both recordings use the same local fixture, Neutral theme, Chromium 149, 1100 × 760 viewport, and interaction sequence. AS-IS loads the two implementation modules from base
6cb8b4a971; TO-BE loads source verified byte-for-byte againstd8cb611778. Readouts come from the actual controlled value and callbacks.These recordings show the original token-restoration comparison. They predate the review follow-up; the current regression tests additionally cover the multi-word-query and no-break-space corrections.
AS-IS
as-is.mp4
TO-BE
to-be.mp4
Scope
Components: ChatComposerInput and its existing mention examples.
Testing
Validation of the changes committed at
6dc1313ef6:pnpm exec vitest run --project ui packages/core/src/Chat/— 502 passed across 25 files, including all four restoration cases.pnpm typecheck— passed across the workspaces included by the root script, including component and template documentation types.pnpm build— passed.pnpm lint:strict— passed with 0 errors and 237 warnings; repository checks passed.8b9fbfa754and284a2e8398— reproduced the missing-token and trigger-query regressions described above without replacing working-tree source files.git diff --check, Changeset validation, and normal pre-commit hooks — passed.