@burdenoff/microfe-healthybowl 2026.902.7 → 2026.902.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,7 +28,7 @@ var _ = 200, v = ({ onSend: v, disabled: y = !1, placeholder: b, mode: oe, avail
28
28
  e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, _)}px`);
29
29
  }, [E]);
30
30
  let Z = s(() => {
31
- X && (G.isListening && G.stop(), v(E.trim(), J), D(""), R());
31
+ X && (G.isActive && G.stop(), v(E.trim(), J), D(""), R());
32
32
  }, [
33
33
  X,
34
34
  v,
@@ -108,14 +108,15 @@ var _ = 200, v = ({ onSend: v, disabled: y = !1, placeholder: b, mode: oe, avail
108
108
  current: W,
109
109
  selected: H,
110
110
  onChange: U,
111
- disabled: y || G.isListening
111
+ disabled: y || G.isActive
112
112
  }),
113
113
  G.isSupported && /* @__PURE__ */ h(ne, {
114
114
  isListening: G.isListening,
115
+ isStarting: G.isStarting,
115
116
  onToggle: G.toggle,
116
117
  disabled: y
117
118
  }),
118
- S && q.length === 0 && j.length === 0 && !G.isListening ? /* @__PURE__ */ h(ie, {
119
+ S && q.length === 0 && j.length === 0 && !G.isActive ? /* @__PURE__ */ h(ie, {
119
120
  onStart: S,
120
121
  disabled: y
121
122
  }) : /* @__PURE__ */ h("button", {
@@ -1 +1 @@
1
- {"version":3,"file":"AssistantComposer.js","names":[],"sources":["../../../../src/components/assistant/composer/AssistantComposer.tsx"],"sourcesContent":["import {\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ClipboardEvent,\n type DragEvent,\n type FC,\n type KeyboardEvent,\n} from 'react';\nimport { ArrowUp, Loader2 } from 'lucide-react';\nimport type { AssistantMode, AssistantModeConfig } from '@/types/assistant';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { useTr } from '../../../shared/hooks/useTr';\nimport { languageDisplayName } from '@/utils/speechVoices';\nimport { resolveAssistantLanguage } from '@/config/assistantLanguages';\nimport { useAssistantStore } from '@/store/assistantStore';\nimport { useVoiceInput } from '@/hooks/useVoiceInput';\nimport { useAssistantAttachments } from '@/hooks/useAssistantAttachments';\nimport {\n MAX_ATTACHMENTS,\n getSendableAttachments,\n type AssistantAttachment,\n type AttachmentRejection,\n} from '@/utils/assistantAttachments';\nimport { AssistantAttachmentButton } from './AssistantAttachmentButton';\nimport { AssistantAttachmentChips } from './AssistantAttachmentChips';\nimport { AssistantVoiceButton } from './AssistantVoiceButton';\nimport { AssistantLanguageSelector } from './AssistantLanguageSelector';\nimport { AssistantVoiceSessionButton } from '../voice/AssistantVoiceSessionButton';\nimport { AssistantModeSelector } from './AssistantModeSelector';\n\ninterface Props {\n /**\n * Send the message. `attachments` are already uploaded and ready; the chat\n * area folds them into the prompt and onto the user bubble.\n */\n onSend: (message: string, attachments: AssistantAttachment[]) => void;\n /** True while a turn is in-flight (assistant busy) — disables send + shows the spinner. */\n disabled?: boolean;\n placeholder?: string;\n mode: AssistantMode;\n /** Role-filtered list of modes the user may pick. */\n availableModes: AssistantModeConfig[];\n onModeChange: (mode: AssistantMode) => void;\n /**\n * Opens the hands-free voice conversation. Omitted where a voice session\n * cannot work at all (no speech input, or nothing able to speak the reply),\n * which is what hides the control rather than offering a dead button.\n */\n onStartVoiceSession?: () => void;\n}\n\nconst MAX_TEXTAREA_HEIGHT = 200;\n\n/**\n * AssistantComposer — the v2 input surface (per the ai-assistant-v2 mockups).\n *\n * A rounded card with, on the input row: a leading circular \"+\" attach control,\n * an auto-growing textarea, a microphone, and a prominent filled forest-green\n * circular send button. BELOW the input sit the mode pills (\"Ask\" active-green /\n * \"Take action\" outline); ABOVE it, chips for any pending attachments.\n *\n * Multimodal input (Workstreams 2–3) arrives through three converging paths —\n * the attach button, drag-and-drop onto the card, and paste (a screenshot from\n * the clipboard is the single most common way a user shares one) — plus voice\n * dictation, which appends recognised speech to the draft so it can still be\n * edited before sending.\n *\n * Fully controlled (React state for the text) with auto-grow via a layout\n * effect. Enter sends, Shift+Enter inserts a newline.\n */\nexport const AssistantComposer: FC<Props> = ({\n onSend,\n disabled = false,\n placeholder,\n mode,\n availableModes,\n onModeChange,\n onStartVoiceSession,\n}) => {\n const tr = useTr();\n const { locale } = useI18n();\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const [text, setText] = useState('');\n const [isDraggingOver, setIsDraggingOver] = useState(false);\n // Nested drag-enter/leave pairs fire for every child element; count them so\n // the highlight survives dragging across the textarea and buttons.\n const dragDepthRef = useRef(0);\n\n const {\n attachments,\n isBusy: attachmentsBusy,\n sendBlocker,\n rejection,\n addFiles,\n remove,\n retry,\n clear,\n clearRejection,\n canAddMore,\n } = useAssistantAttachments();\n\n const appendTranscript = useCallback((phrase: string) => {\n setText((current) => (current ? `${current.replace(/\\s+$/, '')} ${phrase}` : phrase));\n }, []);\n\n // One selection drives the recogniser, the reply language and the voice —\n // see `assistantLanguages`. `null` follows the interface language, which is\n // what this did unconditionally before.\n const assistantLanguage = useAssistantStore((state) => state.assistantLanguage);\n const setAssistantLanguage = useAssistantStore((state) => state.setAssistantLanguage);\n const spokenLanguage = useMemo(\n () => resolveAssistantLanguage(assistantLanguage, locale),\n [assistantLanguage, locale]\n );\n\n const voice = useVoiceInput({ onFinalize: appendTranscript, language: spokenLanguage.tag });\n\n const resolvedPlaceholder =\n placeholder ?? tr('healthybowl.assistant.composer.placeholder', 'Ask HealthyBowl anything…');\n const trimmed = text.trim();\n // Exactly what the model will be given — see `getSendableAttachments`.\n const sendableAttachments = getSendableAttachments(attachments);\n const failedAttachments = attachments.filter((attachment) => attachment.status === 'error');\n // A message may be attachments-only (\"what's wrong with this leaf?\" is often\n // just the photo), but never sends while an upload is in flight OR has failed:\n // `sendBlocker` covers both. Gating on the blocker rather than on\n // `attachmentsBusy` is what stops a turn going out that quietly omits a file\n // the user can still see attached — the chips are cleared by `clear()` below,\n // so the evidence would disappear at the same instant.\n const canSend = (trimmed.length > 0 || sendableAttachments.length > 0) && !disabled && sendBlocker === null;\n\n // Auto-grow the textarea to fit its content (capped), re-measured after every\n // value change so the card breathes as the user types.\n useLayoutEffect(() => {\n const textarea = textareaRef.current;\n if (!textarea) return;\n textarea.style.height = 'auto';\n textarea.style.height = `${Math.min(textarea.scrollHeight, MAX_TEXTAREA_HEIGHT)}px`;\n }, [text]);\n\n const handleSend = useCallback(() => {\n if (!canSend) return;\n // Dictation left running into a send would keep appending to a cleared\n // draft; stop it so the mic state matches what the user sees.\n if (voice.isListening) voice.stop();\n onSend(text.trim(), sendableAttachments);\n setText('');\n clear();\n }, [canSend, onSend, text, sendableAttachments, clear, voice]);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLTextAreaElement>) => {\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault();\n handleSend();\n }\n },\n [handleSend]\n );\n\n const handlePaste = useCallback(\n (event: ClipboardEvent<HTMLTextAreaElement>) => {\n const files = Array.from(event.clipboardData?.files ?? []);\n if (files.length === 0) return;\n // Only claim the paste when it carried files; a normal text paste (which\n // also exposes an empty `files`) must still land in the textarea.\n event.preventDefault();\n addFiles(files);\n },\n [addFiles]\n );\n\n const handleDragEnter = useCallback((event: DragEvent<HTMLDivElement>) => {\n if (!Array.from(event.dataTransfer?.types ?? []).includes('Files')) return;\n dragDepthRef.current += 1;\n setIsDraggingOver(true);\n }, []);\n\n const handleDragLeave = useCallback(() => {\n dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);\n if (dragDepthRef.current === 0) setIsDraggingOver(false);\n }, []);\n\n const handleDragOver = useCallback((event: DragEvent<HTMLDivElement>) => {\n if (!Array.from(event.dataTransfer?.types ?? []).includes('Files')) return;\n // Required for a drop to fire at all, and stops the browser from navigating\n // away to the dropped file.\n event.preventDefault();\n }, []);\n\n const handleDrop = useCallback(\n (event: DragEvent<HTMLDivElement>) => {\n event.preventDefault();\n dragDepthRef.current = 0;\n setIsDraggingOver(false);\n addFiles(event.dataTransfer?.files ?? null);\n },\n [addFiles]\n );\n\n const rejectionMessage = (reason: AttachmentRejection): string => {\n switch (reason) {\n case 'too-many':\n return tr('healthybowl.assistant.attachments.tooMany', 'You can attach up to {{max}} files per message.', {\n max: MAX_ATTACHMENTS,\n });\n case 'too-large':\n return tr('healthybowl.assistant.attachments.tooLarge', 'That file is larger than 10 MB.');\n case 'empty':\n return tr('healthybowl.assistant.attachments.empty', 'That file is empty.');\n case 'unreadable':\n return tr('healthybowl.assistant.attachments.unreadable', 'That file could not be read.');\n case 'unsupported-image':\n return tr(\n 'healthybowl.assistant.attachments.unsupportedImage',\n \"This device can't read that image format, so it can't be resized to send. Save it as JPEG and try again.\"\n );\n }\n };\n\n const voiceErrorMessage = (): string | null => {\n switch (voice.error) {\n case 'not-allowed':\n return tr(\n 'healthybowl.assistant.voice.denied',\n 'Microphone access is blocked. Allow it in your browser settings to dictate.'\n );\n case 'audio-capture':\n return tr('healthybowl.assistant.voice.noMic', 'No microphone was found.');\n case 'network':\n return tr('healthybowl.assistant.voice.network', 'Speech recognition is offline right now.');\n case 'language-not-supported':\n // The recogniser's language list is the browser vendor's, not ours, so\n // name the language and point at the browser rather than implying the\n // assistant is broken.\n return tr(\n 'healthybowl.assistant.voice.languageNotSupported',\n 'This browser cannot recognise spoken {{language}}. Try a different browser, or type instead.',\n { language: languageDisplayName(voice.language, locale) }\n );\n case 'unknown':\n return tr('healthybowl.assistant.voice.failed', 'Dictation stopped unexpectedly.');\n default:\n return null;\n }\n };\n\n const voiceError = voiceErrorMessage();\n\n return (\n <div className=\"flex-shrink-0 px-3 pb-3 pt-1.5\">\n <div\n onDragEnter={handleDragEnter}\n onDragLeave={handleDragLeave}\n onDragOver={handleDragOver}\n onDrop={handleDrop}\n className={`rounded-2xl border p-2 shadow-sm transition-colors focus-within:border-action-primary-bg focus-within:ring-2 focus-within:ring-action-primary-bg/15 ${\n isDraggingOver\n ? 'border-action-primary-bg border-dashed bg-action-primary-bg/5'\n : 'border-border-default bg-bg-sunken'\n }`}\n data-testid=\"assistant-composer\"\n >\n <AssistantAttachmentChips attachments={attachments} onRemove={remove} onRetry={retry} disabled={disabled} />\n\n {/* Input row: attach · textarea · mic · send */}\n <div className=\"flex items-end gap-2\">\n <AssistantAttachmentButton onFiles={addFiles} canAddMore={canAddMore} disabled={disabled} />\n\n <textarea\n ref={textareaRef}\n value={text}\n onChange={(event) => setText(event.target.value)}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n disabled={disabled}\n placeholder={\n isDraggingOver\n ? tr('healthybowl.assistant.composer.dropHere', 'Drop files to attach')\n : resolvedPlaceholder\n }\n rows={1}\n className=\"min-h-[36px] flex-1 resize-none self-center bg-transparent px-1 py-2 text-[15px] leading-relaxed text-text-primary placeholder:text-text-muted focus:outline-none disabled:opacity-50\"\n aria-label={tr('healthybowl.assistant.chatInput.ariaLabel', 'Message input')}\n data-testid=\"assistant-input\"\n />\n\n {/* Outside the dictation guard on purpose: this preference also\n decides what language the assistant REPLIES in, which works\n perfectly well on a browser with no speech recognition at all.\n Hiding it there left Firefox users unable to choose a reply\n language, which is most of what it is for. */}\n <AssistantLanguageSelector\n current={spokenLanguage}\n selected={assistantLanguage}\n onChange={setAssistantLanguage}\n disabled={disabled || voice.isListening}\n />\n\n {voice.isSupported && (\n <AssistantVoiceButton isListening={voice.isListening} onToggle={voice.toggle} disabled={disabled} />\n )}\n\n {/* The voice button takes the send slot while there is nothing to\n send — see AssistantVoiceSessionButton for why swapping rather\n than adding is the only option that fits. */}\n {/* Genuinely empty, NOT merely unsendable: `canSend` is also false\n while an attachment uploads or a turn is in flight, so keying off\n it would replace send even with a draft typed and ready. */}\n {onStartVoiceSession && trimmed.length === 0 && attachments.length === 0 && !voice.isListening ? (\n <AssistantVoiceSessionButton onStart={onStartVoiceSession} disabled={disabled} />\n ) : (\n <button\n type=\"button\"\n onClick={handleSend}\n disabled={!canSend}\n className={`flex size-9 flex-shrink-0 items-center justify-center rounded-full shadow-sm transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong ${\n canSend\n ? 'bg-action-primary-bg text-action-primary-text hover:scale-105 hover:bg-action-primary-bg-hover'\n : 'bg-bg-elevated text-text-muted'\n }`}\n aria-label={tr('healthybowl.assistant.chatInput.send', 'Send message')}\n data-testid=\"assistant-send\"\n >\n {disabled || attachmentsBusy ? (\n <Loader2 className=\"size-4 animate-spin\" />\n ) : (\n <ArrowUp className=\"size-4\" />\n )}\n </button>\n )}\n </div>\n\n {/* Mode pills */}\n {availableModes.length > 1 && (\n <div className=\"mt-2 px-0.5\">\n <AssistantModeSelector\n mode={mode}\n availableModes={availableModes}\n onModeChange={onModeChange}\n disabled={disabled}\n />\n </div>\n )}\n </div>\n\n {/* One status line under the card: live dictation > voice error >\n attachment rejection > failed upload > the keyboard hint. Announced\n politely so a screen-reader user hears dictation land without losing\n their place.\n\n The failed-upload line ranks below `rejection` (which is transient and\n describes the file the user just picked) but above the hint, because a\n disabled send button with no stated reason is the thing this whole\n change exists to avoid. */}\n <div className=\"mt-1.5 px-1 text-center text-[11px]\" aria-live=\"polite\">\n {/* ★ Three states, not two. `isListening` now waits for the recogniser's\n own `onstart`, which is the honest signal — but it left this line\n showing the idle hint after the user had already tapped the\n microphone, for the whole permission-prompt window. */}\n {voice.isStarting && !voice.isListening ? (\n <p className=\"text-text-muted\" data-testid=\"assistant-voice-starting\">\n {tr('healthybowl.assistant.voice.starting', 'Starting the microphone…')}\n </p>\n ) : voice.isListening ? (\n <p className=\"text-status-error-text\" data-testid=\"assistant-voice-status\">\n <span className=\"mr-1 inline-block size-1.5 rounded-full bg-status-error-text align-middle motion-safe:animate-pulse\" />\n {voice.interim ||\n tr('healthybowl.assistant.voice.listening', 'Listening… speak now, tap the square to stop')}\n </p>\n ) : voiceError ? (\n <p className=\"text-status-error-text\" data-testid=\"assistant-voice-error\">\n {voiceError}\n </p>\n ) : rejection ? (\n <button\n type=\"button\"\n onClick={clearRejection}\n className=\"text-status-error-text underline-offset-2 hover:underline\"\n data-testid=\"assistant-attachment-rejection\"\n >\n {rejectionMessage(rejection)}\n </button>\n ) : sendBlocker === 'failed' ? (\n <p className=\"text-status-error-text\" data-testid=\"assistant-attachment-blocked\">\n {failedAttachments.length === 1\n ? tr(\n 'healthybowl.assistant.attachments.blockedOne',\n \"{{name}} didn't upload. Retry or remove it before sending.\",\n { name: failedAttachments[0].filename }\n )\n : tr(\n 'healthybowl.assistant.attachments.blockedMany',\n \"{{count}} attachments didn't upload. Retry or remove them before sending.\",\n { count: failedAttachments.length }\n )}\n </p>\n ) : (\n <p className=\"text-text-muted\">\n {tr(\n 'healthybowl.assistant.composer.hint',\n 'Enter to send · Shift+Enter for newline · drag or paste files to attach'\n )}\n </p>\n )}\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsDA,IAAM,IAAsB,KAmBf,KAAgC,EAC3C,WACA,cAAW,IACX,gBACA,UACA,mBACA,kBACA,6BACI;CACJ,IAAM,IAAK,EAAM,GACX,EAAE,cAAW,EAAQ,GACrB,IAAc,EAA4B,IAAI,GAC9C,CAAC,GAAM,KAAW,EAAS,EAAE,GAC7B,CAAC,GAAgB,KAAqB,EAAS,EAAK,GAGpD,IAAe,EAAO,CAAC,GAEvB,EACJ,gBACA,QAAQ,GACR,gBACA,cACA,aACA,WACA,UACA,UACA,mBACA,kBACE,EAAwB,GAEtB,IAAmB,GAAa,MAAmB;EACvD,GAAS,MAAa,IAAU,GAAG,EAAQ,QAAQ,QAAQ,EAAE,EAAE,GAAG,MAAW,CAAO;CACtF,GAAG,CAAC,CAAC,GAKC,IAAoB,GAAmB,MAAU,EAAM,iBAAiB,GACxE,IAAuB,GAAmB,MAAU,EAAM,oBAAoB,GAC9E,IAAiB,QACf,EAAyB,GAAmB,CAAM,GACxD,CAAC,GAAmB,CAAM,CAC5B,GAEM,IAAQ,EAAc;EAAE,YAAY;EAAkB,UAAU,EAAe;CAAI,CAAC,GAEpF,IACJ,KAAe,EAAG,8CAA8C,2BAA2B,GACvF,I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,WAAU;IACV,eAAY;cAEX,GAAiB,CAAS;GACrB,CAAA,IACN,MAAgB,WAClB,kBAAC,KAAD;IAAG,WAAU;IAAyB,eAAY;cAC/C,EAAkB,WAAW,IAC1B,EACE,gDACA,8DACA,EAAE,MAAM,EAAkB,GAAG,SAAS,CACxC,IACA,EACE,iDACA,6EACA,EAAE,OAAO,EAAkB,OAAO,CACpC;GACH,CAAA,IAEH,kBAAC,KAAD;IAAG,WAAU;cACV,EACC,uCACA,yEACF;GACC,CAAA;EAEF,CAAA,CACF;;AAET"}
1
+ {"version":3,"file":"AssistantComposer.js","names":[],"sources":["../../../../src/components/assistant/composer/AssistantComposer.tsx"],"sourcesContent":["import {\n useCallback,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n type ClipboardEvent,\n type DragEvent,\n type FC,\n type KeyboardEvent,\n} from 'react';\nimport { ArrowUp, Loader2 } from 'lucide-react';\nimport type { AssistantMode, AssistantModeConfig } from '@/types/assistant';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { useTr } from '../../../shared/hooks/useTr';\nimport { languageDisplayName } from '@/utils/speechVoices';\nimport { resolveAssistantLanguage } from '@/config/assistantLanguages';\nimport { useAssistantStore } from '@/store/assistantStore';\nimport { useVoiceInput } from '@/hooks/useVoiceInput';\nimport { useAssistantAttachments } from '@/hooks/useAssistantAttachments';\nimport {\n MAX_ATTACHMENTS,\n getSendableAttachments,\n type AssistantAttachment,\n type AttachmentRejection,\n} from '@/utils/assistantAttachments';\nimport { AssistantAttachmentButton } from './AssistantAttachmentButton';\nimport { AssistantAttachmentChips } from './AssistantAttachmentChips';\nimport { AssistantVoiceButton } from './AssistantVoiceButton';\nimport { AssistantLanguageSelector } from './AssistantLanguageSelector';\nimport { AssistantVoiceSessionButton } from '../voice/AssistantVoiceSessionButton';\nimport { AssistantModeSelector } from './AssistantModeSelector';\n\ninterface Props {\n /**\n * Send the message. `attachments` are already uploaded and ready; the chat\n * area folds them into the prompt and onto the user bubble.\n */\n onSend: (message: string, attachments: AssistantAttachment[]) => void;\n /** True while a turn is in-flight (assistant busy) — disables send + shows the spinner. */\n disabled?: boolean;\n placeholder?: string;\n mode: AssistantMode;\n /** Role-filtered list of modes the user may pick. */\n availableModes: AssistantModeConfig[];\n onModeChange: (mode: AssistantMode) => void;\n /**\n * Opens the hands-free voice conversation. Omitted where a voice session\n * cannot work at all (no speech input, or nothing able to speak the reply),\n * which is what hides the control rather than offering a dead button.\n */\n onStartVoiceSession?: () => void;\n}\n\nconst MAX_TEXTAREA_HEIGHT = 200;\n\n/**\n * AssistantComposer — the v2 input surface (per the ai-assistant-v2 mockups).\n *\n * A rounded card with, on the input row: a leading circular \"+\" attach control,\n * an auto-growing textarea, a microphone, and a prominent filled forest-green\n * circular send button. BELOW the input sit the mode pills (\"Ask\" active-green /\n * \"Take action\" outline); ABOVE it, chips for any pending attachments.\n *\n * Multimodal input (Workstreams 2–3) arrives through three converging paths —\n * the attach button, drag-and-drop onto the card, and paste (a screenshot from\n * the clipboard is the single most common way a user shares one) — plus voice\n * dictation, which appends recognised speech to the draft so it can still be\n * edited before sending.\n *\n * Fully controlled (React state for the text) with auto-grow via a layout\n * effect. Enter sends, Shift+Enter inserts a newline.\n */\nexport const AssistantComposer: FC<Props> = ({\n onSend,\n disabled = false,\n placeholder,\n mode,\n availableModes,\n onModeChange,\n onStartVoiceSession,\n}) => {\n const tr = useTr();\n const { locale } = useI18n();\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n const [text, setText] = useState('');\n const [isDraggingOver, setIsDraggingOver] = useState(false);\n // Nested drag-enter/leave pairs fire for every child element; count them so\n // the highlight survives dragging across the textarea and buttons.\n const dragDepthRef = useRef(0);\n\n const {\n attachments,\n isBusy: attachmentsBusy,\n sendBlocker,\n rejection,\n addFiles,\n remove,\n retry,\n clear,\n clearRejection,\n canAddMore,\n } = useAssistantAttachments();\n\n const appendTranscript = useCallback((phrase: string) => {\n setText((current) => (current ? `${current.replace(/\\s+$/, '')} ${phrase}` : phrase));\n }, []);\n\n // One selection drives the recogniser, the reply language and the voice —\n // see `assistantLanguages`. `null` follows the interface language, which is\n // what this did unconditionally before.\n const assistantLanguage = useAssistantStore((state) => state.assistantLanguage);\n const setAssistantLanguage = useAssistantStore((state) => state.setAssistantLanguage);\n const spokenLanguage = useMemo(\n () => resolveAssistantLanguage(assistantLanguage, locale),\n [assistantLanguage, locale]\n );\n\n const voice = useVoiceInput({ onFinalize: appendTranscript, language: spokenLanguage.tag });\n\n const resolvedPlaceholder =\n placeholder ?? tr('healthybowl.assistant.composer.placeholder', 'Ask HealthyBowl anything…');\n const trimmed = text.trim();\n // Exactly what the model will be given — see `getSendableAttachments`.\n const sendableAttachments = getSendableAttachments(attachments);\n const failedAttachments = attachments.filter((attachment) => attachment.status === 'error');\n // A message may be attachments-only (\"what's wrong with this leaf?\" is often\n // just the photo), but never sends while an upload is in flight OR has failed:\n // `sendBlocker` covers both. Gating on the blocker rather than on\n // `attachmentsBusy` is what stops a turn going out that quietly omits a file\n // the user can still see attached — the chips are cleared by `clear()` below,\n // so the evidence would disappear at the same instant.\n const canSend = (trimmed.length > 0 || sendableAttachments.length > 0) && !disabled && sendBlocker === null;\n\n // Auto-grow the textarea to fit its content (capped), re-measured after every\n // value change so the card breathes as the user types.\n useLayoutEffect(() => {\n const textarea = textareaRef.current;\n if (!textarea) return;\n textarea.style.height = 'auto';\n textarea.style.height = `${Math.min(textarea.scrollHeight, MAX_TEXTAREA_HEIGHT)}px`;\n }, [text]);\n\n const handleSend = useCallback(() => {\n if (!canSend) return;\n // Dictation left running into a send would keep appending to a cleared\n // draft; stop it so the mic state matches what the user sees.\n // ★ `isActive`, not `isListening`. Sending during the permission window left\n // the recogniser running, and its trailing phrase landed in the draft this\n // line had just cleared — precisely what the comment above says it prevents.\n if (voice.isActive) voice.stop();\n onSend(text.trim(), sendableAttachments);\n setText('');\n clear();\n }, [canSend, onSend, text, sendableAttachments, clear, voice]);\n\n const handleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLTextAreaElement>) => {\n if (event.key === 'Enter' && !event.shiftKey) {\n event.preventDefault();\n handleSend();\n }\n },\n [handleSend]\n );\n\n const handlePaste = useCallback(\n (event: ClipboardEvent<HTMLTextAreaElement>) => {\n const files = Array.from(event.clipboardData?.files ?? []);\n if (files.length === 0) return;\n // Only claim the paste when it carried files; a normal text paste (which\n // also exposes an empty `files`) must still land in the textarea.\n event.preventDefault();\n addFiles(files);\n },\n [addFiles]\n );\n\n const handleDragEnter = useCallback((event: DragEvent<HTMLDivElement>) => {\n if (!Array.from(event.dataTransfer?.types ?? []).includes('Files')) return;\n dragDepthRef.current += 1;\n setIsDraggingOver(true);\n }, []);\n\n const handleDragLeave = useCallback(() => {\n dragDepthRef.current = Math.max(0, dragDepthRef.current - 1);\n if (dragDepthRef.current === 0) setIsDraggingOver(false);\n }, []);\n\n const handleDragOver = useCallback((event: DragEvent<HTMLDivElement>) => {\n if (!Array.from(event.dataTransfer?.types ?? []).includes('Files')) return;\n // Required for a drop to fire at all, and stops the browser from navigating\n // away to the dropped file.\n event.preventDefault();\n }, []);\n\n const handleDrop = useCallback(\n (event: DragEvent<HTMLDivElement>) => {\n event.preventDefault();\n dragDepthRef.current = 0;\n setIsDraggingOver(false);\n addFiles(event.dataTransfer?.files ?? null);\n },\n [addFiles]\n );\n\n const rejectionMessage = (reason: AttachmentRejection): string => {\n switch (reason) {\n case 'too-many':\n return tr('healthybowl.assistant.attachments.tooMany', 'You can attach up to {{max}} files per message.', {\n max: MAX_ATTACHMENTS,\n });\n case 'too-large':\n return tr('healthybowl.assistant.attachments.tooLarge', 'That file is larger than 10 MB.');\n case 'empty':\n return tr('healthybowl.assistant.attachments.empty', 'That file is empty.');\n case 'unreadable':\n return tr('healthybowl.assistant.attachments.unreadable', 'That file could not be read.');\n case 'unsupported-image':\n return tr(\n 'healthybowl.assistant.attachments.unsupportedImage',\n \"This device can't read that image format, so it can't be resized to send. Save it as JPEG and try again.\"\n );\n }\n };\n\n const voiceErrorMessage = (): string | null => {\n switch (voice.error) {\n case 'not-allowed':\n return tr(\n 'healthybowl.assistant.voice.denied',\n 'Microphone access is blocked. Allow it in your browser settings to dictate.'\n );\n case 'audio-capture':\n return tr('healthybowl.assistant.voice.noMic', 'No microphone was found.');\n case 'network':\n return tr('healthybowl.assistant.voice.network', 'Speech recognition is offline right now.');\n case 'language-not-supported':\n // The recogniser's language list is the browser vendor's, not ours, so\n // name the language and point at the browser rather than implying the\n // assistant is broken.\n return tr(\n 'healthybowl.assistant.voice.languageNotSupported',\n 'This browser cannot recognise spoken {{language}}. Try a different browser, or type instead.',\n { language: languageDisplayName(voice.language, locale) }\n );\n case 'unknown':\n return tr('healthybowl.assistant.voice.failed', 'Dictation stopped unexpectedly.');\n default:\n return null;\n }\n };\n\n const voiceError = voiceErrorMessage();\n\n return (\n <div className=\"flex-shrink-0 px-3 pb-3 pt-1.5\">\n <div\n onDragEnter={handleDragEnter}\n onDragLeave={handleDragLeave}\n onDragOver={handleDragOver}\n onDrop={handleDrop}\n className={`rounded-2xl border p-2 shadow-sm transition-colors focus-within:border-action-primary-bg focus-within:ring-2 focus-within:ring-action-primary-bg/15 ${\n isDraggingOver\n ? 'border-action-primary-bg border-dashed bg-action-primary-bg/5'\n : 'border-border-default bg-bg-sunken'\n }`}\n data-testid=\"assistant-composer\"\n >\n <AssistantAttachmentChips attachments={attachments} onRemove={remove} onRetry={retry} disabled={disabled} />\n\n {/* Input row: attach · textarea · mic · send */}\n <div className=\"flex items-end gap-2\">\n <AssistantAttachmentButton onFiles={addFiles} canAddMore={canAddMore} disabled={disabled} />\n\n <textarea\n ref={textareaRef}\n value={text}\n onChange={(event) => setText(event.target.value)}\n onKeyDown={handleKeyDown}\n onPaste={handlePaste}\n disabled={disabled}\n placeholder={\n isDraggingOver\n ? tr('healthybowl.assistant.composer.dropHere', 'Drop files to attach')\n : resolvedPlaceholder\n }\n rows={1}\n className=\"min-h-[36px] flex-1 resize-none self-center bg-transparent px-1 py-2 text-[15px] leading-relaxed text-text-primary placeholder:text-text-muted focus:outline-none disabled:opacity-50\"\n aria-label={tr('healthybowl.assistant.chatInput.ariaLabel', 'Message input')}\n data-testid=\"assistant-input\"\n />\n\n {/* Outside the dictation guard on purpose: this preference also\n decides what language the assistant REPLIES in, which works\n perfectly well on a browser with no speech recognition at all.\n Hiding it there left Firefox users unable to choose a reply\n language, which is most of what it is for. */}\n <AssistantLanguageSelector\n current={spokenLanguage}\n selected={assistantLanguage}\n onChange={setAssistantLanguage}\n disabled={disabled || voice.isActive}\n />\n\n {voice.isSupported && (\n <AssistantVoiceButton\n isListening={voice.isListening}\n isStarting={voice.isStarting}\n onToggle={voice.toggle}\n disabled={disabled}\n />\n )}\n\n {/* The voice button takes the send slot while there is nothing to\n send — see AssistantVoiceSessionButton for why swapping rather\n than adding is the only option that fits. */}\n {/* Genuinely empty, NOT merely unsendable: `canSend` is also false\n while an attachment uploads or a turn is in flight, so keying off\n it would replace send even with a draft typed and ready. */}\n {onStartVoiceSession && trimmed.length === 0 && attachments.length === 0 && !voice.isActive ? (\n <AssistantVoiceSessionButton onStart={onStartVoiceSession} disabled={disabled} />\n ) : (\n <button\n type=\"button\"\n onClick={handleSend}\n disabled={!canSend}\n className={`flex size-9 flex-shrink-0 items-center justify-center rounded-full shadow-sm transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong ${\n canSend\n ? 'bg-action-primary-bg text-action-primary-text hover:scale-105 hover:bg-action-primary-bg-hover'\n : 'bg-bg-elevated text-text-muted'\n }`}\n aria-label={tr('healthybowl.assistant.chatInput.send', 'Send message')}\n data-testid=\"assistant-send\"\n >\n {disabled || attachmentsBusy ? (\n <Loader2 className=\"size-4 animate-spin\" />\n ) : (\n <ArrowUp className=\"size-4\" />\n )}\n </button>\n )}\n </div>\n\n {/* Mode pills */}\n {availableModes.length > 1 && (\n <div className=\"mt-2 px-0.5\">\n <AssistantModeSelector\n mode={mode}\n availableModes={availableModes}\n onModeChange={onModeChange}\n disabled={disabled}\n />\n </div>\n )}\n </div>\n\n {/* One status line under the card: live dictation > voice error >\n attachment rejection > failed upload > the keyboard hint. Announced\n politely so a screen-reader user hears dictation land without losing\n their place.\n\n The failed-upload line ranks below `rejection` (which is transient and\n describes the file the user just picked) but above the hint, because a\n disabled send button with no stated reason is the thing this whole\n change exists to avoid. */}\n <div className=\"mt-1.5 px-1 text-center text-[11px]\" aria-live=\"polite\">\n {/* ★ Three states, not two. `isListening` now waits for the recogniser's\n own `onstart`, which is the honest signal — but it left this line\n showing the idle hint after the user had already tapped the\n microphone, for the whole permission-prompt window. */}\n {voice.isStarting && !voice.isListening ? (\n <p className=\"text-text-muted\" data-testid=\"assistant-voice-starting\">\n {tr('healthybowl.assistant.voice.starting', 'Starting the microphone…')}\n </p>\n ) : voice.isListening ? (\n <p className=\"text-status-error-text\" data-testid=\"assistant-voice-status\">\n <span className=\"mr-1 inline-block size-1.5 rounded-full bg-status-error-text align-middle motion-safe:animate-pulse\" />\n {voice.interim ||\n tr('healthybowl.assistant.voice.listening', 'Listening… speak now, tap the square to stop')}\n </p>\n ) : voiceError ? (\n <p className=\"text-status-error-text\" data-testid=\"assistant-voice-error\">\n {voiceError}\n </p>\n ) : rejection ? (\n <button\n type=\"button\"\n onClick={clearRejection}\n className=\"text-status-error-text underline-offset-2 hover:underline\"\n data-testid=\"assistant-attachment-rejection\"\n >\n {rejectionMessage(rejection)}\n </button>\n ) : sendBlocker === 'failed' ? (\n <p className=\"text-status-error-text\" data-testid=\"assistant-attachment-blocked\">\n {failedAttachments.length === 1\n ? tr(\n 'healthybowl.assistant.attachments.blockedOne',\n \"{{name}} didn't upload. Retry or remove it before sending.\",\n { name: failedAttachments[0].filename }\n )\n : tr(\n 'healthybowl.assistant.attachments.blockedMany',\n \"{{count}} attachments didn't upload. Retry or remove them before sending.\",\n { count: failedAttachments.length }\n )}\n </p>\n ) : (\n <p className=\"text-text-muted\">\n {tr(\n 'healthybowl.assistant.composer.hint',\n 'Enter to send · Sh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.js";
2
2
  import { Mic as t, Square as n } from "lucide-react";
3
3
  import { jsx as r, jsxs as i } from "react/jsx-runtime";
4
4
  //#region src/components/assistant/composer/AssistantVoiceButton.tsx
5
- var a = ({ isListening: a, onToggle: o, disabled: s = !1 }) => {
6
- let c = e(), l = a ? c("healthybowl.assistant.composer.voiceStop", "Stop dictation") : c("healthybowl.assistant.composer.voiceStart", "Dictate a message");
5
+ var a = ({ isListening: a, isStarting: o = !1, onToggle: s, disabled: c = !1 }) => {
6
+ let l = e(), u = a ? l("healthybowl.assistant.composer.voiceStop", "Stop dictation") : o ? l("healthybowl.assistant.composer.voiceStarting", "Starting the microphone — tap to cancel") : l("healthybowl.assistant.composer.voiceStart", "Dictate a message");
7
7
  return /* @__PURE__ */ r("button", {
8
8
  type: "button",
9
- onClick: o,
10
- disabled: s,
11
- title: l,
12
- "aria-label": l,
13
- "aria-pressed": a,
14
- className: `flex size-9 flex-shrink-0 items-center justify-center rounded-full border transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:cursor-not-allowed disabled:opacity-50 ${a ? "border-status-error-text/40 bg-status-error-bg/10 text-status-error-text" : "border-border-subtle bg-bg-elevated text-text-secondary hover:bg-bg-sunken hover:text-text-primary"}`,
9
+ onClick: s,
10
+ disabled: c,
11
+ title: u,
12
+ "aria-label": u,
13
+ "aria-pressed": a || o,
14
+ className: `flex size-9 flex-shrink-0 items-center justify-center rounded-full border transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:cursor-not-allowed disabled:opacity-50 ${a ? "border-status-error-text/40 bg-status-error-bg/10 text-status-error-text" : o ? "border-border-strong bg-bg-elevated text-text-secondary" : "border-border-subtle bg-bg-elevated text-text-secondary hover:bg-bg-sunken hover:text-text-primary"}`,
15
15
  "data-testid": "assistant-voice",
16
- children: a ? /* @__PURE__ */ i("span", {
16
+ "data-state": a ? "listening" : o ? "starting" : "idle",
17
+ children: o && !a ? /* @__PURE__ */ r(t, { className: "size-4 motion-safe:animate-pulse opacity-70" }) : a ? /* @__PURE__ */ i("span", {
17
18
  className: "relative flex items-center justify-center",
18
19
  children: [/* @__PURE__ */ r("span", { className: "absolute inline-flex size-7 rounded-full bg-status-error-bg/20 motion-safe:animate-ping" }), /* @__PURE__ */ r(n, { className: "relative size-3 fill-current" })]
19
20
  }) : /* @__PURE__ */ r(t, { className: "size-4" })
@@ -1 +1 @@
1
- {"version":3,"file":"AssistantVoiceButton.js","names":[],"sources":["../../../../src/components/assistant/composer/AssistantVoiceButton.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { Mic, Square } from 'lucide-react';\nimport { useTr } from '../../../shared/hooks/useTr';\n\ninterface Props {\n isListening: boolean;\n onToggle: () => void;\n disabled?: boolean;\n}\n\n/**\n * Microphone control in the composer — real speech-to-text (Workstream 2),\n * driven by `useVoiceInput`. While listening it becomes a stop button with a\n * live ring, so the control that starts dictation is also the one that ends it\n * (no hunting for a second affordance mid-sentence).\n *\n * The composer renders this only when the browser supports SpeechRecognition;\n * an unsupported engine gets no dead control at all.\n */\nexport const AssistantVoiceButton: FC<Props> = ({ isListening, onToggle, disabled = false }) => {\n const tr = useTr();\n const label = isListening\n ? tr('healthybowl.assistant.composer.voiceStop', 'Stop dictation')\n : tr('healthybowl.assistant.composer.voiceStart', 'Dictate a message');\n\n return (\n <button\n type=\"button\"\n onClick={onToggle}\n disabled={disabled}\n title={label}\n aria-label={label}\n aria-pressed={isListening}\n className={`flex size-9 flex-shrink-0 items-center justify-center rounded-full border transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:cursor-not-allowed disabled:opacity-50 ${\n isListening\n ? 'border-status-error-text/40 bg-status-error-bg/10 text-status-error-text'\n : 'border-border-subtle bg-bg-elevated text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n }`}\n data-testid=\"assistant-voice\"\n >\n {isListening ? (\n <span className=\"relative flex items-center justify-center\">\n {/* Pulsing ring reads as \"live\" at a glance; motion-safe so a\n reduced-motion user gets the colour change without the throb. */}\n <span className=\"absolute inline-flex size-7 rounded-full bg-status-error-bg/20 motion-safe:animate-ping\" />\n <Square className=\"relative size-3 fill-current\" />\n </span>\n ) : (\n <Mic className=\"size-4\" />\n )}\n </button>\n );\n};\n"],"mappings":";;;;AAmBA,IAAa,KAAmC,EAAE,gBAAa,aAAU,cAAW,SAAY;CAC9F,IAAM,IAAK,EAAM,GACX,IAAQ,IACV,EAAG,4CAA4C,gBAAgB,IAC/D,EAAG,6CAA6C,mBAAmB;CAEvE,OACE,kBAAC,UAAD;EACE,MAAK;EACL,SAAS;EACC;EACV,OAAO;EACP,cAAY;EACZ,gBAAc;EACd,WAAW,wNACT,IACI,6EACA;EAEN,eAAY;YAEX,IACC,kBAAC,QAAD;GAAM,WAAU;aAAhB,CAGE,kBAAC,QAAD,EAAM,WAAU,0FAA2F,CAAA,GAC3G,kBAAC,GAAD,EAAQ,WAAU,+BAAgC,CAAA,CAC9C;OAEN,kBAAC,GAAD,EAAK,WAAU,SAAU,CAAA;CAErB,CAAA;AAEZ"}
1
+ {"version":3,"file":"AssistantVoiceButton.js","names":[],"sources":["../../../../src/components/assistant/composer/AssistantVoiceButton.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { Mic, Square } from 'lucide-react';\nimport { useTr } from '../../../shared/hooks/useTr';\n\ninterface Props {\n isListening: boolean;\n /** Requested, not yet capturing — the permission prompt / start-up window. */\n isStarting?: boolean;\n onToggle: () => void;\n disabled?: boolean;\n}\n\n/**\n * Microphone control in the composer — real speech-to-text (Workstream 2),\n * driven by `useVoiceInput`. While listening it becomes a stop button with a\n * live ring, so the control that starts dictation is also the one that ends it\n * (no hunting for a second affordance mid-sentence).\n *\n * The composer renders this only when the browser supports SpeechRecognition;\n * an unsupported engine gets no dead control at all.\n */\nexport const AssistantVoiceButton: FC<Props> = ({ isListening, isStarting = false, onToggle, disabled = false }) => {\n const tr = useTr();\n // ★ Three states. Rendering the idle microphone while the browser is still\n // asking for permission told the user nothing had happened, so they pressed it\n // again — and the press was a no-op until `toggle` learned to cancel a pending\n // start. The icon now says which of the three it is.\n const label = isListening\n ? tr('healthybowl.assistant.composer.voiceStop', 'Stop dictation')\n : isStarting\n ? tr('healthybowl.assistant.composer.voiceStarting', 'Starting the microphone — tap to cancel')\n : tr('healthybowl.assistant.composer.voiceStart', 'Dictate a message');\n\n return (\n <button\n type=\"button\"\n onClick={onToggle}\n disabled={disabled}\n title={label}\n aria-label={label}\n aria-pressed={isListening || isStarting}\n className={`flex size-9 flex-shrink-0 items-center justify-center rounded-full border transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:cursor-not-allowed disabled:opacity-50 ${\n isListening\n ? 'border-status-error-text/40 bg-status-error-bg/10 text-status-error-text'\n : isStarting\n ? 'border-border-strong bg-bg-elevated text-text-secondary'\n : 'border-border-subtle bg-bg-elevated text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n }`}\n data-testid=\"assistant-voice\"\n data-state={isListening ? 'listening' : isStarting ? 'starting' : 'idle'}\n >\n {isStarting && !isListening ? (\n // Deliberately NOT disabled: this is the one moment the user most wants\n // a way out, and `toggle` now cancels the pending start.\n <Mic className=\"size-4 motion-safe:animate-pulse opacity-70\" />\n ) : isListening ? (\n <span className=\"relative flex items-center justify-center\">\n {/* Pulsing ring reads as \"live\" at a glance; motion-safe so a\n reduced-motion user gets the colour change without the throb. */}\n <span className=\"absolute inline-flex size-7 rounded-full bg-status-error-bg/20 motion-safe:animate-ping\" />\n <Square className=\"relative size-3 fill-current\" />\n </span>\n ) : (\n <Mic className=\"size-4\" />\n )}\n </button>\n );\n};\n"],"mappings":";;;;AAqBA,IAAa,KAAmC,EAAE,gBAAa,gBAAa,IAAO,aAAU,cAAW,SAAY;CAClH,IAAM,IAAK,EAAM,GAKX,IAAQ,IACV,EAAG,4CAA4C,gBAAgB,IAC/D,IACE,EAAG,gDAAgD,yCAAyC,IAC5F,EAAG,6CAA6C,mBAAmB;CAEzE,OACE,kBAAC,UAAD;EACE,MAAK;EACL,SAAS;EACC;EACV,OAAO;EACP,cAAY;EACZ,gBAAc,KAAe;EAC7B,WAAW,wNACT,IACI,6EACA,IACE,4DACA;EAER,eAAY;EACZ,cAAY,IAAc,cAAc,IAAa,aAAa;YAEjE,KAAc,CAAC,IAGd,kBAAC,GAAD,EAAK,WAAU,8CAA+C,CAAA,IAC5D,IACF,kBAAC,QAAD;GAAM,WAAU;aAAhB,CAGE,kBAAC,QAAD,EAAM,WAAU,0FAA2F,CAAA,GAC3G,kBAAC,GAAD,EAAQ,WAAU,+BAAgC,CAAA,CAC9C;OAEN,kBAAC,GAAD,EAAK,WAAU,SAAU,CAAA;CAErB,CAAA;AAEZ"}
@@ -71,25 +71,29 @@ function c({ onFinalize: c, language: l }) {
71
71
  let e = y.current;
72
72
  y.current = null, b.current += 1, e?.stop(), m(!1), f(!1), g("");
73
73
  }, []), E = n(C);
74
- return t(() => {
74
+ t(() => {
75
75
  E.current !== C && (E.current = C, T(), v(null));
76
- }, [C, T]), {
76
+ }, [C, T]);
77
+ let D = e(() => {
78
+ d || p ? T() : w();
79
+ }, [
80
+ d,
81
+ p,
82
+ w,
83
+ T
84
+ ]), O = e(() => v(null), []);
85
+ return {
77
86
  isSupported: S,
78
87
  isListening: d,
79
88
  isStarting: p,
89
+ isActive: d || p,
80
90
  interim: h,
81
91
  error: _,
82
92
  language: C,
83
93
  start: w,
84
94
  stop: T,
85
- toggle: e(() => {
86
- d ? T() : w();
87
- }, [
88
- d,
89
- w,
90
- T
91
- ]),
92
- clearError: e(() => v(null), [])
95
+ toggle: D,
96
+ clearError: O
93
97
  };
94
98
  }
95
99
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useVoiceInput.js","names":[],"sources":["../../src/hooks/useVoiceInput.ts"],"sourcesContent":["/**\n * Speech-to-text for the assistant composer (Workstream 2 of the AI Assistant\n * V2 multimodal effort).\n *\n * Input-only, browser-native (Web Speech API). It degrades gracefully:\n * `isSupported` is false on engines without SpeechRecognition (notably Firefox),\n * and the composer hides the mic entirely in that case rather than showing a\n * dead control.\n *\n * ⚠️ This does NOT mean the audio stays on the device. Chrome's\n * `webkitSpeechRecognition` is a NETWORK service — the audio is streamed to the\n * browser vendor for recognition, and the supported language list is theirs, not\n * ours. We neither receive nor store it, which is all an earlier version of this\n * comment (\"no audio ever leaves the device through us\") actually claimed; read\n * literally it implied something stronger and untrue. Whether recording farmers'\n * speech this way needs disclosure or consent is a product/legal call, not a\n * code one.\n *\n * Output (reading replies aloud) is a separate concern and lives in\n * `AssistantSpeechProvider`; an earlier version of this note said the assistant\n * does not speak, which stopped being true when BOFF-6290 shipped.\n *\n * Differences from the fe-libs `assistantWidget/useVoiceInput` this is modelled\n * on, all of which the composer needs:\n * - **interim results are exposed**, so the user sees words appear while\n * speaking instead of staring at a silent button until a phrase finalises;\n * - **errors are surfaced** (`error`) so a denied mic permission can be\n * explained rather than looking like a no-op;\n * - **the recogniser language follows the app locale** (a Tamil or Hindi\n * farmer dictating into an `en-US` recogniser gets garbage);\n * - **`stop()` resolves the final transcript** through `onFinalize`, so the\n * composer can commit exactly once when the user stops.\n */\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport type { Locale } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\n\ninterface SpeechRecognitionEventLike extends Event {\n results: SpeechRecognitionResultList;\n resultIndex: number;\n}\n\ninterface SpeechRecognitionErrorEventLike extends Event {\n error: string;\n message: string;\n}\n\ninterface SpeechRecognitionInstance extends EventTarget {\n continuous: boolean;\n interimResults: boolean;\n lang: string;\n start(): void;\n stop(): void;\n abort(): void;\n onresult: ((event: SpeechRecognitionEventLike) => void) | null;\n onerror: ((event: SpeechRecognitionErrorEventLike) => void) | null;\n onend: (() => void) | null;\n /**\n * Fires when the service has actually begun listening — the only honest\n * \"capture has started\" signal. Absent from this declaration until now, which\n * is part of why capture was inferred from `start()` returning instead.\n */\n onstart: (() => void) | null;\n}\n\ntype SpeechRecognitionConstructor = new () => SpeechRecognitionInstance;\n\n/**\n * BCP-47 tag for the recogniser, per app locale. Regional choices follow where\n * HealthyBowl actually operates (India for ta/hi) rather than a generic tag,\n * because the recogniser's acoustic model is region-specific.\n */\nconst RECOGNITION_LANG: Record<Locale, string> = {\n en: 'en-US',\n es: 'es-ES',\n fr: 'fr-FR',\n de: 'de-DE',\n ja: 'ja-JP',\n zh: 'zh-CN',\n ta: 'ta-IN',\n hi: 'hi-IN',\n ar: 'ar-SA',\n};\n\nfunction getSpeechRecognitionConstructor(): SpeechRecognitionConstructor | null {\n if (typeof window === 'undefined') return null;\n const win = window as unknown as Record<string, unknown>;\n return (\n (win.SpeechRecognition as SpeechRecognitionConstructor | undefined) ??\n (win.webkitSpeechRecognition as SpeechRecognitionConstructor | undefined) ??\n null\n );\n}\n\nexport type VoiceInputError =\n 'not-allowed' | 'no-speech' | 'audio-capture' | 'network' | 'language-not-supported' | 'unknown';\n\n/**\n * Map the spec's `SpeechRecognitionErrorEvent.error` codes onto the cases the UI\n * actually distinguishes. Anything else is 'unknown' (generic copy).\n *\n * `language-not-supported` is called out separately because it is the single\n * most likely failure for the users this feature exists for: the recogniser's\n * language list belongs to the browser vendor, not to us, so a Tamil or Hindi\n * speaker can hit it on a browser that simply does not offer their language.\n * Folding it into 'unknown' produced \"Dictation stopped unexpectedly\", which\n * tells them nothing and reads like a bug in HealthyBowl.\n */\nfunction toVoiceInputError(code: string): VoiceInputError {\n switch (code) {\n case 'not-allowed':\n case 'service-not-allowed':\n return 'not-allowed';\n case 'no-speech':\n return 'no-speech';\n case 'audio-capture':\n return 'audio-capture';\n case 'network':\n return 'network';\n case 'language-not-supported':\n return 'language-not-supported';\n default:\n return 'unknown';\n }\n}\n\nexport interface UseVoiceInputOptions {\n /**\n * Called with each newly finalised phrase. The composer appends it to the\n * draft; keeping the committed text in the caller (rather than accumulating\n * here) means the user can freely edit while dictation continues.\n */\n onFinalize: (text: string) => void;\n /**\n * BCP-47 tag to listen for. Omit to follow the app locale, which is what this\n * hook did unconditionally before (BOFF-7108).\n *\n * The two are genuinely independent: a farmer whose interface is English may\n * well speak Tamil, and deriving the recogniser language from the UI meant the\n * only way to dictate Tamil was to translate the entire app.\n */\n language?: string;\n}\n\nexport interface UseVoiceInputResult {\n isSupported: boolean;\n isListening: boolean;\n /** Requested, not yet capturing. Distinguishes starting up from listening. */\n isStarting: boolean;\n /** Words recognised but not yet finalised — render as a live hint. */\n interim: string;\n error: VoiceInputError | null;\n /**\n * BCP-47 tag the recogniser was asked for. Exposed so error copy can name the\n * language that failed (\"Tamil dictation is not supported…\") rather than\n * leaving the user to guess which language the browser rejected.\n */\n language: string;\n start: () => void;\n stop: () => void;\n /** Start if idle, stop if listening — what the mic button binds to. */\n toggle: () => void;\n clearError: () => void;\n}\n\nexport function useVoiceInput({ onFinalize, language: requested }: UseVoiceInputOptions): UseVoiceInputResult {\n const { locale } = useI18n();\n const [isListening, setIsListening] = useState(false);\n /**\n * Requested but not yet capturing — the permission prompt / start-up window.\n *\n * ★ Needed BECAUSE `isListening` now waits for `recognition.onstart`. That is\n * the honest signal, but it lengthened the window in which a caller has been\n * asked to listen and can say nothing about it — the composer showed its\n * idle hint after the user had already tapped the microphone.\n */\n const [isStarting, setIsStarting] = useState(false);\n const [interim, setInterim] = useState('');\n const [error, setError] = useState<VoiceInputError | null>(null);\n const recognitionRef = useRef<SpeechRecognitionInstance | null>(null);\n // Incremented on every stop. Handlers capture the session they were created\n // under and ignore events that arrive after it ends.\n const sessionRef = useRef(0);\n\n // Keep the newest callback reachable from the recogniser's long-lived event\n // handlers without re-creating the recogniser on every parent render.\n const onFinalizeRef = useRef(onFinalize);\n useEffect(() => {\n onFinalizeRef.current = onFinalize;\n }, [onFinalize]);\n\n const isSupported = getSpeechRecognitionConstructor() !== null;\n const language = requested ?? RECOGNITION_LANG[locale] ?? 'en-US';\n\n // Abort (not stop) on unmount: the panel is closing, so a trailing final\n // result would be committed into a draft nobody can see.\n useEffect(() => {\n return () => {\n recognitionRef.current?.abort();\n recognitionRef.current = null;\n };\n }, []);\n\n const start = useCallback(() => {\n const Ctor = getSpeechRecognitionConstructor();\n if (!Ctor || recognitionRef.current) return;\n\n const recognition = new Ctor();\n recognition.continuous = true;\n recognition.interimResults = true;\n recognition.lang = language;\n\n const session = sessionRef.current;\n\n recognition.onresult = (event) => {\n if (session !== sessionRef.current) return;\n let finalText = '';\n let interimText = '';\n for (let index = event.resultIndex; index < event.results.length; index += 1) {\n const result = event.results[index];\n const alternative = result[0]?.transcript ?? '';\n if (result.isFinal) {\n finalText += alternative;\n } else {\n interimText += alternative;\n }\n }\n if (finalText.trim()) onFinalizeRef.current(finalText.trim());\n setInterim(interimText.trim());\n };\n\n recognition.onerror = (event) => {\n if (session !== sessionRef.current) return;\n const mapped = toVoiceInputError(event.error);\n // 'no-speech' fires routinely during a natural pause and the recogniser\n // keeps running — surfacing it would flash a scary message mid-sentence.\n if (mapped !== 'no-speech') setError(mapped);\n };\n\n recognition.onend = () => {\n if (session !== sessionRef.current) return;\n recognitionRef.current = null;\n setIsStarting(false);\n setIsListening(false);\n setInterim('');\n };\n\n /**\n * ★ The TRUE capture signal.\n *\n * This was set optimistically on the line after `start()` returned — which\n * is synchronous, and says only that the request was accepted, not that the\n * microphone is open. Everything downstream then believed capture had begun\n * while the permission prompt was still up: the stage showed \"Listening…\"\n * over a microphone that could not yet hear, so a user who started talking\n * immediately lost the first word or two; the `connecting` stage lasted a\n * single commit; and the 5s \"we aren't hearing your microphone\" notice\n * could never fire, because `capturing` was already true.\n */\n recognition.onstart = () => {\n if (session !== sessionRef.current) return;\n setIsStarting(false);\n setIsListening(true);\n };\n\n setIsStarting(true);\n try {\n recognition.start();\n } catch {\n // start() throws if a recogniser is somehow already running — treat the\n // session as not started rather than leaving the button stuck \"live\".\n recognitionRef.current = null;\n setIsStarting(false);\n setIsListening(false);\n return;\n }\n\n recognitionRef.current = recognition;\n setError(null);\n setInterim('');\n }, [language]);\n\n const stop = useCallback(() => {\n // Detach BEFORE stopping. `onend` is what used to clear this ref, but it\n // arrives asynchronously — so a user who tapped stop and immediately tapped\n // the mic again hit `start()`'s `if (recognitionRef.current) return` guard\n // and got a silent no-op. Bumping the session also makes any trailing final\n // phrase the engine flushes on stop land on a dead session, instead of\n // reappearing in a draft the composer has already sent and cleared.\n const recognition = recognitionRef.current;\n recognitionRef.current = null;\n sessionRef.current += 1;\n recognition?.stop();\n setIsStarting(false);\n setIsListening(false);\n setInterim('');\n }, []);\n\n // Changing language must END the session it no longer describes.\n //\n // A running recogniser keeps the `lang` it was constructed with, so after a\n // switch the in-flight session is still listening in the OLD language while\n // this hook already reports the new one. A late `language-not-supported` from\n // that session would then be rendered as though the browser had rejected the\n // language the user just picked. Clearing the error is not enough — the\n // session producing it has to go too.\n const languageRef = useRef(language);\n useEffect(() => {\n if (languageRef.current === language) return;\n languageRef.current = language;\n stop();\n setError(null);\n }, [language, stop]);\n\n const toggle = useCallback(() => {\n if (isListening) stop();\n else start();\n }, [isListening, start, stop]);\n\n const clearError = useCallback(() => setError(null), []);\n\n return { isSupported, isListening, isStarting, interim, error, language, start, stop, toggle, clearError };\n}\n"],"mappings":";;;AAyEA,IAAM,IAA2C;CAC/C,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,SAAS,IAAuE;CAC9E,IAAI,OAAO,SAAW,KAAa,OAAO;CAC1C,IAAM,IAAM;CACZ,OACG,EAAI,qBACJ,EAAI,2BACL;AAEJ;AAgBA,SAAS,EAAkB,GAA+B;CACxD,QAAQ,GAAR;EACE,KAAK;EACL,KAAK,uBACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,iBACH,OAAO;EACT,KAAK,WACH,OAAO;EACT,KAAK,0BACH,OAAO;EACT,SACE,OAAO;CACX;AACF;AAyCA,SAAgB,EAAc,EAAE,eAAY,UAAU,K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AY,EAAW,YAC3B,EAAe,UAAU,MACzB,EAAc,EAAK,GACnB,EAAe,EAAK,GACpB,EAAW,EAAE;EACf,GAcA,EAAY,gBAAgB;GACtB,MAAY,EAAW,YAC3B,EAAc,EAAK,GACnB,EAAe,EAAI;EACrB,GAEA,EAAc,EAAI;EAClB,IAAI;GACF,EAAY,MAAM;EACpB,QAAQ;GAKN,AAFA,EAAe,UAAU,MACzB,EAAc,EAAK,GACnB,EAAe,EAAK;GACpB;EACF;EAIA,AAFA,EAAe,UAAU,GACzB,EAAS,IAAI,GACb,EAAW,EAAE;CACf,GAAG,CAAC,CAAQ,CAAC,GAEP,IAAO,QAAkB;EAO7B,IAAM,IAAc,EAAe;EAMnC,AALA,EAAe,UAAU,MACzB,EAAW,WAAW,GACtB,GAAa,KAAK,GAClB,EAAc,EAAK,GACnB,EAAe,EAAK,GACpB,EAAW,EAAE;CACf,GAAG,CAAC,CAAC,GAUC,IAAc,EAAO,CAAQ;CAenC,OAdA,QAAgB;EACV,EAAY,YAAY,MAC5B,EAAY,UAAU,GACtB,EAAK,GACL,EAAS,IAAI;CACf,GAAG,CAAC,GAAU,CAAI,CAAC,GASZ;EAAE;EAAa;EAAa;EAAY;EAAS;EAAO;EAAU;EAAO;EAAM,QAPvE,QAAkB;GAC/B,AAAI,IAAa,EAAK,IACjB,EAAM;EACb,GAAG;GAAC;GAAa;GAAO;EAAI,CAI0D;EAAQ,YAF3E,QAAkB,EAAS,IAAI,GAAG,CAAC,CAEwC;CAAW;AAC3G"}
1
+ {"version":3,"file":"useVoiceInput.js","names":[],"sources":["../../src/hooks/useVoiceInput.ts"],"sourcesContent":["/**\n * Speech-to-text for the assistant composer (Workstream 2 of the AI Assistant\n * V2 multimodal effort).\n *\n * Input-only, browser-native (Web Speech API). It degrades gracefully:\n * `isSupported` is false on engines without SpeechRecognition (notably Firefox),\n * and the composer hides the mic entirely in that case rather than showing a\n * dead control.\n *\n * ⚠️ This does NOT mean the audio stays on the device. Chrome's\n * `webkitSpeechRecognition` is a NETWORK service — the audio is streamed to the\n * browser vendor for recognition, and the supported language list is theirs, not\n * ours. We neither receive nor store it, which is all an earlier version of this\n * comment (\"no audio ever leaves the device through us\") actually claimed; read\n * literally it implied something stronger and untrue. Whether recording farmers'\n * speech this way needs disclosure or consent is a product/legal call, not a\n * code one.\n *\n * Output (reading replies aloud) is a separate concern and lives in\n * `AssistantSpeechProvider`; an earlier version of this note said the assistant\n * does not speak, which stopped being true when BOFF-6290 shipped.\n *\n * Differences from the fe-libs `assistantWidget/useVoiceInput` this is modelled\n * on, all of which the composer needs:\n * - **interim results are exposed**, so the user sees words appear while\n * speaking instead of staring at a silent button until a phrase finalises;\n * - **errors are surfaced** (`error`) so a denied mic permission can be\n * explained rather than looking like a no-op;\n * - **the recogniser language follows the app locale** (a Tamil or Hindi\n * farmer dictating into an `en-US` recogniser gets garbage);\n * - **`stop()` resolves the final transcript** through `onFinalize`, so the\n * composer can commit exactly once when the user stops.\n */\n\nimport { useCallback, useEffect, useRef, useState } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport type { Locale } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\n\ninterface SpeechRecognitionEventLike extends Event {\n results: SpeechRecognitionResultList;\n resultIndex: number;\n}\n\ninterface SpeechRecognitionErrorEventLike extends Event {\n error: string;\n message: string;\n}\n\ninterface SpeechRecognitionInstance extends EventTarget {\n continuous: boolean;\n interimResults: boolean;\n lang: string;\n start(): void;\n stop(): void;\n abort(): void;\n onresult: ((event: SpeechRecognitionEventLike) => void) | null;\n onerror: ((event: SpeechRecognitionErrorEventLike) => void) | null;\n onend: (() => void) | null;\n /**\n * Fires when the service has actually begun listening — the only honest\n * \"capture has started\" signal. Absent from this declaration until now, which\n * is part of why capture was inferred from `start()` returning instead.\n */\n onstart: (() => void) | null;\n}\n\ntype SpeechRecognitionConstructor = new () => SpeechRecognitionInstance;\n\n/**\n * BCP-47 tag for the recogniser, per app locale. Regional choices follow where\n * HealthyBowl actually operates (India for ta/hi) rather than a generic tag,\n * because the recogniser's acoustic model is region-specific.\n */\nconst RECOGNITION_LANG: Record<Locale, string> = {\n en: 'en-US',\n es: 'es-ES',\n fr: 'fr-FR',\n de: 'de-DE',\n ja: 'ja-JP',\n zh: 'zh-CN',\n ta: 'ta-IN',\n hi: 'hi-IN',\n ar: 'ar-SA',\n};\n\nfunction getSpeechRecognitionConstructor(): SpeechRecognitionConstructor | null {\n if (typeof window === 'undefined') return null;\n const win = window as unknown as Record<string, unknown>;\n return (\n (win.SpeechRecognition as SpeechRecognitionConstructor | undefined) ??\n (win.webkitSpeechRecognition as SpeechRecognitionConstructor | undefined) ??\n null\n );\n}\n\nexport type VoiceInputError =\n 'not-allowed' | 'no-speech' | 'audio-capture' | 'network' | 'language-not-supported' | 'unknown';\n\n/**\n * Map the spec's `SpeechRecognitionErrorEvent.error` codes onto the cases the UI\n * actually distinguishes. Anything else is 'unknown' (generic copy).\n *\n * `language-not-supported` is called out separately because it is the single\n * most likely failure for the users this feature exists for: the recogniser's\n * language list belongs to the browser vendor, not to us, so a Tamil or Hindi\n * speaker can hit it on a browser that simply does not offer their language.\n * Folding it into 'unknown' produced \"Dictation stopped unexpectedly\", which\n * tells them nothing and reads like a bug in HealthyBowl.\n */\nfunction toVoiceInputError(code: string): VoiceInputError {\n switch (code) {\n case 'not-allowed':\n case 'service-not-allowed':\n return 'not-allowed';\n case 'no-speech':\n return 'no-speech';\n case 'audio-capture':\n return 'audio-capture';\n case 'network':\n return 'network';\n case 'language-not-supported':\n return 'language-not-supported';\n default:\n return 'unknown';\n }\n}\n\nexport interface UseVoiceInputOptions {\n /**\n * Called with each newly finalised phrase. The composer appends it to the\n * draft; keeping the committed text in the caller (rather than accumulating\n * here) means the user can freely edit while dictation continues.\n */\n onFinalize: (text: string) => void;\n /**\n * BCP-47 tag to listen for. Omit to follow the app locale, which is what this\n * hook did unconditionally before (BOFF-7108).\n *\n * The two are genuinely independent: a farmer whose interface is English may\n * well speak Tamil, and deriving the recogniser language from the UI meant the\n * only way to dictate Tamil was to translate the entire app.\n */\n language?: string;\n}\n\nexport interface UseVoiceInputResult {\n isSupported: boolean;\n isListening: boolean;\n /** Requested, not yet capturing. Distinguishes starting up from listening. */\n isStarting: boolean;\n /**\n * Starting OR listening — \"the microphone is busy\".\n *\n * ★ Most callers mean THIS and were testing `isListening`, which was the same\n * thing only while capture was assumed the instant start() returned. Exposing\n * it once stops four call sites disagreeing about what counts as active.\n */\n isActive: boolean;\n /** Words recognised but not yet finalised — render as a live hint. */\n interim: string;\n error: VoiceInputError | null;\n /**\n * BCP-47 tag the recogniser was asked for. Exposed so error copy can name the\n * language that failed (\"Tamil dictation is not supported…\") rather than\n * leaving the user to guess which language the browser rejected.\n */\n language: string;\n start: () => void;\n stop: () => void;\n /** Start if idle, stop if listening — what the mic button binds to. */\n toggle: () => void;\n clearError: () => void;\n}\n\nexport function useVoiceInput({ onFinalize, language: requested }: UseVoiceInputOptions): UseVoiceInputResult {\n const { locale } = useI18n();\n const [isListening, setIsListening] = useState(false);\n /**\n * Requested but not yet capturing — the permission prompt / start-up window.\n *\n * ★ Needed BECAUSE `isListening` now waits for `recognition.onstart`. That is\n * the honest signal, but it lengthened the window in which a caller has been\n * asked to listen and can say nothing about it — the composer showed its\n * idle hint after the user had already tapped the microphone.\n */\n const [isStarting, setIsStarting] = useState(false);\n const [interim, setInterim] = useState('');\n const [error, setError] = useState<VoiceInputError | null>(null);\n const recognitionRef = useRef<SpeechRecognitionInstance | null>(null);\n // Incremented on every stop. Handlers capture the session they were created\n // under and ignore events that arrive after it ends.\n const sessionRef = useRef(0);\n\n // Keep the newest callback reachable from the recogniser's long-lived event\n // handlers without re-creating the recogniser on every parent render.\n const onFinalizeRef = useRef(onFinalize);\n useEffect(() => {\n onFinalizeRef.current = onFinalize;\n }, [onFinalize]);\n\n const isSupported = getSpeechRecognitionConstructor() !== null;\n const language = requested ?? RECOGNITION_LANG[locale] ?? 'en-US';\n\n // Abort (not stop) on unmount: the panel is closing, so a trailing final\n // result would be committed into a draft nobody can see.\n useEffect(() => {\n return () => {\n recognitionRef.current?.abort();\n recognitionRef.current = null;\n };\n }, []);\n\n const start = useCallback(() => {\n const Ctor = getSpeechRecognitionConstructor();\n if (!Ctor || recognitionRef.current) return;\n\n const recognition = new Ctor();\n recognition.continuous = true;\n recognition.interimResults = true;\n recognition.lang = language;\n\n const session = sessionRef.current;\n\n recognition.onresult = (event) => {\n if (session !== sessionRef.current) return;\n let finalText = '';\n let interimText = '';\n for (let index = event.resultIndex; index < event.results.length; index += 1) {\n const result = event.results[index];\n const alternative = result[0]?.transcript ?? '';\n if (result.isFinal) {\n finalText += alternative;\n } else {\n interimText += alternative;\n }\n }\n if (finalText.trim()) onFinalizeRef.current(finalText.trim());\n setInterim(interimText.trim());\n };\n\n recognition.onerror = (event) => {\n if (session !== sessionRef.current) return;\n const mapped = toVoiceInputError(event.error);\n // 'no-speech' fires routinely during a natural pause and the recogniser\n // keeps running — surfacing it would flash a scary message mid-sentence.\n if (mapped !== 'no-speech') setError(mapped);\n };\n\n recognition.onend = () => {\n if (session !== sessionRef.current) return;\n recognitionRef.current = null;\n setIsStarting(false);\n setIsListening(false);\n setInterim('');\n };\n\n /**\n * ★ The TRUE capture signal.\n *\n * This was set optimistically on the line after `start()` returned — which\n * is synchronous, and says only that the request was accepted, not that the\n * microphone is open. Everything downstream then believed capture had begun\n * while the permission prompt was still up: the stage showed \"Listening…\"\n * over a microphone that could not yet hear, so a user who started talking\n * immediately lost the first word or two; the `connecting` stage lasted a\n * single commit; and the 5s \"we aren't hearing your microphone\" notice\n * could never fire, because `capturing` was already true.\n */\n recognition.onstart = () => {\n if (session !== sessionRef.current) return;\n setIsStarting(false);\n setIsListening(true);\n };\n\n setIsStarting(true);\n try {\n recognition.start();\n } catch {\n // start() throws if a recogniser is somehow already running — treat the\n // session as not started rather than leaving the button stuck \"live\".\n recognitionRef.current = null;\n setIsStarting(false);\n setIsListening(false);\n return;\n }\n\n recognitionRef.current = recognition;\n setError(null);\n setInterim('');\n }, [language]);\n\n const stop = useCallback(() => {\n // Detach BEFORE stopping. `onend` is what used to clear this ref, but it\n // arrives asynchronously — so a user who tapped stop and immediately tapped\n // the mic again hit `start()`'s `if (recognitionRef.current) return` guard\n // and got a silent no-op. Bumping the session also makes any trailing final\n // phrase the engine flushes on stop land on a dead session, instead of\n // reappearing in a draft the composer has already sent and cleared.\n const recognition = recognitionRef.current;\n recognitionRef.current = null;\n sessionRef.current += 1;\n recognition?.stop();\n setIsStarting(false);\n setIsListening(false);\n setInterim('');\n }, []);\n\n // Changing language must END the session it no longer describes.\n //\n // A running recogniser keeps the `lang` it was constructed with, so after a\n // switch the in-flight session is still listening in the OLD language while\n // this hook already reports the new one. A late `language-not-supported` from\n // that session would then be rendered as though the browser had rejected the\n // language the user just picked. Clearing the error is not enough — the\n // session producing it has to go too.\n const languageRef = useRef(language);\n useEffect(() => {\n if (languageRef.current === language) return;\n languageRef.current = language;\n stop();\n setError(null);\n }, [language, stop]);\n\n const toggle = useCallback(() => {\n // ★ `isStarting` too, or the button is DEAD for the whole permission window.\n // `start()` bails on `if (recognitionRef.current) return`, and that ref is\n // assigned synchronously the moment start() is called — so once isListening\n // stopped being set optimistically, a press here took the `else start()`\n // branch and returned immediately. The user tapped the microphone, saw the\n // idle icon, tapped again to cancel, and nothing happened either time.\n if (isListening || isStarting) stop();\n else start();\n }, [isListening, isStarting, start, stop]);\n\n const clearError = useCallback(() => setError(null), []);\n\n return {\n isSupported,\n isListening,\n isStarting,\n isActive: isListening || isStarting,\n interim,\n error,\n language,\n start,\n stop,\n toggle,\n clearError,\n };\n}\n"],"mappings":";;;AAyEA,IAAM,IAA2C;CAC/C,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;AACN;AAEA,SAAS,IAAuE;CAC9E,IAAI,OAAO,SAAW,KAAa,OAAO;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ACA;EACA;EACA;EACA;EACA;CACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.902.7",
3
+ "version": "2026.902.8",
4
4
  "description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
5
5
  "type": "module",
6
6
  "files": [