@burdenoff/microfe-healthybowl 2026.830.5 → 2026.831.2

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.
@@ -1,20 +1,26 @@
1
1
  import { orbMode as e } from "../../../utils/voiceSession.js";
2
- import { jsx as t } from "react/jsx-runtime";
2
+ import { Mic as t, MicOff as n, Square as r } from "lucide-react";
3
+ import { jsx as i } from "react/jsx-runtime";
3
4
  //#region src/components/assistant/voice/AssistantVoiceOrb.tsx
4
- var n = ({ session: n, compact: r = !1 }) => {
5
- let i = e(n);
6
- return /* @__PURE__ */ t("div", {
7
- className: "flex items-center justify-center",
8
- "aria-hidden": "true",
5
+ var a = ({ session: a, compact: o = !1, onPress: s, label: c }) => {
6
+ let l = e(a), { muted: u, phase: d } = a, f = d === "thinking" || d === "idle", p = u && d !== "speaking" ? "from-bg-elevated to-bg-elevated" : l === "listening" ? "from-action-primary-bg/80 to-action-primary-bg/20" : l === "thinking" ? "from-text-muted/60 to-text-muted/10" : l === "speaking" ? "from-action-primary-bg to-action-primary-bg/40" : "from-bg-elevated to-bg-elevated/40", m = u && d !== "speaking" ? "" : l === "listening" ? "motion-safe:animate-pulse" : l === "thinking" ? "motion-safe:animate-[pulse_1.6s_ease-in-out_infinite]" : l === "speaking" ? "motion-safe:animate-[pulse_0.9s_ease-in-out_infinite]" : "", h = o ? "h-16 w-40" : "h-24 w-56", g = o ? "size-6" : "size-8", _ = d === "speaking" ? r : u ? n : t;
7
+ return /* @__PURE__ */ i("button", {
8
+ type: "button",
9
+ onClick: s,
10
+ disabled: f || !s,
11
+ className: `flex ${h} items-center justify-center rounded-full bg-gradient-to-b ${p} ${m} text-text-primary shadow-lg transition-colors duration-300 focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:cursor-default`,
12
+ "aria-label": c,
13
+ "aria-pressed": d === "speaking" ? void 0 : u,
9
14
  "data-testid": "assistant-voice-orb",
10
- "data-state": i,
11
- children: /* @__PURE__ */ t("div", {
12
- className: `${r ? "size-24" : "size-40"} rounded-full bg-gradient-to-b ${i === "listening" ? "from-action-primary-bg/80 to-action-primary-bg/20" : i === "thinking" ? "from-text-muted/60 to-text-muted/10" : i === "speaking" ? "from-action-primary-bg to-action-primary-bg/40" : "from-bg-elevated to-bg-elevated/40"} ${i === "listening" ? "motion-safe:animate-pulse" : i === "thinking" ? "motion-safe:animate-[spin_2.4s_linear_infinite]" : i === "speaking" ? "motion-safe:animate-[pulse_0.9s_ease-in-out_infinite]" : ""} shadow-lg transition-colors duration-300`,
15
+ "data-state": l,
16
+ "data-muted": u || void 0,
17
+ children: /* @__PURE__ */ i(_, {
18
+ className: g,
13
19
  "aria-hidden": "true"
14
20
  })
15
21
  });
16
22
  };
17
23
  //#endregion
18
- export { n as AssistantVoiceOrb };
24
+ export { a as AssistantVoiceOrb };
19
25
 
20
26
  //# sourceMappingURL=AssistantVoiceOrb.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AssistantVoiceOrb.js","names":[],"sources":["../../../../src/components/assistant/voice/AssistantVoiceOrb.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport type { VoiceSessionSnapshot } from '../../../utils/voiceSession';\nimport { orbMode } from '../../../utils/voiceSession';\n\n/**\n * The animated state indicator at the centre of a voice session (BOFF-7120).\n *\n * Its whole job is to answer \"is it hearing me, thinking, or talking?\" without\n * words — which matters more here than in a chat panel, because the user is\n * looking at a screen with no transcript scrolling past and needs to know\n * whether to keep speaking.\n *\n * The `thinking` state is deliberately conspicuous. Our pipeline is turn-based,\n * so there is a real 2-5s gap between the user finishing and the reply starting;\n * hiding that would just make the session feel broken rather than busy.\n *\n * Animation is pure CSS so it costs nothing while idle and keeps working under\n * `prefers-reduced-motion`, where the pulse is replaced by a static ring rather\n * than removed entirely — the state still has to be readable.\n */\nexport const AssistantVoiceOrb: FC<{ session: VoiceSessionSnapshot; compact?: boolean }> = ({\n session,\n compact = false,\n}) => {\n const mode = orbMode(session);\n\n // Colour carries the state for anyone who cannot perceive the motion; the\n // animation is a second, redundant channel rather than the only one.\n const tone =\n mode === 'listening'\n ? 'from-action-primary-bg/80 to-action-primary-bg/20'\n : mode === 'thinking'\n ? 'from-text-muted/60 to-text-muted/10'\n : mode === 'speaking'\n ? 'from-action-primary-bg to-action-primary-bg/40'\n : 'from-bg-elevated to-bg-elevated/40';\n\n const motion =\n mode === 'listening'\n ? 'motion-safe:animate-pulse'\n : mode === 'thinking'\n ? 'motion-safe:animate-[spin_2.4s_linear_infinite]'\n : mode === 'speaking'\n ? 'motion-safe:animate-[pulse_0.9s_ease-in-out_infinite]'\n : '';\n\n return (\n <div\n className=\"flex items-center justify-center\"\n // Purely decorative. A `role=\"status\"` here would announce nothing at all,\n // because the only child is aria-hidden and the orb carries no text — the\n // session's status paragraph is the live region, and it has real words.\n aria-hidden=\"true\"\n data-testid=\"assistant-voice-orb\"\n data-state={mode}\n >\n <div\n // Smaller when docked inside the assistant panel: at 160px the orb\n // crowds out the caption in a panel that is only a few hundred px wide.\n className={`${compact ? 'size-24' : 'size-40'} rounded-full bg-gradient-to-b ${tone} ${motion} shadow-lg transition-colors duration-300`}\n aria-hidden=\"true\"\n />\n </div>\n );\n};\n"],"mappings":";;;AAoBA,IAAa,KAA+E,EAC1F,YACA,aAAU,SACN;CACJ,IAAM,IAAO,EAAQ,CAAO;CAsB5B,OACE,kBAAC,OAAD;EACE,WAAU;EAIV,eAAY;EACZ,eAAY;EACZ,cAAY;YAEZ,kBAAC,OAAD;GAGE,WAAW,GAAG,IAAU,YAAY,UAAU,iCA9BlD,MAAS,cACL,sDACA,MAAS,aACP,wCACA,MAAS,aACP,mDACA,qCAwBgF,GArBxF,MAAS,cACL,8BACA,MAAS,aACP,oDACA,MAAS,aACP,0DACA,GAe0F;GAC9F,eAAY;EACb,CAAA;CACE,CAAA;AAET"}
1
+ {"version":3,"file":"AssistantVoiceOrb.js","names":[],"sources":["../../../../src/components/assistant/voice/AssistantVoiceOrb.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { Mic, MicOff, Square } from 'lucide-react';\nimport type { VoiceSessionSnapshot } from '../../../utils/voiceSession';\nimport { orbMode } from '../../../utils/voiceSession';\n\n/**\n * The session's single animated control (BOFF-7120).\n *\n * It was a decorative round orb with a separate mic button beneath it. Now it is\n * one pill that both SHOWS the state and IS the control, because two elements\n * were saying the same thing: the orb pulsed to mean \"listening\" while the mic\n * button sat next to it meaning \"the microphone\". Merging them leaves a single\n * large target, which matters when the user is talking rather than looking.\n *\n * What tapping it does depends on the phase, and the icon always says which:\n * - listening -> mute (Mic)\n * - muted -> unmute (MicOff)\n * - speaking -> interrupt (Square — the stop glyph, not a microphone)\n * - thinking -> nothing (disabled; there is nothing to stop or mute yet)\n *\n * Interruption living here is deliberate: it is the biggest target on screen,\n * and it replaced barge-in when the microphone had to be closed during playback\n * to stop the assistant transcribing its own voice.\n */\ninterface Props {\n session: VoiceSessionSnapshot;\n compact?: boolean;\n onPress?: () => void;\n /** Accessible name — the caller knows the translated strings. */\n label: string;\n}\n\nexport const AssistantVoiceOrb: FC<Props> = ({ session, compact = false, onPress, label }) => {\n const mode = orbMode(session);\n const { muted, phase } = session;\n // Nothing to mute and nothing to stop: a press here would be a no-op, and a\n // control that does nothing is worse than one that is visibly unavailable.\n const disabled = phase === 'thinking' || phase === 'idle';\n\n // Colour carries the state for anyone who cannot perceive the motion; the\n // animation is a second, redundant channel rather than the only one.\n const tone =\n muted && phase !== 'speaking'\n ? 'from-bg-elevated to-bg-elevated'\n : mode === 'listening'\n ? 'from-action-primary-bg/80 to-action-primary-bg/20'\n : mode === 'thinking'\n ? 'from-text-muted/60 to-text-muted/10'\n : mode === 'speaking'\n ? 'from-action-primary-bg to-action-primary-bg/40'\n : 'from-bg-elevated to-bg-elevated/40';\n\n const motion =\n muted && phase !== 'speaking'\n ? ''\n : mode === 'listening'\n ? 'motion-safe:animate-pulse'\n : mode === 'thinking'\n ? 'motion-safe:animate-[pulse_1.6s_ease-in-out_infinite]'\n : mode === 'speaking'\n ? 'motion-safe:animate-[pulse_0.9s_ease-in-out_infinite]'\n : '';\n\n // Pill, not a circle: wide enough to read as a control rather than an\n // ornament, and it leaves room for the icon to sit centred at any size.\n const size = compact ? 'h-16 w-40' : 'h-24 w-56';\n const icon = compact ? 'size-6' : 'size-8';\n\n const Glyph = phase === 'speaking' ? Square : muted ? MicOff : Mic;\n\n return (\n <button\n type=\"button\"\n onClick={onPress}\n disabled={disabled || !onPress}\n className={`flex ${size} items-center justify-center rounded-full bg-gradient-to-b ${tone} ${motion} text-text-primary shadow-lg transition-colors duration-300 focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong disabled:cursor-default`}\n aria-label={label}\n // A toggle in the listening/muted phases, so its state is announced as\n // one. Omitted while speaking, where the press is a one-shot stop rather\n // than a toggle and `aria-pressed` would misdescribe it.\n aria-pressed={phase === 'speaking' ? undefined : muted}\n data-testid=\"assistant-voice-orb\"\n data-state={mode}\n data-muted={muted || undefined}\n >\n <Glyph className={icon} aria-hidden=\"true\" />\n </button>\n );\n};\n"],"mappings":";;;;AAgCA,IAAa,KAAgC,EAAE,YAAS,aAAU,IAAO,YAAS,eAAY;CAC5F,IAAM,IAAO,EAAQ,CAAO,GACtB,EAAE,UAAO,aAAU,GAGnB,IAAW,MAAU,cAAc,MAAU,QAI7C,IACJ,KAAS,MAAU,aACf,oCACA,MAAS,cACP,sDACA,MAAS,aACP,wCACA,MAAS,aACP,mDACA,sCAEN,IACJ,KAAS,MAAU,aACf,KACA,MAAS,cACP,8BACA,MAAS,aACP,0DACA,MAAS,aACP,0DACA,IAIN,IAAO,IAAU,cAAc,aAC/B,IAAO,IAAU,WAAW,UAE5B,IAAQ,MAAU,aAAa,IAAS,IAAQ,IAAS;CAE/D,OACE,kBAAC,UAAD;EACE,MAAK;EACL,SAAS;EACT,UAAU,KAAY,CAAC;EACvB,WAAW,QAAQ,EAAK,6DAA6D,EAAK,GAAG,EAAO;EACpG,cAAY;EAIZ,gBAAc,MAAU,aAAa,KAAA,IAAY;EACjD,eAAY;EACZ,cAAY;EACZ,cAAY,KAAS,KAAA;YAErB,kBAAC,GAAD;GAAO,WAAW;GAAM,eAAY;EAAQ,CAAA;CACtC,CAAA;AAEZ"}
@@ -2,118 +2,96 @@ import { useTr as e } from "../../../shared/hooks/useTr.js";
2
2
  import { spokenSoFar as t } from "../../../utils/voiceSession.js";
3
3
  import { AssistantVoiceOrb as n } from "./AssistantVoiceOrb.js";
4
4
  import { useEffect as r, useRef as i, useState as a } from "react";
5
- import { Maximize2 as o, Mic as s, MicOff as c, Minimize2 as l, X as u } from "lucide-react";
6
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
5
+ import { Maximize2 as o, Minimize2 as s, X as c } from "lucide-react";
6
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
7
7
  //#region src/components/assistant/voice/AssistantVoiceSession.tsx
8
- var p = ({ session: p, turns: g = [], notice: _ = null, spoken: v, onInterrupt: y, onToggleMute: b, onEnd: x }) => {
9
- let S = e(), { phase: C, muted: w, error: T } = p, E = i(null), D = i(null), [O, k] = a(!1);
8
+ var d = ({ session: d, turns: m = [], notice: h = null, spoken: g, onInterrupt: _, onToggleMute: v, onEnd: y }) => {
9
+ let b = e(), { phase: x, muted: S, error: C } = d, w = i(null), T = i(null), [E, D] = a(!1);
10
10
  r(() => {
11
- E.current?.focus();
11
+ w.current?.focus();
12
12
  }, []), r(() => {
13
13
  let e = (e) => {
14
14
  if (e.key === "Escape") {
15
- x();
15
+ y();
16
16
  return;
17
17
  }
18
- if (e.key !== "Tab" || !O) return;
19
- let t = D.current?.querySelectorAll("button:not([disabled])");
18
+ if (e.key !== "Tab" || !E) return;
19
+ let t = T.current?.querySelectorAll("button:not([disabled])");
20
20
  if (!t || t.length === 0) return;
21
21
  let n = t[0], r = t[t.length - 1];
22
22
  !n || !r || (e.shiftKey && document.activeElement === n ? (e.preventDefault(), r.focus()) : !e.shiftKey && document.activeElement === r && (e.preventDefault(), n.focus()));
23
23
  };
24
24
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
25
- }, [x, O]);
26
- let A = C === "thinking" ? S("healthybowl.assistant.voiceSession.thinking", "Thinking…") : C === "speaking" ? S("healthybowl.assistant.voiceSession.speaking", "Speaking — tap to interrupt") : w ? S("healthybowl.assistant.voiceSession.muted", "Microphone off") : S("healthybowl.assistant.voiceSession.listening", "Listening…"), j = T === null ? w && C !== "listening" ? `${A} · ${S("healthybowl.assistant.voiceSession.muted", "Microphone off")}` : A : h(T, S), M = C === "speaking" ? v : t(p);
27
- return /* @__PURE__ */ f("div", {
28
- ref: D,
29
- className: `flex flex-col items-center justify-between bg-bg-sunken ${O ? "fixed inset-0 z-[60] px-6 py-10" : "absolute inset-0 z-20 px-4 py-6"}`,
25
+ }, [y, E]);
26
+ let O = x === "thinking" ? b("healthybowl.assistant.voiceSession.thinking", "Thinking…") : x === "speaking" ? b("healthybowl.assistant.voiceSession.speaking", "Speaking — tap to stop") : S ? b("healthybowl.assistant.voiceSession.muted", "Microphone off") : b("healthybowl.assistant.voiceSession.listening", "Listening…"), k = C === null ? S && x !== "listening" ? `${O} · ${b("healthybowl.assistant.voiceSession.muted", "Microphone off")}` : O : p(C, b), A = x === "speaking" ? g : t(d);
27
+ return /* @__PURE__ */ u("div", {
28
+ ref: T,
29
+ className: `flex flex-col items-center justify-between bg-bg-sunken ${E ? "fixed inset-0 z-[60] px-6 py-10" : "absolute inset-0 z-20 px-4 py-6"}`,
30
30
  role: "dialog",
31
- "aria-modal": O || void 0,
32
- "aria-label": S("healthybowl.assistant.voiceSession.title", "Voice conversation"),
31
+ "aria-modal": E || void 0,
32
+ "aria-label": b("healthybowl.assistant.voiceSession.title", "Voice conversation"),
33
33
  "data-testid": "assistant-voice-session",
34
34
  children: [
35
- /* @__PURE__ */ f("div", {
36
- className: "flex flex-col items-center gap-1",
37
- children: [/* @__PURE__ */ d("p", {
35
+ /* @__PURE__ */ l("button", {
36
+ ref: w,
37
+ type: "button",
38
+ onClick: y,
39
+ className: `absolute ${E ? "right-6 top-6 size-14" : "right-3 top-3 size-11"} flex items-center justify-center rounded-full bg-action-danger-bg text-action-danger-text transition-colors hover:bg-action-danger-bg-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong`,
40
+ "aria-label": b("healthybowl.assistant.voiceSession.end", "End the voice conversation"),
41
+ "data-testid": "assistant-voice-end",
42
+ children: /* @__PURE__ */ l(c, { className: E ? "size-6" : "size-5" })
43
+ }),
44
+ /* @__PURE__ */ u("div", {
45
+ className: "flex flex-col items-center gap-1 px-14",
46
+ children: [/* @__PURE__ */ l("p", {
38
47
  className: "text-sm text-text-muted",
39
48
  role: "status",
40
49
  "aria-live": "polite",
41
50
  "data-testid": "assistant-voice-status",
42
- children: j
43
- }), _ && T === null ? /* @__PURE__ */ d("p", {
51
+ children: k
52
+ }), h && C === null ? /* @__PURE__ */ l("p", {
44
53
  className: "max-w-xs text-center text-xs text-status-warning",
45
54
  "data-testid": "assistant-voice-notice",
46
- children: m(_, S)
55
+ children: f(h, b)
47
56
  }) : null]
48
57
  }),
49
- /* @__PURE__ */ f("div", {
50
- className: "flex min-h-0 flex-1 flex-col items-center justify-center gap-4",
58
+ /* @__PURE__ */ u("div", {
59
+ className: "flex min-h-0 w-full flex-1 flex-col items-center justify-center gap-4 px-14",
51
60
  children: [
52
- g.length > 0 ? /* @__PURE__ */ d("div", {
61
+ m.length > 0 ? /* @__PURE__ */ l("div", {
53
62
  className: "flex w-full max-w-md flex-1 flex-col justify-end gap-2 overflow-y-auto text-sm",
54
63
  "data-testid": "assistant-voice-turns",
55
- children: g.map((e) => /* @__PURE__ */ d("p", {
64
+ children: m.map((e) => /* @__PURE__ */ l("p", {
56
65
  className: e.role === "user" ? "self-end rounded-2xl bg-bg-elevated px-3 py-1.5 text-text-primary" : "self-start text-text-secondary",
57
66
  children: e.text
58
67
  }, e.id))
59
68
  }) : null,
60
- C === "speaking" && y ? /* @__PURE__ */ d("button", {
61
- type: "button",
62
- onClick: y,
63
- className: "rounded-full focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong",
64
- "aria-label": S("healthybowl.assistant.voiceSession.interrupt", "Stop the assistant and speak"),
65
- "data-testid": "assistant-voice-interrupt",
66
- children: /* @__PURE__ */ d(n, {
67
- session: p,
68
- compact: !O
69
- })
70
- }) : /* @__PURE__ */ d(n, {
71
- session: p,
72
- compact: !O
69
+ /* @__PURE__ */ l(n, {
70
+ session: d,
71
+ compact: !E,
72
+ onPress: x === "speaking" ? _ : v,
73
+ label: x === "speaking" ? b("healthybowl.assistant.voiceSession.interrupt", "Stop the assistant and speak") : S ? b("healthybowl.assistant.voiceSession.unmute", "Turn the microphone on") : b("healthybowl.assistant.voiceSession.mute", "Turn the microphone off")
73
74
  }),
74
- M ? /* @__PURE__ */ d("p", {
75
+ A ? /* @__PURE__ */ l("p", {
75
76
  className: "line-clamp-3 max-w-md text-center text-base leading-relaxed text-text-secondary",
76
77
  "data-testid": "assistant-voice-caption",
77
- children: M
78
+ children: A
78
79
  }) : null
79
80
  ]
80
81
  }),
81
- /* @__PURE__ */ f("div", {
82
- className: `flex items-center ${O ? "gap-6" : "gap-4"}`,
83
- children: [
84
- /* @__PURE__ */ d("button", {
85
- type: "button",
86
- onClick: () => k((e) => !e),
87
- className: `flex ${O ? "size-14" : "size-11"} 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": O,
89
- "aria-label": O ? S("healthybowl.assistant.voiceSession.collapse", "Fit the conversation back into the panel") : S("healthybowl.assistant.voiceSession.expand", "Expand the conversation to full screen"),
90
- "data-testid": "assistant-voice-expand",
91
- children: d(O ? l : o, { className: "size-5" })
92
- }),
93
- /* @__PURE__ */ d("button", {
94
- type: "button",
95
- onClick: b,
96
- className: `flex ${O ? "size-14" : "size-11"} items-center justify-center rounded-full bg-bg-elevated text-text-primary transition-colors hover:bg-bg-raised focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong`,
97
- "aria-pressed": w,
98
- "aria-label": w ? S("healthybowl.assistant.voiceSession.unmute", "Turn the microphone on") : S("healthybowl.assistant.voiceSession.mute", "Turn the microphone off"),
99
- "data-testid": "assistant-voice-mute",
100
- children: d(w ? c : s, { className: O ? "size-6" : "size-5" })
101
- }),
102
- /* @__PURE__ */ d("button", {
103
- ref: E,
104
- type: "button",
105
- onClick: x,
106
- className: `flex ${O ? "size-14" : "size-11"} items-center justify-center rounded-full bg-action-danger-bg text-action-danger-text transition-colors hover:bg-action-danger-bg-hover focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong`,
107
- "aria-label": S("healthybowl.assistant.voiceSession.end", "End the voice conversation"),
108
- "data-testid": "assistant-voice-end",
109
- children: /* @__PURE__ */ d(u, { className: O ? "size-6" : "size-5" })
110
- })
111
- ]
82
+ /* @__PURE__ */ l("button", {
83
+ type: "button",
84
+ onClick: () => D((e) => !e),
85
+ className: `absolute ${E ? "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`,
86
+ "aria-pressed": E,
87
+ "aria-label": E ? b("healthybowl.assistant.voiceSession.collapse", "Fit the conversation back into the panel") : b("healthybowl.assistant.voiceSession.expand", "Expand the conversation to full screen"),
88
+ "data-testid": "assistant-voice-expand",
89
+ children: l(E ? s : o, { className: "size-5" })
112
90
  })
113
91
  ]
114
92
  });
115
93
  };
116
- function m(e, t) {
94
+ function f(e, t) {
117
95
  switch (e) {
118
96
  case "network": return t("healthybowl.assistant.voiceSession.noticeNetwork", "Speech recognition lost its connection. Check your network — it will retry.");
119
97
  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.");
@@ -121,7 +99,7 @@ function m(e, t) {
121
99
  default: return e;
122
100
  }
123
101
  }
124
- function h(e, t) {
102
+ function p(e, t) {
125
103
  switch (e) {
126
104
  case "mic-denied": return t("healthybowl.assistant.voiceSession.micDenied", "Microphone access is blocked. Allow it in your browser settings to talk.");
127
105
  case "no-speech-support": return t("healthybowl.assistant.voiceSession.noSpeechSupport", "This browser cannot listen. Try a different browser, or type instead.");
@@ -130,6 +108,6 @@ function h(e, t) {
130
108
  }
131
109
  }
132
110
  //#endregion
133
- export { p as AssistantVoiceSession };
111
+ export { d as AssistantVoiceSession };
134
112
 
135
113
  //# 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, Mic, MicOff, Minimize2, X } from 'lucide-react';\nimport { AssistantVoiceOrb } from './AssistantVoiceOrb';\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}\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}) => {\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\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 interrupt')\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 caption = phase === 'speaking' ? spoken : spokenSoFar(session);\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 {/* The session's single live region. It has real words, unlike the orb. */}\n <div className=\"flex flex-col items-center gap-1\">\n <p className=\"text-sm text-text-muted\" role=\"status\" aria-live=\"polite\" data-testid=\"assistant-voice-status\">\n {status}\n </p>\n {/* A dead microphone used to look exactly like a live one. Whatever else\n happens, the session must never claim to be listening in silence. */}\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 <div className=\"flex min-h-0 flex-1 flex-col items-center justify-center gap-4\">\n {/* The running conversation, as Gemini shows it — so a second question\n in the same session has the first still visible. Oldest first, with\n the newest pinned at the bottom next to the orb. */}\n {turns.length > 0 ? (\n <div\n className=\"flex w-full max-w-md flex-1 flex-col justify-end gap-2 overflow-y-auto text-sm\"\n data-testid=\"assistant-voice-turns\"\n >\n {turns.map((turn) => (\n <p\n key={turn.id}\n className={\n turn.role === 'user'\n ? 'self-end rounded-2xl bg-bg-elevated px-3 py-1.5 text-text-primary'\n : 'self-start text-text-secondary'\n }\n >\n {turn.text}\n </p>\n ))}\n </div>\n ) : null}\n\n {phase === 'speaking' && onInterrupt ? (\n <button\n type=\"button\"\n onClick={onInterrupt}\n className=\"rounded-full focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong\"\n aria-label={tr('healthybowl.assistant.voiceSession.interrupt', 'Stop the assistant and speak')}\n data-testid=\"assistant-voice-interrupt\"\n >\n <AssistantVoiceOrb session={session} compact={!expanded} />\n </button>\n ) : (\n <AssistantVoiceOrb session={session} compact={!expanded} />\n )}\n {caption ? (\n // Capped rather than scrolled: a long reply should not turn the\n // session into a wall of text the user reads instead of listens to.\n <p\n className=\"line-clamp-3 max-w-md text-center text-base leading-relaxed text-text-secondary\"\n data-testid=\"assistant-voice-caption\"\n >\n {caption}\n </p>\n ) : null}\n </div>\n\n <div className={`flex items-center ${expanded ? 'gap-6' : 'gap-4'}`}>\n <button\n type=\"button\"\n onClick={() => setExpanded((current) => !current)}\n className={`flex ${expanded ? 'size-14' : 'size-11'} 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\n <button\n type=\"button\"\n onClick={onToggleMute}\n className={`flex ${expanded ? 'size-14' : 'size-11'} items-center justify-center rounded-full bg-bg-elevated text-text-primary transition-colors hover:bg-bg-raised focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong`}\n aria-pressed={muted}\n aria-label={\n muted\n ? tr('healthybowl.assistant.voiceSession.unmute', 'Turn the microphone on')\n : tr('healthybowl.assistant.voiceSession.mute', 'Turn the microphone off')\n }\n data-testid=\"assistant-voice-mute\"\n >\n {muted ? (\n <MicOff className={expanded ? 'size-6' : 'size-5'} />\n ) : (\n <Mic className={expanded ? 'size-6' : 'size-5'} />\n )}\n </button>\n\n <button\n ref={endRef}\n type=\"button\"\n onClick={onEnd}\n className={`flex ${expanded ? 'size-14' : 'size-11'} items-center justify-center rounded-full bg-action-danger-bg text-action-danger-text transition-colors hover:bg-action-danger-bg-hover 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 </div>\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 '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":";;;;;;;AAyCA,IAAa,KAAoC,EAC/C,YACA,WAAQ,CAAC,GACT,YAAS,MACT,WACA,gBACA,iBACA,eACI;CACJ,IAAM,IAAK,EAAM,GACX,EAAE,UAAO,UAAO,aAAU,GAC1B,IAAS,EAA0B,IAAI,GACvC,IAAY,EAAuB,IAAI,GAUvC,CAAC,GAAU,KAAe,EAAS,EAAK;CAc9C,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,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AO,EACL,oDACA,6EACF;EACF,KAAK,iBACH,OAAO,EACL,yDACA,0FACF;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, X } from 'lucide-react';\nimport { AssistantVoiceOrb } from './AssistantVoiceOrb';\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}\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}) => {\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\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 caption = phase === 'speaking' ? spoken : spokenSoFar(session);\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 bg-action-danger-bg text-action-danger-text transition-colors hover:bg-action-danger-bg-hover 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 session's single live region. It has real words, unlike the orb. */}\n <div className=\"flex flex-col items-center gap-1 px-14\">\n <p className=\"text-sm text-text-muted\" role=\"status\" aria-live=\"polite\" data-testid=\"assistant-voice-status\">\n {status}\n </p>\n {/* A dead microphone used to look exactly like a live one. Whatever else\n happens, the session must never claim to be listening in silence. */}\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 {/* Padded so the pill and caption never collide with the corner controls\n in a docked panel only a few hundred pixels wide. */}\n <div className=\"flex min-h-0 w-full flex-1 flex-col items-center justify-center gap-4 px-14\">\n {/* The running conversation, as Gemini shows it — so a second question\n in the same session has the first still visible. Oldest first, with\n the newest pinned at the bottom next to the orb. */}\n {turns.length > 0 ? (\n <div\n className=\"flex w-full max-w-md flex-1 flex-col justify-end gap-2 overflow-y-auto text-sm\"\n data-testid=\"assistant-voice-turns\"\n >\n {turns.map((turn) => (\n <p\n key={turn.id}\n className={\n turn.role === 'user'\n ? 'self-end rounded-2xl bg-bg-elevated px-3 py-1.5 text-text-primary'\n : 'self-start text-text-secondary'\n }\n >\n {turn.text}\n </p>\n ))}\n </div>\n ) : null}\n\n <AssistantVoiceOrb\n session={session}\n compact={!expanded}\n onPress={phase === 'speaking' ? onInterrupt : onToggleMute}\n label={\n phase === 'speaking'\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 {/* The LIVE caption: what is being said right now, before it is\n finalised into the conversation. `turns` only holds messages that\n already reached history, so without this the in-progress utterance\n appears nowhere and the session looks deaf while it is working. */}\n {caption ? (\n <p\n className=\"line-clamp-3 max-w-md text-center text-base leading-relaxed text-text-secondary\"\n data-testid=\"assistant-voice-caption\"\n >\n {caption}\n </p>\n ) : null}\n </div>\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 '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":";;;;;;;AAyCA,IAAa,KAAoC,EAC/C,YACA,WAAQ,CAAC,GACT,YAAS,MACT,WACA,gBACA,iBACA,eACI;CACJ,IAAM,IAAK,EAAM,GACX,EAAE,UAAO,UAAO,aAAU,GAC1B,IAAS,EAA0B,IAAI,GACvC,IAAY,EAAuB,IAAI,GAUvC,CAAC,GAAU,KAAe,EAAS,EAAK;CAc9C,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;GACtC,CAAC,KAAS,CAAC,MACX,EAAM,YAAY,SAAS,kBAAkB,KAC/C,EAAM,eAAe,GACrB,EAAK,MAAM,KACF,CAAC,EAAM,YAAY,SAAS,kBAAkB,MACvD,EAAM,eAAe,GACrB,EAAM,MAAM;EAEhB;EAEA,OADA,O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AEJ,kBAAC,GAAD;MACW;MACT,SAAS,CAAC;MACV,SAAS,MAAU,aAAa,IAAc;MAC9C,OACE,MAAU,aACN,EAAG,gDAAgD,8BAA8B,IACjF,IACE,EAAG,6CAA6C,wBAAwB,IACxE,EAAG,2CAA2C,yBAAyB;KAEhF,CAAA;KAMA,IACC,kBAAC,KAAD;MACE,WAAU;MACV,eAAY;gBAEX;KACA,CAAA,IACD;IACD;;GAEL,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,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.830.5",
3
+ "version": "2026.831.2",
4
4
  "description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
5
5
  "type": "module",
6
6
  "files": [