@jini-ai/chat 0.6.23 → 0.7.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 +32 -0
- package/README.md +8 -0
- package/dist/core/accepted-input.d.ts +1 -1
- package/dist/core/accepted-input.js +5 -4
- package/dist/core/durable-projection.js +8 -1
- package/dist/core/question-answer.js +2 -1
- package/dist/core/turn-usage.d.ts +1 -1
- package/dist/core/turn-usage.js +4 -5
- package/dist/react/components/AttachmentTray.d.ts +4 -1
- package/dist/react/components/AttachmentTray.js +20 -5
- package/dist/react/components/Composer.d.ts +3 -1
- package/dist/react/components/Composer.js +16 -14
- package/dist/react/components/ComposerDiscovery.d.ts +2 -0
- package/dist/react/components/ComposerDiscovery.js +4 -3
- package/dist/react/components/ConversationList.d.ts +4 -2
- package/dist/react/components/ConversationList.js +16 -7
- package/dist/react/components/CopyMessageButton.d.ts +3 -1
- package/dist/react/components/CopyMessageButton.js +3 -2
- package/dist/react/components/FolderChips.d.ts +3 -1
- package/dist/react/components/FolderChips.js +8 -5
- package/dist/react/components/MessageList.js +1 -1
- package/dist/react/components/MessageRow.js +1 -1
- package/dist/react/components/ToolCard.js +7 -7
- package/dist/react/components/ToolCard.rules.d.ts +5 -0
- package/dist/react/components/ToolCard.rules.js +9 -2
- package/dist/react/components/mcp-ui-surface-state.js +11 -0
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.d.ts +1 -1
- package/dist/react/features/chat-pane/components/AgentRuntimePicker.js +38 -27
- package/dist/react/features/chat-pane/components/ChatPane.js +19 -8
- package/dist/react/features/chat-pane/components/RuntimeDropUp.d.ts +2 -1
- package/dist/react/features/chat-pane/components/RuntimeDropUp.js +11 -6
- package/dist/react/features/chat-pane/hooks/useChatPane.hooks.js +8 -0
- package/dist/react/features/chat-pane/rules.d.ts +22 -1
- package/dist/react/features/chat-pane/rules.js +36 -10
- package/dist/react/features/chat-pane/styles.d.ts +1 -1
- package/dist/react/features/chat-pane/styles.js +32 -39
- package/dist/react/features/chat-pane/types.d.ts +10 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/styles/chat-settings.css +149 -0
- package/package.json +21 -18
|
@@ -160,7 +160,7 @@ function messageAwaitingAnswer({ runStreaming, runInProgress, events }, { isAnsw
|
|
|
160
160
|
}
|
|
161
161
|
function AssistantMessageFooter({ message, usageEvent, showUsageTotal, terminalNotice, pending, runInProgress, runStreaming, runSending, sendingLabel, visibleContent, isAnsweredCard }, _optional = {}) {
|
|
162
162
|
const t = useT();
|
|
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:
|
|
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. */
|
|
166
166
|
const NO_ATTACHMENTS = [];
|
|
@@ -28,7 +28,7 @@ import { useT, useToolRendererRegistry } from '../hooks/context.js';
|
|
|
28
28
|
import { Icon } from './Icon.js';
|
|
29
29
|
import { SAFE_LINK_HREF } from './Markdown.js';
|
|
30
30
|
import { TodoCard } from './TodoCard.js';
|
|
31
|
-
import { toolRowTarget } from './ToolCard.rules.js';
|
|
31
|
+
import { targetAtOffset, toolRowTarget } from './ToolCard.rules.js';
|
|
32
32
|
import { toolPresentation } from '../../core/tool-presentation.js';
|
|
33
33
|
/**
|
|
34
34
|
* Read by `ErrorBadge` only. A context, not one more prop threaded through every family card,
|
|
@@ -213,7 +213,7 @@ function FileReadCard({ input, result, runStreaming, runSucceeded, ctx }) {
|
|
|
213
213
|
const obj = (input ?? {});
|
|
214
214
|
const file = obj.file_path ?? obj.filePath ?? obj.path ?? '(unnamed)';
|
|
215
215
|
// See OpenInTabButton's baseName comment: `.split('/').pop()` is never undefined.
|
|
216
|
-
const baseName = file.split('/').pop();
|
|
216
|
+
const baseName = targetAtOffset({ target: file.split('/').pop(), offset: obj.offset });
|
|
217
217
|
const isRunning = runStreaming && !result;
|
|
218
218
|
return (_jsxs(ExpandableCard, { className: "op-file", call: { input: input, result: result, runStreaming: runStreaming, runSucceeded: runSucceeded }, head: _jsxs(_Fragment, { children: [_jsx(ResultBadge, { result: result, runStreaming: runStreaming, runSucceeded: runSucceeded }), _jsx("span", { className: `op-title${isRunning ? RUNNING_TITLE_CLASS : ''}`, children: t('Read') }), _jsx("span", { className: "op-meta", children: baseName })] }), after: _jsx(FileErrorDetail, { result: result }), children: [_jsxs("div", { className: "op-card-detail op-card-file-detail", children: [_jsx("code", { className: "op-path", children: file }), _jsx(OpenInTabButton, { filePath: file, ctx: ctx })] }), _jsx(ToolCallDetail, { input: input, result: result, runStreaming: runStreaming, runSucceeded: runSucceeded })] }));
|
|
219
219
|
}
|
|
@@ -253,15 +253,15 @@ function GenericCard({ name, input, result, runStreaming, runSucceeded }) {
|
|
|
253
253
|
* The one row shell every card shares: a real `<button>` head (Enter/Space toggle it) that reports
|
|
254
254
|
* `aria-expanded` and points `aria-controls` at its panel. The panel's `children` mount only while
|
|
255
255
|
* open: a long chat mounts hundreds of collapsed rows, and keeping every full detail mounted made a
|
|
256
|
-
* 38-message chat carry ~13k DOM nodes and 3.45 MB of hidden text. Collapsed, the
|
|
257
|
-
*
|
|
258
|
-
*
|
|
256
|
+
* 38-message chat carry ~13k DOM nodes and 3.45 MB of hidden text. Collapsed, the card holds one
|
|
257
|
+
* screen-reader node outside the collapsed panel with the call's capped gist instead, so a
|
|
258
|
+
* `page.*` DOM reader can inspect the same public text without anyone clicking.
|
|
259
259
|
* `after` renders outside the panel, for content that must stay visible collapsed (an error, media).
|
|
260
260
|
*/
|
|
261
261
|
function ExpandableCard({ className, head, after, call, children }) {
|
|
262
262
|
const [open, setOpen] = useState(false);
|
|
263
263
|
const panelId = useId();
|
|
264
|
-
return (_jsxs("div", { className: `op-card ${className}`, children: [_jsxs("button", { type: "button", className: "op-card-head", "aria-expanded": open, "aria-controls": panelId, onClick: () => setOpen((o) => !o), children: [head, _jsx("span", { className: "op-expand-chev", "aria-hidden": true, children: _jsx(Icon, { name: open ? 'chevron-down' : 'chevron-right', size: 11 }) })] }), _jsx("div", { id: panelId, className: `accordion-collapsible${open ? ' open' : ''}`, children: open ? _jsx("div", { className: "accordion-collapsible-inner", children: children }) : _jsx(CollapsedReaderText, { call: call })
|
|
264
|
+
return (_jsxs("div", { className: `op-card ${className}`, children: [_jsxs("button", { type: "button", className: "op-card-head", "aria-expanded": open, "aria-controls": panelId, onClick: () => setOpen((o) => !o), children: [head, _jsx("span", { className: "op-expand-chev", "aria-hidden": true, children: _jsx(Icon, { name: open ? 'chevron-down' : 'chevron-right', size: 11 }) })] }), _jsx("div", { id: panelId, className: `accordion-collapsible${open ? ' open' : ''}`, children: open ? _jsx("div", { className: "accordion-collapsible-inner", children: children }) : null }), open ? null : _jsx(CollapsedReaderText, { call: call }), after] }));
|
|
265
265
|
}
|
|
266
266
|
/** The collapsed row's stand-in for its panel — see {@link ExpandableCard} and `describeCollapsedToolCall`. */
|
|
267
267
|
function CollapsedReaderText({ call }) {
|
|
@@ -273,7 +273,7 @@ function CollapsedReaderText({ call }) {
|
|
|
273
273
|
const runStreaming = !call.result && call.runStreaming;
|
|
274
274
|
const runSucceeded = !call.result && call.runSucceeded;
|
|
275
275
|
const text = useMemo(() => describeCollapsedToolCall({ input, result: resultContent === undefined ? undefined : { content: resultContent, isError: resultIsError } }, { runStreaming, runSucceeded }), [input, resultContent, resultIsError, runStreaming, runSucceeded]);
|
|
276
|
-
return _jsx("span", { className: "op-card-reader-text",
|
|
276
|
+
return _jsx("span", { className: "op-card-reader-text op-sr-prefix", children: text });
|
|
277
277
|
}
|
|
278
278
|
/** The call's input, its result (or why there is none), and any extra `children` — see `describeToolCallDetail` for the redaction and formatting rules. */
|
|
279
279
|
function ToolCallDetail({ input, result, runStreaming, runSucceeded, children }) {
|
|
@@ -17,4 +17,9 @@ export declare function toolRowTarget({ input, resultContent }: {
|
|
|
17
17
|
input: unknown;
|
|
18
18
|
resultContent?: string | undefined;
|
|
19
19
|
}): string | undefined;
|
|
20
|
+
/** Preserve absent/invalid offsets; explicit zero still distinguishes a first-page read. */
|
|
21
|
+
export declare function targetAtOffset({ target, offset }: {
|
|
22
|
+
target: string | undefined;
|
|
23
|
+
offset: unknown;
|
|
24
|
+
}, _options?: {}): string | undefined;
|
|
20
25
|
//# sourceMappingURL=ToolCard.rules.d.ts.map
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* draws it. Moved out of `ToolCard.tsx` (11-01) when the target learned to read the result too.
|
|
4
4
|
*/
|
|
5
5
|
/** Argument keys that name *what* a call acted on, best first: an element handle or page, then a human title/name/slug, then a path or query, then an id. */
|
|
6
|
-
const SUMMARY_KEYS = ['element', 'page', 'handle', 'title', 'name', 'slug', 'file_path', 'path', 'pattern', 'url', 'query', 'command', 'toolId', 'id'];
|
|
6
|
+
const SUMMARY_KEYS = ['element', 'page', 'handle', 'title', 'name', 'slug', 'file_path', 'path', 'pattern', 'url', 'query', 'command', 'toolId', 'pluginId', 'id'];
|
|
7
7
|
/** Result fields that name a record for a person — what a write or read returns about its target. */
|
|
8
8
|
const RESULT_NAME_KEYS = ['title', 'name', 'slug'];
|
|
9
9
|
/** Argument keys that say what *kind* of thing a call acted on — the last-resort target. */
|
|
@@ -88,6 +88,13 @@ export function toolRowTarget({ input, resultContent }) {
|
|
|
88
88
|
return String(input);
|
|
89
89
|
const args = (input ?? {});
|
|
90
90
|
const named = firstReadable(args, SUMMARY_KEYS) ?? resultName(resultContent);
|
|
91
|
-
|
|
91
|
+
const target = named ?? batchTarget(args) ?? firstReadable(args, KIND_KEYS) ?? Object.values(args).find(readable);
|
|
92
|
+
return targetAtOffset({ target, offset: args.offset });
|
|
93
|
+
}
|
|
94
|
+
/** Preserve absent/invalid offsets; explicit zero still distinguishes a first-page read. */
|
|
95
|
+
export function targetAtOffset({ target, offset }, _options = {}) {
|
|
96
|
+
if (!target || typeof offset !== 'number')
|
|
97
|
+
return target;
|
|
98
|
+
return Number.isSafeInteger(offset) && offset >= 0 ? `${target} (offset ${offset})` : target;
|
|
92
99
|
}
|
|
93
100
|
//# sourceMappingURL=ToolCard.rules.js.map
|
|
@@ -8,6 +8,15 @@
|
|
|
8
8
|
import { questionAnswerText } from '../../core/question-answer.js';
|
|
9
9
|
/** Words in a finished call's result that mean nobody answered in time. */
|
|
10
10
|
const UNANSWERED_RESULT = /\b(expired|abandoned|did not respond|run ended)\b/i;
|
|
11
|
+
/** A confirmation the person cancelled ends with `{"cancelled":true,...}`; that is not an answer. @complexity O(r). */
|
|
12
|
+
function wasCancelled({ content }, _options = {}) {
|
|
13
|
+
try {
|
|
14
|
+
return JSON.parse(content)?.cancelled === true;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
11
20
|
/**
|
|
12
21
|
* Why a card can no longer be answered, or `undefined` while it still can.
|
|
13
22
|
*
|
|
@@ -28,6 +37,8 @@ function settledLabel(t, call, runStreaming, documentsForUri) {
|
|
|
28
37
|
return runStreaming ? undefined : t('This question expired');
|
|
29
38
|
if (documentsForUri > 1)
|
|
30
39
|
return undefined;
|
|
40
|
+
if (wasCancelled(call.result))
|
|
41
|
+
return t('Cancelled');
|
|
31
42
|
return UNANSWERED_RESULT.test(call.result.content) ? t('This question expired') : t('Answered');
|
|
32
43
|
}
|
|
33
44
|
/**
|
|
@@ -10,5 +10,5 @@ export declare function runtimeAgentStatus({ agent }: {
|
|
|
10
10
|
* @complexity Time: O(n) in the runtime inventory; space: O(n) for ordering.
|
|
11
11
|
* @overallScore 100/100
|
|
12
12
|
*/
|
|
13
|
-
export declare function AgentRuntimePicker({ agents, nativeToolPolicy, value, onChange, onRescan, scanning, daemonOnline, placement, executionMode, apiModeAvailable, onExecutionModeChange, byokRuntime, onByokModelChange, agentIconBasePath, }: AgentRuntimePickerProps): import("react").JSX.Element;
|
|
13
|
+
export declare function AgentRuntimePicker({ agentHandle, agents, nativeToolPolicy, value, onChange, onRescan, scanning, daemonOnline, placement, executionMode, apiModeAvailable, onExecutionModeChange, byokRuntime, onByokModelChange, agentIconBasePath, }: AgentRuntimePickerProps): import("react").JSX.Element;
|
|
14
14
|
//# sourceMappingURL=AgentRuntimePicker.d.ts.map
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { modelReasoningOptions } from '@jini-ai/agent-runtime/model-selection';
|
|
2
3
|
import { friendlyModelLabel, pickerModelValue, pickerCatalogNote, pickerModelOptions, shortModelLabel } from '../model-options.js';
|
|
3
4
|
import { useId } from 'react';
|
|
4
5
|
import { createPortal } from 'react-dom';
|
|
5
|
-
import { AgentIcon, RemixIcon, SearchableModelSelect } from '@jini-ai/ui';
|
|
6
|
+
import { AgentIcon, RemixIcon, SearchableModelSelect, useAgentHandle, useOverlayContainer } from '@jini-ai/ui';
|
|
7
|
+
import { agentHandleProps, agentHandleSegment } from '@jini-ai/agentic';
|
|
6
8
|
import { InfoTip } from '@jini-ai/ui/admin-widgets';
|
|
7
9
|
import { assessNativeToolPolicy } from '@jini-ai/agent-runtime/native-tool-policy';
|
|
8
10
|
import { useT } from '../../../hooks/context.js';
|
|
9
11
|
import { definedProps } from '../../../util/defined-props.js';
|
|
10
12
|
import { RuntimeDropUp } from './RuntimeDropUp.js';
|
|
11
|
-
import { defaultChatPaneSelection } from '../rules.js';
|
|
13
|
+
import { defaultChatPaneSelection, resolveChatPaneSelection } from '../rules.js';
|
|
12
14
|
import { runtimeOptionLabel, runtimePopoverPosition, useAgentRuntimePicker, } from '../hooks/useAgentRuntimePicker.hooks.js';
|
|
13
15
|
// Re-exported so this module's public surface is unchanged by the behavior extraction; both are
|
|
14
16
|
// pure and now live beside the hook that consumes them.
|
|
@@ -36,21 +38,21 @@ function NativeToolPolicyWarning({ agent, policy, isApi }) {
|
|
|
36
38
|
const warning = policy ? assessNativeToolPolicy({ def: agent, policy }) : null;
|
|
37
39
|
return _jsxs(_Fragment, { children: [agent.fullCliAccessNote ? _jsx(FullAccessNoteTip, { note: agent.fullCliAccessNote, t: t }) : null, warning ? _jsx(InfoTip, { label: t(warning), triggerLabel: t('Agent permissions required'), placement: "top", icon: _jsx(RemixIcon, { name: "alert-line", size: 16 }) }) : null] });
|
|
38
40
|
}
|
|
39
|
-
function RuntimeModeButtons({ executionMode, daemonOnline, apiModeAvailable, onExecutionModeChange, t, }) {
|
|
41
|
+
function RuntimeModeButtons({ base, executionMode, daemonOnline, apiModeAvailable, onExecutionModeChange, t, }) {
|
|
40
42
|
const localModeLabel = executionMode === 'local' ? t('active') : '';
|
|
41
|
-
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: `jini-runtime-mode${executionMode === 'local' ? ' is-active' : ''}`, disabled: !daemonOnline && executionMode !== 'local', onClick: () => onExecutionModeChange?.('local'), children: [_jsx(RemixIcon, { name: "terminal-box-line", size: 18 }), _jsx("span", { children: t('Use Local CLI') }), _jsx("span", { className: "jini-runtime-mode__meta", children: !daemonOnline ? t('offline') : localModeLabel }), executionMode === 'local' ? (_jsx(RemixIcon, { name: "check-line", size: 19, className: "jini-runtime-check" })) : null] }), _jsxs("button", { type: "button", className: `jini-runtime-mode${executionMode === 'api' ? ' is-active' : ''}`, disabled: !apiModeAvailable, onClick: () => onExecutionModeChange?.('api'), children: [_jsx(RemixIcon, { name: "link", size: 18 }), _jsx("span", { children: t('Use API · BYOK') }), !apiModeAvailable ? _jsx("span", { className: "jini-runtime-mode__meta", children: t('not configured') }) : null, executionMode === 'api' ? (_jsx(RemixIcon, { name: "check-line", size: 19, className: "jini-runtime-check" })) : null] })] }));
|
|
43
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", ...agentHandleProps({}, { base, action: 'mode-local', role: 'button', label: t('Use Local CLI') }), className: `jini-runtime-mode${executionMode === 'local' ? ' is-active' : ''}`, disabled: !daemonOnline && executionMode !== 'local', onClick: () => onExecutionModeChange?.('local'), children: [_jsx(RemixIcon, { name: "terminal-box-line", size: 18 }), _jsx("span", { children: t('Use Local CLI') }), _jsx("span", { className: "jini-runtime-mode__meta", children: !daemonOnline ? t('offline') : localModeLabel }), executionMode === 'local' ? (_jsx(RemixIcon, { name: "check-line", size: 19, className: "jini-runtime-check" })) : null] }), _jsxs("button", { type: "button", ...agentHandleProps({}, { base, action: 'mode-api', role: 'button', label: t('Use API · BYOK') }), className: `jini-runtime-mode${executionMode === 'api' ? ' is-active' : ''}`, disabled: !apiModeAvailable, onClick: () => onExecutionModeChange?.('api'), children: [_jsx(RemixIcon, { name: "link", size: 18 }), _jsx("span", { children: t('Use API · BYOK') }), !apiModeAvailable ? _jsx("span", { className: "jini-runtime-mode__meta", children: t('not configured') }) : null, executionMode === 'api' ? (_jsx(RemixIcon, { name: "check-line", size: 19, className: "jini-runtime-check" })) : null] })] }));
|
|
42
44
|
}
|
|
43
|
-
function RuntimeAgentList({ orderedAgents, value, onChange, agentIconBasePath, t, }) {
|
|
45
|
+
function RuntimeAgentList({ base, orderedAgents, value, onChange, agentIconBasePath, t, }) {
|
|
44
46
|
const noteIdPrefix = useId();
|
|
45
47
|
if (orderedAgents.length === 0) {
|
|
46
48
|
return _jsx("div", { className: "jini-runtime-empty", children: t('No available code agents') });
|
|
47
49
|
}
|
|
48
|
-
return (_jsx(_Fragment, { children: orderedAgents.map((agent) => (_jsx(RuntimeAgentRow, { agent: agent, active: agent.id === value.agentId, noteId: agent.fullCliAccessNote ? `${noteIdPrefix}-${agent.id}-note` : undefined, onChange: onChange, agentIconBasePath: agentIconBasePath, t: t }, agent.id))) }));
|
|
50
|
+
return (_jsx(_Fragment, { children: orderedAgents.map((agent) => (_jsx(RuntimeAgentRow, { base: base, agent: agent, active: agent.id === value.agentId, noteId: agent.fullCliAccessNote ? `${noteIdPrefix}-${agent.id}-note` : undefined, onChange: onChange, agentIconBasePath: agentIconBasePath, t: t }, agent.id))) }));
|
|
49
51
|
}
|
|
50
|
-
function RuntimeAgentRow({ agent, active, noteId, onChange, agentIconBasePath, t }) {
|
|
52
|
+
function RuntimeAgentRow({ base, agent, active, noteId, onChange, agentIconBasePath, t }) {
|
|
51
53
|
const status = runtimeAgentStatus({ agent: agent });
|
|
52
54
|
// The note's icon is a control of its own, so it sits beside the radio, never inside it.
|
|
53
|
-
return (_jsxs("div", { className: "jini-runtime-agent-row", children: [_jsxs("button", { type: "button", role: "radio", "aria-checked": active, className: `jini-runtime-agent${active ? ' is-active' : ''}`, "aria-current": active ? 'true' : undefined, "aria-label": `${agent.name} · ${status}`, ...(noteId ? { 'aria-describedby': noteId } : {}), onClick: () => onChange(defaultChatPaneSelection({ agent: agent })), children: [_jsx(AgentIcon, { id: agent.id, size: 20, className: "jini-runtime-agent-icon", ...definedProps({ source: { basePath: agentIconBasePath } }) }), _jsx("span", { className: "jini-runtime-agent__copy", children: _jsx("strong", { children: agent.name }) }), agent.supportsTools === false ? (_jsx("span", { className: "jini-runtime-agent__badge", title: t("This CLI has no MCP support, so it cannot use this app's tools."), children: t('No tools') })) : null, _jsx("span", { className: "jini-runtime-agent__status", children: active ? t('selected') : status }), active ? (_jsx(RemixIcon, { name: "check-line", size: 19, className: "jini-runtime-check" })) : null] }), agent.fullCliAccessNote ? _jsx(FullAccessNoteTip, { note: agent.fullCliAccessNote, descriptionId: noteId, t: t }) : null] }));
|
|
55
|
+
return (_jsxs("div", { className: "jini-runtime-agent-row", children: [_jsxs("button", { type: "button", ...agentHandleProps({}, { base, action: `agent-${agentHandleSegment({ value: agent.id })}`, role: 'button', label: agent.name }), role: "radio", "aria-checked": active, className: `jini-runtime-agent${active ? ' is-active' : ''}`, "aria-current": active ? 'true' : undefined, "aria-label": `${agent.name} · ${status}`, ...(noteId ? { 'aria-describedby': noteId } : {}), onClick: () => onChange(defaultChatPaneSelection({ agent: agent })), children: [_jsx(AgentIcon, { id: agent.id, size: 20, className: "jini-runtime-agent-icon", ...definedProps({ source: { basePath: agentIconBasePath } }) }), _jsx("span", { className: "jini-runtime-agent__copy", children: _jsx("strong", { children: agent.name }) }), agent.supportsTools === false ? (_jsx("span", { className: "jini-runtime-agent__badge", title: t("This CLI has no MCP support, so it cannot use this app's tools."), children: t('No tools') })) : null, _jsx("span", { className: "jini-runtime-agent__status", children: active ? t('selected') : status }), active ? (_jsx(RemixIcon, { name: "check-line", size: 19, className: "jini-runtime-check" })) : null] }), agent.fullCliAccessNote ? _jsx(FullAccessNoteTip, { note: agent.fullCliAccessNote, descriptionId: noteId, t: t }) : null] }));
|
|
54
56
|
}
|
|
55
57
|
/**
|
|
56
58
|
* The composer bar's "Model ⌄" and "Effort ⌄" drop-ups for the selected CLI. These replace the
|
|
@@ -59,20 +61,19 @@ function RuntimeAgentRow({ agent, active, noteId, onChange, agentIconBasePath, t
|
|
|
59
61
|
* selection, so nothing else changed. Either one renders nothing when the agent publishes no
|
|
60
62
|
* choices for it, rather than an empty menu.
|
|
61
63
|
*/
|
|
62
|
-
function RuntimeBarMenus({ selectedAgent, value, onChange, modelLabel, t }) {
|
|
64
|
+
function RuntimeBarMenus({ base, selectedAgent, value, onChange, modelLabel, t }) {
|
|
63
65
|
if (!selectedAgent)
|
|
64
66
|
return null;
|
|
65
67
|
// Raw catalog ids (an offline fallback list's rows) read as friendly names in the bar and its list.
|
|
66
68
|
const models = pickerModelOptions(selectedAgent).map((row) => ({ ...row, label: friendlyModelLabel({ label: row.label }) }));
|
|
67
|
-
const
|
|
69
|
+
const selectedModelId = pickerModelValue(selectedAgent, value.model);
|
|
70
|
+
const efforts = modelReasoningOptions({ agent: selectedAgent, model: models.find(option => option.id === selectedModelId) });
|
|
68
71
|
const modelName = friendlyModelLabel({ label: modelLabel });
|
|
69
|
-
return (_jsxs(_Fragment, { children: [models.length > 0 ? (_jsx(RuntimeDropUp, { label: t('Model'), valueLabel: modelName,
|
|
72
|
+
return (_jsxs(_Fragment, { children: [models.length > 0 ? (_jsx(RuntimeDropUp, { agentHandle: base ? `${base}-model` : false, label: t('Model'), valueLabel: modelName,
|
|
70
73
|
// The agent icon sits right beside it, so the bar drops the vendor word and caps the rest.
|
|
71
|
-
triggerLabel: shortModelLabel({ label: modelLabel, agentId: selectedAgent.id }), value: pickerModelValue(selectedAgent, value.model), options: models, note: pickerCatalogNote(selectedAgent, t), width: 260, onSelect: (model) => onChange({
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
...(value.reasoning ? { reasoning: value.reasoning } : {}),
|
|
75
|
-
}) })) : null, efforts.length > 0 ? (_jsx(RuntimeDropUp, { label: t('Reasoning'),
|
|
74
|
+
triggerLabel: shortModelLabel({ label: modelLabel, agentId: selectedAgent.id }), value: pickerModelValue(selectedAgent, value.model), options: models, note: pickerCatalogNote(selectedAgent, t), width: 260, onSelect: (model) => onChange(value.reasoning ? resolveChatPaneSelection({
|
|
75
|
+
agents: [selectedAgent], requested: { ...value, model },
|
|
76
|
+
}) : { agentId: value.agentId, model }) })) : null, efforts.length > 0 ? (_jsx(RuntimeDropUp, { agentHandle: base ? `${base}-reasoning` : false, label: t('Reasoning'),
|
|
76
77
|
// An unset reasoning shows the first option, as the old native select did.
|
|
77
78
|
valueLabel: efforts.find((option) => option.id === value.reasoning)?.label ?? efforts[0].label, value: value.reasoning ?? '', options: efforts, width: 180, className: "jini-runtime-dropup-trigger--effort", onSelect: (reasoning) => onChange({
|
|
78
79
|
agentId: value.agentId,
|
|
@@ -107,9 +108,9 @@ function resolveByokModel({ onByokModelChange }, { byokRuntime }) {
|
|
|
107
108
|
const pickModel = onByokModelChange !== undefined && models.length > 0 ? onByokModelChange : undefined;
|
|
108
109
|
return { model, models, pickModel };
|
|
109
110
|
}
|
|
110
|
-
function RuntimeByokDetails({ byokRuntime, onByokModelChange, t }) {
|
|
111
|
+
function RuntimeByokDetails({ base, byokRuntime, onByokModelChange, t }) {
|
|
111
112
|
const { model, models, pickModel } = resolveByokModel({ onByokModelChange }, { byokRuntime });
|
|
112
|
-
return (_jsxs("div", { className: "jini-runtime-models", children: [_jsxs("div", { className: "jini-runtime-select jini-runtime-byok-model", children: [_jsx("span", { children: t('Model') }), pickModel ? (_jsx(SearchableModelSelect, { models: models, value: model ?? '', onChange: (next) => pickModel(next), ariaLabel: t('Model'), searchPlaceholder: t('Search models'),
|
|
113
|
+
return (_jsxs("div", { className: "jini-runtime-models", children: [_jsxs("div", { className: "jini-runtime-select jini-runtime-byok-model", children: [_jsx("span", { children: t('Model') }), pickModel ? (_jsx(SearchableModelSelect, { agentHandle: base ? `${base}-byok-model` : false, models: models, value: model ?? '', onChange: (next) => pickModel(next), ariaLabel: t('Model'), searchPlaceholder: t('Search models'),
|
|
113
114
|
// The menu portals to `document.body` at the package default `z-index: 60`, while this
|
|
114
115
|
// popover positions itself at 1000 — so without this the model list opens BEHIND the
|
|
115
116
|
// popover that owns it. Raised here rather than in the shared stylesheet because 60 is
|
|
@@ -117,9 +118,9 @@ function RuntimeByokDetails({ byokRuntime, onByokModelChange, t }) {
|
|
|
117
118
|
// already-elevated surface.
|
|
118
119
|
menuClassName: "jini-runtime-model-menu" })) : (_jsx("strong", { children: model || t('No model configured') }))] }), !model && !pickModel ? (_jsx("div", { className: "jini-runtime-empty", children: t('Set a model in the BYOK settings before sending a message.') })) : null] }));
|
|
119
120
|
}
|
|
120
|
-
function RuntimeRescanFooter({ onRescan, scanning, t }) {
|
|
121
|
+
function RuntimeRescanFooter({ base, onRescan, scanning, t }) {
|
|
121
122
|
if (onRescan) {
|
|
122
|
-
return (_jsxs("button", { type: "button", className: "jini-runtime-rescan", disabled: scanning, onClick: onRescan, children: [_jsx(RemixIcon, { name: "refresh-line", size: 17, ...(scanning ? { className: 'jini-runtime-spinner' } : {}) }), _jsx("span", { children: scanning ? t('Scanning PATH…') : t('Rescan PATH') })] }));
|
|
123
|
+
return (_jsxs("button", { type: "button", ...agentHandleProps({}, { base, action: 'rescan', role: 'button', label: t('Rescan PATH') }), className: "jini-runtime-rescan", disabled: scanning, onClick: onRescan, children: [_jsx(RemixIcon, { name: "refresh-line", size: 17, ...(scanning ? { className: 'jini-runtime-spinner' } : {}) }), _jsx("span", { children: scanning ? t('Scanning PATH…') : t('Rescan PATH') })] }));
|
|
123
124
|
}
|
|
124
125
|
if (scanning) {
|
|
125
126
|
return _jsx("div", { className: "jini-runtime-empty", children: t('Scanning PATH…') });
|
|
@@ -136,14 +137,23 @@ function RuntimeTriggerIcon({ picker, isApi, byokRuntime, agentIconBasePath }) {
|
|
|
136
137
|
}
|
|
137
138
|
return _jsx(RemixIcon, { name: "link", size: 20, className: "jini-runtime-agent-icon" });
|
|
138
139
|
}
|
|
139
|
-
function RuntimeTrigger({ picker, isApi, byokRuntime, agentIconBasePath, t }) {
|
|
140
|
-
return (_jsxs("button", { ref: picker.triggerRef, type: "button", className: isApi ? 'jini-runtime-trigger' : 'jini-runtime-trigger jini-runtime-trigger--icon-only', "aria-label": t('Choose AI runtime'), "aria-haspopup": "dialog", "aria-expanded": picker.open, "aria-controls": picker.dialogId, title: `${picker.triggerTitle} · ${picker.modelLabel}`, onClick: picker.toggleOpen, children: [_jsx(RuntimeTriggerIcon, { picker: picker, isApi: isApi, byokRuntime: byokRuntime, agentIconBasePath: agentIconBasePath }), _jsxs("span", { className: "jini-runtime-trigger__copy", children: [_jsx("strong", { children: picker.triggerTitle }), isApi ? _jsx("small", { children: picker.modelLabel }) : null] }), isApi ? (_jsx(RemixIcon, { name: "arrow-down-s-line", size: 15, className: "jini-runtime-trigger__chevron" })) : null] }));
|
|
140
|
+
function RuntimeTrigger({ base, picker, isApi, byokRuntime, agentIconBasePath, t }) {
|
|
141
|
+
return (_jsxs("button", { ...agentHandleProps({}, { base, action: 'trigger', role: 'button', label: t('Choose AI runtime') }), ref: picker.triggerRef, type: "button", className: isApi ? 'jini-runtime-trigger' : 'jini-runtime-trigger jini-runtime-trigger--icon-only', "aria-label": t('Choose AI runtime'), "aria-haspopup": "dialog", "aria-expanded": picker.open, "aria-controls": picker.dialogId, title: `${picker.triggerTitle} · ${picker.modelLabel}`, onClick: picker.toggleOpen, children: [_jsx(RuntimeTriggerIcon, { picker: picker, isApi: isApi, byokRuntime: byokRuntime, agentIconBasePath: agentIconBasePath }), _jsxs("span", { className: "jini-runtime-trigger__copy", children: [_jsx("strong", { children: picker.triggerTitle }), isApi ? _jsx("small", { children: picker.modelLabel }) : null] }), isApi ? (_jsx(RemixIcon, { name: "arrow-down-s-line", size: 15, className: "jini-runtime-trigger__chevron" })) : null] }));
|
|
142
|
+
}
|
|
143
|
+
/** Keep native-dialog ownership and the originating page across a host overlay portal. */
|
|
144
|
+
function runtimePortalBinding({ trigger, overlay }) {
|
|
145
|
+
return {
|
|
146
|
+
container: trigger?.closest('dialog') ?? overlay,
|
|
147
|
+
page: trigger?.closest('[data-agent-page]')?.getAttribute('data-agent-page') ?? undefined,
|
|
148
|
+
};
|
|
141
149
|
}
|
|
142
|
-
function RuntimePopover({ picker, value, onChange, onRescan, scanning, daemonOnline, executionMode, apiModeAvailable, onExecutionModeChange, byokRuntime, onByokModelChange, agentIconBasePath, t, }) {
|
|
143
|
-
|
|
150
|
+
function RuntimePopover({ base, picker, value, onChange, onRescan, scanning, daemonOnline, executionMode, apiModeAvailable, onExecutionModeChange, byokRuntime, onByokModelChange, agentIconBasePath, t, }) {
|
|
151
|
+
const overlay = useOverlayContainer({});
|
|
152
|
+
const portal = runtimePortalBinding({ trigger: picker.triggerRef.current, overlay });
|
|
153
|
+
if (!picker.open || !picker.position || !portal.container)
|
|
144
154
|
return null;
|
|
145
155
|
const isApi = executionMode === 'api';
|
|
146
|
-
return createPortal(_jsxs("div", { ref: picker.popoverRef, className: "jini-runtime-popover", ...(picker.originTheme ? { 'data-theme': picker.originTheme } : {}), id: picker.dialogId, role: "dialog", "aria-label": t('Choose AI runtime'), "aria-modal": "false", style: picker.position, onKeyDown: picker.handlePopoverKeyDown, children: [_jsxs("div", { className: "jini-runtime-popover__head", children: [_jsx("strong", { children: executionMode === 'local' ? t('Local CLI') : t('API · BYOK') }), _jsx("span", { children: picker.runtimeSummary })] }), _jsx(RuntimeModeButtons, { executionMode: executionMode, daemonOnline: daemonOnline, apiModeAvailable: apiModeAvailable, onExecutionModeChange: onExecutionModeChange, t: t }), isApi ? (_jsx(RuntimeByokDetails, { byokRuntime: byokRuntime, onByokModelChange: onByokModelChange, t: t })) : (_jsxs(_Fragment, { children: [_jsx("div", { className: "jini-runtime-section-label", children: t('Code agent') }), _jsx("div", { role: "radiogroup", "aria-label": t('Code agent'), children: _jsx(RuntimeAgentList, { orderedAgents: picker.orderedAgents, value: value, onChange: onChange, ...definedProps({ source: { agentIconBasePath } }), t: t }) }), _jsx(RuntimeRescanFooter, { onRescan: onRescan, scanning: scanning, t: t })] }))] }),
|
|
156
|
+
return createPortal(_jsxs("div", { ref: picker.popoverRef, className: "jini-runtime-popover", "data-agent-page": portal.page, ...(picker.originTheme ? { 'data-theme': picker.originTheme } : {}), id: picker.dialogId, role: "dialog", "aria-label": t('Choose AI runtime'), "aria-modal": "false", style: picker.position, onKeyDown: picker.handlePopoverKeyDown, children: [_jsxs("div", { className: "jini-runtime-popover__head", children: [_jsx("strong", { children: executionMode === 'local' ? t('Local CLI') : t('API · BYOK') }), _jsx("span", { children: picker.runtimeSummary })] }), _jsx(RuntimeModeButtons, { base: base, executionMode: executionMode, daemonOnline: daemonOnline, apiModeAvailable: apiModeAvailable, onExecutionModeChange: onExecutionModeChange, t: t }), isApi ? (_jsx(RuntimeByokDetails, { base: base, byokRuntime: byokRuntime, onByokModelChange: onByokModelChange, t: t })) : (_jsxs(_Fragment, { children: [_jsx("div", { className: "jini-runtime-section-label", children: t('Code agent') }), _jsx("div", { role: "radiogroup", "aria-label": t('Code agent'), children: _jsx(RuntimeAgentList, { base: base, orderedAgents: picker.orderedAgents, value: value, onChange: onChange, ...definedProps({ source: { agentIconBasePath } }), t: t }) }), _jsx(RuntimeRescanFooter, { base: base, onRescan: onRescan, scanning: scanning, t: t })] }))] }), portal.container);
|
|
147
157
|
}
|
|
148
158
|
/**
|
|
149
159
|
* Renders the package-owned local/API, agent, model, and reasoning picker.
|
|
@@ -151,11 +161,12 @@ function RuntimePopover({ picker, value, onChange, onRescan, scanning, daemonOnl
|
|
|
151
161
|
* @complexity Time: O(n) in the runtime inventory; space: O(n) for ordering.
|
|
152
162
|
* @overallScore 100/100
|
|
153
163
|
*/
|
|
154
|
-
export function AgentRuntimePicker({ agents, nativeToolPolicy, value, onChange, onRescan, scanning = false, daemonOnline = true, placement = 'up', executionMode = 'local', apiModeAvailable = false, onExecutionModeChange, byokRuntime, onByokModelChange,
|
|
164
|
+
export function AgentRuntimePicker({ agentHandle, agents, nativeToolPolicy, value, onChange, onRescan, scanning = false, daemonOnline = true, placement = 'up', executionMode = 'local', apiModeAvailable = false, onExecutionModeChange, byokRuntime, onByokModelChange,
|
|
155
165
|
// No default here (was '/agent-icons'): omitted means "let AgentIcon fall back to its own
|
|
156
166
|
// bundled icon set" — see AgentIcon.tsx's BUNDLED_ICON_URLS. A host that still wants to vendor
|
|
157
167
|
// its own asset directory can pass this explicitly, same as before.
|
|
158
168
|
agentIconBasePath, }) {
|
|
169
|
+
const base = useAgentHandle({ agentHandle });
|
|
159
170
|
const t = useT();
|
|
160
171
|
const picker = useAgentRuntimePicker({ agents, value, placement, t, executionMode, byokRuntime });
|
|
161
172
|
// The one branch this component makes. Everything below the mode buttons describes a detected CLI
|
|
@@ -164,6 +175,6 @@ agentIconBasePath, }) {
|
|
|
164
175
|
// operator on BYOK saw a CLI named as "selected" and a model reading "Default (CLI config)"
|
|
165
176
|
// while their messages went to a provider over an API key.
|
|
166
177
|
const isApi = executionMode === 'api';
|
|
167
|
-
return (_jsxs("div", { className: "jini-runtime-picker", children: [_jsx(RuntimeTrigger, { picker: picker, isApi: isApi, byokRuntime: byokRuntime, agentIconBasePath: agentIconBasePath, t: t }), isApi ? null : (_jsx(RuntimeBarMenus, { selectedAgent: picker.selectedAgent, value: value, onChange: onChange, modelLabel: picker.modelLabel, t: t })), _jsx(NativeToolPolicyWarning, { agent: picker.selectedAgent, policy: nativeToolPolicy, isApi: isApi }), _jsx(RuntimePopover, { picker: picker, value: value, onChange: onChange, onRescan: onRescan, scanning: scanning, daemonOnline: daemonOnline, executionMode: executionMode, apiModeAvailable: apiModeAvailable, onExecutionModeChange: onExecutionModeChange, byokRuntime: byokRuntime, onByokModelChange: onByokModelChange, agentIconBasePath: agentIconBasePath, t: t })] }));
|
|
178
|
+
return (_jsxs("div", { className: "jini-runtime-picker", children: [_jsx(RuntimeTrigger, { base: base, picker: picker, isApi: isApi, byokRuntime: byokRuntime, agentIconBasePath: agentIconBasePath, t: t }), isApi ? null : (_jsx(RuntimeBarMenus, { base: base, selectedAgent: picker.selectedAgent, value: value, onChange: onChange, modelLabel: picker.modelLabel, t: t })), _jsx(NativeToolPolicyWarning, { agent: picker.selectedAgent, policy: nativeToolPolicy, isApi: isApi }), _jsx(RuntimePopover, { base: base, picker: picker, value: value, onChange: onChange, onRescan: onRescan, scanning: scanning, daemonOnline: daemonOnline, executionMode: executionMode, apiModeAvailable: apiModeAvailable, onExecutionModeChange: onExecutionModeChange, byokRuntime: byokRuntime, onByokModelChange: onByokModelChange, agentIconBasePath: agentIconBasePath, t: t })] }));
|
|
168
179
|
}
|
|
169
180
|
//# sourceMappingURL=AgentRuntimePicker.js.map
|
|
@@ -2,13 +2,14 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { AgentPluginUsage } from './AgentPluginUsage.js';
|
|
3
3
|
import { SECRET_REDACTED_NOTICE } from '../../../../core/user-text-redaction.js';
|
|
4
4
|
import { useEffect, useId, useMemo, useRef } from 'react';
|
|
5
|
-
import { WorkingDirPicker } from '@jini-ai/ui';
|
|
5
|
+
import { WorkingDirPicker, useAgentHandle } from '@jini-ai/ui';
|
|
6
6
|
import { Composer } from '../../../components/Composer.js';
|
|
7
7
|
import { appendComposerDiscovery } from '../../../components/composer-discovery.js';
|
|
8
|
+
import { Icon } from '../../../components/Icon.js';
|
|
8
9
|
import { MessageList } from '../../../components/MessageList.js';
|
|
9
10
|
import { useT } from '../../../hooks/context.js';
|
|
10
11
|
import { definedProps } from '../../../util/defined-props.js';
|
|
11
|
-
import { describeChatPaneSendBlocker, describeTypedAnswerNotice, isChatPaneApiModeConfigured, isChatPaneFileDropEnabled } from '../rules.js';
|
|
12
|
+
import { chatPaneSendBlockerNeedsNotice, describeAttachmentError, describeChatPaneSendBlocker, describeTypedAnswerNotice, isChatPaneApiModeConfigured, isChatPaneFileDropEnabled } from '../rules.js';
|
|
12
13
|
import { useChatPane } from '../hooks/useChatPane.hooks.js';
|
|
13
14
|
import { useChatPaneAgentControl } from '../hooks/useChatPaneAgentControl.hooks.js';
|
|
14
15
|
import { useChatPaneComposerPlaceholder } from '../hooks/useChatPaneComposerPlaceholder.hooks.js';
|
|
@@ -115,6 +116,11 @@ function ChatPaneTypedAnswerNotice({ typedAnswerNotice, t, }) {
|
|
|
115
116
|
return null;
|
|
116
117
|
return (_jsx("div", { className: "jini-chat-pane__error", role: "alert", children: t(describeTypedAnswerNotice({ notice: typedAnswerNotice })) }));
|
|
117
118
|
}
|
|
119
|
+
/** A failed upload, in plain words, with redacted details a person can copy into a report. */
|
|
120
|
+
function ChatPaneAttachmentError({ error, t }) {
|
|
121
|
+
const { summary, details } = describeAttachmentError({ error });
|
|
122
|
+
return (_jsxs("div", { className: "jini-chat-pane__error", role: "alert", children: [_jsx("div", { children: t(summary) }), details ? _jsxs("div", { className: "jini-chat-pane__error-details", children: [t('Details:'), " ", details] }) : null] }));
|
|
123
|
+
}
|
|
118
124
|
/** A send the server never accepted. Its text went back into the composer if that was still empty;
|
|
119
125
|
* Retry sends it again either way (see `useChatPane`'s `retrySend`). */
|
|
120
126
|
function ChatPaneSendError({ sendError, onRetry, t }) {
|
|
@@ -126,7 +132,7 @@ function ChatPaneSendError({ sendError, onRetry, t }) {
|
|
|
126
132
|
* source of truth, so they are rendered as siblings rather than folded into one derived state. */
|
|
127
133
|
function ChatPaneStatusMessages({ sendError, onRetrySend, attachmentError, dropReadError, workingDirectoryError, workingDirectoryPending, workingDirectoryInvalid, runtimeInventoryError, typedAnswerNotice, ...availability }) {
|
|
128
134
|
const { t } = availability;
|
|
129
|
-
return (_jsxs(_Fragment, { children: [_jsx(ChatPaneAvailabilityStatus, { ...availability }), _jsx(ChatPaneSendError, { sendError: sendError, onRetry: onRetrySend, t: t }), attachmentError ?
|
|
135
|
+
return (_jsxs(_Fragment, { children: [_jsx(ChatPaneAvailabilityStatus, { ...availability }), _jsx(ChatPaneSendError, { sendError: sendError, onRetry: onRetrySend, t: t }), attachmentError ? _jsx(ChatPaneAttachmentError, { error: attachmentError, t: t }) : null, dropReadError ? (_jsx("div", { className: "jini-chat-pane__error", role: "alert", children: dropReadError })) : null, workingDirectoryError ? (_jsx("div", { className: "jini-chat-pane__error", role: "alert", children: workingDirectoryError.message })) : null, _jsx(ChatPaneWorkingDirectoryStatus, { workingDirectoryPending: workingDirectoryPending, workingDirectoryInvalid: workingDirectoryInvalid, t: t }), runtimeInventoryError && !availability.connectingAgents ? (_jsx("div", { className: "jini-chat-pane__error", role: "alert", children: runtimeInventoryError.message })) : null, _jsx(ChatPaneTypedAnswerNotice, { typedAnswerNotice: typedAnswerNotice, t: t })] }));
|
|
130
136
|
}
|
|
131
137
|
function ChatPaneWorkingDirectoryBlock({ workingDirectoryAccess, workingDirectoryControlPlacement, pane, t, }) {
|
|
132
138
|
if (workingDirectoryAccess && workingDirectoryControlPlacement === 'below') {
|
|
@@ -215,17 +221,21 @@ function resolveComposerWorkingDirectory(workingDirectoryAccess, workingDirector
|
|
|
215
221
|
* The pending-turn strip previously lived here (a banner bolted above the composer). It now
|
|
216
222
|
* renders inside `<MessageList>` itself, as the newest transcript entry — see that component's
|
|
217
223
|
* `pendingPrompts` prop and this component's own call site below. */
|
|
218
|
-
function ChatPaneComposerArea({ fileDrop, uploadAttachments, pane, disabled, unavailable, placeholder, slots, attachmentAccept, workingDirectoryAccess, workingDirectoryControlPlacement, t, }) {
|
|
224
|
+
function ChatPaneComposerArea({ agentHandle, fileDrop, uploadAttachments, pane, disabled, unavailable, placeholder, slots, attachmentAccept, workingDirectoryAccess, workingDirectoryControlPlacement, t, }) {
|
|
219
225
|
const sendDisabledReasonId = useId();
|
|
220
226
|
const sendDisabledReason = pane.sendBlocker && pane.sendBlocker !== 'streaming'
|
|
221
227
|
? t(describeChatPaneSendBlocker(pane.sendBlocker))
|
|
222
228
|
: undefined;
|
|
223
|
-
|
|
229
|
+
// MOVE: the reason used to sit in the composer's footer row beside the folder and model buttons.
|
|
230
|
+
// It is now a notice above the composer, with the other pane notices; Send's tooltip keeps it.
|
|
231
|
+
// While the pane is unavailable its own banner (loading, no usable CLI) already says it.
|
|
232
|
+
const showsNotice = sendDisabledReason !== undefined && !unavailable && chatPaneSendBlockerNeedsNotice({ blocker: pane.sendBlocker });
|
|
233
|
+
return (_jsxs("div", { className: `jini-chat-pane__drop-target${fileDrop.draggingFiles ? ' is-dragging-files' : ''}`, "data-testid": "chat-pane-file-drop-target", "data-dragging-files": fileDrop.draggingFiles ? 'true' : 'false', ...resolveDropTargetProps(uploadAttachments, fileDrop), children: [fileDrop.draggingFiles ? (_jsx("span", { className: "jini-chat-pane__drop-announcement", role: "status", children: t('Drop files to attach') })) : null, showsNotice ? (_jsxs("div", { id: sendDisabledReasonId, className: "jini-chat-pane__status jini-chat-pane__blocker", role: "status", children: [pane.sendBlocker === 'uploads-pending' ? _jsx(Icon, { name: "spinner", size: 13 }) : null, _jsx("span", { children: sendDisabledReason })] })) : null, _jsx(Composer, { agentHandle: agentHandle, composer: pane.composer, onSend: () => void pane.send(),
|
|
224
234
|
// Streaming no longer locks the textarea: `pane.send()` queues a turn typed during a run
|
|
225
235
|
// rather than refusing it, so the operator can keep writing while the agent thinks.
|
|
226
236
|
disabled: disabled || unavailable,
|
|
227
237
|
// The one blocker `send()` handles itself. Every other refusal still greys out the button.
|
|
228
|
-
sendDisabled: !pane.canSend && pane.sendBlocker !== 'streaming', ...definedProps({ source: { sendDisabledReason, sendDisabledReasonId:
|
|
238
|
+
sendDisabled: !pane.canSend && pane.sendBlocker !== 'streaming', ...definedProps({ source: { sendDisabledReason, sendDisabledReasonId: showsNotice ? sendDisabledReasonId : undefined } }), running: pane.conversation.isStreaming, onCancel: pane.conversation.cancel, ...definedProps({ source: { placeholder } }), slots: slots, ...resolveComposerAttachmentPicker(uploadAttachments, pane, attachmentAccept), ...resolveComposerWorkingDirectory(workingDirectoryAccess, workingDirectoryControlPlacement, pane) }), _jsx(ChatPaneWorkingDirectoryBlock, { workingDirectoryAccess: workingDirectoryAccess, workingDirectoryControlPlacement: workingDirectoryControlPlacement, pane: pane, t: t })] }));
|
|
229
239
|
}
|
|
230
240
|
const EMPTY_SUGGESTIONS = [];
|
|
231
241
|
const CHAT_PANE_DEFAULTS = {
|
|
@@ -323,6 +333,7 @@ function showsControlsSuggestions(embed, messageCount, emptyState) {
|
|
|
323
333
|
*/
|
|
324
334
|
export function ChatPane(props) {
|
|
325
335
|
const p = applyChatPaneDefaults(props);
|
|
336
|
+
const base = useAgentHandle({ agentHandle: p.agentHandle });
|
|
326
337
|
const t = useT();
|
|
327
338
|
const surface = useChatPaneSurface({
|
|
328
339
|
variant: p.variant,
|
|
@@ -395,7 +406,7 @@ export function ChatPane(props) {
|
|
|
395
406
|
const slots = buildChatPaneSlots({
|
|
396
407
|
surfaceSlots: surface.composerSlots,
|
|
397
408
|
embed: surface.embed,
|
|
398
|
-
renderRuntimePicker: () => (_jsx(AgentRuntimePicker, { agents: runtimeView.agents, value: pane.selection, onChange: pane.setSelection, ...definedProps({ source: { onRescan: runtimeView.rescanAgents } }), scanning: runtimeView.scanningAgents, daemonOnline: runtimeView.daemonOnline, placement: p.runtimePickerPlacement, executionMode: p.executionMode, apiModeAvailable: p.apiModeAvailable, ...definedProps({ source: {
|
|
409
|
+
renderRuntimePicker: () => (_jsx(AgentRuntimePicker, { agentHandle: base ? `${base}-runtime` : false, agents: runtimeView.agents, value: pane.selection, onChange: pane.setSelection, ...definedProps({ source: { onRescan: runtimeView.rescanAgents } }), scanning: runtimeView.scanningAgents, daemonOnline: runtimeView.daemonOnline, placement: p.runtimePickerPlacement, executionMode: p.executionMode, apiModeAvailable: p.apiModeAvailable, ...definedProps({ source: {
|
|
399
410
|
onExecutionModeChange: p.onExecutionModeChange,
|
|
400
411
|
byokRuntime: p.byokRuntime,
|
|
401
412
|
onByokModelChange: p.onByokModelChange,
|
|
@@ -406,6 +417,6 @@ export function ChatPane(props) {
|
|
|
406
417
|
const selectSuggestion = useChatPaneSuggestion({ rootRef, setDraft: pane.composer.setDraft });
|
|
407
418
|
const openLinkInNewTab = useChatPaneNewTabLinks();
|
|
408
419
|
const { pendingPrompts, projectFileNameSet } = useChatPaneTranscriptProps({ pane }, definedProps({ source: { projectFileNames: p.projectFileNames } }));
|
|
409
|
-
return (_jsxs("section", { className: chatPaneClassName(p.variant, p.className), style: p.style, "data-activity": pane.activity, ref: rootRef, onClickCapture: openLinkInNewTab, children: [_jsx("style", { "data-jini-chat-pane-styles": "true", children: CHAT_PANE_STYLES }), p.header ?? defaultHeader(p.title, pane.reset, t), p.agentPluginsMode !== 'off' && _jsx(AgentPluginUsage, { conversationId: pane.conversation.conversationId, messages: pane.conversation.messages }), _jsxs("div", { className: "jini-chat-pane__body", children: [_jsx(ChatPaneTranscript, { pane: pane, sendingLabel: p.sendingLabel, emptyState: p.emptyState, embed: surface.embed, suggestions: p.suggestions, onSelectSuggestion: selectSuggestion, pendingPrompts: pendingPrompts, projectFileNameSet: projectFileNameSet, toolCallDisplay: p.toolCallDisplay, showUsageLine: p.showUsageLine, showThinking: p.showThinking, t: t }), _jsxs("div", { className: "jini-chat-pane__controls", ref: controlsRef, children: [showsControlsSuggestions(surface.embed, pane.conversation.messages.length, p.emptyState) && (_jsx(ChatPaneSuggestionsRow, { suggestions: p.suggestions, onSelect: selectSuggestion, t: t })), pane.secretRedacted ? (_jsxs("div", { className: "jini-chat-pane__status jini-chat-pane__status--dismissible", role: "status", children: [_jsx("span", { children: t(SECRET_REDACTED_NOTICE) }), _jsx("button", { type: "button", className: "jini-chat-pane__error-action", onClick: pane.dismissSecretRedacted, children: t('Dismiss') })] })) : null, _jsx(ChatPaneStatusMessages, { unavailable: unavailable, scanningAgents: runtimeView.scanningAgents, connectingAgents: runtimeView.connectingAgents, executionMode: p.executionMode, apiModeAvailable: p.apiModeAvailable, onExecutionModeChange: p.onExecutionModeChange, sendError: pane.conversation.sendError, onRetrySend: () => void pane.retrySend(), attachmentError: pane.attachmentError, dropReadError: fileDrop.dropReadError, workingDirectoryError: pane.workingDirectoryError, workingDirectoryPending: pane.workingDirectoryPending, workingDirectoryInvalid: pane.workingDirectoryInvalid, runtimeInventoryError: inventory.runtimeInventoryError, typedAnswerNotice: pane.typedAnswerNotice, t: t }), _jsx(ChatPaneComposerArea, { fileDrop: fileDrop, uploadAttachments: surface.uploadAttachments, pane: pane, disabled: p.disabled, unavailable: unavailable, placeholder: composerPlaceholder, slots: slots, attachmentAccept: p.attachmentAccept, workingDirectoryAccess: p.workingDirectoryAccess, workingDirectoryControlPlacement: surface.workingDirectoryControlPlacement, t: t })] })] }), p.footer] }));
|
|
420
|
+
return (_jsxs("section", { className: chatPaneClassName(p.variant, p.className), style: p.style, "data-activity": pane.activity, ref: rootRef, onClickCapture: openLinkInNewTab, children: [_jsx("style", { "data-jini-chat-pane-styles": "true", children: CHAT_PANE_STYLES }), p.header ?? defaultHeader(p.title, pane.reset, t), p.agentPluginsMode !== 'off' && _jsx(AgentPluginUsage, { conversationId: pane.conversation.conversationId, messages: pane.conversation.messages }), _jsxs("div", { className: "jini-chat-pane__body", children: [_jsx(ChatPaneTranscript, { pane: pane, sendingLabel: p.sendingLabel, emptyState: p.emptyState, embed: surface.embed, suggestions: p.suggestions, onSelectSuggestion: selectSuggestion, pendingPrompts: pendingPrompts, projectFileNameSet: projectFileNameSet, toolCallDisplay: p.toolCallDisplay, showUsageLine: p.showUsageLine, showThinking: p.showThinking, t: t }), _jsxs("div", { className: "jini-chat-pane__controls", ref: controlsRef, children: [showsControlsSuggestions(surface.embed, pane.conversation.messages.length, p.emptyState) && (_jsx(ChatPaneSuggestionsRow, { suggestions: p.suggestions, onSelect: selectSuggestion, t: t })), pane.secretRedacted ? (_jsxs("div", { className: "jini-chat-pane__status jini-chat-pane__status--dismissible", role: "status", children: [_jsx("span", { children: t(SECRET_REDACTED_NOTICE) }), _jsx("button", { type: "button", className: "jini-chat-pane__error-action", onClick: pane.dismissSecretRedacted, children: t('Dismiss') })] })) : null, _jsx(ChatPaneStatusMessages, { unavailable: unavailable, scanningAgents: runtimeView.scanningAgents, connectingAgents: runtimeView.connectingAgents, executionMode: p.executionMode, apiModeAvailable: p.apiModeAvailable, onExecutionModeChange: p.onExecutionModeChange, sendError: pane.conversation.sendError, onRetrySend: () => void pane.retrySend(), attachmentError: pane.attachmentError, dropReadError: fileDrop.dropReadError, workingDirectoryError: pane.workingDirectoryError, workingDirectoryPending: pane.workingDirectoryPending, workingDirectoryInvalid: pane.workingDirectoryInvalid, runtimeInventoryError: inventory.runtimeInventoryError, typedAnswerNotice: pane.typedAnswerNotice, t: t }), _jsx(ChatPaneComposerArea, { agentHandle: base ? `${base}-composer` : false, fileDrop: fileDrop, uploadAttachments: surface.uploadAttachments, pane: pane, disabled: p.disabled, unavailable: unavailable, placeholder: composerPlaceholder, slots: slots, attachmentAccept: p.attachmentAccept, workingDirectoryAccess: p.workingDirectoryAccess, workingDirectoryControlPlacement: surface.workingDirectoryControlPlacement, t: t })] })] }), p.footer] }));
|
|
410
421
|
}
|
|
411
422
|
//# sourceMappingURL=ChatPane.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
export interface RuntimeDropUpProps {
|
|
3
|
+
agentHandle?: string | false | undefined;
|
|
3
4
|
/** Names both the trigger (with the current value appended) and the menu. */
|
|
4
5
|
label: string;
|
|
5
6
|
/** What the trigger shows: the current choice's display label. */
|
|
@@ -25,5 +26,5 @@ export interface RuntimeDropUpProps {
|
|
|
25
26
|
*
|
|
26
27
|
* @complexity Time/space: O(n) in the option count.
|
|
27
28
|
*/
|
|
28
|
-
export declare function RuntimeDropUp({ label, valueLabel, triggerLabel, value, options, onSelect, note, width, className, }: RuntimeDropUpProps): ReactNode;
|
|
29
|
+
export declare function RuntimeDropUp({ agentHandle, label, valueLabel, triggerLabel, value, options, onSelect, note, width, className, }: RuntimeDropUpProps): ReactNode;
|
|
29
30
|
//# sourceMappingURL=RuntimeDropUp.d.ts.map
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
+
import { createElement as _createElement } from "react";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
3
|
import { createPortal } from 'react-dom';
|
|
3
|
-
import { RemixIcon, infoTipBubbleStyle, useInfoTip } from '@jini-ai/ui';
|
|
4
|
+
import { RemixIcon, infoTipBubbleStyle, useInfoTip, useAgentHandle } from '@jini-ai/ui';
|
|
5
|
+
import { agentHandleProps, agentHandleSegment } from '@jini-ai/agentic';
|
|
4
6
|
import { useRuntimeDropUp } from '../hooks/useRuntimeDropUp.hooks.js';
|
|
5
7
|
/** The full `valueLabel` in the same white bubble `InfoTip` uses, portalled to `document.body`. */
|
|
6
8
|
function RuntimeDropUpTipBubble({ tip, valueLabel }) {
|
|
7
9
|
return createPortal(_jsx("span", { ref: tip.bubbleRef, className: tip.placement === 'below' ? 'info-tip-bubble info-tip-bubble-below' : 'info-tip-bubble', role: "presentation", "aria-hidden": "true", style: infoTipBubbleStyle(tip.coords), children: valueLabel }), document.body);
|
|
8
10
|
}
|
|
9
|
-
function RuntimeDropUpMenu({ dropUp, label, value, options, onSelect, note }) {
|
|
11
|
+
function RuntimeDropUpMenu({ base, dropUp, label, value, options, onSelect, note }) {
|
|
10
12
|
if (!dropUp.open || !dropUp.position)
|
|
11
13
|
return null;
|
|
12
14
|
return (_jsxs("div", { ref: dropUp.menuRef, id: dropUp.menuId, role: "menu", "aria-label": label, className: "jini-runtime-dropup", style: dropUp.position, onKeyDown: dropUp.handleMenuKeyDown, children: [note ? _jsx("div", { className: "jini-runtime-dropup__note", children: note }) : null, options.map((option) => {
|
|
13
15
|
const active = option.id === value;
|
|
14
|
-
return (
|
|
16
|
+
return (_createElement("button", { type: "button", ...agentHandleProps({}, { base, action: `option-${agentHandleSegment({ value: option.id })}`, role: 'button', label: option.label }), role: "menuitemradio", "aria-checked": active, className: `jini-runtime-dropup__item${active ? ' is-active' : ''}`, key: option.id, onClick: () => dropUp.choose(() => onSelect(option.id)) },
|
|
17
|
+
_jsx("span", { className: "jini-runtime-dropup__item-label", children: option.label }),
|
|
18
|
+
active ? _jsx(RemixIcon, { name: "check-line", size: 16, className: "jini-runtime-check" }) : null));
|
|
15
19
|
})] }));
|
|
16
20
|
}
|
|
17
21
|
/**
|
|
@@ -20,7 +24,8 @@ function RuntimeDropUpMenu({ dropUp, label, value, options, onSelect, note }) {
|
|
|
20
24
|
*
|
|
21
25
|
* @complexity Time/space: O(n) in the option count.
|
|
22
26
|
*/
|
|
23
|
-
export function RuntimeDropUp({ label, valueLabel, triggerLabel, value, options, onSelect, note, width, className, }) {
|
|
27
|
+
export function RuntimeDropUp({ agentHandle, label, valueLabel, triggerLabel, value, options, onSelect, note, width, className, }) {
|
|
28
|
+
const base = useAgentHandle({ agentHandle });
|
|
24
29
|
const dropUp = useRuntimeDropUp({ width });
|
|
25
30
|
const { menuId, open, triggerRef, toggleOpen, handleTriggerKeyDown } = dropUp;
|
|
26
31
|
// The same white bubble as `InfoTip` (its hook places it), rather than the browser's own title
|
|
@@ -33,13 +38,13 @@ export function RuntimeDropUp({ label, valueLabel, triggerLabel, value, options,
|
|
|
33
38
|
if (tipVisible)
|
|
34
39
|
tip.show();
|
|
35
40
|
};
|
|
36
|
-
return (_jsxs(_Fragment, { children: [_jsxs("button", { ref: triggerRef, type: "button", className: 'jini-runtime-dropup-trigger' + (className ? ' ' + className : ''), "aria-label": `${label}: ${valueLabel}`, "aria-haspopup": "menu", "aria-expanded": open, "aria-controls": menuId, ...(shortened ? {} : { title: valueLabel }), onClick: () => {
|
|
41
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { ...agentHandleProps({}, { base, role: 'button', label }), ref: triggerRef, type: "button", className: 'jini-runtime-dropup-trigger' + (className ? ' ' + className : ''), "aria-label": `${label}: ${valueLabel}`, "aria-haspopup": "menu", "aria-expanded": open, "aria-controls": menuId, ...(shortened ? {} : { title: valueLabel }), onClick: () => {
|
|
37
42
|
tip.hide();
|
|
38
43
|
toggleOpen();
|
|
39
44
|
}, onKeyDown: (event) => {
|
|
40
45
|
if (event.key === 'Escape')
|
|
41
46
|
tip.hide();
|
|
42
47
|
handleTriggerKeyDown(event);
|
|
43
|
-
}, onMouseEnter: showTip, onMouseLeave: tip.leave, onFocus: showTip, onBlur: tip.hide, children: [_jsx("span", { ref: tip.iconRef, className: "jini-runtime-dropup-trigger__label", children: triggerLabel ?? valueLabel }), _jsx(RemixIcon, { name: "arrow-down-s-line", size: 15, className: "jini-runtime-trigger__chevron" })] }), tip.open && tipVisible ? _jsx(RuntimeDropUpTipBubble, { tip: tip, valueLabel: valueLabel }) : null, _jsx(RuntimeDropUpMenu, { dropUp: dropUp, label: label, value: value, options: options, onSelect: onSelect, note: note })] }));
|
|
48
|
+
}, onMouseEnter: showTip, onMouseLeave: tip.leave, onFocus: showTip, onBlur: tip.hide, children: [_jsx("span", { ref: tip.iconRef, className: "jini-runtime-dropup-trigger__label", children: triggerLabel ?? valueLabel }), _jsx(RemixIcon, { name: "arrow-down-s-line", size: 15, className: "jini-runtime-trigger__chevron" })] }), tip.open && tipVisible ? _jsx(RuntimeDropUpTipBubble, { tip: tip, valueLabel: valueLabel }) : null, _jsx(RuntimeDropUpMenu, { base: base, dropUp: dropUp, label: label, value: value, options: options, onSelect: onSelect, note: note })] }));
|
|
44
49
|
}
|
|
45
50
|
//# sourceMappingURL=RuntimeDropUp.js.map
|
|
@@ -357,6 +357,14 @@ export function useChatPane(options) {
|
|
|
357
357
|
latestFoldersRef.current = composer.folders ?? [];
|
|
358
358
|
const latestAttachmentsRef = useRef(composer.attachments);
|
|
359
359
|
latestAttachmentsRef.current = composer.attachments;
|
|
360
|
+
// Removing an attachment is how the user makes room after a "total too large" failure, so the
|
|
361
|
+
// failure notice goes with it instead of staying on screen (it still also clears on the next upload).
|
|
362
|
+
const attachmentCountRef = useRef(composer.attachments.length);
|
|
363
|
+
useEffect(() => {
|
|
364
|
+
if (composer.attachments.length < attachmentCountRef.current)
|
|
365
|
+
setAttachmentError(null);
|
|
366
|
+
attachmentCountRef.current = composer.attachments.length;
|
|
367
|
+
}, [composer.attachments.length]);
|
|
360
368
|
useEffect(() => {
|
|
361
369
|
const previous = typedAnswerConversationRef.current;
|
|
362
370
|
typedAnswerConversationRef.current = options.conversationId;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ChatMessage } from '@jini-ai/chat';
|
|
2
|
-
import type
|
|
2
|
+
import { type UserTextRedaction } from '../../../core/user-text-redaction.js';
|
|
3
3
|
import type { ByokRuntimeSummary, ChatPaneAgent, ChatPaneAgentSelection, TypedAnswerNotice } from './types.js';
|
|
4
4
|
export declare function defaultChatPaneSelection({ agent }: {
|
|
5
5
|
agent: ChatPaneAgent;
|
|
@@ -70,6 +70,27 @@ export declare function isChatPaneFileDropEnabled({ canUpload, disabled, unavail
|
|
|
70
70
|
* @returns The first blocker found, or `null` when sending is allowed.
|
|
71
71
|
*/
|
|
72
72
|
export declare function findChatPaneSendBlocker(state: ChatPaneSendability): ChatPaneSendBlocker | null;
|
|
73
|
+
/**
|
|
74
|
+
* Whether a blocker needs its own notice above the composer. `streaming` is handled by Send turning
|
|
75
|
+
* into Stop, and the working-directory ones already have a banner of their own
|
|
76
|
+
* (`ChatPaneWorkingDirectoryStatus` and the working-directory error banner), so repeating them would
|
|
77
|
+
* show the same sentence twice. Their text still reaches Send's tooltip.
|
|
78
|
+
*/
|
|
79
|
+
export declare function chatPaneSendBlockerNeedsNotice({ blocker }: {
|
|
80
|
+
blocker: ChatPaneSendBlocker | null;
|
|
81
|
+
}): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Plain words for a failed attachment upload: what happened and what to do, plus the reason with
|
|
84
|
+
* credential shapes removed, short enough to paste into a bug report.
|
|
85
|
+
*
|
|
86
|
+
* @complexity O(n) in the error message length.
|
|
87
|
+
*/
|
|
88
|
+
export declare function describeAttachmentError({ error }: {
|
|
89
|
+
error: Error;
|
|
90
|
+
}): {
|
|
91
|
+
summary: string;
|
|
92
|
+
details: string;
|
|
93
|
+
};
|
|
73
94
|
/** Human/model-readable reason for a blocker, so a refused agent send explains itself. */
|
|
74
95
|
export declare function describeChatPaneSendBlocker(blocker: ChatPaneSendBlocker): string;
|
|
75
96
|
/**
|