@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.
- package/CHANGELOG.md +2 -12
- package/README.md +3 -3
- package/dist/contracts/chat-bubble-style.d.ts +1 -1
- package/dist/contracts/chat-bubble-style.js +1 -1
- package/dist/core/ag-ui/event-projection.d.ts +125 -0
- package/dist/core/ag-ui/event-projection.js +275 -0
- package/dist/core/ag-ui/event-reduction.d.ts +39 -0
- package/dist/core/ag-ui/event-reduction.js +99 -0
- package/dist/core/ag-ui/run-input.d.ts +53 -0
- package/dist/core/ag-ui/run-input.js +87 -0
- package/dist/core/agentic/chat-capabilities.d.ts +1 -1
- package/dist/core/agentic/index.d.ts +2 -4
- package/dist/core/agentic/index.js +2 -3
- package/dist/core/agents-port.d.ts +50 -0
- package/dist/core/agents-port.js +2 -0
- package/dist/core/assistant-client/ag-ui-fetch-agent.d.ts +16 -0
- package/dist/core/assistant-client/ag-ui-fetch-agent.js +24 -0
- package/dist/core/assistant-client/ag-ui-transport.d.ts +15 -1
- package/dist/core/assistant-client/ag-ui-transport.js +167 -145
- package/dist/core/assistant-client/attachment-liveness.js +13 -11
- package/dist/core/assistant-client/durable-run-subscription.d.ts +3 -2
- package/dist/core/assistant-client/durable-run-subscription.js +6 -5
- package/dist/core/assistant-client/messages.d.ts +7 -4
- package/dist/core/assistant-client/messages.js +5 -4
- package/dist/core/assistant-client/transport.d.ts +1 -1
- package/dist/core/assistant-client/transport.js +4 -4
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +1 -0
- package/dist/core/page-port.d.ts +15 -0
- package/dist/core/page-port.js +2 -0
- package/dist/core/run-activity.js +1 -1
- package/dist/core/run-events/entry.js +1 -0
- package/dist/core/user-text-redaction.d.ts +1 -3
- package/dist/core/user-text-redaction.js +3 -61
- package/dist/embed-widget/browser/agent-inventory.d.ts +37 -0
- package/dist/embed-widget/browser/agent-inventory.js +36 -0
- package/dist/embed-widget/browser/frontend-session-bridge.d.ts +2 -2
- package/dist/embed-widget/browser/frontend-session-bridge.js +17 -14
- package/dist/embed-widget/react/dialog.hooks.d.ts +16 -0
- package/dist/embed-widget/react/dialog.hooks.js +15 -0
- package/dist/embed-widget/react/embed.d.ts +7 -2
- package/dist/embed-widget/react/embed.js +6 -16
- package/dist/embed-widget/react/header.d.ts +4 -1
- package/dist/embed-widget/react/header.js +2 -2
- package/dist/embed-widget/vanilla/state.js +2 -2
- package/dist/embed-widget/vanilla/style.css +4 -4
- package/dist/react/components/A2uiSurfaceCard.d.ts +18 -4
- package/dist/react/components/A2uiSurfaceCard.hooks.d.ts +36 -0
- package/dist/react/components/A2uiSurfaceCard.hooks.js +174 -0
- package/dist/react/components/A2uiSurfaceCard.js +14 -227
- package/dist/react/components/A2uiSurfaceCard.rules.d.ts +14 -0
- package/dist/react/components/A2uiSurfaceCard.rules.js +24 -0
- package/dist/react/components/AttachmentPreviewModal.d.ts +21 -1
- package/dist/react/components/AttachmentPreviewModal.hooks.js +1 -3
- package/dist/react/components/AttachmentPreviewModal.js +11 -9
- package/dist/react/components/AttachmentTray.d.ts +11 -1
- package/dist/react/components/AttachmentTray.js +12 -8
- package/dist/react/components/ChatFab.d.ts +10 -1
- package/dist/react/components/ChatFab.js +2 -2
- package/dist/react/components/ChatSettingsDialog.d.ts +4 -3
- package/dist/react/components/ChatSettingsDialog.js +9 -6
- package/dist/react/components/ChatSettingsSegmented.d.ts +1 -1
- package/dist/react/components/ChatSettingsSegmented.js +1 -1
- package/dist/react/components/Composer.d.ts +9 -1
- package/dist/react/components/Composer.hooks.d.ts +79 -0
- package/dist/react/components/Composer.hooks.js +336 -0
- package/dist/react/components/Composer.js +40 -341
- package/dist/react/components/ComposerDiscovery.js +1 -1
- package/dist/react/components/ConversationList.d.ts +34 -1
- package/dist/react/components/ConversationList.hooks.d.ts +37 -0
- package/dist/react/components/ConversationList.hooks.js +177 -1
- package/dist/react/components/ConversationList.js +7 -174
- package/dist/react/components/ConversationTitleEditor.d.ts +17 -2
- package/dist/react/components/ConversationTitleEditor.hooks.d.ts +15 -0
- package/dist/react/components/ConversationTitleEditor.hooks.js +36 -0
- package/dist/react/components/ConversationTitleEditor.js +11 -34
- package/dist/react/components/CopyMessageButton.d.ts +6 -1
- package/dist/react/components/CopyMessageButton.js +4 -4
- package/dist/react/components/ExtEventErrorBoundary.d.ts +2 -0
- package/dist/react/components/ExtEventErrorBoundary.js +5 -3
- package/dist/react/components/FolderChips.d.ts +11 -1
- package/dist/react/components/FolderChips.hooks.d.ts +12 -0
- package/dist/react/components/FolderChips.hooks.js +10 -0
- package/dist/react/components/FolderChips.js +9 -9
- package/dist/react/components/Markdown.js +7 -5
- package/dist/react/components/McpUiSurfaceCard.d.ts +29 -5
- package/dist/react/components/McpUiSurfaceCard.js +29 -16
- package/dist/react/components/MessageList.d.ts +10 -1
- package/dist/react/components/MessageList.hooks.d.ts +0 -4
- package/dist/react/components/MessageList.hooks.js +6 -18
- package/dist/react/components/MessageList.js +17 -20
- package/dist/react/components/MessageList.rules.d.ts +0 -5
- package/dist/react/components/MessageList.rules.js +0 -4
- package/dist/react/components/MessageRow.d.ts +46 -2
- package/dist/react/components/MessageRow.hooks.d.ts +60 -0
- package/dist/react/components/MessageRow.hooks.js +94 -0
- package/dist/react/components/MessageRow.js +53 -113
- package/dist/react/components/MidRunUserMessage.d.ts +6 -1
- package/dist/react/components/MidRunUserMessage.js +5 -5
- package/dist/react/components/NextStepActions.d.ts +3 -1
- package/dist/react/components/NextStepActions.js +3 -3
- package/dist/react/components/QuestionForm.answers.hooks.d.ts +26 -0
- package/dist/react/components/QuestionForm.answers.hooks.js +89 -0
- package/dist/react/components/QuestionForm.d.ts +6 -0
- package/dist/react/components/QuestionForm.js +23 -261
- package/dist/react/components/QuestionForm.values.d.ts +22 -0
- package/dist/react/components/QuestionForm.values.js +58 -0
- package/dist/react/components/QuestionFormField.d.ts +17 -0
- package/dist/react/components/QuestionFormField.js +114 -0
- package/dist/react/components/QuestionsPanel.d.ts +3 -1
- package/dist/react/components/QuestionsPanel.js +7 -3
- package/dist/react/components/SentAttachment.d.ts +11 -2
- package/dist/react/components/SentAttachment.hooks.d.ts +1 -1
- package/dist/react/components/SentAttachment.hooks.js +6 -5
- package/dist/react/components/SentAttachment.js +5 -3
- package/dist/react/components/TodoCard.d.ts +3 -1
- package/dist/react/components/TodoCard.js +9 -4
- package/dist/react/components/ToolCallGroup.d.ts +11 -1
- package/dist/react/components/ToolCallGroup.js +10 -4
- package/dist/react/components/ToolCard.d.ts +6 -1
- package/dist/react/components/ToolCard.js +79 -69
- package/dist/react/components/mcp-ui-question-input.d.ts +1 -1
- package/dist/react/components/mcp-ui-question-input.js +3 -3
- package/dist/react/components/mcp-ui-surface-state.d.ts +1 -1
- package/dist/react/features/chat-pane/agent-tools.d.ts +1 -1
- package/dist/react/features/chat-pane/antigravity/model-options.d.ts +2 -0
- package/dist/react/features/chat-pane/antigravity/model-options.js +2 -0
- package/dist/react/features/chat-pane/claude/model-options.d.ts +2 -0
- package/dist/react/features/chat-pane/claude/model-options.js +2 -0
- package/dist/react/features/chat-pane/codex/model-options.d.ts +2 -0
- package/dist/react/features/chat-pane/codex/model-options.js +2 -0
- package/dist/react/features/chat-pane/components/AgentPluginUsage.d.ts +4 -1
- package/dist/react/features/chat-pane/components/AgentPluginUsage.js +2 -2
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts +10 -6
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.js +18 -132
- package/dist/react/features/chat-pane/components/ChatPane.d.ts +24 -2
- package/dist/react/features/chat-pane/components/ChatPane.js +45 -297
- package/dist/react/features/chat-pane/components/ChatPaneComposerArea.d.ts +33 -0
- package/dist/react/features/chat-pane/components/ChatPaneComposerArea.js +119 -0
- package/dist/react/features/chat-pane/components/ChatPaneLayout.d.ts +42 -0
- package/dist/react/features/chat-pane/components/ChatPaneLayout.js +54 -0
- package/dist/react/features/chat-pane/components/ChatPaneStatus.d.ts +27 -0
- package/dist/react/features/chat-pane/components/ChatPaneStatus.js +91 -0
- package/dist/react/features/chat-pane/components/RuntimeDropUp.d.ts +6 -1
- package/dist/react/features/chat-pane/components/RuntimeDropUp.js +20 -19
- package/dist/react/features/chat-pane/components/RuntimePickerSections.d.ts +62 -0
- package/dist/react/features/chat-pane/components/RuntimePickerSections.js +122 -0
- package/dist/react/features/chat-pane/create-mcp-ui-tool-caller.d.ts +1 -1
- package/dist/react/features/chat-pane/hooks/useChatPane.hooks.d.ts +5 -3
- package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js +78 -26
- package/dist/react/features/chat-pane/hooks/useChatPaneAgentControl.hooks.js +6 -6
- package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.d.ts +5 -1
- package/dist/react/features/chat-pane/hooks/useChatPaneFileDrop.hooks.js +7 -7
- package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.d.ts +7 -0
- package/dist/react/features/chat-pane/hooks/useRuntimeDropUp.hooks.js +5 -0
- package/dist/react/features/chat-pane/model-options.js +7 -4
- package/dist/react/features/chat-pane/styles.d.ts +1 -1
- package/dist/react/features/chat-pane/styles.js +25 -41
- package/dist/react/features/chat-pane/types.d.ts +29 -1
- package/dist/react/hooks/assistant-chats-contracts.d.ts +1 -1
- package/dist/react/hooks/attachment-preview-cache.d.ts +1 -1
- package/dist/react/hooks/attachment-preview-cache.js +1 -1
- package/dist/react/hooks/fab-position.js +16 -18
- package/dist/react/hooks/useConversation.d.ts +6 -1
- package/dist/react/hooks/useConversation.js +11 -10
- package/dist/react/hooks/useRunStream.d.ts +3 -0
- package/dist/react/hooks/useRunStream.js +12 -12
- package/dist/react/hooks/useSurfaceRecovery.d.ts +1 -1
- package/dist/react/hooks/useSurfaceRecovery.js +2 -2
- package/dist/react/index.d.ts +6 -3
- package/dist/react/index.js +5 -3
- package/dist/react/styles/chat-settings.css +9 -9
- package/dist/react/surfaces.d.ts +91 -0
- package/dist/react/surfaces.js +28 -0
- package/dist/server/durable-runs/recover.d.ts +4 -3
- package/dist/server/durable-runs/recover.js +4 -3
- package/dist/store/legacy/sqlite/conversations.d.ts +1 -2
- package/dist/store/legacy/sqlite/conversations.js +1 -1
- package/dist/store/legacy/sqlite/messages.d.ts +2 -3
- package/dist/store/legacy/sqlite/messages.js +6 -6
- package/dist/store/pglite/index.d.ts +7 -7
- package/dist/store/pglite/index.js +1 -1
- package/dist/store/ports.d.ts +5 -2
- package/dist/store/postgres/index.d.ts +7 -7
- package/dist/store/postgres/index.js +1 -1
- package/dist/store/runtime/chat-expiry-sweep.js +2 -4
- package/dist/store/runtime/chat-history-store.js +2 -3
- package/dist/store/runtime/durable-run-store.js +16 -2
- package/dist/store/runtime/history-tools.js +33 -11
- package/dist/store/runtime/kernel.d.ts +3 -2
- package/dist/store/runtime/run-ledger.js +2 -2
- package/dist/store/sql/boundary.d.ts +5 -5
- package/dist/store/sql/maintenance.d.ts +3 -2
- package/dist/store/sql/store.d.ts +16 -8
- package/dist/store/sql/store.js +31 -14
- package/dist/store/sqlite/index.d.ts +11 -12
- package/dist/store/sqlite/index.js +5 -5
- package/dist/store/sqlite/schema.d.ts +1 -1
- package/package.json +46 -24
- package/dist/core/ag-ui/entry.d.ts +0 -84
- package/dist/core/ag-ui/entry.js +0 -225
- package/dist/core/browser/page-actions.d.ts +0 -121
- package/dist/core/browser/page-actions.js +0 -113
- package/dist/embed-widget/browser/page-actions.d.ts +0 -2
- package/dist/embed-widget/browser/page-actions.js +0 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { describeErrorForLog } from '@jini-ai/core/model-facing-tool-errors';
|
|
3
|
+
import { createConsoleLogger } from '@jini-ai/core/primitives';
|
|
3
4
|
/**
|
|
4
5
|
* @module ExtEventErrorBoundary
|
|
5
6
|
*
|
|
@@ -26,12 +27,13 @@ export class ExtEventErrorBoundary extends Component {
|
|
|
26
27
|
// React already surfaces this in the dev console via its own error-boundary reporting; this
|
|
27
28
|
// adds the ext-event `name` React's generic report has no way to know, and gives a host a
|
|
28
29
|
// hook to route it into its own error reporting.
|
|
29
|
-
|
|
30
|
+
const logger = this.props.report ?? createConsoleLogger({ prefix: '' });
|
|
31
|
+
logger.error({ message: `[ExtEventErrorBoundary] ext event "${this.props.name}" failed to render:` }, { error });
|
|
30
32
|
this.props.onError?.(error, info);
|
|
31
33
|
}
|
|
32
34
|
render() {
|
|
33
35
|
if (this.state.error) {
|
|
34
|
-
return (_jsx("div", { className: "jini-ext-event-error", role: "alert", "data-ext-event-name": this.props.name, children: `"${this.props.name}"
|
|
36
|
+
return (_jsx("div", { className: "jini-ext-event-error", role: "alert", "data-ext-event-name": this.props.name, children: `"${this.props.name}" could not be rendered (${describeErrorForLog({ err: this.state.error })}).` }));
|
|
35
37
|
}
|
|
36
38
|
return this.props.children;
|
|
37
39
|
}
|
|
@@ -1,15 +1,25 @@
|
|
|
1
|
+
import { useT } from '../hooks/context.js';
|
|
2
|
+
import { useFolderChips } from './FolderChips.hooks.js';
|
|
1
3
|
type OnRemove = (input: {
|
|
2
4
|
path: string;
|
|
3
5
|
}, options?: {}) => void;
|
|
6
|
+
/** Hooks FolderChips calls; defaults to the real ones, a test hands in fakes. */
|
|
7
|
+
export declare const defaultFolderChipsHooks: {
|
|
8
|
+
useT: typeof useT;
|
|
9
|
+
useFolderChips: typeof useFolderChips;
|
|
10
|
+
};
|
|
11
|
+
export type FolderChipsHooks = typeof defaultFolderChipsHooks;
|
|
4
12
|
/**
|
|
5
13
|
* Shared composer/sent-message folder indicator; references never participate in uploads.
|
|
6
14
|
* One folder shows its chip directly; a "Folders (n)" toggle would only repeat its name.
|
|
7
15
|
*/
|
|
8
|
-
export declare function FolderChips({ agentHandle, folders, onRemove }: {
|
|
16
|
+
export declare function FolderChips({ agentHandle, folders, onRemove, hooks }: {
|
|
9
17
|
/** Inherited Composer base; standalone sent-message folders remain opt-in. */
|
|
10
18
|
agentHandle?: string | false | undefined;
|
|
11
19
|
folders?: readonly string[] | undefined;
|
|
12
20
|
onRemove?: OnRemove | undefined;
|
|
21
|
+
} & {
|
|
22
|
+
hooks?: FolderChipsHooks | undefined;
|
|
13
23
|
}): import("react").JSX.Element | null;
|
|
14
24
|
export {};
|
|
15
25
|
//# sourceMappingURL=FolderChips.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/** Track disclosure state and render the same list for single and multiple folders. */
|
|
3
|
+
export declare function useFolderChips({ folders, renderChip }: {
|
|
4
|
+
folders: readonly string[];
|
|
5
|
+
renderChip: (path: string) => ReactNode;
|
|
6
|
+
}, _options?: {}): {
|
|
7
|
+
expanded: boolean;
|
|
8
|
+
setExpanded: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
9
|
+
id: string;
|
|
10
|
+
list: (listId?: string) => import("react").JSX.Element;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=FolderChips.hooks.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from 'react';
|
|
3
|
+
/** Track disclosure state and render the same list for single and multiple folders. */
|
|
4
|
+
export function useFolderChips({ folders, renderChip }, _options = {}) {
|
|
5
|
+
const [expanded, setExpanded] = useState(false);
|
|
6
|
+
const id = useId();
|
|
7
|
+
const list = (listId) => _jsx("ul", { id: listId, className: "jini-folder-chips__list", children: folders.map(renderChip) });
|
|
8
|
+
return { expanded, setExpanded, id, list };
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=FolderChips.hooks.js.map
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { agentHandleProps, agentHandleSegment } from '@jini-ai/agentic';
|
|
2
|
+
import { agentHandleProps, agentHandleSegment } from '@jini-ai/core/agent-handles';
|
|
4
3
|
import { useT } from '../hooks/context.js';
|
|
5
4
|
import { CopyMessageButton } from './CopyMessageButton.js';
|
|
6
5
|
import { Icon } from './Icon.js';
|
|
6
|
+
import { useFolderChips } from './FolderChips.hooks.js';
|
|
7
7
|
/** Display only: splitting both separators never changes the exact path carried or copied. */
|
|
8
8
|
function folderName({ path }, _options = {}) {
|
|
9
9
|
return path.split(/[\\/]/).filter(Boolean).at(-1) ?? path;
|
|
10
10
|
}
|
|
11
11
|
/** One folder: last name (full path on hover), copy, and × when removable. */
|
|
12
|
-
function FolderChip({ base, path, onRemove }) {
|
|
13
|
-
const t =
|
|
12
|
+
function FolderChip({ base, path, onRemove, useTHook = useT }) {
|
|
13
|
+
const t = useTHook();
|
|
14
14
|
const segment = agentHandleSegment({ value: path });
|
|
15
15
|
const copyLabel = t('Copy folder path: {path}', { path });
|
|
16
16
|
const removeLabel = t('Remove folder: {path}', { path });
|
|
17
17
|
return _jsxs("li", { className: "jini-folder-chips__item", children: [_jsx(Icon, { name: "folder" }), _jsx("span", { className: "jini-folder-chips__name", title: path, "aria-label": path, children: folderName({ path }) }), _jsx(CopyMessageButton, { agentHandle: base ? `${base}-folder-copy-${segment}` : false, text: path, label: copyLabel, title: copyLabel }), onRemove && _jsx("button", { type: "button", className: "jini-folder-chips__remove", title: removeLabel, ...agentHandleProps({}, { base, action: `folder-remove-${segment}`, role: 'button', label: removeLabel }), "aria-label": removeLabel, onClick: () => onRemove({ path }), children: _jsx(Icon, { name: "close" }) })] });
|
|
18
18
|
}
|
|
19
|
+
/** Hooks FolderChips calls; defaults to the real ones, a test hands in fakes. */
|
|
20
|
+
export const defaultFolderChipsHooks = { useT, useFolderChips };
|
|
19
21
|
/**
|
|
20
22
|
* Shared composer/sent-message folder indicator; references never participate in uploads.
|
|
21
23
|
* One folder shows its chip directly; a "Folders (n)" toggle would only repeat its name.
|
|
22
24
|
*/
|
|
23
|
-
export function FolderChips({ agentHandle, folders = [], onRemove }) {
|
|
25
|
+
export function FolderChips({ agentHandle, folders = [], onRemove, hooks = defaultFolderChipsHooks }) {
|
|
24
26
|
const base = agentHandle || undefined;
|
|
25
|
-
const t = useT();
|
|
26
|
-
const
|
|
27
|
-
const id = useId();
|
|
27
|
+
const t = hooks.useT();
|
|
28
|
+
const { expanded, setExpanded, id, list } = hooks.useFolderChips({ folders, renderChip: path => _jsx(FolderChip, { base: base, path: path, onRemove: onRemove }, path) });
|
|
28
29
|
if (folders.length === 0)
|
|
29
30
|
return null;
|
|
30
|
-
const list = (listId) => _jsx("ul", { id: listId, className: "jini-folder-chips__list", children: folders.map(path => _jsx(FolderChip, { base: base, path: path, onRemove: onRemove }, path)) });
|
|
31
31
|
if (folders.length === 1)
|
|
32
32
|
return _jsx("div", { className: "jini-folder-chips", children: list() });
|
|
33
33
|
return _jsxs("div", { className: "jini-folder-chips", children: [_jsxs("button", { type: "button", className: "jini-folder-chips__toggle", "aria-expanded": expanded, "aria-controls": id, ...agentHandleProps({}, { base, action: 'folders-toggle', role: 'button', label: t('Folders ({count})', { count: folders.length }) }), onClick: () => setExpanded(value => !value), children: [_jsx(Icon, { name: "folder" }), _jsx("span", { children: t('Folders ({count})', { count: folders.length }) }), _jsx(Icon, { name: expanded ? 'chevron-down' : 'chevron-right' })] }), expanded && list(id)] });
|
|
@@ -303,12 +303,14 @@ function renderBlock(block) {
|
|
|
303
303
|
function CodeBlock({ lang, body }) {
|
|
304
304
|
return (_jsxs("div", { className: "jini-md-code-block", children: [_jsx("div", { className: "jini-md-code-toolbar", children: _jsx(CopyCodeButton, { code: body }) }), _jsx("pre", { children: _jsx("code", { "data-lang": lang ?? undefined, children: body }) })] }));
|
|
305
305
|
}
|
|
306
|
+
/** Hooks CopyCodeButton calls; defaults to the real ones, a test hands in fakes. */
|
|
307
|
+
const defaultCopyCodeButtonHooks = { useT, useCopyToClipboard };
|
|
306
308
|
// Per-block copy affordance for CodeBlock above. Mirrors MessageRow.tsx's CopyMessageButton
|
|
307
309
|
// one-for-one in shape -- same hook, same icon swap, same visually-hidden aria-live announce --
|
|
308
310
|
// but stays its own component rather than a shared one; see this module's header comment for why.
|
|
309
|
-
function CopyCodeButton({ code }) {
|
|
310
|
-
const t = useT();
|
|
311
|
-
const { copied, copy } = useCopyToClipboard();
|
|
311
|
+
function CopyCodeButton({ code, hooks = defaultCopyCodeButtonHooks }) {
|
|
312
|
+
const t = hooks.useT();
|
|
313
|
+
const { copied, copy } = hooks.useCopyToClipboard();
|
|
312
314
|
return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", className: "jini-md-code-copy", "aria-label": copied ? t('Copied') : t('Copy code'), onClick: () => {
|
|
313
315
|
void copy(code);
|
|
314
316
|
}, children: _jsx(Icon, { name: copied ? 'check' : 'copy' }) }), _jsx("span", { className: "jini-md-code-copy-status", "aria-live": "polite", children: copied ? t('Copied to clipboard') : '' })] }));
|
|
@@ -377,8 +379,8 @@ function closeTableDialog(dialog) {
|
|
|
377
379
|
}
|
|
378
380
|
dialog.removeAttribute('open');
|
|
379
381
|
}
|
|
380
|
-
function TableBlock(props) {
|
|
381
|
-
const { wrapRef, isOverflowing } =
|
|
382
|
+
function TableBlock({ useTableOverflowHook = useTableOverflow, ...props }) {
|
|
383
|
+
const { wrapRef, isOverflowing } = useTableOverflowHook();
|
|
382
384
|
const [expanded, setExpanded] = useState(false);
|
|
383
385
|
const dialogRef = useRef(null);
|
|
384
386
|
useEffect(() => {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { type McpUiToolCallHandler } from '@jini-ai/
|
|
2
|
-
import { type ExtEventRendererRegistry, type ExtEventRenderProps } from '../ext-event-renderer-registry.js';
|
|
3
|
-
import {
|
|
1
|
+
import { type McpUiToolCallHandler } from '@jini-ai/protocol/mcp-ui';
|
|
2
|
+
import { type ExtEventRendererRegistry, type ExtEventCall, type ExtEventRenderProps } from '../ext-event-renderer-registry.js';
|
|
3
|
+
import { useT } from '../hooks/context.js';
|
|
4
|
+
import { useSurfaceExpiry, type SurfaceExpiryClock } from '../hooks/useSurfaceExpiry.js';
|
|
5
|
+
import { useSurfaceRecovery } from '../hooks/useSurfaceRecovery.js';
|
|
4
6
|
/** The `kind: 'ext'` event name this renderer claims. */
|
|
5
7
|
export declare const MCP_UI_EXT_EVENT_NAME = "mcp-ui";
|
|
6
8
|
export interface McpUiSurfaceCardProps extends ExtEventRenderProps {
|
|
@@ -8,7 +10,7 @@ export interface McpUiSurfaceCardProps extends ExtEventRenderProps {
|
|
|
8
10
|
* Where the sandbox proxy page is served. Required since 2026-08-18, when this card's rendering
|
|
9
11
|
* switched from a hand-rolled `srcdoc` iframe to the real `@mcp-ui/client` `AppRenderer`, which
|
|
10
12
|
* mounts every View through a real, separately-served proxy page rather than inline HTML — see
|
|
11
|
-
* `@jini-ai/ui/mcp-ui`'s `SANDBOX_PROXY_HTML` (in `sandbox-proxy.
|
|
13
|
+
* `@jini-ai/ui/mcp-ui`'s `SANDBOX_PROXY_HTML` (in `packages/ui/src/features/mcp-ui/sandbox-proxy.ts`) for what must be running at
|
|
12
14
|
* that URL and why this package cannot supply a default itself.
|
|
13
15
|
*/
|
|
14
16
|
sandboxProxyUrl: URL;
|
|
@@ -29,8 +31,29 @@ export interface McpUiSurfaceCardProps extends ExtEventRenderProps {
|
|
|
29
31
|
*/
|
|
30
32
|
expiryClock?: SurfaceExpiryClock;
|
|
31
33
|
}
|
|
34
|
+
/** Hooks McpUiSurfaceCard calls; defaults to the real ones, a test hands in fakes. */
|
|
35
|
+
export declare const defaultMcpUiSurfaceCardHooks: {
|
|
36
|
+
useT: typeof useT;
|
|
37
|
+
useSurfaceRecovery: typeof useSurfaceRecovery;
|
|
38
|
+
useSurfaceQuestionCall: typeof useSurfaceQuestionCall;
|
|
39
|
+
useSurfaceExpiry: typeof useSurfaceExpiry;
|
|
40
|
+
};
|
|
41
|
+
export type McpUiSurfaceCardHooks = typeof defaultMcpUiSurfaceCardHooks;
|
|
32
42
|
/** Registered against `ext-event-renderer-registry.ts`'s `'mcp-ui'` name — see module doc. */
|
|
33
|
-
export declare function McpUiSurfaceCard({ events, sandboxProxyUrl, onToolCall, onOpenLink, maxHeight, call, runStreaming, expiryClock, answered, onAnswered, onAnswerText, answerText, answerRecorded }: McpUiSurfaceCardProps
|
|
43
|
+
export declare function McpUiSurfaceCard({ events, sandboxProxyUrl, onToolCall, onOpenLink, maxHeight, call, runStreaming, expiryClock, answered, onAnswered, onAnswerText, answerText, answerRecorded, hooks }: McpUiSurfaceCardProps & {
|
|
44
|
+
hooks?: McpUiSurfaceCardHooks | undefined;
|
|
45
|
+
}): import("react").JSX.Element;
|
|
46
|
+
/** A standalone form's call may lack the question; its current document supplies the title and
|
|
47
|
+
* option labels, so retry answers read as labels rather than raw values from the replaced question.
|
|
48
|
+
* Receipt recovery retains the original document separately in useSurfaceAnswerContexts. */
|
|
49
|
+
declare function useSurfaceQuestionCall({ events, call }: {
|
|
50
|
+
events: readonly unknown[];
|
|
51
|
+
call: ExtEventCall | undefined;
|
|
52
|
+
}, _options?: {}): {
|
|
53
|
+
displayCall: ExtEventCall;
|
|
54
|
+
input: unknown;
|
|
55
|
+
standalone: boolean;
|
|
56
|
+
};
|
|
34
57
|
/**
|
|
35
58
|
* The ext-event slot key for MCP-UI: one slot per `ui://` URI. Each resource is its own card, so a
|
|
36
59
|
* run's second card renders where it arrived instead of inside the first card's slot, while a
|
|
@@ -67,4 +90,5 @@ export declare function registerMcpUiSurfaceRenderer(options: {
|
|
|
67
90
|
/** Register in owned state when supplied; otherwise preserve the global API. */
|
|
68
91
|
registry?: ExtEventRendererRegistry;
|
|
69
92
|
}): () => void;
|
|
93
|
+
export {};
|
|
70
94
|
//# sourceMappingURL=McpUiSurfaceCard.d.ts.map
|
|
@@ -65,7 +65,8 @@ import { trimChars } from '@jini-ai/core/primitives';
|
|
|
65
65
|
import { questionAnswerFromResult, questionAnswerLabel } from '../../core/question-answer.js';
|
|
66
66
|
import { MidRunUserMessage } from './MidRunUserMessage.js';
|
|
67
67
|
import { Fragment, useMemo } from 'react';
|
|
68
|
-
import { McpUiHost
|
|
68
|
+
import { McpUiHost } from '../surfaces.js';
|
|
69
|
+
import { parseUIResource, readActionPlan, readExpiresAt, readPreferredFrameSize, } from '@jini-ai/protocol/mcp-ui';
|
|
69
70
|
import { defaultExtEventRendererRegistry } from '../ext-event-renderer-registry.js';
|
|
70
71
|
import { useT } from '../hooks/context.js';
|
|
71
72
|
import { useSurfaceExpiry } from '../hooks/useSurfaceExpiry.js';
|
|
@@ -78,7 +79,7 @@ export const MCP_UI_EXT_EVENT_NAME = 'mcp-ui';
|
|
|
78
79
|
function latestResourcesByUri(events) {
|
|
79
80
|
const byUri = new Map();
|
|
80
81
|
for (const event of events) {
|
|
81
|
-
const resource = parseUIResource(event);
|
|
82
|
+
const resource = parseUIResource({ value: event });
|
|
82
83
|
if (resource === undefined)
|
|
83
84
|
continue;
|
|
84
85
|
byUri.set(resource.resource.uri, resource);
|
|
@@ -140,39 +141,51 @@ function ClosedSurface({ call, label }) {
|
|
|
140
141
|
function surfaceInteraction({ resource, answered, onToolCall, onAnswered, onAnswerText, call }, _options = {}) {
|
|
141
142
|
// An answered card has no deadline left: its countdown goes, and the deadline passing while the
|
|
142
143
|
// answer's work still runs must not relabel it "This question expired".
|
|
143
|
-
const expiresAtMs = resource === undefined || answered === true ? undefined : readExpiresAt(resource);
|
|
144
|
+
const expiresAtMs = resource === undefined || answered === true ? undefined : readExpiresAt({ resource });
|
|
144
145
|
// Reports the person's delivered answer to the row, which stops the "Waiting for your answer" line.
|
|
145
146
|
const toolCall = onToolCall === undefined || onAnswered === undefined ? onToolCall : reportDeliveredAnswer({ onToolCall, onAnswered, onAnswerText, input: call?.input });
|
|
146
147
|
return { expiresAtMs, toolCall };
|
|
147
148
|
}
|
|
149
|
+
/** Hooks McpUiSurfaceCard calls; defaults to the real ones, a test hands in fakes. */
|
|
150
|
+
export const defaultMcpUiSurfaceCardHooks = { useT, useSurfaceRecovery, useSurfaceQuestionCall, useSurfaceExpiry };
|
|
148
151
|
/** Registered against `ext-event-renderer-registry.ts`'s `'mcp-ui'` name — see module doc. */
|
|
149
|
-
export function McpUiSurfaceCard({ events, sandboxProxyUrl, onToolCall, onOpenLink, maxHeight, call, runStreaming, expiryClock, answered, onAnswered, onAnswerText, answerText, answerRecorded }) {
|
|
150
|
-
const t = useT();
|
|
152
|
+
export function McpUiSurfaceCard({ events, sandboxProxyUrl, onToolCall, onOpenLink, maxHeight, call, runStreaming, expiryClock, answered, onAnswered, onAnswerText, answerText, answerRecorded, hooks = defaultMcpUiSurfaceCardHooks }) {
|
|
153
|
+
const t = hooks.useT();
|
|
151
154
|
const originalResources = useMemo(() => latestResourcesByUri(events), [events]);
|
|
152
|
-
const recovery = useSurfaceRecovery({ resource: originalResources.length === 1 ? originalResources[0] : undefined,
|
|
155
|
+
const recovery = hooks.useSurfaceRecovery({ resource: originalResources.length === 1 ? originalResources[0] : undefined,
|
|
153
156
|
call, runStreaming, onToolCall });
|
|
154
|
-
const resources
|
|
157
|
+
const { resources, currentEvents, currentCall } = recoveredView({ recovery, resources: originalResources, events, call });
|
|
155
158
|
// One card per slot is the registered shape (`mcpUiSurfaceSlotKey`), so `call` belongs to exactly
|
|
156
159
|
// that card. A group holding several URIs has no single call to judge them by, and stays live.
|
|
157
160
|
const single = resources.length === 1 ? resources[0] : undefined;
|
|
158
|
-
const
|
|
159
|
-
const currentCall = recovery.restored ? undefined : call;
|
|
160
|
-
const { displayCall, input, standalone } = useSurfaceQuestionCall({ events: currentEvents, call: currentCall });
|
|
161
|
+
const { displayCall, input, standalone } = hooks.useSurfaceQuestionCall({ events: currentEvents, call: currentCall });
|
|
161
162
|
const { expiresAtMs, toolCall } = surfaceInteraction({ resource: single, answered, onToolCall: recovery.onToolCall, onAnswered, onAnswerText, call: displayCall });
|
|
162
|
-
const expiry = useSurfaceExpiry({ expiresAtMs }, expiryClock === undefined ? {} : { clock: expiryClock });
|
|
163
|
+
const expiry = hooks.useSurfaceExpiry({ expiresAtMs }, expiryClock === undefined ? {} : { clock: expiryClock });
|
|
163
164
|
const closed = single === undefined
|
|
164
165
|
? undefined
|
|
165
166
|
: closedSurfaceLabel({ t, call: currentCall, runStreaming: recovery.live || runStreaming,
|
|
166
167
|
documentsForUri: currentEvents.length, expired: expiry?.expired === true });
|
|
167
168
|
// A completed call answered the original document; a replacement outcome or retry owns its view.
|
|
168
|
-
const answer = (
|
|
169
|
+
const answer = recordedOrTypedAnswer({ events: currentEvents, call: currentCall, input, answerText });
|
|
169
170
|
return _jsx(SurfaceCardContent, { resources: resources, single: single, answerRecorded: answerRecorded, answer: answer, closed: closed, call: displayCall, standalone: standalone, t: t, sandboxProxyUrl: sandboxProxyUrl, toolCall: toolCall, onOpenLink: onOpenLink, maxHeight: maxHeight, expiry: expiry });
|
|
170
171
|
}
|
|
172
|
+
/** A completed call's answer, when exactly one document was shown for it; else the answer the host typed. */
|
|
173
|
+
function recordedOrTypedAnswer({ events, call, input, answerText }, _options = {}) {
|
|
174
|
+
return (events.length === 1 ? questionAnswerFromResult({ result: call?.result, input }) : undefined) ?? answerText;
|
|
175
|
+
}
|
|
176
|
+
/** What the card shows after recovery: a restored document replaces the originals and leaves no call to judge it by. */
|
|
177
|
+
function recoveredView({ recovery, resources, events, call }, _options = {}) {
|
|
178
|
+
return {
|
|
179
|
+
resources: recovery.restored && recovery.resource ? [recovery.resource] : resources,
|
|
180
|
+
currentEvents: recovery.restored && recovery.resource ? [recovery.resource] : events,
|
|
181
|
+
currentCall: recovery.restored ? undefined : call,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
171
184
|
/** A standalone form's call may lack the question; its current document supplies the title and
|
|
172
185
|
* option labels, so retry answers read as labels rather than raw values from the replaced question.
|
|
173
186
|
* Receipt recovery retains the original document separately in useSurfaceAnswerContexts. */
|
|
174
187
|
function useSurfaceQuestionCall({ events, call }, _options = {}) {
|
|
175
|
-
const resource = parseUIResource(events.at(-1));
|
|
188
|
+
const resource = parseUIResource({ value: events.at(-1) });
|
|
176
189
|
const input = useMemo(() => surfaceQuestionInput({ resource, input: call?.input }), [resource?.resource.text, resource?.resource._meta, call?.input]);
|
|
177
190
|
const displayCall = call === undefined ? { name: '', input } : { ...call, input };
|
|
178
191
|
return { displayCall, input, standalone: input !== call?.input };
|
|
@@ -208,9 +221,9 @@ function SurfaceCardContent({ resources, single, answerRecorded, answer, closed,
|
|
|
208
221
|
return (_jsx("div", { className: "mcpui-surface-card mcpui-surface-card-empty", role: "status", children: t('This MCP-UI event carried no renderable resource.') }));
|
|
209
222
|
}
|
|
210
223
|
return (_jsxs("div", { className: "mcpui-surface-card", children: [resources.map((resource) => {
|
|
211
|
-
const preferred = readPreferredFrameSize(resource);
|
|
224
|
+
const preferred = readPreferredFrameSize({ resource });
|
|
212
225
|
const height = preferred === undefined ? undefined : Number.parseInt(preferred[1], 10);
|
|
213
|
-
const plan = readActionPlan(resource);
|
|
226
|
+
const plan = readActionPlan({ resource });
|
|
214
227
|
return (_jsxs(Fragment, { children: [_jsx(McpUiHost, { title: frameTitle ?? surfaceQuestionTitle({ resource }), html: resource.resource.text, sandboxProxyUrl: sandboxProxyUrl, toolName: resource.resource.uri,
|
|
215
228
|
// The whole document, not its LENGTH. `useMcpUiHost` already defaults `sessionKey` to
|
|
216
229
|
// `html` — exact by construction — and this override replaced that with a digest so
|
|
@@ -230,7 +243,7 @@ function SurfaceCardContent({ resources, single, answerRecorded, answer, closed,
|
|
|
230
243
|
* when registering a custom MCP-UI renderer; {@link registerMcpUiSurfaceRenderer} already does.
|
|
231
244
|
*/
|
|
232
245
|
export function mcpUiSurfaceSlotKey({ data }) {
|
|
233
|
-
return parseUIResource(data)?.resource.uri;
|
|
246
|
+
return parseUIResource({ value: data })?.resource.uri;
|
|
234
247
|
}
|
|
235
248
|
/**
|
|
236
249
|
* Registers {@link McpUiSurfaceCard} against the ext-event registry.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ChatAttachment, ChatMessage } from '../../core/index.js';
|
|
2
|
+
import { useMessageListAutoScroll, useConversationUsage } from './MessageList.hooks.js';
|
|
2
3
|
import { type MessageRowProps } from './MessageRow.js';
|
|
3
4
|
interface PendingPrompt {
|
|
4
5
|
id?: string;
|
|
@@ -24,12 +25,20 @@ export interface MessageListProps extends Pick<MessageRowProps, 'projectFileName
|
|
|
24
25
|
pendingPrompt?: PendingPrompt | null;
|
|
25
26
|
pendingPrompts?: readonly PendingPrompt[];
|
|
26
27
|
}
|
|
28
|
+
/** Hooks MessageList calls; defaults to the real ones, a test hands in fakes. */
|
|
29
|
+
export declare const defaultMessageListHooks: {
|
|
30
|
+
useConversationUsage: typeof useConversationUsage;
|
|
31
|
+
useMessageListAutoScroll: typeof useMessageListAutoScroll;
|
|
32
|
+
};
|
|
33
|
+
export type MessageListHooks = typeof defaultMessageListHooks;
|
|
27
34
|
/**
|
|
28
35
|
* Memoized: the pane re-renders on every composer keystroke, and re-rendering a long transcript
|
|
29
36
|
* (hundreds of tool rows, MCP-UI cards, markdown) per key made typing lag (owner report
|
|
30
37
|
* 2026-10-08). Callers must pass stable props — `ChatPane` memoizes `pendingPrompts` and
|
|
31
38
|
* `projectFileNames` for exactly this.
|
|
32
39
|
*/
|
|
33
|
-
export declare const MessageList: import("react").NamedExoticComponent<MessageListProps
|
|
40
|
+
export declare const MessageList: import("react").NamedExoticComponent<MessageListProps & {
|
|
41
|
+
hooks?: MessageListHooks | undefined;
|
|
42
|
+
}>;
|
|
34
43
|
export {};
|
|
35
44
|
//# sourceMappingURL=MessageList.d.ts.map
|
|
@@ -14,10 +14,6 @@ export interface MessageListAutoScroll {
|
|
|
14
14
|
awayFromLatest: boolean;
|
|
15
15
|
/** Scrolls to the newest message and resumes following new output. */
|
|
16
16
|
jumpToLatest: () => void;
|
|
17
|
-
/** True while the transcript is taller than its box — the "Jump to top" arrow needs somewhere to go. */
|
|
18
|
-
scrollable: boolean;
|
|
19
|
-
/** Scrolls to the oldest message and stops following new output. */
|
|
20
|
-
jumpToTop: () => void;
|
|
21
17
|
}
|
|
22
18
|
/** Recompute costs once per immutable transcript snapshot, including saved history on reload. */
|
|
23
19
|
export declare function useConversationUsage({ messages }: {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
8
8
|
import { conversationUsage } from '../../core/turn-usage.js';
|
|
9
9
|
import { projectAcceptedInputEvents } from '../../core/accepted-input.js';
|
|
10
|
-
import {
|
|
10
|
+
import { nextStickToBottom, startsNewTurn } from './MessageList.rules.js';
|
|
11
11
|
const prefersReducedMotion = () => typeof window !== 'undefined' && (window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false);
|
|
12
12
|
/** Recompute costs once per immutable transcript snapshot, including saved history on reload. */
|
|
13
13
|
export function useConversationUsage({ messages }, _optional = {}) {
|
|
@@ -35,6 +35,9 @@ export function useMessageListAutoScroll({ messages, scrollIntent }, { onScrolle
|
|
|
35
35
|
// Starts true: a freshly mounted pane opens on the latest turn, same as scrollIntent's own default.
|
|
36
36
|
const stickToBottomRef = useRef(true);
|
|
37
37
|
const previousMessagesRef = useRef(messages);
|
|
38
|
+
// Read the latest callback without making callback identity trigger an extra scroll.
|
|
39
|
+
const onScrolledRef = useRef(onScrolled);
|
|
40
|
+
onScrolledRef.current = onScrolled;
|
|
38
41
|
// `scrollTop` at the previous `scroll` event — `nextStickToBottom` needs the direction of travel.
|
|
39
42
|
// Only scroll events write it (a browser fires one for programmatic scrolls too). Starts at
|
|
40
43
|
// Infinity, "no position seen yet", so a first event away from the bottom unsticks as it always did.
|
|
@@ -42,8 +45,6 @@ export function useMessageListAutoScroll({ messages, scrollIntent }, { onScrolle
|
|
|
42
45
|
// State mirror of `!stickToBottomRef.current` for the "Jump to latest" button; the ref stays the
|
|
43
46
|
// source of truth for the scroll effects, which must not wait for a render.
|
|
44
47
|
const [awayFromLatest, setAwayFromLatest] = useState(false);
|
|
45
|
-
// Whether there is history above to jump up to; refreshed on scroll and whenever rows change size.
|
|
46
|
-
const [scrollable, setScrollable] = useState(false);
|
|
47
48
|
// Runs BEFORE the scroll effect below (effects run in declaration order), so a send re-sticks in
|
|
48
49
|
// time for that same commit's scroll. The user's own send (or retry) is an explicit "take me to
|
|
49
50
|
// the latest turn": without this, a user who had scrolled up to read history and then sent stayed
|
|
@@ -70,8 +71,7 @@ export function useMessageListAutoScroll({ messages, scrollIntent }, { onScrolle
|
|
|
70
71
|
if (el && stickToBottomRef.current) {
|
|
71
72
|
el.scrollTop = el.scrollHeight;
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
74
|
+
onScrolledRef.current?.();
|
|
75
75
|
}, [scrollIntent, messages]);
|
|
76
76
|
// Re-sticks to the bottom when a message ROW grows after mount with no accompanying `messages`
|
|
77
77
|
// change — the exact case an embedded MCP-UI/A2UI surface hits: it mounts at an initial guessed
|
|
@@ -91,7 +91,6 @@ export function useMessageListAutoScroll({ messages, scrollIntent }, { onScrolle
|
|
|
91
91
|
if (!el || typeof ResizeObserver !== 'function')
|
|
92
92
|
return undefined;
|
|
93
93
|
const observer = new ResizeObserver(() => {
|
|
94
|
-
setScrollable(hasOverflow(el));
|
|
95
94
|
if (!stickToBottomRef.current)
|
|
96
95
|
return;
|
|
97
96
|
el.scrollTop = el.scrollHeight;
|
|
@@ -105,7 +104,6 @@ export function useMessageListAutoScroll({ messages, scrollIntent }, { onScrolle
|
|
|
105
104
|
stickToBottomRef.current = nextStickToBottom(el, { wasSticking: stickToBottomRef.current, previousScrollTop: lastScrollTopRef.current });
|
|
106
105
|
lastScrollTopRef.current = el.scrollTop;
|
|
107
106
|
setAwayFromLatest(!stickToBottomRef.current);
|
|
108
|
-
setScrollable(hasOverflow(el));
|
|
109
107
|
};
|
|
110
108
|
const jumpToLatest = useCallback(() => {
|
|
111
109
|
const el = containerRef.current;
|
|
@@ -117,16 +115,6 @@ export function useMessageListAutoScroll({ messages, scrollIntent }, { onScrolle
|
|
|
117
115
|
setAwayFromLatest(false);
|
|
118
116
|
el.scrollTo({ top: el.scrollHeight, behavior: reducedMotion() ? 'auto' : 'smooth' });
|
|
119
117
|
}, [reducedMotion]);
|
|
120
|
-
|
|
121
|
-
const el = containerRef.current;
|
|
122
|
-
if (!el)
|
|
123
|
-
return;
|
|
124
|
-
// Unstick first, mirroring jumpToLatest: otherwise output streaming in during the smooth scroll
|
|
125
|
-
// re-sticks via the ResizeObserver and yanks the reader straight back down.
|
|
126
|
-
stickToBottomRef.current = false;
|
|
127
|
-
setAwayFromLatest(true);
|
|
128
|
-
el.scrollTo({ top: 0, behavior: reducedMotion() ? 'auto' : 'smooth' });
|
|
129
|
-
}, [reducedMotion]);
|
|
130
|
-
return { containerRef, onScroll, awayFromLatest, jumpToLatest, scrollable, jumpToTop };
|
|
118
|
+
return { containerRef, onScroll, awayFromLatest, jumpToLatest };
|
|
131
119
|
}
|
|
132
120
|
//# sourceMappingURL=MessageList.hooks.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
* @module MessageList
|
|
4
4
|
*
|
|
@@ -24,19 +24,21 @@ function renderMessageRow({ message, isLast, isStreaming, usageSummary, sending,
|
|
|
24
24
|
const runStreaming = isLast && isStreaming && !isTerminalRunStatus({ status: message.runStatus });
|
|
25
25
|
return (_jsx(MessageRow, { message: message, ...rowProps, showAccessNotice: showAccessNotice, ...(usageSummary === undefined ? {} : { usageSummary }), runStreaming: runStreaming, runSending: sending, runSucceeded: message.runStatus === 'succeeded', questionFormInteractive: message.id === activeQuestionFormMessageId, ...(questionFormSubmittedAnswersByMessageId?.[message.id] !== undefined ? { questionFormSubmittedAnswers: questionFormSubmittedAnswersByMessageId[message.id] } : {}), ...(onQuestionFormSubmit !== undefined ? { onQuestionFormSubmit: (text, answers) => onQuestionFormSubmit(message.id, text, answers) } : {}) }, message.id));
|
|
26
26
|
}
|
|
27
|
+
/** Hooks MessageList calls; defaults to the real ones, a test hands in fakes. */
|
|
28
|
+
export const defaultMessageListHooks = { useConversationUsage, useMessageListAutoScroll };
|
|
27
29
|
/**
|
|
28
30
|
* Memoized: the pane re-renders on every composer keystroke, and re-rendering a long transcript
|
|
29
31
|
* (hundreds of tool rows, MCP-UI cards, markdown) per key made typing lag (owner report
|
|
30
32
|
* 2026-10-08). Callers must pass stable props — `ChatPane` memoizes `pendingPrompts` and
|
|
31
33
|
* `projectFileNames` for exactly this.
|
|
32
34
|
*/
|
|
33
|
-
export const MessageList = memo(function MessageList({ messages: sourceMessages, isStreaming = false, scrollIntent = false, onScrolled, pendingPrompt, pendingPrompts, ...rowProps }) {
|
|
35
|
+
export const MessageList = memo(function MessageList({ messages: sourceMessages, isStreaming = false, scrollIntent = false, onScrolled, pendingPrompt, pendingPrompts, hooks = defaultMessageListHooks, ...rowProps }) {
|
|
34
36
|
const messages = useMemo(() => projectAcceptedInputMessages({ messages: sourceMessages }), [sourceMessages]);
|
|
35
|
-
const usageByMessage = useConversationUsage({ messages });
|
|
37
|
+
const usageByMessage = hooks.useConversationUsage({ messages });
|
|
36
38
|
// Derive from the conversation's saved events, so replay/remount does not repeat the notice.
|
|
37
39
|
const accessNoticeId = useMemo(() => messages.find(message => message.role === 'assistant'
|
|
38
40
|
&& message.events?.some(event => event.kind === 'status' && event.label === 'full_cli_access' && event.detail))?.id, [messages]);
|
|
39
|
-
const { containerRef, onScroll, awayFromLatest, jumpToLatest
|
|
41
|
+
const { containerRef, onScroll, awayFromLatest, jumpToLatest } = hooks.useMessageListAutoScroll({ messages, scrollIntent }, onScrolled !== undefined ? { onScrolled } : {});
|
|
40
42
|
return (_jsxs("div", { className: "jini-message-list", ref: containerRef, onScroll: onScroll, "data-agent-element": "chat-transcript", "data-agent-role": "list", "data-agent-label": "The conversation transcript, oldest message first", children: [messages.map((message, index) => renderMessageRow({
|
|
41
43
|
message,
|
|
42
44
|
showAccessNotice: message.id === accessNoticeId,
|
|
@@ -46,28 +48,23 @@ export const MessageList = memo(function MessageList({ messages: sourceMessages,
|
|
|
46
48
|
sending: message.runId === undefined && messages[index - 1]?.inputPending === true,
|
|
47
49
|
isStreaming,
|
|
48
50
|
usageSummary: usageByMessage.get(message.id),
|
|
49
|
-
}, rowProps)), (pendingPrompts ?? (pendingPrompt ? [pendingPrompt] : [])).map((prompt, index) => (_jsx(QueuedMessage, { prompt: prompt, renderAttachment: rowProps.renderAttachment }, prompt.id ?? index))), awayFromLatest
|
|
50
|
-
: scrollable ? _jsx(JumpArrow, { direction: "up", onJump: jumpToTop }) : null] }));
|
|
51
|
+
}, rowProps)), (pendingPrompts ?? (pendingPrompt ? [pendingPrompt] : [])).map((prompt, index) => (_jsx(QueuedMessage, { prompt: prompt, renderAttachment: rowProps.renderAttachment }, prompt.id ?? index))), awayFromLatest && _jsx(JumpToLatest, { onJump: jumpToLatest })] }));
|
|
51
52
|
});
|
|
52
53
|
/**
|
|
53
|
-
* Sticky, zero-height last child of the scroll container, so the button floats
|
|
54
|
-
*
|
|
55
|
-
* Owner 2026-11-13: the centred "↓ Jump to latest" pill covered a message; it is an icon-only arrow
|
|
56
|
-
* now — down to the latest when scrolled away, up to the top when already there. The label lives in
|
|
57
|
-
* aria-label/title only, so screen readers and hover still name it.
|
|
54
|
+
* Sticky, zero-height last child of the scroll container, so the button floats centred just above
|
|
55
|
+
* the composer without a wrapper element changing the pane's flex layout.
|
|
58
56
|
*/
|
|
59
|
-
function
|
|
60
|
-
const t =
|
|
61
|
-
|
|
62
|
-
return (_jsx("div", { className: "jini-message-list__jump", children: _jsx("button", { type: "button", className: "jini-message-list__jump-btn", onClick: onJump, "aria-label": label, title: label, children: _jsx("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: direction === 'down'
|
|
63
|
-
? _jsxs(_Fragment, { children: [_jsx("path", { d: "M12 5v14" }), _jsx("path", { d: "m19 12-7 7-7-7" })] })
|
|
64
|
-
: _jsxs(_Fragment, { children: [_jsx("path", { d: "M12 19V5" }), _jsx("path", { d: "m5 12 7-7 7 7" })] }) }) }) }));
|
|
57
|
+
function JumpToLatest({ onJump, useTHook = useT }) {
|
|
58
|
+
const t = useTHook();
|
|
59
|
+
return (_jsx("div", { className: "jini-message-list__jump", children: _jsxs("button", { type: "button", className: "jini-message-list__jump-btn", onClick: onJump, children: [_jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("path", { d: "M12 5v14" }), _jsx("path", { d: "m19 12-7 7-7-7" })] }), t('Jump to latest')] }) }));
|
|
65
60
|
}
|
|
61
|
+
/** Hooks QueuedMessage calls; defaults to the real ones, a test hands in fakes. */
|
|
62
|
+
const defaultQueuedMessageHooks = { useT, useAttachmentGallery };
|
|
66
63
|
/** One cancelable queue receipt; attachment rendering reuses the sent-message preview owner. */
|
|
67
|
-
function QueuedMessage({ prompt, renderAttachment }) {
|
|
68
|
-
const t = useT();
|
|
64
|
+
function QueuedMessage({ prompt, renderAttachment, hooks = defaultQueuedMessageHooks }) {
|
|
65
|
+
const t = hooks.useT();
|
|
69
66
|
const attachments = prompt.attachments ?? [];
|
|
70
|
-
const gallery = useAttachmentGallery({ attachments });
|
|
67
|
+
const gallery = hooks.useAttachmentGallery({ attachments });
|
|
71
68
|
return (_jsxs("div", { className: "jini-chat-pane__queued", role: "status", "aria-label": t('Message queued — not yet sent, will send once the current run finishes'), "data-testid": "chat-pane-queued", "data-agent-element": "chat-message-pending", "data-agent-role": "region", "data-agent-label": "A message queued to send once the current run finishes", children: [_jsx("div", { className: "jini-chat-pane__status", children: t('Queued — sends when this reply finishes') }), prompt.folders?.length ? _jsx("div", { className: "jini-message-attachments", children: _jsx(FolderChips, { folders: prompt.folders }) }) : null, _jsx("div", { className: "jini-chat-pane__queued-text", children: prompt.text }), attachments.length > 0 && _jsx("div", { className: "jini-message-attachments", children: attachments.map(attachment => _jsx(SentAttachmentButton, { attachment: attachment, onOpen: gallery.open, renderAttachment: renderAttachment }, attachment.path)) }), gallery.opened !== null && _jsx(AttachmentPreviewModal, { attachment: gallery.opened, onClose: gallery.close, navigation: gallery.navigation }), _jsx("div", { className: "jini-chat-pane__queued-actions", children: _jsx("button", { type: "button", className: "jini-chat-pane__queued-cancel", onClick: () => prompt.onCancel(), title: t('Cancel queued message'), children: t('Cancel') }) })] }));
|
|
72
69
|
}
|
|
73
70
|
//# sourceMappingURL=MessageList.js.map
|
|
@@ -11,11 +11,6 @@ export declare function isScrolledToBottom(el: {
|
|
|
11
11
|
scrollTop: number;
|
|
12
12
|
clientHeight: number;
|
|
13
13
|
}): boolean;
|
|
14
|
-
/** Whether the transcript is taller than its box, i.e. there is anywhere to scroll at all. */
|
|
15
|
-
export declare function hasOverflow(el: {
|
|
16
|
-
scrollHeight: number;
|
|
17
|
-
clientHeight: number;
|
|
18
|
-
}): boolean;
|
|
19
14
|
/**
|
|
20
15
|
* The sticky-follow flag after a `scroll` event.
|
|
21
16
|
*
|
|
@@ -4,10 +4,6 @@ export const AT_BOTTOM_THRESHOLD_PX = 4;
|
|
|
4
4
|
export function isScrolledToBottom(el) {
|
|
5
5
|
return el.scrollHeight - el.scrollTop - el.clientHeight <= AT_BOTTOM_THRESHOLD_PX;
|
|
6
6
|
}
|
|
7
|
-
/** Whether the transcript is taller than its box, i.e. there is anywhere to scroll at all. */
|
|
8
|
-
export function hasOverflow(el) {
|
|
9
|
-
return el.scrollHeight - el.clientHeight > AT_BOTTOM_THRESHOLD_PX;
|
|
10
|
-
}
|
|
11
7
|
/**
|
|
12
8
|
* The sticky-follow flag after a `scroll` event.
|
|
13
9
|
*
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import type { Logger } from '@jini-ai/core/primitives';
|
|
2
|
+
import { useSurfaceAnswerContexts } from './mcp-ui-question-input.js';
|
|
1
3
|
import type { ChatUsageSummary } from '../../core/turn-usage.js';
|
|
4
|
+
import { useUsageSummary } from './MessageRow.usage.js';
|
|
2
5
|
/**
|
|
3
6
|
* @module MessageRow
|
|
4
7
|
*
|
|
@@ -50,9 +53,11 @@ import type { ChatUsageSummary } from '../../core/turn-usage.js';
|
|
|
50
53
|
* chunk stopped arriving.
|
|
51
54
|
*/
|
|
52
55
|
import React, { type ReactNode } from 'react';
|
|
53
|
-
import type { ChatAttachment, ChatMessage } from '../../core/index.js';
|
|
56
|
+
import type { ChatAttachment, ChatMessage, IsAnsweredCard } from '../../core/index.js';
|
|
57
|
+
import { useT } from '../hooks/context.js';
|
|
54
58
|
import { type ToolCallDisplay } from '../tool-call-display.js';
|
|
55
59
|
export interface MessageRowProps {
|
|
60
|
+
report?: Pick<Logger, 'error'> | undefined;
|
|
56
61
|
message: ChatMessage;
|
|
57
62
|
/** Conversation hosts show the first access status only; standalone rows retain it by default. */
|
|
58
63
|
showAccessNotice?: boolean;
|
|
@@ -88,10 +93,49 @@ export interface MessageRowProps {
|
|
|
88
93
|
/** Host-supplied renderer for a `ChatAttachment` chip. Falls back to a plain filename chip. */
|
|
89
94
|
renderAttachment?: (attachment: ChatAttachment) => ReactNode;
|
|
90
95
|
}
|
|
96
|
+
/** Hooks UsageSummary calls; defaults to the real ones, a test hands in fakes. */
|
|
97
|
+
export declare const defaultUsageSummaryHooks: {
|
|
98
|
+
useT: typeof useT;
|
|
99
|
+
useUsageSummary: typeof useUsageSummary;
|
|
100
|
+
};
|
|
101
|
+
export type UsageSummaryHooks = typeof defaultUsageSummaryHooks;
|
|
102
|
+
/** One "Done · 6m 29s · $0.41 · total $2.50" line from reported usage, never estimated (the total is
|
|
103
|
+
* left off when `showTotal` is false). Partial usage stays partial; output tokens are available to
|
|
104
|
+
* assistive technology and in the tooltip. */
|
|
105
|
+
export declare function UsageSummary({ usage, showTotal, message, awaitingAnswer, hooks }: {
|
|
106
|
+
usage: ChatUsageSummary;
|
|
107
|
+
showTotal: boolean;
|
|
108
|
+
message?: ChatMessage;
|
|
109
|
+
awaitingAnswer?: boolean;
|
|
110
|
+
} & {
|
|
111
|
+
hooks?: UsageSummaryHooks | undefined;
|
|
112
|
+
}): React.JSX.Element | null;
|
|
113
|
+
export declare function ThinkingBlock({ text, useTHook }: {
|
|
114
|
+
text: string;
|
|
115
|
+
} & {
|
|
116
|
+
useTHook?: typeof useT;
|
|
117
|
+
}): React.JSX.Element | null;
|
|
118
|
+
export declare function AssistantMessageFooter({ message, usageEvent, showUsageTotal, terminalNotice, pending, runInProgress, runStreaming, runSending, sendingLabel, visibleContent, isAnsweredCard, useTHook }: {
|
|
119
|
+
message: ChatMessage;
|
|
120
|
+
usageEvent: ChatUsageSummary | undefined;
|
|
121
|
+
showUsageTotal: boolean;
|
|
122
|
+
terminalNotice: string | null;
|
|
123
|
+
pending: boolean;
|
|
124
|
+
runInProgress: boolean;
|
|
125
|
+
runStreaming?: boolean;
|
|
126
|
+
runSending: boolean;
|
|
127
|
+
visibleContent: string;
|
|
128
|
+
isAnsweredCard: IsAnsweredCard;
|
|
129
|
+
sendingLabel: string | undefined;
|
|
130
|
+
} & {
|
|
131
|
+
useTHook?: typeof useT;
|
|
132
|
+
}): React.JSX.Element;
|
|
91
133
|
/**
|
|
92
134
|
* Memoized so a transcript re-render (a streaming update to the newest message, or a parent that
|
|
93
135
|
* re-renders per composer keystroke) only re-renders rows whose props actually changed. Messages
|
|
94
136
|
* are replaced, never mutated, so identity is a sound change signal.
|
|
95
137
|
*/
|
|
96
|
-
export declare const MessageRow: React.NamedExoticComponent<MessageRowProps
|
|
138
|
+
export declare const MessageRow: React.NamedExoticComponent<MessageRowProps & {
|
|
139
|
+
useSurfaceAnswerContextsHook?: typeof useSurfaceAnswerContexts;
|
|
140
|
+
}>;
|
|
97
141
|
//# sourceMappingURL=MessageRow.d.ts.map
|