Skip to content

docs(useSpeechRecognition): add hook docs and a transcript example block - #11238

Open
popsiclelmlm wants to merge 2 commits into
meta:mainfrom
popsiclelmlm:docs/use-speech-recognition
Open

popsiclelmlm wants to merge 2 commits into
meta:mainfrom
popsiclelmlm:docs/use-speech-recognition

Conversation

@popsiclelmlm

Copy link
Copy Markdown
Contributor

Part of #11207

Reader impact

A builder cannot find useSpeechRecognition: 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 useSpeechRecognitionHookUsage copies the example.

Source of truth

packages/core/src/Chat/useSpeechRecognition.ts is the headless speech-recognition hook. architecture:knowledge-contracts INV28.

Correction

Adds a HookDoc next to the source, and blocks/components/Chat/useSpeechRecognitionHookUsage (exampleFor: 'useSpeechRecognition'). The block shows support, the interim transcript, and a start control that stays off when recognition is unavailable.

Evidence

use-speech-recognition-hook-usage.test.tsx expects the unsupported-browser message and the empty transcript.

Scope

Components: Chat, useSpeechRecognition

  • 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-speech-recognition-hook-usage.test.tsx

Hook docs for `useSpeechRecognition`, so `astryx hook useSpeechRecognition` and `astryx search` return it, and a `useSpeechRecognition — Transcript` example block: a headless control that shows whether the browser can listen and the interim transcript.
@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 12, 2026 6:34am 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
🔄 In progress (for maintainers only) Nov 12, 2026, 6:50 AM 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 needs:design-review Affects visuals — Design should review 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:52

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

Thanks for documenting useSpeechRecognition: with the hook doc and the Transcript block, astryx hook, astryx search and astryx template now find it, and one change is still needed before this can merge:

  • packages/cli/api/component/resolution-compat.test.mjs fails because packages/cli/api/component/__fixtures__/resolutions/modules.txt line 297 still records Chat/Chat.doc.mjs for useSpeechRecognition, while the new hook doc is now what astryx component useSpeechRecognition opens; change that line to useSpeechRecognition useSpeechRecognition Chat/useSpeechRecognition.doc.mjs Chat/useSpeechRecognition.ts.

The spec approval on this pull request does not clear the failing test. Two non-blocking suggestions still apply: keep the final transcript from onResult in the block so finished phrases stay visible, and list the hook's missing options and returns (audioContext, transformTranscript, onTranscript, onStart, onEnd, isSpeaking, bands, rawBands) in the doc. CI has not run on this head yet; a maintainer adds the ci:run label once the fix is pushed.

Automated review (maintainer link)

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 8920508

The resolution record still named Chat.doc.mjs. The example now keeps each final transcript from onResult.
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 66c8ccb

This branch's preview address cannot be known in advance; open it from Vercel's comment.

Current run: The current CI run concluded failure. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 66c8ccb

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

Thanks for the update: the resolution fixture, the finished-phrase handling and the missing hook-doc rows from the last review are all fixed. One change is still needed before this can merge:

  • The description says the example block is added at blocks/components/Chat/useSpeechRecognitionHookUsage, but the latest commit moved it to blocks/components/ChatComposerInput/, so please correct the path in the description, or move the block back to Chat/ if the move was not intended.

Two non-blocking suggestions: keep finished phrases visible while the next phrase is still being recognized (the transcript line shows only the live words until they are final), and prefer Chat/ over ChatComposerInput/, since the folder sets the block's catalog category and the hook doc advises against using the hook with ChatComposerInput. CI has not run on this head yet; a maintainer adds the ci:run label so it runs.

Claims and files checked
  • Claim: before this change, astryx hook does not find the hook, and it has no docs page or runnable example. Verified: the base has no hook doc and no block naming the hook.
  • Claim: after this change the hook has a page, astryx hook and astryx search return it, and astryx template useSpeechRecognitionHookUsage copies the example. Verified from the discovery code: hook docs are found by scanning component folders, and blocks by their doc file.
  • Claim: the hook doc sits next to the hook's source. Verified: packages/core/src/Chat/useSpeechRecognition.doc.mjs.
  • Claim: the example block is blocks/components/Chat/useSpeechRecognitionHookUsage with exampleFor: 'useSpeechRecognition'. False path: the block is in blocks/components/ChatComposerInput/; exampleFor is correct.
  • Claim: the block shows support, the interim transcript, and a Start control that stays off without recognition. Verified: useSpeechRecognitionHookUsage.tsx:20-38.
  • Claim: the test expects the unsupported-browser message and the empty transcript. Verified: use-speech-recognition-hook-usage.test.tsx:47-52.
  • Changeset: patch releases of core (which ships the hook doc) and the CLI (which ships the block); astryx hook useSpeechRecognition and astryx search return the hook; the block shows support and the interim transcript. Verified.
  • .changeset/hook-doc-use-speech-recognition.md: clear.
  • apps/sandbox/scripts/next-export-routes.json: clear.
  • internal/shadcn-registry/routes.lock.json: clear.
  • packages/cli/api/component/__fixtures__/resolutions/modules.txt: clear.
  • packages/cli/api/template/use-speech-recognition-hook-usage.test.tsx: clear.
  • packages/cli/assets/templates/blocks/components/ChatComposerInput/useSpeechRecognitionHookUsage.doc.mjs: folder differs from the description (blocking).
  • packages/cli/assets/templates/blocks/components/ChatComposerInput/useSpeechRecognitionHookUsage.tsx: finished phrases hidden while the next phrase is live (non-blocking).
  • packages/core/src/Chat/useSpeechRecognition.doc.mjs: clear; every option and return matches the hook's types.

Automated review (maintainer link)

: speech.isListening
? 'Listening'
: 'Ready';
const transcript = speech.interimTranscript || said || 'No transcript yet';

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.

Non-blocking: while a second phrase is still being recognized, this line shows only that phrase, so the finished text from onResult disappears until the new phrase is final. Showing both keeps it visible:

const transcript =
  [said, speech.interimTranscript].filter(Boolean).join(' ') ||
  'No transcript yet';

This branch was successfully deployed

1 active deployment
Preview — 66c8ccb0 Deployed Nov 12, 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. 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 needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants