Skip to content

refactor(Comments): the emoji picker is a render prop, edit history comes from loadVersions alone, and reactions name their emoji - #13740

Open
ernestt wants to merge 2 commits into
fix/comment-composer-agent-menu-i18nfrom
refactor/comments-api-pass
Open

ernestt wants to merge 2 commits into
fix/comment-composer-agent-menu-i18nfrom
refactor/comments-api-pass

Conversation

@ernestt

@ernestt ernestt commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on the four Comments fixes (#13736, #13737, #13738, #13739), which are stacked on the CommentPin PRs (#13702, #13735). Review those first; this PR's base is #13739's branch.

Primary intent

The Comments family's API pass before it moves to Core. Its API review raised these changes; this PR makes the ones the records decide or the spec owner suggested. It is a reshaping of an existing Lab API, not a bug fix or a new capability, so no more specific template fits.

User or maintainer impact

Builders who use Lab's Comments get the names Core uses everywhere else and lose three fields that did nothing or duplicated another path. Once the family is in Core, these names are hard to change, so they settle here, while the family is still in Lab.

Problem and solution fit

Change Why
hasEmojiPicker becomes renderEmojiPicker, a render function that receives onSelect and returns the picker. The composer keeps the Add emoji button, the Popover, its open state, and focus return. onSelect inserts the emoji and closes the Popover. Without renderEmojiPicker there is no emoji button. The new CommentEmojiPickerRenderProps type names what the function receives. EmojiPicker stays in Lab, and Core cannot import Lab. A slot lets the product choose any picker.
loadVersions returns the full history, current version included, at once or as a Promise. previousVersions goes away. A history returned at once opens with no loading state. There were two sources for one history. One callback that may answer at once covers both.
A reaction option is {key, emoji, label?}. The old glyph label becomes emoji, and label is the reaction's name, as everywhere else. isSelected replaces reactedByViewer. DEFAULT_COMMENT_REACTIONS follows. Astryx uses label for an element's human-readable name and is* for booleans.
updatedAt and seenBy leave CommentData. Nothing rendered them. Products keep such metadata beside their records and read it in a render callback; the docs say so.

Before and after:

// Before
<Comments
  comments={threads}
  hasEmojiPicker
  loadVersions={id => fetchVersions(id)}
/>
// reactions: [{key: 'like', label: '👍', description: 'Like', count: 2, reactedByViewer: true}]

// After
<Comments
  comments={threads}
  renderEmojiPicker={({onSelect}) => <EmojiPicker onSelect={onSelect} />}
  loadVersions={id => versionsById[id] ?? fetchVersions(id)}
/>
// reactions: [{key: 'like', emoji: '👍', label: 'Like', count: 2, isSelected: true}]

New caller decisions: which picker to pass, if any. Everything else is a rename or a removal.

Authority

  • Current records decide where they speak. docs/contributing/api-conventions.md names boolean state is<Name> (so isSelected), names a slot by its part (topNav, sideNav), and allows a render function when the parent must provide data, as the composer provides onSelect here. Astryx components take an element's human-readable text in label (Button, Badge, Token, Tab), so a reaction's name is its label.
  • The slot's name follows spec:AST-055 (caller-rendered triggers) DEC-6, a current record: a public component prop whose value is a function that returns rendered output is named render<X>. So the slot is renderEmojiPicker, like the family's renderBody and renderComposer, and its name is not an open question.
  • Needs the spec owner's approval (/approve-spec), since no current record decides them: a composer shows no emoji button unless a picker is passed; loadVersions answers at once or with a Promise, in place of previousVersions; and edit history opens only with loadVersions.
  • The shared person type {id, name, src} is already in refactor(CommentPin): uncontrolled selection, Comments' person type, and ElementSize; the host hides resolved pins, and isDimmed is removed #13702 and its Core move, feat(core): CommentPin moves to Core #13735.

Left out on purpose:

  • Renaming logoUrl to src, and moving isHighlighted out of the thread data. The review itself flagged both as needing an owner decision.
  • defaultIsSelected on CommentThread, and renaming the can* booleans. No record decides them and the review made no suggestion, so they stay as they are and go to the owner.

Change and evidence

  • Types, components, docs, stories, and blocks change together. The blocks pass Lab's EmojiPicker through the slot, so the showcases still offer it.
  • Tests use a small stand-in picker, so they do not depend on Lab's picker. New cases: a history returned at once opens without a loading state, and no loadVersions means no history button. The emoji cases check the insert, the closed Popover, and focus back on the input.
  • Stories and examples that pass no picker show no emoji button. That is the new default, not a regression.
  • The four blocks that pass Lab's EmojiPicker name it in componentsUsed.
  • The renderEmojiPicker docs and JSDoc say that the picker fills a fixed-width panel with no padding, so it brings its own, and the comments beside that panel speak of any picker. The CommentComposer description and the Comments composer part no longer promise an emoji button on every composer.
  • The picker renders through a small component, so a picker component that calls hooks runs them in its own fiber. Before, the composer called the function inside its own render while the Popover was open, and such a picker crashed the composer ("Rendered more hooks than during the previous render"). A new test passes a picker that calls useState; it fails without the fix.
  • First-load size (architecture:component-import-boundaries INV10: an optional feature costs nothing where it is unused). A page that renders CommentComposer without renderEmojiPicker: 185.4 KB → 172.2 KB gzip (−13.2 KB), since EmojiPicker leaves the eager graph. A page that renders the Comments panel without renderEmojiPicker: 390.5 KB → 380.9 KB gzip (−9.6 KB). Measured base against head with the size report's build options (minified ESM, code splitting, React and StyleX external), counting the eager graph only. pnpm check:component-import-boundaries sizes Core entries only, so it does not cover these Lab components.

Scope

Components: Comments, CommentThread, CommentComposer

  • This PR has one primary intent.
  • Independently removable deltas were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • Repeated on this head: vitest run packages/lab/src/Comments: 105 tests pass. Core build, Lab build, and pnpm typecheck (Lab and Lab docs): pass. ASTRYX_STRICT_LINT=1 eslint and prettier --check on the changed files: clean. pnpm review:pre: 0 findings. pnpm check:knowledge: clean.

  • tsc for Lab and Lab docs, after a Lab build: pass. Storybook tsc: no errors in the Comments stories.

  • pnpm review:pre: 0 findings. eslint and prettier on the changed files: clean.

  • Sits on main at 2608fe4, with the pull requests below this one. The rename and the slot fix are one commit added on top, so the pull requests below keep their heads.

@vercel

vercel Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Dec 2, 2026 6:37pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Dec 2, 2026, 6:48 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 24, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on a spec owner's decision about the names and shapes this Comments API pass settles. The review found no defect in the code.

  • No current record decides the composer's render-function name emojiPicker (the alternative is renderEmojiPicker, which matches Core's render… functions and the family's renderBody), the default with no emoji button, or a loadVersions that answers at once. To settle them, an engineering owner comments /approve-spec with the full head commit SHA, or names the record or shape that should govern them; the author can do this only if they are an engineering owner.
  • Approval also waits on the first-load gzip delta the component import-boundaries rule (INV10) asks for when a pull request adds an opt-in feature: report base against head for a page that renders CommentComposer without emojiPicker (pnpm check:component-import-boundaries --base-ref <base> prints it per entry).
Claims and files checked

Review mode: full; reason: no-earlier-review

  • Verified: emojiPicker replaces hasEmojiPicker. The composer keeps the button, Popover, open state and focus return, and onSelect inserts the emoji and closes the Popover (CommentComposer.tsx:518-563, CommentComposer.test.tsx:255-267).
  • Verified: with no emojiPicker there is no emoji button (CommentComposer.tsx:518, and the "leaves the emoji button out without emojiPicker" test).
  • Verified: CommentEmojiPickerRenderProps names what the function receives and is exported (types.ts:246-250, index.ts:26).
  • Verified: loadVersions may answer at once or with a Promise, previousVersions is gone, and an answer given at once opens with no loading state (CommentsContext.tsx:577-600, Comments.test.tsx:1091).
  • Verified: with no loadVersions there is no history button (CommentRow.tsx:404, Comments.test.tsx:1117).
  • Verified: a reaction option is {key, emoji, label?}, isSelected replaces reactedByViewer, and DEFAULT_COMMENT_REACTIONS follows (types.ts:48-64, types.ts:376-384).
  • Verified: updatedAt and seenBy leave CommentData, nothing at the base renders them, and the docs tell products to keep such metadata beside their records (Comments.doc.mjs:111).
  • Verified: the four blocks pass Lab's EmojiPicker through the slot, and stories with no picker show no emoji button.
  • Verified: the tests use a stand-in picker and add the at-once history and no-history-button cases.
  • Verified: the API conventions guide names boolean state is<Name> and allows a render function when the parent provides data. The guide itself creates no policy.
  • Verified: Core takes an element's human-readable text in label (Button, Badge, Token, Tab), and the shared person type comes from Core's CommentPin.
  • Verified: the branch sits on the main base the description names.
  • Not checked here: the 103 Vitest tests, tsc, pnpm review:pre, eslint and prettier.
  • Files, all clear: apps/storybook/stories/Comments.stories.tsx; internal/eslint-plugin-astryx/no-internal-barrel-import.baseline.json; the four packages/lab/blocks Comments blocks; in packages/lab/src/Comments: CommentActions.tsx, CommentComposer.doc.mjs, CommentComposer.test.tsx, CommentComposer.tsx, CommentRow.tsx, CommentThread.doc.mjs, CommentThread.test.tsx, CommentThread.tsx, Comments.doc.mjs, Comments.test.tsx, Comments.tsx, CommentsContext.tsx, i18n.ts, index.ts, types.ts; packages/lab/src/EmojiPicker/EmojiPicker.tsx; packages/lab/src/index.ts.

Automated review (maintainer link)

@ernestt
ernestt force-pushed the fix/comment-composer-agent-menu-i18n branch from e851898 to 088eaa8 Compare November 24, 2026 18:46
@ernestt
ernestt force-pushed the refactor/comments-api-pass branch from a91d4d6 to 2513fb7 Compare November 24, 2026 18:46
@ernestt

ernestt commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Added the first-load size the import-boundaries rule (INV10) asks for. A page that renders CommentComposer without emojiPicker goes from 185.4 KB to 172.2 KB gzip (−13.2 KB), and the Comments panel from 390.5 KB to 380.9 KB (−9.6 KB), since EmojiPicker leaves the eager graph. check:component-import-boundaries sizes Core entries only, so these were measured with the size report's build options, base against head.

The four blocks that pass EmojiPicker now name it in componentsUsed. The name and shape questions wait for the spec owner.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision about the names and shapes this Comments API pass settles. The review found no defect in the code.

  • No current record decides the composer's render-function name emojiPicker (the alternative is renderEmojiPicker, which matches the family's renderComposer and Core's render… functions), the default with no emoji button, or a loadVersions that answers at once or with a Promise, so an engineering owner needs to settle them by commenting /approve-spec with the full head commit SHA, or by naming the record or shape that should govern them; the author can do this only as an engineering owner.

The first-load size the import-boundaries rule asks for is now reported, so that gap is closed. Two non-blocking notes:

  • Miss: the composer still gives any picker the fixed width and zero padding tuned for Lab's EmojiPicker (CommentComposer.tsx:525-529), and neither the emojiPicker docs nor the comments beside it say so.
  • Miss: the CommentComposer description and the Comments composer part (CommentComposer.doc.mjs:13, Comments.doc.mjs:89) still describe an emoji button that a default composer no longer has.
Claims and files checked

Review mode: full; reason: author-not-engowner

  • Verified: emojiPicker replaces hasEmojiPicker; the composer keeps the button, Popover, open state and focus return, and onSelect inserts the emoji and closes the Popover (CommentComposer.tsx:518-563, CommentComposer.test.tsx:239).
  • Verified: with no emojiPicker there is no emoji button (CommentComposer.tsx:518, CommentComposer.test.tsx:550).
  • Verified: CommentEmojiPickerRenderProps names what the function receives and is exported (types.ts:247, Comments/index.ts:26).
  • Verified: loadVersions may answer at once or with a Promise, previousVersions is gone, and an answer given at once opens with no loading state (CommentsContext.tsx:525-548, Comments.test.tsx:1091).
  • Verified: with no loadVersions there is no history button (CommentRow.tsx:402, Comments.test.tsx:1117).
  • Verified: a reaction option is {key, emoji, label?}, isSelected replaces reactedByViewer, and DEFAULT_COMMENT_REACTIONS follows (types.ts:47-67, types.ts:376-384).
  • Verified: updatedAt and seenBy leave CommentData, nothing at the base rendered them, and the docs tell products to keep such metadata beside their records (Comments.doc.mjs:111).
  • Verified: the four blocks pass Lab's EmojiPicker through the slot and list it in componentsUsed; stories that pass no picker show no emoji button.
  • Verified: the tests use a stand-in picker and add the at-once history and no-history-button cases; the emoji case checks the insert, the closed Popover and focus on the input (CommentComposer.test.tsx:239-267).
  • Verified: the API conventions guide names boolean state is<Name> and allows a render function when the parent provides data, though the guide itself creates no policy; Core takes an element's human-readable text in label (Button, Badge, Token, Tab).
  • Verified: the person type comes from Core's CommentPin (types.ts:22), and the fields the description leaves out on purpose are unchanged.
  • Verified: the branch sits on the main commit the description names.
  • Not reproduced: the first-load figures (−13.2 KB for the composer, −9.6 KB for the panel); the composer no longer imports EmojiPicker, so the change cannot add first-load weight.
  • Not checked here: the 103 Vitest tests, tsc, pnpm review:pre, eslint and prettier.
  • Files, clear: apps/storybook/stories/Comments.stories.tsx, internal/eslint-plugin-astryx/no-internal-barrel-import.baseline.json, the four packages/lab/blocks/Comment*.tsx blocks and their four .doc.mjs files, CommentActions.tsx, CommentComposer.test.tsx, CommentRow.tsx, CommentThread.doc.mjs, CommentThread.test.tsx, CommentThread.tsx, Comments.test.tsx, Comments.tsx, CommentsContext.tsx, i18n.ts, Comments/index.ts, types.ts, EmojiPicker.tsx, packages/lab/src/index.ts.
  • Files with a non-blocking note: CommentComposer.tsx (picker panel sizing), CommentComposer.doc.mjs and Comments.doc.mjs (an emoji button described as always there).

Automated review (maintainer link)

@ernestt
ernestt force-pushed the fix/comment-composer-agent-menu-i18n branch from 088eaa8 to cac80b5 Compare November 24, 2026 22:28
@ernestt
ernestt force-pushed the refactor/comments-api-pass branch from 2513fb7 to 1397124 Compare November 24, 2026 22:28
@ernestt

ernestt commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Both notes are fixed. The emojiPicker JSDoc and docs say the picker fills a fixed-width panel with no padding, so it brings its own, and the comments beside that panel speak of any picker. The CommentComposer description and the Comments composer part no longer promise an emoji button on every composer. The name and shape still wait for the spec owner.

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision about three Comments shapes that no current record decides, and two changes are needed whatever that decision is.

  • Miss: The picker render prop needs the name renderEmojiPicker, because DEC-6 of the caller-rendered trigger record (docs/specs/AST-055-caller-rendered-trigger/spec.md) names every function-valued component prop render<X>, so the description's statement that the records are silent on this name does not hold.
  • Miss: A product picker component that calls a hook, passed as emojiPicker={ProductPicker}, type-checks but crashes the composer with "Rendered more hooks than during the previous render" on the first press of Add emoji (reproduced locally), because CommentComposer.tsx:533 calls the function inside the composer's own render while the Popover is open; render it through a small component boundary and add a test with a hook-using picker.
  • Owner decision: No current record decides the composer showing no emoji button unless a picker is passed, loadVersions answering at once or with a Promise in place of previousVersions, or edit history opening only with loadVersions, so an engineering owner needs to approve these by commenting /approve-spec with the full head commit SHA on this pull request, or name the shape they want; the author can record that approval only as an engineering owner.

The Comments test suite, Lab's typecheck and Prettier pass, reproduced locally, and the first-load size the import-boundaries rule asks for is reported.

Claims and files checked

Review mode: full; reason: recipe-changed (many rules)

  • Title, live: "refactor(Comments): the emoji picker is a render prop, edit history comes from loadVersions alone, and reactions name their emoji".
  • Verified: the emoji picker is a render function that receives onSelect and returns the picker (types.ts:246-250, :309; CommentComposer.tsx:531-543).
  • Verified: the composer keeps the Add emoji button, its Popover, open state and focus handling, and onSelect inserts the emoji, closes the Popover and focuses the input (CommentComposer.test.tsx "appends a picked emoji to the draft", run here; in the browser, focus lands on the picker's search field on both base and head).
  • Verified: without a picker there is no emoji button (CommentComposer.tsx:518; test "leaves the emoji button out without emojiPicker"; the InsideACard and Empty stories show one Add emoji button on the base and none on the head).
  • Verified: the new render-props type names what the function receives and is exported (Comments/index.ts:26, packages/lab/src/index.ts:67).
  • Verified, for the documented element-returning form: a slot lets a product choose any picker; passing a hook-using picker component itself crashes (second finding).
  • Verified: loadVersions returns the full history at once or as a Promise, previousVersions is gone everywhere in the repository, and an answer given at once opens with no loading state (CommentsContext.tsx:525-550; test "opens the edit history at once from versions returned synchronously", run here).
  • Verified: one history had two inputs at the base (previousVersions and loadVersions).
  • Verified: a reaction option is {key, emoji, label?}, isSelected replaces reactedByViewer everywhere in the repository, and the default reactions follow (types.ts:47-67, :376-385).
  • Verified: Astryx components take a name in label (Button, Badge, Token, Tab) and the API conventions guide names booleans is<Name>, names slots by their part and allows a render function when the parent provides data.
  • False: the records are silent on whether a render function takes a render prefix; the caller-rendered trigger record's DEC-6 decides it (first finding).
  • Verified: updatedAt and seenBy leave the comment data, nothing in the family rendered either at the base (searched every reader in packages, apps and internal), and the docs tell products to keep such metadata beside their records (Comments.doc.mjs:111).
  • Verified: the only new caller decision is which picker to pass; the wider loadVersions type needs no caller change.
  • Verified: the shared person type comes from Core's CommentPin (types.ts:22), and the fields left out on purpose (logoUrl, isHighlighted, defaultIsSelected, the can* booleans) are unchanged.
  • Verified: the four blocks that pass Lab's EmojiPicker are the only ones that do, they list it in componentsUsed, and the three showcase blocks are among them; stories and examples without a picker show no emoji button.
  • Verified: the tests use a stand-in picker and import nothing from Lab's EmojiPicker; the new cases cover the at-once history and the missing history button.
  • Verified: the docs and JSDoc say the picker fills a fixed-width panel with no padding, the comments beside that panel speak of any picker, and the two composer descriptions no longer promise an emoji button on every composer.
  • Verified: the import-boundaries check sizes Core entries only.
  • Reported: the first-load figures (13.2 KB less gzip for a composer without a picker, 9.6 KB less for the panel); no Comments source imports EmojiPicker at the head.
  • Verified, run here: 103 Comments tests pass; Lab's source and docs typecheck pass after a Lab build; Prettier passes on the changed files.
  • Reported: Storybook's typecheck, pnpm review:pre and eslint results; the branch was validated on the main commit that is its merge base.
  • Verified: the public text and files carry no internal context.
  • Files, first finding (rename): packages/lab/src/Comments/types.ts, CommentComposer.tsx (also the second finding), CommentRow.tsx, CommentThread.tsx, Comments.tsx, CommentsContext.tsx, CommentComposer.doc.mjs, CommentThread.doc.mjs, Comments.doc.mjs, CommentComposer.test.tsx, CommentThread.test.tsx, the four blocks CommentComposerShowcase.tsx, CommentThreadInPopover.tsx, CommentThreadShowcase.tsx, CommentsShowcase.tsx, and packages/lab/src/EmojiPicker/EmojiPicker.tsx (header).
  • Files, clear: apps/storybook/stories/Comments.stories.tsx, internal/eslint-plugin-astryx/no-internal-barrel-import.baseline.json, the four block .doc.mjs files, CommentActions.tsx, Comments.test.tsx, i18n.ts, Comments/index.ts, packages/lab/src/index.ts.

Automated review (maintainer link)

…omes from loadVersions alone, and reactions name their emoji

The Comments family's API pass before it moves to Core:

- `hasEmojiPicker` becomes `emojiPicker`, a render function that receives
  `onSelect` and returns the picker. The composer keeps the Add emoji
  button, the Popover, the open state, and focus return; `onSelect` inserts
  the emoji and closes the Popover. Without `emojiPicker` there is no emoji
  button, so the family no longer imports Lab's EmojiPicker. The new
  `CommentEmojiPickerRenderProps` type names what the function receives.
- `loadVersions` returns the full edit history, current version included,
  at once or as a Promise, and `previousVersions` goes away. A history
  returned at once opens with no loading state.
- A reaction option is `{key, emoji, label?}`: `label` is the reaction's
  name, as everywhere else, and the old glyph `label` becomes `emoji`. A
  reaction marks the viewer's own with `isSelected` instead of
  `reactedByViewer`. `DEFAULT_COMMENT_REACTIONS` follows.
- `updatedAt` and `seenBy`, which nothing rendered, leave CommentData.

Docs, stories, and blocks follow; the blocks pass Lab's EmojiPicker.
@ernestt

ernestt commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main at 2608fe4 with the rest of the stack. This pull request's own diff is unchanged: its patch ID is the same as before the rebase, and it applied without conflicts. In the stack, only #13737 changed in content; #13702, #13735, #13736, #13738, #13739, #13740 and #13741 are unchanged apart from the rebase.

Repeated on this head: vitest run packages/lab/src/Comments: 104 passed (one more than before: #13737 added a test). pnpm review:pre: 0 findings.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision about three Comments shapes that no current record decides, and two changes are needed whatever that decision is.

  • Miss: The picker render prop needs the name renderEmojiPicker, because DEC-6 of the caller-rendered trigger record (docs/specs/AST-055-caller-rendered-trigger/spec.md) names every function-valued component prop render<X>, so the description's statement that the records are silent on this name does not hold.
  • Miss: A product picker component that calls a hook, passed as emojiPicker={ProductPicker}, type-checks but crashes the composer with "Rendered more hooks than during the previous render." on the first press of Add emoji (reproduced locally), because CommentComposer.tsx:533 calls the function inside the composer's own render while the Popover is open; render it through a small component boundary and add a test with a hook-using picker.
  • Owner decision: No current record decides the composer showing no emoji button unless a picker is passed, loadVersions answering at once or with a Promise in place of previousVersions, or edit history opening only with loadVersions, so an engineering owner needs to approve these by commenting /approve-spec with the full head commit SHA on this pull request, or name the shape they want; the author can record that approval only as an engineering owner.

The Comments test suite (104 tests), Lab's typecheck and Prettier pass, reproduced locally, and the first-load size the import-boundaries rule asks for is reported.

Claims and files checked

Review mode: full; reason: author-not-engowner

  • Title, live: "refactor(Comments): the emoji picker is a render prop, edit history comes from loadVersions alone, and reactions name their emoji".
  • Verified: the emoji picker is a render function that receives onSelect and returns the picker (types.ts:246-250, :309; CommentComposer.tsx:532-544).
  • Verified: the composer keeps the Add emoji button, its Popover, open state and focus handling, and onSelect inserts the emoji, closes the Popover and focuses the input (CommentComposer.test.tsx "appends a picked emoji to the draft", run here; in the browser, focus lands on the picker's search field on both base and head).
  • Verified: without a picker there is no emoji button (CommentComposer.tsx:518; test "leaves the emoji button out without emojiPicker, and adds controls", run here; the InsideACard and Empty stories show one Add emoji button on the base and none on the head).
  • Verified: the new render-props type names what the function receives and is exported (Comments/index.ts:26, packages/lab/src/index.ts:67).
  • Verified, for the documented element-returning form: a slot lets a product choose any picker; passing a hook-using picker component itself crashes (second finding).
  • Verified: loadVersions returns the full history at once or as a Promise, previousVersions is gone everywhere in the repository, and an answer given at once opens with no loading state (CommentsContext.tsx:525-550; test "opens the edit history at once from versions returned synchronously", run here).
  • Verified: one history had two inputs at the base (previousVersions and loadVersions).
  • Verified: a reaction option is {key, emoji, label?}, isSelected replaces reactedByViewer everywhere in the repository, and the default reactions follow (types.ts:47-67, :377-385).
  • Verified: Astryx components take a name in label (Button, Badge, Token, Tab) and the API conventions guide names booleans is<Name>, names slots by their part and allows a render function when the parent provides data.
  • False: the records are silent on whether a render function takes a render prefix; the caller-rendered trigger record's DEC-6 decides it (first finding).
  • Verified: updatedAt and seenBy leave the comment data, nothing in the family rendered either at the base (searched every reader in packages, apps and internal), and the docs tell products to keep such metadata beside their records (Comments.doc.mjs:111).
  • Verified: the only new caller decision is which picker to pass; the wider loadVersions type needs no caller change.
  • Verified: the shared person type comes from Core's CommentPin (types.ts:22), and the fields left out on purpose (logoUrl, isHighlighted, defaultIsSelected, the can* booleans) are unchanged.
  • Verified: the four blocks that pass Lab's EmojiPicker are the only ones that do, they list it in componentsUsed, and the three showcase blocks are among them; stories and examples without a picker show no emoji button.
  • Verified: the tests use a stand-in picker and import nothing from Lab's EmojiPicker; the new cases cover the at-once history, the missing history button, and the insert, closed Popover and returned focus after a pick.
  • Verified: the docs and JSDoc say the picker fills a fixed-width panel with no padding, the comments beside that panel speak of any picker, and the two composer descriptions no longer promise an emoji button on every composer.
  • Verified: the import-boundaries check sizes Core entries only.
  • Reported: the first-load figures (13.2 KB less gzip for a composer without a picker, 9.6 KB less for the panel); no Comments source imports EmojiPicker at the head.
  • Verified, run here: 104 Comments tests pass; Lab's source and docs typecheck pass after a Lab build; Prettier passes on the changed files.
  • Reported: Storybook's typecheck, pnpm review:pre and eslint results.
  • Verified: the branch was rebased onto main with the rest of the stack and its own patch is unchanged (the same patch ID before and after).
  • Verified: the public text and files carry no internal context.
  • Files, first finding (rename): packages/lab/src/Comments/types.ts, CommentComposer.tsx (also the second finding), CommentRow.tsx, CommentThread.tsx, Comments.tsx, CommentsContext.tsx, CommentComposer.doc.mjs, CommentThread.doc.mjs, Comments.doc.mjs, CommentComposer.test.tsx, CommentThread.test.tsx, the four blocks CommentComposerShowcase.tsx, CommentThreadInPopover.tsx, CommentThreadShowcase.tsx, CommentsShowcase.tsx, and packages/lab/src/EmojiPicker/EmojiPicker.tsx (header).
  • Files, clear: apps/storybook/stories/Comments.stories.tsx, internal/eslint-plugin-astryx/no-internal-barrel-import.baseline.json, the four block .doc.mjs files, CommentActions.tsx, Comments.test.tsx, i18n.ts, Comments/index.ts, packages/lab/src/index.ts.

Automated review (maintainer link)

Comment thread packages/lab/src/Comments/types.ts Resolved
…t renders as its own component

A public component prop whose value is a function that returns rendered
output is named render<X> (spec:AST-055 DEC-6), so `emojiPicker` becomes
`renderEmojiPicker` on Comments, CommentThread, and CommentComposer, with
their docs, blocks, and tests.

The composer called the picker function inside its own render, and only
while the Popover was open. A picker component that calls hooks then added
hooks to that render and crashed the composer ("Rendered more hooks than
during the previous render"). The picker now renders through a small
component, so its hooks run in their own fiber.
@ernestt

ernestt commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Both required changes are in one new commit on this branch:

  • renderEmojiPicker. spec:AST-055 (caller-rendered triggers) is current, and its DEC-6 names every function-valued component prop render<X>, so the slot is now renderEmojiPicker on Comments, CommentThread and CommentComposer. That includes the docs (English, Chinese and dense), the four blocks, the examples and the tests. The EmojiPicker catalog keys (@astryx.emojiPicker.*) keep their names.
  • Picker components with hooks. The picker now renders through a small component, so its hooks run in their own fiber. A new test passes a picker that calls useState. Without the fix it fails with "Rendered more hooks than during the previous render."; with the fix it passes.

On this head: 105 Comments tests pass. The Core build, the Lab build and pnpm typecheck (Lab and Lab docs) pass. Strict ESLint and Prettier on the changed files are clean, pnpm review:pre shows 0 findings, and pnpm check:knowledge is clean.

The description now cites DEC-6 for the name. It lists the three shapes still waiting on the spec owner's /approve-spec: no emoji button without a picker, loadVersions answering at once or with a Promise, and edit history only with loadVersions.

The commit sits on top of the old head, so #13736–#13739 keep their heads and approvals. #13741 picks this commit up through a merge.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision about three Comments shapes that no current record decides; both changes the last review asked for are in, and nothing else needs to change.

  • Owner decision: No current record decides that a composer shows no emoji button unless a picker is passed, that loadVersions may answer at once or with a Promise in place of previousVersions, or that an edited comment opens its history only when loadVersions is set, so an engineering owner records approval by commenting /approve-spec with the full head commit SHA on this pull request, or names the shape they want; the author may record it if they are an engineering owner.

The renderEmojiPicker name now follows the render<X> rule, and a picker component that calls hooks renders in its own component: the new test passes, and fails without the slot when reproduced locally. The Comments suite (105 tests), the builds, Lab's typecheck, Prettier and ESLint pass locally; CI has not run on this head yet.

Claims and files checked

Review mode: full; reason: author-not-engowner

  • Title, live: "refactor(Comments): the emoji picker is a render prop, edit history comes from loadVersions alone, and reactions name their emoji".
  • Verified: the emoji picker is a render function, renderEmojiPicker, that receives onSelect and returns the picker (types.ts:246-250, :309; CommentComposer.tsx:543-555).
  • Verified: the composer keeps the Add emoji button, its Popover, open state and focus handling; onSelect inserts the emoji, closes the Popover and focuses the input (test "appends a picked emoji to the draft", run locally; in the browser focus lands on the picker's search field on both base and head). The focus code is unchanged apart from the slot, so none of the usual focus edge cases (an unfocused or disabled opener, a stacked popover, a frame or shadow root) changes it.
  • Verified: without a picker there is no emoji button (CommentComposer.tsx:529; test "leaves the emoji button out without renderEmojiPicker, and adds controls", run locally; the InsideACard and Empty stories show one Add emoji button on the base and none on the head).
  • Verified: the new render-props type names what the function receives and is exported (Comments/index.ts:26, packages/lab/src/index.ts:67).
  • Verified: a slot lets a product choose any picker, including a picker component that calls hooks (test "renders a picker component that calls hooks", run locally; it fails with "Rendered more hooks than during the previous render." when the slot is replaced by a direct call).
  • Verified: loadVersions returns the full history at once or as a Promise, previousVersions is gone everywhere in the repository, and an answer given at once opens with no loading state (CommentsContext.tsx:511-550; test "opens the edit history at once from versions returned synchronously", run locally).
  • Verified: one history had two inputs at the base (previousVersions and loadVersions).
  • Verified: a reaction option is {key, emoji, label?}, isSelected replaces reactedByViewer everywhere in the repository, and the default reactions follow (types.ts:47-67, :377-385).
  • Verified: Astryx components take a name in label (Button, Badge, Token, Tab) and the API conventions guide names booleans is<Name>, names slots by their part and allows a render function when the parent provides data.
  • Verified: the render prop's name follows the caller-rendered trigger record's render<X> decision, like the family's renderBody and renderComposer.
  • Verified: updatedAt and seenBy leave the comment data, nothing in the family rendered either at the base (searched every reader in packages, apps and internal), and the docs tell products to keep such metadata beside their records (Comments.doc.mjs:111).
  • Verified: the only new caller decision is which picker to pass; the wider loadVersions type needs no caller change.
  • Verified: the shared person type comes from Core's CommentPin (types.ts:22), and the fields left out on purpose (logoUrl, isHighlighted, defaultIsSelected, the can* booleans) are unchanged.
  • Verified: the four blocks that pass Lab's EmojiPicker are the only ones that do, they list it in componentsUsed, and stories and examples without a picker show no emoji button.
  • Verified: the tests use a stand-in picker and import nothing from Lab's EmojiPicker; the new cases cover the at-once history, the missing history button, the hook-using picker, and the insert, closed Popover and returned focus after a pick.
  • Verified: the docs and JSDoc say the picker fills a fixed-width panel with no padding, the comments beside that panel speak of any picker, and the composer descriptions no longer promise an emoji button on every composer.
  • Verified: the import-boundaries check sizes Core entries only.
  • Reported: the first-load figures (13.2 KB less gzip for a composer without a picker, 9.6 KB less for the panel); no Comments source imports EmojiPicker at the head.
  • Verified, run locally: 105 Comments tests pass; the Core and Lab builds and Lab's source and docs typecheck pass; Prettier passes on the changed files; strict ESLint reports no errors (two warnings sit on unchanged lines).
  • Reported: Storybook's typecheck, the pre-review checklist and the knowledge check.
  • Verified: the branch sits on main with the stack below it, and the rename and the slot fix are one commit on top of the previous head.
  • Verified: the public text and files carry no internal context.
  • Files, clear: apps/storybook/stories/Comments.stories.tsx, internal/eslint-plugin-astryx/no-internal-barrel-import.baseline.json, packages/lab/blocks/CommentComposerShowcase.doc.mjs, CommentComposerShowcase.tsx, CommentThreadInPopover.doc.mjs, CommentThreadInPopover.tsx, CommentThreadShowcase.doc.mjs, CommentThreadShowcase.tsx, CommentsShowcase.doc.mjs, CommentsShowcase.tsx, packages/lab/src/Comments/CommentActions.tsx, CommentComposer.doc.mjs, CommentComposer.test.tsx, CommentComposer.tsx, CommentRow.tsx, CommentThread.doc.mjs, CommentThread.test.tsx, CommentThread.tsx, Comments.doc.mjs, Comments.test.tsx, Comments.tsx, CommentsContext.tsx, i18n.ts, index.ts, types.ts, packages/lab/src/EmojiPicker/EmojiPicker.tsx, packages/lab/src/index.ts.

Automated review (maintainer link)

This branch was successfully deployed

1 active deployment
Preview — 5e154caf Deployed Dec 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant