Skip to content

docs(useChatDictation): add hook docs and a voice input example block - #11237

Merged
cixzhang merged 5 commits into
meta:mainfrom
popsiclelmlm:docs/use-chat-dictation
Nov 13, 2026
Merged

cixzhang merged 5 commits into
meta:mainfrom
popsiclelmlm:docs/use-chat-dictation

Conversation

@popsiclelmlm

@popsiclelmlm popsiclelmlm commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Part of #11207

Reader impact

A builder cannot find useChatDictation: astryx hook does not return it, and the hook has no docsite page or runnable example. After this change the hook has a page, astryx hook and astryx search return it, and astryx template useChatDictationHookUsage copies the example.

Source of truth

packages/core/src/Chat/useChatDictation.ts is the composer voice-input hook. architecture:knowledge-contracts INV28.

Correction

Adds a HookDoc next to the source that lists every option and return of the hook, and blocks/components/ChatComposerInput/useChatDictationHookUsage (exampleFor: 'useChatDictation'). The block passes only inputRef, so it listens in the provider locale; partial words show as ghost text in the composer, and each finished phrase is inserted there once. The control stays disabled when speech recognition is unavailable.

Evidence

use-chat-dictation-hook-usage.test.tsx expects the unsupported-browser message, and, with SpeechRecognition stubbed through vi.stubGlobal, the partial phrase as composer ghost text and the finished phrase inserted into the composer exactly once.

Scope

Components: Chat, useChatDictation

  • This PR changes documentation only, or names every necessary generated artifact.
  • Runtime, API, visual, and policy changes were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

vitest run packages/cli/api/template/use-chat-dictation-hook-usage.test.tsx

Hook docs for `useChatDictation`, so `astryx hook useChatDictation` and `astryx search` return it, and a `useChatDictation — Voice input` example block: a start and stop control that stays off when the browser has no speech recognition.
@vercel

vercel Bot commented Nov 11, 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 Nov 13, 2026 4:42pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 13, 2026, 4:57 PM UTC

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Nov 11, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 11, 2026
@popsiclelmlm
popsiclelmlm marked this pull request as ready for review November 11, 2026 13:51

@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.

Changes requested. Thanks for adding the useChatDictation docs: the hook now has a page and shows up in astryx search. Three things still need fixing:

  • The useChatDictation — Voice input block calls useChatDictation() with no options and never shows what was said, so it does not demonstrate the hook's voice-input use case or its main options as architecture:knowledge-contracts INV28 requires; make the words appear (through inputRef on a ChatComposerInput, or by rendering interimTranscript and the onResult text) and cover that path in the test with a stubbed SpeechRecognition.
  • packages/cli/api/component/__fixtures__/resolutions/modules.txt line 254 still records Chat/Chat.doc.mjs for useChatDictation, so resolution-compat.test.mjs fails now that the hook has its own doc; change it to useChatDictation useChatDictation Chat/useChatDictation.doc.mjs Chat/useChatDictation.ts, as earlier hook-doc additions did.
  • The options.inputRef row, its dense text and both best practices say it only shows interim text, but the hook also focuses the composer and inserts each final transcript there while still calling onResult, so a reader who also inserts the onResult text gets every phrase twice; describe both effects.

Optional: the page could also list onError, the only signal that microphone permission was refused, and say that sustained loud speech turns the transcript to upper case.

Automated review (maintainer link)

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 4875a48

The example now passes inputRef, so a finished phrase is inserted once. The doc says onResult still runs. The resolution record opens the hook doc.
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · a5fb522

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
ChatComposer 84.3 kB (0) · 12.9 kB CSS (0) — ✓ · ✓ · —
ChatComposerDrawer 18.2 kB (0) · 4.7 kB CSS (0) — ✓ · ✓ · —
ChatComposerInput 81.9 kB (0) · 12.1 kB CSS (0) — ✓ · ✓ · —
14 more components
Component Size LoC Visual · A11y · RTL
ChatComposerTokenElement 81.9 kB (0) · 12.1 kB CSS (0) — ✓ · ✓ · —
ChatDictationButton 65.4 kB (0) · 10.8 kB CSS (0) — ✓ · ✓ · —
ChatLayout 88.2 kB (0) · 11.3 kB CSS (0) — ✓ · ✓ · —
ChatLayoutScrollButton 65.4 kB (0) · 11.0 kB CSS (0) — ✓ · ✓ · —
ChatMessage 17.2 kB (0) · 3.7 kB CSS (0) — ✓ · ✓ · ✓
ChatMessageBubble 7.6 kB (0) · 3.7 kB CSS (0) — ✓ · ✓ · ✓
ChatMessageList 30.6 kB (0) · 7.1 kB CSS (0) — ✓ · ✓ · —
ChatMessageMetadata 20.4 kB (0) · 4.1 kB CSS (0) — ✓ · ✓ · —
ChatSendButton 65.2 kB (0) · 10.8 kB CSS (0) — ✓ · ✓ · —
ChatSystemMessage 7.1 kB (0) · 3.8 kB CSS (0) — ✓ · ✓ · —
ChatTokenizedText 7.5 kB (0) · 4.0 kB CSS (0) — ✓ · ✓ · —
ChatToolCalls 34.9 kB (0) · 8.4 kB CSS (0) — ✓ · ✓ · —
chat — — — · ✓ · —
Chat — — ✓ · ✓ · —

Package size:

  • @astryxdesign/cli 4.24 MB packed (+457 B); no new dependencies
  • @astryxdesign/core 7.52 MB packed (+1.4 kB); no new dependencies

Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 66bb8da

@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.

Changes requested, for one small fix. The useChatDictation page and the voice-input block now meet the hook example requirements, and the three points from the last review are fixed.

  • The description's Correction paragraph still says the block is at blocks/components/Chat/useChatDictationHookUsage, but this head moved it to blocks/components/ChatComposerInput/useChatDictationHookUsage, so please update that path to match the files.

Optional: the block's interim line repeats the ghost text the hook already shows in the composer and reads "No words yet" after a phrase lands; lang: 'en-US' overrides the provider locale the hook would use; the page could list onError and the bands return; and the test could stub SpeechRecognition with vi.stubGlobal and check that the phrase is inserted once. Repository CI has not run on this head yet: a maintainer adds the ci:run label so it runs.

Claims and files checked
  • Changeset: astryx hook useChatDictation and astryx search return the hook: verified (discovery and search read the new hook doc).
  • Changeset: the example block is named "useChatDictation — Voice input": verified.
  • Changeset and description: the start and stop control stays disabled without speech recognition: verified (useChatDictationHookUsage.tsx line 37).
  • Description: before this change the hook had no page and no example: verified on the base.
  • Description: after it, astryx template useChatDictationHookUsage copies the example: verified from the template catalog and the route entries.
  • Description: the hook doc sits next to the hook's source: verified.
  • Description: the block is at blocks/components/Chat/useChatDictationHookUsage: false; it is in blocks/components/ChatComposerInput/.
  • Description: the block names the hook in exampleFor: verified.
  • Description: the test expects the unsupported-browser message: verified (test lines 47-51).
  • Description: documentation only, with no runtime, API, visual or policy change: verified.
  • Description: no internal context in public text: verified.
  • Files: the changeset, both route lists, the resolution record and the block's doc: clear.
  • Files: the block, the test and the hook doc: clear apart from the optional notes above.

Automated review (maintainer link)

…ider locale, and list every option and return

@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.

Changes requested, for one layout fix in the example block. The useChatDictation page now lists every option and return, the block shows the hook's composer use case, and the points from the last review are fixed.

  • Miss: in useChatDictationHookUsage.tsx, <VStack align="start"> lets the empty ChatComposerInput shrink to 8 px wide, so its "Type a message…" placeholder wraps one word per line over the Start button until a phrase fills the field; drop align="start" so the field spans the row (passing the input through ChatComposer's input slot, as the other composer blocks do, also gives it a visible frame).

Optional: the page tells builders to handle onError, but the block does not, so a refused microphone permission returns it to "Ready" with no message. Repository CI has not run on this head yet: a maintainer adds the ci:run label so it runs.

Claims and files checked
  • Description: before this change astryx hook did not return the hook, and it had no page or runnable example: verified (the base answers "No hook named" and no block names the hook).
  • Description: after it, the hook has a page, and astryx hook and astryx search return it: verified by running both commands.
  • Description: astryx template useChatDictationHookUsage copies the example: verified (it prints the block).
  • Description: the hook doc sits next to the hook source and lists every option and return: verified (12 options, 11 returns).
  • Description: the block is in blocks/components/ChatComposerInput/ and names the hook in exampleFor: verified.
  • Description: the block passes only inputRef, so it listens in the provider locale: verified (block line 17).
  • Description and changeset: partial words show as ghost text and each finished phrase is inserted once: verified (the test and a browser run).
  • Description and changeset: the control stays disabled without speech recognition: verified (block line 31).
  • Description: the test expects the unsupported-browser message and, with a stubbed recognizer, the ghost text and one insertion: verified (test lines 48-51, 105-106 and 116-117).
  • Description: documentation only, with no runtime, API or policy change: verified (no public API change; the hook is untouched).
  • Description: no internal context in public text: verified.
  • Changeset: the example block is named "useChatDictation — Voice input": verified.
  • Files: the changeset, both route lists, the resolution record, the block's doc, the hook doc and the test: clear.
  • Files: the block: the layout finding above, plus the optional onError note.

Automated review (maintainer link)


export default function UseChatDictationHookUsage() {
const inputRef = useRef<ChatComposerInputHandle>(null);
const dictation = useChatDictation({inputRef});

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.

Optional: the hook page says "Handle onError. It is the only signal that microphone permission was refused." Passing onError here and showing it in the status line would make the block follow its own page; today a refused permission returns it to "Ready" with no message.

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 5263b9f

@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.

Changes requested, for the same layout fix in the example block. This update merges main and leaves the pull request's own changes as they were, so the hook page, the test and the route entries stay ready and one fix remains.

  • In useChatDictationHookUsage.tsx (line 25), <VStack gap={3} align="start" width="100%"> still lets the empty ChatComposerInput shrink to 8 px wide, so its "Type a message…" placeholder wraps one word per line over the Start button; drop align="start" (the width="100%" sizes only the stack, not the field) so the field spans the row.

Optional: the hook page tells builders to handle onError, but the block does not, so a refused microphone permission returns it to "Ready" with no message. CI has not run on this head yet: a maintainer adds the ci:run label so it runs.

Claims and files checked
  • Description: before this change astryx hook did not return the hook, and it had no page or runnable example: verified (the base answers "No hook named").
  • Description: after it, the hook has a page, and astryx hook and astryx search return it: verified by running both commands.
  • Description: astryx template useChatDictationHookUsage copies the example: verified (it prints the block).
  • Description: the hook doc sits next to the hook source and lists every option and return: verified (12 options, 11 returns).
  • Description: the block lives in blocks/components/ChatComposerInput/ and names the hook in exampleFor: verified.
  • Description: the block passes only inputRef, so it listens in the provider locale: verified (block line 17).
  • Description and changeset: partial words show as ghost text and each finished phrase is inserted once: verified (the test and a browser run).
  • Description and changeset: the control stays disabled without speech recognition: verified (block line 31).
  • Description: the test expects the unsupported-browser message and, with a stubbed recognizer, the ghost text and one insertion: verified (test lines 48-51, 77, 106 and 117).
  • Description: documentation only, with no runtime, API or policy change: verified (no public API change; the hook is untouched).
  • Description: no internal context in public text: verified.
  • Changeset: the example block is named "useChatDictation — Voice input": verified.
  • Files: the changeset, both route lists, the resolution record, the block's doc, the hook doc and the test: clear.
  • Files: the block: the layout finding above, plus the optional onError note.

Automated review (maintainer link)

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 13, 2026
The stack aligned its children to the start, so the empty
ChatComposerInput shrank to 8 px and its placeholder wrapped one word per
line over the Start button. The stack now stretches its children, so the
field spans the row, and the Start button sits in a row of its own at its
own width.

Co-authored-by: popsiclelmlm <[email protected]>
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec a5fb522

@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.

Approved pending CI: CI has not run on this head yet because the pull request is still a draft, and with the ci:run label already on it, marking it ready for review starts CI.

The example block's field now spans the row, so the earlier layout fix is done; the useChatDictation page, the voice-input block, its test and the route entries need no further changes.

Optional: the hook page tells builders to handle onError, but the block does not pass it, so a refused microphone permission returns it to "Ready" with no message (useChatDictationHookUsage.tsx, line 17).

Claims and files checked
  • Description: before this change astryx hook did not return the hook and it had no page or example of its own: verified (the base answers "No hook named", search lists no hook entry, and no block names it as its example).
  • Description: after it, the hook has a page and astryx hook and astryx search return it: verified by running both commands.
  • Description: astryx template useChatDictationHookUsage copies the example: verified (it prints the block).
  • Description: the hook source is the composer voice-input hook, and the repository's hook-example rule governs the change: verified (the hook is unchanged; the rule asks for a hook doc and a block naming the hook).
  • Description: the hook doc sits next to the source and lists every option and return: verified (12 options and 11 returns, matching the hook's types and defaults).
  • Description: the block lives in blocks/components/ChatComposerInput/ and names the hook in exampleFor: verified (block doc line 6).
  • Description: the block passes only inputRef, so it listens in the provider locale: verified (block line 17; a browser run reads the provider locale).
  • Description and changeset: partial words show as ghost text and each finished phrase is inserted once: verified (test lines 105-106 and 116-117, and a browser run).
  • Description and changeset: the control stays disabled without speech recognition: verified (block line 32; the browser shows Start disabled).
  • Description: the test expects the unsupported-browser message and, with a stubbed recognizer, the ghost text and one insertion: verified (test lines 48-51, 77, 105-106 and 117; it passes).
  • Description: the scope is Chat and useChatDictation: verified (no other component changes).
  • Description: documentation only, with no runtime, API, visual or policy change: verified (the built public surface is unchanged and no component changes).
  • Description: no internal context in public text: verified.
  • Changeset: patch releases for Core and the CLI: verified (Core ships the hook doc, the CLI ships the block; the changeset check passes).
  • Changeset: the example block is named "useChatDictation — Voice input": verified (block doc line 7).
  • Files: the changeset, the sandbox route list, the route lock, the resolution record, the block's doc, the hook doc and the test: clear.
  • Files: the block: clear, with the optional onError note.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 13, 2026 17:38
@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Nov 13, 2026
@cixzhang
cixzhang merged commit 538e297 into meta:main Nov 13, 2026
137 checks passed

This branch was successfully deployed

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

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants