@flamingo-stack/openframe-frontend-core 0.0.598 → 0.0.599-2039.5716.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat-protocol/index.cjs +8 -1
- package/dist/chat-protocol/index.cjs.map +1 -1
- package/dist/chat-protocol/index.d.ts +1 -0
- package/dist/chat-protocol/index.d.ts.map +1 -1
- package/dist/chat-protocol/index.js +7 -2
- package/dist/chat-protocol/index.js.map +1 -1
- package/dist/chat-protocol/nats-decoder.d.ts.map +1 -1
- package/dist/chat-protocol/wire-narrow.d.ts +17 -0
- package/dist/chat-protocol/wire-narrow.d.ts.map +1 -0
- package/dist/{chunk-VLJTJAHJ.cjs → chunk-2B4HSYAX.cjs} +25 -25
- package/dist/{chunk-VLJTJAHJ.cjs.map → chunk-2B4HSYAX.cjs.map} +1 -1
- package/dist/{chunk-UE7OFLLS.cjs → chunk-2GCBN73M.cjs} +14 -14
- package/dist/{chunk-UE7OFLLS.cjs.map → chunk-2GCBN73M.cjs.map} +1 -1
- package/dist/{chunk-STYNZ4QM.cjs → chunk-3IXDZI3R.cjs} +3 -3
- package/dist/{chunk-STYNZ4QM.cjs.map → chunk-3IXDZI3R.cjs.map} +1 -1
- package/dist/{chunk-DAPOBLAK.cjs → chunk-3RWSKUIN.cjs} +39 -39
- package/dist/{chunk-DAPOBLAK.cjs.map → chunk-3RWSKUIN.cjs.map} +1 -1
- package/dist/{chunk-VNSRNVPD.js → chunk-4HJYXP5O.js} +722 -406
- package/dist/chunk-4HJYXP5O.js.map +1 -0
- package/dist/{chunk-HWAYIK4U.cjs → chunk-4MOY5TQR.cjs} +22 -22
- package/dist/{chunk-HWAYIK4U.cjs.map → chunk-4MOY5TQR.cjs.map} +1 -1
- package/dist/{chunk-VIRTMRS4.js → chunk-4PBUEYAE.js} +7 -7
- package/dist/{chunk-TZPVRWPU.js → chunk-4TG5BWPE.js} +5 -5
- package/dist/{chunk-PTK3CINU.js → chunk-6JF65LRQ.js} +5 -5
- package/dist/{chunk-YWBAIFI2.cjs → chunk-6XISE63Q.cjs} +105 -105
- package/dist/{chunk-YWBAIFI2.cjs.map → chunk-6XISE63Q.cjs.map} +1 -1
- package/dist/{chunk-QD64Q4I2.cjs → chunk-A4HMGZ4L.cjs} +9 -9
- package/dist/{chunk-QD64Q4I2.cjs.map → chunk-A4HMGZ4L.cjs.map} +1 -1
- package/dist/{chunk-BK6CCQG6.js → chunk-AUCJ6I3R.js} +12 -12
- package/dist/{chunk-3WSS7C2V.cjs → chunk-BBBZ5QUB.cjs} +15 -15
- package/dist/{chunk-3WSS7C2V.cjs.map → chunk-BBBZ5QUB.cjs.map} +1 -1
- package/dist/{chunk-EVMHJB6X.js → chunk-BLUL2TE3.js} +4 -4
- package/dist/{chunk-GGQZBSFN.js → chunk-BVQEU5JB.js} +2 -2
- package/dist/{chunk-V2QK5W3O.cjs → chunk-BW644MGF.cjs} +3 -3
- package/dist/{chunk-V2QK5W3O.cjs.map → chunk-BW644MGF.cjs.map} +1 -1
- package/dist/{chunk-H64ZHSYR.cjs → chunk-CCWI3622.cjs} +4 -4
- package/dist/{chunk-H64ZHSYR.cjs.map → chunk-CCWI3622.cjs.map} +1 -1
- package/dist/{chunk-DI3SVVY5.cjs → chunk-COERKO4N.cjs} +85 -85
- package/dist/{chunk-DI3SVVY5.cjs.map → chunk-COERKO4N.cjs.map} +1 -1
- package/dist/{chunk-SE3PVN64.js → chunk-DZ44C6KB.js} +2 -2
- package/dist/{chunk-2SYX2Z7R.cjs → chunk-E27TMQRE.cjs} +34 -34
- package/dist/{chunk-2SYX2Z7R.cjs.map → chunk-E27TMQRE.cjs.map} +1 -1
- package/dist/{chunk-YH6IQTPI.cjs → chunk-EHAYNUOL.cjs} +3 -3
- package/dist/{chunk-YH6IQTPI.cjs.map → chunk-EHAYNUOL.cjs.map} +1 -1
- package/dist/{chunk-WZJOILPU.js → chunk-F2KBCLUG.js} +2 -2
- package/dist/{chunk-MYBXCWEI.js → chunk-FKBM6U43.js} +2 -2
- package/dist/{chunk-75YW6ET4.js → chunk-FNK4RZ25.js} +4 -4
- package/dist/{chunk-UG7JNQZY.cjs → chunk-GB5FPCUN.cjs} +37 -37
- package/dist/{chunk-UG7JNQZY.cjs.map → chunk-GB5FPCUN.cjs.map} +1 -1
- package/dist/{chunk-P24VPJTT.cjs → chunk-HJUXXWTM.cjs} +15 -15
- package/dist/{chunk-P24VPJTT.cjs.map → chunk-HJUXXWTM.cjs.map} +1 -1
- package/dist/{chunk-WPN545FW.js → chunk-ILJTXIEI.js} +12 -12
- package/dist/{chunk-YBPFIXV4.cjs → chunk-ITZDJYWI.cjs} +796 -480
- package/dist/chunk-ITZDJYWI.cjs.map +1 -0
- package/dist/{chunk-LRQCKSZC.js → chunk-IW746HJ7.js} +2 -2
- package/dist/{chunk-PX4IPM7Q.js → chunk-J62LLUDC.js} +3 -3
- package/dist/{chunk-M4YQUHOR.cjs → chunk-JJUV7Z4L.cjs} +15 -15
- package/dist/{chunk-M4YQUHOR.cjs.map → chunk-JJUV7Z4L.cjs.map} +1 -1
- package/dist/{chunk-GHYFVT52.js → chunk-JZF6EUMO.js} +5 -5
- package/dist/{chunk-JVZVVZOZ.cjs → chunk-KYGTR6EG.cjs} +9 -9
- package/dist/{chunk-JVZVVZOZ.cjs.map → chunk-KYGTR6EG.cjs.map} +1 -1
- package/dist/{chunk-QIKBISZM.cjs → chunk-L66UPFCQ.cjs} +242 -242
- package/dist/{chunk-QIKBISZM.cjs.map → chunk-L66UPFCQ.cjs.map} +1 -1
- package/dist/{chunk-NIAMPMKV.js → chunk-LJ4UG2SW.js} +4 -4
- package/dist/{chunk-WDWCQD75.js → chunk-MWQSHXYK.js} +9 -9
- package/dist/{chunk-BPVHDDNY.cjs → chunk-NLFST5II.cjs} +8 -8
- package/dist/{chunk-BPVHDDNY.cjs.map → chunk-NLFST5II.cjs.map} +1 -1
- package/dist/{chunk-SAEJGTCI.cjs → chunk-QPAPUIF3.cjs} +35 -35
- package/dist/{chunk-SAEJGTCI.cjs.map → chunk-QPAPUIF3.cjs.map} +1 -1
- package/dist/{chunk-HLPAVYK7.js → chunk-RSTEDWAT.js} +4 -4
- package/dist/{chunk-UAAXUFK6.js → chunk-RU3IKVY2.js} +3 -3
- package/dist/{chunk-EZM5DNII.js → chunk-S6WBBSII.js} +3 -3
- package/dist/{chunk-2JNCZDJR.js → chunk-TSCIVH7T.js} +2 -2
- package/dist/{chunk-RDTOMWDN.cjs → chunk-UPKZU6QU.cjs} +1 -1
- package/dist/chunk-UPKZU6QU.cjs.map +1 -0
- package/dist/{chunk-WCBRZCU4.cjs → chunk-UQEOAPAI.cjs} +9 -9
- package/dist/{chunk-WCBRZCU4.cjs.map → chunk-UQEOAPAI.cjs.map} +1 -1
- package/dist/{chunk-O4VZOA2Q.cjs → chunk-UXOOVP77.cjs} +3 -3
- package/dist/{chunk-O4VZOA2Q.cjs.map → chunk-UXOOVP77.cjs.map} +1 -1
- package/dist/{chunk-R4UV366K.js → chunk-UYLZAW6Y.js} +6 -6
- package/dist/{chunk-BZEWPW5A.cjs → chunk-VIBREYUK.cjs} +3 -3
- package/dist/{chunk-BZEWPW5A.cjs.map → chunk-VIBREYUK.cjs.map} +1 -1
- package/dist/{chunk-KHOZ52NR.js → chunk-XSMBLU44.js} +6 -6
- package/dist/{chunk-RYXIRVDC.js → chunk-YB6FI2G3.js} +1 -1
- package/dist/chunk-YB6FI2G3.js.map +1 -0
- package/dist/{chunk-XNPAVMPB.js → chunk-YG7DCXRD.js} +5 -5
- package/dist/components/case-studies/index.cjs +14 -14
- package/dist/components/case-studies/index.js +8 -8
- package/dist/components/chat/embeddable-chat.d.ts +10 -19
- package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
- package/dist/components/chat/hooks/index.d.ts +1 -0
- package/dist/components/chat/hooks/index.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-chat-history-hydration.d.ts +13 -3
- package/dist/components/chat/hooks/use-chat-history-hydration.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-managed-dialog-list.d.ts +53 -0
- package/dist/components/chat/hooks/use-managed-dialog-list.d.ts.map +1 -0
- package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts +2 -16
- package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-unified-chat.d.ts.map +1 -1
- package/dist/components/chat/index.cjs +9 -5
- package/dist/components/chat/index.cjs.map +1 -1
- package/dist/components/chat/index.js +8 -4
- package/dist/components/chat/types/unified-chat-state.types.d.ts +72 -6
- package/dist/components/chat/types/unified-chat-state.types.d.ts.map +1 -1
- package/dist/components/chat/utils/chat-conversations-api.d.ts +29 -0
- package/dist/components/chat/utils/chat-conversations-api.d.ts.map +1 -0
- package/dist/components/chat/utils/index.d.ts +1 -0
- package/dist/components/chat/utils/index.d.ts.map +1 -1
- package/dist/components/contact/index.cjs +9 -9
- package/dist/components/contact/index.js +8 -8
- package/dist/components/docs/index.cjs +12 -12
- package/dist/components/docs/index.js +11 -11
- package/dist/components/embeds/index.cjs +9 -9
- package/dist/components/embeds/index.js +8 -8
- package/dist/components/faq/index.cjs +10 -10
- package/dist/components/faq/index.js +9 -9
- package/dist/components/features/index.cjs +8 -8
- package/dist/components/features/index.js +7 -7
- package/dist/components/help-center-pages/index.cjs +31 -31
- package/dist/components/help-center-pages/index.js +22 -22
- package/dist/components/index.cjs +70 -66
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +26 -22
- package/dist/components/index.js.map +1 -1
- package/dist/components/meeting-scheduler/index.cjs +49 -49
- package/dist/components/meeting-scheduler/index.js +9 -9
- package/dist/components/navigation/index.cjs +11 -11
- package/dist/components/navigation/index.js +10 -10
- package/dist/components/onboarding-guides/index.cjs +12 -12
- package/dist/components/onboarding-guides/index.js +11 -11
- package/dist/components/related-content/index.cjs +7 -7
- package/dist/components/related-content/index.js +6 -6
- package/dist/components/tickets/index.cjs +13 -13
- package/dist/components/tickets/index.js +12 -12
- package/dist/components/ui/index.cjs +12 -8
- package/dist/components/ui/index.cjs.map +1 -1
- package/dist/components/ui/index.js +11 -7
- package/dist/contexts/chat-runtime-context.d.ts +12 -0
- package/dist/contexts/chat-runtime-context.d.ts.map +1 -1
- package/dist/contexts/index.cjs +2 -2
- package/dist/contexts/index.js +1 -1
- package/dist/hooks/index.cjs +5 -5
- package/dist/hooks/index.js +4 -4
- package/dist/index.cjs +16 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/chat-protocol/index.ts +1 -0
- package/src/chat-protocol/nats-decoder.ts +1 -5
- package/src/chat-protocol/wire-narrow.ts +22 -0
- package/src/components/chat/.embeddable-chat.md +4 -2
- package/src/components/chat/embeddable-chat.tsx +136 -84
- package/src/components/chat/hooks/.index.md +1 -1
- package/src/components/chat/hooks/.use-managed-dialog-list.md +31 -0
- package/src/components/chat/hooks/.use-nats-chat-adapter.md +3 -1
- package/src/components/chat/hooks/.use-sse-chat-adapter.md +8 -1
- package/src/components/chat/hooks/.use-unified-chat.md +2 -2
- package/src/components/chat/hooks/__tests__/managed-dialog-list.test.ts +280 -0
- package/src/components/chat/hooks/__tests__/nats-adapter-managed-dialogs.test.ts +173 -0
- package/src/components/chat/hooks/__tests__/sse-managed-dialogs.test.ts +310 -0
- package/src/components/chat/hooks/index.ts +2 -0
- package/src/components/chat/hooks/use-chat-history-hydration.ts +67 -24
- package/src/components/chat/hooks/use-managed-dialog-list.ts +339 -0
- package/src/components/chat/hooks/use-nats-chat-adapter.ts +65 -150
- package/src/components/chat/hooks/use-sse-chat-adapter.ts +233 -59
- package/src/components/chat/hooks/use-unified-chat.ts +5 -0
- package/src/components/chat/types/.unified-chat-state.types.md +13 -1
- package/src/components/chat/types/unified-chat-state.types.ts +79 -6
- package/src/components/chat/utils/.chat-conversations-api.md +16 -0
- package/src/components/chat/utils/.index.md +1 -1
- package/src/components/chat/utils/__tests__/chat-conversations-api-golden.test.ts +105 -0
- package/src/components/chat/utils/chat-conversations-api.ts +83 -0
- package/src/components/chat/utils/index.ts +7 -0
- package/src/contexts/.chat-runtime-context.md +3 -1
- package/src/contexts/chat-runtime-context.tsx +12 -0
- package/dist/chunk-RDTOMWDN.cjs.map +0 -1
- package/dist/chunk-RYXIRVDC.js.map +0 -1
- package/dist/chunk-VNSRNVPD.js.map +0 -1
- package/dist/chunk-YBPFIXV4.cjs.map +0 -1
- /package/dist/{chunk-VIRTMRS4.js.map → chunk-4PBUEYAE.js.map} +0 -0
- /package/dist/{chunk-TZPVRWPU.js.map → chunk-4TG5BWPE.js.map} +0 -0
- /package/dist/{chunk-PTK3CINU.js.map → chunk-6JF65LRQ.js.map} +0 -0
- /package/dist/{chunk-BK6CCQG6.js.map → chunk-AUCJ6I3R.js.map} +0 -0
- /package/dist/{chunk-EVMHJB6X.js.map → chunk-BLUL2TE3.js.map} +0 -0
- /package/dist/{chunk-GGQZBSFN.js.map → chunk-BVQEU5JB.js.map} +0 -0
- /package/dist/{chunk-SE3PVN64.js.map → chunk-DZ44C6KB.js.map} +0 -0
- /package/dist/{chunk-WZJOILPU.js.map → chunk-F2KBCLUG.js.map} +0 -0
- /package/dist/{chunk-MYBXCWEI.js.map → chunk-FKBM6U43.js.map} +0 -0
- /package/dist/{chunk-75YW6ET4.js.map → chunk-FNK4RZ25.js.map} +0 -0
- /package/dist/{chunk-WPN545FW.js.map → chunk-ILJTXIEI.js.map} +0 -0
- /package/dist/{chunk-LRQCKSZC.js.map → chunk-IW746HJ7.js.map} +0 -0
- /package/dist/{chunk-PX4IPM7Q.js.map → chunk-J62LLUDC.js.map} +0 -0
- /package/dist/{chunk-GHYFVT52.js.map → chunk-JZF6EUMO.js.map} +0 -0
- /package/dist/{chunk-NIAMPMKV.js.map → chunk-LJ4UG2SW.js.map} +0 -0
- /package/dist/{chunk-WDWCQD75.js.map → chunk-MWQSHXYK.js.map} +0 -0
- /package/dist/{chunk-HLPAVYK7.js.map → chunk-RSTEDWAT.js.map} +0 -0
- /package/dist/{chunk-UAAXUFK6.js.map → chunk-RU3IKVY2.js.map} +0 -0
- /package/dist/{chunk-EZM5DNII.js.map → chunk-S6WBBSII.js.map} +0 -0
- /package/dist/{chunk-2JNCZDJR.js.map → chunk-TSCIVH7T.js.map} +0 -0
- /package/dist/{chunk-R4UV366K.js.map → chunk-UYLZAW6Y.js.map} +0 -0
- /package/dist/{chunk-KHOZ52NR.js.map → chunk-XSMBLU44.js.map} +0 -0
- /package/dist/{chunk-XNPAVMPB.js.map → chunk-YG7DCXRD.js.map} +0 -0
|
@@ -79,7 +79,6 @@ import { useChatDialogManager } from './hooks/use-chat-dialog-manager';
|
|
|
79
79
|
import { useChatIdentity } from './hooks/use-chat-identity';
|
|
80
80
|
import { useCloseOnNavigation } from './hooks/use-close-on-navigation';
|
|
81
81
|
import { useEmptyStateConfig } from './hooks/use-empty-state-config';
|
|
82
|
-
import type { FetchDialogsParams, FetchDialogsResult } from './hooks/use-nats-chat-adapter';
|
|
83
82
|
import { fetchSlashCommands, useSlashCommandRegistry, type SlashCommandSummary } from './hooks/use-slash-commands';
|
|
84
83
|
import type { ChatSource, UseSseChatAdapterOptions } from './hooks/use-sse-chat-adapter';
|
|
85
84
|
import { useUnifiedChat, type ChatMode, type UseUnifiedChatModes } from './hooks/use-unified-chat';
|
|
@@ -91,10 +90,10 @@ import { MingoWelcome, type MingoWelcomeProps } from './mingo-welcome';
|
|
|
91
90
|
import { NavLinkAnchorViaRuntime } from './nav-link-anchor-via-runtime';
|
|
92
91
|
import { accentFromIdentityIcon, getAgentAccent } from './quick-action-chip';
|
|
93
92
|
import { SourceActionButton } from './source-action-button';
|
|
94
|
-
import type { ChatInputRef,
|
|
93
|
+
import type { ChatInputRef, SlashCommandActionId } from './types/component.types';
|
|
95
94
|
import type { ChatContextItem, ChatContextPickerConfig } from './types/context-item.types';
|
|
96
95
|
import type { MessageSegment, Message } from './types/message.types';
|
|
97
|
-
import type { UnifiedChatState } from './types/unified-chat-state.types';
|
|
96
|
+
import type { ChatDialogCapabilities, UnifiedChatState } from './types/unified-chat-state.types';
|
|
98
97
|
import { formatChatAttachmentMarkdownForBubble } from './utils/chat-attachment-markdown';
|
|
99
98
|
import { resolveHrefForRuntime } from './utils/chat-nav-resolution';
|
|
100
99
|
import { chatChipClass } from './utils/chip-styles';
|
|
@@ -105,16 +104,41 @@ import { formatSingularLookupInvocation } from './utils/slash-dispatch-utils';
|
|
|
105
104
|
import { getSourceIconName } from './utils/source-icons';
|
|
106
105
|
import { resolveSourceRowCTA, sourceRowCtxFromRuntime } from './utils/source-row-cta';
|
|
107
106
|
|
|
107
|
+
/**
|
|
108
|
+
* Split (wide) Mingo layout metrics (Figma 113:60931 / 113:63630). The
|
|
109
|
+
* "Current Chats" rail is a fixed 320px column; the chat block fills the rest
|
|
110
|
+
* with a 400px floor. Below their sum the panel is too tight for two columns,
|
|
111
|
+
* so the layout falls back to the stacked (single-column) view where the
|
|
112
|
+
* history renders inline in the Mingo empty state. Purely width-driven and
|
|
113
|
+
* self-contained — the host wires nothing.
|
|
114
|
+
*/
|
|
115
|
+
const HISTORY_RAIL_WIDTH = 320;
|
|
116
|
+
const CHAT_BLOCK_MIN_WIDTH = 400;
|
|
117
|
+
const SPLIT_MIN_WIDTH = HISTORY_RAIL_WIDTH + CHAT_BLOCK_MIN_WIDTH;
|
|
118
|
+
|
|
108
119
|
// Desktop drawer opens at this fraction of the viewport width (clamped to the
|
|
109
120
|
// Drawer's own min/max). The user can still resize (persisted per DRAWER_WIDTH_KEY).
|
|
110
121
|
const DRAWER_DEFAULT_WIDTH_RATIO = 0.5;
|
|
111
122
|
// Bump the suffix whenever the default policy changes so previously-persisted
|
|
112
123
|
// widths (e.g. the old fixed 750px / earlier 30% default) reset on next open.
|
|
113
|
-
const DRAWER_WIDTH_KEY = 'mingo-chat-width-
|
|
124
|
+
const DRAWER_WIDTH_KEY = 'mingo-chat-width-v4';
|
|
114
125
|
const DRAWER_DEFAULT_WIDTH_PX = 750; // SSR fallback before the viewport is known
|
|
115
|
-
|
|
126
|
+
/**
|
|
127
|
+
* A panel that owns a dialog list opens WIDE ENOUGH TO SPLIT, so the "Current
|
|
128
|
+
* Chats" rail sits beside the conversation instead of replacing it.
|
|
129
|
+
*
|
|
130
|
+
* 50% of the viewport is under `SPLIT_MIN_WIDTH` on any screen narrower than
|
|
131
|
+
* 1440, which silently downgraded every such user to the stacked single-column
|
|
132
|
+
* list — the layout meant for phones. The floor is the measured panel width the
|
|
133
|
+
* split needs plus a few px of chrome, and the Drawer still clamps it to the
|
|
134
|
+
* viewport, so a genuinely small screen keeps the stacked view.
|
|
135
|
+
*/
|
|
136
|
+
const SPLIT_DEFAULT_WIDTH_ALLOWANCE = 16;
|
|
137
|
+
function drawerDefaultWidth(withHistoryRail: boolean): number {
|
|
116
138
|
if (typeof window === 'undefined') return DRAWER_DEFAULT_WIDTH_PX;
|
|
117
|
-
|
|
139
|
+
const ratioWidth = Math.round(window.innerWidth * DRAWER_DEFAULT_WIDTH_RATIO);
|
|
140
|
+
if (!withHistoryRail) return ratioWidth;
|
|
141
|
+
return Math.max(ratioWidth, SPLIT_MIN_WIDTH + SPLIT_DEFAULT_WIDTH_ALLOWANCE);
|
|
118
142
|
}
|
|
119
143
|
|
|
120
144
|
// =============================================================================
|
|
@@ -214,23 +238,16 @@ export interface EmbeddableChatProps {
|
|
|
214
238
|
* When the host injects `mingoState`, it doesn't pass `modes.mingo` (that
|
|
215
239
|
* would re-activate the idle built-in adapter), so the rename/archive/
|
|
216
240
|
* restore/archive-page affordances can't read their capability flags off the
|
|
217
|
-
* callback config. Supply them here instead.
|
|
218
|
-
*
|
|
219
|
-
*
|
|
241
|
+
* callback config. Supply them here instead. Default OFF: the row ⋯ menu and
|
|
242
|
+
* the archive page appear only when the host opts in, so nothing advertises
|
|
243
|
+
* an action the host hasn't wired. Ignored unless `mingoState` is set.
|
|
244
|
+
*
|
|
245
|
+
* Same shape an adapter reports through `UnifiedChatState.dialogCapabilities`
|
|
246
|
+
* (`ChatDialogCapabilities`) — one type, whether the list is host-owned or
|
|
247
|
+
* adapter-owned. `onCopyLink` adds "Copy chat link" to the header ⋯ menu and
|
|
248
|
+
* every row menu; the host owns the URL shape and the clipboard write.
|
|
220
249
|
*/
|
|
221
|
-
mingoDialogCapabilities?:
|
|
222
|
-
canRename?: boolean;
|
|
223
|
-
canArchive?: boolean;
|
|
224
|
-
fetchArchivedDialogs?: (params: FetchDialogsParams) => Promise<FetchDialogsResult>;
|
|
225
|
-
unarchiveDialog?: (id: string) => Promise<void>;
|
|
226
|
-
searchQuery?: string;
|
|
227
|
-
onSearchChange?: (query: string) => void;
|
|
228
|
-
/** Copy a shareable link to a conversation — adds "Copy chat link" to the
|
|
229
|
-
* header ⋯ menu and every dialog row menu. The host owns the URL shape and
|
|
230
|
-
* the clipboard write; the panel knows neither the app's routes nor whether
|
|
231
|
-
* a clipboard is available. Omit to hide the action. */
|
|
232
|
-
onCopyLink?: (dialog: DialogItem) => void;
|
|
233
|
-
};
|
|
250
|
+
mingoDialogCapabilities?: ChatDialogCapabilities;
|
|
234
251
|
|
|
235
252
|
/**
|
|
236
253
|
* Controlled active-mode. When provided, `onActiveModeChange` MUST
|
|
@@ -424,18 +441,6 @@ const mentionTokenOf = (key: string, markerByType: Map<string, string>): string
|
|
|
424
441
|
*/
|
|
425
442
|
const FALLBACK_TOP_RETRIEVED = 3;
|
|
426
443
|
|
|
427
|
-
/**
|
|
428
|
-
* Split (wide) Mingo layout metrics (Figma 113:60931 / 113:63630). The
|
|
429
|
-
* "Current Chats" rail is a fixed 320px column; the chat block fills the rest
|
|
430
|
-
* with a 400px floor. Below their sum the panel is too tight for two columns,
|
|
431
|
-
* so the layout falls back to the stacked (single-column) view where the
|
|
432
|
-
* history renders inline in the Mingo empty state. Purely width-driven and
|
|
433
|
-
* self-contained — the host wires nothing.
|
|
434
|
-
*/
|
|
435
|
-
const HISTORY_RAIL_WIDTH = 320;
|
|
436
|
-
const CHAT_BLOCK_MIN_WIDTH = 400;
|
|
437
|
-
const SPLIT_MIN_WIDTH = HISTORY_RAIL_WIDTH + CHAT_BLOCK_MIN_WIDTH;
|
|
438
|
-
|
|
439
444
|
/** Persists the user's rail collapse choice across drawer open/close + reloads. */
|
|
440
445
|
const RAIL_COLLAPSED_STORAGE_KEY = 'mingo-chat-history-collapsed';
|
|
441
446
|
|
|
@@ -1074,38 +1079,6 @@ function EmbeddableChatInner({
|
|
|
1074
1079
|
return { guide: guideOptions };
|
|
1075
1080
|
}, [modes, tableIdForDocumentType]);
|
|
1076
1081
|
|
|
1077
|
-
// Resolve dialog-management capabilities (rename / archive / archive-page /
|
|
1078
|
-
// restore) from a single source. With injected `mingoState` they come from
|
|
1079
|
-
// `mingoDialogCapabilities` (the host doesn't pass `modes.mingo`); otherwise
|
|
1080
|
-
// from the callback-config shape, where the presence of a callback IS the
|
|
1081
|
-
// capability. Both feed the same gating below so the JSX has one source.
|
|
1082
|
-
const mingoCaps = useMemo(() => {
|
|
1083
|
-
if (mingoState) {
|
|
1084
|
-
// Default OFF: the row ⋯ menu (Rename / Archive) and the archive page are
|
|
1085
|
-
// shown only when the host explicitly opts in — same capability-gating as
|
|
1086
|
-
// the archive button (`fetchArchivedDialogs` presence). Otherwise the menu
|
|
1087
|
-
// would advertise actions the host hasn't actually wired (no-ops).
|
|
1088
|
-
return {
|
|
1089
|
-
canRename: mingoDialogCapabilities?.canRename ?? false,
|
|
1090
|
-
canArchive: mingoDialogCapabilities?.canArchive ?? false,
|
|
1091
|
-
fetchArchivedDialogs: mingoDialogCapabilities?.fetchArchivedDialogs,
|
|
1092
|
-
unarchiveDialog: mingoDialogCapabilities?.unarchiveDialog,
|
|
1093
|
-
searchQuery: mingoDialogCapabilities?.searchQuery,
|
|
1094
|
-
onSearchChange: mingoDialogCapabilities?.onSearchChange,
|
|
1095
|
-
onCopyLink: mingoDialogCapabilities?.onCopyLink,
|
|
1096
|
-
};
|
|
1097
|
-
}
|
|
1098
|
-
return {
|
|
1099
|
-
canRename: !!effectiveModes.mingo?.renameDialog,
|
|
1100
|
-
canArchive: !!effectiveModes.mingo?.archiveDialog,
|
|
1101
|
-
fetchArchivedDialogs: effectiveModes.mingo?.fetchArchivedDialogs,
|
|
1102
|
-
unarchiveDialog: effectiveModes.mingo?.unarchiveDialog,
|
|
1103
|
-
searchQuery: undefined as string | undefined,
|
|
1104
|
-
onSearchChange: undefined as ((query: string) => void) | undefined,
|
|
1105
|
-
onCopyLink: undefined as ((dialog: DialogItem) => void) | undefined,
|
|
1106
|
-
};
|
|
1107
|
-
}, [mingoState, mingoDialogCapabilities, effectiveModes]);
|
|
1108
|
-
|
|
1109
1082
|
// "Does Mingo mode exist?" — true via either the callback config OR injected
|
|
1110
1083
|
// state. Gates the guide↔mingo back-chevron and the guide-mode banner.
|
|
1111
1084
|
const hasMingoMode = !!effectiveModes.mingo || !!mingoState;
|
|
@@ -1239,8 +1212,49 @@ function EmbeddableChatInner({
|
|
|
1239
1212
|
setDialogScope,
|
|
1240
1213
|
hasMoreMessages,
|
|
1241
1214
|
loadMoreMessages,
|
|
1215
|
+
dialogsManaged,
|
|
1216
|
+
dialogCapabilities,
|
|
1242
1217
|
} = useUnifiedChat({ modes: effectiveModes, activeMode, mingoStateOverride: mingoState });
|
|
1243
1218
|
|
|
1219
|
+
// Transport-agnostic "this panel has a conversation list" gate. Mingo mode
|
|
1220
|
+
// keeps its list UI unconditionally (bare transports and the host-injected
|
|
1221
|
+
// `mingoState` drive it through the mode itself); Guide mode gains the SAME
|
|
1222
|
+
// rail / stacked list / archive / rename UI only when its adapter owns a
|
|
1223
|
+
// server-side list (`ChatRuntime.endpoints.chatConversationsUrl`).
|
|
1224
|
+
const historyListMode = activeMode === 'mingo' || dialogsManaged === true;
|
|
1225
|
+
|
|
1226
|
+
// Resolve dialog-management capabilities (rename / archive / archive-page /
|
|
1227
|
+
// restore) from a single source. With injected `mingoState` they come from
|
|
1228
|
+
// `mingoDialogCapabilities` (the host doesn't pass `modes.mingo`); otherwise
|
|
1229
|
+
// from the callback-config shape, where the presence of a callback IS the
|
|
1230
|
+
// capability. Both feed the same gating below so the JSX has one source.
|
|
1231
|
+
// ONE `ChatDialogCapabilities`, from whichever source owns the list:
|
|
1232
|
+
// 1. the ACTIVE ADAPTER (SSE with a conversations endpoint, or NATS
|
|
1233
|
+
// managed mode) — checked first so a Guide panel can never inherit the
|
|
1234
|
+
// Mingo config's callbacks;
|
|
1235
|
+
// 2. the host-injected `mingoState`'s companion prop;
|
|
1236
|
+
// 3. the legacy callback config, where a callback's PRESENCE is the
|
|
1237
|
+
// capability.
|
|
1238
|
+
// `canRename`/`canArchive` default OFF everywhere: the ⋯ menu must never
|
|
1239
|
+
// advertise an action nothing has wired.
|
|
1240
|
+
const mingoCaps = useMemo<ChatDialogCapabilities>(() => {
|
|
1241
|
+
const caps: ChatDialogCapabilities | undefined =
|
|
1242
|
+
dialogCapabilities ??
|
|
1243
|
+
(mingoState
|
|
1244
|
+
? mingoDialogCapabilities
|
|
1245
|
+
: {
|
|
1246
|
+
canRename: !!effectiveModes.mingo?.renameDialog,
|
|
1247
|
+
canArchive: !!effectiveModes.mingo?.archiveDialog,
|
|
1248
|
+
fetchArchivedDialogs: effectiveModes.mingo?.fetchArchivedDialogs,
|
|
1249
|
+
unarchiveDialog: effectiveModes.mingo?.unarchiveDialog,
|
|
1250
|
+
});
|
|
1251
|
+
return {
|
|
1252
|
+
...caps,
|
|
1253
|
+
canRename: caps?.canRename ?? false,
|
|
1254
|
+
canArchive: caps?.canArchive ?? false,
|
|
1255
|
+
};
|
|
1256
|
+
}, [dialogCapabilities, mingoState, mingoDialogCapabilities, effectiveModes]);
|
|
1257
|
+
|
|
1244
1258
|
// ── One-shot Guide-mode launcher prompt ────────────────────────────────────
|
|
1245
1259
|
// A host launcher (e.g. an "Ask Mingo about X" empty-state button) requests
|
|
1246
1260
|
// contextual guidance by forcing `activeMode='guide'` and passing the prompt
|
|
@@ -1780,7 +1794,14 @@ function EmbeddableChatInner({
|
|
|
1780
1794
|
// that wants a message-list skeleton (real header + composer, skeleton bubbles)
|
|
1781
1795
|
// signals it via `isMessagesLoading` — treat that as an open conversation so
|
|
1782
1796
|
// the content branch shows the skeleton instead of the new-user welcome.
|
|
1783
|
-
|
|
1797
|
+
// A managed Guide panel re-hydrating a stored/selected conversation shows the
|
|
1798
|
+
// message skeleton too (instead of flashing the list) — SSE only reports
|
|
1799
|
+
// `isMessagesLoading` while that fetch is in flight.
|
|
1800
|
+
const hasConversation =
|
|
1801
|
+
hasMessages ||
|
|
1802
|
+
isOpeningDialog ||
|
|
1803
|
+
isViewingArchived ||
|
|
1804
|
+
((previewMode || (activeMode === 'guide' && dialogsManaged === true)) && isMessagesLoading);
|
|
1784
1805
|
// Opening a dialog whose history hasn't arrived yet — show a message-list
|
|
1785
1806
|
// skeleton instead of an empty thread so the open reads as "loading" rather
|
|
1786
1807
|
// than a blank flash before the bubbles stream in.
|
|
@@ -1865,26 +1886,38 @@ function EmbeddableChatInner({
|
|
|
1865
1886
|
// mode / archive page) it stays the stacked single-column layout with the
|
|
1866
1887
|
// history inline in the empty state. Fully self-contained — the host opts
|
|
1867
1888
|
// into nothing; the switch is width-driven inside this component.
|
|
1889
|
+
//
|
|
1890
|
+
// Measured off the panel NODE (state), not a ref read once on mount. In the
|
|
1891
|
+
// `drawer` shell the panel body does not exist until the drawer opens, so a
|
|
1892
|
+
// mount-time ref read saw `null`, bailed, and — with `[]` deps — never ran
|
|
1893
|
+
// again: `panelWidth` stayed 0, `canSplit` stayed false, and EVERY drawer
|
|
1894
|
+
// host was silently pinned to the stacked single-column list no matter how
|
|
1895
|
+
// wide it was. Only `shell="none"` hosts (the panel is inline and present at
|
|
1896
|
+
// mount) ever reached the split layout.
|
|
1868
1897
|
const [panelWidth, setPanelWidth] = useState(0);
|
|
1869
|
-
const panelMeasureRef = useRef<HTMLDivElement | null>(null);
|
|
1870
1898
|
useEffect(() => {
|
|
1871
|
-
|
|
1872
|
-
if (!el || typeof ResizeObserver === 'undefined') return undefined;
|
|
1899
|
+
if (!panelBoundary || typeof ResizeObserver === 'undefined') return undefined;
|
|
1873
1900
|
const ro = new ResizeObserver(entries => {
|
|
1874
1901
|
const w = entries[0]?.contentRect?.width;
|
|
1875
1902
|
if (typeof w === 'number') setPanelWidth(w);
|
|
1876
1903
|
});
|
|
1877
|
-
ro.observe(
|
|
1878
|
-
setPanelWidth(el.clientWidth);
|
|
1904
|
+
ro.observe(panelBoundary);
|
|
1879
1905
|
return () => ro.disconnect();
|
|
1880
|
-
}, []);
|
|
1906
|
+
}, [panelBoundary]);
|
|
1881
1907
|
|
|
1882
|
-
//
|
|
1883
|
-
//
|
|
1884
|
-
//
|
|
1908
|
+
// ONE node for two consumers: the width measurement above and the
|
|
1909
|
+
// collision-boundary context. State, not a ref, so both re-run when the node
|
|
1910
|
+
// appears (the drawer shell mounts its body only on open).
|
|
1911
|
+
//
|
|
1912
|
+
// The width is ALSO seeded here, in the commit-phase ref callback: the
|
|
1913
|
+
// ResizeObserver's first callback is delivered asynchronously, so seeding
|
|
1914
|
+
// only there would leave a split-eligible panel painting one stacked frame at
|
|
1915
|
+
// width 0 before flipping. Seeding in the effect instead is what the
|
|
1916
|
+
// pre-refactor code did, but `react-hooks/set-state-in-effect` rejects it in
|
|
1917
|
+
// a reactive (non-mount-only) effect.
|
|
1885
1918
|
const setPanelNode = useCallback((node: HTMLDivElement | null) => {
|
|
1886
|
-
panelMeasureRef.current = node;
|
|
1887
1919
|
setPanelBoundary(node);
|
|
1920
|
+
if (node) setPanelWidth(node.clientWidth);
|
|
1888
1921
|
}, []);
|
|
1889
1922
|
|
|
1890
1923
|
// Rail collapse toggle (Figma ⟶| control), persisted so it survives the
|
|
@@ -1929,7 +1962,7 @@ function EmbeddableChatInner({
|
|
|
1929
1962
|
// page stays split-eligible: in wide mode it opens INSIDE the left rail (the
|
|
1930
1963
|
// right chat block stays put), and only falls back to the full-panel archive
|
|
1931
1964
|
// when stacked/collapsed.
|
|
1932
|
-
const splitEligible =
|
|
1965
|
+
const splitEligible = historyListMode;
|
|
1933
1966
|
const canSplit = panelWidth >= SPLIT_MIN_WIDTH;
|
|
1934
1967
|
// Embedded previews (hero demo tabs) always use the compact single-column
|
|
1935
1968
|
// header, never the two-column split — so `previewMode` opts out of `wideMingo`.
|
|
@@ -1960,14 +1993,26 @@ function EmbeddableChatInner({
|
|
|
1960
1993
|
// the SAME render the conversation opened in. Guarded, so the extra render
|
|
1961
1994
|
// pass takes the early exit.
|
|
1962
1995
|
if (hasConversation && composeOpen) setComposeOpen(false);
|
|
1963
|
-
const isMingoMode =
|
|
1996
|
+
const isMingoMode = historyListMode;
|
|
1964
1997
|
// The stacked "Current Chats" list — the NARROW single-column Mingo view. It
|
|
1965
1998
|
// is a narrow-only layout: in any wide layout the chat list lives in the rail,
|
|
1966
1999
|
// and collapsing the rail (`wideCollapsed`) shows the chat / new-chat welcome
|
|
1967
2000
|
// in the fill column (navigation is via re-expanding the rail), NOT the list.
|
|
1968
2001
|
// Requires no open conversation, no archive, and not composing (the composer
|
|
1969
2002
|
// lives on the compose view).
|
|
1970
|
-
|
|
2003
|
+
// …but a managed GUIDE panel with NOTHING to list skips straight to the
|
|
2004
|
+
// welcome + composer: a first-time visitor to a marketing site must not have
|
|
2005
|
+
// to tap through an empty "Current Chats" screen to ask a question. Only
|
|
2006
|
+
// once they have history does the list become the landing view. Gated on the
|
|
2007
|
+
// first page having loaded so it doesn't flash the welcome mid-load.
|
|
2008
|
+
const guideListIsEmpty =
|
|
2009
|
+
activeMode === 'guide' &&
|
|
2010
|
+
dialogsManaged === true &&
|
|
2011
|
+
dialogs.length === 0 &&
|
|
2012
|
+
!dialogsInitialLoading &&
|
|
2013
|
+
!mingoCaps.searchQuery;
|
|
2014
|
+
const stackedListView =
|
|
2015
|
+
isMingoMode && !hasConversation && !archiveOpen && !wideMingo && !composeOpen && !guideListIsEmpty;
|
|
1971
2016
|
|
|
1972
2017
|
// Shared header derivations — consumed by the stacked `ChatPanelHeader`, its
|
|
1973
2018
|
// mobile fallback, and the desktop split header's right cell, so the title /
|
|
@@ -2037,12 +2082,19 @@ function EmbeddableChatInner({
|
|
|
2037
2082
|
// Chats" list header (search + archive, no back) and a "New Chat" compose
|
|
2038
2083
|
// header (back to the list); conversations + guide keep the shared header
|
|
2039
2084
|
// derivations. Wide mode uses its own two-cell header instead.
|
|
2040
|
-
|
|
2085
|
+
// `!guideListIsEmpty` for the same reason as `stackedListView`: with nothing
|
|
2086
|
+
// to list the BODY renders the Guide welcome, so a "Current Chats" header
|
|
2087
|
+
// above it would be half of the empty screen the shortcut exists to remove.
|
|
2088
|
+
// The else-branch header resolves to the assistant name via `isGuideEmpty`
|
|
2089
|
+
// and keeps the archive entry point.
|
|
2090
|
+
const narrowMingoEmpty = isMingoMode && !hasConversation && !archiveOpen && !guideListIsEmpty;
|
|
2041
2091
|
const narrowHeaderProps: ChatPanelHeaderProps = narrowMingoEmpty
|
|
2042
2092
|
? composeOpen
|
|
2043
2093
|
? {
|
|
2044
2094
|
showBack: true,
|
|
2045
|
-
|
|
2095
|
+
// Guide's compose view is its own welcome (assistant name), not a
|
|
2096
|
+
// Mingo "New Chat".
|
|
2097
|
+
title: isGuideEmpty ? (headerAssistantName ?? 'Mingo Guide') : 'New Chat',
|
|
2046
2098
|
subtitle: headerUserName,
|
|
2047
2099
|
avatar: headerAvatar,
|
|
2048
2100
|
backAriaLabel: 'Back to chats',
|
|
@@ -2212,7 +2264,7 @@ function EmbeddableChatInner({
|
|
|
2212
2264
|
<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)]">
|
|
2213
2265
|
<div className="flex min-w-0 flex-col">
|
|
2214
2266
|
<p className="truncate leading-tight text-ods-text-primary text-h3">
|
|
2215
|
-
{headerShowBack ? headerTitle : 'New Chat'}
|
|
2267
|
+
{headerShowBack || isGuideEmpty ? headerTitle : 'New Chat'}
|
|
2216
2268
|
</p>
|
|
2217
2269
|
{headerPersonName && (
|
|
2218
2270
|
<p className="truncate leading-tight text-ods-text-secondary text-h6">{headerPersonName}</p>
|
|
@@ -2659,7 +2711,7 @@ function EmbeddableChatInner({
|
|
|
2659
2711
|
resizable
|
|
2660
2712
|
minSize={480}
|
|
2661
2713
|
maxSize={1600}
|
|
2662
|
-
defaultSize={drawerDefaultWidth()}
|
|
2714
|
+
defaultSize={drawerDefaultWidth(historyListMode)}
|
|
2663
2715
|
storageKey={DRAWER_WIDTH_KEY}
|
|
2664
2716
|
resizeAriaLabel="Resize chat panel"
|
|
2665
2717
|
overlayClassName="mingo-chat-overlay"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- source-hash:
|
|
1
|
+
<!-- source-hash: d460fe7481ce4297ddeae04cf82f3fce -->
|
|
2
2
|
Barrel export file for the chat hooks module, re-exporting all public hooks from their individual files into a single `'use client'` entry point.
|
|
3
3
|
|
|
4
4
|
## Key Components
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<!-- source-hash: d18d474fc595dcd22de25996000d540f -->
|
|
2
|
+
The ONE dialog-list state machine shared by both transport adapters — NATS/Mingo managed-dialog mode and the SSE/Guide adapter when `ChatRuntime.endpoints.chatConversationsUrl` is set. The Chat Archive page keeps its own local pager in `useChatDialogManager`, deliberately untouched. Extracted from `useNatsChatAdapter` so Guide mode reuses the exact list/paging/mutation semantics openframe-frontend already relies on.
|
|
3
|
+
|
|
4
|
+
## Key Components
|
|
5
|
+
|
|
6
|
+
### `useManagedDialogList(args)`
|
|
7
|
+
Owns the loaded `DialogItem[]` page, the server cursor, first-page loading/error state (with the retry re-arm), cursor pagination, an optional server-side `search` term (a change re-runs page 1) and the optimistic rename / archive / delete mutations. Does NOT own the active dialog id, message history or the transport — the adapters layer those on top via `onDialogRemoved`.
|
|
8
|
+
|
|
9
|
+
### `UseManagedDialogListArgs`
|
|
10
|
+
- `autoLoad` — gates the AUTOMATIC first-page load only; the adapters pass their own `active` gate so an idle transport does no network
|
|
11
|
+
- `fetchDialogs` / `renameDialog` / `archiveDialog` / `deleteDialog` — host callbacks; presence IS the capability (absent = inert / no-op)
|
|
12
|
+
- `pageSize` — sent as `limit`
|
|
13
|
+
- `search` — `undefined` = no search support (NATS keeps `{cursor, limit}` wire params); any string change reloads page 1 with `search`
|
|
14
|
+
- `onDialogRemoved(id, 'archived' | 'deleted')` — fires AFTER the local removal, read through a latest-ref
|
|
15
|
+
- `logTag` — console prefix for failure logs
|
|
16
|
+
|
|
17
|
+
### `UseManagedDialogListResult`
|
|
18
|
+
`dialogs`, `dialogsNextCursor`, `isDialogsLoading`, `dialogsError`, `hasMoreDialogs`, `loadDialogsPage`, `reloadDialogs`, `loadMoreDialogs`, `renameDialog`, `archiveDialog`, `deleteDialog`, plus `upsertDialogTop(item)` (prepend + dedupe) and `bumpDialogToTop(id)` (re-head with a fresh timestamp, matching the server's `last_message_at desc`).
|
|
19
|
+
|
|
20
|
+
## Behavioural contracts
|
|
21
|
+
|
|
22
|
+
- `isDialogsLoading` reads true from the FIRST render whenever a first page is coming (and again synchronously on every search change, including clearing one), so a consumer branching on "the list is empty" never sees a settled-and-empty frame before the request starts.
|
|
23
|
+
- A monotonic request id means only the LATEST page-1 load may touch the list, cursor or flags — search-as-you-type, the end-of-turn refresh and an unarchive all overlap, and without it the last-resolving response wins.
|
|
24
|
+
- Appends dedupe by id: a row whose `last_message_at` moved between page fetches can come back on a later page.
|
|
25
|
+
- Only the FIRST page failing sets `dialogsError`; a pagination failure keeps the loaded rows.
|
|
26
|
+
- Archive and delete failures are logged AND re-thrown, so `useChatDialogManager.handleConfirmArchive` (which awaits and catches) can keep its modal open for a retry instead of closing over a write the server rejected. Rename is the exception: it is logged and SWALLOWED after rolling its optimistic title back, matching the pre-extraction NATS adapter, because `handleConfirmRename` fires it as `void renameDialog(...)` and a rejection would only surface as an unhandled rejection.
|
|
27
|
+
- Rename is optimistic; the rollback title is read synchronously from a live ref at call time (capturing it inside a `setState` updater was unreliable — the updater may run after an immediately-rejecting callback reaches the catch).
|
|
28
|
+
|
|
29
|
+
## Source
|
|
30
|
+
|
|
31
|
+
[`use-managed-dialog-list.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/use-managed-dialog-list.ts)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- source-hash:
|
|
1
|
+
<!-- source-hash: 1cda8eab406b1762bfddf3d0b586c9ab -->
|
|
2
2
|
Provides the NATS/Mingo-mode transport adapter for the unified chat surface, implementing the `UnifiedChatState` contract so the `useChat({ mode })` dispatcher can switch between NATS and SSE adapters without shell-side branching.
|
|
3
3
|
|
|
4
4
|
## Key Components
|
|
@@ -28,6 +28,8 @@ useChunkCatchup → back-fills missed chunks on reconnect/activation
|
|
|
28
28
|
|
|
29
29
|
Returns a full `UnifiedChatState` object including `messages`, `isLoading`, `streamingPhase`, `sendMessage`, `stopMessage`, and `clearMessages`.
|
|
30
30
|
|
|
31
|
+
In managed-dialog mode (`fetchDialogs` provided) the dialog list itself — paging, retry, optimistic rename/archive/delete — is the SHARED `useManagedDialogList` hook (also behind the SSE/Guide adapter); this adapter only layers the active-id and reducer-store side effects on top through `onDialogRemoved`, and reports `dialogsManaged: true` plus `dialogCapabilities` (presence of a host callback = the capability). `FetchDialogsParams` / `FetchDialogsResult` now live in `unified-chat-state.types.ts` and are re-exported here.
|
|
32
|
+
|
|
31
33
|
## Usage Example
|
|
32
34
|
|
|
33
35
|
```typescript
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- source-hash:
|
|
1
|
+
<!-- source-hash: 4c53d129235a1e38a4bb4ae25ee53ebe -->
|
|
2
2
|
Provides the SSE (Server-Sent Events) transport adapter for the unified chat surface, implementing `UnifiedChatState` for Guide mode. Serves as the canonical replacement for the legacy `useEmbeddedChat` hook following the unified-chat refactor.
|
|
3
3
|
|
|
4
4
|
## Key Components
|
|
@@ -40,6 +40,13 @@ const chatState = useSseChatAdapter(options, { active: true })
|
|
|
40
40
|
- `tableIdForDocumentType` defaults to `defaultTableIdForDocumentType` (lib-baked map), so Ask / Display buttons work in embedders without any wiring
|
|
41
41
|
- The SSE decoder/buffer lives inside the per-call closure to prevent cross-stream buffer corruption on rapid send-stop-send sequences
|
|
42
42
|
|
|
43
|
+
**Managed conversation list (`ChatRuntime.endpoints.chatConversationsUrl`):**
|
|
44
|
+
|
|
45
|
+
- With the endpoint set, the adapter runs the SAME `useManagedDialogList` state machine as the NATS adapter, with its callbacks built by `createChatConversationsApi` — the server transcript store becomes the dialog list (`dialogs`, `activeDialogId`, `selectDialog`, `renameDialog`, `archiveDialog`, paging, `dialogsManaged: true`, `dialogCapabilities` incl. archive page / restore / server-side search).
|
|
46
|
+
- `selectDialog(id)` aborts any in-flight stream, resets the reducer, re-arms the hydration guard and commits the id (ref + state + localStorage); `useChatHistoryHydration` then re-fetches through `chatHistoryUrl`. `isMessagesLoading` mirrors that fetch.
|
|
47
|
+
- A first send that mints a new id pre-seeds the hydration guard (the streamed turn IS the history — no prepend), inserts an optimistic row, and re-reads the list at end of turn so the server's derived title lands.
|
|
48
|
+
- Without the endpoint the single-thread stubs are returned unchanged (`dialogsManaged: false`) — zero behaviour change for hosts that never set it.
|
|
49
|
+
|
|
43
50
|
## Source
|
|
44
51
|
|
|
45
52
|
[`use-sse-chat-adapter.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/use-sse-chat-adapter.ts)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!-- source-hash:
|
|
1
|
+
<!-- source-hash: a0eb58b3207fd44705d8e6448daa8387 -->
|
|
2
2
|
Unified entry point hook that dispatches chat state between two transport adapters — SSE/Guide and NATS/Mingo — based on the `activeMode` flag, while keeping both hooks always mounted to satisfy React's rules of hooks.
|
|
3
3
|
|
|
4
4
|
## Key Components
|
|
@@ -31,7 +31,7 @@ Main hook. Returns a stable `UnifiedChatState` composed of:
|
|
|
31
31
|
the NATS/Mingo adapters omit it, because consumers gate the card menu's "Display" row on the
|
|
32
32
|
callback being there; forwarding an always-truthy wrapper around a missing method would advertise
|
|
33
33
|
a display path that isn't there and throw on click.
|
|
34
|
-
- **Dialog management** — `selectDialog`, `startNewDialog`, `deleteDialog`, `renameDialog`, `archiveDialog`, `loadMoreDialogs`, `setDialogScope`, `reloadDialogs`, `loadMoreMessages`
|
|
34
|
+
- **Dialog management** — `selectDialog`, `startNewDialog`, `deleteDialog`, `renameDialog`, `archiveDialog`, `loadMoreDialogs`, `setDialogScope`, `reloadDialogs`, `loadMoreMessages`; plus the adapter-owned `dialogsManaged` flag and `dialogCapabilities`, forwarded verbatim so `EmbeddableChat` can gate the history UI on them regardless of transport
|
|
35
35
|
- **Approvals** — `approveRequest`, `rejectRequest`
|
|
36
36
|
|
|
37
37
|
Callbacks are bound through `activeStateRef` (a live ref updated every render) so their identities remain referentially stable across streaming chunks, preventing unnecessary downstream re-renders.
|