@flamingo-stack/openframe-frontend-core 0.0.609-snapshot.20260908170120 → 0.0.609
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/events.d.ts +2 -21
- package/dist/chat-protocol/events.d.ts.map +1 -1
- package/dist/chat-protocol/index.cjs +9 -211
- package/dist/chat-protocol/index.cjs.map +1 -1
- package/dist/chat-protocol/index.js +9 -211
- package/dist/chat-protocol/index.js.map +1 -1
- package/dist/chat-protocol/nats-decoder.d.ts.map +1 -1
- package/dist/{chunk-2YMDDD5V.cjs → chunk-3N4FXBVJ.cjs} +3 -3
- package/dist/{chunk-2YMDDD5V.cjs.map → chunk-3N4FXBVJ.cjs.map} +1 -1
- package/dist/{chunk-THCB7NHV.cjs → chunk-3XNMDLGB.cjs} +9 -9
- package/dist/{chunk-THCB7NHV.cjs.map → chunk-3XNMDLGB.cjs.map} +1 -1
- package/dist/{chunk-GFAHCXIL.cjs → chunk-45XXK2VU.cjs} +10 -10
- package/dist/{chunk-GFAHCXIL.cjs.map → chunk-45XXK2VU.cjs.map} +1 -1
- package/dist/{chunk-2QBXG74C.js → chunk-6MLRFM3T.js} +5 -5
- package/dist/{chunk-IBMHEOBV.js → chunk-B3UXNGVM.js} +3 -3
- package/dist/{chunk-O6PO5BHE.js → chunk-B7LYKBCD.js} +5 -5
- package/dist/{chunk-F2C2U7CP.js → chunk-BSMPCPOZ.js} +299 -590
- package/dist/chunk-BSMPCPOZ.js.map +1 -0
- package/dist/{chunk-MGXSJI23.js → chunk-BUXGWBTF.js} +2 -2
- package/dist/{chunk-OIKZDXNW.js → chunk-C7CTEUU7.js} +2 -2
- package/dist/{chunk-EANAFFAD.cjs → chunk-CZTOSG7Q.cjs} +22 -22
- package/dist/{chunk-EANAFFAD.cjs.map → chunk-CZTOSG7Q.cjs.map} +1 -1
- package/dist/{chunk-C4KQ2XPK.cjs → chunk-D3DTC7SZ.cjs} +15 -15
- package/dist/{chunk-C4KQ2XPK.cjs.map → chunk-D3DTC7SZ.cjs.map} +1 -1
- package/dist/{chunk-HKJ3WKGW.cjs → chunk-DKNXAJMP.cjs} +159 -159
- package/dist/{chunk-HKJ3WKGW.cjs.map → chunk-DKNXAJMP.cjs.map} +1 -1
- package/dist/{chunk-UFFVMZDL.cjs → chunk-FYG7QNAO.cjs} +5 -5
- package/dist/{chunk-UFFVMZDL.cjs.map → chunk-FYG7QNAO.cjs.map} +1 -1
- package/dist/{chunk-THCSSPXU.cjs → chunk-GMOBT5NP.cjs} +70 -70
- package/dist/{chunk-THCSSPXU.cjs.map → chunk-GMOBT5NP.cjs.map} +1 -1
- package/dist/{chunk-HQSCJYCF.js → chunk-HGVW7OHI.js} +2 -2
- package/dist/{chunk-FS3CTGIR.js → chunk-JKM5FH63.js} +3 -3
- package/dist/{chunk-37CAZTLP.js → chunk-JOCVQZGT.js} +5 -5
- package/dist/{chunk-ROOIHDLS.js → chunk-JR7I2AGL.js} +3 -3
- package/dist/{chunk-OVVKVIMH.cjs → chunk-L2JWC5VS.cjs} +43 -43
- package/dist/{chunk-OVVKVIMH.cjs.map → chunk-L2JWC5VS.cjs.map} +1 -1
- package/dist/{chunk-25YIHMZ6.js → chunk-LA2W5L6K.js} +2 -2
- package/dist/{chunk-V6TINNLD.js → chunk-MVBRMQGU.js} +2 -2
- package/dist/{chunk-Q3APHZK5.cjs → chunk-NJUSDREV.cjs} +22 -22
- package/dist/{chunk-Q3APHZK5.cjs.map → chunk-NJUSDREV.cjs.map} +1 -1
- package/dist/{chunk-FASOANK7.cjs → chunk-O2M4T34Q.cjs} +4 -4
- package/dist/{chunk-FASOANK7.cjs.map → chunk-O2M4T34Q.cjs.map} +1 -1
- package/dist/{chunk-R2UDEMKK.js → chunk-OTYV6SDN.js} +3 -3
- package/dist/{chunk-HZS4TV34.js → chunk-QX4ANESW.js} +6 -6
- package/dist/{chunk-ZDLCWNM6.cjs → chunk-RZM6FPOT.cjs} +25 -25
- package/dist/{chunk-ZDLCWNM6.cjs.map → chunk-RZM6FPOT.cjs.map} +1 -1
- package/dist/{chunk-GNLV326I.cjs → chunk-SEW25Y2W.cjs} +10 -10
- package/dist/{chunk-GNLV326I.cjs.map → chunk-SEW25Y2W.cjs.map} +1 -1
- package/dist/{chunk-QE2Z6WME.cjs → chunk-TCEALWE3.cjs} +33 -33
- package/dist/{chunk-QE2Z6WME.cjs.map → chunk-TCEALWE3.cjs.map} +1 -1
- package/dist/{chunk-OJZW3GE2.js → chunk-TJ3GFULR.js} +3 -3
- package/dist/{chunk-Q2CNCBMK.js → chunk-VCYRJY7J.js} +4 -4
- package/dist/{chunk-YXTAV2E3.cjs → chunk-XNDTYTVT.cjs} +683 -974
- package/dist/chunk-XNDTYTVT.cjs.map +1 -0
- package/dist/{chunk-WJQOYSR3.cjs → chunk-ZRLFBLME.cjs} +3 -3
- package/dist/{chunk-WJQOYSR3.cjs.map → chunk-ZRLFBLME.cjs.map} +1 -1
- package/dist/components/case-studies/index.cjs +9 -9
- package/dist/components/case-studies/index.js +3 -3
- package/dist/components/chat/chat-message-enhanced.d.ts.map +1 -1
- package/dist/components/chat/chat-message-list.d.ts.map +1 -1
- package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts +28 -5
- package/dist/components/chat/hooks/use-sse-chat-adapter.d.ts.map +1 -1
- package/dist/components/chat/index.cjs +2 -2
- package/dist/components/chat/index.js +1 -1
- package/dist/components/chat/remark-card-links.d.ts +4 -5
- package/dist/components/chat/remark-card-links.d.ts.map +1 -1
- package/dist/components/chat/stream/chat-stream-reducer.d.ts.map +1 -1
- package/dist/components/chat/tool-execution-display.d.ts.map +1 -1
- package/dist/components/chat/types/component.types.d.ts +0 -27
- package/dist/components/chat/types/component.types.d.ts.map +1 -1
- package/dist/components/chat/types/message.types.d.ts +1 -81
- package/dist/components/chat/types/message.types.d.ts.map +1 -1
- package/dist/components/chat/types/unified-chat-state.types.d.ts +3 -12
- package/dist/components/chat/types/unified-chat-state.types.d.ts.map +1 -1
- package/dist/components/chat/utils/process-historical-messages.d.ts.map +1 -1
- package/dist/components/contact/index.cjs +4 -4
- package/dist/components/contact/index.js +3 -3
- package/dist/components/docs/index.cjs +7 -7
- package/dist/components/docs/index.js +6 -6
- package/dist/components/embeds/index.cjs +4 -4
- package/dist/components/embeds/index.js +3 -3
- package/dist/components/faq/index.cjs +4 -4
- package/dist/components/faq/index.js +3 -3
- package/dist/components/features/index.cjs +3 -3
- package/dist/components/features/index.js +2 -2
- package/dist/components/help-center-pages/index.cjs +23 -23
- package/dist/components/help-center-pages/index.js +14 -14
- package/dist/components/index.cjs +38 -38
- package/dist/components/index.js +13 -13
- package/dist/components/meeting-scheduler/index.cjs +24 -24
- package/dist/components/meeting-scheduler/index.js +2 -2
- package/dist/components/navigation/index.cjs +6 -6
- package/dist/components/navigation/index.js +5 -5
- package/dist/components/onboarding-guides/index.cjs +6 -6
- package/dist/components/onboarding-guides/index.js +5 -5
- package/dist/components/tickets/index.cjs +7 -7
- package/dist/components/tickets/index.js +6 -6
- package/dist/components/ui/index.cjs +3 -3
- package/dist/components/ui/index.js +2 -2
- package/dist/index.cjs +7 -7
- package/dist/index.js +6 -6
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/chat-protocol/events.ts +1 -22
- package/src/chat-protocol/nats-decoder.ts +0 -12
- package/src/components/chat/chat-message-enhanced.tsx +12 -37
- package/src/components/chat/chat-message-list.tsx +1 -14
- package/src/components/chat/embeddable-chat.tsx +87 -47
- package/src/components/chat/hooks/use-sse-chat-adapter.ts +28 -5
- package/src/components/chat/remark-card-links.ts +12 -14
- package/src/components/chat/stream/chat-stream-reducer.ts +3 -48
- package/src/components/chat/tool-execution-display.tsx +4 -18
- package/src/components/chat/types/component.types.ts +0 -27
- package/src/components/chat/types/message.types.ts +0 -83
- package/src/components/chat/types/unified-chat-state.types.ts +3 -12
- package/src/components/chat/utils/process-historical-messages.ts +0 -25
- package/dist/chat-protocol/card-marker.d.ts +0 -31
- package/dist/chat-protocol/card-marker.d.ts.map +0 -1
- package/dist/chat-protocol/source-metadata.d.ts +0 -56
- package/dist/chat-protocol/source-metadata.d.ts.map +0 -1
- package/dist/chunk-F2C2U7CP.js.map +0 -1
- package/dist/chunk-YXTAV2E3.cjs.map +0 -1
- package/dist/components/chat/utils/cited-sources.d.ts +0 -24
- package/dist/components/chat/utils/cited-sources.d.ts.map +0 -1
- package/dist/components/chat/utils/host-message.d.ts +0 -41
- package/dist/components/chat/utils/host-message.d.ts.map +0 -1
- package/src/chat-protocol/__tests__/card-marker.test.ts +0 -63
- package/src/chat-protocol/__tests__/source-metadata.test.ts +0 -243
- package/src/chat-protocol/card-marker.ts +0 -40
- package/src/chat-protocol/source-metadata.ts +0 -336
- package/src/components/chat/__tests__/tool-execution-display.test.tsx +0 -70
- package/src/components/chat/utils/__tests__/cited-sources.test.ts +0 -80
- package/src/components/chat/utils/__tests__/host-message.test.ts +0 -92
- package/src/components/chat/utils/__tests__/process-historical-messages-sources.test.ts +0 -138
- package/src/components/chat/utils/cited-sources.ts +0 -61
- package/src/components/chat/utils/host-message.ts +0 -87
- /package/dist/{chunk-2QBXG74C.js.map → chunk-6MLRFM3T.js.map} +0 -0
- /package/dist/{chunk-IBMHEOBV.js.map → chunk-B3UXNGVM.js.map} +0 -0
- /package/dist/{chunk-O6PO5BHE.js.map → chunk-B7LYKBCD.js.map} +0 -0
- /package/dist/{chunk-MGXSJI23.js.map → chunk-BUXGWBTF.js.map} +0 -0
- /package/dist/{chunk-OIKZDXNW.js.map → chunk-C7CTEUU7.js.map} +0 -0
- /package/dist/{chunk-HQSCJYCF.js.map → chunk-HGVW7OHI.js.map} +0 -0
- /package/dist/{chunk-FS3CTGIR.js.map → chunk-JKM5FH63.js.map} +0 -0
- /package/dist/{chunk-37CAZTLP.js.map → chunk-JOCVQZGT.js.map} +0 -0
- /package/dist/{chunk-ROOIHDLS.js.map → chunk-JR7I2AGL.js.map} +0 -0
- /package/dist/{chunk-25YIHMZ6.js.map → chunk-LA2W5L6K.js.map} +0 -0
- /package/dist/{chunk-V6TINNLD.js.map → chunk-MVBRMQGU.js.map} +0 -0
- /package/dist/{chunk-R2UDEMKK.js.map → chunk-OTYV6SDN.js.map} +0 -0
- /package/dist/{chunk-HZS4TV34.js.map → chunk-QX4ANESW.js.map} +0 -0
- /package/dist/{chunk-OJZW3GE2.js.map → chunk-TJ3GFULR.js.map} +0 -0
- /package/dist/{chunk-Q2CNCBMK.js.map → chunk-VCYRJY7J.js.map} +0 -0
package/package.json
CHANGED
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
// rows straight to the accumulator, so restating them here would be two
|
|
13
13
|
// declarations of one wire contract. Type-only import from a React-free
|
|
14
14
|
// module; `nats-decoder.ts` already depends on the same file for MESSAGE_TYPE.
|
|
15
|
-
import type {
|
|
16
|
-
import type { AskOptionData, ChatSource } from '../components/chat/types/message.types';
|
|
15
|
+
import type { AskOptionData } from '../components/chat/types/message.types';
|
|
17
16
|
// The wire-frame shapes these events carry through are defined ONCE in
|
|
18
17
|
// `./frames.ts` — reuse them here rather than restating their fields.
|
|
19
18
|
import type { ApprovalRequestField, DecisionResolvedFrame, UsageTelemetry } from './frames';
|
|
@@ -218,25 +217,6 @@ export interface TicketEventEvent extends ChatStreamEventBase {
|
|
|
218
217
|
targetStatusKind?: string;
|
|
219
218
|
}
|
|
220
219
|
|
|
221
|
-
/**
|
|
222
|
-
* Per-answer source metadata — the documents an answer cited, plus the video
|
|
223
|
-
* and entity-card references its `[card://type:id]` markers expand with.
|
|
224
|
-
*
|
|
225
|
-
* Unlike `ChatMetadataEvent`, this one is DECODED, not passthrough: the payload
|
|
226
|
-
* comes from a remote MCP server's tool output rather than from our own
|
|
227
|
-
* backend's frame, so it is validated at the protocol boundary (see
|
|
228
|
-
* `source-metadata.ts`) and never reaches a consumer half-checked.
|
|
229
|
-
*
|
|
230
|
-
* Both fields are optional and never both absent — the decoder returns `null`
|
|
231
|
-
* instead of emitting an empty event, so applying one can't blank metadata an
|
|
232
|
-
* earlier chunk of the same turn already supplied.
|
|
233
|
-
*/
|
|
234
|
-
export interface SourcesEvent extends ChatStreamEventBase {
|
|
235
|
-
type: 'sources';
|
|
236
|
-
sources?: ChatSource[];
|
|
237
|
-
refs?: ChatRef[];
|
|
238
|
-
}
|
|
239
|
-
|
|
240
220
|
/** Per-turn metadata. Raw wire values pass through UNVALIDATED — the
|
|
241
221
|
* consumer replicates the legacy truthiness/typeof gates (so a
|
|
242
222
|
* malformed frame degrades identically to the pre-SSOT parser). */
|
|
@@ -382,7 +362,6 @@ export type ChatStreamEvent =
|
|
|
382
362
|
| TicketEscalatedEvent
|
|
383
363
|
| TicketEventEvent
|
|
384
364
|
| ChatMetadataEvent
|
|
385
|
-
| SourcesEvent
|
|
386
365
|
| UsageEvent
|
|
387
366
|
| TokenUsageEvent
|
|
388
367
|
| CompactionEvent
|
|
@@ -20,7 +20,6 @@ import { MESSAGE_TYPE } from '../components/chat/types/message.types';
|
|
|
20
20
|
import type { AskOptionData } from '../components/chat/types/message.types';
|
|
21
21
|
import { ESCALATION_STATE, escalationResolvedStatus } from './events';
|
|
22
22
|
import type { ApprovalToolCall, ChatStreamEvent } from './events';
|
|
23
|
-
import { sourceMetadataEvent } from './source-metadata';
|
|
24
23
|
import { isRecord } from './wire-narrow';
|
|
25
24
|
|
|
26
25
|
/** Minimal structural view of a NATS chunk (see `ChunkData` in
|
|
@@ -122,17 +121,6 @@ export function decodeNatsChunk(chunk: unknown): ChatStreamEvent | null {
|
|
|
122
121
|
}
|
|
123
122
|
return null;
|
|
124
123
|
|
|
125
|
-
// Two chunk names, one payload and one decoder. `SOURCES` is the contract
|
|
126
|
-
// the backend is moving to; `GUIDE` is the v2 envelope it ships in during
|
|
127
|
-
// the rollout (see `MESSAGE_TYPE.GUIDE`). The chunk arrives BEFORE or
|
|
128
|
-
// between the answer's text deltas, so the reducer — not this decoder —
|
|
129
|
-
// owns attaching it to the right turn.
|
|
130
|
-
case MESSAGE_TYPE.GUIDE:
|
|
131
|
-
case MESSAGE_TYPE.SOURCES: {
|
|
132
|
-
const event = sourceMetadataEvent(data.payload);
|
|
133
|
-
return event ? { ...event, ...seq } : null;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
124
|
// An ask card is only an ask card with something to pick: a question and at
|
|
137
125
|
// least one option. Anything less is dropped rather than rendered as an
|
|
138
126
|
// empty card the user can't answer — the backend already falls back to a
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import React, { forwardRef, memo, useEffect, useMemo, useRef } from 'react';
|
|
4
|
-
import { createCardMarkerScanner } from '../../chat-protocol/card-marker';
|
|
5
4
|
import { cn } from '../../utils/cn';
|
|
6
5
|
import { isToday } from '../../utils/date-utils';
|
|
7
6
|
import { formatDate, formatTime } from '../../utils/format-date';
|
|
@@ -37,10 +36,13 @@ import type { AskSegment, MessageSegment, MessageContent, ChatMessageEnhancedPro
|
|
|
37
36
|
* `scheduledScript`); id is the mention-token charset. */
|
|
38
37
|
const MENTION_MARKER_REGEX = /(^|[^\w@])@[a-zA-Z]+:([A-Za-z0-9_.+/=-]*[A-Za-z0-9_+/=])/g;
|
|
39
38
|
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Same regex shape as `remarkCardLinks` — kept in lockstep so the
|
|
41
|
+
* pre-scan and the remark plugin see the SAME set of markers. If the
|
|
42
|
+
* grammar widens (today: snake_case OR kebab-case; closer `]` OR `)`),
|
|
43
|
+
* both files must update.
|
|
44
|
+
*/
|
|
45
|
+
const CARD_MARKER_REGEX = /\[card:\/\/([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)[\])]/g;
|
|
44
46
|
|
|
45
47
|
/** Timestamp label: today's messages show time only ("2:47 PM"),
|
|
46
48
|
* older messages prepend a locale-formatted date ("05/05/2026 2:47 PM"
|
|
@@ -101,7 +103,6 @@ const ChatMessageEnhanced = forwardRef<HTMLDivElement, ChatMessageEnhancedProps>
|
|
|
101
103
|
renderContextItem,
|
|
102
104
|
renderMention,
|
|
103
105
|
renderEntityCard,
|
|
104
|
-
refs,
|
|
105
106
|
onAskSelect,
|
|
106
107
|
NavLinkAnchor,
|
|
107
108
|
...props
|
|
@@ -179,29 +180,9 @@ const ChatMessageEnhanced = forwardRef<HTMLDivElement, ChatMessageEnhancedProps>
|
|
|
179
180
|
// (and its open menu) survives across chunks. Invalidated per key when the
|
|
180
181
|
// render fn identity changes.
|
|
181
182
|
const renderedCardNodeCache = useRef(
|
|
182
|
-
new Map<
|
|
183
|
-
string,
|
|
184
|
-
{
|
|
185
|
-
render: ((ref: ChatRef) => React.ReactNode) | undefined;
|
|
186
|
-
/** The descriptor the node was built from. Part of the cache identity
|
|
187
|
-
* because metadata can arrive AFTER the marker was first rendered —
|
|
188
|
-
* a card mounted from the bare `{type, id}` descriptor has to be
|
|
189
|
-
* rebuilt once its real title and URL land. */
|
|
190
|
-
ref: ChatRef | undefined;
|
|
191
|
-
node: React.ReactNode;
|
|
192
|
-
}
|
|
193
|
-
>(),
|
|
183
|
+
new Map<string, { render: ((ref: ChatRef) => React.ReactNode) | undefined; node: React.ReactNode }>(),
|
|
194
184
|
);
|
|
195
185
|
|
|
196
|
-
/** The answer's own references, by `type:id`. What turns a bare marker into
|
|
197
|
-
* a card with a title and a link, without a per-entity lookup the host may
|
|
198
|
-
* not even have an API for. */
|
|
199
|
-
const refByKey = useMemo(() => {
|
|
200
|
-
const byKey = new Map<string, ChatRef>();
|
|
201
|
-
for (const described of refs ?? []) byKey.set(`${described.type}:${described.id}`, described);
|
|
202
|
-
return byKey;
|
|
203
|
-
}, [refs]);
|
|
204
|
-
|
|
205
186
|
/**
|
|
206
187
|
* Per-message rendering plan for `[card://type:id]` markers.
|
|
207
188
|
*
|
|
@@ -260,11 +241,8 @@ const ChatMessageEnhanced = forwardRef<HTMLDivElement, ChatMessageEnhancedProps>
|
|
|
260
241
|
// stops React from re-mounting the card (and closing its open
|
|
261
242
|
// menu / re-fetching) on every stream chunk. Also dedups the same
|
|
262
243
|
// key emitted twice within one message.
|
|
263
|
-
// The answer's metadata wins when it described this reference: it
|
|
264
|
-
// carries the title, URL and source the wire marker cannot.
|
|
265
|
-
const describedRef = refByKey.get(key);
|
|
266
244
|
let entry = cache.get(key);
|
|
267
|
-
if (!entry || entry.render !== render
|
|
245
|
+
if (!entry || entry.render !== render) {
|
|
268
246
|
// The marker is the ONLY data on the wire: cards hydrate by id
|
|
269
247
|
// from the host's per-object APIs, so a minimal {type, id}
|
|
270
248
|
// descriptor is all the renderer needs to mount the loader.
|
|
@@ -279,13 +257,13 @@ const ChatMessageEnhanced = forwardRef<HTMLDivElement, ChatMessageEnhancedProps>
|
|
|
279
257
|
// the id rather than `undefined`) and `url` to null (matches
|
|
280
258
|
// the no-link semantics fetch-mode cards rely on — they
|
|
281
259
|
// resolve their own URL after fetch).
|
|
282
|
-
const refForRender: ChatRef =
|
|
260
|
+
const refForRender: ChatRef = {
|
|
283
261
|
type: cardType,
|
|
284
262
|
id: cardId,
|
|
285
263
|
title: cardId,
|
|
286
264
|
url: null,
|
|
287
265
|
};
|
|
288
|
-
entry = { render,
|
|
266
|
+
entry = { render, node: render(refForRender) };
|
|
289
267
|
cache.set(key, entry);
|
|
290
268
|
}
|
|
291
269
|
const rendered = entry.node;
|
|
@@ -348,7 +326,7 @@ const ChatMessageEnhanced = forwardRef<HTMLDivElement, ChatMessageEnhancedProps>
|
|
|
348
326
|
}
|
|
349
327
|
});
|
|
350
328
|
return { inlineByKey, partsBySegment, usedKeys };
|
|
351
|
-
}, [hasMarkerSupport, renderEntityCard,
|
|
329
|
+
}, [hasMarkerSupport, renderEntityCard, segments]);
|
|
352
330
|
|
|
353
331
|
// Drop cached nodes for markers no longer present so the cache can't grow
|
|
354
332
|
// unbounded as a long message's markers change. Deliberately an EFFECT,
|
|
@@ -738,9 +716,6 @@ const MemoizedChatMessageEnhanced = memo(ChatMessageEnhanced, (prevProps, nextPr
|
|
|
738
716
|
// equality holds across streaming chunks.
|
|
739
717
|
prevProps.renderMention === nextProps.renderMention &&
|
|
740
718
|
prevProps.renderEntityCard === nextProps.renderEntityCard &&
|
|
741
|
-
// Reference equality: the reducer sets this once per answer and the host
|
|
742
|
-
// forwards the same array instance, so it holds across streaming chunks.
|
|
743
|
-
prevProps.refs === nextProps.refs &&
|
|
744
719
|
// Same stability contract as the renderers above: hosts pass a `useCallback`
|
|
745
720
|
// (EmbeddableChat passes its memoized `handleSend`), so this holds across
|
|
746
721
|
// streaming chunks instead of re-rendering every ask card per chunk.
|
|
@@ -137,7 +137,6 @@ const ChatMessageList = forwardRef<HTMLDivElement, ChatMessageListProps>(
|
|
|
137
137
|
resolveContextIcon,
|
|
138
138
|
renderContextItem,
|
|
139
139
|
renderMention,
|
|
140
|
-
renderAfterMessage,
|
|
141
140
|
onAskSelect,
|
|
142
141
|
NavLinkAnchor,
|
|
143
142
|
...props
|
|
@@ -986,8 +985,7 @@ const ChatMessageList = forwardRef<HTMLDivElement, ChatMessageListProps>(
|
|
|
986
985
|
!hasNonEmptyContent(message.content) &&
|
|
987
986
|
(!Array.isArray(message.content) || message.content.every(s => s.type === 'text'));
|
|
988
987
|
if (isEmptyPendingTurn) return null;
|
|
989
|
-
|
|
990
|
-
const row = (
|
|
988
|
+
return (
|
|
991
989
|
<ChatMessageEnhanced
|
|
992
990
|
key={message.id}
|
|
993
991
|
ref={getRegisterMessageEl(message.id)}
|
|
@@ -1007,21 +1005,10 @@ const ChatMessageList = forwardRef<HTMLDivElement, ChatMessageListProps>(
|
|
|
1007
1005
|
renderContextItem={renderContextItem}
|
|
1008
1006
|
renderMention={renderMention}
|
|
1009
1007
|
renderEntityCard={renderEntityCard}
|
|
1010
|
-
refs={message.refs}
|
|
1011
1008
|
onAskSelect={index > lastUserMessageIndex ? onAskSelect : undefined}
|
|
1012
1009
|
NavLinkAnchor={NavLinkAnchor}
|
|
1013
1010
|
/>
|
|
1014
1011
|
);
|
|
1015
|
-
// Only wrap when there IS owned content: the bare row keeps
|
|
1016
|
-
// its own key and its place as a direct flex child, so a
|
|
1017
|
-
// thread without any stays byte-identical to before.
|
|
1018
|
-
if (!ownedContent) return row;
|
|
1019
|
-
return (
|
|
1020
|
-
<div key={message.id} className="flex w-full min-w-0 flex-col">
|
|
1021
|
-
{row}
|
|
1022
|
-
{ownedContent}
|
|
1023
|
-
</div>
|
|
1024
|
-
);
|
|
1025
1012
|
})}
|
|
1026
1013
|
</div>
|
|
1027
1014
|
</div>
|
|
@@ -97,10 +97,7 @@ import type { ChatDialogCapabilities, UnifiedChatState } from './types/unified-c
|
|
|
97
97
|
import { formatChatAttachmentMarkdownForBubble } from './utils/chat-attachment-markdown';
|
|
98
98
|
import { resolveHrefForRuntime } from './utils/chat-nav-resolution';
|
|
99
99
|
import { chatChipClass } from './utils/chip-styles';
|
|
100
|
-
import { FALLBACK_TOP_RETRIEVED, splitCitedSources } from './utils/cited-sources';
|
|
101
100
|
import { executeNavigation } from './utils/execute-navigation';
|
|
102
|
-
import { flattenAssistantContent } from './utils/flatten-assistant-content';
|
|
103
|
-
import { mapHostMessage, pruneTimestampCache } from './utils/host-message';
|
|
104
101
|
import { resolveIcon } from './utils/icon-library';
|
|
105
102
|
import { computeIsNewTab, newTabAnchorAttrs } from './utils/nav-anchor-props';
|
|
106
103
|
import { formatSingularLookupInvocation } from './utils/slash-dispatch-utils';
|
|
@@ -438,6 +435,12 @@ const mentionTokenOf = (key: string, markerByType: Map<string, string>): string
|
|
|
438
435
|
return `${markerByType.get(type) ?? type.toLowerCase()}:${id}`;
|
|
439
436
|
};
|
|
440
437
|
|
|
438
|
+
/**
|
|
439
|
+
* Fallback fan-out when the model didn't cite any source. Show the top-N
|
|
440
|
+
* retrieved sources instead of zero chips. Mirrors Perplexity's behavior.
|
|
441
|
+
*/
|
|
442
|
+
const FALLBACK_TOP_RETRIEVED = 3;
|
|
443
|
+
|
|
441
444
|
/** Persists the user's rail collapse choice across drawer open/close + reloads. */
|
|
442
445
|
const RAIL_COLLAPSED_STORAGE_KEY = 'mingo-chat-history-collapsed';
|
|
443
446
|
|
|
@@ -1536,12 +1539,56 @@ function EmbeddableChatInner({
|
|
|
1536
1539
|
: undefined;
|
|
1537
1540
|
const guideUserAvatar = activeMode === 'guide' ? identityUser?.avatarUrl?.trim() || undefined : undefined;
|
|
1538
1541
|
|
|
1539
|
-
// Map
|
|
1540
|
-
// `mapHostMessage`, which is where its pass-through list is pinned by tests.
|
|
1542
|
+
// Map docMessages → lib's Message type, forwarding scrollAnchor.
|
|
1541
1543
|
const messages: Message[] = useMemo(() => {
|
|
1542
|
-
const
|
|
1543
|
-
const
|
|
1544
|
-
|
|
1544
|
+
const cache = timestampCache;
|
|
1545
|
+
const seenIds = new Set<string>();
|
|
1546
|
+
|
|
1547
|
+
const mapped = rawMessages.map(m => {
|
|
1548
|
+
seenIds.add(m.id);
|
|
1549
|
+
let timestamp: Date;
|
|
1550
|
+
if (m.timestamp != null) {
|
|
1551
|
+
timestamp = new Date(m.timestamp);
|
|
1552
|
+
} else {
|
|
1553
|
+
const cached = cache.get(m.id);
|
|
1554
|
+
timestamp = cached ?? new Date();
|
|
1555
|
+
if (!cached) cache.set(m.id, timestamp);
|
|
1556
|
+
}
|
|
1557
|
+
|
|
1558
|
+
return {
|
|
1559
|
+
id: m.id,
|
|
1560
|
+
role: m.role,
|
|
1561
|
+
// Host-supplied per-message name/avatar win (e.g. the signed-in user's
|
|
1562
|
+
// full name + photo on a `user` bubble); fall back to the role default
|
|
1563
|
+
// when the host doesn't provide them.
|
|
1564
|
+
name: m.name ?? (m.role === 'assistant' ? 'Mingo' : (guideUserName ?? 'You')),
|
|
1565
|
+
avatar: m.avatar ?? (m.role === 'user' ? (guideUserAvatar ?? null) : null),
|
|
1566
|
+
// Forward the host's authorType so user bubbles get the same accent
|
|
1567
|
+
// name color as the standalone /mingo page (user → 'admin').
|
|
1568
|
+
...(m.authorType ? { authorType: m.authorType } : {}),
|
|
1569
|
+
content: m.segments && m.segments.length > 0 ? m.segments : m.content,
|
|
1570
|
+
timestamp,
|
|
1571
|
+
assistantType: m.role === 'assistant' ? ('mingo' as const) : undefined,
|
|
1572
|
+
// `hidden` is load-bearing, NOT cosmetic: it carries synthetic rows
|
|
1573
|
+
// (e.g. an auto-continuation directive) that the LLM must see but the
|
|
1574
|
+
// reader must not. Dropping it here made the raw directive text render
|
|
1575
|
+
// as an ordinary bubble. This field-by-field rebuild has to forward it
|
|
1576
|
+
// explicitly — see `Message.hidden` and `chat-message-list`'s skip.
|
|
1577
|
+
...(m.hidden ? { hidden: true } : {}),
|
|
1578
|
+
...(m.scrollAnchor ? { scrollAnchor: m.scrollAnchor } : {}),
|
|
1579
|
+
// Forward attached context items so the user bubble renders its chips.
|
|
1580
|
+
...(m.contextItems && m.contextItems.length > 0 ? { contextItems: m.contextItems } : {}),
|
|
1581
|
+
};
|
|
1582
|
+
});
|
|
1583
|
+
|
|
1584
|
+
// Drop cached fallbacks for messages no longer present so the map can't
|
|
1585
|
+
// grow unbounded across a long-lived session.
|
|
1586
|
+
if (cache.size > seenIds.size) {
|
|
1587
|
+
for (const id of cache.keys()) {
|
|
1588
|
+
if (!seenIds.has(id)) cache.delete(id);
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1545
1592
|
return mapped;
|
|
1546
1593
|
}, [rawMessages, guideUserName, guideUserAvatar, timestampCache]);
|
|
1547
1594
|
|
|
@@ -1789,44 +1836,24 @@ function EmbeddableChatInner({
|
|
|
1789
1836
|
return out;
|
|
1790
1837
|
}, [commandsById, enabledSet]);
|
|
1791
1838
|
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
// answer too — a reader scrolled up watches finished citations blink out
|
|
1811
|
-
// for the duration of an unrelated turn.
|
|
1812
|
-
if (chatLoading && index === messages.length - 1) return null;
|
|
1813
|
-
const { cited, uncited } = splitCitedSources(message.sources, flattenAssistantContent(message.content));
|
|
1814
|
-
if (cited.length === 0 && uncited.length === 0) return null;
|
|
1815
|
-
return (
|
|
1816
|
-
<div className="pb-2">
|
|
1817
|
-
<SourceChips
|
|
1818
|
-
cited={cited}
|
|
1819
|
-
uncited={uncited}
|
|
1820
|
-
baseRoute={resolvedBaseRoute}
|
|
1821
|
-
chipBasePlatform={chipBasePlatform}
|
|
1822
|
-
onClose={handleNavigationClose}
|
|
1823
|
-
onDiscuss={discussRef}
|
|
1824
|
-
/>
|
|
1825
|
-
</div>
|
|
1826
|
-
);
|
|
1827
|
-
},
|
|
1828
|
-
[chatLoading, messages.length, resolvedBaseRoute, chipBasePlatform, handleNavigationClose, discussRef],
|
|
1829
|
-
);
|
|
1839
|
+
// Find sources for the last assistant message; split into cited / uncited.
|
|
1840
|
+
const lastAssistantMsg = [...rawMessages].reverse().find(m => m.role === 'assistant');
|
|
1841
|
+
const lastSources = useMemo(() => {
|
|
1842
|
+
if (chatLoading) return undefined;
|
|
1843
|
+
const sources = lastAssistantMsg?.sources;
|
|
1844
|
+
if (!sources || sources.length === 0) return undefined;
|
|
1845
|
+
const content = lastAssistantMsg?.content || '';
|
|
1846
|
+
const citationOrder = [...content.matchAll(/\[(\d+)\]/g)].map(m => parseInt(m[1], 10));
|
|
1847
|
+
const seenOrder = new Map<number, number>();
|
|
1848
|
+
citationOrder.forEach(idx => {
|
|
1849
|
+
if (!seenOrder.has(idx)) seenOrder.set(idx, seenOrder.size);
|
|
1850
|
+
});
|
|
1851
|
+
const cited = sources
|
|
1852
|
+
.filter(s => seenOrder.has(s.index))
|
|
1853
|
+
.sort((a, b) => (seenOrder.get(a.index) ?? 0) - (seenOrder.get(b.index) ?? 0));
|
|
1854
|
+
const uncited = sources.filter(s => !seenOrder.has(s.index));
|
|
1855
|
+
return { cited, uncited };
|
|
1856
|
+
}, [lastAssistantMsg, chatLoading]);
|
|
1830
1857
|
|
|
1831
1858
|
// Host node for in-panel Radix portals (see the body wrapper below).
|
|
1832
1859
|
const [portalHost, setPortalHost] = useState<HTMLDivElement | null>(null);
|
|
@@ -2407,7 +2434,6 @@ function EmbeddableChatInner({
|
|
|
2407
2434
|
resolveContextIcon={resolveContextIcon}
|
|
2408
2435
|
renderContextItem={renderContextItem}
|
|
2409
2436
|
renderMention={renderMention}
|
|
2410
|
-
renderAfterMessage={renderMessageSources}
|
|
2411
2437
|
// Gated on `chatLoading` for the same reason the composer
|
|
2412
2438
|
// is: no second send while a turn is in flight. Passive
|
|
2413
2439
|
// demo hosts (previewMode) stay read-only.
|
|
@@ -2445,6 +2471,20 @@ function EmbeddableChatInner({
|
|
|
2445
2471
|
onLoadMore={loadMoreMessages}
|
|
2446
2472
|
/>
|
|
2447
2473
|
)}
|
|
2474
|
+
{lastSources &&
|
|
2475
|
+
(lastSources.cited.length > 0 || lastSources.uncited.length > 0) &&
|
|
2476
|
+
!chatLoading && (
|
|
2477
|
+
<div className="flex-shrink-0 pb-2">
|
|
2478
|
+
<SourceChips
|
|
2479
|
+
cited={lastSources.cited}
|
|
2480
|
+
uncited={lastSources.uncited}
|
|
2481
|
+
baseRoute={resolvedBaseRoute}
|
|
2482
|
+
chipBasePlatform={chipBasePlatform}
|
|
2483
|
+
onClose={handleNavigationClose}
|
|
2484
|
+
onDiscuss={discussRef}
|
|
2485
|
+
/>
|
|
2486
|
+
</div>
|
|
2487
|
+
)}
|
|
2448
2488
|
</div>
|
|
2449
2489
|
) : activeMode === 'mingo' ? (
|
|
2450
2490
|
/* Figma node 7532:222444 — default (Mingo-mode) empty state:
|
|
@@ -62,7 +62,7 @@ import { createChatDialogStore } from '../stream/chat-dialog-store';
|
|
|
62
62
|
import type { ChatDialogStore } from '../stream/chat-dialog-store';
|
|
63
63
|
import type { ChatStreamReducerOptions } from '../stream/chat-stream-reducer';
|
|
64
64
|
import { useChatStreamReducer } from '../stream/use-chat-stream-reducer';
|
|
65
|
-
import type {
|
|
65
|
+
import type { Message, MessageSegment } from '../types/message.types';
|
|
66
66
|
import type {
|
|
67
67
|
ChatDialogCapabilities,
|
|
68
68
|
FetchDialogsParams,
|
|
@@ -121,10 +121,33 @@ const noopBumpMetaTick = (): void => {};
|
|
|
121
121
|
* hub-side platform-utils, not in lib). */
|
|
122
122
|
export type DocSource = string;
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
export interface ChatSource {
|
|
125
|
+
index: number;
|
|
126
|
+
name: string;
|
|
127
|
+
path: string;
|
|
128
|
+
documentType: string;
|
|
129
|
+
externalUrl?: string;
|
|
130
|
+
/** Platform that owns the destination at `externalUrl`. */
|
|
131
|
+
targetPlatform?: string | null;
|
|
132
|
+
/** Primary-key value for single-row chips. */
|
|
133
|
+
id?: string;
|
|
134
|
+
/** Per-row items for grouped chips. */
|
|
135
|
+
items?: Array<{
|
|
136
|
+
id: string;
|
|
137
|
+
documentType: string;
|
|
138
|
+
name: string;
|
|
139
|
+
externalUrl?: string;
|
|
140
|
+
targetPlatform?: string | null;
|
|
141
|
+
/** In-app doc-tree path for markdown / data-room-doc rows so the
|
|
142
|
+
* grouped chip's anchor can trigger an in-page doc-tree swap via
|
|
143
|
+
* `handleChatNavClick` (parity with single-row chips + cards). */
|
|
144
|
+
path?: string | null;
|
|
145
|
+
}>;
|
|
146
|
+
/** RagTableConfig.id for this source. */
|
|
147
|
+
sourceRepo?: string;
|
|
148
|
+
/** Optional display label override returned by the chat API. */
|
|
149
|
+
label?: string;
|
|
150
|
+
}
|
|
128
151
|
|
|
129
152
|
export interface DocChatMessage {
|
|
130
153
|
id: string;
|
|
@@ -15,26 +15,24 @@
|
|
|
15
15
|
* Per v6.1 §B.2.6: "implement as a `react-markdown` `components.text` override
|
|
16
16
|
* OR a remark plugin. NOT a regex-on-raw-text pre-pass (which loses formatting)."
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* and then never rendered — the reader is left with the literal `[card://…]`.
|
|
18
|
+
* Regex shape: `[a-zA-Z0-9_-]+` for both type and id. Tolerates snake_case
|
|
19
|
+
* AND kebab-case so it matches whatever `documentType` value the LLM echoes
|
|
20
|
+
* from the server snapshot (e.g. `customer_interview` from the config vs
|
|
21
|
+
* `customer-interview` if a future config switches conventions).
|
|
23
22
|
*/
|
|
24
23
|
|
|
25
24
|
import type { Root, Text, Link } from 'mdast';
|
|
26
25
|
import type { Plugin } from 'unified';
|
|
27
26
|
import { visit, SKIP } from 'unist-util-visit';
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
const CARD_REGEX = createCardMarkerScanner();
|
|
28
|
+
// Closing bracket is `]` per spec, but tolerate `)` as well — the LLM
|
|
29
|
+
// occasionally drifts to `)` after long dashed UUID ids (bracket-balancing
|
|
30
|
+
// noise on opaque tokens; reproduced in production with podcast UUIDs).
|
|
31
|
+
// The `[card://` open is the load-bearing signature; if the open matches,
|
|
32
|
+
// treat trailing `)` as `]`. `[card://type:id)` is not valid markdown
|
|
33
|
+
// syntax anywhere else (regular links use `[text](url)`, not `[text)`),
|
|
34
|
+
// so widening the closer has zero false-positive risk.
|
|
35
|
+
const CARD_REGEX = /\[card:\/\/([a-zA-Z0-9_-]+):([a-zA-Z0-9_-]+)[\])]/g;
|
|
38
36
|
|
|
39
37
|
export const remarkCardLinks: Plugin<[], Root> = () => {
|
|
40
38
|
return (tree: Root) => {
|
|
@@ -60,7 +60,6 @@ import {
|
|
|
60
60
|
type ParticipantEvent,
|
|
61
61
|
type UsageEvent,
|
|
62
62
|
} from '../../../chat-protocol/events';
|
|
63
|
-
import { mergeSourceMetadata, type SourceMetadata } from '../../../chat-protocol/source-metadata';
|
|
64
63
|
import type {
|
|
65
64
|
ApprovalBatchSegment,
|
|
66
65
|
ApprovalRequestSegment,
|
|
@@ -756,56 +755,22 @@ export function createChatStreamReducer(options: ChatStreamReducerOptions = {}):
|
|
|
756
755
|
return [...next.slice(0, -1), { ...last, streamSeq: seq }];
|
|
757
756
|
}
|
|
758
757
|
|
|
759
|
-
/**
|
|
760
|
-
* Source metadata accumulated for the CURRENT turn.
|
|
761
|
-
*
|
|
762
|
-
* The chunk is published when a remote tool returns, so it lands inside the
|
|
763
|
-
* turn but usually BEFORE the answer text the reader will see it under —
|
|
764
|
-
* sometimes before the assistant bubble exists at all. Holding it here and
|
|
765
|
-
* stamping it on every trailing-assistant write is what makes the arrival
|
|
766
|
-
* order stop mattering.
|
|
767
|
-
*
|
|
768
|
-
* Reset at `turn-start`, so metadata can never leak onto the next answer.
|
|
769
|
-
* Losing a chunk that somehow arrived outside a turn is the better failure of
|
|
770
|
-
* the two: a stale citation strip under an unrelated answer is a wrong
|
|
771
|
-
* statement about where that answer came from.
|
|
772
|
-
*/
|
|
773
|
-
let turnSourceMetadata: SourceMetadata | null = null;
|
|
774
|
-
|
|
775
|
-
/** Stamp the turn's metadata onto the trailing assistant bubble. A no-op
|
|
776
|
-
* when there is none yet — the next write through here picks it up. */
|
|
777
|
-
function stampTrailingAssistantSourceMetadata(next: UnifiedChatMessage[]): UnifiedChatMessage[] {
|
|
778
|
-
const metadata = turnSourceMetadata;
|
|
779
|
-
if (!metadata) return next;
|
|
780
|
-
const last = next[next.length - 1];
|
|
781
|
-
if (!last || last.role !== 'assistant') return next;
|
|
782
|
-
if (last.sources === metadata.sources && last.refs === metadata.refs) return next;
|
|
783
|
-
return [...next.slice(0, -1), { ...last, ...metadata }];
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
/** The two stamps every trailing-assistant write needs, in one place — a
|
|
787
|
-
* write that skips either loses the seq the merge decides with, or the
|
|
788
|
-
* citations the answer was built from. */
|
|
789
|
-
function commitTrailingAssistant(next: UnifiedChatMessage[], seq: number | undefined): UnifiedChatMessage[] {
|
|
790
|
-
return stampTrailingAssistantSourceMetadata(stampTrailingAssistantSeq(next, seq));
|
|
791
|
-
}
|
|
792
|
-
|
|
793
758
|
function applySegmentsToState(segments: MessageSegment[], meta?: SegmentsUpdateMetadata): void {
|
|
794
759
|
const seq = meta?.streamSeq;
|
|
795
760
|
// Standalone compaction updates carry the accumulator's cumulative
|
|
796
761
|
// array — apply only the compaction segment (upsert) or interleaved
|
|
797
762
|
// continuation text would duplicate.
|
|
798
763
|
if (meta?.append && meta.isCompacting) {
|
|
799
|
-
setMessagesInternal(
|
|
764
|
+
setMessagesInternal(stampTrailingAssistantSeq(upsertTrailingCompaction(messages, segments), seq));
|
|
800
765
|
return;
|
|
801
766
|
}
|
|
802
767
|
// Post-MESSAGE_END continuation fragments append into the existing
|
|
803
768
|
// bubble; replacing would wipe the completed reply.
|
|
804
769
|
if (meta?.append) {
|
|
805
|
-
setMessagesInternal(
|
|
770
|
+
setMessagesInternal(stampTrailingAssistantSeq(appendToTrailingAssistant(messages, segments), seq));
|
|
806
771
|
return;
|
|
807
772
|
}
|
|
808
|
-
setMessagesInternal(
|
|
773
|
+
setMessagesInternal(stampTrailingAssistantSeq(updateTrailingAssistant(messages, segments), seq));
|
|
809
774
|
}
|
|
810
775
|
|
|
811
776
|
function applyStreamStartToState(): void {
|
|
@@ -1004,7 +969,6 @@ export function createChatStreamReducer(options: ChatStreamReducerOptions = {}):
|
|
|
1004
969
|
isInStream = true;
|
|
1005
970
|
hasEverStreamed = true;
|
|
1006
971
|
turnStartedAt = Date.now();
|
|
1007
|
-
turnSourceMetadata = null;
|
|
1008
972
|
emit('onStreamStart');
|
|
1009
973
|
applyStreamStartToState();
|
|
1010
974
|
accumulator.resetSegments();
|
|
@@ -1020,15 +984,6 @@ export function createChatStreamReducer(options: ChatStreamReducerOptions = {}):
|
|
|
1020
984
|
break;
|
|
1021
985
|
}
|
|
1022
986
|
|
|
1023
|
-
// Per-answer source metadata. Applied to the trailing assistant bubble
|
|
1024
|
-
// immediately when there is one, and held for the next write when the
|
|
1025
|
-
// chunk beat the answer text to the reducer.
|
|
1026
|
-
case 'sources': {
|
|
1027
|
-
turnSourceMetadata = mergeSourceMetadata(turnSourceMetadata, event);
|
|
1028
|
-
setMessagesInternal(stampTrailingAssistantSourceMetadata(messages));
|
|
1029
|
-
break;
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1032
987
|
case 'metadata': {
|
|
1033
988
|
// Legacy `parseChunkToAction` action shape, reconstructed for the
|
|
1034
989
|
// callback contract.
|
|
@@ -53,19 +53,6 @@ const ToolExecutionDisplay = forwardRef<HTMLDivElement, ToolExecutionDisplayProp
|
|
|
53
53
|
}, [message.parameters, variant]);
|
|
54
54
|
|
|
55
55
|
const hasResult = isExecuted && typeof message.result === 'string' && message.result.length > 0;
|
|
56
|
-
|
|
57
|
-
// A remote (MCP) read-only tool deliberately publishes NO parameters and NO
|
|
58
|
-
// result — the backend hides both, and sends a human title instead. There is
|
|
59
|
-
// therefore nothing behind the chevron, and offering one is a promise the
|
|
60
|
-
// row cannot keep: the reader expands it and gets an empty box. Render the
|
|
61
|
-
// title as a status line instead, the same static shape the client view uses.
|
|
62
|
-
//
|
|
63
|
-
// Keyed on the absent `integratedToolType`, which is what marks a tool as
|
|
64
|
-
// remote rather than one of ours — and guarded on there being a title to
|
|
65
|
-
// show, so a title-less row keeps the old behaviour rather than collapsing
|
|
66
|
-
// to a blank line.
|
|
67
|
-
const isConciseRemoteRead = !message.integratedToolType && !!previewText && argEntries.length === 0 && !hasResult;
|
|
68
|
-
const isStaticRow = isClientView || isConciseRemoteRead;
|
|
69
56
|
const hasBody = argEntries.length > 0 || hasResult || isExecuting;
|
|
70
57
|
|
|
71
58
|
const renderStatusIcon = () => {
|
|
@@ -95,7 +82,7 @@ const ToolExecutionDisplay = forwardRef<HTMLDivElement, ToolExecutionDisplayProp
|
|
|
95
82
|
{previewText}
|
|
96
83
|
</div>
|
|
97
84
|
<div className="flex h-5 w-5 shrink-0 items-center justify-center">{renderStatusIcon()}</div>
|
|
98
|
-
{!
|
|
85
|
+
{!isClientView && (
|
|
99
86
|
<div className="flex h-5 w-5 shrink-0 items-center justify-center">
|
|
100
87
|
<ExpandChevron expanded={expanded} />
|
|
101
88
|
</div>
|
|
@@ -114,10 +101,9 @@ const ToolExecutionDisplay = forwardRef<HTMLDivElement, ToolExecutionDisplayProp
|
|
|
114
101
|
)}
|
|
115
102
|
{...props}
|
|
116
103
|
>
|
|
117
|
-
{
|
|
118
|
-
//
|
|
119
|
-
//
|
|
120
|
-
// detail) and a remote read-only tool (there IS no detail).
|
|
104
|
+
{isClientView ? (
|
|
105
|
+
// Client (Fae end-user): static, non-expandable row — no chevron, no
|
|
106
|
+
// body. Just the explanation + status; command/args/result are hidden.
|
|
121
107
|
<div className="flex w-full items-start gap-[var(--spacing-system-xs)] p-[var(--spacing-system-s)] text-left">
|
|
122
108
|
{headerContent}
|
|
123
109
|
</div>
|