@mistriwork/agent-ui 1.4.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agentIde.d.ts +43 -2
- package/dist/agentIde.js +163 -27
- package/dist/fileTree.d.ts +29 -3
- package/dist/fileTree.js +82 -13
- package/dist/index.d.ts +3 -3
- package/dist/orchestrator.d.ts +25 -1
- package/dist/orchestrator.js +102 -33
- package/dist/pierreAdapter.d.ts +1 -1
- package/dist/pierreAdapter.js +56 -4
- package/dist/surfaces.d.ts +18 -1
- package/dist/surfaces.js +13 -2
- package/dist/tools.d.ts +14 -2
- package/dist/tools.js +97 -11
- package/dist/workbench.css +122 -0
- package/package.json +2 -2
package/dist/orchestrator.js
CHANGED
|
@@ -6,8 +6,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
* - `<ApprovalQueue>`: cross-agent permission & checkpoint approval inbox
|
|
7
7
|
* - `<PlanView>`: structured agent execution plan with progress meter
|
|
8
8
|
*/
|
|
9
|
-
import { useMemo, useState } from 'react';
|
|
10
|
-
import { Badge, Button, EmptyState, Meter, SegmentedControl, StatusDot } from '@mistriwork/mistri/ui';
|
|
9
|
+
import { memo, useCallback, useMemo, useState } from 'react';
|
|
10
|
+
import { Badge, Button, EmptyState, Meter, SegmentedControl, StatusDot, TextField } from '@mistriwork/mistri/ui';
|
|
11
11
|
import './workbench.css';
|
|
12
12
|
function sessionTone(status) {
|
|
13
13
|
if (status === 'completed')
|
|
@@ -33,32 +33,88 @@ function sessionLabel(status) {
|
|
|
33
33
|
return 'Failed';
|
|
34
34
|
return 'Idle';
|
|
35
35
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return
|
|
36
|
+
function hasAnyArchived(nodes) {
|
|
37
|
+
for (const node of nodes) {
|
|
38
|
+
if (node.archived)
|
|
39
|
+
return true;
|
|
40
|
+
if (node.children && hasAnyArchived(node.children))
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
if (filter === '
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
function matchesFilter(node, filter, showArchived, query) {
|
|
46
|
+
if (filter === 'archived') {
|
|
47
|
+
if (!node.archived)
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
else if (node.archived && !showArchived) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
if (filter === 'active' && node.status !== 'running' && node.status !== 'waiting_approval' && node.status !== 'paused') {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
if (filter === 'waiting' && node.status !== 'waiting_approval' && (node.pendingApprovals ?? 0) === 0) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (filter === 'failed' && node.status !== 'failed') {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
if (query) {
|
|
63
|
+
const haystack = [node.title, node.model, node.branch, ...(node.repos ?? [])].filter(Boolean).join(' ').toLowerCase();
|
|
64
|
+
if (!haystack.includes(query))
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
function sortPinnedFirst(nodes) {
|
|
70
|
+
const pinned = [];
|
|
71
|
+
const rest = [];
|
|
49
72
|
for (const node of nodes) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
73
|
+
if (node.pinned)
|
|
74
|
+
pinned.push(node);
|
|
75
|
+
else
|
|
76
|
+
rest.push(node);
|
|
77
|
+
}
|
|
78
|
+
return [...pinned, ...rest];
|
|
79
|
+
}
|
|
80
|
+
function filterTree(nodes, filter, showArchived, query) {
|
|
81
|
+
const ordered = sortPinnedFirst(nodes);
|
|
82
|
+
const out = [];
|
|
83
|
+
for (const node of ordered) {
|
|
84
|
+
const kids = node.children ? filterTree(node.children, filter, showArchived, query) : [];
|
|
85
|
+
if (matchesFilter(node, filter, showArchived, query) || kids.length > 0) {
|
|
86
|
+
out.push({ ...node, ...(kids.length > 0 ? { children: kids } : { children: undefined }) });
|
|
53
87
|
}
|
|
54
88
|
}
|
|
55
89
|
return out;
|
|
56
90
|
}
|
|
57
|
-
|
|
91
|
+
const SessionRow = memo(function SessionRow({ node, selectedId, collapsed, editingId, draftTitle, onDraftTitleChange, onStartRename, onCommitRename, onCancelRename, onToggleCollapse, onSelect, onCancel, onFork, onRename, onWatch, onPin, onArchive, renderNodeActions, renderNodeBadges, }) {
|
|
92
|
+
const hasKids = Boolean(node.children && node.children.length > 0);
|
|
93
|
+
const isCollapsed = collapsed.has(node.id);
|
|
94
|
+
const selected = node.id === selectedId;
|
|
95
|
+
const isEditing = editingId === node.id;
|
|
96
|
+
const handleRenameKeyDown = (event) => {
|
|
97
|
+
if (event.key === 'Enter') {
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
onCommitRename();
|
|
100
|
+
}
|
|
101
|
+
else if (event.key === 'Escape') {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
onCancelRename();
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
return (_jsxs("li", { role: "treeitem", "aria-selected": selected, "aria-expanded": hasKids ? !isCollapsed : undefined, children: [_jsxs("div", { className: "aui-session-row", "data-selected": selected ? 'true' : undefined, "data-pinned": node.pinned ? 'true' : undefined, "data-watched": node.watched ? 'true' : undefined, "data-archived": node.archived ? 'true' : undefined, children: [_jsxs("div", { className: "aui-session-row-head", children: [hasKids ? (_jsx(Button, { size: "sm", variant: "ghost", ariaLabel: isCollapsed ? `Expand ${node.title}` : `Collapse ${node.title}`, onClick: () => onToggleCollapse(node.id), children: isCollapsed ? '▸' : '▾' })) : null, _jsx(StatusDot, { tone: sessionTone(node.status), pulse: node.status === 'running' }), isEditing ? (_jsxs("div", { className: "aui-session-rename", onKeyDown: handleRenameKeyDown, children: [_jsx(TextField, { label: `Rename ${node.title}`, labelHidden: true, reserve: false, value: draftTitle, onValueChange: onDraftTitleChange }), _jsx(Button, { size: "sm", variant: "primary", onClick: onCommitRename, children: "Save" }), _jsx(Button, { size: "sm", variant: "ghost", onClick: onCancelRename, children: "Cancel" })] })) : (_jsx("button", { type: "button", className: "aui-session-title", onClick: () => onSelect(node.id), children: node.title })), _jsx(Badge, { tone: sessionTone(node.status), children: sessionLabel(node.status) })] }), node.repos && node.repos.length > 0 ? (_jsx("div", { className: "aui-session-repos", "aria-label": "Repositories", children: node.repos.map((repo) => (_jsx(Badge, { tone: "neutral", children: repo }, repo))) })) : null, _jsxs("div", { className: "aui-session-meta", children: [node.pinned ? _jsx(Badge, { tone: "neutral", children: "Pinned" }) : null, node.watched ? _jsx(Badge, { tone: "info", children: "Watching" }) : null, node.archived ? _jsx(Badge, { tone: "neutral", children: "Archived" }) : null, node.model ? _jsx("span", { children: node.model }) : null, node.branch ? _jsx("span", { children: node.branch }) : null, node.durationLabel ? _jsx("span", { children: node.durationLabel }) : null, node.tokensLabel ? _jsx("span", { children: node.tokensLabel }) : null, node.pendingApprovals && node.pendingApprovals > 0 ? (_jsx(Badge, { tone: "warning", children: `${node.pendingApprovals} approval${node.pendingApprovals === 1 ? '' : 's'}` })) : null, renderNodeBadges ? renderNodeBadges(node) : null, _jsxs("span", { className: "aui-session-actions", children: [onWatch ? (_jsx(Button, { size: "sm", variant: node.watched ? 'secondary' : 'ghost', ariaLabel: node.watched ? `Unwatch ${node.title}` : `Watch ${node.title}`, onClick: () => onWatch(node.id, !node.watched), children: node.watched ? 'Unwatch' : 'Watch' })) : null, onPin ? (_jsx(Button, { size: "sm", variant: "ghost", ariaLabel: node.pinned ? `Unpin ${node.title}` : `Pin ${node.title}`, onClick: () => onPin(node.id, !node.pinned), children: node.pinned ? 'Unpin' : 'Pin' })) : null, onRename && !isEditing ? (_jsx(Button, { size: "sm", variant: "ghost", ariaLabel: `Rename ${node.title}`, onClick: () => onStartRename(node), children: "Rename" })) : null, onFork ? (_jsx(Button, { size: "sm", variant: "ghost", onClick: () => onFork(node.id), children: "Fork" })) : null, onCancel && (node.status === 'running' || node.status === 'paused') ? (_jsx(Button, { size: "sm", variant: "ghost", onClick: () => onCancel(node.id), children: "Stop" })) : null, onArchive ? (_jsx(Button, { size: "sm", variant: "ghost", ariaLabel: node.archived ? `Unarchive ${node.title}` : `Archive ${node.title}`, onClick: () => onArchive(node.id, !node.archived), children: node.archived ? 'Restore' : 'Archive' })) : null, renderNodeActions ? renderNodeActions(node) : null] })] })] }), hasKids && !isCollapsed ? (_jsx("ul", { className: "aui-session-list aui-session-children", children: node.children.map((child) => (_jsx(SessionRow, { node: child, selectedId: selectedId, collapsed: collapsed, editingId: editingId, draftTitle: draftTitle, onDraftTitleChange: onDraftTitleChange, onStartRename: onStartRename, onCommitRename: onCommitRename, onCancelRename: onCancelRename, onToggleCollapse: onToggleCollapse, onSelect: onSelect, onCancel: onCancel, onFork: onFork, onRename: onRename, onWatch: onWatch, onPin: onPin, onArchive: onArchive, renderNodeActions: renderNodeActions, renderNodeBadges: renderNodeBadges }, child.id))) })) : null] }));
|
|
107
|
+
});
|
|
108
|
+
export function SessionTree({ sessions, selectedId, onSelect, onCancel, onFork, onRename, onWatch, onPin, onArchive, renderNodeActions, renderNodeBadges, showArchived = false, searchable = false, filterable = false, empty, className, }) {
|
|
58
109
|
const [filter, setFilter] = useState('all');
|
|
110
|
+
const [query, setQuery] = useState('');
|
|
59
111
|
const [collapsed, setCollapsed] = useState(() => new Set());
|
|
60
|
-
const
|
|
61
|
-
const
|
|
112
|
+
const [editingId, setEditingId] = useState(null);
|
|
113
|
+
const [draftTitle, setDraftTitle] = useState('');
|
|
114
|
+
const archivedPresent = useMemo(() => hasAnyArchived(sessions), [sessions]);
|
|
115
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
116
|
+
const visible = useMemo(() => filterTree(sessions, filter, showArchived, normalizedQuery), [sessions, filter, showArchived, normalizedQuery]);
|
|
117
|
+
const toggleCollapse = useCallback((id) => {
|
|
62
118
|
setCollapsed((prev) => {
|
|
63
119
|
const next = new Set(prev);
|
|
64
120
|
if (next.has(id))
|
|
@@ -67,19 +123,32 @@ export function SessionTree({ sessions, selectedId, onSelect, onCancel, onFork,
|
|
|
67
123
|
next.add(id);
|
|
68
124
|
return next;
|
|
69
125
|
});
|
|
70
|
-
};
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
126
|
+
}, []);
|
|
127
|
+
const handleStartRename = useCallback((node) => {
|
|
128
|
+
setEditingId(node.id);
|
|
129
|
+
setDraftTitle(node.title);
|
|
130
|
+
}, []);
|
|
131
|
+
const handleCancelRename = useCallback(() => {
|
|
132
|
+
setEditingId(null);
|
|
133
|
+
setDraftTitle('');
|
|
134
|
+
}, []);
|
|
135
|
+
const handleCommitRename = useCallback(() => {
|
|
136
|
+
if (!editingId)
|
|
137
|
+
return;
|
|
138
|
+
const trimmed = draftTitle.trim();
|
|
139
|
+
if (trimmed)
|
|
140
|
+
onRename?.(editingId, trimmed);
|
|
141
|
+
setEditingId(null);
|
|
142
|
+
setDraftTitle('');
|
|
143
|
+
}, [editingId, draftTitle, onRename]);
|
|
144
|
+
const filterOptions = useMemo(() => [
|
|
145
|
+
{ value: 'all', label: 'All' },
|
|
146
|
+
{ value: 'active', label: 'Active' },
|
|
147
|
+
{ value: 'waiting', label: 'Approvals' },
|
|
148
|
+
{ value: 'failed', label: 'Failed' },
|
|
149
|
+
...(archivedPresent ? [{ value: 'archived', label: 'Archived' }] : []),
|
|
150
|
+
], [archivedPresent]);
|
|
151
|
+
return (_jsxs("div", { className: className ? `aui-session-tree ${className}` : 'aui-session-tree', children: [searchable ? (_jsx(TextField, { label: "Filter sessions", labelHidden: true, reserve: false, value: query, onValueChange: setQuery, placeholder: "Search sessions, branches, repos\u2026" })) : null, filterable ? (_jsx("div", { className: "aui-session-filters", children: _jsx(SegmentedControl, { ariaLabel: "Filter agent sessions", size: "sm", value: filter, onValueChange: (next) => setFilter(next), options: filterOptions }) })) : null, visible.length === 0 ? ((empty ?? _jsx(EmptyState, { compact: true, title: "No agent sessions" }))) : (_jsx("ul", { className: "aui-session-list", role: "tree", "aria-label": "Agent sessions", children: visible.map((node) => (_jsx(SessionRow, { node: node, selectedId: selectedId, collapsed: collapsed, editingId: editingId, draftTitle: draftTitle, onDraftTitleChange: setDraftTitle, onStartRename: handleStartRename, onCommitRename: handleCommitRename, onCancelRename: handleCancelRename, onToggleCollapse: toggleCollapse, onSelect: onSelect, onCancel: onCancel, onFork: onFork, onRename: onRename, onWatch: onWatch, onPin: onPin, onArchive: onArchive, renderNodeActions: renderNodeActions, renderNodeBadges: renderNodeBadges }, node.id))) }))] }));
|
|
83
152
|
}
|
|
84
153
|
export function RaceCompare({ candidates, winnerId, onPickWinner, onInspect, renderDiff, empty, className }) {
|
|
85
154
|
if (candidates.length === 0) {
|
package/dist/pierreAdapter.d.ts
CHANGED
|
@@ -153,7 +153,7 @@ export interface PierreDiffSurfaceProps extends DiffSurfaceProps {
|
|
|
153
153
|
}
|
|
154
154
|
/**
|
|
155
155
|
* `@pierre/diffs/react` `<MultiFileDiff>` / `<PatchDiff>` surface wrapper with
|
|
156
|
-
* automatic zero-dep fallback.
|
|
156
|
+
* automatic zero-dep fallback and optional multi-root grouping.
|
|
157
157
|
*
|
|
158
158
|
* Note: While `editable` is true, `PierreDiffSurface` keeps `newFile` stable
|
|
159
159
|
* across echoed `onChange` updates per `@pierre/diffs`'s `onEditChange` contract.
|
package/dist/pierreAdapter.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
* `@mistriwork/agent-ui/pierre`: Optional adapter connecting `@pierre/diffs`
|
|
4
4
|
* (`@pierre/diffs@1.7.2` Shiki code/diff viewer, virtualized split/unified
|
|
@@ -12,8 +12,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
12
12
|
* imported Pierre modules so Vite/Rolldown tree-shakes cleanly, and surfaces
|
|
13
13
|
* fall back gracefully to built-in zero-dep primitives if omitted.
|
|
14
14
|
*/
|
|
15
|
-
import { useCallback, useMemo, useRef } from 'react';
|
|
16
|
-
import {
|
|
15
|
+
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
16
|
+
import { Badge } from '@mistriwork/mistri/ui';
|
|
17
|
+
import { DefaultFileTree, resolveFileTreeRoots } from './fileTree.js';
|
|
17
18
|
import { DefaultCodeSurface, DefaultDiffSurface, } from './surfaces.js';
|
|
18
19
|
const DEFAULT_THEME = { dark: 'pierre-dark', light: 'pierre-light' };
|
|
19
20
|
function extractLineRange(content, startLine, endLine) {
|
|
@@ -261,9 +262,34 @@ function PierreDiffSurfaceMounted({ diffs, theme = DEFAULT_THEME, themeMode = 's
|
|
|
261
262
|
}
|
|
262
263
|
return rendered;
|
|
263
264
|
}
|
|
265
|
+
function PierreMultiRootDiffSurface(props) {
|
|
266
|
+
const [collapsedRoots, setCollapsedRoots] = useState(() => new Set());
|
|
267
|
+
const roots = props.roots ?? [];
|
|
268
|
+
const toggleRoot = useCallback((rootId) => {
|
|
269
|
+
setCollapsedRoots((prev) => {
|
|
270
|
+
const next = new Set(prev);
|
|
271
|
+
if (next.has(rootId))
|
|
272
|
+
next.delete(rootId);
|
|
273
|
+
else
|
|
274
|
+
next.add(rootId);
|
|
275
|
+
return next;
|
|
276
|
+
});
|
|
277
|
+
}, []);
|
|
278
|
+
if (roots.length === 0) {
|
|
279
|
+
return props.empty ? _jsx("div", { className: props.className, children: props.empty }) : null;
|
|
280
|
+
}
|
|
281
|
+
return (_jsx("div", { className: props.className ? `aui-diff-roots ${props.className}` : 'aui-diff-roots', children: roots.map((root) => {
|
|
282
|
+
const label = root.label ?? root.id;
|
|
283
|
+
const isCollapsed = collapsedRoots.has(root.id);
|
|
284
|
+
return (_jsxs("section", { className: "aui-diff-root", "aria-label": label, children: [_jsxs("button", { type: "button", className: "aui-diff-root-head", "aria-expanded": !isCollapsed, onClick: () => toggleRoot(root.id), children: [_jsx("span", { className: "aui-file-tree-caret", "aria-hidden": "true", children: isCollapsed ? '▸' : '▾' }), _jsx("span", { className: "aui-diff-root-label", children: label }), root.badge ? _jsx(Badge, { tone: "neutral", children: root.badge }) : null] }), !isCollapsed ? (_jsx("div", { className: "aui-diff-root-body", children: _jsx(PierreDiffSurfaceMounted, { ...props, roots: undefined, patch: root.patch, files: root.files, oldFile: root.oldFile, newFile: root.newFile, selectedFile: props.selectedRoot && props.selectedRoot !== root.id ? undefined : props.selectedFile, onSelectFile: (path) => {
|
|
285
|
+
props.onSelectInRoot?.(root.id, path);
|
|
286
|
+
props.onSelectFile?.(path);
|
|
287
|
+
} }) })) : null] }, root.id));
|
|
288
|
+
}) }));
|
|
289
|
+
}
|
|
264
290
|
/**
|
|
265
291
|
* `@pierre/diffs/react` `<MultiFileDiff>` / `<PatchDiff>` surface wrapper with
|
|
266
|
-
* automatic zero-dep fallback.
|
|
292
|
+
* automatic zero-dep fallback and optional multi-root grouping.
|
|
267
293
|
*
|
|
268
294
|
* Note: While `editable` is true, `PierreDiffSurface` keeps `newFile` stable
|
|
269
295
|
* across echoed `onChange` updates per `@pierre/diffs`'s `onEditChange` contract.
|
|
@@ -273,6 +299,9 @@ export function PierreDiffSurface(props) {
|
|
|
273
299
|
const { diffs: _d, theme: _t, themeMode: _tm, unsafeCSS: _u, createEditor: _c, ...rest } = props;
|
|
274
300
|
return _jsx(DefaultDiffSurface, { ...rest });
|
|
275
301
|
}
|
|
302
|
+
if (props.roots && props.roots.length > 0) {
|
|
303
|
+
return _jsx(PierreMultiRootDiffSurface, { ...props, diffs: props.diffs });
|
|
304
|
+
}
|
|
276
305
|
return _jsx(PierreDiffSurfaceMounted, { ...props, diffs: props.diffs });
|
|
277
306
|
}
|
|
278
307
|
function PierreFileTreeMounted({ trees, flatPaths, ...props }) {
|
|
@@ -286,6 +315,8 @@ function PierreFileTreeMounted({ trees, flatPaths, ...props }) {
|
|
|
286
315
|
return _jsx(TreeComponent, { model: model, className: props.className });
|
|
287
316
|
}
|
|
288
317
|
export function PierreFileTree({ trees, ...props }) {
|
|
318
|
+
const [collapsedRoots, setCollapsedRoots] = useState(() => new Set());
|
|
319
|
+
const resolvedRoots = useMemo(() => resolveFileTreeRoots({ entries: props.entries, roots: props.roots }), [props.entries, props.roots]);
|
|
289
320
|
const flatPaths = useMemo(() => {
|
|
290
321
|
if (props.paths)
|
|
291
322
|
return props.paths;
|
|
@@ -293,9 +324,30 @@ export function PierreFileTree({ trees, ...props }) {
|
|
|
293
324
|
return props.entries.map((entry) => entry.path);
|
|
294
325
|
return [];
|
|
295
326
|
}, [props.paths, props.entries]);
|
|
327
|
+
const toggleRoot = useCallback((rootId) => {
|
|
328
|
+
setCollapsedRoots((prev) => {
|
|
329
|
+
const next = new Set(prev);
|
|
330
|
+
if (next.has(rootId))
|
|
331
|
+
next.delete(rootId);
|
|
332
|
+
else
|
|
333
|
+
next.add(rootId);
|
|
334
|
+
return next;
|
|
335
|
+
});
|
|
336
|
+
}, []);
|
|
296
337
|
if (!trees?.FileTree || !trees?.useFileTree) {
|
|
297
338
|
return _jsx(DefaultFileTree, { ...props });
|
|
298
339
|
}
|
|
340
|
+
if (resolvedRoots && resolvedRoots.length > 0) {
|
|
341
|
+
return (_jsx("div", { className: props.className ? `aui-file-tree aui-file-tree-roots ${props.className}` : 'aui-file-tree aui-file-tree-roots', children: resolvedRoots.map((root) => {
|
|
342
|
+
const label = root.label ?? root.id;
|
|
343
|
+
const rootPaths = root.paths ? root.paths : (root.entries ?? []).map((entry) => entry.path);
|
|
344
|
+
const isCollapsed = collapsedRoots.has(root.id);
|
|
345
|
+
return (_jsxs("section", { className: "aui-file-tree-root", "aria-label": label, children: [_jsxs("button", { type: "button", className: "aui-file-tree-root-head", "aria-expanded": !isCollapsed, onClick: () => toggleRoot(root.id), children: [_jsx("span", { className: "aui-file-tree-caret", "aria-hidden": "true", children: isCollapsed ? '▸' : '▾' }), _jsx("span", { className: "aui-file-tree-root-label", children: label }), root.badge ? _jsx(Badge, { tone: "neutral", children: root.badge }) : null] }), !isCollapsed ? (_jsx(PierreFileTreeMounted, { trees: trees, flatPaths: rootPaths, ...props, roots: undefined, className: undefined, onSelect: (path) => {
|
|
346
|
+
props.onSelectInRoot?.(root.id, path);
|
|
347
|
+
props.onSelect(path);
|
|
348
|
+
} }, `${root.id}:${rootPaths.join('\0')}`)) : null] }, root.id));
|
|
349
|
+
}) }));
|
|
350
|
+
}
|
|
299
351
|
/* `@pierre/trees/react`'s `useFileTree` initializes `new FileTree(options)` once on mount inside `useState`,
|
|
300
352
|
so keying on the joined path list ensures async file lists loaded after mount populate the tree cleanly. */
|
|
301
353
|
return _jsx(PierreFileTreeMounted, { trees: trees, flatPaths: flatPaths, ...props }, flatPaths.join('\0'));
|
package/dist/surfaces.d.ts
CHANGED
|
@@ -51,11 +51,22 @@ export interface DiffSurfaceFileInput {
|
|
|
51
51
|
readonly contents: string;
|
|
52
52
|
readonly lang?: string;
|
|
53
53
|
}
|
|
54
|
+
export interface DiffSurfaceRoot {
|
|
55
|
+
readonly id: string;
|
|
56
|
+
readonly label?: string;
|
|
57
|
+
readonly badge?: string;
|
|
58
|
+
readonly patch?: string;
|
|
59
|
+
readonly files?: readonly DiffFile[];
|
|
60
|
+
readonly oldFile?: DiffSurfaceFileInput;
|
|
61
|
+
readonly newFile?: DiffSurfaceFileInput;
|
|
62
|
+
}
|
|
54
63
|
export interface DiffSurfaceProps {
|
|
55
64
|
/** Raw unified diff text (e.g. `git diff`). */
|
|
56
65
|
readonly patch?: string;
|
|
57
66
|
/** Structured file list (compatible with `<DiffView>`). */
|
|
58
67
|
readonly files?: readonly DiffFile[];
|
|
68
|
+
/** Optional multi-root / multi-repo diff groups rendered under collapsible headers. */
|
|
69
|
+
readonly roots?: readonly DiffSurfaceRoot[];
|
|
59
70
|
/** Explicit old/new file pair for file-to-file diffing (used natively by Pierre `FileDiff`). */
|
|
60
71
|
readonly oldFile?: DiffSurfaceFileInput;
|
|
61
72
|
readonly newFile?: DiffSurfaceFileInput;
|
|
@@ -63,10 +74,16 @@ export interface DiffSurfaceProps {
|
|
|
63
74
|
readonly editable?: boolean;
|
|
64
75
|
readonly onChange?: (nextNewContent: string) => void;
|
|
65
76
|
readonly selectedFile?: string;
|
|
77
|
+
/** Optional selected root id when rendering multi-root diffs. */
|
|
78
|
+
readonly selectedRoot?: string;
|
|
66
79
|
readonly onSelectFile?: (path: string) => void;
|
|
80
|
+
/** Called when selecting a file inside a multi-root diff. */
|
|
81
|
+
readonly onSelectInRoot?: (rootId: string, path: string) => void;
|
|
67
82
|
readonly annotations?: readonly DiffAnnotation[];
|
|
68
83
|
readonly onLineComment?: (file: string, line: number, content: string) => void;
|
|
69
84
|
readonly onAddToChat?: (snippet: CodeSelectionSnippet) => void;
|
|
85
|
+
/** Maximum lines rendered per file in the fallback `<DiffView>` before truncation. */
|
|
86
|
+
readonly maxLinesPerFile?: number;
|
|
70
87
|
readonly empty?: ReactNode;
|
|
71
88
|
readonly className?: string;
|
|
72
89
|
}
|
|
@@ -84,7 +101,7 @@ export declare function AgentUiProvider({ surfaces, children }: AgentUiProviderP
|
|
|
84
101
|
/** Read the currently registered code/diff/file-tree surface renderers. */
|
|
85
102
|
export declare function useAgentUiSurfaces(): AgentUiSurfaces;
|
|
86
103
|
export declare function DefaultCodeSurface({ path, content, language, editable, onChange, markers, annotations, onAddToChat, className, }: CodeSurfaceProps): import("react").JSX.Element;
|
|
87
|
-
export declare function DefaultDiffSurface({ patch, files, oldFile, newFile, selectedFile, onSelectFile, onLineComment, empty, className, }: DiffSurfaceProps): import("react").JSX.Element;
|
|
104
|
+
export declare function DefaultDiffSurface({ patch, files, roots, oldFile, newFile, selectedFile, selectedRoot, onSelectFile, onSelectInRoot, onLineComment, maxLinesPerFile, empty, className, }: DiffSurfaceProps): import("react").JSX.Element;
|
|
88
105
|
/** Code viewer/editor surface: delegates to registered `surfaces.code` (e.g. Pierre) or uses the built-in fallback. */
|
|
89
106
|
export declare function CodeSurface(props: CodeSurfaceProps): import("react").JSX.Element;
|
|
90
107
|
/** Diff viewer/editor surface: delegates to registered `surfaces.diff` (e.g. Pierre) or uses `<DiffView>`. */
|
package/dist/surfaces.js
CHANGED
|
@@ -100,7 +100,7 @@ function buildFallbackPatchFromPair(oldFile, newFile) {
|
|
|
100
100
|
}
|
|
101
101
|
return out.join('\n');
|
|
102
102
|
}
|
|
103
|
-
export function DefaultDiffSurface({ patch, files, oldFile, newFile, selectedFile, onSelectFile, onLineComment, empty, className, }) {
|
|
103
|
+
export function DefaultDiffSurface({ patch, files, roots, oldFile, newFile, selectedFile, selectedRoot, onSelectFile, onSelectInRoot, onLineComment, maxLinesPerFile, empty, className, }) {
|
|
104
104
|
const resolvedPatch = useMemo(() => {
|
|
105
105
|
if (patch)
|
|
106
106
|
return patch;
|
|
@@ -108,7 +108,18 @@ export function DefaultDiffSurface({ patch, files, oldFile, newFile, selectedFil
|
|
|
108
108
|
return buildFallbackPatchFromPair(oldFile, newFile);
|
|
109
109
|
return undefined;
|
|
110
110
|
}, [patch, oldFile, newFile]);
|
|
111
|
-
|
|
111
|
+
const resolvedRoots = useMemo(() => {
|
|
112
|
+
if (!roots || roots.length === 0)
|
|
113
|
+
return undefined;
|
|
114
|
+
return roots.map((root) => ({
|
|
115
|
+
id: root.id,
|
|
116
|
+
label: root.label,
|
|
117
|
+
badge: root.badge,
|
|
118
|
+
files: root.files,
|
|
119
|
+
diff: root.patch ?? (root.oldFile && root.newFile ? buildFallbackPatchFromPair(root.oldFile, root.newFile) : undefined),
|
|
120
|
+
}));
|
|
121
|
+
}, [roots]);
|
|
122
|
+
return (_jsx(DiffView, { diff: resolvedPatch, files: files, roots: resolvedRoots, selectedFile: selectedFile, selectedRoot: selectedRoot, onSelectFile: onSelectFile, onSelectInRoot: onSelectInRoot, onLineComment: onLineComment, maxLinesPerFile: maxLinesPerFile, empty: empty, className: className }));
|
|
112
123
|
}
|
|
113
124
|
/** Code viewer/editor surface: delegates to registered `surfaces.code` (e.g. Pierre) or uses the built-in fallback. */
|
|
114
125
|
export function CodeSurface(props) {
|
package/dist/tools.d.ts
CHANGED
|
@@ -14,10 +14,16 @@ export interface ToolCallInspectorProps {
|
|
|
14
14
|
readonly selectedId?: string;
|
|
15
15
|
readonly onSelect?: (id: string) => void;
|
|
16
16
|
readonly title?: string;
|
|
17
|
+
/** Number of tool calls rendered initially before showing a "Show more" control. Default `50`. */
|
|
18
|
+
readonly initialVisibleCount?: number;
|
|
19
|
+
/** How many additional calls to reveal per click on "Show more". Default `50`. */
|
|
20
|
+
readonly loadMoreStep?: number;
|
|
21
|
+
/** Maximum characters rendered inline for a single tool call output before showing a "Show full output" toggle. Default `8000`. */
|
|
22
|
+
readonly maxOutputChars?: number;
|
|
17
23
|
readonly empty?: ReactNode;
|
|
18
24
|
readonly className?: string;
|
|
19
25
|
}
|
|
20
|
-
export declare function ToolCallInspector({ calls, selectedId, onSelect, title, empty, className }: ToolCallInspectorProps): import("react").JSX.Element;
|
|
26
|
+
export declare function ToolCallInspector({ calls, selectedId, onSelect, title, initialVisibleCount, loadMoreStep, maxOutputChars, empty, className, }: ToolCallInspectorProps): import("react").JSX.Element;
|
|
21
27
|
export interface AnsiSegment {
|
|
22
28
|
readonly text: string;
|
|
23
29
|
readonly className?: string;
|
|
@@ -34,10 +40,16 @@ export interface TerminalOutputProps {
|
|
|
34
40
|
readonly searchable?: boolean;
|
|
35
41
|
readonly autoFollow?: boolean;
|
|
36
42
|
readonly defaultWrap?: boolean;
|
|
43
|
+
/** Line count threshold above which `<TerminalOutput>` virtualizes line rendering so 50k+ line logs stay 60 FPS. Default `200`. */
|
|
44
|
+
readonly virtualizeThreshold?: number;
|
|
45
|
+
/** Estimated line height in pixels used for virtualized scrolling. Default `20`. */
|
|
46
|
+
readonly rowHeight?: number;
|
|
47
|
+
/** Extra lines rendered above and below the viewport when virtualized. Default `25`. */
|
|
48
|
+
readonly overscan?: number;
|
|
37
49
|
readonly onClear?: () => void;
|
|
38
50
|
readonly className?: string;
|
|
39
51
|
}
|
|
40
|
-
export declare function TerminalOutput({ text, lines, title, running, searchable, autoFollow, defaultWrap, onClear, className, }: TerminalOutputProps): import("react").JSX.Element;
|
|
52
|
+
export declare function TerminalOutput({ text, lines, title, running, searchable, autoFollow, defaultWrap, virtualizeThreshold, rowHeight, overscan, onClear, className, }: TerminalOutputProps): import("react").JSX.Element;
|
|
41
53
|
export interface AgentModeOption<T extends string = string> {
|
|
42
54
|
readonly value: T;
|
|
43
55
|
readonly label: string;
|
package/dist/tools.js
CHANGED
|
@@ -6,7 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
* - `<ModeSwitcher>`: compact agent mode selector (`Ask` / `Plan` / `Agent` / `Review`)
|
|
7
7
|
* - `<ModelPicker>`: compact model / ACP provider selector
|
|
8
8
|
*/
|
|
9
|
-
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
9
|
+
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
10
10
|
import { Badge, Button, EmptyState, SegmentedControl, Select, StatusDot, TextField } from '@mistriwork/mistri/ui';
|
|
11
11
|
import './workbench.css';
|
|
12
12
|
function callTone(status) {
|
|
@@ -16,22 +16,49 @@ function callTone(status) {
|
|
|
16
16
|
return 'critical';
|
|
17
17
|
return 'info';
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
const ToolCallCard = memo(function ToolCallCard({ call, defaultOpen, maxOutputChars, onSelect }) {
|
|
20
|
+
const [open, setOpen] = useState(defaultOpen);
|
|
21
|
+
const [showFullOutput, setShowFullOutput] = useState(false);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (defaultOpen)
|
|
24
|
+
setOpen(true);
|
|
25
|
+
}, [defaultOpen]);
|
|
26
|
+
const inputJson = useMemo(() => (open && call.input ? JSON.stringify(call.input, null, 2) : undefined), [open, call.input]);
|
|
27
|
+
const outputInfo = useMemo(() => {
|
|
28
|
+
if (!open || !call.output)
|
|
29
|
+
return undefined;
|
|
30
|
+
const total = call.output.length;
|
|
31
|
+
if (showFullOutput || !Number.isFinite(maxOutputChars) || total <= maxOutputChars) {
|
|
32
|
+
return { text: call.output, truncated: false, total };
|
|
33
|
+
}
|
|
34
|
+
return { text: call.output.slice(0, maxOutputChars), truncated: true, total };
|
|
35
|
+
}, [open, call.output, showFullOutput, maxOutputChars]);
|
|
36
|
+
return (_jsxs("details", { className: "aui-tool-card", open: open, onToggle: (e) => {
|
|
37
|
+
const nextOpen = e.currentTarget.open;
|
|
38
|
+
setOpen(nextOpen);
|
|
39
|
+
if (nextOpen)
|
|
40
|
+
onSelect?.(call.id);
|
|
41
|
+
}, children: [_jsxs("summary", { className: "aui-tool-card-summary", children: [_jsx(StatusDot, { tone: callTone(call.status), pulse: call.status === 'running' }), _jsx("span", { children: call.label ?? call.name }), _jsx(Badge, { tone: callTone(call.status), children: call.status }), call.durationMs !== undefined ? _jsx("span", { className: "kit-agent-msg-meta", children: `${call.durationMs}ms` }) : null] }), open ? (_jsxs("div", { className: "aui-tool-card-body", children: [inputJson ? (_jsxs("div", { children: [_jsx("div", { className: "aui-tool-section-label", children: "Input" }), _jsx("pre", { className: "kit-agent-code", children: _jsx("code", { children: inputJson }) })] })) : null, call.error ? (_jsxs("div", { children: [_jsx("div", { className: "aui-tool-section-label", children: "Error" }), _jsx("pre", { className: "kit-agent-code", children: _jsx("code", { children: call.error }) })] })) : null, outputInfo ? (_jsxs("div", { children: [_jsx("div", { className: "aui-tool-section-label", children: "Output" }), _jsx("pre", { className: "kit-agent-code", children: _jsx("code", { children: outputInfo.text }) }), outputInfo.truncated ? (_jsxs("div", { className: "aui-truncate-bar", children: [_jsx("span", { children: `Showing ${maxOutputChars.toLocaleString()} of ${outputInfo.total.toLocaleString()} chars` }), _jsx(Button, { size: "sm", variant: "ghost", onClick: () => setShowFullOutput(true), children: "Show full output" })] })) : null] })) : null] })) : null] }));
|
|
42
|
+
});
|
|
43
|
+
export function ToolCallInspector({ calls, selectedId, onSelect, title = 'Tool calls', initialVisibleCount = 50, loadMoreStep = 50, maxOutputChars = 8_000, empty, className, }) {
|
|
20
44
|
const [filter, setFilter] = useState('all');
|
|
45
|
+
const [visibleLimit, setVisibleLimit] = useState(initialVisibleCount);
|
|
21
46
|
const visible = useMemo(() => {
|
|
22
47
|
if (filter === 'all')
|
|
23
48
|
return calls;
|
|
24
49
|
return calls.filter((c) => c.status === filter);
|
|
25
50
|
}, [calls, filter]);
|
|
26
|
-
|
|
51
|
+
const hiddenCount = Number.isFinite(visibleLimit) ? Math.max(0, visible.length - visibleLimit) : 0;
|
|
52
|
+
const windowed = useMemo(() => (hiddenCount > 0 ? visible.slice(visible.length - visibleLimit) : visible), [visible, hiddenCount, visibleLimit]);
|
|
53
|
+
return (_jsxs("section", { className: className ? `aui-tool-inspector ${className}` : 'aui-tool-inspector', "aria-label": title, children: [_jsxs("header", { className: "aui-tool-inspector-head", children: [_jsxs("span", { className: "aui-approval-queue-title", children: [_jsx("span", { children: title }), _jsx(Badge, { tone: "neutral", children: String(calls.length) })] }), _jsx(SegmentedControl, { ariaLabel: "Filter tool calls", size: "sm", value: filter, onValueChange: (next) => {
|
|
54
|
+
setFilter(next);
|
|
55
|
+
setVisibleLimit(initialVisibleCount);
|
|
56
|
+
}, options: [
|
|
27
57
|
{ value: 'all', label: 'All' },
|
|
28
58
|
{ value: 'running', label: 'Running' },
|
|
29
59
|
{ value: 'completed', label: 'Done' },
|
|
30
60
|
{ value: 'failed', label: 'Failed' },
|
|
31
|
-
] })] }), visible.length === 0 ? ((empty ?? _jsx(EmptyState, { compact: true, title: "No tool calls" }))) : (
|
|
32
|
-
if (e.currentTarget.open)
|
|
33
|
-
onSelect?.(call.id);
|
|
34
|
-
}, children: [_jsxs("summary", { className: "aui-tool-card-summary", children: [_jsx(StatusDot, { tone: callTone(call.status), pulse: call.status === 'running' }), _jsx("span", { children: call.label ?? call.name }), _jsx(Badge, { tone: callTone(call.status), children: call.status }), call.durationMs !== undefined ? _jsx("span", { className: "kit-agent-msg-meta", children: `${call.durationMs}ms` }) : null] }), _jsxs("div", { className: "aui-tool-card-body", children: [call.input ? (_jsxs("div", { children: [_jsx("div", { className: "aui-tool-section-label", children: "Input" }), _jsx("pre", { className: "kit-agent-code", children: _jsx("code", { children: JSON.stringify(call.input, null, 2) }) })] })) : null, call.error ? (_jsxs("div", { children: [_jsx("div", { className: "aui-tool-section-label", children: "Error" }), _jsx("pre", { className: "kit-agent-code", children: _jsx("code", { children: call.error }) })] })) : null, call.output ? (_jsxs("div", { children: [_jsx("div", { className: "aui-tool-section-label", children: "Output" }), _jsx("pre", { className: "kit-agent-code", children: _jsx("code", { children: call.output }) })] })) : null] })] }, call.id))) }))] }));
|
|
61
|
+
] })] }), visible.length === 0 ? ((empty ?? _jsx(EmptyState, { compact: true, title: "No tool calls" }))) : (_jsxs("div", { className: "aui-tool-inspector-list", children: [hiddenCount > 0 ? (_jsxs("div", { className: "aui-thread-window-bar", children: [_jsx("span", { children: `Showing latest ${windowed.length} of ${visible.length} calls` }), _jsxs("div", { className: "aui-session-actions", children: [_jsx(Button, { size: "sm", variant: "ghost", onClick: () => setVisibleLimit((n) => n + loadMoreStep), children: `Show ${Math.min(loadMoreStep, hiddenCount)} earlier` }), _jsx(Button, { size: "sm", variant: "ghost", onClick: () => setVisibleLimit(Number.POSITIVE_INFINITY), children: "Show all" })] })] })) : null, windowed.map((call) => (_jsx(ToolCallCard, { call: call, defaultOpen: selectedId === call.id || call.status === 'failed', maxOutputChars: maxOutputChars, onSelect: onSelect }, call.id)))] }))] }));
|
|
35
62
|
}
|
|
36
63
|
const ANSI_FG_CLASS = {
|
|
37
64
|
30: 'aui-ansi-muted',
|
|
@@ -125,10 +152,20 @@ export function parseAnsiLine(line) {
|
|
|
125
152
|
}
|
|
126
153
|
return segments;
|
|
127
154
|
}
|
|
128
|
-
|
|
155
|
+
const DEFAULT_VIEWPORT_HEIGHT = 384;
|
|
156
|
+
function renderAnsiLine(line, key) {
|
|
157
|
+
return (_jsx("div", { className: "aui-terminal-line", children: parseAnsiLine(line).map((seg, segIdx) => seg.className ? (_jsx("span", { className: seg.className, children: seg.text }, segIdx)) : (_jsx("span", { children: seg.text }, segIdx))) }, key));
|
|
158
|
+
}
|
|
159
|
+
export function TerminalOutput({ text, lines, title = 'Terminal', running = false, searchable = false, autoFollow = true, defaultWrap = true, virtualizeThreshold = 200, rowHeight = 20, overscan = 25, onClear, className, }) {
|
|
129
160
|
const [wrap, setWrap] = useState(defaultWrap);
|
|
130
161
|
const [query, setQuery] = useState('');
|
|
162
|
+
const [following, setFollowing] = useState(autoFollow);
|
|
163
|
+
const [scrollTop, setScrollTop] = useState(0);
|
|
164
|
+
const [viewportHeight, setViewportHeight] = useState(DEFAULT_VIEWPORT_HEIGHT);
|
|
131
165
|
const bodyRef = useRef(null);
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
setFollowing(autoFollow);
|
|
168
|
+
}, [autoFollow]);
|
|
132
169
|
const allLines = useMemo(() => {
|
|
133
170
|
if (lines)
|
|
134
171
|
return lines;
|
|
@@ -142,12 +179,61 @@ export function TerminalOutput({ text, lines, title = 'Terminal', running = fals
|
|
|
142
179
|
return allLines;
|
|
143
180
|
return allLines.filter((line) => line.replace(ANSI_SGR_RE, '').toLowerCase().includes(q));
|
|
144
181
|
}, [allLines, query]);
|
|
182
|
+
const virtualized = filteredLines.length > virtualizeThreshold;
|
|
183
|
+
const { startIndex, endIndex, topPad, bottomPad } = useMemo(() => {
|
|
184
|
+
if (!virtualized) {
|
|
185
|
+
return { startIndex: 0, endIndex: filteredLines.length, topPad: 0, bottomPad: 0 };
|
|
186
|
+
}
|
|
187
|
+
const visibleRows = Math.max(1, Math.ceil(viewportHeight / rowHeight));
|
|
188
|
+
if (following) {
|
|
189
|
+
const end = filteredLines.length;
|
|
190
|
+
const start = Math.max(0, end - visibleRows - overscan * 2);
|
|
191
|
+
return {
|
|
192
|
+
startIndex: start,
|
|
193
|
+
endIndex: end,
|
|
194
|
+
topPad: start * rowHeight,
|
|
195
|
+
bottomPad: 0,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
const rawStart = Math.floor(scrollTop / rowHeight);
|
|
199
|
+
const start = Math.max(0, rawStart - overscan);
|
|
200
|
+
const end = Math.min(filteredLines.length, rawStart + visibleRows + overscan);
|
|
201
|
+
return {
|
|
202
|
+
startIndex: start,
|
|
203
|
+
endIndex: end,
|
|
204
|
+
topPad: start * rowHeight,
|
|
205
|
+
bottomPad: Math.max(0, (filteredLines.length - end) * rowHeight),
|
|
206
|
+
};
|
|
207
|
+
}, [virtualized, filteredLines.length, viewportHeight, rowHeight, following, scrollTop, overscan]);
|
|
145
208
|
useEffect(() => {
|
|
146
|
-
if (!
|
|
209
|
+
if (!following || !bodyRef.current)
|
|
147
210
|
return;
|
|
148
211
|
bodyRef.current.scrollTop = bodyRef.current.scrollHeight;
|
|
149
|
-
}, [
|
|
150
|
-
|
|
212
|
+
}, [following, filteredLines.length]);
|
|
213
|
+
const handleScroll = useCallback(() => {
|
|
214
|
+
const el = bodyRef.current;
|
|
215
|
+
if (!el)
|
|
216
|
+
return;
|
|
217
|
+
const distanceFromBottom = el.scrollHeight - el.scrollTop - el.clientHeight;
|
|
218
|
+
if (el.clientHeight > 0)
|
|
219
|
+
setViewportHeight(el.clientHeight);
|
|
220
|
+
setScrollTop(el.scrollTop);
|
|
221
|
+
if (distanceFromBottom > rowHeight * 2) {
|
|
222
|
+
setFollowing(false);
|
|
223
|
+
}
|
|
224
|
+
else if (autoFollow) {
|
|
225
|
+
setFollowing(true);
|
|
226
|
+
}
|
|
227
|
+
}, [autoFollow, rowHeight]);
|
|
228
|
+
const jumpToTail = useCallback(() => {
|
|
229
|
+
setFollowing(true);
|
|
230
|
+
if (bodyRef.current) {
|
|
231
|
+
bodyRef.current.scrollTop = bodyRef.current.scrollHeight;
|
|
232
|
+
setScrollTop(bodyRef.current.scrollTop);
|
|
233
|
+
}
|
|
234
|
+
}, []);
|
|
235
|
+
const visibleSlice = useMemo(() => (virtualized ? filteredLines.slice(startIndex, endIndex) : filteredLines), [virtualized, filteredLines, startIndex, endIndex]);
|
|
236
|
+
return (_jsxs("section", { className: className ? `aui-terminal ${className}` : 'aui-terminal', "aria-label": title, children: [_jsxs("header", { className: "aui-terminal-head", children: [_jsxs("span", { className: "aui-terminal-title", children: [_jsx(StatusDot, { tone: running ? 'info' : 'neutral', pulse: running }), _jsx("span", { children: title }), running ? _jsx(Badge, { tone: "info", children: "Running" }) : null, virtualized ? _jsx(Badge, { tone: "neutral", children: `${filteredLines.length.toLocaleString()} lines` }) : null] }), _jsxs("div", { className: "aui-terminal-controls", children: [searchable ? (_jsx(TextField, { label: "Filter output", labelHidden: true, reserve: false, value: query, onValueChange: (next) => setQuery(next), placeholder: "Filter logs\u2026" })) : null, !following && filteredLines.length > 0 ? (_jsx(Button, { size: "sm", variant: "secondary", onClick: jumpToTail, children: "Follow tail" })) : null, _jsx(Button, { size: "sm", variant: "ghost", onClick: () => setWrap((w) => !w), children: wrap ? 'No wrap' : 'Wrap' }), onClear ? (_jsx(Button, { size: "sm", variant: "ghost", onClick: onClear, children: "Clear" })) : null] })] }), _jsxs("pre", { ref: bodyRef, className: "aui-terminal-body", "data-wrap": wrap ? 'true' : 'false', "data-virtualized": virtualized ? 'true' : undefined, onScroll: handleScroll, children: [topPad > 0 ? _jsx("div", { "aria-hidden": "true", style: { height: `${topPad}px` } }) : null, visibleSlice.map((line, offset) => renderAnsiLine(line, startIndex + offset)), bottomPad > 0 ? _jsx("div", { "aria-hidden": "true", style: { height: `${bottomPad}px` } }) : null] })] }));
|
|
151
237
|
}
|
|
152
238
|
const DEFAULT_MODES = [
|
|
153
239
|
{ value: 'ask', label: 'Ask' },
|