Repository navigation
docs(useChatDictation): add hook docs and a voice input example block - #11237
Conversation
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.
|
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.
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 inputblock callsuseChatDictation()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 asarchitecture:knowledge-contractsINV28 requires; make the words appear (throughinputRefon aChatComposerInput, or by renderinginterimTranscriptand theonResulttext) and cover that path in the test with a stubbedSpeechRecognition. packages/cli/api/component/__fixtures__/resolutions/modules.txtline 254 still recordsChat/Chat.doc.mjsforuseChatDictation, soresolution-compat.test.mjsfails now that the hook has its own doc; change it touseChatDictation useChatDictation Chat/useChatDictation.doc.mjs Chat/useChatDictation.ts, as earlier hook-doc additions did.- The
options.inputRefrow, 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 callingonResult, so a reader who also inserts theonResulttext 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.
|
/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.
PR Analysis Report🔎 Preview ·
|
| 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
|
/approve-spec 66bb8da |
There was a problem hiding this comment.
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 toblocks/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 useChatDictationandastryx searchreturn 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.tsxline 37). - Description: before this change the hook had no page and no example: verified on the base.
- Description: after it,
astryx template useChatDictationHookUsagecopies 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 inblocks/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.
…ider locale, and list every option and return
There was a problem hiding this comment.
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 emptyChatComposerInputshrink 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; dropalign="start"so the field spans the row (passing the input throughChatComposer'sinputslot, 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 hookdid 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 hookandastryx searchreturn it: verified by running both commands. - Description:
astryx template useChatDictationHookUsagecopies 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 inexampleFor: 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
onErrornote.
|
|
||
| export default function UseChatDictationHookUsage() { | ||
| const inputRef = useRef<ChatComposerInputHandle>(null); | ||
| const dictation = useChatDictation({inputRef}); |
There was a problem hiding this comment.
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.
|
/approve-spec 5263b9f |
There was a problem hiding this comment.
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 emptyChatComposerInputshrink to 8 px wide, so its "Type a message…" placeholder wraps one word per line over the Start button; dropalign="start"(thewidth="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 hookdid 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 hookandastryx searchreturn it: verified by running both commands. - Description:
astryx template useChatDictationHookUsagecopies 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 inexampleFor: 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
onErrornote.
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]>
|
/approve-spec a5fb522 |
There was a problem hiding this comment.
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 hookdid 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 hookandastryx searchreturn it: verified by running both commands. - Description:
astryx template useChatDictationHookUsagecopies 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 inexampleFor: 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
onErrornote.
Part of #11207
Reader impact
A builder cannot find
useChatDictation: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 useChatDictationHookUsagecopies the example.Source of truth
packages/core/src/Chat/useChatDictation.tsis the composer voice-input hook.architecture:knowledge-contractsINV28.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 onlyinputRef, 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.tsxexpects the unsupported-browser message, and, withSpeechRecognitionstubbed throughvi.stubGlobal, the partial phrase as composer ghost text and the finished phrase inserted into the composer exactly once.Scope
Components: Chat, useChatDictation
Testing
vitest run packages/cli/api/template/use-chat-dictation-hook-usage.test.tsx