@flamingo-stack/openframe-frontend-core 0.0.598 → 0.0.599-2039.5716.1
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/index.cjs +8 -1
- package/dist/chat-protocol/index.cjs.map +1 -1
- package/dist/chat-protocol/index.d.ts +1 -0
- package/dist/chat-protocol/index.d.ts.map +1 -1
- package/dist/chat-protocol/index.js +7 -2
- package/dist/chat-protocol/index.js.map +1 -1
- package/dist/chat-protocol/nats-decoder.d.ts.map +1 -1
- package/dist/chat-protocol/wire-narrow.d.ts +17 -0
- package/dist/chat-protocol/wire-narrow.d.ts.map +1 -0
- package/dist/{chunk-VLJTJAHJ.cjs → chunk-2B4HSYAX.cjs} +25 -25
- package/dist/{chunk-VLJTJAHJ.cjs.map → chunk-2B4HSYAX.cjs.map} +1 -1
- package/dist/{chunk-UE7OFLLS.cjs → chunk-2GCBN73M.cjs} +14 -14
- package/dist/{chunk-UE7OFLLS.cjs.map → chunk-2GCBN73M.cjs.map} +1 -1
- package/dist/{chunk-STYNZ4QM.cjs → chunk-3IXDZI3R.cjs} +3 -3
- package/dist/{chunk-STYNZ4QM.cjs.map → chunk-3IXDZI3R.cjs.map} +1 -1
- package/dist/{chunk-DAPOBLAK.cjs → chunk-3RWSKUIN.cjs} +39 -39
- package/dist/{chunk-DAPOBLAK.cjs.map → chunk-3RWSKUIN.cjs.map} +1 -1
- package/dist/{chunk-VNSRNVPD.js → chunk-4HJYXP5O.js} +722 -406
- package/dist/chunk-4HJYXP5O.js.map +1 -0
- package/dist/{chunk-HWAYIK4U.cjs → chunk-4MOY5TQR.cjs} +22 -22
- package/dist/{chunk-HWAYIK4U.cjs.map → chunk-4MOY5TQR.cjs.map} +1 -1
- package/dist/{chunk-VIRTMRS4.js → chunk-4PBUEYAE.js} +7 -7
- package/dist/{chunk-TZPVRWPU.js → chunk-4TG5BWPE.js} +5 -5
- package/dist/{chunk-PTK3CINU.js → chunk-6JF65LRQ.js} +5 -5
- package/dist/{chunk-YWBAIFI2.cjs → chunk-6XISE63Q.cjs} +105 -105
- package/dist/{chunk-YWBAIFI2.cjs.map → chunk-6XISE63Q.cjs.map} +1 -1
- package/dist/{chunk-QD64Q4I2.cjs → chunk-A4HMGZ4L.cjs} +9 -9
- package/dist/{chunk-QD64Q4I2.cjs.map → chunk-A4HMGZ4L.cjs.map} +1 -1
- package/dist/{chunk-BK6CCQG6.js → chunk-AUCJ6I3R.js} +12 -12
- package/dist/{chunk-3WSS7C2V.cjs → chunk-BBBZ5QUB.cjs} +15 -15
- package/dist/{chunk-3WSS7C2V.cjs.map → chunk-BBBZ5QUB.cjs.map} +1 -1
- package/dist/{chunk-EVMHJB6X.js → chunk-BLUL2TE3.js} +4 -4
- package/dist/{chunk-GGQZBSFN.js → chunk-BVQEU5JB.js} +2 -2
- package/dist/{chunk-V2QK5W3O.cjs → chunk-BW644MGF.cjs} +3 -3
- package/dist/{chunk-V2QK5W3O.cjs.map → chunk-BW644MGF.cjs.map} +1 -1
- package/dist/{chunk-H64ZHSYR.cjs → chunk-CCWI3622.cjs} +4 -4
- package/dist/{chunk-H64ZHSYR.cjs.map → chunk-CCWI3622.cjs.map} +1 -1
- package/dist/{chunk-DI3SVVY5.cjs → chunk-COERKO4N.cjs} +85 -85
- package/dist/{chunk-DI3SVVY5.cjs.map → chunk-COERKO4N.cjs.map} +1 -1
- package/dist/{chunk-SE3PVN64.js → chunk-DZ44C6KB.js} +2 -2
- package/dist/{chunk-2SYX2Z7R.cjs → chunk-E27TMQRE.cjs} +34 -34
- package/dist/{chunk-2SYX2Z7R.cjs.map → chunk-E27TMQRE.cjs.map} +1 -1
- package/dist/{chunk-YH6IQTPI.cjs → chunk-EHAYNUOL.cjs} +3 -3
- package/dist/{chunk-YH6IQTPI.cjs.map → chunk-EHAYNUOL.cjs.map} +1 -1
- package/dist/{chunk-WZJOILPU.js → chunk-F2KBCLUG.js} +2 -2
- package/dist/{chunk-MYBXCWEI.js → chunk-FKBM6U43.js} +2 -2
- package/dist/{chunk-75YW6ET4.js → chunk-FNK4RZ25.js} +4 -4
- package/dist/{chunk-UG7JNQZY.cjs → chunk-GB5FPCUN.cjs} +37 -37
- package/dist/{chunk-UG7JNQZY.cjs.map → chunk-GB5FPCUN.cjs.map} +1 -1
- package/dist/{chunk-P24VPJTT.cjs → chunk-HJUXXWTM.cjs} +15 -15
- package/dist/{chunk-P24VPJTT.cjs.map → chunk-HJUXXWTM.cjs.map} +1 -1
- package/dist/{chunk-WPN545FW.js → chunk-ILJTXIEI.js} +12 -12
- package/dist/{chunk-YBPFIXV4.cjs → chunk-ITZDJYWI.cjs} +796 -480
- package/dist/chunk-ITZDJYWI.cjs.map +1 -0
- package/dist/{chunk-LRQCKSZC.js → chunk-IW746HJ7.js} +2 -2
- package/dist/{chunk-PX4IPM7Q.js → chunk-J62LLUDC.js} +3 -3
- package/dist/{chunk-M4YQUHOR.cjs → chunk-JJUV7Z4L.cjs} +15 -15
- package/dist/{chunk-M4YQUHOR.cjs.map → chunk-JJUV7Z4L.cjs.map} +1 -1
- package/dist/{chunk-GHYFVT52.js → chunk-JZF6EUMO.js} +5 -5
- package/dist/{chunk-JVZVVZOZ.cjs → chunk-KYGTR6EG.cjs} +9 -9
- package/dist/{chunk-JVZVVZOZ.cjs.map → chunk-KYGTR6EG.cjs.map} +1 -1
- package/dist/{chunk-QIKBISZM.cjs → chunk-L66UPFCQ.cjs} +242 -242
- package/dist/{chunk-QIKBISZM.cjs.map → chunk-L66UPFCQ.cjs.map} +1 -1
- package/dist/{chunk-NIAMPMKV.js → chunk-LJ4UG2SW.js} +4 -4
- package/dist/{chunk-WDWCQD75.js → chunk-MWQSHXYK.js} +9 -9
- package/dist/{chunk-BPVHDDNY.cjs → chunk-NLFST5II.cjs} +8 -8
- package/dist/{chunk-BPVHDDNY.cjs.map → chunk-NLFST5II.cjs.map} +1 -1
- package/dist/{chunk-SAEJGTCI.cjs → chunk-QPAPUIF3.cjs} +35 -35
- package/dist/{chunk-SAEJGTCI.cjs.map → chunk-QPAPUIF3.cjs.map} +1 -1
- package/dist/{chunk-HLPAVYK7.js → chunk-RSTEDWAT.js} +4 -4
- package/dist/{chunk-UAAXUFK6.js → chunk-RU3IKVY2.js} +3 -3
- package/dist/{chunk-EZM5DNII.js → chunk-S6WBBSII.js} +3 -3
- package/dist/{chunk-2JNCZDJR.js → chunk-TSCIVH7T.js} +2 -2
- package/dist/{chunk-RDTOMWDN.cjs → chunk-UPKZU6QU.cjs} +1 -1
- package/dist/chunk-UPKZU6QU.cjs.map +1 -0
- package/dist/{chunk-WCBRZCU4.cjs → chunk-UQEOAPAI.cjs} +9 -9
- package/dist/{chunk-WCBRZCU4.cjs.map → chunk-UQEOAPAI.cjs.map} +1 -1
- package/dist/{chunk-O4VZOA2Q.cjs → chunk-UXOOVP77.cjs} +3 -3
- package/dist/{chunk-O4VZOA2Q.cjs.map → chunk-UXOOVP77.cjs.map} +1 -1
- package/dist/{chunk-R4UV366K.js → chunk-UYLZAW6Y.js} +6 -6
- package/dist/{chunk-BZEWPW5A.cjs → chunk-VIBREYUK.cjs} +3 -3
- package/dist/{chunk-BZEWPW5A.cjs.map → chunk-VIBREYUK.cjs.map} +1 -1
- package/dist/{chunk-KHOZ52NR.js → chunk-XSMBLU44.js} +6 -6
- package/dist/{chunk-RYXIRVDC.js → chunk-YB6FI2G3.js} +1 -1
- package/dist/chunk-YB6FI2G3.js.map +1 -0
- package/dist/{chunk-XNPAVMPB.js → chunk-YG7DCXRD.js} +5 -5
- package/dist/components/case-studies/index.cjs +14 -14
- package/dist/components/case-studies/index.js +8 -8
- package/dist/components/chat/embeddable-chat.d.ts +10 -19
- package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
- package/dist/components/chat/hooks/index.d.ts +1 -0
- package/dist/components/chat/hooks/index.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-chat-history-hydration.d.ts +13 -3
- package/dist/components/chat/hooks/use-chat-history-hydration.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-managed-dialog-list.d.ts +53 -0
- package/dist/components/chat/hooks/use-managed-dialog-list.d.ts.map +1 -0
- package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts +2 -16
- package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-unified-chat.d.ts.map +1 -1
- package/dist/components/chat/index.cjs +9 -5
- package/dist/components/chat/index.cjs.map +1 -1
- package/dist/components/chat/index.js +8 -4
- package/dist/components/chat/types/unified-chat-state.types.d.ts +72 -6
- package/dist/components/chat/types/unified-chat-state.types.d.ts.map +1 -1
- package/dist/components/chat/utils/chat-conversations-api.d.ts +29 -0
- package/dist/components/chat/utils/chat-conversations-api.d.ts.map +1 -0
- package/dist/components/chat/utils/index.d.ts +1 -0
- package/dist/components/chat/utils/index.d.ts.map +1 -1
- package/dist/components/contact/index.cjs +9 -9
- package/dist/components/contact/index.js +8 -8
- package/dist/components/docs/index.cjs +12 -12
- package/dist/components/docs/index.js +11 -11
- package/dist/components/embeds/index.cjs +9 -9
- package/dist/components/embeds/index.js +8 -8
- package/dist/components/faq/index.cjs +10 -10
- package/dist/components/faq/index.js +9 -9
- package/dist/components/features/index.cjs +8 -8
- package/dist/components/features/index.js +7 -7
- package/dist/components/help-center-pages/index.cjs +31 -31
- package/dist/components/help-center-pages/index.js +22 -22
- package/dist/components/index.cjs +70 -66
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +26 -22
- package/dist/components/index.js.map +1 -1
- package/dist/components/meeting-scheduler/index.cjs +49 -49
- package/dist/components/meeting-scheduler/index.js +9 -9
- package/dist/components/navigation/index.cjs +11 -11
- package/dist/components/navigation/index.js +10 -10
- package/dist/components/onboarding-guides/index.cjs +12 -12
- package/dist/components/onboarding-guides/index.js +11 -11
- package/dist/components/related-content/index.cjs +7 -7
- package/dist/components/related-content/index.js +6 -6
- package/dist/components/tickets/index.cjs +13 -13
- package/dist/components/tickets/index.js +12 -12
- package/dist/components/ui/index.cjs +12 -8
- package/dist/components/ui/index.cjs.map +1 -1
- package/dist/components/ui/index.js +11 -7
- package/dist/contexts/chat-runtime-context.d.ts +12 -0
- package/dist/contexts/chat-runtime-context.d.ts.map +1 -1
- package/dist/contexts/index.cjs +2 -2
- package/dist/contexts/index.js +1 -1
- package/dist/hooks/index.cjs +5 -5
- package/dist/hooks/index.js +4 -4
- package/dist/index.cjs +16 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/chat-protocol/index.ts +1 -0
- package/src/chat-protocol/nats-decoder.ts +1 -5
- package/src/chat-protocol/wire-narrow.ts +22 -0
- package/src/components/chat/.embeddable-chat.md +4 -2
- package/src/components/chat/embeddable-chat.tsx +136 -84
- package/src/components/chat/hooks/.index.md +1 -1
- package/src/components/chat/hooks/.use-managed-dialog-list.md +31 -0
- package/src/components/chat/hooks/.use-nats-chat-adapter.md +3 -1
- package/src/components/chat/hooks/.use-sse-chat-adapter.md +8 -1
- package/src/components/chat/hooks/.use-unified-chat.md +2 -2
- package/src/components/chat/hooks/__tests__/managed-dialog-list.test.ts +280 -0
- package/src/components/chat/hooks/__tests__/nats-adapter-managed-dialogs.test.ts +173 -0
- package/src/components/chat/hooks/__tests__/sse-managed-dialogs.test.ts +310 -0
- package/src/components/chat/hooks/index.ts +2 -0
- package/src/components/chat/hooks/use-chat-history-hydration.ts +67 -24
- package/src/components/chat/hooks/use-managed-dialog-list.ts +339 -0
- package/src/components/chat/hooks/use-nats-chat-adapter.ts +65 -150
- package/src/components/chat/hooks/use-sse-chat-adapter.ts +233 -59
- package/src/components/chat/hooks/use-unified-chat.ts +5 -0
- package/src/components/chat/types/.unified-chat-state.types.md +13 -1
- package/src/components/chat/types/unified-chat-state.types.ts +79 -6
- package/src/components/chat/utils/.chat-conversations-api.md +16 -0
- package/src/components/chat/utils/.index.md +1 -1
- package/src/components/chat/utils/__tests__/chat-conversations-api-golden.test.ts +105 -0
- package/src/components/chat/utils/chat-conversations-api.ts +83 -0
- package/src/components/chat/utils/index.ts +7 -0
- package/src/contexts/.chat-runtime-context.md +3 -1
- package/src/contexts/chat-runtime-context.tsx +12 -0
- package/dist/chunk-RDTOMWDN.cjs.map +0 -1
- package/dist/chunk-RYXIRVDC.js.map +0 -1
- package/dist/chunk-VNSRNVPD.js.map +0 -1
- package/dist/chunk-YBPFIXV4.cjs.map +0 -1
- /package/dist/{chunk-VIRTMRS4.js.map → chunk-4PBUEYAE.js.map} +0 -0
- /package/dist/{chunk-TZPVRWPU.js.map → chunk-4TG5BWPE.js.map} +0 -0
- /package/dist/{chunk-PTK3CINU.js.map → chunk-6JF65LRQ.js.map} +0 -0
- /package/dist/{chunk-BK6CCQG6.js.map → chunk-AUCJ6I3R.js.map} +0 -0
- /package/dist/{chunk-EVMHJB6X.js.map → chunk-BLUL2TE3.js.map} +0 -0
- /package/dist/{chunk-GGQZBSFN.js.map → chunk-BVQEU5JB.js.map} +0 -0
- /package/dist/{chunk-SE3PVN64.js.map → chunk-DZ44C6KB.js.map} +0 -0
- /package/dist/{chunk-WZJOILPU.js.map → chunk-F2KBCLUG.js.map} +0 -0
- /package/dist/{chunk-MYBXCWEI.js.map → chunk-FKBM6U43.js.map} +0 -0
- /package/dist/{chunk-75YW6ET4.js.map → chunk-FNK4RZ25.js.map} +0 -0
- /package/dist/{chunk-WPN545FW.js.map → chunk-ILJTXIEI.js.map} +0 -0
- /package/dist/{chunk-LRQCKSZC.js.map → chunk-IW746HJ7.js.map} +0 -0
- /package/dist/{chunk-PX4IPM7Q.js.map → chunk-J62LLUDC.js.map} +0 -0
- /package/dist/{chunk-GHYFVT52.js.map → chunk-JZF6EUMO.js.map} +0 -0
- /package/dist/{chunk-NIAMPMKV.js.map → chunk-LJ4UG2SW.js.map} +0 -0
- /package/dist/{chunk-WDWCQD75.js.map → chunk-MWQSHXYK.js.map} +0 -0
- /package/dist/{chunk-HLPAVYK7.js.map → chunk-RSTEDWAT.js.map} +0 -0
- /package/dist/{chunk-UAAXUFK6.js.map → chunk-RU3IKVY2.js.map} +0 -0
- /package/dist/{chunk-EZM5DNII.js.map → chunk-S6WBBSII.js.map} +0 -0
- /package/dist/{chunk-2JNCZDJR.js.map → chunk-TSCIVH7T.js.map} +0 -0
- /package/dist/{chunk-R4UV366K.js.map → chunk-UYLZAW6Y.js.map} +0 -0
- /package/dist/{chunk-KHOZ52NR.js.map → chunk-XSMBLU44.js.map} +0 -0
- /package/dist/{chunk-XNPAVMPB.js.map → chunk-YG7DCXRD.js.map} +0 -0
|
@@ -170,7 +170,7 @@ import {
|
|
|
170
170
|
safeHref,
|
|
171
171
|
sortBitesByCreatedAtDesc,
|
|
172
172
|
useCoverImageFallback
|
|
173
|
-
} from "./chunk-
|
|
173
|
+
} from "./chunk-RU3IKVY2.js";
|
|
174
174
|
import {
|
|
175
175
|
next_image_default
|
|
176
176
|
} from "./chunk-MDKCTSDS.js";
|
|
@@ -183,14 +183,14 @@ import {
|
|
|
183
183
|
getPlatformDisplayName,
|
|
184
184
|
useAuthedAssetSrc,
|
|
185
185
|
useAuthedImageSrc
|
|
186
|
-
} from "./chunk-
|
|
186
|
+
} from "./chunk-FKBM6U43.js";
|
|
187
187
|
import {
|
|
188
188
|
OpenFrameLogo
|
|
189
189
|
} from "./chunk-OTX6XNSA.js";
|
|
190
190
|
import {
|
|
191
191
|
useChatRuntime,
|
|
192
192
|
useRequiredChatRuntime
|
|
193
|
-
} from "./chunk-
|
|
193
|
+
} from "./chunk-YB6FI2G3.js";
|
|
194
194
|
import {
|
|
195
195
|
COLLISION_PADDING_PX,
|
|
196
196
|
CollisionBoundaryContext,
|
|
@@ -17764,7 +17764,7 @@ function useChat({
|
|
|
17764
17764
|
}
|
|
17765
17765
|
|
|
17766
17766
|
// src/components/chat/hooks/use-sse-chat-adapter.ts
|
|
17767
|
-
import { useCallback as
|
|
17767
|
+
import { useCallback as useCallback21, useMemo as useMemo26, useRef as useRef29, useState as useState41 } from "react";
|
|
17768
17768
|
|
|
17769
17769
|
// src/chat-protocol/confirm-tool.ts
|
|
17770
17770
|
function buildConfirmToolBody(request) {
|
|
@@ -20251,6 +20251,62 @@ function pruneStaleChatConversationStorage(source) {
|
|
|
20251
20251
|
}
|
|
20252
20252
|
}
|
|
20253
20253
|
|
|
20254
|
+
// src/chat-protocol/wire-narrow.ts
|
|
20255
|
+
function isRecord(value) {
|
|
20256
|
+
return typeof value === "object" && value !== null;
|
|
20257
|
+
}
|
|
20258
|
+
function unwrapEnvelope(payload) {
|
|
20259
|
+
return isRecord(payload) && "data" in payload ? payload.data : payload;
|
|
20260
|
+
}
|
|
20261
|
+
|
|
20262
|
+
// src/components/chat/utils/chat-conversations-api.ts
|
|
20263
|
+
function toDialogItem(row) {
|
|
20264
|
+
if (!isRecord(row)) return null;
|
|
20265
|
+
const id = typeof row.id === "string" ? row.id : "";
|
|
20266
|
+
if (!id) return null;
|
|
20267
|
+
const title = typeof row.title === "string" && row.title.length > 0 ? row.title : "Untitled chat";
|
|
20268
|
+
const ts = typeof row.timestamp === "string" ? new Date(row.timestamp) : void 0;
|
|
20269
|
+
return {
|
|
20270
|
+
id,
|
|
20271
|
+
title,
|
|
20272
|
+
...ts && !Number.isNaN(ts.getTime()) ? { timestamp: ts } : {},
|
|
20273
|
+
...typeof row.lastMessage === "string" ? { lastMessage: row.lastMessage } : {}
|
|
20274
|
+
};
|
|
20275
|
+
}
|
|
20276
|
+
async function failWith(response, fallback) {
|
|
20277
|
+
const message = await readServerErrorMessage(response);
|
|
20278
|
+
throw new Error(message ?? `${fallback}: ${response.status}`);
|
|
20279
|
+
}
|
|
20280
|
+
function createChatConversationsApi(baseUrl) {
|
|
20281
|
+
const base = baseUrl.replace(/\/+$/, "");
|
|
20282
|
+
const patch = async (id, body, what) => {
|
|
20283
|
+
const response = await embedAuthedFetch(`${base}/${encodeURIComponent(id)}`, {
|
|
20284
|
+
method: "PATCH",
|
|
20285
|
+
body: JSON.stringify(body)
|
|
20286
|
+
});
|
|
20287
|
+
if (!response.ok) await failWith(response, `${what} failed`);
|
|
20288
|
+
};
|
|
20289
|
+
return {
|
|
20290
|
+
async fetchDialogs({ status, cursor, limit, search }) {
|
|
20291
|
+
const qs = new URLSearchParams();
|
|
20292
|
+
qs.set("status", status);
|
|
20293
|
+
if (limit !== void 0) qs.set("limit", String(limit));
|
|
20294
|
+
if (cursor) qs.set("cursor", cursor);
|
|
20295
|
+
if (search) qs.set("search", search);
|
|
20296
|
+
const response = await embedAuthedFetch(`${base}?${qs.toString()}`, { method: "GET" });
|
|
20297
|
+
if (!response.ok) await failWith(response, "Conversation list failed");
|
|
20298
|
+
const body = unwrapEnvelope(await response.json());
|
|
20299
|
+
const rawDialogs = isRecord(body) && Array.isArray(body.dialogs) ? body.dialogs : [];
|
|
20300
|
+
const dialogs = rawDialogs.map(toDialogItem).filter((d) => d !== null);
|
|
20301
|
+
const nextCursor = isRecord(body) && typeof body.nextCursor === "string" ? body.nextCursor : null;
|
|
20302
|
+
return { dialogs, nextCursor };
|
|
20303
|
+
},
|
|
20304
|
+
renameDialog: (id, title) => patch(id, { title }, "Rename"),
|
|
20305
|
+
archiveDialog: (id) => patch(id, { archived: true }, "Archive"),
|
|
20306
|
+
unarchiveDialog: (id) => patch(id, { archived: false }, "Restore")
|
|
20307
|
+
};
|
|
20308
|
+
}
|
|
20309
|
+
|
|
20254
20310
|
// src/components/chat/utils/slash-dispatch-utils.ts
|
|
20255
20311
|
var WIRE_TABLE_ID_REGEX = /^[a-z][a-z0-9-]*$/;
|
|
20256
20312
|
var WIRE_ID_REGEX = /^[A-Za-z0-9._:/-]+$/;
|
|
@@ -20333,41 +20389,48 @@ function buildAutoContinuationDirective(toolName, opts = {}) {
|
|
|
20333
20389
|
}
|
|
20334
20390
|
|
|
20335
20391
|
// src/components/chat/hooks/use-chat-history-hydration.ts
|
|
20336
|
-
function isRecord(value) {
|
|
20337
|
-
return typeof value === "object" && value !== null;
|
|
20338
|
-
}
|
|
20339
20392
|
function useChatHistoryHydration({
|
|
20340
20393
|
active,
|
|
20341
20394
|
source,
|
|
20342
20395
|
historyUrl,
|
|
20343
|
-
|
|
20396
|
+
conversationId,
|
|
20344
20397
|
sendCountRef,
|
|
20345
20398
|
hydrateMessages,
|
|
20346
|
-
bumpMetaTick
|
|
20399
|
+
bumpMetaTick,
|
|
20400
|
+
onOrphanedConversation
|
|
20347
20401
|
}) {
|
|
20348
20402
|
const [isHydratingHistory, setIsHydratingHistory] = useState39(false);
|
|
20349
20403
|
const hydratedKeyRef = useRef27(null);
|
|
20404
|
+
const runIdRef = useRef27(0);
|
|
20350
20405
|
useEffect33(() => {
|
|
20351
|
-
if (!active) return
|
|
20352
|
-
const conversationId = conversationIdRef.current;
|
|
20353
|
-
if (!conversationId) return void 0;
|
|
20406
|
+
if (!active || !conversationId) return () => setIsHydratingHistory(false);
|
|
20354
20407
|
const key = `${source}:${conversationId}`;
|
|
20355
|
-
if (hydratedKeyRef.current === key) return
|
|
20408
|
+
if (hydratedKeyRef.current === key) return () => setIsHydratingHistory(false);
|
|
20356
20409
|
hydratedKeyRef.current = key;
|
|
20357
20410
|
let cancelled = false;
|
|
20411
|
+
let completed = false;
|
|
20412
|
+
const runId = ++runIdRef.current;
|
|
20413
|
+
const isCurrentRun = () => runIdRef.current === runId;
|
|
20358
20414
|
setIsHydratingHistory(true);
|
|
20359
20415
|
void (async () => {
|
|
20360
20416
|
try {
|
|
20361
20417
|
const res = await embedAuthedFetch(`${historyUrl}?conversationId=${encodeURIComponent(conversationId)}`, {
|
|
20362
20418
|
method: "GET"
|
|
20363
20419
|
});
|
|
20364
|
-
if (!res.ok)
|
|
20420
|
+
if (!res.ok) {
|
|
20421
|
+
if (isCurrentRun() && hydratedKeyRef.current === key) hydratedKeyRef.current = null;
|
|
20422
|
+
return;
|
|
20423
|
+
}
|
|
20365
20424
|
const payload = await res.json().catch(() => null);
|
|
20366
|
-
const
|
|
20367
|
-
const body = envelope ?? payload;
|
|
20425
|
+
const body = unwrapEnvelope(payload);
|
|
20368
20426
|
const rawRows = isRecord(body) ? body.messages : void 0;
|
|
20369
20427
|
const rows = Array.isArray(rawRows) ? rawRows.filter(isRecord) : [];
|
|
20370
|
-
if (cancelled
|
|
20428
|
+
if (cancelled) return;
|
|
20429
|
+
if (rows.length === 0) {
|
|
20430
|
+
const found = isRecord(body) ? body.found : void 0;
|
|
20431
|
+
if (found === false) onOrphanedConversation?.(conversationId);
|
|
20432
|
+
return;
|
|
20433
|
+
}
|
|
20371
20434
|
const hydrated = [];
|
|
20372
20435
|
const sourcesSeed = /* @__PURE__ */ new Map();
|
|
20373
20436
|
let userTurns = 0;
|
|
@@ -20395,32 +20458,218 @@ function useChatHistoryHydration({
|
|
|
20395
20458
|
hydrateMessages(hydrated, Array.from(sourcesSeed.entries()));
|
|
20396
20459
|
bumpMetaTick();
|
|
20397
20460
|
} catch {
|
|
20461
|
+
if (isCurrentRun() && hydratedKeyRef.current === key) hydratedKeyRef.current = null;
|
|
20398
20462
|
} finally {
|
|
20399
|
-
|
|
20463
|
+
completed = true;
|
|
20464
|
+
if (isCurrentRun()) setIsHydratingHistory(false);
|
|
20400
20465
|
}
|
|
20401
20466
|
})();
|
|
20402
20467
|
return () => {
|
|
20403
20468
|
cancelled = true;
|
|
20469
|
+
if (!completed && isCurrentRun() && hydratedKeyRef.current === key) hydratedKeyRef.current = null;
|
|
20470
|
+
if (isCurrentRun()) setIsHydratingHistory(false);
|
|
20404
20471
|
};
|
|
20405
|
-
}, [active, source, historyUrl, hydrateMessages, bumpMetaTick,
|
|
20472
|
+
}, [active, source, historyUrl, conversationId, hydrateMessages, bumpMetaTick, onOrphanedConversation, sendCountRef]);
|
|
20406
20473
|
return { isHydratingHistory, hydratedKeyRef };
|
|
20407
20474
|
}
|
|
20408
20475
|
|
|
20476
|
+
// src/components/chat/hooks/use-managed-dialog-list.ts
|
|
20477
|
+
import { useCallback as useCallback20, useEffect as useEffect34, useMemo as useMemo25, useRef as useRef28, useState as useState40 } from "react";
|
|
20478
|
+
function useManagedDialogList({
|
|
20479
|
+
autoLoad,
|
|
20480
|
+
fetchDialogs,
|
|
20481
|
+
renameDialog: renameDialogCallback,
|
|
20482
|
+
archiveDialog: archiveDialogCallback,
|
|
20483
|
+
deleteDialog: deleteDialogCallback,
|
|
20484
|
+
pageSize,
|
|
20485
|
+
search,
|
|
20486
|
+
onDialogRemoved,
|
|
20487
|
+
logTag
|
|
20488
|
+
}) {
|
|
20489
|
+
const [dialogs, setDialogs] = useState40([]);
|
|
20490
|
+
const [dialogsNextCursor, setDialogsNextCursor] = useState40(null);
|
|
20491
|
+
const [isDialogsLoading, setIsDialogsLoading] = useState40(false);
|
|
20492
|
+
const [settledSearch, setSettledSearch] = useState40(
|
|
20493
|
+
autoLoad && fetchDialogs ? void 0 : null
|
|
20494
|
+
);
|
|
20495
|
+
const [autoLoadWas, setAutoLoadWas] = useState40(autoLoad);
|
|
20496
|
+
if (autoLoad !== autoLoadWas) {
|
|
20497
|
+
setAutoLoadWas(autoLoad);
|
|
20498
|
+
if (autoLoad && fetchDialogs) setSettledSearch(void 0);
|
|
20499
|
+
}
|
|
20500
|
+
const pendingRef = useRef28(false);
|
|
20501
|
+
const [dialogsError, setDialogsError] = useState40(false);
|
|
20502
|
+
const dialogsRef = useRef28(dialogs);
|
|
20503
|
+
useEffect34(() => {
|
|
20504
|
+
dialogsRef.current = dialogs;
|
|
20505
|
+
});
|
|
20506
|
+
const onDialogRemovedRef = useRef28(onDialogRemoved);
|
|
20507
|
+
useEffect34(() => {
|
|
20508
|
+
onDialogRemovedRef.current = onDialogRemoved;
|
|
20509
|
+
});
|
|
20510
|
+
const initialDialogsLoadedRef = useRef28(false);
|
|
20511
|
+
const requestIdRef = useRef28(0);
|
|
20512
|
+
const loadDialogsPage = useCallback20(
|
|
20513
|
+
async (cursor) => {
|
|
20514
|
+
if (!fetchDialogs) return;
|
|
20515
|
+
const requestId = ++requestIdRef.current;
|
|
20516
|
+
const isCurrent = () => requestIdRef.current === requestId;
|
|
20517
|
+
pendingRef.current = true;
|
|
20518
|
+
setIsDialogsLoading(true);
|
|
20519
|
+
if (cursor === void 0) setDialogsError(false);
|
|
20520
|
+
try {
|
|
20521
|
+
const result = await fetchDialogs({
|
|
20522
|
+
cursor,
|
|
20523
|
+
limit: pageSize,
|
|
20524
|
+
// Only hosts that run a search ever see the key.
|
|
20525
|
+
...search !== void 0 ? { search } : {}
|
|
20526
|
+
});
|
|
20527
|
+
if (!isCurrent()) return;
|
|
20528
|
+
setDialogsNextCursor(result.nextCursor);
|
|
20529
|
+
if (cursor === void 0) {
|
|
20530
|
+
setDialogs(result.dialogs);
|
|
20531
|
+
} else {
|
|
20532
|
+
setDialogs((prev) => {
|
|
20533
|
+
const seen = new Set(prev.map((d) => d.id));
|
|
20534
|
+
return [...prev, ...result.dialogs.filter((d) => !seen.has(d.id))];
|
|
20535
|
+
});
|
|
20536
|
+
}
|
|
20537
|
+
} catch (err) {
|
|
20538
|
+
if (!isCurrent()) return;
|
|
20539
|
+
console.error(`${logTag} fetchDialogs failed:`, err);
|
|
20540
|
+
if (cursor === void 0) {
|
|
20541
|
+
setDialogsError(true);
|
|
20542
|
+
initialDialogsLoadedRef.current = false;
|
|
20543
|
+
}
|
|
20544
|
+
} finally {
|
|
20545
|
+
if (isCurrent()) {
|
|
20546
|
+
pendingRef.current = false;
|
|
20547
|
+
if (cursor === void 0) setSettledSearch(search ?? null);
|
|
20548
|
+
setIsDialogsLoading(false);
|
|
20549
|
+
}
|
|
20550
|
+
}
|
|
20551
|
+
},
|
|
20552
|
+
[fetchDialogs, pageSize, search, logTag]
|
|
20553
|
+
);
|
|
20554
|
+
const reloadDialogs = useCallback20(() => {
|
|
20555
|
+
void loadDialogsPage();
|
|
20556
|
+
}, [loadDialogsPage]);
|
|
20557
|
+
const loadedSearchRef = useRef28(void 0);
|
|
20558
|
+
useEffect34(() => {
|
|
20559
|
+
if (!fetchDialogs) return;
|
|
20560
|
+
if (!autoLoad) return;
|
|
20561
|
+
if (initialDialogsLoadedRef.current && loadedSearchRef.current === search) return;
|
|
20562
|
+
initialDialogsLoadedRef.current = true;
|
|
20563
|
+
loadedSearchRef.current = search;
|
|
20564
|
+
void loadDialogsPage();
|
|
20565
|
+
}, [autoLoad, fetchDialogs, search, loadDialogsPage]);
|
|
20566
|
+
const removeLocal = useCallback20((id) => {
|
|
20567
|
+
setDialogs((prev) => prev.filter((d) => d.id !== id));
|
|
20568
|
+
}, []);
|
|
20569
|
+
const deleteDialog = useCallback20(
|
|
20570
|
+
async (id) => {
|
|
20571
|
+
if (!deleteDialogCallback) return;
|
|
20572
|
+
try {
|
|
20573
|
+
await deleteDialogCallback(id);
|
|
20574
|
+
removeLocal(id);
|
|
20575
|
+
onDialogRemovedRef.current?.(id, "deleted");
|
|
20576
|
+
} catch (err) {
|
|
20577
|
+
console.error(`${logTag} deleteDialog failed:`, err);
|
|
20578
|
+
throw err;
|
|
20579
|
+
}
|
|
20580
|
+
},
|
|
20581
|
+
[deleteDialogCallback, removeLocal, logTag]
|
|
20582
|
+
);
|
|
20583
|
+
const renameDialog = useCallback20(
|
|
20584
|
+
async (id, title) => {
|
|
20585
|
+
if (!renameDialogCallback) return;
|
|
20586
|
+
const previous = dialogsRef.current.find((d) => d.id === id)?.title;
|
|
20587
|
+
setDialogs((prev) => prev.map((d) => d.id === id ? { ...d, title } : d));
|
|
20588
|
+
try {
|
|
20589
|
+
await renameDialogCallback(id, title);
|
|
20590
|
+
} catch (err) {
|
|
20591
|
+
console.error(`${logTag} renameDialog failed:`, err);
|
|
20592
|
+
if (previous !== void 0) {
|
|
20593
|
+
setDialogs((prev) => prev.map((d) => d.id === id ? { ...d, title: previous } : d));
|
|
20594
|
+
}
|
|
20595
|
+
}
|
|
20596
|
+
},
|
|
20597
|
+
[renameDialogCallback, logTag]
|
|
20598
|
+
);
|
|
20599
|
+
const archiveDialog = useCallback20(
|
|
20600
|
+
async (id) => {
|
|
20601
|
+
if (!archiveDialogCallback) return;
|
|
20602
|
+
try {
|
|
20603
|
+
await archiveDialogCallback(id);
|
|
20604
|
+
removeLocal(id);
|
|
20605
|
+
onDialogRemovedRef.current?.(id, "archived");
|
|
20606
|
+
} catch (err) {
|
|
20607
|
+
console.error(`${logTag} archiveDialog failed:`, err);
|
|
20608
|
+
throw err;
|
|
20609
|
+
}
|
|
20610
|
+
},
|
|
20611
|
+
[archiveDialogCallback, removeLocal, logTag]
|
|
20612
|
+
);
|
|
20613
|
+
const loadMoreDialogs = useCallback20(async () => {
|
|
20614
|
+
if (!dialogsNextCursor) return;
|
|
20615
|
+
if (pendingRef.current) return;
|
|
20616
|
+
await loadDialogsPage(dialogsNextCursor);
|
|
20617
|
+
}, [dialogsNextCursor, loadDialogsPage]);
|
|
20618
|
+
const upsertDialogTop = useCallback20((item) => {
|
|
20619
|
+
setDialogs((prev) => [item, ...prev.filter((d) => d.id !== item.id)]);
|
|
20620
|
+
}, []);
|
|
20621
|
+
const bumpDialogToTop = useCallback20((id) => {
|
|
20622
|
+
setDialogs((prev) => {
|
|
20623
|
+
const row = prev.find((d) => d.id === id);
|
|
20624
|
+
if (!row) return prev;
|
|
20625
|
+
return [{ ...row, timestamp: /* @__PURE__ */ new Date() }, ...prev.filter((d) => d.id !== id)];
|
|
20626
|
+
});
|
|
20627
|
+
}, []);
|
|
20628
|
+
const hasMoreDialogs = dialogsNextCursor != null;
|
|
20629
|
+
const awaitingFirstPage = !!fetchDialogs && settledSearch !== (search ?? null);
|
|
20630
|
+
const dialogsLoading = isDialogsLoading || awaitingFirstPage;
|
|
20631
|
+
return useMemo25(
|
|
20632
|
+
() => ({
|
|
20633
|
+
dialogs,
|
|
20634
|
+
dialogsNextCursor,
|
|
20635
|
+
isDialogsLoading: dialogsLoading,
|
|
20636
|
+
dialogsError,
|
|
20637
|
+
hasMoreDialogs,
|
|
20638
|
+
loadDialogsPage,
|
|
20639
|
+
reloadDialogs,
|
|
20640
|
+
loadMoreDialogs,
|
|
20641
|
+
renameDialog,
|
|
20642
|
+
archiveDialog,
|
|
20643
|
+
deleteDialog,
|
|
20644
|
+
upsertDialogTop,
|
|
20645
|
+
bumpDialogToTop
|
|
20646
|
+
}),
|
|
20647
|
+
[
|
|
20648
|
+
dialogs,
|
|
20649
|
+
dialogsNextCursor,
|
|
20650
|
+
dialogsLoading,
|
|
20651
|
+
dialogsError,
|
|
20652
|
+
hasMoreDialogs,
|
|
20653
|
+
loadDialogsPage,
|
|
20654
|
+
reloadDialogs,
|
|
20655
|
+
loadMoreDialogs,
|
|
20656
|
+
renameDialog,
|
|
20657
|
+
archiveDialog,
|
|
20658
|
+
deleteDialog,
|
|
20659
|
+
upsertDialogTop,
|
|
20660
|
+
bumpDialogToTop
|
|
20661
|
+
]
|
|
20662
|
+
);
|
|
20663
|
+
}
|
|
20664
|
+
|
|
20409
20665
|
// src/components/chat/hooks/use-sse-chat-adapter.ts
|
|
20410
|
-
var SSE_EMPTY_DIALOGS = [];
|
|
20411
20666
|
var noopSelectDialog = (_id) => {
|
|
20412
20667
|
};
|
|
20413
20668
|
var noopStartNewDialog = () => Promise.resolve(null);
|
|
20414
20669
|
var noopDeleteDialog = async (_id) => {
|
|
20415
20670
|
};
|
|
20416
|
-
var noopRenameDialog = async (_id, _title) => {
|
|
20417
|
-
};
|
|
20418
|
-
var noopArchiveDialog = async (_id) => {
|
|
20419
|
-
};
|
|
20420
20671
|
var noopAsync = async () => {
|
|
20421
20672
|
};
|
|
20422
|
-
var noopReloadDialogs = () => {
|
|
20423
|
-
};
|
|
20424
20673
|
var noopApproveRequest = async (_id) => {
|
|
20425
20674
|
};
|
|
20426
20675
|
var noopRejectRequest = async (_id, _reason) => {
|
|
@@ -20446,10 +20695,10 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
20446
20695
|
const runtime = useRequiredChatRuntime();
|
|
20447
20696
|
const source = runtime.source || DEFAULT_CHAT_SOURCE;
|
|
20448
20697
|
const tableIdForDocumentType = options?.tableIdForDocumentType ?? defaultTableIdForDocumentType;
|
|
20449
|
-
const sendMessageRef =
|
|
20698
|
+
const sendMessageRef = useRef29(
|
|
20450
20699
|
() => Promise.resolve(true)
|
|
20451
20700
|
);
|
|
20452
|
-
const cardResolve =
|
|
20701
|
+
const cardResolve = useCallback21(
|
|
20453
20702
|
(action) => (reqId) => {
|
|
20454
20703
|
if (!reqId) return void 0;
|
|
20455
20704
|
return sendMessageRef.current("", {
|
|
@@ -20459,36 +20708,45 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
20459
20708
|
},
|
|
20460
20709
|
[]
|
|
20461
20710
|
);
|
|
20462
|
-
const cardApprove =
|
|
20463
|
-
const cardReject =
|
|
20464
|
-
const createReducerOptions =
|
|
20711
|
+
const cardApprove = useMemo26(() => cardResolve("approve"), [cardResolve]);
|
|
20712
|
+
const cardReject = useMemo26(() => cardResolve("reject"), [cardResolve]);
|
|
20713
|
+
const createReducerOptions = useCallback21(
|
|
20465
20714
|
() => ({
|
|
20466
20715
|
transport: "sse",
|
|
20467
20716
|
callbacks: { onApprove: cardApprove, onReject: cardReject }
|
|
20468
20717
|
}),
|
|
20469
20718
|
[cardApprove, cardReject]
|
|
20470
20719
|
);
|
|
20471
|
-
const storeRef =
|
|
20720
|
+
const storeRef = useRef29(null);
|
|
20472
20721
|
if (storeRef.current === null) storeRef.current = createChatDialogStore();
|
|
20473
20722
|
const { state, applyEvent, flushDeltas, mutate } = useChatStreamReducer({
|
|
20474
20723
|
store: storeRef.current,
|
|
20475
20724
|
dialogId: source,
|
|
20476
20725
|
createReducerOptions
|
|
20477
20726
|
});
|
|
20478
|
-
const
|
|
20479
|
-
const
|
|
20480
|
-
const
|
|
20481
|
-
const restoredConversationRef = useRef28(false);
|
|
20727
|
+
const conversationStorage = useMemo26(() => createChatConversationStorage(source), [source]);
|
|
20728
|
+
const conversationIdRef = useRef29(null);
|
|
20729
|
+
const restoredConversationRef = useRef29(false);
|
|
20482
20730
|
if (!restoredConversationRef.current) {
|
|
20483
20731
|
restoredConversationRef.current = true;
|
|
20484
20732
|
pruneStaleChatConversationStorage(source);
|
|
20485
20733
|
conversationIdRef.current = conversationStorage.load()?.conversationId ?? null;
|
|
20486
20734
|
}
|
|
20735
|
+
const [conversationId, setConversationId] = useState41(() => conversationIdRef.current);
|
|
20736
|
+
const commitConversationId = useCallback21(
|
|
20737
|
+
(id) => {
|
|
20738
|
+
conversationIdRef.current = id;
|
|
20739
|
+
setConversationId(id);
|
|
20740
|
+
if (id) conversationStorage.save({ conversationId: id });
|
|
20741
|
+
else conversationStorage.clear();
|
|
20742
|
+
},
|
|
20743
|
+
[conversationStorage]
|
|
20744
|
+
);
|
|
20487
20745
|
const commandsUrl = runtime.endpoints.commandsUrl;
|
|
20488
20746
|
const { commands: slashCommands } = useSlashCommandRegistry(commandsUrl, {
|
|
20489
20747
|
enabled: active
|
|
20490
20748
|
});
|
|
20491
|
-
const cmdIdByTableId =
|
|
20749
|
+
const cmdIdByTableId = useMemo26(() => {
|
|
20492
20750
|
const buckets = /* @__PURE__ */ new Map();
|
|
20493
20751
|
for (const cmd of slashCommands) {
|
|
20494
20752
|
if (!cmd.primarySourceId) continue;
|
|
@@ -20509,8 +20767,8 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
20509
20767
|
return map;
|
|
20510
20768
|
}, [slashCommands]);
|
|
20511
20769
|
const historyUrl = runtime.endpoints.chatHistoryUrl ?? `${runtime.endpoints.chatStreamUrl.replace(/\/+$/, "")}/history`;
|
|
20512
|
-
const hydrationSendCountRef =
|
|
20513
|
-
const hydrateMessages =
|
|
20770
|
+
const hydrationSendCountRef = useRef29(0);
|
|
20771
|
+
const hydrateMessages = useCallback21(
|
|
20514
20772
|
(history, sourcesSeed) => {
|
|
20515
20773
|
mutate((r) => {
|
|
20516
20774
|
const mapped = history.map(historyMessageToReducerMessage);
|
|
@@ -20531,52 +20789,130 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
20531
20789
|
},
|
|
20532
20790
|
[mutate]
|
|
20533
20791
|
);
|
|
20792
|
+
const messagesLenRef = useRef29(0);
|
|
20793
|
+
messagesLenRef.current = state.messages.length;
|
|
20794
|
+
const onOrphanedConversation = useCallback21(
|
|
20795
|
+
(id) => {
|
|
20796
|
+
if (conversationIdRef.current === id && messagesLenRef.current === 0) commitConversationId(null);
|
|
20797
|
+
},
|
|
20798
|
+
[commitConversationId]
|
|
20799
|
+
);
|
|
20534
20800
|
const { isHydratingHistory, hydratedKeyRef } = useChatHistoryHydration({
|
|
20535
20801
|
active,
|
|
20536
20802
|
source,
|
|
20537
20803
|
historyUrl,
|
|
20538
|
-
|
|
20804
|
+
conversationId,
|
|
20539
20805
|
sendCountRef: hydrationSendCountRef,
|
|
20540
20806
|
hydrateMessages,
|
|
20541
20807
|
// Meta invalidation is a reducer concern here: `seedSseMaps` (inside
|
|
20542
20808
|
// `hydrateMessages` above) already invalidates the snapshot.
|
|
20543
|
-
bumpMetaTick: noopBumpMetaTick
|
|
20809
|
+
bumpMetaTick: noopBumpMetaTick,
|
|
20810
|
+
// Drop a stored id the server no longer recognizes (deleted, or claimed by
|
|
20811
|
+
// an account while this browser is signed out) — keeping it would stream
|
|
20812
|
+
// answers the server refuses to persist. Guarded on "no live turn yet" so
|
|
20813
|
+
// a just-minted id is never dropped.
|
|
20814
|
+
//
|
|
20815
|
+
// IDENTITY-STABLE by construction: this is a dependency of the hydration
|
|
20816
|
+
// effect, so a callback that changed with the message count would CANCEL
|
|
20817
|
+
// an in-flight hydration the moment the user typed — silently discarding
|
|
20818
|
+
// the thread they just opened. The live count is read through a ref.
|
|
20819
|
+
onOrphanedConversation
|
|
20544
20820
|
});
|
|
20545
|
-
const
|
|
20821
|
+
const abortControllerRef = useRef29(null);
|
|
20822
|
+
const switchConversation = useCallback21(
|
|
20823
|
+
(id) => {
|
|
20824
|
+
abortControllerRef.current?.abort();
|
|
20825
|
+
flushDeltas();
|
|
20826
|
+
mutate((r) => r.reset());
|
|
20827
|
+
hydrationSendCountRef.current = 0;
|
|
20828
|
+
hydratedKeyRef.current = null;
|
|
20829
|
+
commitConversationId(id);
|
|
20830
|
+
},
|
|
20831
|
+
[flushDeltas, mutate, hydratedKeyRef, commitConversationId]
|
|
20832
|
+
);
|
|
20833
|
+
const conversationsUrl = runtime.endpoints.chatConversationsUrl;
|
|
20834
|
+
const conversationsApi = useMemo26(
|
|
20835
|
+
() => conversationsUrl ? createChatConversationsApi(conversationsUrl) : null,
|
|
20836
|
+
[conversationsUrl]
|
|
20837
|
+
);
|
|
20838
|
+
const [dialogSearch, setDialogSearch] = useState41("");
|
|
20839
|
+
const fetchActiveDialogs = useMemo26(
|
|
20840
|
+
() => conversationsApi ? (params) => conversationsApi.fetchDialogs({ ...params, status: "active" }) : void 0,
|
|
20841
|
+
[conversationsApi]
|
|
20842
|
+
);
|
|
20843
|
+
const fetchArchivedDialogs = useMemo26(
|
|
20844
|
+
() => conversationsApi ? (params) => conversationsApi.fetchDialogs({ ...params, status: "archived" }) : void 0,
|
|
20845
|
+
[conversationsApi]
|
|
20846
|
+
);
|
|
20847
|
+
const {
|
|
20848
|
+
dialogs,
|
|
20849
|
+
isDialogsLoading,
|
|
20850
|
+
dialogsError,
|
|
20851
|
+
hasMoreDialogs,
|
|
20852
|
+
reloadDialogs,
|
|
20853
|
+
loadMoreDialogs,
|
|
20854
|
+
renameDialog,
|
|
20855
|
+
archiveDialog,
|
|
20856
|
+
upsertDialogTop,
|
|
20857
|
+
bumpDialogToTop
|
|
20858
|
+
} = useManagedDialogList({
|
|
20859
|
+
autoLoad: active,
|
|
20860
|
+
fetchDialogs: fetchActiveDialogs,
|
|
20861
|
+
renameDialog: conversationsApi?.renameDialog,
|
|
20862
|
+
archiveDialog: conversationsApi?.archiveDialog,
|
|
20863
|
+
pageSize: 20,
|
|
20864
|
+
search: conversationsApi ? dialogSearch : void 0,
|
|
20865
|
+
logTag: "[useSseChatAdapter]",
|
|
20866
|
+
// Archiving the OPEN conversation drops back to the draft state (the
|
|
20867
|
+
// manager also clears the thread; both paths are idempotent).
|
|
20868
|
+
onDialogRemoved: (id) => {
|
|
20869
|
+
if (conversationIdRef.current === id) switchConversation(null);
|
|
20870
|
+
}
|
|
20871
|
+
});
|
|
20872
|
+
const unarchiveDialog = useMemo26(
|
|
20873
|
+
() => conversationsApi ? async (id) => {
|
|
20874
|
+
await conversationsApi.unarchiveDialog(id);
|
|
20875
|
+
reloadDialogs();
|
|
20876
|
+
} : void 0,
|
|
20877
|
+
[conversationsApi, reloadDialogs]
|
|
20878
|
+
);
|
|
20879
|
+
const endpointsRef = useRef29(runtime.endpoints);
|
|
20546
20880
|
endpointsRef.current = runtime.endpoints;
|
|
20547
|
-
const captureConversationId =
|
|
20881
|
+
const captureConversationId = useCallback21(
|
|
20548
20882
|
(event) => {
|
|
20549
|
-
if (event.type !== "metadata") return;
|
|
20883
|
+
if (event.type !== "metadata") return false;
|
|
20550
20884
|
const id = event.conversationId;
|
|
20551
|
-
if (typeof id !== "string" || !id) return;
|
|
20552
|
-
if (conversationIdRef.current === id) return;
|
|
20553
|
-
|
|
20554
|
-
|
|
20885
|
+
if (typeof id !== "string" || !id) return false;
|
|
20886
|
+
if (conversationIdRef.current === id) return false;
|
|
20887
|
+
hydratedKeyRef.current = `${source}:${id}`;
|
|
20888
|
+
commitConversationId(id);
|
|
20889
|
+
return true;
|
|
20555
20890
|
},
|
|
20556
|
-
[
|
|
20891
|
+
[commitConversationId, hydratedKeyRef, source]
|
|
20557
20892
|
);
|
|
20558
|
-
const sendMessage =
|
|
20893
|
+
const sendMessage = useCallback21(
|
|
20559
20894
|
// Resolves `true` on a clean turn, `false` when the request failed
|
|
20560
20895
|
// (surfaced to batch approve-all loops via the card callbacks).
|
|
20561
20896
|
async (text, sendOptions) => {
|
|
20562
20897
|
const { hidden, attachments, commandOverride, approvalAction } = sendOptions ?? {};
|
|
20563
|
-
const
|
|
20898
|
+
const echoedConversationId = conversationIdRef.current;
|
|
20564
20899
|
const targetPath = approvalAction ? endpointsRef.current.approvalToolUrl : endpointsRef.current.chatStreamUrl;
|
|
20565
20900
|
const requestBody = approvalAction ? (
|
|
20566
20901
|
// Shared with every other transport that resolves a hub proposal —
|
|
20567
20902
|
// the body shape is the hub's, not this adapter's. `conversationId`
|
|
20568
20903
|
// is always present here: an approval can only happen inside an
|
|
20569
20904
|
// established conversation (the proposal turn captured the id).
|
|
20570
|
-
buildConfirmToolBody({ ...approvalAction, conversationId })
|
|
20905
|
+
buildConfirmToolBody({ ...approvalAction, conversationId: echoedConversationId })
|
|
20571
20906
|
) : {
|
|
20572
20907
|
messages: [{ role: "user", content: text }],
|
|
20573
20908
|
...commandOverride ? { commandOverride } : {},
|
|
20574
20909
|
...attachments && attachments.length > 0 ? { pendingAttachments: attachments } : {},
|
|
20575
|
-
...
|
|
20910
|
+
...echoedConversationId ? { conversationId: echoedConversationId } : {}
|
|
20576
20911
|
};
|
|
20577
20912
|
mutate((r) => r.beginSseSend({ text, hidden, userName: "You", assistantName: "Mingo AI" }));
|
|
20578
20913
|
const ctrl = new AbortController();
|
|
20579
20914
|
abortControllerRef.current = ctrl;
|
|
20915
|
+
let mintedThisTurn = false;
|
|
20580
20916
|
try {
|
|
20581
20917
|
const response = await embedAuthedFetch(targetPath, {
|
|
20582
20918
|
method: "POST",
|
|
@@ -20597,7 +20933,13 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
20597
20933
|
if (done) break;
|
|
20598
20934
|
if (ctrl.signal.aborted) break;
|
|
20599
20935
|
for (const event of frameDecoder.push(value)) {
|
|
20600
|
-
captureConversationId(event)
|
|
20936
|
+
if (captureConversationId(event)) {
|
|
20937
|
+
mintedThisTurn = true;
|
|
20938
|
+
const mintedId = conversationIdRef.current;
|
|
20939
|
+
if (conversationsApi && !hidden && mintedId) {
|
|
20940
|
+
upsertDialogTop({ id: mintedId, title: "New chat", timestamp: /* @__PURE__ */ new Date() });
|
|
20941
|
+
}
|
|
20942
|
+
}
|
|
20601
20943
|
applyEvent(event);
|
|
20602
20944
|
}
|
|
20603
20945
|
}
|
|
@@ -20624,24 +20966,57 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
20624
20966
|
}
|
|
20625
20967
|
flushDeltas();
|
|
20626
20968
|
mutate((r) => r.endSseTurn());
|
|
20969
|
+
if (conversationsApi && !ctrl.signal.aborted) {
|
|
20970
|
+
if (mintedThisTurn) {
|
|
20971
|
+
reloadDialogs();
|
|
20972
|
+
} else if (conversationIdRef.current) {
|
|
20973
|
+
bumpDialogToTop(conversationIdRef.current);
|
|
20974
|
+
}
|
|
20975
|
+
}
|
|
20627
20976
|
}
|
|
20628
20977
|
},
|
|
20629
|
-
[
|
|
20978
|
+
[
|
|
20979
|
+
mutate,
|
|
20980
|
+
applyEvent,
|
|
20981
|
+
flushDeltas,
|
|
20982
|
+
captureConversationId,
|
|
20983
|
+
conversationsApi,
|
|
20984
|
+
upsertDialogTop,
|
|
20985
|
+
reloadDialogs,
|
|
20986
|
+
bumpDialogToTop
|
|
20987
|
+
]
|
|
20630
20988
|
);
|
|
20631
20989
|
sendMessageRef.current = sendMessage;
|
|
20632
|
-
const stopMessage =
|
|
20990
|
+
const stopMessage = useCallback21(() => {
|
|
20633
20991
|
abortControllerRef.current?.abort();
|
|
20634
20992
|
flushDeltas();
|
|
20635
20993
|
mutate((r) => r.setPhase("idle"));
|
|
20636
20994
|
}, [mutate, flushDeltas]);
|
|
20637
|
-
const clearMessages =
|
|
20995
|
+
const clearMessages = useCallback21(() => {
|
|
20638
20996
|
mutate((r) => r.reset());
|
|
20639
|
-
|
|
20640
|
-
conversationStorage.clear();
|
|
20997
|
+
commitConversationId(null);
|
|
20641
20998
|
hydrationSendCountRef.current = 0;
|
|
20642
20999
|
hydratedKeyRef.current = null;
|
|
20643
|
-
}, [mutate,
|
|
20644
|
-
const
|
|
21000
|
+
}, [mutate, commitConversationId, hydratedKeyRef]);
|
|
21001
|
+
const selectDialog = useCallback21(
|
|
21002
|
+
(id) => {
|
|
21003
|
+
if (id === conversationIdRef.current) return;
|
|
21004
|
+
switchConversation(id);
|
|
21005
|
+
},
|
|
21006
|
+
[switchConversation]
|
|
21007
|
+
);
|
|
21008
|
+
const dialogCapabilities = useMemo26(
|
|
21009
|
+
() => conversationsApi ? {
|
|
21010
|
+
canRename: true,
|
|
21011
|
+
canArchive: true,
|
|
21012
|
+
fetchArchivedDialogs,
|
|
21013
|
+
unarchiveDialog,
|
|
21014
|
+
searchQuery: dialogSearch,
|
|
21015
|
+
onSearchChange: setDialogSearch
|
|
21016
|
+
} : void 0,
|
|
21017
|
+
[conversationsApi, fetchArchivedDialogs, unarchiveDialog, dialogSearch]
|
|
21018
|
+
);
|
|
21019
|
+
const docMessages = useMemo26(() => {
|
|
20645
21020
|
const { meta, sources: sourcesMap } = state.turnMeta;
|
|
20646
21021
|
let sendIdx = -1;
|
|
20647
21022
|
return state.messages.map((m) => {
|
|
@@ -20668,7 +21043,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
20668
21043
|
};
|
|
20669
21044
|
});
|
|
20670
21045
|
}, [state.messages, state.turnMeta]);
|
|
20671
|
-
const displayRef =
|
|
21046
|
+
const displayRef = useCallback21(
|
|
20672
21047
|
(reference) => {
|
|
20673
21048
|
const tableId = tableIdForDocumentType(reference.type);
|
|
20674
21049
|
if (!tableId) {
|
|
@@ -20690,7 +21065,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
20690
21065
|
},
|
|
20691
21066
|
[sendMessage, source, cmdIdByTableId, tableIdForDocumentType]
|
|
20692
21067
|
);
|
|
20693
|
-
const discussRef =
|
|
21068
|
+
const discussRef = useCallback21(
|
|
20694
21069
|
(reference) => {
|
|
20695
21070
|
const tableId = tableIdForDocumentType(reference.type);
|
|
20696
21071
|
if (!tableId) {
|
|
@@ -20709,7 +21084,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
20709
21084
|
},
|
|
20710
21085
|
[sendMessage, tableIdForDocumentType]
|
|
20711
21086
|
);
|
|
20712
|
-
const latestMeta =
|
|
21087
|
+
const latestMeta = useMemo26(() => {
|
|
20713
21088
|
const { meta, sendCount } = state.turnMeta;
|
|
20714
21089
|
return meta.get(sendCount - 1) ?? meta.get(sendCount - 2) ?? null;
|
|
20715
21090
|
}, [state]);
|
|
@@ -20740,26 +21115,30 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
20740
21115
|
/** Cross-call usage breakdown (Haiku rewriter/classifier/summarizer
|
|
20741
21116
|
* token counts). null until the trailing usage frame lands. */
|
|
20742
21117
|
currentUsageBreakdown: latestMeta?.breakdown ?? null,
|
|
20743
|
-
// ─── Dialog management
|
|
20744
|
-
//
|
|
20745
|
-
// (`
|
|
20746
|
-
//
|
|
20747
|
-
//
|
|
20748
|
-
//
|
|
20749
|
-
|
|
20750
|
-
|
|
20751
|
-
|
|
21118
|
+
// ─── Dialog management ───────────────────────────────────────────────
|
|
21119
|
+
// With `chatConversationsUrl` the server transcript store IS the dialog
|
|
21120
|
+
// list (shared `useManagedDialogList`); selecting a row re-hydrates through
|
|
21121
|
+
// the history route. WITHOUT it the same hook is inert by construction —
|
|
21122
|
+
// no `fetchDialogs`, so an empty list, false flags and memoized no-op
|
|
21123
|
+
// mutations — which is why only the four genuinely mode-dependent fields
|
|
21124
|
+
// are branched here.
|
|
21125
|
+
dialogs,
|
|
21126
|
+
isDialogsLoading,
|
|
21127
|
+
dialogsError,
|
|
21128
|
+
reloadDialogs,
|
|
21129
|
+
hasMoreDialogs,
|
|
21130
|
+
loadMoreDialogs,
|
|
21131
|
+
renameDialog,
|
|
21132
|
+
archiveDialog,
|
|
21133
|
+
// New chat = `clearMessages` (the server mints on the next send); there is
|
|
21134
|
+
// no create call. Delete is not offered — archive replaces it.
|
|
20752
21135
|
startNewDialog: noopStartNewDialog,
|
|
20753
21136
|
deleteDialog: noopDeleteDialog,
|
|
20754
|
-
|
|
20755
|
-
|
|
20756
|
-
|
|
20757
|
-
|
|
20758
|
-
|
|
20759
|
-
reloadDialogs: noopReloadDialogs,
|
|
20760
|
-
isMessagesLoading: false,
|
|
20761
|
-
hasMoreDialogs: false,
|
|
20762
|
-
loadMoreDialogs: noopAsync,
|
|
21137
|
+
activeDialogId: conversationsApi ? conversationId : null,
|
|
21138
|
+
selectDialog: conversationsApi ? selectDialog : noopSelectDialog,
|
|
21139
|
+
isMessagesLoading: conversationsApi ? isHydratingHistory : false,
|
|
21140
|
+
dialogsManaged: !!conversationsApi,
|
|
21141
|
+
dialogCapabilities,
|
|
20763
21142
|
hasMoreMessages: false,
|
|
20764
21143
|
loadMoreMessages: noopAsync,
|
|
20765
21144
|
approveRequest: noopApproveRequest,
|
|
@@ -20770,12 +21149,9 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
20770
21149
|
}
|
|
20771
21150
|
|
|
20772
21151
|
// src/components/chat/hooks/use-nats-chat-adapter.ts
|
|
20773
|
-
import { useCallback as
|
|
21152
|
+
import { useCallback as useCallback22, useEffect as useEffect35, useMemo as useMemo27, useRef as useRef30, useState as useState42 } from "react";
|
|
20774
21153
|
|
|
20775
21154
|
// src/chat-protocol/nats-decoder.ts
|
|
20776
|
-
function isRecord2(value) {
|
|
20777
|
-
return typeof value === "object" && value !== null;
|
|
20778
|
-
}
|
|
20779
21155
|
function str(value) {
|
|
20780
21156
|
return typeof value === "string" ? value : void 0;
|
|
20781
21157
|
}
|
|
@@ -20788,7 +21164,7 @@ function numOr(value, fallback = 0) {
|
|
|
20788
21164
|
}
|
|
20789
21165
|
function normalizeToolCalls(raw) {
|
|
20790
21166
|
if (!Array.isArray(raw)) return [];
|
|
20791
|
-
return raw.filter(
|
|
21167
|
+
return raw.filter(isRecord).map((item) => ({
|
|
20792
21168
|
toolExecutionRequestId: String(item.toolExecutionRequestId ?? ""),
|
|
20793
21169
|
toolName: String(item.toolName ?? ""),
|
|
20794
21170
|
toolTitle: typeof item.toolTitle === "string" ? item.toolTitle : void 0,
|
|
@@ -20796,12 +21172,12 @@ function normalizeToolCalls(raw) {
|
|
|
20796
21172
|
toolType: typeof item.toolType === "string" ? item.toolType : void 0,
|
|
20797
21173
|
requiresApproval: item.requiresApproval === true,
|
|
20798
21174
|
approvalType: typeof item.approvalType === "string" ? item.approvalType : null,
|
|
20799
|
-
toolCallArguments:
|
|
21175
|
+
toolCallArguments: isRecord(item.toolCallArguments) ? item.toolCallArguments : null
|
|
20800
21176
|
}));
|
|
20801
21177
|
}
|
|
20802
21178
|
function normalizeAskOptions(raw) {
|
|
20803
21179
|
if (!Array.isArray(raw)) return [];
|
|
20804
|
-
return raw.filter(
|
|
21180
|
+
return raw.filter(isRecord).map((item) => ({
|
|
20805
21181
|
label: typeof item.label === "string" ? item.label.trim() : "",
|
|
20806
21182
|
description: typeof item.description === "string" ? item.description : void 0
|
|
20807
21183
|
})).filter((option) => option.label.length > 0);
|
|
@@ -20870,7 +21246,7 @@ function decodeNatsChunk(chunk) {
|
|
|
20870
21246
|
// the EXECUTING segment held. Dropping it here therefore blanks the
|
|
20871
21247
|
// card for the whole lifetime of the run.
|
|
20872
21248
|
toolExplanation: typeof data.toolExplanation === "string" ? data.toolExplanation : void 0,
|
|
20873
|
-
parameters:
|
|
21249
|
+
parameters: isRecord(data.parameters) ? data.parameters : void 0,
|
|
20874
21250
|
toolExecutionRequestId: typeof data.toolExecutionRequestId === "string" ? data.toolExecutionRequestId : void 0
|
|
20875
21251
|
},
|
|
20876
21252
|
...seq
|
|
@@ -20883,7 +21259,7 @@ function decodeNatsChunk(chunk) {
|
|
|
20883
21259
|
integratedToolType: strOr(data.integratedToolType),
|
|
20884
21260
|
toolFunction: strOr(data.toolFunction),
|
|
20885
21261
|
toolTitle: typeof data.title === "string" ? data.title : void 0,
|
|
20886
|
-
parameters:
|
|
21262
|
+
parameters: isRecord(data.parameters) ? data.parameters : void 0,
|
|
20887
21263
|
result: str(data.result),
|
|
20888
21264
|
success: typeof data.success === "boolean" ? data.success : void 0,
|
|
20889
21265
|
toolExecutionRequestId: typeof data.toolExecutionRequestId === "string" ? data.toolExecutionRequestId : void 0
|
|
@@ -21748,6 +22124,8 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
21748
22124
|
deleteDialog: deleteDialogCallback,
|
|
21749
22125
|
renameDialog: renameDialogCallback,
|
|
21750
22126
|
archiveDialog: archiveDialogCallback,
|
|
22127
|
+
fetchArchivedDialogs,
|
|
22128
|
+
unarchiveDialog,
|
|
21751
22129
|
approveRequest: approveRequestCallback,
|
|
21752
22130
|
rejectRequest: rejectRequestCallback,
|
|
21753
22131
|
stopGeneration: stopGenerationCallback,
|
|
@@ -21759,26 +22137,26 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
21759
22137
|
modelLabel = null
|
|
21760
22138
|
} = config;
|
|
21761
22139
|
const isManagedMode = fetchDialogs !== void 0;
|
|
21762
|
-
const [internalDialogId, setInternalDialogId] =
|
|
22140
|
+
const [internalDialogId, setInternalDialogId] = useState42(null);
|
|
21763
22141
|
const dialogId = isManagedMode ? internalDialogId : controlledDialogId !== void 0 ? controlledDialogId : null;
|
|
21764
|
-
const currentDialogIdRef =
|
|
21765
|
-
|
|
22142
|
+
const currentDialogIdRef = useRef30(dialogId);
|
|
22143
|
+
useEffect35(() => {
|
|
21766
22144
|
currentDialogIdRef.current = dialogId;
|
|
21767
22145
|
});
|
|
21768
|
-
const handleApproveRef =
|
|
22146
|
+
const handleApproveRef = useRef30(async () => {
|
|
21769
22147
|
});
|
|
21770
|
-
const handleRejectRef =
|
|
22148
|
+
const handleRejectRef = useRef30(async () => {
|
|
21771
22149
|
});
|
|
21772
|
-
const accumApprove =
|
|
22150
|
+
const accumApprove = useCallback22((requestId) => {
|
|
21773
22151
|
if (!requestId) return void 0;
|
|
21774
22152
|
return handleApproveRef.current(requestId);
|
|
21775
22153
|
}, []);
|
|
21776
|
-
const accumReject =
|
|
22154
|
+
const accumReject = useCallback22((requestId) => {
|
|
21777
22155
|
if (!requestId) return void 0;
|
|
21778
22156
|
return handleRejectRef.current(requestId);
|
|
21779
22157
|
}, []);
|
|
21780
|
-
const [dialogStore] =
|
|
21781
|
-
const [globalApprovalStatuses] =
|
|
22158
|
+
const [dialogStore] = useState42(() => createChatDialogStore());
|
|
22159
|
+
const [globalApprovalStatuses] = useState42(() => ({}));
|
|
21782
22160
|
const dialogKey = dialogId ?? DRAFT_DIALOG_KEY;
|
|
21783
22161
|
const { state, applyEvent, mutate } = useChatStreamReducer({
|
|
21784
22162
|
store: dialogStore,
|
|
@@ -21791,10 +22169,10 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
21791
22169
|
callbacks: { onApprove: accumApprove, onReject: accumReject }
|
|
21792
22170
|
})
|
|
21793
22171
|
});
|
|
21794
|
-
|
|
22172
|
+
useEffect35(() => {
|
|
21795
22173
|
Object.assign(globalApprovalStatuses, state.approvalStatuses);
|
|
21796
22174
|
}, [globalApprovalStatuses, state.approvalStatuses]);
|
|
21797
|
-
|
|
22175
|
+
useEffect35(() => {
|
|
21798
22176
|
handleApproveRef.current = async (requestId) => {
|
|
21799
22177
|
if (!approveRequestCallback) return;
|
|
21800
22178
|
const key = dialogKey;
|
|
@@ -21826,22 +22204,44 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
21826
22204
|
}
|
|
21827
22205
|
};
|
|
21828
22206
|
});
|
|
21829
|
-
const processChunk =
|
|
22207
|
+
const processChunk = useCallback22(
|
|
21830
22208
|
(chunk) => {
|
|
21831
22209
|
const event = decodeNatsChunk(chunk);
|
|
21832
22210
|
if (event) applyEvent(event);
|
|
21833
22211
|
},
|
|
21834
22212
|
[applyEvent]
|
|
21835
22213
|
);
|
|
21836
|
-
const [
|
|
21837
|
-
const
|
|
21838
|
-
|
|
21839
|
-
|
|
21840
|
-
|
|
21841
|
-
|
|
21842
|
-
|
|
21843
|
-
|
|
21844
|
-
|
|
22214
|
+
const [isCreatingDialog, setIsCreatingDialog] = useState42(false);
|
|
22215
|
+
const {
|
|
22216
|
+
dialogs,
|
|
22217
|
+
isDialogsLoading,
|
|
22218
|
+
dialogsError,
|
|
22219
|
+
hasMoreDialogs,
|
|
22220
|
+
reloadDialogs,
|
|
22221
|
+
loadMoreDialogs,
|
|
22222
|
+
renameDialog,
|
|
22223
|
+
archiveDialog,
|
|
22224
|
+
deleteDialog,
|
|
22225
|
+
upsertDialogTop
|
|
22226
|
+
} = useManagedDialogList({
|
|
22227
|
+
autoLoad: active,
|
|
22228
|
+
fetchDialogs,
|
|
22229
|
+
renameDialog: renameDialogCallback,
|
|
22230
|
+
archiveDialog: archiveDialogCallback,
|
|
22231
|
+
deleteDialog: deleteDialogCallback,
|
|
22232
|
+
pageSize: dialogsPageSize,
|
|
22233
|
+
logTag: "[useNatsChatAdapter]",
|
|
22234
|
+
onDialogRemoved: (id, reason) => {
|
|
22235
|
+
if (reason === "deleted") dialogStore.remove(id);
|
|
22236
|
+
if (isManagedMode && internalDialogId === id) {
|
|
22237
|
+
setInternalDialogId(null);
|
|
22238
|
+
}
|
|
22239
|
+
}
|
|
22240
|
+
});
|
|
22241
|
+
const [messagesNextCursor, setMessagesNextCursor] = useState42(null);
|
|
22242
|
+
const [isMessagesLoading, setIsMessagesLoading] = useState42(false);
|
|
22243
|
+
const [connectedForDialog, setConnectedForDialog] = useState42(null);
|
|
22244
|
+
const hasConnectedOnceRef = useRef30(false);
|
|
21845
22245
|
const {
|
|
21846
22246
|
processChunk: catchupProcessChunk,
|
|
21847
22247
|
catchUpChunks,
|
|
@@ -21854,8 +22254,8 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
21854
22254
|
onChunkReceived: (chunk) => processChunk(chunk),
|
|
21855
22255
|
fetchChunks
|
|
21856
22256
|
});
|
|
21857
|
-
const historyLoadSeqRef =
|
|
21858
|
-
const loadDialogHistory =
|
|
22257
|
+
const historyLoadSeqRef = useRef30(0);
|
|
22258
|
+
const loadDialogHistory = useCallback22(
|
|
21859
22259
|
async (id, cursor) => {
|
|
21860
22260
|
if (!fetchDialogMessages) return;
|
|
21861
22261
|
historyLoadSeqRef.current += 1;
|
|
@@ -21913,8 +22313,8 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
21913
22313
|
isBufferingActive
|
|
21914
22314
|
]
|
|
21915
22315
|
);
|
|
21916
|
-
const prevDialogIdRef =
|
|
21917
|
-
|
|
22316
|
+
const prevDialogIdRef = useRef30(void 0);
|
|
22317
|
+
useEffect35(() => {
|
|
21918
22318
|
if (prevDialogIdRef.current === dialogId) return;
|
|
21919
22319
|
prevDialogIdRef.current = dialogId;
|
|
21920
22320
|
historyLoadSeqRef.current += 1;
|
|
@@ -21927,7 +22327,7 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
21927
22327
|
if (!active || !dialogId) return;
|
|
21928
22328
|
void loadDialogHistory(dialogId);
|
|
21929
22329
|
}, [active, dialogId, dialogKey, dialogStore, globalApprovalStatuses, loadDialogHistory]);
|
|
21930
|
-
|
|
22330
|
+
useEffect35(() => {
|
|
21931
22331
|
if (!active || !dialogId) return;
|
|
21932
22332
|
const store = dialogStore;
|
|
21933
22333
|
store.mutate(dialogId, DEFAULT_DIALOG_SIDE, (r) => r.adjustAgentBusySuppression(1));
|
|
@@ -21987,46 +22387,7 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
21987
22387
|
}
|
|
21988
22388
|
});
|
|
21989
22389
|
const connectionState = !active || !dialogId ? "connected" : connectedForDialog === dialogId ? "connected" : "connecting";
|
|
21990
|
-
const
|
|
21991
|
-
const loadDialogsPage = useCallback21(
|
|
21992
|
-
async (cursor) => {
|
|
21993
|
-
if (!fetchDialogs) return;
|
|
21994
|
-
setIsDialogsLoading(true);
|
|
21995
|
-
if (cursor === void 0) setDialogsError(false);
|
|
21996
|
-
try {
|
|
21997
|
-
const result = await fetchDialogs({
|
|
21998
|
-
cursor,
|
|
21999
|
-
limit: dialogsPageSize
|
|
22000
|
-
});
|
|
22001
|
-
setDialogsNextCursor(result.nextCursor);
|
|
22002
|
-
if (cursor === void 0) {
|
|
22003
|
-
setDialogs(result.dialogs);
|
|
22004
|
-
} else {
|
|
22005
|
-
setDialogs((prev) => [...prev, ...result.dialogs]);
|
|
22006
|
-
}
|
|
22007
|
-
} catch (err) {
|
|
22008
|
-
console.error("[useNatsChatAdapter] fetchDialogs failed:", err);
|
|
22009
|
-
if (cursor === void 0) {
|
|
22010
|
-
setDialogsError(true);
|
|
22011
|
-
initialDialogsLoadedRef.current = false;
|
|
22012
|
-
}
|
|
22013
|
-
} finally {
|
|
22014
|
-
setIsDialogsLoading(false);
|
|
22015
|
-
}
|
|
22016
|
-
},
|
|
22017
|
-
[fetchDialogs, dialogsPageSize]
|
|
22018
|
-
);
|
|
22019
|
-
const reloadDialogs = useCallback21(() => {
|
|
22020
|
-
void loadDialogsPage();
|
|
22021
|
-
}, [loadDialogsPage]);
|
|
22022
|
-
useEffect34(() => {
|
|
22023
|
-
if (!fetchDialogs) return;
|
|
22024
|
-
if (!active) return;
|
|
22025
|
-
if (initialDialogsLoadedRef.current) return;
|
|
22026
|
-
initialDialogsLoadedRef.current = true;
|
|
22027
|
-
void loadDialogsPage();
|
|
22028
|
-
}, [active, fetchDialogs, loadDialogsPage]);
|
|
22029
|
-
const sendMessage = useCallback21(
|
|
22390
|
+
const sendMessage = useCallback22(
|
|
22030
22391
|
async (text, sendOptions) => {
|
|
22031
22392
|
const hidden = sendOptions?.hidden ?? false;
|
|
22032
22393
|
mutate((r) => r.pushOptimisticSend(text, hidden));
|
|
@@ -22034,7 +22395,7 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22034
22395
|
},
|
|
22035
22396
|
[mutate, publishUserMessage, dialogId]
|
|
22036
22397
|
);
|
|
22037
|
-
const stopMessage =
|
|
22398
|
+
const stopMessage = useCallback22(() => {
|
|
22038
22399
|
mutate((r) => r.setPhase("idle"));
|
|
22039
22400
|
if (stopGenerationCallback && dialogId) {
|
|
22040
22401
|
void stopGenerationCallback(dialogId).catch((err) => {
|
|
@@ -22042,10 +22403,10 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22042
22403
|
});
|
|
22043
22404
|
}
|
|
22044
22405
|
}, [mutate, stopGenerationCallback, dialogId]);
|
|
22045
|
-
const clearMessages =
|
|
22406
|
+
const clearMessages = useCallback22(() => {
|
|
22046
22407
|
mutate((r) => r.clearThread());
|
|
22047
22408
|
}, [mutate]);
|
|
22048
|
-
const selectDialog =
|
|
22409
|
+
const selectDialog = useCallback22(
|
|
22049
22410
|
(id) => {
|
|
22050
22411
|
if (!isManagedMode) {
|
|
22051
22412
|
return;
|
|
@@ -22054,20 +22415,17 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22054
22415
|
},
|
|
22055
22416
|
[isManagedMode]
|
|
22056
22417
|
);
|
|
22057
|
-
const startNewDialog =
|
|
22418
|
+
const startNewDialog = useCallback22(async () => {
|
|
22058
22419
|
if (!createDialogCallback) return null;
|
|
22059
22420
|
if (isCreatingDialog) return null;
|
|
22060
22421
|
try {
|
|
22061
22422
|
setIsCreatingDialog(true);
|
|
22062
22423
|
const result = await createDialogCallback();
|
|
22063
|
-
|
|
22064
|
-
|
|
22065
|
-
|
|
22066
|
-
|
|
22067
|
-
|
|
22068
|
-
},
|
|
22069
|
-
...prev.filter((d) => d.id !== result.dialogId)
|
|
22070
|
-
]);
|
|
22424
|
+
upsertDialogTop({
|
|
22425
|
+
id: result.dialogId,
|
|
22426
|
+
title: "New Chat",
|
|
22427
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
22428
|
+
});
|
|
22071
22429
|
if (isManagedMode) {
|
|
22072
22430
|
setInternalDialogId(result.dialogId);
|
|
22073
22431
|
}
|
|
@@ -22078,76 +22436,18 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22078
22436
|
} finally {
|
|
22079
22437
|
setIsCreatingDialog(false);
|
|
22080
22438
|
}
|
|
22081
|
-
}, [createDialogCallback, isCreatingDialog, isManagedMode]);
|
|
22082
|
-
const
|
|
22083
|
-
async (id) => {
|
|
22084
|
-
if (!deleteDialogCallback) return;
|
|
22085
|
-
try {
|
|
22086
|
-
await deleteDialogCallback(id);
|
|
22087
|
-
setDialogs((prev) => prev.filter((d) => d.id !== id));
|
|
22088
|
-
dialogStore.remove(id);
|
|
22089
|
-
if (isManagedMode && internalDialogId === id) {
|
|
22090
|
-
setInternalDialogId(null);
|
|
22091
|
-
}
|
|
22092
|
-
} catch (err) {
|
|
22093
|
-
console.error("[useNatsChatAdapter] deleteDialog failed:", err);
|
|
22094
|
-
}
|
|
22095
|
-
},
|
|
22096
|
-
[deleteDialogCallback, dialogStore, internalDialogId, isManagedMode]
|
|
22097
|
-
);
|
|
22098
|
-
const renameDialog = useCallback21(
|
|
22099
|
-
async (id, title) => {
|
|
22100
|
-
if (!renameDialogCallback) return;
|
|
22101
|
-
let previous;
|
|
22102
|
-
setDialogs(
|
|
22103
|
-
(prev) => prev.map((d) => {
|
|
22104
|
-
if (d.id !== id) return d;
|
|
22105
|
-
previous = d.title;
|
|
22106
|
-
return { ...d, title };
|
|
22107
|
-
})
|
|
22108
|
-
);
|
|
22109
|
-
try {
|
|
22110
|
-
await renameDialogCallback(id, title);
|
|
22111
|
-
} catch (err) {
|
|
22112
|
-
console.error("[useNatsChatAdapter] renameDialog failed:", err);
|
|
22113
|
-
const rollbackTitle = previous;
|
|
22114
|
-
if (rollbackTitle !== void 0) {
|
|
22115
|
-
setDialogs((prev) => prev.map((d) => d.id === id ? { ...d, title: rollbackTitle } : d));
|
|
22116
|
-
}
|
|
22117
|
-
}
|
|
22118
|
-
},
|
|
22119
|
-
[renameDialogCallback]
|
|
22120
|
-
);
|
|
22121
|
-
const archiveDialog = useCallback21(
|
|
22122
|
-
async (id) => {
|
|
22123
|
-
if (!archiveDialogCallback) return;
|
|
22124
|
-
try {
|
|
22125
|
-
await archiveDialogCallback(id);
|
|
22126
|
-
setDialogs((prev) => prev.filter((d) => d.id !== id));
|
|
22127
|
-
if (isManagedMode && internalDialogId === id) {
|
|
22128
|
-
setInternalDialogId(null);
|
|
22129
|
-
}
|
|
22130
|
-
} catch (err) {
|
|
22131
|
-
console.error("[useNatsChatAdapter] archiveDialog failed:", err);
|
|
22132
|
-
}
|
|
22133
|
-
},
|
|
22134
|
-
[archiveDialogCallback, internalDialogId, isManagedMode]
|
|
22135
|
-
);
|
|
22136
|
-
const loadMoreDialogs = useCallback21(async () => {
|
|
22137
|
-
if (!dialogsNextCursor) return;
|
|
22138
|
-
await loadDialogsPage(dialogsNextCursor);
|
|
22139
|
-
}, [dialogsNextCursor, loadDialogsPage]);
|
|
22140
|
-
const loadMoreMessages = useCallback21(async () => {
|
|
22439
|
+
}, [createDialogCallback, isCreatingDialog, isManagedMode, upsertDialogTop]);
|
|
22440
|
+
const loadMoreMessages = useCallback22(async () => {
|
|
22141
22441
|
if (!dialogId || !messagesNextCursor) return;
|
|
22142
22442
|
await loadDialogHistory(dialogId, messagesNextCursor);
|
|
22143
22443
|
}, [dialogId, messagesNextCursor, loadDialogHistory]);
|
|
22144
|
-
const approveRequest =
|
|
22444
|
+
const approveRequest = useCallback22(async (requestId) => {
|
|
22145
22445
|
await handleApproveRef.current(requestId);
|
|
22146
22446
|
}, []);
|
|
22147
|
-
const rejectRequest =
|
|
22447
|
+
const rejectRequest = useCallback22(async (requestId, reason) => {
|
|
22148
22448
|
await handleRejectRef.current(requestId, reason);
|
|
22149
22449
|
}, []);
|
|
22150
|
-
const discussRef =
|
|
22450
|
+
const discussRef = useCallback22(
|
|
22151
22451
|
(reference) => {
|
|
22152
22452
|
const prompt = buildDiscussPrompt(reference, { includeReference: true });
|
|
22153
22453
|
void sendMessage(prompt).catch((err) => {
|
|
@@ -22158,9 +22458,17 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22158
22458
|
);
|
|
22159
22459
|
const { messages, streamingPhase, dialogTokenUsage = null, liveModel = null } = state;
|
|
22160
22460
|
const isLoading = streamingPhase !== "idle";
|
|
22161
|
-
const hasMoreDialogs = dialogsNextCursor != null;
|
|
22162
22461
|
const hasMoreMessages = messagesNextCursor != null;
|
|
22163
|
-
|
|
22462
|
+
const dialogCapabilities = useMemo27(
|
|
22463
|
+
() => isManagedMode ? {
|
|
22464
|
+
canRename: !!renameDialogCallback,
|
|
22465
|
+
canArchive: !!archiveDialogCallback,
|
|
22466
|
+
fetchArchivedDialogs,
|
|
22467
|
+
unarchiveDialog
|
|
22468
|
+
} : void 0,
|
|
22469
|
+
[isManagedMode, renameDialogCallback, archiveDialogCallback, fetchArchivedDialogs, unarchiveDialog]
|
|
22470
|
+
);
|
|
22471
|
+
return useMemo27(
|
|
22164
22472
|
() => ({
|
|
22165
22473
|
messages,
|
|
22166
22474
|
isLoading,
|
|
@@ -22197,6 +22505,8 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22197
22505
|
loadMoreDialogs,
|
|
22198
22506
|
hasMoreMessages,
|
|
22199
22507
|
loadMoreMessages,
|
|
22508
|
+
dialogsManaged: isManagedMode,
|
|
22509
|
+
dialogCapabilities,
|
|
22200
22510
|
// Approval mutations
|
|
22201
22511
|
approveRequest,
|
|
22202
22512
|
rejectRequest,
|
|
@@ -22229,6 +22539,8 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22229
22539
|
loadMoreDialogs,
|
|
22230
22540
|
hasMoreMessages,
|
|
22231
22541
|
loadMoreMessages,
|
|
22542
|
+
isManagedMode,
|
|
22543
|
+
dialogCapabilities,
|
|
22232
22544
|
approveRequest,
|
|
22233
22545
|
rejectRequest,
|
|
22234
22546
|
dialogTokenUsage,
|
|
@@ -22241,7 +22553,7 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22241
22553
|
}
|
|
22242
22554
|
|
|
22243
22555
|
// src/components/chat/hooks/use-unified-chat.ts
|
|
22244
|
-
import { useCallback as
|
|
22556
|
+
import { useCallback as useCallback23, useEffect as useEffect36, useMemo as useMemo28, useRef as useRef31, useState as useState43 } from "react";
|
|
22245
22557
|
var EMPTY_SSE_OPTIONS = {};
|
|
22246
22558
|
function createDisabledNatsConfig() {
|
|
22247
22559
|
return {
|
|
@@ -22256,7 +22568,7 @@ function createDisabledNatsConfig() {
|
|
|
22256
22568
|
}
|
|
22257
22569
|
function useUnifiedChat(options) {
|
|
22258
22570
|
const { modes, activeMode, mingoStateOverride } = options;
|
|
22259
|
-
const [disabledNatsConfig] =
|
|
22571
|
+
const [disabledNatsConfig] = useState43(createDisabledNatsConfig);
|
|
22260
22572
|
const sseActive = activeMode === "guide" && modes.guide !== void 0;
|
|
22261
22573
|
const natsActive = activeMode === "mingo" && modes.mingo !== void 0;
|
|
22262
22574
|
const sseState = useSseChatAdapter(modes.guide ?? EMPTY_SSE_OPTIONS, {
|
|
@@ -22264,40 +22576,40 @@ function useUnifiedChat(options) {
|
|
|
22264
22576
|
});
|
|
22265
22577
|
const natsState = useNatsChatAdapter(modes.mingo ?? disabledNatsConfig, { active: natsActive });
|
|
22266
22578
|
const activeState = activeMode === "guide" ? sseState : mingoStateOverride ?? natsState;
|
|
22267
|
-
const activeStateRef =
|
|
22268
|
-
|
|
22579
|
+
const activeStateRef = useRef31(activeState);
|
|
22580
|
+
useEffect36(() => {
|
|
22269
22581
|
activeStateRef.current = activeState;
|
|
22270
22582
|
});
|
|
22271
|
-
const stopMessage =
|
|
22272
|
-
const clearMessages =
|
|
22273
|
-
const sendMessage =
|
|
22583
|
+
const stopMessage = useCallback23(() => activeStateRef.current.stopMessage(), []);
|
|
22584
|
+
const clearMessages = useCallback23(() => activeStateRef.current.clearMessages(), []);
|
|
22585
|
+
const sendMessage = useCallback23(
|
|
22274
22586
|
(text, opts) => activeStateRef.current.sendMessage(text, opts),
|
|
22275
22587
|
[]
|
|
22276
22588
|
);
|
|
22277
|
-
const discussRef =
|
|
22589
|
+
const discussRef = useCallback23(
|
|
22278
22590
|
(ref) => activeStateRef.current.discussRef(ref),
|
|
22279
22591
|
[]
|
|
22280
22592
|
);
|
|
22281
|
-
const displayRefForward =
|
|
22593
|
+
const displayRefForward = useCallback23(
|
|
22282
22594
|
(ref) => activeStateRef.current.displayRef?.(ref),
|
|
22283
22595
|
[]
|
|
22284
22596
|
);
|
|
22285
22597
|
const displayRef = activeState.displayRef ? displayRefForward : void 0;
|
|
22286
|
-
const selectDialog =
|
|
22287
|
-
const startNewDialog =
|
|
22288
|
-
const deleteDialog =
|
|
22289
|
-
const renameDialog =
|
|
22290
|
-
const archiveDialog =
|
|
22291
|
-
const loadMoreDialogs =
|
|
22292
|
-
const setDialogScope =
|
|
22293
|
-
const reloadDialogs =
|
|
22294
|
-
const loadMoreMessages =
|
|
22295
|
-
const approveRequest =
|
|
22296
|
-
const rejectRequest =
|
|
22598
|
+
const selectDialog = useCallback23((id) => activeStateRef.current.selectDialog(id), []);
|
|
22599
|
+
const startNewDialog = useCallback23(() => activeStateRef.current.startNewDialog(), []);
|
|
22600
|
+
const deleteDialog = useCallback23((id) => activeStateRef.current.deleteDialog(id), []);
|
|
22601
|
+
const renameDialog = useCallback23((id, title) => activeStateRef.current.renameDialog(id, title), []);
|
|
22602
|
+
const archiveDialog = useCallback23((id) => activeStateRef.current.archiveDialog(id), []);
|
|
22603
|
+
const loadMoreDialogs = useCallback23(() => activeStateRef.current.loadMoreDialogs(), []);
|
|
22604
|
+
const setDialogScope = useCallback23((scope) => activeStateRef.current.setDialogScope?.(scope), []);
|
|
22605
|
+
const reloadDialogs = useCallback23(() => activeStateRef.current.reloadDialogs(), []);
|
|
22606
|
+
const loadMoreMessages = useCallback23(() => activeStateRef.current.loadMoreMessages(), []);
|
|
22607
|
+
const approveRequest = useCallback23((requestId) => activeStateRef.current.approveRequest(requestId), []);
|
|
22608
|
+
const rejectRequest = useCallback23(
|
|
22297
22609
|
(requestId, reason) => activeStateRef.current.rejectRequest(requestId, reason),
|
|
22298
22610
|
[]
|
|
22299
22611
|
);
|
|
22300
|
-
return
|
|
22612
|
+
return useMemo28(
|
|
22301
22613
|
() => ({
|
|
22302
22614
|
messages: activeState.messages,
|
|
22303
22615
|
isLoading: activeState.isLoading,
|
|
@@ -22334,6 +22646,11 @@ function useUnifiedChat(options) {
|
|
|
22334
22646
|
setDialogScope,
|
|
22335
22647
|
hasMoreMessages: activeState.hasMoreMessages,
|
|
22336
22648
|
loadMoreMessages,
|
|
22649
|
+
// Adapter-owned dialog list flag + capabilities (SSE with a
|
|
22650
|
+
// conversations endpoint, NATS managed mode). Forwarded verbatim —
|
|
22651
|
+
// `EmbeddableChat` gates the history UI on them.
|
|
22652
|
+
dialogsManaged: activeState.dialogsManaged,
|
|
22653
|
+
dialogCapabilities: activeState.dialogCapabilities,
|
|
22337
22654
|
// Approvals
|
|
22338
22655
|
approveRequest,
|
|
22339
22656
|
rejectRequest,
|
|
@@ -22653,7 +22970,7 @@ import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
|
|
|
22653
22970
|
import { usePreventScroll } from "@react-aria/overlays";
|
|
22654
22971
|
import { isIOS } from "@react-aria/utils";
|
|
22655
22972
|
import { MessageSquare as MessageSquare3 } from "lucide-react";
|
|
22656
|
-
import React10, { useCallback as
|
|
22973
|
+
import React10, { useCallback as useCallback27, useEffect as useEffect38, useImperativeHandle as useImperativeHandle4, useMemo as useMemo30, useRef as useRef35, useState as useState47 } from "react";
|
|
22657
22974
|
|
|
22658
22975
|
// src/components/ui/drawer.tsx
|
|
22659
22976
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
@@ -22661,10 +22978,10 @@ import { cva as cva2 } from "class-variance-authority";
|
|
|
22661
22978
|
import { X } from "lucide-react";
|
|
22662
22979
|
import {
|
|
22663
22980
|
forwardRef as forwardRef26,
|
|
22664
|
-
useCallback as
|
|
22665
|
-
useEffect as
|
|
22666
|
-
useRef as
|
|
22667
|
-
useState as
|
|
22981
|
+
useCallback as useCallback24,
|
|
22982
|
+
useEffect as useEffect37,
|
|
22983
|
+
useRef as useRef32,
|
|
22984
|
+
useState as useState44
|
|
22668
22985
|
} from "react";
|
|
22669
22986
|
import { jsx as jsx95, jsxs as jsxs73 } from "react/jsx-runtime";
|
|
22670
22987
|
var OVERLAY_BACKDROP_CLASS = "bg-ods-overlay";
|
|
@@ -22758,7 +23075,7 @@ function viewportSize(isHorizontal) {
|
|
|
22758
23075
|
return isHorizontal ? window.innerWidth : window.innerHeight;
|
|
22759
23076
|
}
|
|
22760
23077
|
function useResizableSize({ enabled, isHorizontal, minSize, maxSize, defaultSize, storageKey }) {
|
|
22761
|
-
const clampToViewport =
|
|
23078
|
+
const clampToViewport = useCallback24(
|
|
22762
23079
|
(value) => {
|
|
22763
23080
|
const vp = viewportSize(isHorizontal);
|
|
22764
23081
|
const effectiveMax = vp > 0 ? Math.min(maxSize, vp - 80) : maxSize;
|
|
@@ -22766,7 +23083,7 @@ function useResizableSize({ enabled, isHorizontal, minSize, maxSize, defaultSize
|
|
|
22766
23083
|
},
|
|
22767
23084
|
[isHorizontal, minSize, maxSize]
|
|
22768
23085
|
);
|
|
22769
|
-
const readInitial =
|
|
23086
|
+
const readInitial = useCallback24(() => {
|
|
22770
23087
|
if (!enabled) return defaultSize;
|
|
22771
23088
|
if (typeof window === "undefined") return defaultSize;
|
|
22772
23089
|
if (!storageKey) return clampToViewport(defaultSize);
|
|
@@ -22780,16 +23097,16 @@ function useResizableSize({ enabled, isHorizontal, minSize, maxSize, defaultSize
|
|
|
22780
23097
|
return clampToViewport(defaultSize);
|
|
22781
23098
|
}
|
|
22782
23099
|
}, [enabled, storageKey, defaultSize, clampToViewport]);
|
|
22783
|
-
const [size2, setSizeRaw] =
|
|
22784
|
-
const setSize =
|
|
22785
|
-
|
|
23100
|
+
const [size2, setSizeRaw] = useState44(readInitial);
|
|
23101
|
+
const setSize = useCallback24((next) => setSizeRaw(clampToViewport(next)), [clampToViewport]);
|
|
23102
|
+
useEffect37(() => {
|
|
22786
23103
|
if (!enabled || !storageKey || typeof window === "undefined") return;
|
|
22787
23104
|
try {
|
|
22788
23105
|
window.localStorage.setItem(storageKey, String(Math.round(size2)));
|
|
22789
23106
|
} catch {
|
|
22790
23107
|
}
|
|
22791
23108
|
}, [enabled, size2, storageKey]);
|
|
22792
|
-
|
|
23109
|
+
useEffect37(() => {
|
|
22793
23110
|
if (!enabled || typeof window === "undefined") return void 0;
|
|
22794
23111
|
const onResize = () => setSizeRaw((prev) => clampToViewport(prev));
|
|
22795
23112
|
window.addEventListener("resize", onResize);
|
|
@@ -22799,7 +23116,7 @@ function useResizableSize({ enabled, isHorizontal, minSize, maxSize, defaultSize
|
|
|
22799
23116
|
}
|
|
22800
23117
|
function DrawerResizeHandle({ side, size: size2, minSize, maxSize, onSize, ariaLabel }) {
|
|
22801
23118
|
const isHorizontal = HORIZONTAL_SIDES.has(side);
|
|
22802
|
-
const startRef =
|
|
23119
|
+
const startRef = useRef32(null);
|
|
22803
23120
|
const direction = side === "right" || side === "bottom" ? -1 : 1;
|
|
22804
23121
|
const handlePointerDown = (e) => {
|
|
22805
23122
|
if (e.button !== 0 && e.pointerType === "mouse") return;
|
|
@@ -22904,8 +23221,8 @@ var DrawerContent = forwardRef26(
|
|
|
22904
23221
|
const isHorizontal = HORIZONTAL_SIDES.has(resolvedSide);
|
|
22905
23222
|
const initialSize = defaultSize ?? (isHorizontal ? 560 : 480);
|
|
22906
23223
|
const headerHeight = useHeaderHeight();
|
|
22907
|
-
const [isMobile, setIsMobile] =
|
|
22908
|
-
|
|
23224
|
+
const [isMobile, setIsMobile] = useState44(false);
|
|
23225
|
+
useEffect37(() => {
|
|
22909
23226
|
if (typeof window === "undefined") return void 0;
|
|
22910
23227
|
const mq = window.matchMedia(`(max-width: ${mobileBreakpoint - 1}px)`);
|
|
22911
23228
|
const update = () => setIsMobile(mq.matches);
|
|
@@ -22995,7 +23312,7 @@ var DrawerFooter = ({ className, ...props }) => /* @__PURE__ */ jsx95("div", { c
|
|
|
22995
23312
|
DrawerFooter.displayName = "DrawerFooter";
|
|
22996
23313
|
|
|
22997
23314
|
// src/components/ui/hover-dropdown.tsx
|
|
22998
|
-
import { useState as
|
|
23315
|
+
import { useState as useState45, useRef as useRef33, useCallback as useCallback25 } from "react";
|
|
22999
23316
|
import { Fragment as Fragment33, jsx as jsx96, jsxs as jsxs74 } from "react/jsx-runtime";
|
|
23000
23317
|
function DefaultAnchor({ href, className, children }) {
|
|
23001
23318
|
return /* @__PURE__ */ jsx96("a", { href, className, children });
|
|
@@ -23008,10 +23325,10 @@ function HoverDropdown({
|
|
|
23008
23325
|
className,
|
|
23009
23326
|
renderAnchor
|
|
23010
23327
|
}) {
|
|
23011
|
-
const [open, setOpen] =
|
|
23012
|
-
const timeoutRef =
|
|
23013
|
-
const containerRef =
|
|
23014
|
-
const panelRef =
|
|
23328
|
+
const [open, setOpen] = useState45(false);
|
|
23329
|
+
const timeoutRef = useRef33(void 0);
|
|
23330
|
+
const containerRef = useRef33(null);
|
|
23331
|
+
const panelRef = useRef33(null);
|
|
23015
23332
|
useIsomorphicLayoutEffect(() => {
|
|
23016
23333
|
const el = panelRef.current;
|
|
23017
23334
|
const container = containerRef.current;
|
|
@@ -23039,14 +23356,14 @@ function HoverDropdown({
|
|
|
23039
23356
|
}
|
|
23040
23357
|
}
|
|
23041
23358
|
});
|
|
23042
|
-
const show =
|
|
23359
|
+
const show = useCallback25(() => {
|
|
23043
23360
|
clearTimeout(timeoutRef.current);
|
|
23044
23361
|
setOpen(true);
|
|
23045
23362
|
}, []);
|
|
23046
|
-
const hide =
|
|
23363
|
+
const hide = useCallback25(() => {
|
|
23047
23364
|
timeoutRef.current = setTimeout(() => setOpen(false), hideDelay);
|
|
23048
23365
|
}, [hideDelay]);
|
|
23049
|
-
const toggle =
|
|
23366
|
+
const toggle = useCallback25((e) => {
|
|
23050
23367
|
e.stopPropagation();
|
|
23051
23368
|
clearTimeout(timeoutRef.current);
|
|
23052
23369
|
setOpen((prev) => !prev);
|
|
@@ -23112,7 +23429,7 @@ function HoverDropdown({
|
|
|
23112
23429
|
}
|
|
23113
23430
|
|
|
23114
23431
|
// src/components/chat/hooks/use-chat-dialog-manager.ts
|
|
23115
|
-
import { useCallback as
|
|
23432
|
+
import { useCallback as useCallback26, useMemo as useMemo29, useRef as useRef34, useState as useState46 } from "react";
|
|
23116
23433
|
function useChatDialogManager({
|
|
23117
23434
|
dialogs,
|
|
23118
23435
|
activeDialogId,
|
|
@@ -23123,17 +23440,17 @@ function useChatDialogManager({
|
|
|
23123
23440
|
fetchArchivedDialogs,
|
|
23124
23441
|
unarchiveDialog
|
|
23125
23442
|
}) {
|
|
23126
|
-
const [renameTarget, setRenameTarget] =
|
|
23127
|
-
const [archiveTarget, setArchiveTarget] =
|
|
23128
|
-
const handleConfirmRename =
|
|
23443
|
+
const [renameTarget, setRenameTarget] = useState46(null);
|
|
23444
|
+
const [archiveTarget, setArchiveTarget] = useState46(null);
|
|
23445
|
+
const handleConfirmRename = useCallback26(
|
|
23129
23446
|
(name) => {
|
|
23130
23447
|
if (renameTarget) void renameDialog(renameTarget.id, name);
|
|
23131
23448
|
setRenameTarget(null);
|
|
23132
23449
|
},
|
|
23133
23450
|
[renameTarget, renameDialog]
|
|
23134
23451
|
);
|
|
23135
|
-
const [openingDialogId, setOpeningDialogId] =
|
|
23136
|
-
const handleConfirmArchive =
|
|
23452
|
+
const [openingDialogId, setOpeningDialogId] = useState46(null);
|
|
23453
|
+
const handleConfirmArchive = useCallback26(async () => {
|
|
23137
23454
|
if (archiveTarget) {
|
|
23138
23455
|
try {
|
|
23139
23456
|
await archiveDialog(archiveTarget.id);
|
|
@@ -23148,13 +23465,13 @@ function useChatDialogManager({
|
|
|
23148
23465
|
}
|
|
23149
23466
|
setArchiveTarget(null);
|
|
23150
23467
|
}, [archiveTarget, archiveDialog, activeDialogId, clearMessages]);
|
|
23151
|
-
const [archiveOpen, setArchiveOpen] =
|
|
23152
|
-
const [archivedDialogs, setArchivedDialogs] =
|
|
23153
|
-
const [archivedCursor, setArchivedCursor] =
|
|
23154
|
-
const [archivedLoading, setArchivedLoading] =
|
|
23155
|
-
const [archivedPending, setArchivedPending] =
|
|
23156
|
-
const archivedRequestIdRef =
|
|
23157
|
-
const loadArchivedPage =
|
|
23468
|
+
const [archiveOpen, setArchiveOpen] = useState46(false);
|
|
23469
|
+
const [archivedDialogs, setArchivedDialogs] = useState46([]);
|
|
23470
|
+
const [archivedCursor, setArchivedCursor] = useState46(null);
|
|
23471
|
+
const [archivedLoading, setArchivedLoading] = useState46(false);
|
|
23472
|
+
const [archivedPending, setArchivedPending] = useState46(false);
|
|
23473
|
+
const archivedRequestIdRef = useRef34(0);
|
|
23474
|
+
const loadArchivedPage = useCallback26(
|
|
23158
23475
|
async (cursor) => {
|
|
23159
23476
|
if (!fetchArchivedDialogs) return;
|
|
23160
23477
|
const requestId = ++archivedRequestIdRef.current;
|
|
@@ -23187,13 +23504,13 @@ function useChatDialogManager({
|
|
|
23187
23504
|
},
|
|
23188
23505
|
[fetchArchivedDialogs]
|
|
23189
23506
|
);
|
|
23190
|
-
const openArchive =
|
|
23507
|
+
const openArchive = useCallback26(() => {
|
|
23191
23508
|
setArchiveOpen(true);
|
|
23192
23509
|
void loadArchivedPage();
|
|
23193
23510
|
}, [loadArchivedPage]);
|
|
23194
|
-
const closeArchive =
|
|
23195
|
-
const [viewingArchivedId, setViewingArchivedId] =
|
|
23196
|
-
const handleSelectDialog =
|
|
23511
|
+
const closeArchive = useCallback26(() => setArchiveOpen(false), []);
|
|
23512
|
+
const [viewingArchivedId, setViewingArchivedId] = useState46(null);
|
|
23513
|
+
const handleSelectDialog = useCallback26(
|
|
23197
23514
|
(id) => {
|
|
23198
23515
|
setViewingArchivedId(null);
|
|
23199
23516
|
setOpeningDialogId(id);
|
|
@@ -23202,7 +23519,7 @@ function useChatDialogManager({
|
|
|
23202
23519
|
[selectDialog]
|
|
23203
23520
|
);
|
|
23204
23521
|
const isOpeningDialog = openingDialogId != null && openingDialogId === activeDialogId;
|
|
23205
|
-
const handleArchivedSelect =
|
|
23522
|
+
const handleArchivedSelect = useCallback26(
|
|
23206
23523
|
(id) => {
|
|
23207
23524
|
setArchiveOpen(false);
|
|
23208
23525
|
setOpeningDialogId(null);
|
|
@@ -23211,8 +23528,8 @@ function useChatDialogManager({
|
|
|
23211
23528
|
},
|
|
23212
23529
|
[selectDialog]
|
|
23213
23530
|
);
|
|
23214
|
-
const [restoreTarget, setRestoreTarget] =
|
|
23215
|
-
const handleConfirmRestore =
|
|
23531
|
+
const [restoreTarget, setRestoreTarget] = useState46(null);
|
|
23532
|
+
const handleConfirmRestore = useCallback26(async () => {
|
|
23216
23533
|
if (restoreTarget) {
|
|
23217
23534
|
try {
|
|
23218
23535
|
await unarchiveDialog?.(restoreTarget.id);
|
|
@@ -23226,7 +23543,7 @@ function useChatDialogManager({
|
|
|
23226
23543
|
setRestoreTarget(null);
|
|
23227
23544
|
}, [restoreTarget, unarchiveDialog]);
|
|
23228
23545
|
const isViewingArchived = viewingArchivedId != null && viewingArchivedId === activeDialogId;
|
|
23229
|
-
const handleBack =
|
|
23546
|
+
const handleBack = useCallback26(() => {
|
|
23230
23547
|
const wasArchived = isViewingArchived;
|
|
23231
23548
|
setViewingArchivedId(null);
|
|
23232
23549
|
setOpeningDialogId(null);
|
|
@@ -23234,14 +23551,14 @@ function useChatDialogManager({
|
|
|
23234
23551
|
clearMessages();
|
|
23235
23552
|
if (wasArchived) setArchiveOpen(true);
|
|
23236
23553
|
}, [isViewingArchived, selectDialog, clearMessages]);
|
|
23237
|
-
const resetToNewChat =
|
|
23554
|
+
const resetToNewChat = useCallback26(() => {
|
|
23238
23555
|
setViewingArchivedId(null);
|
|
23239
23556
|
setOpeningDialogId(null);
|
|
23240
23557
|
selectDialog(null);
|
|
23241
23558
|
clearMessages();
|
|
23242
23559
|
setArchiveOpen(false);
|
|
23243
23560
|
}, [selectDialog, clearMessages]);
|
|
23244
|
-
const activeDialog =
|
|
23561
|
+
const activeDialog = useMemo29(
|
|
23245
23562
|
() => dialogs.find((d) => d.id === activeDialogId) ?? archivedDialogs.find((d) => d.id === activeDialogId),
|
|
23246
23563
|
[dialogs, archivedDialogs, activeDialogId]
|
|
23247
23564
|
);
|
|
@@ -23282,12 +23599,18 @@ function useChatDialogManager({
|
|
|
23282
23599
|
|
|
23283
23600
|
// src/components/chat/embeddable-chat.tsx
|
|
23284
23601
|
import { Fragment as Fragment34, jsx as jsx97, jsxs as jsxs75 } from "react/jsx-runtime";
|
|
23602
|
+
var HISTORY_RAIL_WIDTH = 320;
|
|
23603
|
+
var CHAT_BLOCK_MIN_WIDTH = 400;
|
|
23604
|
+
var SPLIT_MIN_WIDTH = HISTORY_RAIL_WIDTH + CHAT_BLOCK_MIN_WIDTH;
|
|
23285
23605
|
var DRAWER_DEFAULT_WIDTH_RATIO = 0.5;
|
|
23286
|
-
var DRAWER_WIDTH_KEY = "mingo-chat-width-
|
|
23606
|
+
var DRAWER_WIDTH_KEY = "mingo-chat-width-v4";
|
|
23287
23607
|
var DRAWER_DEFAULT_WIDTH_PX = 750;
|
|
23288
|
-
|
|
23608
|
+
var SPLIT_DEFAULT_WIDTH_ALLOWANCE = 16;
|
|
23609
|
+
function drawerDefaultWidth(withHistoryRail) {
|
|
23289
23610
|
if (typeof window === "undefined") return DRAWER_DEFAULT_WIDTH_PX;
|
|
23290
|
-
|
|
23611
|
+
const ratioWidth = Math.round(window.innerWidth * DRAWER_DEFAULT_WIDTH_RATIO);
|
|
23612
|
+
if (!withHistoryRail) return ratioWidth;
|
|
23613
|
+
return Math.max(ratioWidth, SPLIT_MIN_WIDTH + SPLIT_DEFAULT_WIDTH_ALLOWANCE);
|
|
23291
23614
|
}
|
|
23292
23615
|
var formatRelativePath = (p) => p.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
23293
23616
|
var mentionTokenOf = (key, markerByType) => {
|
|
@@ -23297,18 +23620,15 @@ var mentionTokenOf = (key, markerByType) => {
|
|
|
23297
23620
|
return `${markerByType.get(type) ?? type.toLowerCase()}:${id}`;
|
|
23298
23621
|
};
|
|
23299
23622
|
var FALLBACK_TOP_RETRIEVED = 3;
|
|
23300
|
-
var HISTORY_RAIL_WIDTH = 320;
|
|
23301
|
-
var CHAT_BLOCK_MIN_WIDTH = 400;
|
|
23302
|
-
var SPLIT_MIN_WIDTH = HISTORY_RAIL_WIDTH + CHAT_BLOCK_MIN_WIDTH;
|
|
23303
23623
|
var RAIL_COLLAPSED_STORAGE_KEY = "mingo-chat-history-collapsed";
|
|
23304
23624
|
var NO_CONTEXT_ITEMS = [];
|
|
23305
23625
|
var RAIL_ANIM_MS = 320;
|
|
23306
23626
|
function useRailPresence(open) {
|
|
23307
|
-
const [mounted, setMounted] =
|
|
23308
|
-
const [active, setActive] =
|
|
23627
|
+
const [mounted, setMounted] = useState47(open);
|
|
23628
|
+
const [active, setActive] = useState47(false);
|
|
23309
23629
|
if (open && !mounted) setMounted(true);
|
|
23310
23630
|
if (!open && active) setActive(false);
|
|
23311
|
-
|
|
23631
|
+
useEffect38(() => {
|
|
23312
23632
|
if (open) {
|
|
23313
23633
|
let raf2 = 0;
|
|
23314
23634
|
const raf1 = requestAnimationFrame(() => {
|
|
@@ -23524,7 +23844,7 @@ function SourceChips({
|
|
|
23524
23844
|
onClose,
|
|
23525
23845
|
onDiscuss
|
|
23526
23846
|
}) {
|
|
23527
|
-
const [expanded, setExpanded] =
|
|
23847
|
+
const [expanded, setExpanded] = useState47(false);
|
|
23528
23848
|
if (cited.length === 0) {
|
|
23529
23849
|
const fallback = uncited.slice(0, FALLBACK_TOP_RETRIEVED);
|
|
23530
23850
|
if (fallback.length === 0) return null;
|
|
@@ -23631,7 +23951,7 @@ function EmbeddableChatInner({
|
|
|
23631
23951
|
const commandsUrl = runtime.endpoints.commandsUrl;
|
|
23632
23952
|
const { attachmentsEnabled, user: identityUser } = useChatIdentity();
|
|
23633
23953
|
const viewUrlPrefix = runtime.endpoints.attachmentViewUrlPrefix;
|
|
23634
|
-
|
|
23954
|
+
useEffect38(() => {
|
|
23635
23955
|
if (process.env.NODE_ENV !== "production") {
|
|
23636
23956
|
const hasOpen = open !== void 0;
|
|
23637
23957
|
const hasHandler = onOpenChange !== void 0;
|
|
@@ -23647,13 +23967,13 @@ function EmbeddableChatInner({
|
|
|
23647
23967
|
defaultProp: defaultOpen ?? false,
|
|
23648
23968
|
onChange: onOpenChange
|
|
23649
23969
|
});
|
|
23650
|
-
const [autoFocusInput] =
|
|
23970
|
+
const [autoFocusInput] = useState47(() => {
|
|
23651
23971
|
if (typeof window === "undefined") return false;
|
|
23652
23972
|
return !window.matchMedia("(pointer: coarse)").matches;
|
|
23653
23973
|
});
|
|
23654
23974
|
usePreventScroll({ isDisabled: !isOpen || shellLess });
|
|
23655
|
-
const navigatingAwayRef =
|
|
23656
|
-
|
|
23975
|
+
const navigatingAwayRef = useRef35(false);
|
|
23976
|
+
useEffect38(() => {
|
|
23657
23977
|
if (!isOpen) return void 0;
|
|
23658
23978
|
if (shellLess) return void 0;
|
|
23659
23979
|
if (typeof window === "undefined") return void 0;
|
|
@@ -23679,9 +23999,9 @@ function EmbeddableChatInner({
|
|
|
23679
23999
|
window.scrollTo(0, scrollY);
|
|
23680
24000
|
};
|
|
23681
24001
|
}, [isOpen, shellLess]);
|
|
23682
|
-
const chatInputRef =
|
|
23683
|
-
const [quickActionPreview, setQuickActionPreview] =
|
|
23684
|
-
const slashCommandsProp =
|
|
24002
|
+
const chatInputRef = useRef35(null);
|
|
24003
|
+
const [quickActionPreview, setQuickActionPreview] = useState47(null);
|
|
24004
|
+
const slashCommandsProp = useMemo30(
|
|
23685
24005
|
() => ({
|
|
23686
24006
|
fetchCommands: (prefix, signal) => fetchSlashCommands(prefix, signal, commandsUrl),
|
|
23687
24007
|
resolveSourceIcon: (sourceId) => {
|
|
@@ -23696,38 +24016,16 @@ function EmbeddableChatInner({
|
|
|
23696
24016
|
[commandsUrl]
|
|
23697
24017
|
);
|
|
23698
24018
|
const headerUserName = identityUser?.name?.trim() || [identityUser?.firstName, identityUser?.lastName].filter(Boolean).join(" ").trim() || userDisplayName?.trim() || void 0;
|
|
23699
|
-
const effectiveModes =
|
|
24019
|
+
const effectiveModes = useMemo30(() => {
|
|
23700
24020
|
if (modes) return modes;
|
|
23701
24021
|
const guideOptions = tableIdForDocumentType ? { tableIdForDocumentType } : {};
|
|
23702
24022
|
return { guide: guideOptions };
|
|
23703
24023
|
}, [modes, tableIdForDocumentType]);
|
|
23704
|
-
const mingoCaps = useMemo29(() => {
|
|
23705
|
-
if (mingoState) {
|
|
23706
|
-
return {
|
|
23707
|
-
canRename: mingoDialogCapabilities?.canRename ?? false,
|
|
23708
|
-
canArchive: mingoDialogCapabilities?.canArchive ?? false,
|
|
23709
|
-
fetchArchivedDialogs: mingoDialogCapabilities?.fetchArchivedDialogs,
|
|
23710
|
-
unarchiveDialog: mingoDialogCapabilities?.unarchiveDialog,
|
|
23711
|
-
searchQuery: mingoDialogCapabilities?.searchQuery,
|
|
23712
|
-
onSearchChange: mingoDialogCapabilities?.onSearchChange,
|
|
23713
|
-
onCopyLink: mingoDialogCapabilities?.onCopyLink
|
|
23714
|
-
};
|
|
23715
|
-
}
|
|
23716
|
-
return {
|
|
23717
|
-
canRename: !!effectiveModes.mingo?.renameDialog,
|
|
23718
|
-
canArchive: !!effectiveModes.mingo?.archiveDialog,
|
|
23719
|
-
fetchArchivedDialogs: effectiveModes.mingo?.fetchArchivedDialogs,
|
|
23720
|
-
unarchiveDialog: effectiveModes.mingo?.unarchiveDialog,
|
|
23721
|
-
searchQuery: void 0,
|
|
23722
|
-
onSearchChange: void 0,
|
|
23723
|
-
onCopyLink: void 0
|
|
23724
|
-
};
|
|
23725
|
-
}, [mingoState, mingoDialogCapabilities, effectiveModes]);
|
|
23726
24024
|
const hasMingoMode = !!effectiveModes.mingo || !!mingoState;
|
|
23727
24025
|
const initialActiveMode = controlledActiveMode ?? defaultActiveMode ?? (effectiveModes.guide ? "guide" : "mingo");
|
|
23728
|
-
const [uncontrolledActiveMode, setUncontrolledActiveMode] =
|
|
24026
|
+
const [uncontrolledActiveMode, setUncontrolledActiveMode] = useState47(initialActiveMode);
|
|
23729
24027
|
const activeMode = controlledActiveMode ?? uncontrolledActiveMode;
|
|
23730
|
-
const handleActiveModeChange =
|
|
24028
|
+
const handleActiveModeChange = useCallback27(
|
|
23731
24029
|
(next) => {
|
|
23732
24030
|
if (controlledActiveMode === void 0) {
|
|
23733
24031
|
setUncontrolledActiveMode(next);
|
|
@@ -23739,7 +24037,7 @@ function EmbeddableChatInner({
|
|
|
23739
24037
|
const { commands: commandsList, loaded: commandsLoaded } = useSlashCommandRegistry(commandsUrl, {
|
|
23740
24038
|
enabled: activeMode === "guide"
|
|
23741
24039
|
});
|
|
23742
|
-
const commandsById =
|
|
24040
|
+
const commandsById = useMemo30(() => {
|
|
23743
24041
|
const map = /* @__PURE__ */ new Map();
|
|
23744
24042
|
for (const cmd of commandsList) map.set(cmd.id, cmd);
|
|
23745
24043
|
return map;
|
|
@@ -23753,7 +24051,7 @@ function EmbeddableChatInner({
|
|
|
23753
24051
|
const effectiveGreeting = emptyStateConfig.greeting ?? emptyStateGreeting;
|
|
23754
24052
|
const effectiveEnabledRagTableIds = emptyStateUrl ? emptyStateConfig.enabledRagTableIds : enabledRagTableIds;
|
|
23755
24053
|
const effectiveSuggestedQueries = emptyStateUrl ? emptyStateConfig.suggestedQueries : suggestedQueries;
|
|
23756
|
-
const effectiveQuickActions =
|
|
24054
|
+
const effectiveQuickActions = useMemo30(
|
|
23757
24055
|
() => emptyStateUrl ? emptyStateConfig.quickActions : [],
|
|
23758
24056
|
[emptyStateUrl, emptyStateConfig.quickActions]
|
|
23759
24057
|
);
|
|
@@ -23790,10 +24088,26 @@ function EmbeddableChatInner({
|
|
|
23790
24088
|
dialogScope,
|
|
23791
24089
|
setDialogScope,
|
|
23792
24090
|
hasMoreMessages,
|
|
23793
|
-
loadMoreMessages
|
|
24091
|
+
loadMoreMessages,
|
|
24092
|
+
dialogsManaged,
|
|
24093
|
+
dialogCapabilities
|
|
23794
24094
|
} = useUnifiedChat({ modes: effectiveModes, activeMode, mingoStateOverride: mingoState });
|
|
23795
|
-
const
|
|
23796
|
-
|
|
24095
|
+
const historyListMode = activeMode === "mingo" || dialogsManaged === true;
|
|
24096
|
+
const mingoCaps = useMemo30(() => {
|
|
24097
|
+
const caps = dialogCapabilities ?? (mingoState ? mingoDialogCapabilities : {
|
|
24098
|
+
canRename: !!effectiveModes.mingo?.renameDialog,
|
|
24099
|
+
canArchive: !!effectiveModes.mingo?.archiveDialog,
|
|
24100
|
+
fetchArchivedDialogs: effectiveModes.mingo?.fetchArchivedDialogs,
|
|
24101
|
+
unarchiveDialog: effectiveModes.mingo?.unarchiveDialog
|
|
24102
|
+
});
|
|
24103
|
+
return {
|
|
24104
|
+
...caps,
|
|
24105
|
+
canRename: caps?.canRename ?? false,
|
|
24106
|
+
canArchive: caps?.canArchive ?? false
|
|
24107
|
+
};
|
|
24108
|
+
}, [dialogCapabilities, mingoState, mingoDialogCapabilities, effectiveModes]);
|
|
24109
|
+
const guidePromptSentRef = useRef35(false);
|
|
24110
|
+
useEffect38(() => {
|
|
23797
24111
|
if (!guidePendingPrompt) {
|
|
23798
24112
|
guidePromptSentRef.current = false;
|
|
23799
24113
|
return;
|
|
@@ -23816,35 +24130,35 @@ function EmbeddableChatInner({
|
|
|
23816
24130
|
const { panelRef: galleryPanelRef, modal: galleryModal } = useChatAttachmentImageGallery();
|
|
23817
24131
|
const contextMaxItems = contextPicker?.maxItems ?? 10;
|
|
23818
24132
|
const contextPickerForMode = activeMode === "mingo" ? contextPicker : void 0;
|
|
23819
|
-
const [contextItems, setContextItems] =
|
|
23820
|
-
const [contextPickerOpen, setContextPickerOpen] =
|
|
23821
|
-
const [mentionQuery, setMentionQuery] =
|
|
23822
|
-
const mentionActiveRef =
|
|
23823
|
-
|
|
24133
|
+
const [contextItems, setContextItems] = useState47(NO_CONTEXT_ITEMS);
|
|
24134
|
+
const [contextPickerOpen, setContextPickerOpen] = useState47(false);
|
|
24135
|
+
const [mentionQuery, setMentionQuery] = useState47(null);
|
|
24136
|
+
const mentionActiveRef = useRef35(false);
|
|
24137
|
+
useEffect38(() => {
|
|
23824
24138
|
mentionActiveRef.current = mentionQuery !== null;
|
|
23825
24139
|
}, [mentionQuery]);
|
|
23826
|
-
const mentionKeysRef =
|
|
23827
|
-
const [contextClearedFor, setContextClearedFor] =
|
|
24140
|
+
const mentionKeysRef = useRef35(/* @__PURE__ */ new Set());
|
|
24141
|
+
const [contextClearedFor, setContextClearedFor] = useState47({ activeDialogId, activeMode });
|
|
23828
24142
|
if (contextClearedFor.activeDialogId !== activeDialogId || contextClearedFor.activeMode !== activeMode) {
|
|
23829
24143
|
setContextClearedFor({ activeDialogId, activeMode });
|
|
23830
24144
|
setContextItems(NO_CONTEXT_ITEMS);
|
|
23831
24145
|
setMentionQuery(null);
|
|
23832
24146
|
}
|
|
23833
|
-
|
|
24147
|
+
useEffect38(() => {
|
|
23834
24148
|
mentionKeysRef.current.clear();
|
|
23835
24149
|
}, [activeDialogId, activeMode]);
|
|
23836
|
-
const mentionMarkerByType =
|
|
24150
|
+
const mentionMarkerByType = useMemo30(() => {
|
|
23837
24151
|
const m = /* @__PURE__ */ new Map();
|
|
23838
24152
|
for (const t of contextPicker?.entityTypes ?? []) if (t.marker) m.set(t.type, t.marker);
|
|
23839
24153
|
return m;
|
|
23840
24154
|
}, [contextPicker?.entityTypes]);
|
|
23841
24155
|
const contextEntityTypes = contextPicker?.entityTypes;
|
|
23842
|
-
const resolveContextIcon =
|
|
24156
|
+
const resolveContextIcon = useMemo30(() => {
|
|
23843
24157
|
const byType = /* @__PURE__ */ new Map();
|
|
23844
24158
|
for (const t of contextEntityTypes ?? []) byType.set(t.type, t.icon);
|
|
23845
24159
|
return (item) => byType.get(item.type);
|
|
23846
24160
|
}, [contextEntityTypes]);
|
|
23847
|
-
const toggleContextItem =
|
|
24161
|
+
const toggleContextItem = useCallback27(
|
|
23848
24162
|
(item) => {
|
|
23849
24163
|
const key = `${item.type}:${item.id}`;
|
|
23850
24164
|
if (mentionActiveRef.current) {
|
|
@@ -23867,7 +24181,7 @@ function EmbeddableChatInner({
|
|
|
23867
24181
|
},
|
|
23868
24182
|
[contextMaxItems, contextItems, mentionMarkerByType, resolveContextIcon]
|
|
23869
24183
|
);
|
|
23870
|
-
const removeContextItem =
|
|
24184
|
+
const removeContextItem = useCallback27(
|
|
23871
24185
|
(item) => {
|
|
23872
24186
|
const key = `${item.type}:${item.id}`;
|
|
23873
24187
|
setContextItems((prev) => prev.filter((p) => `${p.type}:${p.id}` !== key));
|
|
@@ -23880,7 +24194,7 @@ function EmbeddableChatInner({
|
|
|
23880
24194
|
},
|
|
23881
24195
|
[mentionMarkerByType]
|
|
23882
24196
|
);
|
|
23883
|
-
const handleContextValueChange =
|
|
24197
|
+
const handleContextValueChange = useCallback27(
|
|
23884
24198
|
(value) => {
|
|
23885
24199
|
for (const key of Array.from(mentionKeysRef.current)) {
|
|
23886
24200
|
if (!value.includes(`@${mentionTokenOf(key, mentionMarkerByType)}`)) {
|
|
@@ -23891,32 +24205,32 @@ function EmbeddableChatInner({
|
|
|
23891
24205
|
},
|
|
23892
24206
|
[mentionMarkerByType]
|
|
23893
24207
|
);
|
|
23894
|
-
const openContextPicker =
|
|
24208
|
+
const openContextPicker = useCallback27(() => {
|
|
23895
24209
|
setMentionQuery(null);
|
|
23896
24210
|
setContextPickerOpen(true);
|
|
23897
24211
|
}, []);
|
|
23898
|
-
const closeContextPicker =
|
|
24212
|
+
const closeContextPicker = useCallback27(() => {
|
|
23899
24213
|
if (mentionActiveRef.current) {
|
|
23900
24214
|
chatInputRef.current?.removeMentionTrigger();
|
|
23901
24215
|
}
|
|
23902
24216
|
setContextPickerOpen(false);
|
|
23903
24217
|
setMentionQuery(null);
|
|
23904
24218
|
}, []);
|
|
23905
|
-
const handleMentionQueryChange =
|
|
24219
|
+
const handleMentionQueryChange = useCallback27((query) => {
|
|
23906
24220
|
setMentionQuery(query);
|
|
23907
24221
|
setContextPickerOpen(query !== null);
|
|
23908
24222
|
}, []);
|
|
23909
24223
|
const resolvedBaseRoute = baseRoute || (source === "flamingo" ? "/knowledge-base" : "/data-room");
|
|
23910
|
-
const handleClose =
|
|
23911
|
-
const handleNavigationClose =
|
|
24224
|
+
const handleClose = useCallback27(() => setIsOpen(false), [setIsOpen]);
|
|
24225
|
+
const handleNavigationClose = useCallback27(() => {
|
|
23912
24226
|
navigatingAwayRef.current = true;
|
|
23913
24227
|
setIsOpen(false);
|
|
23914
24228
|
}, [setIsOpen]);
|
|
23915
|
-
const chatPanelHandle =
|
|
24229
|
+
const chatPanelHandle = useMemo30(
|
|
23916
24230
|
() => ({ closeChat: handleNavigationClose }),
|
|
23917
24231
|
[handleNavigationClose]
|
|
23918
24232
|
);
|
|
23919
|
-
const renderEntityCard =
|
|
24233
|
+
const renderEntityCard = useCallback27(
|
|
23920
24234
|
(reference) => renderChatInlineEntityCard(reference, {
|
|
23921
24235
|
onDiscuss: discussRef,
|
|
23922
24236
|
onDisplay: displayRef,
|
|
@@ -23926,14 +24240,14 @@ function EmbeddableChatInner({
|
|
|
23926
24240
|
}),
|
|
23927
24241
|
[discussRef, displayRef, resolvedBaseRoute, chipBasePlatform, extras]
|
|
23928
24242
|
);
|
|
23929
|
-
const mingoAssistantIcon =
|
|
24243
|
+
const mingoAssistantIcon = useMemo30(
|
|
23930
24244
|
() => effectiveAssistantIcon ? /* @__PURE__ */ jsx97(EntityIcon, { icon: effectiveAssistantIcon, size: 24 }) : /* @__PURE__ */ jsx97(MingoIcon, { className: "h-6 w-6", cornerColor: "var(--ods-flamingo-cyan-base)" }),
|
|
23931
24245
|
[effectiveAssistantIcon]
|
|
23932
24246
|
);
|
|
23933
|
-
const [timestampCache] =
|
|
24247
|
+
const [timestampCache] = useState47(() => /* @__PURE__ */ new Map());
|
|
23934
24248
|
const guideUserName = activeMode === "guide" ? [identityUser?.firstName, identityUser?.lastName].filter(Boolean).join(" ").trim() || identityUser?.name?.trim() || void 0 : void 0;
|
|
23935
24249
|
const guideUserAvatar = activeMode === "guide" ? identityUser?.avatarUrl?.trim() || void 0 : void 0;
|
|
23936
|
-
const messages =
|
|
24250
|
+
const messages = useMemo30(() => {
|
|
23937
24251
|
const cache = timestampCache;
|
|
23938
24252
|
const seenIds = /* @__PURE__ */ new Set();
|
|
23939
24253
|
const mapped = rawMessages.map((m) => {
|
|
@@ -23978,7 +24292,7 @@ function EmbeddableChatInner({
|
|
|
23978
24292
|
}
|
|
23979
24293
|
return mapped;
|
|
23980
24294
|
}, [rawMessages, guideUserName, guideUserAvatar, timestampCache]);
|
|
23981
|
-
const handleSend =
|
|
24295
|
+
const handleSend = useCallback27(
|
|
23982
24296
|
(text) => {
|
|
23983
24297
|
let augmentedText = text;
|
|
23984
24298
|
if (readyAttachments.length > 0) {
|
|
@@ -24000,7 +24314,7 @@ function EmbeddableChatInner({
|
|
|
24000
24314
|
},
|
|
24001
24315
|
[sendMessage, readyAttachments, viewUrlPrefix, clearAttachments, contextItems]
|
|
24002
24316
|
);
|
|
24003
|
-
const handleAskSelect =
|
|
24317
|
+
const handleAskSelect = useCallback27(
|
|
24004
24318
|
(label) => {
|
|
24005
24319
|
void sendMessage(label).catch((err) => {
|
|
24006
24320
|
console.error("[EmbeddableChat] handleAskSelect send failed:", err);
|
|
@@ -24008,7 +24322,7 @@ function EmbeddableChatInner({
|
|
|
24008
24322
|
},
|
|
24009
24323
|
[sendMessage]
|
|
24010
24324
|
);
|
|
24011
|
-
const guideSuggestedActions =
|
|
24325
|
+
const guideSuggestedActions = useMemo30(() => {
|
|
24012
24326
|
if (effectiveQuickActions.length > 0) {
|
|
24013
24327
|
return effectiveQuickActions.map((qa) => ({
|
|
24014
24328
|
id: qa.id,
|
|
@@ -24067,9 +24381,9 @@ function EmbeddableChatInner({
|
|
|
24067
24381
|
fetchArchivedDialogs: mingoCaps.fetchArchivedDialogs,
|
|
24068
24382
|
unarchiveDialog: mingoCaps.unarchiveDialog
|
|
24069
24383
|
});
|
|
24070
|
-
const handleOpen =
|
|
24384
|
+
const handleOpen = useCallback27(() => setIsOpen(true), [setIsOpen]);
|
|
24071
24385
|
useCloseOnNavigation(handleNavigationClose, null);
|
|
24072
|
-
|
|
24386
|
+
useEffect38(() => {
|
|
24073
24387
|
const handler = (e) => {
|
|
24074
24388
|
const detail = e.detail;
|
|
24075
24389
|
if (!detail || detail.source !== source) return;
|
|
@@ -24079,7 +24393,7 @@ function EmbeddableChatInner({
|
|
|
24079
24393
|
window.addEventListener("ask-ai:open-with-ref", handler);
|
|
24080
24394
|
return () => window.removeEventListener("ask-ai:open-with-ref", handler);
|
|
24081
24395
|
}, [source, discussRef, setIsOpen]);
|
|
24082
|
-
|
|
24396
|
+
useEffect38(() => {
|
|
24083
24397
|
const handler = (e) => {
|
|
24084
24398
|
const detail = e.detail;
|
|
24085
24399
|
if (!detail || detail.source !== source) return;
|
|
@@ -24091,7 +24405,7 @@ function EmbeddableChatInner({
|
|
|
24091
24405
|
const hasMessages = messages.length > 0;
|
|
24092
24406
|
const dialogsInitialLoading = isDialogsLoading && dialogs.length === 0;
|
|
24093
24407
|
const dialogsLoadError = dialogsError && dialogs.length === 0;
|
|
24094
|
-
const hasConversation = hasMessages || isOpeningDialog || isViewingArchived || previewMode && isMessagesLoading;
|
|
24408
|
+
const hasConversation = hasMessages || isOpeningDialog || isViewingArchived || (previewMode || activeMode === "guide" && dialogsManaged === true) && isMessagesLoading;
|
|
24095
24409
|
const messagesInitialLoading = isMessagesLoading && !hasMessages;
|
|
24096
24410
|
const contentViewKey = hasConversation ? "conversation" : activeMode;
|
|
24097
24411
|
const isGuideEmpty = !hasConversation && activeMode === "guide";
|
|
@@ -24099,11 +24413,11 @@ function EmbeddableChatInner({
|
|
|
24099
24413
|
if (!isQuickActionEmpty && quickActionPreview !== null) setQuickActionPreview(null);
|
|
24100
24414
|
const guideCanReturnToMingo = isGuideEmpty && hasMingoMode;
|
|
24101
24415
|
const sourceLabel = source === "flamingo" ? "Knowledge Base" : "Data Room";
|
|
24102
|
-
const enabledSet =
|
|
24416
|
+
const enabledSet = useMemo30(
|
|
24103
24417
|
() => effectiveEnabledRagTableIds ? new Set(effectiveEnabledRagTableIds) : null,
|
|
24104
24418
|
[effectiveEnabledRagTableIds]
|
|
24105
24419
|
);
|
|
24106
|
-
const chipCommands =
|
|
24420
|
+
const chipCommands = useMemo30(() => {
|
|
24107
24421
|
const out = [];
|
|
24108
24422
|
for (const cmd of commandsById.values()) {
|
|
24109
24423
|
if (cmd.displayOrder === void 0) continue;
|
|
@@ -24119,7 +24433,7 @@ function EmbeddableChatInner({
|
|
|
24119
24433
|
return out;
|
|
24120
24434
|
}, [commandsById, enabledSet]);
|
|
24121
24435
|
const lastAssistantMsg = [...rawMessages].reverse().find((m) => m.role === "assistant");
|
|
24122
|
-
const lastSources =
|
|
24436
|
+
const lastSources = useMemo30(() => {
|
|
24123
24437
|
if (chatLoading) return void 0;
|
|
24124
24438
|
const sources = lastAssistantMsg?.sources;
|
|
24125
24439
|
if (!sources || sources.length === 0) return void 0;
|
|
@@ -24133,28 +24447,25 @@ function EmbeddableChatInner({
|
|
|
24133
24447
|
const uncited = sources.filter((s) => !seenOrder.has(s.index));
|
|
24134
24448
|
return { cited, uncited };
|
|
24135
24449
|
}, [lastAssistantMsg, chatLoading]);
|
|
24136
|
-
const [portalHost, setPortalHost] =
|
|
24137
|
-
const [panelBoundary, setPanelBoundary] =
|
|
24138
|
-
const [panelWidth, setPanelWidth] =
|
|
24139
|
-
|
|
24140
|
-
|
|
24141
|
-
const el = panelMeasureRef.current;
|
|
24142
|
-
if (!el || typeof ResizeObserver === "undefined") return void 0;
|
|
24450
|
+
const [portalHost, setPortalHost] = useState47(null);
|
|
24451
|
+
const [panelBoundary, setPanelBoundary] = useState47(null);
|
|
24452
|
+
const [panelWidth, setPanelWidth] = useState47(0);
|
|
24453
|
+
useEffect38(() => {
|
|
24454
|
+
if (!panelBoundary || typeof ResizeObserver === "undefined") return void 0;
|
|
24143
24455
|
const ro = new ResizeObserver((entries) => {
|
|
24144
24456
|
const w = entries[0]?.contentRect?.width;
|
|
24145
24457
|
if (typeof w === "number") setPanelWidth(w);
|
|
24146
24458
|
});
|
|
24147
|
-
ro.observe(
|
|
24148
|
-
setPanelWidth(el.clientWidth);
|
|
24459
|
+
ro.observe(panelBoundary);
|
|
24149
24460
|
return () => ro.disconnect();
|
|
24150
|
-
}, []);
|
|
24151
|
-
const setPanelNode =
|
|
24152
|
-
panelMeasureRef.current = node;
|
|
24461
|
+
}, [panelBoundary]);
|
|
24462
|
+
const setPanelNode = useCallback27((node) => {
|
|
24153
24463
|
setPanelBoundary(node);
|
|
24464
|
+
if (node) setPanelWidth(node.clientWidth);
|
|
24154
24465
|
}, []);
|
|
24155
|
-
const [railCollapsed, setRailCollapsed] =
|
|
24466
|
+
const [railCollapsed, setRailCollapsed] = useState47(false);
|
|
24156
24467
|
const railStorageHydrated = useIsHydrated();
|
|
24157
|
-
const [railStorageRead, setRailStorageRead] =
|
|
24468
|
+
const [railStorageRead, setRailStorageRead] = useState47(false);
|
|
24158
24469
|
if (railStorageHydrated && !railStorageRead) {
|
|
24159
24470
|
setRailStorageRead(true);
|
|
24160
24471
|
try {
|
|
@@ -24162,7 +24473,7 @@ function EmbeddableChatInner({
|
|
|
24162
24473
|
} catch {
|
|
24163
24474
|
}
|
|
24164
24475
|
}
|
|
24165
|
-
const toggleRailCollapsed =
|
|
24476
|
+
const toggleRailCollapsed = useCallback27(() => {
|
|
24166
24477
|
setRailCollapsed((prev) => {
|
|
24167
24478
|
const next = !prev;
|
|
24168
24479
|
try {
|
|
@@ -24172,17 +24483,18 @@ function EmbeddableChatInner({
|
|
|
24172
24483
|
return next;
|
|
24173
24484
|
});
|
|
24174
24485
|
}, []);
|
|
24175
|
-
const [railSearchOpen, setRailSearchOpen] =
|
|
24176
|
-
const splitEligible =
|
|
24486
|
+
const [railSearchOpen, setRailSearchOpen] = useState47(false);
|
|
24487
|
+
const splitEligible = historyListMode;
|
|
24177
24488
|
const canSplit = panelWidth >= SPLIT_MIN_WIDTH;
|
|
24178
24489
|
const wideMingo = splitEligible && canSplit && !previewMode;
|
|
24179
24490
|
const splitActive = wideMingo && !railCollapsed;
|
|
24180
24491
|
const railPresence = useRailPresence(splitActive);
|
|
24181
24492
|
const showWideHeader = wideMingo || railPresence.mounted;
|
|
24182
|
-
const [composeOpen, setComposeOpen] =
|
|
24493
|
+
const [composeOpen, setComposeOpen] = useState47(false);
|
|
24183
24494
|
if (hasConversation && composeOpen) setComposeOpen(false);
|
|
24184
|
-
const isMingoMode =
|
|
24185
|
-
const
|
|
24495
|
+
const isMingoMode = historyListMode;
|
|
24496
|
+
const guideListIsEmpty = activeMode === "guide" && dialogsManaged === true && dialogs.length === 0 && !dialogsInitialLoading && !mingoCaps.searchQuery;
|
|
24497
|
+
const stackedListView = isMingoMode && !hasConversation && !archiveOpen && !wideMingo && !composeOpen && !guideListIsEmpty;
|
|
24186
24498
|
const headerShowBack = hasConversation || guideCanReturnToMingo;
|
|
24187
24499
|
const headerTitle = hasConversation ? activeDialog?.title || "New Chat" : isGuideEmpty ? headerAssistantName ?? "Mingo Guide" : "Current Chats";
|
|
24188
24500
|
const headerBackAriaLabel = hasConversation ? isViewingArchived ? "Back to archive" : "Back" : "Back to Mingo";
|
|
@@ -24196,7 +24508,7 @@ function EmbeddableChatInner({
|
|
|
24196
24508
|
const headerPersonName = headerOwner?.name?.trim() || headerUserName;
|
|
24197
24509
|
const headerPersonAvatarUrl = headerOwner ? headerOwner.avatarUrl?.trim() || void 0 : identityUser?.avatarUrl?.trim() || userAvatarUrl?.trim() || void 0;
|
|
24198
24510
|
const headerAvatar = headerPersonName || headerPersonAvatarUrl ? { name: headerPersonName, avatarUrl: headerPersonAvatarUrl } : void 0;
|
|
24199
|
-
const handleNewChat =
|
|
24511
|
+
const handleNewChat = useCallback27(() => {
|
|
24200
24512
|
resetToNewChat();
|
|
24201
24513
|
}, [resetToNewChat]);
|
|
24202
24514
|
useImperativeHandle4(
|
|
@@ -24214,10 +24526,12 @@ function EmbeddableChatInner({
|
|
|
24214
24526
|
headerOnRename && { id: "rename", label: "Rename chat", onClick: headerOnRename },
|
|
24215
24527
|
headerOnArchive && { id: "archive", label: "Archive chat", onClick: headerOnArchive }
|
|
24216
24528
|
].filter(Boolean);
|
|
24217
|
-
const narrowMingoEmpty = isMingoMode && !hasConversation && !archiveOpen;
|
|
24529
|
+
const narrowMingoEmpty = isMingoMode && !hasConversation && !archiveOpen && !guideListIsEmpty;
|
|
24218
24530
|
const narrowHeaderProps = narrowMingoEmpty ? composeOpen ? {
|
|
24219
24531
|
showBack: true,
|
|
24220
|
-
|
|
24532
|
+
// Guide's compose view is its own welcome (assistant name), not a
|
|
24533
|
+
// Mingo "New Chat".
|
|
24534
|
+
title: isGuideEmpty ? headerAssistantName ?? "Mingo Guide" : "New Chat",
|
|
24221
24535
|
subtitle: headerUserName,
|
|
24222
24536
|
avatar: headerAvatar,
|
|
24223
24537
|
backAriaLabel: "Back to chats",
|
|
@@ -24334,7 +24648,7 @@ function EmbeddableChatInner({
|
|
|
24334
24648
|
),
|
|
24335
24649
|
/* @__PURE__ */ jsxs75("div", { className: "flex min-w-0 flex-1 items-center gap-[var(--spacing-system-m)] px-[var(--spacing-system-mf)] py-[var(--spacing-system-sf)]", children: [
|
|
24336
24650
|
/* @__PURE__ */ jsxs75("div", { className: "flex min-w-0 flex-col", children: [
|
|
24337
|
-
/* @__PURE__ */ jsx97("p", { className: "truncate leading-tight text-ods-text-primary text-h3", children: headerShowBack ? headerTitle : "New Chat" }),
|
|
24651
|
+
/* @__PURE__ */ jsx97("p", { className: "truncate leading-tight text-ods-text-primary text-h3", children: headerShowBack || isGuideEmpty ? headerTitle : "New Chat" }),
|
|
24338
24652
|
headerPersonName && /* @__PURE__ */ jsx97("p", { className: "truncate leading-tight text-ods-text-secondary text-h6", children: headerPersonName })
|
|
24339
24653
|
] }),
|
|
24340
24654
|
headerAvatar ? (
|
|
@@ -24656,7 +24970,7 @@ function EmbeddableChatInner({
|
|
|
24656
24970
|
resizable: true,
|
|
24657
24971
|
minSize: 480,
|
|
24658
24972
|
maxSize: 1600,
|
|
24659
|
-
defaultSize: drawerDefaultWidth(),
|
|
24973
|
+
defaultSize: drawerDefaultWidth(historyListMode),
|
|
24660
24974
|
storageKey: DRAWER_WIDTH_KEY,
|
|
24661
24975
|
resizeAriaLabel: "Resize chat panel",
|
|
24662
24976
|
overlayClassName: "mingo-chat-overlay",
|
|
@@ -25031,6 +25345,7 @@ export {
|
|
|
25031
25345
|
createChatDialogStore,
|
|
25032
25346
|
createDeltaBatcher,
|
|
25033
25347
|
useChatStreamReducer,
|
|
25348
|
+
createChatConversationsApi,
|
|
25034
25349
|
parseWireCommandOverride,
|
|
25035
25350
|
sanitizeTitleForChat,
|
|
25036
25351
|
formatSingularLookupInvocation,
|
|
@@ -25039,6 +25354,7 @@ export {
|
|
|
25039
25354
|
buildDiscussPrompt,
|
|
25040
25355
|
AUTO_CONTINUATION_DIRECTIVE_PREFIX,
|
|
25041
25356
|
buildAutoContinuationDirective,
|
|
25357
|
+
useManagedDialogList,
|
|
25042
25358
|
useSseChatAdapter,
|
|
25043
25359
|
extractIncompleteMessageState,
|
|
25044
25360
|
extractIncompleteTailState,
|
|
@@ -25063,4 +25379,4 @@ export {
|
|
|
25063
25379
|
buildStreamFrames,
|
|
25064
25380
|
EmbeddableChat
|
|
25065
25381
|
};
|
|
25066
|
-
//# sourceMappingURL=chunk-
|
|
25382
|
+
//# sourceMappingURL=chunk-4HJYXP5O.js.map
|