@burdenoff/fe-libs 2026.1114.12 → 2026.1114.14

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.
Files changed (40) hide show
  1. package/dist/shared/assistant/conversation.d.ts +16 -0
  2. package/dist/shared/assistant/i18nManifest.d.ts +32 -0
  3. package/dist/shared/assistant/i18nManifest.js +32 -0
  4. package/dist/shared/assistant/index.d.ts +10 -0
  5. package/dist/shared/assistant/store.d.ts +7 -0
  6. package/dist/shared/assistant/store.js +3 -0
  7. package/dist/shared/assistant/ui/AssistantChatArea.js +1275 -1181
  8. package/dist/shared/assistant/ui/AssistantMessageList.d.ts +14 -0
  9. package/dist/shared/assistant/ui/AssistantMessageList.js +55 -52
  10. package/dist/shared/assistant/ui/composer/AssistantComposer.d.ts +6 -0
  11. package/dist/shared/assistant/ui/composer/AssistantComposer.js +400 -311
  12. package/dist/shared/assistant/ui/composer/AssistantDictation.d.ts +42 -0
  13. package/dist/shared/assistant/ui/composer/AssistantDictation.js +127 -0
  14. package/dist/shared/assistant/ui/composer/AssistantMicMenu.d.ts +23 -0
  15. package/dist/shared/assistant/ui/composer/AssistantMicMenu.js +176 -0
  16. package/dist/shared/assistant/ui/composer/microphones.d.ts +13 -0
  17. package/dist/shared/assistant/ui/composer/microphones.js +15 -0
  18. package/dist/shared/assistant/ui/composer/useCompactDictation.d.ts +70 -0
  19. package/dist/shared/assistant/ui/composer/useCompactDictation.js +136 -0
  20. package/dist/shared/assistant/ui/useVoiceSession.js +166 -164
  21. package/dist/shared/assistant/ui/voice/AssistantPageVoiceBar.d.ts +67 -0
  22. package/dist/shared/assistant/ui/voice/AssistantPageVoiceBar.js +290 -0
  23. package/dist/shared/assistant/ui/voice/AssistantVoiceSession.d.ts +11 -1
  24. package/dist/shared/assistant/ui/voice/AssistantVoiceSession.js +288 -244
  25. package/dist/shared/assistant/ui/voice/AssistantVoiceSessionButton.d.ts +5 -0
  26. package/dist/shared/assistant/ui/voice/AssistantVoiceSessionButton.js +6 -6
  27. package/dist/shared/assistant/ui/voice/LiveWaveform.d.ts +32 -0
  28. package/dist/shared/assistant/ui/voice/LiveWaveform.js +52 -0
  29. package/dist/shared/assistant/ui/voice/VoiceTurnMarks.d.ts +15 -0
  30. package/dist/shared/assistant/ui/voice/VoiceTurnMarks.js +43 -0
  31. package/dist/shared/assistant/ui/voice/formatClock.d.ts +2 -0
  32. package/dist/shared/assistant/ui/voice/formatClock.js +3 -0
  33. package/dist/shared/assistant/ui/voice/useLiveLevel.d.ts +23 -0
  34. package/dist/shared/assistant/ui/voice/useLiveLevel.js +56 -0
  35. package/dist/shared/assistant/voice/liveLevel.d.ts +85 -0
  36. package/dist/shared/assistant/voice/liveLevel.js +78 -0
  37. package/dist/shared/assistant/voice/useVoiceInput.d.ts +27 -1
  38. package/dist/shared/assistant/voice/useVoiceInput.js +141 -71
  39. package/dist/shared-assistant.js +393 -383
  40. package/package.json +1 -1
@@ -0,0 +1,290 @@
1
+ import { useAssistantTr as e } from "../../i18n.js";
2
+ import { PAGE_COLUMN as t } from "../assistantPageLayout.js";
3
+ import { ASSISTANT_VOICE_SESSION_ATTR as n } from "../panelOverlays.js";
4
+ import { usePrefersReducedMotion as r } from "../usePrefersReducedMotion.js";
5
+ import { AssistantAttachmentButton as i } from "../composer/AssistantAttachmentButton.js";
6
+ import { AssistantAttachmentChips as a } from "../composer/AssistantAttachmentChips.js";
7
+ import { formatClock as o } from "./formatClock.js";
8
+ import { HandsFreePrivacyNotice as s } from "./HandsFreePrivacyNotice.js";
9
+ import { VoiceStatusText as c } from "./VoiceStatusText.js";
10
+ import { useEffect as l, useRef as u, useState as d } from "react";
11
+ import { Loader2 as f, MicOff as p } from "lucide-react";
12
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
13
+ // src/shared/assistant/ui/voice/AssistantPageVoiceBar.tsx
14
+ function _(e, t) {
15
+ return e === "mic-error" ? "error" : t ? "off" : e === "listening" || e === "endpoint-grace" || e === "interrupting" ? "hearing" : e === "speaking" ? "talking" : "waiting";
16
+ }
17
+ var v = {
18
+ hearing: "border-status-warning-bg ring-1 ring-status-warning-bg",
19
+ talking: "border-status-info-bg ring-1 ring-status-info-bg",
20
+ waiting: "border-border-default",
21
+ off: "border-border-default",
22
+ error: "border-status-error-bg"
23
+ }, y = {
24
+ hearing: "bg-status-warning-bg-subtle text-status-warning-bg",
25
+ talking: "bg-status-info-bg-subtle text-status-info-bg",
26
+ waiting: "bg-bg-sunken text-text-secondary",
27
+ off: "bg-bg-sunken text-text-muted",
28
+ error: "bg-status-error-bg-subtle text-status-error-text"
29
+ }, b = ({ level: e }) => {
30
+ let t = r(), n = u([]);
31
+ return l(() => {
32
+ if (t) return;
33
+ let r = 0;
34
+ return e.subscribe((e) => {
35
+ r += 1, n.current.forEach((t, n) => {
36
+ if (!t) return;
37
+ let i = .55 + .45 * Math.abs(Math.sin(r / 3 + n * 1.3));
38
+ t.style.transform = `scaleY(${Math.max(.2, Math.min(1, e * 1.6 * i))})`;
39
+ });
40
+ });
41
+ }, [e, t]), /* @__PURE__ */ h("span", {
42
+ className: "flex h-5 items-center gap-[3px]",
43
+ "aria-hidden": "true",
44
+ children: [
45
+ 0,
46
+ 1,
47
+ 2,
48
+ 3
49
+ ].map((e) => /* @__PURE__ */ h("span", {
50
+ ref: (t) => {
51
+ n.current[e] = t;
52
+ },
53
+ className: "h-full w-[3px] origin-center scale-y-[0.35] rounded-full bg-current transition-transform duration-75"
54
+ }, e))
55
+ });
56
+ }, x = ({ tone: e, level: t }) => {
57
+ let n = r();
58
+ return /* @__PURE__ */ h("span", {
59
+ "aria-hidden": "true",
60
+ className: `flex size-11 shrink-0 items-center justify-center rounded-full ${y[e]}`,
61
+ "data-testid": "assistant-voice-circle",
62
+ "data-tone": e,
63
+ children: e === "hearing" || e === "talking" ? /* @__PURE__ */ h(b, { level: t }) : e === "off" || e === "error" ? /* @__PURE__ */ h(p, { className: "size-5" }) : /* @__PURE__ */ h(f, { className: `size-5${n ? "" : " motion-safe:animate-spin"}` })
64
+ });
65
+ };
66
+ function S(e, t) {
67
+ if (t.heard) return t.heard;
68
+ let n = e("voiceDock.listeningCaption", "Go ahead, I am listening.");
69
+ return t.stage === "listening" && t.stageText === e("voiceSession.listening", "Listening…") ? n : t.stageText || n;
70
+ }
71
+ function C(e, t) {
72
+ let { stage: n } = t;
73
+ return n === "mic-error" ? {
74
+ title: e("voiceDock.problem", "Microphone problem"),
75
+ caption: t.errorText ?? ""
76
+ } : t.muted ? {
77
+ title: e("voiceDock.muted", "Muted"),
78
+ caption: e("voiceDock.mutedCaption", "Your microphone is off. Unmute to continue.")
79
+ } : n === "connecting" ? {
80
+ title: e("voiceDock.connecting", "Connecting"),
81
+ caption: e("voiceDock.connectingCaption", "Setting up audio")
82
+ } : n === "thinking" ? {
83
+ title: e("voiceDock.thinking", "Thinking"),
84
+ caption: e("voiceDock.thinkingCaption", "Working on an answer")
85
+ } : n === "speaking" ? {
86
+ title: e("voiceDock.speaking", "Speaking"),
87
+ caption: t.bargeIn ? e("voiceDock.speakingCaption", "Speak or tap Interrupt to cut in.") : e("voiceDock.speakingCaptionTap", "Tap Interrupt to cut in.")
88
+ } : {
89
+ title: e("voiceDock.listening", "Listening"),
90
+ caption: S(e, t)
91
+ };
92
+ }
93
+ function w(t) {
94
+ return C(e(), t);
95
+ }
96
+ function T() {
97
+ let [e, t] = d(0);
98
+ return l(() => {
99
+ let e = Date.now(), n = setInterval(() => t(Math.floor((Date.now() - e) / 1e3)), 1e3);
100
+ return () => clearInterval(n);
101
+ }, []), e;
102
+ }
103
+ function E(e) {
104
+ let t = u(null);
105
+ l(() => {
106
+ if (typeof document < "u") return t.current = document.title, () => {
107
+ t.current !== null && (document.title = t.current);
108
+ };
109
+ }, []), l(() => {
110
+ typeof document < "u" && t.current !== null && (document.title = `${e} · ${t.current}`);
111
+ }, [e]);
112
+ }
113
+ var D = ({ notice: e, announcedNotice: t, attachmentNotice: n, startedCue: r }) => /* @__PURE__ */ g(m, { children: [
114
+ /* @__PURE__ */ g("div", {
115
+ className: "flex flex-col items-center gap-1 px-1 text-center text-xs empty:hidden [&:not(:empty)]:pb-1.5",
116
+ "data-testid": "assistant-voice-page-notices",
117
+ children: [
118
+ e ? /* @__PURE__ */ h("p", {
119
+ className: "text-status-warning-text",
120
+ "data-testid": "assistant-voice-notice",
121
+ children: e
122
+ }) : null,
123
+ n ? /* @__PURE__ */ h("p", {
124
+ className: "text-status-warning-text",
125
+ role: "status",
126
+ "aria-live": "polite",
127
+ "data-testid": "assistant-voice-attachment-notice",
128
+ children: n
129
+ }) : null,
130
+ r ? /* @__PURE__ */ h("p", {
131
+ className: "text-text-secondary",
132
+ "data-testid": "assistant-voice-started-cue",
133
+ children: r
134
+ }) : null
135
+ ]
136
+ }),
137
+ /* @__PURE__ */ h("span", {
138
+ className: "sr-only",
139
+ role: "status",
140
+ "aria-live": "polite",
141
+ "aria-atomic": "true",
142
+ "data-testid": "assistant-voice-notice-announced",
143
+ children: t
144
+ }),
145
+ r === void 0 ? null : /* @__PURE__ */ h("span", {
146
+ className: "sr-only",
147
+ role: "status",
148
+ "aria-live": "polite",
149
+ "aria-atomic": "true",
150
+ "data-testid": "assistant-voice-started-cue-announced",
151
+ children: r
152
+ })
153
+ ] }), O = "flex h-11 shrink-0 items-center justify-center gap-1.5 rounded-full border px-4 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-focus-ring)] disabled:cursor-default disabled:opacity-50 sm:h-10", k = `${O} border-border-default bg-bg-elevated text-text-primary hover:bg-bg-sunken`, A = (t) => {
154
+ let n = e(), { muted: r, stage: a, hold: o, onAttachFiles: s, endRef: c, onEnd: d, onInterrupt: f, onToggleMute: p } = t, m = a === "speaking" && !r, _ = u(null), v = u(!1);
155
+ return l(() => {
156
+ !m && v.current && (v.current = !1, _.current?.focus());
157
+ }, [m]), /* @__PURE__ */ g("div", {
158
+ className: "flex flex-wrap items-center gap-2 px-1.5 pb-1.5 pt-1",
159
+ "data-testid": "assistant-voice-page-controls",
160
+ children: [
161
+ /* @__PURE__ */ h("button", {
162
+ ref: _,
163
+ type: "button",
164
+ onClick: p,
165
+ disabled: t.muteDisabled,
166
+ "aria-pressed": r,
167
+ className: k,
168
+ "data-testid": "assistant-voice-mute",
169
+ children: r ? n("window.unmute", "Unmute") : n("window.mute", "Mute")
170
+ }),
171
+ m && f ? /* @__PURE__ */ h("button", {
172
+ type: "button",
173
+ onClick: () => {
174
+ f(), _.current?.focus();
175
+ },
176
+ onFocus: () => {
177
+ v.current = !0;
178
+ },
179
+ onBlur: () => {
180
+ v.current = !1;
181
+ },
182
+ className: k,
183
+ "data-testid": "assistant-voice-interrupt",
184
+ children: n("voiceDock.interrupt", "Interrupt")
185
+ }) : null,
186
+ o ? /* @__PURE__ */ h("button", {
187
+ type: "button",
188
+ onClick: o.onPress,
189
+ className: o.holding ? `${O} border-transparent bg-action-primary-bg text-action-primary-text hover:bg-action-primary-bg-hover` : k,
190
+ title: o.holding ? n("voiceSession.imDoneHint", "Send what you said now") : n("voiceSession.letMeFinishHint", "Pause sending until you tap “I’m done”"),
191
+ "data-testid": "assistant-voice-hold",
192
+ "data-holding": o.holding ? "true" : "false",
193
+ children: o.holding ? n("voiceSession.imDone", "I’m done") : n("voiceSession.letMeFinish", "Let me finish")
194
+ }) : null,
195
+ s ? /* @__PURE__ */ h(i, {
196
+ onFiles: s,
197
+ onPickerOpen: t.onPickerOpen,
198
+ canAddMore: t.canAttachMore,
199
+ disabled: t.attachmentsLocked,
200
+ compact: !0,
201
+ capMenuHeight: !0
202
+ }) : null,
203
+ /* @__PURE__ */ h("span", { className: "min-w-0 flex-1" }),
204
+ /* @__PURE__ */ h("button", {
205
+ ref: c,
206
+ type: "button",
207
+ onClick: d,
208
+ className: `${O} basis-full border-transparent bg-text-primary text-bg-elevated hover:opacity-90 sm:basis-auto`,
209
+ title: n("voiceSession.end", "End the voice conversation"),
210
+ "data-testid": "assistant-voice-end",
211
+ children: n("voiceDock.end", "End voice chat")
212
+ })
213
+ ]
214
+ });
215
+ }, j = (r) => {
216
+ let i = e(), { rootRef: l, stage: u, muted: d, attachments: f, preparingAttachments: p, attachmentsLocked: m } = r, y = _(u, d), b = w(r), S = T();
217
+ E(b.title);
218
+ let C = f.length > 0 || p > 0;
219
+ return /* @__PURE__ */ g("div", {
220
+ ref: l,
221
+ role: "region",
222
+ "aria-label": i("voiceSession.title", "Voice conversation"),
223
+ className: `relative flex-shrink-0 px-3 pt-1.5 ${t}`,
224
+ "data-testid": "assistant-voice-session",
225
+ "data-presentation": "page",
226
+ [n]: "",
227
+ children: [
228
+ /* @__PURE__ */ h(D, { ...r }),
229
+ /* @__PURE__ */ g("div", {
230
+ className: `flex flex-col gap-1 rounded-3xl border bg-bg-elevated transition-colors ${v[y]}`,
231
+ "data-testid": "assistant-voice-page-bar",
232
+ "data-state": u,
233
+ "data-tone": y,
234
+ children: [
235
+ C ? /* @__PURE__ */ h("div", {
236
+ className: "px-3 pt-3",
237
+ "data-testid": "assistant-voice-attachments",
238
+ children: /* @__PURE__ */ h(a, {
239
+ attachments: f,
240
+ onRemove: r.onRemoveAttachment ?? (() => void 0),
241
+ onRetry: r.onRetryAttachment ?? (() => void 0),
242
+ preparingCount: p,
243
+ disabled: m
244
+ })
245
+ }) : null,
246
+ /* @__PURE__ */ g("div", {
247
+ className: "flex items-center gap-3 px-3 pt-3",
248
+ children: [
249
+ /* @__PURE__ */ h(x, {
250
+ tone: y,
251
+ level: r.level
252
+ }),
253
+ /* @__PURE__ */ g("div", {
254
+ className: "min-w-0 flex-1",
255
+ children: [/* @__PURE__ */ h("p", {
256
+ className: "text-base font-semibold text-text-primary",
257
+ "data-testid": "assistant-voice-title",
258
+ children: b.title
259
+ }), /* @__PURE__ */ h("p", {
260
+ className: `line-clamp-2 text-sm ${r.heard ? "text-text-primary" : "text-text-secondary"}`,
261
+ "data-testid": r.heard ? "assistant-voice-heard" : "assistant-voice-caption-line",
262
+ children: b.caption
263
+ })]
264
+ }),
265
+ /* @__PURE__ */ h("span", {
266
+ className: "shrink-0 self-start text-xs tabular-nums text-text-secondary",
267
+ "aria-hidden": "true",
268
+ "data-testid": "assistant-voice-time",
269
+ children: o(S)
270
+ })
271
+ ]
272
+ }),
273
+ /* @__PURE__ */ h(c, {
274
+ status: r.status,
275
+ suffix: r.statusSuffix,
276
+ rotating: r.rotateStatus,
277
+ className: "sr-only"
278
+ }),
279
+ /* @__PURE__ */ h(A, { ...r })
280
+ ]
281
+ }),
282
+ r.privacyNotice ? /* @__PURE__ */ h(s, {
283
+ view: "mini",
284
+ onContinue: r.privacyNotice.accept,
285
+ onNotNow: r.privacyNotice.decline
286
+ }) : null
287
+ ]
288
+ });
289
+ };
290
+ export { j as AssistantPageVoiceBar };
@@ -24,6 +24,8 @@ interface Props {
24
24
  * app configured the stream).
25
25
  */
26
26
  privacyNotice?: HandsFreePrivacyNoticeActions | null;
27
+ /** ★ BOFF-13461: speaking over the assistant cuts in (hands-free interrupt is running). */
28
+ bargeIn?: boolean;
27
29
  /** The assistant's last reply, captioned while it is spoken. */
28
30
  spoken: string | null;
29
31
  onToggleMute: () => void;
@@ -125,8 +127,16 @@ interface Props {
125
127
  * ★ HANDOFF: when the control ends, the session was handed to the full
126
128
  * assistant, and it keeps going as the SAME instance: a `compact` view becomes
127
129
  * the `panel` view, and any other view stays what it was. Nothing remounts.
130
+ * - ★ BOFF-13461 `page`: the assistant laid out as a page (`/assistant`). The
131
+ * session is a bar in the page's column, in the message box's place, and the
132
+ * conversation is the page's own thread (the chat area shows the spoken turns
133
+ * there, as a chat app does). No strip, no stage, no transcript drawer and no
134
+ * stepper: the thread is the transcript. Every rule of the session (states,
135
+ * Escape, focus, notices, hold, mute, interrupt, attachments) is the same.
128
136
  */
129
- view?: VoiceView | 'compact';
137
+ view?: VoiceView | 'compact' | 'page';
138
+ /** ★ BOFF-13461: with `view="page"`, the element the bar is drawn in (the chat area's slot). */
139
+ pageSlot?: HTMLElement | null;
130
140
  /**
131
141
  * ★ BOFF-10180 (N3, compact presentation): "Started a voice conversation. Your
132
142
  * chat is in History." — said when this session moved into a conversation of