@burdenoff/microfe-healthybowl 2026.901.8 → 2026.901.10

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.
@@ -15,24 +15,32 @@ var g = ({ session: g, turns: y = [], notice: b = null, spoken: x, onInterrupt:
15
15
  }, []), s(() => {
16
16
  let e = (e) => {
17
17
  if (e.key === "Escape") {
18
+ if (P) {
19
+ F(!1);
20
+ return;
21
+ }
18
22
  w();
19
23
  return;
20
24
  }
21
25
  if (e.key !== "Tab" || !M) return;
22
- let t = j.current?.querySelectorAll("button:not([disabled])");
26
+ let t = (P ? j.current?.querySelector("[data-testid=\"assistant-voice-transcript\"]") : j.current)?.querySelectorAll("button:not([disabled])");
23
27
  if (!t || t.length === 0) return;
24
28
  let n = t[0], r = t[t.length - 1];
25
29
  !n || !r || (e.shiftKey && document.activeElement === n ? (e.preventDefault(), r.focus()) : !e.shiftKey && document.activeElement === r && (e.preventDefault(), n.focus()));
26
30
  };
27
31
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
28
- }, [w, M]);
32
+ }, [
33
+ w,
34
+ M,
35
+ P
36
+ ]);
29
37
  let I = D === "thinking" ? E("healthybowl.assistant.voiceSession.thinking", "Thinking…") : D === "speaking" ? E("healthybowl.assistant.voiceSession.speaking", "Speaking — tap to stop") : O ? E("healthybowl.assistant.voiceSession.muted", "Microphone off") : E("healthybowl.assistant.voiceSession.listening", "Listening…"), L = k === null ? O && D !== "listening" ? `${I} · ${E("healthybowl.assistant.voiceSession.muted", "Microphone off")}` : I : v(k, E), R = t(g), z = i({
30
38
  snapshot: g,
31
39
  capturing: T
32
40
  });
33
41
  return /* @__PURE__ */ h("div", {
34
42
  ref: j,
35
- className: `flex flex-col items-center justify-between bg-bg-sunken ${M ? "fixed inset-0 z-[60] px-6 py-10" : "absolute inset-0 z-20 px-4 py-6"}`,
43
+ className: `flex flex-col items-center justify-between bg-bg-sunken ${M ? "fixed inset-0 z-[60] px-6 pb-10 pt-20" : "absolute inset-0 z-20 px-4 py-6"}`,
36
44
  role: "dialog",
37
45
  "aria-modal": M || void 0,
38
46
  "aria-label": E("healthybowl.assistant.voiceSession.title", "Voice conversation"),
@@ -1 +1 @@
1
- {"version":3,"file":"AssistantVoiceSession.js","names":[],"sources":["../../../../src/components/assistant/voice/AssistantVoiceSession.tsx"],"sourcesContent":["import { useEffect, useRef, useState, type FC } from 'react';\nimport { Maximize2, Minimize2, ScrollText, X } from 'lucide-react';\nimport { AssistantVoiceOrb } from './AssistantVoiceOrb';\nimport { VoiceStage } from './VoiceStage';\nimport { VoiceTranscriptDrawer } from './VoiceTranscriptDrawer';\nimport { voiceStageState, micIsInterrupt } from '../../../utils/voiceStageState';\nimport { useTr } from '../../../shared/hooks/useTr';\nimport { spokenSoFar, type VoiceSessionSnapshot } from '../../../utils/voiceSession';\nimport type { VoiceSessionError } from '../../../utils/voiceSession';\nimport type { VoiceSessionNotice } from '../../../hooks/useVoiceSession';\n\ninterface Props {\n session: VoiceSessionSnapshot;\n /** Recent exchanges, oldest first — the running conversation. */\n turns?: ReadonlyArray<{ id: string; role: 'user' | 'assistant'; text: string }>;\n /** Cut the assistant off mid-reply. */\n onInterrupt?: () => void;\n /** A recoverable problem to surface. Null when the microphone is healthy. */\n notice?: VoiceSessionNotice | null;\n /** The assistant's last reply, captioned while it is spoken. */\n spoken: string | null;\n onToggleMute: () => void;\n onEnd: () => void;\n /** Is the recogniser actually running? Distinguishes CONNECTING from LISTENING. */\n capturing?: boolean;\n}\n\n/**\n * Full-screen voice conversation (BOFF-7120).\n *\n * ★ **Voice only, by explicit product decision.** The reference (Gemini Live)\n * also offers camera and screen sharing; those are deliberately absent here.\n * Attaching images is a separate, existing capability of the assistant and\n * stays in the composer, and screen sharing could not work on the primary\n * device anyway — `getDisplayMedia` is unsupported by every iOS browser, so\n * that control would be dead on an iPhone.\n *\n * The controls are therefore the two that a voice conversation actually needs:\n * mute, and end. Anything else would be a button the user has to think about\n * while talking.\n *\n * This component is presentational: every transition is owned by\n * `voiceSessionReducer`, which is pure and tested. That split exists because\n * this file cannot be tested at all in this repo — vitest runs in `node` with\n * no DOM and no audio.\n */\nexport const AssistantVoiceSession: FC<Props> = ({\n session,\n turns = [],\n notice = null,\n spoken,\n onInterrupt,\n onToggleMute,\n onEnd,\n capturing = true,\n}) => {\n const tr = useTr();\n const { phase, muted, error } = session;\n const endRef = useRef<HTMLButtonElement>(null);\n const dialogRef = useRef<HTMLDivElement>(null);\n /**\n * Docked inside the assistant panel by default; full-screen only on request.\n *\n * A voice conversation is usually a glance-and-listen thing, so taking over\n * the whole screen for it is the wrong default — the user loses the page they\n * were asking about. Expanding is opt-in and per-session: reopening starts\n * docked again, which is the behaviour that matches \"default should be the\n * same size as the assistant\".\n */\n const [expanded, setExpanded] = useState(false);\n /** History is secondary: the stage shows now, this shows the session. */\n const [transcriptOpen, setTranscriptOpen] = useState(false);\n\n // A full-screen `aria-modal` overlay that cannot be dismissed from the\n // keyboard is a trap. Escape ends the session, and focus starts on End so a\n // keyboard or screen-reader user lands somewhere useful rather than behind\n // the overlay.\n // Focus lands on End ONCE, on open. Keeping this in the keydown effect below\n // meant every expand/collapse re-ran it and silently stole focus from the\n // button just pressed — a Space or Enter a beat later would then end the\n // session instead of toggling the size again.\n useEffect(() => {\n endRef.current?.focus();\n }, []);\n\n useEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n onEnd();\n return;\n }\n // Trapping focus is only correct when the overlay actually covers\n // everything. Docked, it sits inside the panel and the rest of the page\n // is legitimately reachable, so trapping there would be the bug rather\n // than the fix.\n if (event.key !== 'Tab' || !expanded) return;\n // `aria-modal` only TELLS assistive technology this is modal; it does not\n // make it so. Without this, Tab walks straight out of the overlay into the\n // page behind it, which is still fully interactive underneath — a\n // keyboard user ends up operating a screen they cannot see.\n const focusable = dialogRef.current?.querySelectorAll<HTMLElement>('button:not([disabled])');\n if (!focusable || focusable.length === 0) return;\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n if (!first || !last) return;\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n window.addEventListener('keydown', onKeyDown);\n return () => window.removeEventListener('keydown', onKeyDown);\n }, [onEnd, expanded]);\n\n // Muted is reported ALONGSIDE the phase, not instead of it: the assistant may\n // still be speaking with the microphone off, and saying only \"Microphone off\"\n // would misreport that.\n const phaseText =\n phase === 'thinking'\n ? tr('healthybowl.assistant.voiceSession.thinking', 'Thinking…')\n : phase === 'speaking'\n ? tr('healthybowl.assistant.voiceSession.speaking', 'Speaking — tap to stop')\n : muted\n ? tr('healthybowl.assistant.voiceSession.muted', 'Microphone off')\n : tr('healthybowl.assistant.voiceSession.listening', 'Listening…');\n\n const status =\n error !== null\n ? errorMessage(error, tr)\n : muted && phase !== 'listening'\n ? `${phaseText} · ${tr('healthybowl.assistant.voiceSession.muted', 'Microphone off')}`\n : phaseText;\n\n // While speaking, the caption shows the REPLY; otherwise what we have heard.\n // Showing the stale transcript under the assistant's own voice reads as a\n // mis-transcription of the assistant, which is worse than showing nothing.\n const heard = spokenSoFar(session);\n\n // ★ ONE state, derived. The reducer's phase cannot tell \"listening\" from\n // \"the microphone has not started yet\", and the old overlay rendered every\n // signal at once — status, warning, transcript, caption and orb together.\n const stage = voiceStageState({ snapshot: session, capturing });\n\n return (\n <div\n ref={dialogRef}\n className={`flex flex-col items-center justify-between bg-bg-sunken ${\n expanded ? 'fixed inset-0 z-[60] px-6 py-10' : 'absolute inset-0 z-20 px-4 py-6'\n }`}\n role=\"dialog\"\n // Only modal when it really is: docked, the page behind stays usable.\n // `undefined` rather than `false` — the ARIA default is already false, and\n // some older assistive technology treats an explicit \"false\" on a dialog\n // as still modal.\n aria-modal={expanded || undefined}\n aria-label={tr('healthybowl.assistant.voiceSession.title', 'Voice conversation')}\n data-testid=\"assistant-voice-session\"\n >\n {/* End sits top-right and expand bottom-left, out of the centre column.\n Absolute rather than part of the flow so the pill stays optically\n centred at both sizes — the overlay is already a positioning context\n (`fixed` when expanded, `absolute` when docked). */}\n <button\n ref={endRef}\n type=\"button\"\n onClick={onEnd}\n className={`absolute ${expanded ? 'right-6 top-6 size-14' : 'right-3 top-3 size-11'} flex items-center justify-center rounded-full border border-border-default bg-bg-elevated text-text-secondary hover:bg-bg-sunken transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong`}\n aria-label={tr('healthybowl.assistant.voiceSession.end', 'End the voice conversation')}\n data-testid=\"assistant-voice-end\"\n >\n <X className={expanded ? 'size-6' : 'size-5'} />\n </button>\n\n {/* ★ The notice is CHROME, not conversation. It used to sit above the\n transcript in the same column as the reply, which is why a microphone\n warning read as part of what the assistant said. The status line moved\n into the stage, where it labels the state it belongs to. */}\n <div className=\"flex min-h-[1.5rem] flex-col items-center px-14\">\n {notice && error === null ? (\n <p className=\"max-w-xs text-center text-xs text-status-warning\" data-testid=\"assistant-voice-notice\">\n {noticeMessage(notice, tr)}\n </p>\n ) : null}\n </div>\n\n <VoiceStage\n state={stage}\n userCaption={heard || null}\n assistantCaption={spoken}\n expanded={expanded}\n statusText={status}\n errorText={error !== null ? errorMessage(error, tr) : null}\n control={\n <AssistantVoiceOrb\n session={session}\n compact={!expanded}\n onPress={micIsInterrupt(stage) ? onInterrupt : onToggleMute}\n label={\n micIsInterrupt(stage)\n ? tr('healthybowl.assistant.voiceSession.interrupt', 'Stop the assistant and speak')\n : muted\n ? tr('healthybowl.assistant.voiceSession.unmute', 'Turn the microphone on')\n : tr('healthybowl.assistant.voiceSession.mute', 'Turn the microphone off')\n }\n />\n }\n />\n\n {transcriptOpen ? <VoiceTranscriptDrawer turns={turns} onClose={() => setTranscriptOpen(false)} /> : null}\n\n {/* History is SECONDARY — behind a button, never on the stage. */}\n <button\n type=\"button\"\n onClick={() => setTranscriptOpen((open) => !open)}\n className={`absolute ${expanded ? 'bottom-6 right-6 size-14' : 'bottom-3 right-3 size-11'} flex items-center justify-center rounded-full bg-bg-elevated text-text-secondary transition-colors hover:bg-bg-raised hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong`}\n aria-pressed={transcriptOpen}\n aria-label={tr('healthybowl.assistant.voiceSession.transcript', 'Voice transcript')}\n data-testid=\"assistant-voice-transcript-toggle\"\n >\n <ScrollText className={expanded ? 'size-6' : 'size-5'} />\n </button>\n\n <button\n type=\"button\"\n onClick={() => setExpanded((current) => !current)}\n className={`absolute ${expanded ? 'bottom-6 left-6 size-14' : 'bottom-3 left-3 size-11'} flex items-center justify-center rounded-full bg-bg-elevated text-text-secondary transition-colors hover:bg-bg-raised hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong`}\n aria-pressed={expanded}\n aria-label={\n expanded\n ? tr('healthybowl.assistant.voiceSession.collapse', 'Fit the conversation back into the panel')\n : tr('healthybowl.assistant.voiceSession.expand', 'Expand the conversation to full screen')\n }\n data-testid=\"assistant-voice-expand\"\n >\n {expanded ? <Minimize2 className=\"size-5\" /> : <Maximize2 className=\"size-5\" />}\n </button>\n </div>\n );\n};\n\n/**\n * Recoverable problems, shown WITHOUT ending the session.\n *\n * The bug these exist for: the overlay said \"Listening…\" while the recogniser\n * was dead, and nothing anywhere said otherwise.\n */\nfunction noticeMessage(notice: VoiceSessionNotice, tr: ReturnType<typeof useTr>): string {\n switch (notice) {\n case 'network':\n return tr(\n 'healthybowl.assistant.voiceSession.noticeNetwork',\n 'Speech recognition lost its connection. Check your network — it will retry.'\n );\n case 'not-capturing':\n return tr(\n 'healthybowl.assistant.voiceSession.noticeNotCapturing',\n 'The microphone did not start. Check that this site is allowed to use it, then try again.'\n );\n case 'recognition-failed':\n return tr(\n 'healthybowl.assistant.voiceSession.noticeRecognitionFailed',\n 'Speech recognition stopped unexpectedly. It will retry — if it keeps happening, reload the page.'\n );\n case 'nothing-heard':\n return tr(\n 'healthybowl.assistant.voiceSession.noticeNothingHeard',\n 'Nothing heard yet. Check your microphone is not muted or in use by another app.'\n );\n default: {\n const unhandled: never = notice;\n return unhandled;\n }\n }\n}\n\n/**\n * Every failure is explained rather than silently closing the session.\n *\n * A session that just vanishes is the dead-button bug in another shape — the\n * exact defect BOFF-7106 had to fix on the per-message speak control.\n */\nfunction errorMessage(error: VoiceSessionError, tr: ReturnType<typeof useTr>): string {\n switch (error) {\n case 'mic-denied':\n return tr(\n 'healthybowl.assistant.voiceSession.micDenied',\n 'Microphone access is blocked. Allow it in your browser settings to talk.'\n );\n case 'no-speech-support':\n return tr(\n 'healthybowl.assistant.voiceSession.noSpeechSupport',\n 'This browser cannot listen. Try a different browser, or type instead.'\n );\n case 'no-voice-support':\n return tr(\n 'healthybowl.assistant.voiceSession.noVoiceSupport',\n 'This device has no voice that can speak this language.'\n );\n default: {\n // Exhaustive: adding a variant without copy becomes a build error rather\n // than a silently empty status line.\n const unhandled: never = error;\n return unhandled;\n }\n }\n}\n"],"mappings":";;;;;;;;;;AA8CA,IAAa,KAAoC,EAC/C,YACA,WAAQ,CAAC,GACT,YAAS,MACT,WACA,gBACA,iBACA,UACA,eAAY,SACR;CACJ,IAAM,IAAK,EAAM,GACX,EAAE,UAAO,UAAO,aAAU,GAC1B,IAAS,EAA0B,IAAI,GACvC,IAAY,EAAuB,IAAI,GAUvC,CAAC,GAAU,KAAe,EAAS,EAAK,GAExC,CAAC,GAAgB,KAAqB,EAAS,EAAK;CAc1D,AAJA,QAAgB;EACd,EAAO,SAAS,MAAM;CACxB,GAAG,CAAC,CAAC,GAEL,QAAgB;EACd,IAAM,KAAa,MAAyB;GAC1C,IAAI,EAAM,QAAQ,UAAU;IAC1B,EAAM;IACN;GACF;GAKA,IAAI,EAAM,QAAQ,SAAS,CAAC,GAAU;GAKtC,IAAM,IAAY,EAAU,SAAS,iBAA8B,wBAAwB;GAC3F,IAAI,CAAC,KAAa,EAAU,WAAW,GAAG;GAC1C,IAAM,IAAQ,EAAU,IAClB,IAAO,EAAU,EAAU,SAAS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oBACH,OAAO,EACL,qDACA,wDACF;EACF,SAIE,OAAO;CAEX;AACF"}
1
+ {"version":3,"file":"AssistantVoiceSession.js","names":[],"sources":["../../../../src/components/assistant/voice/AssistantVoiceSession.tsx"],"sourcesContent":["import { useEffect, useRef, useState, type FC } from 'react';\nimport { Maximize2, Minimize2, ScrollText, X } from 'lucide-react';\nimport { AssistantVoiceOrb } from './AssistantVoiceOrb';\nimport { VoiceStage } from './VoiceStage';\nimport { VoiceTranscriptDrawer } from './VoiceTranscriptDrawer';\nimport { voiceStageState, micIsInterrupt } from '../../../utils/voiceStageState';\nimport { useTr } from '../../../shared/hooks/useTr';\nimport { spokenSoFar, type VoiceSessionSnapshot } from '../../../utils/voiceSession';\nimport type { VoiceSessionError } from '../../../utils/voiceSession';\nimport type { VoiceSessionNotice } from '../../../hooks/useVoiceSession';\n\ninterface Props {\n session: VoiceSessionSnapshot;\n /** Recent exchanges, oldest first — the running conversation. */\n turns?: ReadonlyArray<{ id: string; role: 'user' | 'assistant'; text: string }>;\n /** Cut the assistant off mid-reply. */\n onInterrupt?: () => void;\n /** A recoverable problem to surface. Null when the microphone is healthy. */\n notice?: VoiceSessionNotice | null;\n /** The assistant's last reply, captioned while it is spoken. */\n spoken: string | null;\n onToggleMute: () => void;\n onEnd: () => void;\n /** Is the recogniser actually running? Distinguishes CONNECTING from LISTENING. */\n capturing?: boolean;\n}\n\n/**\n * Full-screen voice conversation (BOFF-7120).\n *\n * ★ **Voice only, by explicit product decision.** The reference (Gemini Live)\n * also offers camera and screen sharing; those are deliberately absent here.\n * Attaching images is a separate, existing capability of the assistant and\n * stays in the composer, and screen sharing could not work on the primary\n * device anyway — `getDisplayMedia` is unsupported by every iOS browser, so\n * that control would be dead on an iPhone.\n *\n * The controls are therefore the two that a voice conversation actually needs:\n * mute, and end. Anything else would be a button the user has to think about\n * while talking.\n *\n * This component is presentational: every transition is owned by\n * `voiceSessionReducer`, which is pure and tested. That split exists because\n * this file cannot be tested at all in this repo — vitest runs in `node` with\n * no DOM and no audio.\n */\nexport const AssistantVoiceSession: FC<Props> = ({\n session,\n turns = [],\n notice = null,\n spoken,\n onInterrupt,\n onToggleMute,\n onEnd,\n capturing = true,\n}) => {\n const tr = useTr();\n const { phase, muted, error } = session;\n const endRef = useRef<HTMLButtonElement>(null);\n const dialogRef = useRef<HTMLDivElement>(null);\n /**\n * Docked inside the assistant panel by default; full-screen only on request.\n *\n * A voice conversation is usually a glance-and-listen thing, so taking over\n * the whole screen for it is the wrong default — the user loses the page they\n * were asking about. Expanding is opt-in and per-session: reopening starts\n * docked again, which is the behaviour that matches \"default should be the\n * same size as the assistant\".\n */\n const [expanded, setExpanded] = useState(false);\n /** History is secondary: the stage shows now, this shows the session. */\n const [transcriptOpen, setTranscriptOpen] = useState(false);\n\n // A full-screen `aria-modal` overlay that cannot be dismissed from the\n // keyboard is a trap. Escape ends the session, and focus starts on End so a\n // keyboard or screen-reader user lands somewhere useful rather than behind\n // the overlay.\n // Focus lands on End ONCE, on open. Keeping this in the keydown effect below\n // meant every expand/collapse re-ran it and silently stole focus from the\n // button just pressed — a Space or Enter a beat later would then end the\n // session instead of toggling the size again.\n useEffect(() => {\n endRef.current?.focus();\n }, []);\n\n useEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n // ★ Escape closes the drawer first. Ending the whole conversation\n // because someone dismissed a panel would be a surprising amount of\n // destruction for one keypress.\n if (transcriptOpen) {\n setTranscriptOpen(false);\n return;\n }\n onEnd();\n return;\n }\n // Trapping focus is only correct when the overlay actually covers\n // everything. Docked, it sits inside the panel and the rest of the page\n // is legitimately reachable, so trapping there would be the bug rather\n // than the fix.\n if (event.key !== 'Tab' || !expanded) return;\n // `aria-modal` only TELLS assistive technology this is modal; it does not\n // make it so. Without this, Tab walks straight out of the overlay into the\n // page behind it, which is still fully interactive underneath — a\n // keyboard user ends up operating a screen they cannot see.\n // ★ Scope the trap to what is actually on screen. With the transcript\n // drawer open, a flat `button` query also collects the controls it covers,\n // so Tab walked into buttons the user could not see — the same class of\n // bug the trap exists to prevent.\n const scope = transcriptOpen\n ? dialogRef.current?.querySelector<HTMLElement>('[data-testid=\"assistant-voice-transcript\"]')\n : dialogRef.current;\n const focusable = scope?.querySelectorAll<HTMLElement>('button:not([disabled])');\n if (!focusable || focusable.length === 0) return;\n const first = focusable[0];\n const last = focusable[focusable.length - 1];\n if (!first || !last) return;\n if (event.shiftKey && document.activeElement === first) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n };\n window.addEventListener('keydown', onKeyDown);\n return () => window.removeEventListener('keydown', onKeyDown);\n }, [onEnd, expanded, transcriptOpen]);\n\n // Muted is reported ALONGSIDE the phase, not instead of it: the assistant may\n // still be speaking with the microphone off, and saying only \"Microphone off\"\n // would misreport that.\n const phaseText =\n phase === 'thinking'\n ? tr('healthybowl.assistant.voiceSession.thinking', 'Thinking…')\n : phase === 'speaking'\n ? tr('healthybowl.assistant.voiceSession.speaking', 'Speaking — tap to stop')\n : muted\n ? tr('healthybowl.assistant.voiceSession.muted', 'Microphone off')\n : tr('healthybowl.assistant.voiceSession.listening', 'Listening…');\n\n const status =\n error !== null\n ? errorMessage(error, tr)\n : muted && phase !== 'listening'\n ? `${phaseText} · ${tr('healthybowl.assistant.voiceSession.muted', 'Microphone off')}`\n : phaseText;\n\n // While speaking, the caption shows the REPLY; otherwise what we have heard.\n // Showing the stale transcript under the assistant's own voice reads as a\n // mis-transcription of the assistant, which is worse than showing nothing.\n const heard = spokenSoFar(session);\n\n // ★ ONE state, derived. The reducer's phase cannot tell \"listening\" from\n // \"the microphone has not started yet\", and the old overlay rendered every\n // signal at once — status, warning, transcript, caption and orb together.\n const stage = voiceStageState({ snapshot: session, capturing });\n\n return (\n <div\n ref={dialogRef}\n className={`flex flex-col items-center justify-between bg-bg-sunken ${\n expanded ? 'fixed inset-0 z-[60] px-6 pb-10 pt-20' : 'absolute inset-0 z-20 px-4 py-6'\n }`}\n role=\"dialog\"\n // Only modal when it really is: docked, the page behind stays usable.\n // `undefined` rather than `false` — the ARIA default is already false, and\n // some older assistive technology treats an explicit \"false\" on a dialog\n // as still modal.\n aria-modal={expanded || undefined}\n aria-label={tr('healthybowl.assistant.voiceSession.title', 'Voice conversation')}\n data-testid=\"assistant-voice-session\"\n >\n {/* End sits top-right and expand bottom-left, out of the centre column.\n Absolute rather than part of the flow so the pill stays optically\n centred at both sizes — the overlay is already a positioning context\n (`fixed` when expanded, `absolute` when docked). */}\n <button\n ref={endRef}\n type=\"button\"\n onClick={onEnd}\n className={`absolute ${expanded ? 'right-6 top-6 size-14' : 'right-3 top-3 size-11'} flex items-center justify-center rounded-full border border-border-default bg-bg-elevated text-text-secondary hover:bg-bg-sunken transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong`}\n aria-label={tr('healthybowl.assistant.voiceSession.end', 'End the voice conversation')}\n data-testid=\"assistant-voice-end\"\n >\n <X className={expanded ? 'size-6' : 'size-5'} />\n </button>\n\n {/* ★ The notice is CHROME, not conversation. It used to sit above the\n transcript in the same column as the reply, which is why a microphone\n warning read as part of what the assistant said. The status line moved\n into the stage, where it labels the state it belongs to. */}\n <div className=\"flex min-h-[1.5rem] flex-col items-center px-14\">\n {notice && error === null ? (\n <p className=\"max-w-xs text-center text-xs text-status-warning\" data-testid=\"assistant-voice-notice\">\n {noticeMessage(notice, tr)}\n </p>\n ) : null}\n </div>\n\n <VoiceStage\n state={stage}\n userCaption={heard || null}\n assistantCaption={spoken}\n expanded={expanded}\n statusText={status}\n errorText={error !== null ? errorMessage(error, tr) : null}\n control={\n <AssistantVoiceOrb\n session={session}\n compact={!expanded}\n onPress={micIsInterrupt(stage) ? onInterrupt : onToggleMute}\n label={\n micIsInterrupt(stage)\n ? tr('healthybowl.assistant.voiceSession.interrupt', 'Stop the assistant and speak')\n : muted\n ? tr('healthybowl.assistant.voiceSession.unmute', 'Turn the microphone on')\n : tr('healthybowl.assistant.voiceSession.mute', 'Turn the microphone off')\n }\n />\n }\n />\n\n {transcriptOpen ? <VoiceTranscriptDrawer turns={turns} onClose={() => setTranscriptOpen(false)} /> : null}\n\n {/* History is SECONDARY — behind a button, never on the stage. */}\n <button\n type=\"button\"\n onClick={() => setTranscriptOpen((open) => !open)}\n className={`absolute ${expanded ? 'bottom-6 right-6 size-14' : 'bottom-3 right-3 size-11'} flex items-center justify-center rounded-full bg-bg-elevated text-text-secondary transition-colors hover:bg-bg-raised hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong`}\n aria-pressed={transcriptOpen}\n aria-label={tr('healthybowl.assistant.voiceSession.transcript', 'Voice transcript')}\n data-testid=\"assistant-voice-transcript-toggle\"\n >\n <ScrollText className={expanded ? 'size-6' : 'size-5'} />\n </button>\n\n <button\n type=\"button\"\n onClick={() => setExpanded((current) => !current)}\n className={`absolute ${expanded ? 'bottom-6 left-6 size-14' : 'bottom-3 left-3 size-11'} flex items-center justify-center rounded-full bg-bg-elevated text-text-secondary transition-colors hover:bg-bg-raised hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong`}\n aria-pressed={expanded}\n aria-label={\n expanded\n ? tr('healthybowl.assistant.voiceSession.collapse', 'Fit the conversation back into the panel')\n : tr('healthybowl.assistant.voiceSession.expand', 'Expand the conversation to full screen')\n }\n data-testid=\"assistant-voice-expand\"\n >\n {expanded ? <Minimize2 className=\"size-5\" /> : <Maximize2 className=\"size-5\" />}\n </button>\n </div>\n );\n};\n\n/**\n * Recoverable problems, shown WITHOUT ending the session.\n *\n * The bug these exist for: the overlay said \"Listening…\" while the recogniser\n * was dead, and nothing anywhere said otherwise.\n */\nfunction noticeMessage(notice: VoiceSessionNotice, tr: ReturnType<typeof useTr>): string {\n switch (notice) {\n case 'network':\n return tr(\n 'healthybowl.assistant.voiceSession.noticeNetwork',\n 'Speech recognition lost its connection. Check your network — it will retry.'\n );\n case 'not-capturing':\n return tr(\n 'healthybowl.assistant.voiceSession.noticeNotCapturing',\n 'The microphone did not start. Check that this site is allowed to use it, then try again.'\n );\n case 'recognition-failed':\n return tr(\n 'healthybowl.assistant.voiceSession.noticeRecognitionFailed',\n 'Speech recognition stopped unexpectedly. It will retry — if it keeps happening, reload the page.'\n );\n case 'nothing-heard':\n return tr(\n 'healthybowl.assistant.voiceSession.noticeNothingHeard',\n 'Nothing heard yet. Check your microphone is not muted or in use by another app.'\n );\n default: {\n const unhandled: never = notice;\n return unhandled;\n }\n }\n}\n\n/**\n * Every failure is explained rather than silently closing the session.\n *\n * A session that just vanishes is the dead-button bug in another shape — the\n * exact defect BOFF-7106 had to fix on the per-message speak control.\n */\nfunction errorMessage(error: VoiceSessionError, tr: ReturnType<typeof useTr>): string {\n switch (error) {\n case 'mic-denied':\n return tr(\n 'healthybowl.assistant.voiceSession.micDenied',\n 'Microphone access is blocked. Allow it in your browser settings to talk.'\n );\n case 'no-speech-support':\n return tr(\n 'healthybowl.assistant.voiceSession.noSpeechSupport',\n 'This browser cannot listen. Try a different browser, or type instead.'\n );\n case 'no-voice-support':\n return tr(\n 'healthybowl.assistant.voiceSession.noVoiceSupport',\n 'This device has no voice that can speak this language.'\n );\n default: {\n // Exhaustive: adding a variant without copy becomes a build error rather\n // than a silently empty status line.\n const unhandled: never = error;\n return unhandled;\n }\n }\n}\n"],"mappings":";;;;;;;;;;AA8CA,IAAa,KAAoC,EAC/C,YACA,WAAQ,CAAC,GACT,YAAS,MACT,WACA,gBACA,iBACA,UACA,eAAY,SACR;CACJ,IAAM,IAAK,EAAM,GACX,EAAE,UAAO,UAAO,aAAU,GAC1B,IAAS,EAA0B,IAAI,GACvC,IAAY,EAAuB,IAAI,GAUvC,CAAC,GAAU,KAAe,EAAS,EAAK,GAExC,CAAC,GAAgB,KAAqB,EAAS,EAAK;CAc1D,AAJA,QAAgB;EACd,EAAO,SAAS,MAAM;CACxB,GAAG,CAAC,CAAC,GAEL,QAAgB;EACd,IAAM,KAAa,MAAyB;GAC1C,IAAI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EACE,KAAK,WACH,OAAO,EACL,oDACA,6EACF;EACF,KAAK,iBACH,OAAO,EACL,yDACA,0FACF;EACF,KAAK,sBACH,OAAO,EACL,8DACA,kGACF;EACF,KAAK,iBACH,OAAO,EACL,yDACA,iFACF;EACF,SAEE,OAAO;CAEX;AACF;AAQA,SAAS,EAAa,GAA0B,GAAsC;CACpF,QAAQ,GAAR;EACE,KAAK,cACH,OAAO,EACL,gDACA,0EACF;EACF,KAAK,qBACH,OAAO,EACL,sDACA,uEACF;EACF,KAAK,oBACH,OAAO,EACL,qDACA,wDACF;EACF,SAIE,OAAO;CAEX;AACF"}
@@ -6,12 +6,20 @@ import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime";
6
6
  var s = ({ state: s, userCaption: c, assistantCaption: l, expanded: u, statusText: d, control: f, errorText: p = null }) => {
7
7
  let m = n(s) ? l : r(s) ? c : null;
8
8
  return /* @__PURE__ */ o("div", {
9
- className: `flex min-h-0 w-full flex-1 flex-col items-center justify-center ${u ? "gap-8 px-8" : "gap-4 px-14"}`,
9
+ className: [
10
+ "flex min-h-0 w-full flex-1 flex-col items-center",
11
+ u ? "px-8" : "px-14",
12
+ u ? "justify-start pt-[16vh]" : "justify-center"
13
+ ].join(" "),
10
14
  "data-testid": "assistant-voice-stage",
11
15
  "data-state": s,
12
16
  children: [
13
17
  /* @__PURE__ */ a("p", {
14
- className: `text-center text-text-muted ${u ? "text-base" : "text-sm"}`,
18
+ className: [
19
+ "text-center text-text-muted",
20
+ u ? "text-base" : "text-sm",
21
+ u ? "mb-3" : "mb-2"
22
+ ].join(" "),
15
23
  "data-testid": "assistant-voice-status",
16
24
  children: d
17
25
  }),
@@ -20,17 +28,23 @@ var s = ({ state: s, userCaption: c, assistantCaption: l, expanded: u, statusTex
20
28
  role: "alert",
21
29
  "data-testid": "assistant-voice-stage-error",
22
30
  children: p
23
- }) : /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a(t, {
24
- active: s === "listening" || s === "speaking",
25
- tone: s === "speaking" ? "speaking" : "listening",
26
- expanded: u
27
- }), m ? /* @__PURE__ */ a(e, {
28
- text: m,
29
- role: n(s) ? "assistant" : "user",
30
- expanded: u,
31
- testId: "assistant-voice-caption"
31
+ }) : /* @__PURE__ */ o(i, { children: [/* @__PURE__ */ a("div", {
32
+ className: u ? "mb-10" : "mb-5",
33
+ children: /* @__PURE__ */ a(t, {
34
+ active: s === "listening" || s === "speaking",
35
+ tone: s === "speaking" ? "speaking" : "listening",
36
+ expanded: u
37
+ })
38
+ }), m ? /* @__PURE__ */ a("div", {
39
+ className: u ? "mb-12 w-full" : "mb-6 w-full",
40
+ children: /* @__PURE__ */ a(e, {
41
+ text: m,
42
+ role: n(s) ? "assistant" : "user",
43
+ expanded: u,
44
+ testId: "assistant-voice-caption"
45
+ })
32
46
  }) : /* @__PURE__ */ a("div", {
33
- className: u ? "h-24" : "h-12",
47
+ className: u ? "mb-12 h-[4.5rem]" : "mb-6 h-12",
34
48
  "aria-hidden": "true"
35
49
  })] }),
36
50
  f
@@ -1 +1 @@
1
- {"version":3,"file":"VoiceStage.js","names":[],"sources":["../../../../src/components/assistant/voice/VoiceStage.tsx"],"sourcesContent":["import type { FC, ReactNode } from 'react';\nimport { VoiceCaption } from './VoiceCaption';\nimport { VoiceWaveform } from './VoiceWaveform';\nimport { showsAssistantCaption, showsUserCaption, type VoiceStageState } from '../../../utils/voiceStageState';\n\n/**\n * The middle of the voice panel: exactly ONE state, rendered as itself.\n *\n * What this replaces is the whole problem the operator screenshotted. The old\n * overlay showed, simultaneously: \"Listening…\", a microphone warning, the last\n * six messages of the chat conversation as bubbles (markdown syntax and all),\n * the assistant's answer AGAIN as a caption, and the orb. Five things competing,\n * none of them readable.\n *\n * ★ A stage shows one thing because the session IS one thing at a time. The\n * state is derived in `voiceStageState`, which is pure and tested; this file is\n * presentational and cannot be tested in this repo (vitest runs in `node`, no\n * DOM), so it deliberately contains no logic worth testing.\n *\n * The microphone warning is NOT rendered here. Mixing a system message into the\n * conversation area is what made it read as part of the reply; it belongs to\n * the chrome around the stage.\n */\n\ninterface Props {\n state: VoiceStageState;\n /** What the user is saying (live) or last said. */\n userCaption: string | null;\n /** What the assistant is saying. */\n assistantCaption: string | null;\n expanded: boolean;\n /** Status words — already localised by the caller. */\n statusText: string;\n /** The microphone / interrupt control. */\n control: ReactNode;\n /** Shown in the mic-error state instead of a caption. */\n errorText?: string | null;\n}\n\nexport const VoiceStage: FC<Props> = ({\n state,\n userCaption,\n assistantCaption,\n expanded,\n statusText,\n control,\n errorText = null,\n}) => {\n const caption = showsAssistantCaption(state) ? assistantCaption : showsUserCaption(state) ? userCaption : null;\n\n return (\n <div\n className={`flex min-h-0 w-full flex-1 flex-col items-center justify-center ${expanded ? 'gap-8 px-8' : 'gap-4 px-14'}`}\n data-testid=\"assistant-voice-stage\"\n data-state={state}\n >\n {/* Status first and small: it is the label for the state, not the content. */}\n <p\n className={`text-center text-text-muted ${expanded ? 'text-base' : 'text-sm'}`}\n data-testid=\"assistant-voice-status\"\n >\n {statusText}\n </p>\n\n {state === 'mic-error' ? (\n // A failure gets the stage to itself — no caption, no waveform. It is\n // not part of the conversation and must not look like it.\n <p\n className={`max-w-md text-center text-status-warning ${expanded ? 'text-lg' : 'text-sm'}`}\n role=\"alert\"\n data-testid=\"assistant-voice-stage-error\"\n >\n {errorText}\n </p>\n ) : (\n <>\n <VoiceWaveform\n active={state === 'listening' || state === 'speaking'}\n tone={state === 'speaking' ? 'speaking' : 'listening'}\n expanded={expanded}\n />\n\n {caption ? (\n <VoiceCaption\n text={caption}\n role={showsAssistantCaption(state) ? 'assistant' : 'user'}\n expanded={expanded}\n testId=\"assistant-voice-caption\"\n />\n ) : (\n // Reserve the caption's space so the control does not jump when the\n // first words arrive.\n <div className={expanded ? 'h-24' : 'h-12'} aria-hidden=\"true\" />\n )}\n </>\n )}\n\n {control}\n </div>\n );\n};\n"],"mappings":";;;;;AAuCA,IAAa,KAAyB,EACpC,UACA,gBACA,qBACA,aACA,eACA,YACA,eAAY,WACR;CACJ,IAAM,IAAU,EAAsB,CAAK,IAAI,IAAmB,EAAiB,CAAK,IAAI,IAAc;CAE1G,OACE,kBAAC,OAAD;EACE,WAAW,mEAAmE,IAAW,eAAe;EACxG,eAAY;EACZ,cAAY;YAHd;GAME,kBAAC,KAAD;IACE,WAAW,+BAA+B,IAAW,cAAc;IACnE,eAAY;cAEX;GACA,CAAA;GAEF,MAAU,cAGT,kBAAC,KAAD;IACE,WAAW,4CAA4C,IAAW,YAAY;IAC9E,MAAK;IACL,eAAY;cAEX;GACA,CAAA,IAEH,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,GAAD;IACE,QAAQ,MAAU,eAAe,MAAU;IAC3C,MAAM,MAAU,aAAa,aAAa;IAChC;GACX,CAAA,GAEA,IACC,kBAAC,GAAD;IACE,MAAM;IACN,MAAM,EAAsB,CAAK,IAAI,cAAc;IACzC;IACV,QAAO;GACR,CAAA,IAID,kBAAC,OAAD;IAAK,WAAW,IAAW,SAAS;IAAQ,eAAY;GAAQ,CAAA,CAElE,EAAA,CAAA;GAGH;EACE;;AAET"}
1
+ {"version":3,"file":"VoiceStage.js","names":[],"sources":["../../../../src/components/assistant/voice/VoiceStage.tsx"],"sourcesContent":["import type { FC, ReactNode } from 'react';\nimport { VoiceCaption } from './VoiceCaption';\nimport { VoiceWaveform } from './VoiceWaveform';\nimport { showsAssistantCaption, showsUserCaption, type VoiceStageState } from '../../../utils/voiceStageState';\n\n/**\n * The middle of the voice panel: exactly ONE state, rendered as itself.\n *\n * What this replaces is the whole problem the operator screenshotted. The old\n * overlay showed, simultaneously: \"Listening…\", a microphone warning, the last\n * six messages of the chat conversation as bubbles (markdown syntax and all),\n * the assistant's answer AGAIN as a caption, and the orb. Five things competing,\n * none of them readable.\n *\n * ★ A stage shows one thing because the session IS one thing at a time. The\n * state is derived in `voiceStageState`, which is pure and tested; this file is\n * presentational and cannot be tested in this repo (vitest runs in `node`, no\n * DOM), so it deliberately contains no logic worth testing.\n *\n * The microphone warning is NOT rendered here. Mixing a system message into the\n * conversation area is what made it read as part of the reply; it belongs to\n * the chrome around the stage.\n */\n\ninterface Props {\n state: VoiceStageState;\n /** What the user is saying (live) or last said. */\n userCaption: string | null;\n /** What the assistant is saying. */\n assistantCaption: string | null;\n expanded: boolean;\n /** Status words — already localised by the caller. */\n statusText: string;\n /** The microphone / interrupt control. */\n control: ReactNode;\n /** Shown in the mic-error state instead of a caption. */\n errorText?: string | null;\n}\n\nexport const VoiceStage: FC<Props> = ({\n state,\n userCaption,\n assistantCaption,\n expanded,\n statusText,\n control,\n errorText = null,\n}) => {\n const caption = showsAssistantCaption(state) ? assistantCaption : showsUserCaption(state) ? userCaption : null;\n\n return (\n <div\n className={[\n 'flex min-h-0 w-full flex-1 flex-col items-center',\n expanded ? 'px-8' : 'px-14',\n // ★ Expanded, the group is anchored just above the optical centre\n // rather than centred in the whole box. Measured at 1440x900 the\n // content was 314px of a 756px stage with 221px of dead air above AND\n // below — technically centred, visually adrift. Docked the box is\n // small enough that centring is right.\n expanded ? 'justify-start pt-[16vh]' : 'justify-center',\n ].join(' ')}\n data-testid=\"assistant-voice-stage\"\n data-state={state}\n >\n {/* Status first and small: it is the label for the state, not the content. */}\n <p\n className={[\n 'text-center text-text-muted',\n expanded ? 'text-base' : 'text-sm',\n // The status LABELS the waveform, so it sits close to it. A uniform\n // gap made status, waveform, caption and control read as four\n // items of equal weight, with no hierarchy at all.\n expanded ? 'mb-3' : 'mb-2',\n ].join(' ')}\n data-testid=\"assistant-voice-status\"\n >\n {statusText}\n </p>\n\n {state === 'mic-error' ? (\n // A failure gets the stage to itself — no caption, no waveform. It is\n // not part of the conversation and must not look like it.\n <p\n className={`max-w-md text-center text-status-warning ${expanded ? 'text-lg' : 'text-sm'}`}\n role=\"alert\"\n data-testid=\"assistant-voice-stage-error\"\n >\n {errorText}\n </p>\n ) : (\n <>\n <div className={expanded ? 'mb-10' : 'mb-5'}>\n <VoiceWaveform\n active={state === 'listening' || state === 'speaking'}\n tone={state === 'speaking' ? 'speaking' : 'listening'}\n expanded={expanded}\n />\n </div>\n\n {caption ? (\n <div className={expanded ? 'mb-12 w-full' : 'mb-6 w-full'}>\n <VoiceCaption\n text={caption}\n role={showsAssistantCaption(state) ? 'assistant' : 'user'}\n expanded={expanded}\n testId=\"assistant-voice-caption\"\n />\n </div>\n ) : (\n // Reserve the caption's space so the control does not jump when the\n // first words arrive. Two lines' worth at each size, matching what\n // a typical utterance actually occupies.\n <div className={expanded ? 'mb-12 h-[4.5rem]' : 'mb-6 h-12'} aria-hidden=\"true\" />\n )}\n </>\n )}\n\n {control}\n </div>\n );\n};\n"],"mappings":";;;;;AAuCA,IAAa,KAAyB,EACpC,UACA,gBACA,qBACA,aACA,eACA,YACA,eAAY,WACR;CACJ,IAAM,IAAU,EAAsB,CAAK,IAAI,IAAmB,EAAiB,CAAK,IAAI,IAAc;CAE1G,OACE,kBAAC,OAAD;EACE,WAAW;GACT;GACA,IAAW,SAAS;GAMpB,IAAW,4BAA4B;EACzC,EAAE,KAAK,GAAG;EACV,eAAY;EACZ,cAAY;YAZd;GAeE,kBAAC,KAAD;IACE,WAAW;KACT;KACA,IAAW,cAAc;KAIzB,IAAW,SAAS;IACtB,EAAE,KAAK,GAAG;IACV,eAAY;cAEX;GACA,CAAA;GAEF,MAAU,cAGT,kBAAC,KAAD;IACE,WAAW,4CAA4C,IAAW,YAAY;IAC9E,MAAK;IACL,eAAY;cAEX;GACA,CAAA,IAEH,kBAAA,GAAA,EAAA,UAAA,CACE,kBAAC,OAAD;IAAK,WAAW,IAAW,UAAU;cACnC,kBAAC,GAAD;KACE,QAAQ,MAAU,eAAe,MAAU;KAC3C,MAAM,MAAU,aAAa,aAAa;KAChC;IACX,CAAA;GACE,CAAA,GAEJ,IACC,kBAAC,OAAD;IAAK,WAAW,IAAW,iBAAiB;cAC1C,kBAAC,GAAD;KACE,MAAM;KACN,MAAM,EAAsB,CAAK,IAAI,cAAc;KACzC;KACV,QAAO;IACR,CAAA;GACE,CAAA,IAKL,kBAAC,OAAD;IAAK,WAAW,IAAW,qBAAqB;IAAa,eAAY;GAAQ,CAAA,CAEnF,EAAA,CAAA;GAGH;EACE;;AAET"}
@@ -5,7 +5,7 @@ import { jsx as n, jsxs as r } from "react/jsx-runtime";
5
5
  var i = ({ turns: i, onClose: a }) => {
6
6
  let o = e();
7
7
  return /* @__PURE__ */ r("div", {
8
- className: "absolute inset-0 z-10 flex flex-col bg-bg-sunken/95 backdrop-blur-sm",
8
+ className: "absolute inset-0 z-30 flex flex-col bg-bg-sunken/95 backdrop-blur-sm",
9
9
  role: "dialog",
10
10
  "aria-label": o("healthybowl.assistant.voiceSession.transcript", "Voice transcript"),
11
11
  "data-testid": "assistant-voice-transcript",
@@ -1 +1 @@
1
- {"version":3,"file":"VoiceTranscriptDrawer.js","names":[],"sources":["../../../../src/components/assistant/voice/VoiceTranscriptDrawer.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { X } from 'lucide-react';\nimport { useTr } from '../../../shared/hooks/useTr';\n\n/**\n * This session's spoken turns, on demand.\n *\n * The stage shows only what is happening NOW, which is right for a live\n * conversation and would otherwise mean the history is simply gone. This is\n * where it goes: secondary, behind a button, and explicitly a VOICE transcript\n * rather than the chat thread.\n *\n * ★ Session-scoped and ephemeral by design. It renders the turns it is handed —\n * which are already filtered to this voice session — so it can never resurrect\n * the typed conversation the old overlay used to paint.\n */\n\ninterface Props {\n turns: ReadonlyArray<{ id: string; role: 'user' | 'assistant'; text: string }>;\n onClose: () => void;\n}\n\nexport const VoiceTranscriptDrawer: FC<Props> = ({ turns, onClose }) => {\n const tr = useTr();\n return (\n <div\n className=\"absolute inset-0 z-10 flex flex-col bg-bg-sunken/95 backdrop-blur-sm\"\n role=\"dialog\"\n aria-label={tr('healthybowl.assistant.voiceSession.transcript', 'Voice transcript')}\n data-testid=\"assistant-voice-transcript\"\n >\n <div className=\"flex items-center justify-between border-b border-border-subtle px-4 py-3\">\n <h2 className=\"text-sm font-semibold text-text-primary\">\n {tr('healthybowl.assistant.voiceSession.transcript', 'Voice transcript')}\n </h2>\n <button\n type=\"button\"\n onClick={onClose}\n className=\"flex size-8 items-center justify-center rounded-full text-text-secondary transition-colors hover:bg-bg-raised hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong\"\n aria-label={tr('healthybowl.assistant.voiceSession.transcriptClose', 'Close the transcript')}\n data-testid=\"assistant-voice-transcript-close\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n\n <div className=\"flex-1 space-y-4 overflow-y-auto px-4 py-4\">\n {turns.length === 0 ? (\n <p className=\"text-sm text-text-muted\">\n {tr('healthybowl.assistant.voiceSession.transcriptEmpty', 'Nothing spoken yet in this session.')}\n </p>\n ) : (\n turns.map((turn) => (\n <div key={turn.id} className=\"space-y-1\">\n <p className=\"text-xs font-medium uppercase tracking-wide text-text-muted\">\n {turn.role === 'user'\n ? tr('healthybowl.assistant.voiceSession.transcriptYou', 'You')\n : tr('healthybowl.assistant.voiceSession.transcriptAssistant', 'HealthyBowl AI')}\n </p>\n <p className=\"whitespace-pre-wrap text-sm leading-relaxed text-text-primary\">{turn.text}</p>\n </div>\n ))\n )}\n </div>\n </div>\n );\n};\n"],"mappings":";;;;AAsBA,IAAa,KAAoC,EAAE,UAAO,iBAAc;CACtE,IAAM,IAAK,EAAM;CACjB,OACE,kBAAC,OAAD;EACE,WAAU;EACV,MAAK;EACL,cAAY,EAAG,iDAAiD,kBAAkB;EAClF,eAAY;YAJd,CAME,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,MAAD;IAAI,WAAU;cACX,EAAG,iDAAiD,kBAAkB;GACrE,CAAA,GACJ,kBAAC,UAAD;IACE,MAAK;IACL,SAAS;IACT,WAAU;IACV,cAAY,EAAG,sDAAsD,sBAAsB;IAC3F,eAAY;cAEZ,kBAAC,GAAD,EAAG,WAAU,SAAU,CAAA;GACjB,CAAA,CACL;MAEL,kBAAC,OAAD;GAAK,WAAU;aACZ,EAAM,WAAW,IAChB,kBAAC,KAAD;IAAG,WAAU;cACV,EAAG,sDAAsD,qCAAqC;GAC9F,CAAA,IAEH,EAAM,KAAK,MACT,kBAAC,OAAD;IAAmB,WAAU;cAA7B,CACE,kBAAC,KAAD;KAAG,WAAU;eACV,EAAK,SAAS,SACX,EAAG,oDAAoD,KAAK,IAC5D,EAAG,0DAA0D,gBAAgB;IAChF,CAAA,GACH,kBAAC,KAAD;KAAG,WAAU;eAAiE,EAAK;IAAQ,CAAA,CACxF;MAPK,EAAK,EAOV,CACN;EAEA,CAAA,CACF;;AAET"}
1
+ {"version":3,"file":"VoiceTranscriptDrawer.js","names":[],"sources":["../../../../src/components/assistant/voice/VoiceTranscriptDrawer.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { X } from 'lucide-react';\nimport { useTr } from '../../../shared/hooks/useTr';\n\n/**\n * This session's spoken turns, on demand.\n *\n * The stage shows only what is happening NOW, which is right for a live\n * conversation and would otherwise mean the history is simply gone. This is\n * where it goes: secondary, behind a button, and explicitly a VOICE transcript\n * rather than the chat thread.\n *\n * ★ `z-30` is not decoration: the session container is `z-20` docked and\n * `z-[60]` expanded, and a child at `z-10` painted BEHIND its own parent — the\n * drawer opened and was invisible. Stacking contexts are per-parent, so this\n * only has to beat its siblings, not the overlay itself.\n *\n * ★ Session-scoped and ephemeral by design. It renders the turns it is handed —\n * which are already filtered to this voice session — so it can never resurrect\n * the typed conversation the old overlay used to paint.\n */\n\ninterface Props {\n turns: ReadonlyArray<{ id: string; role: 'user' | 'assistant'; text: string }>;\n onClose: () => void;\n}\n\nexport const VoiceTranscriptDrawer: FC<Props> = ({ turns, onClose }) => {\n const tr = useTr();\n return (\n <div\n className=\"absolute inset-0 z-30 flex flex-col bg-bg-sunken/95 backdrop-blur-sm\"\n role=\"dialog\"\n aria-label={tr('healthybowl.assistant.voiceSession.transcript', 'Voice transcript')}\n data-testid=\"assistant-voice-transcript\"\n >\n <div className=\"flex items-center justify-between border-b border-border-subtle px-4 py-3\">\n <h2 className=\"text-sm font-semibold text-text-primary\">\n {tr('healthybowl.assistant.voiceSession.transcript', 'Voice transcript')}\n </h2>\n <button\n type=\"button\"\n onClick={onClose}\n className=\"flex size-8 items-center justify-center rounded-full text-text-secondary transition-colors hover:bg-bg-raised hover:text-text-primary focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong\"\n aria-label={tr('healthybowl.assistant.voiceSession.transcriptClose', 'Close the transcript')}\n data-testid=\"assistant-voice-transcript-close\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n\n <div className=\"flex-1 space-y-4 overflow-y-auto px-4 py-4\">\n {turns.length === 0 ? (\n <p className=\"text-sm text-text-muted\">\n {tr('healthybowl.assistant.voiceSession.transcriptEmpty', 'Nothing spoken yet in this session.')}\n </p>\n ) : (\n turns.map((turn) => (\n <div key={turn.id} className=\"space-y-1\">\n <p className=\"text-xs font-medium uppercase tracking-wide text-text-muted\">\n {turn.role === 'user'\n ? tr('healthybowl.assistant.voiceSession.transcriptYou', 'You')\n : tr('healthybowl.assistant.voiceSession.transcriptAssistant', 'HealthyBowl AI')}\n </p>\n <p className=\"whitespace-pre-wrap text-sm leading-relaxed text-text-primary\">{turn.text}</p>\n </div>\n ))\n )}\n </div>\n </div>\n );\n};\n"],"mappings":";;;;AA2BA,IAAa,KAAoC,EAAE,UAAO,iBAAc;CACtE,IAAM,IAAK,EAAM;CACjB,OACE,kBAAC,OAAD;EACE,WAAU;EACV,MAAK;EACL,cAAY,EAAG,iDAAiD,kBAAkB;EAClF,eAAY;YAJd,CAME,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,MAAD;IAAI,WAAU;cACX,EAAG,iDAAiD,kBAAkB;GACrE,CAAA,GACJ,kBAAC,UAAD;IACE,MAAK;IACL,SAAS;IACT,WAAU;IACV,cAAY,EAAG,sDAAsD,sBAAsB;IAC3F,eAAY;cAEZ,kBAAC,GAAD,EAAG,WAAU,SAAU,CAAA;GACjB,CAAA,CACL;MAEL,kBAAC,OAAD;GAAK,WAAU;aACZ,EAAM,WAAW,IAChB,kBAAC,KAAD;IAAG,WAAU;cACV,EAAG,sDAAsD,qCAAqC;GAC9F,CAAA,IAEH,EAAM,KAAK,MACT,kBAAC,OAAD;IAAmB,WAAU;cAA7B,CACE,kBAAC,KAAD;KAAG,WAAU;eACV,EAAK,SAAS,SACX,EAAG,oDAAoD,KAAK,IAC5D,EAAG,0DAA0D,gBAAgB;IAChF,CAAA,GACH,kBAAC,KAAD;KAAG,WAAU;eAAiE,EAAK;IAAQ,CAAA,CACxF;MAPK,EAAK,EAOV,CACN;EAEA,CAAA,CACF;;AAET"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.901.8",
3
+ "version": "2026.901.10",
4
4
  "description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
5
5
  "type": "module",
6
6
  "files": [