@jini-ai/chat 0.7.2 → 0.7.3-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/CHANGELOG.md +2 -12
  2. package/README.md +3 -3
  3. package/dist/contracts/chat-bubble-style.d.ts +1 -1
  4. package/dist/contracts/chat-bubble-style.js +1 -1
  5. package/dist/core/ag-ui/event-projection.d.ts +125 -0
  6. package/dist/core/ag-ui/event-projection.js +275 -0
  7. package/dist/core/ag-ui/event-reduction.d.ts +39 -0
  8. package/dist/core/ag-ui/event-reduction.js +99 -0
  9. package/dist/core/ag-ui/run-input.d.ts +53 -0
  10. package/dist/core/ag-ui/run-input.js +87 -0
  11. package/dist/core/agentic/chat-capabilities.d.ts +1 -1
  12. package/dist/core/agentic/index.d.ts +2 -4
  13. package/dist/core/agentic/index.js +2 -3
  14. package/dist/core/agents-port.d.ts +50 -0
  15. package/dist/core/agents-port.js +2 -0
  16. package/dist/core/assistant-client/ag-ui-fetch-agent.d.ts +16 -0
  17. package/dist/core/assistant-client/ag-ui-fetch-agent.js +24 -0
  18. package/dist/core/assistant-client/ag-ui-transport.d.ts +15 -1
  19. package/dist/core/assistant-client/ag-ui-transport.js +167 -145
  20. package/dist/core/assistant-client/attachment-liveness.js +13 -11
  21. package/dist/core/assistant-client/durable-run-subscription.d.ts +3 -2
  22. package/dist/core/assistant-client/durable-run-subscription.js +6 -5
  23. package/dist/core/assistant-client/messages.d.ts +7 -4
  24. package/dist/core/assistant-client/messages.js +5 -4
  25. package/dist/core/assistant-client/transport.d.ts +1 -1
  26. package/dist/core/assistant-client/transport.js +4 -4
  27. package/dist/core/index.d.ts +2 -0
  28. package/dist/core/index.js +1 -0
  29. package/dist/core/page-port.d.ts +15 -0
  30. package/dist/core/page-port.js +2 -0
  31. package/dist/core/run-activity.js +1 -1
  32. package/dist/core/run-events/entry.js +1 -0
  33. package/dist/core/user-text-redaction.d.ts +1 -3
  34. package/dist/core/user-text-redaction.js +3 -61
  35. package/dist/embed-widget/browser/agent-inventory.d.ts +37 -0
  36. package/dist/embed-widget/browser/agent-inventory.js +36 -0
  37. package/dist/embed-widget/browser/frontend-session-bridge.d.ts +2 -2
  38. package/dist/embed-widget/browser/frontend-session-bridge.js +17 -14
  39. package/dist/embed-widget/react/dialog.hooks.d.ts +16 -0
  40. package/dist/embed-widget/react/dialog.hooks.js +15 -0
  41. package/dist/embed-widget/react/embed.d.ts +7 -2
  42. package/dist/embed-widget/react/embed.js +6 -16
  43. package/dist/embed-widget/react/header.d.ts +4 -1
  44. package/dist/embed-widget/react/header.js +2 -2
  45. package/dist/embed-widget/vanilla/state.js +2 -2
  46. package/dist/embed-widget/vanilla/style.css +4 -4
  47. package/dist/react/components/A2uiSurfaceCard.d.ts +18 -4
  48. package/dist/react/components/A2uiSurfaceCard.hooks.d.ts +36 -0
  49. package/dist/react/components/A2uiSurfaceCard.hooks.js +174 -0
  50. package/dist/react/components/A2uiSurfaceCard.js +14 -227
  51. package/dist/react/components/A2uiSurfaceCard.rules.d.ts +14 -0
  52. package/dist/react/components/A2uiSurfaceCard.rules.js +24 -0
  53. package/dist/react/components/AttachmentPreviewModal.d.ts +21 -1
  54. package/dist/react/components/AttachmentPreviewModal.hooks.js +1 -3
  55. package/dist/react/components/AttachmentPreviewModal.js +11 -9
  56. package/dist/react/components/AttachmentTray.d.ts +11 -1
  57. package/dist/react/components/AttachmentTray.js +12 -8
  58. package/dist/react/components/ChatFab.d.ts +10 -1
  59. package/dist/react/components/ChatFab.js +2 -2
  60. package/dist/react/components/ChatSettingsDialog.d.ts +4 -3
  61. package/dist/react/components/ChatSettingsDialog.js +9 -6
  62. package/dist/react/components/ChatSettingsSegmented.d.ts +1 -1
  63. package/dist/react/components/ChatSettingsSegmented.js +1 -1
  64. package/dist/react/components/Composer.d.ts +9 -1
  65. package/dist/react/components/Composer.hooks.d.ts +79 -0
  66. package/dist/react/components/Composer.hooks.js +336 -0
  67. package/dist/react/components/Composer.js +40 -341
  68. package/dist/react/components/ComposerDiscovery.js +1 -1
  69. package/dist/react/components/ConversationList.d.ts +34 -1
  70. package/dist/react/components/ConversationList.hooks.d.ts +37 -0
  71. package/dist/react/components/ConversationList.hooks.js +177 -1
  72. package/dist/react/components/ConversationList.js +7 -174
  73. package/dist/react/components/ConversationTitleEditor.d.ts +17 -2
  74. package/dist/react/components/ConversationTitleEditor.hooks.d.ts +15 -0
  75. package/dist/react/components/ConversationTitleEditor.hooks.js +36 -0
  76. package/dist/react/components/ConversationTitleEditor.js +11 -34
  77. package/dist/react/components/CopyMessageButton.d.ts +6 -1
  78. package/dist/react/components/CopyMessageButton.js +4 -4
  79. package/dist/react/components/ExtEventErrorBoundary.d.ts +2 -0
  80. package/dist/react/components/ExtEventErrorBoundary.js +5 -3
  81. package/dist/react/components/FolderChips.d.ts +11 -1
  82. package/dist/react/components/FolderChips.hooks.d.ts +12 -0
  83. package/dist/react/components/FolderChips.hooks.js +10 -0
  84. package/dist/react/components/FolderChips.js +9 -9
  85. package/dist/react/components/Markdown.js +7 -5
  86. package/dist/react/components/McpUiSurfaceCard.d.ts +29 -5
  87. package/dist/react/components/McpUiSurfaceCard.js +29 -16
  88. package/dist/react/components/MessageList.d.ts +10 -1
  89. package/dist/react/components/MessageList.hooks.d.ts +0 -4
  90. package/dist/react/components/MessageList.hooks.js +6 -18
  91. package/dist/react/components/MessageList.js +17 -20
  92. package/dist/react/components/MessageList.rules.d.ts +0 -5
  93. package/dist/react/components/MessageList.rules.js +0 -4
  94. package/dist/react/components/MessageRow.d.ts +46 -2
  95. package/dist/react/components/MessageRow.hooks.d.ts +60 -0
  96. package/dist/react/components/MessageRow.hooks.js +94 -0
  97. package/dist/react/components/MessageRow.js +53 -113
  98. package/dist/react/components/MidRunUserMessage.d.ts +6 -1
  99. package/dist/react/components/MidRunUserMessage.js +5 -5
  100. package/dist/react/components/NextStepActions.d.ts +3 -1
  101. package/dist/react/components/NextStepActions.js +3 -3
  102. package/dist/react/components/QuestionForm.answers.hooks.d.ts +26 -0
  103. package/dist/react/components/QuestionForm.answers.hooks.js +89 -0
  104. package/dist/react/components/QuestionForm.d.ts +6 -0
  105. package/dist/react/components/QuestionForm.js +23 -261
  106. package/dist/react/components/QuestionForm.values.d.ts +22 -0
  107. package/dist/react/components/QuestionForm.values.js +58 -0
  108. package/dist/react/components/QuestionFormField.d.ts +17 -0
  109. package/dist/react/components/QuestionFormField.js +114 -0
  110. package/dist/react/components/QuestionsPanel.d.ts +3 -1
  111. package/dist/react/components/QuestionsPanel.js +7 -3
  112. package/dist/react/components/SentAttachment.d.ts +11 -2
  113. package/dist/react/components/SentAttachment.hooks.d.ts +1 -1
  114. package/dist/react/components/SentAttachment.hooks.js +6 -5
  115. package/dist/react/components/SentAttachment.js +5 -3
  116. package/dist/react/components/TodoCard.d.ts +3 -1
  117. package/dist/react/components/TodoCard.js +9 -4
  118. package/dist/react/components/ToolCallGroup.d.ts +11 -1
  119. package/dist/react/components/ToolCallGroup.js +10 -4
  120. package/dist/react/components/ToolCard.d.ts +6 -1
  121. package/dist/react/components/ToolCard.js +79 -69
  122. package/dist/react/components/mcp-ui-question-input.d.ts +1 -1
  123. package/dist/react/components/mcp-ui-question-input.js +3 -3
  124. package/dist/react/components/mcp-ui-surface-state.d.ts +1 -1
  125. package/dist/react/features/chat-pane/agent-tools.d.ts +1 -1
  126. package/dist/react/features/chat-pane/antigravity/model-options.d.ts +2 -0
  127. package/dist/react/features/chat-pane/antigravity/model-options.js +2 -0
  128. package/dist/react/features/chat-pane/claude/model-options.d.ts +2 -0
  129. package/dist/react/features/chat-pane/claude/model-options.js +2 -0
  130. package/dist/react/features/chat-pane/codex/model-options.d.ts +2 -0
  131. package/dist/react/features/chat-pane/codex/model-options.js +2 -0
  132. package/dist/react/features/chat-pane/components/AgentPluginUsage.d.ts +4 -1
  133. package/dist/react/features/chat-pane/components/AgentPluginUsage.js +2 -2
  134. package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts +10 -6
  135. package/dist/react/features/chat-pane/components/AgentRuntimePicker.js +18 -132
  136. package/dist/react/features/chat-pane/components/ChatPane.d.ts +24 -2
  137. package/dist/react/features/chat-pane/components/ChatPane.js +45 -297
  138. package/dist/react/features/chat-pane/components/ChatPaneComposerArea.d.ts +33 -0
  139. package/dist/react/features/chat-pane/components/ChatPaneComposerArea.js +119 -0
  140. package/dist/react/features/chat-pane/components/ChatPaneLayout.d.ts +42 -0
  141. package/dist/react/features/chat-pane/components/ChatPaneLayout.js +54 -0
  142. package/dist/react/features/chat-pane/components/ChatPaneStatus.d.ts +27 -0
  143. package/dist/react/features/chat-pane/components/ChatPaneStatus.js +91 -0
  144. package/dist/react/features/chat-pane/components/RuntimeDropUp.d.ts +6 -1
  145. package/dist/react/features/chat-pane/components/RuntimeDropUp.js +20 -19
  146. package/dist/react/features/chat-pane/components/RuntimePickerSections.d.ts +62 -0
  147. package/dist/react/features/chat-pane/components/RuntimePickerSections.js +122 -0
  148. package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.d.ts +1 -1
  149. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts +5 -3
  150. package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js +78 -26
  151. package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.js +6 -6
  152. package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.d.ts +5 -1
  153. package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.js +7 -7
  154. package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.d.ts +7 -0
  155. package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.js +5 -0
  156. package/dist/react/features/chat-pane/model-options.js +7 -4
  157. package/dist/react/features/chat-pane/styles.d.ts +1 -1
  158. package/dist/react/features/chat-pane/styles.js +25 -41
  159. package/dist/react/features/chat-pane/types.d.ts +29 -1
  160. package/dist/react/hooks/assistant-chats-contracts.d.ts +1 -1
  161. package/dist/react/hooks/attachment-preview-cache.d.ts +1 -1
  162. package/dist/react/hooks/attachment-preview-cache.js +1 -1
  163. package/dist/react/hooks/fab-position.js +16 -18
  164. package/dist/react/hooks/useConversation.d.ts +6 -1
  165. package/dist/react/hooks/useConversation.js +11 -10
  166. package/dist/react/hooks/useRunStream.d.ts +3 -0
  167. package/dist/react/hooks/useRunStream.js +12 -12
  168. package/dist/react/hooks/useSurfaceRecovery.d.ts +1 -1
  169. package/dist/react/hooks/useSurfaceRecovery.js +2 -2
  170. package/dist/react/index.d.ts +6 -3
  171. package/dist/react/index.js +5 -3
  172. package/dist/react/styles/chat-settings.css +9 -9
  173. package/dist/react/surfaces.d.ts +91 -0
  174. package/dist/react/surfaces.js +28 -0
  175. package/dist/server/durable-runs/recover.d.ts +4 -3
  176. package/dist/server/durable-runs/recover.js +4 -3
  177. package/dist/store/legacy/sqlite/conversations.d.ts +1 -2
  178. package/dist/store/legacy/sqlite/conversations.js +1 -1
  179. package/dist/store/legacy/sqlite/messages.d.ts +2 -3
  180. package/dist/store/legacy/sqlite/messages.js +6 -6
  181. package/dist/store/pglite/index.d.ts +7 -7
  182. package/dist/store/pglite/index.js +1 -1
  183. package/dist/store/ports.d.ts +5 -2
  184. package/dist/store/postgres/index.d.ts +7 -7
  185. package/dist/store/postgres/index.js +1 -1
  186. package/dist/store/runtime/chat-expiry-sweep.js +2 -4
  187. package/dist/store/runtime/chat-history-store.js +2 -3
  188. package/dist/store/runtime/durable-run-store.js +16 -2
  189. package/dist/store/runtime/history-tools.js +33 -11
  190. package/dist/store/runtime/kernel.d.ts +3 -2
  191. package/dist/store/runtime/run-ledger.js +2 -2
  192. package/dist/store/sql/boundary.d.ts +5 -5
  193. package/dist/store/sql/maintenance.d.ts +3 -2
  194. package/dist/store/sql/store.d.ts +16 -8
  195. package/dist/store/sql/store.js +31 -14
  196. package/dist/store/sqlite/index.d.ts +11 -12
  197. package/dist/store/sqlite/index.js +5 -5
  198. package/dist/store/sqlite/schema.d.ts +1 -1
  199. package/package.json +46 -24
  200. package/dist/core/ag-ui/entry.d.ts +0 -84
  201. package/dist/core/ag-ui/entry.js +0 -225
  202. package/dist/core/browser/page-actions.d.ts +0 -121
  203. package/dist/core/browser/page-actions.js +0 -113
  204. package/dist/embed-widget/browser/page-actions.d.ts +0 -2
  205. package/dist/embed-widget/browser/page-actions.js +0 -3
@@ -0,0 +1,60 @@
1
+ import type { Logger } from '@jini-ai/core/primitives';
2
+ import React, { type ReactNode } from 'react';
3
+ import type { ChatMessage } from '../../core/index.js';
4
+ import type { ToolTimelineRow } from '../hooks/useToolTimeline.js';
5
+ import type { ExtEventGroup } from '../hooks/useExtEventGroups.js';
6
+ import type { AnsweredCards } from '../hooks/useAnsweredCards.js';
7
+ import type { ExtEventRendererRegistry } from '../ext-event-renderer-registry.js';
8
+ import type { MessageBlock } from '../message-blocks.js';
9
+ import { type ToolCallDisplay } from '../tool-call-display.js';
10
+ import { type usageLayout } from './MessageRow.usage.js';
11
+ import type { MessageRowProps, UsageSummary as UsageSummaryComponent, ThinkingBlock as ThinkingBlockComponent, AssistantMessageFooter as AssistantMessageFooterComponent } from './MessageRow.js';
12
+ type AssistantBlock = MessageBlock<ToolTimelineRow>;
13
+ /** Build the assistant transcript renderers with the current row's state and host callbacks. */
14
+ export declare function useAssistantMessageRenderers({ message, rows, runStreaming, runSucceeded, projectFileNames, onRequestOpenFile, toolCallDisplay, registry, answeredCards, runInProgress, awaitingAnswer, questionFormInteractive, questionFormSubmittedAnswers, onQuestionFormSubmit, usage, showUsageLine, showUsageTotal, lastFinishedReply, extGroups, footerUsage, terminalNotice, pending, runSending, sendingLabel, visibleContent, flatTools, flatExtGroups, UsageSummary, ThinkingBlock, AssistantMessageFooter }: {
15
+ message: ChatMessage;
16
+ rows: ToolTimelineRow[];
17
+ runStreaming: boolean;
18
+ runSucceeded: boolean;
19
+ projectFileNames: MessageRowProps['projectFileNames'];
20
+ onRequestOpenFile: MessageRowProps['onRequestOpenFile'];
21
+ toolCallDisplay: ToolCallDisplay;
22
+ registry: ExtEventRendererRegistry;
23
+ answeredCards: AnsweredCards;
24
+ runInProgress: boolean;
25
+ awaitingAnswer: boolean;
26
+ questionFormInteractive: boolean;
27
+ questionFormSubmittedAnswers: MessageRowProps['questionFormSubmittedAnswers'];
28
+ onQuestionFormSubmit: MessageRowProps['onQuestionFormSubmit'];
29
+ usage: ReturnType<typeof usageLayout>;
30
+ showUsageLine: boolean;
31
+ showUsageTotal: boolean;
32
+ lastFinishedReply: number;
33
+ extGroups: ExtEventGroup[];
34
+ footerUsage: ReturnType<typeof usageLayout>['footer'];
35
+ terminalNotice: string | null;
36
+ pending: boolean;
37
+ runSending: boolean;
38
+ sendingLabel: string | undefined;
39
+ visibleContent: string;
40
+ flatTools: {
41
+ rows: readonly ToolTimelineRow[];
42
+ key: string;
43
+ }[];
44
+ flatExtGroups: ExtEventGroup[];
45
+ UsageSummary: typeof UsageSummaryComponent;
46
+ ThinkingBlock: typeof ThinkingBlockComponent;
47
+ AssistantMessageFooter: typeof AssistantMessageFooterComponent;
48
+ }, { report }?: {
49
+ report?: Pick<Logger, 'error'> | undefined;
50
+ }): {
51
+ renderBlock: (block: AssistantBlock) => ReactNode;
52
+ renderExtGroup: (group: ExtEventGroup) => React.JSX.Element | null;
53
+ renderAssistantSection: ({ section, key, footer }: {
54
+ section: readonly AssistantBlock[] | null;
55
+ key: string;
56
+ footer: boolean;
57
+ }) => React.JSX.Element;
58
+ };
59
+ export {};
60
+ //# sourceMappingURL=MessageRow.hooks.d.ts.map
@@ -0,0 +1,94 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, {} from 'react';
3
+ import { splitOnQuestionForms } from '../../core/index.js';
4
+ import { retriedToolRowIds } from '../tool-call-display.js';
5
+ import { usageLineMeetsActions } from './MessageRow.usage.js';
6
+ import { MidRunUserMessage, MID_RUN_USER_MESSAGE_EXT_EVENT_NAME } from './MidRunUserMessage.js';
7
+ import { ExtEventErrorBoundary } from './ExtEventErrorBoundary.js';
8
+ import { Markdown } from './Markdown.js';
9
+ import { ToolCard } from './ToolCard.js';
10
+ import { QuestionForm } from './QuestionForm.js';
11
+ import { ToolCallGroup } from './ToolCallGroup.js';
12
+ /** Preserve optional render-prop presence for custom extension renderers. */
13
+ function answerRenderProps({ answeredCards, slot, answerText }, _options = {}) {
14
+ return { ...(answeredCards.isRecorded(slot) ? { answerRecorded: true } : {}),
15
+ ...(answerText === undefined ? {} : { answerText }) };
16
+ }
17
+ /** Build the assistant transcript renderers with the current row's state and host callbacks. */
18
+ export function useAssistantMessageRenderers({ message, rows, runStreaming, runSucceeded, projectFileNames, onRequestOpenFile, toolCallDisplay, registry, answeredCards, runInProgress, awaitingAnswer, questionFormInteractive, questionFormSubmittedAnswers, onQuestionFormSubmit, usage, showUsageLine, showUsageTotal, lastFinishedReply, extGroups, footerUsage, terminalNotice, pending, runSending, sendingLabel, visibleContent, flatTools, flatExtGroups, UsageSummary, ThinkingBlock, AssistantMessageFooter }, { report } = {}) {
19
+ const retriedRows = retriedToolRowIds({ rows });
20
+ const renderToolCard = (row) => (_jsx(ToolCard, { report: report, retried: retriedRows.has(row.id), use: row.use, result: row.result, runStreaming: runStreaming, runSucceeded: runSucceeded, ...(projectFileNames !== undefined ? { projectFileNames } : {}), ...(onRequestOpenFile !== undefined ? { onRequestOpenFile } : {}) }, row.id));
21
+ // Hidden mode reuses the same disclosure and card renderer for unrecovered failures.
22
+ const renderTools = (rows, key) => (toolCallDisplay !== 'show'
23
+ ? _jsx(ToolCallGroup, { rows: rows, renderRow: renderToolCard, failureOnly: toolCallDisplay === 'hidden' }, key)
24
+ : _jsx("div", { className: "jini-message-tools", children: rows.map(renderToolCard) }, key));
25
+ const renderExtGroup = (group) => {
26
+ const transcriptRow = group.name === MID_RUN_USER_MESSAGE_EXT_EVENT_NAME;
27
+ const renderer = registry.get({ name: group.name });
28
+ if (!renderer && group.name === MID_RUN_USER_MESSAGE_EXT_EVENT_NAME)
29
+ return _jsx(MidRunUserMessage, { events: group.events, runStreaming: runInProgress, transcriptRow: true }, group.slot);
30
+ if (!renderer)
31
+ return null;
32
+ const answerText = answeredCards.answerText(group.slot);
33
+ const node = renderer({
34
+ name: group.name,
35
+ events: group.events,
36
+ runStreaming: group.name === MID_RUN_USER_MESSAGE_EXT_EVENT_NAME ? runInProgress : answeredCards.runStreaming,
37
+ ...(group.name === MID_RUN_USER_MESSAGE_EXT_EVENT_NAME ? { transcriptRow: true } : {}),
38
+ runSucceeded,
39
+ awaitingAnswer,
40
+ runId: message.runId,
41
+ ...(group.call === undefined ? {} : { call: group.call }),
42
+ answered: answeredCards.isAnswered(group.slot),
43
+ onAnswered: () => answeredCards.markAnswered(group.slot),
44
+ onAnswerText: (text) => answeredCards.markAnswered(group.slot, text),
45
+ ...answerRenderProps({ answeredCards, slot: group.slot, answerText }),
46
+ });
47
+ if (!node)
48
+ return null;
49
+ return (
50
+ // `key` includes the event count so a group that failed on an earlier, shorter event list
51
+ // gets a fresh boundary instance (not the still-tripped one) once a new event actually
52
+ // arrives for it, instead of staying tombstoned for the message's whole lifetime.
53
+ _jsx(ExtEventErrorBoundary, { name: group.name, report: report, children: transcriptRow ? node : _jsx("div", { children: node }) }, `${group.slot}:${group.events.length}`));
54
+ };
55
+ const renderTextSegments = (text, keyPrefix) => splitOnQuestionForms({ input: text }).map((segment, i) => {
56
+ if (segment.kind === 'text')
57
+ return segment.text.trim() ? (_jsx("div", { className: "jini-message-content", children: _jsx(Markdown, { children: segment.text }) }, `${keyPrefix}-${i}`)) : null;
58
+ return (_jsx(QuestionForm, { form: segment.form, interactive: questionFormInteractive, ...(questionFormSubmittedAnswers !== undefined ? { submittedAnswers: questionFormSubmittedAnswers } : {}), ...(onQuestionFormSubmit !== undefined ? { onSubmit: onQuestionFormSubmit } : {}) }, `${keyPrefix}-${i}`));
59
+ });
60
+ const renderBlock = (block) => {
61
+ if (block.kind === 'text') {
62
+ return _jsx(React.Fragment, { children: renderTextSegments(block.text, block.key) }, block.key);
63
+ }
64
+ if (block.kind === 'reply-end') {
65
+ const reply = usage.replies[block.index];
66
+ // A trailing input may have no reply: its predecessor's usage belongs above that input.
67
+ if (!reply || !showUsageLine)
68
+ return null;
69
+ return _jsx(UsageSummary, { usage: reply, showTotal: showUsageTotal, ...(block.index === lastFinishedReply ? { message } : {}) }, block.key);
70
+ }
71
+ if (block.kind === 'tools')
72
+ return renderTools(block.rows, block.key);
73
+ if (block.kind === 'thinking')
74
+ return _jsx(ThinkingBlock, { text: block.text }, block.key);
75
+ return renderExtBlock(block);
76
+ };
77
+ // A mid-run bubble is its own transcript row, so it skips the ext-events wrapper and its spacing.
78
+ const renderExtBlock = (block) => {
79
+ const group = extGroups.find((g) => g.slot === block.slot);
80
+ if (!group)
81
+ return null;
82
+ if (group.name === MID_RUN_USER_MESSAGE_EXT_EVENT_NAME)
83
+ return _jsx(React.Fragment, { children: renderExtGroup(group) }, block.key);
84
+ return (_jsx("div", { className: "jini-message-ext-events", children: renderExtGroup(group) }, block.key));
85
+ };
86
+ // The live footer follows the run as transcript sections split; its clock must not remount.
87
+ const renderAssistantSection = ({ section, key, footer }) => (_jsxs("div", { className: usageLineMeetsActions({ footer: footerUsage, terminalNotice, pending, runInProgress }, { showTotal: showUsageTotal })
88
+ ? 'jini-message jini-message-assistant jini-message-assistant--usage-actions'
89
+ : 'jini-message jini-message-assistant', "data-message-id": message.id, "data-run-status": message.runStatus, "data-agent-element": `chat-message-${message.id}`, "data-agent-role": "region", "data-agent-label": "A reply from the assistant", children: [message.agentName ? _jsx("div", { className: "jini-message-agent", children: message.agentName }) : null, section
90
+ ? section.map(renderBlock)
91
+ : (_jsxs(_Fragment, { children: [renderTextSegments(visibleContent, 'text'), flatTools.map((group) => renderTools(group.rows, group.key)), flatExtGroups.length > 0 ? _jsx("div", { className: "jini-message-ext-events", children: flatExtGroups.map(renderExtGroup) }) : null] })), footer && _jsx(AssistantMessageFooter, { message, usageEvent: footerUsage, showUsageTotal, terminalNotice, pending, runInProgress, runStreaming, runSending, sendingLabel, visibleContent, isAnsweredCard: answeredCards.isAnsweredCard })] }, footer ? message.id : key));
92
+ return { renderBlock, renderExtGroup, renderAssistantSection };
93
+ }
94
+ //# sourceMappingURL=MessageRow.hooks.js.map
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { FolderChips } from './FolderChips.js';
3
3
  import { projectAcceptedInputEvents } from '../../core/accepted-input.js';
4
- import { MidRunUserMessage, MID_RUN_USER_MESSAGE_EXT_EVENT_NAME } from './MidRunUserMessage.js';
4
+ import { MID_RUN_USER_MESSAGE_EXT_EVENT_NAME } from './MidRunUserMessage.js';
5
5
  import { useSurfaceAnswerContexts } from './mcp-ui-question-input.js';
6
6
  import { terminalMessageNotice, continuingRunNotice } from '../../core/durable-projection.js';
7
- import { usageEndLabel, usageLayout, usageLineMeetsActions, useMessageUsage, useUsageSummary } from './MessageRow.usage.js';
7
+ import { usageEndLabel, usageLayout, useMessageUsage, useUsageSummary } from './MessageRow.usage.js';
8
8
  /**
9
9
  * @module MessageRow
10
10
  *
@@ -56,23 +56,19 @@ import { usageEndLabel, usageLayout, usageLineMeetsActions, useMessageUsage, use
56
56
  * chunk stopped arriving.
57
57
  */
58
58
  import React, { memo, useMemo } from 'react';
59
- import { assistantContentFromEvents, isAwaitingAnswer, isTerminalRunStatus, splitOnQuestionForms, stripArtifact } from '../../core/index.js';
59
+ import { assistantContentFromEvents, isAwaitingAnswer, isTerminalRunStatus, stripArtifact } from '../../core/index.js';
60
60
  import { useToolTimeline } from '../hooks/useToolTimeline.js';
61
61
  import { useExtEventGroups } from '../hooks/useExtEventGroups.js';
62
62
  import { useRunActivity } from '../hooks/useRunActivity.js';
63
63
  import { useAnsweredCards } from '../hooks/useAnsweredCards.js';
64
64
  import { interleaveMessageBlocks, splitMidRunBlocks } from '../message-blocks.js';
65
65
  import { useT, useExtEventRendererRegistry } from '../hooks/context.js';
66
- import { ExtEventErrorBoundary } from './ExtEventErrorBoundary.js';
67
66
  import { AttachmentPreviewModal } from './AttachmentPreviewModal.js';
68
67
  import { SentAttachmentButton } from './SentAttachment.js';
69
68
  import { useAttachmentGallery } from './AttachmentGallery.hooks.js';
70
69
  import { CopyMessageButton } from './CopyMessageButton.js';
71
- import { Markdown } from './Markdown.js';
72
- import { ToolCard } from './ToolCard.js';
73
- import { QuestionForm } from './QuestionForm.js';
74
- import { ToolCallGroup } from './ToolCallGroup.js';
75
- import { applyToolCallDisplay, retriedToolRowIds, toolRowsForDisplay } from '../tool-call-display.js';
70
+ import { applyToolCallDisplay, toolRowsForDisplay } from '../tool-call-display.js';
71
+ import { useAssistantMessageRenderers } from './MessageRow.hooks.js';
76
72
  /**
77
73
  * True while an assistant message is still fully pending — no visible text
78
74
  * and no tool rows have arrived yet. Shared by the "Thinking…" placeholder
@@ -109,13 +105,15 @@ function isPendingWithNoContent(message, visibleContent, toolRowCount) {
109
105
  function isRunInProgress(runStatus) {
110
106
  return runStatus !== undefined && !isTerminalRunStatus({ status: runStatus });
111
107
  }
108
+ /** Hooks UsageSummary calls; defaults to the real ones, a test hands in fakes. */
109
+ export const defaultUsageSummaryHooks = { useT, useUsageSummary };
112
110
  /** One "Done · 6m 29s · $0.41 · total $2.50" line from reported usage, never estimated (the total is
113
111
  * left off when `showTotal` is false). Partial usage stays partial; output tokens are available to
114
112
  * assistive technology and in the tooltip. */
115
- function UsageSummary({ usage, showTotal, message, awaitingAnswer }) {
116
- const t = useT();
113
+ export function UsageSummary({ usage, showTotal, message, awaitingAnswer, hooks = defaultUsageSummaryHooks }) {
114
+ const t = hooks.useT();
117
115
  const label = usageEndLabel({ usage, ...(message === undefined ? {} : { message }), ...(awaitingAnswer === undefined ? {} : { awaitingAnswer }) });
118
- const { text, title, ariaLabel } = useUsageSummary({ usage }, { showTotal, label });
116
+ const { text, title, ariaLabel } = hooks.useUsageSummary({ usage }, { showTotal, label });
119
117
  if (!text)
120
118
  return null;
121
119
  return (_jsxs("div", { className: "jini-message-usage", title: title, role: "note", "aria-label": ariaLabel, children: [label === 'Done' ? _jsx("span", { className: "jini-message-usage-dot", "aria-hidden": true, children: "\u25CF" }) : null, t(label), " \u00B7 ", text] }));
@@ -142,15 +140,17 @@ function flatToolGroups({ message, rows, registry, displayBlocks }, { toolCallDi
142
140
  }
143
141
  /** The model's reasoning, folded under a "Thinking" summary so it never crowds the answer. */
144
142
  /** A host status belongs to the run that emitted it, regardless of the current picker selection. */
145
- function RunAccessNotice({ events }) {
146
- const t = useT();
143
+ function RunAccessNotice({ show, events, useTHook = useT }) {
144
+ const t = useTHook();
145
+ if (!show)
146
+ return null;
147
147
  const notice = events?.find(event => event.kind === 'status' && event.label === 'full_cli_access');
148
148
  if (notice?.kind !== 'status' || !notice.detail)
149
149
  return null;
150
150
  return _jsx("div", { className: "jini-chat-pane__notice", role: "status", children: t(notice.detail) });
151
151
  }
152
- function ThinkingBlock({ text }) {
153
- const t = useT();
152
+ export function ThinkingBlock({ text, useTHook = useT }) {
153
+ const t = useTHook();
154
154
  if (!text.trim())
155
155
  return null;
156
156
  return (_jsxs("details", { className: "jini-message-thinking", children: [_jsx("summary", { children: t('Thinking') }), _jsx("div", { className: "jini-message-thinking__text", children: text })] }));
@@ -158,8 +158,8 @@ function ThinkingBlock({ text }) {
158
158
  function messageAwaitingAnswer({ runStreaming, runInProgress, events }, { isAnsweredCard } = {}) {
159
159
  return runStreaming === true && runInProgress && isAwaitingAnswer({ events }, { isAnsweredCard });
160
160
  }
161
- function AssistantMessageFooter({ message, usageEvent, showUsageTotal, terminalNotice, pending, runInProgress, runStreaming, runSending, sendingLabel, visibleContent, isAnsweredCard }, _optional = {}) {
162
- const t = useT();
161
+ export function AssistantMessageFooter({ message, usageEvent, showUsageTotal, terminalNotice, pending, runInProgress, runStreaming, runSending, sendingLabel, visibleContent, isAnsweredCard, useTHook = useT }) {
162
+ const t = useTHook();
163
163
  return _jsxs(_Fragment, { children: [usageEvent ? _jsx(UsageSummary, { usage: usageEvent, showTotal: showUsageTotal, message: message, awaitingAnswer: isAwaitingAnswer({ events: message.events }, { isAnsweredCard }) }) : null, terminalNotice ? _jsx("div", { className: message.runStatus === 'canceled' ? 'jini-chat-pane__notice' : 'jini-message-error', role: "status", children: t(terminalNotice) }) : null, !pending && !runInProgress ? (_jsx("div", { className: "jini-message-actions jini-message-actions--assistant", children: _jsx(CopyMessageButton, { text: visibleContent, label: t('Copy message') }) })) : null, runInProgress ? _jsx(RunActivityLine, { events: message.events, active: pending || (runStreaming === true && runInProgress), isAnsweredCard: isAnsweredCard, sending: runSending, sendingLabel: sendingLabel }) : null] });
164
164
  }
165
165
  /** Stable empty list for a message with no attachments. */
@@ -169,22 +169,29 @@ const NO_ATTACHMENTS = [];
169
169
  * re-renders per composer keystroke) only re-renders rows whose props actually changed. Messages
170
170
  * are replaced, never mutated, so identity is a sound change signal.
171
171
  */
172
- export const MessageRow = memo(function MessageRow({ showUsageTotal = true, showUsageLine = true, toolCallDisplay = 'show', showThinking = false, runStreaming = false, runSending = false, runSucceeded = false, questionFormInteractive = false, ...props }) {
173
- const answerContexts = useSurfaceAnswerContexts({ events: props.message.events });
172
+ export const MessageRow = memo(function MessageRow({ useSurfaceAnswerContextsHook = useSurfaceAnswerContexts, ...props }) {
173
+ const answerContexts = useSurfaceAnswerContextsHook({ events: props.message.events });
174
174
  const message = useMemo(() => props.message.events === undefined ? props.message : {
175
175
  ...props.message, events: projectAcceptedInputEvents({ events: props.message.events }, answerContexts),
176
176
  }, [props.message, answerContexts]);
177
177
  if (message.role === 'user')
178
178
  return _jsx(UserMessageRow, { ...props, message: message });
179
- return _jsx(AssistantMessageRow, { ...props, message: message, showUsageTotal, showUsageLine, toolCallDisplay, showThinking, runStreaming, runSending, runSucceeded, questionFormInteractive });
179
+ return _jsx(AssistantMessageRow, { ...resolveDisplayProps(props), message: message });
180
180
  });
181
- function UserMessageRow({ message, renderAttachment }) {
182
- const t = useT();
181
+ /** `MessageRow`'s display props with their defaults applied, ready for `AssistantMessageRow`. */
182
+ function resolveDisplayProps(props, _options = {}) {
183
+ const { showUsageTotal = true, showUsageLine = true, toolCallDisplay = 'show', showThinking = false, runStreaming = false, runSending = false, runSucceeded = false, questionFormInteractive = false, } = props;
184
+ return { ...props, showUsageTotal, showUsageLine, toolCallDisplay, showThinking, runStreaming, runSending, runSucceeded, questionFormInteractive };
185
+ }
186
+ /** Hooks UserMessageRow calls; defaults to the real ones, a test hands in fakes. */
187
+ const defaultUserMessageRowHooks = { useT, useAttachmentGallery };
188
+ function UserMessageRow({ message, renderAttachment, hooks = defaultUserMessageRowHooks }) {
189
+ const t = hooks.useT();
183
190
  // Which attachment chip (if any) this row's preview modal is open for. Row-local, not
184
191
  // module-level: two attachments in the same message can never be "open" at once, but two
185
192
  // different messages opening their own attachments independently is fine and expected.
186
193
  // Previous/next steps through this message's images only.
187
- const gallery = useAttachmentGallery({ attachments: message.attachments ?? NO_ATTACHMENTS });
194
+ const gallery = hooks.useAttachmentGallery({ attachments: message.attachments ?? NO_ATTACHMENTS });
188
195
  return (_jsxs("div", { className: "jini-message jini-message-user", "data-message-id": message.id, "data-agent-element": `chat-message-${message.id}`, "data-agent-role": "region", "data-agent-label": "A message from the user", children: [(message.attachments?.length || message.folders?.length) ? (_jsxs("div", { className: "jini-message-attachments", children: [_jsx(FolderChips, { folders: message.folders }), (message.attachments ?? []).map((a) => (_jsx(SentAttachmentButton, { attachment: a, onOpen: gallery.open, renderAttachment: renderAttachment }, a.path)))] })) : null, _jsx("div", { className: "jini-message-content", children: message.content }), _jsx("div", { className: "jini-message-actions jini-message-actions--user", children: _jsx(CopyMessageButton, { text: message.content, label: t('Copy message') }) }), gallery.opened ? (_jsx(AttachmentPreviewModal, { attachment: gallery.opened, onClose: gallery.close, navigation: gallery.navigation })) : null] }));
189
196
  }
190
197
  // A validated extension may already show the explanation. Keep the generic fallback when its
@@ -197,12 +204,14 @@ function assistantTerminalNotice({ message, runStreaming, runSucceeded, extGroup
197
204
  function lastFinishedReplyIndex({ runInProgress, usage }, _options = {}) {
198
205
  return !runInProgress && !usage.footer ? usage.replies.findLastIndex(value => value !== undefined) : -1;
199
206
  }
200
- function AssistantMessageRow({ showAccessNotice = true, message, usageSummary, showUsageTotal, showUsageLine, toolCallDisplay, showThinking, runStreaming, runSending, sendingLabel, runSucceeded, questionFormInteractive, questionFormSubmittedAnswers, onQuestionFormSubmit, projectFileNames, onRequestOpenFile, }) {
201
- const registry = useExtEventRendererRegistry();
202
- const messageUsage = useMessageUsage({ message, ...(usageSummary === undefined ? {} : { summary: usageSummary }) });
203
- const timeline = useToolTimeline({ events: message.events }, { runStreaming, runSucceeded });
204
- const extGroups = useExtEventGroups({ events: message.events }, { slotOf: (name, data) => registry.slot({ name, data }) });
205
- const answeredCards = useAnsweredCards({ slotOf: registry.slot, events: message.events ?? [], groups: extGroups, runStreaming, runStatus: message.runStatus });
207
+ /** Hooks AssistantMessageRow calls; defaults to the real ones, a test hands in fakes. */
208
+ const defaultAssistantMessageRowHooks = { useExtEventRendererRegistry, useMessageUsage, useToolTimeline, useExtEventGroups, useAnsweredCards, useAssistantMessageRenderers };
209
+ function AssistantMessageRow({ showAccessNotice = true, message, usageSummary, showUsageTotal, showUsageLine, toolCallDisplay, showThinking, runStreaming, runSending, sendingLabel, runSucceeded, questionFormInteractive, questionFormSubmittedAnswers, onQuestionFormSubmit, projectFileNames, onRequestOpenFile, hooks = defaultAssistantMessageRowHooks, report, }) {
210
+ const registry = hooks.useExtEventRendererRegistry();
211
+ const messageUsage = hooks.useMessageUsage({ message, ...(usageSummary === undefined ? {} : { summary: usageSummary }) });
212
+ const timeline = hooks.useToolTimeline({ events: message.events }, { runStreaming, runSucceeded });
213
+ const extGroups = hooks.useExtEventGroups({ events: message.events }, { slotOf: (name, data) => registry.slot({ name, data }) });
214
+ const answeredCards = hooks.useAnsweredCards({ slotOf: registry.slot, events: message.events ?? [], groups: extGroups, runStreaming, runStatus: message.runStatus });
206
215
  const terminalNotice = assistantTerminalNotice({ message, runStreaming, runSucceeded, extGroups, registry });
207
216
  const visibleContent = stripArtifact({ content: message.content });
208
217
  const displayBlocks = messageBlocks({ message, rows: timeline.rows, registry }, { toolCallDisplay, includeThinking: showThinking });
@@ -217,98 +226,27 @@ function AssistantMessageRow({ showAccessNotice = true, message, usageSummary, s
217
226
  });
218
227
  const footerUsage = showUsageLine ? usage.footer : undefined;
219
228
  const lastFinishedReply = lastFinishedReplyIndex({ runInProgress, usage });
220
- const retriedRows = retriedToolRowIds({ rows: timeline.rows });
221
- const renderToolCard = (row) => (_jsx(ToolCard, { retried: retriedRows.has(row.id), use: row.use, result: row.result, runStreaming: runStreaming, runSucceeded: runSucceeded, ...(projectFileNames !== undefined ? { projectFileNames } : {}), ...(onRequestOpenFile !== undefined ? { onRequestOpenFile } : {}) }, row.id));
222
- // Hidden mode reuses the same disclosure and card renderer for unrecovered failures.
223
- const renderTools = (rows, key) => (toolCallDisplay !== 'show'
224
- ? _jsx(ToolCallGroup, { rows: rows, renderRow: renderToolCard, failureOnly: toolCallDisplay === 'hidden' }, key)
225
- : _jsx("div", { className: "jini-message-tools", children: rows.map(renderToolCard) }, key));
226
229
  const flatTools = flatToolGroups({ message, rows: timeline.rows, registry, displayBlocks }, { toolCallDisplay });
227
230
  const flatExtGroups = extGroups.filter(group => group.name !== MID_RUN_USER_MESSAGE_EXT_EVENT_NAME);
228
- const renderExtGroup = (group) => {
229
- const transcriptRow = group.name === MID_RUN_USER_MESSAGE_EXT_EVENT_NAME;
230
- const renderer = registry.get({ name: group.name });
231
- if (!renderer && group.name === MID_RUN_USER_MESSAGE_EXT_EVENT_NAME)
232
- return _jsx(MidRunUserMessage, { events: group.events, runStreaming: runInProgress, transcriptRow: true }, group.slot);
233
- if (!renderer)
234
- return null;
235
- const answerText = answeredCards.answerText(group.slot);
236
- const node = renderer({
237
- name: group.name,
238
- events: group.events,
239
- runStreaming: group.name === MID_RUN_USER_MESSAGE_EXT_EVENT_NAME ? runInProgress : answeredCards.runStreaming,
240
- ...(group.name === MID_RUN_USER_MESSAGE_EXT_EVENT_NAME ? { transcriptRow: true } : {}),
241
- runSucceeded,
242
- awaitingAnswer,
243
- runId: message.runId,
244
- ...(group.call === undefined ? {} : { call: group.call }),
245
- answered: answeredCards.isAnswered(group.slot),
246
- onAnswered: () => answeredCards.markAnswered(group.slot),
247
- onAnswerText: (text) => answeredCards.markAnswered(group.slot, text),
248
- ...answerRenderProps({ answeredCards, slot: group.slot, answerText }),
249
- });
250
- if (!node)
251
- return null;
252
- return (
253
- // `key` includes the event count so a group that failed on an earlier, shorter event list
254
- // gets a fresh boundary instance (not the still-tripped one) once a new event actually
255
- // arrives for it, instead of staying tombstoned for the message's whole lifetime.
256
- _jsx(ExtEventErrorBoundary, { name: group.name, children: transcriptRow ? node : _jsx("div", { children: node }) }, `${group.slot}:${group.events.length}`));
257
- };
258
- const renderTextSegments = (text, keyPrefix) => splitOnQuestionForms({ input: text }).map((segment, i) => {
259
- if (segment.kind === 'text')
260
- return segment.text.trim() ? (_jsx("div", { className: "jini-message-content", children: _jsx(Markdown, { children: segment.text }) }, `${keyPrefix}-${i}`)) : null;
261
- return (_jsx(QuestionForm, { form: segment.form, interactive: questionFormInteractive, ...(questionFormSubmittedAnswers !== undefined ? { submittedAnswers: questionFormSubmittedAnswers } : {}), ...(onQuestionFormSubmit !== undefined ? { onSubmit: onQuestionFormSubmit } : {}) }, `${keyPrefix}-${i}`));
262
- });
263
- const renderBlock = (block) => {
264
- if (block.kind === 'text') {
265
- return _jsx(React.Fragment, { children: renderTextSegments(block.text, block.key) }, block.key);
266
- }
267
- if (block.kind === 'reply-end') {
268
- const reply = usage.replies[block.index];
269
- // A trailing input may have no reply: its predecessor's usage belongs above that input.
270
- if (!reply || !showUsageLine)
271
- return null;
272
- return _jsx(UsageSummary, { usage: reply, showTotal: showUsageTotal, ...(block.index === lastFinishedReply ? { message } : {}) }, block.key);
273
- }
274
- if (block.kind === 'tools')
275
- return renderTools(block.rows, block.key);
276
- if (block.kind === 'thinking')
277
- return _jsx(ThinkingBlock, { text: block.text }, block.key);
278
- return renderExtBlock(block);
279
- };
280
- // A mid-run bubble is its own transcript row, so it skips the ext-events wrapper and its spacing.
281
- const renderExtBlock = (block) => {
282
- const group = extGroups.find((g) => g.slot === block.slot);
283
- if (!group)
284
- return null;
285
- if (group.name === MID_RUN_USER_MESSAGE_EXT_EVENT_NAME)
286
- return _jsx(React.Fragment, { children: renderExtGroup(group) }, block.key);
287
- return (_jsx("div", { className: "jini-message-ext-events", children: renderExtGroup(group) }, block.key));
288
- };
289
- // The live footer follows the run as transcript sections split; its clock must not remount.
290
- const renderAssistantSection = ({ section, key, footer }) => (_jsxs("div", { className: usageLineMeetsActions({ footer: footerUsage, terminalNotice, pending, runInProgress }, { showTotal: showUsageTotal })
291
- ? 'jini-message jini-message-assistant jini-message-assistant--usage-actions'
292
- : 'jini-message jini-message-assistant', "data-message-id": message.id, "data-run-status": message.runStatus, "data-agent-element": `chat-message-${message.id}`, "data-agent-role": "region", "data-agent-label": "A reply from the assistant", children: [message.agentName ? _jsx("div", { className: "jini-message-agent", children: message.agentName }) : null, section
293
- ? section.map(renderBlock)
294
- : (_jsxs(_Fragment, { children: [renderTextSegments(visibleContent, 'text'), flatTools.map((group) => renderTools(group.rows, group.key)), flatExtGroups.length > 0 ? _jsx("div", { className: "jini-message-ext-events", children: flatExtGroups.map(renderExtGroup) }) : null] })), footer && _jsx(AssistantMessageFooter, { message, usageEvent: footerUsage, showUsageTotal, terminalNotice, pending, runInProgress, runStreaming, runSending, sendingLabel, visibleContent, isAnsweredCard: answeredCards.isAnsweredCard })] }, footer ? message.id : key));
231
+ const { renderBlock, renderExtGroup, renderAssistantSection } = hooks.useAssistantMessageRenderers({
232
+ message, rows: timeline.rows, runStreaming, runSucceeded, projectFileNames, onRequestOpenFile,
233
+ toolCallDisplay, registry, answeredCards, runInProgress, awaitingAnswer, questionFormInteractive,
234
+ questionFormSubmittedAnswers, onQuestionFormSubmit, usage, showUsageLine, showUsageTotal,
235
+ lastFinishedReply, extGroups, footerUsage, terminalNotice, pending, runSending, sendingLabel,
236
+ visibleContent, flatTools, flatExtGroups, UsageSummary, ThinkingBlock, AssistantMessageFooter,
237
+ }, { report });
295
238
  // The lossless fallback keeps the host's text intact; user receipts still own separate rows,
296
239
  // in their original receipt order, outside the assistant's actions and usage footer.
297
240
  // Keep the same child-array nesting as the interleaved path so React preserves the footer.
298
241
  if (blocks === null)
299
- return _jsxs(_Fragment, { children: [showAccessNotice && _jsx(RunAccessNotice, { events: message.events }), [renderAssistantSection({ section: null, key: message.id, footer: true })], extGroups.filter(group => group.name === MID_RUN_USER_MESSAGE_EXT_EVENT_NAME).map(renderExtGroup)] });
242
+ return _jsxs(_Fragment, { children: [_jsx(RunAccessNotice, { show: showAccessNotice, events: message.events }), [renderAssistantSection({ section: null, key: message.id, footer: true })], extGroups.filter(group => group.name === MID_RUN_USER_MESSAGE_EXT_EVENT_NAME).map(renderExtGroup)] });
300
243
  // A reply boundary without reported usage renders nothing; it must not create an empty row's gap.
301
244
  const visibleBlocks = blocks.filter(block => block.kind !== 'reply-end' || (showUsageLine && usage.replies[block.index] !== undefined));
302
245
  const { sections, footerIndex } = transcriptSections({ blocks: visibleBlocks, runInProgress });
303
- return _jsxs(_Fragment, { children: [showAccessNotice && _jsx(RunAccessNotice, { events: message.events }), sections.map((section, index) => isUserSection({ section })
246
+ return _jsxs(_Fragment, { children: [_jsx(RunAccessNotice, { show: showAccessNotice, events: message.events }), sections.map((section, index) => isUserSection({ section })
304
247
  ? _jsx(React.Fragment, { children: section.map(renderBlock) }, section[0].key)
305
248
  : renderAssistantSection({ section, key: section[0]?.key ?? message.id, footer: index === footerIndex }))] });
306
249
  }
307
- /** Preserve optional render-prop presence for custom extension renderers. */
308
- function answerRenderProps({ answeredCards, slot, answerText }, _options = {}) {
309
- return { ...(answeredCards.isRecorded(slot) ? { answerRecorded: true } : {}),
310
- ...(answerText === undefined ? {} : { answerText }) };
311
- }
312
250
  /** Place the one footer on the last assistant section, never below a completed trailing input. */
313
251
  function transcriptSections({ blocks, runInProgress }, _options = {}) {
314
252
  const sections = splitMidRunBlocks({ blocks });
@@ -326,15 +264,17 @@ function isUserSection({ section }, _options = {}) {
326
264
  const block = section?.[0];
327
265
  return block?.kind === 'ext' && block.name === MID_RUN_USER_MESSAGE_EXT_EVENT_NAME;
328
266
  }
267
+ /** Hooks RunActivityLine calls; defaults to the real ones, a test hands in fakes. */
268
+ const defaultRunActivityLineHooks = { useT, useRunActivity };
329
269
  /**
330
270
  * The live "what is it doing" line under a running reply (see `core/run-activity.ts`). Replaces the
331
271
  * old "Thinking…" placeholder, which vanished for good as soon as the first tool row appeared.
332
272
  * Kept a separate component so its one-second tick re-renders only this line, not the whole row.
333
273
  * A host's already-localized sending label is used verbatim until acceptance.
334
274
  */
335
- function RunActivityLine({ events, active, isAnsweredCard, sending, sendingLabel }) {
336
- const t = useT();
337
- const activityLabel = useRunActivity({ events: events, active: active }, { isAnsweredCard });
275
+ function RunActivityLine({ events, active, isAnsweredCard, sending, sendingLabel, hooks = defaultRunActivityLineHooks }) {
276
+ const t = hooks.useT();
277
+ const activityLabel = hooks.useRunActivity({ events: events, active: active }, { isAnsweredCard });
338
278
  // Until the server accepts the start the turn is still on its way: "Thinking…" there read as the
339
279
  // model working while the text had not even arrived (owner, 2026-10-27). No timeout.
340
280
  const label = active && sending ? sendingLabel ?? t('Sending…') : continuingRunNotice({ events, active }, {}) ?? activityLabel;
@@ -1,3 +1,5 @@
1
+ import { useAttachmentGallery } from './AttachmentGallery.hooks.js';
2
+ import { useT } from '../hooks/context.js';
1
3
  import { type ExtEventRenderProps } from '../ext-event-renderer-registry.js';
2
4
  /** The ext-event name the daemon's mid-run `user_message` run event arrives under. One source with
3
5
  * the core reply split (`replySegments`), which ends a reply's usage at this same event. */
@@ -7,7 +9,10 @@ export declare function midRunUserMessageSlotKey({ data }: {
7
9
  data: unknown;
8
10
  }): string | undefined;
9
11
  /** The bubble for one mid-run message — the same classes as a sent user message, so it reads as one. */
10
- export declare function MidRunUserMessage({ events, runStreaming, transcriptRow }: Pick<ExtEventRenderProps, 'events'> & Partial<Pick<ExtEventRenderProps, 'runStreaming' | 'transcriptRow'>>): import("react").JSX.Element | null;
12
+ export declare function MidRunUserMessage({ events, runStreaming, transcriptRow, useTHook, useAttachmentGalleryHook }: {
13
+ useTHook?: typeof useT;
14
+ useAttachmentGalleryHook?: typeof useAttachmentGallery;
15
+ } & Pick<ExtEventRenderProps, 'events'> & Partial<Pick<ExtEventRenderProps, 'runStreaming' | 'transcriptRow'>>): import("react").JSX.Element | null;
11
16
  /**
12
17
  * Registers {@link MidRunUserMessage} against the ext-event registry.
13
18
  *
@@ -31,7 +31,7 @@ export function midRunUserMessageSlotKey({ data }) {
31
31
  return field(data, 'id');
32
32
  }
33
33
  /** The bubble for one mid-run message — the same classes as a sent user message, so it reads as one. */
34
- export function MidRunUserMessage({ events, runStreaming = false, transcriptRow = false }) {
34
+ export function MidRunUserMessage({ events, runStreaming = false, transcriptRow = false, useTHook, useAttachmentGalleryHook }) {
35
35
  const data = events.at(-1);
36
36
  const text = field(data, 'text');
37
37
  if (text === undefined)
@@ -40,15 +40,15 @@ export function MidRunUserMessage({ events, runStreaming = false, transcriptRow
40
40
  // MOVE: A single live delivery may contain several queued inputs; display their original receipts.
41
41
  const inputs = receipt?.data.inputs ?? [receipt?.data ?? { id: field(data, 'id') ?? 'mid-run', text }];
42
42
  // A run that ended without reading the message hands it to the next turn; it is no longer queued here.
43
- return _jsx(_Fragment, { children: inputs.map(input => _jsx(MidRunInput, { input: input, transcriptRow: transcriptRow, queued: runStreaming && (input.deliveryState ?? receipt?.data.deliveryState) === 'queued' }, input.id)) });
43
+ return _jsx(_Fragment, { children: inputs.map(input => _jsx(MidRunInput, { input: input, transcriptRow: transcriptRow, queued: runStreaming && (input.deliveryState ?? receipt?.data.deliveryState) === 'queued', ...(useTHook ? { useTHook } : {}), ...(useAttachmentGalleryHook ? { useAttachmentGalleryHook } : {}) }, input.id)) });
44
44
  }
45
45
  /** One receipt's text, files and shared copy action; queued state belongs to this input alone.
46
46
  * @complexity O(a) time/space for a attachments; clipboard and gallery effects stay with their owners.
47
47
  */
48
- function MidRunInput({ input, queued, transcriptRow }) {
49
- const t = useT();
48
+ function MidRunInput({ input, queued, transcriptRow, useTHook = useT, useAttachmentGalleryHook = useAttachmentGallery }) {
49
+ const t = useTHook();
50
50
  const attachments = input.attachments ?? [];
51
- const gallery = useAttachmentGallery({ attachments });
51
+ const gallery = useAttachmentGalleryHook({ attachments });
52
52
  return (_jsxs("div", { className: `jini-message jini-message-user${transcriptRow ? '' : ' jini-message-user--mid-run'}`, "data-agent-role": "region", "data-agent-label": "A message from the user, sent while the agent was working", children: [queued && _jsx("div", { className: "jini-chat-pane__status jini-message-user__queued", role: "status", children: t('Queued — read after the current step') }), input.folders?.length ? _jsx("div", { className: "jini-message-attachments", children: _jsx(FolderChips, { folders: input.folders }) }) : null, _jsx("div", { className: "jini-message-content", children: input.text }), attachments.length > 0 && _jsx("div", { className: "jini-message-attachments", children: attachments.map(attachment => _jsx(SentAttachmentButton, { attachment: attachment, onOpen: gallery.open }, attachment.path)) }), _jsx("div", { className: "jini-message-actions jini-message-actions--user", children: _jsx(CopyMessageButton, { text: input.text, label: t('Copy message') }) }), gallery.opened !== null && _jsx(AttachmentPreviewModal, { attachment: gallery.opened, onClose: gallery.close, navigation: gallery.navigation })] }));
53
53
  }
54
54
  /**
@@ -16,6 +16,7 @@
16
16
  * action-row shape; every user-facing string wrapped in `useT()`.
17
17
  */
18
18
  import type { ReactNode } from 'react';
19
+ import { useT } from '../hooks/context.js';
19
20
  export interface NextStepAction {
20
21
  id: string;
21
22
  label: string;
@@ -29,6 +30,7 @@ export interface NextStepAction {
29
30
  export interface NextStepActionsProps {
30
31
  actions: NextStepAction[];
31
32
  onSelect: (actionId: string) => void;
33
+ useTHook?: typeof useT;
32
34
  }
33
- export declare function NextStepActions({ actions, onSelect }: NextStepActionsProps): import("react").JSX.Element | null;
35
+ export declare function NextStepActions({ actions, onSelect, useTHook }: NextStepActionsProps): import("react").JSX.Element | null;
34
36
  //# sourceMappingURL=NextStepActions.d.ts.map
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useT } from '../hooks/context.js';
3
- export function NextStepActions({ actions, onSelect }) {
4
- const t = useT();
3
+ export function NextStepActions({ actions, onSelect, useTHook = useT }) {
4
+ const t = useTHook();
5
5
  if (actions.length === 0)
6
6
  return null;
7
- return (_jsx("div", { className: "next-step-actions", children: actions.map((action) => (_jsxs("button", { type: "button", className: "next-step-action", disabled: action.disabled || action.busy, onClick: () => onSelect(action.id), children: [action.icon ? (_jsx("span", { className: "next-step-action-icon", "aria-hidden": true, children: action.icon })) : null, _jsxs("span", { className: "next-step-action-body", children: [_jsx("span", { className: "next-step-action-title", children: action.busy && action.busyLabel ? t(action.busyLabel) : t(action.label) }), action.description ? _jsx("span", { className: "next-step-action-desc", children: t(action.description) }) : null] })] }, action.id))) }));
7
+ return (_jsx("div", { className: "jini-next-step-actions", children: actions.map((action) => (_jsxs("button", { type: "button", className: "jini-next-step-action", disabled: action.disabled || action.busy, onClick: () => onSelect(action.id), children: [action.icon ? (_jsx("span", { className: "jini-next-step-action-icon", "aria-hidden": true, children: action.icon })) : null, _jsxs("span", { className: "jini-next-step-action-body", children: [_jsx("span", { className: "jini-next-step-action-title", children: action.busy && action.busyLabel ? t(action.busyLabel) : t(action.label) }), action.description ? _jsx("span", { className: "jini-next-step-action-desc", children: t(action.description) }) : null] })] }, action.id))) }));
8
8
  }
9
9
  //# sourceMappingURL=NextStepActions.js.map
@@ -0,0 +1,26 @@
1
+ import type { QuestionForm as QuestionFormType } from '../../core/index.js';
2
+ import type { QuestionFormProps } from './QuestionForm.js';
3
+ type Question = QuestionFormType['questions'][number];
4
+ type Answers = Record<string, string | string[]>;
5
+ /** Owns the editable answers plus the picked files; every edit is a no-op once the form is locked. */
6
+ export declare function useQuestionAnswers({ form, submittedAnswers, draftAnswers, locked }: {
7
+ form: QuestionFormType;
8
+ submittedAnswers: Answers | undefined;
9
+ draftAnswers: Answers | undefined;
10
+ locked: boolean;
11
+ }, { onDraftChange, onAnswerChange }?: {
12
+ onDraftChange?: QuestionFormProps['onDraftChange'] | undefined;
13
+ onAnswerChange?: QuestionFormProps['onAnswerChange'] | undefined;
14
+ }): {
15
+ answers: Answers;
16
+ setAnswers: import("react").Dispatch<import("react").SetStateAction<Answers>>;
17
+ fileAnswers: Record<string, File[]>;
18
+ handlers: {
19
+ update: (id: string, value: string | string[]) => void;
20
+ toggleCheckbox: (id: string, option: string, maxSelections?: number) => void;
21
+ updateCheckboxCustom: (q: Question, raw: string) => void;
22
+ selectFiles: (q: Question, list: FileList | null) => void;
23
+ };
24
+ };
25
+ export {};
26
+ //# sourceMappingURL=QuestionForm.answers.hooks.d.ts.map