@flamingo-stack/openframe-frontend-core 0.0.609-snapshot.20260908170120 → 0.0.609
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/chat-protocol/events.d.ts +2 -21
- package/dist/chat-protocol/events.d.ts.map +1 -1
- package/dist/chat-protocol/index.cjs +9 -211
- package/dist/chat-protocol/index.cjs.map +1 -1
- package/dist/chat-protocol/index.js +9 -211
- package/dist/chat-protocol/index.js.map +1 -1
- package/dist/chat-protocol/nats-decoder.d.ts.map +1 -1
- package/dist/{chunk-2YMDDD5V.cjs → chunk-3N4FXBVJ.cjs} +3 -3
- package/dist/{chunk-2YMDDD5V.cjs.map → chunk-3N4FXBVJ.cjs.map} +1 -1
- package/dist/{chunk-THCB7NHV.cjs → chunk-3XNMDLGB.cjs} +9 -9
- package/dist/{chunk-THCB7NHV.cjs.map → chunk-3XNMDLGB.cjs.map} +1 -1
- package/dist/{chunk-GFAHCXIL.cjs → chunk-45XXK2VU.cjs} +10 -10
- package/dist/{chunk-GFAHCXIL.cjs.map → chunk-45XXK2VU.cjs.map} +1 -1
- package/dist/{chunk-2QBXG74C.js → chunk-6MLRFM3T.js} +5 -5
- package/dist/{chunk-IBMHEOBV.js → chunk-B3UXNGVM.js} +3 -3
- package/dist/{chunk-O6PO5BHE.js → chunk-B7LYKBCD.js} +5 -5
- package/dist/{chunk-F2C2U7CP.js → chunk-BSMPCPOZ.js} +299 -590
- package/dist/chunk-BSMPCPOZ.js.map +1 -0
- package/dist/{chunk-MGXSJI23.js → chunk-BUXGWBTF.js} +2 -2
- package/dist/{chunk-OIKZDXNW.js → chunk-C7CTEUU7.js} +2 -2
- package/dist/{chunk-EANAFFAD.cjs → chunk-CZTOSG7Q.cjs} +22 -22
- package/dist/{chunk-EANAFFAD.cjs.map → chunk-CZTOSG7Q.cjs.map} +1 -1
- package/dist/{chunk-C4KQ2XPK.cjs → chunk-D3DTC7SZ.cjs} +15 -15
- package/dist/{chunk-C4KQ2XPK.cjs.map → chunk-D3DTC7SZ.cjs.map} +1 -1
- package/dist/{chunk-HKJ3WKGW.cjs → chunk-DKNXAJMP.cjs} +159 -159
- package/dist/{chunk-HKJ3WKGW.cjs.map → chunk-DKNXAJMP.cjs.map} +1 -1
- package/dist/{chunk-UFFVMZDL.cjs → chunk-FYG7QNAO.cjs} +5 -5
- package/dist/{chunk-UFFVMZDL.cjs.map → chunk-FYG7QNAO.cjs.map} +1 -1
- package/dist/{chunk-THCSSPXU.cjs → chunk-GMOBT5NP.cjs} +70 -70
- package/dist/{chunk-THCSSPXU.cjs.map → chunk-GMOBT5NP.cjs.map} +1 -1
- package/dist/{chunk-HQSCJYCF.js → chunk-HGVW7OHI.js} +2 -2
- package/dist/{chunk-FS3CTGIR.js → chunk-JKM5FH63.js} +3 -3
- package/dist/{chunk-37CAZTLP.js → chunk-JOCVQZGT.js} +5 -5
- package/dist/{chunk-ROOIHDLS.js → chunk-JR7I2AGL.js} +3 -3
- package/dist/{chunk-OVVKVIMH.cjs → chunk-L2JWC5VS.cjs} +43 -43
- package/dist/{chunk-OVVKVIMH.cjs.map → chunk-L2JWC5VS.cjs.map} +1 -1
- package/dist/{chunk-25YIHMZ6.js → chunk-LA2W5L6K.js} +2 -2
- package/dist/{chunk-V6TINNLD.js → chunk-MVBRMQGU.js} +2 -2
- package/dist/{chunk-Q3APHZK5.cjs → chunk-NJUSDREV.cjs} +22 -22
- package/dist/{chunk-Q3APHZK5.cjs.map → chunk-NJUSDREV.cjs.map} +1 -1
- package/dist/{chunk-FASOANK7.cjs → chunk-O2M4T34Q.cjs} +4 -4
- package/dist/{chunk-FASOANK7.cjs.map → chunk-O2M4T34Q.cjs.map} +1 -1
- package/dist/{chunk-R2UDEMKK.js → chunk-OTYV6SDN.js} +3 -3
- package/dist/{chunk-HZS4TV34.js → chunk-QX4ANESW.js} +6 -6
- package/dist/{chunk-ZDLCWNM6.cjs → chunk-RZM6FPOT.cjs} +25 -25
- package/dist/{chunk-ZDLCWNM6.cjs.map → chunk-RZM6FPOT.cjs.map} +1 -1
- package/dist/{chunk-GNLV326I.cjs → chunk-SEW25Y2W.cjs} +10 -10
- package/dist/{chunk-GNLV326I.cjs.map → chunk-SEW25Y2W.cjs.map} +1 -1
- package/dist/{chunk-QE2Z6WME.cjs → chunk-TCEALWE3.cjs} +33 -33
- package/dist/{chunk-QE2Z6WME.cjs.map → chunk-TCEALWE3.cjs.map} +1 -1
- package/dist/{chunk-OJZW3GE2.js → chunk-TJ3GFULR.js} +3 -3
- package/dist/{chunk-Q2CNCBMK.js → chunk-VCYRJY7J.js} +4 -4
- package/dist/{chunk-YXTAV2E3.cjs → chunk-XNDTYTVT.cjs} +683 -974
- package/dist/chunk-XNDTYTVT.cjs.map +1 -0
- package/dist/{chunk-WJQOYSR3.cjs → chunk-ZRLFBLME.cjs} +3 -3
- package/dist/{chunk-WJQOYSR3.cjs.map → chunk-ZRLFBLME.cjs.map} +1 -1
- package/dist/components/case-studies/index.cjs +9 -9
- package/dist/components/case-studies/index.js +3 -3
- package/dist/components/chat/chat-message-enhanced.d.ts.map +1 -1
- package/dist/components/chat/chat-message-list.d.ts.map +1 -1
- package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts +28 -5
- package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts.map +1 -1
- package/dist/components/chat/index.cjs +2 -2
- package/dist/components/chat/index.js +1 -1
- package/dist/components/chat/remark-card-links.d.ts +4 -5
- package/dist/components/chat/remark-card-links.d.ts.map +1 -1
- package/dist/components/chat/stream/chat-stream-reducer.d.ts.map +1 -1
- package/dist/components/chat/tool-execution-display.d.ts.map +1 -1
- package/dist/components/chat/types/component.types.d.ts +0 -27
- package/dist/components/chat/types/component.types.d.ts.map +1 -1
- package/dist/components/chat/types/message.types.d.ts +1 -81
- package/dist/components/chat/types/message.types.d.ts.map +1 -1
- package/dist/components/chat/types/unified-chat-state.types.d.ts +3 -12
- package/dist/components/chat/types/unified-chat-state.types.d.ts.map +1 -1
- package/dist/components/chat/utils/process-historical-messages.d.ts.map +1 -1
- package/dist/components/contact/index.cjs +4 -4
- package/dist/components/contact/index.js +3 -3
- package/dist/components/docs/index.cjs +7 -7
- package/dist/components/docs/index.js +6 -6
- package/dist/components/embeds/index.cjs +4 -4
- package/dist/components/embeds/index.js +3 -3
- package/dist/components/faq/index.cjs +4 -4
- package/dist/components/faq/index.js +3 -3
- package/dist/components/features/index.cjs +3 -3
- package/dist/components/features/index.js +2 -2
- package/dist/components/help-center-pages/index.cjs +23 -23
- package/dist/components/help-center-pages/index.js +14 -14
- package/dist/components/index.cjs +38 -38
- package/dist/components/index.js +13 -13
- package/dist/components/meeting-scheduler/index.cjs +24 -24
- package/dist/components/meeting-scheduler/index.js +2 -2
- package/dist/components/navigation/index.cjs +6 -6
- package/dist/components/navigation/index.js +5 -5
- package/dist/components/onboarding-guides/index.cjs +6 -6
- package/dist/components/onboarding-guides/index.js +5 -5
- package/dist/components/tickets/index.cjs +7 -7
- package/dist/components/tickets/index.js +6 -6
- package/dist/components/ui/index.cjs +3 -3
- package/dist/components/ui/index.js +2 -2
- package/dist/index.cjs +7 -7
- package/dist/index.js +6 -6
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/chat-protocol/events.ts +1 -22
- package/src/chat-protocol/nats-decoder.ts +0 -12
- package/src/components/chat/chat-message-enhanced.tsx +12 -37
- package/src/components/chat/chat-message-list.tsx +1 -14
- package/src/components/chat/embeddable-chat.tsx +87 -47
- package/src/components/chat/hooks/use-sse-chat-adapter.ts +28 -5
- package/src/components/chat/remark-card-links.ts +12 -14
- package/src/components/chat/stream/chat-stream-reducer.ts +3 -48
- package/src/components/chat/tool-execution-display.tsx +4 -18
- package/src/components/chat/types/component.types.ts +0 -27
- package/src/components/chat/types/message.types.ts +0 -83
- package/src/components/chat/types/unified-chat-state.types.ts +3 -12
- package/src/components/chat/utils/process-historical-messages.ts +0 -25
- package/dist/chat-protocol/card-marker.d.ts +0 -31
- package/dist/chat-protocol/card-marker.d.ts.map +0 -1
- package/dist/chat-protocol/source-metadata.d.ts +0 -56
- package/dist/chat-protocol/source-metadata.d.ts.map +0 -1
- package/dist/chunk-F2C2U7CP.js.map +0 -1
- package/dist/chunk-YXTAV2E3.cjs.map +0 -1
- package/dist/components/chat/utils/cited-sources.d.ts +0 -24
- package/dist/components/chat/utils/cited-sources.d.ts.map +0 -1
- package/dist/components/chat/utils/host-message.d.ts +0 -41
- package/dist/components/chat/utils/host-message.d.ts.map +0 -1
- package/src/chat-protocol/__tests__/card-marker.test.ts +0 -63
- package/src/chat-protocol/__tests__/source-metadata.test.ts +0 -243
- package/src/chat-protocol/card-marker.ts +0 -40
- package/src/chat-protocol/source-metadata.ts +0 -336
- package/src/components/chat/__tests__/tool-execution-display.test.tsx +0 -70
- package/src/components/chat/utils/__tests__/cited-sources.test.ts +0 -80
- package/src/components/chat/utils/__tests__/host-message.test.ts +0 -92
- package/src/components/chat/utils/__tests__/process-historical-messages-sources.test.ts +0 -138
- package/src/components/chat/utils/cited-sources.ts +0 -61
- package/src/components/chat/utils/host-message.ts +0 -87
- /package/dist/{chunk-2QBXG74C.js.map → chunk-6MLRFM3T.js.map} +0 -0
- /package/dist/{chunk-IBMHEOBV.js.map → chunk-B3UXNGVM.js.map} +0 -0
- /package/dist/{chunk-O6PO5BHE.js.map → chunk-B7LYKBCD.js.map} +0 -0
- /package/dist/{chunk-MGXSJI23.js.map → chunk-BUXGWBTF.js.map} +0 -0
- /package/dist/{chunk-OIKZDXNW.js.map → chunk-C7CTEUU7.js.map} +0 -0
- /package/dist/{chunk-HQSCJYCF.js.map → chunk-HGVW7OHI.js.map} +0 -0
- /package/dist/{chunk-FS3CTGIR.js.map → chunk-JKM5FH63.js.map} +0 -0
- /package/dist/{chunk-37CAZTLP.js.map → chunk-JOCVQZGT.js.map} +0 -0
- /package/dist/{chunk-ROOIHDLS.js.map → chunk-JR7I2AGL.js.map} +0 -0
- /package/dist/{chunk-25YIHMZ6.js.map → chunk-LA2W5L6K.js.map} +0 -0
- /package/dist/{chunk-V6TINNLD.js.map → chunk-MVBRMQGU.js.map} +0 -0
- /package/dist/{chunk-R2UDEMKK.js.map → chunk-OTYV6SDN.js.map} +0 -0
- /package/dist/{chunk-HZS4TV34.js.map → chunk-QX4ANESW.js.map} +0 -0
- /package/dist/{chunk-OJZW3GE2.js.map → chunk-TJ3GFULR.js.map} +0 -0
- /package/dist/{chunk-Q2CNCBMK.js.map → chunk-VCYRJY7J.js.map} +0 -0
|
@@ -247,16 +247,16 @@ import {
|
|
|
247
247
|
} from "@floating-ui/react";
|
|
248
248
|
import { useMemo, useState } from "react";
|
|
249
249
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
250
|
-
function parseColoredText(
|
|
251
|
-
if (typeof
|
|
250
|
+
function parseColoredText(text) {
|
|
251
|
+
if (typeof text !== "string") return text;
|
|
252
252
|
const parts = [];
|
|
253
253
|
let lastIndex = 0;
|
|
254
254
|
const colorRegex = /\[([A-Z]+)\](.*?)\[\/\1\]/g;
|
|
255
255
|
let match;
|
|
256
256
|
let keyIndex = 0;
|
|
257
|
-
while ((match = colorRegex.exec(
|
|
257
|
+
while ((match = colorRegex.exec(text)) !== null) {
|
|
258
258
|
if (match.index > lastIndex) {
|
|
259
|
-
const beforeText =
|
|
259
|
+
const beforeText = text.slice(lastIndex, match.index);
|
|
260
260
|
parts.push(/* @__PURE__ */ jsx("span", { children: beforeText }, `text-${keyIndex++}`));
|
|
261
261
|
}
|
|
262
262
|
const color = match[1].toLowerCase();
|
|
@@ -267,11 +267,11 @@ function parseColoredText(text2) {
|
|
|
267
267
|
);
|
|
268
268
|
lastIndex = match.index + match[0].length;
|
|
269
269
|
}
|
|
270
|
-
if (lastIndex <
|
|
271
|
-
const remainingText =
|
|
270
|
+
if (lastIndex < text.length) {
|
|
271
|
+
const remainingText = text.slice(lastIndex);
|
|
272
272
|
parts.push(/* @__PURE__ */ jsx("span", { children: remainingText }, `text-${keyIndex++}`));
|
|
273
273
|
}
|
|
274
|
-
return parts.length > 0 ? /* @__PURE__ */ jsx(Fragment, { children: parts }) :
|
|
274
|
+
return parts.length > 0 ? /* @__PURE__ */ jsx(Fragment, { children: parts }) : text;
|
|
275
275
|
}
|
|
276
276
|
function FloatingTooltip({
|
|
277
277
|
content,
|
|
@@ -1163,15 +1163,6 @@ var MESSAGE_TYPE = {
|
|
|
1163
1163
|
TEXT: "TEXT",
|
|
1164
1164
|
THINKING: "THINKING",
|
|
1165
1165
|
ASK: "ASK",
|
|
1166
|
-
/** Per-answer source metadata (documents, videos, entity cards).
|
|
1167
|
-
*
|
|
1168
|
-
* TWO names for ONE payload, on purpose. `SOURCES` is the contract the
|
|
1169
|
-
* backend is moving to; `GUIDE` is the envelope it ships in today, reused
|
|
1170
|
-
* from Guide Mode v2 so a released frontend keeps working during the v2→v3
|
|
1171
|
-
* rollout. Both decode through the same path, so dropping `GUIDE` later is a
|
|
1172
|
-
* deletion here and nothing else. */
|
|
1173
|
-
GUIDE: "GUIDE",
|
|
1174
|
-
SOURCES: "SOURCES",
|
|
1175
1166
|
EXECUTING_TOOL: "EXECUTING_TOOL",
|
|
1176
1167
|
EXECUTED_TOOL: "EXECUTED_TOOL",
|
|
1177
1168
|
APPROVAL_REQUEST: "APPROVAL_REQUEST",
|
|
@@ -1310,16 +1301,16 @@ function buildHeadingIdMap(content, sectionIds) {
|
|
|
1310
1301
|
let sectionOrdinal = 0;
|
|
1311
1302
|
let headingOrdinal = 0;
|
|
1312
1303
|
for (const { line, level, text: rawText } of scanHeadings(content)) {
|
|
1313
|
-
const
|
|
1304
|
+
const text = stripInlineMarkdown(rawText).trim();
|
|
1314
1305
|
headingOrdinal++;
|
|
1315
1306
|
if (level <= EXTRACTOR_MAX_LEVEL) sectionOrdinal++;
|
|
1316
1307
|
let assigned;
|
|
1317
1308
|
if (sectionIds && level <= EXTRACTOR_MAX_LEVEL) {
|
|
1318
1309
|
for (const variation of [
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
stripHeadingEmojis(
|
|
1322
|
-
stripHeadingEmojis(
|
|
1310
|
+
text,
|
|
1311
|
+
text.toLowerCase(),
|
|
1312
|
+
stripHeadingEmojis(text),
|
|
1313
|
+
stripHeadingEmojis(text).toLowerCase()
|
|
1323
1314
|
]) {
|
|
1324
1315
|
const id = sectionIdMap.get(variation);
|
|
1325
1316
|
if (id) {
|
|
@@ -1329,7 +1320,7 @@ function buildHeadingIdMap(content, sectionIds) {
|
|
|
1329
1320
|
}
|
|
1330
1321
|
}
|
|
1331
1322
|
if (assigned === void 0) {
|
|
1332
|
-
const baseId = slugifyHeadingText(
|
|
1323
|
+
const baseId = slugifyHeadingText(text);
|
|
1333
1324
|
assigned = dedupe(
|
|
1334
1325
|
baseId || (level <= EXTRACTOR_MAX_LEVEL ? `section-${sectionOrdinal}` : `heading-${headingOrdinal}`)
|
|
1335
1326
|
);
|
|
@@ -2320,8 +2311,8 @@ function findInlineCodeRanges(source) {
|
|
|
2320
2311
|
}
|
|
2321
2312
|
return ranges;
|
|
2322
2313
|
}
|
|
2323
|
-
function foldAsciiCase(
|
|
2324
|
-
return
|
|
2314
|
+
function foldAsciiCase(text) {
|
|
2315
|
+
return text.replace(/[A-Z]/g, (c) => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
2325
2316
|
}
|
|
2326
2317
|
function blankRanges(masked, ranges) {
|
|
2327
2318
|
if (ranges.length === 0) return masked;
|
|
@@ -2563,13 +2554,13 @@ function footnoteLabelEnd(c, open) {
|
|
|
2563
2554
|
}
|
|
2564
2555
|
function blankUnreferencedFootnotes(masked, lines, folded) {
|
|
2565
2556
|
if (masked.indexOf("[^") === -1) return masked;
|
|
2566
|
-
const
|
|
2557
|
+
const text = (line) => stripCr(masked.slice(line.contentStart, line.contentStart + line.content.length));
|
|
2567
2558
|
const refMask = footnoteReferenceMask(masked, folded);
|
|
2568
2559
|
const refText = (line) => stripCr(refMask.slice(line.contentStart, line.contentStart + line.content.length));
|
|
2569
2560
|
const referenced = /* @__PURE__ */ new Set();
|
|
2570
2561
|
const defAt = [];
|
|
2571
2562
|
for (const line of lines) {
|
|
2572
|
-
const c =
|
|
2563
|
+
const c = text(line);
|
|
2573
2564
|
let isDef = null;
|
|
2574
2565
|
if (c.indexOf("[^") !== -1) {
|
|
2575
2566
|
const open = FOOTNOTE_DEF_OPEN_RE.exec(c);
|
|
@@ -2598,13 +2589,13 @@ function blankUnreferencedFootnotes(masked, lines, folded) {
|
|
|
2598
2589
|
for (let i = 0; i < lines.length; i++) {
|
|
2599
2590
|
const at = defAt[i];
|
|
2600
2591
|
if (at === null) continue;
|
|
2601
|
-
const head =
|
|
2592
|
+
const head = text(lines[i]);
|
|
2602
2593
|
const end = footnoteLabelEnd(head, at);
|
|
2603
2594
|
if (referenced.has(normalizeFootnoteLabel(head.slice(at + 2, end)))) continue;
|
|
2604
2595
|
let j = i;
|
|
2605
2596
|
let sawBlank = false;
|
|
2606
2597
|
for (let k = i + 1; k < lines.length; k++) {
|
|
2607
|
-
const c =
|
|
2598
|
+
const c = text(lines[k]);
|
|
2608
2599
|
if (isBlankLine(c)) {
|
|
2609
2600
|
sawBlank = true;
|
|
2610
2601
|
continue;
|
|
@@ -2787,9 +2778,9 @@ function spliceWindows(masked, edits) {
|
|
|
2787
2778
|
if (edits.length === 0) return masked;
|
|
2788
2779
|
const parts = [];
|
|
2789
2780
|
let cursor = 0;
|
|
2790
|
-
for (const [from, to,
|
|
2781
|
+
for (const [from, to, text] of edits) {
|
|
2791
2782
|
if (from > cursor) parts.push(masked.slice(cursor, from));
|
|
2792
|
-
parts.push(
|
|
2783
|
+
parts.push(text);
|
|
2793
2784
|
cursor = to;
|
|
2794
2785
|
}
|
|
2795
2786
|
parts.push(masked.slice(cursor));
|
|
@@ -2893,8 +2884,8 @@ function blankListItemCode(masked, lines, depth = 0) {
|
|
|
2893
2884
|
flush();
|
|
2894
2885
|
return spliceWindows(masked, edits);
|
|
2895
2886
|
}
|
|
2896
|
-
function buildCloserHaystack(
|
|
2897
|
-
const folded = foldAsciiCase(
|
|
2887
|
+
function buildCloserHaystack(text) {
|
|
2888
|
+
const folded = foldAsciiCase(text);
|
|
2898
2889
|
const lines = toMaskLines(folded);
|
|
2899
2890
|
let masked = blankRanges(folded, findInlineCodeRanges(folded));
|
|
2900
2891
|
masked = blankFencedRegions(masked, lines);
|
|
@@ -3081,8 +3072,8 @@ function htmlBlockStartKind(line, inParagraph) {
|
|
|
3081
3072
|
if (!inParagraph && HTML_BLOCK_START_7.test(line)) return 7;
|
|
3082
3073
|
return null;
|
|
3083
3074
|
}
|
|
3084
|
-
function computeHtmlBlockRanges(
|
|
3085
|
-
if (
|
|
3075
|
+
function computeHtmlBlockRanges(text) {
|
|
3076
|
+
if (text.indexOf("<") === -1) return [];
|
|
3086
3077
|
const ranges = [];
|
|
3087
3078
|
const fences = createFenceTracker();
|
|
3088
3079
|
let kind = null;
|
|
@@ -3092,7 +3083,7 @@ function computeHtmlBlockRanges(text2) {
|
|
|
3092
3083
|
let offset2 = 0;
|
|
3093
3084
|
let listContentCol = 0;
|
|
3094
3085
|
let openPrefixLen = 0;
|
|
3095
|
-
for (const line of
|
|
3086
|
+
for (const line of text.split("\n")) {
|
|
3096
3087
|
const lineStart = offset2;
|
|
3097
3088
|
const lineEnd = offset2 + line.length;
|
|
3098
3089
|
offset2 = lineEnd + 1;
|
|
@@ -3154,21 +3145,21 @@ function escapeLeftoverTagStarts(gap, lowerSource, gapOffset) {
|
|
|
3154
3145
|
(m, slash, tag, at) => isMaskedBlank(lowerSource, gapOffset + at, gapOffset + at + m.length) ? m : `<${slash}${tag}`
|
|
3155
3146
|
);
|
|
3156
3147
|
}
|
|
3157
|
-
function escapeUnknownHtmlTags(
|
|
3158
|
-
if (!
|
|
3159
|
-
const lowerSource = buildCloserHaystack(
|
|
3148
|
+
function escapeUnknownHtmlTags(text, allowedTags = SAFE_HTML_TAGS) {
|
|
3149
|
+
if (!text || text.indexOf("<") === -1) return text;
|
|
3150
|
+
const lowerSource = buildCloserHaystack(text);
|
|
3160
3151
|
let htmlBlocks = null;
|
|
3161
3152
|
const spanInsideHtmlBlock = (from, to) => {
|
|
3162
|
-
htmlBlocks ?? (htmlBlocks = computeHtmlBlockRanges(
|
|
3153
|
+
htmlBlocks ?? (htmlBlocks = computeHtmlBlockRanges(text));
|
|
3163
3154
|
return htmlBlocks.some((r) => r.start < to && r.end > from);
|
|
3164
3155
|
};
|
|
3165
3156
|
const parts = [];
|
|
3166
3157
|
let cursor = 0;
|
|
3167
3158
|
PROTECTED_SPAN_RE.lastIndex = 0;
|
|
3168
3159
|
let span;
|
|
3169
|
-
while ((span = PROTECTED_SPAN_RE.exec(
|
|
3160
|
+
while ((span = PROTECTED_SPAN_RE.exec(text)) !== null) {
|
|
3170
3161
|
if (span.index > cursor) {
|
|
3171
|
-
parts.push(escapeOutsideFences(
|
|
3162
|
+
parts.push(escapeOutsideFences(text.slice(cursor, span.index), allowedTags, lowerSource, cursor));
|
|
3172
3163
|
}
|
|
3173
3164
|
const isFence = span[1] !== void 0;
|
|
3174
3165
|
const spanEnd = span.index + span[0].length;
|
|
@@ -3177,8 +3168,8 @@ function escapeUnknownHtmlTags(text2, allowedTags = SAFE_HTML_TAGS) {
|
|
|
3177
3168
|
);
|
|
3178
3169
|
cursor = span.index + span[0].length;
|
|
3179
3170
|
}
|
|
3180
|
-
if (cursor <
|
|
3181
|
-
parts.push(escapeOutsideFences(
|
|
3171
|
+
if (cursor < text.length) {
|
|
3172
|
+
parts.push(escapeOutsideFences(text.slice(cursor), allowedTags, lowerSource, cursor));
|
|
3182
3173
|
}
|
|
3183
3174
|
return parts.join("");
|
|
3184
3175
|
}
|
|
@@ -3361,12 +3352,12 @@ function splitStreamingBlocks(content) {
|
|
|
3361
3352
|
}
|
|
3362
3353
|
let cursorLine = 1;
|
|
3363
3354
|
return units.map((unitLines, idx) => {
|
|
3364
|
-
const
|
|
3355
|
+
const text = unitLines.join("\n");
|
|
3365
3356
|
const isTail = idx === units.length - 1;
|
|
3366
3357
|
const startLine = cursorLine;
|
|
3367
3358
|
cursorLine += unitLines.length;
|
|
3368
3359
|
return {
|
|
3369
|
-
text
|
|
3360
|
+
text,
|
|
3370
3361
|
index: idx,
|
|
3371
3362
|
startLine,
|
|
3372
3363
|
// Units carrying UNBALANCED raw HTML are never cached: an open
|
|
@@ -3376,7 +3367,7 @@ function splitStreamingBlocks(content) {
|
|
|
3376
3367
|
// opens AND closes within the unit (`<div>x</div>`) leaves the
|
|
3377
3368
|
// scanner's depth unchanged, so it stays memoizable — correctly: its
|
|
3378
3369
|
// parse cannot be invalidated by later tokens.
|
|
3379
|
-
memoizable: !isTail && !unitTouchedHtml[idx] && !NON_MEMOIZABLE_RE.test(
|
|
3370
|
+
memoizable: !isTail && !unitTouchedHtml[idx] && !NON_MEMOIZABLE_RE.test(text)
|
|
3380
3371
|
};
|
|
3381
3372
|
});
|
|
3382
3373
|
}
|
|
@@ -3465,7 +3456,7 @@ function resolveTextSizeConfig(config) {
|
|
|
3465
3456
|
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
3466
3457
|
var NO_BROKEN_LINKS = [];
|
|
3467
3458
|
var StreamingBlockRenderer = memo(function StreamingBlockRendererImpl({
|
|
3468
|
-
text
|
|
3459
|
+
text,
|
|
3469
3460
|
remarkPlugins,
|
|
3470
3461
|
rehypePlugins,
|
|
3471
3462
|
components
|
|
@@ -3477,7 +3468,7 @@ var StreamingBlockRenderer = memo(function StreamingBlockRendererImpl({
|
|
|
3477
3468
|
rehypePlugins,
|
|
3478
3469
|
urlTransform: cardAwareUrlTransform,
|
|
3479
3470
|
components,
|
|
3480
|
-
children:
|
|
3471
|
+
children: text
|
|
3481
3472
|
}
|
|
3482
3473
|
);
|
|
3483
3474
|
});
|
|
@@ -3625,7 +3616,7 @@ var thoughtMdClasses = [
|
|
|
3625
3616
|
"[&_.code-block-container_>div:last-child]:!p-3"
|
|
3626
3617
|
].join(" ");
|
|
3627
3618
|
var ThinkingDisplay = forwardRef8(
|
|
3628
|
-
({ className, text
|
|
3619
|
+
({ className, text, isStreaming = false, ...props }, ref) => {
|
|
3629
3620
|
const [expanded, setExpanded] = useState7(false);
|
|
3630
3621
|
const { innerRef, isOverflowing, containerStyle } = useCollapsible({
|
|
3631
3622
|
expanded,
|
|
@@ -3659,7 +3650,7 @@ var ThinkingDisplay = forwardRef8(
|
|
|
3659
3650
|
] }),
|
|
3660
3651
|
isStreaming && /* @__PURE__ */ jsx15(DotsLoaderIcon, { size: 16, className: "text-ods-text-secondary" })
|
|
3661
3652
|
] }),
|
|
3662
|
-
/* @__PURE__ */ jsx15("div", { className: "min-w-0 flex-1", style: containerStyle, children: /* @__PURE__ */ jsx15("div", { ref: innerRef, className: cn("text-sm leading-snug text-ods-text-secondary", thoughtMdClasses), children: /* @__PURE__ */ jsx15(SimpleMarkdownRenderer, { content:
|
|
3653
|
+
/* @__PURE__ */ jsx15("div", { className: "min-w-0 flex-1", style: containerStyle, children: /* @__PURE__ */ jsx15("div", { ref: innerRef, className: cn("text-sm leading-snug text-ods-text-secondary", thoughtMdClasses), children: /* @__PURE__ */ jsx15(SimpleMarkdownRenderer, { content: text, textSize: "compact" }) }) }),
|
|
3663
3654
|
canToggle && /* @__PURE__ */ jsx15("div", { className: "flex h-[19px] shrink-0 items-center", children: /* @__PURE__ */ jsx15(ExpandChevron, { expanded }) })
|
|
3664
3655
|
]
|
|
3665
3656
|
}
|
|
@@ -3672,15 +3663,15 @@ ThinkingDisplay.displayName = "ThinkingDisplay";
|
|
|
3672
3663
|
import { forwardRef as forwardRef9, useEffect as useEffect2, useId, useState as useState8 } from "react";
|
|
3673
3664
|
import { Fragment as Fragment3, jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3674
3665
|
var LOCKED_HINT = "This question was already answered";
|
|
3675
|
-
var AskDisplay = forwardRef9(({ className, cards
|
|
3666
|
+
var AskDisplay = forwardRef9(({ className, cards, onSelect, ...props }, ref) => {
|
|
3676
3667
|
const [index, setIndex] = useState8(0);
|
|
3677
3668
|
const lockedHintId = useId();
|
|
3678
3669
|
useEffect2(() => {
|
|
3679
|
-
setIndex((current) => current <
|
|
3680
|
-
}, [
|
|
3681
|
-
const active =
|
|
3670
|
+
setIndex((current) => current < cards.length ? current : Math.max(0, cards.length - 1));
|
|
3671
|
+
}, [cards.length]);
|
|
3672
|
+
const active = cards[Math.min(index, cards.length - 1)];
|
|
3682
3673
|
if (!active) return null;
|
|
3683
|
-
const showPager =
|
|
3674
|
+
const showPager = cards.length > 1;
|
|
3684
3675
|
const isInteractive = !!onSelect;
|
|
3685
3676
|
return /* @__PURE__ */ jsxs11(
|
|
3686
3677
|
"div",
|
|
@@ -3712,15 +3703,15 @@ var AskDisplay = forwardRef9(({ className, cards: cards2, onSelect, ...props },
|
|
|
3712
3703
|
/* @__PURE__ */ jsxs11("span", { className: "whitespace-nowrap text-ods-text-secondary text-h6", children: [
|
|
3713
3704
|
index + 1,
|
|
3714
3705
|
" of ",
|
|
3715
|
-
|
|
3706
|
+
cards.length
|
|
3716
3707
|
] }),
|
|
3717
3708
|
/* @__PURE__ */ jsx16(
|
|
3718
3709
|
"button",
|
|
3719
3710
|
{
|
|
3720
3711
|
type: "button",
|
|
3721
3712
|
"aria-label": "Next question",
|
|
3722
|
-
disabled: index ===
|
|
3723
|
-
onClick: () => setIndex((current) => Math.min(
|
|
3713
|
+
disabled: index === cards.length - 1,
|
|
3714
|
+
onClick: () => setIndex((current) => Math.min(cards.length - 1, current + 1)),
|
|
3724
3715
|
className: "text-ods-text-secondary transition-colors hover:text-ods-text-primary disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:text-ods-text-secondary",
|
|
3725
3716
|
children: /* @__PURE__ */ jsx16(Chevron02RightIcon, { size: 16 })
|
|
3726
3717
|
}
|
|
@@ -5787,12 +5778,12 @@ function placeCaretAtOffset(el, offset2) {
|
|
|
5787
5778
|
sel.removeAllRanges();
|
|
5788
5779
|
sel.addRange(range);
|
|
5789
5780
|
}
|
|
5790
|
-
function insertTextAtCaret(
|
|
5781
|
+
function insertTextAtCaret(text) {
|
|
5791
5782
|
const sel = typeof window !== "undefined" ? window.getSelection() : null;
|
|
5792
5783
|
if (!sel || sel.rangeCount === 0) return;
|
|
5793
5784
|
const range = sel.getRangeAt(0);
|
|
5794
5785
|
range.deleteContents();
|
|
5795
|
-
const tn = document.createTextNode(
|
|
5786
|
+
const tn = document.createTextNode(text);
|
|
5796
5787
|
range.insertNode(tn);
|
|
5797
5788
|
range.setStartAfter(tn);
|
|
5798
5789
|
range.collapse(true);
|
|
@@ -5994,9 +5985,9 @@ var ChatInput = forwardRef14((allProps, ref) => {
|
|
|
5994
5985
|
const handlePaste = useCallback2(
|
|
5995
5986
|
(e) => {
|
|
5996
5987
|
e.preventDefault();
|
|
5997
|
-
const
|
|
5998
|
-
if (!
|
|
5999
|
-
insertTextAtCaret(
|
|
5988
|
+
const text = e.clipboardData.getData("text/plain");
|
|
5989
|
+
if (!text) return;
|
|
5990
|
+
insertTextAtCaret(text);
|
|
6000
5991
|
syncFromDom();
|
|
6001
5992
|
},
|
|
6002
5993
|
[syncFromDom]
|
|
@@ -6253,14 +6244,6 @@ ChatInput.displayName = "ChatInput";
|
|
|
6253
6244
|
// src/components/chat/chat-message-enhanced.tsx
|
|
6254
6245
|
import React2, { forwardRef as forwardRef16, memo as memo2, useEffect as useEffect6, useMemo as useMemo8, useRef as useRef4 } from "react";
|
|
6255
6246
|
|
|
6256
|
-
// src/chat-protocol/card-marker.ts
|
|
6257
|
-
var CARD_TYPE = "[a-zA-Z0-9_-]+";
|
|
6258
|
-
var CARD_ID = "[^\\]\\r\\n)]+";
|
|
6259
|
-
var CARD_REFERENCE = new RegExp(`^\\[card://(${CARD_TYPE}):(${CARD_ID})\\]$`);
|
|
6260
|
-
function createCardMarkerScanner() {
|
|
6261
|
-
return new RegExp(`\\[card://(${CARD_TYPE}):(${CARD_ID})[\\])]`, "g");
|
|
6262
|
-
}
|
|
6263
|
-
|
|
6264
6247
|
// src/utils/date-utils.ts
|
|
6265
6248
|
function formatTicketRelativeTime(iso) {
|
|
6266
6249
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -6814,21 +6797,21 @@ function BlockCard(_props) {
|
|
|
6814
6797
|
|
|
6815
6798
|
// src/components/chat/remark-card-links.ts
|
|
6816
6799
|
import { visit, SKIP } from "unist-util-visit";
|
|
6817
|
-
var CARD_REGEX =
|
|
6800
|
+
var CARD_REGEX = /\[card:\/\/([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)[\])]/g;
|
|
6818
6801
|
var remarkCardLinks = () => {
|
|
6819
6802
|
return (tree) => {
|
|
6820
6803
|
visit(tree, "text", (node, index, parent) => {
|
|
6821
6804
|
if (!parent || typeof index !== "number") return void 0;
|
|
6822
|
-
const
|
|
6823
|
-
if (!
|
|
6805
|
+
const text = node.value;
|
|
6806
|
+
if (!text || !text.includes("[card://")) return void 0;
|
|
6824
6807
|
const parts = [];
|
|
6825
6808
|
let lastIndex = 0;
|
|
6826
6809
|
CARD_REGEX.lastIndex = 0;
|
|
6827
6810
|
let match;
|
|
6828
|
-
while ((match = CARD_REGEX.exec(
|
|
6811
|
+
while ((match = CARD_REGEX.exec(text)) !== null) {
|
|
6829
6812
|
const matchStart = match.index;
|
|
6830
6813
|
if (matchStart > lastIndex) {
|
|
6831
|
-
parts.push({ type: "text", value:
|
|
6814
|
+
parts.push({ type: "text", value: text.slice(lastIndex, matchStart) });
|
|
6832
6815
|
}
|
|
6833
6816
|
const cardType = match[1];
|
|
6834
6817
|
const cardId = match[2];
|
|
@@ -6843,8 +6826,8 @@ var remarkCardLinks = () => {
|
|
|
6843
6826
|
lastIndex = matchStart + match[0].length;
|
|
6844
6827
|
}
|
|
6845
6828
|
if (lastIndex === 0) return void 0;
|
|
6846
|
-
if (lastIndex <
|
|
6847
|
-
parts.push({ type: "text", value:
|
|
6829
|
+
if (lastIndex < text.length) {
|
|
6830
|
+
parts.push({ type: "text", value: text.slice(lastIndex) });
|
|
6848
6831
|
}
|
|
6849
6832
|
parent.children.splice(index, 1, ...parts);
|
|
6850
6833
|
return [SKIP, index + parts.length];
|
|
@@ -6859,19 +6842,19 @@ var remarkMentionChips = () => {
|
|
|
6859
6842
|
return (tree) => {
|
|
6860
6843
|
visit2(tree, "text", (node, index, parent) => {
|
|
6861
6844
|
if (!parent || typeof index !== "number") return void 0;
|
|
6862
|
-
const
|
|
6863
|
-
if (!
|
|
6845
|
+
const text = node.value;
|
|
6846
|
+
if (!text || !text.includes("@")) return void 0;
|
|
6864
6847
|
const parts = [];
|
|
6865
6848
|
let lastIndex = 0;
|
|
6866
6849
|
MENTION_REGEX.lastIndex = 0;
|
|
6867
6850
|
let match;
|
|
6868
|
-
while ((match = MENTION_REGEX.exec(
|
|
6851
|
+
while ((match = MENTION_REGEX.exec(text)) !== null) {
|
|
6869
6852
|
const lead = match[1];
|
|
6870
6853
|
const marker = match[2];
|
|
6871
6854
|
const id = match[3];
|
|
6872
6855
|
const tokenStart = match.index + lead.length;
|
|
6873
6856
|
if (tokenStart > lastIndex) {
|
|
6874
|
-
parts.push({ type: "text", value:
|
|
6857
|
+
parts.push({ type: "text", value: text.slice(lastIndex, tokenStart) });
|
|
6875
6858
|
}
|
|
6876
6859
|
parts.push({
|
|
6877
6860
|
type: "link",
|
|
@@ -6883,8 +6866,8 @@ var remarkMentionChips = () => {
|
|
|
6883
6866
|
lastIndex = match.index + match[0].length;
|
|
6884
6867
|
}
|
|
6885
6868
|
if (lastIndex === 0) return void 0;
|
|
6886
|
-
if (lastIndex <
|
|
6887
|
-
parts.push({ type: "text", value:
|
|
6869
|
+
if (lastIndex < text.length) {
|
|
6870
|
+
parts.push({ type: "text", value: text.slice(lastIndex) });
|
|
6888
6871
|
}
|
|
6889
6872
|
parent.children.splice(index, 1, ...parts);
|
|
6890
6873
|
return [SKIP2, index + parts.length];
|
|
@@ -6936,8 +6919,6 @@ var ToolExecutionDisplay = forwardRef15(
|
|
|
6936
6919
|
return [...commandEntries, ...otherEntries];
|
|
6937
6920
|
}, [message.parameters, variant]);
|
|
6938
6921
|
const hasResult = isExecuted && typeof message.result === "string" && message.result.length > 0;
|
|
6939
|
-
const isConciseRemoteRead = !message.integratedToolType && !!previewText && argEntries.length === 0 && !hasResult;
|
|
6940
|
-
const isStaticRow = isClientView || isConciseRemoteRead;
|
|
6941
6922
|
const hasBody = argEntries.length > 0 || hasResult || isExecuting;
|
|
6942
6923
|
const renderStatusIcon = () => {
|
|
6943
6924
|
if (isExecuting) return /* @__PURE__ */ jsx34(DotsLoaderIcon, { size: 16, className: "text-ods-text-secondary" });
|
|
@@ -6958,7 +6939,7 @@ var ToolExecutionDisplay = forwardRef15(
|
|
|
6958
6939
|
}
|
|
6959
6940
|
),
|
|
6960
6941
|
/* @__PURE__ */ jsx34("div", { className: "flex h-5 w-5 shrink-0 items-center justify-center", children: renderStatusIcon() }),
|
|
6961
|
-
!
|
|
6942
|
+
!isClientView && /* @__PURE__ */ jsx34("div", { className: "flex h-5 w-5 shrink-0 items-center justify-center", children: /* @__PURE__ */ jsx34(ExpandChevron, { expanded }) })
|
|
6962
6943
|
] });
|
|
6963
6944
|
return /* @__PURE__ */ jsx34(
|
|
6964
6945
|
"div",
|
|
@@ -6971,10 +6952,9 @@ var ToolExecutionDisplay = forwardRef15(
|
|
|
6971
6952
|
className
|
|
6972
6953
|
),
|
|
6973
6954
|
...props,
|
|
6974
|
-
children:
|
|
6975
|
-
//
|
|
6976
|
-
//
|
|
6977
|
-
// detail) and a remote read-only tool (there IS no detail).
|
|
6955
|
+
children: isClientView ? (
|
|
6956
|
+
// Client (Fae end-user): static, non-expandable row — no chevron, no
|
|
6957
|
+
// body. Just the explanation + status; command/args/result are hidden.
|
|
6978
6958
|
/* @__PURE__ */ jsx34("div", { className: "flex w-full items-start gap-[var(--spacing-system-xs)] p-[var(--spacing-system-s)] text-left", children: headerContent })
|
|
6979
6959
|
) : /* @__PURE__ */ jsxs24(Fragment9, { children: [
|
|
6980
6960
|
/* @__PURE__ */ jsx34(
|
|
@@ -7019,7 +6999,7 @@ ToolExecutionDisplay.displayName = "ToolExecutionDisplay";
|
|
|
7019
6999
|
// src/components/chat/chat-message-enhanced.tsx
|
|
7020
7000
|
import { Fragment as Fragment10, jsx as jsx35, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
7021
7001
|
var MENTION_MARKER_REGEX = /(^|[^\w@])@[a-zA-Z]+:([A-Za-z0-9_.+/=-]*[A-Za-z0-9_+/=])/g;
|
|
7022
|
-
var CARD_MARKER_REGEX =
|
|
7002
|
+
var CARD_MARKER_REGEX = /\[card:\/\/([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)[\])]/g;
|
|
7023
7003
|
function formatMessageTimestamp(timestamp) {
|
|
7024
7004
|
const time = formatTime(timestamp);
|
|
7025
7005
|
return isToday(timestamp) ? time : `${formatDate(timestamp)} ${time}`;
|
|
@@ -7066,7 +7046,6 @@ var ChatMessageEnhanced = forwardRef16(
|
|
|
7066
7046
|
renderContextItem,
|
|
7067
7047
|
renderMention,
|
|
7068
7048
|
renderEntityCard,
|
|
7069
|
-
refs,
|
|
7070
7049
|
onAskSelect,
|
|
7071
7050
|
NavLinkAnchor,
|
|
7072
7051
|
...props
|
|
@@ -7101,11 +7080,6 @@ var ChatMessageEnhanced = forwardRef16(
|
|
|
7101
7080
|
const renderedCardNodeCache = useRef4(
|
|
7102
7081
|
/* @__PURE__ */ new Map()
|
|
7103
7082
|
);
|
|
7104
|
-
const refByKey = useMemo8(() => {
|
|
7105
|
-
const byKey = /* @__PURE__ */ new Map();
|
|
7106
|
-
for (const described of refs ?? []) byKey.set(`${described.type}:${described.id}`, described);
|
|
7107
|
-
return byKey;
|
|
7108
|
-
}, [refs]);
|
|
7109
7083
|
const renderingPlan = useMemo8(() => {
|
|
7110
7084
|
if (!hasMarkerSupport) return null;
|
|
7111
7085
|
const render = renderEntityCard;
|
|
@@ -7117,33 +7091,32 @@ var ChatMessageEnhanced = forwardRef16(
|
|
|
7117
7091
|
const emittedBlockKeys = /* @__PURE__ */ new Set();
|
|
7118
7092
|
segments.forEach((segment, segIdx) => {
|
|
7119
7093
|
if (segment.type !== "text") return;
|
|
7120
|
-
const
|
|
7094
|
+
const text = segment.text;
|
|
7121
7095
|
const parts = [];
|
|
7122
7096
|
let cursor = 0;
|
|
7123
7097
|
CARD_MARKER_REGEX.lastIndex = 0;
|
|
7124
7098
|
let match;
|
|
7125
|
-
while ((match = CARD_MARKER_REGEX.exec(
|
|
7099
|
+
while ((match = CARD_MARKER_REGEX.exec(text)) !== null) {
|
|
7126
7100
|
const cardType = match[1];
|
|
7127
7101
|
const cardId = match[2];
|
|
7128
7102
|
const key = `${cardType}:${cardId}`;
|
|
7129
7103
|
usedKeys.add(key);
|
|
7130
|
-
const describedRef = refByKey.get(key);
|
|
7131
7104
|
let entry = cache.get(key);
|
|
7132
|
-
if (!entry || entry.render !== render
|
|
7133
|
-
const refForRender =
|
|
7105
|
+
if (!entry || entry.render !== render) {
|
|
7106
|
+
const refForRender = {
|
|
7134
7107
|
type: cardType,
|
|
7135
7108
|
id: cardId,
|
|
7136
7109
|
title: cardId,
|
|
7137
7110
|
url: null
|
|
7138
7111
|
};
|
|
7139
|
-
entry = { render,
|
|
7112
|
+
entry = { render, node: render(refForRender) };
|
|
7140
7113
|
cache.set(key, entry);
|
|
7141
7114
|
}
|
|
7142
7115
|
const rendered = entry.node;
|
|
7143
7116
|
if (React2.isValidElement(rendered) && rendered.type === BlockCard) {
|
|
7144
7117
|
const cardProps = rendered.props;
|
|
7145
7118
|
const markerEnd = match.index + match[0].length;
|
|
7146
|
-
parts.push({ kind: "text", text:
|
|
7119
|
+
parts.push({ kind: "text", text: text.slice(cursor, markerEnd) });
|
|
7147
7120
|
if (!emittedBlockKeys.has(key)) {
|
|
7148
7121
|
emittedBlockKeys.add(key);
|
|
7149
7122
|
parts.push({ kind: "block", key, node: cardProps.children });
|
|
@@ -7154,7 +7127,7 @@ var ChatMessageEnhanced = forwardRef16(
|
|
|
7154
7127
|
cardProps.inline != null ? cardProps.inline : /* @__PURE__ */ jsx35("span", { className: "font-medium text-ods-text-primary", children: cardId })
|
|
7155
7128
|
);
|
|
7156
7129
|
} else if (rendered != null) {
|
|
7157
|
-
parts.push({ kind: "text", text:
|
|
7130
|
+
parts.push({ kind: "text", text: text.slice(cursor, match.index) });
|
|
7158
7131
|
if (!emittedBlockKeys.has(key)) {
|
|
7159
7132
|
emittedBlockKeys.add(key);
|
|
7160
7133
|
parts.push({ kind: "block", key, node: rendered });
|
|
@@ -7162,15 +7135,15 @@ var ChatMessageEnhanced = forwardRef16(
|
|
|
7162
7135
|
cursor = match.index + match[0].length;
|
|
7163
7136
|
}
|
|
7164
7137
|
}
|
|
7165
|
-
if (cursor <
|
|
7166
|
-
parts.push({ kind: "text", text:
|
|
7138
|
+
if (cursor < text.length) {
|
|
7139
|
+
parts.push({ kind: "text", text: text.slice(cursor) });
|
|
7167
7140
|
}
|
|
7168
7141
|
if (parts.some((p) => p.kind === "block")) {
|
|
7169
7142
|
partsBySegment.set(segIdx, parts);
|
|
7170
7143
|
}
|
|
7171
7144
|
});
|
|
7172
7145
|
return { inlineByKey, partsBySegment, usedKeys };
|
|
7173
|
-
}, [hasMarkerSupport, renderEntityCard,
|
|
7146
|
+
}, [hasMarkerSupport, renderEntityCard, segments]);
|
|
7174
7147
|
useEffect6(() => {
|
|
7175
7148
|
const cache = renderedCardNodeCache.current;
|
|
7176
7149
|
const usedKeys = renderingPlan?.usedKeys;
|
|
@@ -7219,13 +7192,13 @@ var ChatMessageEnhanced = forwardRef16(
|
|
|
7219
7192
|
}
|
|
7220
7193
|
};
|
|
7221
7194
|
}, [hasMarkerSupport, hasMentionSupport, renderMention, NavLinkAnchor]);
|
|
7222
|
-
const renderSegmentBody = (segIndex,
|
|
7195
|
+
const renderSegmentBody = (segIndex, text, isStreaming) => {
|
|
7223
7196
|
const parts = renderingPlan?.partsBySegment.get(segIndex);
|
|
7224
7197
|
if (!parts || parts.length === 0) {
|
|
7225
7198
|
return /* @__PURE__ */ jsx35(
|
|
7226
7199
|
SimpleMarkdownRenderer,
|
|
7227
7200
|
{
|
|
7228
|
-
content:
|
|
7201
|
+
content: text,
|
|
7229
7202
|
textSize: "compact",
|
|
7230
7203
|
additionalRemarkPlugins: cardRemarkPlugins,
|
|
7231
7204
|
componentOverrides: cardComponentOverrides,
|
|
@@ -7397,9 +7370,7 @@ var MemoizedChatMessageEnhanced = memo2(ChatMessageEnhanced, (prevProps, nextPro
|
|
|
7397
7370
|
// message (it's set once on the optimistic send and never mutated).
|
|
7398
7371
|
prevProps.contextItems === nextProps.contextItems && prevProps.resolveContextIcon === nextProps.resolveContextIcon && prevProps.renderContextItem === nextProps.renderContextItem && // Host keeps this stable (module const / useCallback), so reference
|
|
7399
7372
|
// equality holds across streaming chunks.
|
|
7400
|
-
prevProps.renderMention === nextProps.renderMention && prevProps.renderEntityCard === nextProps.renderEntityCard && //
|
|
7401
|
-
// forwards the same array instance, so it holds across streaming chunks.
|
|
7402
|
-
prevProps.refs === nextProps.refs && // Same stability contract as the renderers above: hosts pass a `useCallback`
|
|
7373
|
+
prevProps.renderMention === nextProps.renderMention && prevProps.renderEntityCard === nextProps.renderEntityCard && // Same stability contract as the renderers above: hosts pass a `useCallback`
|
|
7403
7374
|
// (EmbeddableChat passes its memoized `handleSend`), so this holds across
|
|
7404
7375
|
// streaming chunks instead of re-rendering every ask card per chunk.
|
|
7405
7376
|
prevProps.onAskSelect === nextProps.onAskSelect && prevProps.NavLinkAnchor === nextProps.NavLinkAnchor;
|
|
@@ -7496,11 +7467,11 @@ var BLINK_KEYFRAMES = `
|
|
|
7496
7467
|
`;
|
|
7497
7468
|
function CyclingPhrase({ words, className, charMs = 60, holdMs = 4500 }) {
|
|
7498
7469
|
const [wordIndex, setWordIndex] = useState13(0);
|
|
7499
|
-
const [
|
|
7470
|
+
const [text, setText] = useState13("");
|
|
7500
7471
|
const [cursor, setCursor] = useState13(0);
|
|
7501
7472
|
const target = words[wordIndex] ?? "";
|
|
7502
|
-
const holding = words.length > 0 && cursor >= Math.max(
|
|
7503
|
-
const shownText = holding ? target :
|
|
7473
|
+
const holding = words.length > 0 && cursor >= Math.max(text.length, target.length);
|
|
7474
|
+
const shownText = holding ? target : text;
|
|
7504
7475
|
const placeholder = useMemo9(
|
|
7505
7476
|
() => words.reduce((longest, w) => w.length > longest.length ? w : longest, ""),
|
|
7506
7477
|
[words]
|
|
@@ -7526,7 +7497,7 @@ function CyclingPhrase({ words, className, charMs = 60, holdMs = 4500 }) {
|
|
|
7526
7497
|
setCursor((c) => c + 1);
|
|
7527
7498
|
}, charMs);
|
|
7528
7499
|
return () => clearTimeout(timeoutId);
|
|
7529
|
-
}, [wordIndex, cursor,
|
|
7500
|
+
}, [wordIndex, cursor, text, holding, target, words, charMs, holdMs]);
|
|
7530
7501
|
if (words.length === 0) return null;
|
|
7531
7502
|
const before = shownText.slice(0, cursor);
|
|
7532
7503
|
const after = shownText.slice(cursor);
|
|
@@ -7610,7 +7581,6 @@ var ChatMessageList = forwardRef17(
|
|
|
7610
7581
|
resolveContextIcon,
|
|
7611
7582
|
renderContextItem,
|
|
7612
7583
|
renderMention,
|
|
7613
|
-
renderAfterMessage,
|
|
7614
7584
|
onAskSelect,
|
|
7615
7585
|
NavLinkAnchor,
|
|
7616
7586
|
...props
|
|
@@ -7968,8 +7938,7 @@ var ChatMessageList = forwardRef17(
|
|
|
7968
7938
|
if (message.hidden) return null;
|
|
7969
7939
|
const isEmptyPendingTurn = index === messages.length - 1 && isTyping && message.role === "assistant" && !hasNonEmptyContent(message.content) && (!Array.isArray(message.content) || message.content.every((s) => s.type === "text"));
|
|
7970
7940
|
if (isEmptyPendingTurn) return null;
|
|
7971
|
-
|
|
7972
|
-
const row = /* @__PURE__ */ jsx38(
|
|
7941
|
+
return /* @__PURE__ */ jsx38(
|
|
7973
7942
|
MemoizedChatMessageEnhanced,
|
|
7974
7943
|
{
|
|
7975
7944
|
ref: getRegisterMessageEl(message.id),
|
|
@@ -7989,17 +7958,11 @@ var ChatMessageList = forwardRef17(
|
|
|
7989
7958
|
renderContextItem,
|
|
7990
7959
|
renderMention,
|
|
7991
7960
|
renderEntityCard,
|
|
7992
|
-
refs: message.refs,
|
|
7993
7961
|
onAskSelect: index > lastUserMessageIndex ? onAskSelect : void 0,
|
|
7994
7962
|
NavLinkAnchor
|
|
7995
7963
|
},
|
|
7996
7964
|
message.id
|
|
7997
7965
|
);
|
|
7998
|
-
if (!ownedContent) return row;
|
|
7999
|
-
return /* @__PURE__ */ jsxs28("div", { className: "flex w-full min-w-0 flex-col", children: [
|
|
8000
|
-
row,
|
|
8001
|
-
ownedContent
|
|
8002
|
-
] }, message.id);
|
|
8003
7966
|
})
|
|
8004
7967
|
]
|
|
8005
7968
|
}
|
|
@@ -10594,8 +10557,8 @@ var ANTHROPIC_SUPPORTED_IMAGE_MIME = ["image/jpeg", "image/png", "image/webp", "
|
|
|
10594
10557
|
function buildChatAttachmentViewUrl(viewUrlPrefix, storagePath, viewToken) {
|
|
10595
10558
|
return `${viewUrlPrefix}${storagePath}?${CHAT_ATTACHMENT_VIEW_TOKEN_QUERY_PARAM}=${encodeURIComponent(viewToken)}`;
|
|
10596
10559
|
}
|
|
10597
|
-
function escapeMarkdownInline(
|
|
10598
|
-
return
|
|
10560
|
+
function escapeMarkdownInline(text) {
|
|
10561
|
+
return text.replace(/[[\]()\\\n\r<>"]/g, (ch) => {
|
|
10599
10562
|
switch (ch) {
|
|
10600
10563
|
case "\n":
|
|
10601
10564
|
return " ";
|
|
@@ -10624,10 +10587,10 @@ var CHAT_ATTACHMENT_MARKDOWN_PATTERN = new RegExp(
|
|
|
10624
10587
|
`^\\s*!?\\[[^\\]]*\\]\\(${CHAT_ATTACHMENT_VIEW_URL_PREFIX_REGEX_ESCAPED}[^)]+\\)\\s*$`,
|
|
10625
10588
|
"gm"
|
|
10626
10589
|
);
|
|
10627
|
-
function stripChatAttachmentMarkdown(
|
|
10590
|
+
function stripChatAttachmentMarkdown(text) {
|
|
10628
10591
|
const storagePaths = [];
|
|
10629
10592
|
const pathExtract = new RegExp(`\\(${CHAT_ATTACHMENT_VIEW_URL_PREFIX_REGEX_ESCAPED}([^?)]+)`);
|
|
10630
|
-
const stripped =
|
|
10593
|
+
const stripped = text.replace(CHAT_ATTACHMENT_MARKDOWN_PATTERN, (match) => {
|
|
10631
10594
|
const m = match.match(pathExtract);
|
|
10632
10595
|
if (m && m[1]) storagePaths.push(m[1]);
|
|
10633
10596
|
return "";
|
|
@@ -16102,11 +16065,11 @@ function makeSeqKey(messageType, chunkType, sequenceId) {
|
|
|
16102
16065
|
function makeBatchDedupKey(item) {
|
|
16103
16066
|
const seq = item.chunk.sequenceId ?? "na";
|
|
16104
16067
|
const type = typeof item.chunk.type === "string" ? item.chunk.type : "na";
|
|
16105
|
-
const
|
|
16068
|
+
const text = typeof item.chunk.text === "string" ? item.chunk.text : "";
|
|
16106
16069
|
const integratedToolType = typeof item.chunk.integratedToolType === "string" ? item.chunk.integratedToolType : "";
|
|
16107
16070
|
const toolFunction = typeof item.chunk.toolFunction === "string" ? item.chunk.toolFunction : "";
|
|
16108
16071
|
const approvalRequestId = typeof item.chunk.approvalRequestId === "string" ? item.chunk.approvalRequestId : typeof item.chunk.approval_request_id === "string" ? item.chunk.approval_request_id : "";
|
|
16109
|
-
return `${item.messageType}:${seq}:${type}:${
|
|
16072
|
+
return `${item.messageType}:${seq}:${type}:${text}:${integratedToolType}:${toolFunction}:${approvalRequestId}`;
|
|
16110
16073
|
}
|
|
16111
16074
|
function getChatTypeMessageType(chatType) {
|
|
16112
16075
|
return chatType === CHAT_TYPE.ADMIN ? "admin-message" : "message";
|
|
@@ -17620,12 +17583,12 @@ function useChat({
|
|
|
17620
17583
|
});
|
|
17621
17584
|
}, []);
|
|
17622
17585
|
const sendMessage = useCallback18(
|
|
17623
|
-
async (
|
|
17586
|
+
async (text, extra, options) => {
|
|
17624
17587
|
const userMessage = {
|
|
17625
17588
|
id: `user-${Date.now()}`,
|
|
17626
17589
|
role: "user",
|
|
17627
17590
|
name: "You",
|
|
17628
|
-
content:
|
|
17591
|
+
content: text,
|
|
17629
17592
|
timestamp: /* @__PURE__ */ new Date(),
|
|
17630
17593
|
...options?.hidden ? { hidden: true } : {}
|
|
17631
17594
|
};
|
|
@@ -17644,7 +17607,7 @@ function useChat({
|
|
|
17644
17607
|
try {
|
|
17645
17608
|
let receivedFirstTextChunk = false;
|
|
17646
17609
|
let currentTextSegment = "";
|
|
17647
|
-
for await (const rawSegment of streamMessage(
|
|
17610
|
+
for await (const rawSegment of streamMessage(text, extra)) {
|
|
17648
17611
|
const segment = asStreamFrame(rawSegment);
|
|
17649
17612
|
if (!receivedFirstTextChunk && segment.type === "text") {
|
|
17650
17613
|
setIsTyping(false);
|
|
@@ -17853,8 +17816,8 @@ var END_OF_LEADING = "";
|
|
|
17853
17816
|
var TRAILER_SENTINEL = "";
|
|
17854
17817
|
|
|
17855
17818
|
// src/chat-protocol/leading-frames.ts
|
|
17856
|
-
function escapeThinkingTags(
|
|
17857
|
-
return
|
|
17819
|
+
function escapeThinkingTags(text) {
|
|
17820
|
+
return text.replace(/</g, "<");
|
|
17858
17821
|
}
|
|
17859
17822
|
function frameStr(value) {
|
|
17860
17823
|
return typeof value === "string" ? value : void 0;
|
|
@@ -17965,11 +17928,11 @@ function isFrameObject(value) {
|
|
|
17965
17928
|
}
|
|
17966
17929
|
function frameTelemetry(value) {
|
|
17967
17930
|
if (!isFrameObject(value)) return void 0;
|
|
17968
|
-
const { cards
|
|
17969
|
-
if (typeof
|
|
17931
|
+
const { cards, chips, sentences, answerLen } = value;
|
|
17932
|
+
if (typeof cards !== "number" || typeof chips !== "number" || typeof sentences !== "number" || typeof answerLen !== "number") {
|
|
17970
17933
|
return void 0;
|
|
17971
17934
|
}
|
|
17972
|
-
return { cards
|
|
17935
|
+
return { cards, chips, sentences, answerLen };
|
|
17973
17936
|
}
|
|
17974
17937
|
function createSseFrameDecoder() {
|
|
17975
17938
|
const textDecoder = new TextDecoder();
|
|
@@ -18110,207 +18073,6 @@ function errorDetailsMessage(details) {
|
|
|
18110
18073
|
}
|
|
18111
18074
|
var CHAT_OWNER_ADMIN = "ADMIN";
|
|
18112
18075
|
|
|
18113
|
-
// src/chat-protocol/wire-narrow.ts
|
|
18114
|
-
function isRecord(value) {
|
|
18115
|
-
return typeof value === "object" && value !== null;
|
|
18116
|
-
}
|
|
18117
|
-
function unwrapEnvelope(payload) {
|
|
18118
|
-
return isRecord(payload) && "data" in payload ? payload.data : payload;
|
|
18119
|
-
}
|
|
18120
|
-
|
|
18121
|
-
// src/chat-protocol/source-metadata.ts
|
|
18122
|
-
var YOUTUBE_ID = /^[A-Za-z0-9_-]{11}$/;
|
|
18123
|
-
var VIDEO_URL_KEYS = ["videoUrl", "highlightVideoUrl", "videoPoster", "highlightVideoPoster"];
|
|
18124
|
-
function text(value) {
|
|
18125
|
-
if (typeof value !== "string") return void 0;
|
|
18126
|
-
const trimmed = value.trim();
|
|
18127
|
-
return trimmed || void 0;
|
|
18128
|
-
}
|
|
18129
|
-
function nullableText(value) {
|
|
18130
|
-
return value === null ? null : text(value);
|
|
18131
|
-
}
|
|
18132
|
-
function httpsUrl(value) {
|
|
18133
|
-
const candidate = text(value);
|
|
18134
|
-
if (!candidate) return void 0;
|
|
18135
|
-
try {
|
|
18136
|
-
return new URL(candidate).protocol === "https:" ? candidate : void 0;
|
|
18137
|
-
} catch {
|
|
18138
|
-
return void 0;
|
|
18139
|
-
}
|
|
18140
|
-
}
|
|
18141
|
-
function youtubeVideoId(value) {
|
|
18142
|
-
const candidate = text(value);
|
|
18143
|
-
if (!candidate) return void 0;
|
|
18144
|
-
if (YOUTUBE_ID.test(candidate)) return candidate;
|
|
18145
|
-
const url = httpsUrl(candidate);
|
|
18146
|
-
if (!url) return void 0;
|
|
18147
|
-
const parsed = new URL(url);
|
|
18148
|
-
const hostname = parsed.hostname.toLowerCase();
|
|
18149
|
-
const isYoutubeHost = hostname === "youtu.be" || hostname === "youtube.com" || hostname.endsWith(".youtube.com");
|
|
18150
|
-
if (!isYoutubeHost) return void 0;
|
|
18151
|
-
const fromPath = hostname === "youtu.be" ? parsed.pathname.split("/").filter(Boolean)[0] : /^\/(?:embed|v|shorts)\/([A-Za-z0-9_-]{11})(?:\/|$)/.exec(parsed.pathname)?.[1];
|
|
18152
|
-
const id = fromPath ?? parsed.searchParams.get("v") ?? void 0;
|
|
18153
|
-
return id && YOUTUBE_ID.test(id) ? id : void 0;
|
|
18154
|
-
}
|
|
18155
|
-
function sourceItems(value) {
|
|
18156
|
-
if (!Array.isArray(value)) return void 0;
|
|
18157
|
-
const items = value.filter(isRecord).flatMap((item) => {
|
|
18158
|
-
const id = text(item.id);
|
|
18159
|
-
const documentType = text(item.documentType);
|
|
18160
|
-
const name = text(item.name);
|
|
18161
|
-
if (!id || !documentType || !name) return [];
|
|
18162
|
-
const externalUrl = httpsUrl(item.externalUrl);
|
|
18163
|
-
const targetPlatform = nullableText(item.targetPlatform);
|
|
18164
|
-
const path = nullableText(item.path);
|
|
18165
|
-
return [
|
|
18166
|
-
{
|
|
18167
|
-
id,
|
|
18168
|
-
documentType,
|
|
18169
|
-
name,
|
|
18170
|
-
...externalUrl ? { externalUrl } : {},
|
|
18171
|
-
...targetPlatform !== void 0 ? { targetPlatform } : {},
|
|
18172
|
-
...path !== void 0 ? { path } : {}
|
|
18173
|
-
}
|
|
18174
|
-
];
|
|
18175
|
-
});
|
|
18176
|
-
return items.length > 0 ? items : void 0;
|
|
18177
|
-
}
|
|
18178
|
-
function sources(value) {
|
|
18179
|
-
if (!Array.isArray(value)) return [];
|
|
18180
|
-
const claimed = /* @__PURE__ */ new Set();
|
|
18181
|
-
const decoded = [];
|
|
18182
|
-
for (const candidate of value) {
|
|
18183
|
-
if (!isRecord(candidate)) continue;
|
|
18184
|
-
const index = candidate.index;
|
|
18185
|
-
const name = text(candidate.name);
|
|
18186
|
-
const isUsableIndex = typeof index === "number" && Number.isInteger(index) && index > 0 && !claimed.has(index);
|
|
18187
|
-
if (!isUsableIndex || !name) continue;
|
|
18188
|
-
claimed.add(index);
|
|
18189
|
-
const path = text(candidate.path);
|
|
18190
|
-
const documentType = text(candidate.documentType);
|
|
18191
|
-
const externalUrl = httpsUrl(candidate.externalUrl);
|
|
18192
|
-
const targetPlatform = nullableText(candidate.targetPlatform);
|
|
18193
|
-
const id = text(candidate.id);
|
|
18194
|
-
const sourceRepo = text(candidate.sourceRepo);
|
|
18195
|
-
const label = text(candidate.label);
|
|
18196
|
-
const items = sourceItems(candidate.items);
|
|
18197
|
-
decoded.push({
|
|
18198
|
-
index,
|
|
18199
|
-
name,
|
|
18200
|
-
// Both are typed non-optional on `ChatSource` and predate this decoder;
|
|
18201
|
-
// '' is the established "no value" for them across the SSE path.
|
|
18202
|
-
path: path ?? "",
|
|
18203
|
-
documentType: documentType ?? "",
|
|
18204
|
-
...externalUrl ? { externalUrl } : {},
|
|
18205
|
-
...targetPlatform !== void 0 ? { targetPlatform } : {},
|
|
18206
|
-
...id ? { id } : {},
|
|
18207
|
-
...sourceRepo ? { sourceRepo } : {},
|
|
18208
|
-
...label ? { label } : {},
|
|
18209
|
-
...items ? { items } : {}
|
|
18210
|
-
});
|
|
18211
|
-
}
|
|
18212
|
-
return decoded;
|
|
18213
|
-
}
|
|
18214
|
-
function videoMetadata(value, url) {
|
|
18215
|
-
const metadata = {};
|
|
18216
|
-
if (isRecord(value)) {
|
|
18217
|
-
for (const key of VIDEO_URL_KEYS) {
|
|
18218
|
-
const validated = httpsUrl(value[key]);
|
|
18219
|
-
if (validated) metadata[key] = validated;
|
|
18220
|
-
}
|
|
18221
|
-
const declaredId = youtubeVideoId(value.youtubeUrl);
|
|
18222
|
-
if (declaredId) metadata.youtubeUrl = declaredId;
|
|
18223
|
-
}
|
|
18224
|
-
if (url) {
|
|
18225
|
-
const idFromUrl = youtubeVideoId(url);
|
|
18226
|
-
if (idFromUrl) {
|
|
18227
|
-
metadata.youtubeUrl = idFromUrl;
|
|
18228
|
-
delete metadata.videoUrl;
|
|
18229
|
-
} else {
|
|
18230
|
-
metadata.videoUrl = url;
|
|
18231
|
-
delete metadata.youtubeUrl;
|
|
18232
|
-
}
|
|
18233
|
-
}
|
|
18234
|
-
return metadata;
|
|
18235
|
-
}
|
|
18236
|
-
function videos(value) {
|
|
18237
|
-
if (!Array.isArray(value)) return [];
|
|
18238
|
-
return value.filter(isRecord).flatMap((video) => {
|
|
18239
|
-
const match = typeof video.ref === "string" ? CARD_REFERENCE.exec(video.ref) : null;
|
|
18240
|
-
if (!match || match[1] !== "video") return [];
|
|
18241
|
-
const id = match[2];
|
|
18242
|
-
const url = httpsUrl(video.url) ?? null;
|
|
18243
|
-
const sourceRepo = text(video.sourceRepo);
|
|
18244
|
-
const metadata = videoMetadata(video.metadata, url);
|
|
18245
|
-
return [
|
|
18246
|
-
{
|
|
18247
|
-
type: "video",
|
|
18248
|
-
id,
|
|
18249
|
-
title: text(video.title) ?? id,
|
|
18250
|
-
url,
|
|
18251
|
-
...sourceRepo ? { sourceRepo } : {},
|
|
18252
|
-
...Object.keys(metadata).length > 0 ? { metadata } : {}
|
|
18253
|
-
}
|
|
18254
|
-
];
|
|
18255
|
-
});
|
|
18256
|
-
}
|
|
18257
|
-
function cards(value, decodedSources) {
|
|
18258
|
-
if (!Array.isArray(value)) return [];
|
|
18259
|
-
return value.filter(isRecord).flatMap((card) => {
|
|
18260
|
-
const match = typeof card.ref === "string" ? CARD_REFERENCE.exec(card.ref) : null;
|
|
18261
|
-
if (!match || match[1] === "video") return [];
|
|
18262
|
-
const type = text(card.entityType);
|
|
18263
|
-
const id = text(card.entityId);
|
|
18264
|
-
if (!type || !id || type !== match[1] || id !== match[2]) return [];
|
|
18265
|
-
const source = decodedSources.find((candidate) => candidate.id === id && candidate.documentType === type);
|
|
18266
|
-
return [
|
|
18267
|
-
{
|
|
18268
|
-
type,
|
|
18269
|
-
id,
|
|
18270
|
-
title: source?.name ?? id,
|
|
18271
|
-
url: source?.externalUrl ?? null,
|
|
18272
|
-
...source?.sourceRepo ? { sourceRepo: source.sourceRepo } : {},
|
|
18273
|
-
...source?.targetPlatform !== void 0 ? { targetPlatform: source.targetPlatform } : {},
|
|
18274
|
-
...source?.path ? { metadata: { path: source.path } } : {}
|
|
18275
|
-
}
|
|
18276
|
-
];
|
|
18277
|
-
});
|
|
18278
|
-
}
|
|
18279
|
-
function deduplicateRefs(refs) {
|
|
18280
|
-
const byIdentity = /* @__PURE__ */ new Map();
|
|
18281
|
-
for (const ref of refs) {
|
|
18282
|
-
const identity = `${ref.type}:${ref.id}`;
|
|
18283
|
-
if (!byIdentity.has(identity)) byIdentity.set(identity, ref);
|
|
18284
|
-
}
|
|
18285
|
-
return [...byIdentity.values()];
|
|
18286
|
-
}
|
|
18287
|
-
function sourceMetadataEvent(payload) {
|
|
18288
|
-
if (!isRecord(payload)) return null;
|
|
18289
|
-
const decodedSources = sources(payload.sources);
|
|
18290
|
-
const refs = deduplicateRefs([...videos(payload.videos), ...cards(payload.cards, decodedSources)]);
|
|
18291
|
-
if (decodedSources.length === 0 && refs.length === 0) return null;
|
|
18292
|
-
return {
|
|
18293
|
-
type: "sources",
|
|
18294
|
-
...decodedSources.length > 0 ? { sources: decodedSources } : {},
|
|
18295
|
-
...refs.length > 0 ? { refs } : {}
|
|
18296
|
-
};
|
|
18297
|
-
}
|
|
18298
|
-
function mergeSourceMetadata(previous, event) {
|
|
18299
|
-
const byIndex = /* @__PURE__ */ new Map();
|
|
18300
|
-
for (const source of [...previous?.sources ?? [], ...event.sources ?? []]) {
|
|
18301
|
-
if (!byIndex.has(source.index)) byIndex.set(source.index, source);
|
|
18302
|
-
}
|
|
18303
|
-
const byIdentity = /* @__PURE__ */ new Map();
|
|
18304
|
-
for (const ref of [...previous?.refs ?? [], ...event.refs ?? []]) {
|
|
18305
|
-
const identity = `${ref.type}:${ref.id}`;
|
|
18306
|
-
if (!byIdentity.has(identity)) byIdentity.set(identity, ref);
|
|
18307
|
-
}
|
|
18308
|
-
return {
|
|
18309
|
-
...byIndex.size > 0 ? { sources: [...byIndex.values()] } : {},
|
|
18310
|
-
...byIdentity.size > 0 ? { refs: [...byIdentity.values()] } : {}
|
|
18311
|
-
};
|
|
18312
|
-
}
|
|
18313
|
-
|
|
18314
18076
|
// src/components/chat/utils/approval-display.ts
|
|
18315
18077
|
function approvalDisplaysInline(approvalType, displayApprovalTypes) {
|
|
18316
18078
|
return !displayApprovalTypes || displayApprovalTypes.includes(approvalType);
|
|
@@ -18612,12 +18374,12 @@ var MessageSegmentAccumulator = class {
|
|
|
18612
18374
|
* Append text to the current message
|
|
18613
18375
|
* If the last segment is text, append to it; otherwise create a new text segment
|
|
18614
18376
|
*/
|
|
18615
|
-
appendText(
|
|
18377
|
+
appendText(text) {
|
|
18616
18378
|
const lastSegment = this.segments[this.segments.length - 1];
|
|
18617
18379
|
if (lastSegment && lastSegment.type === "text") {
|
|
18618
|
-
this.segments[this.segments.length - 1] = { type: "text", text: lastSegment.text +
|
|
18380
|
+
this.segments[this.segments.length - 1] = { type: "text", text: lastSegment.text + text };
|
|
18619
18381
|
} else {
|
|
18620
|
-
this.segments.push({ type: "text", text
|
|
18382
|
+
this.segments.push({ type: "text", text });
|
|
18621
18383
|
}
|
|
18622
18384
|
return this.getSegments();
|
|
18623
18385
|
}
|
|
@@ -18625,12 +18387,12 @@ var MessageSegmentAccumulator = class {
|
|
|
18625
18387
|
* Append thinking text to the current message.
|
|
18626
18388
|
* If the last segment is thinking, append to it; otherwise start a new thinking segment.
|
|
18627
18389
|
*/
|
|
18628
|
-
appendThinking(
|
|
18390
|
+
appendThinking(text) {
|
|
18629
18391
|
const lastSegment = this.segments[this.segments.length - 1];
|
|
18630
18392
|
if (lastSegment && lastSegment.type === "thinking") {
|
|
18631
|
-
this.segments[this.segments.length - 1] = { type: "thinking", text: lastSegment.text +
|
|
18393
|
+
this.segments[this.segments.length - 1] = { type: "thinking", text: lastSegment.text + text };
|
|
18632
18394
|
} else {
|
|
18633
|
-
this.segments.push({ type: "thinking", text
|
|
18395
|
+
this.segments.push({ type: "thinking", text });
|
|
18634
18396
|
}
|
|
18635
18397
|
return this.getSegments();
|
|
18636
18398
|
}
|
|
@@ -18860,7 +18622,7 @@ var MessageSegmentAccumulator = class {
|
|
|
18860
18622
|
* `[existing..., new...]` back through `replaySegments`, which would
|
|
18861
18623
|
* otherwise yield two cards for one offer.
|
|
18862
18624
|
*/
|
|
18863
|
-
addEscalationOffer(offerId,
|
|
18625
|
+
addEscalationOffer(offerId, text, origin, status = "pending", resolvedByName) {
|
|
18864
18626
|
const existingIndex = this.segments.findIndex(
|
|
18865
18627
|
(s) => s.type === "escalation_offer" && s.data.offerId === offerId
|
|
18866
18628
|
);
|
|
@@ -18869,7 +18631,7 @@ var MessageSegmentAccumulator = class {
|
|
|
18869
18631
|
type: "escalation_offer",
|
|
18870
18632
|
// The resolved chunk carries no text/origin — a redelivered offer must
|
|
18871
18633
|
// not blank the card the PENDING chunk already painted.
|
|
18872
|
-
data: { offerId, text:
|
|
18634
|
+
data: { offerId, text: text || existing?.data.text || "", origin: origin ?? existing?.data.origin },
|
|
18873
18635
|
status,
|
|
18874
18636
|
resolvedByName: resolvedByName ?? existing?.resolvedByName,
|
|
18875
18637
|
onApprove: this.callbacks.onEscalationApprove,
|
|
@@ -19160,12 +18922,12 @@ function createChatStreamReducer(options = {}) {
|
|
|
19160
18922
|
let lastAppliedSeq = Number.NEGATIVE_INFINITY;
|
|
19161
18923
|
let pendingEchoTexts = [];
|
|
19162
18924
|
let turnStartedAt = 0;
|
|
19163
|
-
function consumeOwnEcho(
|
|
18925
|
+
function consumeOwnEcho(text, authorMatched = false) {
|
|
19164
18926
|
if (pendingEchoTexts.length === 0) return false;
|
|
19165
18927
|
const now = Date.now();
|
|
19166
18928
|
pendingEchoTexts = pendingEchoTexts.filter((e) => now - e.at < OWN_ECHO_AUTHOR_TTL_MS);
|
|
19167
18929
|
const ttl = authorMatched ? OWN_ECHO_AUTHOR_TTL_MS : OWN_ECHO_TTL_MS;
|
|
19168
|
-
const idx = pendingEchoTexts.findIndex((e) => e.text ===
|
|
18930
|
+
const idx = pendingEchoTexts.findIndex((e) => e.text === text && now - e.at < ttl);
|
|
19169
18931
|
if (idx === -1) return false;
|
|
19170
18932
|
pendingEchoTexts.splice(idx, 1);
|
|
19171
18933
|
return true;
|
|
@@ -19242,29 +19004,17 @@ function createChatStreamReducer(options = {}) {
|
|
|
19242
19004
|
if (typeof last.streamSeq === "number" && last.streamSeq >= seq) return next;
|
|
19243
19005
|
return [...next.slice(0, -1), { ...last, streamSeq: seq }];
|
|
19244
19006
|
}
|
|
19245
|
-
let turnSourceMetadata = null;
|
|
19246
|
-
function stampTrailingAssistantSourceMetadata(next) {
|
|
19247
|
-
const metadata = turnSourceMetadata;
|
|
19248
|
-
if (!metadata) return next;
|
|
19249
|
-
const last = next[next.length - 1];
|
|
19250
|
-
if (!last || last.role !== "assistant") return next;
|
|
19251
|
-
if (last.sources === metadata.sources && last.refs === metadata.refs) return next;
|
|
19252
|
-
return [...next.slice(0, -1), { ...last, ...metadata }];
|
|
19253
|
-
}
|
|
19254
|
-
function commitTrailingAssistant(next, seq) {
|
|
19255
|
-
return stampTrailingAssistantSourceMetadata(stampTrailingAssistantSeq(next, seq));
|
|
19256
|
-
}
|
|
19257
19007
|
function applySegmentsToState(segments, meta) {
|
|
19258
19008
|
const seq = meta?.streamSeq;
|
|
19259
19009
|
if (meta?.append && meta.isCompacting) {
|
|
19260
|
-
setMessagesInternal(
|
|
19010
|
+
setMessagesInternal(stampTrailingAssistantSeq(upsertTrailingCompaction(messages, segments), seq));
|
|
19261
19011
|
return;
|
|
19262
19012
|
}
|
|
19263
19013
|
if (meta?.append) {
|
|
19264
|
-
setMessagesInternal(
|
|
19014
|
+
setMessagesInternal(stampTrailingAssistantSeq(appendToTrailingAssistant(messages, segments), seq));
|
|
19265
19015
|
return;
|
|
19266
19016
|
}
|
|
19267
|
-
setMessagesInternal(
|
|
19017
|
+
setMessagesInternal(stampTrailingAssistantSeq(updateTrailingAssistant(messages, segments), seq));
|
|
19268
19018
|
}
|
|
19269
19019
|
function applyStreamStartToState() {
|
|
19270
19020
|
setPhaseInternal("streaming");
|
|
@@ -19277,8 +19027,8 @@ function createChatStreamReducer(options = {}) {
|
|
|
19277
19027
|
setMessagesInternal([...messages, { id: nextId("assistant"), role: "assistant", content: "", segments: [] }]);
|
|
19278
19028
|
}
|
|
19279
19029
|
function applyUserMessageToState(ev) {
|
|
19280
|
-
const
|
|
19281
|
-
if (!
|
|
19030
|
+
const text = ev.text;
|
|
19031
|
+
if (!text) return;
|
|
19282
19032
|
const seq = ev.seq;
|
|
19283
19033
|
const adminEchoAllowed = ev.ownerType !== CHAT_OWNER_ADMIN || options.ownEchoIncludesAdmin === true;
|
|
19284
19034
|
const selfUserId = resolveSelfUserId();
|
|
@@ -19286,11 +19036,11 @@ function createChatStreamReducer(options = {}) {
|
|
|
19286
19036
|
if (selfUserId !== void 0 && !authorDeclared) warnIdLessAuthor();
|
|
19287
19037
|
const authorMatched = selfUserId !== void 0 && authorDeclared && ev.userId === selfUserId;
|
|
19288
19038
|
const authorEchoAllowed = selfUserId === void 0 || !authorDeclared || authorMatched;
|
|
19289
|
-
if (adminEchoAllowed && authorEchoAllowed && consumeOwnEcho(
|
|
19039
|
+
if (adminEchoAllowed && authorEchoAllowed && consumeOwnEcho(text, authorMatched)) return;
|
|
19290
19040
|
const authorType = ev.ownerType === CHAT_OWNER_ADMIN ? "admin" : "user";
|
|
19291
19041
|
if (typeof seq !== "number" && hasRecentMessage(
|
|
19292
19042
|
messages,
|
|
19293
|
-
(m) => m.role === "user" && (m.authorType ?? "user") === authorType && m.content ===
|
|
19043
|
+
(m) => m.role === "user" && (m.authorType ?? "user") === authorType && m.content === text,
|
|
19294
19044
|
CONTENT_DEDUP_WINDOW
|
|
19295
19045
|
)) {
|
|
19296
19046
|
return;
|
|
@@ -19300,7 +19050,7 @@ function createChatStreamReducer(options = {}) {
|
|
|
19300
19050
|
{
|
|
19301
19051
|
id: nextId("user"),
|
|
19302
19052
|
role: "user",
|
|
19303
|
-
content:
|
|
19053
|
+
content: text,
|
|
19304
19054
|
// Coverage signal for the history merge — see `streamSeq` on
|
|
19305
19055
|
// `UnifiedChatMessage`. For `user-` rows it is also what tells a
|
|
19306
19056
|
// REPLAYED echo (history already has its row) apart from a genuine new
|
|
@@ -19313,12 +19063,12 @@ function createChatStreamReducer(options = {}) {
|
|
|
19313
19063
|
]);
|
|
19314
19064
|
}
|
|
19315
19065
|
function applyDirectMessageToState(ev) {
|
|
19316
|
-
const
|
|
19317
|
-
if (!
|
|
19066
|
+
const text = ev.text;
|
|
19067
|
+
if (!text) return;
|
|
19318
19068
|
const seq = ev.seq;
|
|
19319
19069
|
if (typeof seq !== "number" && hasRecentMessage(
|
|
19320
19070
|
messages,
|
|
19321
|
-
(m) => m.role === "user" && m.authorType === "admin" && m.content ===
|
|
19071
|
+
(m) => m.role === "user" && m.authorType === "admin" && m.content === text,
|
|
19322
19072
|
CONTENT_DEDUP_WINDOW
|
|
19323
19073
|
)) {
|
|
19324
19074
|
return;
|
|
@@ -19328,7 +19078,7 @@ function createChatStreamReducer(options = {}) {
|
|
|
19328
19078
|
{
|
|
19329
19079
|
id: `direct-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,
|
|
19330
19080
|
role: "user",
|
|
19331
|
-
content:
|
|
19081
|
+
content: text,
|
|
19332
19082
|
...typeof seq === "number" ? { streamSeq: seq } : {},
|
|
19333
19083
|
name: ev.displayName ?? "Admin",
|
|
19334
19084
|
authorType: "admin"
|
|
@@ -19336,10 +19086,10 @@ function createChatStreamReducer(options = {}) {
|
|
|
19336
19086
|
]);
|
|
19337
19087
|
}
|
|
19338
19088
|
function applySystemMessageToState(ev) {
|
|
19339
|
-
const
|
|
19340
|
-
if (!
|
|
19089
|
+
const text = ev.text;
|
|
19090
|
+
if (!text) return;
|
|
19341
19091
|
const seq = ev.seq;
|
|
19342
|
-
if (typeof seq !== "number" && hasRecentMessage(messages, (m) => m.authorType === "system" && m.name ===
|
|
19092
|
+
if (typeof seq !== "number" && hasRecentMessage(messages, (m) => m.authorType === "system" && m.name === text, SYSTEM_DEDUP_WINDOW)) {
|
|
19343
19093
|
return;
|
|
19344
19094
|
}
|
|
19345
19095
|
setMessagesInternal([
|
|
@@ -19349,7 +19099,7 @@ function createChatStreamReducer(options = {}) {
|
|
|
19349
19099
|
role: "user",
|
|
19350
19100
|
content: "",
|
|
19351
19101
|
...typeof seq === "number" ? { streamSeq: seq } : {},
|
|
19352
|
-
name:
|
|
19102
|
+
name: text,
|
|
19353
19103
|
authorType: "system"
|
|
19354
19104
|
}
|
|
19355
19105
|
]);
|
|
@@ -19387,7 +19137,6 @@ function createChatStreamReducer(options = {}) {
|
|
|
19387
19137
|
isInStream = true;
|
|
19388
19138
|
hasEverStreamed = true;
|
|
19389
19139
|
turnStartedAt = Date.now();
|
|
19390
|
-
turnSourceMetadata = null;
|
|
19391
19140
|
emit("onStreamStart");
|
|
19392
19141
|
applyStreamStartToState();
|
|
19393
19142
|
accumulator.resetSegments();
|
|
@@ -19401,14 +19150,6 @@ function createChatStreamReducer(options = {}) {
|
|
|
19401
19150
|
accumulator.resetSegments();
|
|
19402
19151
|
break;
|
|
19403
19152
|
}
|
|
19404
|
-
// Per-answer source metadata. Applied to the trailing assistant bubble
|
|
19405
|
-
// immediately when there is one, and held for the next write when the
|
|
19406
|
-
// chunk beat the answer text to the reducer.
|
|
19407
|
-
case "sources": {
|
|
19408
|
-
turnSourceMetadata = mergeSourceMetadata(turnSourceMetadata, event);
|
|
19409
|
-
setMessagesInternal(stampTrailingAssistantSourceMetadata(messages));
|
|
19410
|
-
break;
|
|
19411
|
-
}
|
|
19412
19153
|
case "metadata": {
|
|
19413
19154
|
emit("onMetadata", {
|
|
19414
19155
|
action: "metadata",
|
|
@@ -19730,20 +19471,20 @@ function createChatStreamReducer(options = {}) {
|
|
|
19730
19471
|
break;
|
|
19731
19472
|
}
|
|
19732
19473
|
}
|
|
19733
|
-
function sseWriteTrailingText(
|
|
19474
|
+
function sseWriteTrailingText(text) {
|
|
19734
19475
|
const last = messages[messages.length - 1];
|
|
19735
19476
|
if (!last || last.role !== "assistant") return;
|
|
19736
19477
|
const segments = [...last.segments ?? []];
|
|
19737
19478
|
const tail = segments[segments.length - 1];
|
|
19738
19479
|
if (tail && tail.type === "text") {
|
|
19739
|
-
segments[segments.length - 1] = { type: "text", text
|
|
19480
|
+
segments[segments.length - 1] = { type: "text", text };
|
|
19740
19481
|
} else {
|
|
19741
|
-
segments.push({ type: "text", text
|
|
19482
|
+
segments.push({ type: "text", text });
|
|
19742
19483
|
}
|
|
19743
19484
|
setMessagesInternal([...messages.slice(0, -1), { ...last, segments }]);
|
|
19744
19485
|
}
|
|
19745
|
-
function sseAppendText(
|
|
19746
|
-
sseCurrentText +=
|
|
19486
|
+
function sseAppendText(text) {
|
|
19487
|
+
sseCurrentText += text;
|
|
19747
19488
|
sseWriteTrailingText(sseCurrentText);
|
|
19748
19489
|
}
|
|
19749
19490
|
function sseAppendThinking(escapedDelta) {
|
|
@@ -20036,19 +19777,19 @@ function createChatStreamReducer(options = {}) {
|
|
|
20036
19777
|
messages = [...older, ...messages];
|
|
20037
19778
|
invalidate();
|
|
20038
19779
|
},
|
|
20039
|
-
pushOptimisticSend(
|
|
20040
|
-
pendingEchoTexts.push({ text
|
|
19780
|
+
pushOptimisticSend(text, hidden = false) {
|
|
19781
|
+
pendingEchoTexts.push({ text, at: Date.now() });
|
|
20041
19782
|
if (pendingEchoTexts.length > MAX_PENDING_ECHOES) pendingEchoTexts.shift();
|
|
20042
19783
|
messages = [
|
|
20043
19784
|
...messages,
|
|
20044
19785
|
// An EMPTY-text send is out-of-band metadata (an approval decision),
|
|
20045
19786
|
// not something the user said — see `beginSseSend` for the full
|
|
20046
19787
|
// rationale. Never materialize a row for it.
|
|
20047
|
-
...
|
|
19788
|
+
...text.length > 0 ? [
|
|
20048
19789
|
{
|
|
20049
19790
|
id: nextId("user"),
|
|
20050
19791
|
role: "user",
|
|
20051
|
-
content:
|
|
19792
|
+
content: text,
|
|
20052
19793
|
...hidden ? { hidden: true } : {}
|
|
20053
19794
|
}
|
|
20054
19795
|
] : [],
|
|
@@ -20064,7 +19805,7 @@ function createChatStreamReducer(options = {}) {
|
|
|
20064
19805
|
invalidate();
|
|
20065
19806
|
},
|
|
20066
19807
|
resetForDialogSwitch,
|
|
20067
|
-
beginSseSend({ text
|
|
19808
|
+
beginSseSend({ text, hidden, userName = "You", assistantName, assistantAvatar }) {
|
|
20068
19809
|
const now = Date.now();
|
|
20069
19810
|
messages = [
|
|
20070
19811
|
...messages,
|
|
@@ -20076,12 +19817,12 @@ function createChatStreamReducer(options = {}) {
|
|
|
20076
19817
|
// label with no body). So we never mint it. Hidden sends that DO carry
|
|
20077
19818
|
// text (e.g. an auto-continuation directive) still become real state:
|
|
20078
19819
|
// the LLM must see them, `Message.hidden` keeps them off screen.
|
|
20079
|
-
...
|
|
19820
|
+
...text.length > 0 ? [
|
|
20080
19821
|
{
|
|
20081
19822
|
id: `user-${now}`,
|
|
20082
19823
|
role: "user",
|
|
20083
19824
|
name: userName,
|
|
20084
|
-
content:
|
|
19825
|
+
content: text,
|
|
20085
19826
|
timestamp: new Date(now),
|
|
20086
19827
|
...hidden ? { hidden: true } : {}
|
|
20087
19828
|
}
|
|
@@ -20124,8 +19865,8 @@ function createChatStreamReducer(options = {}) {
|
|
|
20124
19865
|
streamingPhase = "idle";
|
|
20125
19866
|
invalidate();
|
|
20126
19867
|
},
|
|
20127
|
-
seedSseMaps({ sources
|
|
20128
|
-
if (
|
|
19868
|
+
seedSseMaps({ sources, sendCount: seedSendCount }) {
|
|
19869
|
+
if (sources) for (const [k, v] of sources) sourcesMap.set(k, v);
|
|
20129
19870
|
if (typeof seedSendCount === "number") sendCount = seedSendCount;
|
|
20130
19871
|
invalidate();
|
|
20131
19872
|
},
|
|
@@ -20537,6 +20278,14 @@ function pruneStaleChatConversationStorage(source) {
|
|
|
20537
20278
|
}
|
|
20538
20279
|
}
|
|
20539
20280
|
|
|
20281
|
+
// src/chat-protocol/wire-narrow.ts
|
|
20282
|
+
function isRecord(value) {
|
|
20283
|
+
return typeof value === "object" && value !== null;
|
|
20284
|
+
}
|
|
20285
|
+
function unwrapEnvelope(payload) {
|
|
20286
|
+
return isRecord(payload) && "data" in payload ? payload.data : payload;
|
|
20287
|
+
}
|
|
20288
|
+
|
|
20540
20289
|
// src/components/chat/utils/chat-conversations-api.ts
|
|
20541
20290
|
function toDialogItem(row) {
|
|
20542
20291
|
if (!isRecord(row)) return null;
|
|
@@ -21171,7 +20920,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21171
20920
|
const sendMessage = useCallback21(
|
|
21172
20921
|
// Resolves `true` on a clean turn, `false` when the request failed
|
|
21173
20922
|
// (surfaced to batch approve-all loops via the card callbacks).
|
|
21174
|
-
async (
|
|
20923
|
+
async (text, sendOptions) => {
|
|
21175
20924
|
const { hidden, attachments, commandOverride, approvalAction } = sendOptions ?? {};
|
|
21176
20925
|
const echoedConversationId = conversationIdRef.current;
|
|
21177
20926
|
const targetPath = approvalAction ? endpointsRef.current.approvalToolUrl : endpointsRef.current.chatStreamUrl;
|
|
@@ -21182,12 +20931,12 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21182
20931
|
// established conversation (the proposal turn captured the id).
|
|
21183
20932
|
buildConfirmToolBody({ ...approvalAction, conversationId: echoedConversationId })
|
|
21184
20933
|
) : {
|
|
21185
|
-
messages: [{ role: "user", content:
|
|
20934
|
+
messages: [{ role: "user", content: text }],
|
|
21186
20935
|
...commandOverride ? { commandOverride } : {},
|
|
21187
20936
|
...attachments && attachments.length > 0 ? { pendingAttachments: attachments } : {},
|
|
21188
20937
|
...echoedConversationId ? { conversationId: echoedConversationId } : {}
|
|
21189
20938
|
};
|
|
21190
|
-
mutate((r) => r.beginSseSend({ text
|
|
20939
|
+
mutate((r) => r.beginSseSend({ text, hidden, userName: "You", assistantName: "Mingo AI" }));
|
|
21191
20940
|
const ctrl = new AbortController();
|
|
21192
20941
|
abortControllerRef.current = ctrl;
|
|
21193
20942
|
let mintedThisTurn = false;
|
|
@@ -21303,14 +21052,14 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21303
21052
|
return state.messages.map((m) => {
|
|
21304
21053
|
const segments = m.segments;
|
|
21305
21054
|
const content = typeof m.content === "string" && !segments ? m.content : segments?.filter((s) => s.type === "text").map((s) => s.text).join("") ?? "";
|
|
21306
|
-
let
|
|
21055
|
+
let sources;
|
|
21307
21056
|
let scrollAnchor;
|
|
21308
21057
|
if (m.role === "user" && !m.hidden) {
|
|
21309
21058
|
sendIdx++;
|
|
21310
21059
|
}
|
|
21311
21060
|
if (m.role === "assistant") {
|
|
21312
21061
|
const lookupIdx = sendIdx >= 0 ? sendIdx : 0;
|
|
21313
|
-
|
|
21062
|
+
sources = sourcesMap.get(lookupIdx);
|
|
21314
21063
|
scrollAnchor = meta.get(lookupIdx)?.scrollAnchor ?? void 0;
|
|
21315
21064
|
}
|
|
21316
21065
|
return {
|
|
@@ -21318,7 +21067,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21318
21067
|
role: m.role,
|
|
21319
21068
|
content,
|
|
21320
21069
|
...segments ? { segments } : {},
|
|
21321
|
-
...
|
|
21070
|
+
...sources ? { sources } : {},
|
|
21322
21071
|
...scrollAnchor ? { scrollAnchor } : {},
|
|
21323
21072
|
...m.hidden ? { hidden: true } : {}
|
|
21324
21073
|
};
|
|
@@ -21341,8 +21090,8 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21341
21090
|
const refSlug = typeof reference.metadata?.slug === "string" && reference.metadata.slug.length > 0 ? reference.metadata.slug : "";
|
|
21342
21091
|
const queryValue = refSlug || sanitizeTitleForChat(reference.title) || reference.id;
|
|
21343
21092
|
const escaped = queryValue.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
21344
|
-
const
|
|
21345
|
-
void sendMessage(
|
|
21093
|
+
const text = `/${cmdId} display "${escaped}"`;
|
|
21094
|
+
void sendMessage(text);
|
|
21346
21095
|
},
|
|
21347
21096
|
[sendMessage, source, cmdIdByTableId, tableIdForDocumentType]
|
|
21348
21097
|
);
|
|
@@ -21496,16 +21245,6 @@ function decodeNatsChunk(chunk) {
|
|
|
21496
21245
|
return { type: "thinking-delta", text: data.text, ...seq };
|
|
21497
21246
|
}
|
|
21498
21247
|
return null;
|
|
21499
|
-
// Two chunk names, one payload and one decoder. `SOURCES` is the contract
|
|
21500
|
-
// the backend is moving to; `GUIDE` is the v2 envelope it ships in during
|
|
21501
|
-
// the rollout (see `MESSAGE_TYPE.GUIDE`). The chunk arrives BEFORE or
|
|
21502
|
-
// between the answer's text deltas, so the reducer — not this decoder —
|
|
21503
|
-
// owns attaching it to the right turn.
|
|
21504
|
-
case MESSAGE_TYPE.GUIDE:
|
|
21505
|
-
case MESSAGE_TYPE.SOURCES: {
|
|
21506
|
-
const event = sourceMetadataEvent(data.payload);
|
|
21507
|
-
return event ? { ...event, ...seq } : null;
|
|
21508
|
-
}
|
|
21509
21248
|
// An ask card is only an ask card with something to pick: a question and at
|
|
21510
21249
|
// least one option. Anything less is dropped rather than rendered as an
|
|
21511
21250
|
// empty card the user can't answer — the backend already falls back to a
|
|
@@ -21857,12 +21596,6 @@ function decodeHistoricalMessageData(data) {
|
|
|
21857
21596
|
return { type: "thinking-delta", text: data.text };
|
|
21858
21597
|
}
|
|
21859
21598
|
return null;
|
|
21860
|
-
// Persisted source metadata, through the SAME decoder the live chunk uses
|
|
21861
|
-
// (`sourceMetadataEvent`). That shared parse is the whole reason a reloaded
|
|
21862
|
-
// answer renders identically to the one the reader watched arrive.
|
|
21863
|
-
case MESSAGE_TYPE.GUIDE:
|
|
21864
|
-
case MESSAGE_TYPE.SOURCES:
|
|
21865
|
-
return "payload" in data ? sourceMetadataEvent(data.payload) : null;
|
|
21866
21599
|
// Same completeness gate as the live decoder (`decodeNatsChunk`): a
|
|
21867
21600
|
// persisted row without a question or without options is not a card the
|
|
21868
21601
|
// user can answer, so it replays as nothing rather than as empty chrome.
|
|
@@ -22222,7 +21955,6 @@ function processHistoricalMessages(messages, options = {}) {
|
|
|
22222
21955
|
let currentAssistantTimestamp = null;
|
|
22223
21956
|
let lastAssistantId = null;
|
|
22224
21957
|
let currentAssistantStreamSeq;
|
|
22225
|
-
let currentAssistantSourceMetadata = null;
|
|
22226
21958
|
const flushAssistantMessage = () => {
|
|
22227
21959
|
const idToUse = lastAssistantId || currentAssistantId;
|
|
22228
21960
|
if (idToUse && accumulator.hasContent()) {
|
|
@@ -22235,8 +21967,7 @@ function processHistoricalMessages(messages, options = {}) {
|
|
|
22235
21967
|
authorType: assistantType,
|
|
22236
21968
|
timestamp: currentAssistantTimestamp || /* @__PURE__ */ new Date(),
|
|
22237
21969
|
avatar: assistantAvatar,
|
|
22238
|
-
...currentAssistantStreamSeq !== void 0 ? { streamSeq: currentAssistantStreamSeq } : {}
|
|
22239
|
-
...currentAssistantSourceMetadata ?? {}
|
|
21970
|
+
...currentAssistantStreamSeq !== void 0 ? { streamSeq: currentAssistantStreamSeq } : {}
|
|
22240
21971
|
});
|
|
22241
21972
|
accumulator.resetSegments();
|
|
22242
21973
|
}
|
|
@@ -22244,7 +21975,6 @@ function processHistoricalMessages(messages, options = {}) {
|
|
|
22244
21975
|
currentAssistantTimestamp = null;
|
|
22245
21976
|
lastAssistantId = null;
|
|
22246
21977
|
currentAssistantStreamSeq = void 0;
|
|
22247
|
-
currentAssistantSourceMetadata = null;
|
|
22248
21978
|
};
|
|
22249
21979
|
messages.forEach((msg, index) => {
|
|
22250
21980
|
if (chatTypeFilter && msg.chatType !== chatTypeFilter) return;
|
|
@@ -22288,10 +22018,6 @@ function processHistoricalMessages(messages, options = {}) {
|
|
|
22288
22018
|
messageDataArray.forEach((data) => {
|
|
22289
22019
|
const event = decodeHistoricalMessageData(data);
|
|
22290
22020
|
if (!event) return;
|
|
22291
|
-
if (event.type === "sources") {
|
|
22292
|
-
currentAssistantSourceMetadata = mergeSourceMetadata(currentAssistantSourceMetadata, event);
|
|
22293
|
-
return;
|
|
22294
|
-
}
|
|
22295
22021
|
applyHistoryEvent(
|
|
22296
22022
|
event,
|
|
22297
22023
|
accumulator,
|
|
@@ -22691,10 +22417,10 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22691
22417
|
});
|
|
22692
22418
|
const connectionState = !active || !dialogId ? "connected" : connectedForDialog === dialogId ? "connected" : "connecting";
|
|
22693
22419
|
const sendMessage = useCallback22(
|
|
22694
|
-
async (
|
|
22420
|
+
async (text, sendOptions) => {
|
|
22695
22421
|
const hidden = sendOptions?.hidden ?? false;
|
|
22696
|
-
mutate((r) => r.pushOptimisticSend(
|
|
22697
|
-
await publishUserMessage(
|
|
22422
|
+
mutate((r) => r.pushOptimisticSend(text, hidden));
|
|
22423
|
+
await publishUserMessage(text, { hidden, dialogId });
|
|
22698
22424
|
},
|
|
22699
22425
|
[mutate, publishUserMessage, dialogId]
|
|
22700
22426
|
);
|
|
@@ -22903,7 +22629,7 @@ function useUnifiedChat(options) {
|
|
|
22903
22629
|
const stopMessage = useCallback23(() => activeStateRef.current.stopMessage(), []);
|
|
22904
22630
|
const clearMessages = useCallback23(() => activeStateRef.current.clearMessages(), []);
|
|
22905
22631
|
const sendMessage = useCallback23(
|
|
22906
|
-
(
|
|
22632
|
+
(text, opts) => activeStateRef.current.sendMessage(text, opts),
|
|
22907
22633
|
[]
|
|
22908
22634
|
);
|
|
22909
22635
|
const discussRef = useCallback23(
|
|
@@ -23062,27 +22788,27 @@ function collectTwinSignals(rows) {
|
|
|
23062
22788
|
for (const row of rows) {
|
|
23063
22789
|
for (const key of turnRequestKeys(row.content)) signals.requestKeys.add(key);
|
|
23064
22790
|
if (row.role === "assistant") {
|
|
23065
|
-
const
|
|
23066
|
-
if (
|
|
22791
|
+
const text2 = assistantAnswerText(row.content);
|
|
22792
|
+
if (text2 !== "") signals.assistantTexts.set(text2, (signals.assistantTexts.get(text2) ?? 0) + 1);
|
|
23067
22793
|
continue;
|
|
23068
22794
|
}
|
|
23069
|
-
const
|
|
23070
|
-
if (
|
|
22795
|
+
const text = userText(row);
|
|
22796
|
+
if (text !== "") signals.userContents.set(text, (signals.userContents.get(text) ?? 0) + 1);
|
|
23071
22797
|
}
|
|
23072
22798
|
return signals;
|
|
23073
22799
|
}
|
|
23074
22800
|
function twinVerdict(signals, m) {
|
|
23075
22801
|
if (m.role !== "assistant") {
|
|
23076
|
-
const
|
|
23077
|
-
if (
|
|
23078
|
-
return signals.userContents.has(
|
|
22802
|
+
const text2 = userText(m);
|
|
22803
|
+
if (text2 === "") return "unknown";
|
|
22804
|
+
return signals.userContents.has(text2) ? "twin" : "distinct";
|
|
23079
22805
|
}
|
|
23080
22806
|
const keys = turnRequestKeys(m.content);
|
|
23081
22807
|
if (keys.size > 0) return sharesRequestKey(keys, signals.requestKeys) ? "twin" : "distinct";
|
|
23082
|
-
const
|
|
23083
|
-
if (
|
|
22808
|
+
const text = assistantAnswerText(m.content);
|
|
22809
|
+
if (text === "") return "unknown";
|
|
23084
22810
|
for (const other of signals.assistantTexts.keys()) {
|
|
23085
|
-
if (other.startsWith(
|
|
22811
|
+
if (other.startsWith(text) || text.startsWith(other)) return "twin";
|
|
23086
22812
|
}
|
|
23087
22813
|
return "distinct";
|
|
23088
22814
|
}
|
|
@@ -23275,10 +23001,10 @@ function computeHistoryPrepend(processedHistory, existingMessages) {
|
|
|
23275
23001
|
for (let i = newEnd - 1; i >= 0; i--) {
|
|
23276
23002
|
const pm = processedHistory[i];
|
|
23277
23003
|
if (pm.role === "user") {
|
|
23278
|
-
const
|
|
23279
|
-
const left =
|
|
23004
|
+
const text = userText(pm);
|
|
23005
|
+
const left = text === "" ? 0 : userTwinsLeft.get(text) ?? 0;
|
|
23280
23006
|
if (left === 0) continue;
|
|
23281
|
-
userTwinsLeft.set(
|
|
23007
|
+
userTwinsLeft.set(text, left - 1);
|
|
23282
23008
|
twinIndices.add(i);
|
|
23283
23009
|
} else if (pm.role === "assistant") {
|
|
23284
23010
|
const keys = turnRequestKeys(pm.content);
|
|
@@ -23286,10 +23012,10 @@ function computeHistoryPrepend(processedHistory, existingMessages) {
|
|
|
23286
23012
|
if (sharesRequestKey(keys, liveSignals.requestKeys)) twinIndices.add(i);
|
|
23287
23013
|
continue;
|
|
23288
23014
|
}
|
|
23289
|
-
const
|
|
23290
|
-
if (
|
|
23015
|
+
const text = assistantAnswerText(pm.content);
|
|
23016
|
+
if (text === "") continue;
|
|
23291
23017
|
for (const [liveText, left] of assistantTwinsLeft) {
|
|
23292
|
-
if (left === 0 || !
|
|
23018
|
+
if (left === 0 || !text.startsWith(liveText)) continue;
|
|
23293
23019
|
assistantTwinsLeft.set(liveText, left - 1);
|
|
23294
23020
|
twinIndices.add(i);
|
|
23295
23021
|
break;
|
|
@@ -23353,8 +23079,8 @@ var TOKEN_MS = 55;
|
|
|
23353
23079
|
var USER_MS = 480;
|
|
23354
23080
|
var SEGMENT_MS = 340;
|
|
23355
23081
|
var POST_MS = 240;
|
|
23356
|
-
function tokenize(
|
|
23357
|
-
return
|
|
23082
|
+
function tokenize(text) {
|
|
23083
|
+
return text.match(/\s*\S+\s*/g) ?? (text ? [text] : []);
|
|
23358
23084
|
}
|
|
23359
23085
|
function buildStreamFrames(messages) {
|
|
23360
23086
|
const frames = [];
|
|
@@ -24032,70 +23758,6 @@ function useChatDialogManager({
|
|
|
24032
23758
|
};
|
|
24033
23759
|
}
|
|
24034
23760
|
|
|
24035
|
-
// src/components/chat/utils/cited-sources.ts
|
|
24036
|
-
var FALLBACK_TOP_RETRIEVED = 3;
|
|
24037
|
-
var CITATION = /\[(\d+)\]/g;
|
|
24038
|
-
var CODE = /```[\s\S]*?```|~~~[\s\S]*?~~~|`[^`\n]*`/g;
|
|
24039
|
-
function withoutCode(content) {
|
|
24040
|
-
return content.replace(CODE, (block) => " ".repeat(block.length));
|
|
24041
|
-
}
|
|
24042
|
-
function splitCitedSources(sources2, content) {
|
|
24043
|
-
if (!sources2 || sources2.length === 0) return { cited: [], uncited: [] };
|
|
24044
|
-
const firstMentionAt = /* @__PURE__ */ new Map();
|
|
24045
|
-
for (const match of withoutCode(content).matchAll(CITATION)) {
|
|
24046
|
-
const index = Number.parseInt(match[1], 10);
|
|
24047
|
-
if (!firstMentionAt.has(index)) firstMentionAt.set(index, firstMentionAt.size);
|
|
24048
|
-
}
|
|
24049
|
-
const cited = sources2.filter((source) => firstMentionAt.has(source.index)).sort((a, b) => (firstMentionAt.get(a.index) ?? 0) - (firstMentionAt.get(b.index) ?? 0));
|
|
24050
|
-
const uncited = sources2.filter((source) => !firstMentionAt.has(source.index));
|
|
24051
|
-
return { cited, uncited };
|
|
24052
|
-
}
|
|
24053
|
-
|
|
24054
|
-
// src/components/chat/utils/host-message.ts
|
|
24055
|
-
function mapHostMessage(m, options) {
|
|
24056
|
-
const { userName, userAvatar, timestampCache } = options;
|
|
24057
|
-
let timestamp;
|
|
24058
|
-
if (m.timestamp != null) {
|
|
24059
|
-
timestamp = new Date(m.timestamp);
|
|
24060
|
-
} else {
|
|
24061
|
-
const cached = timestampCache.get(m.id);
|
|
24062
|
-
timestamp = cached ?? /* @__PURE__ */ new Date();
|
|
24063
|
-
if (!cached) timestampCache.set(m.id, timestamp);
|
|
24064
|
-
}
|
|
24065
|
-
return {
|
|
24066
|
-
id: m.id,
|
|
24067
|
-
role: m.role,
|
|
24068
|
-
// Host-supplied per-message name/avatar win (e.g. the signed-in user's
|
|
24069
|
-
// full name + photo on a `user` bubble); fall back to the role default
|
|
24070
|
-
// when the host doesn't provide them.
|
|
24071
|
-
name: m.name ?? (m.role === "assistant" ? "Mingo" : userName ?? "You"),
|
|
24072
|
-
avatar: m.avatar ?? (m.role === "user" ? userAvatar ?? null : null),
|
|
24073
|
-
// Forward the host's authorType so user bubbles get the same accent
|
|
24074
|
-
// name color as the standalone /mingo page (user → 'admin').
|
|
24075
|
-
...m.authorType ? { authorType: m.authorType } : {},
|
|
24076
|
-
content: m.segments && m.segments.length > 0 ? m.segments : m.content,
|
|
24077
|
-
timestamp,
|
|
24078
|
-
assistantType: m.role === "assistant" ? "mingo" : void 0,
|
|
24079
|
-
// `hidden` is load-bearing, NOT cosmetic: it carries synthetic rows
|
|
24080
|
-
// (e.g. an auto-continuation directive) that the LLM must see but the
|
|
24081
|
-
// reader must not. See the module note above.
|
|
24082
|
-
...m.hidden ? { hidden: true } : {},
|
|
24083
|
-
...m.scrollAnchor ? { scrollAnchor: m.scrollAnchor } : {},
|
|
24084
|
-
// Forward attached context items so the user bubble renders its chips.
|
|
24085
|
-
...m.contextItems && m.contextItems.length > 0 ? { contextItems: m.contextItems } : {},
|
|
24086
|
-
// Per-answer source metadata: the citation strip under the answer, and the
|
|
24087
|
-
// descriptions the `[card://…]` markers in its body expand into.
|
|
24088
|
-
...m.sources && m.sources.length > 0 ? { sources: m.sources } : {},
|
|
24089
|
-
...m.refs && m.refs.length > 0 ? { refs: m.refs } : {}
|
|
24090
|
-
};
|
|
24091
|
-
}
|
|
24092
|
-
function pruneTimestampCache(timestampCache, liveIds) {
|
|
24093
|
-
if (timestampCache.size <= liveIds.size) return;
|
|
24094
|
-
for (const id of timestampCache.keys()) {
|
|
24095
|
-
if (!liveIds.has(id)) timestampCache.delete(id);
|
|
24096
|
-
}
|
|
24097
|
-
}
|
|
24098
|
-
|
|
24099
23761
|
// src/components/chat/embeddable-chat.tsx
|
|
24100
23762
|
import { Fragment as Fragment34, jsx as jsx97, jsxs as jsxs75 } from "react/jsx-runtime";
|
|
24101
23763
|
var HISTORY_RAIL_WIDTH = 320;
|
|
@@ -24118,6 +23780,7 @@ var mentionTokenOf = (key, markerByType) => {
|
|
|
24118
23780
|
const id = ci === -1 ? "" : key.slice(ci + 1);
|
|
24119
23781
|
return `${markerByType.get(type) ?? type.toLowerCase()}:${id}`;
|
|
24120
23782
|
};
|
|
23783
|
+
var FALLBACK_TOP_RETRIEVED = 3;
|
|
24121
23784
|
var RAIL_COLLAPSED_STORAGE_KEY = "mingo-chat-history-collapsed";
|
|
24122
23785
|
var NO_CONTEXT_ITEMS = [];
|
|
24123
23786
|
var RAIL_ANIM_MS = 320;
|
|
@@ -24181,13 +23844,13 @@ function dispatchSlashCommandAction(actionId, cmdId, ref) {
|
|
|
24181
23844
|
input.setValue(`/${cmdId} `);
|
|
24182
23845
|
return;
|
|
24183
23846
|
case "find": {
|
|
24184
|
-
const
|
|
24185
|
-
input.setValueAndCursor(
|
|
23847
|
+
const text = `/${cmdId} ""`;
|
|
23848
|
+
input.setValueAndCursor(text, text.length - 1);
|
|
24186
23849
|
return;
|
|
24187
23850
|
}
|
|
24188
23851
|
case "display": {
|
|
24189
|
-
const
|
|
24190
|
-
input.setValueAndCursor(
|
|
23852
|
+
const text = `/${cmdId} display ""`;
|
|
23853
|
+
input.setValueAndCursor(text, text.length - 1);
|
|
24191
23854
|
return;
|
|
24192
23855
|
}
|
|
24193
23856
|
}
|
|
@@ -24745,17 +24408,56 @@ function EmbeddableChatInner({
|
|
|
24745
24408
|
const guideUserName = activeMode === "guide" ? [identityUser?.firstName, identityUser?.lastName].filter(Boolean).join(" ").trim() || identityUser?.name?.trim() || void 0 : void 0;
|
|
24746
24409
|
const guideUserAvatar = activeMode === "guide" ? identityUser?.avatarUrl?.trim() || void 0 : void 0;
|
|
24747
24410
|
const messages = useMemo30(() => {
|
|
24748
|
-
const
|
|
24749
|
-
const
|
|
24750
|
-
|
|
24411
|
+
const cache = timestampCache;
|
|
24412
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
24413
|
+
const mapped = rawMessages.map((m) => {
|
|
24414
|
+
seenIds.add(m.id);
|
|
24415
|
+
let timestamp;
|
|
24416
|
+
if (m.timestamp != null) {
|
|
24417
|
+
timestamp = new Date(m.timestamp);
|
|
24418
|
+
} else {
|
|
24419
|
+
const cached = cache.get(m.id);
|
|
24420
|
+
timestamp = cached ?? /* @__PURE__ */ new Date();
|
|
24421
|
+
if (!cached) cache.set(m.id, timestamp);
|
|
24422
|
+
}
|
|
24423
|
+
return {
|
|
24424
|
+
id: m.id,
|
|
24425
|
+
role: m.role,
|
|
24426
|
+
// Host-supplied per-message name/avatar win (e.g. the signed-in user's
|
|
24427
|
+
// full name + photo on a `user` bubble); fall back to the role default
|
|
24428
|
+
// when the host doesn't provide them.
|
|
24429
|
+
name: m.name ?? (m.role === "assistant" ? "Mingo" : guideUserName ?? "You"),
|
|
24430
|
+
avatar: m.avatar ?? (m.role === "user" ? guideUserAvatar ?? null : null),
|
|
24431
|
+
// Forward the host's authorType so user bubbles get the same accent
|
|
24432
|
+
// name color as the standalone /mingo page (user → 'admin').
|
|
24433
|
+
...m.authorType ? { authorType: m.authorType } : {},
|
|
24434
|
+
content: m.segments && m.segments.length > 0 ? m.segments : m.content,
|
|
24435
|
+
timestamp,
|
|
24436
|
+
assistantType: m.role === "assistant" ? "mingo" : void 0,
|
|
24437
|
+
// `hidden` is load-bearing, NOT cosmetic: it carries synthetic rows
|
|
24438
|
+
// (e.g. an auto-continuation directive) that the LLM must see but the
|
|
24439
|
+
// reader must not. Dropping it here made the raw directive text render
|
|
24440
|
+
// as an ordinary bubble. This field-by-field rebuild has to forward it
|
|
24441
|
+
// explicitly — see `Message.hidden` and `chat-message-list`'s skip.
|
|
24442
|
+
...m.hidden ? { hidden: true } : {},
|
|
24443
|
+
...m.scrollAnchor ? { scrollAnchor: m.scrollAnchor } : {},
|
|
24444
|
+
// Forward attached context items so the user bubble renders its chips.
|
|
24445
|
+
...m.contextItems && m.contextItems.length > 0 ? { contextItems: m.contextItems } : {}
|
|
24446
|
+
};
|
|
24447
|
+
});
|
|
24448
|
+
if (cache.size > seenIds.size) {
|
|
24449
|
+
for (const id of cache.keys()) {
|
|
24450
|
+
if (!seenIds.has(id)) cache.delete(id);
|
|
24451
|
+
}
|
|
24452
|
+
}
|
|
24751
24453
|
return mapped;
|
|
24752
24454
|
}, [rawMessages, guideUserName, guideUserAvatar, timestampCache]);
|
|
24753
24455
|
const handleSend = useCallback27(
|
|
24754
|
-
(
|
|
24755
|
-
let augmentedText =
|
|
24456
|
+
(text) => {
|
|
24457
|
+
let augmentedText = text;
|
|
24756
24458
|
if (readyAttachments.length > 0) {
|
|
24757
24459
|
const markdown = readyAttachments.map((att) => formatChatAttachmentMarkdownForBubble(att, viewUrlPrefix)).join("");
|
|
24758
|
-
augmentedText = `${
|
|
24460
|
+
augmentedText = `${text}${markdown}`;
|
|
24759
24461
|
}
|
|
24760
24462
|
void sendMessage(augmentedText, {
|
|
24761
24463
|
...readyAttachments.length > 0 ? { attachments: readyAttachments } : {},
|
|
@@ -24891,26 +24593,21 @@ function EmbeddableChatInner({
|
|
|
24891
24593
|
});
|
|
24892
24594
|
return out;
|
|
24893
24595
|
}, [commandsById, enabledSet]);
|
|
24894
|
-
const
|
|
24895
|
-
|
|
24896
|
-
|
|
24897
|
-
|
|
24898
|
-
|
|
24899
|
-
|
|
24900
|
-
|
|
24901
|
-
|
|
24902
|
-
|
|
24903
|
-
|
|
24904
|
-
|
|
24905
|
-
|
|
24906
|
-
|
|
24907
|
-
|
|
24908
|
-
|
|
24909
|
-
}
|
|
24910
|
-
) });
|
|
24911
|
-
},
|
|
24912
|
-
[chatLoading, messages.length, resolvedBaseRoute, chipBasePlatform, handleNavigationClose, discussRef]
|
|
24913
|
-
);
|
|
24596
|
+
const lastAssistantMsg = [...rawMessages].reverse().find((m) => m.role === "assistant");
|
|
24597
|
+
const lastSources = useMemo30(() => {
|
|
24598
|
+
if (chatLoading) return void 0;
|
|
24599
|
+
const sources = lastAssistantMsg?.sources;
|
|
24600
|
+
if (!sources || sources.length === 0) return void 0;
|
|
24601
|
+
const content = lastAssistantMsg?.content || "";
|
|
24602
|
+
const citationOrder = [...content.matchAll(/\[(\d+)\]/g)].map((m) => parseInt(m[1], 10));
|
|
24603
|
+
const seenOrder = /* @__PURE__ */ new Map();
|
|
24604
|
+
citationOrder.forEach((idx) => {
|
|
24605
|
+
if (!seenOrder.has(idx)) seenOrder.set(idx, seenOrder.size);
|
|
24606
|
+
});
|
|
24607
|
+
const cited = sources.filter((s) => seenOrder.has(s.index)).sort((a, b) => (seenOrder.get(a.index) ?? 0) - (seenOrder.get(b.index) ?? 0));
|
|
24608
|
+
const uncited = sources.filter((s) => !seenOrder.has(s.index));
|
|
24609
|
+
return { cited, uncited };
|
|
24610
|
+
}, [lastAssistantMsg, chatLoading]);
|
|
24914
24611
|
const [portalHost, setPortalHost] = useState48(null);
|
|
24915
24612
|
const [panelBoundary, setPanelBoundary] = useState48(null);
|
|
24916
24613
|
const [panelWidth, setPanelWidth] = useState48(0);
|
|
@@ -25226,44 +24923,56 @@ function EmbeddableChatInner({
|
|
|
25226
24923
|
"div",
|
|
25227
24924
|
{
|
|
25228
24925
|
className: "flex min-h-0 flex-1 flex-col duration-200 animate-in fade-in-0",
|
|
25229
|
-
children: hasConversation ? /* @__PURE__ */
|
|
25230
|
-
|
|
25231
|
-
|
|
25232
|
-
|
|
25233
|
-
|
|
25234
|
-
|
|
25235
|
-
|
|
25236
|
-
|
|
25237
|
-
|
|
25238
|
-
|
|
25239
|
-
|
|
25240
|
-
|
|
25241
|
-
|
|
25242
|
-
|
|
25243
|
-
|
|
25244
|
-
|
|
25245
|
-
|
|
25246
|
-
|
|
25247
|
-
|
|
25248
|
-
|
|
25249
|
-
|
|
25250
|
-
|
|
25251
|
-
|
|
25252
|
-
|
|
25253
|
-
|
|
25254
|
-
|
|
25255
|
-
|
|
25256
|
-
|
|
25257
|
-
|
|
25258
|
-
|
|
25259
|
-
|
|
25260
|
-
|
|
25261
|
-
|
|
25262
|
-
|
|
25263
|
-
|
|
25264
|
-
|
|
25265
|
-
|
|
25266
|
-
|
|
24926
|
+
children: hasConversation ? /* @__PURE__ */ jsxs75("div", { className: "flex min-h-0 flex-1 flex-col", children: [
|
|
24927
|
+
messagesInitialLoading ? (
|
|
24928
|
+
// Match the real list's `fullWidth` layout so swapping
|
|
24929
|
+
// skeleton → bubbles doesn't shift the column. The panel
|
|
24930
|
+
// wrapper above already pads (`p-[var(--spacing-system-m)]`),
|
|
24931
|
+
// so the skeleton sits flush (no inner px/pb).
|
|
24932
|
+
//
|
|
24933
|
+
// In `previewMode` the chat lives in a fixed-height host box
|
|
24934
|
+
// (e.g. the Mingo hero demo). The default bottom-anchored
|
|
24935
|
+
// skeleton overflows a short panel and grows its OWN
|
|
24936
|
+
// scrollbar — ugly. `fill` top-anchors + clips overflow so
|
|
24937
|
+
// it reads as "the whole panel is loading" and never scrolls.
|
|
24938
|
+
/* @__PURE__ */ jsx97(ChatMessageListSkeleton, { fullWidth: true, fill: previewMode, className: "flex-1" })
|
|
24939
|
+
) : /* @__PURE__ */ jsx97(
|
|
24940
|
+
ChatMessageList,
|
|
24941
|
+
{
|
|
24942
|
+
messages,
|
|
24943
|
+
isTyping: chatLoading,
|
|
24944
|
+
pendingApprovals,
|
|
24945
|
+
autoScroll: !previewMode,
|
|
24946
|
+
pinBottom: previewMode,
|
|
24947
|
+
overscrollContain: !previewMode,
|
|
24948
|
+
assistantType: "mingo",
|
|
24949
|
+
assistantIcon: mingoAssistantIcon,
|
|
24950
|
+
renderEntityCard,
|
|
24951
|
+
resolveContextIcon,
|
|
24952
|
+
renderContextItem,
|
|
24953
|
+
renderMention,
|
|
24954
|
+
onAskSelect: chatLoading || previewMode ? void 0 : handleAskSelect,
|
|
24955
|
+
NavLinkAnchor: NavLinkAnchorViaRuntime,
|
|
24956
|
+
className: previewMode ? "pointer-events-auto flex-1" : "flex-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",
|
|
24957
|
+
contentClassName: "max-w-none pb-0",
|
|
24958
|
+
fullWidth: true,
|
|
24959
|
+
hasNextPage: hasMoreMessages,
|
|
24960
|
+
isFetchingNextPage: isMessagesLoading,
|
|
24961
|
+
onLoadMore: loadMoreMessages
|
|
24962
|
+
}
|
|
24963
|
+
),
|
|
24964
|
+
lastSources && (lastSources.cited.length > 0 || lastSources.uncited.length > 0) && !chatLoading && /* @__PURE__ */ jsx97("div", { className: "flex-shrink-0 pb-2", children: /* @__PURE__ */ jsx97(
|
|
24965
|
+
SourceChips,
|
|
24966
|
+
{
|
|
24967
|
+
cited: lastSources.cited,
|
|
24968
|
+
uncited: lastSources.uncited,
|
|
24969
|
+
baseRoute: resolvedBaseRoute,
|
|
24970
|
+
chipBasePlatform,
|
|
24971
|
+
onClose: handleNavigationClose,
|
|
24972
|
+
onDiscuss: discussRef
|
|
24973
|
+
}
|
|
24974
|
+
) })
|
|
24975
|
+
] }) : activeMode === "mingo" ? (
|
|
25267
24976
|
/* Figma node 7532:222444 — default (Mingo-mode) empty state:
|
|
25268
24977
|
centred greeting + capability grid + Guide-chat promo +
|
|
25269
24978
|
quick-action chips. Guide mode keeps the slash-command
|
|
@@ -25832,4 +25541,4 @@ export {
|
|
|
25832
25541
|
buildStreamFrames,
|
|
25833
25542
|
EmbeddableChat
|
|
25834
25543
|
};
|
|
25835
|
-
//# sourceMappingURL=chunk-
|
|
25544
|
+
//# sourceMappingURL=chunk-BSMPCPOZ.js.map
|