@flamingo-stack/openframe-frontend-core 0.0.598-2039.5713.1 → 0.0.598
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 +1 -8
- package/dist/chat-protocol/index.cjs.map +1 -1
- package/dist/chat-protocol/index.d.ts +0 -1
- package/dist/chat-protocol/index.d.ts.map +1 -1
- package/dist/chat-protocol/index.js +2 -7
- package/dist/chat-protocol/index.js.map +1 -1
- package/dist/chat-protocol/nats-decoder.d.ts.map +1 -1
- package/dist/{chunk-TSCIVH7T.js → chunk-2JNCZDJR.js} +2 -2
- package/dist/{chunk-6NSGAH5H.cjs → chunk-2SYX2Z7R.cjs} +34 -34
- package/dist/{chunk-6NSGAH5H.cjs.map → chunk-2SYX2Z7R.cjs.map} +1 -1
- package/dist/{chunk-6ZHH37RS.cjs → chunk-3WSS7C2V.cjs} +15 -15
- package/dist/{chunk-6ZHH37RS.cjs.map → chunk-3WSS7C2V.cjs.map} +1 -1
- package/dist/{chunk-5L4ERWSW.js → chunk-75YW6ET4.js} +4 -4
- package/dist/{chunk-VKCETV3C.js → chunk-BK6CCQG6.js} +12 -12
- package/dist/{chunk-HM25MFZX.cjs → chunk-BPVHDDNY.cjs} +8 -8
- package/dist/{chunk-HM25MFZX.cjs.map → chunk-BPVHDDNY.cjs.map} +1 -1
- package/dist/{chunk-VIBREYUK.cjs → chunk-BZEWPW5A.cjs} +3 -3
- package/dist/{chunk-VIBREYUK.cjs.map → chunk-BZEWPW5A.cjs.map} +1 -1
- package/dist/{chunk-KYWU6F3O.cjs → chunk-DAPOBLAK.cjs} +39 -39
- package/dist/{chunk-KYWU6F3O.cjs.map → chunk-DAPOBLAK.cjs.map} +1 -1
- package/dist/{chunk-DHCA5BZP.cjs → chunk-DI3SVVY5.cjs} +85 -85
- package/dist/{chunk-DHCA5BZP.cjs.map → chunk-DI3SVVY5.cjs.map} +1 -1
- package/dist/{chunk-BLUL2TE3.js → chunk-EVMHJB6X.js} +4 -4
- package/dist/{chunk-S6WBBSII.js → chunk-EZM5DNII.js} +3 -3
- package/dist/{chunk-BVQEU5JB.js → chunk-GGQZBSFN.js} +2 -2
- package/dist/{chunk-KTX5B2FW.js → chunk-GHYFVT52.js} +439 -414
- package/dist/chunk-GHYFVT52.js.map +1 -0
- package/dist/{chunk-CCWI3622.cjs → chunk-H64ZHSYR.cjs} +4 -4
- package/dist/{chunk-CCWI3622.cjs.map → chunk-H64ZHSYR.cjs.map} +1 -1
- package/dist/{chunk-4T42D6YG.js → chunk-HLPAVYK7.js} +4 -4
- package/dist/{chunk-HFHBA3VV.cjs → chunk-HWAYIK4U.cjs} +22 -22
- package/dist/{chunk-HFHBA3VV.cjs.map → chunk-HWAYIK4U.cjs.map} +1 -1
- package/dist/{chunk-CF4QJPTN.cjs → chunk-JVZVVZOZ.cjs} +9 -9
- package/dist/{chunk-CF4QJPTN.cjs.map → chunk-JVZVVZOZ.cjs.map} +1 -1
- package/dist/{chunk-XV7RFACE.js → chunk-KHOZ52NR.js} +6 -6
- package/dist/{chunk-IW746HJ7.js → chunk-LRQCKSZC.js} +2 -2
- package/dist/{chunk-JJUV7Z4L.cjs → chunk-M4YQUHOR.cjs} +15 -15
- package/dist/{chunk-JJUV7Z4L.cjs.map → chunk-M4YQUHOR.cjs.map} +1 -1
- package/dist/{chunk-FKBM6U43.js → chunk-MYBXCWEI.js} +2 -2
- package/dist/{chunk-QTPHBCPI.js → chunk-NIAMPMKV.js} +4 -4
- package/dist/{chunk-UXOOVP77.cjs → chunk-O4VZOA2Q.cjs} +3 -3
- package/dist/{chunk-UXOOVP77.cjs.map → chunk-O4VZOA2Q.cjs.map} +1 -1
- package/dist/{chunk-ABNBTPI2.cjs → chunk-P24VPJTT.cjs} +15 -15
- package/dist/{chunk-ABNBTPI2.cjs.map → chunk-P24VPJTT.cjs.map} +1 -1
- package/dist/{chunk-4XPPQDEM.js → chunk-PTK3CINU.js} +5 -5
- package/dist/{chunk-7FUIRGMU.js → chunk-PX4IPM7Q.js} +3 -3
- package/dist/{chunk-NLT5R43J.cjs → chunk-QD64Q4I2.cjs} +9 -9
- package/dist/{chunk-NLT5R43J.cjs.map → chunk-QD64Q4I2.cjs.map} +1 -1
- package/dist/{chunk-TEVP4KNG.cjs → chunk-QIKBISZM.cjs} +522 -497
- package/dist/chunk-QIKBISZM.cjs.map +1 -0
- package/dist/{chunk-FGNUI4CC.js → chunk-R4UV366K.js} +6 -6
- package/dist/{chunk-UPKZU6QU.cjs → chunk-RDTOMWDN.cjs} +1 -1
- package/dist/chunk-RDTOMWDN.cjs.map +1 -0
- package/dist/{chunk-YB6FI2G3.js → chunk-RYXIRVDC.js} +1 -1
- package/dist/chunk-RYXIRVDC.js.map +1 -0
- package/dist/{chunk-QPAPUIF3.cjs → chunk-SAEJGTCI.cjs} +35 -35
- package/dist/{chunk-QPAPUIF3.cjs.map → chunk-SAEJGTCI.cjs.map} +1 -1
- package/dist/{chunk-66HTVTZZ.js → chunk-SE3PVN64.js} +2 -2
- package/dist/{chunk-3IXDZI3R.cjs → chunk-STYNZ4QM.cjs} +3 -3
- package/dist/{chunk-3IXDZI3R.cjs.map → chunk-STYNZ4QM.cjs.map} +1 -1
- package/dist/{chunk-CQRYXSHL.js → chunk-TZPVRWPU.js} +5 -5
- package/dist/{chunk-RU3IKVY2.js → chunk-UAAXUFK6.js} +3 -3
- package/dist/{chunk-F5NEZLTG.cjs → chunk-UE7OFLLS.cjs} +14 -14
- package/dist/{chunk-F5NEZLTG.cjs.map → chunk-UE7OFLLS.cjs.map} +1 -1
- package/dist/{chunk-VUR24QYH.cjs → chunk-UG7JNQZY.cjs} +37 -37
- package/dist/{chunk-VUR24QYH.cjs.map → chunk-UG7JNQZY.cjs.map} +1 -1
- package/dist/{chunk-UQSOFWXP.cjs → chunk-V2QK5W3O.cjs} +3 -3
- package/dist/{chunk-UQSOFWXP.cjs.map → chunk-V2QK5W3O.cjs.map} +1 -1
- package/dist/{chunk-ZABAXD4U.js → chunk-VIRTMRS4.js} +7 -7
- package/dist/{chunk-D565OOXC.cjs → chunk-VLJTJAHJ.cjs} +25 -25
- package/dist/{chunk-D565OOXC.cjs.map → chunk-VLJTJAHJ.cjs.map} +1 -1
- package/dist/{chunk-K5QV7ZAY.js → chunk-VNSRNVPD.js} +437 -756
- package/dist/chunk-VNSRNVPD.js.map +1 -0
- package/dist/{chunk-UQEOAPAI.cjs → chunk-WCBRZCU4.cjs} +9 -9
- package/dist/{chunk-UQEOAPAI.cjs.map → chunk-WCBRZCU4.cjs.map} +1 -1
- package/dist/{chunk-3XFDRL32.js → chunk-WDWCQD75.js} +9 -9
- package/dist/{chunk-QT35C6CW.js → chunk-WPN545FW.js} +12 -12
- package/dist/{chunk-F2KBCLUG.js → chunk-WZJOILPU.js} +2 -2
- package/dist/{chunk-KAADFO74.js → chunk-XNPAVMPB.js} +5 -5
- package/dist/{chunk-5PPYXXUO.cjs → chunk-YBPFIXV4.cjs} +522 -841
- package/dist/chunk-YBPFIXV4.cjs.map +1 -0
- package/dist/{chunk-EHAYNUOL.cjs → chunk-YH6IQTPI.cjs} +3 -3
- package/dist/{chunk-EHAYNUOL.cjs.map → chunk-YH6IQTPI.cjs.map} +1 -1
- package/dist/{chunk-AVAENPVE.cjs → chunk-YWBAIFI2.cjs} +105 -105
- package/dist/{chunk-AVAENPVE.cjs.map → chunk-YWBAIFI2.cjs.map} +1 -1
- 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 +19 -10
- package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
- package/dist/components/chat/hooks/index.d.ts +0 -1
- package/dist/components/chat/hooks/index.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-chat-dialog-manager.d.ts +2 -2
- package/dist/components/chat/hooks/use-chat-dialog-manager.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-chat-history-hydration.d.ts +3 -13
- package/dist/components/chat/hooks/use-chat-history-hydration.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts +16 -2
- 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 +5 -9
- package/dist/components/chat/index.cjs.map +1 -1
- package/dist/components/chat/index.js +4 -8
- package/dist/components/chat/types/unified-chat-state.types.d.ts +6 -67
- package/dist/components/chat/types/unified-chat-state.types.d.ts.map +1 -1
- package/dist/components/chat/utils/index.d.ts +0 -1
- 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 +66 -70
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +22 -26
- 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/data-table/data-table-body.d.ts.map +1 -1
- package/dist/components/ui/data-table/data-table-skeleton.d.ts +31 -0
- package/dist/components/ui/data-table/data-table-skeleton.d.ts.map +1 -1
- package/dist/components/ui/index.cjs +8 -12
- package/dist/components/ui/index.cjs.map +1 -1
- package/dist/components/ui/index.js +7 -11
- package/dist/components/ui/table/table-empty-state.d.ts +1 -1
- package/dist/components/ui/table/table-empty-state.d.ts.map +1 -1
- package/dist/components/ui/table/table-skeleton.d.ts +1 -14
- package/dist/components/ui/table/table-skeleton.d.ts.map +1 -1
- package/dist/components/ui/table/table.d.ts +1 -1
- package/dist/components/ui/table/table.d.ts.map +1 -1
- package/dist/components/ui/table/types.d.ts +33 -6
- package/dist/components/ui/table/types.d.ts.map +1 -1
- package/dist/contexts/chat-runtime-context.d.ts +0 -12
- 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 +12 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/chat-protocol/index.ts +0 -1
- package/src/chat-protocol/nats-decoder.ts +5 -1
- package/src/components/chat/.embeddable-chat.md +2 -4
- package/src/components/chat/embeddable-chat.tsx +84 -131
- package/src/components/chat/hooks/.use-chat-dialog-manager.md +1 -3
- package/src/components/chat/hooks/.use-nats-chat-adapter.md +1 -3
- package/src/components/chat/hooks/.use-sse-chat-adapter.md +1 -8
- package/src/components/chat/hooks/.use-unified-chat.md +2 -2
- package/src/components/chat/hooks/index.ts +0 -2
- package/src/components/chat/hooks/use-chat-dialog-manager.ts +65 -38
- package/src/components/chat/hooks/use-chat-history-hydration.ts +24 -67
- package/src/components/chat/hooks/use-nats-chat-adapter.ts +150 -65
- package/src/components/chat/hooks/use-sse-chat-adapter.ts +59 -233
- package/src/components/chat/hooks/use-unified-chat.ts +0 -5
- package/src/components/chat/types/.unified-chat-state.types.md +1 -13
- package/src/components/chat/types/unified-chat-state.types.ts +6 -74
- package/src/components/chat/utils/index.ts +0 -7
- package/src/components/ui/data-table/data-table-body.tsx +8 -49
- package/src/components/ui/data-table/data-table-skeleton.tsx +100 -0
- package/src/components/ui/table/table-empty-state.tsx +5 -1
- package/src/components/ui/table/table-skeleton.tsx +14 -40
- package/src/components/ui/table/table.tsx +34 -15
- package/src/components/ui/table/types.ts +33 -6
- package/src/contexts/.chat-runtime-context.md +1 -3
- package/src/contexts/chat-runtime-context.tsx +0 -12
- package/dist/chat-protocol/wire-narrow.d.ts +0 -17
- package/dist/chat-protocol/wire-narrow.d.ts.map +0 -1
- package/dist/chunk-5PPYXXUO.cjs.map +0 -1
- package/dist/chunk-K5QV7ZAY.js.map +0 -1
- package/dist/chunk-KTX5B2FW.js.map +0 -1
- package/dist/chunk-TEVP4KNG.cjs.map +0 -1
- package/dist/chunk-UPKZU6QU.cjs.map +0 -1
- package/dist/chunk-YB6FI2G3.js.map +0 -1
- package/dist/components/chat/hooks/use-managed-dialog-list.d.ts +0 -68
- package/dist/components/chat/hooks/use-managed-dialog-list.d.ts.map +0 -1
- package/dist/components/chat/utils/chat-conversations-api.d.ts +0 -29
- package/dist/components/chat/utils/chat-conversations-api.d.ts.map +0 -1
- package/src/chat-protocol/wire-narrow.ts +0 -22
- package/src/components/chat/hooks/.use-managed-dialog-list.md +0 -31
- package/src/components/chat/hooks/__tests__/managed-dialog-list.test.ts +0 -280
- package/src/components/chat/hooks/__tests__/nats-adapter-managed-dialogs.test.ts +0 -172
- package/src/components/chat/hooks/__tests__/sse-managed-dialogs.test.ts +0 -310
- package/src/components/chat/hooks/use-managed-dialog-list.ts +0 -371
- package/src/components/chat/utils/.chat-conversations-api.md +0 -16
- package/src/components/chat/utils/__tests__/chat-conversations-api-golden.test.ts +0 -105
- package/src/components/chat/utils/chat-conversations-api.ts +0 -83
- /package/dist/{chunk-TSCIVH7T.js.map → chunk-2JNCZDJR.js.map} +0 -0
- /package/dist/{chunk-5L4ERWSW.js.map → chunk-75YW6ET4.js.map} +0 -0
- /package/dist/{chunk-VKCETV3C.js.map → chunk-BK6CCQG6.js.map} +0 -0
- /package/dist/{chunk-BLUL2TE3.js.map → chunk-EVMHJB6X.js.map} +0 -0
- /package/dist/{chunk-S6WBBSII.js.map → chunk-EZM5DNII.js.map} +0 -0
- /package/dist/{chunk-BVQEU5JB.js.map → chunk-GGQZBSFN.js.map} +0 -0
- /package/dist/{chunk-4T42D6YG.js.map → chunk-HLPAVYK7.js.map} +0 -0
- /package/dist/{chunk-XV7RFACE.js.map → chunk-KHOZ52NR.js.map} +0 -0
- /package/dist/{chunk-IW746HJ7.js.map → chunk-LRQCKSZC.js.map} +0 -0
- /package/dist/{chunk-FKBM6U43.js.map → chunk-MYBXCWEI.js.map} +0 -0
- /package/dist/{chunk-QTPHBCPI.js.map → chunk-NIAMPMKV.js.map} +0 -0
- /package/dist/{chunk-4XPPQDEM.js.map → chunk-PTK3CINU.js.map} +0 -0
- /package/dist/{chunk-7FUIRGMU.js.map → chunk-PX4IPM7Q.js.map} +0 -0
- /package/dist/{chunk-FGNUI4CC.js.map → chunk-R4UV366K.js.map} +0 -0
- /package/dist/{chunk-66HTVTZZ.js.map → chunk-SE3PVN64.js.map} +0 -0
- /package/dist/{chunk-CQRYXSHL.js.map → chunk-TZPVRWPU.js.map} +0 -0
- /package/dist/{chunk-RU3IKVY2.js.map → chunk-UAAXUFK6.js.map} +0 -0
- /package/dist/{chunk-ZABAXD4U.js.map → chunk-VIRTMRS4.js.map} +0 -0
- /package/dist/{chunk-3XFDRL32.js.map → chunk-WDWCQD75.js.map} +0 -0
- /package/dist/{chunk-QT35C6CW.js.map → chunk-WPN545FW.js.map} +0 -0
- /package/dist/{chunk-F2KBCLUG.js.map → chunk-WZJOILPU.js.map} +0 -0
- /package/dist/{chunk-KAADFO74.js.map → chunk-XNPAVMPB.js.map} +0 -0
|
@@ -170,7 +170,7 @@ import {
|
|
|
170
170
|
safeHref,
|
|
171
171
|
sortBitesByCreatedAtDesc,
|
|
172
172
|
useCoverImageFallback
|
|
173
|
-
} from "./chunk-
|
|
173
|
+
} from "./chunk-UAAXUFK6.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-MYBXCWEI.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-RYXIRVDC.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 useCallback20, useMemo as useMemo25, useRef as useRef28 } from "react";
|
|
17768
17768
|
|
|
17769
17769
|
// src/chat-protocol/confirm-tool.ts
|
|
17770
17770
|
function buildConfirmToolBody(request) {
|
|
@@ -20251,62 +20251,6 @@ 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
|
-
|
|
20310
20254
|
// src/components/chat/utils/slash-dispatch-utils.ts
|
|
20311
20255
|
var WIRE_TABLE_ID_REGEX = /^[a-z][a-z0-9-]*$/;
|
|
20312
20256
|
var WIRE_ID_REGEX = /^[A-Za-z0-9._:/-]+$/;
|
|
@@ -20389,48 +20333,41 @@ function buildAutoContinuationDirective(toolName, opts = {}) {
|
|
|
20389
20333
|
}
|
|
20390
20334
|
|
|
20391
20335
|
// src/components/chat/hooks/use-chat-history-hydration.ts
|
|
20336
|
+
function isRecord(value) {
|
|
20337
|
+
return typeof value === "object" && value !== null;
|
|
20338
|
+
}
|
|
20392
20339
|
function useChatHistoryHydration({
|
|
20393
20340
|
active,
|
|
20394
20341
|
source,
|
|
20395
20342
|
historyUrl,
|
|
20396
|
-
|
|
20343
|
+
conversationIdRef,
|
|
20397
20344
|
sendCountRef,
|
|
20398
20345
|
hydrateMessages,
|
|
20399
|
-
bumpMetaTick
|
|
20400
|
-
onOrphanedConversation
|
|
20346
|
+
bumpMetaTick
|
|
20401
20347
|
}) {
|
|
20402
20348
|
const [isHydratingHistory, setIsHydratingHistory] = useState39(false);
|
|
20403
20349
|
const hydratedKeyRef = useRef27(null);
|
|
20404
|
-
const runIdRef = useRef27(0);
|
|
20405
20350
|
useEffect33(() => {
|
|
20406
|
-
if (!active
|
|
20351
|
+
if (!active) return void 0;
|
|
20352
|
+
const conversationId = conversationIdRef.current;
|
|
20353
|
+
if (!conversationId) return void 0;
|
|
20407
20354
|
const key = `${source}:${conversationId}`;
|
|
20408
|
-
if (hydratedKeyRef.current === key) return
|
|
20355
|
+
if (hydratedKeyRef.current === key) return void 0;
|
|
20409
20356
|
hydratedKeyRef.current = key;
|
|
20410
20357
|
let cancelled = false;
|
|
20411
|
-
let completed = false;
|
|
20412
|
-
const runId = ++runIdRef.current;
|
|
20413
|
-
const isCurrentRun = () => runIdRef.current === runId;
|
|
20414
20358
|
setIsHydratingHistory(true);
|
|
20415
20359
|
void (async () => {
|
|
20416
20360
|
try {
|
|
20417
20361
|
const res = await embedAuthedFetch(`${historyUrl}?conversationId=${encodeURIComponent(conversationId)}`, {
|
|
20418
20362
|
method: "GET"
|
|
20419
20363
|
});
|
|
20420
|
-
if (!res.ok)
|
|
20421
|
-
if (isCurrentRun() && hydratedKeyRef.current === key) hydratedKeyRef.current = null;
|
|
20422
|
-
return;
|
|
20423
|
-
}
|
|
20364
|
+
if (!res.ok) return;
|
|
20424
20365
|
const payload = await res.json().catch(() => null);
|
|
20425
|
-
const
|
|
20366
|
+
const envelope = isRecord(payload) ? payload.data : void 0;
|
|
20367
|
+
const body = envelope ?? payload;
|
|
20426
20368
|
const rawRows = isRecord(body) ? body.messages : void 0;
|
|
20427
20369
|
const rows = Array.isArray(rawRows) ? rawRows.filter(isRecord) : [];
|
|
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
|
-
}
|
|
20370
|
+
if (cancelled || rows.length === 0) return;
|
|
20434
20371
|
const hydrated = [];
|
|
20435
20372
|
const sourcesSeed = /* @__PURE__ */ new Map();
|
|
20436
20373
|
let userTurns = 0;
|
|
@@ -20458,236 +20395,32 @@ function useChatHistoryHydration({
|
|
|
20458
20395
|
hydrateMessages(hydrated, Array.from(sourcesSeed.entries()));
|
|
20459
20396
|
bumpMetaTick();
|
|
20460
20397
|
} catch {
|
|
20461
|
-
if (isCurrentRun() && hydratedKeyRef.current === key) hydratedKeyRef.current = null;
|
|
20462
20398
|
} finally {
|
|
20463
|
-
|
|
20464
|
-
if (isCurrentRun()) setIsHydratingHistory(false);
|
|
20399
|
+
if (!cancelled) setIsHydratingHistory(false);
|
|
20465
20400
|
}
|
|
20466
20401
|
})();
|
|
20467
20402
|
return () => {
|
|
20468
20403
|
cancelled = true;
|
|
20469
|
-
if (!completed && isCurrentRun() && hydratedKeyRef.current === key) hydratedKeyRef.current = null;
|
|
20470
|
-
if (isCurrentRun()) setIsHydratingHistory(false);
|
|
20471
20404
|
};
|
|
20472
|
-
}, [active, source, historyUrl,
|
|
20405
|
+
}, [active, source, historyUrl, hydrateMessages, bumpMetaTick, conversationIdRef, sendCountRef]);
|
|
20473
20406
|
return { isHydratingHistory, hydratedKeyRef };
|
|
20474
20407
|
}
|
|
20475
20408
|
|
|
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
|
-
skeletonDelayMs = 0,
|
|
20486
|
-
search,
|
|
20487
|
-
onDialogRemoved,
|
|
20488
|
-
logTag
|
|
20489
|
-
}) {
|
|
20490
|
-
const [dialogs, setDialogs] = useState40([]);
|
|
20491
|
-
const [dialogsNextCursor, setDialogsNextCursor] = useState40(null);
|
|
20492
|
-
const [isDialogsLoading, setIsDialogsLoading] = useState40(false);
|
|
20493
|
-
const [settledSearch, setSettledSearch] = useState40(
|
|
20494
|
-
autoLoad && fetchDialogs ? void 0 : null
|
|
20495
|
-
);
|
|
20496
|
-
const [autoLoadWas, setAutoLoadWas] = useState40(autoLoad);
|
|
20497
|
-
if (autoLoad !== autoLoadWas) {
|
|
20498
|
-
setAutoLoadWas(autoLoad);
|
|
20499
|
-
if (autoLoad && fetchDialogs) setSettledSearch(void 0);
|
|
20500
|
-
}
|
|
20501
|
-
const [isDialogsPending, setIsDialogsPending] = useState40(false);
|
|
20502
|
-
const pendingRef = useRef28(false);
|
|
20503
|
-
const [dialogsError, setDialogsError] = useState40(false);
|
|
20504
|
-
const dialogsRef = useRef28(dialogs);
|
|
20505
|
-
useEffect34(() => {
|
|
20506
|
-
dialogsRef.current = dialogs;
|
|
20507
|
-
});
|
|
20508
|
-
const onDialogRemovedRef = useRef28(onDialogRemoved);
|
|
20509
|
-
useEffect34(() => {
|
|
20510
|
-
onDialogRemovedRef.current = onDialogRemoved;
|
|
20511
|
-
});
|
|
20512
|
-
const initialDialogsLoadedRef = useRef28(false);
|
|
20513
|
-
const requestIdRef = useRef28(0);
|
|
20514
|
-
const loadDialogsPage = useCallback20(
|
|
20515
|
-
async (cursor) => {
|
|
20516
|
-
if (!fetchDialogs) return;
|
|
20517
|
-
const requestId = ++requestIdRef.current;
|
|
20518
|
-
const isCurrent = () => requestIdRef.current === requestId;
|
|
20519
|
-
pendingRef.current = true;
|
|
20520
|
-
setIsDialogsPending(true);
|
|
20521
|
-
let skeletonTimer;
|
|
20522
|
-
if (cursor === void 0 && skeletonDelayMs > 0) {
|
|
20523
|
-
skeletonTimer = setTimeout(() => {
|
|
20524
|
-
if (isCurrent()) setIsDialogsLoading(true);
|
|
20525
|
-
}, skeletonDelayMs);
|
|
20526
|
-
} else {
|
|
20527
|
-
setIsDialogsLoading(true);
|
|
20528
|
-
}
|
|
20529
|
-
if (cursor === void 0) setDialogsError(false);
|
|
20530
|
-
try {
|
|
20531
|
-
const result = await fetchDialogs({
|
|
20532
|
-
cursor,
|
|
20533
|
-
limit: pageSize,
|
|
20534
|
-
// Only hosts that run a search ever see the key.
|
|
20535
|
-
...search !== void 0 ? { search } : {}
|
|
20536
|
-
});
|
|
20537
|
-
if (!isCurrent()) return;
|
|
20538
|
-
setDialogsNextCursor(result.nextCursor);
|
|
20539
|
-
if (cursor === void 0) {
|
|
20540
|
-
setDialogs(result.dialogs);
|
|
20541
|
-
} else {
|
|
20542
|
-
setDialogs((prev) => {
|
|
20543
|
-
const seen = new Set(prev.map((d) => d.id));
|
|
20544
|
-
return [...prev, ...result.dialogs.filter((d) => !seen.has(d.id))];
|
|
20545
|
-
});
|
|
20546
|
-
}
|
|
20547
|
-
} catch (err) {
|
|
20548
|
-
if (!isCurrent()) return;
|
|
20549
|
-
console.error(`${logTag} fetchDialogs failed:`, err);
|
|
20550
|
-
if (cursor === void 0) {
|
|
20551
|
-
setDialogsError(true);
|
|
20552
|
-
initialDialogsLoadedRef.current = false;
|
|
20553
|
-
}
|
|
20554
|
-
} finally {
|
|
20555
|
-
if (skeletonTimer) clearTimeout(skeletonTimer);
|
|
20556
|
-
if (isCurrent()) {
|
|
20557
|
-
pendingRef.current = false;
|
|
20558
|
-
if (cursor === void 0) setSettledSearch(search ?? null);
|
|
20559
|
-
setIsDialogsLoading(false);
|
|
20560
|
-
setIsDialogsPending(false);
|
|
20561
|
-
}
|
|
20562
|
-
}
|
|
20563
|
-
},
|
|
20564
|
-
[fetchDialogs, pageSize, skeletonDelayMs, search, logTag]
|
|
20565
|
-
);
|
|
20566
|
-
const reloadDialogs = useCallback20(() => {
|
|
20567
|
-
void loadDialogsPage();
|
|
20568
|
-
}, [loadDialogsPage]);
|
|
20569
|
-
const loadedSearchRef = useRef28(void 0);
|
|
20570
|
-
useEffect34(() => {
|
|
20571
|
-
if (!fetchDialogs) return;
|
|
20572
|
-
if (!autoLoad) return;
|
|
20573
|
-
if (initialDialogsLoadedRef.current && loadedSearchRef.current === search) return;
|
|
20574
|
-
initialDialogsLoadedRef.current = true;
|
|
20575
|
-
loadedSearchRef.current = search;
|
|
20576
|
-
void loadDialogsPage();
|
|
20577
|
-
}, [autoLoad, fetchDialogs, search, loadDialogsPage]);
|
|
20578
|
-
const removeLocal = useCallback20((id) => {
|
|
20579
|
-
setDialogs((prev) => prev.filter((d) => d.id !== id));
|
|
20580
|
-
}, []);
|
|
20581
|
-
const deleteDialog = useCallback20(
|
|
20582
|
-
async (id) => {
|
|
20583
|
-
if (!deleteDialogCallback) return;
|
|
20584
|
-
try {
|
|
20585
|
-
await deleteDialogCallback(id);
|
|
20586
|
-
removeLocal(id);
|
|
20587
|
-
onDialogRemovedRef.current?.(id, "deleted");
|
|
20588
|
-
} catch (err) {
|
|
20589
|
-
console.error(`${logTag} deleteDialog failed:`, err);
|
|
20590
|
-
throw err;
|
|
20591
|
-
}
|
|
20592
|
-
},
|
|
20593
|
-
[deleteDialogCallback, removeLocal, logTag]
|
|
20594
|
-
);
|
|
20595
|
-
const renameDialog = useCallback20(
|
|
20596
|
-
async (id, title) => {
|
|
20597
|
-
if (!renameDialogCallback) return;
|
|
20598
|
-
const previous = dialogsRef.current.find((d) => d.id === id)?.title;
|
|
20599
|
-
setDialogs((prev) => prev.map((d) => d.id === id ? { ...d, title } : d));
|
|
20600
|
-
try {
|
|
20601
|
-
await renameDialogCallback(id, title);
|
|
20602
|
-
} catch (err) {
|
|
20603
|
-
console.error(`${logTag} renameDialog failed:`, err);
|
|
20604
|
-
if (previous !== void 0) {
|
|
20605
|
-
setDialogs((prev) => prev.map((d) => d.id === id ? { ...d, title: previous } : d));
|
|
20606
|
-
}
|
|
20607
|
-
throw err;
|
|
20608
|
-
}
|
|
20609
|
-
},
|
|
20610
|
-
[renameDialogCallback, logTag]
|
|
20611
|
-
);
|
|
20612
|
-
const archiveDialog = useCallback20(
|
|
20613
|
-
async (id) => {
|
|
20614
|
-
if (!archiveDialogCallback) return;
|
|
20615
|
-
try {
|
|
20616
|
-
await archiveDialogCallback(id);
|
|
20617
|
-
removeLocal(id);
|
|
20618
|
-
onDialogRemovedRef.current?.(id, "archived");
|
|
20619
|
-
} catch (err) {
|
|
20620
|
-
console.error(`${logTag} archiveDialog failed:`, err);
|
|
20621
|
-
throw err;
|
|
20622
|
-
}
|
|
20623
|
-
},
|
|
20624
|
-
[archiveDialogCallback, removeLocal, logTag]
|
|
20625
|
-
);
|
|
20626
|
-
const loadMoreDialogs = useCallback20(async () => {
|
|
20627
|
-
if (!dialogsNextCursor) return;
|
|
20628
|
-
if (pendingRef.current) return;
|
|
20629
|
-
await loadDialogsPage(dialogsNextCursor);
|
|
20630
|
-
}, [dialogsNextCursor, loadDialogsPage]);
|
|
20631
|
-
const upsertDialogTop = useCallback20((item) => {
|
|
20632
|
-
setDialogs((prev) => [item, ...prev.filter((d) => d.id !== item.id)]);
|
|
20633
|
-
}, []);
|
|
20634
|
-
const removeDialog = removeLocal;
|
|
20635
|
-
const bumpDialogToTop = useCallback20((id) => {
|
|
20636
|
-
setDialogs((prev) => {
|
|
20637
|
-
const row = prev.find((d) => d.id === id);
|
|
20638
|
-
if (!row) return prev;
|
|
20639
|
-
return [{ ...row, timestamp: /* @__PURE__ */ new Date() }, ...prev.filter((d) => d.id !== id)];
|
|
20640
|
-
});
|
|
20641
|
-
}, []);
|
|
20642
|
-
const hasMoreDialogs = dialogsNextCursor != null;
|
|
20643
|
-
const awaitingFirstPage = !!fetchDialogs && settledSearch !== (search ?? null);
|
|
20644
|
-
const dialogsLoading = isDialogsLoading || awaitingFirstPage;
|
|
20645
|
-
return useMemo25(
|
|
20646
|
-
() => ({
|
|
20647
|
-
dialogs,
|
|
20648
|
-
dialogsNextCursor,
|
|
20649
|
-
isDialogsLoading: dialogsLoading,
|
|
20650
|
-
isDialogsPending,
|
|
20651
|
-
dialogsError,
|
|
20652
|
-
hasMoreDialogs,
|
|
20653
|
-
loadDialogsPage,
|
|
20654
|
-
reloadDialogs,
|
|
20655
|
-
loadMoreDialogs,
|
|
20656
|
-
renameDialog,
|
|
20657
|
-
archiveDialog,
|
|
20658
|
-
deleteDialog,
|
|
20659
|
-
upsertDialogTop,
|
|
20660
|
-
removeDialog,
|
|
20661
|
-
bumpDialogToTop
|
|
20662
|
-
}),
|
|
20663
|
-
[
|
|
20664
|
-
dialogs,
|
|
20665
|
-
dialogsNextCursor,
|
|
20666
|
-
dialogsLoading,
|
|
20667
|
-
isDialogsPending,
|
|
20668
|
-
dialogsError,
|
|
20669
|
-
hasMoreDialogs,
|
|
20670
|
-
loadDialogsPage,
|
|
20671
|
-
reloadDialogs,
|
|
20672
|
-
loadMoreDialogs,
|
|
20673
|
-
renameDialog,
|
|
20674
|
-
archiveDialog,
|
|
20675
|
-
deleteDialog,
|
|
20676
|
-
upsertDialogTop,
|
|
20677
|
-
removeDialog,
|
|
20678
|
-
bumpDialogToTop
|
|
20679
|
-
]
|
|
20680
|
-
);
|
|
20681
|
-
}
|
|
20682
|
-
|
|
20683
20409
|
// src/components/chat/hooks/use-sse-chat-adapter.ts
|
|
20410
|
+
var SSE_EMPTY_DIALOGS = [];
|
|
20684
20411
|
var noopSelectDialog = (_id) => {
|
|
20685
20412
|
};
|
|
20686
20413
|
var noopStartNewDialog = () => Promise.resolve(null);
|
|
20687
20414
|
var noopDeleteDialog = async (_id) => {
|
|
20688
20415
|
};
|
|
20416
|
+
var noopRenameDialog = async (_id, _title) => {
|
|
20417
|
+
};
|
|
20418
|
+
var noopArchiveDialog = async (_id) => {
|
|
20419
|
+
};
|
|
20689
20420
|
var noopAsync = async () => {
|
|
20690
20421
|
};
|
|
20422
|
+
var noopReloadDialogs = () => {
|
|
20423
|
+
};
|
|
20691
20424
|
var noopApproveRequest = async (_id) => {
|
|
20692
20425
|
};
|
|
20693
20426
|
var noopRejectRequest = async (_id, _reason) => {
|
|
@@ -20713,10 +20446,10 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
20713
20446
|
const runtime = useRequiredChatRuntime();
|
|
20714
20447
|
const source = runtime.source || DEFAULT_CHAT_SOURCE;
|
|
20715
20448
|
const tableIdForDocumentType = options?.tableIdForDocumentType ?? defaultTableIdForDocumentType;
|
|
20716
|
-
const sendMessageRef =
|
|
20449
|
+
const sendMessageRef = useRef28(
|
|
20717
20450
|
() => Promise.resolve(true)
|
|
20718
20451
|
);
|
|
20719
|
-
const cardResolve =
|
|
20452
|
+
const cardResolve = useCallback20(
|
|
20720
20453
|
(action) => (reqId) => {
|
|
20721
20454
|
if (!reqId) return void 0;
|
|
20722
20455
|
return sendMessageRef.current("", {
|
|
@@ -20726,45 +20459,36 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
20726
20459
|
},
|
|
20727
20460
|
[]
|
|
20728
20461
|
);
|
|
20729
|
-
const cardApprove =
|
|
20730
|
-
const cardReject =
|
|
20731
|
-
const createReducerOptions =
|
|
20462
|
+
const cardApprove = useMemo25(() => cardResolve("approve"), [cardResolve]);
|
|
20463
|
+
const cardReject = useMemo25(() => cardResolve("reject"), [cardResolve]);
|
|
20464
|
+
const createReducerOptions = useCallback20(
|
|
20732
20465
|
() => ({
|
|
20733
20466
|
transport: "sse",
|
|
20734
20467
|
callbacks: { onApprove: cardApprove, onReject: cardReject }
|
|
20735
20468
|
}),
|
|
20736
20469
|
[cardApprove, cardReject]
|
|
20737
20470
|
);
|
|
20738
|
-
const storeRef =
|
|
20471
|
+
const storeRef = useRef28(null);
|
|
20739
20472
|
if (storeRef.current === null) storeRef.current = createChatDialogStore();
|
|
20740
20473
|
const { state, applyEvent, flushDeltas, mutate } = useChatStreamReducer({
|
|
20741
20474
|
store: storeRef.current,
|
|
20742
20475
|
dialogId: source,
|
|
20743
20476
|
createReducerOptions
|
|
20744
20477
|
});
|
|
20745
|
-
const
|
|
20746
|
-
const
|
|
20747
|
-
const
|
|
20478
|
+
const abortControllerRef = useRef28(null);
|
|
20479
|
+
const conversationStorage = useMemo25(() => createChatConversationStorage(source), [source]);
|
|
20480
|
+
const conversationIdRef = useRef28(null);
|
|
20481
|
+
const restoredConversationRef = useRef28(false);
|
|
20748
20482
|
if (!restoredConversationRef.current) {
|
|
20749
20483
|
restoredConversationRef.current = true;
|
|
20750
20484
|
pruneStaleChatConversationStorage(source);
|
|
20751
20485
|
conversationIdRef.current = conversationStorage.load()?.conversationId ?? null;
|
|
20752
20486
|
}
|
|
20753
|
-
const [conversationId, setConversationId] = useState41(() => conversationIdRef.current);
|
|
20754
|
-
const commitConversationId = useCallback21(
|
|
20755
|
-
(id) => {
|
|
20756
|
-
conversationIdRef.current = id;
|
|
20757
|
-
setConversationId(id);
|
|
20758
|
-
if (id) conversationStorage.save({ conversationId: id });
|
|
20759
|
-
else conversationStorage.clear();
|
|
20760
|
-
},
|
|
20761
|
-
[conversationStorage]
|
|
20762
|
-
);
|
|
20763
20487
|
const commandsUrl = runtime.endpoints.commandsUrl;
|
|
20764
20488
|
const { commands: slashCommands } = useSlashCommandRegistry(commandsUrl, {
|
|
20765
20489
|
enabled: active
|
|
20766
20490
|
});
|
|
20767
|
-
const cmdIdByTableId =
|
|
20491
|
+
const cmdIdByTableId = useMemo25(() => {
|
|
20768
20492
|
const buckets = /* @__PURE__ */ new Map();
|
|
20769
20493
|
for (const cmd of slashCommands) {
|
|
20770
20494
|
if (!cmd.primarySourceId) continue;
|
|
@@ -20785,8 +20509,8 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
20785
20509
|
return map;
|
|
20786
20510
|
}, [slashCommands]);
|
|
20787
20511
|
const historyUrl = runtime.endpoints.chatHistoryUrl ?? `${runtime.endpoints.chatStreamUrl.replace(/\/+$/, "")}/history`;
|
|
20788
|
-
const hydrationSendCountRef =
|
|
20789
|
-
const hydrateMessages =
|
|
20512
|
+
const hydrationSendCountRef = useRef28(0);
|
|
20513
|
+
const hydrateMessages = useCallback20(
|
|
20790
20514
|
(history, sourcesSeed) => {
|
|
20791
20515
|
mutate((r) => {
|
|
20792
20516
|
const mapped = history.map(historyMessageToReducerMessage);
|
|
@@ -20807,130 +20531,52 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
20807
20531
|
},
|
|
20808
20532
|
[mutate]
|
|
20809
20533
|
);
|
|
20810
|
-
const messagesLenRef = useRef29(0);
|
|
20811
|
-
messagesLenRef.current = state.messages.length;
|
|
20812
|
-
const onOrphanedConversation = useCallback21(
|
|
20813
|
-
(id) => {
|
|
20814
|
-
if (conversationIdRef.current === id && messagesLenRef.current === 0) commitConversationId(null);
|
|
20815
|
-
},
|
|
20816
|
-
[commitConversationId]
|
|
20817
|
-
);
|
|
20818
20534
|
const { isHydratingHistory, hydratedKeyRef } = useChatHistoryHydration({
|
|
20819
20535
|
active,
|
|
20820
20536
|
source,
|
|
20821
20537
|
historyUrl,
|
|
20822
|
-
|
|
20538
|
+
conversationIdRef,
|
|
20823
20539
|
sendCountRef: hydrationSendCountRef,
|
|
20824
20540
|
hydrateMessages,
|
|
20825
20541
|
// Meta invalidation is a reducer concern here: `seedSseMaps` (inside
|
|
20826
20542
|
// `hydrateMessages` above) already invalidates the snapshot.
|
|
20827
|
-
bumpMetaTick: noopBumpMetaTick
|
|
20828
|
-
// Drop a stored id the server no longer recognizes (deleted, or claimed by
|
|
20829
|
-
// an account while this browser is signed out) — keeping it would stream
|
|
20830
|
-
// answers the server refuses to persist. Guarded on "no live turn yet" so
|
|
20831
|
-
// a just-minted id is never dropped.
|
|
20832
|
-
//
|
|
20833
|
-
// IDENTITY-STABLE by construction: this is a dependency of the hydration
|
|
20834
|
-
// effect, so a callback that changed with the message count would CANCEL
|
|
20835
|
-
// an in-flight hydration the moment the user typed — silently discarding
|
|
20836
|
-
// the thread they just opened. The live count is read through a ref.
|
|
20837
|
-
onOrphanedConversation
|
|
20543
|
+
bumpMetaTick: noopBumpMetaTick
|
|
20838
20544
|
});
|
|
20839
|
-
const
|
|
20840
|
-
const switchConversation = useCallback21(
|
|
20841
|
-
(id) => {
|
|
20842
|
-
abortControllerRef.current?.abort();
|
|
20843
|
-
flushDeltas();
|
|
20844
|
-
mutate((r) => r.reset());
|
|
20845
|
-
hydrationSendCountRef.current = 0;
|
|
20846
|
-
hydratedKeyRef.current = null;
|
|
20847
|
-
commitConversationId(id);
|
|
20848
|
-
},
|
|
20849
|
-
[flushDeltas, mutate, hydratedKeyRef, commitConversationId]
|
|
20850
|
-
);
|
|
20851
|
-
const conversationsUrl = runtime.endpoints.chatConversationsUrl;
|
|
20852
|
-
const conversationsApi = useMemo26(
|
|
20853
|
-
() => conversationsUrl ? createChatConversationsApi(conversationsUrl) : null,
|
|
20854
|
-
[conversationsUrl]
|
|
20855
|
-
);
|
|
20856
|
-
const [dialogSearch, setDialogSearch] = useState41("");
|
|
20857
|
-
const fetchActiveDialogs = useMemo26(
|
|
20858
|
-
() => conversationsApi ? (params) => conversationsApi.fetchDialogs({ ...params, status: "active" }) : void 0,
|
|
20859
|
-
[conversationsApi]
|
|
20860
|
-
);
|
|
20861
|
-
const fetchArchivedDialogs = useMemo26(
|
|
20862
|
-
() => conversationsApi ? (params) => conversationsApi.fetchDialogs({ ...params, status: "archived" }) : void 0,
|
|
20863
|
-
[conversationsApi]
|
|
20864
|
-
);
|
|
20865
|
-
const {
|
|
20866
|
-
dialogs,
|
|
20867
|
-
isDialogsLoading,
|
|
20868
|
-
dialogsError,
|
|
20869
|
-
hasMoreDialogs,
|
|
20870
|
-
reloadDialogs,
|
|
20871
|
-
loadMoreDialogs,
|
|
20872
|
-
renameDialog,
|
|
20873
|
-
archiveDialog,
|
|
20874
|
-
upsertDialogTop,
|
|
20875
|
-
bumpDialogToTop
|
|
20876
|
-
} = useManagedDialogList({
|
|
20877
|
-
autoLoad: active,
|
|
20878
|
-
fetchDialogs: fetchActiveDialogs,
|
|
20879
|
-
renameDialog: conversationsApi?.renameDialog,
|
|
20880
|
-
archiveDialog: conversationsApi?.archiveDialog,
|
|
20881
|
-
pageSize: 20,
|
|
20882
|
-
search: conversationsApi ? dialogSearch : void 0,
|
|
20883
|
-
logTag: "[useSseChatAdapter]",
|
|
20884
|
-
// Archiving the OPEN conversation drops back to the draft state (the
|
|
20885
|
-
// manager also clears the thread; both paths are idempotent).
|
|
20886
|
-
onDialogRemoved: (id) => {
|
|
20887
|
-
if (conversationIdRef.current === id) switchConversation(null);
|
|
20888
|
-
}
|
|
20889
|
-
});
|
|
20890
|
-
const unarchiveDialog = useMemo26(
|
|
20891
|
-
() => conversationsApi ? async (id) => {
|
|
20892
|
-
await conversationsApi.unarchiveDialog(id);
|
|
20893
|
-
reloadDialogs();
|
|
20894
|
-
} : void 0,
|
|
20895
|
-
[conversationsApi, reloadDialogs]
|
|
20896
|
-
);
|
|
20897
|
-
const endpointsRef = useRef29(runtime.endpoints);
|
|
20545
|
+
const endpointsRef = useRef28(runtime.endpoints);
|
|
20898
20546
|
endpointsRef.current = runtime.endpoints;
|
|
20899
|
-
const captureConversationId =
|
|
20547
|
+
const captureConversationId = useCallback20(
|
|
20900
20548
|
(event) => {
|
|
20901
|
-
if (event.type !== "metadata") return
|
|
20549
|
+
if (event.type !== "metadata") return;
|
|
20902
20550
|
const id = event.conversationId;
|
|
20903
|
-
if (typeof id !== "string" || !id) return
|
|
20904
|
-
if (conversationIdRef.current === id) return
|
|
20905
|
-
|
|
20906
|
-
|
|
20907
|
-
return true;
|
|
20551
|
+
if (typeof id !== "string" || !id) return;
|
|
20552
|
+
if (conversationIdRef.current === id) return;
|
|
20553
|
+
conversationIdRef.current = id;
|
|
20554
|
+
conversationStorage.save({ conversationId: id });
|
|
20908
20555
|
},
|
|
20909
|
-
[
|
|
20556
|
+
[conversationStorage]
|
|
20910
20557
|
);
|
|
20911
|
-
const sendMessage =
|
|
20558
|
+
const sendMessage = useCallback20(
|
|
20912
20559
|
// Resolves `true` on a clean turn, `false` when the request failed
|
|
20913
20560
|
// (surfaced to batch approve-all loops via the card callbacks).
|
|
20914
20561
|
async (text, sendOptions) => {
|
|
20915
20562
|
const { hidden, attachments, commandOverride, approvalAction } = sendOptions ?? {};
|
|
20916
|
-
const
|
|
20563
|
+
const conversationId = conversationIdRef.current;
|
|
20917
20564
|
const targetPath = approvalAction ? endpointsRef.current.approvalToolUrl : endpointsRef.current.chatStreamUrl;
|
|
20918
20565
|
const requestBody = approvalAction ? (
|
|
20919
20566
|
// Shared with every other transport that resolves a hub proposal —
|
|
20920
20567
|
// the body shape is the hub's, not this adapter's. `conversationId`
|
|
20921
20568
|
// is always present here: an approval can only happen inside an
|
|
20922
20569
|
// established conversation (the proposal turn captured the id).
|
|
20923
|
-
buildConfirmToolBody({ ...approvalAction, conversationId
|
|
20570
|
+
buildConfirmToolBody({ ...approvalAction, conversationId })
|
|
20924
20571
|
) : {
|
|
20925
20572
|
messages: [{ role: "user", content: text }],
|
|
20926
20573
|
...commandOverride ? { commandOverride } : {},
|
|
20927
20574
|
...attachments && attachments.length > 0 ? { pendingAttachments: attachments } : {},
|
|
20928
|
-
...
|
|
20575
|
+
...conversationId ? { conversationId } : {}
|
|
20929
20576
|
};
|
|
20930
20577
|
mutate((r) => r.beginSseSend({ text, hidden, userName: "You", assistantName: "Mingo AI" }));
|
|
20931
20578
|
const ctrl = new AbortController();
|
|
20932
20579
|
abortControllerRef.current = ctrl;
|
|
20933
|
-
let mintedThisTurn = false;
|
|
20934
20580
|
try {
|
|
20935
20581
|
const response = await embedAuthedFetch(targetPath, {
|
|
20936
20582
|
method: "POST",
|
|
@@ -20951,13 +20597,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
20951
20597
|
if (done) break;
|
|
20952
20598
|
if (ctrl.signal.aborted) break;
|
|
20953
20599
|
for (const event of frameDecoder.push(value)) {
|
|
20954
|
-
|
|
20955
|
-
mintedThisTurn = true;
|
|
20956
|
-
const mintedId = conversationIdRef.current;
|
|
20957
|
-
if (conversationsApi && !hidden && mintedId) {
|
|
20958
|
-
upsertDialogTop({ id: mintedId, title: "New chat", timestamp: /* @__PURE__ */ new Date() });
|
|
20959
|
-
}
|
|
20960
|
-
}
|
|
20600
|
+
captureConversationId(event);
|
|
20961
20601
|
applyEvent(event);
|
|
20962
20602
|
}
|
|
20963
20603
|
}
|
|
@@ -20984,57 +20624,24 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
20984
20624
|
}
|
|
20985
20625
|
flushDeltas();
|
|
20986
20626
|
mutate((r) => r.endSseTurn());
|
|
20987
|
-
if (conversationsApi && !ctrl.signal.aborted) {
|
|
20988
|
-
if (mintedThisTurn) {
|
|
20989
|
-
reloadDialogs();
|
|
20990
|
-
} else if (conversationIdRef.current) {
|
|
20991
|
-
bumpDialogToTop(conversationIdRef.current);
|
|
20992
|
-
}
|
|
20993
|
-
}
|
|
20994
20627
|
}
|
|
20995
20628
|
},
|
|
20996
|
-
[
|
|
20997
|
-
mutate,
|
|
20998
|
-
applyEvent,
|
|
20999
|
-
flushDeltas,
|
|
21000
|
-
captureConversationId,
|
|
21001
|
-
conversationsApi,
|
|
21002
|
-
upsertDialogTop,
|
|
21003
|
-
reloadDialogs,
|
|
21004
|
-
bumpDialogToTop
|
|
21005
|
-
]
|
|
20629
|
+
[mutate, applyEvent, flushDeltas, captureConversationId]
|
|
21006
20630
|
);
|
|
21007
20631
|
sendMessageRef.current = sendMessage;
|
|
21008
|
-
const stopMessage =
|
|
20632
|
+
const stopMessage = useCallback20(() => {
|
|
21009
20633
|
abortControllerRef.current?.abort();
|
|
21010
20634
|
flushDeltas();
|
|
21011
20635
|
mutate((r) => r.setPhase("idle"));
|
|
21012
20636
|
}, [mutate, flushDeltas]);
|
|
21013
|
-
const clearMessages =
|
|
20637
|
+
const clearMessages = useCallback20(() => {
|
|
21014
20638
|
mutate((r) => r.reset());
|
|
21015
|
-
|
|
20639
|
+
conversationIdRef.current = null;
|
|
20640
|
+
conversationStorage.clear();
|
|
21016
20641
|
hydrationSendCountRef.current = 0;
|
|
21017
20642
|
hydratedKeyRef.current = null;
|
|
21018
|
-
}, [mutate,
|
|
21019
|
-
const
|
|
21020
|
-
(id) => {
|
|
21021
|
-
if (id === conversationIdRef.current) return;
|
|
21022
|
-
switchConversation(id);
|
|
21023
|
-
},
|
|
21024
|
-
[switchConversation]
|
|
21025
|
-
);
|
|
21026
|
-
const dialogCapabilities = useMemo26(
|
|
21027
|
-
() => conversationsApi ? {
|
|
21028
|
-
canRename: true,
|
|
21029
|
-
canArchive: true,
|
|
21030
|
-
fetchArchivedDialogs,
|
|
21031
|
-
unarchiveDialog,
|
|
21032
|
-
searchQuery: dialogSearch,
|
|
21033
|
-
onSearchChange: setDialogSearch
|
|
21034
|
-
} : void 0,
|
|
21035
|
-
[conversationsApi, fetchArchivedDialogs, unarchiveDialog, dialogSearch]
|
|
21036
|
-
);
|
|
21037
|
-
const docMessages = useMemo26(() => {
|
|
20643
|
+
}, [mutate, conversationStorage, hydratedKeyRef]);
|
|
20644
|
+
const docMessages = useMemo25(() => {
|
|
21038
20645
|
const { meta, sources: sourcesMap } = state.turnMeta;
|
|
21039
20646
|
let sendIdx = -1;
|
|
21040
20647
|
return state.messages.map((m) => {
|
|
@@ -21061,7 +20668,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21061
20668
|
};
|
|
21062
20669
|
});
|
|
21063
20670
|
}, [state.messages, state.turnMeta]);
|
|
21064
|
-
const displayRef =
|
|
20671
|
+
const displayRef = useCallback20(
|
|
21065
20672
|
(reference) => {
|
|
21066
20673
|
const tableId = tableIdForDocumentType(reference.type);
|
|
21067
20674
|
if (!tableId) {
|
|
@@ -21083,7 +20690,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21083
20690
|
},
|
|
21084
20691
|
[sendMessage, source, cmdIdByTableId, tableIdForDocumentType]
|
|
21085
20692
|
);
|
|
21086
|
-
const discussRef =
|
|
20693
|
+
const discussRef = useCallback20(
|
|
21087
20694
|
(reference) => {
|
|
21088
20695
|
const tableId = tableIdForDocumentType(reference.type);
|
|
21089
20696
|
if (!tableId) {
|
|
@@ -21102,7 +20709,7 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21102
20709
|
},
|
|
21103
20710
|
[sendMessage, tableIdForDocumentType]
|
|
21104
20711
|
);
|
|
21105
|
-
const latestMeta =
|
|
20712
|
+
const latestMeta = useMemo25(() => {
|
|
21106
20713
|
const { meta, sendCount } = state.turnMeta;
|
|
21107
20714
|
return meta.get(sendCount - 1) ?? meta.get(sendCount - 2) ?? null;
|
|
21108
20715
|
}, [state]);
|
|
@@ -21133,30 +20740,26 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21133
20740
|
/** Cross-call usage breakdown (Haiku rewriter/classifier/summarizer
|
|
21134
20741
|
* token counts). null until the trailing usage frame lands. */
|
|
21135
20742
|
currentUsageBreakdown: latestMeta?.breakdown ?? null,
|
|
21136
|
-
// ─── Dialog management
|
|
21137
|
-
//
|
|
21138
|
-
//
|
|
21139
|
-
//
|
|
21140
|
-
//
|
|
21141
|
-
//
|
|
21142
|
-
|
|
21143
|
-
|
|
21144
|
-
|
|
21145
|
-
dialogsError,
|
|
21146
|
-
reloadDialogs,
|
|
21147
|
-
hasMoreDialogs,
|
|
21148
|
-
loadMoreDialogs,
|
|
21149
|
-
renameDialog,
|
|
21150
|
-
archiveDialog,
|
|
21151
|
-
// New chat = `clearMessages` (the server mints on the next send); there is
|
|
21152
|
-
// no create call. Delete is not offered — archive replaces it.
|
|
20743
|
+
// ─── Dialog management — stubs for v1 ────────────────────────────────
|
|
20744
|
+
// Guide mode keeps ONE server-side conversation per stored id
|
|
20745
|
+
// (`chat_conversations`, hydrated on mount). Surfacing multiple threads
|
|
20746
|
+
// as a structured dialog list is a follow-up; for now the shape is
|
|
20747
|
+
// satisfied with empty defaults so the unified contract type-checks and
|
|
20748
|
+
// EmbeddableChat hides sidebar affordances when `dialogs.length === 0`.
|
|
20749
|
+
dialogs: SSE_EMPTY_DIALOGS,
|
|
20750
|
+
activeDialogId: null,
|
|
20751
|
+
selectDialog: noopSelectDialog,
|
|
21153
20752
|
startNewDialog: noopStartNewDialog,
|
|
21154
20753
|
deleteDialog: noopDeleteDialog,
|
|
21155
|
-
|
|
21156
|
-
|
|
21157
|
-
|
|
21158
|
-
|
|
21159
|
-
|
|
20754
|
+
renameDialog: noopRenameDialog,
|
|
20755
|
+
archiveDialog: noopArchiveDialog,
|
|
20756
|
+
isDialogsLoading: false,
|
|
20757
|
+
// SSE/guide has no server-side dialog list — never errors, nothing to retry.
|
|
20758
|
+
dialogsError: false,
|
|
20759
|
+
reloadDialogs: noopReloadDialogs,
|
|
20760
|
+
isMessagesLoading: false,
|
|
20761
|
+
hasMoreDialogs: false,
|
|
20762
|
+
loadMoreDialogs: noopAsync,
|
|
21160
20763
|
hasMoreMessages: false,
|
|
21161
20764
|
loadMoreMessages: noopAsync,
|
|
21162
20765
|
approveRequest: noopApproveRequest,
|
|
@@ -21167,9 +20770,12 @@ function useSseChatAdapter(options, runtimeOptions = {}) {
|
|
|
21167
20770
|
}
|
|
21168
20771
|
|
|
21169
20772
|
// src/components/chat/hooks/use-nats-chat-adapter.ts
|
|
21170
|
-
import { useCallback as
|
|
20773
|
+
import { useCallback as useCallback21, useEffect as useEffect34, useMemo as useMemo26, useRef as useRef29, useState as useState40 } from "react";
|
|
21171
20774
|
|
|
21172
20775
|
// src/chat-protocol/nats-decoder.ts
|
|
20776
|
+
function isRecord2(value) {
|
|
20777
|
+
return typeof value === "object" && value !== null;
|
|
20778
|
+
}
|
|
21173
20779
|
function str(value) {
|
|
21174
20780
|
return typeof value === "string" ? value : void 0;
|
|
21175
20781
|
}
|
|
@@ -21182,7 +20788,7 @@ function numOr(value, fallback = 0) {
|
|
|
21182
20788
|
}
|
|
21183
20789
|
function normalizeToolCalls(raw) {
|
|
21184
20790
|
if (!Array.isArray(raw)) return [];
|
|
21185
|
-
return raw.filter(
|
|
20791
|
+
return raw.filter(isRecord2).map((item) => ({
|
|
21186
20792
|
toolExecutionRequestId: String(item.toolExecutionRequestId ?? ""),
|
|
21187
20793
|
toolName: String(item.toolName ?? ""),
|
|
21188
20794
|
toolTitle: typeof item.toolTitle === "string" ? item.toolTitle : void 0,
|
|
@@ -21190,12 +20796,12 @@ function normalizeToolCalls(raw) {
|
|
|
21190
20796
|
toolType: typeof item.toolType === "string" ? item.toolType : void 0,
|
|
21191
20797
|
requiresApproval: item.requiresApproval === true,
|
|
21192
20798
|
approvalType: typeof item.approvalType === "string" ? item.approvalType : null,
|
|
21193
|
-
toolCallArguments:
|
|
20799
|
+
toolCallArguments: isRecord2(item.toolCallArguments) ? item.toolCallArguments : null
|
|
21194
20800
|
}));
|
|
21195
20801
|
}
|
|
21196
20802
|
function normalizeAskOptions(raw) {
|
|
21197
20803
|
if (!Array.isArray(raw)) return [];
|
|
21198
|
-
return raw.filter(
|
|
20804
|
+
return raw.filter(isRecord2).map((item) => ({
|
|
21199
20805
|
label: typeof item.label === "string" ? item.label.trim() : "",
|
|
21200
20806
|
description: typeof item.description === "string" ? item.description : void 0
|
|
21201
20807
|
})).filter((option) => option.label.length > 0);
|
|
@@ -21264,7 +20870,7 @@ function decodeNatsChunk(chunk) {
|
|
|
21264
20870
|
// the EXECUTING segment held. Dropping it here therefore blanks the
|
|
21265
20871
|
// card for the whole lifetime of the run.
|
|
21266
20872
|
toolExplanation: typeof data.toolExplanation === "string" ? data.toolExplanation : void 0,
|
|
21267
|
-
parameters:
|
|
20873
|
+
parameters: isRecord2(data.parameters) ? data.parameters : void 0,
|
|
21268
20874
|
toolExecutionRequestId: typeof data.toolExecutionRequestId === "string" ? data.toolExecutionRequestId : void 0
|
|
21269
20875
|
},
|
|
21270
20876
|
...seq
|
|
@@ -21277,7 +20883,7 @@ function decodeNatsChunk(chunk) {
|
|
|
21277
20883
|
integratedToolType: strOr(data.integratedToolType),
|
|
21278
20884
|
toolFunction: strOr(data.toolFunction),
|
|
21279
20885
|
toolTitle: typeof data.title === "string" ? data.title : void 0,
|
|
21280
|
-
parameters:
|
|
20886
|
+
parameters: isRecord2(data.parameters) ? data.parameters : void 0,
|
|
21281
20887
|
result: str(data.result),
|
|
21282
20888
|
success: typeof data.success === "boolean" ? data.success : void 0,
|
|
21283
20889
|
toolExecutionRequestId: typeof data.toolExecutionRequestId === "string" ? data.toolExecutionRequestId : void 0
|
|
@@ -22142,8 +21748,6 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22142
21748
|
deleteDialog: deleteDialogCallback,
|
|
22143
21749
|
renameDialog: renameDialogCallback,
|
|
22144
21750
|
archiveDialog: archiveDialogCallback,
|
|
22145
|
-
fetchArchivedDialogs,
|
|
22146
|
-
unarchiveDialog,
|
|
22147
21751
|
approveRequest: approveRequestCallback,
|
|
22148
21752
|
rejectRequest: rejectRequestCallback,
|
|
22149
21753
|
stopGeneration: stopGenerationCallback,
|
|
@@ -22155,26 +21759,26 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22155
21759
|
modelLabel = null
|
|
22156
21760
|
} = config;
|
|
22157
21761
|
const isManagedMode = fetchDialogs !== void 0;
|
|
22158
|
-
const [internalDialogId, setInternalDialogId] =
|
|
21762
|
+
const [internalDialogId, setInternalDialogId] = useState40(null);
|
|
22159
21763
|
const dialogId = isManagedMode ? internalDialogId : controlledDialogId !== void 0 ? controlledDialogId : null;
|
|
22160
|
-
const currentDialogIdRef =
|
|
22161
|
-
|
|
21764
|
+
const currentDialogIdRef = useRef29(dialogId);
|
|
21765
|
+
useEffect34(() => {
|
|
22162
21766
|
currentDialogIdRef.current = dialogId;
|
|
22163
21767
|
});
|
|
22164
|
-
const handleApproveRef =
|
|
21768
|
+
const handleApproveRef = useRef29(async () => {
|
|
22165
21769
|
});
|
|
22166
|
-
const handleRejectRef =
|
|
21770
|
+
const handleRejectRef = useRef29(async () => {
|
|
22167
21771
|
});
|
|
22168
|
-
const accumApprove =
|
|
21772
|
+
const accumApprove = useCallback21((requestId) => {
|
|
22169
21773
|
if (!requestId) return void 0;
|
|
22170
21774
|
return handleApproveRef.current(requestId);
|
|
22171
21775
|
}, []);
|
|
22172
|
-
const accumReject =
|
|
21776
|
+
const accumReject = useCallback21((requestId) => {
|
|
22173
21777
|
if (!requestId) return void 0;
|
|
22174
21778
|
return handleRejectRef.current(requestId);
|
|
22175
21779
|
}, []);
|
|
22176
|
-
const [dialogStore] =
|
|
22177
|
-
const [globalApprovalStatuses] =
|
|
21780
|
+
const [dialogStore] = useState40(() => createChatDialogStore());
|
|
21781
|
+
const [globalApprovalStatuses] = useState40(() => ({}));
|
|
22178
21782
|
const dialogKey = dialogId ?? DRAFT_DIALOG_KEY;
|
|
22179
21783
|
const { state, applyEvent, mutate } = useChatStreamReducer({
|
|
22180
21784
|
store: dialogStore,
|
|
@@ -22187,10 +21791,10 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22187
21791
|
callbacks: { onApprove: accumApprove, onReject: accumReject }
|
|
22188
21792
|
})
|
|
22189
21793
|
});
|
|
22190
|
-
|
|
21794
|
+
useEffect34(() => {
|
|
22191
21795
|
Object.assign(globalApprovalStatuses, state.approvalStatuses);
|
|
22192
21796
|
}, [globalApprovalStatuses, state.approvalStatuses]);
|
|
22193
|
-
|
|
21797
|
+
useEffect34(() => {
|
|
22194
21798
|
handleApproveRef.current = async (requestId) => {
|
|
22195
21799
|
if (!approveRequestCallback) return;
|
|
22196
21800
|
const key = dialogKey;
|
|
@@ -22222,44 +21826,22 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22222
21826
|
}
|
|
22223
21827
|
};
|
|
22224
21828
|
});
|
|
22225
|
-
const processChunk =
|
|
21829
|
+
const processChunk = useCallback21(
|
|
22226
21830
|
(chunk) => {
|
|
22227
21831
|
const event = decodeNatsChunk(chunk);
|
|
22228
21832
|
if (event) applyEvent(event);
|
|
22229
21833
|
},
|
|
22230
21834
|
[applyEvent]
|
|
22231
21835
|
);
|
|
22232
|
-
const [
|
|
22233
|
-
const
|
|
22234
|
-
|
|
22235
|
-
|
|
22236
|
-
|
|
22237
|
-
|
|
22238
|
-
|
|
22239
|
-
|
|
22240
|
-
|
|
22241
|
-
archiveDialog,
|
|
22242
|
-
deleteDialog,
|
|
22243
|
-
upsertDialogTop
|
|
22244
|
-
} = useManagedDialogList({
|
|
22245
|
-
autoLoad: active,
|
|
22246
|
-
fetchDialogs,
|
|
22247
|
-
renameDialog: renameDialogCallback,
|
|
22248
|
-
archiveDialog: archiveDialogCallback,
|
|
22249
|
-
deleteDialog: deleteDialogCallback,
|
|
22250
|
-
pageSize: dialogsPageSize,
|
|
22251
|
-
logTag: "[useNatsChatAdapter]",
|
|
22252
|
-
onDialogRemoved: (id, reason) => {
|
|
22253
|
-
if (reason === "deleted") dialogStore.remove(id);
|
|
22254
|
-
if (isManagedMode && internalDialogId === id) {
|
|
22255
|
-
setInternalDialogId(null);
|
|
22256
|
-
}
|
|
22257
|
-
}
|
|
22258
|
-
});
|
|
22259
|
-
const [messagesNextCursor, setMessagesNextCursor] = useState42(null);
|
|
22260
|
-
const [isMessagesLoading, setIsMessagesLoading] = useState42(false);
|
|
22261
|
-
const [connectedForDialog, setConnectedForDialog] = useState42(null);
|
|
22262
|
-
const hasConnectedOnceRef = useRef30(false);
|
|
21836
|
+
const [dialogs, setDialogs] = useState40([]);
|
|
21837
|
+
const [dialogsNextCursor, setDialogsNextCursor] = useState40(null);
|
|
21838
|
+
const [isDialogsLoading, setIsDialogsLoading] = useState40(false);
|
|
21839
|
+
const [dialogsError, setDialogsError] = useState40(false);
|
|
21840
|
+
const [isCreatingDialog, setIsCreatingDialog] = useState40(false);
|
|
21841
|
+
const [messagesNextCursor, setMessagesNextCursor] = useState40(null);
|
|
21842
|
+
const [isMessagesLoading, setIsMessagesLoading] = useState40(false);
|
|
21843
|
+
const [connectedForDialog, setConnectedForDialog] = useState40(null);
|
|
21844
|
+
const hasConnectedOnceRef = useRef29(false);
|
|
22263
21845
|
const {
|
|
22264
21846
|
processChunk: catchupProcessChunk,
|
|
22265
21847
|
catchUpChunks,
|
|
@@ -22272,8 +21854,8 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22272
21854
|
onChunkReceived: (chunk) => processChunk(chunk),
|
|
22273
21855
|
fetchChunks
|
|
22274
21856
|
});
|
|
22275
|
-
const historyLoadSeqRef =
|
|
22276
|
-
const loadDialogHistory =
|
|
21857
|
+
const historyLoadSeqRef = useRef29(0);
|
|
21858
|
+
const loadDialogHistory = useCallback21(
|
|
22277
21859
|
async (id, cursor) => {
|
|
22278
21860
|
if (!fetchDialogMessages) return;
|
|
22279
21861
|
historyLoadSeqRef.current += 1;
|
|
@@ -22331,8 +21913,8 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22331
21913
|
isBufferingActive
|
|
22332
21914
|
]
|
|
22333
21915
|
);
|
|
22334
|
-
const prevDialogIdRef =
|
|
22335
|
-
|
|
21916
|
+
const prevDialogIdRef = useRef29(void 0);
|
|
21917
|
+
useEffect34(() => {
|
|
22336
21918
|
if (prevDialogIdRef.current === dialogId) return;
|
|
22337
21919
|
prevDialogIdRef.current = dialogId;
|
|
22338
21920
|
historyLoadSeqRef.current += 1;
|
|
@@ -22345,7 +21927,7 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22345
21927
|
if (!active || !dialogId) return;
|
|
22346
21928
|
void loadDialogHistory(dialogId);
|
|
22347
21929
|
}, [active, dialogId, dialogKey, dialogStore, globalApprovalStatuses, loadDialogHistory]);
|
|
22348
|
-
|
|
21930
|
+
useEffect34(() => {
|
|
22349
21931
|
if (!active || !dialogId) return;
|
|
22350
21932
|
const store = dialogStore;
|
|
22351
21933
|
store.mutate(dialogId, DEFAULT_DIALOG_SIDE, (r) => r.adjustAgentBusySuppression(1));
|
|
@@ -22405,7 +21987,46 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22405
21987
|
}
|
|
22406
21988
|
});
|
|
22407
21989
|
const connectionState = !active || !dialogId ? "connected" : connectedForDialog === dialogId ? "connected" : "connecting";
|
|
22408
|
-
const
|
|
21990
|
+
const initialDialogsLoadedRef = useRef29(false);
|
|
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(
|
|
22409
22030
|
async (text, sendOptions) => {
|
|
22410
22031
|
const hidden = sendOptions?.hidden ?? false;
|
|
22411
22032
|
mutate((r) => r.pushOptimisticSend(text, hidden));
|
|
@@ -22413,7 +22034,7 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22413
22034
|
},
|
|
22414
22035
|
[mutate, publishUserMessage, dialogId]
|
|
22415
22036
|
);
|
|
22416
|
-
const stopMessage =
|
|
22037
|
+
const stopMessage = useCallback21(() => {
|
|
22417
22038
|
mutate((r) => r.setPhase("idle"));
|
|
22418
22039
|
if (stopGenerationCallback && dialogId) {
|
|
22419
22040
|
void stopGenerationCallback(dialogId).catch((err) => {
|
|
@@ -22421,10 +22042,10 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22421
22042
|
});
|
|
22422
22043
|
}
|
|
22423
22044
|
}, [mutate, stopGenerationCallback, dialogId]);
|
|
22424
|
-
const clearMessages =
|
|
22045
|
+
const clearMessages = useCallback21(() => {
|
|
22425
22046
|
mutate((r) => r.clearThread());
|
|
22426
22047
|
}, [mutate]);
|
|
22427
|
-
const selectDialog =
|
|
22048
|
+
const selectDialog = useCallback21(
|
|
22428
22049
|
(id) => {
|
|
22429
22050
|
if (!isManagedMode) {
|
|
22430
22051
|
return;
|
|
@@ -22433,17 +22054,20 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22433
22054
|
},
|
|
22434
22055
|
[isManagedMode]
|
|
22435
22056
|
);
|
|
22436
|
-
const startNewDialog =
|
|
22057
|
+
const startNewDialog = useCallback21(async () => {
|
|
22437
22058
|
if (!createDialogCallback) return null;
|
|
22438
22059
|
if (isCreatingDialog) return null;
|
|
22439
22060
|
try {
|
|
22440
22061
|
setIsCreatingDialog(true);
|
|
22441
22062
|
const result = await createDialogCallback();
|
|
22442
|
-
|
|
22443
|
-
|
|
22444
|
-
|
|
22445
|
-
|
|
22446
|
-
|
|
22063
|
+
setDialogs((prev) => [
|
|
22064
|
+
{
|
|
22065
|
+
id: result.dialogId,
|
|
22066
|
+
title: "New Chat",
|
|
22067
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
22068
|
+
},
|
|
22069
|
+
...prev.filter((d) => d.id !== result.dialogId)
|
|
22070
|
+
]);
|
|
22447
22071
|
if (isManagedMode) {
|
|
22448
22072
|
setInternalDialogId(result.dialogId);
|
|
22449
22073
|
}
|
|
@@ -22454,18 +22078,76 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22454
22078
|
} finally {
|
|
22455
22079
|
setIsCreatingDialog(false);
|
|
22456
22080
|
}
|
|
22457
|
-
}, [createDialogCallback, isCreatingDialog, isManagedMode
|
|
22458
|
-
const
|
|
22081
|
+
}, [createDialogCallback, isCreatingDialog, isManagedMode]);
|
|
22082
|
+
const deleteDialog = useCallback21(
|
|
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 () => {
|
|
22459
22141
|
if (!dialogId || !messagesNextCursor) return;
|
|
22460
22142
|
await loadDialogHistory(dialogId, messagesNextCursor);
|
|
22461
22143
|
}, [dialogId, messagesNextCursor, loadDialogHistory]);
|
|
22462
|
-
const approveRequest =
|
|
22144
|
+
const approveRequest = useCallback21(async (requestId) => {
|
|
22463
22145
|
await handleApproveRef.current(requestId);
|
|
22464
22146
|
}, []);
|
|
22465
|
-
const rejectRequest =
|
|
22147
|
+
const rejectRequest = useCallback21(async (requestId, reason) => {
|
|
22466
22148
|
await handleRejectRef.current(requestId, reason);
|
|
22467
22149
|
}, []);
|
|
22468
|
-
const discussRef =
|
|
22150
|
+
const discussRef = useCallback21(
|
|
22469
22151
|
(reference) => {
|
|
22470
22152
|
const prompt = buildDiscussPrompt(reference, { includeReference: true });
|
|
22471
22153
|
void sendMessage(prompt).catch((err) => {
|
|
@@ -22476,17 +22158,9 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22476
22158
|
);
|
|
22477
22159
|
const { messages, streamingPhase, dialogTokenUsage = null, liveModel = null } = state;
|
|
22478
22160
|
const isLoading = streamingPhase !== "idle";
|
|
22161
|
+
const hasMoreDialogs = dialogsNextCursor != null;
|
|
22479
22162
|
const hasMoreMessages = messagesNextCursor != null;
|
|
22480
|
-
|
|
22481
|
-
() => isManagedMode ? {
|
|
22482
|
-
canRename: !!renameDialogCallback,
|
|
22483
|
-
canArchive: !!archiveDialogCallback,
|
|
22484
|
-
fetchArchivedDialogs,
|
|
22485
|
-
unarchiveDialog
|
|
22486
|
-
} : void 0,
|
|
22487
|
-
[isManagedMode, renameDialogCallback, archiveDialogCallback, fetchArchivedDialogs, unarchiveDialog]
|
|
22488
|
-
);
|
|
22489
|
-
return useMemo27(
|
|
22163
|
+
return useMemo26(
|
|
22490
22164
|
() => ({
|
|
22491
22165
|
messages,
|
|
22492
22166
|
isLoading,
|
|
@@ -22523,8 +22197,6 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22523
22197
|
loadMoreDialogs,
|
|
22524
22198
|
hasMoreMessages,
|
|
22525
22199
|
loadMoreMessages,
|
|
22526
|
-
dialogsManaged: isManagedMode,
|
|
22527
|
-
dialogCapabilities,
|
|
22528
22200
|
// Approval mutations
|
|
22529
22201
|
approveRequest,
|
|
22530
22202
|
rejectRequest,
|
|
@@ -22557,8 +22229,6 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22557
22229
|
loadMoreDialogs,
|
|
22558
22230
|
hasMoreMessages,
|
|
22559
22231
|
loadMoreMessages,
|
|
22560
|
-
isManagedMode,
|
|
22561
|
-
dialogCapabilities,
|
|
22562
22232
|
approveRequest,
|
|
22563
22233
|
rejectRequest,
|
|
22564
22234
|
dialogTokenUsage,
|
|
@@ -22571,7 +22241,7 @@ function useNatsChatAdapter(config, options = {}) {
|
|
|
22571
22241
|
}
|
|
22572
22242
|
|
|
22573
22243
|
// src/components/chat/hooks/use-unified-chat.ts
|
|
22574
|
-
import { useCallback as
|
|
22244
|
+
import { useCallback as useCallback22, useEffect as useEffect35, useMemo as useMemo27, useRef as useRef30, useState as useState41 } from "react";
|
|
22575
22245
|
var EMPTY_SSE_OPTIONS = {};
|
|
22576
22246
|
function createDisabledNatsConfig() {
|
|
22577
22247
|
return {
|
|
@@ -22586,7 +22256,7 @@ function createDisabledNatsConfig() {
|
|
|
22586
22256
|
}
|
|
22587
22257
|
function useUnifiedChat(options) {
|
|
22588
22258
|
const { modes, activeMode, mingoStateOverride } = options;
|
|
22589
|
-
const [disabledNatsConfig] =
|
|
22259
|
+
const [disabledNatsConfig] = useState41(createDisabledNatsConfig);
|
|
22590
22260
|
const sseActive = activeMode === "guide" && modes.guide !== void 0;
|
|
22591
22261
|
const natsActive = activeMode === "mingo" && modes.mingo !== void 0;
|
|
22592
22262
|
const sseState = useSseChatAdapter(modes.guide ?? EMPTY_SSE_OPTIONS, {
|
|
@@ -22594,40 +22264,40 @@ function useUnifiedChat(options) {
|
|
|
22594
22264
|
});
|
|
22595
22265
|
const natsState = useNatsChatAdapter(modes.mingo ?? disabledNatsConfig, { active: natsActive });
|
|
22596
22266
|
const activeState = activeMode === "guide" ? sseState : mingoStateOverride ?? natsState;
|
|
22597
|
-
const activeStateRef =
|
|
22598
|
-
|
|
22267
|
+
const activeStateRef = useRef30(activeState);
|
|
22268
|
+
useEffect35(() => {
|
|
22599
22269
|
activeStateRef.current = activeState;
|
|
22600
22270
|
});
|
|
22601
|
-
const stopMessage =
|
|
22602
|
-
const clearMessages =
|
|
22603
|
-
const sendMessage =
|
|
22271
|
+
const stopMessage = useCallback22(() => activeStateRef.current.stopMessage(), []);
|
|
22272
|
+
const clearMessages = useCallback22(() => activeStateRef.current.clearMessages(), []);
|
|
22273
|
+
const sendMessage = useCallback22(
|
|
22604
22274
|
(text, opts) => activeStateRef.current.sendMessage(text, opts),
|
|
22605
22275
|
[]
|
|
22606
22276
|
);
|
|
22607
|
-
const discussRef =
|
|
22277
|
+
const discussRef = useCallback22(
|
|
22608
22278
|
(ref) => activeStateRef.current.discussRef(ref),
|
|
22609
22279
|
[]
|
|
22610
22280
|
);
|
|
22611
|
-
const displayRefForward =
|
|
22281
|
+
const displayRefForward = useCallback22(
|
|
22612
22282
|
(ref) => activeStateRef.current.displayRef?.(ref),
|
|
22613
22283
|
[]
|
|
22614
22284
|
);
|
|
22615
22285
|
const displayRef = activeState.displayRef ? displayRefForward : void 0;
|
|
22616
|
-
const selectDialog =
|
|
22617
|
-
const startNewDialog =
|
|
22618
|
-
const deleteDialog =
|
|
22619
|
-
const renameDialog =
|
|
22620
|
-
const archiveDialog =
|
|
22621
|
-
const loadMoreDialogs =
|
|
22622
|
-
const setDialogScope =
|
|
22623
|
-
const reloadDialogs =
|
|
22624
|
-
const loadMoreMessages =
|
|
22625
|
-
const approveRequest =
|
|
22626
|
-
const rejectRequest =
|
|
22286
|
+
const selectDialog = useCallback22((id) => activeStateRef.current.selectDialog(id), []);
|
|
22287
|
+
const startNewDialog = useCallback22(() => activeStateRef.current.startNewDialog(), []);
|
|
22288
|
+
const deleteDialog = useCallback22((id) => activeStateRef.current.deleteDialog(id), []);
|
|
22289
|
+
const renameDialog = useCallback22((id, title) => activeStateRef.current.renameDialog(id, title), []);
|
|
22290
|
+
const archiveDialog = useCallback22((id) => activeStateRef.current.archiveDialog(id), []);
|
|
22291
|
+
const loadMoreDialogs = useCallback22(() => activeStateRef.current.loadMoreDialogs(), []);
|
|
22292
|
+
const setDialogScope = useCallback22((scope) => activeStateRef.current.setDialogScope?.(scope), []);
|
|
22293
|
+
const reloadDialogs = useCallback22(() => activeStateRef.current.reloadDialogs(), []);
|
|
22294
|
+
const loadMoreMessages = useCallback22(() => activeStateRef.current.loadMoreMessages(), []);
|
|
22295
|
+
const approveRequest = useCallback22((requestId) => activeStateRef.current.approveRequest(requestId), []);
|
|
22296
|
+
const rejectRequest = useCallback22(
|
|
22627
22297
|
(requestId, reason) => activeStateRef.current.rejectRequest(requestId, reason),
|
|
22628
22298
|
[]
|
|
22629
22299
|
);
|
|
22630
|
-
return
|
|
22300
|
+
return useMemo27(
|
|
22631
22301
|
() => ({
|
|
22632
22302
|
messages: activeState.messages,
|
|
22633
22303
|
isLoading: activeState.isLoading,
|
|
@@ -22664,11 +22334,6 @@ function useUnifiedChat(options) {
|
|
|
22664
22334
|
setDialogScope,
|
|
22665
22335
|
hasMoreMessages: activeState.hasMoreMessages,
|
|
22666
22336
|
loadMoreMessages,
|
|
22667
|
-
// Adapter-owned dialog list flag + capabilities (SSE with a
|
|
22668
|
-
// conversations endpoint, NATS managed mode). Forwarded verbatim —
|
|
22669
|
-
// `EmbeddableChat` gates the history UI on them.
|
|
22670
|
-
dialogsManaged: activeState.dialogsManaged,
|
|
22671
|
-
dialogCapabilities: activeState.dialogCapabilities,
|
|
22672
22337
|
// Approvals
|
|
22673
22338
|
approveRequest,
|
|
22674
22339
|
rejectRequest,
|
|
@@ -22988,7 +22653,7 @@ import { VisuallyHidden } from "@radix-ui/react-visually-hidden";
|
|
|
22988
22653
|
import { usePreventScroll } from "@react-aria/overlays";
|
|
22989
22654
|
import { isIOS } from "@react-aria/utils";
|
|
22990
22655
|
import { MessageSquare as MessageSquare3 } from "lucide-react";
|
|
22991
|
-
import React10, { useCallback as
|
|
22656
|
+
import React10, { useCallback as useCallback26, useEffect as useEffect37, useImperativeHandle as useImperativeHandle4, useMemo as useMemo29, useRef as useRef34, useState as useState45 } from "react";
|
|
22992
22657
|
|
|
22993
22658
|
// src/components/ui/drawer.tsx
|
|
22994
22659
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
@@ -22996,10 +22661,10 @@ import { cva as cva2 } from "class-variance-authority";
|
|
|
22996
22661
|
import { X } from "lucide-react";
|
|
22997
22662
|
import {
|
|
22998
22663
|
forwardRef as forwardRef26,
|
|
22999
|
-
useCallback as
|
|
23000
|
-
useEffect as
|
|
23001
|
-
useRef as
|
|
23002
|
-
useState as
|
|
22664
|
+
useCallback as useCallback23,
|
|
22665
|
+
useEffect as useEffect36,
|
|
22666
|
+
useRef as useRef31,
|
|
22667
|
+
useState as useState42
|
|
23003
22668
|
} from "react";
|
|
23004
22669
|
import { jsx as jsx95, jsxs as jsxs73 } from "react/jsx-runtime";
|
|
23005
22670
|
var OVERLAY_BACKDROP_CLASS = "bg-ods-overlay";
|
|
@@ -23093,7 +22758,7 @@ function viewportSize(isHorizontal) {
|
|
|
23093
22758
|
return isHorizontal ? window.innerWidth : window.innerHeight;
|
|
23094
22759
|
}
|
|
23095
22760
|
function useResizableSize({ enabled, isHorizontal, minSize, maxSize, defaultSize, storageKey }) {
|
|
23096
|
-
const clampToViewport =
|
|
22761
|
+
const clampToViewport = useCallback23(
|
|
23097
22762
|
(value) => {
|
|
23098
22763
|
const vp = viewportSize(isHorizontal);
|
|
23099
22764
|
const effectiveMax = vp > 0 ? Math.min(maxSize, vp - 80) : maxSize;
|
|
@@ -23101,7 +22766,7 @@ function useResizableSize({ enabled, isHorizontal, minSize, maxSize, defaultSize
|
|
|
23101
22766
|
},
|
|
23102
22767
|
[isHorizontal, minSize, maxSize]
|
|
23103
22768
|
);
|
|
23104
|
-
const readInitial =
|
|
22769
|
+
const readInitial = useCallback23(() => {
|
|
23105
22770
|
if (!enabled) return defaultSize;
|
|
23106
22771
|
if (typeof window === "undefined") return defaultSize;
|
|
23107
22772
|
if (!storageKey) return clampToViewport(defaultSize);
|
|
@@ -23115,16 +22780,16 @@ function useResizableSize({ enabled, isHorizontal, minSize, maxSize, defaultSize
|
|
|
23115
22780
|
return clampToViewport(defaultSize);
|
|
23116
22781
|
}
|
|
23117
22782
|
}, [enabled, storageKey, defaultSize, clampToViewport]);
|
|
23118
|
-
const [size2, setSizeRaw] =
|
|
23119
|
-
const setSize =
|
|
23120
|
-
|
|
22783
|
+
const [size2, setSizeRaw] = useState42(readInitial);
|
|
22784
|
+
const setSize = useCallback23((next) => setSizeRaw(clampToViewport(next)), [clampToViewport]);
|
|
22785
|
+
useEffect36(() => {
|
|
23121
22786
|
if (!enabled || !storageKey || typeof window === "undefined") return;
|
|
23122
22787
|
try {
|
|
23123
22788
|
window.localStorage.setItem(storageKey, String(Math.round(size2)));
|
|
23124
22789
|
} catch {
|
|
23125
22790
|
}
|
|
23126
22791
|
}, [enabled, size2, storageKey]);
|
|
23127
|
-
|
|
22792
|
+
useEffect36(() => {
|
|
23128
22793
|
if (!enabled || typeof window === "undefined") return void 0;
|
|
23129
22794
|
const onResize = () => setSizeRaw((prev) => clampToViewport(prev));
|
|
23130
22795
|
window.addEventListener("resize", onResize);
|
|
@@ -23134,7 +22799,7 @@ function useResizableSize({ enabled, isHorizontal, minSize, maxSize, defaultSize
|
|
|
23134
22799
|
}
|
|
23135
22800
|
function DrawerResizeHandle({ side, size: size2, minSize, maxSize, onSize, ariaLabel }) {
|
|
23136
22801
|
const isHorizontal = HORIZONTAL_SIDES.has(side);
|
|
23137
|
-
const startRef =
|
|
22802
|
+
const startRef = useRef31(null);
|
|
23138
22803
|
const direction = side === "right" || side === "bottom" ? -1 : 1;
|
|
23139
22804
|
const handlePointerDown = (e) => {
|
|
23140
22805
|
if (e.button !== 0 && e.pointerType === "mouse") return;
|
|
@@ -23239,8 +22904,8 @@ var DrawerContent = forwardRef26(
|
|
|
23239
22904
|
const isHorizontal = HORIZONTAL_SIDES.has(resolvedSide);
|
|
23240
22905
|
const initialSize = defaultSize ?? (isHorizontal ? 560 : 480);
|
|
23241
22906
|
const headerHeight = useHeaderHeight();
|
|
23242
|
-
const [isMobile, setIsMobile] =
|
|
23243
|
-
|
|
22907
|
+
const [isMobile, setIsMobile] = useState42(false);
|
|
22908
|
+
useEffect36(() => {
|
|
23244
22909
|
if (typeof window === "undefined") return void 0;
|
|
23245
22910
|
const mq = window.matchMedia(`(max-width: ${mobileBreakpoint - 1}px)`);
|
|
23246
22911
|
const update = () => setIsMobile(mq.matches);
|
|
@@ -23330,7 +22995,7 @@ var DrawerFooter = ({ className, ...props }) => /* @__PURE__ */ jsx95("div", { c
|
|
|
23330
22995
|
DrawerFooter.displayName = "DrawerFooter";
|
|
23331
22996
|
|
|
23332
22997
|
// src/components/ui/hover-dropdown.tsx
|
|
23333
|
-
import { useState as
|
|
22998
|
+
import { useState as useState43, useRef as useRef32, useCallback as useCallback24 } from "react";
|
|
23334
22999
|
import { Fragment as Fragment33, jsx as jsx96, jsxs as jsxs74 } from "react/jsx-runtime";
|
|
23335
23000
|
function DefaultAnchor({ href, className, children }) {
|
|
23336
23001
|
return /* @__PURE__ */ jsx96("a", { href, className, children });
|
|
@@ -23343,10 +23008,10 @@ function HoverDropdown({
|
|
|
23343
23008
|
className,
|
|
23344
23009
|
renderAnchor
|
|
23345
23010
|
}) {
|
|
23346
|
-
const [open, setOpen] =
|
|
23347
|
-
const timeoutRef =
|
|
23348
|
-
const containerRef =
|
|
23349
|
-
const panelRef =
|
|
23011
|
+
const [open, setOpen] = useState43(false);
|
|
23012
|
+
const timeoutRef = useRef32(void 0);
|
|
23013
|
+
const containerRef = useRef32(null);
|
|
23014
|
+
const panelRef = useRef32(null);
|
|
23350
23015
|
useIsomorphicLayoutEffect(() => {
|
|
23351
23016
|
const el = panelRef.current;
|
|
23352
23017
|
const container = containerRef.current;
|
|
@@ -23374,14 +23039,14 @@ function HoverDropdown({
|
|
|
23374
23039
|
}
|
|
23375
23040
|
}
|
|
23376
23041
|
});
|
|
23377
|
-
const show =
|
|
23042
|
+
const show = useCallback24(() => {
|
|
23378
23043
|
clearTimeout(timeoutRef.current);
|
|
23379
23044
|
setOpen(true);
|
|
23380
23045
|
}, []);
|
|
23381
|
-
const hide =
|
|
23046
|
+
const hide = useCallback24(() => {
|
|
23382
23047
|
timeoutRef.current = setTimeout(() => setOpen(false), hideDelay);
|
|
23383
23048
|
}, [hideDelay]);
|
|
23384
|
-
const toggle =
|
|
23049
|
+
const toggle = useCallback24((e) => {
|
|
23385
23050
|
e.stopPropagation();
|
|
23386
23051
|
clearTimeout(timeoutRef.current);
|
|
23387
23052
|
setOpen((prev) => !prev);
|
|
@@ -23447,7 +23112,7 @@ function HoverDropdown({
|
|
|
23447
23112
|
}
|
|
23448
23113
|
|
|
23449
23114
|
// src/components/chat/hooks/use-chat-dialog-manager.ts
|
|
23450
|
-
import { useCallback as
|
|
23115
|
+
import { useCallback as useCallback25, useMemo as useMemo28, useRef as useRef33, useState as useState44 } from "react";
|
|
23451
23116
|
function useChatDialogManager({
|
|
23452
23117
|
dialogs,
|
|
23453
23118
|
activeDialogId,
|
|
@@ -23458,23 +23123,17 @@ function useChatDialogManager({
|
|
|
23458
23123
|
fetchArchivedDialogs,
|
|
23459
23124
|
unarchiveDialog
|
|
23460
23125
|
}) {
|
|
23461
|
-
const [renameTarget, setRenameTarget] =
|
|
23462
|
-
const [archiveTarget, setArchiveTarget] =
|
|
23463
|
-
const handleConfirmRename =
|
|
23464
|
-
|
|
23465
|
-
if (
|
|
23466
|
-
try {
|
|
23467
|
-
await renameDialog(renameTarget.id, name);
|
|
23468
|
-
} catch (err) {
|
|
23469
|
-
console.error("[useChatDialogManager] rename failed:", err);
|
|
23470
|
-
return;
|
|
23471
|
-
}
|
|
23126
|
+
const [renameTarget, setRenameTarget] = useState44(null);
|
|
23127
|
+
const [archiveTarget, setArchiveTarget] = useState44(null);
|
|
23128
|
+
const handleConfirmRename = useCallback25(
|
|
23129
|
+
(name) => {
|
|
23130
|
+
if (renameTarget) void renameDialog(renameTarget.id, name);
|
|
23472
23131
|
setRenameTarget(null);
|
|
23473
23132
|
},
|
|
23474
23133
|
[renameTarget, renameDialog]
|
|
23475
23134
|
);
|
|
23476
|
-
const [openingDialogId, setOpeningDialogId] =
|
|
23477
|
-
const handleConfirmArchive =
|
|
23135
|
+
const [openingDialogId, setOpeningDialogId] = useState44(null);
|
|
23136
|
+
const handleConfirmArchive = useCallback25(async () => {
|
|
23478
23137
|
if (archiveTarget) {
|
|
23479
23138
|
try {
|
|
23480
23139
|
await archiveDialog(archiveTarget.id);
|
|
@@ -23489,32 +23148,52 @@ function useChatDialogManager({
|
|
|
23489
23148
|
}
|
|
23490
23149
|
setArchiveTarget(null);
|
|
23491
23150
|
}, [archiveTarget, archiveDialog, activeDialogId, clearMessages]);
|
|
23492
|
-
const [archiveOpen, setArchiveOpen] =
|
|
23493
|
-
const
|
|
23494
|
-
|
|
23495
|
-
|
|
23496
|
-
|
|
23497
|
-
|
|
23498
|
-
|
|
23499
|
-
|
|
23500
|
-
|
|
23501
|
-
|
|
23502
|
-
|
|
23503
|
-
|
|
23504
|
-
|
|
23505
|
-
|
|
23506
|
-
|
|
23507
|
-
|
|
23508
|
-
|
|
23509
|
-
|
|
23510
|
-
|
|
23511
|
-
|
|
23151
|
+
const [archiveOpen, setArchiveOpen] = useState44(false);
|
|
23152
|
+
const [archivedDialogs, setArchivedDialogs] = useState44([]);
|
|
23153
|
+
const [archivedCursor, setArchivedCursor] = useState44(null);
|
|
23154
|
+
const [archivedLoading, setArchivedLoading] = useState44(false);
|
|
23155
|
+
const [archivedPending, setArchivedPending] = useState44(false);
|
|
23156
|
+
const archivedRequestIdRef = useRef33(0);
|
|
23157
|
+
const loadArchivedPage = useCallback25(
|
|
23158
|
+
async (cursor) => {
|
|
23159
|
+
if (!fetchArchivedDialogs) return;
|
|
23160
|
+
const requestId = ++archivedRequestIdRef.current;
|
|
23161
|
+
const isCurrent = () => archivedRequestIdRef.current === requestId;
|
|
23162
|
+
const isInitial = !cursor;
|
|
23163
|
+
setArchivedPending(true);
|
|
23164
|
+
let skeletonTimer;
|
|
23165
|
+
if (isInitial) {
|
|
23166
|
+
skeletonTimer = setTimeout(() => {
|
|
23167
|
+
if (isCurrent()) setArchivedLoading(true);
|
|
23168
|
+
}, 120);
|
|
23169
|
+
} else {
|
|
23170
|
+
setArchivedLoading(true);
|
|
23171
|
+
}
|
|
23172
|
+
try {
|
|
23173
|
+
const result = await fetchArchivedDialogs({ cursor, limit: 20 });
|
|
23174
|
+
if (!isCurrent()) return;
|
|
23175
|
+
setArchivedCursor(result.nextCursor);
|
|
23176
|
+
setArchivedDialogs((prev) => cursor ? [...prev, ...result.dialogs] : result.dialogs);
|
|
23177
|
+
} catch (err) {
|
|
23178
|
+
if (!isCurrent()) return;
|
|
23179
|
+
console.error("[useChatDialogManager] fetchArchivedDialogs failed:", err);
|
|
23180
|
+
} finally {
|
|
23181
|
+
if (skeletonTimer) clearTimeout(skeletonTimer);
|
|
23182
|
+
if (isCurrent()) {
|
|
23183
|
+
setArchivedLoading(false);
|
|
23184
|
+
setArchivedPending(false);
|
|
23185
|
+
}
|
|
23186
|
+
}
|
|
23187
|
+
},
|
|
23188
|
+
[fetchArchivedDialogs]
|
|
23189
|
+
);
|
|
23190
|
+
const openArchive = useCallback25(() => {
|
|
23512
23191
|
setArchiveOpen(true);
|
|
23513
23192
|
void loadArchivedPage();
|
|
23514
23193
|
}, [loadArchivedPage]);
|
|
23515
|
-
const closeArchive =
|
|
23516
|
-
const [viewingArchivedId, setViewingArchivedId] =
|
|
23517
|
-
const handleSelectDialog =
|
|
23194
|
+
const closeArchive = useCallback25(() => setArchiveOpen(false), []);
|
|
23195
|
+
const [viewingArchivedId, setViewingArchivedId] = useState44(null);
|
|
23196
|
+
const handleSelectDialog = useCallback25(
|
|
23518
23197
|
(id) => {
|
|
23519
23198
|
setViewingArchivedId(null);
|
|
23520
23199
|
setOpeningDialogId(id);
|
|
@@ -23523,7 +23202,7 @@ function useChatDialogManager({
|
|
|
23523
23202
|
[selectDialog]
|
|
23524
23203
|
);
|
|
23525
23204
|
const isOpeningDialog = openingDialogId != null && openingDialogId === activeDialogId;
|
|
23526
|
-
const handleArchivedSelect =
|
|
23205
|
+
const handleArchivedSelect = useCallback25(
|
|
23527
23206
|
(id) => {
|
|
23528
23207
|
setArchiveOpen(false);
|
|
23529
23208
|
setOpeningDialogId(null);
|
|
@@ -23532,8 +23211,8 @@ function useChatDialogManager({
|
|
|
23532
23211
|
},
|
|
23533
23212
|
[selectDialog]
|
|
23534
23213
|
);
|
|
23535
|
-
const [restoreTarget, setRestoreTarget] =
|
|
23536
|
-
const handleConfirmRestore =
|
|
23214
|
+
const [restoreTarget, setRestoreTarget] = useState44(null);
|
|
23215
|
+
const handleConfirmRestore = useCallback25(async () => {
|
|
23537
23216
|
if (restoreTarget) {
|
|
23538
23217
|
try {
|
|
23539
23218
|
await unarchiveDialog?.(restoreTarget.id);
|
|
@@ -23541,13 +23220,13 @@ function useChatDialogManager({
|
|
|
23541
23220
|
console.error("[useChatDialogManager] unarchive failed:", err);
|
|
23542
23221
|
return;
|
|
23543
23222
|
}
|
|
23544
|
-
|
|
23223
|
+
setArchivedDialogs((prev) => prev.filter((d) => d.id !== restoreTarget.id));
|
|
23545
23224
|
setViewingArchivedId((cur) => cur === restoreTarget.id ? null : cur);
|
|
23546
23225
|
}
|
|
23547
23226
|
setRestoreTarget(null);
|
|
23548
|
-
}, [restoreTarget, unarchiveDialog
|
|
23227
|
+
}, [restoreTarget, unarchiveDialog]);
|
|
23549
23228
|
const isViewingArchived = viewingArchivedId != null && viewingArchivedId === activeDialogId;
|
|
23550
|
-
const handleBack =
|
|
23229
|
+
const handleBack = useCallback25(() => {
|
|
23551
23230
|
const wasArchived = isViewingArchived;
|
|
23552
23231
|
setViewingArchivedId(null);
|
|
23553
23232
|
setOpeningDialogId(null);
|
|
@@ -23555,14 +23234,14 @@ function useChatDialogManager({
|
|
|
23555
23234
|
clearMessages();
|
|
23556
23235
|
if (wasArchived) setArchiveOpen(true);
|
|
23557
23236
|
}, [isViewingArchived, selectDialog, clearMessages]);
|
|
23558
|
-
const resetToNewChat =
|
|
23237
|
+
const resetToNewChat = useCallback25(() => {
|
|
23559
23238
|
setViewingArchivedId(null);
|
|
23560
23239
|
setOpeningDialogId(null);
|
|
23561
23240
|
selectDialog(null);
|
|
23562
23241
|
clearMessages();
|
|
23563
23242
|
setArchiveOpen(false);
|
|
23564
23243
|
}, [selectDialog, clearMessages]);
|
|
23565
|
-
const activeDialog =
|
|
23244
|
+
const activeDialog = useMemo28(
|
|
23566
23245
|
() => dialogs.find((d) => d.id === activeDialogId) ?? archivedDialogs.find((d) => d.id === activeDialogId),
|
|
23567
23246
|
[dialogs, archivedDialogs, activeDialogId]
|
|
23568
23247
|
);
|
|
@@ -23603,18 +23282,12 @@ function useChatDialogManager({
|
|
|
23603
23282
|
|
|
23604
23283
|
// src/components/chat/embeddable-chat.tsx
|
|
23605
23284
|
import { Fragment as Fragment34, jsx as jsx97, jsxs as jsxs75 } from "react/jsx-runtime";
|
|
23606
|
-
var HISTORY_RAIL_WIDTH = 320;
|
|
23607
|
-
var CHAT_BLOCK_MIN_WIDTH = 400;
|
|
23608
|
-
var SPLIT_MIN_WIDTH = HISTORY_RAIL_WIDTH + CHAT_BLOCK_MIN_WIDTH;
|
|
23609
23285
|
var DRAWER_DEFAULT_WIDTH_RATIO = 0.5;
|
|
23610
|
-
var DRAWER_WIDTH_KEY = "mingo-chat-width-
|
|
23286
|
+
var DRAWER_WIDTH_KEY = "mingo-chat-width-v3";
|
|
23611
23287
|
var DRAWER_DEFAULT_WIDTH_PX = 750;
|
|
23612
|
-
|
|
23613
|
-
function drawerDefaultWidth(withHistoryRail) {
|
|
23288
|
+
function drawerDefaultWidth() {
|
|
23614
23289
|
if (typeof window === "undefined") return DRAWER_DEFAULT_WIDTH_PX;
|
|
23615
|
-
|
|
23616
|
-
if (!withHistoryRail) return ratioWidth;
|
|
23617
|
-
return Math.max(ratioWidth, SPLIT_MIN_WIDTH + SPLIT_DEFAULT_WIDTH_ALLOWANCE);
|
|
23290
|
+
return Math.round(window.innerWidth * DRAWER_DEFAULT_WIDTH_RATIO);
|
|
23618
23291
|
}
|
|
23619
23292
|
var formatRelativePath = (p) => p.replace(/^\/+/, "").replace(/\/+$/, "");
|
|
23620
23293
|
var mentionTokenOf = (key, markerByType) => {
|
|
@@ -23624,15 +23297,18 @@ var mentionTokenOf = (key, markerByType) => {
|
|
|
23624
23297
|
return `${markerByType.get(type) ?? type.toLowerCase()}:${id}`;
|
|
23625
23298
|
};
|
|
23626
23299
|
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;
|
|
23627
23303
|
var RAIL_COLLAPSED_STORAGE_KEY = "mingo-chat-history-collapsed";
|
|
23628
23304
|
var NO_CONTEXT_ITEMS = [];
|
|
23629
23305
|
var RAIL_ANIM_MS = 320;
|
|
23630
23306
|
function useRailPresence(open) {
|
|
23631
|
-
const [mounted, setMounted] =
|
|
23632
|
-
const [active, setActive] =
|
|
23307
|
+
const [mounted, setMounted] = useState45(open);
|
|
23308
|
+
const [active, setActive] = useState45(false);
|
|
23633
23309
|
if (open && !mounted) setMounted(true);
|
|
23634
23310
|
if (!open && active) setActive(false);
|
|
23635
|
-
|
|
23311
|
+
useEffect37(() => {
|
|
23636
23312
|
if (open) {
|
|
23637
23313
|
let raf2 = 0;
|
|
23638
23314
|
const raf1 = requestAnimationFrame(() => {
|
|
@@ -23848,7 +23524,7 @@ function SourceChips({
|
|
|
23848
23524
|
onClose,
|
|
23849
23525
|
onDiscuss
|
|
23850
23526
|
}) {
|
|
23851
|
-
const [expanded, setExpanded] =
|
|
23527
|
+
const [expanded, setExpanded] = useState45(false);
|
|
23852
23528
|
if (cited.length === 0) {
|
|
23853
23529
|
const fallback = uncited.slice(0, FALLBACK_TOP_RETRIEVED);
|
|
23854
23530
|
if (fallback.length === 0) return null;
|
|
@@ -23955,7 +23631,7 @@ function EmbeddableChatInner({
|
|
|
23955
23631
|
const commandsUrl = runtime.endpoints.commandsUrl;
|
|
23956
23632
|
const { attachmentsEnabled, user: identityUser } = useChatIdentity();
|
|
23957
23633
|
const viewUrlPrefix = runtime.endpoints.attachmentViewUrlPrefix;
|
|
23958
|
-
|
|
23634
|
+
useEffect37(() => {
|
|
23959
23635
|
if (process.env.NODE_ENV !== "production") {
|
|
23960
23636
|
const hasOpen = open !== void 0;
|
|
23961
23637
|
const hasHandler = onOpenChange !== void 0;
|
|
@@ -23971,13 +23647,13 @@ function EmbeddableChatInner({
|
|
|
23971
23647
|
defaultProp: defaultOpen ?? false,
|
|
23972
23648
|
onChange: onOpenChange
|
|
23973
23649
|
});
|
|
23974
|
-
const [autoFocusInput] =
|
|
23650
|
+
const [autoFocusInput] = useState45(() => {
|
|
23975
23651
|
if (typeof window === "undefined") return false;
|
|
23976
23652
|
return !window.matchMedia("(pointer: coarse)").matches;
|
|
23977
23653
|
});
|
|
23978
23654
|
usePreventScroll({ isDisabled: !isOpen || shellLess });
|
|
23979
23655
|
const navigatingAwayRef = useRef34(false);
|
|
23980
|
-
|
|
23656
|
+
useEffect37(() => {
|
|
23981
23657
|
if (!isOpen) return void 0;
|
|
23982
23658
|
if (shellLess) return void 0;
|
|
23983
23659
|
if (typeof window === "undefined") return void 0;
|
|
@@ -24004,8 +23680,8 @@ function EmbeddableChatInner({
|
|
|
24004
23680
|
};
|
|
24005
23681
|
}, [isOpen, shellLess]);
|
|
24006
23682
|
const chatInputRef = useRef34(null);
|
|
24007
|
-
const [quickActionPreview, setQuickActionPreview] =
|
|
24008
|
-
const slashCommandsProp =
|
|
23683
|
+
const [quickActionPreview, setQuickActionPreview] = useState45(null);
|
|
23684
|
+
const slashCommandsProp = useMemo29(
|
|
24009
23685
|
() => ({
|
|
24010
23686
|
fetchCommands: (prefix, signal) => fetchSlashCommands(prefix, signal, commandsUrl),
|
|
24011
23687
|
resolveSourceIcon: (sourceId) => {
|
|
@@ -24020,16 +23696,38 @@ function EmbeddableChatInner({
|
|
|
24020
23696
|
[commandsUrl]
|
|
24021
23697
|
);
|
|
24022
23698
|
const headerUserName = identityUser?.name?.trim() || [identityUser?.firstName, identityUser?.lastName].filter(Boolean).join(" ").trim() || userDisplayName?.trim() || void 0;
|
|
24023
|
-
const effectiveModes =
|
|
23699
|
+
const effectiveModes = useMemo29(() => {
|
|
24024
23700
|
if (modes) return modes;
|
|
24025
23701
|
const guideOptions = tableIdForDocumentType ? { tableIdForDocumentType } : {};
|
|
24026
23702
|
return { guide: guideOptions };
|
|
24027
23703
|
}, [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]);
|
|
24028
23726
|
const hasMingoMode = !!effectiveModes.mingo || !!mingoState;
|
|
24029
23727
|
const initialActiveMode = controlledActiveMode ?? defaultActiveMode ?? (effectiveModes.guide ? "guide" : "mingo");
|
|
24030
|
-
const [uncontrolledActiveMode, setUncontrolledActiveMode] =
|
|
23728
|
+
const [uncontrolledActiveMode, setUncontrolledActiveMode] = useState45(initialActiveMode);
|
|
24031
23729
|
const activeMode = controlledActiveMode ?? uncontrolledActiveMode;
|
|
24032
|
-
const handleActiveModeChange =
|
|
23730
|
+
const handleActiveModeChange = useCallback26(
|
|
24033
23731
|
(next) => {
|
|
24034
23732
|
if (controlledActiveMode === void 0) {
|
|
24035
23733
|
setUncontrolledActiveMode(next);
|
|
@@ -24041,7 +23739,7 @@ function EmbeddableChatInner({
|
|
|
24041
23739
|
const { commands: commandsList, loaded: commandsLoaded } = useSlashCommandRegistry(commandsUrl, {
|
|
24042
23740
|
enabled: activeMode === "guide"
|
|
24043
23741
|
});
|
|
24044
|
-
const commandsById =
|
|
23742
|
+
const commandsById = useMemo29(() => {
|
|
24045
23743
|
const map = /* @__PURE__ */ new Map();
|
|
24046
23744
|
for (const cmd of commandsList) map.set(cmd.id, cmd);
|
|
24047
23745
|
return map;
|
|
@@ -24055,7 +23753,7 @@ function EmbeddableChatInner({
|
|
|
24055
23753
|
const effectiveGreeting = emptyStateConfig.greeting ?? emptyStateGreeting;
|
|
24056
23754
|
const effectiveEnabledRagTableIds = emptyStateUrl ? emptyStateConfig.enabledRagTableIds : enabledRagTableIds;
|
|
24057
23755
|
const effectiveSuggestedQueries = emptyStateUrl ? emptyStateConfig.suggestedQueries : suggestedQueries;
|
|
24058
|
-
const effectiveQuickActions =
|
|
23756
|
+
const effectiveQuickActions = useMemo29(
|
|
24059
23757
|
() => emptyStateUrl ? emptyStateConfig.quickActions : [],
|
|
24060
23758
|
[emptyStateUrl, emptyStateConfig.quickActions]
|
|
24061
23759
|
);
|
|
@@ -24092,26 +23790,10 @@ function EmbeddableChatInner({
|
|
|
24092
23790
|
dialogScope,
|
|
24093
23791
|
setDialogScope,
|
|
24094
23792
|
hasMoreMessages,
|
|
24095
|
-
loadMoreMessages
|
|
24096
|
-
dialogsManaged,
|
|
24097
|
-
dialogCapabilities
|
|
23793
|
+
loadMoreMessages
|
|
24098
23794
|
} = useUnifiedChat({ modes: effectiveModes, activeMode, mingoStateOverride: mingoState });
|
|
24099
|
-
const historyListMode = activeMode === "mingo" || dialogsManaged === true;
|
|
24100
|
-
const mingoCaps = useMemo30(() => {
|
|
24101
|
-
const caps = dialogCapabilities ?? (mingoState ? mingoDialogCapabilities : {
|
|
24102
|
-
canRename: !!effectiveModes.mingo?.renameDialog,
|
|
24103
|
-
canArchive: !!effectiveModes.mingo?.archiveDialog,
|
|
24104
|
-
fetchArchivedDialogs: effectiveModes.mingo?.fetchArchivedDialogs,
|
|
24105
|
-
unarchiveDialog: effectiveModes.mingo?.unarchiveDialog
|
|
24106
|
-
});
|
|
24107
|
-
return {
|
|
24108
|
-
...caps,
|
|
24109
|
-
canRename: caps?.canRename ?? false,
|
|
24110
|
-
canArchive: caps?.canArchive ?? false
|
|
24111
|
-
};
|
|
24112
|
-
}, [dialogCapabilities, mingoState, mingoDialogCapabilities, effectiveModes]);
|
|
24113
23795
|
const guidePromptSentRef = useRef34(false);
|
|
24114
|
-
|
|
23796
|
+
useEffect37(() => {
|
|
24115
23797
|
if (!guidePendingPrompt) {
|
|
24116
23798
|
guidePromptSentRef.current = false;
|
|
24117
23799
|
return;
|
|
@@ -24134,35 +23816,35 @@ function EmbeddableChatInner({
|
|
|
24134
23816
|
const { panelRef: galleryPanelRef, modal: galleryModal } = useChatAttachmentImageGallery();
|
|
24135
23817
|
const contextMaxItems = contextPicker?.maxItems ?? 10;
|
|
24136
23818
|
const contextPickerForMode = activeMode === "mingo" ? contextPicker : void 0;
|
|
24137
|
-
const [contextItems, setContextItems] =
|
|
24138
|
-
const [contextPickerOpen, setContextPickerOpen] =
|
|
24139
|
-
const [mentionQuery, setMentionQuery] =
|
|
23819
|
+
const [contextItems, setContextItems] = useState45(NO_CONTEXT_ITEMS);
|
|
23820
|
+
const [contextPickerOpen, setContextPickerOpen] = useState45(false);
|
|
23821
|
+
const [mentionQuery, setMentionQuery] = useState45(null);
|
|
24140
23822
|
const mentionActiveRef = useRef34(false);
|
|
24141
|
-
|
|
23823
|
+
useEffect37(() => {
|
|
24142
23824
|
mentionActiveRef.current = mentionQuery !== null;
|
|
24143
23825
|
}, [mentionQuery]);
|
|
24144
23826
|
const mentionKeysRef = useRef34(/* @__PURE__ */ new Set());
|
|
24145
|
-
const [contextClearedFor, setContextClearedFor] =
|
|
23827
|
+
const [contextClearedFor, setContextClearedFor] = useState45({ activeDialogId, activeMode });
|
|
24146
23828
|
if (contextClearedFor.activeDialogId !== activeDialogId || contextClearedFor.activeMode !== activeMode) {
|
|
24147
23829
|
setContextClearedFor({ activeDialogId, activeMode });
|
|
24148
23830
|
setContextItems(NO_CONTEXT_ITEMS);
|
|
24149
23831
|
setMentionQuery(null);
|
|
24150
23832
|
}
|
|
24151
|
-
|
|
23833
|
+
useEffect37(() => {
|
|
24152
23834
|
mentionKeysRef.current.clear();
|
|
24153
23835
|
}, [activeDialogId, activeMode]);
|
|
24154
|
-
const mentionMarkerByType =
|
|
23836
|
+
const mentionMarkerByType = useMemo29(() => {
|
|
24155
23837
|
const m = /* @__PURE__ */ new Map();
|
|
24156
23838
|
for (const t of contextPicker?.entityTypes ?? []) if (t.marker) m.set(t.type, t.marker);
|
|
24157
23839
|
return m;
|
|
24158
23840
|
}, [contextPicker?.entityTypes]);
|
|
24159
23841
|
const contextEntityTypes = contextPicker?.entityTypes;
|
|
24160
|
-
const resolveContextIcon =
|
|
23842
|
+
const resolveContextIcon = useMemo29(() => {
|
|
24161
23843
|
const byType = /* @__PURE__ */ new Map();
|
|
24162
23844
|
for (const t of contextEntityTypes ?? []) byType.set(t.type, t.icon);
|
|
24163
23845
|
return (item) => byType.get(item.type);
|
|
24164
23846
|
}, [contextEntityTypes]);
|
|
24165
|
-
const toggleContextItem =
|
|
23847
|
+
const toggleContextItem = useCallback26(
|
|
24166
23848
|
(item) => {
|
|
24167
23849
|
const key = `${item.type}:${item.id}`;
|
|
24168
23850
|
if (mentionActiveRef.current) {
|
|
@@ -24185,7 +23867,7 @@ function EmbeddableChatInner({
|
|
|
24185
23867
|
},
|
|
24186
23868
|
[contextMaxItems, contextItems, mentionMarkerByType, resolveContextIcon]
|
|
24187
23869
|
);
|
|
24188
|
-
const removeContextItem =
|
|
23870
|
+
const removeContextItem = useCallback26(
|
|
24189
23871
|
(item) => {
|
|
24190
23872
|
const key = `${item.type}:${item.id}`;
|
|
24191
23873
|
setContextItems((prev) => prev.filter((p) => `${p.type}:${p.id}` !== key));
|
|
@@ -24198,7 +23880,7 @@ function EmbeddableChatInner({
|
|
|
24198
23880
|
},
|
|
24199
23881
|
[mentionMarkerByType]
|
|
24200
23882
|
);
|
|
24201
|
-
const handleContextValueChange =
|
|
23883
|
+
const handleContextValueChange = useCallback26(
|
|
24202
23884
|
(value) => {
|
|
24203
23885
|
for (const key of Array.from(mentionKeysRef.current)) {
|
|
24204
23886
|
if (!value.includes(`@${mentionTokenOf(key, mentionMarkerByType)}`)) {
|
|
@@ -24209,32 +23891,32 @@ function EmbeddableChatInner({
|
|
|
24209
23891
|
},
|
|
24210
23892
|
[mentionMarkerByType]
|
|
24211
23893
|
);
|
|
24212
|
-
const openContextPicker =
|
|
23894
|
+
const openContextPicker = useCallback26(() => {
|
|
24213
23895
|
setMentionQuery(null);
|
|
24214
23896
|
setContextPickerOpen(true);
|
|
24215
23897
|
}, []);
|
|
24216
|
-
const closeContextPicker =
|
|
23898
|
+
const closeContextPicker = useCallback26(() => {
|
|
24217
23899
|
if (mentionActiveRef.current) {
|
|
24218
23900
|
chatInputRef.current?.removeMentionTrigger();
|
|
24219
23901
|
}
|
|
24220
23902
|
setContextPickerOpen(false);
|
|
24221
23903
|
setMentionQuery(null);
|
|
24222
23904
|
}, []);
|
|
24223
|
-
const handleMentionQueryChange =
|
|
23905
|
+
const handleMentionQueryChange = useCallback26((query) => {
|
|
24224
23906
|
setMentionQuery(query);
|
|
24225
23907
|
setContextPickerOpen(query !== null);
|
|
24226
23908
|
}, []);
|
|
24227
23909
|
const resolvedBaseRoute = baseRoute || (source === "flamingo" ? "/knowledge-base" : "/data-room");
|
|
24228
|
-
const handleClose =
|
|
24229
|
-
const handleNavigationClose =
|
|
23910
|
+
const handleClose = useCallback26(() => setIsOpen(false), [setIsOpen]);
|
|
23911
|
+
const handleNavigationClose = useCallback26(() => {
|
|
24230
23912
|
navigatingAwayRef.current = true;
|
|
24231
23913
|
setIsOpen(false);
|
|
24232
23914
|
}, [setIsOpen]);
|
|
24233
|
-
const chatPanelHandle =
|
|
23915
|
+
const chatPanelHandle = useMemo29(
|
|
24234
23916
|
() => ({ closeChat: handleNavigationClose }),
|
|
24235
23917
|
[handleNavigationClose]
|
|
24236
23918
|
);
|
|
24237
|
-
const renderEntityCard =
|
|
23919
|
+
const renderEntityCard = useCallback26(
|
|
24238
23920
|
(reference) => renderChatInlineEntityCard(reference, {
|
|
24239
23921
|
onDiscuss: discussRef,
|
|
24240
23922
|
onDisplay: displayRef,
|
|
@@ -24244,14 +23926,14 @@ function EmbeddableChatInner({
|
|
|
24244
23926
|
}),
|
|
24245
23927
|
[discussRef, displayRef, resolvedBaseRoute, chipBasePlatform, extras]
|
|
24246
23928
|
);
|
|
24247
|
-
const mingoAssistantIcon =
|
|
23929
|
+
const mingoAssistantIcon = useMemo29(
|
|
24248
23930
|
() => effectiveAssistantIcon ? /* @__PURE__ */ jsx97(EntityIcon, { icon: effectiveAssistantIcon, size: 24 }) : /* @__PURE__ */ jsx97(MingoIcon, { className: "h-6 w-6", cornerColor: "var(--ods-flamingo-cyan-base)" }),
|
|
24249
23931
|
[effectiveAssistantIcon]
|
|
24250
23932
|
);
|
|
24251
|
-
const [timestampCache] =
|
|
23933
|
+
const [timestampCache] = useState45(() => /* @__PURE__ */ new Map());
|
|
24252
23934
|
const guideUserName = activeMode === "guide" ? [identityUser?.firstName, identityUser?.lastName].filter(Boolean).join(" ").trim() || identityUser?.name?.trim() || void 0 : void 0;
|
|
24253
23935
|
const guideUserAvatar = activeMode === "guide" ? identityUser?.avatarUrl?.trim() || void 0 : void 0;
|
|
24254
|
-
const messages =
|
|
23936
|
+
const messages = useMemo29(() => {
|
|
24255
23937
|
const cache = timestampCache;
|
|
24256
23938
|
const seenIds = /* @__PURE__ */ new Set();
|
|
24257
23939
|
const mapped = rawMessages.map((m) => {
|
|
@@ -24296,7 +23978,7 @@ function EmbeddableChatInner({
|
|
|
24296
23978
|
}
|
|
24297
23979
|
return mapped;
|
|
24298
23980
|
}, [rawMessages, guideUserName, guideUserAvatar, timestampCache]);
|
|
24299
|
-
const handleSend =
|
|
23981
|
+
const handleSend = useCallback26(
|
|
24300
23982
|
(text) => {
|
|
24301
23983
|
let augmentedText = text;
|
|
24302
23984
|
if (readyAttachments.length > 0) {
|
|
@@ -24318,7 +24000,7 @@ function EmbeddableChatInner({
|
|
|
24318
24000
|
},
|
|
24319
24001
|
[sendMessage, readyAttachments, viewUrlPrefix, clearAttachments, contextItems]
|
|
24320
24002
|
);
|
|
24321
|
-
const handleAskSelect =
|
|
24003
|
+
const handleAskSelect = useCallback26(
|
|
24322
24004
|
(label) => {
|
|
24323
24005
|
void sendMessage(label).catch((err) => {
|
|
24324
24006
|
console.error("[EmbeddableChat] handleAskSelect send failed:", err);
|
|
@@ -24326,7 +24008,7 @@ function EmbeddableChatInner({
|
|
|
24326
24008
|
},
|
|
24327
24009
|
[sendMessage]
|
|
24328
24010
|
);
|
|
24329
|
-
const guideSuggestedActions =
|
|
24011
|
+
const guideSuggestedActions = useMemo29(() => {
|
|
24330
24012
|
if (effectiveQuickActions.length > 0) {
|
|
24331
24013
|
return effectiveQuickActions.map((qa) => ({
|
|
24332
24014
|
id: qa.id,
|
|
@@ -24385,9 +24067,9 @@ function EmbeddableChatInner({
|
|
|
24385
24067
|
fetchArchivedDialogs: mingoCaps.fetchArchivedDialogs,
|
|
24386
24068
|
unarchiveDialog: mingoCaps.unarchiveDialog
|
|
24387
24069
|
});
|
|
24388
|
-
const handleOpen =
|
|
24070
|
+
const handleOpen = useCallback26(() => setIsOpen(true), [setIsOpen]);
|
|
24389
24071
|
useCloseOnNavigation(handleNavigationClose, null);
|
|
24390
|
-
|
|
24072
|
+
useEffect37(() => {
|
|
24391
24073
|
const handler = (e) => {
|
|
24392
24074
|
const detail = e.detail;
|
|
24393
24075
|
if (!detail || detail.source !== source) return;
|
|
@@ -24397,7 +24079,7 @@ function EmbeddableChatInner({
|
|
|
24397
24079
|
window.addEventListener("ask-ai:open-with-ref", handler);
|
|
24398
24080
|
return () => window.removeEventListener("ask-ai:open-with-ref", handler);
|
|
24399
24081
|
}, [source, discussRef, setIsOpen]);
|
|
24400
|
-
|
|
24082
|
+
useEffect37(() => {
|
|
24401
24083
|
const handler = (e) => {
|
|
24402
24084
|
const detail = e.detail;
|
|
24403
24085
|
if (!detail || detail.source !== source) return;
|
|
@@ -24409,7 +24091,7 @@ function EmbeddableChatInner({
|
|
|
24409
24091
|
const hasMessages = messages.length > 0;
|
|
24410
24092
|
const dialogsInitialLoading = isDialogsLoading && dialogs.length === 0;
|
|
24411
24093
|
const dialogsLoadError = dialogsError && dialogs.length === 0;
|
|
24412
|
-
const hasConversation = hasMessages || isOpeningDialog || isViewingArchived ||
|
|
24094
|
+
const hasConversation = hasMessages || isOpeningDialog || isViewingArchived || previewMode && isMessagesLoading;
|
|
24413
24095
|
const messagesInitialLoading = isMessagesLoading && !hasMessages;
|
|
24414
24096
|
const contentViewKey = hasConversation ? "conversation" : activeMode;
|
|
24415
24097
|
const isGuideEmpty = !hasConversation && activeMode === "guide";
|
|
@@ -24417,11 +24099,11 @@ function EmbeddableChatInner({
|
|
|
24417
24099
|
if (!isQuickActionEmpty && quickActionPreview !== null) setQuickActionPreview(null);
|
|
24418
24100
|
const guideCanReturnToMingo = isGuideEmpty && hasMingoMode;
|
|
24419
24101
|
const sourceLabel = source === "flamingo" ? "Knowledge Base" : "Data Room";
|
|
24420
|
-
const enabledSet =
|
|
24102
|
+
const enabledSet = useMemo29(
|
|
24421
24103
|
() => effectiveEnabledRagTableIds ? new Set(effectiveEnabledRagTableIds) : null,
|
|
24422
24104
|
[effectiveEnabledRagTableIds]
|
|
24423
24105
|
);
|
|
24424
|
-
const chipCommands =
|
|
24106
|
+
const chipCommands = useMemo29(() => {
|
|
24425
24107
|
const out = [];
|
|
24426
24108
|
for (const cmd of commandsById.values()) {
|
|
24427
24109
|
if (cmd.displayOrder === void 0) continue;
|
|
@@ -24437,7 +24119,7 @@ function EmbeddableChatInner({
|
|
|
24437
24119
|
return out;
|
|
24438
24120
|
}, [commandsById, enabledSet]);
|
|
24439
24121
|
const lastAssistantMsg = [...rawMessages].reverse().find((m) => m.role === "assistant");
|
|
24440
|
-
const lastSources =
|
|
24122
|
+
const lastSources = useMemo29(() => {
|
|
24441
24123
|
if (chatLoading) return void 0;
|
|
24442
24124
|
const sources = lastAssistantMsg?.sources;
|
|
24443
24125
|
if (!sources || sources.length === 0) return void 0;
|
|
@@ -24451,24 +24133,28 @@ function EmbeddableChatInner({
|
|
|
24451
24133
|
const uncited = sources.filter((s) => !seenOrder.has(s.index));
|
|
24452
24134
|
return { cited, uncited };
|
|
24453
24135
|
}, [lastAssistantMsg, chatLoading]);
|
|
24454
|
-
const [portalHost, setPortalHost] =
|
|
24455
|
-
const [panelBoundary, setPanelBoundary] =
|
|
24456
|
-
const [panelWidth, setPanelWidth] =
|
|
24457
|
-
|
|
24458
|
-
|
|
24136
|
+
const [portalHost, setPortalHost] = useState45(null);
|
|
24137
|
+
const [panelBoundary, setPanelBoundary] = useState45(null);
|
|
24138
|
+
const [panelWidth, setPanelWidth] = useState45(0);
|
|
24139
|
+
const panelMeasureRef = useRef34(null);
|
|
24140
|
+
useEffect37(() => {
|
|
24141
|
+
const el = panelMeasureRef.current;
|
|
24142
|
+
if (!el || typeof ResizeObserver === "undefined") return void 0;
|
|
24459
24143
|
const ro = new ResizeObserver((entries) => {
|
|
24460
24144
|
const w = entries[0]?.contentRect?.width;
|
|
24461
24145
|
if (typeof w === "number") setPanelWidth(w);
|
|
24462
24146
|
});
|
|
24463
|
-
ro.observe(
|
|
24147
|
+
ro.observe(el);
|
|
24148
|
+
setPanelWidth(el.clientWidth);
|
|
24464
24149
|
return () => ro.disconnect();
|
|
24465
|
-
}, [
|
|
24466
|
-
const setPanelNode =
|
|
24150
|
+
}, []);
|
|
24151
|
+
const setPanelNode = useCallback26((node) => {
|
|
24152
|
+
panelMeasureRef.current = node;
|
|
24467
24153
|
setPanelBoundary(node);
|
|
24468
24154
|
}, []);
|
|
24469
|
-
const [railCollapsed, setRailCollapsed] =
|
|
24155
|
+
const [railCollapsed, setRailCollapsed] = useState45(false);
|
|
24470
24156
|
const railStorageHydrated = useIsHydrated();
|
|
24471
|
-
const [railStorageRead, setRailStorageRead] =
|
|
24157
|
+
const [railStorageRead, setRailStorageRead] = useState45(false);
|
|
24472
24158
|
if (railStorageHydrated && !railStorageRead) {
|
|
24473
24159
|
setRailStorageRead(true);
|
|
24474
24160
|
try {
|
|
@@ -24476,7 +24162,7 @@ function EmbeddableChatInner({
|
|
|
24476
24162
|
} catch {
|
|
24477
24163
|
}
|
|
24478
24164
|
}
|
|
24479
|
-
const toggleRailCollapsed =
|
|
24165
|
+
const toggleRailCollapsed = useCallback26(() => {
|
|
24480
24166
|
setRailCollapsed((prev) => {
|
|
24481
24167
|
const next = !prev;
|
|
24482
24168
|
try {
|
|
@@ -24486,18 +24172,17 @@ function EmbeddableChatInner({
|
|
|
24486
24172
|
return next;
|
|
24487
24173
|
});
|
|
24488
24174
|
}, []);
|
|
24489
|
-
const [railSearchOpen, setRailSearchOpen] =
|
|
24490
|
-
const splitEligible =
|
|
24175
|
+
const [railSearchOpen, setRailSearchOpen] = useState45(false);
|
|
24176
|
+
const splitEligible = activeMode === "mingo";
|
|
24491
24177
|
const canSplit = panelWidth >= SPLIT_MIN_WIDTH;
|
|
24492
24178
|
const wideMingo = splitEligible && canSplit && !previewMode;
|
|
24493
24179
|
const splitActive = wideMingo && !railCollapsed;
|
|
24494
24180
|
const railPresence = useRailPresence(splitActive);
|
|
24495
24181
|
const showWideHeader = wideMingo || railPresence.mounted;
|
|
24496
|
-
const [composeOpen, setComposeOpen] =
|
|
24182
|
+
const [composeOpen, setComposeOpen] = useState45(false);
|
|
24497
24183
|
if (hasConversation && composeOpen) setComposeOpen(false);
|
|
24498
|
-
const isMingoMode =
|
|
24499
|
-
const
|
|
24500
|
-
const stackedListView = isMingoMode && !hasConversation && !archiveOpen && !wideMingo && !composeOpen && !guideListIsEmpty;
|
|
24184
|
+
const isMingoMode = activeMode === "mingo";
|
|
24185
|
+
const stackedListView = isMingoMode && !hasConversation && !archiveOpen && !wideMingo && !composeOpen;
|
|
24501
24186
|
const headerShowBack = hasConversation || guideCanReturnToMingo;
|
|
24502
24187
|
const headerTitle = hasConversation ? activeDialog?.title || "New Chat" : isGuideEmpty ? headerAssistantName ?? "Mingo Guide" : "Current Chats";
|
|
24503
24188
|
const headerBackAriaLabel = hasConversation ? isViewingArchived ? "Back to archive" : "Back" : "Back to Mingo";
|
|
@@ -24511,7 +24196,7 @@ function EmbeddableChatInner({
|
|
|
24511
24196
|
const headerPersonName = headerOwner?.name?.trim() || headerUserName;
|
|
24512
24197
|
const headerPersonAvatarUrl = headerOwner ? headerOwner.avatarUrl?.trim() || void 0 : identityUser?.avatarUrl?.trim() || userAvatarUrl?.trim() || void 0;
|
|
24513
24198
|
const headerAvatar = headerPersonName || headerPersonAvatarUrl ? { name: headerPersonName, avatarUrl: headerPersonAvatarUrl } : void 0;
|
|
24514
|
-
const handleNewChat =
|
|
24199
|
+
const handleNewChat = useCallback26(() => {
|
|
24515
24200
|
resetToNewChat();
|
|
24516
24201
|
}, [resetToNewChat]);
|
|
24517
24202
|
useImperativeHandle4(
|
|
@@ -24529,12 +24214,10 @@ function EmbeddableChatInner({
|
|
|
24529
24214
|
headerOnRename && { id: "rename", label: "Rename chat", onClick: headerOnRename },
|
|
24530
24215
|
headerOnArchive && { id: "archive", label: "Archive chat", onClick: headerOnArchive }
|
|
24531
24216
|
].filter(Boolean);
|
|
24532
|
-
const narrowMingoEmpty = isMingoMode && !hasConversation && !archiveOpen
|
|
24217
|
+
const narrowMingoEmpty = isMingoMode && !hasConversation && !archiveOpen;
|
|
24533
24218
|
const narrowHeaderProps = narrowMingoEmpty ? composeOpen ? {
|
|
24534
24219
|
showBack: true,
|
|
24535
|
-
|
|
24536
|
-
// Mingo "New Chat".
|
|
24537
|
-
title: isGuideEmpty ? headerAssistantName ?? "Mingo Guide" : "New Chat",
|
|
24220
|
+
title: "New Chat",
|
|
24538
24221
|
subtitle: headerUserName,
|
|
24539
24222
|
avatar: headerAvatar,
|
|
24540
24223
|
backAriaLabel: "Back to chats",
|
|
@@ -24651,7 +24334,7 @@ function EmbeddableChatInner({
|
|
|
24651
24334
|
),
|
|
24652
24335
|
/* @__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: [
|
|
24653
24336
|
/* @__PURE__ */ jsxs75("div", { className: "flex min-w-0 flex-col", children: [
|
|
24654
|
-
/* @__PURE__ */ jsx97("p", { className: "truncate leading-tight text-ods-text-primary text-h3", children: headerShowBack
|
|
24337
|
+
/* @__PURE__ */ jsx97("p", { className: "truncate leading-tight text-ods-text-primary text-h3", children: headerShowBack ? headerTitle : "New Chat" }),
|
|
24655
24338
|
headerPersonName && /* @__PURE__ */ jsx97("p", { className: "truncate leading-tight text-ods-text-secondary text-h6", children: headerPersonName })
|
|
24656
24339
|
] }),
|
|
24657
24340
|
headerAvatar ? (
|
|
@@ -24973,7 +24656,7 @@ function EmbeddableChatInner({
|
|
|
24973
24656
|
resizable: true,
|
|
24974
24657
|
minSize: 480,
|
|
24975
24658
|
maxSize: 1600,
|
|
24976
|
-
defaultSize: drawerDefaultWidth(
|
|
24659
|
+
defaultSize: drawerDefaultWidth(),
|
|
24977
24660
|
storageKey: DRAWER_WIDTH_KEY,
|
|
24978
24661
|
resizeAriaLabel: "Resize chat panel",
|
|
24979
24662
|
overlayClassName: "mingo-chat-overlay",
|
|
@@ -25348,7 +25031,6 @@ export {
|
|
|
25348
25031
|
createChatDialogStore,
|
|
25349
25032
|
createDeltaBatcher,
|
|
25350
25033
|
useChatStreamReducer,
|
|
25351
|
-
createChatConversationsApi,
|
|
25352
25034
|
parseWireCommandOverride,
|
|
25353
25035
|
sanitizeTitleForChat,
|
|
25354
25036
|
formatSingularLookupInvocation,
|
|
@@ -25357,7 +25039,6 @@ export {
|
|
|
25357
25039
|
buildDiscussPrompt,
|
|
25358
25040
|
AUTO_CONTINUATION_DIRECTIVE_PREFIX,
|
|
25359
25041
|
buildAutoContinuationDirective,
|
|
25360
|
-
useManagedDialogList,
|
|
25361
25042
|
useSseChatAdapter,
|
|
25362
25043
|
extractIncompleteMessageState,
|
|
25363
25044
|
extractIncompleteTailState,
|
|
@@ -25382,4 +25063,4 @@ export {
|
|
|
25382
25063
|
buildStreamFrames,
|
|
25383
25064
|
EmbeddableChat
|
|
25384
25065
|
};
|
|
25385
|
-
//# sourceMappingURL=chunk-
|
|
25066
|
+
//# sourceMappingURL=chunk-VNSRNVPD.js.map
|