@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
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
* Ask + Display buttons WORK out of the box.
|
|
52
52
|
*/
|
|
53
53
|
|
|
54
|
-
import { useCallback, useMemo, useRef
|
|
54
|
+
import { useCallback, useMemo, useRef } from 'react';
|
|
55
55
|
import { buildConfirmToolBody, readServerErrorMessage } from '../../../chat-protocol/confirm-tool';
|
|
56
56
|
import { createSseFrameDecoder } from '../../../chat-protocol/decode';
|
|
57
57
|
import type { ChatStreamEvent } from '../../../chat-protocol/events';
|
|
@@ -62,46 +62,53 @@ import { createChatDialogStore } from '../stream/chat-dialog-store';
|
|
|
62
62
|
import type { ChatDialogStore } from '../stream/chat-dialog-store';
|
|
63
63
|
import type { ChatStreamReducerOptions } from '../stream/chat-stream-reducer';
|
|
64
64
|
import { useChatStreamReducer } from '../stream/use-chat-stream-reducer';
|
|
65
|
+
import type { DialogItem } from '../types/component.types';
|
|
65
66
|
import type { Message, MessageSegment } from '../types/message.types';
|
|
66
67
|
import type {
|
|
67
|
-
ChatDialogCapabilities,
|
|
68
|
-
FetchDialogsParams,
|
|
69
68
|
UnifiedChatState,
|
|
70
69
|
UnifiedChatMessage,
|
|
71
70
|
UnifiedSendMessageOptions,
|
|
72
71
|
} from '../types/unified-chat-state.types';
|
|
73
72
|
import { createChatConversationStorage, pruneStaleChatConversationStorage } from '../utils/chat-conversation-storage';
|
|
74
|
-
import { createChatConversationsApi } from '../utils/chat-conversations-api';
|
|
75
73
|
import { buildDiscussPrompt } from '../utils/discuss-ref-prompt';
|
|
76
74
|
import type { ScrollAnchor } from '../utils/scroll-anchor';
|
|
77
75
|
import { sanitizeTitleForChat } from '../utils/slash-dispatch-utils';
|
|
78
76
|
import type { WireCommandOverride } from '../utils/slash-dispatch-utils';
|
|
79
77
|
import { defaultTableIdForDocumentType } from '../utils/source-icons';
|
|
80
78
|
import { useChatHistoryHydration } from './use-chat-history-hydration';
|
|
81
|
-
import { useManagedDialogList } from './use-managed-dialog-list';
|
|
82
79
|
import { useSlashCommandRegistry, type SlashCommandSummary } from './use-slash-commands';
|
|
83
80
|
|
|
84
81
|
// Canonical home of the per-turn meta row moved to the stream module in
|
|
85
82
|
// Phase 3; re-exported here to keep the legacy import path stable.
|
|
86
83
|
export type { ChatTurnMeta } from '../stream/chat-stream-reducer';
|
|
87
84
|
|
|
88
|
-
// ─── Stable no-op references for the
|
|
89
|
-
// Plain module-scope constants so the adapter's return identity stays
|
|
90
|
-
// across renders — consumers that memo on these fields don't get
|
|
91
|
-
// re-runs.
|
|
92
|
-
|
|
93
|
-
// construction (empty list, false flags, memoized no-op mutations).
|
|
85
|
+
// ─── Stable no-op references for the Guide-mode dialog-management stubs ──
|
|
86
|
+
// Plain module-scope constants so the adapter's return identity stays
|
|
87
|
+
// stable across renders — consumers that memo on these fields don't get
|
|
88
|
+
// spurious re-runs.
|
|
89
|
+
const SSE_EMPTY_DIALOGS: DialogItem[] = [];
|
|
94
90
|
const noopSelectDialog = (_id: string | null): void => {
|
|
95
|
-
/*
|
|
91
|
+
/* Guide mode has no managed dialog list yet */
|
|
96
92
|
};
|
|
97
|
-
/** "New chat" is `clearMessages` (the server mints an id on the next send);
|
|
98
|
-
* there is no create call to make. */
|
|
99
93
|
const noopStartNewDialog = (): Promise<string | null> => Promise.resolve(null);
|
|
100
94
|
const noopDeleteDialog = async (_id: string): Promise<void> => {
|
|
101
|
-
/*
|
|
95
|
+
/* no-op until Guide server-side history is exposed as dialogs */
|
|
96
|
+
};
|
|
97
|
+
const noopRenameDialog = async (_id: string, _title: string): Promise<void> => {
|
|
98
|
+
/* no-op until Guide server-side history is exposed as dialogs */
|
|
99
|
+
};
|
|
100
|
+
const noopArchiveDialog = async (_id: string): Promise<void> => {
|
|
101
|
+
/* no-op until Guide server-side history is exposed as dialogs */
|
|
102
102
|
};
|
|
103
103
|
const noopAsync = async (): Promise<void> => {
|
|
104
|
-
/* no-op pagination stub
|
|
104
|
+
/* no-op pagination stub */
|
|
105
|
+
};
|
|
106
|
+
/** `reloadDialogs` is `() => void` in the unified contract, unlike the async
|
|
107
|
+
* pagination stubs above — it is wired straight to an error-state `onRetry`,
|
|
108
|
+
* which ignores a returned promise. Keeping it sync means no caller is handed
|
|
109
|
+
* a promise it will silently drop. */
|
|
110
|
+
const noopReloadDialogs = (): void => {
|
|
111
|
+
/* no-op until Guide server-side history is exposed as dialogs */
|
|
105
112
|
};
|
|
106
113
|
const noopApproveRequest = async (_id: string): Promise<void> => {
|
|
107
114
|
/* Guide mode has no tool-call approval workflow */
|
|
@@ -309,6 +316,8 @@ export function useSseChatAdapter(
|
|
|
309
316
|
createReducerOptions,
|
|
310
317
|
});
|
|
311
318
|
|
|
319
|
+
const abortControllerRef = useRef<AbortController | null>(null);
|
|
320
|
+
|
|
312
321
|
// ─── Conversation identity — server-minted id, restored once on mount ─────
|
|
313
322
|
// Null = no conversation yet: the FIRST send goes out without an id, the
|
|
314
323
|
// server mints one, and the metadata-frame capture (in the send loop below)
|
|
@@ -323,20 +332,6 @@ export function useSseChatAdapter(
|
|
|
323
332
|
pruneStaleChatConversationStorage(source);
|
|
324
333
|
conversationIdRef.current = conversationStorage.load()?.conversationId ?? null;
|
|
325
334
|
}
|
|
326
|
-
// Render-visible mirror of the ref. The ref stays the SYNCHRONOUS send-time
|
|
327
|
-
// source (a capture mid-stream must be visible to the very next send); the
|
|
328
|
-
// state is what re-arms history hydration and drives `activeDialogId` when
|
|
329
|
-
// the user switches conversations. ONE writer for both + storage.
|
|
330
|
-
const [conversationId, setConversationId] = useState<string | null>(() => conversationIdRef.current);
|
|
331
|
-
const commitConversationId = useCallback(
|
|
332
|
-
(id: string | null) => {
|
|
333
|
-
conversationIdRef.current = id;
|
|
334
|
-
setConversationId(id);
|
|
335
|
-
if (id) conversationStorage.save({ conversationId: id });
|
|
336
|
-
else conversationStorage.clear();
|
|
337
|
-
},
|
|
338
|
-
[conversationStorage],
|
|
339
|
-
);
|
|
340
335
|
|
|
341
336
|
// ─── Slash-command registry (displayRef lookup) ───────────────────────────
|
|
342
337
|
// Reads from the SAME react-query cache entry as `<EmbeddableChat>`'s
|
|
@@ -406,119 +401,18 @@ export function useSseChatAdapter(
|
|
|
406
401
|
},
|
|
407
402
|
[mutate],
|
|
408
403
|
);
|
|
409
|
-
// Live message count for the orphan guard below (a ref, so the callback's
|
|
410
|
-
// identity never changes — see the note on `onOrphanedConversation`).
|
|
411
|
-
const messagesLenRef = useRef(0);
|
|
412
|
-
messagesLenRef.current = state.messages.length;
|
|
413
|
-
const onOrphanedConversation = useCallback(
|
|
414
|
-
(id: string) => {
|
|
415
|
-
if (conversationIdRef.current === id && messagesLenRef.current === 0) commitConversationId(null);
|
|
416
|
-
},
|
|
417
|
-
[commitConversationId],
|
|
418
|
-
);
|
|
419
|
-
|
|
420
404
|
const { isHydratingHistory, hydratedKeyRef } = useChatHistoryHydration({
|
|
421
405
|
active,
|
|
422
406
|
source,
|
|
423
407
|
historyUrl,
|
|
424
|
-
|
|
408
|
+
conversationIdRef,
|
|
425
409
|
sendCountRef: hydrationSendCountRef,
|
|
426
410
|
hydrateMessages,
|
|
427
411
|
// Meta invalidation is a reducer concern here: `seedSseMaps` (inside
|
|
428
412
|
// `hydrateMessages` above) already invalidates the snapshot.
|
|
429
413
|
bumpMetaTick: noopBumpMetaTick,
|
|
430
|
-
// Drop a stored id the server no longer recognizes (deleted, or claimed by
|
|
431
|
-
// an account while this browser is signed out) — keeping it would stream
|
|
432
|
-
// answers the server refuses to persist. Guarded on "no live turn yet" so
|
|
433
|
-
// a just-minted id is never dropped.
|
|
434
|
-
//
|
|
435
|
-
// IDENTITY-STABLE by construction: this is a dependency of the hydration
|
|
436
|
-
// effect, so a callback that changed with the message count would CANCEL
|
|
437
|
-
// an in-flight hydration the moment the user typed — silently discarding
|
|
438
|
-
// the thread they just opened. The live count is read through a ref.
|
|
439
|
-
onOrphanedConversation,
|
|
440
414
|
});
|
|
441
415
|
|
|
442
|
-
const abortControllerRef = useRef<AbortController | null>(null);
|
|
443
|
-
|
|
444
|
-
/** Switch the panel to another conversation (or to the draft state with
|
|
445
|
-
* `null`): abort any in-flight stream, flush + reset the reducer, re-arm
|
|
446
|
-
* the hydration guard, and commit the new id. `useChatHistoryHydration`
|
|
447
|
-
* then re-fetches for a non-null id through its `conversationId` dep. */
|
|
448
|
-
const switchConversation = useCallback(
|
|
449
|
-
(id: string | null) => {
|
|
450
|
-
abortControllerRef.current?.abort();
|
|
451
|
-
flushDeltas();
|
|
452
|
-
mutate(r => r.reset());
|
|
453
|
-
hydrationSendCountRef.current = 0;
|
|
454
|
-
hydratedKeyRef.current = null;
|
|
455
|
-
commitConversationId(id);
|
|
456
|
-
},
|
|
457
|
-
[flushDeltas, mutate, hydratedKeyRef, commitConversationId],
|
|
458
|
-
);
|
|
459
|
-
|
|
460
|
-
// ─── Managed dialog list (only with `chatConversationsUrl`) ───────────────
|
|
461
|
-
// The SAME list state machine the NATS adapter runs; the host contract is
|
|
462
|
-
// the hub's conversations route, spelled out once in
|
|
463
|
-
// `chat-conversations-api.ts`. Without the endpoint the hook is inert and
|
|
464
|
-
// the return shape below keeps the single-thread stubs — zero behaviour
|
|
465
|
-
// change for hosts that never set it.
|
|
466
|
-
const conversationsUrl = runtime.endpoints.chatConversationsUrl;
|
|
467
|
-
const conversationsApi = useMemo(
|
|
468
|
-
() => (conversationsUrl ? createChatConversationsApi(conversationsUrl) : null),
|
|
469
|
-
[conversationsUrl],
|
|
470
|
-
);
|
|
471
|
-
const [dialogSearch, setDialogSearch] = useState('');
|
|
472
|
-
const fetchActiveDialogs = useMemo(
|
|
473
|
-
() =>
|
|
474
|
-
conversationsApi
|
|
475
|
-
? (params: FetchDialogsParams) => conversationsApi.fetchDialogs({ ...params, status: 'active' })
|
|
476
|
-
: undefined,
|
|
477
|
-
[conversationsApi],
|
|
478
|
-
);
|
|
479
|
-
const fetchArchivedDialogs = useMemo(
|
|
480
|
-
() =>
|
|
481
|
-
conversationsApi
|
|
482
|
-
? (params: FetchDialogsParams) => conversationsApi.fetchDialogs({ ...params, status: 'archived' })
|
|
483
|
-
: undefined,
|
|
484
|
-
[conversationsApi],
|
|
485
|
-
);
|
|
486
|
-
const {
|
|
487
|
-
dialogs,
|
|
488
|
-
isDialogsLoading,
|
|
489
|
-
dialogsError,
|
|
490
|
-
hasMoreDialogs,
|
|
491
|
-
reloadDialogs,
|
|
492
|
-
loadMoreDialogs,
|
|
493
|
-
renameDialog,
|
|
494
|
-
archiveDialog,
|
|
495
|
-
upsertDialogTop,
|
|
496
|
-
bumpDialogToTop,
|
|
497
|
-
} = useManagedDialogList({
|
|
498
|
-
autoLoad: active,
|
|
499
|
-
fetchDialogs: fetchActiveDialogs,
|
|
500
|
-
renameDialog: conversationsApi?.renameDialog,
|
|
501
|
-
archiveDialog: conversationsApi?.archiveDialog,
|
|
502
|
-
pageSize: 20,
|
|
503
|
-
search: conversationsApi ? dialogSearch : undefined,
|
|
504
|
-
logTag: '[useSseChatAdapter]',
|
|
505
|
-
// Archiving the OPEN conversation drops back to the draft state (the
|
|
506
|
-
// manager also clears the thread; both paths are idempotent).
|
|
507
|
-
onDialogRemoved: id => {
|
|
508
|
-
if (conversationIdRef.current === id) switchConversation(null);
|
|
509
|
-
},
|
|
510
|
-
});
|
|
511
|
-
const unarchiveDialog = useMemo(
|
|
512
|
-
() =>
|
|
513
|
-
conversationsApi
|
|
514
|
-
? async (id: string) => {
|
|
515
|
-
await conversationsApi.unarchiveDialog(id);
|
|
516
|
-
reloadDialogs();
|
|
517
|
-
}
|
|
518
|
-
: undefined,
|
|
519
|
-
[conversationsApi, reloadDialogs],
|
|
520
|
-
);
|
|
521
|
-
|
|
522
416
|
// ─── Send / stream loop ────────────────────────────────────────────────────
|
|
523
417
|
|
|
524
418
|
/**
|
|
@@ -541,19 +435,15 @@ export function useSseChatAdapter(
|
|
|
541
435
|
* same conversation. The reducer ignores the field (identity is a
|
|
542
436
|
* transport/persistence concern, not render state). */
|
|
543
437
|
const captureConversationId = useCallback(
|
|
544
|
-
(event: ChatStreamEvent):
|
|
545
|
-
if (event.type !== 'metadata') return
|
|
438
|
+
(event: ChatStreamEvent): void => {
|
|
439
|
+
if (event.type !== 'metadata') return;
|
|
546
440
|
const id = event.conversationId;
|
|
547
|
-
if (typeof id !== 'string' || !id) return
|
|
548
|
-
if (conversationIdRef.current === id) return
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
// would prepend that same turn once the server has persisted it.
|
|
552
|
-
hydratedKeyRef.current = `${source}:${id}`;
|
|
553
|
-
commitConversationId(id);
|
|
554
|
-
return true;
|
|
441
|
+
if (typeof id !== 'string' || !id) return;
|
|
442
|
+
if (conversationIdRef.current === id) return;
|
|
443
|
+
conversationIdRef.current = id;
|
|
444
|
+
conversationStorage.save({ conversationId: id });
|
|
555
445
|
},
|
|
556
|
-
[
|
|
446
|
+
[conversationStorage],
|
|
557
447
|
);
|
|
558
448
|
|
|
559
449
|
const sendMessage = useCallback(
|
|
@@ -570,19 +460,19 @@ export function useSseChatAdapter(
|
|
|
570
460
|
// The server is the single source of conversation history: it re-reads
|
|
571
461
|
// `chat_messages` by conversation id on every turn. The wire therefore
|
|
572
462
|
// carries ONLY the new user message — never the prior conversation.
|
|
573
|
-
const
|
|
463
|
+
const conversationId = conversationIdRef.current;
|
|
574
464
|
const targetPath = approvalAction ? endpointsRef.current.approvalToolUrl : endpointsRef.current.chatStreamUrl;
|
|
575
465
|
const requestBody = approvalAction
|
|
576
466
|
? // Shared with every other transport that resolves a hub proposal —
|
|
577
467
|
// the body shape is the hub's, not this adapter's. `conversationId`
|
|
578
468
|
// is always present here: an approval can only happen inside an
|
|
579
469
|
// established conversation (the proposal turn captured the id).
|
|
580
|
-
buildConfirmToolBody({ ...approvalAction, conversationId
|
|
470
|
+
buildConfirmToolBody({ ...approvalAction, conversationId })
|
|
581
471
|
: {
|
|
582
472
|
messages: [{ role: 'user', content: text }],
|
|
583
473
|
...(commandOverride ? { commandOverride } : {}),
|
|
584
474
|
...(attachments && attachments.length > 0 ? { pendingAttachments: attachments } : {}),
|
|
585
|
-
...(
|
|
475
|
+
...(conversationId ? { conversationId } : {}),
|
|
586
476
|
};
|
|
587
477
|
|
|
588
478
|
// Optimistic user bubble + assistant placeholder + phase 'thinking'
|
|
@@ -591,7 +481,6 @@ export function useSseChatAdapter(
|
|
|
591
481
|
|
|
592
482
|
const ctrl = new AbortController();
|
|
593
483
|
abortControllerRef.current = ctrl;
|
|
594
|
-
let mintedThisTurn = false;
|
|
595
484
|
|
|
596
485
|
try {
|
|
597
486
|
// `embedAuthedFetch` carries the bearer-act-as headers (+ Supabase
|
|
@@ -624,19 +513,7 @@ export function useSseChatAdapter(
|
|
|
624
513
|
if (done) break;
|
|
625
514
|
if (ctrl.signal.aborted) break;
|
|
626
515
|
for (const event of frameDecoder.push(value)) {
|
|
627
|
-
|
|
628
|
-
mintedThisTurn = true;
|
|
629
|
-
// Optimistic row so the list shows the new conversation at
|
|
630
|
-
// once; the end-of-turn reload swaps in the server's title.
|
|
631
|
-
// NEUTRAL placeholder — the SERVER owns titles (it strips slash
|
|
632
|
-
// commands + attachment markdown and cuts at a word boundary),
|
|
633
|
-
// so guessing here would flash a signed attachment URL or a
|
|
634
|
-
// `/command` token, and a naive slice can split an emoji.
|
|
635
|
-
const mintedId = conversationIdRef.current;
|
|
636
|
-
if (conversationsApi && !hidden && mintedId) {
|
|
637
|
-
upsertDialogTop({ id: mintedId, title: 'New chat', timestamp: new Date() });
|
|
638
|
-
}
|
|
639
|
-
}
|
|
516
|
+
captureConversationId(event);
|
|
640
517
|
applyEvent(event);
|
|
641
518
|
}
|
|
642
519
|
}
|
|
@@ -673,33 +550,9 @@ export function useSseChatAdapter(
|
|
|
673
550
|
// path streams no text — and returns the phase to idle).
|
|
674
551
|
flushDeltas();
|
|
675
552
|
mutate(r => r.endSseTurn());
|
|
676
|
-
// Keep the managed list in step with the transcript: a first turn
|
|
677
|
-
// re-reads the list (server-derived title replaces the placeholder,
|
|
678
|
-
// the row is persisted by the time the stream ends); a later turn
|
|
679
|
-
// just bumps the row to the top.
|
|
680
|
-
if (conversationsApi && !ctrl.signal.aborted) {
|
|
681
|
-
if (mintedThisTurn) {
|
|
682
|
-
reloadDialogs();
|
|
683
|
-
} else if (conversationIdRef.current) {
|
|
684
|
-
// Re-insert at the TOP rather than patching in place: the server
|
|
685
|
-
// has moved this row to the head of `last_message_at desc`, so an
|
|
686
|
-
// in-place bump would leave the rail's order and its
|
|
687
|
-
// Today/Yesterday grouping disagreeing with the server.
|
|
688
|
-
bumpDialogToTop(conversationIdRef.current);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
553
|
}
|
|
692
554
|
},
|
|
693
|
-
[
|
|
694
|
-
mutate,
|
|
695
|
-
applyEvent,
|
|
696
|
-
flushDeltas,
|
|
697
|
-
captureConversationId,
|
|
698
|
-
conversationsApi,
|
|
699
|
-
upsertDialogTop,
|
|
700
|
-
reloadDialogs,
|
|
701
|
-
bumpDialogToTop,
|
|
702
|
-
],
|
|
555
|
+
[mutate, applyEvent, flushDeltas, captureConversationId],
|
|
703
556
|
);
|
|
704
557
|
sendMessageRef.current = sendMessage;
|
|
705
558
|
|
|
@@ -715,34 +568,11 @@ export function useSseChatAdapter(
|
|
|
715
568
|
// server-side; the NEXT send goes out id-less and the server mints a
|
|
716
569
|
// fresh conversation (echoed back and re-captured then). Resetting the
|
|
717
570
|
// hydration guard means a re-captured id can hydrate again if needed.
|
|
718
|
-
|
|
571
|
+
conversationIdRef.current = null;
|
|
572
|
+
conversationStorage.clear();
|
|
719
573
|
hydrationSendCountRef.current = 0;
|
|
720
574
|
hydratedKeyRef.current = null;
|
|
721
|
-
}, [mutate,
|
|
722
|
-
|
|
723
|
-
/** Open a conversation from the managed list. Idempotent on the active id. */
|
|
724
|
-
const selectDialog = useCallback(
|
|
725
|
-
(id: string | null) => {
|
|
726
|
-
if (id === conversationIdRef.current) return;
|
|
727
|
-
switchConversation(id);
|
|
728
|
-
},
|
|
729
|
-
[switchConversation],
|
|
730
|
-
);
|
|
731
|
-
|
|
732
|
-
const dialogCapabilities = useMemo<ChatDialogCapabilities | undefined>(
|
|
733
|
-
() =>
|
|
734
|
-
conversationsApi
|
|
735
|
-
? {
|
|
736
|
-
canRename: true,
|
|
737
|
-
canArchive: true,
|
|
738
|
-
fetchArchivedDialogs,
|
|
739
|
-
unarchiveDialog,
|
|
740
|
-
searchQuery: dialogSearch,
|
|
741
|
-
onSearchChange: setDialogSearch,
|
|
742
|
-
}
|
|
743
|
-
: undefined,
|
|
744
|
-
[conversationsApi, fetchArchivedDialogs, unarchiveDialog, dialogSearch],
|
|
745
|
-
);
|
|
575
|
+
}, [mutate, conversationStorage, hydratedKeyRef]);
|
|
746
576
|
|
|
747
577
|
// ─── Public message mapping (sendIdx fan-out lookup) ──────────────────────
|
|
748
578
|
// Index sources/scrollAnchor by USER-SEND count (`sendIdx`), not by
|
|
@@ -891,30 +721,26 @@ export function useSseChatAdapter(
|
|
|
891
721
|
/** Cross-call usage breakdown (Haiku rewriter/classifier/summarizer
|
|
892
722
|
* token counts). null until the trailing usage frame lands. */
|
|
893
723
|
currentUsageBreakdown: latestMeta?.breakdown ?? null,
|
|
894
|
-
// ─── Dialog management
|
|
895
|
-
//
|
|
896
|
-
//
|
|
897
|
-
//
|
|
898
|
-
//
|
|
899
|
-
//
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
dialogsError,
|
|
904
|
-
reloadDialogs,
|
|
905
|
-
hasMoreDialogs,
|
|
906
|
-
loadMoreDialogs,
|
|
907
|
-
renameDialog,
|
|
908
|
-
archiveDialog,
|
|
909
|
-
// New chat = `clearMessages` (the server mints on the next send); there is
|
|
910
|
-
// no create call. Delete is not offered — archive replaces it.
|
|
724
|
+
// ─── Dialog management — stubs for v1 ────────────────────────────────
|
|
725
|
+
// Guide mode keeps ONE server-side conversation per stored id
|
|
726
|
+
// (`chat_conversations`, hydrated on mount). Surfacing multiple threads
|
|
727
|
+
// as a structured dialog list is a follow-up; for now the shape is
|
|
728
|
+
// satisfied with empty defaults so the unified contract type-checks and
|
|
729
|
+
// EmbeddableChat hides sidebar affordances when `dialogs.length === 0`.
|
|
730
|
+
dialogs: SSE_EMPTY_DIALOGS,
|
|
731
|
+
activeDialogId: null,
|
|
732
|
+
selectDialog: noopSelectDialog,
|
|
911
733
|
startNewDialog: noopStartNewDialog,
|
|
912
734
|
deleteDialog: noopDeleteDialog,
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
735
|
+
renameDialog: noopRenameDialog,
|
|
736
|
+
archiveDialog: noopArchiveDialog,
|
|
737
|
+
isDialogsLoading: false,
|
|
738
|
+
// SSE/guide has no server-side dialog list — never errors, nothing to retry.
|
|
739
|
+
dialogsError: false,
|
|
740
|
+
reloadDialogs: noopReloadDialogs,
|
|
741
|
+
isMessagesLoading: false,
|
|
742
|
+
hasMoreDialogs: false,
|
|
743
|
+
loadMoreDialogs: noopAsync,
|
|
918
744
|
hasMoreMessages: false,
|
|
919
745
|
loadMoreMessages: noopAsync,
|
|
920
746
|
approveRequest: noopApproveRequest,
|
|
@@ -220,11 +220,6 @@ export function useUnifiedChat(options: UseUnifiedChatOptions): UnifiedChatState
|
|
|
220
220
|
setDialogScope,
|
|
221
221
|
hasMoreMessages: activeState.hasMoreMessages,
|
|
222
222
|
loadMoreMessages,
|
|
223
|
-
// Adapter-owned dialog list flag + capabilities (SSE with a
|
|
224
|
-
// conversations endpoint, NATS managed mode). Forwarded verbatim —
|
|
225
|
-
// `EmbeddableChat` gates the history UI on them.
|
|
226
|
-
dialogsManaged: activeState.dialogsManaged,
|
|
227
|
-
dialogCapabilities: activeState.dialogCapabilities,
|
|
228
223
|
// Approvals
|
|
229
224
|
approveRequest,
|
|
230
225
|
rejectRequest,
|
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
<!-- source-hash:
|
|
1
|
+
<!-- source-hash: c1ee0588313988b2559f2016a0a5d7cf -->
|
|
2
2
|
Unified contract type definitions for the `useChat` hook's transport-agnostic return shape, shared by both the SSE (Guide mode) and NATS (Mingo mode) transport adapters.
|
|
3
3
|
|
|
4
|
-
### Dialog-list host contract (shared by both adapters)
|
|
5
|
-
|
|
6
|
-
| Export | Kind | Description |
|
|
7
|
-
|---|---|---|
|
|
8
|
-
| `FetchDialogsParams` | interface | `{ cursor?, limit?, search? }` — page-fetch params passed to a host `fetchDialogs`. `search` is present ONLY when the adapter runs a server-side list search |
|
|
9
|
-
| `FetchDialogsResult` | interface | `{ dialogs: DialogItem[], nextCursor: string \| null }` — `null` terminates infinite scroll |
|
|
10
|
-
| `ChatDialogCapabilities` | interface | What a transport (or an injecting host) can honour: `canRename`, `canArchive`, `fetchArchivedDialogs`, `unarchiveDialog`, `searchQuery`, `onSearchChange`, `onCopyLink`. ONE shape for both the adapter-owned (`UnifiedChatState.dialogCapabilities`) and host-injected (`EmbeddableChatProps.mingoDialogCapabilities`) paths |
|
|
11
|
-
|
|
12
|
-
`renameDialog` / `archiveDialog` / `deleteDialog` REJECT on a failed backend write (rename after rolling its optimistic title back) so a confirmation modal can stay open — callers must await or catch.
|
|
13
|
-
|
|
14
|
-
`UnifiedChatState` additions: **`dialogsManaged?: boolean`** — true when the active adapter owns a server-side dialog list (NATS managed mode, or the SSE/Guide adapter with `ChatRuntime.endpoints.chatConversationsUrl`); `EmbeddableChat` gates its history UI on this rather than on the mode, so Guide mode gets the same "Current Chats" rail as Mingo. **`dialogCapabilities?: ChatDialogCapabilities`** — read in preference to the legacy per-mode derivations, so the ⋯ menu never advertises an unwired action.
|
|
15
|
-
|
|
16
4
|
## Key Components
|
|
17
5
|
|
|
18
6
|
| Export | Kind | Description |
|
|
@@ -24,48 +24,6 @@ import type { DialogItem } from './component.types';
|
|
|
24
24
|
import type { ChatContextItem } from './context-item.types';
|
|
25
25
|
import type { MessageSegment, ScrollAnchor } from './message.types';
|
|
26
26
|
|
|
27
|
-
// ─── Dialog-list host contract (shared by the NATS + SSE adapters) ───────────
|
|
28
|
-
|
|
29
|
-
/** Page-fetch parameters passed to a host `fetchDialogs` callback. The
|
|
30
|
-
* adapter owns the cursor — the host only resolves it against the backend.
|
|
31
|
-
* `search` is present ONLY when the adapter runs a server-side list search
|
|
32
|
-
* (never spread as an `undefined` key). */
|
|
33
|
-
export interface FetchDialogsParams {
|
|
34
|
-
cursor?: string;
|
|
35
|
-
limit?: number;
|
|
36
|
-
search?: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** Successful `fetchDialogs` response. `nextCursor: null` means "no more
|
|
40
|
-
* pages" — used to terminate the infinite-scroll observer in the list. */
|
|
41
|
-
export interface FetchDialogsResult {
|
|
42
|
-
dialogs: DialogItem[];
|
|
43
|
-
nextCursor: string | null;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Dialog-management capabilities a transport exposes to `EmbeddableChat`.
|
|
48
|
-
* Structurally identical to the host-injected `mingoDialogCapabilities`
|
|
49
|
-
* prop — one shape, whether the list is host-owned (openframe `mingoState`)
|
|
50
|
-
* or adapter-owned (`UnifiedChatState.dialogCapabilities`).
|
|
51
|
-
*/
|
|
52
|
-
export interface ChatDialogCapabilities {
|
|
53
|
-
/** Show "Rename chat" in the row ⋯ menu and the conversation header. */
|
|
54
|
-
canRename?: boolean;
|
|
55
|
-
/** Show "Archive chat" in the row ⋯ menu and the conversation header. */
|
|
56
|
-
canArchive?: boolean;
|
|
57
|
-
/** Pages archived dialogs — presence gates the archive page + header button. */
|
|
58
|
-
fetchArchivedDialogs?: (params: FetchDialogsParams) => Promise<FetchDialogsResult>;
|
|
59
|
-
/** Restores an archived dialog — presence gates the restore button. */
|
|
60
|
-
unarchiveDialog?: (id: string) => Promise<void>;
|
|
61
|
-
/** Current list-search term (host/adapter owned; the list never filters). */
|
|
62
|
-
searchQuery?: string;
|
|
63
|
-
/** Presence wires the header magnifier + the rail's search field. */
|
|
64
|
-
onSearchChange?: (query: string) => void;
|
|
65
|
-
/** "Copy chat link" — the owner of the URL shape + clipboard write. */
|
|
66
|
-
onCopyLink?: (dialog: DialogItem) => void;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
27
|
// ─── Per-dialog token usage (Mingo backend telemetry) ────────────────────────
|
|
70
28
|
|
|
71
29
|
/**
|
|
@@ -399,23 +357,17 @@ export interface UnifiedChatState {
|
|
|
399
357
|
* adapter doesn't support creation, resolves to `null`. */
|
|
400
358
|
startNewDialog: () => Promise<string | null>;
|
|
401
359
|
|
|
402
|
-
/** Delete a dialog from history. No-op
|
|
403
|
-
* expose `deleteDialog
|
|
404
|
-
*
|
|
405
|
-
* REJECTS when the backend call fails — the row is kept and the error is
|
|
406
|
-
* re-thrown so a confirmation modal can stay open for a retry instead of
|
|
407
|
-
* closing over a write that never landed. Callers must `await`/`.catch()`;
|
|
408
|
-
* a bare `void state.deleteDialog(id)` produces an unhandled rejection. */
|
|
360
|
+
/** Delete a dialog from history. No-op when the adapter doesn't
|
|
361
|
+
* expose `deleteDialog` (Guide localStorage always supports it;
|
|
362
|
+
* Mingo gates on the host-provided callback). */
|
|
409
363
|
deleteDialog: (id: string) => Promise<void>;
|
|
410
364
|
|
|
411
365
|
/** Rename a dialog. Optimistically updates the title in the local list.
|
|
412
|
-
* No-op
|
|
413
|
-
* REJECTS on failure AFTER rolling the title back — see `deleteDialog`. */
|
|
366
|
+
* No-op when the adapter doesn't expose a rename callback. */
|
|
414
367
|
renameDialog: (id: string, title: string) => Promise<void>;
|
|
415
368
|
|
|
416
|
-
/** Archive a dialog (removes it from the active list). No-op
|
|
417
|
-
*
|
|
418
|
-
* REJECTS on failure, keeping the row — see `deleteDialog`. */
|
|
369
|
+
/** Archive a dialog (removes it from the active list). No-op when the
|
|
370
|
+
* adapter doesn't expose an archive callback. */
|
|
419
371
|
archiveDialog: (id: string) => Promise<void>;
|
|
420
372
|
|
|
421
373
|
/** True while the dialog list is being fetched for the first time. */
|
|
@@ -453,26 +405,6 @@ export interface UnifiedChatState {
|
|
|
453
405
|
/** Fetch the next page of historical messages for the active dialog. */
|
|
454
406
|
loadMoreMessages: () => Promise<void>;
|
|
455
407
|
|
|
456
|
-
/**
|
|
457
|
-
* True when the active adapter OWNS a server-side dialog list (NATS
|
|
458
|
-
* managed-dialog mode, or the SSE/Guide adapter with
|
|
459
|
-
* `ChatRuntime.endpoints.chatConversationsUrl` set). `EmbeddableChat` gates
|
|
460
|
-
* the history list / archive / rename affordances on this flag — transport-
|
|
461
|
-
* agnostic, so Guide mode gets the same "Current Chats" UI as Mingo mode.
|
|
462
|
-
* Undefined/false = the single-thread panel (bare transports, host-injected
|
|
463
|
-
* `mingoState`, which drives the UI through the Mingo mode check instead).
|
|
464
|
-
*/
|
|
465
|
-
dialogsManaged?: boolean;
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* Dialog-management capabilities the active adapter can honour. Only
|
|
469
|
-
* meaningful when `dialogsManaged` is true; `EmbeddableChat` reads it in
|
|
470
|
-
* preference to the legacy per-mode derivations so the row ⋯ menu, the
|
|
471
|
-
* archive page and the header search never advertise an action the
|
|
472
|
-
* transport hasn't wired.
|
|
473
|
-
*/
|
|
474
|
-
dialogCapabilities?: ChatDialogCapabilities;
|
|
475
|
-
|
|
476
408
|
// ─── Approval mutations (Mingo agent tool-call workflow) ──────────────────
|
|
477
409
|
|
|
478
410
|
/** Approve an in-flight tool-call request. Errors surface via the
|
|
@@ -41,13 +41,6 @@ export {
|
|
|
41
41
|
type HistoryPrependResult,
|
|
42
42
|
} from './history-merge';
|
|
43
43
|
|
|
44
|
-
// Conversation-list wire client (`ChatRuntime.endpoints.chatConversationsUrl`)
|
|
45
|
-
export {
|
|
46
|
-
createChatConversationsApi,
|
|
47
|
-
type ChatConversationsApi,
|
|
48
|
-
type ChatConversationStatus,
|
|
49
|
-
} from './chat-conversations-api';
|
|
50
|
-
|
|
51
44
|
// Tool call helpers
|
|
52
45
|
export { getCommandText } from './tool-call-helpers';
|
|
53
46
|
|
|
@@ -6,7 +6,7 @@ import type { NoDataProps } from '../no-data';
|
|
|
6
6
|
import { useDataTableContext } from './data-table';
|
|
7
7
|
import { DataTableEmpty } from './data-table-empty';
|
|
8
8
|
import { DataTableRow } from './data-table-row';
|
|
9
|
-
import { DataTableSkeleton,
|
|
9
|
+
import { DataTableSkeleton, PlaceholderRows, ReservedEmptyState } from './data-table-skeleton';
|
|
10
10
|
|
|
11
11
|
export interface DataTableBodyProps<T = unknown> {
|
|
12
12
|
/** Show skeleton rows while `loading` is true and data is empty. */
|
|
@@ -117,10 +117,13 @@ export function DataTableBody<T = unknown>({
|
|
|
117
117
|
// slots here and center the empty state over them.
|
|
118
118
|
if (minRows) {
|
|
119
119
|
return (
|
|
120
|
-
<
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
<ReservedEmptyState
|
|
121
|
+
count={minRows}
|
|
122
|
+
gapClassName={cn('gap-[var(--spacing-system-xsf)]', className)}
|
|
123
|
+
rowHeightClassName={rowHeightClassName}
|
|
124
|
+
>
|
|
125
|
+
{empty}
|
|
126
|
+
</ReservedEmptyState>
|
|
124
127
|
);
|
|
125
128
|
}
|
|
126
129
|
|
|
@@ -153,47 +156,3 @@ export function DataTableBody<T = unknown>({
|
|
|
153
156
|
</div>
|
|
154
157
|
);
|
|
155
158
|
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Invisible rows that occupy exactly one row slot each.
|
|
159
|
-
*
|
|
160
|
-
* THE height reservation for a table whose page is short or empty — both call
|
|
161
|
-
* sites use it, so a padded page and an empty one are the same height by
|
|
162
|
-
* construction rather than by two matching guesses.
|
|
163
|
-
*/
|
|
164
|
-
function PlaceholderRows({ count, rowHeightClassName }: { count: number; rowHeightClassName?: string }) {
|
|
165
|
-
return (
|
|
166
|
-
<>
|
|
167
|
-
{Array.from({ length: count }).map((_, i) => (
|
|
168
|
-
<div
|
|
169
|
-
key={`placeholder-${i}`}
|
|
170
|
-
// `border-transparent`, not no border: a real row card draws a 1px
|
|
171
|
-
// border on each side, so its outer block is the inner height PLUS 2.
|
|
172
|
-
// A pad row without one is 2px shorter than the row it stands in for
|
|
173
|
-
// — invisible per row, 54px over a 27-row remainder, which is the
|
|
174
|
-
// same shift `minRows` exists to prevent.
|
|
175
|
-
className={cn(
|
|
176
|
-
'pointer-events-none relative overflow-hidden rounded-md border border-transparent',
|
|
177
|
-
// The stated slot height belongs on the CARD, exactly as a real
|
|
178
|
-
// row carries it — a real row with a sub-row is taller than its
|
|
179
|
-
// cells, so reserving the cells' height here left every pad row
|
|
180
|
-
// short by the sub-row.
|
|
181
|
-
rowHeightClassName,
|
|
182
|
-
)}
|
|
183
|
-
aria-hidden="true"
|
|
184
|
-
>
|
|
185
|
-
<div
|
|
186
|
-
className={cn('hidden py-0 md:flex', ROW_SHELL_CLASSES, rowHeightClassName ? 'h-full' : ROW_HEIGHT_DESKTOP)}
|
|
187
|
-
/>
|
|
188
|
-
<div
|
|
189
|
-
className={cn(
|
|
190
|
-
'flex justify-start py-0 md:hidden',
|
|
191
|
-
ROW_SHELL_CLASSES,
|
|
192
|
-
rowHeightClassName ? 'h-full' : ROW_HEIGHT_MOBILE,
|
|
193
|
-
)}
|
|
194
|
-
/>
|
|
195
|
-
</div>
|
|
196
|
-
))}
|
|
197
|
-
</>
|
|
198
|
-
);
|
|
199
|
-
}
|