@flamingo-stack/openframe-frontend-core 0.0.607 → 0.0.608-snapshot.20260908153450
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/{chunk-7ZAPPBFT.cjs → chunk-3N4FXBVJ.cjs} +3 -3
- package/dist/{chunk-7ZAPPBFT.cjs.map → chunk-3N4FXBVJ.cjs.map} +1 -1
- package/dist/{chunk-PS4WZ7YL.cjs → chunk-3XNMDLGB.cjs} +9 -9
- package/dist/{chunk-PS4WZ7YL.cjs.map → chunk-3XNMDLGB.cjs.map} +1 -1
- package/dist/{chunk-UJ64PL7A.cjs → chunk-45XXK2VU.cjs} +10 -10
- package/dist/{chunk-UJ64PL7A.cjs.map → chunk-45XXK2VU.cjs.map} +1 -1
- package/dist/{chunk-ANHHTB32.js → chunk-6MLRFM3T.js} +5 -5
- package/dist/{chunk-ZYEAIBWA.js → chunk-B3UXNGVM.js} +3 -3
- package/dist/{chunk-2V3PJ5X5.js → chunk-B7LYKBCD.js} +5 -5
- package/dist/{chunk-JGSEBZYO.js → chunk-BSMPCPOZ.js} +155 -38
- package/dist/{chunk-JGSEBZYO.js.map → chunk-BSMPCPOZ.js.map} +1 -1
- package/dist/{chunk-3J73ZG3V.js → chunk-BUXGWBTF.js} +2 -2
- package/dist/{chunk-63AGD45L.js → chunk-C7CTEUU7.js} +2 -2
- package/dist/{chunk-XOQI3AH7.cjs → chunk-CZTOSG7Q.cjs} +22 -22
- package/dist/{chunk-XOQI3AH7.cjs.map → chunk-CZTOSG7Q.cjs.map} +1 -1
- package/dist/{chunk-Y6MYIJTK.cjs → chunk-D3DTC7SZ.cjs} +15 -15
- package/dist/{chunk-Y6MYIJTK.cjs.map → chunk-D3DTC7SZ.cjs.map} +1 -1
- package/dist/{chunk-YUDYFA6H.cjs → chunk-DKNXAJMP.cjs} +183 -163
- package/dist/chunk-DKNXAJMP.cjs.map +1 -0
- package/dist/{chunk-XRNILWKL.cjs → chunk-FYG7QNAO.cjs} +5 -5
- package/dist/{chunk-XRNILWKL.cjs.map → chunk-FYG7QNAO.cjs.map} +1 -1
- package/dist/{chunk-IXXMNATN.cjs → chunk-GMOBT5NP.cjs} +70 -70
- package/dist/{chunk-IXXMNATN.cjs.map → chunk-GMOBT5NP.cjs.map} +1 -1
- package/dist/{chunk-CCY47QKL.js → chunk-HGVW7OHI.js} +2 -2
- package/dist/{chunk-7CQA7DAB.js → chunk-JKM5FH63.js} +3 -3
- package/dist/{chunk-RVCLDXCR.js → chunk-JOCVQZGT.js} +5 -5
- package/dist/{chunk-GPIPJOOV.js → chunk-JR7I2AGL.js} +3 -3
- package/dist/{chunk-SWC5LOGS.cjs → chunk-L2JWC5VS.cjs} +43 -43
- package/dist/{chunk-SWC5LOGS.cjs.map → chunk-L2JWC5VS.cjs.map} +1 -1
- package/dist/{chunk-TF6FCNKU.js → chunk-LA2W5L6K.js} +2 -2
- package/dist/{chunk-XJKNJJYO.js → chunk-MVBRMQGU.js} +26 -6
- package/dist/{chunk-XJKNJJYO.js.map → chunk-MVBRMQGU.js.map} +1 -1
- package/dist/{chunk-G7ZK3Q5B.cjs → chunk-NJUSDREV.cjs} +22 -22
- package/dist/{chunk-G7ZK3Q5B.cjs.map → chunk-NJUSDREV.cjs.map} +1 -1
- package/dist/{chunk-Q6ZFTDRR.cjs → chunk-O2M4T34Q.cjs} +4 -4
- package/dist/{chunk-Q6ZFTDRR.cjs.map → chunk-O2M4T34Q.cjs.map} +1 -1
- package/dist/{chunk-PSGHIQXU.js → chunk-OTYV6SDN.js} +3 -3
- package/dist/{chunk-YCOXI5CH.js → chunk-QX4ANESW.js} +6 -6
- package/dist/{chunk-JLVIGGUF.cjs → chunk-RZM6FPOT.cjs} +25 -25
- package/dist/{chunk-JLVIGGUF.cjs.map → chunk-RZM6FPOT.cjs.map} +1 -1
- package/dist/{chunk-WR23DZLT.cjs → chunk-SEW25Y2W.cjs} +10 -10
- package/dist/{chunk-WR23DZLT.cjs.map → chunk-SEW25Y2W.cjs.map} +1 -1
- package/dist/{chunk-25XSOCZK.cjs → chunk-TCEALWE3.cjs} +33 -33
- package/dist/{chunk-25XSOCZK.cjs.map → chunk-TCEALWE3.cjs.map} +1 -1
- package/dist/{chunk-Z2NXXA27.js → chunk-TJ3GFULR.js} +3 -3
- package/dist/{chunk-3FC4DPRX.js → chunk-VCYRJY7J.js} +4 -4
- package/dist/{chunk-VK743MVL.cjs → chunk-XNDTYTVT.cjs} +188 -71
- package/dist/chunk-XNDTYTVT.cjs.map +1 -0
- package/dist/{chunk-BEDMOEAM.cjs → chunk-ZRLFBLME.cjs} +3 -3
- package/dist/{chunk-BEDMOEAM.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/index.cjs +2 -2
- package/dist/components/chat/index.js +1 -1
- package/dist/components/chat/utils/history-merge.d.ts +4 -2
- package/dist/components/chat/utils/history-merge.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/board/index.d.ts +1 -1
- package/dist/components/features/board/index.d.ts.map +1 -1
- package/dist/components/features/board/ticket-card.d.ts.map +1 -1
- package/dist/components/features/board/types.d.ts +18 -0
- package/dist/components/features/board/types.d.ts.map +1 -1
- 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/package.json +1 -1
- package/src/components/chat/utils/__tests__/history-merge.test.ts +292 -0
- package/src/components/chat/utils/history-merge.ts +276 -56
- package/src/components/features/board/index.ts +2 -0
- package/src/components/features/board/ticket-card.tsx +31 -2
- package/src/components/features/board/types.ts +20 -0
- package/src/stories/TicketCard.stories.tsx +40 -1
- package/dist/chunk-VK743MVL.cjs.map +0 -1
- package/dist/chunk-YUDYFA6H.cjs.map +0 -1
- /package/dist/{chunk-ANHHTB32.js.map → chunk-6MLRFM3T.js.map} +0 -0
- /package/dist/{chunk-ZYEAIBWA.js.map → chunk-B3UXNGVM.js.map} +0 -0
- /package/dist/{chunk-2V3PJ5X5.js.map → chunk-B7LYKBCD.js.map} +0 -0
- /package/dist/{chunk-3J73ZG3V.js.map → chunk-BUXGWBTF.js.map} +0 -0
- /package/dist/{chunk-63AGD45L.js.map → chunk-C7CTEUU7.js.map} +0 -0
- /package/dist/{chunk-CCY47QKL.js.map → chunk-HGVW7OHI.js.map} +0 -0
- /package/dist/{chunk-7CQA7DAB.js.map → chunk-JKM5FH63.js.map} +0 -0
- /package/dist/{chunk-RVCLDXCR.js.map → chunk-JOCVQZGT.js.map} +0 -0
- /package/dist/{chunk-GPIPJOOV.js.map → chunk-JR7I2AGL.js.map} +0 -0
- /package/dist/{chunk-TF6FCNKU.js.map → chunk-LA2W5L6K.js.map} +0 -0
- /package/dist/{chunk-PSGHIQXU.js.map → chunk-OTYV6SDN.js.map} +0 -0
- /package/dist/{chunk-YCOXI5CH.js.map → chunk-QX4ANESW.js.map} +0 -0
- /package/dist/{chunk-Z2NXXA27.js.map → chunk-TJ3GFULR.js.map} +0 -0
- /package/dist/{chunk-3FC4DPRX.js.map → chunk-VCYRJY7J.js.map} +0 -0
|
@@ -3,16 +3,16 @@ import {
|
|
|
3
3
|
FileDownloadCard,
|
|
4
4
|
GoogleSheetsViewer,
|
|
5
5
|
PdfViewer
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HGVW7OHI.js";
|
|
7
7
|
import {
|
|
8
8
|
MobileNavigationDropdown,
|
|
9
9
|
MultiLevelNavigation,
|
|
10
10
|
StickySectionNav
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-LA2W5L6K.js";
|
|
12
12
|
import {
|
|
13
13
|
DocSearchBar,
|
|
14
14
|
useDocSearch
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-TJ3GFULR.js";
|
|
16
16
|
import {
|
|
17
17
|
CategorySidebarSkeleton,
|
|
18
18
|
DEFAULT_FOLDER_INDEX_FILE,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
findDocNodeByPath,
|
|
23
23
|
getDocAncestorNodeIds,
|
|
24
24
|
stripFolderIndexFromPath
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-MVBRMQGU.js";
|
|
26
26
|
import {
|
|
27
27
|
contentFetch
|
|
28
28
|
} from "./chunk-BVQEU5JB.js";
|
|
@@ -1050,4 +1050,4 @@ export {
|
|
|
1050
1050
|
EmbedSkeleton,
|
|
1051
1051
|
DocsHubPage
|
|
1052
1052
|
};
|
|
1053
|
-
//# sourceMappingURL=chunk-
|
|
1053
|
+
//# sourceMappingURL=chunk-6MLRFM3T.js.map
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
SelectTrigger,
|
|
9
9
|
SelectValue,
|
|
10
10
|
Textarea
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-MVBRMQGU.js";
|
|
12
12
|
import {
|
|
13
13
|
useContactSubmission,
|
|
14
14
|
useHumanitySignals
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
ChatAttachmentChipStrip,
|
|
23
23
|
SECTION_HEADING_CLASS,
|
|
24
24
|
useChatAttachments
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-BSMPCPOZ.js";
|
|
26
26
|
import {
|
|
27
27
|
Label
|
|
28
28
|
} from "./chunk-5JUTGEZE.js";
|
|
@@ -376,4 +376,4 @@ function ContactForm({
|
|
|
376
376
|
export {
|
|
377
377
|
ContactForm
|
|
378
378
|
};
|
|
379
|
-
//# sourceMappingURL=chunk-
|
|
379
|
+
//# sourceMappingURL=chunk-B3UXNGVM.js.map
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import {
|
|
3
3
|
ArticleAuthorByline,
|
|
4
4
|
DetailPageSkeleton
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-C7CTEUU7.js";
|
|
6
6
|
import {
|
|
7
7
|
DocSearchBar,
|
|
8
8
|
useDocSearch
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-TJ3GFULR.js";
|
|
10
10
|
import {
|
|
11
11
|
useSelfFetch
|
|
12
12
|
} from "./chunk-F2KBCLUG.js";
|
|
@@ -18,13 +18,13 @@ import {
|
|
|
18
18
|
PageShell,
|
|
19
19
|
RichMarkdownRenderer,
|
|
20
20
|
resolveContentHref
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-MVBRMQGU.js";
|
|
22
22
|
import {
|
|
23
23
|
EntityVideoSection,
|
|
24
24
|
VideoBitesStrip,
|
|
25
25
|
useCaptions,
|
|
26
26
|
useVideoWarmup
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-BSMPCPOZ.js";
|
|
28
28
|
import {
|
|
29
29
|
useRouter,
|
|
30
30
|
useSearchParams
|
|
@@ -389,4 +389,4 @@ export {
|
|
|
389
389
|
useOnboardingGuide,
|
|
390
390
|
useOnboardingGuideSections
|
|
391
391
|
};
|
|
392
|
-
//# sourceMappingURL=chunk-
|
|
392
|
+
//# sourceMappingURL=chunk-B7LYKBCD.js.map
|
|
@@ -22729,6 +22729,18 @@ var SYNTHETIC_REALTIME_ID_PREFIXES = ["assistant-", "user-", "direct-", "system-
|
|
|
22729
22729
|
function isSyntheticRealtimeId(id) {
|
|
22730
22730
|
return SYNTHETIC_REALTIME_ID_PREFIXES.some((prefix) => id.startsWith(prefix));
|
|
22731
22731
|
}
|
|
22732
|
+
function isOptimisticId(id) {
|
|
22733
|
+
return id.startsWith("optimistic-");
|
|
22734
|
+
}
|
|
22735
|
+
function isUserRequestSyntheticId(id) {
|
|
22736
|
+
return id.startsWith("user-");
|
|
22737
|
+
}
|
|
22738
|
+
function isClientMintedId(id) {
|
|
22739
|
+
return isSyntheticRealtimeId(id) || isOptimisticId(id);
|
|
22740
|
+
}
|
|
22741
|
+
function isWelcomeId(id) {
|
|
22742
|
+
return id.startsWith("welcome-");
|
|
22743
|
+
}
|
|
22732
22744
|
function assistantAnswerText(content) {
|
|
22733
22745
|
if (typeof content === "string") return content.trim();
|
|
22734
22746
|
if (!Array.isArray(content)) return "";
|
|
@@ -22761,13 +22773,45 @@ function turnRequestKeys(content) {
|
|
|
22761
22773
|
}
|
|
22762
22774
|
return keys;
|
|
22763
22775
|
}
|
|
22764
|
-
function sharesRequestKey(
|
|
22765
|
-
if (keys.size === 0) return false;
|
|
22766
|
-
for (const key of
|
|
22767
|
-
if (
|
|
22776
|
+
function sharesRequestKey(keys, others) {
|
|
22777
|
+
if (keys.size === 0 || others.size === 0) return false;
|
|
22778
|
+
for (const key of keys) {
|
|
22779
|
+
if (others.has(key)) return true;
|
|
22768
22780
|
}
|
|
22769
22781
|
return false;
|
|
22770
22782
|
}
|
|
22783
|
+
function userText(m) {
|
|
22784
|
+
return m.role === "user" && typeof m.content === "string" ? m.content : "";
|
|
22785
|
+
}
|
|
22786
|
+
function collectTwinSignals(rows) {
|
|
22787
|
+
const signals = { requestKeys: /* @__PURE__ */ new Set(), assistantTexts: /* @__PURE__ */ new Map(), userContents: /* @__PURE__ */ new Map() };
|
|
22788
|
+
for (const row of rows) {
|
|
22789
|
+
for (const key of turnRequestKeys(row.content)) signals.requestKeys.add(key);
|
|
22790
|
+
if (row.role === "assistant") {
|
|
22791
|
+
const text2 = assistantAnswerText(row.content);
|
|
22792
|
+
if (text2 !== "") signals.assistantTexts.set(text2, (signals.assistantTexts.get(text2) ?? 0) + 1);
|
|
22793
|
+
continue;
|
|
22794
|
+
}
|
|
22795
|
+
const text = userText(row);
|
|
22796
|
+
if (text !== "") signals.userContents.set(text, (signals.userContents.get(text) ?? 0) + 1);
|
|
22797
|
+
}
|
|
22798
|
+
return signals;
|
|
22799
|
+
}
|
|
22800
|
+
function twinVerdict(signals, m) {
|
|
22801
|
+
if (m.role !== "assistant") {
|
|
22802
|
+
const text2 = userText(m);
|
|
22803
|
+
if (text2 === "") return "unknown";
|
|
22804
|
+
return signals.userContents.has(text2) ? "twin" : "distinct";
|
|
22805
|
+
}
|
|
22806
|
+
const keys = turnRequestKeys(m.content);
|
|
22807
|
+
if (keys.size > 0) return sharesRequestKey(keys, signals.requestKeys) ? "twin" : "distinct";
|
|
22808
|
+
const text = assistantAnswerText(m.content);
|
|
22809
|
+
if (text === "") return "unknown";
|
|
22810
|
+
for (const other of signals.assistantTexts.keys()) {
|
|
22811
|
+
if (other.startsWith(text) || text.startsWith(other)) return "twin";
|
|
22812
|
+
}
|
|
22813
|
+
return "distinct";
|
|
22814
|
+
}
|
|
22771
22815
|
function flattenMessagePagesChronological(pages) {
|
|
22772
22816
|
if (!pages) return [];
|
|
22773
22817
|
return [...pages].reverse().flatMap((page) => [...page.messages].reverse());
|
|
@@ -22832,7 +22876,7 @@ function mergeHistoryWithRealtime(input) {
|
|
|
22832
22876
|
const persistedSize = historyTrailingAssistant.content.length;
|
|
22833
22877
|
const persistedSeq = historyTrailingAssistant.streamSeq ?? 0;
|
|
22834
22878
|
const trailingKeys = turnRequestKeys(historyTrailingAssistant.content);
|
|
22835
|
-
const isSameTurn = (m) => m.id === historyTrailingAssistant.id ||
|
|
22879
|
+
const isSameTurn = (m) => m.id === historyTrailingAssistant.id || sharesRequestKey(turnRequestKeys(m.content), trailingKeys);
|
|
22836
22880
|
const richerTwin = existingMessages.find(
|
|
22837
22881
|
(m) => m !== historyTrailingAssistant && m.role === "assistant" && Array.isArray(m.content) && isSameTurn(m) && // A STILL-STREAMING twin wins outright: it is the copy the chunks are
|
|
22838
22882
|
// landing in, so "richer" is a property it is about to have anyway,
|
|
@@ -22849,30 +22893,64 @@ function mergeHistoryWithRealtime(input) {
|
|
|
22849
22893
|
}
|
|
22850
22894
|
const lastProcessed = processedToUse[processedToUse.length - 1];
|
|
22851
22895
|
const trailingAssistantText = lastProcessed && lastProcessed.role === "assistant" ? assistantAnswerText(lastProcessed.content) : "";
|
|
22852
|
-
const
|
|
22853
|
-
|
|
22854
|
-
|
|
22855
|
-
|
|
22896
|
+
const windowSignals = collectTwinSignals(processedToUse);
|
|
22897
|
+
const seenUserSyntheticByContent = /* @__PURE__ */ new Map();
|
|
22898
|
+
const isInWindow = (m) => processedIds.has(m.id) || (rawHistoryIds?.has(m.id) ?? false);
|
|
22899
|
+
const firstWindowIndex = existingMessages.findIndex(isInWindow);
|
|
22900
|
+
const isPersistedOlder = (m) => !isClientMintedId(m.id) && (m.timestamp?.getTime() ?? 0) <= historyFetchedAt;
|
|
22901
|
+
let lastOlderPersistedIndex = -1;
|
|
22902
|
+
if (firstWindowIndex < 0) {
|
|
22903
|
+
for (const [index, m] of existingMessages.entries()) {
|
|
22904
|
+
if (isPersistedOlder(m) && !pinnedSyntheticIds.has(m.id) && !droppedSyntheticIds.has(m.id)) {
|
|
22905
|
+
lastOlderPersistedIndex = index;
|
|
22906
|
+
}
|
|
22856
22907
|
}
|
|
22857
22908
|
}
|
|
22858
|
-
|
|
22859
|
-
|
|
22860
|
-
|
|
22861
|
-
|
|
22862
|
-
if (
|
|
22863
|
-
|
|
22864
|
-
if (
|
|
22909
|
+
let windowMinSeq = Number.POSITIVE_INFINITY;
|
|
22910
|
+
let windowMinTime = Number.POSITIVE_INFINITY;
|
|
22911
|
+
let windowHasUnstampedAssistant = false;
|
|
22912
|
+
for (const pm of processedToUse) {
|
|
22913
|
+
if (typeof pm.streamSeq === "number") {
|
|
22914
|
+
if (pm.streamSeq < windowMinSeq) windowMinSeq = pm.streamSeq;
|
|
22915
|
+
} else if (pm.role === "assistant") {
|
|
22916
|
+
windowHasUnstampedAssistant = true;
|
|
22917
|
+
}
|
|
22918
|
+
const time = pm.timestamp?.getTime();
|
|
22919
|
+
if (typeof time === "number" && time < windowMinTime) windowMinTime = time;
|
|
22920
|
+
}
|
|
22921
|
+
const threadHasClientMintedRow = existingMessages.some((m) => isClientMintedId(m.id));
|
|
22922
|
+
const seqCanMislead = (m) => m.role === "assistant" ? windowHasUnstampedAssistant : isUserRequestSyntheticId(m.id) || isOptimisticId(m.id);
|
|
22923
|
+
const isOlderThanWindow = (m, index) => {
|
|
22924
|
+
if (m.id === streamingMessageId) return false;
|
|
22925
|
+
if (firstWindowIndex >= 0) {
|
|
22926
|
+
if (index >= firstWindowIndex) return false;
|
|
22927
|
+
return !(isClientMintedId(m.id) && sharesRequestKey(turnRequestKeys(m.content), windowSignals.requestKeys));
|
|
22928
|
+
}
|
|
22929
|
+
if (index < lastOlderPersistedIndex) return true;
|
|
22930
|
+
if (!isClientMintedId(m.id)) return isPersistedOlder(m);
|
|
22931
|
+
if (typeof m.streamSeq === "number") {
|
|
22932
|
+
if (!Number.isFinite(windowMinSeq) || m.streamSeq >= windowMinSeq) return false;
|
|
22933
|
+
const verdict = twinVerdict(windowSignals, m);
|
|
22934
|
+
return verdict === "unknown" ? !seqCanMislead(m) : verdict === "distinct";
|
|
22935
|
+
}
|
|
22936
|
+
const time = m.timestamp?.getTime();
|
|
22937
|
+
if (typeof time !== "number" || time > historyFetchedAt) return false;
|
|
22938
|
+
if (!Number.isFinite(windowMinTime) || time >= windowMinTime) return false;
|
|
22939
|
+
return twinVerdict(windowSignals, m) === "distinct";
|
|
22940
|
+
};
|
|
22941
|
+
const keepRealtime = (m) => {
|
|
22942
|
+
if (m.role === "user" && isOptimisticId(m.id) && typeof m.content === "string") {
|
|
22865
22943
|
const canBeInSnapshot = (m.timestamp?.getTime() ?? 0) <= historyFetchedAt;
|
|
22866
|
-
return !(canBeInSnapshot &&
|
|
22944
|
+
return !(canBeInSnapshot && windowSignals.userContents.has(m.content));
|
|
22867
22945
|
}
|
|
22868
22946
|
if (isSyntheticRealtimeId(m.id) && m.id !== streamingMessageId) {
|
|
22869
22947
|
if (m.role === "assistant" && trailingAssistantText && assistantAnswerText(m.content) === trailingAssistantText) {
|
|
22870
22948
|
return false;
|
|
22871
22949
|
}
|
|
22872
|
-
if (m.role === "user" && m.id
|
|
22950
|
+
if (m.role === "user" && isUserRequestSyntheticId(m.id) && typeof m.content === "string") {
|
|
22873
22951
|
const seen = (seenUserSyntheticByContent.get(m.content) ?? 0) + 1;
|
|
22874
22952
|
seenUserSyntheticByContent.set(m.content, seen);
|
|
22875
|
-
if ((
|
|
22953
|
+
if ((windowSignals.userContents.get(m.content) ?? 0) < seen) return true;
|
|
22876
22954
|
if (typeof m.streamSeq !== "number" || historyMaxStreamSeq <= 0) return false;
|
|
22877
22955
|
if (historyMaxStreamSeq >= m.streamSeq) return false;
|
|
22878
22956
|
const lastPersisted = processedToUse[processedToUse.length - 1];
|
|
@@ -22891,32 +22969,71 @@ function mergeHistoryWithRealtime(input) {
|
|
|
22891
22969
|
if (covered) return false;
|
|
22892
22970
|
}
|
|
22893
22971
|
return true;
|
|
22894
|
-
}
|
|
22895
|
-
|
|
22972
|
+
};
|
|
22973
|
+
const olderThanWindowMessages = [];
|
|
22974
|
+
const realtimeMessages = [];
|
|
22975
|
+
for (const [index, m] of existingMessages.entries()) {
|
|
22976
|
+
if (pinnedSyntheticIds.has(m.id)) {
|
|
22977
|
+
realtimeMessages.push(m);
|
|
22978
|
+
continue;
|
|
22979
|
+
}
|
|
22980
|
+
if (droppedSyntheticIds.has(m.id) || isInWindow(m)) continue;
|
|
22981
|
+
if (firstWindowIndex < 0 && !threadHasClientMintedRow && isPersistedOlder(m) && !isWelcomeId(m.id)) continue;
|
|
22982
|
+
if (isOlderThanWindow(m, index)) {
|
|
22983
|
+
olderThanWindowMessages.push(m);
|
|
22984
|
+
continue;
|
|
22985
|
+
}
|
|
22986
|
+
if (keepRealtime(m)) realtimeMessages.push(m);
|
|
22987
|
+
}
|
|
22988
|
+
return [...olderThanWindowMessages, ...processedToUse, ...realtimeMessages];
|
|
22896
22989
|
}
|
|
22897
22990
|
function computeHistoryPrepend(processedHistory, existingMessages) {
|
|
22898
22991
|
const existingIds = new Set(existingMessages.map((m) => m.id));
|
|
22899
|
-
const
|
|
22900
|
-
|
|
22901
|
-
|
|
22902
|
-
|
|
22903
|
-
|
|
22904
|
-
|
|
22992
|
+
const boundaryMessageIndex = processedHistory.findIndex((m) => existingIds.has(m.id));
|
|
22993
|
+
const newEnd = boundaryMessageIndex >= 0 ? boundaryMessageIndex : processedHistory.length;
|
|
22994
|
+
const boundaryIndexInExisting = boundaryMessageIndex >= 0 ? existingMessages.findIndex((m) => m.id === processedHistory[boundaryMessageIndex].id) : -1;
|
|
22995
|
+
const liveAboveBoundary = boundaryIndexInExisting > 0 ? existingMessages.slice(0, boundaryIndexInExisting).filter((m) => isClientMintedId(m.id)) : [];
|
|
22996
|
+
const twinIndices = /* @__PURE__ */ new Set();
|
|
22997
|
+
if (liveAboveBoundary.length > 0) {
|
|
22998
|
+
const liveSignals = collectTwinSignals(liveAboveBoundary);
|
|
22999
|
+
const userTwinsLeft = new Map(liveSignals.userContents);
|
|
23000
|
+
const assistantTwinsLeft = new Map(liveSignals.assistantTexts);
|
|
23001
|
+
for (let i = newEnd - 1; i >= 0; i--) {
|
|
23002
|
+
const pm = processedHistory[i];
|
|
23003
|
+
if (pm.role === "user") {
|
|
23004
|
+
const text = userText(pm);
|
|
23005
|
+
const left = text === "" ? 0 : userTwinsLeft.get(text) ?? 0;
|
|
23006
|
+
if (left === 0) continue;
|
|
23007
|
+
userTwinsLeft.set(text, left - 1);
|
|
23008
|
+
twinIndices.add(i);
|
|
23009
|
+
} else if (pm.role === "assistant") {
|
|
23010
|
+
const keys = turnRequestKeys(pm.content);
|
|
23011
|
+
if (keys.size > 0) {
|
|
23012
|
+
if (sharesRequestKey(keys, liveSignals.requestKeys)) twinIndices.add(i);
|
|
23013
|
+
continue;
|
|
23014
|
+
}
|
|
23015
|
+
const text = assistantAnswerText(pm.content);
|
|
23016
|
+
if (text === "") continue;
|
|
23017
|
+
for (const [liveText, left] of assistantTwinsLeft) {
|
|
23018
|
+
if (left === 0 || !text.startsWith(liveText)) continue;
|
|
23019
|
+
assistantTwinsLeft.set(liveText, left - 1);
|
|
23020
|
+
twinIndices.add(i);
|
|
23021
|
+
break;
|
|
23022
|
+
}
|
|
23023
|
+
}
|
|
22905
23024
|
}
|
|
22906
|
-
newMessages.push(processedHistory[i]);
|
|
22907
23025
|
}
|
|
23026
|
+
const newMessages = processedHistory.slice(0, newEnd).filter((_, i) => !twinIndices.has(i));
|
|
22908
23027
|
let boundaryMessageId;
|
|
22909
23028
|
let boundaryUpdates;
|
|
22910
|
-
if (
|
|
23029
|
+
if (boundaryIndexInExisting >= 0) {
|
|
22911
23030
|
const boundaryMessage = processedHistory[boundaryMessageIndex];
|
|
22912
|
-
const existingBoundary = existingMessages
|
|
22913
|
-
|
|
22914
|
-
|
|
22915
|
-
|
|
22916
|
-
|
|
22917
|
-
|
|
22918
|
-
boundaryUpdates = { content: boundaryMessage.content };
|
|
22919
|
-
}
|
|
23031
|
+
const existingBoundary = existingMessages[boundaryIndexInExisting];
|
|
23032
|
+
const existingContent = JSON.stringify(existingBoundary.content);
|
|
23033
|
+
const newContent = JSON.stringify(boundaryMessage.content);
|
|
23034
|
+
if (existingContent !== newContent) {
|
|
23035
|
+
boundaryMessageId = boundaryMessage.id;
|
|
23036
|
+
boundaryUpdates = { content: boundaryMessage.content };
|
|
22920
23037
|
}
|
|
22921
23038
|
}
|
|
22922
23039
|
if (newMessages.length === 0 && !boundaryUpdates) return null;
|
|
@@ -25424,4 +25541,4 @@ export {
|
|
|
25424
25541
|
buildStreamFrames,
|
|
25425
25542
|
EmbeddableChat
|
|
25426
25543
|
};
|
|
25427
|
-
//# sourceMappingURL=chunk-
|
|
25544
|
+
//# sourceMappingURL=chunk-BSMPCPOZ.js.map
|