@pyxis-llm/react 0.0.0-stage → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/dist/AgentProfileEditor.d.ts +48 -0
  2. package/dist/AgentProfileEditor.d.ts.map +1 -0
  3. package/dist/AgentProfileEditor.js +122 -0
  4. package/dist/AgentProfileList.d.ts +17 -0
  5. package/dist/AgentProfileList.d.ts.map +1 -0
  6. package/dist/AgentProfileList.js +46 -0
  7. package/dist/AskCardAnswerChip.d.ts +8 -0
  8. package/dist/AskCardAnswerChip.d.ts.map +1 -0
  9. package/dist/AskCardAnswerChip.js +21 -0
  10. package/dist/AskCardView.d.ts +85 -0
  11. package/dist/AskCardView.d.ts.map +1 -0
  12. package/dist/AskCardView.js +158 -0
  13. package/dist/CatalogColumnBrowser.d.ts +33 -0
  14. package/dist/CatalogColumnBrowser.d.ts.map +1 -0
  15. package/dist/CatalogColumnBrowser.js +219 -0
  16. package/dist/CatalogModelPicker.d.ts +68 -0
  17. package/dist/CatalogModelPicker.d.ts.map +1 -0
  18. package/dist/CatalogModelPicker.js +119 -0
  19. package/dist/CatalogModelPickerMenuContent.d.ts +17 -0
  20. package/dist/CatalogModelPickerMenuContent.d.ts.map +1 -0
  21. package/dist/CatalogModelPickerMenuContent.js +103 -0
  22. package/dist/CatalogPickerMenuItem.d.ts +17 -0
  23. package/dist/CatalogPickerMenuItem.d.ts.map +1 -0
  24. package/dist/CatalogPickerMenuItem.js +15 -0
  25. package/dist/CatalogTreePickerOptions.d.ts +52 -0
  26. package/dist/CatalogTreePickerOptions.d.ts.map +1 -0
  27. package/dist/CatalogTreePickerOptions.js +248 -0
  28. package/dist/ChatMessage.d.ts +172 -0
  29. package/dist/ChatMessage.d.ts.map +1 -0
  30. package/dist/ChatMessage.js +295 -0
  31. package/dist/ChatPanel.d.ts +252 -0
  32. package/dist/ChatPanel.d.ts.map +1 -0
  33. package/dist/ChatPanel.js +247 -0
  34. package/dist/ChatTranscriptFind.d.ts +19 -0
  35. package/dist/ChatTranscriptFind.d.ts.map +1 -0
  36. package/dist/ChatTranscriptFind.js +224 -0
  37. package/dist/ChatTranscriptFindBar.d.ts +15 -0
  38. package/dist/ChatTranscriptFindBar.d.ts.map +1 -0
  39. package/dist/ChatTranscriptFindBar.js +22 -0
  40. package/dist/Composer.d.ts +43 -0
  41. package/dist/Composer.d.ts.map +1 -0
  42. package/dist/Composer.js +45 -0
  43. package/dist/ComposerAttachments.d.ts +101 -0
  44. package/dist/ComposerAttachments.d.ts.map +1 -0
  45. package/dist/ComposerAttachments.js +126 -0
  46. package/dist/DisplayCards.d.ts +18 -0
  47. package/dist/DisplayCards.d.ts.map +1 -0
  48. package/dist/DisplayCards.js +72 -0
  49. package/dist/ErrorBoundary.d.ts +27 -0
  50. package/dist/ErrorBoundary.d.ts.map +1 -0
  51. package/dist/ErrorBoundary.js +107 -0
  52. package/dist/ImageDisplayCard.d.ts +6 -0
  53. package/dist/ImageDisplayCard.d.ts.map +1 -0
  54. package/dist/ImageDisplayCard.js +57 -0
  55. package/dist/MarkdownCodeComponents.d.ts +23 -0
  56. package/dist/MarkdownCodeComponents.d.ts.map +1 -0
  57. package/dist/MarkdownCodeComponents.js +256 -0
  58. package/dist/MermaidDiagram.d.ts +18 -0
  59. package/dist/MermaidDiagram.d.ts.map +1 -0
  60. package/dist/MermaidDiagram.js +66 -0
  61. package/dist/MessageContentWithPastes.d.ts +14 -0
  62. package/dist/MessageContentWithPastes.d.ts.map +1 -0
  63. package/dist/MessageContentWithPastes.js +44 -0
  64. package/dist/PastePill.d.ts +16 -0
  65. package/dist/PastePill.d.ts.map +1 -0
  66. package/dist/PastePill.js +43 -0
  67. package/dist/ProviderAuthTerminal.d.ts +12 -0
  68. package/dist/ProviderAuthTerminal.d.ts.map +1 -0
  69. package/dist/ProviderAuthTerminal.js +50 -0
  70. package/dist/ProviderConnectForm.d.ts +62 -0
  71. package/dist/ProviderConnectForm.d.ts.map +1 -0
  72. package/dist/ProviderConnectForm.js +206 -0
  73. package/dist/ProviderList.d.ts +18 -0
  74. package/dist/ProviderList.d.ts.map +1 -0
  75. package/dist/ProviderList.js +67 -0
  76. package/dist/QueueStrip.d.ts +17 -0
  77. package/dist/QueueStrip.d.ts.map +1 -0
  78. package/dist/QueueStrip.js +60 -0
  79. package/dist/SettingsScreen.d.ts +10 -0
  80. package/dist/SettingsScreen.d.ts.map +1 -0
  81. package/dist/SettingsScreen.js +26 -0
  82. package/dist/StreamingMarkdown.d.ts +47 -0
  83. package/dist/StreamingMarkdown.d.ts.map +1 -0
  84. package/dist/StreamingMarkdown.js +103 -0
  85. package/dist/TurnTimer.d.ts +72 -0
  86. package/dist/TurnTimer.d.ts.map +1 -0
  87. package/dist/TurnTimer.js +114 -0
  88. package/dist/VegaChart.d.ts +36 -0
  89. package/dist/VegaChart.d.ts.map +1 -0
  90. package/dist/VegaChart.js +180 -0
  91. package/dist/browser.d.ts +7 -0
  92. package/dist/browser.d.ts.map +1 -0
  93. package/dist/browser.js +18 -0
  94. package/dist/catalogColumnBrowserTree.d.ts +9 -0
  95. package/dist/catalogColumnBrowserTree.d.ts.map +1 -0
  96. package/dist/catalogColumnBrowserTree.js +48 -0
  97. package/dist/catalogPickerMenuStyles.d.ts +81 -0
  98. package/dist/catalogPickerMenuStyles.d.ts.map +1 -0
  99. package/dist/catalogPickerMenuStyles.js +130 -0
  100. package/dist/charts.d.ts +12 -0
  101. package/dist/charts.d.ts.map +1 -0
  102. package/dist/charts.js +45 -0
  103. package/dist/chatMessageScroll.d.ts +40 -0
  104. package/dist/chatMessageScroll.d.ts.map +1 -0
  105. package/dist/chatMessageScroll.js +62 -0
  106. package/dist/chatModelOptions.d.ts +28 -0
  107. package/dist/chatModelOptions.d.ts.map +1 -0
  108. package/dist/chatModelOptions.js +59 -0
  109. package/dist/chatTranscriptFindHighlights.d.ts +9 -0
  110. package/dist/chatTranscriptFindHighlights.d.ts.map +1 -0
  111. package/dist/chatTranscriptFindHighlights.js +88 -0
  112. package/dist/draftStore.d.ts +13 -0
  113. package/dist/draftStore.d.ts.map +1 -0
  114. package/dist/draftStore.js +38 -0
  115. package/dist/highlight.d.ts +4 -0
  116. package/dist/highlight.d.ts.map +1 -0
  117. package/dist/highlight.js +47 -0
  118. package/dist/index.d.ts +74 -0
  119. package/dist/index.d.ts.map +1 -0
  120. package/dist/index.js +48 -0
  121. package/dist/keyboardShortcuts.d.ts +5 -0
  122. package/dist/keyboardShortcuts.d.ts.map +1 -0
  123. package/dist/keyboardShortcuts.js +19 -0
  124. package/dist/markdownClipboard.d.ts +22 -0
  125. package/dist/markdownClipboard.d.ts.map +1 -0
  126. package/dist/markdownClipboard.js +98 -0
  127. package/dist/markdownPlugins.d.ts +31 -0
  128. package/dist/markdownPlugins.d.ts.map +1 -0
  129. package/dist/markdownPlugins.js +32 -0
  130. package/dist/mermaid.d.ts +17 -0
  131. package/dist/mermaid.d.ts.map +1 -0
  132. package/dist/mermaid.js +11 -0
  133. package/dist/mermaidRuntime.d.ts +21 -0
  134. package/dist/mermaidRuntime.d.ts.map +1 -0
  135. package/dist/mermaidRuntime.js +140 -0
  136. package/dist/modelCatalogHelpers.d.ts +14 -0
  137. package/dist/modelCatalogHelpers.d.ts.map +1 -0
  138. package/dist/modelCatalogHelpers.js +65 -0
  139. package/dist/modelCatalogSource.d.ts +22 -0
  140. package/dist/modelCatalogSource.d.ts.map +1 -0
  141. package/dist/modelCatalogSource.js +26 -0
  142. package/dist/modelCatalogTree.d.ts +24 -0
  143. package/dist/modelCatalogTree.d.ts.map +1 -0
  144. package/dist/modelCatalogTree.js +77 -0
  145. package/dist/node.d.ts +9 -0
  146. package/dist/node.d.ts.map +1 -0
  147. package/dist/node.js +13 -0
  148. package/dist/pasteFences.d.ts +20 -0
  149. package/dist/pasteFences.d.ts.map +1 -0
  150. package/dist/pasteFences.js +157 -0
  151. package/dist/pasteFormat.d.ts +5 -0
  152. package/dist/pasteFormat.d.ts.map +1 -0
  153. package/dist/pasteFormat.js +18 -0
  154. package/dist/plugins.d.ts +110 -0
  155. package/dist/plugins.d.ts.map +1 -0
  156. package/dist/plugins.js +98 -0
  157. package/dist/remarkAlerts.d.ts +12 -0
  158. package/dist/remarkAlerts.d.ts.map +1 -0
  159. package/dist/remarkAlerts.js +52 -0
  160. package/dist/sendMode.d.ts +69 -0
  161. package/dist/sendMode.d.ts.map +1 -0
  162. package/dist/sendMode.js +66 -0
  163. package/dist/useLlmdChatDriver.d.ts +367 -0
  164. package/dist/useLlmdChatDriver.d.ts.map +1 -0
  165. package/dist/useLlmdChatDriver.js +1739 -0
  166. package/dist/useLlmdModelCatalog.d.ts +23 -0
  167. package/dist/useLlmdModelCatalog.d.ts.map +1 -0
  168. package/dist/useLlmdModelCatalog.js +89 -0
  169. package/dist/useLlmdSessionModel.d.ts +34 -0
  170. package/dist/useLlmdSessionModel.d.ts.map +1 -0
  171. package/dist/useLlmdSessionModel.js +79 -0
  172. package/dist/useProviderAuthCommand.d.ts +26 -0
  173. package/dist/useProviderAuthCommand.d.ts.map +1 -0
  174. package/dist/useProviderAuthCommand.js +80 -0
  175. package/dist/vegaRuntime.d.ts +83 -0
  176. package/dist/vegaRuntime.d.ts.map +1 -0
  177. package/dist/vegaRuntime.js +314 -0
  178. package/dist/vendor/llmd-types/conversationEvents.d.ts +238 -0
  179. package/dist/vendor/llmd-types/conversationEvents.d.ts.map +1 -0
  180. package/dist/vendor/llmd-types/conversationEvents.js +98 -0
  181. package/dist/vendor/llmd-types/index.d.ts +4 -0
  182. package/dist/vendor/llmd-types/index.d.ts.map +1 -0
  183. package/dist/vendor/llmd-types/index.js +5 -0
  184. package/dist/vendor/llmd-types/messages.d.ts +67 -0
  185. package/dist/vendor/llmd-types/messages.d.ts.map +1 -0
  186. package/dist/vendor/llmd-types/messages.js +71 -0
  187. package/dist/vendor/llmd-types/sessionQueue.d.ts +54 -0
  188. package/dist/vendor/llmd-types/sessionQueue.d.ts.map +1 -0
  189. package/dist/vendor/llmd-types/sessionQueue.js +40 -0
  190. package/package.json +120 -4
  191. package/styles.css +389 -0
  192. package/README.md +0 -3
@@ -0,0 +1,295 @@
1
+ import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright 2026 John Ewart <john@johnewart.net>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Renders one transcript message: role-tagged bubble, markdown/paste-aware
8
+ * content, tracked-context badges, and an optional footer row (decoration
9
+ * chips + token usage). This is intentionally NOT a 1:1 port of any host's
10
+ * chat bubble — it owns only what every llmd-backed chat surface needs
11
+ * (markdown, attachment placement tags, paste fences, raw/clean toggle,
12
+ * token usage) and exposes slots for everything host-specific:
13
+ *
14
+ * - `renderCustomMessage`: a message that should replace the whole bubble
15
+ * (e.g. a host's embedded-run card keyed off message.metadata).
16
+ * - cards at inline `<attachment:id/>` tags: ask cards are built in;
17
+ * everything else (display cards, a host's own kinds) renders through the
18
+ * plugin registered for it (see plugins.tsx). This component only owns
19
+ * placement (see @pyxis-llm/core's messageContentTags/messageAttachments).
20
+ * - `renderDecorations`: how per-turn TurnDecorationView[] (e.g. a host's
21
+ * graph-provenance badges) render in the footer, next to token usage.
22
+ * - `transformVisibleContent`: last-mile cleanup of assistant content
23
+ * beyond the generic control-tag stripping this component always does
24
+ * (e.g. a host-specific tag-pinning convention).
25
+ *
26
+ * A host that supplies none of these gets a plain, fully-functional bubble
27
+ * with attachments rendered as an inert placeholder — which is the "vanilla
28
+ * + attachments" baseline a minimal host can ship as-is.
29
+ */
30
+ import React, { useEffect, useRef, useState } from 'react';
31
+ import ReactMarkdown from 'react-markdown';
32
+ import { ActionIcon, Badge, Code, Group, Popover, ScrollArea, Text, Tooltip as MantineTooltip, } from '@mantine/core';
33
+ import { IconTrash, IconEye, IconEyeOff, IconFileText } from '@tabler/icons-react';
34
+ import { parseMessageContent, stripAgentControlTagsFromAssistantContent, decodeAskCard, decodeAskCardResponse, messageIsAnchorlessCardRow, ASK_CARD_KIND, ASK_CARD_RESPONSE_KIND, } from '@pyxis-llm/core';
35
+ import { markdownCodeComponents } from './MarkdownCodeComponents.js';
36
+ import { useLlmdPlugins } from './plugins.js';
37
+ import { useMarkdownPlugins } from './markdownPlugins.js';
38
+ import { MessageContentWithPastes } from './MessageContentWithPastes.js';
39
+ import { messageHasPasteFences } from './pasteFences.js';
40
+ import { bindMarkdownRenderedCopy } from './markdownClipboard.js';
41
+ import { AskCardErrorBoundary, AskCardUnavailable, AskCardView, } from './AskCardView.js';
42
+ import { AskCardAnswerChip } from './AskCardAnswerChip.js';
43
+ import { PluginAttachment } from './DisplayCards.js';
44
+ /**
45
+ * Reads the usage llmd recorded for a message from `metadata.usage` (where
46
+ * @pyxis-llm/client's history mapping and useLlmdChatDriver put it; the key is
47
+ * @pyxis-llm/client's MESSAGE_USAGE_METADATA_KEY). Undefined when there is none.
48
+ */
49
+ export function usageFromMessageMetadata(metadata) {
50
+ const raw = metadata?.usage;
51
+ if (!raw || typeof raw !== 'object')
52
+ return undefined;
53
+ const u = raw;
54
+ const opt = (v) => (typeof v === 'number' && Number.isFinite(v) ? v : undefined);
55
+ return {
56
+ inputTokens: opt(u.inputTokens) ?? 0,
57
+ outputTokens: opt(u.outputTokens) ?? 0,
58
+ cacheReadTokens: opt(u.cacheReadTokens) ?? 0,
59
+ cacheWriteTokens: opt(u.cacheWriteTokens) ?? 0,
60
+ reasoningTokens: opt(u.reasoningTokens),
61
+ modelDurationMs: opt(u.modelDurationMs),
62
+ originalTokens: 0,
63
+ compressedTokens: 0,
64
+ };
65
+ }
66
+ function fmtTokens(n) {
67
+ if (n >= 1_000_000)
68
+ return `${(n / 1_000_000).toFixed(1)}M`;
69
+ if (n >= 1_000)
70
+ return `${(n / 1_000).toFixed(1)}k`;
71
+ return String(n);
72
+ }
73
+ /** 14.2s under a minute, 1m 05s above. */
74
+ export function fmtModelDuration(ms) {
75
+ const seconds = ms / 1000;
76
+ if (seconds < 59.95)
77
+ return `${seconds.toFixed(1)}s`;
78
+ const total = Math.round(seconds);
79
+ return `${Math.floor(total / 60)}m ${String(total % 60).padStart(2, '0')}s`;
80
+ }
81
+ function TokenUsageBadge({ usage }) {
82
+ const effectiveIn = usage.inputTokens + usage.cacheReadTokens + usage.cacheWriteTokens;
83
+ const hasTokens = effectiveIn > 0 || usage.outputTokens > 0;
84
+ const durationMs = usage.modelDurationMs ?? 0;
85
+ const hasTime = durationMs > 0;
86
+ if (!hasTokens && !hasTime)
87
+ return null;
88
+ const hasCompression = usage.originalTokens > 0 && usage.compressedTokens > 0;
89
+ const savedTokens = hasCompression ? usage.originalTokens - usage.compressedTokens : 0;
90
+ return (_jsxs("div", { className: "chat-message__usage-badge", children: [_jsxs("span", { className: "chat-message__usage-badge-tokens", children: [hasTokens && (_jsxs(_Fragment, { children: [_jsxs("span", { className: "chat-message__usage-badge-in", title: `${effectiveIn.toLocaleString()} tokens in (input + cache)`, children: ["\u2191\u2009", fmtTokens(effectiveIn)] }), _jsx("span", { className: "chat-message__usage-badge-sep", children: " \u00B7 " }), _jsxs("span", { className: "chat-message__usage-badge-out", title: `${usage.outputTokens.toLocaleString()} tokens out`, children: ["\u2193\u2009", fmtTokens(usage.outputTokens)] })] })), hasTime && (_jsxs(_Fragment, { children: [hasTokens && _jsx("span", { className: "chat-message__usage-badge-sep", children: " \u00B7 " }), _jsx("span", { className: "chat-message__usage-badge-time", title: `The model took ${(durationMs / 1000).toFixed(1)} seconds for this message`, children: fmtModelDuration(durationMs) })] })), (usage.cacheReadTokens > 0 || usage.cacheWriteTokens > 0) && (_jsxs("span", { className: "chat-message__usage-badge-cache", title: `Cache: ${usage.cacheReadTokens.toLocaleString()} read · ${usage.cacheWriteTokens.toLocaleString()} written`, children: [' ', "(cache: ", fmtTokens(usage.cacheReadTokens), " read / ", fmtTokens(usage.cacheWriteTokens), " written)"] }))] }), hasCompression && (_jsxs("span", { className: "chat-message__usage-badge-compression", title: `Compressed tool results saved ${savedTokens.toLocaleString()} tokens (${usage.originalTokens.toLocaleString()} → ${usage.compressedTokens.toLocaleString()})`, children: ["\uD83D\uDDDC\u2009", fmtTokens(savedTokens), " saved"] }))] }));
91
+ }
92
+ /**
93
+ * A clickable badge that reveals, in a popover, the exact content that llmd
94
+ * injected into the model for this turn — the session seed or a tracked-document
95
+ * version. These live only in the model view (never in the persisted user text),
96
+ * so this is the UI's window into what the assistant actually saw.
97
+ */
98
+ function TrackedContextPopover({ label, color, title, content, }) {
99
+ return (_jsxs(Popover, { width: 540, position: "bottom-start", withArrow: true, shadow: "md", children: [_jsx(Popover.Target, { children: _jsx(Badge, { variant: "light", color: color, size: "sm", leftSection: _jsx(IconFileText, { size: 11, stroke: 1.6 }), style: { cursor: 'pointer', textTransform: 'none' }, children: label }) }), _jsxs(Popover.Dropdown, { children: [_jsx(Text, { size: "xs", fw: 600, mb: 6, children: title }), _jsx(ScrollArea.Autosize, { mah: 360, children: _jsx(Code, { block: true, style: { whiteSpace: 'pre-wrap', wordBreak: 'break-word' }, children: content }) })] })] }));
100
+ }
101
+ function TrackedContextBadges({ documents, initialSeed, }) {
102
+ const seed = (initialSeed ?? '').trim();
103
+ const docs = documents ?? [];
104
+ if (!seed && docs.length === 0)
105
+ return null;
106
+ return (_jsxs(Group, { gap: 6, mt: 6, className: "chat-message__tracked-context", children: [seed && (_jsx(TrackedContextPopover, { label: "Session context", color: "grape", title: "Initial session context (injected into the model on the first turn)", content: seed })), docs.map((d) => (_jsx(TrackedContextPopover, { label: d.change === 'updated' ? `${d.name} · updated` : d.name, color: d.change === 'updated' ? 'yellow' : 'blue', title: `${d.name} (v${d.version}, ${d.change}) — attached to the model this turn`, content: d.content }, `${d.documentId}:${d.version}`)))] }));
107
+ }
108
+ /**
109
+ * Chips for the ask-card answers carried by this (user) message: the
110
+ * `ask_card_response` attachments anchored to it.
111
+ */
112
+ function AnsweredCardChips({ message, attachmentIndex, renderUserAttachment, }) {
113
+ const id = message.id?.trim();
114
+ if (!id || !attachmentIndex?.size)
115
+ return null;
116
+ const chips = [];
117
+ for (const a of attachmentIndex.values()) {
118
+ if (a.anchorMessageId?.trim() !== id)
119
+ continue;
120
+ if (a.kind !== ASK_CARD_RESPONSE_KIND) {
121
+ const chip = renderUserAttachment?.(a, { message });
122
+ if (chip != null && chip !== false)
123
+ chips.push(_jsx(React.Fragment, { children: chip }, a.id));
124
+ continue;
125
+ }
126
+ const response = decodeAskCardResponse(a.payloadJson);
127
+ if (!response)
128
+ continue;
129
+ const cardAtt = attachmentIndex.get(response.cardId);
130
+ const card = cardAtt ? decodeAskCard(cardAtt.payloadJson) : undefined;
131
+ chips.push(_jsx(AskCardAnswerChip, { card: card, response: response }, a.id));
132
+ }
133
+ if (!chips.length)
134
+ return null;
135
+ return (_jsx(Group, { gap: 4, mt: 4, className: "chat-message__answered-cards", children: chips }));
136
+ }
137
+ /** Shared (stable identity) style for `containOffscreen` rows. */
138
+ const OFFSCREEN_CONTAINMENT_STYLE = {
139
+ contentVisibility: 'auto',
140
+ containIntrinsicSize: 'auto 160px',
141
+ };
142
+ function SegmentSteps({ steps }) {
143
+ const [open, setOpen] = useState(false);
144
+ const [openStep, setOpenStep] = useState(null);
145
+ return (_jsxs("div", { className: "chat-message__steps", children: [_jsxs("button", { type: "button", className: "chat-message__steps-toggle", "aria-expanded": open, onClick: () => setOpen((v) => !v), style: { background: 'none', border: 0, padding: 0, cursor: 'pointer', color: 'inherit', opacity: 0.7 }, children: [open ? '▾' : '▸', " ", steps.length, " ", steps.length === 1 ? 'step' : 'steps'] }), open && (_jsx("ul", { className: "chat-message__steps-list", children: steps.map((s, i) => (_jsxs("li", { children: [_jsx("div", { children: stripAgentControlTagsFromAssistantContent(s.text) }), s.toolCalls?.length ? (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", "aria-expanded": openStep === i, onClick: () => setOpenStep(openStep === i ? null : i), style: { background: 'none', border: 0, padding: 0, cursor: 'pointer', color: 'inherit', opacity: 0.6 }, children: [s.toolCalls.length, " tool ", s.toolCalls.length === 1 ? 'call' : 'calls'] }), openStep === i && (_jsx("div", { className: "chat-message__step-tools", children: s.toolCalls.map((t, j) => (_jsx("div", { children: t.name ?? 'tool' }, t.id ?? j))) }))] })) : null] }, i))) }))] }));
146
+ }
147
+ export const ChatMessage = React.memo(function ChatMessage({ message, streamPlainContent = false, onDelete, deleteDisabled = false, deleteTooltip = 'Delete this message and everything after it', attachmentIndex, usage, decorations, trackedDocuments, initialSeed, renderCustomMessage, renderUserAttachment, renderDecorations, askCardResponses, onAskCardSubmit, onAskCardDismiss, transformVisibleContent, containOffscreen = false, deferMarkdown = false, }) {
148
+ // Every hook below must run on every render, so the early returns (custom
149
+ // render, tool messages) come after them — a message whose role or custom
150
+ // render changes between renders must not change the hook call order.
151
+ const isUser = message.role === 'user';
152
+ const isAssistant = message.role === 'assistant';
153
+ // The persisted user content is exactly what the user typed — tracked docs and
154
+ // the session seed are injected by llmd only into the model view, never stored
155
+ // here — so it renders directly with no stripping.
156
+ const visibleContent = isUser
157
+ ? message.content
158
+ : (transformVisibleContent ?? ((s) => s))(stripAgentControlTagsFromAssistantContent(message.content), message);
159
+ const liveStreamMeta = message.metadata;
160
+ const isLiveActivityPreview = liveStreamMeta?.liveActivityPreview === true;
161
+ const isStreamingPlaceholder = liveStreamMeta?.streamingPlaceholder === true;
162
+ const contentRef = useRef(null);
163
+ const [showRaw, setShowRaw] = useState(false);
164
+ // Initial value only: see `deferMarkdown`. Once true, never goes back.
165
+ const [renderMarkdown, setRenderMarkdown] = useState(() => !deferMarkdown);
166
+ useEffect(() => {
167
+ if (renderMarkdown)
168
+ return;
169
+ const el = contentRef.current;
170
+ if (!el || typeof IntersectionObserver === 'undefined') {
171
+ setRenderMarkdown(true);
172
+ return;
173
+ }
174
+ // Generous margin so a row is already formatted by the time it scrolls in.
175
+ const io = new IntersectionObserver((entries) => {
176
+ if (entries.some((e) => e.isIntersecting))
177
+ setRenderMarkdown(true);
178
+ }, { rootMargin: '1000px 0px' });
179
+ io.observe(el);
180
+ return () => io.disconnect();
181
+ }, [renderMarkdown]);
182
+ // Raw = exactly what was sent to the model (initial-context/seed blocks,
183
+ // tracked-doc prefixes, attachment fences, agent control tags). The bubble
184
+ // normally shows the cleaned view; the eye toggle reveals the hidden parts.
185
+ const rawContent = message.content;
186
+ const hasHiddenContent = rawContent.trim() !== visibleContent.trim();
187
+ const usesRenderedMarkdown = renderMarkdown &&
188
+ !(isAssistant && streamPlainContent) &&
189
+ !(isUser && messageHasPasteFences(visibleContent));
190
+ useEffect(() => {
191
+ if (!usesRenderedMarkdown)
192
+ return;
193
+ return bindMarkdownRenderedCopy(contentRef.current, message.content);
194
+ }, [usesRenderedMarkdown, visibleContent, message.content]);
195
+ const { remarkPlugins, rehypePlugins } = useMarkdownPlugins();
196
+ const { attachmentKindPlugins } = useLlmdPlugins();
197
+ const custom = renderCustomMessage?.(message);
198
+ if (custom !== undefined)
199
+ return _jsx(_Fragment, { children: custom });
200
+ if (message.role === 'tool')
201
+ return null;
202
+ // A host-supplied usage wins; otherwise what llmd recorded on the message.
203
+ const shownUsage = usage !== undefined ? usage : isAssistant ? usageFromMessageMetadata(message.metadata) : undefined;
204
+ const turnSegments = isAssistant && message.segments && message.segments.length >= 2 ? message.segments : undefined;
205
+ const finalSegmentText = turnSegments
206
+ ? (transformVisibleContent ?? ((s) => s))(stripAgentControlTagsFromAssistantContent(turnSegments[turnSegments.length - 1].text), message)
207
+ : undefined;
208
+ const renderProseSegments = () => {
209
+ const segments = parseMessageContent(finalSegmentText ?? visibleContent);
210
+ return segments.map((segment, idx) => {
211
+ if (segment.type === 'markdown') {
212
+ const text = segment.text;
213
+ if (!text.trim())
214
+ return null;
215
+ if (isAssistant && streamPlainContent) {
216
+ return (
217
+ // div (not <pre>) so `.chat-message__content pre` code-block
218
+ // styling can never claim the streaming tail; pre-wrap comes
219
+ // from the CSS class.
220
+ _jsx("div", { className: "chat-message__stream-plain", children: text }, `md-${idx}`));
221
+ }
222
+ if (!renderMarkdown) {
223
+ // Deferred: raw text, cheap to mount and still searchable.
224
+ return (_jsx("div", { className: "chat-message__deferred-plain", style: { whiteSpace: 'pre-wrap', wordBreak: 'break-word' }, children: text }, `md-${idx}`));
225
+ }
226
+ if (isUser && messageHasPasteFences(text)) {
227
+ return _jsx(MessageContentWithPastes, { content: text }, `md-${idx}`);
228
+ }
229
+ return (_jsx(ReactMarkdown, { remarkPlugins: remarkPlugins, rehypePlugins: rehypePlugins, components: markdownCodeComponents, children: text }, `md-${idx}`));
230
+ }
231
+ // An attachment tag that resolves to no card must degrade to something
232
+ // VISIBLE, never to nothing. Returning null here silently deletes
233
+ // content: a message whose only body was an unresolvable tag would
234
+ // render as an empty bubble, and the user would see "no response" with
235
+ // no way to tell whether the agent had replied at all. What it
236
+ // degrades to used to be the raw `<attachment:id/>` tag, which is
237
+ // machinery leaking into the transcript; a muted placeholder keeps the
238
+ // "something was here" signal without pretending the id is meaningful.
239
+ const attachment = attachmentIndex?.get(segment.attachmentId);
240
+ // End-of-turn kinds render once, in their own row at the end of the turn;
241
+ // an inline tag (mid-turn) renders nothing, not a placeholder.
242
+ if (attachment &&
243
+ attachmentKindPlugins.some((p) => p.kind === attachment.kind && p.endOfTurn) &&
244
+ !messageIsAnchorlessCardRow(message)) {
245
+ return null;
246
+ }
247
+ if (attachment?.kind === ASK_CARD_KIND) {
248
+ const card = decodeAskCard(attachment.payloadJson);
249
+ const dismiss = onAskCardDismiss
250
+ ? () => onAskCardDismiss(card?.id ?? attachment.id)
251
+ : undefined;
252
+ if (card) {
253
+ const response = askCardResponses?.get(card.id) ?? null;
254
+ return (_jsx("div", { className: "chat-message__attachments", children: _jsx(AskCardErrorBoundary, { cardId: card.id, onDismiss: dismiss, children: _jsx(AskCardView, { card: card, response: response, onSubmit: onAskCardSubmit, onDismiss: response ? undefined : dismiss, disabled: !onAskCardSubmit }) }) }, `att-${segment.attachmentId}`));
255
+ }
256
+ // Undecodable card: still clearable, so a broken one is not stuck.
257
+ return (_jsx("div", { className: "chat-message__attachments", children: _jsx(AskCardUnavailable, { cardId: attachment.id, label: "[card unavailable]", onDismiss: dismiss }) }, `att-${segment.attachmentId}`));
258
+ }
259
+ if (!attachment) {
260
+ return (_jsx("span", { title: `Unresolved attachment: ${segment.attachmentId}`, style: { opacity: 0.6, fontStyle: 'italic' }, children: "[card unavailable]" }, `att-text-${idx}`));
261
+ }
262
+ return (
263
+ // Display cards and host kinds: whatever plugin is registered for them.
264
+ _jsx("div", { className: "chat-message__attachments", children: _jsx(PluginAttachment, { attachment: attachment, attachmentId: segment.attachmentId, messageId: message.id, dismiss: onAskCardDismiss ? () => onAskCardDismiss(segment.attachmentId) : undefined }) }, `att-${segment.attachmentId}`));
265
+ });
266
+ };
267
+ return (_jsxs("div", { className: `chat-message chat-message--${message.role}`, style: containOffscreen ? OFFSCREEN_CONTAINMENT_STYLE : undefined, "data-message-id": message.id, "data-message-role": message.role, children: [_jsxs("div", { className: "chat-message__header", children: [_jsxs("div", { className: "chat-message__role", children: [!isUser && !isAssistant && message.role, message.providerId && (_jsx("span", { className: "chat-message__provider-badge", children: message.providerId })), message.metadata?.queued && (_jsx("span", { className: "chat-message__queued-badge", style: {
268
+ marginLeft: 6,
269
+ fontSize: '0.62rem',
270
+ fontWeight: 700,
271
+ letterSpacing: '0.05em',
272
+ textTransform: 'uppercase',
273
+ color: 'var(--mantine-color-yellow-7)',
274
+ }, children: "Queued" })), message.metadata?.interrupted && (_jsx("span", { className: "chat-message__interrupted-badge", title: "This reply was interrupted before the model finished", style: {
275
+ marginLeft: 6,
276
+ fontSize: '0.62rem',
277
+ fontWeight: 700,
278
+ letterSpacing: '0.05em',
279
+ textTransform: 'uppercase',
280
+ color: 'var(--mantine-color-orange-7)',
281
+ }, children: "Interrupted" }))] }), hasHiddenContent && (_jsx(MantineTooltip, { label: showRaw
282
+ ? 'Show cleaned message'
283
+ : 'Show raw message (includes hidden context stripped from view)', withArrow: true, position: "left", children: _jsx(ActionIcon, { type: "button", variant: "subtle", color: "gray", size: "xs", className: "chat-message__raw-toggle", "aria-label": showRaw ? 'Show cleaned message' : 'Show raw message', "aria-pressed": showRaw, onClick: (e) => {
284
+ e.stopPropagation();
285
+ setShowRaw((v) => !v);
286
+ }, children: showRaw ? (_jsx(IconEyeOff, { size: 14, stroke: 1.5 })) : (_jsx(IconEye, { size: 14, stroke: 1.5 })) }) })), onDelete && (_jsx(MantineTooltip, { label: deleteTooltip, withArrow: true, position: "left", children: _jsx(ActionIcon, { type: "button", variant: "subtle", color: "gray", size: "xs", className: "chat-message__delete", "aria-label": deleteTooltip, disabled: deleteDisabled, onClick: (e) => {
287
+ e.stopPropagation();
288
+ onDelete();
289
+ }, children: _jsx(IconTrash, { size: 14, stroke: 1.5 }) }) }))] }), _jsx("div", { ref: contentRef, className: "chat-message__content", children: showRaw ? (_jsx("pre", { className: "chat-message__raw", style: { whiteSpace: 'pre-wrap', wordBreak: 'break-word' }, children: rawContent })) : isAssistant && isStreamingPlaceholder && !visibleContent.trim() ? (_jsxs("div", { className: "chat-message__stream-placeholder", "aria-live": "polite", children: [_jsx("span", { className: "chat-message__stream-placeholder-dot" }), _jsx("span", { className: "chat-message__stream-placeholder-dot" }), _jsx("span", { className: "chat-message__stream-placeholder-dot" })] })) : isAssistant && isLiveActivityPreview ? (_jsx("p", { className: "chat-message__activity-preview", children: visibleContent })) : turnSegments ? (_jsxs(_Fragment, { children: [_jsx(SegmentSteps, { steps: turnSegments.slice(0, -1) }), renderProseSegments()] })) : (renderProseSegments()) }), isUser && (_jsx(AnsweredCardChips, { message: message, attachmentIndex: attachmentIndex, renderUserAttachment: renderUserAttachment })), isUser && (_jsx(TrackedContextBadges, { documents: trackedDocuments, initialSeed: initialSeed })), ((decorations && decorations.length > 0) || shownUsage) && (_jsxs("div", { className: "chat-message__footer-badges", style: {
290
+ display: 'flex',
291
+ alignItems: 'center',
292
+ justifyContent: 'space-between',
293
+ gap: 8,
294
+ }, children: [_jsx("div", { children: decorations && decorations.length > 0 && renderDecorations?.(decorations) }), shownUsage && _jsx(TokenUsageBadge, { usage: shownUsage })] }))] }));
295
+ });
@@ -0,0 +1,252 @@
1
+ /**
2
+ * A complete, minimal chat surface: scrollable message list (via
3
+ * ChatMessage) + Composer, wired together by props/callbacks only.
4
+ *
5
+ * Deliberately transport-agnostic: it does NOT import `@pyxis-llm/client` or
6
+ * drive `ChatStream` itself. `@pyxis-llm/client`'s gRPC transport
7
+ * (`@grpc/grpc-js`) is Node-only — most hosts (Electron renderers, browser
8
+ * apps) can't call it directly from the same process this component
9
+ * renders in, and even hosts that could will have very different session/
10
+ * attachment/model-catalog state management. So `ChatPanel` takes the
11
+ * current `messages` array and an `onSend` callback and lets the host own
12
+ * everything upstream of that (a hook wrapping `chatStreamEvents` over
13
+ * IPC, a REST proxy, a mock for tests — whatever fits).
14
+ *
15
+ * Extension points (the "slots and callbacks" needed to slim this down to a
16
+ * shared core while hosts add their own chrome):
17
+ * - `header` / `composerBefore` / `composerAfter`: arbitrary chrome
18
+ * (status bar, model switcher, attachments strip).
19
+ * - `renderCustomMessage` / `renderDecorations` / `transformVisibleContent`:
20
+ * forwarded to every ChatMessage — see its own docs for what each does.
21
+ * - Cards, code renderers and attachment placement come from llmd plugins
22
+ * (plugins.tsx: registerLlmdPlugin / LlmdPluginProvider), not props.
23
+ * - `usageByMessageId` / `decorationsByMessageId` / `trackedDocumentsByMessage`:
24
+ * per-message data a host looks up by id; ChatPanel does no bookkeeping
25
+ * of its own beyond the lookup.
26
+ *
27
+ * A host that supplies none of the optional props gets a fully working
28
+ * "vanilla" chat panel — text in, text out, attachments degrade to a
29
+ * placeholder — which is the Owlbert-style baseline. A host app
30
+ * adds graph badges, a model switcher, and its own attachment kinds purely
31
+ * by passing props; it never needs to fork this component.
32
+ *
33
+ * Addressing a single message: every `ChatMessage` root carries
34
+ * `data-message-id` (its `Message.id`) and `data-message-role`, so a host can
35
+ * map a DOM node or text selection back to a message and anchor its own
36
+ * overlays — selection menus, comment pins, highlight ranges — with no extra
37
+ * props. `scrollRequest` and the `ChatPanelHandle` ref bring a given message
38
+ * into view; see `ChatPanelScrollRequest` for why it carries a nonce and
39
+ * `autoScroll` for how the two interact.
40
+ *
41
+ * Note that message ids are the only *durable* address llmd has: turn ids and
42
+ * turn sequence numbers exist on the live conversation event stream but are
43
+ * not persisted, so anything a host wants to survive a reload should be keyed
44
+ * off `Message.id`.
45
+ *
46
+ * Ask cards (llmd's first-class AskCard/AskCardResponse primitive, including
47
+ * ones created server-side by the `ask_user` tool) need NO dedicated prop
48
+ * here: they're plain attachments (kind `ask_card`), rendered inline by
49
+ * `ChatMessage` via the existing `attachmentIndex`/`askCardResponses`/
50
+ * `onAskCardSubmit` props — see packages/react/e2e/askCard.e2e.test.tsx for
51
+ * the full round trip (load attachments, render, answer via
52
+ * UpsertSessionAttachment).
53
+ */
54
+ import { type ReactNode } from 'react';
55
+ import { type TurnTiming, type TurnTimerState } from './TurnTimer.js';
56
+ import { type TurnDecorationView, type LlmdMessageAttachment, type TrackedDocumentRefView, type AskCardResponse } from '@pyxis-llm/core';
57
+ import { type ChatMessageData, type ChatMessageProps, type ChatMessageUsage } from './ChatMessage.js';
58
+ import type { AskCardSubmitOptions } from './AskCardView.js';
59
+ import { type ComposerProps } from './Composer.js';
60
+ import { type DraftStore } from './draftStore.js';
61
+ import type { QueuedMessage } from './vendor/llmd-types/index.js';
62
+ /**
63
+ * A request to bring one message into view.
64
+ *
65
+ * `token` is a nonce, and it is the whole point of this shape: a bare
66
+ * `scrollToMessageId` prop can only fire once, so clicking the same pin twice
67
+ * (or re-opening the same deep link) would be a no-op because the prop value
68
+ * never changed. Change `token` to re-fire against the same `messageId` —
69
+ * `Date.now()`, a counter, or the click event's id all work.
70
+ *
71
+ * A request whose `messageId` is not mounted yet (history still loading) is
72
+ * retained and retried as `messages` changes, until it resolves.
73
+ */
74
+ export type ChatPanelScrollRequest = {
75
+ messageId: string;
76
+ token: string | number;
77
+ };
78
+ /** Imperative escape hatch for hosts that would rather call than pass a prop. */
79
+ export type ChatPanelHandle = {
80
+ /**
81
+ * Scrolls `messageId` into view, centered. Returns false when that message
82
+ * is not currently rendered — unlike `scrollRequest`, this does not retry.
83
+ */
84
+ scrollToMessage: (messageId: string) => boolean;
85
+ /** Jumps to the newest message and re-arms auto-scroll. */
86
+ scrollToBottom: () => void;
87
+ /** The scrolling viewport element, for hosts positioning their own overlays. */
88
+ getViewport: () => HTMLDivElement | null;
89
+ };
90
+ export type ChatPanelProps = {
91
+ messages: ChatMessageData[];
92
+ /**
93
+ * Called on submit with what the user asked for while a turn may be running:
94
+ * plain Enter / the send button give one behavior, holding ⌥/Ctrl/⌘ the
95
+ * other (see `sendMode`). Signature-compatible with `useLlmdChatDriver`'s
96
+ * `send`.
97
+ */
98
+ onSend: (text: string, behavior: 'queue' | 'interrupt') => void;
99
+ /**
100
+ * Pin what plain Enter does. Omitted (recommended) = follow the queue:
101
+ * queue normally, send now while `queuePaused`. The modifier always gives
102
+ * the other one.
103
+ */
104
+ defaultSendBehavior?: 'queue' | 'interrupt';
105
+ /**
106
+ * The session queue (driver's `queue`). When provided, a `QueueStrip` is
107
+ * rendered above the composer; the `on*Queue*` callbacks enable its controls.
108
+ */
109
+ queue?: QueuedMessage[];
110
+ queuePaused?: boolean;
111
+ onRemoveQueued?: (entryId: string) => void | Promise<void>;
112
+ onReorderQueue?: (entryIds: string[]) => void | Promise<void>;
113
+ onSetQueuePaused?: (paused: boolean) => void | Promise<void>;
114
+ /** Pull an entry out of the queue and send it now as an interrupt (driver's `interruptWithQueued`). */
115
+ onInterruptWithQueued?: (entryId: string) => void | Promise<void>;
116
+ streaming?: boolean;
117
+ onStop?: () => void;
118
+ onDeleteMessage?: (message: ChatMessageData) => void;
119
+ /** Id of the last message still being generated — disables its delete button, matching the chip-in convention. */
120
+ streamingMessageId?: string;
121
+ /**
122
+ * Every attachment on the session (the driver's `attachmentIndex`). A
123
+ * still-pending ask card that no message references — e.g. one the agent
124
+ * asked via `ask_user` before any assistant text was saved — gets a row of
125
+ * its own at the end of the transcript, so it can never silently vanish.
126
+ * Image and chart cards that no message references get a row right after
127
+ * the tool result that produced them.
128
+ */
129
+ attachmentIndex?: Map<string, LlmdMessageAttachment>;
130
+ usageByMessageId?: Map<string, ChatMessageUsage>;
131
+ decorationsByMessageId?: Map<string, TurnDecorationView[]>;
132
+ trackedDocumentsByMessageId?: Map<string, TrackedDocumentRefView[]>;
133
+ /** First-turn session seed, shown as a badge on the first user message that has one. */
134
+ initialSeed?: string;
135
+ /**
136
+ * Agent-authored session title (from the `set_session_title` tool — see
137
+ * `useLlmdChatDriver`'s `sessionTitle`). Rendered as
138
+ * a small title bar above the message list when set, so a session the
139
+ * agent names live re-titles the panel without any host-supplied chrome.
140
+ * A host that wants its own title UI (e.g. in a tab strip instead of
141
+ * inline) can ignore this and read `sessionTitle` off the driver itself —
142
+ * this prop is a convenience default, not the only way to consume it.
143
+ */
144
+ sessionTitle?: string;
145
+ /**
146
+ * Agent-authored status headline (from the `set_status` tool — see the
147
+ * driver hooks' `sessionStatus`). Rendered in the turn bar just above the
148
+ * composer, left of the turn timer. Turn-scoped: llmd clears it when a turn
149
+ * starts and when it ends, so it only ever shows the running turn's headline.
150
+ */
151
+ sessionStatus?: string;
152
+ /**
153
+ * When the running turn started (ms since epoch), for the turn timer. Optional:
154
+ * by default the timer starts when `streaming` turns true, which is exact for
155
+ * turns this panel sends and approximate (mount time) for a turn it rejoined.
156
+ */
157
+ turnStartedAt?: number;
158
+ /**
159
+ * Per-session turn timing from useLlmdChatDriver (`driver.turnTiming`).
160
+ * Preferred over `turnStartedAt`: it uses llmd's own turn-start time and
161
+ * resets with the session, so the timer is right across reloads, rejoins
162
+ * and session switches.
163
+ */
164
+ turnTiming?: TurnTiming;
165
+ /**
166
+ * Show the turn timer in the turn bar (right of the status headline). Default
167
+ * true. Set false to place it yourself: `<TurnTimer streaming={driver.streaming} />`
168
+ * or `useTurnTimer(...)` anywhere in your own chrome.
169
+ */
170
+ showTurnTimer?: boolean;
171
+ /**
172
+ * Replace what is drawn in the turn timer's default spot. Receives the timer
173
+ * state (`elapsedMs`, `running`, `label`); return null to draw nothing for a
174
+ * given state. Ignored when `showTurnTimer` is false.
175
+ */
176
+ renderTurnTimer?: (state: TurnTimerState) => ReactNode;
177
+ renderCustomMessage?: (message: ChatMessageData) => ReactNode | undefined;
178
+ /** Chips for host attachments sent on user messages (see ChatMessage). */
179
+ renderUserAttachment?: ChatMessageProps['renderUserAttachment'];
180
+ renderDecorations?: (decorations: TurnDecorationView[]) => ReactNode;
181
+ /** Ask-card responses, keyed by the AskCard.id they answer. Defaults to the answers found in `attachmentIndex`. */
182
+ askCardResponses?: Map<string, AskCardResponse>;
183
+ /**
184
+ * Called when the user submits an ask card anywhere in the transcript.
185
+ * `options.continueWithTools` is true for "Answer & continue", false for
186
+ * "Answer & stop" (pass both straight to the driver's `submitAskCard`).
187
+ */
188
+ onAskCardSubmit?: (response: AskCardResponse, options: AskCardSubmitOptions) => void;
189
+ /**
190
+ * Called with a card's id when the user dismisses an ask card (the ✕).
191
+ * Pass the driver's `dismissAskCard`. Omit to hide the ✕.
192
+ */
193
+ onAskCardDismiss?: (cardId: string) => void;
194
+ transformVisibleContent?: (content: string, message: ChatMessageData) => string;
195
+ /** Chrome above the message list (e.g. a status bar). */
196
+ header?: ReactNode;
197
+ /** Chrome below the message list, above the composer (e.g. a scroll-to-bottom affordance). */
198
+ footer?: ReactNode;
199
+ /** Composer row above the textarea (attachments strip, paste pills). */
200
+ composerBefore?: ReactNode;
201
+ /** Composer row below the textarea (model switcher, token counter). */
202
+ composerAfter?: ReactNode;
203
+ composerPlaceholder?: string;
204
+ composerDisabled?: boolean;
205
+ composerValue?: ComposerProps['value'];
206
+ /**
207
+ * The driver's draft store (`driver.draft`). Preferred over `composerValue`:
208
+ * only the composer subscribes, so typing does not re-render the panel or
209
+ * the page that owns the driver. Ignored when `composerValue` is set.
210
+ */
211
+ composerDraft?: DraftStore;
212
+ onComposerValueChange?: ComposerProps['onValueChange'];
213
+ /**
214
+ * Auto-scroll to the newest message when `messages` grows. Default true.
215
+ *
216
+ * Only chases while the viewport is parked at the bottom. Scroll away —
217
+ * by hand or via `scrollRequest` — and new messages stop yanking the
218
+ * transcript out from under you; scroll back to the bottom and it resumes.
219
+ */
220
+ autoScroll?: boolean;
221
+ /**
222
+ * Bring one message into view. See `ChatPanelScrollRequest` — change its
223
+ * `token` to re-fire for the same `messageId`.
224
+ *
225
+ * This counts as scrolling by hand: landing somewhere other than the bottom
226
+ * suspends `autoScroll`, so a reply streaming in mid-read will not drag the
227
+ * view back to the newest message. Returning to the bottom re-arms it.
228
+ */
229
+ scrollRequest?: ChatPanelScrollRequest;
230
+ /**
231
+ * How many of the newest messages render as markdown at mount. Older ones
232
+ * mount as plain text (still in the DOM, so find-in-page works) and upgrade
233
+ * to markdown as they near the viewport. Default 10.
234
+ */
235
+ fullRenderTail?: number;
236
+ /**
237
+ * Render only the bottom of the panel (queue strip, turn bar, composer): no title bar,
238
+ * header, transcript or footer, and the panel sizes to its content instead of filling
239
+ * its parent. Toggling it keeps the composer the same element with the same styling,
240
+ * so a host can collapse the chat to "just the input" (e.g. under a document on a
241
+ * phone) without the input moving, remounting or losing focus.
242
+ */
243
+ hideTranscript?: boolean;
244
+ /**
245
+ * Show a round "jump to newest" arrow over the transcript's bottom-right corner while the
246
+ * reader is scrolled up (more than SCROLL_BUTTON_THRESHOLD_PX from the bottom). Default true.
247
+ */
248
+ showScrollToBottom?: boolean;
249
+ className?: string;
250
+ };
251
+ export declare const ChatPanel: import("react").ForwardRefExoticComponent<ChatPanelProps & import("react").RefAttributes<ChatPanelHandle>>;
252
+ //# sourceMappingURL=ChatPanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatPanel.d.ts","sourceRoot":"","sources":["../src/ChatPanel.tsx"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,OAAO,EAQL,KA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