@devicai/ui 0.55.0 → 0.57.0
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/README.md +50 -0
- package/dist/cjs/api/types.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/ChatDrawer.js +4 -1
- package/dist/cjs/components/ChatDrawer/ChatDrawer.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/ChatMessages.js +41 -4
- package/dist/cjs/components/ChatDrawer/ChatMessages.js.map +1 -1
- package/dist/cjs/components/ChatDrawer/CompactionWidget.js +80 -0
- package/dist/cjs/components/ChatDrawer/CompactionWidget.js.map +1 -0
- package/dist/cjs/hooks/useDevicChat.js +32 -1
- package/dist/cjs/hooks/useDevicChat.js.map +1 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/styles.css +1 -1
- package/dist/esm/api/types.d.ts +83 -0
- package/dist/esm/api/types.js.map +1 -1
- package/dist/esm/components/ChatDrawer/ChatDrawer.js +4 -1
- package/dist/esm/components/ChatDrawer/ChatDrawer.js.map +1 -1
- package/dist/esm/components/ChatDrawer/ChatDrawer.types.d.ts +51 -1
- package/dist/esm/components/ChatDrawer/ChatMessages.d.ts +1 -1
- package/dist/esm/components/ChatDrawer/ChatMessages.js +41 -4
- package/dist/esm/components/ChatDrawer/ChatMessages.js.map +1 -1
- package/dist/esm/components/ChatDrawer/CompactionWidget.d.ts +63 -0
- package/dist/esm/components/ChatDrawer/CompactionWidget.js +78 -0
- package/dist/esm/components/ChatDrawer/CompactionWidget.js.map +1 -0
- package/dist/esm/components/ChatDrawer/index.d.ts +2 -0
- package/dist/esm/hooks/useDevicChat.d.ts +13 -1
- package/dist/esm/hooks/useDevicChat.js +32 -1
- package/dist/esm/hooks/useDevicChat.js.map +1 -1
- package/dist/esm/index.d.ts +3 -3
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { ChatMessage, ModelInterfaceTool, ChatFile, AgentThreadDto, AgentDto, ToolGroupConfig, WhisperTranscriptionResponse, TenantLimitExceeded, RecalledMemoryRecord, QueueDisposition } from '../../api/types';
|
|
1
|
+
import type { ChatMessage, ModelInterfaceTool, ChatFile, AgentThreadDto, AgentDto, ToolGroupConfig, WhisperTranscriptionResponse, TenantLimitExceeded, RecalledMemoryRecord, QueueDisposition, CompactionCheckpoint, CompactionActivity } from '../../api/types';
|
|
2
2
|
import type { PendingWidgetCall } from '../../hooks/useModelInterface';
|
|
3
3
|
import type { SendMessageResult } from '../../hooks/useDevicChat';
|
|
4
4
|
import type { AIReference } from '../../provider/types';
|
|
5
5
|
import type { UsageBarDisplay, UsageBarData } from './UsageBar';
|
|
6
6
|
import type { RecalledMemoriesRenderer } from './RecalledMemoriesWidget';
|
|
7
|
+
import type { CompactionRenderer } from './CompactionWidget';
|
|
7
8
|
import type { CoreMemoryLabels } from '../CoreMemoryModal';
|
|
8
9
|
/**
|
|
9
10
|
* A suggested message displayed as a quick action button.
|
|
@@ -535,6 +536,47 @@ export interface ChatDrawerOptions {
|
|
|
535
536
|
* ```
|
|
536
537
|
*/
|
|
537
538
|
recalledMemoriesRenderer?: RecalledMemoriesRenderer;
|
|
539
|
+
/**
|
|
540
|
+
* Show the compaction marker: the cut line across the conversation at the
|
|
541
|
+
* point where the assistant stopped receiving the messages above it, and
|
|
542
|
+
* the "Compacting context" indicator while one is being written. Only
|
|
543
|
+
* appears for assistants with compaction enabled.
|
|
544
|
+
* @default true
|
|
545
|
+
*/
|
|
546
|
+
showCompaction?: boolean;
|
|
547
|
+
/**
|
|
548
|
+
* Let the reader open a compaction marker and read the checkpoint behind it.
|
|
549
|
+
*
|
|
550
|
+
* Off by default. What opens is not metadata about the conversation, it is
|
|
551
|
+
* an account OF it: the goal the model inferred, the decisions it recorded
|
|
552
|
+
* and why, what it believes is still pending, and the identifiers it lifted
|
|
553
|
+
* out verbatim. Worth showing an operator debugging an assistant; not
|
|
554
|
+
* something to put in front of the customer the conversation is with unless
|
|
555
|
+
* you have decided it is. Closed is therefore the default.
|
|
556
|
+
*
|
|
557
|
+
* The marker itself still appears either way, with how many messages were
|
|
558
|
+
* folded and the token counts — a conversation that was compacted should
|
|
559
|
+
* say so.
|
|
560
|
+
* @default false
|
|
561
|
+
*/
|
|
562
|
+
expandableCompaction?: boolean;
|
|
563
|
+
/**
|
|
564
|
+
* Render your own compaction node instead of the built-in marker. Called
|
|
565
|
+
* once per checkpoint, and once more while a compaction is in flight (with
|
|
566
|
+
* `checkpoint: null` and the `activity` describing what it is folding).
|
|
567
|
+
* Return null to hide that instance.
|
|
568
|
+
*
|
|
569
|
+
* @example
|
|
570
|
+
* ```tsx
|
|
571
|
+
* compactionRenderer: ({ checkpoint, activity }) =>
|
|
572
|
+
* activity?.state === "running" ? (
|
|
573
|
+
* <MySpinner label="Summarizing the conversation…" />
|
|
574
|
+
* ) : (
|
|
575
|
+
* <MyDivider text={`${checkpoint!.compactedMessageCount} messages folded`} />
|
|
576
|
+
* )
|
|
577
|
+
* ```
|
|
578
|
+
*/
|
|
579
|
+
compactionRenderer?: CompactionRenderer;
|
|
538
580
|
/**
|
|
539
581
|
* Show a brain button in the drawer header that opens the CoreMemoryModal:
|
|
540
582
|
* the standing entries the assistant permanently remembers for the drawer's
|
|
@@ -791,6 +833,14 @@ export interface ChatMessagesProps {
|
|
|
791
833
|
recalledMemories?: RecalledMemoryRecord[];
|
|
792
834
|
/** Custom renderer replacing the built-in recalled-memories strip */
|
|
793
835
|
recalledMemoriesRenderer?: RecalledMemoriesRenderer;
|
|
836
|
+
/** Compaction checkpoints, drawn as a cut line at the message each folded */
|
|
837
|
+
compactions?: CompactionCheckpoint[];
|
|
838
|
+
/** The compaction being written right now, if any */
|
|
839
|
+
compaction?: CompactionActivity | null;
|
|
840
|
+
/** Custom renderer replacing the built-in compaction marker */
|
|
841
|
+
compactionRenderer?: CompactionRenderer;
|
|
842
|
+
/** Let the reader open a checkpoint and read it (see ChatDrawerOptions) */
|
|
843
|
+
expandableCompaction?: boolean;
|
|
794
844
|
}
|
|
795
845
|
/**
|
|
796
846
|
* Props for ChatInput component
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { ChatMessagesProps } from "./ChatDrawer.types";
|
|
2
2
|
import "../Feedback/Feedback.css";
|
|
3
|
-
export declare function ChatMessages({ messages, allMessages, isLoading, welcomeMessage, suggestedMessages, onSuggestedClick, toolRenderers, toolIcons, loadingIndicator, showFeedback, feedbackMap, onFeedback, handedOffSubThreadId, onHandoffCompleted, handoffWidgetRenderer, toolGroups, userMessageRenderer, assistantMessageRenderer, apiKey, baseUrl, pollingInterval, pendingInlineWidgets, onSubmitWidget, onCancelWidget, recalledMemories, recalledMemoriesRenderer, }: ChatMessagesProps): JSX.Element;
|
|
3
|
+
export declare function ChatMessages({ messages, allMessages, isLoading, welcomeMessage, suggestedMessages, onSuggestedClick, toolRenderers, toolIcons, loadingIndicator, showFeedback, feedbackMap, onFeedback, handedOffSubThreadId, onHandoffCompleted, handoffWidgetRenderer, toolGroups, userMessageRenderer, assistantMessageRenderer, apiKey, baseUrl, pollingInterval, pendingInlineWidgets, onSubmitWidget, onCancelWidget, recalledMemories, recalledMemoriesRenderer, compactions, compaction, compactionRenderer, expandableCompaction, }: ChatMessagesProps): JSX.Element;
|
|
@@ -8,6 +8,7 @@ import { MessageActions } from '../Feedback/MessageActions.js';
|
|
|
8
8
|
import { HandoffSubagentWidget } from './HandoffSubagentWidget.js';
|
|
9
9
|
import { ReferenceChip } from './ReferenceChip.js';
|
|
10
10
|
import { RecalledMemoriesWidget } from './RecalledMemoriesWidget.js';
|
|
11
|
+
import { CompactionWidget } from './CompactionWidget.js';
|
|
11
12
|
import { normalizeMessageFile } from '../../api/types.js';
|
|
12
13
|
import { parsePastedBlocks, pastedPreview, pastedLineCount } from './pastedText.js';
|
|
13
14
|
|
|
@@ -314,7 +315,7 @@ function extractSubThreadId(toolCallId, allMessages, handedOffSubThreadId) {
|
|
|
314
315
|
// Fall back to active handoff subthread ID
|
|
315
316
|
return handedOffSubThreadId || null;
|
|
316
317
|
}
|
|
317
|
-
function ChatMessages({ messages, allMessages, isLoading, welcomeMessage, suggestedMessages, onSuggestedClick, toolRenderers, toolIcons, loadingIndicator, showFeedback = true, feedbackMap, onFeedback, handedOffSubThreadId, onHandoffCompleted, handoffWidgetRenderer, toolGroups, userMessageRenderer, assistantMessageRenderer, apiKey, baseUrl, pollingInterval, pendingInlineWidgets, onSubmitWidget, onCancelWidget, recalledMemories, recalledMemoriesRenderer, }) {
|
|
318
|
+
function ChatMessages({ messages, allMessages, isLoading, welcomeMessage, suggestedMessages, onSuggestedClick, toolRenderers, toolIcons, loadingIndicator, showFeedback = true, feedbackMap, onFeedback, handedOffSubThreadId, onHandoffCompleted, handoffWidgetRenderer, toolGroups, userMessageRenderer, assistantMessageRenderer, apiKey, baseUrl, pollingInterval, pendingInlineWidgets, onSubmitWidget, onCancelWidget, recalledMemories, recalledMemoriesRenderer, compactions, compaction, compactionRenderer, expandableCompaction, }) {
|
|
318
319
|
const containerRef = useRef(null);
|
|
319
320
|
const prevLengthRef = useRef(messages.length);
|
|
320
321
|
// Anchor each recall record to the message that brought it in: the
|
|
@@ -349,6 +350,40 @@ function ChatMessages({ messages, allMessages, isLoading, welcomeMessage, sugges
|
|
|
349
350
|
}, [recalledMemories, messages]);
|
|
350
351
|
// The strip renders after the message (or tool group) that anchors it.
|
|
351
352
|
const recallsFor = (uids) => uids.flatMap((uid) => recallsByAnchor.get(uid) ?? []);
|
|
353
|
+
// Compaction checkpoints, keyed by the LAST message each one folded: the
|
|
354
|
+
// point where the assistant's view of the conversation stops. A checkpoint
|
|
355
|
+
// whose anchor is not on screen (it folded messages this client never
|
|
356
|
+
// loaded) is drawn at the top instead, so the cut is never invisible.
|
|
357
|
+
const { compactionsByAnchor, orphanCompactions, activeCompactionUid } = useMemo(() => {
|
|
358
|
+
const byAnchor = new Map();
|
|
359
|
+
const orphans = [];
|
|
360
|
+
for (const checkpoint of compactions ?? []) {
|
|
361
|
+
const anchor = checkpoint.anchorMessageUid
|
|
362
|
+
? messages.find((m) => m.uid === checkpoint.anchorMessageUid ||
|
|
363
|
+
m.serverUid === checkpoint.anchorMessageUid)?.uid
|
|
364
|
+
: undefined;
|
|
365
|
+
if (anchor) {
|
|
366
|
+
const list = byAnchor.get(anchor);
|
|
367
|
+
if (list)
|
|
368
|
+
list.push(checkpoint);
|
|
369
|
+
else
|
|
370
|
+
byAnchor.set(anchor, [checkpoint]);
|
|
371
|
+
}
|
|
372
|
+
else {
|
|
373
|
+
orphans.push(checkpoint);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
// Only the newest checkpoint governs the context: each compaction
|
|
377
|
+
// merges the previous summary into itself.
|
|
378
|
+
const active = (compactions ?? []).reduce((latest, candidate) => !latest || candidate.index > latest.index ? candidate : latest, null);
|
|
379
|
+
return {
|
|
380
|
+
compactionsByAnchor: byAnchor,
|
|
381
|
+
orphanCompactions: orphans,
|
|
382
|
+
activeCompactionUid: active?.uid,
|
|
383
|
+
};
|
|
384
|
+
}, [compactions, messages]);
|
|
385
|
+
const compactionsFor = (uids) => uids.flatMap((uid) => compactionsByAnchor.get(uid) ?? []);
|
|
386
|
+
const renderCompactions = (checkpoints) => checkpoints.map((checkpoint) => (jsx(CompactionWidget, { checkpoint: checkpoint, isActive: checkpoint.uid === activeCompactionUid, renderer: compactionRenderer, expandable: expandableCompaction }, checkpoint.uid)));
|
|
352
387
|
// Auto-scroll to bottom when new messages arrive
|
|
353
388
|
useEffect(() => {
|
|
354
389
|
if (containerRef.current) {
|
|
@@ -370,7 +405,8 @@ function ChatMessages({ messages, allMessages, isLoading, welcomeMessage, sugges
|
|
|
370
405
|
}) }))] })), grouped.map((item) => {
|
|
371
406
|
if (item.type === "toolGroup") {
|
|
372
407
|
const groupRecalls = recallsFor(item.toolMessages.map((m) => m.uid));
|
|
373
|
-
|
|
408
|
+
const groupCompactions = compactionsFor(item.toolMessages.map((m) => m.uid));
|
|
409
|
+
return (jsxs(React.Fragment, { children: [jsx(ToolGroup, { toolMessages: item.toolMessages, isActive: item.isActive, allMessages: allMessages, toolRenderers: toolRenderers, toolIcons: toolIcons, toolGroups: toolGroups, handedOffSubThreadId: handedOffSubThreadId, onHandoffCompleted: onHandoffCompleted, handoffWidgetRenderer: handoffWidgetRenderer, apiKey: apiKey, baseUrl: baseUrl, pollingInterval: pollingInterval }), groupRecalls.length > 0 && (jsx(RecalledMemoriesWidget, { records: groupRecalls, isLoading: isLoading, renderer: recalledMemoriesRenderer })), renderCompactions(groupCompactions)] }, `tg-${item.toolMessages[0].uid}`));
|
|
374
410
|
}
|
|
375
411
|
const message = item.message;
|
|
376
412
|
const rawText = message.content?.message;
|
|
@@ -401,6 +437,7 @@ function ChatMessages({ messages, allMessages, isLoading, welcomeMessage, sugges
|
|
|
401
437
|
? assistantMessageRenderer
|
|
402
438
|
: userMessageRenderer;
|
|
403
439
|
const messageRecalls = recallsFor([message.uid]);
|
|
440
|
+
const messageCompactions = compactionsFor([message.uid]);
|
|
404
441
|
return (jsxs(React.Fragment, { children: [jsxs("div", { className: "devic-message", "data-role": message.role, "data-queued": message.queued ? 'true' : undefined, children: [refLabels.length > 0 && (jsx("div", { className: "devic-message-references", children: refLabels.map((lbl, i) => (jsx(ReferenceChip, { label: lbl, variant: "message" }, i))) })), jsxs("div", { className: "devic-message-bubble", children: [pastedBlocks.length > 0 && (jsx("div", { className: "devic-message-pasted", children: pastedBlocks.map((block) => (jsx(PastedBlockCard, { block: block }, block.id))) })), bodyText ? (bubbleRenderer ? (bubbleRenderer({
|
|
405
442
|
message,
|
|
406
443
|
content: bodyText,
|
|
@@ -409,8 +446,8 @@ function ChatMessages({ messages, allMessages, isLoading, welcomeMessage, sugges
|
|
|
409
446
|
})) : (jsx(Markdown, { options: { overrides: markdownOverrides }, children: bodyText }))) : null, hasFiles && (jsx("div", { className: "devic-message-files", children: message.content.files.map((raw, fileIdx) => {
|
|
410
447
|
const file = normalizeMessageFile(raw);
|
|
411
448
|
return file.type === "image" && file.url ? (jsx("a", { className: "devic-message-file-image", href: file.url, target: "_blank", rel: "noreferrer", children: jsx("img", { src: file.url, alt: file.name }) }, fileIdx)) : (jsxs("div", { className: "devic-message-file", children: [jsx(FileIcon, {}), jsx("span", { children: file.name })] }, fileIdx));
|
|
412
|
-
}) })), !isAssistant && message.transcriptId && (jsx(TranscriptPlayback, { transcriptId: message.transcriptId, apiKey: apiKey, baseUrl: baseUrl }))] }), jsxs("div", { className: "devic-message-footer", children: [message.queued && (jsxs("span", { className: "devic-message-queued-label", children: [jsx(QueuedIcon, {}), "Queued"] })), jsx("span", { className: "devic-message-time", children: formatTime(message.timestamp) }), isAssistant && showFeedback && onFeedback && (jsx(MessageActions, { messageId: message.uid, messageContent: messageText, currentFeedback: currentFeedback, onFeedback: onFeedback, showCopy: true, showFeedback: true }))] })] }), messageRecalls.length > 0 && (jsx(RecalledMemoriesWidget, { records: messageRecalls, isLoading: isLoading, renderer: recalledMemoriesRenderer }))] }, message.uid));
|
|
413
|
-
}), isLoading && pendingRecalls.length > 0 && (jsx(RecalledMemoriesWidget, { records: pendingRecalls, isLoading: isLoading, renderer: recalledMemoriesRenderer })), pendingInlineWidgets && pendingInlineWidgets.length > 0 && (jsx("div", { className: "devic-inline-widgets", children: pendingInlineWidgets.map((wc) => {
|
|
449
|
+
}) })), !isAssistant && message.transcriptId && (jsx(TranscriptPlayback, { transcriptId: message.transcriptId, apiKey: apiKey, baseUrl: baseUrl }))] }), jsxs("div", { className: "devic-message-footer", children: [message.queued && (jsxs("span", { className: "devic-message-queued-label", children: [jsx(QueuedIcon, {}), "Queued"] })), jsx("span", { className: "devic-message-time", children: formatTime(message.timestamp) }), isAssistant && showFeedback && onFeedback && (jsx(MessageActions, { messageId: message.uid, messageContent: messageText, currentFeedback: currentFeedback, onFeedback: onFeedback, showCopy: true, showFeedback: true }))] })] }), messageRecalls.length > 0 && (jsx(RecalledMemoriesWidget, { records: messageRecalls, isLoading: isLoading, renderer: recalledMemoriesRenderer })), renderCompactions(messageCompactions)] }, message.uid));
|
|
450
|
+
}), isLoading && pendingRecalls.length > 0 && (jsx(RecalledMemoriesWidget, { records: pendingRecalls, isLoading: isLoading, renderer: recalledMemoriesRenderer })), renderCompactions(orphanCompactions), compaction?.state === "running" && (jsx(CompactionWidget, { checkpoint: null, activity: compaction, renderer: compactionRenderer })), pendingInlineWidgets && pendingInlineWidgets.length > 0 && (jsx("div", { className: "devic-inline-widgets", children: pendingInlineWidgets.map((wc) => {
|
|
414
451
|
const WidgetComponent = wc.widget.component;
|
|
415
452
|
return (jsx("div", { className: "devic-inline-widget", "data-tool-name": wc.toolName, children: jsx(WidgetComponent, { toolCall: wc.toolCall, params: wc.params, submit: (response) => onSubmitWidget?.(wc.toolCall.id, response), cancel: (reason) => onCancelWidget?.(wc.toolCall.id, reason) }) }, wc.toolCall.id));
|
|
416
453
|
}) })), showLoadingDots &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatMessages.js","sources":["../../../../src/components/ChatDrawer/ChatMessages.tsx"],"sourcesContent":["import React, { useState, useEffect, useMemo, useRef } from \"react\";\nimport { useOptionalDevicContext } from \"../../provider\";\nimport Markdown from \"markdown-to-jsx\";\nimport { MessageActions } from \"../Feedback\";\nimport { HandoffSubagentWidget } from \"./HandoffSubagentWidget\";\nimport { ReferenceChip } from \"./ReferenceChip\";\nimport { RecalledMemoriesWidget } from \"./RecalledMemoriesWidget\";\nimport type { ChatMessagesProps, SuggestedMessage } from \"./ChatDrawer.types\";\nimport type { ChatMessage, RecalledMemoryRecord, ToolGroupConfig, ToolGroupCall } from \"../../api/types\";\nimport { normalizeMessageFile } from \"../../api/types\";\nimport type { FeedbackState } from \"../Feedback\";\nimport { segmentToolCalls } from \"../../utils/toolGroups\";\nimport { DevicApiClient } from \"../../api/client\";\nimport {\n parsePastedBlocks,\n pastedPreview,\n pastedLineCount,\n type PastedText,\n} from \"./pastedText\";\nimport \"../Feedback/Feedback.css\";\n\n// Backend finalizer tool for assistants configured with \"Require Tool Use to\n// Finish\". It carries the final answer in its `message` argument, which the\n// backend copies to content.message, so it renders as a plain assistant bubble\n// instead of a tool activity line. Agents have a same-named tool with a\n// different shape, but their timeline does not go through this component.\nconst FINISH_EXECUTION_TOOL = \"finish_execution\";\n\n/**\n * Format timestamp to readable time\n */\nfunction formatTime(timestamp: number): string {\n return new Date(timestamp).toLocaleTimeString([], {\n hour: \"2-digit\",\n minute: \"2-digit\",\n });\n}\n\nfunction MicGlyph(): JSX.Element {\n return (\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z\" />\n <path d=\"M19 10v2a7 7 0 0 1-14 0v-2\" />\n <line x1=\"12\" y1=\"19\" x2=\"12\" y2=\"23\" />\n </svg>\n );\n}\n\nfunction PlayGlyph(): JSX.Element {\n return (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\">\n <path d=\"M8 5v14l11-7z\" />\n </svg>\n );\n}\n\nfunction PauseGlyph(): JSX.Element {\n return (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\">\n <rect x=\"6\" y=\"5\" width=\"4\" height=\"14\" rx=\"1\" />\n <rect x=\"14\" y=\"5\" width=\"4\" height=\"14\" rx=\"1\" />\n </svg>\n );\n}\n\n/**\n * Compact playback control shown on user messages that were dictated by voice\n * (i.e. carry a `transcriptId`). The source audio URL is resolved lazily on the\n * first play via GET /api/v1/whisper/:transcriptId, so listing a conversation\n * never triggers extra requests until the user actually wants to listen.\n */\nfunction TranscriptPlayback({\n transcriptId,\n apiKey,\n baseUrl,\n}: {\n transcriptId: string;\n apiKey?: string;\n baseUrl?: string;\n}): JSX.Element {\n const devicContext = useOptionalDevicContext();\n const getTenantSession = devicContext?.getTenantSession;\n const onSessionExpired = devicContext?.onSessionExpired;\n const [isPlaying, setIsPlaying] = useState(false);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const audioUrlRef = useRef<string | null>(null);\n const audioRef = useRef<HTMLAudioElement | null>(null);\n\n useEffect(() => {\n return () => {\n if (audioRef.current) {\n audioRef.current.pause();\n audioRef.current = null;\n }\n };\n }, []);\n\n const resolveAudio = async (): Promise<HTMLAudioElement | null> => {\n if (audioRef.current) return audioRef.current;\n let url = audioUrlRef.current;\n if (!url) {\n if (!apiKey && !getTenantSession) {\n setError(\"Unavailable\");\n return null;\n }\n setIsLoading(true);\n setError(null);\n try {\n const client = new DevicApiClient({\n apiKey,\n baseUrl: baseUrl || \"https://api.devic.ai\",\n getTenantSession,\n onSessionExpired,\n });\n const transcript = await client.getTranscript(transcriptId);\n url = transcript.audioUrl || null;\n audioUrlRef.current = url;\n } catch {\n setError(\"Audio unavailable\");\n return null;\n } finally {\n setIsLoading(false);\n }\n }\n if (!url) {\n setError(\"Audio unavailable\");\n return null;\n }\n const audio = new Audio(url);\n audio.onplay = () => setIsPlaying(true);\n audio.onpause = () => setIsPlaying(false);\n audio.onended = () => setIsPlaying(false);\n audio.onerror = () => {\n setError(\"Playback failed\");\n setIsPlaying(false);\n };\n audioRef.current = audio;\n return audio;\n };\n\n const toggle = async () => {\n if (isPlaying && audioRef.current) {\n audioRef.current.pause();\n return;\n }\n const audio = await resolveAudio();\n if (audio) {\n try {\n await audio.play();\n } catch {\n setError(\"Playback failed\");\n }\n }\n };\n\n return (\n <div\n className=\"devic-transcript-playback\"\n data-playing={isPlaying ? \"true\" : \"false\"}\n title=\"Dictated by voice\"\n >\n <button\n type=\"button\"\n className=\"devic-transcript-btn\"\n onClick={toggle}\n disabled={isLoading}\n aria-label={isPlaying ? \"Pause recording\" : \"Play recording\"}\n >\n {isLoading ? (\n <span className=\"devic-transcript-spinner\" aria-hidden=\"true\" />\n ) : isPlaying ? (\n <PauseGlyph />\n ) : (\n <PlayGlyph />\n )}\n </button>\n <span className=\"devic-transcript-icon\" aria-hidden=\"true\">\n <MicGlyph />\n </span>\n <span className=\"devic-transcript-label\">\n {error || \"Voice message\"}\n </span>\n </div>\n );\n}\n\n/**\n * Groups consecutive tool-call assistant messages (no text content)\n * into { toolMessages, isActive } groups, interleaved with regular messages.\n */\nfunction groupMessages(\n messages: ChatMessage[],\n isLoading: boolean,\n): Array<\n | { type: \"message\"; message: ChatMessage }\n | { type: \"toolGroup\"; toolMessages: ChatMessage[]; isActive: boolean }\n> {\n const result: Array<\n | { type: \"message\"; message: ChatMessage }\n | { type: \"toolGroup\"; toolMessages: ChatMessage[]; isActive: boolean }\n > = [];\n\n let currentToolGroup: ChatMessage[] = [];\n\n const flushToolGroup = (isActive: boolean) => {\n if (currentToolGroup.length > 0) {\n result.push({\n type: \"toolGroup\",\n toolMessages: [...currentToolGroup],\n isActive,\n });\n currentToolGroup = [];\n }\n };\n\n for (let i = 0; i < messages.length; i++) {\n const msg = messages[i];\n\n // Skip developer, system and tool response messages\n if (msg.role === \"developer\" || msg.role === \"system\" || msg.role === \"tool\") {\n continue;\n }\n\n // `finish_execution` is not an action the assistant took, it is how the\n // backend delivers the final answer when the assistant is configured with\n // \"Require Tool Use to Finish\": the tool's `message` argument is copied to\n // content.message and rendered as the assistant bubble below. Showing it as\n // a tool activity line would just duplicate that bubble with plumbing.\n const visibleToolCalls = (msg.tool_calls || []).filter(\n (toolCall) => toolCall.function?.name !== FINISH_EXECUTION_TOOL,\n );\n const hasToolCalls = visibleToolCalls.length > 0;\n const hasText = !!msg.content?.message;\n const hasFiles = msg.content?.files && msg.content.files.length > 0;\n\n if (hasToolCalls) {\n // If message has both text and tool_calls, show text first\n if (hasText || hasFiles) {\n // Flush any prior tool group before inserting the text message\n const remainingMeaningful = messages\n .slice(i + 1)\n .some(\n (m) =>\n (m.role === \"assistant\" && m.content?.message) ||\n m.role === \"user\",\n );\n flushToolGroup(isLoading && !remainingMeaningful);\n result.push({ type: \"message\", message: msg });\n }\n // Always accumulate the tool call\n currentToolGroup.push(\n visibleToolCalls.length === msg.tool_calls!.length\n ? msg\n : { ...msg, tool_calls: visibleToolCalls },\n );\n } else {\n // Regular message → flush any accumulated tool group first\n const remainingMeaningful = messages\n .slice(i)\n .some(\n (m) =>\n (m.role === \"assistant\" && m.content?.message) || m.role === \"user\",\n );\n flushToolGroup(isLoading && !remainingMeaningful);\n\n if (hasText || hasFiles) {\n result.push({ type: \"message\", message: msg });\n }\n }\n }\n\n // Flush remaining tool group (is active if still loading)\n flushToolGroup(isLoading);\n\n return result;\n}\n\n/**\n * Collapsible tool actions group\n */\nfunction ToolGroup({\n toolMessages,\n isActive,\n allMessages,\n toolRenderers,\n toolIcons,\n toolGroups,\n handedOffSubThreadId,\n onHandoffCompleted,\n handoffWidgetRenderer,\n apiKey,\n baseUrl,\n pollingInterval,\n}: {\n toolMessages: ChatMessage[];\n isActive: boolean;\n allMessages?: ChatMessage[];\n toolRenderers?: Record<string, (input: any, output: any) => React.ReactNode>;\n toolIcons?: Record<string, React.ReactNode>;\n toolGroups?: ToolGroupConfig[];\n handedOffSubThreadId?: string;\n onHandoffCompleted?: () => void;\n handoffWidgetRenderer?: ChatMessagesProps[\"handoffWidgetRenderer\"];\n apiKey?: string;\n baseUrl?: string;\n pollingInterval?: number;\n}): JSX.Element {\n const [isCollapsed, setIsCollapsed] = useState(false);\n const shouldCollapse = toolMessages.length > 3 && !isActive;\n\n // Auto-collapse when transitioning from active to completed\n const wasActiveRef = useRef(isActive);\n useEffect(() => {\n if (wasActiveRef.current && !isActive && toolMessages.length > 3) {\n setIsCollapsed(true);\n }\n wasActiveRef.current = isActive;\n }, [isActive, toolMessages.length]);\n\n const lastIndex = toolMessages.length - 1;\n\n const renderToolItem = (\n msg: ChatMessage,\n opts: { active?: boolean; showSpinner?: boolean },\n ) => {\n const toolCall = msg.tool_calls?.[0];\n const toolName = toolCall?.function?.name;\n const summaryText =\n msg.summary || toolName || (opts.active ? \"Processing...\" : \"Completed\");\n\n // Render HandoffSubagentWidget for hand_off_subagent tool calls\n if (toolName === \"hand_off_subagent\" && toolCall && allMessages) {\n const subThreadId = extractSubThreadId(\n toolCall.id,\n allMessages,\n handedOffSubThreadId,\n );\n if (subThreadId) {\n return (\n <HandoffSubagentWidget\n subThreadId={subThreadId}\n onCompleted={onHandoffCompleted}\n renderWidget={handoffWidgetRenderer}\n apiKey={apiKey}\n baseUrl={baseUrl}\n pollingInterval={pollingInterval}\n />\n );\n }\n }\n\n // Custom renderer for completed tools\n if (!opts.active && toolName && toolRenderers?.[toolName] && allMessages) {\n const toolResponse = allMessages.find(\n (m) => m.role === \"tool\" && m.tool_call_id === toolCall!.id,\n );\n let input: any = {};\n try {\n input = JSON.parse(toolCall!.function.arguments);\n } catch {}\n const output =\n toolResponse?.content?.data ||\n toolResponse?.content?.message ||\n toolResponse?.content;\n return toolRenderers[toolName](input, output);\n }\n\n const icon = opts.showSpinner ? (\n <SpinnerIcon />\n ) : (\n (toolName && toolIcons?.[toolName]) || <ToolDoneIcon />\n );\n\n return (\n <>\n <span className=\"devic-tool-activity-icon\">{icon}</span>\n <span\n className={`devic-tool-activity-text ${opts.active ? \"devic-glow-text\" : \"\"}`}\n >\n {summaryText}\n </span>\n </>\n );\n };\n\n /** Resolve a ChatMessage into a ToolGroupCall */\n const resolveToolGroupCall = (msg: ChatMessage): ToolGroupCall | null => {\n const toolCall = msg.tool_calls?.[0];\n if (!toolCall) return null;\n const toolName = toolCall.function?.name;\n let input: any = {};\n try {\n input = JSON.parse(toolCall.function.arguments);\n } catch {}\n const toolResponse = allMessages?.find(\n (m) => m.role === \"tool\" && m.tool_call_id === toolCall.id,\n );\n const output =\n toolResponse?.content?.data ||\n toolResponse?.content?.message ||\n toolResponse?.content;\n return { name: toolName, input, output, toolCallId: toolCall.id };\n };\n\n /** Render completed tool messages, applying toolGroups segmentation when configured */\n const renderCompletedItems = (msgs: ChatMessage[]) => {\n if (!toolGroups || toolGroups.length === 0) {\n return msgs.map((msg) => (\n <div key={msg.uid} className=\"devic-tool-activity\">\n {renderToolItem(msg, {})}\n </div>\n ));\n }\n\n // Build ToolGroupCall array for completed messages\n const calls: Array<{ msg: ChatMessage; call: ToolGroupCall }> = [];\n for (const msg of msgs) {\n const call = resolveToolGroupCall(msg);\n if (call) {\n calls.push({ msg, call });\n }\n }\n\n const segments = segmentToolCalls(\n calls.map((c) => c.call),\n toolGroups,\n );\n\n const elements: React.ReactNode[] = [];\n let callIdx = 0;\n\n for (const segment of segments) {\n if (segment.type === \"group\") {\n const groupKey = segment.calls\n .map((c) => c.toolCallId)\n .join(\"-\");\n elements.push(\n <div key={`tg-group-${groupKey}`} className=\"devic-tool-activity devic-tool-activity--grouped\">\n {segment.config.renderer(segment.calls)}\n </div>,\n );\n callIdx += segment.calls.length;\n } else {\n const entry = calls[callIdx];\n elements.push(\n <div key={entry.msg.uid} className=\"devic-tool-activity\">\n {renderToolItem(entry.msg, {})}\n </div>,\n );\n callIdx += 1;\n }\n }\n\n return elements;\n };\n\n // If active, show all items; last one gets the glow treatment\n if (isActive) {\n // For active groups: render all completed items with grouping, then render the active (last) item individually\n const completedMessages = toolMessages.slice(0, lastIndex);\n const lastMsg = toolMessages[lastIndex];\n\n return (\n <div className=\"devic-tool-group\">\n {completedMessages.length > 0 && renderCompletedItems(completedMessages)}\n <div\n key={lastMsg.uid}\n className=\"devic-tool-activity devic-tool-activity--active\"\n >\n {renderToolItem(lastMsg, { active: true, showSpinner: true })}\n </div>\n </div>\n );\n }\n\n // Completed: collapse if > 3 actions\n if (shouldCollapse && isCollapsed) {\n return (\n <div className=\"devic-tool-group\">\n <button\n className=\"devic-tool-collapse-btn\"\n onClick={() => setIsCollapsed(false)}\n type=\"button\"\n >\n <ToolDoneIcon />\n <span>{toolMessages.length} actions</span>\n <ChevronDownIcon />\n </button>\n </div>\n );\n }\n\n return (\n <div className=\"devic-tool-group\">\n {shouldCollapse && (\n <button\n className=\"devic-tool-collapse-btn\"\n onClick={() => setIsCollapsed(true)}\n type=\"button\"\n >\n <span>{toolMessages.length} actions</span>\n <ChevronUpIcon />\n </button>\n )}\n <div className=\"devic-tool-group-items\" data-expanded=\"true\">\n {renderCompletedItems(toolMessages)}\n </div>\n </div>\n );\n}\n\n/**\n * Messages list component\n */\nconst markdownOverrides = {\n table: {\n component: ({ children, ...props }: any) =>\n React.createElement(\n \"div\",\n { className: \"markdown-table\" },\n React.createElement(\"table\", props, children),\n ),\n },\n};\n\n/**\n * Extract subthread ID from a hand_off_subagent tool call.\n * Checks the tool response in allMessages first, then falls back to handedOffSubThreadId.\n */\nfunction extractSubThreadId(\n toolCallId: string,\n allMessages: ChatMessage[],\n handedOffSubThreadId?: string,\n): string | null {\n // Look for the tool response message\n const toolResponse = allMessages.find(\n (m) => m.role === \"tool\" && m.tool_call_id === toolCallId,\n );\n if (toolResponse) {\n const content = toolResponse.content?.data || toolResponse.content;\n if (content && typeof content === \"object\" && \"subthreadId\" in content) {\n return (content as any).subthreadId;\n }\n if (content && typeof content === \"object\" && \"subThreadId\" in content) {\n return (content as any).subThreadId;\n }\n }\n // Fall back to active handoff subthread ID\n return handedOffSubThreadId || null;\n}\n\nexport function ChatMessages({\n messages,\n allMessages,\n isLoading,\n welcomeMessage,\n suggestedMessages,\n onSuggestedClick,\n toolRenderers,\n toolIcons,\n loadingIndicator,\n showFeedback = true,\n feedbackMap,\n onFeedback,\n handedOffSubThreadId,\n onHandoffCompleted,\n handoffWidgetRenderer,\n toolGroups,\n userMessageRenderer,\n assistantMessageRenderer,\n apiKey,\n baseUrl,\n pollingInterval,\n pendingInlineWidgets,\n onSubmitWidget,\n onCancelWidget,\n recalledMemories,\n recalledMemoriesRenderer,\n}: ChatMessagesProps): JSX.Element {\n const containerRef = useRef<HTMLDivElement>(null);\n const prevLengthRef = useRef(messages.length);\n\n // Anchor each recall record to the message that brought it in: the\n // assistant message carrying its memory tool call (toolCallId), or the\n // message the backend named (messageUid — matched against serverUid too,\n // since user messages may render under an adopted optimistic uid). Records\n // whose anchor is not on screen yet (the run is still producing it) go to\n // the pending group shown at the bottom while loading.\n const { recallsByAnchor, pendingRecalls } = useMemo(() => {\n const byAnchor = new Map<string, RecalledMemoryRecord[]>();\n const pending: RecalledMemoryRecord[] = [];\n for (const record of recalledMemories ?? []) {\n let anchor: string | undefined;\n if (record.toolCallId) {\n anchor = messages.find((m) =>\n m.tool_calls?.some((tc) => tc.id === record.toolCallId)\n )?.uid;\n }\n if (!anchor && record.messageUid) {\n anchor = messages.find(\n (m) =>\n m.uid === record.messageUid || m.serverUid === record.messageUid\n )?.uid;\n }\n if (anchor) {\n const list = byAnchor.get(anchor);\n if (list) list.push(record);\n else byAnchor.set(anchor, [record]);\n } else {\n pending.push(record);\n }\n }\n return { recallsByAnchor: byAnchor, pendingRecalls: pending };\n }, [recalledMemories, messages]);\n\n // The strip renders after the message (or tool group) that anchors it.\n const recallsFor = (uids: string[]): RecalledMemoryRecord[] =>\n uids.flatMap((uid) => recallsByAnchor.get(uid) ?? []);\n\n // Auto-scroll to bottom when new messages arrive\n useEffect(() => {\n if (containerRef.current) {\n containerRef.current.scrollTop = containerRef.current.scrollHeight;\n }\n prevLengthRef.current = messages.length;\n }, [messages.length, isLoading]);\n\n const grouped = groupMessages(messages, isLoading);\n\n // Show loading dots only if there's no active tool group at the end\n const lastGroup = grouped[grouped.length - 1];\n const showLoadingDots =\n isLoading && !(lastGroup?.type === \"toolGroup\" && lastGroup.isActive);\n\n return (\n <div className=\"devic-messages-container\" ref={containerRef}>\n {messages.length === 0 &&\n !isLoading &&\n (welcomeMessage || suggestedMessages?.length) && (\n <div className=\"devic-welcome\">\n {welcomeMessage && (\n <p className=\"devic-welcome-text\">{welcomeMessage}</p>\n )}\n {suggestedMessages && suggestedMessages.length > 0 && (\n <div className=\"devic-suggested-messages\">\n {suggestedMessages.map((msg, idx) => {\n const isObject = typeof msg === \"object\" && msg !== null;\n const content = isObject ? (msg as SuggestedMessage).content : msg;\n const message = isObject ? (msg as SuggestedMessage).message : (msg as string);\n return (\n <button\n key={idx}\n className=\"devic-suggested-btn\"\n onClick={() => onSuggestedClick?.(message)}\n >\n {content}\n </button>\n );\n })}\n </div>\n )}\n </div>\n )}\n\n {grouped.map((item) => {\n if (item.type === \"toolGroup\") {\n const groupRecalls = recallsFor(\n item.toolMessages.map((m) => m.uid)\n );\n return (\n <React.Fragment key={`tg-${item.toolMessages[0].uid}`}>\n <ToolGroup\n toolMessages={item.toolMessages}\n isActive={item.isActive}\n allMessages={allMessages}\n toolRenderers={toolRenderers}\n toolIcons={toolIcons}\n toolGroups={toolGroups}\n handedOffSubThreadId={handedOffSubThreadId}\n onHandoffCompleted={onHandoffCompleted}\n handoffWidgetRenderer={handoffWidgetRenderer}\n apiKey={apiKey}\n baseUrl={baseUrl}\n pollingInterval={pollingInterval}\n />\n {groupRecalls.length > 0 && (\n <RecalledMemoriesWidget\n records={groupRecalls}\n isLoading={isLoading}\n renderer={recalledMemoriesRenderer}\n />\n )}\n </React.Fragment>\n );\n }\n\n const message = item.message;\n const rawText = message.content?.message;\n const hasFiles =\n message.content?.files && message.content.files.length > 0;\n const isAssistant = message.role === \"assistant\";\n const currentFeedback = feedbackMap?.get(message.uid) || \"none\";\n\n // Extract reference chips from user messages (sent by AIElementWrapper).\n // The ChatDrawer prefixes user messages with:\n // Elemento referenciado: \"label1\", \"label2\"\\n\\n<actual message>\n // We render the labels as chips and only display the actual message\n // text inside the bubble.\n const parsed = !isAssistant && rawText\n ? parseReferencedPrefix(rawText)\n : null;\n const messageText = parsed ? parsed.cleanContent : rawText;\n const refLabels = parsed ? parsed.references : [];\n\n // Long pasted text travels inside the message but is shown as a card,\n // so the bubble renders what the user actually typed. Runs after the\n // reference prefix, which ChatDrawer prepends to the composed message.\n const pasted = !isAssistant && messageText\n ? parsePastedBlocks(messageText)\n : null;\n const bodyText = pasted ? pasted.cleanContent : messageText;\n const pastedBlocks = pasted ? pasted.blocks : [];\n\n // A custom bubble renderer (per role) fully replaces the default\n // markdown rendering of the message text.\n const bubbleRenderer = isAssistant\n ? assistantMessageRenderer\n : userMessageRenderer;\n\n const messageRecalls = recallsFor([message.uid]);\n\n return (\n <React.Fragment key={message.uid}>\n <div\n className=\"devic-message\"\n data-role={message.role}\n // Accepted but not seen by the model yet. Drawn as a message that\n // has not landed, so it is not mistaken for something the assistant\n // has already read.\n data-queued={message.queued ? 'true' : undefined}\n >\n {refLabels.length > 0 && (\n <div className=\"devic-message-references\">\n {refLabels.map((lbl, i) => (\n <ReferenceChip key={i} label={lbl} variant=\"message\" />\n ))}\n </div>\n )}\n <div className=\"devic-message-bubble\">\n {pastedBlocks.length > 0 && (\n <div className=\"devic-message-pasted\">\n {pastedBlocks.map((block) => (\n <PastedBlockCard key={block.id} block={block} />\n ))}\n </div>\n )}\n {bodyText ? (\n bubbleRenderer ? (\n bubbleRenderer({\n message,\n content: bodyText,\n role: isAssistant ? \"assistant\" : \"user\",\n references: refLabels,\n })\n ) : (\n <Markdown options={{ overrides: markdownOverrides }}>\n {bodyText}\n </Markdown>\n )\n ) : null}\n {hasFiles && (\n <div className=\"devic-message-files\">\n {message.content!.files!.map((raw, fileIdx) => {\n const file = normalizeMessageFile(raw);\n return file.type === \"image\" && file.url ? (\n <a\n key={fileIdx}\n className=\"devic-message-file-image\"\n href={file.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n <img src={file.url} alt={file.name} />\n </a>\n ) : (\n <div key={fileIdx} className=\"devic-message-file\">\n <FileIcon />\n <span>{file.name}</span>\n </div>\n );\n })}\n </div>\n )}\n {!isAssistant && message.transcriptId && (\n <TranscriptPlayback\n transcriptId={message.transcriptId}\n apiKey={apiKey}\n baseUrl={baseUrl}\n />\n )}\n </div>\n <div className=\"devic-message-footer\">\n {message.queued && (\n <span className=\"devic-message-queued-label\">\n <QueuedIcon />\n Queued\n </span>\n )}\n <span className=\"devic-message-time\">\n {formatTime(message.timestamp)}\n </span>\n {isAssistant && showFeedback && onFeedback && (\n <MessageActions\n messageId={message.uid}\n messageContent={messageText}\n currentFeedback={currentFeedback as FeedbackState}\n onFeedback={onFeedback}\n showCopy={true}\n showFeedback={true}\n />\n )}\n </div>\n </div>\n {messageRecalls.length > 0 && (\n <RecalledMemoriesWidget\n records={messageRecalls}\n isLoading={isLoading}\n renderer={recalledMemoriesRenderer}\n />\n )}\n </React.Fragment>\n );\n })}\n\n {/* Recall events whose anchor message has not landed yet — shown while\n the run is in flight so the user sees what the assistant recalled\n before the first response arrives. */}\n {isLoading && pendingRecalls.length > 0 && (\n <RecalledMemoriesWidget\n records={pendingRecalls}\n isLoading={isLoading}\n renderer={recalledMemoriesRenderer}\n />\n )}\n\n {pendingInlineWidgets && pendingInlineWidgets.length > 0 && (\n <div className=\"devic-inline-widgets\">\n {pendingInlineWidgets.map((wc) => {\n const WidgetComponent = wc.widget.component;\n return (\n <div\n key={wc.toolCall.id}\n className=\"devic-inline-widget\"\n data-tool-name={wc.toolName}\n >\n <WidgetComponent\n toolCall={wc.toolCall}\n params={wc.params}\n submit={(response) => onSubmitWidget?.(wc.toolCall.id, response)}\n cancel={(reason) => onCancelWidget?.(wc.toolCall.id, reason)}\n />\n </div>\n );\n })}\n </div>\n )}\n\n {showLoadingDots &&\n (loadingIndicator ? (\n <div className=\"devic-loading\">{loadingIndicator}</div>\n ) : (\n <div className=\"devic-loading\">\n <span className=\"devic-loading-dot\"></span>\n <span className=\"devic-loading-dot\"></span>\n <span className=\"devic-loading-dot\"></span>\n </div>\n ))}\n </div>\n );\n}\n\n/* ── Icons ── */\n\nfunction SpinnerIcon(): JSX.Element {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n className=\"devic-spinner\"\n >\n <path d=\"M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83\" />\n </svg>\n );\n}\n\nfunction ToolDoneIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"20,6 9,17 4,12\" />\n </svg>\n );\n}\n\nfunction ChevronDownIcon(): JSX.Element {\n return (\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"6,9 12,15 18,9\" />\n </svg>\n );\n}\n\nfunction ChevronUpIcon(): JSX.Element {\n return (\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"6,15 12,9 18,15\" />\n </svg>\n );\n}\n\n/** Small clock on a queued bubble's footer. */\nfunction QueuedIcon(): JSX.Element {\n return (\n <svg\n width=\"11\"\n height=\"11\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"9\" />\n <polyline points=\"12 7 12 12 15 14\" />\n </svg>\n );\n}\n\nfunction FileIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z\" />\n <polyline points=\"14,2 14,8 20,8\" />\n </svg>\n );\n}\n\n/**\n * Extracts the \"Elemento referenciado: ...\" prefix that ChatDrawer prepends\n * to user messages when AIElementWrapper references are active. Returns the\n * parsed labels and the message text without the prefix. Returns null when\n * the content does not start with the prefix.\n */\nconst REFERENCE_PREFIX_RE =\n /^Elemento referenciado: ((?:\"[^\"]+\")(?:, \"[^\"]+\")*)\\n\\n([\\s\\S]*)$/;\n\nfunction parseReferencedPrefix(\n content: string\n): { references: string[]; cleanContent: string } | null {\n const m = content.match(REFERENCE_PREFIX_RE);\n if (!m) return null;\n const labels = (m[1].match(/\"([^\"]+)\"/g) || []).map((s) =>\n s.slice(1, -1)\n );\n return { references: labels, cleanContent: m[2] };\n}\n\n/**\n * A block of pasted text inside a sent message: collapsed to a card by default,\n * expandable to read the whole thing without leaving the thread.\n */\nfunction PastedBlockCard({ block }: { block: PastedText }): JSX.Element {\n const [expanded, setExpanded] = useState(false);\n\n return (\n <div className=\"devic-pasted-card\" data-expanded={expanded ? \"true\" : \"false\"}>\n <button\n type=\"button\"\n className=\"devic-pasted-card-toggle\"\n onClick={() => setExpanded((prev) => !prev)}\n aria-expanded={expanded}\n >\n {expanded ? (\n <pre className=\"devic-pasted-card-full\">{block.text}</pre>\n ) : (\n <p className=\"devic-pasted-card-preview\">{pastedPreview(block.text)}</p>\n )}\n <span className=\"devic-pasted-card-footer\">\n <span className=\"devic-pasted-card-badge\">PASTED</span>\n <span className=\"devic-pasted-card-meta\">\n {pastedLineCount(block.text)} lines · {expanded ? \"collapse\" : \"expand\"}\n </span>\n </span>\n </button>\n </div>\n );\n}\n"],"names":["_jsxs","_jsx","_Fragment"],"mappings":";;;;;;;;;;;;;AAqBA;AACA;AACA;AACA;AACA;AACA,MAAM,qBAAqB,GAAG,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AAS,EAAC,mBAAmB,mBAAgB,QAAQ,GAAG,MAAM,GAAG,OAAO,EAAA,QAAA,EAC3ED,IAAA,CAAA,QAAA,EAAA,EACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,0BAA0B,EACpC,OAAO,EAAE,MAAM,WAAW,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,EAAA,eAAA,EAC5B,QAAQ,EAAA,QAAA,EAAA,CAEtB,QAAQ,IACPC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,wBAAwB,EAAA,QAAA,EAAE,KAAK,CAAC,IAAI,GAAO,KAE1DA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,2BAA2B,EAAA,QAAA,EAAE,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAA,CAAK,CACzE,EACDD,IAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,0BAA0B,EAAA,QAAA,EAAA,CACxCC,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,yBAAyB,uBAAc,EACvDD,IAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,wBAAwB,EAAA,QAAA,EAAA,CACrC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAA,gBAAA,EAAW,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAA,EAAA,CAClE,CAAA,EAAA,CACF,CAAA,EAAA,CACA,EAAA,CACL;AAEV;;"}
|
|
1
|
+
{"version":3,"file":"ChatMessages.js","sources":["../../../../src/components/ChatDrawer/ChatMessages.tsx"],"sourcesContent":["import React, { useState, useEffect, useMemo, useRef } from \"react\";\nimport { useOptionalDevicContext } from \"../../provider\";\nimport Markdown from \"markdown-to-jsx\";\nimport { MessageActions } from \"../Feedback\";\nimport { HandoffSubagentWidget } from \"./HandoffSubagentWidget\";\nimport { ReferenceChip } from \"./ReferenceChip\";\nimport { RecalledMemoriesWidget } from \"./RecalledMemoriesWidget\";\nimport { CompactionWidget } from \"./CompactionWidget\";\nimport type { ChatMessagesProps, SuggestedMessage } from \"./ChatDrawer.types\";\nimport type { ChatMessage, CompactionCheckpoint, RecalledMemoryRecord, ToolGroupConfig, ToolGroupCall } from \"../../api/types\";\nimport { normalizeMessageFile } from \"../../api/types\";\nimport type { FeedbackState } from \"../Feedback\";\nimport { segmentToolCalls } from \"../../utils/toolGroups\";\nimport { DevicApiClient } from \"../../api/client\";\nimport {\n parsePastedBlocks,\n pastedPreview,\n pastedLineCount,\n type PastedText,\n} from \"./pastedText\";\nimport \"../Feedback/Feedback.css\";\n\n// Backend finalizer tool for assistants configured with \"Require Tool Use to\n// Finish\". It carries the final answer in its `message` argument, which the\n// backend copies to content.message, so it renders as a plain assistant bubble\n// instead of a tool activity line. Agents have a same-named tool with a\n// different shape, but their timeline does not go through this component.\nconst FINISH_EXECUTION_TOOL = \"finish_execution\";\n\n/**\n * Format timestamp to readable time\n */\nfunction formatTime(timestamp: number): string {\n return new Date(timestamp).toLocaleTimeString([], {\n hour: \"2-digit\",\n minute: \"2-digit\",\n });\n}\n\nfunction MicGlyph(): JSX.Element {\n return (\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z\" />\n <path d=\"M19 10v2a7 7 0 0 1-14 0v-2\" />\n <line x1=\"12\" y1=\"19\" x2=\"12\" y2=\"23\" />\n </svg>\n );\n}\n\nfunction PlayGlyph(): JSX.Element {\n return (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\">\n <path d=\"M8 5v14l11-7z\" />\n </svg>\n );\n}\n\nfunction PauseGlyph(): JSX.Element {\n return (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\">\n <rect x=\"6\" y=\"5\" width=\"4\" height=\"14\" rx=\"1\" />\n <rect x=\"14\" y=\"5\" width=\"4\" height=\"14\" rx=\"1\" />\n </svg>\n );\n}\n\n/**\n * Compact playback control shown on user messages that were dictated by voice\n * (i.e. carry a `transcriptId`). The source audio URL is resolved lazily on the\n * first play via GET /api/v1/whisper/:transcriptId, so listing a conversation\n * never triggers extra requests until the user actually wants to listen.\n */\nfunction TranscriptPlayback({\n transcriptId,\n apiKey,\n baseUrl,\n}: {\n transcriptId: string;\n apiKey?: string;\n baseUrl?: string;\n}): JSX.Element {\n const devicContext = useOptionalDevicContext();\n const getTenantSession = devicContext?.getTenantSession;\n const onSessionExpired = devicContext?.onSessionExpired;\n const [isPlaying, setIsPlaying] = useState(false);\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const audioUrlRef = useRef<string | null>(null);\n const audioRef = useRef<HTMLAudioElement | null>(null);\n\n useEffect(() => {\n return () => {\n if (audioRef.current) {\n audioRef.current.pause();\n audioRef.current = null;\n }\n };\n }, []);\n\n const resolveAudio = async (): Promise<HTMLAudioElement | null> => {\n if (audioRef.current) return audioRef.current;\n let url = audioUrlRef.current;\n if (!url) {\n if (!apiKey && !getTenantSession) {\n setError(\"Unavailable\");\n return null;\n }\n setIsLoading(true);\n setError(null);\n try {\n const client = new DevicApiClient({\n apiKey,\n baseUrl: baseUrl || \"https://api.devic.ai\",\n getTenantSession,\n onSessionExpired,\n });\n const transcript = await client.getTranscript(transcriptId);\n url = transcript.audioUrl || null;\n audioUrlRef.current = url;\n } catch {\n setError(\"Audio unavailable\");\n return null;\n } finally {\n setIsLoading(false);\n }\n }\n if (!url) {\n setError(\"Audio unavailable\");\n return null;\n }\n const audio = new Audio(url);\n audio.onplay = () => setIsPlaying(true);\n audio.onpause = () => setIsPlaying(false);\n audio.onended = () => setIsPlaying(false);\n audio.onerror = () => {\n setError(\"Playback failed\");\n setIsPlaying(false);\n };\n audioRef.current = audio;\n return audio;\n };\n\n const toggle = async () => {\n if (isPlaying && audioRef.current) {\n audioRef.current.pause();\n return;\n }\n const audio = await resolveAudio();\n if (audio) {\n try {\n await audio.play();\n } catch {\n setError(\"Playback failed\");\n }\n }\n };\n\n return (\n <div\n className=\"devic-transcript-playback\"\n data-playing={isPlaying ? \"true\" : \"false\"}\n title=\"Dictated by voice\"\n >\n <button\n type=\"button\"\n className=\"devic-transcript-btn\"\n onClick={toggle}\n disabled={isLoading}\n aria-label={isPlaying ? \"Pause recording\" : \"Play recording\"}\n >\n {isLoading ? (\n <span className=\"devic-transcript-spinner\" aria-hidden=\"true\" />\n ) : isPlaying ? (\n <PauseGlyph />\n ) : (\n <PlayGlyph />\n )}\n </button>\n <span className=\"devic-transcript-icon\" aria-hidden=\"true\">\n <MicGlyph />\n </span>\n <span className=\"devic-transcript-label\">\n {error || \"Voice message\"}\n </span>\n </div>\n );\n}\n\n/**\n * Groups consecutive tool-call assistant messages (no text content)\n * into { toolMessages, isActive } groups, interleaved with regular messages.\n */\nfunction groupMessages(\n messages: ChatMessage[],\n isLoading: boolean,\n): Array<\n | { type: \"message\"; message: ChatMessage }\n | { type: \"toolGroup\"; toolMessages: ChatMessage[]; isActive: boolean }\n> {\n const result: Array<\n | { type: \"message\"; message: ChatMessage }\n | { type: \"toolGroup\"; toolMessages: ChatMessage[]; isActive: boolean }\n > = [];\n\n let currentToolGroup: ChatMessage[] = [];\n\n const flushToolGroup = (isActive: boolean) => {\n if (currentToolGroup.length > 0) {\n result.push({\n type: \"toolGroup\",\n toolMessages: [...currentToolGroup],\n isActive,\n });\n currentToolGroup = [];\n }\n };\n\n for (let i = 0; i < messages.length; i++) {\n const msg = messages[i];\n\n // Skip developer, system and tool response messages\n if (msg.role === \"developer\" || msg.role === \"system\" || msg.role === \"tool\") {\n continue;\n }\n\n // `finish_execution` is not an action the assistant took, it is how the\n // backend delivers the final answer when the assistant is configured with\n // \"Require Tool Use to Finish\": the tool's `message` argument is copied to\n // content.message and rendered as the assistant bubble below. Showing it as\n // a tool activity line would just duplicate that bubble with plumbing.\n const visibleToolCalls = (msg.tool_calls || []).filter(\n (toolCall) => toolCall.function?.name !== FINISH_EXECUTION_TOOL,\n );\n const hasToolCalls = visibleToolCalls.length > 0;\n const hasText = !!msg.content?.message;\n const hasFiles = msg.content?.files && msg.content.files.length > 0;\n\n if (hasToolCalls) {\n // If message has both text and tool_calls, show text first\n if (hasText || hasFiles) {\n // Flush any prior tool group before inserting the text message\n const remainingMeaningful = messages\n .slice(i + 1)\n .some(\n (m) =>\n (m.role === \"assistant\" && m.content?.message) ||\n m.role === \"user\",\n );\n flushToolGroup(isLoading && !remainingMeaningful);\n result.push({ type: \"message\", message: msg });\n }\n // Always accumulate the tool call\n currentToolGroup.push(\n visibleToolCalls.length === msg.tool_calls!.length\n ? msg\n : { ...msg, tool_calls: visibleToolCalls },\n );\n } else {\n // Regular message → flush any accumulated tool group first\n const remainingMeaningful = messages\n .slice(i)\n .some(\n (m) =>\n (m.role === \"assistant\" && m.content?.message) || m.role === \"user\",\n );\n flushToolGroup(isLoading && !remainingMeaningful);\n\n if (hasText || hasFiles) {\n result.push({ type: \"message\", message: msg });\n }\n }\n }\n\n // Flush remaining tool group (is active if still loading)\n flushToolGroup(isLoading);\n\n return result;\n}\n\n/**\n * Collapsible tool actions group\n */\nfunction ToolGroup({\n toolMessages,\n isActive,\n allMessages,\n toolRenderers,\n toolIcons,\n toolGroups,\n handedOffSubThreadId,\n onHandoffCompleted,\n handoffWidgetRenderer,\n apiKey,\n baseUrl,\n pollingInterval,\n}: {\n toolMessages: ChatMessage[];\n isActive: boolean;\n allMessages?: ChatMessage[];\n toolRenderers?: Record<string, (input: any, output: any) => React.ReactNode>;\n toolIcons?: Record<string, React.ReactNode>;\n toolGroups?: ToolGroupConfig[];\n handedOffSubThreadId?: string;\n onHandoffCompleted?: () => void;\n handoffWidgetRenderer?: ChatMessagesProps[\"handoffWidgetRenderer\"];\n apiKey?: string;\n baseUrl?: string;\n pollingInterval?: number;\n}): JSX.Element {\n const [isCollapsed, setIsCollapsed] = useState(false);\n const shouldCollapse = toolMessages.length > 3 && !isActive;\n\n // Auto-collapse when transitioning from active to completed\n const wasActiveRef = useRef(isActive);\n useEffect(() => {\n if (wasActiveRef.current && !isActive && toolMessages.length > 3) {\n setIsCollapsed(true);\n }\n wasActiveRef.current = isActive;\n }, [isActive, toolMessages.length]);\n\n const lastIndex = toolMessages.length - 1;\n\n const renderToolItem = (\n msg: ChatMessage,\n opts: { active?: boolean; showSpinner?: boolean },\n ) => {\n const toolCall = msg.tool_calls?.[0];\n const toolName = toolCall?.function?.name;\n const summaryText =\n msg.summary || toolName || (opts.active ? \"Processing...\" : \"Completed\");\n\n // Render HandoffSubagentWidget for hand_off_subagent tool calls\n if (toolName === \"hand_off_subagent\" && toolCall && allMessages) {\n const subThreadId = extractSubThreadId(\n toolCall.id,\n allMessages,\n handedOffSubThreadId,\n );\n if (subThreadId) {\n return (\n <HandoffSubagentWidget\n subThreadId={subThreadId}\n onCompleted={onHandoffCompleted}\n renderWidget={handoffWidgetRenderer}\n apiKey={apiKey}\n baseUrl={baseUrl}\n pollingInterval={pollingInterval}\n />\n );\n }\n }\n\n // Custom renderer for completed tools\n if (!opts.active && toolName && toolRenderers?.[toolName] && allMessages) {\n const toolResponse = allMessages.find(\n (m) => m.role === \"tool\" && m.tool_call_id === toolCall!.id,\n );\n let input: any = {};\n try {\n input = JSON.parse(toolCall!.function.arguments);\n } catch {}\n const output =\n toolResponse?.content?.data ||\n toolResponse?.content?.message ||\n toolResponse?.content;\n return toolRenderers[toolName](input, output);\n }\n\n const icon = opts.showSpinner ? (\n <SpinnerIcon />\n ) : (\n (toolName && toolIcons?.[toolName]) || <ToolDoneIcon />\n );\n\n return (\n <>\n <span className=\"devic-tool-activity-icon\">{icon}</span>\n <span\n className={`devic-tool-activity-text ${opts.active ? \"devic-glow-text\" : \"\"}`}\n >\n {summaryText}\n </span>\n </>\n );\n };\n\n /** Resolve a ChatMessage into a ToolGroupCall */\n const resolveToolGroupCall = (msg: ChatMessage): ToolGroupCall | null => {\n const toolCall = msg.tool_calls?.[0];\n if (!toolCall) return null;\n const toolName = toolCall.function?.name;\n let input: any = {};\n try {\n input = JSON.parse(toolCall.function.arguments);\n } catch {}\n const toolResponse = allMessages?.find(\n (m) => m.role === \"tool\" && m.tool_call_id === toolCall.id,\n );\n const output =\n toolResponse?.content?.data ||\n toolResponse?.content?.message ||\n toolResponse?.content;\n return { name: toolName, input, output, toolCallId: toolCall.id };\n };\n\n /** Render completed tool messages, applying toolGroups segmentation when configured */\n const renderCompletedItems = (msgs: ChatMessage[]) => {\n if (!toolGroups || toolGroups.length === 0) {\n return msgs.map((msg) => (\n <div key={msg.uid} className=\"devic-tool-activity\">\n {renderToolItem(msg, {})}\n </div>\n ));\n }\n\n // Build ToolGroupCall array for completed messages\n const calls: Array<{ msg: ChatMessage; call: ToolGroupCall }> = [];\n for (const msg of msgs) {\n const call = resolveToolGroupCall(msg);\n if (call) {\n calls.push({ msg, call });\n }\n }\n\n const segments = segmentToolCalls(\n calls.map((c) => c.call),\n toolGroups,\n );\n\n const elements: React.ReactNode[] = [];\n let callIdx = 0;\n\n for (const segment of segments) {\n if (segment.type === \"group\") {\n const groupKey = segment.calls\n .map((c) => c.toolCallId)\n .join(\"-\");\n elements.push(\n <div key={`tg-group-${groupKey}`} className=\"devic-tool-activity devic-tool-activity--grouped\">\n {segment.config.renderer(segment.calls)}\n </div>,\n );\n callIdx += segment.calls.length;\n } else {\n const entry = calls[callIdx];\n elements.push(\n <div key={entry.msg.uid} className=\"devic-tool-activity\">\n {renderToolItem(entry.msg, {})}\n </div>,\n );\n callIdx += 1;\n }\n }\n\n return elements;\n };\n\n // If active, show all items; last one gets the glow treatment\n if (isActive) {\n // For active groups: render all completed items with grouping, then render the active (last) item individually\n const completedMessages = toolMessages.slice(0, lastIndex);\n const lastMsg = toolMessages[lastIndex];\n\n return (\n <div className=\"devic-tool-group\">\n {completedMessages.length > 0 && renderCompletedItems(completedMessages)}\n <div\n key={lastMsg.uid}\n className=\"devic-tool-activity devic-tool-activity--active\"\n >\n {renderToolItem(lastMsg, { active: true, showSpinner: true })}\n </div>\n </div>\n );\n }\n\n // Completed: collapse if > 3 actions\n if (shouldCollapse && isCollapsed) {\n return (\n <div className=\"devic-tool-group\">\n <button\n className=\"devic-tool-collapse-btn\"\n onClick={() => setIsCollapsed(false)}\n type=\"button\"\n >\n <ToolDoneIcon />\n <span>{toolMessages.length} actions</span>\n <ChevronDownIcon />\n </button>\n </div>\n );\n }\n\n return (\n <div className=\"devic-tool-group\">\n {shouldCollapse && (\n <button\n className=\"devic-tool-collapse-btn\"\n onClick={() => setIsCollapsed(true)}\n type=\"button\"\n >\n <span>{toolMessages.length} actions</span>\n <ChevronUpIcon />\n </button>\n )}\n <div className=\"devic-tool-group-items\" data-expanded=\"true\">\n {renderCompletedItems(toolMessages)}\n </div>\n </div>\n );\n}\n\n/**\n * Messages list component\n */\nconst markdownOverrides = {\n table: {\n component: ({ children, ...props }: any) =>\n React.createElement(\n \"div\",\n { className: \"markdown-table\" },\n React.createElement(\"table\", props, children),\n ),\n },\n};\n\n/**\n * Extract subthread ID from a hand_off_subagent tool call.\n * Checks the tool response in allMessages first, then falls back to handedOffSubThreadId.\n */\nfunction extractSubThreadId(\n toolCallId: string,\n allMessages: ChatMessage[],\n handedOffSubThreadId?: string,\n): string | null {\n // Look for the tool response message\n const toolResponse = allMessages.find(\n (m) => m.role === \"tool\" && m.tool_call_id === toolCallId,\n );\n if (toolResponse) {\n const content = toolResponse.content?.data || toolResponse.content;\n if (content && typeof content === \"object\" && \"subthreadId\" in content) {\n return (content as any).subthreadId;\n }\n if (content && typeof content === \"object\" && \"subThreadId\" in content) {\n return (content as any).subThreadId;\n }\n }\n // Fall back to active handoff subthread ID\n return handedOffSubThreadId || null;\n}\n\nexport function ChatMessages({\n messages,\n allMessages,\n isLoading,\n welcomeMessage,\n suggestedMessages,\n onSuggestedClick,\n toolRenderers,\n toolIcons,\n loadingIndicator,\n showFeedback = true,\n feedbackMap,\n onFeedback,\n handedOffSubThreadId,\n onHandoffCompleted,\n handoffWidgetRenderer,\n toolGroups,\n userMessageRenderer,\n assistantMessageRenderer,\n apiKey,\n baseUrl,\n pollingInterval,\n pendingInlineWidgets,\n onSubmitWidget,\n onCancelWidget,\n recalledMemories,\n recalledMemoriesRenderer,\n compactions,\n compaction,\n compactionRenderer,\n expandableCompaction,\n}: ChatMessagesProps): JSX.Element {\n const containerRef = useRef<HTMLDivElement>(null);\n const prevLengthRef = useRef(messages.length);\n\n // Anchor each recall record to the message that brought it in: the\n // assistant message carrying its memory tool call (toolCallId), or the\n // message the backend named (messageUid — matched against serverUid too,\n // since user messages may render under an adopted optimistic uid). Records\n // whose anchor is not on screen yet (the run is still producing it) go to\n // the pending group shown at the bottom while loading.\n const { recallsByAnchor, pendingRecalls } = useMemo(() => {\n const byAnchor = new Map<string, RecalledMemoryRecord[]>();\n const pending: RecalledMemoryRecord[] = [];\n for (const record of recalledMemories ?? []) {\n let anchor: string | undefined;\n if (record.toolCallId) {\n anchor = messages.find((m) =>\n m.tool_calls?.some((tc) => tc.id === record.toolCallId)\n )?.uid;\n }\n if (!anchor && record.messageUid) {\n anchor = messages.find(\n (m) =>\n m.uid === record.messageUid || m.serverUid === record.messageUid\n )?.uid;\n }\n if (anchor) {\n const list = byAnchor.get(anchor);\n if (list) list.push(record);\n else byAnchor.set(anchor, [record]);\n } else {\n pending.push(record);\n }\n }\n return { recallsByAnchor: byAnchor, pendingRecalls: pending };\n }, [recalledMemories, messages]);\n\n // The strip renders after the message (or tool group) that anchors it.\n const recallsFor = (uids: string[]): RecalledMemoryRecord[] =>\n uids.flatMap((uid) => recallsByAnchor.get(uid) ?? []);\n\n // Compaction checkpoints, keyed by the LAST message each one folded: the\n // point where the assistant's view of the conversation stops. A checkpoint\n // whose anchor is not on screen (it folded messages this client never\n // loaded) is drawn at the top instead, so the cut is never invisible.\n const { compactionsByAnchor, orphanCompactions, activeCompactionUid } =\n useMemo(() => {\n const byAnchor = new Map<string, CompactionCheckpoint[]>();\n const orphans: CompactionCheckpoint[] = [];\n for (const checkpoint of compactions ?? []) {\n const anchor = checkpoint.anchorMessageUid\n ? messages.find(\n (m) =>\n m.uid === checkpoint.anchorMessageUid ||\n m.serverUid === checkpoint.anchorMessageUid\n )?.uid\n : undefined;\n if (anchor) {\n const list = byAnchor.get(anchor);\n if (list) list.push(checkpoint);\n else byAnchor.set(anchor, [checkpoint]);\n } else {\n orphans.push(checkpoint);\n }\n }\n // Only the newest checkpoint governs the context: each compaction\n // merges the previous summary into itself.\n const active = (compactions ?? []).reduce<CompactionCheckpoint | null>(\n (latest, candidate) =>\n !latest || candidate.index > latest.index ? candidate : latest,\n null\n );\n return {\n compactionsByAnchor: byAnchor,\n orphanCompactions: orphans,\n activeCompactionUid: active?.uid,\n };\n }, [compactions, messages]);\n\n const compactionsFor = (uids: string[]): CompactionCheckpoint[] =>\n uids.flatMap((uid) => compactionsByAnchor.get(uid) ?? []);\n\n const renderCompactions = (checkpoints: CompactionCheckpoint[]) =>\n checkpoints.map((checkpoint) => (\n <CompactionWidget\n key={checkpoint.uid}\n checkpoint={checkpoint}\n isActive={checkpoint.uid === activeCompactionUid}\n renderer={compactionRenderer}\n expandable={expandableCompaction}\n />\n ));\n\n // Auto-scroll to bottom when new messages arrive\n useEffect(() => {\n if (containerRef.current) {\n containerRef.current.scrollTop = containerRef.current.scrollHeight;\n }\n prevLengthRef.current = messages.length;\n }, [messages.length, isLoading]);\n\n const grouped = groupMessages(messages, isLoading);\n\n // Show loading dots only if there's no active tool group at the end\n const lastGroup = grouped[grouped.length - 1];\n const showLoadingDots =\n isLoading && !(lastGroup?.type === \"toolGroup\" && lastGroup.isActive);\n\n return (\n <div className=\"devic-messages-container\" ref={containerRef}>\n {messages.length === 0 &&\n !isLoading &&\n (welcomeMessage || suggestedMessages?.length) && (\n <div className=\"devic-welcome\">\n {welcomeMessage && (\n <p className=\"devic-welcome-text\">{welcomeMessage}</p>\n )}\n {suggestedMessages && suggestedMessages.length > 0 && (\n <div className=\"devic-suggested-messages\">\n {suggestedMessages.map((msg, idx) => {\n const isObject = typeof msg === \"object\" && msg !== null;\n const content = isObject ? (msg as SuggestedMessage).content : msg;\n const message = isObject ? (msg as SuggestedMessage).message : (msg as string);\n return (\n <button\n key={idx}\n className=\"devic-suggested-btn\"\n onClick={() => onSuggestedClick?.(message)}\n >\n {content}\n </button>\n );\n })}\n </div>\n )}\n </div>\n )}\n\n {grouped.map((item) => {\n if (item.type === \"toolGroup\") {\n const groupRecalls = recallsFor(\n item.toolMessages.map((m) => m.uid)\n );\n const groupCompactions = compactionsFor(\n item.toolMessages.map((m) => m.uid)\n );\n return (\n <React.Fragment key={`tg-${item.toolMessages[0].uid}`}>\n <ToolGroup\n toolMessages={item.toolMessages}\n isActive={item.isActive}\n allMessages={allMessages}\n toolRenderers={toolRenderers}\n toolIcons={toolIcons}\n toolGroups={toolGroups}\n handedOffSubThreadId={handedOffSubThreadId}\n onHandoffCompleted={onHandoffCompleted}\n handoffWidgetRenderer={handoffWidgetRenderer}\n apiKey={apiKey}\n baseUrl={baseUrl}\n pollingInterval={pollingInterval}\n />\n {groupRecalls.length > 0 && (\n <RecalledMemoriesWidget\n records={groupRecalls}\n isLoading={isLoading}\n renderer={recalledMemoriesRenderer}\n />\n )}\n {renderCompactions(groupCompactions)}\n </React.Fragment>\n );\n }\n\n const message = item.message;\n const rawText = message.content?.message;\n const hasFiles =\n message.content?.files && message.content.files.length > 0;\n const isAssistant = message.role === \"assistant\";\n const currentFeedback = feedbackMap?.get(message.uid) || \"none\";\n\n // Extract reference chips from user messages (sent by AIElementWrapper).\n // The ChatDrawer prefixes user messages with:\n // Elemento referenciado: \"label1\", \"label2\"\\n\\n<actual message>\n // We render the labels as chips and only display the actual message\n // text inside the bubble.\n const parsed = !isAssistant && rawText\n ? parseReferencedPrefix(rawText)\n : null;\n const messageText = parsed ? parsed.cleanContent : rawText;\n const refLabels = parsed ? parsed.references : [];\n\n // Long pasted text travels inside the message but is shown as a card,\n // so the bubble renders what the user actually typed. Runs after the\n // reference prefix, which ChatDrawer prepends to the composed message.\n const pasted = !isAssistant && messageText\n ? parsePastedBlocks(messageText)\n : null;\n const bodyText = pasted ? pasted.cleanContent : messageText;\n const pastedBlocks = pasted ? pasted.blocks : [];\n\n // A custom bubble renderer (per role) fully replaces the default\n // markdown rendering of the message text.\n const bubbleRenderer = isAssistant\n ? assistantMessageRenderer\n : userMessageRenderer;\n\n const messageRecalls = recallsFor([message.uid]);\n const messageCompactions = compactionsFor([message.uid]);\n\n return (\n <React.Fragment key={message.uid}>\n <div\n className=\"devic-message\"\n data-role={message.role}\n // Accepted but not seen by the model yet. Drawn as a message that\n // has not landed, so it is not mistaken for something the assistant\n // has already read.\n data-queued={message.queued ? 'true' : undefined}\n >\n {refLabels.length > 0 && (\n <div className=\"devic-message-references\">\n {refLabels.map((lbl, i) => (\n <ReferenceChip key={i} label={lbl} variant=\"message\" />\n ))}\n </div>\n )}\n <div className=\"devic-message-bubble\">\n {pastedBlocks.length > 0 && (\n <div className=\"devic-message-pasted\">\n {pastedBlocks.map((block) => (\n <PastedBlockCard key={block.id} block={block} />\n ))}\n </div>\n )}\n {bodyText ? (\n bubbleRenderer ? (\n bubbleRenderer({\n message,\n content: bodyText,\n role: isAssistant ? \"assistant\" : \"user\",\n references: refLabels,\n })\n ) : (\n <Markdown options={{ overrides: markdownOverrides }}>\n {bodyText}\n </Markdown>\n )\n ) : null}\n {hasFiles && (\n <div className=\"devic-message-files\">\n {message.content!.files!.map((raw, fileIdx) => {\n const file = normalizeMessageFile(raw);\n return file.type === \"image\" && file.url ? (\n <a\n key={fileIdx}\n className=\"devic-message-file-image\"\n href={file.url}\n target=\"_blank\"\n rel=\"noreferrer\"\n >\n <img src={file.url} alt={file.name} />\n </a>\n ) : (\n <div key={fileIdx} className=\"devic-message-file\">\n <FileIcon />\n <span>{file.name}</span>\n </div>\n );\n })}\n </div>\n )}\n {!isAssistant && message.transcriptId && (\n <TranscriptPlayback\n transcriptId={message.transcriptId}\n apiKey={apiKey}\n baseUrl={baseUrl}\n />\n )}\n </div>\n <div className=\"devic-message-footer\">\n {message.queued && (\n <span className=\"devic-message-queued-label\">\n <QueuedIcon />\n Queued\n </span>\n )}\n <span className=\"devic-message-time\">\n {formatTime(message.timestamp)}\n </span>\n {isAssistant && showFeedback && onFeedback && (\n <MessageActions\n messageId={message.uid}\n messageContent={messageText}\n currentFeedback={currentFeedback as FeedbackState}\n onFeedback={onFeedback}\n showCopy={true}\n showFeedback={true}\n />\n )}\n </div>\n </div>\n {messageRecalls.length > 0 && (\n <RecalledMemoriesWidget\n records={messageRecalls}\n isLoading={isLoading}\n renderer={recalledMemoriesRenderer}\n />\n )}\n {renderCompactions(messageCompactions)}\n </React.Fragment>\n );\n })}\n\n {/* Recall events whose anchor message has not landed yet — shown while\n the run is in flight so the user sees what the assistant recalled\n before the first response arrives. */}\n {isLoading && pendingRecalls.length > 0 && (\n <RecalledMemoriesWidget\n records={pendingRecalls}\n isLoading={isLoading}\n renderer={recalledMemoriesRenderer}\n />\n )}\n\n {/* Checkpoints whose anchor message is not on screen — this client only\n loaded the messages that still travel, so the cut has nowhere to sit\n in the thread. Shown here rather than dropped: the conversation is\n shorter than it looks, and that is worth saying. */}\n {renderCompactions(orphanCompactions)}\n\n {/* A compaction being written right now. It is a model call of its own,\n taken between two assistant messages, so without this the\n conversation simply appears to have gone quiet. */}\n {compaction?.state === \"running\" && (\n <CompactionWidget\n checkpoint={null}\n activity={compaction}\n renderer={compactionRenderer}\n />\n )}\n\n {pendingInlineWidgets && pendingInlineWidgets.length > 0 && (\n <div className=\"devic-inline-widgets\">\n {pendingInlineWidgets.map((wc) => {\n const WidgetComponent = wc.widget.component;\n return (\n <div\n key={wc.toolCall.id}\n className=\"devic-inline-widget\"\n data-tool-name={wc.toolName}\n >\n <WidgetComponent\n toolCall={wc.toolCall}\n params={wc.params}\n submit={(response) => onSubmitWidget?.(wc.toolCall.id, response)}\n cancel={(reason) => onCancelWidget?.(wc.toolCall.id, reason)}\n />\n </div>\n );\n })}\n </div>\n )}\n\n {showLoadingDots &&\n (loadingIndicator ? (\n <div className=\"devic-loading\">{loadingIndicator}</div>\n ) : (\n <div className=\"devic-loading\">\n <span className=\"devic-loading-dot\"></span>\n <span className=\"devic-loading-dot\"></span>\n <span className=\"devic-loading-dot\"></span>\n </div>\n ))}\n </div>\n );\n}\n\n/* ── Icons ── */\n\nfunction SpinnerIcon(): JSX.Element {\n return (\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n className=\"devic-spinner\"\n >\n <path d=\"M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83\" />\n </svg>\n );\n}\n\nfunction ToolDoneIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"20,6 9,17 4,12\" />\n </svg>\n );\n}\n\nfunction ChevronDownIcon(): JSX.Element {\n return (\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"6,9 12,15 18,9\" />\n </svg>\n );\n}\n\nfunction ChevronUpIcon(): JSX.Element {\n return (\n <svg\n width=\"12\"\n height=\"12\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <polyline points=\"6,15 12,9 18,15\" />\n </svg>\n );\n}\n\n/** Small clock on a queued bubble's footer. */\nfunction QueuedIcon(): JSX.Element {\n return (\n <svg\n width=\"11\"\n height=\"11\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden=\"true\"\n >\n <circle cx=\"12\" cy=\"12\" r=\"9\" />\n <polyline points=\"12 7 12 12 15 14\" />\n </svg>\n );\n}\n\nfunction FileIcon(): JSX.Element {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z\" />\n <polyline points=\"14,2 14,8 20,8\" />\n </svg>\n );\n}\n\n/**\n * Extracts the \"Elemento referenciado: ...\" prefix that ChatDrawer prepends\n * to user messages when AIElementWrapper references are active. Returns the\n * parsed labels and the message text without the prefix. Returns null when\n * the content does not start with the prefix.\n */\nconst REFERENCE_PREFIX_RE =\n /^Elemento referenciado: ((?:\"[^\"]+\")(?:, \"[^\"]+\")*)\\n\\n([\\s\\S]*)$/;\n\nfunction parseReferencedPrefix(\n content: string\n): { references: string[]; cleanContent: string } | null {\n const m = content.match(REFERENCE_PREFIX_RE);\n if (!m) return null;\n const labels = (m[1].match(/\"([^\"]+)\"/g) || []).map((s) =>\n s.slice(1, -1)\n );\n return { references: labels, cleanContent: m[2] };\n}\n\n/**\n * A block of pasted text inside a sent message: collapsed to a card by default,\n * expandable to read the whole thing without leaving the thread.\n */\nfunction PastedBlockCard({ block }: { block: PastedText }): JSX.Element {\n const [expanded, setExpanded] = useState(false);\n\n return (\n <div className=\"devic-pasted-card\" data-expanded={expanded ? \"true\" : \"false\"}>\n <button\n type=\"button\"\n className=\"devic-pasted-card-toggle\"\n onClick={() => setExpanded((prev) => !prev)}\n aria-expanded={expanded}\n >\n {expanded ? (\n <pre className=\"devic-pasted-card-full\">{block.text}</pre>\n ) : (\n <p className=\"devic-pasted-card-preview\">{pastedPreview(block.text)}</p>\n )}\n <span className=\"devic-pasted-card-footer\">\n <span className=\"devic-pasted-card-badge\">PASTED</span>\n <span className=\"devic-pasted-card-meta\">\n {pastedLineCount(block.text)} lines · {expanded ? \"collapse\" : \"expand\"}\n </span>\n </span>\n </button>\n </div>\n );\n}\n"],"names":["_jsxs","_jsx","_Fragment"],"mappings":";;;;;;;;;;;;;;AAsBA;AACA;AACA;AACA;AACA;AACA,MAAM,qBAAqB,GAAG,kBAAkB;AAEhD;;AAEG;AACH,SAAS,UAAU,CAAC,SAAiB,EAAA;IACnC,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,EAAE,EAAE;AAChD,QAAA,IAAI,EAAE,SAAS;AACf,QAAA,MAAM,EAAE,SAAS;AAClB,KAAA,CAAC;AACJ;AAEA,SAAS,QAAQ,GAAA;AACf,IAAA,QACEA,IAAA,CAAA,KAAA,EAAA,EACE,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,EACrB,cAAc,EAAC,OAAO,EAAA,aAAA,EACV,MAAM,EAAA,QAAA,EAAA,CAElBC,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,sDAAsD,EAAA,CAAG,EACjEA,GAAA,CAAA,MAAA,EAAA,EAAM,CAAC,EAAC,4BAA4B,EAAA,CAAG,EACvCA,cAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,CAAA,EAA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AE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;IAE/C,QACEA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,mBAAmB,mBAAgB,QAAQ,GAAG,MAAM,GAAG,OAAO,EAAA,QAAA,EAC3ED,IAAA,CAAA,QAAA,EAAA,EACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,0BAA0B,EACpC,OAAO,EAAE,MAAM,WAAW,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,EAAA,eAAA,EAC5B,QAAQ,EAAA,QAAA,EAAA,CAEtB,QAAQ,IACPC,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,wBAAwB,EAAA,QAAA,EAAE,KAAK,CAAC,IAAI,GAAO,KAE1DA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,2BAA2B,EAAA,QAAA,EAAE,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,EAAA,CAAK,CACzE,EACDD,IAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,0BAA0B,EAAA,QAAA,EAAA,CACxCC,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,yBAAyB,uBAAc,EACvDD,IAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,wBAAwB,EAAA,QAAA,EAAA,CACrC,eAAe,CAAC,KAAK,CAAC,IAAI,CAAC,EAAA,gBAAA,EAAW,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAA,EAAA,CAClE,CAAA,EAAA,CACF,CAAA,EAAA,CACA,EAAA,CACL;AAEV;;"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type JSX, type ReactNode } from "react";
|
|
2
|
+
import type { CompactionActivity, CompactionCheckpoint } from "../../api/types";
|
|
3
|
+
/** Data handed to a custom compaction renderer. */
|
|
4
|
+
export interface CompactionRendererProps {
|
|
5
|
+
/**
|
|
6
|
+
* The checkpoint at this point of the conversation. Null while a compaction
|
|
7
|
+
* is being written and there is nothing to show yet.
|
|
8
|
+
*/
|
|
9
|
+
checkpoint: CompactionCheckpoint | null;
|
|
10
|
+
/**
|
|
11
|
+
* True for the checkpoint that currently governs the context. Each
|
|
12
|
+
* compaction merges the previous summary into itself, so the earlier ones
|
|
13
|
+
* are a record rather than something still being sent.
|
|
14
|
+
*/
|
|
15
|
+
isActive: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The compaction happening right now, or null. Present without a checkpoint
|
|
18
|
+
* means one is being written; the numbers say what it is folding.
|
|
19
|
+
*/
|
|
20
|
+
activity: CompactionActivity | null;
|
|
21
|
+
}
|
|
22
|
+
/** Replaces the built-in compaction marker. Return null to hide it. */
|
|
23
|
+
export type CompactionRenderer = (props: CompactionRendererProps) => ReactNode;
|
|
24
|
+
export interface CompactionWidgetProps {
|
|
25
|
+
checkpoint: CompactionCheckpoint | null;
|
|
26
|
+
isActive?: boolean;
|
|
27
|
+
activity?: CompactionActivity | null;
|
|
28
|
+
renderer?: CompactionRenderer;
|
|
29
|
+
/**
|
|
30
|
+
* Lets the reader open the checkpoint and read what it says.
|
|
31
|
+
*
|
|
32
|
+
* Off by default, because what opens is not metadata: it is a model-written
|
|
33
|
+
* account of the conversation — its goal, the decisions taken and why, what
|
|
34
|
+
* is still pending, and the identifiers lifted out of it verbatim. That is
|
|
35
|
+
* the right thing to put in front of an operator and the wrong thing to put
|
|
36
|
+
* in front of the customer the conversation is with, so the closed form is
|
|
37
|
+
* the default and opening it is a decision the host makes.
|
|
38
|
+
*
|
|
39
|
+
* Collapsed it still says a compaction happened and how much it folded:
|
|
40
|
+
* hiding that would misrepresent the conversation, which is the opposite of
|
|
41
|
+
* the point.
|
|
42
|
+
*/
|
|
43
|
+
expandable?: boolean;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The cut line in the conversation.
|
|
47
|
+
*
|
|
48
|
+
* Anchored to the last message a checkpoint folded, it marks the exact point
|
|
49
|
+
* where the assistant's view of the conversation stops: everything above it
|
|
50
|
+
* is still here, still readable, and no longer sent. It is a rule across the
|
|
51
|
+
* thread with the headline numbers, and — where the host opts in with
|
|
52
|
+
* `expandable` — it opens to show what the assistant reads in place of those
|
|
53
|
+
* messages.
|
|
54
|
+
*
|
|
55
|
+
* With no checkpoint yet and a compaction in flight it says so instead — that
|
|
56
|
+
* is a model call of its own, and without it the conversation just appears to
|
|
57
|
+
* have gone quiet.
|
|
58
|
+
*
|
|
59
|
+
* Deliberately not a message bubble: a checkpoint is not something anyone
|
|
60
|
+
* said.
|
|
61
|
+
*/
|
|
62
|
+
export declare function CompactionWidget({ checkpoint, isActive, activity, renderer, expandable, }: CompactionWidgetProps): JSX.Element | null;
|
|
63
|
+
export default CompactionWidget;
|