@saar-ai/web-widget 0.15.0 → 0.16.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.
- package/dist/brand-mark.d.ts +16 -0
- package/dist/brand-mark.d.ts.map +1 -0
- package/dist/chunks/{chat-CrbRIHVN.js → chat-DUERxmYS.js} +8 -1
- package/dist/chunks/{host-widget-CppBkOCF.js → host-widget-B5F_BxhC.js} +143 -46
- package/dist/concierge-shell.css +1 -1
- package/dist/dock/dock.d.ts +2 -0
- package/dist/dock/dock.d.ts.map +1 -1
- package/dist/generated/concierge-shell-css.d.ts.map +1 -1
- package/dist/generated/widget-css.d.ts.map +1 -1
- package/dist/host-widget.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/messages.d.ts +4 -4
- package/dist/messages.d.ts.map +1 -1
- package/dist/next/index.js +1 -1
- package/dist/use-chat-session.d.ts +17 -16
- package/dist/use-chat-session.d.ts.map +1 -1
- package/dist/voice-widget.d.ts.map +1 -1
- package/dist/widget/concierge-shell.d.ts.map +1 -1
- package/dist/widget/shell-renderer.d.ts.map +1 -1
- package/dist/widget.css +1 -1
- package/package.json +3 -3
- package/src/styles/concierge-shell-entry.css +1 -0
- package/src/styles/concierge.css +2 -13
- package/src/styles/cursor.css +45 -0
- package/src/styles/widget-entry.css +1 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The product's own colours for the attribution badge, as literal sRGB hex: the
|
|
3
|
+
* marketing `Wordmark` in light mode (rose-500 → amber-400 dot, plum-800 text
|
|
4
|
+
* on white). Never a custom property, because every `--brand-*` the widget
|
|
5
|
+
* sees is the TENANT's skin. `__tests__/brand-mark.test.tsx` pins them to
|
|
6
|
+
* apps/marketing/src/app/icon.svg and packages/ui/src/theme/color-tokens.css.
|
|
7
|
+
*/
|
|
8
|
+
export declare const BRAND_MARK_STOPS: readonly ['#f83e54', '#f3b01d'];
|
|
9
|
+
export declare const BRAND_WORDMARK_COLOR = "#80027c";
|
|
10
|
+
export declare const BRAND_BADGE_PLATE = "#fff";
|
|
11
|
+
/** `plate`: draw the badge's own white pill behind it, for a surface that has none. */
|
|
12
|
+
export declare function BrandWordmark({ name, plate, }: {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly plate?: boolean;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
//# sourceMappingURL=brand-mark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-mark.d.ts","sourceRoot":"","sources":["../src/brand-mark.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,YAAI,SAAS,EAAE,SAAS,CAAU,CAAC;AAChE,eAAO,MAAM,oBAAoB,YAAY,CAAC;AAC9C,eAAO,MAAM,iBAAiB,SAAS,CAAC;AAsBxC,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,KAAK,GACN,EAAE;IACD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B,+BAcA"}
|
|
@@ -645,6 +645,12 @@ var WidgetChatAddToCartEventSchema = object({
|
|
|
645
645
|
* (it arrives ahead of the reply's text on the same stream).
|
|
646
646
|
*/
|
|
647
647
|
var WidgetChatResumedEventSchema = object({ type: literal("resumed") });
|
|
648
|
+
/**
|
|
649
|
+
* The concierge has picked the shopper's message up (SAA-449): the turn has
|
|
650
|
+
* an agent and is about to generate. The widget draws the second tick on the
|
|
651
|
+
* shopper's own bubble from it. Never sent while a person holds the thread.
|
|
652
|
+
*/
|
|
653
|
+
var WidgetChatReadEventSchema = object({ type: literal("read") });
|
|
648
654
|
var WidgetChatDoneEventSchema = object({
|
|
649
655
|
type: literal("done"),
|
|
650
656
|
turnId: string().min(1)
|
|
@@ -665,6 +671,7 @@ var WidgetChatSseEventSchema = discriminatedUnion("type", [
|
|
|
665
671
|
WidgetChatCaptureCardEventSchema,
|
|
666
672
|
WidgetChatFillFormEventSchema,
|
|
667
673
|
WidgetChatResumedEventSchema,
|
|
674
|
+
WidgetChatReadEventSchema,
|
|
668
675
|
WidgetChatDoneEventSchema,
|
|
669
676
|
WidgetChatErrorEventSchema
|
|
670
677
|
]);
|
|
@@ -1112,4 +1119,4 @@ function parseWidgetChatCart(value) {
|
|
|
1112
1119
|
return parsed.success ? parsed.data : null;
|
|
1113
1120
|
}
|
|
1114
1121
|
//#endregion
|
|
1115
|
-
export { CART_LINE_PLATFORM_VARIANT_ID_PATTERN, CART_LINE_VARIANT_ID_PATTERN, DROPPABLE_CARD_FIELDS, MAX_CARDS_PER_EVENT, MAX_CART_LINES, WidgetCartAddFailedReportSchema, WidgetCartAddReportSchema, WidgetChatAddToCartEventSchema, WidgetChatCardSchema, WidgetChatCardsEventSchema, WidgetChatCartLineSchema, WidgetChatCartSchema, WidgetChatCartSourceSchema, WidgetChatCheckoutEventSchema, WidgetChatDoneEventSchema, WidgetChatErrorEventSchema, WidgetChatEscalatedEventSchema, WidgetChatReportSchema, WidgetChatResumedEventSchema, WidgetChatSseEventSchema, WidgetChatTextDeltaEventSchema, WidgetToolEventSchema, WidgetVariantChoiceRequestReportSchema, buildWidgetChatCard, buildWidgetChatCardsEvent, buildWithDroppableFields, extractWidgetToolEvent, parseWidgetChatCart, parseWidgetChatReport };
|
|
1122
|
+
export { CART_LINE_PLATFORM_VARIANT_ID_PATTERN, CART_LINE_VARIANT_ID_PATTERN, DROPPABLE_CARD_FIELDS, MAX_CARDS_PER_EVENT, MAX_CART_LINES, WidgetCartAddFailedReportSchema, WidgetCartAddReportSchema, WidgetChatAddToCartEventSchema, WidgetChatCardSchema, WidgetChatCardsEventSchema, WidgetChatCartLineSchema, WidgetChatCartSchema, WidgetChatCartSourceSchema, WidgetChatCheckoutEventSchema, WidgetChatDoneEventSchema, WidgetChatErrorEventSchema, WidgetChatEscalatedEventSchema, WidgetChatReadEventSchema, WidgetChatReportSchema, WidgetChatResumedEventSchema, WidgetChatSseEventSchema, WidgetChatTextDeltaEventSchema, WidgetToolEventSchema, WidgetVariantChoiceRequestReportSchema, buildWidgetChatCard, buildWidgetChatCardsEvent, buildWithDroppableFields, extractWidgetToolEvent, parseWidgetChatCart, parseWidgetChatReport };
|
|
@@ -4622,8 +4622,9 @@ var defaultWidgetMessages = {
|
|
|
4622
4622
|
capture_saved_event: "Thanks — sent.",
|
|
4623
4623
|
capture_declined_event: "No problem — skipped.",
|
|
4624
4624
|
escalated_banner: "A human teammate will pick this up shortly.",
|
|
4625
|
-
status_sending: "
|
|
4626
|
-
status_sent: "
|
|
4625
|
+
status_sending: "Queued",
|
|
4626
|
+
status_sent: "Delivered",
|
|
4627
|
+
status_read: "Read",
|
|
4627
4628
|
typing: "Typing",
|
|
4628
4629
|
suggestions_label: "Suggested questions",
|
|
4629
4630
|
suggestion_1: "What is popular right now?",
|
|
@@ -8334,6 +8335,63 @@ function deriveView(state, input) {
|
|
|
8334
8335
|
throw new TypeError(`Unknown dock state: ${JSON.stringify(state)}`);
|
|
8335
8336
|
}
|
|
8336
8337
|
//#endregion
|
|
8338
|
+
//#region src/brand-mark.tsx
|
|
8339
|
+
/**
|
|
8340
|
+
* The product's own colours for the attribution badge, as literal sRGB hex: the
|
|
8341
|
+
* marketing `Wordmark` in light mode (rose-500 → amber-400 dot, plum-800 text
|
|
8342
|
+
* on white). Never a custom property, because every `--brand-*` the widget
|
|
8343
|
+
* sees is the TENANT's skin. `__tests__/brand-mark.test.tsx` pins them to
|
|
8344
|
+
* apps/marketing/src/app/icon.svg and packages/ui/src/theme/color-tokens.css.
|
|
8345
|
+
*/
|
|
8346
|
+
var BRAND_MARK_STOPS = ["#f83e54", "#f3b01d"];
|
|
8347
|
+
var BRAND_WORDMARK_COLOR = "#80027c";
|
|
8348
|
+
var BRAND_BADGE_PLATE = "#fff";
|
|
8349
|
+
var WORDMARK_STYLE = {
|
|
8350
|
+
display: "inline-flex",
|
|
8351
|
+
alignItems: "center",
|
|
8352
|
+
gap: ".4em",
|
|
8353
|
+
fontSize: 20,
|
|
8354
|
+
fontWeight: 600,
|
|
8355
|
+
letterSpacing: "-.025em",
|
|
8356
|
+
color: BRAND_WORDMARK_COLOR,
|
|
8357
|
+
WebkitTextFillColor: BRAND_WORDMARK_COLOR
|
|
8358
|
+
};
|
|
8359
|
+
var PLATED_STYLE = {
|
|
8360
|
+
...WORDMARK_STYLE,
|
|
8361
|
+
background: BRAND_BADGE_PLATE,
|
|
8362
|
+
borderRadius: 99,
|
|
8363
|
+
padding: "2px 10px"
|
|
8364
|
+
};
|
|
8365
|
+
var MARK_STYLE = {
|
|
8366
|
+
width: ".5em",
|
|
8367
|
+
height: ".5em"
|
|
8368
|
+
};
|
|
8369
|
+
/** `plate`: draw the badge's own white pill behind it, for a surface that has none. */
|
|
8370
|
+
function BrandWordmark({ name, plate }) {
|
|
8371
|
+
const id = "wgt-mark" + useId().replace(/\W/g, "");
|
|
8372
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
8373
|
+
style: plate ? PLATED_STYLE : WORDMARK_STYLE,
|
|
8374
|
+
children: [/* @__PURE__ */ jsxs("svg", {
|
|
8375
|
+
"aria-hidden": "true",
|
|
8376
|
+
viewBox: "0 0 32 32",
|
|
8377
|
+
style: MARK_STYLE,
|
|
8378
|
+
children: [/* @__PURE__ */ jsxs("linearGradient", {
|
|
8379
|
+
id,
|
|
8380
|
+
y2: "1",
|
|
8381
|
+
children: [/* @__PURE__ */ jsx("stop", { stopColor: BRAND_MARK_STOPS[0] }), /* @__PURE__ */ jsx("stop", {
|
|
8382
|
+
offset: "1",
|
|
8383
|
+
stopColor: BRAND_MARK_STOPS[1]
|
|
8384
|
+
})]
|
|
8385
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
8386
|
+
cx: "16",
|
|
8387
|
+
cy: "16",
|
|
8388
|
+
r: "16",
|
|
8389
|
+
fill: `url(#${id})`
|
|
8390
|
+
})]
|
|
8391
|
+
}), name]
|
|
8392
|
+
});
|
|
8393
|
+
}
|
|
8394
|
+
//#endregion
|
|
8337
8395
|
//#region src/dock/dock.tsx
|
|
8338
8396
|
var DEFAULT_COLOR = {
|
|
8339
8397
|
primary: "#4c1d50",
|
|
@@ -8351,7 +8409,7 @@ var DEFAULT_LAYOUT = {
|
|
|
8351
8409
|
};
|
|
8352
8410
|
var INTERRUPT_SEEN_STORAGE_KEY = "wgt_dock_interrupt_seen";
|
|
8353
8411
|
function Dock(props) {
|
|
8354
|
-
const { identity, color = DEFAULT_COLOR, type = DEFAULT_TYPE, layout = DEFAULT_LAYOUT, copy = {}, direction = "ltr", locale = "en", messages = defaultWidgetMessages, voice, escalated = false, offline = false, status, notice, statusKind, operatorLine, operatorName, reconnecting = false, roomDropped = false, partialTranscript, preamble, clause, channel = "text", shelf, transcript, transcriptCount, lastTurn, composing = false, unread = false, sheetExtra, followKey, revealSheet = false, showPrice = true, cardImageAspect = DEFAULT_CARD_ASPECT, bottomOffset = "auto", curationHref, productHref, navigate, draft, onDraftChange, onSubmit, composerDisabled = false, onAttach, attachSlot, attachBusy, proactive, pageKey, conciergeScrollRef, onEndCall, skinStyle, skin, preview = false, announcement, attribution, privacyChoices, initialDraft, initialSelection, initialFocus, initialMinimised, insets, hold, audio, onReady } = props;
|
|
8412
|
+
const { identity, color = DEFAULT_COLOR, type = DEFAULT_TYPE, layout = DEFAULT_LAYOUT, copy = {}, direction = "ltr", locale = "en", messages = defaultWidgetMessages, voice, escalated = false, offline = false, status, notice, statusKind, operatorLine, operatorName, reconnecting = false, roomDropped = false, partialTranscript, preamble, clause, channel = "text", shelf, transcript, transcriptCount, lastTurn, composing = false, unread = false, sheetExtra, followKey, revealSheet = false, showPrice = true, cardImageAspect = DEFAULT_CARD_ASPECT, bottomOffset = "auto", curationHref, productHref, navigate, draft, onDraftChange, onSubmit, composerDisabled = false, onAttach, attachSlot, attachBusy, proactive, pageKey, conciergeScrollRef, onEndCall, skinStyle, skin, preview = false, announcement, attribution, privacyChoices, initialDraft, initialSelection, initialFocus, initialMinimised, insets, hold, audio, onReady, onShown } = props;
|
|
8355
8413
|
const scopeId = useId().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
8356
8414
|
const rootRef = useRef(null);
|
|
8357
8415
|
const rowRef = useRef(null);
|
|
@@ -8393,6 +8451,7 @@ function Dock(props) {
|
|
|
8393
8451
|
persistMinimised(window, next === "pill");
|
|
8394
8452
|
}, [layout.minimised, preview]);
|
|
8395
8453
|
const [sheet, setSheet] = useState("closed");
|
|
8454
|
+
useEffect(() => onShown?.(sheet !== "closed"), [sheet, onShown]);
|
|
8396
8455
|
/**
|
|
8397
8456
|
* The sheet has been open at least once this session — one of the three
|
|
8398
8457
|
* things that retire the greeting placeholder (see `placeholder` below).
|
|
@@ -9380,7 +9439,10 @@ function Dock(props) {
|
|
|
9380
9439
|
href: attribution.href,
|
|
9381
9440
|
target: "_blank",
|
|
9382
9441
|
rel: "noopener noreferrer",
|
|
9383
|
-
children:
|
|
9442
|
+
children: /* @__PURE__ */ jsx(BrandWordmark, {
|
|
9443
|
+
name: attribution.name,
|
|
9444
|
+
plate: true
|
|
9445
|
+
})
|
|
9384
9446
|
}) : null,
|
|
9385
9447
|
privacyChoices !== void 0 ? /* @__PURE__ */ jsx("button", {
|
|
9386
9448
|
type: "button",
|
|
@@ -11376,19 +11438,14 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
11376
11438
|
})
|
|
11377
11439
|
]
|
|
11378
11440
|
}),
|
|
11379
|
-
attribution ? /* @__PURE__ */
|
|
11441
|
+
attribution ? /* @__PURE__ */ jsx("a", {
|
|
11380
11442
|
href: attribution.href,
|
|
11381
11443
|
target: "_blank",
|
|
11382
11444
|
rel: "noopener noreferrer",
|
|
11383
11445
|
"data-testid": "widget-branding",
|
|
11384
|
-
className: cn(FOOTER_PILL, "left-1/2 inline-flex -translate-x-1/2 items-center
|
|
11385
|
-
|
|
11386
|
-
|
|
11387
|
-
className: "size-2.5 rounded-full bg-gradient-to-br from-brand-rose to-brand-amber"
|
|
11388
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
11389
|
-
className: "text-brand-plum font-semibold tracking-tight",
|
|
11390
|
-
children: attribution.name
|
|
11391
|
-
})]
|
|
11446
|
+
className: cn(FOOTER_PILL, "left-1/2 inline-flex -translate-x-1/2 items-center whitespace-nowrap", open ? "pointer-events-auto opacity-100" : "pointer-events-none opacity-0"),
|
|
11447
|
+
style: { backgroundColor: BRAND_BADGE_PLATE },
|
|
11448
|
+
children: /* @__PURE__ */ jsx(BrandWordmark, { name: attribution.name })
|
|
11392
11449
|
}) : null,
|
|
11393
11450
|
privacyChoices ? /* @__PURE__ */ jsx("button", {
|
|
11394
11451
|
type: "button",
|
|
@@ -11709,7 +11766,11 @@ function positionFor(dock) {
|
|
|
11709
11766
|
function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndCall, statusKind, statusLine, escalated, operatorName, humanTyping, composing, replyStreaming, channel, draft, onDraftChange, submit, attaching, onAttach, attachInput, transcript, extras, messages, skinStyle, avatar, attribution, privacyChoices, voice: derivedVoice, dock }) {
|
|
11710
11767
|
const [restored] = useState(readOpen);
|
|
11711
11768
|
const [open, setOpen] = useState(dock?.initialMinimised === false || restored);
|
|
11712
|
-
|
|
11769
|
+
const onShown = dock?.onShown;
|
|
11770
|
+
useEffect(() => {
|
|
11771
|
+
writeOpen(open);
|
|
11772
|
+
onShown?.(open);
|
|
11773
|
+
}, [open, onShown]);
|
|
11713
11774
|
const onReady = dock?.onReady;
|
|
11714
11775
|
useLayoutEffect(() => {
|
|
11715
11776
|
onReady?.();
|
|
@@ -12817,30 +12878,30 @@ function TranscriptEvent({ event, awaitingReply, messages }) {
|
|
|
12817
12878
|
});
|
|
12818
12879
|
}
|
|
12819
12880
|
/**
|
|
12820
|
-
* The shopper's own
|
|
12821
|
-
*
|
|
12822
|
-
*
|
|
12823
|
-
*
|
|
12824
|
-
*
|
|
12825
|
-
* not ship a tick it cannot back with an observation.
|
|
12826
|
-
*
|
|
12827
|
-
* The state is carried on `data-delivery` as well as in the accessible name
|
|
12828
|
-
* so that the assertion in a test — and any host styling — reads the actual
|
|
12829
|
-
* state rather than matching on a glyph.
|
|
12881
|
+
* The shopper's own message receipt, under their bubble (SAA-449): no tick
|
|
12882
|
+
* while queued, one once the server stored it, two once it was read — see
|
|
12883
|
+
* `ChatTurnDelivery`. The ticks are an SVG and the state is the accessible
|
|
12884
|
+
* name, so the row's text carries no receipt words; `data-delivery` carries
|
|
12885
|
+
* the state for tests and host styling.
|
|
12830
12886
|
*/
|
|
12831
12887
|
function TurnDeliveryStatus({ delivery, messages }) {
|
|
12832
|
-
const
|
|
12833
|
-
return /* @__PURE__ */
|
|
12888
|
+
const key = delivery === "read" ? "status_read" : delivery === "sent" ? "status_sent" : "status_sending";
|
|
12889
|
+
return /* @__PURE__ */ jsx("span", {
|
|
12890
|
+
role: "img",
|
|
12891
|
+
"aria-label": messages[key] ?? defaultWidgetMessages[key],
|
|
12834
12892
|
"data-testid": "widget-turn-status",
|
|
12835
12893
|
"data-delivery": delivery,
|
|
12836
|
-
className:
|
|
12837
|
-
children:
|
|
12838
|
-
|
|
12839
|
-
|
|
12840
|
-
|
|
12894
|
+
className: "pt-0.5 pe-0.5 text-[var(--widget-foreground-muted)]",
|
|
12895
|
+
children: delivery !== "sending" ? /* @__PURE__ */ jsx("svg", {
|
|
12896
|
+
viewBox: "0 0 16 10",
|
|
12897
|
+
width: "16",
|
|
12898
|
+
height: "10",
|
|
12899
|
+
fill: "none",
|
|
12900
|
+
stroke: "currentColor",
|
|
12901
|
+
strokeWidth: "1.6",
|
|
12841
12902
|
"aria-hidden": "true",
|
|
12842
|
-
children: delivery === "
|
|
12843
|
-
})
|
|
12903
|
+
children: /* @__PURE__ */ jsx("path", { d: `M1 5l3 3 6-7${delivery === "read" ? "M7 8l6-7" : ""}` })
|
|
12904
|
+
}) : null
|
|
12844
12905
|
});
|
|
12845
12906
|
}
|
|
12846
12907
|
/** Kept in sync with `ATTACHMENT_IMAGE_CONTENT_TYPES` in `apps/api/src/conversations/attachment-limits.ts` — display-only, never a security decision on this side. */
|
|
@@ -14482,6 +14543,7 @@ function useChatSession(options) {
|
|
|
14482
14543
|
const [connection, setConnection] = useState("idle");
|
|
14483
14544
|
/** See `UseChatSessionResult.deskTyping`. Expiry timer lives in `deskTypingTimerRef`. */
|
|
14484
14545
|
const [deskTyping, setDeskTyping] = useState(false);
|
|
14546
|
+
const [shown, setShown] = useState();
|
|
14485
14547
|
/**
|
|
14486
14548
|
* Counts SESSIONS, not renders — bumped once per successful `bootSession`,
|
|
14487
14549
|
* and by nothing else. A token ROTATION deliberately does not bump it.
|
|
@@ -14768,12 +14830,25 @@ function useChatSession(options) {
|
|
|
14768
14830
|
seq: t.seq,
|
|
14769
14831
|
...t.attachments && t.attachments.length > 0 ? { attachments: t.attachments } : {},
|
|
14770
14832
|
...t.cards && Array.isArray(t.cards.items) && t.cards.items.length > 0 ? { cards: t.cards } : {},
|
|
14771
|
-
...typeof t.operatorName === "string" && t.operatorName !== "" ? { operatorName: t.operatorName } : {}
|
|
14833
|
+
...typeof t.operatorName === "string" && t.operatorName !== "" ? { operatorName: t.operatorName } : {},
|
|
14834
|
+
...t.readAt !== void 0 ? { delivery: t.readAt ? "read" : "sent" } : {}
|
|
14772
14835
|
})) insertBySeq(next, turn);
|
|
14773
14836
|
return next;
|
|
14774
14837
|
});
|
|
14775
14838
|
}, [clearDeskTyping]);
|
|
14776
14839
|
/**
|
|
14840
|
+
* SAA-449: the shopper's delivered bubbles named by `ids` become read — the
|
|
14841
|
+
* one the SSE `read` frame answers, or those whose server turn id the
|
|
14842
|
+
* holder's `desk:read` named. Only ever on the server's word.
|
|
14843
|
+
*/
|
|
14844
|
+
const markRead = useCallback((ids) => {
|
|
14845
|
+
if (!mountedRef.current) return;
|
|
14846
|
+
setTurns((prev) => prev.map((t) => t.delivery === "sent" && ids.includes(t.id.split(":")[0]) ? {
|
|
14847
|
+
...t,
|
|
14848
|
+
delivery: "read"
|
|
14849
|
+
} : t));
|
|
14850
|
+
}, []);
|
|
14851
|
+
/**
|
|
14777
14852
|
* Records the handoff to a human AS AN EVENT IN THE TRANSCRIPT, at the
|
|
14778
14853
|
* point in the thread where it happened, and flips `status`.
|
|
14779
14854
|
*
|
|
@@ -15379,6 +15454,9 @@ function useChatSession(options) {
|
|
|
15379
15454
|
socket.on(DESK_MESSAGE_EVENT, (message) => {
|
|
15380
15455
|
mergeIncoming([message], "push");
|
|
15381
15456
|
});
|
|
15457
|
+
socket.on("desk:read", (payload) => {
|
|
15458
|
+
if (Array.isArray(payload?.ids)) markRead(payload.ids);
|
|
15459
|
+
});
|
|
15382
15460
|
socket.on(DESK_OWNERSHIP_EVENT, (payload) => {
|
|
15383
15461
|
const event = parseDeskOwnershipEvent(payload);
|
|
15384
15462
|
if (!event || !mountedRef.current) return;
|
|
@@ -15405,6 +15483,7 @@ function useChatSession(options) {
|
|
|
15405
15483
|
status,
|
|
15406
15484
|
socketFactory,
|
|
15407
15485
|
mergeIncoming,
|
|
15486
|
+
markRead,
|
|
15408
15487
|
clearDeskTyping,
|
|
15409
15488
|
markHandbackToAi,
|
|
15410
15489
|
markHandoffToHuman,
|
|
@@ -15576,13 +15655,18 @@ function useChatSession(options) {
|
|
|
15576
15655
|
next: "streaming"
|
|
15577
15656
|
});
|
|
15578
15657
|
},
|
|
15658
|
+
onRead: () => markRead([callerTurnId]),
|
|
15579
15659
|
onDone: (turnId) => {
|
|
15580
15660
|
release();
|
|
15581
15661
|
if (!mountedRef.current) return;
|
|
15582
|
-
|
|
15662
|
+
const inId = `${turnId}:in`;
|
|
15663
|
+
setTurns((prev) => prev.filter((t) => t.id !== turnId && t.id !== inId || t.id === agentTurnId).map((t) => t.id === agentTurnId ? {
|
|
15583
15664
|
...t,
|
|
15584
15665
|
id: turnId,
|
|
15585
15666
|
final: true
|
|
15667
|
+
} : t.id === callerTurnId ? {
|
|
15668
|
+
...t,
|
|
15669
|
+
id: inId
|
|
15586
15670
|
} : t));
|
|
15587
15671
|
setStatus((prev) => prev === "escalated" ? prev : "idle");
|
|
15588
15672
|
},
|
|
@@ -15612,7 +15696,8 @@ function useChatSession(options) {
|
|
|
15612
15696
|
fetchImpl,
|
|
15613
15697
|
status,
|
|
15614
15698
|
markHandoffToHuman,
|
|
15615
|
-
markHandbackToAi
|
|
15699
|
+
markHandbackToAi,
|
|
15700
|
+
markRead
|
|
15616
15701
|
]);
|
|
15617
15702
|
useEffect(() => {
|
|
15618
15703
|
if (status === "streaming" || replyInFlightRef.current !== null) return;
|
|
@@ -15846,11 +15931,14 @@ function useChatSession(options) {
|
|
|
15846
15931
|
* synonym for "read" and left the state it exists to express — reached
|
|
15847
15932
|
* them, has not been looked at — unrepresentable.
|
|
15848
15933
|
*
|
|
15849
|
-
* **Read waits for the tab
|
|
15850
|
-
* === 'visible'`
|
|
15851
|
-
*
|
|
15852
|
-
*
|
|
15853
|
-
*
|
|
15934
|
+
* **Read waits for the tab AND the panel (SAA-449).** `document.
|
|
15935
|
+
* visibilityState === 'visible'` with the transcript on screen — the
|
|
15936
|
+
* renderer reports its panel/sheet through `setShown` — is the honest limit
|
|
15937
|
+
* of what a browser can say about the shopper having seen a reply. A closed
|
|
15938
|
+
* panel holds the read until it opens. A host that never calls `setShown`
|
|
15939
|
+
* keeps the tab-only rule. It over-claims (a visible tab in another window,
|
|
15940
|
+
* a shopper who walked away) and this is stated plainly in the field's own
|
|
15941
|
+
* GraphQL description rather than dressed up.
|
|
15854
15942
|
*
|
|
15855
15943
|
* **`final`, not merely present, is what counts — for both.** A streaming
|
|
15856
15944
|
* reply renders as an agent-speaker turn from its FIRST token
|
|
@@ -15878,7 +15966,7 @@ function useChatSession(options) {
|
|
|
15878
15966
|
const reportReceipts = () => {
|
|
15879
15967
|
const delivered = deliveredTurnIdsRef.current;
|
|
15880
15968
|
const read = readTurnIdsRef.current;
|
|
15881
|
-
const visible = isTabVisible();
|
|
15969
|
+
const visible = isTabVisible() && shown !== false;
|
|
15882
15970
|
const kinds = [];
|
|
15883
15971
|
let sawNewDelivery = false;
|
|
15884
15972
|
let sawNewRead = false;
|
|
@@ -15901,7 +15989,11 @@ function useChatSession(options) {
|
|
|
15901
15989
|
if (typeof document === "undefined") return;
|
|
15902
15990
|
document.addEventListener("visibilitychange", reportReceipts);
|
|
15903
15991
|
return () => document.removeEventListener("visibilitychange", reportReceipts);
|
|
15904
|
-
}, [
|
|
15992
|
+
}, [
|
|
15993
|
+
turns,
|
|
15994
|
+
shown,
|
|
15995
|
+
sendClientReceipts
|
|
15996
|
+
]);
|
|
15905
15997
|
const checkout = useCallback(async (items, curationId, cartAttributionToken) => {
|
|
15906
15998
|
const chatToken = chatTokenRef.current;
|
|
15907
15999
|
if (chatToken === void 0 || items.length === 0) return null;
|
|
@@ -16033,6 +16125,7 @@ function useChatSession(options) {
|
|
|
16033
16125
|
submitCapture,
|
|
16034
16126
|
sendEvent,
|
|
16035
16127
|
notifyTyping,
|
|
16128
|
+
setShown,
|
|
16036
16129
|
checkout,
|
|
16037
16130
|
sendAttachment,
|
|
16038
16131
|
markHandoffToHuman,
|
|
@@ -16045,7 +16138,7 @@ function useChatSession(options) {
|
|
|
16045
16138
|
* promise and is trivially unit-testable with a synthetic `ReadableStream`.
|
|
16046
16139
|
*/
|
|
16047
16140
|
async function streamReply(args) {
|
|
16048
|
-
const { body, agentTurnId, setTurns, onCardsEvent, onCheckoutEvent, onCartAddEvent, onActEvent, onEscalated, onResumed, onDone, onError, isMounted } = args;
|
|
16141
|
+
const { body, agentTurnId, setTurns, onCardsEvent, onCheckoutEvent, onCartAddEvent, onActEvent, onEscalated, onResumed, onRead, onDone, onError, isMounted } = args;
|
|
16049
16142
|
const reader = body.getReader();
|
|
16050
16143
|
const decoder = new TextDecoder();
|
|
16051
16144
|
const parser = new SseFrameParser();
|
|
@@ -16191,6 +16284,9 @@ async function streamReply(args) {
|
|
|
16191
16284
|
case "resumed":
|
|
16192
16285
|
onResumed();
|
|
16193
16286
|
break;
|
|
16287
|
+
case "read":
|
|
16288
|
+
onRead();
|
|
16289
|
+
break;
|
|
16194
16290
|
case "done":
|
|
16195
16291
|
onDone(evt.data?.turnId ?? agentTurnId);
|
|
16196
16292
|
break;
|
|
@@ -16213,7 +16309,7 @@ async function streamReply(args) {
|
|
|
16213
16309
|
* cache makes a second `start()` after `stop()` free).
|
|
16214
16310
|
*/
|
|
16215
16311
|
async function loadVoiceProtocol() {
|
|
16216
|
-
const [telemetry, chat] = await Promise.all([import("./telemetry-UHSrhVyf.js"), import("./chat-
|
|
16312
|
+
const [telemetry, chat] = await Promise.all([import("./telemetry-UHSrhVyf.js"), import("./chat-DUERxmYS.js")]);
|
|
16217
16313
|
return {
|
|
16218
16314
|
decodeTelemetry: telemetry.decodeTelemetry,
|
|
16219
16315
|
encodeCallerText: telemetry.encodeCallerText,
|
|
@@ -19821,7 +19917,8 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19821
19917
|
...insets !== void 0 ? { insets } : {},
|
|
19822
19918
|
...hold !== void 0 ? { hold } : {},
|
|
19823
19919
|
...audio !== void 0 ? { audio } : {},
|
|
19824
|
-
...onReady !== void 0 ? { onReady } : {}
|
|
19920
|
+
...onReady !== void 0 ? { onReady } : {},
|
|
19921
|
+
onShown: session.setShown
|
|
19825
19922
|
};
|
|
19826
19923
|
return /* @__PURE__ */ jsx(VoiceWidgetWithRenderer, {
|
|
19827
19924
|
renderer,
|