Repository navigation
docs(useSpeechRecognition): add hook docs and a transcript example block - #11238
popsiclelmlm wants to merge 2 commits into
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
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.mjsfails becausepackages/cli/api/component/__fixtures__/resolutions/modules.txtline 297 still recordsChat/Chat.doc.mjsforuseSpeechRecognition, while the new hook doc is now whatastryx component useSpeechRecognitionopens; change that line touseSpeechRecognition 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.
|
/approve-spec 8920508 |
The resolution record still named Chat.doc.mjs. The example now keeps each final transcript from onResult.
PR Analysis Report🔎 Preview ·
|
|
/approve-spec 66c8ccb |
There was a problem hiding this comment.
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 toblocks/components/ChatComposerInput/, so please correct the path in the description, or move the block back toChat/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 hookdoes 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 hookandastryx searchreturn it, andastryx template useSpeechRecognitionHookUsagecopies 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/useSpeechRecognitionHookUsagewithexampleFor: 'useSpeechRecognition'. False path: the block is inblocks/components/ChatComposerInput/;exampleForis 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 useSpeechRecognitionandastryx searchreturn 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.
| : speech.isListening | ||
| ? 'Listening' | ||
| : 'Ready'; | ||
| const transcript = speech.interimTranscript || said || 'No transcript yet'; |
There was a problem hiding this comment.
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';
Part of #11207
Reader impact
A builder cannot find
useSpeechRecognition:astryx hookdoes not return it, and the hook has no docsite page or runnable example. After this change the hook has a page,astryx hookandastryx searchreturn it, andastryx template useSpeechRecognitionHookUsagecopies the example.Source of truth
packages/core/src/Chat/useSpeechRecognition.tsis the headless speech-recognition hook.architecture:knowledge-contractsINV28.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.tsxexpects the unsupported-browser message and the empty transcript.Scope
Components: Chat, useSpeechRecognition
Testing
vitest run packages/cli/api/template/use-speech-recognition-hook-usage.test.tsx