@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.
Files changed (225) hide show
  1. package/dist/chat-protocol/index.cjs +1 -8
  2. package/dist/chat-protocol/index.cjs.map +1 -1
  3. package/dist/chat-protocol/index.d.ts +0 -1
  4. package/dist/chat-protocol/index.d.ts.map +1 -1
  5. package/dist/chat-protocol/index.js +2 -7
  6. package/dist/chat-protocol/index.js.map +1 -1
  7. package/dist/chat-protocol/nats-decoder.d.ts.map +1 -1
  8. package/dist/{chunk-TSCIVH7T.js → chunk-2JNCZDJR.js} +2 -2
  9. package/dist/{chunk-6NSGAH5H.cjs → chunk-2SYX2Z7R.cjs} +34 -34
  10. package/dist/{chunk-6NSGAH5H.cjs.map → chunk-2SYX2Z7R.cjs.map} +1 -1
  11. package/dist/{chunk-6ZHH37RS.cjs → chunk-3WSS7C2V.cjs} +15 -15
  12. package/dist/{chunk-6ZHH37RS.cjs.map → chunk-3WSS7C2V.cjs.map} +1 -1
  13. package/dist/{chunk-5L4ERWSW.js → chunk-75YW6ET4.js} +4 -4
  14. package/dist/{chunk-VKCETV3C.js → chunk-BK6CCQG6.js} +12 -12
  15. package/dist/{chunk-HM25MFZX.cjs → chunk-BPVHDDNY.cjs} +8 -8
  16. package/dist/{chunk-HM25MFZX.cjs.map → chunk-BPVHDDNY.cjs.map} +1 -1
  17. package/dist/{chunk-VIBREYUK.cjs → chunk-BZEWPW5A.cjs} +3 -3
  18. package/dist/{chunk-VIBREYUK.cjs.map → chunk-BZEWPW5A.cjs.map} +1 -1
  19. package/dist/{chunk-KYWU6F3O.cjs → chunk-DAPOBLAK.cjs} +39 -39
  20. package/dist/{chunk-KYWU6F3O.cjs.map → chunk-DAPOBLAK.cjs.map} +1 -1
  21. package/dist/{chunk-DHCA5BZP.cjs → chunk-DI3SVVY5.cjs} +85 -85
  22. package/dist/{chunk-DHCA5BZP.cjs.map → chunk-DI3SVVY5.cjs.map} +1 -1
  23. package/dist/{chunk-BLUL2TE3.js → chunk-EVMHJB6X.js} +4 -4
  24. package/dist/{chunk-S6WBBSII.js → chunk-EZM5DNII.js} +3 -3
  25. package/dist/{chunk-BVQEU5JB.js → chunk-GGQZBSFN.js} +2 -2
  26. package/dist/{chunk-KTX5B2FW.js → chunk-GHYFVT52.js} +439 -414
  27. package/dist/chunk-GHYFVT52.js.map +1 -0
  28. package/dist/{chunk-CCWI3622.cjs → chunk-H64ZHSYR.cjs} +4 -4
  29. package/dist/{chunk-CCWI3622.cjs.map → chunk-H64ZHSYR.cjs.map} +1 -1
  30. package/dist/{chunk-4T42D6YG.js → chunk-HLPAVYK7.js} +4 -4
  31. package/dist/{chunk-HFHBA3VV.cjs → chunk-HWAYIK4U.cjs} +22 -22
  32. package/dist/{chunk-HFHBA3VV.cjs.map → chunk-HWAYIK4U.cjs.map} +1 -1
  33. package/dist/{chunk-CF4QJPTN.cjs → chunk-JVZVVZOZ.cjs} +9 -9
  34. package/dist/{chunk-CF4QJPTN.cjs.map → chunk-JVZVVZOZ.cjs.map} +1 -1
  35. package/dist/{chunk-XV7RFACE.js → chunk-KHOZ52NR.js} +6 -6
  36. package/dist/{chunk-IW746HJ7.js → chunk-LRQCKSZC.js} +2 -2
  37. package/dist/{chunk-JJUV7Z4L.cjs → chunk-M4YQUHOR.cjs} +15 -15
  38. package/dist/{chunk-JJUV7Z4L.cjs.map → chunk-M4YQUHOR.cjs.map} +1 -1
  39. package/dist/{chunk-FKBM6U43.js → chunk-MYBXCWEI.js} +2 -2
  40. package/dist/{chunk-QTPHBCPI.js → chunk-NIAMPMKV.js} +4 -4
  41. package/dist/{chunk-UXOOVP77.cjs → chunk-O4VZOA2Q.cjs} +3 -3
  42. package/dist/{chunk-UXOOVP77.cjs.map → chunk-O4VZOA2Q.cjs.map} +1 -1
  43. package/dist/{chunk-ABNBTPI2.cjs → chunk-P24VPJTT.cjs} +15 -15
  44. package/dist/{chunk-ABNBTPI2.cjs.map → chunk-P24VPJTT.cjs.map} +1 -1
  45. package/dist/{chunk-4XPPQDEM.js → chunk-PTK3CINU.js} +5 -5
  46. package/dist/{chunk-7FUIRGMU.js → chunk-PX4IPM7Q.js} +3 -3
  47. package/dist/{chunk-NLT5R43J.cjs → chunk-QD64Q4I2.cjs} +9 -9
  48. package/dist/{chunk-NLT5R43J.cjs.map → chunk-QD64Q4I2.cjs.map} +1 -1
  49. package/dist/{chunk-TEVP4KNG.cjs → chunk-QIKBISZM.cjs} +522 -497
  50. package/dist/chunk-QIKBISZM.cjs.map +1 -0
  51. package/dist/{chunk-FGNUI4CC.js → chunk-R4UV366K.js} +6 -6
  52. package/dist/{chunk-UPKZU6QU.cjs → chunk-RDTOMWDN.cjs} +1 -1
  53. package/dist/chunk-RDTOMWDN.cjs.map +1 -0
  54. package/dist/{chunk-YB6FI2G3.js → chunk-RYXIRVDC.js} +1 -1
  55. package/dist/chunk-RYXIRVDC.js.map +1 -0
  56. package/dist/{chunk-QPAPUIF3.cjs → chunk-SAEJGTCI.cjs} +35 -35
  57. package/dist/{chunk-QPAPUIF3.cjs.map → chunk-SAEJGTCI.cjs.map} +1 -1
  58. package/dist/{chunk-66HTVTZZ.js → chunk-SE3PVN64.js} +2 -2
  59. package/dist/{chunk-3IXDZI3R.cjs → chunk-STYNZ4QM.cjs} +3 -3
  60. package/dist/{chunk-3IXDZI3R.cjs.map → chunk-STYNZ4QM.cjs.map} +1 -1
  61. package/dist/{chunk-CQRYXSHL.js → chunk-TZPVRWPU.js} +5 -5
  62. package/dist/{chunk-RU3IKVY2.js → chunk-UAAXUFK6.js} +3 -3
  63. package/dist/{chunk-F5NEZLTG.cjs → chunk-UE7OFLLS.cjs} +14 -14
  64. package/dist/{chunk-F5NEZLTG.cjs.map → chunk-UE7OFLLS.cjs.map} +1 -1
  65. package/dist/{chunk-VUR24QYH.cjs → chunk-UG7JNQZY.cjs} +37 -37
  66. package/dist/{chunk-VUR24QYH.cjs.map → chunk-UG7JNQZY.cjs.map} +1 -1
  67. package/dist/{chunk-UQSOFWXP.cjs → chunk-V2QK5W3O.cjs} +3 -3
  68. package/dist/{chunk-UQSOFWXP.cjs.map → chunk-V2QK5W3O.cjs.map} +1 -1
  69. package/dist/{chunk-ZABAXD4U.js → chunk-VIRTMRS4.js} +7 -7
  70. package/dist/{chunk-D565OOXC.cjs → chunk-VLJTJAHJ.cjs} +25 -25
  71. package/dist/{chunk-D565OOXC.cjs.map → chunk-VLJTJAHJ.cjs.map} +1 -1
  72. package/dist/{chunk-K5QV7ZAY.js → chunk-VNSRNVPD.js} +437 -756
  73. package/dist/chunk-VNSRNVPD.js.map +1 -0
  74. package/dist/{chunk-UQEOAPAI.cjs → chunk-WCBRZCU4.cjs} +9 -9
  75. package/dist/{chunk-UQEOAPAI.cjs.map → chunk-WCBRZCU4.cjs.map} +1 -1
  76. package/dist/{chunk-3XFDRL32.js → chunk-WDWCQD75.js} +9 -9
  77. package/dist/{chunk-QT35C6CW.js → chunk-WPN545FW.js} +12 -12
  78. package/dist/{chunk-F2KBCLUG.js → chunk-WZJOILPU.js} +2 -2
  79. package/dist/{chunk-KAADFO74.js → chunk-XNPAVMPB.js} +5 -5
  80. package/dist/{chunk-5PPYXXUO.cjs → chunk-YBPFIXV4.cjs} +522 -841
  81. package/dist/chunk-YBPFIXV4.cjs.map +1 -0
  82. package/dist/{chunk-EHAYNUOL.cjs → chunk-YH6IQTPI.cjs} +3 -3
  83. package/dist/{chunk-EHAYNUOL.cjs.map → chunk-YH6IQTPI.cjs.map} +1 -1
  84. package/dist/{chunk-AVAENPVE.cjs → chunk-YWBAIFI2.cjs} +105 -105
  85. package/dist/{chunk-AVAENPVE.cjs.map → chunk-YWBAIFI2.cjs.map} +1 -1
  86. package/dist/components/case-studies/index.cjs +14 -14
  87. package/dist/components/case-studies/index.js +8 -8
  88. package/dist/components/chat/embeddable-chat.d.ts +19 -10
  89. package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
  90. package/dist/components/chat/hooks/index.d.ts +0 -1
  91. package/dist/components/chat/hooks/index.d.ts.map +1 -1
  92. package/dist/components/chat/hooks/use-chat-dialog-manager.d.ts +2 -2
  93. package/dist/components/chat/hooks/use-chat-dialog-manager.d.ts.map +1 -1
  94. package/dist/components/chat/hooks/use-chat-history-hydration.d.ts +3 -13
  95. package/dist/components/chat/hooks/use-chat-history-hydration.d.ts.map +1 -1
  96. package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts +16 -2
  97. package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts.map +1 -1
  98. package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts.map +1 -1
  99. package/dist/components/chat/hooks/use-unified-chat.d.ts.map +1 -1
  100. package/dist/components/chat/index.cjs +5 -9
  101. package/dist/components/chat/index.cjs.map +1 -1
  102. package/dist/components/chat/index.js +4 -8
  103. package/dist/components/chat/types/unified-chat-state.types.d.ts +6 -67
  104. package/dist/components/chat/types/unified-chat-state.types.d.ts.map +1 -1
  105. package/dist/components/chat/utils/index.d.ts +0 -1
  106. package/dist/components/chat/utils/index.d.ts.map +1 -1
  107. package/dist/components/contact/index.cjs +9 -9
  108. package/dist/components/contact/index.js +8 -8
  109. package/dist/components/docs/index.cjs +12 -12
  110. package/dist/components/docs/index.js +11 -11
  111. package/dist/components/embeds/index.cjs +9 -9
  112. package/dist/components/embeds/index.js +8 -8
  113. package/dist/components/faq/index.cjs +10 -10
  114. package/dist/components/faq/index.js +9 -9
  115. package/dist/components/features/index.cjs +8 -8
  116. package/dist/components/features/index.js +7 -7
  117. package/dist/components/help-center-pages/index.cjs +31 -31
  118. package/dist/components/help-center-pages/index.js +22 -22
  119. package/dist/components/index.cjs +66 -70
  120. package/dist/components/index.cjs.map +1 -1
  121. package/dist/components/index.js +22 -26
  122. package/dist/components/index.js.map +1 -1
  123. package/dist/components/meeting-scheduler/index.cjs +49 -49
  124. package/dist/components/meeting-scheduler/index.js +9 -9
  125. package/dist/components/navigation/index.cjs +11 -11
  126. package/dist/components/navigation/index.js +10 -10
  127. package/dist/components/onboarding-guides/index.cjs +12 -12
  128. package/dist/components/onboarding-guides/index.js +11 -11
  129. package/dist/components/related-content/index.cjs +7 -7
  130. package/dist/components/related-content/index.js +6 -6
  131. package/dist/components/tickets/index.cjs +13 -13
  132. package/dist/components/tickets/index.js +12 -12
  133. package/dist/components/ui/data-table/data-table-body.d.ts.map +1 -1
  134. package/dist/components/ui/data-table/data-table-skeleton.d.ts +31 -0
  135. package/dist/components/ui/data-table/data-table-skeleton.d.ts.map +1 -1
  136. package/dist/components/ui/index.cjs +8 -12
  137. package/dist/components/ui/index.cjs.map +1 -1
  138. package/dist/components/ui/index.js +7 -11
  139. package/dist/components/ui/table/table-empty-state.d.ts +1 -1
  140. package/dist/components/ui/table/table-empty-state.d.ts.map +1 -1
  141. package/dist/components/ui/table/table-skeleton.d.ts +1 -14
  142. package/dist/components/ui/table/table-skeleton.d.ts.map +1 -1
  143. package/dist/components/ui/table/table.d.ts +1 -1
  144. package/dist/components/ui/table/table.d.ts.map +1 -1
  145. package/dist/components/ui/table/types.d.ts +33 -6
  146. package/dist/components/ui/table/types.d.ts.map +1 -1
  147. package/dist/contexts/chat-runtime-context.d.ts +0 -12
  148. package/dist/contexts/chat-runtime-context.d.ts.map +1 -1
  149. package/dist/contexts/index.cjs +2 -2
  150. package/dist/contexts/index.js +1 -1
  151. package/dist/hooks/index.cjs +5 -5
  152. package/dist/hooks/index.js +4 -4
  153. package/dist/index.cjs +12 -16
  154. package/dist/index.cjs.map +1 -1
  155. package/dist/index.js +11 -15
  156. package/dist/index.js.map +1 -1
  157. package/package.json +1 -1
  158. package/src/chat-protocol/index.ts +0 -1
  159. package/src/chat-protocol/nats-decoder.ts +5 -1
  160. package/src/components/chat/.embeddable-chat.md +2 -4
  161. package/src/components/chat/embeddable-chat.tsx +84 -131
  162. package/src/components/chat/hooks/.use-chat-dialog-manager.md +1 -3
  163. package/src/components/chat/hooks/.use-nats-chat-adapter.md +1 -3
  164. package/src/components/chat/hooks/.use-sse-chat-adapter.md +1 -8
  165. package/src/components/chat/hooks/.use-unified-chat.md +2 -2
  166. package/src/components/chat/hooks/index.ts +0 -2
  167. package/src/components/chat/hooks/use-chat-dialog-manager.ts +65 -38
  168. package/src/components/chat/hooks/use-chat-history-hydration.ts +24 -67
  169. package/src/components/chat/hooks/use-nats-chat-adapter.ts +150 -65
  170. package/src/components/chat/hooks/use-sse-chat-adapter.ts +59 -233
  171. package/src/components/chat/hooks/use-unified-chat.ts +0 -5
  172. package/src/components/chat/types/.unified-chat-state.types.md +1 -13
  173. package/src/components/chat/types/unified-chat-state.types.ts +6 -74
  174. package/src/components/chat/utils/index.ts +0 -7
  175. package/src/components/ui/data-table/data-table-body.tsx +8 -49
  176. package/src/components/ui/data-table/data-table-skeleton.tsx +100 -0
  177. package/src/components/ui/table/table-empty-state.tsx +5 -1
  178. package/src/components/ui/table/table-skeleton.tsx +14 -40
  179. package/src/components/ui/table/table.tsx +34 -15
  180. package/src/components/ui/table/types.ts +33 -6
  181. package/src/contexts/.chat-runtime-context.md +1 -3
  182. package/src/contexts/chat-runtime-context.tsx +0 -12
  183. package/dist/chat-protocol/wire-narrow.d.ts +0 -17
  184. package/dist/chat-protocol/wire-narrow.d.ts.map +0 -1
  185. package/dist/chunk-5PPYXXUO.cjs.map +0 -1
  186. package/dist/chunk-K5QV7ZAY.js.map +0 -1
  187. package/dist/chunk-KTX5B2FW.js.map +0 -1
  188. package/dist/chunk-TEVP4KNG.cjs.map +0 -1
  189. package/dist/chunk-UPKZU6QU.cjs.map +0 -1
  190. package/dist/chunk-YB6FI2G3.js.map +0 -1
  191. package/dist/components/chat/hooks/use-managed-dialog-list.d.ts +0 -68
  192. package/dist/components/chat/hooks/use-managed-dialog-list.d.ts.map +0 -1
  193. package/dist/components/chat/utils/chat-conversations-api.d.ts +0 -29
  194. package/dist/components/chat/utils/chat-conversations-api.d.ts.map +0 -1
  195. package/src/chat-protocol/wire-narrow.ts +0 -22
  196. package/src/components/chat/hooks/.use-managed-dialog-list.md +0 -31
  197. package/src/components/chat/hooks/__tests__/managed-dialog-list.test.ts +0 -280
  198. package/src/components/chat/hooks/__tests__/nats-adapter-managed-dialogs.test.ts +0 -172
  199. package/src/components/chat/hooks/__tests__/sse-managed-dialogs.test.ts +0 -310
  200. package/src/components/chat/hooks/use-managed-dialog-list.ts +0 -371
  201. package/src/components/chat/utils/.chat-conversations-api.md +0 -16
  202. package/src/components/chat/utils/__tests__/chat-conversations-api-golden.test.ts +0 -105
  203. package/src/components/chat/utils/chat-conversations-api.ts +0 -83
  204. /package/dist/{chunk-TSCIVH7T.js.map → chunk-2JNCZDJR.js.map} +0 -0
  205. /package/dist/{chunk-5L4ERWSW.js.map → chunk-75YW6ET4.js.map} +0 -0
  206. /package/dist/{chunk-VKCETV3C.js.map → chunk-BK6CCQG6.js.map} +0 -0
  207. /package/dist/{chunk-BLUL2TE3.js.map → chunk-EVMHJB6X.js.map} +0 -0
  208. /package/dist/{chunk-S6WBBSII.js.map → chunk-EZM5DNII.js.map} +0 -0
  209. /package/dist/{chunk-BVQEU5JB.js.map → chunk-GGQZBSFN.js.map} +0 -0
  210. /package/dist/{chunk-4T42D6YG.js.map → chunk-HLPAVYK7.js.map} +0 -0
  211. /package/dist/{chunk-XV7RFACE.js.map → chunk-KHOZ52NR.js.map} +0 -0
  212. /package/dist/{chunk-IW746HJ7.js.map → chunk-LRQCKSZC.js.map} +0 -0
  213. /package/dist/{chunk-FKBM6U43.js.map → chunk-MYBXCWEI.js.map} +0 -0
  214. /package/dist/{chunk-QTPHBCPI.js.map → chunk-NIAMPMKV.js.map} +0 -0
  215. /package/dist/{chunk-4XPPQDEM.js.map → chunk-PTK3CINU.js.map} +0 -0
  216. /package/dist/{chunk-7FUIRGMU.js.map → chunk-PX4IPM7Q.js.map} +0 -0
  217. /package/dist/{chunk-FGNUI4CC.js.map → chunk-R4UV366K.js.map} +0 -0
  218. /package/dist/{chunk-66HTVTZZ.js.map → chunk-SE3PVN64.js.map} +0 -0
  219. /package/dist/{chunk-CQRYXSHL.js.map → chunk-TZPVRWPU.js.map} +0 -0
  220. /package/dist/{chunk-RU3IKVY2.js.map → chunk-UAAXUFK6.js.map} +0 -0
  221. /package/dist/{chunk-ZABAXD4U.js.map → chunk-VIRTMRS4.js.map} +0 -0
  222. /package/dist/{chunk-3XFDRL32.js.map → chunk-WDWCQD75.js.map} +0 -0
  223. /package/dist/{chunk-QT35C6CW.js.map → chunk-WPN545FW.js.map} +0 -0
  224. /package/dist/{chunk-F2KBCLUG.js.map → chunk-WZJOILPU.js.map} +0 -0
  225. /package/dist/{chunk-KAADFO74.js.map → chunk-XNPAVMPB.js.map} +0 -0
@@ -79,6 +79,7 @@ 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';
82
83
  import { fetchSlashCommands, useSlashCommandRegistry, type SlashCommandSummary } from './hooks/use-slash-commands';
83
84
  import type { ChatSource, UseSseChatAdapterOptions } from './hooks/use-sse-chat-adapter';
84
85
  import { useUnifiedChat, type ChatMode, type UseUnifiedChatModes } from './hooks/use-unified-chat';
@@ -90,10 +91,10 @@ import { MingoWelcome, type MingoWelcomeProps } from './mingo-welcome';
90
91
  import { NavLinkAnchorViaRuntime } from './nav-link-anchor-via-runtime';
91
92
  import { accentFromIdentityIcon, getAgentAccent } from './quick-action-chip';
92
93
  import { SourceActionButton } from './source-action-button';
93
- import type { ChatInputRef, SlashCommandActionId } from './types/component.types';
94
+ import type { ChatInputRef, DialogItem, SlashCommandActionId } from './types/component.types';
94
95
  import type { ChatContextItem, ChatContextPickerConfig } from './types/context-item.types';
95
96
  import type { MessageSegment, Message } from './types/message.types';
96
- import type { ChatDialogCapabilities, UnifiedChatState } from './types/unified-chat-state.types';
97
+ import type { UnifiedChatState } from './types/unified-chat-state.types';
97
98
  import { formatChatAttachmentMarkdownForBubble } from './utils/chat-attachment-markdown';
98
99
  import { resolveHrefForRuntime } from './utils/chat-nav-resolution';
99
100
  import { chatChipClass } from './utils/chip-styles';
@@ -104,41 +105,16 @@ import { formatSingularLookupInvocation } from './utils/slash-dispatch-utils';
104
105
  import { getSourceIconName } from './utils/source-icons';
105
106
  import { resolveSourceRowCTA, sourceRowCtxFromRuntime } from './utils/source-row-cta';
106
107
 
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
-
119
108
  // Desktop drawer opens at this fraction of the viewport width (clamped to the
120
109
  // Drawer's own min/max). The user can still resize (persisted per DRAWER_WIDTH_KEY).
121
110
  const DRAWER_DEFAULT_WIDTH_RATIO = 0.5;
122
111
  // Bump the suffix whenever the default policy changes so previously-persisted
123
112
  // widths (e.g. the old fixed 750px / earlier 30% default) reset on next open.
124
- const DRAWER_WIDTH_KEY = 'mingo-chat-width-v4';
113
+ const DRAWER_WIDTH_KEY = 'mingo-chat-width-v3';
125
114
  const DRAWER_DEFAULT_WIDTH_PX = 750; // SSR fallback before the viewport is known
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 {
115
+ function drawerDefaultWidth(): number {
138
116
  if (typeof window === 'undefined') return DRAWER_DEFAULT_WIDTH_PX;
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);
117
+ return Math.round(window.innerWidth * DRAWER_DEFAULT_WIDTH_RATIO);
142
118
  }
143
119
 
144
120
  // =============================================================================
@@ -238,16 +214,23 @@ export interface EmbeddableChatProps {
238
214
  * When the host injects `mingoState`, it doesn't pass `modes.mingo` (that
239
215
  * would re-activate the idle built-in adapter), so the rename/archive/
240
216
  * restore/archive-page affordances can't read their capability flags off the
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.
217
+ * callback config. Supply them here instead. `canRename`/`canArchive` default
218
+ * to `true` when `mingoState` is set; the archive page + restore are shown
219
+ * only when their callbacks are provided. Ignored unless `mingoState` is set.
249
220
  */
250
- mingoDialogCapabilities?: ChatDialogCapabilities;
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
+ };
251
234
 
252
235
  /**
253
236
  * Controlled active-mode. When provided, `onActiveModeChange` MUST
@@ -441,6 +424,18 @@ const mentionTokenOf = (key: string, markerByType: Map<string, string>): string
441
424
  */
442
425
  const FALLBACK_TOP_RETRIEVED = 3;
443
426
 
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
+
444
439
  /** Persists the user's rail collapse choice across drawer open/close + reloads. */
445
440
  const RAIL_COLLAPSED_STORAGE_KEY = 'mingo-chat-history-collapsed';
446
441
 
@@ -1079,6 +1074,38 @@ function EmbeddableChatInner({
1079
1074
  return { guide: guideOptions };
1080
1075
  }, [modes, tableIdForDocumentType]);
1081
1076
 
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
+
1082
1109
  // "Does Mingo mode exist?" — true via either the callback config OR injected
1083
1110
  // state. Gates the guide↔mingo back-chevron and the guide-mode banner.
1084
1111
  const hasMingoMode = !!effectiveModes.mingo || !!mingoState;
@@ -1212,49 +1239,8 @@ function EmbeddableChatInner({
1212
1239
  setDialogScope,
1213
1240
  hasMoreMessages,
1214
1241
  loadMoreMessages,
1215
- dialogsManaged,
1216
- dialogCapabilities,
1217
1242
  } = useUnifiedChat({ modes: effectiveModes, activeMode, mingoStateOverride: mingoState });
1218
1243
 
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
-
1258
1244
  // ── One-shot Guide-mode launcher prompt ────────────────────────────────────
1259
1245
  // A host launcher (e.g. an "Ask Mingo about X" empty-state button) requests
1260
1246
  // contextual guidance by forcing `activeMode='guide'` and passing the prompt
@@ -1794,14 +1780,7 @@ function EmbeddableChatInner({
1794
1780
  // that wants a message-list skeleton (real header + composer, skeleton bubbles)
1795
1781
  // signals it via `isMessagesLoading` — treat that as an open conversation so
1796
1782
  // the content branch shows the skeleton instead of the new-user welcome.
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);
1783
+ const hasConversation = hasMessages || isOpeningDialog || isViewingArchived || (previewMode && isMessagesLoading);
1805
1784
  // Opening a dialog whose history hasn't arrived yet — show a message-list
1806
1785
  // skeleton instead of an empty thread so the open reads as "loading" rather
1807
1786
  // than a blank flash before the bubbles stream in.
@@ -1886,32 +1865,25 @@ function EmbeddableChatInner({
1886
1865
  // mode / archive page) it stays the stacked single-column layout with the
1887
1866
  // history inline in the empty state. Fully self-contained — the host opts
1888
1867
  // 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.
1897
1868
  const [panelWidth, setPanelWidth] = useState(0);
1869
+ const panelMeasureRef = useRef<HTMLDivElement | null>(null);
1898
1870
  useEffect(() => {
1899
- if (!panelBoundary || typeof ResizeObserver === 'undefined') return undefined;
1871
+ const el = panelMeasureRef.current;
1872
+ if (!el || typeof ResizeObserver === 'undefined') return undefined;
1900
1873
  const ro = new ResizeObserver(entries => {
1901
1874
  const w = entries[0]?.contentRect?.width;
1902
1875
  if (typeof w === 'number') setPanelWidth(w);
1903
1876
  });
1904
- // `observe` fires the callback once with the current size, so no
1905
- // synchronous seed is needed (and a synchronous setState here would be a
1906
- // cascading render).
1907
- ro.observe(panelBoundary);
1877
+ ro.observe(el);
1878
+ setPanelWidth(el.clientWidth);
1908
1879
  return () => ro.disconnect();
1909
- }, [panelBoundary]);
1880
+ }, []);
1910
1881
 
1911
- // ONE node for two consumers: the width measurement above and the
1912
- // collision-boundary context. State, not a ref, so both re-run when the node
1913
- // appears (the drawer shell mounts its body only on open).
1882
+ // One ref for two consumers: the width measurement above (a plain ref, read
1883
+ // once on mount) and the collision-boundary context (state, so provider
1884
+ // consumers re-render once the node exists).
1914
1885
  const setPanelNode = useCallback((node: HTMLDivElement | null) => {
1886
+ panelMeasureRef.current = node;
1915
1887
  setPanelBoundary(node);
1916
1888
  }, []);
1917
1889
 
@@ -1957,7 +1929,7 @@ function EmbeddableChatInner({
1957
1929
  // page stays split-eligible: in wide mode it opens INSIDE the left rail (the
1958
1930
  // right chat block stays put), and only falls back to the full-panel archive
1959
1931
  // when stacked/collapsed.
1960
- const splitEligible = historyListMode;
1932
+ const splitEligible = activeMode === 'mingo';
1961
1933
  const canSplit = panelWidth >= SPLIT_MIN_WIDTH;
1962
1934
  // Embedded previews (hero demo tabs) always use the compact single-column
1963
1935
  // header, never the two-column split — so `previewMode` opts out of `wideMingo`.
@@ -1988,26 +1960,14 @@ function EmbeddableChatInner({
1988
1960
  // the SAME render the conversation opened in. Guarded, so the extra render
1989
1961
  // pass takes the early exit.
1990
1962
  if (hasConversation && composeOpen) setComposeOpen(false);
1991
- const isMingoMode = historyListMode;
1963
+ const isMingoMode = activeMode === 'mingo';
1992
1964
  // The stacked "Current Chats" list — the NARROW single-column Mingo view. It
1993
1965
  // is a narrow-only layout: in any wide layout the chat list lives in the rail,
1994
1966
  // and collapsing the rail (`wideCollapsed`) shows the chat / new-chat welcome
1995
1967
  // in the fill column (navigation is via re-expanding the rail), NOT the list.
1996
1968
  // Requires no open conversation, no archive, and not composing (the composer
1997
1969
  // lives on the compose view).
1998
- // …but a managed GUIDE panel with NOTHING to list skips straight to the
1999
- // welcome + composer: a first-time visitor to a marketing site must not have
2000
- // to tap through an empty "Current Chats" screen to ask a question. Only
2001
- // once they have history does the list become the landing view. Gated on the
2002
- // first page having loaded so it doesn't flash the welcome mid-load.
2003
- const guideListIsEmpty =
2004
- activeMode === 'guide' &&
2005
- dialogsManaged === true &&
2006
- dialogs.length === 0 &&
2007
- !dialogsInitialLoading &&
2008
- !mingoCaps.searchQuery;
2009
- const stackedListView =
2010
- isMingoMode && !hasConversation && !archiveOpen && !wideMingo && !composeOpen && !guideListIsEmpty;
1970
+ const stackedListView = isMingoMode && !hasConversation && !archiveOpen && !wideMingo && !composeOpen;
2011
1971
 
2012
1972
  // Shared header derivations — consumed by the stacked `ChatPanelHeader`, its
2013
1973
  // mobile fallback, and the desktop split header's right cell, so the title /
@@ -2077,19 +2037,12 @@ function EmbeddableChatInner({
2077
2037
  // Chats" list header (search + archive, no back) and a "New Chat" compose
2078
2038
  // header (back to the list); conversations + guide keep the shared header
2079
2039
  // derivations. Wide mode uses its own two-cell header instead.
2080
- // `!guideListIsEmpty` for the same reason as `stackedListView`: with nothing
2081
- // to list the BODY renders the Guide welcome, so a "Current Chats" header
2082
- // above it would be half of the empty screen the shortcut exists to remove.
2083
- // The else-branch header resolves to the assistant name via `isGuideEmpty`
2084
- // and keeps the archive entry point.
2085
- const narrowMingoEmpty = isMingoMode && !hasConversation && !archiveOpen && !guideListIsEmpty;
2040
+ const narrowMingoEmpty = isMingoMode && !hasConversation && !archiveOpen;
2086
2041
  const narrowHeaderProps: ChatPanelHeaderProps = narrowMingoEmpty
2087
2042
  ? composeOpen
2088
2043
  ? {
2089
2044
  showBack: true,
2090
- // Guide's compose view is its own welcome (assistant name), not a
2091
- // Mingo "New Chat".
2092
- title: isGuideEmpty ? (headerAssistantName ?? 'Mingo Guide') : 'New Chat',
2045
+ title: 'New Chat',
2093
2046
  subtitle: headerUserName,
2094
2047
  avatar: headerAvatar,
2095
2048
  backAriaLabel: 'Back to chats',
@@ -2259,7 +2212,7 @@ function EmbeddableChatInner({
2259
2212
  <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)]">
2260
2213
  <div className="flex min-w-0 flex-col">
2261
2214
  <p className="truncate leading-tight text-ods-text-primary text-h3">
2262
- {headerShowBack || isGuideEmpty ? headerTitle : 'New Chat'}
2215
+ {headerShowBack ? headerTitle : 'New Chat'}
2263
2216
  </p>
2264
2217
  {headerPersonName && (
2265
2218
  <p className="truncate leading-tight text-ods-text-secondary text-h6">{headerPersonName}</p>
@@ -2706,7 +2659,7 @@ function EmbeddableChatInner({
2706
2659
  resizable
2707
2660
  minSize={480}
2708
2661
  maxSize={1600}
2709
- defaultSize={drawerDefaultWidth(historyListMode)}
2662
+ defaultSize={drawerDefaultWidth()}
2710
2663
  storageKey={DRAWER_WIDTH_KEY}
2711
2664
  resizeAriaLabel="Resize chat panel"
2712
2665
  overlayClassName="mingo-chat-overlay"
@@ -1,6 +1,4 @@
1
- <!-- source-hash: c1865985f91c46a89c4353f6911c2b3b -->
2
-
3
- The Chat Archive list is NOT a second pager: it runs the shared `useManagedDialogList` (`autoLoad: false`, so it loads on open rather than on mount, with a 120 ms delayed skeleton), the same machine behind both transport adapters' dialog lists.
1
+ <!-- source-hash: 18f2ec0cf9ed75af0e8e8ae198973c29 -->
4
2
  Manages the dialog-history concerns for the chat panel, including archive navigation, read-only archived conversation mode, and rename/archive/restore confirmation modals — keeping `EmbeddableChat` as a thin orchestration layer.
5
3
 
6
4
  ## Key Components
@@ -1,4 +1,4 @@
1
- <!-- source-hash: 1cda8eab406b1762bfddf3d0b586c9ab -->
1
+ <!-- source-hash: 6c5780e92306ea381bac35aaf97c435f -->
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,8 +28,6 @@ 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
-
33
31
  ## Usage Example
34
32
 
35
33
  ```typescript
@@ -1,4 +1,4 @@
1
- <!-- source-hash: 4c53d129235a1e38a4bb4ae25ee53ebe -->
1
+ <!-- source-hash: b64329bea22eab16802f8dbf5b7a58c5 -->
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,13 +40,6 @@ 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
-
50
43
  ## Source
51
44
 
52
45
  [`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: a0eb58b3207fd44705d8e6448daa8387 -->
1
+ <!-- source-hash: bed5f9e4619da46892b2552f6d7eb1d6 -->
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`; plus the adapter-owned `dialogsManaged` flag and `dialogCapabilities`, forwarded verbatim so `EmbeddableChat` can gate the history UI on them regardless of transport
34
+ - **Dialog management** — `selectDialog`, `startNewDialog`, `deleteDialog`, `renameDialog`, `archiveDialog`, `loadMoreDialogs`, `setDialogScope`, `reloadDialogs`, `loadMoreMessages`
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.
@@ -27,8 +27,6 @@ export * from './use-sse';
27
27
  // access is needed. `useEmbeddedChat` is the legacy SSE alias.
28
28
  export * from './use-sse-chat-adapter';
29
29
  export * from './use-nats-chat-adapter';
30
- // Shared dialog-list state machine behind both adapters' managed modes.
31
- export * from './use-managed-dialog-list';
32
30
  export * from './use-unified-chat';
33
31
  export * from './use-embedded-chat';
34
32
 
@@ -1,9 +1,8 @@
1
1
  'use client';
2
2
 
3
- import { useCallback, useMemo, useState } from 'react';
3
+ import { useCallback, useMemo, useRef, useState } from 'react';
4
4
  import type { DialogItem } from '../types/component.types';
5
- import type { FetchDialogsParams, FetchDialogsResult } from '../types/unified-chat-state.types';
6
- import { useManagedDialogList } from './use-managed-dialog-list';
5
+ import type { FetchDialogsParams, FetchDialogsResult } from './use-nats-chat-adapter';
7
6
 
8
7
  export interface UseChatDialogManagerArgs {
9
8
  /** Active (non-archived) dialogs from the unified chat state. */
@@ -49,16 +48,8 @@ export function useChatDialogManager({
49
48
  const [renameTarget, setRenameTarget] = useState<DialogItem | null>(null);
50
49
  const [archiveTarget, setArchiveTarget] = useState<DialogItem | null>(null);
51
50
  const handleConfirmRename = useCallback(
52
- async (name: string) => {
53
- if (!renameTarget) return;
54
- try {
55
- await renameDialog(renameTarget.id, name);
56
- } catch (err) {
57
- // Keep the modal open for a retry — the same posture as archive; the
58
- // optimistic title has already rolled back inside the list hook.
59
- console.error('[useChatDialogManager] rename failed:', err);
60
- return;
61
- }
51
+ (name: string) => {
52
+ if (renameTarget) void renameDialog(renameTarget.id, name);
62
53
  setRenameTarget(null);
63
54
  },
64
55
  [renameTarget, renameDialog],
@@ -92,30 +83,66 @@ export function useChatDialogManager({
92
83
  }, [archiveTarget, archiveDialog, activeDialogId, clearMessages]);
93
84
 
94
85
  // ─── Chat Archive page ───
95
- // A secondary, on-demand view: opened from the header, paged on demand.
86
+ // The archived list is paged locally (it's a secondary, on-demand view).
96
87
  const [archiveOpen, setArchiveOpen] = useState(false);
97
- // The archived list runs the SAME cursor-paged machine as the active list
98
- // (`useManagedDialogList`) — one implementation of paging, request-ordering,
99
- // append dedupe and error handling.
100
- const {
101
- dialogs: archivedDialogs,
102
- dialogsNextCursor: archivedCursor,
103
- isDialogsLoading: archivedLoading,
104
- isDialogsPending: archivedPending,
105
- loadDialogsPage: loadArchivedPage,
106
- removeDialog: removeArchivedDialog,
107
- } = useManagedDialogList({
108
- // Loads on OPEN, not on mount — `openArchive` drives page 1 and
109
- // re-validates it on every re-open (stale-while-revalidate).
110
- autoLoad: false,
111
- fetchDialogs: fetchArchivedDialogs,
112
- pageSize: 20,
113
- // Delay the full-view skeleton so a cached/fast page-1 fetch never flashes
114
- // it; `archivedPending` still suppresses the empty state meanwhile.
115
- skeletonDelayMs: 120,
116
- logTag: '[useChatDialogManager]',
117
- });
118
-
88
+ const [archivedDialogs, setArchivedDialogs] = useState<DialogItem[]>([]);
89
+ const [archivedCursor, setArchivedCursor] = useState<string | null>(null);
90
+ const [archivedLoading, setArchivedLoading] = useState(false);
91
+ // A fetch is in flight, tracked SEPARATELY from the delayed skeleton
92
+ // (`archivedLoading`). Set synchronously so the empty state stays suppressed
93
+ // during the 120ms skeleton delay — otherwise an uncached first open flashes
94
+ // "No archived chats" before the skeleton/data appears.
95
+ const [archivedPending, setArchivedPending] = useState(false);
96
+ // Monotonic request id — a background page-1 refresh and a pagination fetch
97
+ // can overlap (the retained list stays interactive while page 1 revalidates).
98
+ // Only the LATEST request may mutate the list / cursor / loading flags, so a
99
+ // slow earlier response can't clobber newer rows, append stale ones, or clear
100
+ // the shared loading flag while another request is still in flight.
101
+ const archivedRequestIdRef = useRef(0);
102
+ const loadArchivedPage = useCallback(
103
+ async (cursor?: string): Promise<void> => {
104
+ if (!fetchArchivedDialogs) return;
105
+ const requestId = ++archivedRequestIdRef.current;
106
+ const isCurrent = () => archivedRequestIdRef.current === requestId;
107
+ // Only a first-page load drives the full-view skeleton, and only if it's
108
+ // actually slow: a 120ms delay means a cached/fast fetch (the host caches
109
+ // page 1) resolves first and never flashes a skeleton. Pagination
110
+ // (`cursor`) keeps the current list visible.
111
+ const isInitial = !cursor;
112
+ setArchivedPending(true);
113
+ let skeletonTimer: ReturnType<typeof setTimeout> | undefined;
114
+ if (isInitial) {
115
+ // Delay the full-view skeleton so a cached/fast page-1 fetch never
116
+ // flashes it (and skip it if a newer request already superseded us).
117
+ skeletonTimer = setTimeout(() => {
118
+ if (isCurrent()) setArchivedLoading(true);
119
+ }, 120);
120
+ } else {
121
+ // Pagination shows its "load more" indicator immediately (the list
122
+ // stays visible), so no delay here.
123
+ setArchivedLoading(true);
124
+ }
125
+ try {
126
+ const result = await fetchArchivedDialogs({ cursor, limit: 20 });
127
+ // A newer request superseded this one — drop the response so overlapping
128
+ // refresh / pagination can't append stale rows or clobber newer results.
129
+ if (!isCurrent()) return;
130
+ setArchivedCursor(result.nextCursor);
131
+ setArchivedDialogs(prev => (cursor ? [...prev, ...result.dialogs] : result.dialogs));
132
+ } catch (err) {
133
+ if (!isCurrent()) return;
134
+ console.error('[useChatDialogManager] fetchArchivedDialogs failed:', err);
135
+ } finally {
136
+ if (skeletonTimer) clearTimeout(skeletonTimer);
137
+ // Only the latest request owns the shared loading / pending flags.
138
+ if (isCurrent()) {
139
+ setArchivedLoading(false);
140
+ setArchivedPending(false);
141
+ }
142
+ }
143
+ },
144
+ [fetchArchivedDialogs],
145
+ );
119
146
  const openArchive = useCallback(() => {
120
147
  setArchiveOpen(true);
121
148
  // Don't clear the list — keep any already-loaded page visible and refresh
@@ -163,11 +190,11 @@ export function useChatDialogManager({
163
190
  }
164
191
  // Drop it from the locally-cached archived list and exit read-only mode
165
192
  // so the composer returns and the user can keep chatting.
166
- removeArchivedDialog(restoreTarget.id);
193
+ setArchivedDialogs(prev => prev.filter(d => d.id !== restoreTarget.id));
167
194
  setViewingArchivedId(cur => (cur === restoreTarget.id ? null : cur));
168
195
  }
169
196
  setRestoreTarget(null);
170
- }, [restoreTarget, unarchiveDialog, removeArchivedDialog]);
197
+ }, [restoreTarget, unarchiveDialog]);
171
198
 
172
199
  const isViewingArchived = viewingArchivedId != null && viewingArchivedId === activeDialogId;
173
200