@flamingo-stack/openframe-frontend-core 0.0.583 → 0.0.584-1973.5420.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.
Files changed (149) hide show
  1. package/dist/chat-protocol/events.d.ts +8 -2
  2. package/dist/chat-protocol/events.d.ts.map +1 -1
  3. package/dist/chat-protocol/index.cjs +177 -0
  4. package/dist/chat-protocol/index.cjs.map +1 -1
  5. package/dist/chat-protocol/index.js +177 -0
  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/chat-protocol/source-metadata.d.ts +3 -0
  9. package/dist/chat-protocol/source-metadata.d.ts.map +1 -0
  10. package/dist/{chunk-EATPU5EF.cjs → chunk-3MAG3EG4.cjs} +9 -9
  11. package/dist/{chunk-EATPU5EF.cjs.map → chunk-3MAG3EG4.cjs.map} +1 -1
  12. package/dist/{chunk-IKUSKKFZ.cjs → chunk-4TZOFXPH.cjs} +712 -432
  13. package/dist/chunk-4TZOFXPH.cjs.map +1 -0
  14. package/dist/{chunk-WMRXB6RS.js → chunk-54WRMPCY.js} +3 -3
  15. package/dist/{chunk-WTC6QQNX.cjs → chunk-7IVT56YY.cjs} +3 -3
  16. package/dist/{chunk-WTC6QQNX.cjs.map → chunk-7IVT56YY.cjs.map} +1 -1
  17. package/dist/{chunk-PFKWJ6PJ.js → chunk-AQW2PDRS.js} +2 -2
  18. package/dist/{chunk-DROXHJVZ.js → chunk-AVVKXNGI.js} +2 -2
  19. package/dist/{chunk-YNLIXABT.cjs → chunk-CE6CA6EM.cjs} +43 -43
  20. package/dist/{chunk-YNLIXABT.cjs.map → chunk-CE6CA6EM.cjs.map} +1 -1
  21. package/dist/{chunk-TRD2YICZ.cjs → chunk-CGLQLBMQ.cjs} +21 -21
  22. package/dist/{chunk-TRD2YICZ.cjs.map → chunk-CGLQLBMQ.cjs.map} +1 -1
  23. package/dist/{chunk-XWBND4G5.js → chunk-CO4WRST6.js} +301 -21
  24. package/dist/chunk-CO4WRST6.js.map +1 -0
  25. package/dist/{chunk-IJVWKLJK.cjs → chunk-DHLD3JXN.cjs} +69 -69
  26. package/dist/{chunk-IJVWKLJK.cjs.map → chunk-DHLD3JXN.cjs.map} +1 -1
  27. package/dist/{chunk-M6ZUEBDK.cjs → chunk-F2EN6MXN.cjs} +159 -159
  28. package/dist/{chunk-M6ZUEBDK.cjs.map → chunk-F2EN6MXN.cjs.map} +1 -1
  29. package/dist/{chunk-J3EEL6YC.js → chunk-FH2FH337.js} +5 -5
  30. package/dist/{chunk-L26MD32B.js → chunk-GDHI3JN5.js} +3 -3
  31. package/dist/{chunk-VWHEXQ64.js → chunk-GFIH73Q3.js} +3 -3
  32. package/dist/{chunk-R5A3MGMY.js → chunk-H6GYY5CB.js} +3 -3
  33. package/dist/{chunk-FCLM2RXI.js → chunk-HGJAUYHW.js} +2 -2
  34. package/dist/{chunk-RBDVHLT5.cjs → chunk-HKKQCVVY.cjs} +22 -22
  35. package/dist/{chunk-RBDVHLT5.cjs.map → chunk-HKKQCVVY.cjs.map} +1 -1
  36. package/dist/{chunk-KDWNMFX4.cjs → chunk-JEMGFSC2.cjs} +24 -24
  37. package/dist/{chunk-KDWNMFX4.cjs.map → chunk-JEMGFSC2.cjs.map} +1 -1
  38. package/dist/{chunk-BTBW4L2W.cjs → chunk-JX6RSSZP.cjs} +33 -33
  39. package/dist/{chunk-BTBW4L2W.cjs.map → chunk-JX6RSSZP.cjs.map} +1 -1
  40. package/dist/{chunk-WHNC7C76.js → chunk-KN2ZCZQ7.js} +5 -5
  41. package/dist/{chunk-WBTKXNKZ.cjs → chunk-MYVHYVQM.cjs} +10 -10
  42. package/dist/{chunk-WBTKXNKZ.cjs.map → chunk-MYVHYVQM.cjs.map} +1 -1
  43. package/dist/{chunk-3TNM6SDP.cjs → chunk-PI3BNDCW.cjs} +15 -15
  44. package/dist/{chunk-3TNM6SDP.cjs.map → chunk-PI3BNDCW.cjs.map} +1 -1
  45. package/dist/{chunk-XZ3MKTJZ.js → chunk-PWI66GZF.js} +2 -2
  46. package/dist/{chunk-IFPGXSMZ.cjs → chunk-RTI3TYMX.cjs} +3 -3
  47. package/dist/{chunk-IFPGXSMZ.cjs.map → chunk-RTI3TYMX.cjs.map} +1 -1
  48. package/dist/{chunk-6BI3AYBY.cjs → chunk-SS2TCIKA.cjs} +4 -4
  49. package/dist/{chunk-6BI3AYBY.cjs.map → chunk-SS2TCIKA.cjs.map} +1 -1
  50. package/dist/{chunk-HIHPWVKP.js → chunk-T35JA5XV.js} +5 -5
  51. package/dist/{chunk-EZ5VU5WS.js → chunk-TLZ7HTXP.js} +2 -2
  52. package/dist/{chunk-OCXFFGFA.cjs → chunk-UZUG7QZ3.cjs} +10 -10
  53. package/dist/{chunk-OCXFFGFA.cjs.map → chunk-UZUG7QZ3.cjs.map} +1 -1
  54. package/dist/{chunk-3RR67XC2.cjs → chunk-W46U5J3H.cjs} +5 -5
  55. package/dist/{chunk-3RR67XC2.cjs.map → chunk-W46U5J3H.cjs.map} +1 -1
  56. package/dist/{chunk-IOP7BCRQ.js → chunk-WFF5JMQ2.js} +6 -6
  57. package/dist/{chunk-AJLF6MBD.js → chunk-X4HLHN36.js} +3 -3
  58. package/dist/{chunk-PMA7DVQR.js → chunk-ZWB64HOD.js} +4 -4
  59. package/dist/components/case-studies/index.cjs +9 -9
  60. package/dist/components/case-studies/index.js +3 -3
  61. package/dist/components/chat/chat-message-enhanced.d.ts.map +1 -1
  62. package/dist/components/chat/chat-message-list.d.ts.map +1 -1
  63. package/dist/components/chat/entity-cards/dispatch.d.ts.map +1 -1
  64. package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts +4 -1
  65. package/dist/components/chat/hooks/use-nats-chat-adapter.d.ts.map +1 -1
  66. package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts +2 -28
  67. package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts.map +1 -1
  68. package/dist/components/chat/index.cjs +2 -2
  69. package/dist/components/chat/index.js +1 -1
  70. package/dist/components/chat/stream/chat-stream-reducer.d.ts.map +1 -1
  71. package/dist/components/chat/tool-execution-display.d.ts.map +1 -1
  72. package/dist/components/chat/types/component.types.d.ts +2 -0
  73. package/dist/components/chat/types/component.types.d.ts.map +1 -1
  74. package/dist/components/chat/types/message.types.d.ts +35 -1
  75. package/dist/components/chat/types/message.types.d.ts.map +1 -1
  76. package/dist/components/chat/types/unified-chat-state.types.d.ts +3 -3
  77. package/dist/components/chat/types/unified-chat-state.types.d.ts.map +1 -1
  78. package/dist/components/chat/utils/chat-source-metadata.d.ts +5 -0
  79. package/dist/components/chat/utils/chat-source-metadata.d.ts.map +1 -0
  80. package/dist/components/chat/utils/process-historical-messages.d.ts.map +1 -1
  81. package/dist/components/contact/index.cjs +4 -4
  82. package/dist/components/contact/index.js +3 -3
  83. package/dist/components/docs/index.cjs +7 -7
  84. package/dist/components/docs/index.js +6 -6
  85. package/dist/components/embeds/index.cjs +4 -4
  86. package/dist/components/embeds/index.js +3 -3
  87. package/dist/components/faq/index.cjs +4 -4
  88. package/dist/components/faq/index.js +3 -3
  89. package/dist/components/features/index.cjs +3 -3
  90. package/dist/components/features/index.js +2 -2
  91. package/dist/components/help-center-pages/index.cjs +23 -23
  92. package/dist/components/help-center-pages/index.js +14 -14
  93. package/dist/components/index.cjs +36 -36
  94. package/dist/components/index.js +13 -13
  95. package/dist/components/meeting-scheduler/index.cjs +21 -21
  96. package/dist/components/meeting-scheduler/index.js +2 -2
  97. package/dist/components/navigation/index.cjs +6 -6
  98. package/dist/components/navigation/index.js +5 -5
  99. package/dist/components/onboarding-guides/index.cjs +6 -6
  100. package/dist/components/onboarding-guides/index.js +5 -5
  101. package/dist/components/tickets/index.cjs +7 -7
  102. package/dist/components/tickets/index.js +6 -6
  103. package/dist/components/ui/index.cjs +3 -3
  104. package/dist/components/ui/index.js +2 -2
  105. package/dist/index.cjs +7 -7
  106. package/dist/index.js +6 -6
  107. package/dist/utils/index.cjs.map +1 -1
  108. package/dist/utils/index.js.map +1 -1
  109. package/package.json +1 -1
  110. package/src/chat-protocol/__tests__/nats-decoder-golden.test.ts +130 -0
  111. package/src/chat-protocol/events.ts +9 -1
  112. package/src/chat-protocol/nats-decoder.ts +7 -0
  113. package/src/chat-protocol/source-metadata.ts +187 -0
  114. package/src/components/chat/__tests__/chat-message-streaming-memo.test.tsx +86 -0
  115. package/src/components/chat/__tests__/embeddable-chat-sources.test.tsx +171 -0
  116. package/src/components/chat/__tests__/tool-execution-display.test.tsx +93 -0
  117. package/src/components/chat/chat-message-enhanced.tsx +28 -13
  118. package/src/components/chat/chat-message-list.tsx +1 -0
  119. package/src/components/chat/embeddable-chat.tsx +10 -1
  120. package/src/components/chat/entity-cards/__tests__/dispatch-video-refs.test.tsx +74 -0
  121. package/src/components/chat/entity-cards/dispatch.tsx +48 -11
  122. package/src/components/chat/hooks/use-nats-chat-adapter.ts +7 -0
  123. package/src/components/chat/hooks/use-sse-chat-adapter.ts +2 -29
  124. package/src/components/chat/stream/__tests__/chat-stream-reducer.test.ts +56 -0
  125. package/src/components/chat/stream/chat-stream-reducer.ts +31 -0
  126. package/src/components/chat/tool-execution-display.tsx +5 -2
  127. package/src/components/chat/types/component.types.ts +2 -0
  128. package/src/components/chat/types/message.types.ts +39 -0
  129. package/src/components/chat/types/unified-chat-state.types.ts +4 -3
  130. package/src/components/chat/utils/__tests__/process-historical-messages-golden.test.ts +57 -0
  131. package/src/components/chat/utils/chat-source-metadata.ts +19 -0
  132. package/src/components/chat/utils/process-historical-messages.ts +19 -1
  133. package/dist/chunk-IKUSKKFZ.cjs.map +0 -1
  134. package/dist/chunk-XWBND4G5.js.map +0 -1
  135. /package/dist/{chunk-WMRXB6RS.js.map → chunk-54WRMPCY.js.map} +0 -0
  136. /package/dist/{chunk-PFKWJ6PJ.js.map → chunk-AQW2PDRS.js.map} +0 -0
  137. /package/dist/{chunk-DROXHJVZ.js.map → chunk-AVVKXNGI.js.map} +0 -0
  138. /package/dist/{chunk-J3EEL6YC.js.map → chunk-FH2FH337.js.map} +0 -0
  139. /package/dist/{chunk-L26MD32B.js.map → chunk-GDHI3JN5.js.map} +0 -0
  140. /package/dist/{chunk-VWHEXQ64.js.map → chunk-GFIH73Q3.js.map} +0 -0
  141. /package/dist/{chunk-R5A3MGMY.js.map → chunk-H6GYY5CB.js.map} +0 -0
  142. /package/dist/{chunk-FCLM2RXI.js.map → chunk-HGJAUYHW.js.map} +0 -0
  143. /package/dist/{chunk-WHNC7C76.js.map → chunk-KN2ZCZQ7.js.map} +0 -0
  144. /package/dist/{chunk-XZ3MKTJZ.js.map → chunk-PWI66GZF.js.map} +0 -0
  145. /package/dist/{chunk-HIHPWVKP.js.map → chunk-T35JA5XV.js.map} +0 -0
  146. /package/dist/{chunk-EZ5VU5WS.js.map → chunk-TLZ7HTXP.js.map} +0 -0
  147. /package/dist/{chunk-IOP7BCRQ.js.map → chunk-WFF5JMQ2.js.map} +0 -0
  148. /package/dist/{chunk-AJLF6MBD.js.map → chunk-X4HLHN36.js.map} +0 -0
  149. /package/dist/{chunk-PMA7DVQR.js.map → chunk-ZWB64HOD.js.map} +0 -0
@@ -3,6 +3,7 @@
3
3
  * Contains all message structures, segments, and content types
4
4
  */
5
5
 
6
+ import type { ChatRef } from '../chat-ref.types';
6
7
  import type { AssistantType, AuthorType, ChatApprovalStatus, MessageOwner } from './chat.types';
7
8
 
8
9
  // ========== Message Type Definitions ==========
@@ -10,6 +11,8 @@ import type { AssistantType, AuthorType, ChatApprovalStatus, MessageOwner } from
10
11
  export const MESSAGE_TYPE = {
11
12
  TEXT: 'TEXT',
12
13
  THINKING: 'THINKING',
14
+ GUIDE: 'GUIDE',
15
+ SOURCES: 'SOURCES',
13
16
  ASK: 'ASK',
14
17
  EXECUTING_TOOL: 'EXECUTING_TOOL',
15
18
  EXECUTED_TOOL: 'EXECUTED_TOOL',
@@ -46,6 +49,26 @@ export const SCROLL_ANCHOR = { TOP: 'top', BOTTOM: 'bottom' } as const;
46
49
 
47
50
  export type ScrollAnchor = (typeof SCROLL_ANCHOR)[keyof typeof SCROLL_ANCHOR];
48
51
 
52
+ export interface ChatSource {
53
+ index: number;
54
+ name: string;
55
+ path: string;
56
+ documentType: string;
57
+ externalUrl?: string;
58
+ targetPlatform?: string | null;
59
+ id?: string;
60
+ items?: Array<{
61
+ id: string;
62
+ documentType: string;
63
+ name: string;
64
+ externalUrl?: string;
65
+ targetPlatform?: string | null;
66
+ path?: string | null;
67
+ }>;
68
+ sourceRepo?: string;
69
+ label?: string;
70
+ }
71
+
49
72
  // ========== Tool Execution Types ==========
50
73
 
51
74
  export interface ToolExecutionData {
@@ -391,6 +414,16 @@ export interface ThinkingMessageData extends MessageDataBase {
391
414
  text?: string;
392
415
  }
393
416
 
417
+ export interface GuideMessageData extends MessageDataBase {
418
+ type: 'GUIDE';
419
+ payload?: Record<string, unknown>;
420
+ }
421
+
422
+ export interface SourcesMessageData extends MessageDataBase {
423
+ type: 'SOURCES';
424
+ payload?: Record<string, unknown>;
425
+ }
426
+
394
427
  /** Persisted `ASK` row (GraphQL `AskData`). `text` is the intro sentence, which
395
428
  * history replays as a text segment ahead of the card — same split the live
396
429
  * `ASK` chunk carries. */
@@ -532,6 +565,8 @@ export interface ContextCompactionEndMessageData extends MessageDataBase {
532
565
  export type MessageData =
533
566
  | TextMessageData
534
567
  | ThinkingMessageData
568
+ | GuideMessageData
569
+ | SourcesMessageData
535
570
  | AskMessageData
536
571
  | ExecutingToolMessageData
537
572
  | ExecutedToolMessageData
@@ -576,6 +611,8 @@ export interface ProcessedMessage {
576
611
  authorType?: AuthorType;
577
612
  timestamp: Date;
578
613
  avatar?: string;
614
+ sources?: ChatSource[];
615
+ refs?: ChatRef[];
579
616
  /** Persisted last-chunk stream sequence carried through from
580
617
  * `HistoricalMessage.lastChunkStreamSeq` (for assistant turns: the MAX
581
618
  * across the grouped rows). Hosts stamp it onto the rendered message's
@@ -598,6 +635,8 @@ export interface Message {
598
635
  authorType?: AuthorType;
599
636
  timestamp?: Date;
600
637
  avatar?: string | null;
638
+ sources?: ChatSource[];
639
+ refs?: ChatRef[];
601
640
  /** Highest CONTENT chunk streamSeq that composed this message. Stamped on
602
641
  * realtime synthetics so `mergeHistoryWithRealtime` can decide history
603
642
  * coverage per-message (see `MergeableChatMessage.streamSeq`). */
@@ -17,12 +17,11 @@
17
17
  */
18
18
 
19
19
  import type { ChatRef } from '../chat-ref.types';
20
- import type { ChatSource } from '../hooks/use-sse-chat-adapter';
21
20
  import type { ChatAttachment } from '../utils/chat-attachment-markdown';
22
21
  import type { AuthorType } from './chat.types';
23
22
  import type { DialogItem } from './component.types';
24
23
  import type { ChatContextItem } from './context-item.types';
25
- import type { MessageSegment, ScrollAnchor } from './message.types';
24
+ import type { ChatSource, MessageSegment, ScrollAnchor } from './message.types';
26
25
 
27
26
  // ─── Per-dialog token usage (Mingo backend telemetry) ────────────────────────
28
27
 
@@ -169,9 +168,11 @@ export interface UnifiedChatMessage {
169
168
  */
170
169
  timestamp?: Date | string | number;
171
170
 
172
- /** Guide/SSE-only: document citations. Undefined in Mingo mode. */
171
+ /** Document citations for a Guide answer over SSE or NATS. */
173
172
  sources?: ChatSource[];
174
173
 
174
+ refs?: ChatRef[];
175
+
175
176
  /**
176
177
  * Per-message viewport-positioning hint. Common to both modes; the
177
178
  * message-list reads it to override default tail-on-stream behaviour
@@ -391,3 +391,60 @@ describe('processHistoricalMessages — ASK rows', () => {
391
391
  expect(processHistoricalMessages(dialog).messages).toEqual([]);
392
392
  });
393
393
  });
394
+
395
+ describe('processHistoricalMessages — Mingo source metadata', () => {
396
+ it.each(['GUIDE', 'SOURCES'] as const)('restores %s metadata on the same assistant turn', type => {
397
+ const dialog: HistoricalMessage[] = [
398
+ {
399
+ id: 'a1',
400
+ chatType: 'ADMIN_AI_CHAT',
401
+ createdAt: '2026-07-19T09:00:05Z',
402
+ owner: { type: 'ASSISTANT' },
403
+ messageData: [
404
+ {
405
+ type,
406
+ payload: {
407
+ sources: [
408
+ {
409
+ index: 1,
410
+ name: 'Install agent',
411
+ path: 'docs/install.md',
412
+ documentType: 'markdown',
413
+ },
414
+ ],
415
+ videos: [
416
+ {
417
+ ref: '[card://video:mux-9b6586b494]',
418
+ title: 'Community demo',
419
+ url: 'https://stream.mux.com/playback-id.m3u8',
420
+ metadata: { videoUrl: 'https://stream.mux.com/playback-id.m3u8' },
421
+ },
422
+ ],
423
+ },
424
+ },
425
+ { type: 'TEXT', text: 'Install the agent [1]. [card://video:mux-9b6586b494]' },
426
+ ],
427
+ },
428
+ ];
429
+
430
+ expect(processHistoricalMessages(dialog).messages[0]).toMatchObject({
431
+ role: 'assistant',
432
+ sources: [
433
+ {
434
+ index: 1,
435
+ name: 'Install agent',
436
+ path: 'docs/install.md',
437
+ documentType: 'markdown',
438
+ },
439
+ ],
440
+ refs: [
441
+ {
442
+ type: 'video',
443
+ id: 'mux-9b6586b494',
444
+ metadata: { videoUrl: 'https://stream.mux.com/playback-id.m3u8' },
445
+ },
446
+ ],
447
+ content: [{ type: 'text', text: 'Install the agent [1]. [card://video:mux-9b6586b494]' }],
448
+ });
449
+ });
450
+ });
@@ -0,0 +1,19 @@
1
+ import type { ChatRef } from '../chat-ref.types';
2
+ import type { ChatSource } from '../types/message.types';
3
+
4
+ export function mergeChatSources(current: ChatSource[] | undefined, incoming: ChatSource[]): ChatSource[] {
5
+ const sourcesByIndex = new Map((current ?? []).map(source => [source.index, source]));
6
+ incoming.forEach(source => {
7
+ if (!sourcesByIndex.has(source.index)) sourcesByIndex.set(source.index, source);
8
+ });
9
+ return Array.from(sourcesByIndex.values());
10
+ }
11
+
12
+ export function mergeChatRefs(current: ChatRef[] | undefined, incoming: ChatRef[]): ChatRef[] {
13
+ const refsByIdentity = new Map((current ?? []).map(ref => [`${ref.type}:${ref.id}`, ref]));
14
+ incoming.forEach(ref => {
15
+ const identity = `${ref.type}:${ref.id}`;
16
+ if (!refsByIdentity.has(identity)) refsByIdentity.set(identity, ref);
17
+ });
18
+ return Array.from(refsByIdentity.values());
19
+ }
@@ -33,7 +33,8 @@ import {
33
33
  } from '../../../chat-protocol/events';
34
34
  // One normalizer for ask rows, shared with the live decoder — history and the
35
35
  // stream must agree on which options are usable.
36
- import { normalizeAskOptions } from '../../../chat-protocol/nats-decoder';
36
+ import { decodeNatsChunk, normalizeAskOptions } from '../../../chat-protocol/nats-decoder';
37
+ import type { ChatRef } from '../chat-ref.types';
37
38
  import { applyApprovalStatusToSegment } from '../stream/message-mutations';
38
39
  import {
39
40
  MESSAGE_TYPE,
@@ -46,8 +47,10 @@ import {
46
47
  type MessageProcessingOptions,
47
48
  type MessageData,
48
49
  type MessageOwner,
50
+ type ChatSource,
49
51
  } from '../types';
50
52
  import { approvalDisplaysInline } from './approval-display';
53
+ import { mergeChatRefs, mergeChatSources } from './chat-source-metadata';
51
54
  import { type MessageSegmentAccumulator, createMessageSegmentAccumulator } from './message-segment-accumulator';
52
55
  import { getCommandText } from './tool-call-helpers';
53
56
 
@@ -121,6 +124,10 @@ export function decodeHistoricalMessageData(data: MessageData): ChatStreamEvent
121
124
  }
122
125
  return null;
123
126
 
127
+ case MESSAGE_TYPE.GUIDE:
128
+ case MESSAGE_TYPE.SOURCES:
129
+ return decodeNatsChunk({ type: data.type, payload: data.payload });
130
+
124
131
  // Same completeness gate as the live decoder (`decodeNatsChunk`): a
125
132
  // persisted row without a question or without options is not a card the
126
133
  // user can answer, so it replays as nothing rather than as empty chrome.
@@ -591,6 +598,8 @@ export function processHistoricalMessages(
591
598
  // MAX persisted seq across the rows grouped into the current assistant turn
592
599
  // — carried onto the flushed message's streamSeq for per-role merge coverage.
593
600
  let currentAssistantStreamSeq: number | undefined;
601
+ let currentAssistantSources: ChatSource[] | undefined;
602
+ let currentAssistantRefs: ChatRef[] | undefined;
594
603
 
595
604
  /**
596
605
  * Flush the current assistant message to processedMessages.
@@ -608,6 +617,8 @@ export function processHistoricalMessages(
608
617
  authorType: assistantType,
609
618
  timestamp: currentAssistantTimestamp || new Date(),
610
619
  avatar: assistantAvatar,
620
+ ...(currentAssistantSources ? { sources: currentAssistantSources } : {}),
621
+ ...(currentAssistantRefs ? { refs: currentAssistantRefs } : {}),
611
622
  ...(currentAssistantStreamSeq !== undefined ? { streamSeq: currentAssistantStreamSeq } : {}),
612
623
  });
613
624
  accumulator.resetSegments();
@@ -623,6 +634,8 @@ export function processHistoricalMessages(
623
634
  currentAssistantTimestamp = null;
624
635
  lastAssistantId = null;
625
636
  currentAssistantStreamSeq = undefined;
637
+ currentAssistantSources = undefined;
638
+ currentAssistantRefs = undefined;
626
639
  };
627
640
 
628
641
  messages.forEach((msg, index) => {
@@ -689,6 +702,11 @@ export function processHistoricalMessages(
689
702
  messageDataArray.forEach(data => {
690
703
  const event = decodeHistoricalMessageData(data);
691
704
  if (!event) return;
705
+ if (event.type === 'sources') {
706
+ currentAssistantSources = mergeChatSources(currentAssistantSources, event.sources);
707
+ if (event.refs) currentAssistantRefs = mergeChatRefs(currentAssistantRefs, event.refs);
708
+ return;
709
+ }
692
710
  applyHistoryEvent(
693
711
  event,
694
712
  accumulator,