@burdenoff/microfe-healthybowl 2026.901.10 → 2026.901.11

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.
@@ -3,106 +3,116 @@ import { spokenSoFar as t } from "../../../utils/voiceSession.js";
3
3
  import { AssistantVoiceOrb as n } from "./AssistantVoiceOrb.js";
4
4
  import { micIsInterrupt as r, voiceStageState as i } from "../../../utils/voiceStageState.js";
5
5
  import { VoiceStage as a } from "./VoiceStage.js";
6
- import { VoiceTranscriptDrawer as o } from "./VoiceTranscriptDrawer.js";
7
- import { useEffect as s, useRef as c, useState as l } from "react";
8
- import { Maximize2 as u, Minimize2 as d, ScrollText as f, X as p } from "lucide-react";
9
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
6
+ import { VoiceMiniController as o } from "./VoiceMiniController.js";
7
+ import { VoiceTranscriptDrawer as s } from "./VoiceTranscriptDrawer.js";
8
+ import { useEffect as c, useRef as l, useState as u } from "react";
9
+ import { Maximize2 as d, Minimize2 as f, ScrollText as p, X as m } from "lucide-react";
10
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
10
11
  //#region src/components/assistant/voice/AssistantVoiceSession.tsx
11
- var g = ({ session: g, turns: y = [], notice: b = null, spoken: x, onInterrupt: S, onToggleMute: C, onEnd: w, capturing: T = !0 }) => {
12
- let E = e(), { phase: D, muted: O, error: k } = g, A = c(null), j = c(null), [M, N] = l(!1), [P, F] = l(!1);
13
- s(() => {
14
- A.current?.focus();
15
- }, []), s(() => {
12
+ var _ = ({ session: _, turns: b = [], notice: x = null, spoken: S, onInterrupt: C, onToggleMute: w, onEnd: T, capturing: E = !0 }) => {
13
+ let D = e(), { phase: O, muted: k, error: A } = _, j = l(null), M = l(null), [N, P] = u(!1), [F, I] = u(!1);
14
+ c(() => {
15
+ j.current?.focus();
16
+ }, []), c(() => {
16
17
  let e = (e) => {
17
18
  if (e.key === "Escape") {
18
- if (P) {
19
- F(!1);
19
+ if (F) {
20
+ I(!1);
20
21
  return;
21
22
  }
22
- w();
23
+ T();
23
24
  return;
24
25
  }
25
- if (e.key !== "Tab" || !M) return;
26
- let t = (P ? j.current?.querySelector("[data-testid=\"assistant-voice-transcript\"]") : j.current)?.querySelectorAll("button:not([disabled])");
26
+ if (e.key !== "Tab" || !N) return;
27
+ let t = (F ? M.current?.querySelector("[data-testid=\"assistant-voice-transcript\"]") : M.current)?.querySelectorAll("button:not([disabled])");
27
28
  if (!t || t.length === 0) return;
28
29
  let n = t[0], r = t[t.length - 1];
29
30
  !n || !r || (e.shiftKey && document.activeElement === n ? (e.preventDefault(), r.focus()) : !e.shiftKey && document.activeElement === r && (e.preventDefault(), n.focus()));
30
31
  };
31
32
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
32
33
  }, [
33
- w,
34
- M,
35
- P
34
+ T,
35
+ N,
36
+ F
36
37
  ]);
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({
38
- snapshot: g,
39
- capturing: T
38
+ let L = O === "thinking" ? D("healthybowl.assistant.voiceSession.thinking", "Thinking…") : O === "speaking" ? D("healthybowl.assistant.voiceSession.speaking", "Speaking — tap to stop") : k ? D("healthybowl.assistant.voiceSession.muted", "Microphone off") : D("healthybowl.assistant.voiceSession.listening", "Listening…"), R = A === null ? k && O !== "listening" ? `${L} · ${D("healthybowl.assistant.voiceSession.muted", "Microphone off")}` : L : y(A, D), z = t(_), B = i({
39
+ snapshot: _,
40
+ capturing: E
40
41
  });
41
- return /* @__PURE__ */ h("div", {
42
- ref: j,
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"}`,
42
+ return /* @__PURE__ */ g("div", {
43
+ ref: M,
44
+ className: `flex flex-col items-center justify-between bg-bg-sunken ${N ? "fixed inset-0 z-[60] px-6 pb-10 pt-20" : "absolute inset-x-0 bottom-0 z-20 h-[11.25rem] border-t border-border-subtle px-3 py-3 shadow-lg"}`,
44
45
  role: "dialog",
45
- "aria-modal": M || void 0,
46
- "aria-label": E("healthybowl.assistant.voiceSession.title", "Voice conversation"),
46
+ "aria-modal": N || void 0,
47
+ "aria-label": D("healthybowl.assistant.voiceSession.title", "Voice conversation"),
47
48
  "data-testid": "assistant-voice-session",
48
49
  children: [
49
- /* @__PURE__ */ m("button", {
50
- ref: A,
50
+ /* @__PURE__ */ h("button", {
51
+ ref: j,
51
52
  type: "button",
52
- onClick: w,
53
- className: `absolute ${M ? "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`,
54
- "aria-label": E("healthybowl.assistant.voiceSession.end", "End the voice conversation"),
53
+ onClick: T,
54
+ className: `absolute ${N ? "right-6 top-6 size-14" : "right-2 top-2 size-8"} 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`,
55
+ "aria-label": D("healthybowl.assistant.voiceSession.end", "End the voice conversation"),
55
56
  "data-testid": "assistant-voice-end",
56
- children: /* @__PURE__ */ m(p, { className: M ? "size-6" : "size-5" })
57
+ children: /* @__PURE__ */ h(m, { className: N ? "size-6" : "size-4" })
57
58
  }),
58
- /* @__PURE__ */ m("div", {
59
- className: "flex min-h-[1.5rem] flex-col items-center px-14",
60
- children: b && k === null ? /* @__PURE__ */ m("p", {
59
+ /* @__PURE__ */ h("div", {
60
+ className: `flex flex-col items-center ${N ? "min-h-[1.5rem] px-14" : "px-3"}`,
61
+ children: x && A === null ? /* @__PURE__ */ h("p", {
61
62
  className: "max-w-xs text-center text-xs text-status-warning",
62
63
  "data-testid": "assistant-voice-notice",
63
- children: _(b, E)
64
+ children: v(x, D)
64
65
  }) : null
65
66
  }),
66
- /* @__PURE__ */ m(a, {
67
- state: z,
68
- userCaption: R || null,
69
- assistantCaption: x,
70
- expanded: M,
71
- statusText: L,
72
- errorText: k === null ? null : v(k, E),
73
- control: /* @__PURE__ */ m(n, {
74
- session: g,
75
- compact: !M,
76
- onPress: r(z) ? S : C,
77
- label: r(z) ? E("healthybowl.assistant.voiceSession.interrupt", "Stop the assistant and speak") : O ? E("healthybowl.assistant.voiceSession.unmute", "Turn the microphone on") : E("healthybowl.assistant.voiceSession.mute", "Turn the microphone off")
78
- })
79
- }),
80
- P ? /* @__PURE__ */ m(o, {
81
- turns: y,
82
- onClose: () => F(!1)
67
+ (() => {
68
+ let e = /* @__PURE__ */ h(n, {
69
+ session: _,
70
+ compact: !N,
71
+ onPress: r(B) ? C : w,
72
+ label: r(B) ? D("healthybowl.assistant.voiceSession.interrupt", "Stop the assistant and speak") : k ? D("healthybowl.assistant.voiceSession.unmute", "Turn the microphone on") : D("healthybowl.assistant.voiceSession.mute", "Turn the microphone off")
73
+ }), t = r(B) ? S : z || null, i = A === null ? null : y(A, D);
74
+ return N ? /* @__PURE__ */ h(a, {
75
+ state: B,
76
+ userCaption: z || null,
77
+ assistantCaption: S,
78
+ expanded: !0,
79
+ statusText: R,
80
+ errorText: i,
81
+ control: e
82
+ }) : /* @__PURE__ */ h(o, {
83
+ state: B,
84
+ caption: t,
85
+ statusText: R,
86
+ errorText: i,
87
+ control: e
88
+ });
89
+ })(),
90
+ F ? /* @__PURE__ */ h(s, {
91
+ turns: b,
92
+ onClose: () => I(!1)
83
93
  }) : null,
84
- /* @__PURE__ */ m("button", {
94
+ /* @__PURE__ */ h("button", {
85
95
  type: "button",
86
- onClick: () => F((e) => !e),
87
- className: `absolute ${M ? "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`,
88
- "aria-pressed": P,
89
- "aria-label": E("healthybowl.assistant.voiceSession.transcript", "Voice transcript"),
96
+ onClick: () => I((e) => !e),
97
+ className: `absolute ${N ? "bottom-6 right-6 size-14" : "right-11 top-2 size-8"} 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`,
98
+ "aria-pressed": F,
99
+ "aria-label": D("healthybowl.assistant.voiceSession.transcript", "Voice transcript"),
90
100
  "data-testid": "assistant-voice-transcript-toggle",
91
- children: /* @__PURE__ */ m(f, { className: M ? "size-6" : "size-5" })
101
+ children: /* @__PURE__ */ h(p, { className: N ? "size-6" : "size-4" })
92
102
  }),
93
- /* @__PURE__ */ m("button", {
103
+ /* @__PURE__ */ h("button", {
94
104
  type: "button",
95
- onClick: () => N((e) => !e),
96
- className: `absolute ${M ? "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`,
97
- "aria-pressed": M,
98
- "aria-label": M ? E("healthybowl.assistant.voiceSession.collapse", "Fit the conversation back into the panel") : E("healthybowl.assistant.voiceSession.expand", "Expand the conversation to full screen"),
105
+ onClick: () => P((e) => !e),
106
+ className: `absolute ${N ? "bottom-6 left-6 size-14" : "left-2 top-2 size-8"} 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`,
107
+ "aria-pressed": N,
108
+ "aria-label": N ? D("healthybowl.assistant.voiceSession.collapse", "Fit the conversation back into the panel") : D("healthybowl.assistant.voiceSession.expand", "Expand the conversation to full screen"),
99
109
  "data-testid": "assistant-voice-expand",
100
- children: m(M ? d : u, { className: "size-5" })
110
+ children: N ? /* @__PURE__ */ h(f, { className: "size-5" }) : /* @__PURE__ */ h(d, { className: "size-4" })
101
111
  })
102
112
  ]
103
113
  });
104
114
  };
105
- function _(e, t) {
115
+ function v(e, t) {
106
116
  switch (e) {
107
117
  case "network": return t("healthybowl.assistant.voiceSession.noticeNetwork", "Speech recognition lost its connection. Check your network — it will retry.");
108
118
  case "not-capturing": return t("healthybowl.assistant.voiceSession.noticeNotCapturing", "The microphone did not start. Check that this site is allowed to use it, then try again.");
@@ -111,7 +121,7 @@ function _(e, t) {
111
121
  default: return e;
112
122
  }
113
123
  }
114
- function v(e, t) {
124
+ function y(e, t) {
115
125
  switch (e) {
116
126
  case "mic-denied": return t("healthybowl.assistant.voiceSession.micDenied", "Microphone access is blocked. Allow it in your browser settings to talk.");
117
127
  case "no-speech-support": return t("healthybowl.assistant.voiceSession.noSpeechSupport", "This browser cannot listen. Try a different browser, or type instead.");
@@ -120,6 +130,6 @@ function v(e, t) {
120
130
  }
121
131
  }
122
132
  //#endregion
123
- export { g as AssistantVoiceSession };
133
+ export { _ as AssistantVoiceSession };
124
134
 
125
135
  //# sourceMappingURL=AssistantVoiceSession.js.map
@@ -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 // ★ 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,EAAM,QAAQ,UAAU;IAI1B,IAAI,GAAgB;KAClB,EAAkB,EAAK;KACvB;IACF;IACA,EAAM;IACN;GACF;GAKA,IAAI,EAAM,QAAQ,SAAS,CAAC,GAAU;GAYtC,IAAM,KAHQ,IACV,EAAU,SAAS,cAA2B,8CAA4C,IAC1F,EAAU,UACW,iBAA8B,wBAAwB;GAC/E,IAAI,CAAC,KAAa,EAAU,WAAW,GAAG;GAC1C,IAAM,IAAQ,EAAU,IAClB,IAAO,EAAU,EAAU,SAAS;GACtC,CAAC,KAAS,CAAC,MACX,EAAM,YAAY,SAAS,kBAAkB,KAC/C,EAAM,eAAe,GACrB,EAAK,MAAM,KACF,CAAC,EAAM,YAAY,SAAS,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c;KAC/C,OACE,EAAe,CAAK,IAChB,EAAG,gDAAgD,8BAA8B,IACjF,IACE,EAAG,6CAA6C,wBAAwB,IACxE,EAAG,2CAA2C,yBAAyB;IAEhF,CAAA;GAEJ,CAAA;GAEA,IAAiB,kBAAC,GAAD;IAA8B;IAAO,eAAe,EAAkB,EAAK;GAAI,CAAA,IAAI;GAGrG,kBAAC,UAAD;IACE,MAAK;IACL,eAAe,GAAmB,MAAS,CAAC,CAAI;IAChD,WAAW,YAAY,IAAW,6BAA6B,2BAA2B;IAC1F,gBAAc;IACd,cAAY,EAAG,iDAAiD,kBAAkB;IAClF,eAAY;cAEZ,kBAAC,GAAD,EAAY,WAAW,IAAW,WAAW,SAAW,CAAA;GAClD,CAAA;GAER,kBAAC,UAAD;IACE,MAAK;IACL,eAAe,GAAa,MAAY,CAAC,CAAO;IAChD,WAAW,YAAY,IAAW,4BAA4B,0BAA0B;IACxF,gBAAc;IACd,cACE,IACI,EAAG,+CAA+C,0CAA0C,IAC5F,EAAG,6CAA6C,wCAAwC;IAE9F,eAAY;cAEA,EAAX,IAAY,IAAmC,GAApC,EAAW,WAAU,SAAU,CAAmC;GACxE,CAAA;EACL;;AAET;AAQA,SAAS,EAAc,GAA4B,GAAsC;CACvF,QAAQ,GAAR;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"}
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 { VoiceMiniController } from './VoiceMiniController';\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\n ? 'fixed inset-0 z-[60] px-6 pb-10 pt-20'\n : // ★ Docked is a CONTROLLER, not the stage shrunk: a strip at the\n // bottom of the panel, ~180px, leaving the conversation behind it\n // visible. It used to be `inset-0`, i.e. the whole panel.\n 'absolute inset-x-0 bottom-0 z-20 h-[11.25rem] border-t border-border-subtle px-3 py-3 shadow-lg'\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-2 top-2 size-8'} 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-4'} />\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 flex-col items-center ${expanded ? 'min-h-[1.5rem] px-14' : 'px-3'}`}>\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 {/* ★ Two genuinely different surfaces, not one scaled. Expanded is a\n reading stage; docked is a controller. */}\n {(() => {\n const orb = (\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 const caption = micIsInterrupt(stage) ? spoken : heard || null;\n const errorText = error !== null ? errorMessage(error, tr) : null;\n return expanded ? (\n <VoiceStage\n state={stage}\n userCaption={heard || null}\n assistantCaption={spoken}\n expanded\n statusText={status}\n errorText={errorText}\n control={orb}\n />\n ) : (\n <VoiceMiniController\n state={stage}\n caption={caption}\n statusText={status}\n errorText={errorText}\n control={orb}\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' : 'right-11 top-2 size-8'} 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-4'} />\n </button>\n\n <button\n type=\"button\"\n onClick={() => setExpanded((current) => !current)}\n className={`absolute ${expanded ? 'bottom-6 left-6 size-14' : 'left-2 top-2 size-8'} 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-4\" />}\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":";;;;;;;;;;;AA+CA,IAAa,KAAoC,EAC/C,YACA,WAAQ,CAAC,GACT,YAAS,MACT,WACA,gBACA,iBACA,UACA,eAAY,SACR;CACJ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,IAAW,6BAA6B,wBAAwB;IACvF,gBAAc;IACd,cAAY,EAAG,iDAAiD,kBAAkB;IAClF,eAAY;cAEZ,kBAAC,GAAD,EAAY,WAAW,IAAW,WAAW,SAAW,CAAA;GAClD,CAAA;GAER,kBAAC,UAAD;IACE,MAAK;IACL,eAAe,GAAa,MAAY,CAAC,CAAO;IAChD,WAAW,YAAY,IAAW,4BAA4B,sBAAsB;IACpF,gBAAc;IACd,cACE,IACI,EAAG,+CAA+C,0CAA0C,IAC5F,EAAG,6CAA6C,wCAAwC;IAE9F,eAAY;cAEX,IAAW,kBAAC,GAAD,EAAW,WAAU,SAAU,CAAA,IAAI,kBAAC,GAAD,EAAW,WAAU,SAAU,CAAA;GACxE,CAAA;EACL;;AAET;AAQA,SAAS,EAAc,GAA4B,GAAsC;CACvF,QAAQ,GAAR;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"}
@@ -0,0 +1,47 @@
1
+ import { VoiceWaveform as e } from "./VoiceWaveform.js";
2
+ import { showsAssistantCaption as t } from "../../../utils/voiceStageState.js";
3
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
+ //#region src/components/assistant/voice/VoiceMiniController.tsx
5
+ var i = ({ state: i, caption: a, statusText: o, control: s, errorText: c = null }) => {
6
+ let l = t(i);
7
+ return /* @__PURE__ */ r("div", {
8
+ className: "flex min-h-0 w-full flex-1 items-center gap-3 px-4",
9
+ "data-testid": "assistant-voice-mini",
10
+ "data-state": i,
11
+ children: [/* @__PURE__ */ r("div", {
12
+ className: "flex min-w-0 flex-1 flex-col gap-1.5",
13
+ children: [/* @__PURE__ */ r("div", {
14
+ className: "flex items-center gap-2",
15
+ children: [/* @__PURE__ */ n(e, {
16
+ active: i === "listening" || i === "speaking",
17
+ tone: i === "speaking" ? "speaking" : "listening"
18
+ }), /* @__PURE__ */ n("p", {
19
+ className: "truncate text-xs text-text-muted",
20
+ "data-testid": "assistant-voice-status",
21
+ children: o
22
+ })]
23
+ }), i === "mic-error" ? /* @__PURE__ */ n("p", {
24
+ className: "line-clamp-2 text-xs text-status-warning",
25
+ role: "alert",
26
+ "data-testid": "assistant-voice-mini-error",
27
+ children: c
28
+ }) : a ? /* @__PURE__ */ n("p", {
29
+ className: ["line-clamp-3 text-left text-sm leading-snug", l ? "font-semibold text-text-primary" : "font-medium text-text-secondary"].join(" "),
30
+ role: "status",
31
+ "aria-live": "polite",
32
+ "data-testid": "assistant-voice-caption",
33
+ children: a
34
+ }) : /* @__PURE__ */ n("div", {
35
+ className: "h-9",
36
+ "aria-hidden": "true"
37
+ })]
38
+ }), /* @__PURE__ */ n("div", {
39
+ className: "shrink-0",
40
+ children: s
41
+ })]
42
+ });
43
+ };
44
+ //#endregion
45
+ export { i as VoiceMiniController };
46
+
47
+ //# sourceMappingURL=VoiceMiniController.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VoiceMiniController.js","names":[],"sources":["../../../../src/components/assistant/voice/VoiceMiniController.tsx"],"sourcesContent":["import type { FC, ReactNode } from 'react';\nimport { VoiceWaveform } from './VoiceWaveform';\nimport { showsAssistantCaption, type VoiceStageState } from '../../../utils/voiceStageState';\n\n/**\n * Docked voice: a compact live controller, not the full stage shrunk.\n *\n * Measured in prod, the docked panel was 554px tall — the expanded composition\n * scaled down, with the same generous vertical rhythm in a space that cannot\n * carry it. Docked is a glance-and-listen surface: state, the last thing said,\n * and the controls. Everything else belongs to the expanded stage or the\n * transcript.\n *\n * ★ Two to three lines of caption, hard-clamped. The point is not to save\n * pixels — it is that a docked panel scrolling a long reply is the chat window\n * this feature exists to stop being. If the user wants the whole answer, they\n * expand or open the transcript.\n *\n * The row is deliberately horizontal: status and caption on the left, controls\n * on the right, so the panel reads as one strip rather than a stack. That is\n * what makes it feel like a controller instead of a small conversation.\n */\n\ninterface Props {\n state: VoiceStageState;\n /** Live user transcript, or the assistant's caption while speaking. */\n caption: string | null;\n statusText: string;\n /** Mic / interrupt control — the same orb, in its compact size. */\n control: ReactNode;\n errorText?: string | null;\n}\n\nexport const VoiceMiniController: FC<Props> = ({ state, caption, statusText, control, errorText = null }) => {\n const assistantSpeaking = showsAssistantCaption(state);\n\n return (\n <div\n className=\"flex min-h-0 w-full flex-1 items-center gap-3 px-4\"\n data-testid=\"assistant-voice-mini\"\n data-state={state}\n >\n <div className=\"flex min-w-0 flex-1 flex-col gap-1.5\">\n <div className=\"flex items-center gap-2\">\n <VoiceWaveform\n active={state === 'listening' || state === 'speaking'}\n tone={state === 'speaking' ? 'speaking' : 'listening'}\n />\n <p className=\"truncate text-xs text-text-muted\" data-testid=\"assistant-voice-status\">\n {statusText}\n </p>\n </div>\n\n {state === 'mic-error' ? (\n <p className=\"line-clamp-2 text-xs text-status-warning\" role=\"alert\" data-testid=\"assistant-voice-mini-error\">\n {errorText}\n </p>\n ) : caption ? (\n <p\n className={[\n // Three lines maximum. Older content scrolls out of existence\n // rather than growing the panel — see the note above.\n 'line-clamp-3 text-left text-sm leading-snug',\n assistantSpeaking ? 'font-semibold text-text-primary' : 'font-medium text-text-secondary',\n ].join(' ')}\n // The live region lives here when docked: this is the element that\n // actually changes.\n role=\"status\"\n aria-live=\"polite\"\n data-testid=\"assistant-voice-caption\"\n >\n {caption}\n </p>\n ) : (\n // Hold two lines so the controls do not shift when speech starts.\n <div className=\"h-9\" aria-hidden=\"true\" />\n )}\n </div>\n\n <div className=\"shrink-0\">{control}</div>\n </div>\n );\n};\n"],"mappings":";;;;AAiCA,IAAa,KAAkC,EAAE,UAAO,YAAS,eAAY,YAAS,eAAY,WAAW;CAC3G,IAAM,IAAoB,EAAsB,CAAK;CAErD,OACE,kBAAC,OAAD;EACE,WAAU;EACV,eAAY;EACZ,cAAY;YAHd,CAKE,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,OAAD;IAAK,WAAU;cAAf,CACE,kBAAC,GAAD;KACE,QAAQ,MAAU,eAAe,MAAU;KAC3C,MAAM,MAAU,aAAa,aAAa;IAC3C,CAAA,GACD,kBAAC,KAAD;KAAG,WAAU;KAAmC,eAAY;eACzD;IACA,CAAA,CACA;OAEJ,MAAU,cACT,kBAAC,KAAD;IAAG,WAAU;IAA2C,MAAK;IAAQ,eAAY;cAC9E;GACA,CAAA,IACD,IACF,kBAAC,KAAD;IACE,WAAW,CAGT,+CACA,IAAoB,oCAAoC,iCAC1D,EAAE,KAAK,GAAG;IAGV,MAAK;IACL,aAAU;IACV,eAAY;cAEX;GACA,CAAA,IAGH,kBAAC,OAAD;IAAK,WAAU;IAAM,eAAY;GAAQ,CAAA,CAExC;MAEL,kBAAC,OAAD;GAAK,WAAU;aAAY;EAAa,CAAA,CACrC;;AAET"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.901.10",
3
+ "version": "2026.901.11",
4
4
  "description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
5
5
  "type": "module",
6
6
  "files": [