Skip to content

feat(Comments): a renderTypingIndicator render prop shows who is typing - #13741

Open
ernestt wants to merge 3 commits into
refactor/comments-api-passfrom
feat/comments-typing-indicator-slot
Open

ernestt wants to merge 3 commits into
refactor/comments-api-passfrom
feat/comments-typing-indicator-slot

Conversation

@ernestt

@ernestt ernestt commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #13740 (the Comments API pass). Review that first; this PR's base is its branch.

Needs the spec owner's approval. This proposes a new public slot, and without it typing shows nothing, on desktop too. No record decides either.

User need

Comments must move to Core, and Core cannot import from Lab. Comments drew typing state with Lab's ChatTypingIndicator, and Chat's additions stay in Lab. Products still need to show who is typing in an open thread.

Problem and solution fit

renderTypingIndicator is a render function, in the same shape as the renderEmojiPicker slot from the API pass. While an open thread's typingUsers name someone besides the viewer, Comments calls it with those people, each once and without the viewer, and places the result at the end of the thread. The new CommentTypingIndicatorRenderProps type names what it receives. The family no longer imports ChatTypingIndicator.

Current specification

No record decides a typing slot. It follows the shape of the renderEmojiPicker slot the spec owner suggested in the API review: a render function that takes what the parent provides. docs/contributing/api-conventions.md allows a render function when the parent must provide data, here the deduplicated typing people.

The slot's name is not open: spec:AST-055 (caller-rendered triggers) DEC-6, a current record, names every function-valued component prop render<X>, so the slot is renderTypingIndicator, like the family's renderBody and renderComposer.

The spec owner's /approve-spec would settle three things no record decides:

  1. The slot itself and its shape.
  2. A desktop behavior change. With default props, an open thread no longer shows the animated typing row, for mouse, trackpad, keyboard, and touch users alike: the row shows only when a product passes renderTypingIndicator. The change comes from Core not importing Lab's indicator, not from the input, so a gate on the input type would not fit.
  3. Whether Comments passes the avatar-column width to the slot (see Design and alternatives).

Public delta and caller burden

  • New prop on Comments and CommentThread: renderTypingIndicator?: (props: {users: readonly CommentUser[]}) => ReactNode, and the CommentTypingIndicatorRenderProps type.
  • Behavior change: without renderTypingIndicator, typing shows nothing. Before, Comments always drew Lab's indicator.
  • Visual change: Comments set a private width on Lab's indicator, so its dots sat in the avatar column. A product's indicator now lays itself out, so the dots start at the row's edge (images below).
// Before: typing showed by default
<Comments comments={threads} currentUser={viewer} />

// After
<Comments
  comments={threads}
  currentUser={viewer}
  renderTypingIndicator={({users}) => (
    <ChatTypingIndicator names={users.map(user => user.name)} />
  )}
/>

The new caller decision: which indicator to pass, if any. Inside the threads log (the default layout), the log announces the indicator's text, so the docs tell the indicator not to announce it again. With layout="embedded", which has no log, the indicator says who is typing once per change, politely. The live-state guidance in both components' docs names renderTypingIndicator.

Design and alternatives

  • Chosen: a slot in the shape of renderEmojiPicker. Core stays free of Lab, and a product can use any indicator.
  • Moving ChatTypingIndicator to Core with the family. Rejected: Chat's additions stay in Lab.
  • A typing line built into Comments. Rejected: it would copy Lab's component, its grammar, and its announcement into Core.

Open for the owner: should Comments pass the avatar-column width to the slot, so an indicator can align its dots with the avatars as before?

Evidence

The Live state story. Before: the Comments fixes below this PR, where Comments draws Lab's indicator; the API pass does not change this row. After: this branch, where the story passes ChatTypingIndicator through the slot.

Before After
Typing row before Typing row after

Tests:

  • renderTypingIndicator renders once the thread opens, with each person once and without the viewer: the function receives [Maya Chen, Release Assistant] from [viewer, Maya, Maya, agent].
  • Without renderTypingIndicator, there is no typing row.
  • An indicator component that calls hooks, passed as renderTypingIndicator={MyIndicator}, renders as typing starts and stops. Before, the row called the function inside its own render and the thread crashed ("Rendered more hooks than during the previous render"); the indicator now renders through a small component. The new test 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 the Comments panel without renderTypingIndicator: 380.9 KB → 380.0 KB gzip (−0.9 KB); CommentThread: 373.8 KB → 373.2 KB (−0.6 KB). ChatTypingIndicator leaves the eager graph. 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.

The panel showcase passes ChatTypingIndicator through the slot and names it in componentsUsed.

The CommentThread docs gain a typing accessibility row, in English, Chinese, and the dense text: a standalone thread has no log, so a passed indicator says who is typing once per change, politely, unless the page puts the thread inside a live region that already speaks it.

Scope

Components: Comments, CommentThread

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Testing

@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:39pm 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 an owner decision: an engineering owner needs to provide or identify the governing spec for the new typingIndicator slot on Comments and CommentThread, because no current spec covers it. What must be settled is the slot itself, the change that leaves typing hidden unless a product passes the slot, and the typing row's alignment with the avatar column, including whether the slot receives the avatar-column width. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so if they are an engineering owner.

Independent of that decision, these are needed before approval:

  • The typing accessibility text in Comments.doc.mjs (line 136) tells every indicator to announce who is typing, but in the default layout the threads sit in a polite role="log" that already speaks the indicator's text, so an indicator built from this guidance is heard twice; say that inside the log the indicator must not announce again, and that with layout="embedded" it announces once per change, politely, as ChatTypingIndicator does.
  • The description needs the first-load gzip size delta, base against head, for a page that renders Comments without typingIndicator, which the optional-feature size rule requires.

Two smaller doc points: the live-state guidance in both components' docs still says to map typingUsers without naming typingIndicator, and the showcase block's componentsUsed omits ChatTypingIndicator.

Claims and files checked

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

  • Claim: Comments drew typing with Lab's ChatTypingIndicator: verified, the base CommentRow.tsx imported and rendered it.
  • Claim: typingIndicator follows the emojiPicker render-function shape: verified, types.ts:315 and :321.
  • Claim: for an open thread, Comments calls it with each typing person once and without the viewer, at the end of the thread: verified, CommentRow.tsx:396-398 and :804-811.
  • Claim: CommentTypingIndicatorRenderProps names what the function receives: verified, types.ts:253-257, exported from the family index and the Lab root.
  • Claim: the family no longer imports ChatTypingIndicator: verified; only the doc example string names it.
  • Claim: no spec decides a typing slot: verified, no current record covers it.
  • Claim: the contributor API guide allows a render function when the parent provides data: verified (docs/contributing/api-conventions.md), but that guide is not a spec.
  • Claim: without typingIndicator, typing shows nothing: verified, CommentRow.tsx:806 and the new test.
  • Claim: Comments set a private width so the dots sat in the avatar column, and now they start at the row's edge: verified from code, not from rendered frames.
  • Claim: the docs say the indicator announces once per change, politely: verified as written, but wrong inside the default threads log (finding above).
  • Claim: the tests check [Maya Chen, Release Assistant] from a list with the viewer and a duplicate, and no row without the prop: verified by reading Comments.test.tsx:579-623; not run.
  • Claim: the Comments tests pass, the Lab typecheck passes, and pre-review, lint and formatting checks are clean: unverified; they were not run for this review and CI has not run them on this head.
  • Claim: the branch sits on a recent main commit and applied without conflicts: verified, its merge base with main is that commit.
  • Claim: public text carries no internal context: verified for the added lines, title, body, branch name and commit message.
  • Claim (commit message): the docs, the Live state story and the panel showcase pass ChatTypingIndicator: verified.
  • File apps/storybook/stories/Comments.stories.tsx: clear.
  • File packages/lab/blocks/CommentsShowcase.tsx: clear; its doc's componentsUsed is the note above.
  • File packages/lab/src/Comments/CommentRow.tsx: clear.
  • File packages/lab/src/Comments/CommentThread.doc.mjs: note, the guidance at line 81 does not name the prop.
  • File packages/lab/src/Comments/CommentThread.tsx: clear.
  • File packages/lab/src/Comments/Comments.doc.mjs: finding at line 136, and a note at line 111.
  • File packages/lab/src/Comments/Comments.test.tsx: clear.
  • File packages/lab/src/Comments/Comments.tsx: clear.
  • File packages/lab/src/Comments/CommentsContext.tsx: clear.
  • File packages/lab/src/Comments/index.ts: clear.
  • File packages/lab/src/Comments/types.ts: clear.
  • File packages/lab/src/index.ts: clear.

Automated review (maintainer link)

@ernestt
ernestt force-pushed the refactor/comments-api-pass branch from a91d4d6 to 2513fb7 Compare November 24, 2026 18:46
@ernestt
ernestt force-pushed the feat/comments-typing-indicator-slot branch from 1aaf784 to 4e4e565 Compare November 24, 2026 18:46
@ernestt

ernestt commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

The typing accessibility text in the Comments docs now uses the suggested wording: inside the threads log, the log announces the indicator's text, so the indicator must not announce it again; with layout="embedded", which has no log, it says who is typing once per change, politely. The draft Comments record that comes with the move says the same.

  • The live-state guidance in both components' docs, with the Chinese and dense versions, names typingIndicator.
  • The panel showcase names ChatTypingIndicator in componentsUsed.
  • First-load size, in the description: the Comments panel without typingIndicator goes from 380.9 KB to 380.0 KB gzip (−0.9 KB), and CommentThread from 373.8 KB to 373.2 KB (−0.6 KB).

The slot itself waits for the owner's decision.

@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 owner decision: no current spec covers the new typingIndicator slot on Comments and CommentThread, so an engineering owner needs to provide or identify the governing spec for the slot, for the change that hides typing unless a product passes it, and for the typing row's alignment with the avatar column, including whether the slot receives the column width. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so if they are an engineering owner.

Also needed before approval:

  • Miss: desktop behavior change needs an owner decision: with default props, an open thread no longer shows the animated typing row for mouse and trackpad users (CommentRow.tsx:802-809), so gate the change to touch input or cite the owner's decision for it.

The earlier accessibility-text, first-load size and doc points are fixed; one small doc gap remains, since the CommentThread docs never say how a passed typing indicator announces, although a standalone thread has no log.

Claims and files checked

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

Claims:

  • The slot is a render function shaped like the emojiPicker slot: verified (types.ts:315, :321).
  • Comments calls it for an open thread with each typing person once and without the viewer, at the end of the thread: verified (CommentRow.tsx:394-396, :802-809).
  • The new CommentTypingIndicatorRenderProps type names what it receives and is exported: verified (types.ts:253-257, Comments/index.ts:36, lab/src/index.ts:77).
  • The family no longer imports ChatTypingIndicator: verified (only the doc example names it).
  • No spec decides a typing slot: verified (no current spec names it).
  • The API conventions guide allows a render function when the parent must provide data: verified, though the guide sets no policy.
  • Without the slot typing shows nothing, where Comments always drew the indicator before: verified (base CommentRow.tsx; the new test).
  • The dots move from the avatar column to the row's edge: verified from code (the private width override is gone).
  • The docs tell the indicator to stay silent inside the threads log and to announce once per change when embedded, and the live-state guidance names the prop: verified (Comments.doc.mjs:111, :136; CommentThread.doc.mjs:81, :395, :509).
  • A page without the slot loads 0.9 KB (panel) and 0.6 KB (thread) less gzip: direction verified from the import graph; the numbers were not re-measured.
  • The panel showcase passes the indicator and lists it in componentsUsed: verified (CommentsShowcase.tsx:320-322, CommentsShowcase.doc.mjs:14).
  • The test feeds the viewer, Maya twice and the agent, and the function receives Maya and the agent: verified (Comments.test.tsx:579-610).
  • Without the slot there is no typing row: verified (Comments.test.tsx:612-623).
  • The Lab tests, typecheck, lint and browser runs pass: not verified here; no CI workflow ran on this head.
  • Stacked on the Comments API pass, with unrelated fixes split out: verified; the only tagalong is a header-comment accuracy fix.

Files:

  • packages/lab/src/Comments/CommentRow.tsx: desktop behavior finding.
  • packages/lab/src/Comments/CommentThread.doc.mjs: non-blocking doc gap (no typing accessibility row).
  • packages/lab/src/Comments/Comments.doc.mjs: clear.
  • packages/lab/src/Comments/types.ts: clear.
  • packages/lab/src/Comments/CommentsContext.tsx: clear.
  • packages/lab/src/Comments/Comments.tsx: clear.
  • packages/lab/src/Comments/CommentThread.tsx: clear.
  • packages/lab/src/Comments/index.ts: clear.
  • packages/lab/src/index.ts: clear.
  • packages/lab/src/Comments/Comments.test.tsx: clear.
  • packages/lab/blocks/CommentsShowcase.tsx: clear.
  • packages/lab/blocks/CommentsShowcase.doc.mjs: clear.
  • apps/storybook/stories/Comments.stories.tsx: clear.

Automated review (maintainer link)

Comment on lines +802 to +809
{depth === 0 &&
isThreadSelected &&
typingIndicator != null &&
typingUsers.length > 0 && (
<HStack width="100%" data-thread-typing-indicator="true">
{typingIndicator({users: typingUsers})}
</HStack>
)}

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.

Desktop behavior change needs an owner decision: with default props, an open thread whose typingUsers name someone besides the viewer no longer shows the animated typing row for mouse and trackpad users, since the row now renders only when typingIndicator is passed. Gate the change to touch input, or cite the owner's decision for removing the default row.

@ernestt
ernestt force-pushed the refactor/comments-api-pass branch from 2513fb7 to 1397124 Compare November 24, 2026 22:28
@ernestt
ernestt force-pushed the feat/comments-typing-indicator-slot branch from 4e4e565 to a43854e Compare November 24, 2026 22:29
@ernestt

ernestt commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

The default change is now in the description as an item for the spec owner's /approve-spec: without typingIndicator, an open thread shows no typing row for any input, desktop included. The change comes from Core not importing Lab's indicator, not from the input, so a gate on the input type would not fit.

The CommentThread docs gain a typing accessibility row, in English, Chinese and the dense text: a standalone thread has no log, so a passed indicator says who is typing once per change, politely, unless the page puts the thread inside a live region that already speaks it. The draft CommentThread record that comes with the move says the same.

@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 owner decision, and two code fixes are needed either way.

No current spec covers the new typingIndicator slot on Comments and CommentThread: an engineering owner needs to provide or identify the governing spec for the slot, for hiding typing unless a product passes it, and for the typing row's alignment with the avatar column, including whether the slot receives the column width. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so if they are an engineering owner.

Blocking findings:

  • Desktop behavior change needs an owner decision: with default props, an open thread no longer shows the animated typing row for mouse and trackpad users (CommentRow.tsx:802-809), so gate the change to touch input or cite the owner's decision for it.
  • Miss: CommentRow.tsx:807 calls typingIndicator as a plain function during its own render, so a function component with hooks passed as typingIndicator={MyIndicator} crashes the thread with "Rendered more hooks than during the previous render" when typing starts (reproduced locally); render the slot through a small stable component instead and add a test for it.
  • Miss: the spec's rule that every function-valued component prop is named render<X> (the caller-rendered trigger spec, DEC-6) makes this prop renderTypingIndicator (types.ts:322), and it means the slot's name is not one of the open questions.

The new typing accessibility row in the CommentThread docs closes the earlier doc gap.

Claims and files checked

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

changed rules (12): Complete pass before approval; Claim evidence must reach the case; A claim about all, every; A negative claim that names; A claim backed by a test; A claim that cites code lines; Any exception found to a claim; Reported evidence is not; Claim bounding in one round; A claim bounded by a record; The rules above still apply; When the issued head equals

Claims:

  • Title: a typingIndicator render prop shows who is typing: verified (CommentRow.tsx:802-809; test at Comments.test.tsx:579-610, run locally).
  • The slot is a render function shaped like emojiPicker: verified (types.ts:316, :322).
  • It is called for an open thread with each typing person once and without the viewer, after the last reply: verified (CommentRow.tsx:276-285, :394-397, :802-809; the test feeds viewer, Maya twice and the agent and asserts the last call gets Maya and the agent, run locally).
  • The new render-props type names what it receives and is exported: verified (types.ts:253-257, Comments/index.ts:36, lab/src/index.ts:77).
  • The family no longer imports the typing indicator: verified (the import graph of Comments.tsx and CommentThread.tsx reaches 15 files, none under Chat/; a text search of the Comments folder finds the name only in a doc example).
  • No spec decides the slot's name and shape: false for the name (DEC-6 above); true for the slot and its default.
  • The emojiPicker shape is the one the spec owner suggested: unverified; the base pull request's discussion still shows its name awaiting the owner.
  • The API conventions guide allows a render function when the parent provides data: verified; the guide says it creates no policy.
  • Without the slot typing shows nothing for any input, where Comments drew the indicator before: verified (test at Comments.test.tsx:612-623, run locally; base and head browser captures).
  • An input-type gate would not fit because the cause is the import boundary: consistent with the code, which has no input condition.
  • The dots move from the avatar column to the row's edge: verified (captures: the dots column narrows from 28px to 19px and the label moves 9px left).
  • The docs tell the indicator not to announce inside the threads log and to announce once per change, politely, with layout="embedded": verified (Comments.doc.mjs:136; ChatTypingIndicator.tsx:192-199 does so).
  • The live-state guidance in both components' docs names the prop: verified (Comments.doc.mjs:111; CommentThread.doc.mjs:81, :402, :523).
  • The CommentThread docs gain a typing accessibility row in English, Chinese and dense text: verified (CommentThread.doc.mjs:114-120, :435-441, :556-562).
  • First-load size without the slot drops by 0.9 KB (panel) and 0.6 KB (thread): reported; the direction matches the import graph.
  • The import-boundaries check sizes Core entries only: verified (every entry module in scripts/check-component-import-boundaries.mjs is under packages/core/src).
  • The showcase passes the indicator and lists it in componentsUsed: verified (CommentsShowcase.tsx:320-322, CommentsShowcase.doc.mjs:14).
  • The Comments tests pass (104): verified, 104 passed locally.
  • Typecheck and the pre-review checklist pass: reported; prettier and eslint on the changed files are clean locally.
  • Validated on main with the pull requests below: reported.
  • One capability; unrelated fixes split; no internal context in public text: verified (the header edit sits in the header sentence the change rewrites; no internal references found).

Files:

  • packages/lab/src/Comments/CommentRow.tsx: desktop behavior and inline-call crash findings.
  • packages/lab/src/Comments/types.ts: DEC-6 name finding.
  • packages/lab/src/Comments/CommentsContext.tsx: clear (follows the rename).
  • packages/lab/src/Comments/Comments.tsx: clear (follows the rename).
  • packages/lab/src/Comments/CommentThread.tsx: clear (follows the rename).
  • packages/lab/src/Comments/index.ts: clear.
  • packages/lab/src/index.ts: clear.
  • packages/lab/src/Comments/Comments.doc.mjs: clear (follows the rename).
  • packages/lab/src/Comments/CommentThread.doc.mjs: clear (follows the rename).
  • packages/lab/src/Comments/Comments.test.tsx: clear; a hook-component case belongs with the crash fix.
  • packages/lab/blocks/CommentsShowcase.tsx: clear (follows the rename).
  • packages/lab/blocks/CommentsShowcase.doc.mjs: clear.
  • apps/storybook/stories/Comments.stories.tsx: clear (follows the rename).

Automated review (maintainer link)

Comments drew typing state with Lab's ChatTypingIndicator, so Comments and
CommentThread imported a component that stays in Lab. `typingIndicator`
now renders it: while an open thread's `typingUsers` name someone besides
the viewer, Comments passes those people, each once, and places what the
function returns at the end of the thread. It follows `emojiPicker`'s
shape. Without it, typing shows nothing. The new
`CommentTypingIndicatorRenderProps` type names what the function receives.
Docs, the Live state story, and the panel showcase pass ChatTypingIndicator.
@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: 105 passed. Lab build and pnpm typecheck (Lab and Lab docs): pass. 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 owner decision, and two code fixes are needed either way.

No current spec covers the new typingIndicator slot on Comments and CommentThread: an engineering owner needs to provide or identify the governing spec for the slot, for hiding typing unless a product passes it, and for the typing row's alignment with the avatar column, including whether the slot receives the column width. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so if they are an engineering owner.

Blocking findings:

  • Desktop behavior change needs an owner decision: with default props, an open thread no longer shows the animated typing row for mouse and trackpad users (CommentRow.tsx:802-809), so gate the change to touch input or cite the owner's decision for it.
  • Miss: CommentRow.tsx:807 calls typingIndicator as a plain function during its own render, so a function component with hooks passed as typingIndicator={MyIndicator} crashes the thread with "Rendered more hooks than during the previous render" when typing starts (reproduced locally on this head); render the slot through a small stable component instead and add a test for it.
  • Miss: the spec's rule that every function-valued component prop is named render<X> (the caller-rendered trigger spec, DEC-6) makes this prop renderTypingIndicator (types.ts:322), and it means the slot's name is not one of the open questions.
Claims and files checked

Review mode: full; reason: merge-touches-pr-files

Claims:

  • Title: a typingIndicator render prop shows who is typing: verified (CommentRow.tsx:802-809; test at Comments.test.tsx:578-609, run locally).
  • The slot is a render function shaped like emojiPicker: verified (types.ts:316, :322).
  • It is called for an open thread with each typing person once and without the viewer, and its result is placed at the end of the thread: verified (CommentRow.tsx:276-285, :394-396, :802-809: after the last reply, with the reply composer below it when open; the test feeds viewer, Maya twice and the agent and asserts the last call gets Maya and the agent, run locally).
  • The new render-props type names what it receives and is exported: verified (types.ts:253-257, Comments/index.ts:36, lab/src/index.ts:77).
  • The family no longer imports the typing indicator: verified (a text search of the Comments folder finds the name only in a doc example string, and no Comments module imports anything from Lab's Chat folder, directly or through its two shared Lab helpers).
  • No spec decides the slot's name and shape: false for the name (DEC-6 above); true for the slot and its default.
  • The emojiPicker shape is the one the spec owner suggested: unverified; the base pull request's discussion still shows its name awaiting the owner.
  • The API conventions guide allows a render function when the parent provides data: verified.
  • Without the slot typing shows nothing for any input, where Comments drew the indicator before: verified (test at Comments.test.tsx:611-622, run locally; base and head browser captures).
  • An input-type gate would not fit because the cause is the import boundary: consistent with the code, which has no input condition.
  • The dots move from the avatar column to the row's edge: verified (captures: the dots column narrows from 28px to 19px and the label moves 9px left).
  • The docs tell the indicator not to announce inside the threads log and to announce once per change, politely, with layout="embedded": verified (Comments.doc.mjs:136; the default layout renders a log and the embedded one does not, Comments.tsx:193, :611-649).
  • The live-state guidance in both components' docs names the prop: verified (Comments.doc.mjs:111; CommentThread.doc.mjs:81, :402, :523).
  • The CommentThread docs gain a typing accessibility row in English, Chinese and dense text: verified (CommentThread.doc.mjs:114-120, :435-441, :556-562).
  • First-load size without the slot drops by 0.9 KB (panel) and 0.6 KB (thread): reported; the direction matches the import graph.
  • The import-boundaries check sizes Core entries only: verified (every entry module in scripts/check-component-import-boundaries.mjs is under packages/core/src).
  • The showcase passes the indicator and lists it in componentsUsed: verified (CommentsShowcase.tsx:320-322, CommentsShowcase.doc.mjs:14).
  • The Comments tests pass (105): verified, 105 passed locally.
  • Lab build, typecheck and the pre-review checklist pass: reported; prettier and eslint on the changed files are clean locally.
  • Rebased onto main with the pull requests below, with this pull request's own diff unchanged: verified (the patch matches the pre-rebase patch apart from two hunk offsets).
  • One capability; unrelated fixes split; consumer docs and focused tests ship; no internal context in public text: verified (the header edit sits in the header sentence the change rewrites; no internal references found).

Files:

  • packages/lab/src/Comments/CommentRow.tsx: desktop behavior and inline-call crash findings.
  • packages/lab/src/Comments/types.ts: DEC-6 name finding.
  • packages/lab/src/Comments/CommentsContext.tsx: clear (follows the rename).
  • packages/lab/src/Comments/Comments.tsx: clear (follows the rename).
  • packages/lab/src/Comments/CommentThread.tsx: clear (follows the rename).
  • packages/lab/src/Comments/index.ts: clear.
  • packages/lab/src/index.ts: clear.
  • packages/lab/src/Comments/Comments.doc.mjs: clear (follows the rename).
  • packages/lab/src/Comments/CommentThread.doc.mjs: clear (follows the rename).
  • packages/lab/src/Comments/Comments.test.tsx: clear; a hook-component case belongs with the crash fix.
  • packages/lab/blocks/CommentsShowcase.tsx: clear (follows the rename).
  • packages/lab/blocks/CommentsShowcase.doc.mjs: clear.
  • apps/storybook/stories/Comments.stories.tsx: clear (follows the rename).

Automated review (maintainer link)

Comment thread packages/lab/src/Comments/types.ts Resolved
@ernestt ernestt changed the title feat(Comments): a typingIndicator render prop shows who is typing feat(Comments): a renderTypingIndicator render prop shows who is typing Dec 2, 2026
…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 `typingIndicator`
becomes `renderTypingIndicator` on Comments and CommentThread, with their
docs, the Live state story, the panel showcase, and the tests.

The row called the indicator function inside its own render, and only while
someone typed. An indicator component that calls hooks then changed the
row's hook count when typing started or stopped, and the thread crashed
("Rendered more hooks than during the previous render"). The indicator 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 code fixes are in, on top of #13740's new head:

  • renderTypingIndicator. spec:AST-055 DEC-6 (current) names every function-valued component prop render<X>, so the slot is now renderTypingIndicator on Comments and CommentThread. That covers the docs (English, Chinese and dense), the Live state story, the panel showcase and the tests. The name is no longer listed as an open question.
  • Indicator components with hooks. The indicator now renders through a small component, so its hooks run in their own fiber. A new test passes an indicator that calls useState while typing goes from none to someone and back. Without the fix it fails with "Rendered more hooks than during the previous render."; with the fix it passes.

The head is a merge of #13740's new head (the renderEmojiPicker rename and its slot fix) plus one commit for this pull request. Nothing below #13740 changed, so #13736–#13739 keep their heads.

On this head: 107 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 against #13740 shows 0 findings, and pnpm check:knowledge is clean.

The desktop default (no typing row without the slot) stays in the description as an item for the spec owner's /approve-spec, with the avatar-column question. The change comes from Core not importing Lab's indicator, not from the input type, so I didn't add a touch-only gate. The CommentThread docs already carry the typing accessibility row from the previous round.

@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 owner decision, and one code change is needed either way.

No current spec covers the new renderTypingIndicator slot on Comments and CommentThread: an engineering owner needs to provide or identify the governing spec for the slot, for hiding typing unless a product passes it, and for the typing row's alignment with the avatar column, including whether the slot receives the column width. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so if they are an engineering owner.

Blocking findings:

  • Desktop behavior change needs an owner decision: with default props, an open thread no longer shows the animated typing row for mouse and trackpad users (CommentRow.tsx:814-824), so gate the change to touch input or cite the owner's decision for it.
  • TypingIndicatorSlot (CommentRow.tsx:82-91) repeats the base's EmojiPickerSlot (CommentComposer.tsx:89-98), so make one shared render-slot helper for the family, use it in both places, and delete the two private copies.

The earlier hook crash and the render<X> naming are fixed: the hook-component test passes locally and fails locally when the slot is called inline again.

Claims and files checked

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

Claims:

  • Title: a renderTypingIndicator render prop shows who is typing: verified (CommentRow.tsx:814-824; test at Comments.test.tsx:578-609, run locally).
  • The slot is a render function in the same shape as renderEmojiPicker: verified (types.ts:316, :322-324).
  • For an open thread it receives the typing people besides the viewer, each once, and its result is placed at the end of the thread: verified (CommentRow.tsx:288-297, :406-408, :814-824: after the last reply, with the reply composer below it when open; the test feeds the viewer, Maya twice and the agent and asserts the last call gets Maya and the agent, run locally).
  • The new render-props type names what it receives and is exported: verified (types.ts:253-257, Comments/index.ts:36, lab/src/index.ts:77).
  • The family no longer imports the typing indicator: verified (a text search of the Comments folder finds the name only in a doc example string, and no Comments module imports anything from Lab's Chat folder, directly or through its two shared Lab helpers).
  • No spec decides a typing slot: verified (no current record names one; no Comments record exists).
  • The renderEmojiPicker shape is the one the spec owner suggested in the API review: unverified; the base pull request's discussion does not show that suggestion.
  • The API conventions guide allows a render function when the parent provides data: verified.
  • The slot's name follows the caller-rendered trigger spec's render<X> rule, so it is not open: verified.
  • Without the slot typing shows nothing for any input, where Comments drew the indicator before: verified (test at Comments.test.tsx:642-653, run locally; base and head browser captures).
  • An input-type gate would not fit because the cause is the import boundary: consistent with the code, which has no input condition.
  • The dots move from the avatar column to the row's edge: verified (captures: the private column width is gone and the label moves 9px left of the comment text).
  • The docs tell the indicator not to announce inside the threads log and to announce once per change, politely, with layout="embedded": verified (Comments.doc.mjs:136; the default layout renders a log and the embedded one does not, Comments.tsx:611-651).
  • The live-state guidance in both components' docs names the prop: verified (Comments.doc.mjs:111; CommentThread.doc.mjs:81, :402, :523).
  • Tests: the slot gets each person once without the viewer, there is no row without it, and a hook-using indicator renders as typing starts and stops, a test that fails without the fix: verified (Comments.test.tsx:578-653, run locally; the hook test fails locally when the slot is called inline again).
  • First-load size without the slot drops by 0.9 KB (panel) and 0.6 KB (thread): reported; the direction matches the import graph.
  • The import-boundaries check sizes Core entries only: verified (every entry in scripts/check-component-import-boundaries.mjs is under packages/core/src).
  • The showcase passes the indicator and lists it in componentsUsed: verified (CommentsShowcase.tsx:320-322, CommentsShowcase.doc.mjs:14).
  • The CommentThread docs gain a typing accessibility row in English, Chinese and dense text: verified (CommentThread.doc.mjs:114-120, :435-441, :556-562).
  • The Comments tests pass (107): verified, 107 passed locally.
  • Core and Lab builds, typecheck, the pre-review checklist and the knowledge check pass: reported; prettier is clean and eslint shows no errors on the changed files locally.
  • This head merges the base pull request's new head and adds one commit; nothing below it changed: verified (history shows one merge of the base branch and one commit).
  • One capability; unrelated fixes split; consumer docs and focused tests ship; no internal context in public text: verified (the header edit sits in the header sentence the change rewrites; no internal references found).

Files:

  • packages/lab/src/Comments/CommentRow.tsx: desktop behavior and shared-helper findings.
  • packages/lab/src/Comments/types.ts: clear.
  • packages/lab/src/Comments/CommentsContext.tsx: clear.
  • packages/lab/src/Comments/Comments.tsx: clear.
  • packages/lab/src/Comments/CommentThread.tsx: clear.
  • packages/lab/src/Comments/index.ts: clear.
  • packages/lab/src/index.ts: clear.
  • packages/lab/src/Comments/Comments.doc.mjs: clear.
  • packages/lab/src/Comments/CommentThread.doc.mjs: clear.
  • packages/lab/src/Comments/Comments.test.tsx: clear.
  • packages/lab/blocks/CommentsShowcase.tsx: clear.
  • packages/lab/blocks/CommentsShowcase.doc.mjs: clear.
  • apps/storybook/stories/Comments.stories.tsx: clear.

Automated review (maintainer link)

Comment on lines +82 to +91
/* Its own component, so the hooks of an indicator component run in their own
fiber, not in the row's render. */
function TypingIndicatorSlot({
render,
users,
}: CommentTypingIndicatorRenderProps & {
render: (props: CommentTypingIndicatorRenderProps) => ReactNode;
}) {
return render({users});
}

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.

This repeats EmojiPickerSlot in CommentComposer.tsx:89-98, comment included, with other props. A later fix to how the family renders a slot, such as a caller that switches between two indicator components, would reach only one of them. Make one shared helper and use it in both places, for example:

function RenderSlot<P>({
  render,
  props,
}: {
  render: (props: P) => ReactNode;
  props: P;
}) {
  return render(props);
}
// …
<RenderSlot render={renderTypingIndicator} props={{users: typingUsers}} />

then delete TypingIndicatorSlot and EmojiPickerSlot.

This branch was successfully deployed

1 active deployment
Preview — f735ad98 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