@saar-ai/web-widget 0.11.0 → 0.12.0

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.
@@ -6672,20 +6672,18 @@ function DockFloat({ turn, suppressed, ducked, agentName, youLabel, label, dismi
6672
6672
  });
6673
6673
  }
6674
6674
  //#endregion
6675
- //#region src/dock/dock-row.tsx
6675
+ //#region src/handoff-initials.ts
6676
6676
  /**
6677
- * §5.2's gesture split, from one pointer event.
6677
+ * The operator's initials — SHARED chrome, not the dock's.
6678
+ *
6679
+ * Moved out of `dock/dock-row.tsx` for docs/CONCIERGE_GENERATIONS.md §4's
6680
+ * surfaces row: the dock draws them in its handoff disc and the widget draws
6681
+ * them in the launcher's face, and two renderers computing initials two ways
6682
+ * would let the same operator read as `AR` in one and `A` in the other.
6683
+ * `dock-row.tsx` re-exports it, so every existing import still resolves.
6684
+ *
6685
+ * Everything below is the original, unchanged.
6678
6686
  *
6679
- * A thumb HOLDS and a desktop pointer TOGGLES, and `pen` is a desktop pointer
6680
- * for this purpose: it is aimed, so a press with it is a click. Written once
6681
- * rather than at each of the three handlers that need it — they have to agree,
6682
- * and a `pointercancel` that classified itself differently from the
6683
- * `pointerdown` it cancels would leave the microphone open.
6684
- */
6685
- function micSourceOf(event) {
6686
- return event.pointerType === "touch" ? "touch" : "pointer";
6687
- }
6688
- /**
6689
6687
  * The INITIALS a handoff disc draws for `name` — one or two letters, or `''`
6690
6688
  * when there is no name to derive them from (DOCK_SPEC §2).
6691
6689
  *
@@ -6710,6 +6708,20 @@ function micSourceOf(event) {
6710
6708
  function handoffInitials(name) {
6711
6709
  return (name ?? "").trim().split(/\s+/).filter(Boolean).slice(0, 2).map((word) => Array.from(word)[0] ?? "").join("").toUpperCase();
6712
6710
  }
6711
+ //#endregion
6712
+ //#region src/dock/dock-row.tsx
6713
+ /**
6714
+ * §5.2's gesture split, from one pointer event.
6715
+ *
6716
+ * A thumb HOLDS and a desktop pointer TOGGLES, and `pen` is a desktop pointer
6717
+ * for this purpose: it is aimed, so a press with it is a click. Written once
6718
+ * rather than at each of the three handlers that need it — they have to agree,
6719
+ * and a `pointercancel` that classified itself differently from the
6720
+ * `pointerdown` it cancels would leave the microphone open.
6721
+ */
6722
+ function micSourceOf(event) {
6723
+ return event.pointerType === "touch" ? "touch" : "pointer";
6724
+ }
6713
6725
  /**
6714
6726
  * The tenant's mark, at whatever size the row (32 px) or the pill (28 px)
6715
6727
  * asks for — or, while a PERSON holds the conversation, that person's disc.
@@ -10018,6 +10030,20 @@ var Send = createLucideIcon("send", [["path", {
10018
10030
  * This source code is licensed under the ISC license.
10019
10031
  * See the LICENSE file in the root directory of this source tree.
10020
10032
  */
10033
+ var Square = createLucideIcon("square", [["rect", {
10034
+ width: "18",
10035
+ height: "18",
10036
+ x: "3",
10037
+ y: "3",
10038
+ rx: "2",
10039
+ key: "afitv7"
10040
+ }]]);
10041
+ /**
10042
+ * @license lucide-react v1.25.0 - ISC
10043
+ *
10044
+ * This source code is licensed under the ISC license.
10045
+ * See the LICENSE file in the root directory of this source tree.
10046
+ */
10021
10047
  var X = createLucideIcon("x", [["path", {
10022
10048
  d: "M18 6 6 18",
10023
10049
  key: "1bl5f8"
@@ -10142,7 +10168,15 @@ function panelClasses(position) {
10142
10168
  }
10143
10169
  //#endregion
10144
10170
  //#region src/widget/concierge-launcher.tsx
10145
- function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChange, onOpen, hidden, id, testId, avatar = "orb" }) {
10171
+ /** Nothing to say — what a launcher rendered without a `spec` draws. */
10172
+ var QUIET = {
10173
+ busy: false,
10174
+ dimmed: false,
10175
+ disabled: false,
10176
+ badge: false,
10177
+ initials: false
10178
+ };
10179
+ function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChange, onOpen, hidden, id, testId, avatar = "orb", spec = QUIET, initials = "" }) {
10146
10180
  const rootRef = useRef(null);
10147
10181
  /** Pixel offset while a drag is in flight; `null` when it is not. */
10148
10182
  const [drag, setDrag] = useState(null);
@@ -10232,7 +10266,7 @@ function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChan
10232
10266
  "data-testid": testId,
10233
10267
  "data-position": position,
10234
10268
  "aria-hidden": hidden,
10235
- className: cn("fixed z-50 flex items-center gap-1 rounded-full border border-white/40 bg-[var(--widget-card)] py-1.5 pe-4 ps-2 shadow-[0_12px_32px_-12px_color-mix(in_oklab,var(--brand-plum)_35%,transparent)] backdrop-blur-xl", positionClasses(position), dragging ? "cursor-grabbing" : "transition-[opacity,scale] duration-300 ease-out", hidden ? "pointer-events-none scale-75 opacity-0" : "pointer-events-auto opacity-100"),
10269
+ className: cn("fixed z-50 flex items-center gap-1 rounded-full border border-white/40 bg-[var(--widget-card)] py-1.5 pe-4 ps-2 shadow-[0_12px_32px_-12px_color-mix(in_oklab,var(--brand-plum)_35%,transparent)] backdrop-blur-xl", positionClasses(position), dragging ? "cursor-grabbing" : "transition-[opacity,scale] duration-300 ease-out", hidden ? "pointer-events-none scale-75 opacity-0" : "pointer-events-auto opacity-100", !hidden && spec.dimmed ? "opacity-60" : null, spec.disabled ? "cursor-default opacity-70" : null),
10236
10270
  style: drag ? { transform: `translate(${drag.dx}px, ${drag.dy}px)` } : void 0,
10237
10271
  children: [onPositionChange ? /* @__PURE__ */ jsx("button", {
10238
10272
  type: "button",
@@ -10253,25 +10287,43 @@ function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChan
10253
10287
  }) : null, /* @__PURE__ */ jsxs("button", {
10254
10288
  type: "button",
10255
10289
  "aria-label": label === void 0 ? srLabel : void 0,
10256
- tabIndex: hidden ? -1 : 0,
10290
+ tabIndex: hidden || spec.disabled ? -1 : 0,
10291
+ disabled: spec.disabled,
10292
+ ...spec.busy ? { "aria-busy": true } : {},
10293
+ "data-launcher-state": spec.disabled ? "offline" : spec.busy ? "busy" : spec.dimmed ? "ducked" : void 0,
10257
10294
  onClick: () => {
10295
+ if (spec.disabled) return;
10258
10296
  setTightenKey((k) => k + 1);
10259
10297
  onOpen();
10260
10298
  },
10261
10299
  "data-testid": testId ? `${testId}-open` : void 0,
10262
10300
  className: "flex items-center gap-2.5 rounded-full focus-visible:ring-brand-plum/30 focus-visible:ring-2 focus-visible:outline-none",
10263
- children: [/* @__PURE__ */ jsx("span", {
10301
+ children: [/* @__PURE__ */ jsxs("span", {
10264
10302
  "aria-hidden": true,
10265
10303
  className: "relative block size-12 shrink-0",
10266
- children: /* @__PURE__ */ jsx("span", {
10267
- className: "absolute start-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 scale-[0.75] rtl:translate-x-1/2",
10268
- children: /* @__PURE__ */ jsx(AvatarFace, {
10269
- avatar,
10270
- state: "idle",
10271
- size: "sm",
10272
- tightenKey
10273
- })
10274
- })
10304
+ children: [
10305
+ spec.initials && initials !== "" ? /* @__PURE__ */ jsx("span", {
10306
+ "data-testid": "widget-launcher-initials",
10307
+ className: "absolute start-1/2 top-1/2 flex size-9 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-[var(--widget-accent)] text-[13px] font-semibold text-[var(--widget-accent-foreground)] rtl:translate-x-1/2",
10308
+ children: initials
10309
+ }) : /* @__PURE__ */ jsx("span", {
10310
+ className: "absolute start-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 scale-[0.75] rtl:translate-x-1/2",
10311
+ children: /* @__PURE__ */ jsx(AvatarFace, {
10312
+ avatar,
10313
+ state: "idle",
10314
+ size: "sm",
10315
+ tightenKey
10316
+ })
10317
+ }),
10318
+ spec.busy ? /* @__PURE__ */ jsx("span", {
10319
+ "data-testid": "widget-launcher-busy",
10320
+ className: "pointer-events-none absolute inset-0 animate-spin rounded-full border-2 border-transparent border-t-[var(--widget-accent)] motion-reduce:animate-none"
10321
+ }) : null,
10322
+ spec.badge ? /* @__PURE__ */ jsx("span", {
10323
+ "data-testid": "widget-launcher-badge",
10324
+ className: "absolute end-0 top-0 size-3 rounded-full bg-[var(--widget-accent)] ring-2 ring-[var(--widget-card)]"
10325
+ }) : null
10326
+ ]
10275
10327
  }), label === void 0 ? null : /* @__PURE__ */ jsx("span", {
10276
10328
  dir: "auto",
10277
10329
  className: "max-w-[14rem] truncate text-sm font-medium text-[var(--widget-foreground)]",
@@ -10612,7 +10664,7 @@ function voiceStatePillDotColor(pillState) {
10612
10664
  }
10613
10665
  /** How long the opening flourish runs. Matches `.widget-portal`'s own duration. */
10614
10666
  var PORTAL_MS = 720;
10615
- function ConciergeShell({ open, onOpenChange, state, messageArrived = false, avatar = "orb", labels, children, badge, draft, onDraftChange, onSubmit, composerDisabled = false, voice, announcement, skin, skinStyle, idPrefix = "concierge", scrollKey, composerLeading, testIds, position = DEFAULT_CONCIERGE_POSITION, onPositionChange, attribution }) {
10667
+ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, launcher, launcherInitials, typing = false, operatorName, avatar = "orb", labels, children, badge, draft, onDraftChange, onSubmit, composerDisabled = false, voice, announcement, skin, skinStyle, idPrefix = "concierge", scrollKey, composerLeading, testIds, position = DEFAULT_CONCIERGE_POSITION, onPositionChange, attribution }) {
10616
10668
  const triggerId = `${idPrefix}-trigger`;
10617
10669
  const inputId = `${idPrefix}-input`;
10618
10670
  const [portalActive, setPortalActive] = useState(false);
@@ -10820,7 +10872,9 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, ava
10820
10872
  ...onPositionChange !== void 0 ? { onPositionChange } : {},
10821
10873
  onOpen: () => onOpenChange(true),
10822
10874
  hidden: open,
10823
- avatar
10875
+ avatar,
10876
+ ...launcher !== void 0 ? { spec: launcher } : {},
10877
+ ...launcherInitials !== void 0 ? { initials: launcherInitials } : {}
10824
10878
  }),
10825
10879
  /* @__PURE__ */ jsx("div", {
10826
10880
  "aria-hidden": true,
@@ -10900,17 +10954,40 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, ava
10900
10954
  }), /* @__PURE__ */ jsx("span", { children: voiceStatePillLabel(voicePillState, voice?.labels) })] }) : null
10901
10955
  })]
10902
10956
  }),
10903
- badge == null ? null : /* @__PURE__ */ jsx("div", {
10957
+ badge == null && operatorName === void 0 ? null : /* @__PURE__ */ jsxs("div", {
10904
10958
  className: "z-10 mt-[104px] w-[68%] shrink-0 text-center",
10905
- children: badge
10959
+ children: [operatorName === void 0 ? null : /* @__PURE__ */ jsx("p", {
10960
+ "data-testid": "widget-operator-name",
10961
+ dir: "auto",
10962
+ className: "text-[11px] font-medium text-[var(--widget-foreground-muted)]",
10963
+ children: operatorName
10964
+ }), badge]
10906
10965
  }),
10907
10966
  /* @__PURE__ */ jsx("div", {
10908
10967
  ref: transcriptRef,
10909
10968
  className: "no-scrollbar w-full min-h-0 flex-1 overflow-y-auto",
10910
10969
  style: badge == null ? TRANSCRIPT_EDGE_FADE : TRANSCRIPT_EDGE_FADE_WITH_BADGE,
10911
- children: /* @__PURE__ */ jsx("div", {
10970
+ children: /* @__PURE__ */ jsxs("div", {
10912
10971
  ref: transcriptContentRef,
10913
- children
10972
+ children: [children, typing ? /* @__PURE__ */ jsxs("p", {
10973
+ "data-testid": "widget-typing-indicator",
10974
+ className: "flex items-center gap-1 px-1 py-1 text-[var(--widget-foreground-muted)]",
10975
+ children: [/* @__PURE__ */ jsx("span", {
10976
+ className: "sr-only",
10977
+ children: defaultWidgetMessages.typing
10978
+ }), [
10979
+ 0,
10980
+ 1,
10981
+ 2
10982
+ ].map((i) => /* @__PURE__ */ jsx("span", {
10983
+ "aria-hidden": "true",
10984
+ className: "h-1.5 w-1.5 animate-bounce rounded-full bg-current motion-reduce:animate-none",
10985
+ style: {
10986
+ animationDelay: `${i * 140}ms`,
10987
+ animationDuration: "1s"
10988
+ }
10989
+ }, i))]
10990
+ }) : null]
10914
10991
  })
10915
10992
  }),
10916
10993
  /* @__PURE__ */ jsx("div", {
@@ -10957,35 +11034,54 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, ava
10957
11034
  })]
10958
11035
  }), voice ? /* @__PURE__ */ jsxs("div", {
10959
11036
  className: "mt-1 flex items-center gap-3",
10960
- children: [/* @__PURE__ */ jsx("button", {
10961
- type: "button",
10962
- onClick: connecting ? void 0 : inCall ? voice.onToggleMute ?? voice.onStart : voice.onStart,
10963
- disabled: micUnusable || connecting,
10964
- "data-testid": testIds?.mic,
10965
- title: micLabel,
10966
- "aria-label": micLabel,
10967
- ...connecting ? { "aria-busy": true } : {},
10968
- ...inCall && !connecting ? { "aria-pressed": voice.muted ?? false } : {},
10969
- className: cn("from-brand-plum to-brand-rose text-[var(--widget-accent-foreground)] flex size-12 shrink-0 items-center justify-center rounded-full bg-gradient-to-br transition-[transform,opacity]", micUnusable ? "cursor-not-allowed opacity-40" : connecting ? "cursor-wait" : cn("hover:scale-105 focus-visible:ring-2 focus-visible:ring-white/50 focus-visible:outline-none", "shadow-[0_0_0_1px_color-mix(in_oklab,var(--brand-plum)_18%,transparent),0_4px_14px_-2px_color-mix(in_oklab,var(--brand-plum)_45%,transparent),0_0_22px_-4px_color-mix(in_oklab,var(--brand-rose)_40%,transparent)]", "hover:shadow-[0_0_0_1px_color-mix(in_oklab,var(--brand-plum)_26%,transparent),0_6px_18px_-2px_color-mix(in_oklab,var(--brand-plum)_60%,transparent),0_0_30px_-4px_color-mix(in_oklab,var(--brand-rose)_55%,transparent)]"), inCall && !connecting && voice.muted !== true && "ring-brand-rose/50 ring-4"),
10970
- children: connecting ? /* @__PURE__ */ jsx("span", {
10971
- "aria-hidden": "true",
10972
- "data-testid": "widget-mic-spinner",
10973
- className: "flex items-center justify-center",
10974
- children: /* @__PURE__ */ jsx(MorphingLoader, {
10975
- size: "md",
10976
- variant: "light",
10977
- label: connectingLabel
10978
- })
10979
- }) : inCall && voice.muted === true ? /* @__PURE__ */ jsx(MicOff, { className: "size-5" }) : /* @__PURE__ */ jsx(Mic, { className: "size-5" })
10980
- }), inCall && voice.onEnd !== void 0 ? /* @__PURE__ */ jsx("button", {
10981
- type: "button",
10982
- onClick: voice.onEnd,
10983
- "data-testid": testIds?.endCall,
10984
- title: voice.labels.end ?? "",
10985
- "aria-label": voice.labels.end ?? "",
10986
- className: cn("bg-destructive/10 text-destructive hover:bg-destructive/20 flex size-10 shrink-0 items-center justify-center rounded-full transition-colors", "focus-visible:ring-destructive/30 focus-visible:ring-2 focus-visible:outline-none"),
10987
- children: /* @__PURE__ */ jsx(PhoneOff, { className: "size-4" })
10988
- }) : null]
11037
+ children: [
11038
+ /* @__PURE__ */ jsx("button", {
11039
+ type: "button",
11040
+ onClick: connecting ? void 0 : inCall ? voice.onToggleMute ?? voice.onStart : voice.onStart,
11041
+ disabled: micUnusable || connecting,
11042
+ "data-testid": testIds?.mic,
11043
+ title: micLabel,
11044
+ "aria-label": micLabel,
11045
+ ...connecting ? { "aria-busy": true } : {},
11046
+ ...inCall && !connecting ? { "aria-pressed": voice.muted ?? false } : {},
11047
+ className: cn("from-brand-plum to-brand-rose text-[var(--widget-accent-foreground)] flex size-12 shrink-0 items-center justify-center rounded-full bg-gradient-to-br transition-[transform,opacity]", micUnusable ? "cursor-not-allowed opacity-40" : connecting ? "cursor-wait" : cn("hover:scale-105 focus-visible:ring-2 focus-visible:ring-white/50 focus-visible:outline-none", "shadow-[0_0_0_1px_color-mix(in_oklab,var(--brand-plum)_18%,transparent),0_4px_14px_-2px_color-mix(in_oklab,var(--brand-plum)_45%,transparent),0_0_22px_-4px_color-mix(in_oklab,var(--brand-rose)_40%,transparent)]", "hover:shadow-[0_0_0_1px_color-mix(in_oklab,var(--brand-plum)_26%,transparent),0_6px_18px_-2px_color-mix(in_oklab,var(--brand-plum)_60%,transparent),0_0_30px_-4px_color-mix(in_oklab,var(--brand-rose)_55%,transparent)]"), inCall && !connecting && voice.muted !== true && "ring-brand-rose/50 ring-4"),
11048
+ children: connecting ? /* @__PURE__ */ jsx("span", {
11049
+ "aria-hidden": "true",
11050
+ "data-testid": "widget-mic-spinner",
11051
+ className: "flex items-center justify-center",
11052
+ children: /* @__PURE__ */ jsx(MorphingLoader, {
11053
+ size: "md",
11054
+ variant: "light",
11055
+ label: connectingLabel
11056
+ })
11057
+ }) : inCall && voice.muted === true ? /* @__PURE__ */ jsx(MicOff, { className: "size-5" }) : /* @__PURE__ */ jsx(Mic, { className: "size-5" })
11058
+ }),
11059
+ inCall && voice.agentSpeaking === true && voice.onInterrupt !== void 0 ? /* @__PURE__ */ jsx("button", {
11060
+ type: "button",
11061
+ onClick: () => voice.onInterrupt?.("tap"),
11062
+ "data-testid": "widget-interrupt",
11063
+ title: voice.labels.interrupt ?? "",
11064
+ "aria-label": voice.labels.interrupt ?? "",
11065
+ className: cn("flex size-10 shrink-0 items-center justify-center rounded-full bg-[var(--widget-chip)] text-[var(--widget-foreground)] transition-colors", "hover:bg-[var(--widget-bubble)] focus-visible:ring-2 focus-visible:ring-[var(--widget-accent-ring)] focus-visible:outline-none"),
11066
+ children: /* @__PURE__ */ jsx(Square, { className: "size-4" })
11067
+ }) : null,
11068
+ voice.phase === "blocked" && voice.onFixPermission !== void 0 ? /* @__PURE__ */ jsx("button", {
11069
+ type: "button",
11070
+ onClick: voice.onFixPermission,
11071
+ "data-testid": "widget-fix-permission",
11072
+ className: cn("shrink-0 rounded-full bg-[var(--widget-chip)] px-3 py-2 text-xs font-medium text-[var(--widget-foreground)] transition-colors", "hover:bg-[var(--widget-bubble)] focus-visible:ring-2 focus-visible:ring-[var(--widget-accent-ring)] focus-visible:outline-none"),
11073
+ children: voice.labels.fixBrowser ?? defaultWidgetMessages.dock_fix_browser
11074
+ }) : null,
11075
+ inCall && voice.onEnd !== void 0 ? /* @__PURE__ */ jsx("button", {
11076
+ type: "button",
11077
+ onClick: voice.onEnd,
11078
+ "data-testid": testIds?.endCall,
11079
+ title: voice.labels.end ?? "",
11080
+ "aria-label": voice.labels.end ?? "",
11081
+ className: cn("bg-destructive/10 text-destructive hover:bg-destructive/20 flex size-10 shrink-0 items-center justify-center rounded-full transition-colors", "focus-visible:ring-destructive/30 focus-visible:ring-2 focus-visible:outline-none"),
11082
+ children: /* @__PURE__ */ jsx(PhoneOff, { className: "size-4" })
11083
+ }) : null
11084
+ ]
10989
11085
  }) : null]
10990
11086
  })
10991
11087
  })
@@ -11031,6 +11127,244 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, ava
11031
11127
  });
11032
11128
  }
11033
11129
  //#endregion
11130
+ //#region src/widget/widget-view.ts
11131
+ /** Every launcher field off — the shape most states return. */
11132
+ var QUIET_LAUNCHER = {
11133
+ busy: false,
11134
+ dimmed: false,
11135
+ disabled: false,
11136
+ badge: false,
11137
+ initials: false
11138
+ };
11139
+ /**
11140
+ * The widget's presentation of a state the shared machine already decided.
11141
+ *
11142
+ * @param snapshot the state and the shared facts — see {@link ConciergeSnapshot}
11143
+ * @param input the session, read for CONTENT only (a partial transcript, an
11144
+ * operator's line, the host's error text) — never to decide the state
11145
+ */
11146
+ function deriveWidgetView(snapshot, input) {
11147
+ const { state } = snapshot;
11148
+ const shared = {
11149
+ state,
11150
+ handoff: snapshot.handoff,
11151
+ callActive: snapshot.callActive,
11152
+ shelfCount: snapshot.shelfCount
11153
+ };
11154
+ const text = (value) => value !== void 0 && value !== "" ? {
11155
+ kind: "text",
11156
+ text: value
11157
+ } : null;
11158
+ switch (state) {
11159
+ case "dormant": return {
11160
+ ...shared,
11161
+ avatar: "idle",
11162
+ launcher: QUIET_LAUNCHER,
11163
+ announce: false,
11164
+ typing: false,
11165
+ interrupt: false,
11166
+ panel: "as-is",
11167
+ status: null,
11168
+ composerDisabled: false
11169
+ };
11170
+ case "connecting": return {
11171
+ ...shared,
11172
+ avatar: "thinking",
11173
+ launcher: {
11174
+ ...QUIET_LAUNCHER,
11175
+ busy: true
11176
+ },
11177
+ announce: false,
11178
+ typing: false,
11179
+ interrupt: false,
11180
+ panel: "as-is",
11181
+ status: {
11182
+ kind: "message",
11183
+ key: "dock_connecting"
11184
+ },
11185
+ composerDisabled: false
11186
+ };
11187
+ case "listening": return {
11188
+ ...shared,
11189
+ avatar: "listening",
11190
+ launcher: QUIET_LAUNCHER,
11191
+ announce: false,
11192
+ typing: false,
11193
+ interrupt: false,
11194
+ panel: "as-is",
11195
+ status: text(input.partialTranscript) ?? {
11196
+ kind: "message",
11197
+ key: "dock_listening"
11198
+ },
11199
+ composerDisabled: false
11200
+ };
11201
+ case "thinking": return {
11202
+ ...shared,
11203
+ avatar: "thinking",
11204
+ launcher: QUIET_LAUNCHER,
11205
+ announce: false,
11206
+ typing: false,
11207
+ interrupt: false,
11208
+ panel: "as-is",
11209
+ status: text(input.preamble) ?? {
11210
+ kind: "message",
11211
+ key: "dock_thinking"
11212
+ },
11213
+ composerDisabled: false
11214
+ };
11215
+ case "speaking": return {
11216
+ ...shared,
11217
+ avatar: "speaking",
11218
+ launcher: QUIET_LAUNCHER,
11219
+ announce: false,
11220
+ typing: false,
11221
+ interrupt: true,
11222
+ panel: "as-is",
11223
+ status: text(input.clause) ?? {
11224
+ kind: "message",
11225
+ key: "dock_thinking"
11226
+ },
11227
+ composerDisabled: false
11228
+ };
11229
+ case "ducked": return {
11230
+ ...shared,
11231
+ avatar: "idle",
11232
+ launcher: {
11233
+ ...QUIET_LAUNCHER,
11234
+ dimmed: true
11235
+ },
11236
+ announce: false,
11237
+ typing: false,
11238
+ interrupt: false,
11239
+ panel: "as-is",
11240
+ status: {
11241
+ kind: "message",
11242
+ key: "dock_ducked"
11243
+ },
11244
+ composerDisabled: false
11245
+ };
11246
+ case "reconnecting": return {
11247
+ ...shared,
11248
+ avatar: "idle",
11249
+ launcher: {
11250
+ ...QUIET_LAUNCHER,
11251
+ badge: true
11252
+ },
11253
+ announce: true,
11254
+ typing: false,
11255
+ interrupt: false,
11256
+ panel: "as-is",
11257
+ status: {
11258
+ kind: "message",
11259
+ key: input.roomDropped ? "dock_still_here_resume" : "dock_still_here"
11260
+ },
11261
+ composerDisabled: false
11262
+ };
11263
+ case "muted": return {
11264
+ ...shared,
11265
+ avatar: "idle",
11266
+ launcher: QUIET_LAUNCHER,
11267
+ announce: true,
11268
+ typing: false,
11269
+ interrupt: false,
11270
+ panel: "as-is",
11271
+ status: {
11272
+ kind: "message",
11273
+ key: "dock_muted"
11274
+ },
11275
+ composerDisabled: false
11276
+ };
11277
+ case "mic_blocked": return {
11278
+ ...shared,
11279
+ avatar: "idle",
11280
+ launcher: QUIET_LAUNCHER,
11281
+ announce: true,
11282
+ typing: false,
11283
+ interrupt: false,
11284
+ panel: "as-is",
11285
+ status: {
11286
+ kind: "message",
11287
+ key: "dock_mic_blocked"
11288
+ },
11289
+ composerDisabled: false
11290
+ };
11291
+ case "typing": return {
11292
+ ...shared,
11293
+ avatar: "idle",
11294
+ launcher: QUIET_LAUNCHER,
11295
+ announce: false,
11296
+ typing: input.composing,
11297
+ interrupt: false,
11298
+ panel: "as-is",
11299
+ status: null,
11300
+ composerDisabled: false
11301
+ };
11302
+ case "human": return {
11303
+ ...shared,
11304
+ avatar: "idle",
11305
+ launcher: {
11306
+ ...QUIET_LAUNCHER,
11307
+ initials: true
11308
+ },
11309
+ announce: true,
11310
+ typing: input.composing,
11311
+ interrupt: false,
11312
+ panel: "as-is",
11313
+ status: text(input.operatorLine) ?? {
11314
+ kind: "message",
11315
+ key: "escalated_banner"
11316
+ },
11317
+ composerDisabled: false
11318
+ };
11319
+ case "offline": return {
11320
+ ...shared,
11321
+ avatar: "idle",
11322
+ launcher: {
11323
+ ...QUIET_LAUNCHER,
11324
+ disabled: true
11325
+ },
11326
+ announce: true,
11327
+ typing: false,
11328
+ interrupt: false,
11329
+ panel: "as-is",
11330
+ status: text(input.offlineMessage),
11331
+ composerDisabled: true
11332
+ };
11333
+ case "error": return {
11334
+ ...shared,
11335
+ avatar: "idle",
11336
+ launcher: QUIET_LAUNCHER,
11337
+ announce: true,
11338
+ typing: false,
11339
+ interrupt: false,
11340
+ panel: "as-is",
11341
+ status: input.errorSource === "voice" && input.voice.enabled && input.voice.phase === "failed" ? {
11342
+ kind: "message",
11343
+ key: "dock_voice_failed"
11344
+ } : text(input.error),
11345
+ composerDisabled: false
11346
+ };
11347
+ case "cards": return {
11348
+ ...shared,
11349
+ avatar: "idle",
11350
+ launcher: {
11351
+ ...QUIET_LAUNCHER,
11352
+ badge: true
11353
+ },
11354
+ announce: false,
11355
+ typing: false,
11356
+ interrupt: false,
11357
+ panel: "as-is",
11358
+ status: {
11359
+ kind: "message",
11360
+ key: "dock_cards"
11361
+ },
11362
+ composerDisabled: false
11363
+ };
11364
+ }
11365
+ throw new TypeError(`Unknown concierge state: ${JSON.stringify(state)}`);
11366
+ }
11367
+ //#endregion
11034
11368
  //#region src/widget/shell-renderer.tsx
11035
11369
  /**
11036
11370
  * The widget — launcher and panel — as a `ConciergeRenderer`
@@ -11053,7 +11387,7 @@ function positionFor(dock) {
11053
11387
  const align = dock?.layout?.desktopAlign;
11054
11388
  return align === "left" || align === "right" ? `bottom-${align}` : DEFAULT_CONCIERGE_POSITION;
11055
11389
  }
11056
- function ShellRenderer({ state, turns, showMic, callPhase, micOpen, onToggleMic, onEndCall, statusLine, escalated, humanTyping, draft, onDraftChange, submit, attaching, onAttach, attachInput, transcript, extras, messages, skinStyle, avatar, attribution, dock }) {
11390
+ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndCall, statusKind, statusLine, escalated, operatorName, humanTyping, composing, channel, draft, onDraftChange, submit, attaching, onAttach, attachInput, transcript, extras, messages, skinStyle, avatar, attribution, voice: derivedVoice, dock }) {
11057
11391
  const [open, setOpen] = useState(dock?.initialMinimised === false);
11058
11392
  const onReady = dock?.onReady;
11059
11393
  useLayoutEffect(() => {
@@ -11062,14 +11396,106 @@ function ShellRenderer({ state, turns, showMic, callPhase, micOpen, onToggleMic,
11062
11396
  const [position, setPosition] = useState(() => positionFor(dock));
11063
11397
  const draggable = dock?.layout?.draggable !== false;
11064
11398
  const launcherLabel = dock?.copy?.minimisedLabel?.trim();
11399
+ /**
11400
+ * The host's voice bag, merged the same way `DockRenderer` merges it: the
11401
+ * conversation derives the PHASE fields (`agentSpeaking`, `micOpen` …) and
11402
+ * the host supplies the CALLBACKS (`onInterrupt`, `onFixPermission`) on
11403
+ * `dock.voice`. A renderer that read only the derived half would draw a
11404
+ * control the host never gets told about.
11405
+ */
11406
+ const voiceInput = {
11407
+ ...derivedVoice,
11408
+ ...dock?.voice ?? {}
11409
+ };
11065
11410
  const voiceUnavailable = showMic && escalated ? messages.voice_unavailable_escalated : void 0;
11066
11411
  const lastTurn = turns[turns.length - 1];
11412
+ /**
11413
+ * The SAME state machine the dock runs (docs/CONCIERGE_GENERATIONS.md §2:
11414
+ * one state, two presentations). `Dock` builds a `DockStateInput` from its
11415
+ * props and calls `deriveDockState`; this is that, in the widget's terms.
11416
+ *
11417
+ * Two fields the dock reads from its own internals rather than from props,
11418
+ * answered here the widget's way:
11419
+ *
11420
+ * - `engaged` — the dock tracks a row that has been woken. The widget's
11421
+ * equivalent is a panel the shopper opened, or a call that is running.
11422
+ * - `sheetOpen` — the dock's sheet is the widget's panel.
11423
+ *
11424
+ * And two the widget does not have yet: `ducked` and `textIdle` are timers
11425
+ * the dock runs to recede its row. The widget has no row, and §4's answer —
11426
+ * the launcher dims — is a row of its own with its own timer; until that
11427
+ * lands, the widget never ducks, which is visible here rather than hidden
11428
+ * behind a prop that silently reads `false`.
11429
+ */
11430
+ const stateInput = useMemo(() => ({
11431
+ ...idleConciergeInput,
11432
+ engaged: open || callPhase !== "idle",
11433
+ voice: {
11434
+ enabled: voiceInput.enabled === true,
11435
+ phase: voiceInput.phase ?? "idle",
11436
+ micOpen: voiceInput.micOpen === true,
11437
+ micPending: voiceInput.micPending === true,
11438
+ micBlocked: voiceInput.micBlocked === true,
11439
+ agentPresent: voiceInput.agentPresent === true,
11440
+ agentSpeaking: voiceInput.agentSpeaking === true,
11441
+ callerSpeaking: voiceInput.callerSpeaking === true,
11442
+ awaitingAgent: voiceInput.awaitingAgent === true
11443
+ },
11444
+ draft,
11445
+ escalated,
11446
+ canAttach: onAttach !== void 0,
11447
+ canFixPermission: voiceInput.onFixPermission !== void 0,
11448
+ offline: dock?.offline === true,
11449
+ reconnecting: dock?.reconnecting === true,
11450
+ roomDropped: dock?.roomDropped === true,
11451
+ sheetOpen: open,
11452
+ shelfCount: dock?.shelf?.items.length ?? 0,
11453
+ hasTranscript: turns.length > 0,
11454
+ channel,
11455
+ composing,
11456
+ ...operatorName !== void 0 ? { operatorLine: operatorName } : {},
11457
+ ...dock?.copy?.offlineMessage !== void 0 ? { offlineMessage: dock.copy.offlineMessage } : {},
11458
+ ...statusLine !== void 0 && statusLine !== "" ? {
11459
+ error: statusLine,
11460
+ ...statusKind !== void 0 ? { errorSource: statusKind } : {}
11461
+ } : {},
11462
+ ...dock?.partialTranscript !== void 0 ? { partialTranscript: dock.partialTranscript } : {},
11463
+ ...dock?.preamble !== void 0 ? { preamble: dock.preamble } : {},
11464
+ ...dock?.clause !== void 0 ? { clause: dock.clause } : {}
11465
+ }), [
11466
+ open,
11467
+ callPhase,
11468
+ voiceInput,
11469
+ draft,
11470
+ escalated,
11471
+ onAttach,
11472
+ dock,
11473
+ turns.length,
11474
+ channel,
11475
+ composing,
11476
+ operatorName,
11477
+ statusLine,
11478
+ statusKind
11479
+ ]);
11480
+ const view = useMemo(() => deriveWidgetView(deriveConciergeState(stateInput), stateInput), [stateInput]);
11481
+ /**
11482
+ * The status line in the shopper's own language. The view decides WHICH
11483
+ * line, never its words: a `text` status is the host's own string (a
11484
+ * partial transcript, an operator's line, an error) and a `message` status
11485
+ * is a key into the tenant's catalogue. Same split the dock's
11486
+ * `resolveCaption` makes, for the same reason — a renderer that invented
11487
+ * copy would need translating twice.
11488
+ */
11489
+ const statusText = view.status === null ? void 0 : view.status.kind === "text" ? view.status.text : messages[view.status.key] ?? void 0;
11067
11490
  const voice = showMic ? {
11068
11491
  phase: callPhase,
11069
11492
  onStart: onToggleMic,
11070
11493
  ...onEndCall !== void 0 ? { onEnd: onEndCall } : {},
11071
11494
  onToggleMute: onToggleMic,
11072
11495
  muted: !micOpen,
11496
+ agentSpeaking: view.interrupt,
11497
+ ...voiceInput.onInterrupt !== void 0 ? { onInterrupt: voiceInput.onInterrupt } : {},
11498
+ ...voiceInput.onFixPermission !== void 0 ? { onFixPermission: voiceInput.onFixPermission } : {},
11073
11499
  ...voiceUnavailable !== void 0 ? { disabled: true } : {},
11074
11500
  labels: {
11075
11501
  start: messages.mic_start,
@@ -11077,6 +11503,7 @@ function ShellRenderer({ state, turns, showMic, callPhase, micOpen, onToggleMic,
11077
11503
  mute: messages.mic_stop,
11078
11504
  unmute: messages.mic_start,
11079
11505
  connecting: messages.voice_state_connecting,
11506
+ ...messages.dock_fix_browser !== void 0 ? { fixBrowser: messages.dock_fix_browser } : {},
11080
11507
  listening: messages.voice_state_listening,
11081
11508
  thinking: messages.voice_state_thinking,
11082
11509
  speaking: messages.voice_state_speaking,
@@ -11109,16 +11536,21 @@ function ShellRenderer({ state, turns, showMic, callPhase, micOpen, onToggleMic,
11109
11536
  return /* @__PURE__ */ jsxs(ConciergeShell, {
11110
11537
  open,
11111
11538
  onOpenChange: setOpen,
11112
- state,
11539
+ state: view.avatar,
11113
11540
  ...skinStyle !== void 0 ? { skinStyle } : {},
11114
11541
  ...avatar !== void 0 ? { avatar } : {},
11115
11542
  ...attribution !== void 0 ? { attribution } : {},
11543
+ launcher: view.launcher,
11544
+ ...view.handoff && operatorName !== void 0 ? { operatorName } : {},
11545
+ launcherInitials: view.launcher.initials ? handoffInitials(operatorName) : "",
11546
+ typing: view.typing,
11116
11547
  messageArrived: lastTurn?.speaker === "caller",
11117
11548
  idPrefix: "widget",
11118
11549
  scrollKey: turns.length + (humanTyping ? 1 : 0),
11119
11550
  draft,
11120
11551
  onDraftChange,
11121
11552
  onSubmit: submit,
11553
+ composerDisabled: view.composerDisabled,
11122
11554
  position,
11123
11555
  ...draggable ? { onPositionChange: setPosition } : {},
11124
11556
  labels: {
@@ -11132,10 +11564,14 @@ function ShellRenderer({ state, turns, showMic, callPhase, micOpen, onToggleMic,
11132
11564
  },
11133
11565
  ...voice !== void 0 ? { voice } : {},
11134
11566
  composerLeading,
11135
- badge: statusLine === void 0 ? null : /* @__PURE__ */ jsx("p", {
11567
+ badge: statusText === void 0 ? null : /* @__PURE__ */ jsx("p", {
11136
11568
  "data-testid": "widget-status",
11569
+ ...view.announce ? {
11570
+ role: "status",
11571
+ "aria-live": "polite"
11572
+ } : {},
11137
11573
  className: "mt-1 max-w-full rounded-2xl bg-[var(--widget-chip)] px-2.5 py-1 text-center text-[10px] leading-snug font-semibold tracking-wide text-[var(--widget-foreground-muted)]",
11138
- children: statusLine
11574
+ children: statusText
11139
11575
  }),
11140
11576
  testIds: {
11141
11577
  trigger: "voice-widget-launcher",
@@ -18504,4 +18940,4 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
18504
18940
  });
18505
18941
  }
18506
18942
  //#endregion
18507
- export { exchangeCount as $, themeToCss as $t, DockRenderer as A, cn as An, SHEET_PEEK_MAX as At, positionClasses as B, pillAnchor as Bt, readsAsCheckoutIntent as C, DEFAULT_WIDGET_AVATAR as Cn, PILL_MARK as Ct, WidgetMarkdown as D, RopeKnot as Dn, SHEET_EXPANDED_DESKTOP_MAX as Dt, WidgetCardList as E, KNOT_PATH as En, ROW_H as Et, DEFAULT_CONCIERGE_POSITION as F, bottomLen as Ft, SESSION_EVENTS as G, sheetMaxHeightLen as Gt, IDLE_SNAPSHOT as H, readStoredAlign as Ht, alignOf as I, containerAnchor as It, latencyBetween as J, CARD_RADIUS_MAX_PX as Jt, SessionLog as K, snapAlign as Kt, edgeOf as L, geometryVars as Lt, ConciergeShell as M, SHEET_TUCK as Mt, ConciergeLauncher as N, SHORT_VIEWPORT as Nt, parseBlocks as O, BotFace as On, SHEET_EXPANDED_VH as Ot, CONCIERGE_POSITIONS as P, Z_INDEX as Pt, deriveDockView as Q, deriveTheme as Qt, nearestPosition as R, persistAlign as Rt, readsAsCartViewIntent as S, MorphingLoader as Sn, PILL_H as St, WidgetCartSummary as T, isWidgetAvatar as Tn, RADII as Tt, botStateFor as U, readStoredMinimised as Ut, positionForArrow as V, readStored as Vt, SseFrameParser as W, rowWidthLen as Wt, DOCK_STATES as X, SYSTEM_FONT_STACK as Xt, Dock as Y, SHEET_RADIUS_MAX_PX as Yt, deriveDockState as Z, WIDGET_THEME_TOKENS as Zt, useChatSession as _, withAlpha as _n, FLOAT_DUCK_DISMISS_MS as _t, MAX_REPORTED_CART_LINES as a, linearRgbToOklab as an, formatMoney as at, VoiceWidgetWithRenderer as b, resolveWidgetMessages as bn, MARK as bt, deriveCallPhase as c, oklabToHex as cn, CONTROL as ct, resolveCheckoutUrl as d, oklchToHex as dn, DESKTOP_GUTTER as dt, themeToInlineStyle as en, idleDockInput as et, toChatCart as f, oklchToOklab as fn, DESKTOP_WIDTHS as ft, isSameOriginPath as g, srgbToLinear as gn, DRAG_TAP_SLOP_PX as gt, useVoiceSession as h, rotateHue as hn, DRAG_CLICK_WINDOW_MS as ht, ConciergeWidget as i, hexToOklch as in, idleConciergeInput as it, ShellRenderer as j, SHEET_TOP_CLEARANCE as jt, rendererFor as k, labelProps as kn, SHEET_GAP as kt, mergeAddedCartLine as l, oklabToLinearRgb as ln, DESKTOP_BOTTOM as lt, createWidgetVoiceTokenFetcher as m, relativeLuminance as mn, DOCK_MINIMISED_STORAGE_KEY as mt, CART_LINE_VARIANT_ID_SHAPE as n, formatHex as nn, CONCIERGE_STATES as nt, cartLinesFromSnapshot as o, linearToSrgb as on, ACTIVITY_W as ot, ROOM_EVENTS as p, parseHex as pn, DOCK_ALIGN_STORAGE_KEY as pt, formatMs as q, writeStored as qt, ConciergeHost as r, hexToOklab as rn, deriveConciergeState as rt, chooseOptionsAction as s, mixToward as sn, BOTTOM_FLOOR as st, CART_LINE_PLATFORM_VARIANT_ID_SHAPE as t, contrastRatio as tn, latestExchangeStart as tt, resolveAddToCartHandler as u, oklabToOklch as un, DESKTOP_BREAKPOINT as ut, detectPage as v, defaultWidgetMessages as vn, FLOAT_GAP as vt, textDirectionFor as w, WIDGET_AVATARS as wn, PROACTIVE_NUDGE_MS as wt, basketIntentFromTurns as x, widgetMessagesFromCopy as xn, MOBILE_MARGIN as xt, VoiceWidget as y, formatMessage as yn, GLASS_IDLE_MS as yt, panelClasses as z, persistMinimised as zt };
18943
+ export { deriveDockView as $, deriveTheme as $t, DockRenderer as A, labelProps as An, SHEET_GAP as At, panelClasses as B, persistMinimised as Bt, readsAsCheckoutIntent as C, MorphingLoader as Cn, PILL_H as Ct, WidgetMarkdown as D, KNOT_PATH as Dn, ROW_H as Dt, WidgetCardList as E, isWidgetAvatar as En, RADII as Et, CONCIERGE_POSITIONS as F, Z_INDEX as Ft, SseFrameParser as G, rowWidthLen as Gt, positionForArrow as H, readStored as Ht, DEFAULT_CONCIERGE_POSITION as I, bottomLen as It, formatMs as J, writeStored as Jt, SESSION_EVENTS as K, sheetMaxHeightLen as Kt, alignOf as L, containerAnchor as Lt, deriveWidgetView as M, SHEET_TOP_CLEARANCE as Mt, ConciergeShell as N, SHEET_TUCK as Nt, parseBlocks as O, RopeKnot as On, SHEET_EXPANDED_DESKTOP_MAX as Ot, ConciergeLauncher as P, SHORT_VIEWPORT as Pt, deriveDockState as Q, WIDGET_THEME_TOKENS as Qt, edgeOf as R, geometryVars as Rt, readsAsCartViewIntent as S, widgetMessagesFromCopy as Sn, MOBILE_MARGIN as St, WidgetCartSummary as T, WIDGET_AVATARS as Tn, PROACTIVE_NUDGE_MS as Tt, IDLE_SNAPSHOT as U, readStoredAlign as Ut, positionClasses as V, pillAnchor as Vt, botStateFor as W, readStoredMinimised as Wt, Dock as X, SHEET_RADIUS_MAX_PX as Xt, latencyBetween as Y, CARD_RADIUS_MAX_PX as Yt, DOCK_STATES as Z, SYSTEM_FONT_STACK as Zt, useChatSession as _, srgbToLinear as _n, DRAG_TAP_SLOP_PX as _t, MAX_REPORTED_CART_LINES as a, hexToOklch as an, idleConciergeInput as at, VoiceWidgetWithRenderer as b, formatMessage as bn, GLASS_IDLE_MS as bt, deriveCallPhase as c, mixToward as cn, BOTTOM_FLOOR as ct, resolveCheckoutUrl as d, oklabToOklch as dn, DESKTOP_BREAKPOINT as dt, themeToCss as en, exchangeCount as et, toChatCart as f, oklchToHex as fn, DESKTOP_GUTTER as ft, isSameOriginPath as g, rotateHue as gn, DRAG_CLICK_WINDOW_MS as gt, useVoiceSession as h, relativeLuminance as hn, DOCK_MINIMISED_STORAGE_KEY as ht, ConciergeWidget as i, hexToOklab as in, deriveConciergeState as it, ShellRenderer as j, cn as jn, SHEET_PEEK_MAX as jt, rendererFor as k, BotFace as kn, SHEET_EXPANDED_VH as kt, mergeAddedCartLine as l, oklabToHex as ln, CONTROL as lt, createWidgetVoiceTokenFetcher as m, parseHex as mn, DOCK_ALIGN_STORAGE_KEY as mt, CART_LINE_VARIANT_ID_SHAPE as n, contrastRatio as nn, latestExchangeStart as nt, cartLinesFromSnapshot as o, linearRgbToOklab as on, formatMoney as ot, ROOM_EVENTS as p, oklchToOklab as pn, DESKTOP_WIDTHS as pt, SessionLog as q, snapAlign as qt, ConciergeHost as r, formatHex as rn, CONCIERGE_STATES as rt, chooseOptionsAction as s, linearToSrgb as sn, ACTIVITY_W as st, CART_LINE_PLATFORM_VARIANT_ID_SHAPE as t, themeToInlineStyle as tn, idleDockInput as tt, resolveAddToCartHandler as u, oklabToLinearRgb as un, DESKTOP_BOTTOM as ut, detectPage as v, withAlpha as vn, FLOAT_DUCK_DISMISS_MS as vt, textDirectionFor as w, DEFAULT_WIDGET_AVATAR as wn, PILL_MARK as wt, basketIntentFromTurns as x, resolveWidgetMessages as xn, MARK as xt, VoiceWidget as y, defaultWidgetMessages as yn, FLOAT_GAP as yt, nearestPosition as z, persistAlign as zt };