@mistriwork/agent-ui 1.4.1 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,10 +62,29 @@ export interface AgentThreadProps {
62
62
  /** Optional custom renderer for fenced code blocks (e.g. `<CodeSurface>` / Pierre). */
63
63
  readonly renderCodeBlock?: (block: AgentThreadCodeBlock) => ReactNode;
64
64
  readonly labels?: AgentThreadLabels;
65
+ /**
66
+ * Maximum number of recent messages rendered initially for long-running sessions.
67
+ * Defaults to `60`; set to `0` or `Infinity` to render all messages immediately.
68
+ */
69
+ readonly initialVisibleCount?: number;
70
+ /** Number of additional earlier messages revealed per "Show earlier" click (defaults to `60`). */
71
+ readonly loadMoreStep?: number;
72
+ /**
73
+ * Maximum characters rendered inline for each tool call's output before showing
74
+ * a "Show full output" toggle. Defaults to `4000`; set to `0` or `Infinity` to disable.
75
+ */
76
+ readonly maxToolOutputChars?: number;
77
+ /**
78
+ * When true, renders the thread in a sticky bottom-following scroll container
79
+ * that pauses auto-follow when the user scrolls up and shows a "Jump to latest" button.
80
+ */
81
+ readonly stickyScroll?: boolean;
82
+ /** Optional callback to load older persisted history when the user requests earlier turns. */
83
+ readonly onLoadEarlier?: () => void;
65
84
  readonly empty?: ReactNode;
66
85
  readonly className?: string;
67
86
  }
68
- export declare function AgentThread({ messages, onApprove, onDeny, renderCodeBlock, labels, empty, className }: AgentThreadProps): import("react").JSX.Element | null;
87
+ export declare function AgentThread({ messages, onApprove, onDeny, renderCodeBlock, labels, initialVisibleCount, loadMoreStep, maxToolOutputChars, stickyScroll, onLoadEarlier, empty, className, }: AgentThreadProps): import("react").JSX.Element | null;
69
88
  export interface ComposerAttachment {
70
89
  readonly id: string;
71
90
  readonly label: string;
@@ -109,26 +128,48 @@ export interface DiffLine {
109
128
  }
110
129
  export interface DiffFile {
111
130
  readonly path: string;
131
+ /** Optional repository / workspace root identifier for multi-root grouping. */
132
+ readonly root?: string;
112
133
  readonly status?: 'M' | 'A' | 'D' | 'R';
113
134
  readonly additions?: number;
114
135
  readonly deletions?: number;
115
136
  readonly lines?: readonly DiffLine[];
116
137
  readonly patch?: string;
117
138
  }
139
+ export interface DiffViewRoot {
140
+ readonly id: string;
141
+ readonly label?: string;
142
+ readonly badge?: string;
143
+ /** Raw unified diff text for this repository/root. */
144
+ readonly diff?: string;
145
+ /** Structured file list for this repository/root. */
146
+ readonly files?: readonly DiffFile[];
147
+ }
118
148
  export interface DiffViewProps {
119
149
  /** Raw unified diff text (e.g. from `git diff` or `worktree.diff()`). */
120
150
  readonly diff?: string;
121
151
  /** Structured file list (alternative to raw `diff` string). */
122
152
  readonly files?: readonly DiffFile[];
153
+ /** Optional multi-root / multi-repo groups rendered under collapsible headers. */
154
+ readonly roots?: readonly DiffViewRoot[];
123
155
  /** Optional selected file path to filter the displayed diff. */
124
156
  readonly selectedFile?: string;
157
+ /** Optional selected root id when rendering multi-root diffs. */
158
+ readonly selectedRoot?: string;
125
159
  /** Called when a user selects a file pill in the summary bar. */
126
160
  readonly onSelectFile?: (path: string) => void;
161
+ /** Called when a user selects a file pill inside a multi-root diff. */
162
+ readonly onSelectInRoot?: (rootId: string, path: string) => void;
127
163
  /** Called when a user clicks the comment action on a diff line. */
128
164
  readonly onLineComment?: (file: string, line: number, content: string) => void;
165
+ /**
166
+ * Maximum diff lines rendered per file before showing a "Show all N lines" toggle.
167
+ * Defaults to `400`; pass `0` or `Infinity` to render all lines immediately.
168
+ */
169
+ readonly maxLinesPerFile?: number;
129
170
  readonly empty?: ReactNode;
130
171
  readonly className?: string;
131
172
  }
132
173
  /** Parse raw unified `git diff` output into structured `DiffFile[]` entries. */
133
174
  export declare function parseUnifiedDiff(diff: string): DiffFile[];
134
- export declare function DiffView({ diff, files, selectedFile, onSelectFile, onLineComment, empty, className }: DiffViewProps): import("react").JSX.Element;
175
+ export declare function DiffView({ diff, files, roots, selectedFile, selectedRoot, onSelectFile, onSelectInRoot, onLineComment, maxLinesPerFile, empty, className, }: DiffViewProps): import("react").JSX.Element;
package/dist/agentIde.js CHANGED
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /**
3
3
  * `@mistriwork/agent-ui` workbench components built on `@mistriwork/mistri/ui`
4
4
  * primitives and Mistri design tokens:
@@ -9,7 +9,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
9
  * - `<DiffView>`: unified diff parser + line-numbered renderer with file
10
10
  * summary pills (`M`/`A`/`D`/`R` + `+add`/`-del`) and `onLineComment`.
11
11
  */
12
- import { useMemo, useState } from 'react';
12
+ import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
13
13
  import { Badge, Button, Chip, TextArea } from '@mistriwork/mistri/ui';
14
14
  import './agentIde.css';
15
15
  import './workbench.css';
@@ -55,16 +55,68 @@ function riskTone(risk) {
55
55
  return 'warning';
56
56
  return 'neutral';
57
57
  }
58
- export function AgentThread({ messages, onApprove, onDeny, renderCodeBlock, labels, empty, className }) {
58
+ const DEFAULT_THREAD_VISIBLE = 60;
59
+ const DEFAULT_THREAD_OUTPUT_CHARS = 4_000;
60
+ const AgentThreadToolRow = memo(function AgentThreadToolRow({ tool, maxOutputChars }) {
61
+ const [inputOpen, setInputOpen] = useState(false);
62
+ const [showFullOutput, setShowFullOutput] = useState(false);
63
+ const formattedInput = useMemo(() => (inputOpen && tool.input ? JSON.stringify(tool.input, null, 2) : null), [inputOpen, tool.input]);
64
+ const output = tool.output ?? '';
65
+ const isTruncated = maxOutputChars > 0 && Number.isFinite(maxOutputChars) && output.length > maxOutputChars && !showFullOutput;
66
+ const visibleOutput = isTruncated ? `${output.slice(0, maxOutputChars)}…` : output;
67
+ return (_jsxs("div", { className: "kit-agent-tool", "data-status": tool.status, children: [_jsxs("div", { className: "kit-agent-tool-head", children: [_jsx("span", { children: tool.label ?? tool.name }), _jsx(Badge, { tone: toolTone(tool.status), children: tool.status })] }), tool.input ? (_jsxs("details", { className: "kit-agent-reasoning", open: inputOpen, onToggle: (e) => setInputOpen(e.currentTarget.open), children: [_jsx("summary", { children: "Input" }), formattedInput ? _jsx("pre", { className: "kit-agent-reasoning-body", children: formattedInput }) : null] })) : null, output ? (_jsxs(_Fragment, { children: [_jsx("pre", { className: "kit-agent-tool-out", children: visibleOutput }), isTruncated ? (_jsxs("div", { className: "aui-truncate-bar", children: [_jsx("span", { children: `Showing first ${maxOutputChars.toLocaleString()} of ${output.length.toLocaleString()} chars` }), _jsx(Button, { size: "sm", variant: "ghost", onClick: () => setShowFullOutput(true), children: "Show full output" })] })) : null] })) : null] }));
68
+ });
69
+ const AgentThreadMessageRow = memo(function AgentThreadMessageRow({ msg, onApprove, onDeny, renderCodeBlock, labels, maxToolOutputChars, }) {
70
+ const segments = useMemo(() => parseBodySegments(msg.content), [msg.content]);
71
+ return (_jsxs("article", { className: "kit-agent-msg", "data-role": msg.role, children: [_jsxs("header", { className: "kit-agent-msg-head", children: [_jsx("span", { className: "kit-agent-msg-role", children: roleLabel(msg.role, labels) }), msg.model ? _jsx(Badge, { tone: "neutral", children: msg.model }) : null, msg.streaming ? _jsx(Badge, { tone: "info", children: labels?.streaming ?? 'Streaming…' }) : null, msg.timestamp ? _jsx("span", { className: "kit-agent-msg-meta", children: msg.timestamp }) : null] }), msg.reasoning ? (_jsxs("details", { className: "kit-agent-reasoning", children: [_jsx("summary", { children: labels?.reasoning ?? 'Reasoning' }), _jsx("pre", { className: "kit-agent-reasoning-body", children: msg.reasoning })] })) : null, segments.length > 0 ? (_jsx("div", { className: "kit-agent-msg-body", children: segments.map((seg, i) => seg.kind === 'code' ? (renderCodeBlock ? (_jsx("div", { children: renderCodeBlock({ messageId: msg.id, index: i, lang: seg.lang, code: seg.code }) }, i)) : (_jsx("pre", { className: "kit-agent-code", "data-lang": seg.lang || undefined, children: _jsx("code", { children: seg.code }) }, i))) : (_jsx("p", { className: "kit-agent-msg-para", children: seg.text }, i))) })) : null, msg.toolCalls && msg.toolCalls.length > 0 ? (_jsx("div", { className: "kit-agent-tools", "aria-label": labels?.toolCalls ?? 'Tool calls', children: msg.toolCalls.map((tool) => (_jsx(AgentThreadToolRow, { tool: tool, maxOutputChars: maxToolOutputChars }, tool.id))) })) : null, msg.approvals && msg.approvals.length > 0
72
+ ? msg.approvals.map((approval) => (_jsxs("div", { className: "kit-agent-approval", role: "region", "aria-label": labels?.approvalRequired ?? 'Approval required', children: [_jsxs("div", { className: "kit-agent-approval-head", children: [_jsx(Badge, { tone: riskTone(approval.risk), children: approval.risk ?? 'medium' }), _jsx("code", { children: approval.tool })] }), _jsx("p", { className: "kit-agent-approval-summary", children: approval.summary }), approval.input ? (_jsx("pre", { className: "kit-agent-code", children: _jsx("code", { children: JSON.stringify(approval.input, null, 2) }) })) : null, onApprove || onDeny ? (_jsxs("div", { className: "kit-agent-approval-actions", children: [onApprove ? (_jsx(Button, { size: "sm", variant: "primary", onClick: () => onApprove(approval.id), children: labels?.approve ?? 'Approve' })) : null, onDeny ? (_jsx(Button, { size: "sm", variant: "secondary", onClick: () => onDeny(approval.id), children: labels?.deny ?? 'Deny' })) : null] })) : null] }, approval.id)))
73
+ : null] }));
74
+ });
75
+ export function AgentThread({ messages, onApprove, onDeny, renderCodeBlock, labels, initialVisibleCount = DEFAULT_THREAD_VISIBLE, loadMoreStep = DEFAULT_THREAD_VISIBLE, maxToolOutputChars = DEFAULT_THREAD_OUTPUT_CHARS, stickyScroll = false, onLoadEarlier, empty, className, }) {
76
+ const windowEnabled = initialVisibleCount > 0 && Number.isFinite(initialVisibleCount);
77
+ const [visibleLimit, setVisibleLimit] = useState(initialVisibleCount);
78
+ const scrollRef = useRef(null);
79
+ const [pinnedToBottom, setPinnedToBottom] = useState(true);
80
+ const effectiveLimit = windowEnabled ? Math.max(initialVisibleCount, visibleLimit) : messages.length;
81
+ const hiddenCount = windowEnabled ? Math.max(0, messages.length - effectiveLimit) : 0;
82
+ const visibleMessages = useMemo(() => (hiddenCount > 0 ? messages.slice(hiddenCount) : messages), [messages, hiddenCount]);
83
+ const lastMessage = visibleMessages[visibleMessages.length - 1];
84
+ const tailSignature = lastMessage
85
+ ? `${visibleMessages.length}:${lastMessage.id}:${lastMessage.content.length}:${lastMessage.toolCalls?.length ?? 0}`
86
+ : '0';
87
+ useEffect(() => {
88
+ if (!stickyScroll || !pinnedToBottom)
89
+ return;
90
+ const el = scrollRef.current;
91
+ if (el)
92
+ el.scrollTop = el.scrollHeight;
93
+ }, [stickyScroll, pinnedToBottom, tailSignature]);
94
+ const handleScroll = useCallback(() => {
95
+ const el = scrollRef.current;
96
+ if (!el)
97
+ return;
98
+ const distanceFromBottom = el.scrollHeight - el.scrollTop - el.clientHeight;
99
+ setPinnedToBottom(distanceFromBottom <= 32);
100
+ }, []);
101
+ const jumpToLatest = useCallback(() => {
102
+ setPinnedToBottom(true);
103
+ const el = scrollRef.current;
104
+ if (el)
105
+ el.scrollTop = el.scrollHeight;
106
+ }, []);
59
107
  if (messages.length === 0) {
60
108
  return empty ? _jsx("div", { className: className, children: empty }) : null;
61
109
  }
62
- return (_jsx("div", { className: className ? `kit-agent-thread ${className}` : 'kit-agent-thread', children: messages.map((msg) => {
63
- const segments = parseBodySegments(msg.content);
64
- return (_jsxs("article", { className: "kit-agent-msg", "data-role": msg.role, children: [_jsxs("header", { className: "kit-agent-msg-head", children: [_jsx("span", { className: "kit-agent-msg-role", children: roleLabel(msg.role, labels) }), msg.model ? _jsx(Badge, { tone: "neutral", children: msg.model }) : null, msg.streaming ? _jsx(Badge, { tone: "info", children: labels?.streaming ?? 'Streaming…' }) : null, msg.timestamp ? _jsx("span", { className: "kit-agent-msg-meta", children: msg.timestamp }) : null] }), msg.reasoning ? (_jsxs("details", { className: "kit-agent-reasoning", children: [_jsx("summary", { children: labels?.reasoning ?? 'Reasoning' }), _jsx("pre", { className: "kit-agent-reasoning-body", children: msg.reasoning })] })) : null, segments.length > 0 ? (_jsx("div", { className: "kit-agent-msg-body", children: segments.map((seg, i) => seg.kind === 'code' ? (renderCodeBlock ? (_jsx("div", { children: renderCodeBlock({ messageId: msg.id, index: i, lang: seg.lang, code: seg.code }) }, i)) : (_jsx("pre", { className: "kit-agent-code", "data-lang": seg.lang || undefined, children: _jsx("code", { children: seg.code }) }, i))) : (_jsx("p", { className: "kit-agent-msg-para", children: seg.text }, i))) })) : null, msg.toolCalls && msg.toolCalls.length > 0 ? (_jsx("div", { className: "kit-agent-tools", "aria-label": labels?.toolCalls ?? 'Tool calls', children: msg.toolCalls.map((tool) => (_jsxs("div", { className: "kit-agent-tool", "data-status": tool.status, children: [_jsxs("div", { className: "kit-agent-tool-head", children: [_jsx("span", { children: tool.label ?? tool.name }), _jsx(Badge, { tone: toolTone(tool.status), children: tool.status })] }), tool.input ? (_jsxs("details", { className: "kit-agent-reasoning", children: [_jsx("summary", { children: "Input" }), _jsx("pre", { className: "kit-agent-reasoning-body", children: JSON.stringify(tool.input, null, 2) })] })) : null, tool.output ? _jsx("pre", { className: "kit-agent-tool-out", children: tool.output }) : null] }, tool.id))) })) : null, msg.approvals && msg.approvals.length > 0
65
- ? msg.approvals.map((approval) => (_jsxs("div", { className: "kit-agent-approval", role: "region", "aria-label": labels?.approvalRequired ?? 'Approval required', children: [_jsxs("div", { className: "kit-agent-approval-head", children: [_jsx(Badge, { tone: riskTone(approval.risk), children: approval.risk ?? 'medium' }), _jsx("code", { children: approval.tool })] }), _jsx("p", { className: "kit-agent-approval-summary", children: approval.summary }), approval.input ? (_jsx("pre", { className: "kit-agent-code", children: _jsx("code", { children: JSON.stringify(approval.input, null, 2) }) })) : null, onApprove || onDeny ? (_jsxs("div", { className: "kit-agent-approval-actions", children: [onApprove ? (_jsx(Button, { size: "sm", variant: "primary", onClick: () => onApprove(approval.id), children: labels?.approve ?? 'Approve' })) : null, onDeny ? (_jsx(Button, { size: "sm", variant: "secondary", onClick: () => onDeny(approval.id), children: labels?.deny ?? 'Deny' })) : null] })) : null] }, approval.id)))
66
- : null] }, msg.id));
67
- }) }));
110
+ const rootClass = stickyScroll
111
+ ? className
112
+ ? `kit-agent-thread aui-thread-sticky ${className}`
113
+ : 'kit-agent-thread aui-thread-sticky'
114
+ : className
115
+ ? `kit-agent-thread ${className}`
116
+ : 'kit-agent-thread';
117
+ return (_jsxs("div", { ref: stickyScroll ? scrollRef : undefined, className: rootClass, onScroll: stickyScroll ? handleScroll : undefined, children: [hiddenCount > 0 || onLoadEarlier ? (_jsxs("div", { className: "aui-thread-window-bar", children: [_jsx("span", { children: hiddenCount > 0
118
+ ? `Showing latest ${visibleMessages.length.toLocaleString()} of ${messages.length.toLocaleString()} messages`
119
+ : `${messages.length.toLocaleString()} messages loaded` }), _jsx("div", { className: "aui-session-actions", children: hiddenCount > 0 ? (_jsxs(_Fragment, { children: [_jsx(Button, { size: "sm", variant: "ghost", onClick: () => setVisibleLimit((prev) => prev + Math.max(1, loadMoreStep)), children: `Show ${Math.min(hiddenCount, Math.max(1, loadMoreStep))} earlier` }), _jsx(Button, { size: "sm", variant: "ghost", onClick: () => setVisibleLimit(messages.length), children: "Show all" })] })) : onLoadEarlier ? (_jsx(Button, { size: "sm", variant: "ghost", onClick: onLoadEarlier, children: "Load earlier" })) : null })] })) : null, visibleMessages.map((msg) => (_jsx(AgentThreadMessageRow, { msg: msg, onApprove: onApprove, onDeny: onDeny, renderCodeBlock: renderCodeBlock, labels: labels, maxToolOutputChars: maxToolOutputChars }, msg.id))), stickyScroll && !pinnedToBottom ? (_jsx("div", { className: "aui-thread-jump", children: _jsx(Button, { size: "sm", variant: "secondary", onClick: jumpToLatest, children: "Jump to latest" }) })) : null] }));
68
120
  }
69
121
  export function AgentComposer({ value, onValueChange, onSubmit, label = 'Message', placeholder = 'Send a prompt or instruction…', submitLabel = 'Send', stopLabel = 'Stop', busy = false, disabled = false, rows = 2, onStop, slots, attachments, onRemoveAttachment, slashCommands, onSelectSlashCommand, className, }) {
70
122
  const [slashIndex, setSlashIndex] = useState(0);
@@ -198,30 +250,114 @@ function statusBadgeTone(status) {
198
250
  return 'info';
199
251
  return 'warning';
200
252
  }
201
- export function DiffView({ diff, files, selectedFile, onSelectFile, onLineComment, empty, className }) {
202
- const parsedFiles = useMemo(() => {
203
- if (files && files.length > 0) {
204
- return files.map((file) => {
205
- if (file.lines)
206
- return file;
207
- const parsed = file.patch ? parsePatchLines(file.patch) : { lines: [], additions: 0, deletions: 0 };
253
+ function normalizeDiffFiles(files, diff) {
254
+ if (files && files.length > 0) {
255
+ return files.map((file) => {
256
+ if (file.lines)
257
+ return file;
258
+ const parsed = file.patch ? parsePatchLines(file.patch) : { lines: [], additions: 0, deletions: 0 };
259
+ return {
260
+ ...file,
261
+ lines: parsed.lines,
262
+ additions: file.additions ?? parsed.additions,
263
+ deletions: file.deletions ?? parsed.deletions,
264
+ };
265
+ });
266
+ }
267
+ return diff ? parseUnifiedDiff(diff) : [];
268
+ }
269
+ const DEFAULT_MAX_DIFF_LINES = 400;
270
+ const DiffFileSection = memo(function DiffFileSection({ file, maxLinesPerFile, onLineComment }) {
271
+ const [collapsed, setCollapsed] = useState(false);
272
+ const [expandedLines, setExpandedLines] = useState(false);
273
+ const lines = file.lines ?? [];
274
+ const capActive = maxLinesPerFile > 0 && Number.isFinite(maxLinesPerFile) && lines.length > maxLinesPerFile && !expandedLines;
275
+ const visibleLines = capActive ? lines.slice(0, maxLinesPerFile) : lines;
276
+ return (_jsxs("section", { className: "kit-diff-file", children: [_jsxs("header", { className: "kit-diff-file-head", children: [_jsx("button", { type: "button", className: "aui-diff-file-toggle", "aria-expanded": !collapsed, "aria-label": `${collapsed ? 'Expand' : 'Collapse'} ${file.path}`, onClick: () => setCollapsed((prev) => !prev), children: collapsed ? '▸' : '▾' }), _jsx(Badge, { tone: statusBadgeTone(file.status), children: file.status ?? 'M' }), _jsx("span", { className: "kit-diff-file-path", children: file.path }), _jsxs("span", { className: "kit-diff-file-stats", children: [file.additions !== undefined ? _jsx("span", { className: "kit-diff-stat-add", children: `+${file.additions}` }) : null, file.deletions !== undefined ? _jsx("span", { className: "kit-diff-stat-del", children: `-${file.deletions}` }) : null] })] }), !collapsed ? (_jsxs(_Fragment, { children: [_jsx("table", { className: "kit-diff-table", children: _jsx("tbody", { children: visibleLines.map((line, idx) => {
277
+ const targetLine = line.newLine ?? line.oldLine;
278
+ const prefix = line.kind === 'add' ? '+' : line.kind === 'del' ? '-' : line.kind === 'hunk' ? '' : ' ';
279
+ return (_jsxs("tr", { className: "kit-diff-line", "data-kind": line.kind, children: [_jsx("td", { className: "kit-diff-ln", children: line.oldLine ?? '' }), _jsx("td", { className: "kit-diff-ln", children: line.newLine ?? '' }), onLineComment ? (_jsx("td", { className: "kit-diff-comment-cell", children: line.kind !== 'hunk' && targetLine !== undefined ? (_jsx(Button, { size: "sm", variant: "ghost", ariaLabel: `Comment on line ${targetLine} of ${file.path}`, onClick: () => onLineComment(file.path, targetLine, line.content), children: "+" })) : null })) : null, _jsx("td", { className: "kit-diff-code", children: `${prefix}${line.content}` })] }, idx));
280
+ }) }) }), capActive ? (_jsxs("div", { className: "aui-truncate-bar", children: [_jsx("span", { children: `Showing first ${maxLinesPerFile.toLocaleString()} of ${lines.length.toLocaleString()} lines` }), _jsx(Button, { size: "sm", variant: "ghost", onClick: () => setExpandedLines(true), children: `Show all ${lines.length.toLocaleString()} lines` })] })) : null] })) : null] }));
281
+ });
282
+ export function DiffView({ diff, files, roots, selectedFile, selectedRoot, onSelectFile, onSelectInRoot, onLineComment, maxLinesPerFile = DEFAULT_MAX_DIFF_LINES, empty, className, }) {
283
+ const [collapsedRoots, setCollapsedRoots] = useState(() => new Set());
284
+ const resolvedRoots = useMemo(() => {
285
+ if (roots && roots.length > 0) {
286
+ return roots.map((root) => {
287
+ const rootFiles = normalizeDiffFiles(root.files, root.diff);
288
+ let additions = 0;
289
+ let deletions = 0;
290
+ for (const f of rootFiles) {
291
+ additions += f.additions ?? 0;
292
+ deletions += f.deletions ?? 0;
293
+ }
208
294
  return {
209
- ...file,
210
- lines: parsed.lines,
211
- additions: file.additions ?? parsed.additions,
212
- deletions: file.deletions ?? parsed.deletions,
295
+ id: root.id,
296
+ label: root.label ?? root.id,
297
+ badge: root.badge,
298
+ files: rootFiles,
299
+ additions,
300
+ deletions,
213
301
  };
214
302
  });
215
303
  }
216
- return diff ? parseUnifiedDiff(diff) : [];
217
- }, [diff, files]);
304
+ if (files && files.some((file) => Boolean(file.root))) {
305
+ const normalized = normalizeDiffFiles(files);
306
+ const grouped = new Map();
307
+ for (const file of normalized) {
308
+ const key = file.root ?? 'default';
309
+ const bucket = grouped.get(key) ?? [];
310
+ bucket.push(file);
311
+ grouped.set(key, bucket);
312
+ }
313
+ return [...grouped.entries()].map(([id, rootFiles]) => {
314
+ let additions = 0;
315
+ let deletions = 0;
316
+ for (const f of rootFiles) {
317
+ additions += f.additions ?? 0;
318
+ deletions += f.deletions ?? 0;
319
+ }
320
+ return { id, label: id, files: rootFiles, additions, deletions };
321
+ });
322
+ }
323
+ return null;
324
+ }, [roots, files]);
325
+ const parsedFiles = useMemo(() => (resolvedRoots ? [] : normalizeDiffFiles(files, diff)), [resolvedRoots, files, diff]);
326
+ const toggleRoot = useCallback((rootId) => {
327
+ setCollapsedRoots((prev) => {
328
+ const next = new Set(prev);
329
+ if (next.has(rootId))
330
+ next.delete(rootId);
331
+ else
332
+ next.add(rootId);
333
+ return next;
334
+ });
335
+ }, []);
336
+ if (resolvedRoots) {
337
+ const totalFiles = resolvedRoots.reduce((sum, r) => sum + r.files.length, 0);
338
+ if (totalFiles === 0) {
339
+ return (_jsx("div", { className: className ? `kit-diff-view ${className}` : 'kit-diff-view', children: empty ?? _jsx("p", { className: "note", children: "No file changes." }) }));
340
+ }
341
+ const canSelect = Boolean(onSelectInRoot || onSelectFile);
342
+ return (_jsx("div", { className: className ? `kit-diff-view aui-diff-roots ${className}` : 'kit-diff-view aui-diff-roots', children: resolvedRoots.map((root) => {
343
+ const isCollapsed = collapsedRoots.has(root.id);
344
+ const visibleFiles = selectedFile && (!selectedRoot || selectedRoot === root.id)
345
+ ? root.files.filter((file) => file.path === selectedFile)
346
+ : selectedFile && selectedRoot && selectedRoot !== root.id
347
+ ? []
348
+ : root.files;
349
+ return (_jsxs("section", { className: "aui-diff-root", "aria-label": root.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: root.label }), root.badge ? _jsx(Badge, { tone: "neutral", children: root.badge }) : null, _jsx(Badge, { tone: "neutral", children: `${root.files.length} ${root.files.length === 1 ? 'file' : 'files'}` }), _jsxs("span", { className: "kit-diff-file-stats", children: [root.additions > 0 ? _jsx("span", { className: "kit-diff-stat-add", children: `+${root.additions}` }) : null, root.deletions > 0 ? _jsx("span", { className: "kit-diff-stat-del", children: `-${root.deletions}` }) : null] })] }), !isCollapsed ? (_jsxs("div", { className: "aui-diff-root-body", children: [root.files.length > 1 && canSelect ? (_jsx("div", { className: "kit-diff-files", role: "group", "aria-label": `Changed files in ${root.label}`, children: root.files.map((file) => {
350
+ const isSelected = selectedFile === file.path && (!selectedRoot || selectedRoot === root.id);
351
+ return (_jsx(Button, { size: "sm", variant: isSelected ? 'primary' : 'secondary', onClick: () => {
352
+ onSelectInRoot?.(root.id, file.path);
353
+ onSelectFile?.(file.path);
354
+ }, children: `${file.status ?? 'M'} ${file.path}` }, `${root.id}:${file.path}`));
355
+ }) })) : null, visibleFiles.map((file) => (_jsx(DiffFileSection, { file: file, maxLinesPerFile: maxLinesPerFile, onLineComment: onLineComment }, `${root.id}:${file.path}`)))] })) : null] }, root.id));
356
+ }) }));
357
+ }
218
358
  if (parsedFiles.length === 0) {
219
359
  return (_jsx("div", { className: className ? `kit-diff-view ${className}` : 'kit-diff-view', children: empty ?? _jsx("p", { className: "note", children: "No file changes." }) }));
220
360
  }
221
361
  const visible = selectedFile ? parsedFiles.filter((file) => file.path === selectedFile) : parsedFiles;
222
- return (_jsxs("div", { className: className ? `kit-diff-view ${className}` : 'kit-diff-view', children: [parsedFiles.length > 1 && onSelectFile ? (_jsx("div", { className: "kit-diff-files", role: "group", "aria-label": "Changed files", children: parsedFiles.map((file) => (_jsx(Button, { size: "sm", variant: selectedFile === file.path ? 'primary' : 'secondary', onClick: () => onSelectFile(file.path), children: `${file.status ?? 'M'} ${file.path}` }, file.path))) })) : null, visible.map((file) => (_jsxs("section", { className: "kit-diff-file", children: [_jsxs("header", { className: "kit-diff-file-head", children: [_jsx(Badge, { tone: statusBadgeTone(file.status), children: file.status ?? 'M' }), _jsx("span", { className: "kit-diff-file-path", children: file.path }), _jsxs("span", { className: "kit-diff-file-stats", children: [file.additions !== undefined ? _jsx("span", { className: "kit-diff-stat-add", children: `+${file.additions}` }) : null, file.deletions !== undefined ? _jsx("span", { className: "kit-diff-stat-del", children: `-${file.deletions}` }) : null] })] }), _jsx("table", { className: "kit-diff-table", children: _jsx("tbody", { children: (file.lines ?? []).map((line, idx) => {
223
- const targetLine = line.newLine ?? line.oldLine;
224
- const prefix = line.kind === 'add' ? '+' : line.kind === 'del' ? '-' : line.kind === 'hunk' ? '' : ' ';
225
- return (_jsxs("tr", { className: "kit-diff-line", "data-kind": line.kind, children: [_jsx("td", { className: "kit-diff-ln", children: line.oldLine ?? '' }), _jsx("td", { className: "kit-diff-ln", children: line.newLine ?? '' }), onLineComment ? (_jsx("td", { className: "kit-diff-comment-cell", children: line.kind !== 'hunk' && targetLine !== undefined ? (_jsx(Button, { size: "sm", variant: "ghost", ariaLabel: `Comment on line ${targetLine} of ${file.path}`, onClick: () => onLineComment(file.path, targetLine, line.content), children: "+" })) : null })) : null, _jsx("td", { className: "kit-diff-code", children: `${prefix}${line.content}` })] }, idx));
226
- }) }) })] }, file.path)))] }));
362
+ return (_jsxs("div", { className: className ? `kit-diff-view ${className}` : 'kit-diff-view', children: [parsedFiles.length > 1 && onSelectFile ? (_jsx("div", { className: "kit-diff-files", role: "group", "aria-label": "Changed files", children: parsedFiles.map((file) => (_jsx(Button, { size: "sm", variant: selectedFile === file.path ? 'primary' : 'secondary', onClick: () => onSelectFile(file.path), children: `${file.status ?? 'M'} ${file.path}` }, file.path))) })) : null, visible.map((file) => (_jsx(DiffFileSection, { file: file, maxLinesPerFile: maxLinesPerFile, onLineComment: onLineComment }, file.path)))] }));
227
363
  }
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Path-first file tree builder and zero-dep accessible fallback `<DefaultFileTree>`.
2
+ * Path-first file tree builder and zero-dep accessible fallback `<DefaultFileTree>`,
3
+ * supporting both single-root and multi-root / multi-repo grouped trees.
3
4
  */
4
5
  import { type ReactNode } from 'react';
5
6
  import './workbench.css';
@@ -8,6 +9,23 @@ export interface FileTreeEntry {
8
9
  readonly path: string;
9
10
  readonly kind?: 'file' | 'directory';
10
11
  readonly gitStatus?: FileGitStatus;
12
+ /** Optional repo/workspace root label (e.g. `'api'`, `'web'`) for automatic multi-root grouping. */
13
+ readonly root?: string;
14
+ }
15
+ export interface FileTreeRoot {
16
+ /** Stable root identifier (e.g. `'api'`, `'web'`). */
17
+ readonly id: string;
18
+ /** Display label for the root group header (defaults to `id`). */
19
+ readonly label?: string;
20
+ /** Optional badge shown in the root header (e.g. branch name or status). */
21
+ readonly badge?: string;
22
+ /** Flat canonical paths inside this root. */
23
+ readonly paths?: readonly string[];
24
+ /** Structured entries inside this root. */
25
+ readonly entries?: readonly FileTreeEntry[];
26
+ /** Optional map of path -> git status badge when passing flat `paths`. */
27
+ readonly gitStatus?: Readonly<Record<string, FileGitStatus>>;
28
+ readonly defaultExpandedPaths?: readonly string[];
11
29
  }
12
30
  export interface FileTreeNode {
13
31
  readonly path: string;
@@ -19,13 +37,19 @@ export interface FileTreeNode {
19
37
  export interface FileTreeProps {
20
38
  /** Flat canonical paths (e.g. `['src/index.ts', 'src/app.ts']`). */
21
39
  readonly paths?: readonly string[];
22
- /** Structured entries with optional directory/git status metadata. */
40
+ /** Structured entries with optional directory/git status/root metadata. */
23
41
  readonly entries?: readonly FileTreeEntry[];
42
+ /** Optional multi-root / multi-repo groups (e.g. `api`, `web`) rendered with collapsible group headers. */
43
+ readonly roots?: readonly FileTreeRoot[];
24
44
  /** Optional map of path -> git status badge when passing flat `paths`. */
25
45
  readonly gitStatus?: Readonly<Record<string, FileGitStatus>>;
26
46
  readonly selectedPath?: string;
47
+ /** Optional selected root id (disambiguates identical relative paths across multiple repos). */
48
+ readonly selectedRoot?: string;
27
49
  readonly defaultExpandedPaths?: readonly string[];
28
50
  readonly onSelect: (path: string) => void;
51
+ /** Optional root-aware selection callback invoked alongside `onSelect` in multi-root trees. */
52
+ readonly onSelectInRoot?: (rootId: string, path: string) => void;
29
53
  readonly onToggleDirectory?: (path: string, expanded: boolean) => void;
30
54
  readonly searchable?: boolean;
31
55
  readonly placeholder?: string;
@@ -39,4 +63,6 @@ export declare function buildFileTreeNodes(input: {
39
63
  readonly entries?: readonly FileTreeEntry[];
40
64
  readonly gitStatus?: Readonly<Record<string, FileGitStatus>>;
41
65
  }): FileTreeNode[];
42
- export declare function DefaultFileTree({ paths, entries, gitStatus, selectedPath, defaultExpandedPaths, onSelect, onToggleDirectory, searchable, placeholder, empty, ariaLabel, className, }: FileTreeProps): import("react").JSX.Element;
66
+ /** Resolve explicit `roots` or infer roots from `entries[].root` when present. */
67
+ export declare function resolveFileTreeRoots(props: Pick<FileTreeProps, 'roots' | 'entries' | 'gitStatus' | 'defaultExpandedPaths'>): readonly FileTreeRoot[] | undefined;
68
+ export declare function DefaultFileTree({ paths, entries, roots, gitStatus, selectedPath, selectedRoot, defaultExpandedPaths, onSelect, onSelectInRoot, onToggleDirectory, searchable, placeholder, empty, ariaLabel, className, }: FileTreeProps): import("react").JSX.Element;
package/dist/fileTree.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /**
3
- * Path-first file tree builder and zero-dep accessible fallback `<DefaultFileTree>`.
3
+ * Path-first file tree builder and zero-dep accessible fallback `<DefaultFileTree>`,
4
+ * supporting both single-root and multi-root / multi-repo grouped trees.
4
5
  */
5
6
  import { useMemo, useState } from 'react';
6
7
  import { Badge, EmptyState, TextField } from '@mistriwork/mistri/ui';
@@ -63,6 +64,29 @@ export function buildFileTreeNodes(input) {
63
64
  }));
64
65
  return freeze(roots);
65
66
  }
67
+ /** Resolve explicit `roots` or infer roots from `entries[].root` when present. */
68
+ export function resolveFileTreeRoots(props) {
69
+ if (props.roots && props.roots.length > 0)
70
+ return props.roots;
71
+ if (!props.entries || !props.entries.some((entry) => Boolean(entry.root)))
72
+ return undefined;
73
+ const groups = new Map();
74
+ for (const entry of props.entries) {
75
+ const rootId = entry.root?.trim() || 'workspace';
76
+ const bucket = groups.get(rootId);
77
+ if (bucket)
78
+ bucket.push(entry);
79
+ else
80
+ groups.set(rootId, [entry]);
81
+ }
82
+ return [...groups.entries()].map(([id, entries]) => ({
83
+ id,
84
+ label: id,
85
+ entries,
86
+ gitStatus: props.gitStatus,
87
+ defaultExpandedPaths: props.defaultExpandedPaths,
88
+ }));
89
+ }
66
90
  function gitTone(status) {
67
91
  if (status === 'A' || status === 'U')
68
92
  return 'good';
@@ -95,11 +119,9 @@ function filterNodes(nodes, query) {
95
119
  }
96
120
  return out;
97
121
  }
98
- export function DefaultFileTree({ paths, entries, gitStatus, selectedPath, defaultExpandedPaths, onSelect, onToggleDirectory, searchable = false, placeholder = 'Filter files…', empty, ariaLabel = 'Files', className, }) {
99
- const [query, setQuery] = useState('');
122
+ function FileTreeList({ rootId, nodes, query, selectedPath, selectedRoot, defaultExpandedPaths, onSelect, onSelectInRoot, onToggleDirectory, ariaLabel, }) {
100
123
  const [expanded, setExpanded] = useState(() => new Set(defaultExpandedPaths ?? []));
101
- const tree = useMemo(() => buildFileTreeNodes({ paths, entries, gitStatus }), [paths, entries, gitStatus]);
102
- const filtered = useMemo(() => filterNodes(tree, query), [tree, query]);
124
+ const filtered = useMemo(() => filterNodes(nodes, query), [nodes, query]);
103
125
  const rows = useMemo(() => flattenVisible(filtered, expanded, query.trim().length > 0), [filtered, expanded, query]);
104
126
  const toggleDir = (path) => {
105
127
  setExpanded((prev) => {
@@ -113,18 +135,23 @@ export function DefaultFileTree({ paths, entries, gitStatus, selectedPath, defau
113
135
  return next;
114
136
  });
115
137
  };
138
+ const selectFile = (path) => {
139
+ if (rootId)
140
+ onSelectInRoot?.(rootId, path);
141
+ onSelect(path);
142
+ };
116
143
  const handleKeyDown = (index, row, event) => {
117
144
  if (event.key === 'ArrowDown' && rows[index + 1]) {
118
145
  event.preventDefault();
119
146
  const next = rows[index + 1];
120
147
  if (next.node.kind === 'file')
121
- onSelect(next.node.path);
148
+ selectFile(next.node.path);
122
149
  }
123
150
  else if (event.key === 'ArrowUp' && rows[index - 1]) {
124
151
  event.preventDefault();
125
152
  const prev = rows[index - 1];
126
153
  if (prev.node.kind === 'file')
127
- onSelect(prev.node.path);
154
+ selectFile(prev.node.path);
128
155
  }
129
156
  else if (event.key === 'ArrowRight' && row.node.kind === 'directory' && !expanded.has(row.node.path)) {
130
157
  event.preventDefault();
@@ -135,10 +162,52 @@ export function DefaultFileTree({ paths, entries, gitStatus, selectedPath, defau
135
162
  toggleDir(row.node.path);
136
163
  }
137
164
  };
138
- return (_jsxs("div", { className: className ? `aui-file-tree ${className}` : 'aui-file-tree', children: [searchable ? (_jsx(TextField, { label: "Filter files", labelHidden: true, reserve: false, value: query, onValueChange: (next) => setQuery(next), placeholder: placeholder })) : null, rows.length === 0 ? ((empty ?? _jsx(EmptyState, { compact: true, title: "No files" }))) : (_jsx("ul", { className: "aui-file-tree-list", role: "tree", "aria-label": ariaLabel, children: rows.map((row, idx) => {
139
- const isDir = row.node.kind === 'directory';
140
- const isOpen = query.trim().length > 0 || expanded.has(row.node.path);
141
- const selected = row.node.path === selectedPath;
142
- return (_jsx("li", { role: "treeitem", "aria-expanded": isDir ? isOpen : undefined, "aria-selected": selected, children: _jsxs("button", { type: "button", className: "aui-file-tree-row", "aria-selected": selected, style: { paddingInlineStart: `calc(var(--space-2) + ${row.depth} * var(--space-3))` }, onClick: () => (isDir ? toggleDir(row.node.path) : onSelect(row.node.path)), onKeyDown: (e) => handleKeyDown(idx, row, e), children: [_jsx("span", { className: "aui-file-tree-caret", "aria-hidden": "true", children: isDir ? (isOpen ? '▾' : '▸') : '·' }), _jsx("span", { className: "aui-file-tree-name", children: row.node.name }), row.node.gitStatus ? _jsx(Badge, { tone: gitTone(row.node.gitStatus), children: row.node.gitStatus }) : null] }) }, row.node.path));
143
- }) }))] }));
165
+ if (rows.length === 0)
166
+ return null;
167
+ return (_jsx("ul", { className: "aui-file-tree-list", role: "tree", "aria-label": ariaLabel, children: rows.map((row, idx) => {
168
+ const isDir = row.node.kind === 'directory';
169
+ const isOpen = query.trim().length > 0 || expanded.has(row.node.path);
170
+ const selected = row.node.path === selectedPath && (!rootId || !selectedRoot || selectedRoot === rootId);
171
+ return (_jsx("li", { role: "treeitem", "aria-expanded": isDir ? isOpen : undefined, "aria-selected": selected, children: _jsxs("button", { type: "button", className: "aui-file-tree-row", "aria-selected": selected, style: { paddingInlineStart: `calc(var(--space-2) + ${row.depth} * var(--space-3))` }, onClick: () => (isDir ? toggleDir(row.node.path) : selectFile(row.node.path)), onKeyDown: (e) => handleKeyDown(idx, row, e), children: [_jsx("span", { className: "aui-file-tree-caret", "aria-hidden": "true", children: isDir ? (isOpen ? '▾' : '▸') : '·' }), _jsx("span", { className: "aui-file-tree-name", children: row.node.name }), row.node.gitStatus ? _jsx(Badge, { tone: gitTone(row.node.gitStatus), children: row.node.gitStatus }) : null] }) }, row.node.path));
172
+ }) }));
173
+ }
174
+ export function DefaultFileTree({ paths, entries, roots, gitStatus, selectedPath, selectedRoot, defaultExpandedPaths, onSelect, onSelectInRoot, onToggleDirectory, searchable = false, placeholder = 'Filter files…', empty, ariaLabel = 'Files', className, }) {
175
+ const [query, setQuery] = useState('');
176
+ const [collapsedRoots, setCollapsedRoots] = useState(() => new Set());
177
+ const resolvedRoots = useMemo(() => resolveFileTreeRoots({ roots, entries, gitStatus, defaultExpandedPaths }), [roots, entries, gitStatus, defaultExpandedPaths]);
178
+ const singleTree = useMemo(() => (resolvedRoots ? [] : buildFileTreeNodes({ paths, entries, gitStatus })), [resolvedRoots, paths, entries, gitStatus]);
179
+ const rootTrees = useMemo(() => resolvedRoots
180
+ ? resolvedRoots.map((root) => ({
181
+ root,
182
+ nodes: buildFileTreeNodes({
183
+ paths: root.paths,
184
+ entries: root.entries,
185
+ gitStatus: root.gitStatus ?? gitStatus,
186
+ }),
187
+ }))
188
+ : [], [resolvedRoots, gitStatus]);
189
+ const toggleRoot = (id) => {
190
+ setCollapsedRoots((prev) => {
191
+ const next = new Set(prev);
192
+ if (next.has(id))
193
+ next.delete(id);
194
+ else
195
+ next.add(id);
196
+ return next;
197
+ });
198
+ };
199
+ const hasAnyMatches = useMemo(() => {
200
+ if (resolvedRoots) {
201
+ return rootTrees.some(({ nodes }) => filterNodes(nodes, query).length > 0);
202
+ }
203
+ return filterNodes(singleTree, query).length > 0;
204
+ }, [resolvedRoots, rootTrees, singleTree, query]);
205
+ return (_jsxs("div", { className: className ? `aui-file-tree ${className}` : 'aui-file-tree', children: [searchable ? (_jsx(TextField, { label: "Filter files", labelHidden: true, reserve: false, value: query, onValueChange: (next) => setQuery(next), placeholder: placeholder })) : null, !hasAnyMatches ? ((empty ?? _jsx(EmptyState, { compact: true, title: "No files" }))) : resolvedRoots ? (_jsx("div", { className: "aui-file-tree-roots", children: rootTrees.map(({ root, nodes }) => {
206
+ const matching = filterNodes(nodes, query);
207
+ if (matching.length === 0)
208
+ return null;
209
+ const isOpen = query.trim().length > 0 || !collapsedRoots.has(root.id);
210
+ const label = root.label ?? root.id;
211
+ return (_jsxs("section", { className: "aui-file-tree-root", "aria-label": label, children: [_jsxs("button", { type: "button", className: "aui-file-tree-root-head", "aria-expanded": isOpen, onClick: () => toggleRoot(root.id), children: [_jsx("span", { className: "aui-file-tree-caret", "aria-hidden": "true", children: isOpen ? '▾' : '▸' }), _jsx("span", { className: "aui-file-tree-root-label", children: label }), root.badge ? _jsx(Badge, { tone: "neutral", children: root.badge }) : null] }), isOpen ? (_jsx(FileTreeList, { rootId: root.id, nodes: nodes, query: query, selectedPath: selectedPath, selectedRoot: selectedRoot, defaultExpandedPaths: root.defaultExpandedPaths ?? defaultExpandedPaths, onSelect: onSelect, onSelectInRoot: onSelectInRoot, onToggleDirectory: onToggleDirectory, ariaLabel: `${label} files` })) : null] }, root.id));
212
+ }) })) : (_jsx(FileTreeList, { nodes: singleTree, query: query, selectedPath: selectedPath, defaultExpandedPaths: defaultExpandedPaths, onSelect: onSelect, onToggleDirectory: onToggleDirectory, ariaLabel: ariaLabel }))] }));
144
213
  }
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  * multi-agent orchestrators, and AI IDEs on Mistri.
4
4
  */
5
5
  export { AgentComposer, AgentThread, DiffView, parseUnifiedDiff } from './agentIde.js';
6
- export type { AgentComposerProps, AgentThreadApproval, AgentThreadCodeBlock, AgentThreadLabels, AgentThreadMessage, AgentThreadProps, AgentThreadToolCall, ComposerAttachment, ComposerSlashCommand, DiffFile, DiffLine, DiffViewProps, } from './agentIde.js';
6
+ export type { AgentComposerProps, AgentThreadApproval, AgentThreadCodeBlock, AgentThreadLabels, AgentThreadMessage, AgentThreadProps, AgentThreadToolCall, ComposerAttachment, ComposerSlashCommand, DiffFile, DiffLine, DiffViewProps, DiffViewRoot, } from './agentIde.js';
7
7
  export { CommandPalette, StatusBar, TabStrip, WorkbenchLayout } from './shell.js';
8
8
  export type { CommandPaletteItem, CommandPaletteProps, StatusBarItem, StatusBarProps, TabStripItem, TabStripProps, WorkbenchLayoutProps, WorkbenchLayoutSizes, } from './shell.js';
9
9
  export { ApprovalQueue, PlanView, RaceCompare, SessionTree } from './orchestrator.js';
@@ -13,6 +13,6 @@ export type { AgentModeOption, AnsiSegment, ModeSwitcherProps, ModelOption, Mode
13
13
  export { mergeStreamingTurn, streamStateToApprovals, streamStateToDiffFiles, streamStateToThreadMessage, streamStateToToolCalls, } from './streamBridge.js';
14
14
  export type { AgentStreamApprovalLike, AgentStreamDiffLike, AgentStreamSnapshot, AgentStreamStatusLike, AgentStreamToolCallLike, ApprovalQueueItem, StreamToMessageOptions, ToolCallRecord, } from './streamBridge.js';
15
15
  export { DefaultFileTree, buildFileTreeNodes } from './fileTree.js';
16
- export type { FileGitStatus, FileTreeEntry, FileTreeNode, FileTreeProps } from './fileTree.js';
16
+ export type { FileGitStatus, FileTreeEntry, FileTreeNode, FileTreeProps, FileTreeRoot } from './fileTree.js';
17
17
  export { AgentUiProvider, CodeSurface, DefaultCodeSurface, DefaultDiffSurface, DiffSurface, FileTree, useAgentUiSurfaces, } from './surfaces.js';
18
- export type { AgentUiProviderProps, AgentUiSurfaces, CodeAnnotation, CodeMarker, CodeSelectionSnippet, CodeSurfaceProps, DiffAnnotation, DiffSurfaceFileInput, DiffSurfaceProps, } from './surfaces.js';
18
+ export type { AgentUiProviderProps, AgentUiSurfaces, CodeAnnotation, CodeMarker, CodeSelectionSnippet, CodeSurfaceProps, DiffAnnotation, DiffSurfaceFileInput, DiffSurfaceProps, DiffSurfaceRoot, } from './surfaces.js';
@@ -15,6 +15,14 @@ export interface AgentSessionNode {
15
15
  readonly status: AgentSessionStatus;
16
16
  readonly model?: string;
17
17
  readonly branch?: string;
18
+ /** Optional multi-repo labels rendered as compact pill badges (e.g. `['api', 'web']`). */
19
+ readonly repos?: readonly string[];
20
+ /** Whether this session is currently observed/watched in a multi-session view. */
21
+ readonly watched?: boolean;
22
+ /** Whether this session is pinned to the top of its sibling list. */
23
+ readonly pinned?: boolean;
24
+ /** Whether this session is archived. */
25
+ readonly archived?: boolean;
18
26
  readonly durationLabel?: string;
19
27
  readonly tokensLabel?: string;
20
28
  readonly pendingApprovals?: number;
@@ -26,11 +34,27 @@ export interface SessionTreeProps {
26
34
  readonly onSelect: (id: string) => void;
27
35
  readonly onCancel?: (id: string) => void;
28
36
  readonly onFork?: (id: string) => void;
37
+ /** Inline rename callback invoked when the user confirms a new session title. */
38
+ readonly onRename?: (id: string, nextTitle: string) => void;
39
+ /** Toggle watch/observe state for a session (`nextWatched = !node.watched`). */
40
+ readonly onWatch?: (id: string, nextWatched: boolean) => void;
41
+ /** Toggle pin state for a session (`nextPinned = !node.pinned`). */
42
+ readonly onPin?: (id: string, nextPinned: boolean) => void;
43
+ /** Toggle archive state for a session (`nextArchived = !node.archived`). */
44
+ readonly onArchive?: (id: string, nextArchived: boolean) => void;
45
+ /** Optional custom inline action slot rendered at the end of each session row. */
46
+ readonly renderNodeActions?: (node: AgentSessionNode) => ReactNode;
47
+ /** Optional custom badge/meta slot rendered inside each session row's metadata bar. */
48
+ readonly renderNodeBadges?: (node: AgentSessionNode) => ReactNode;
49
+ /** Include archived sessions in the default non-archived view. Default `false`. */
50
+ readonly showArchived?: boolean;
51
+ /** Show an inline search input to filter large session lists by title, branch, model, or repo. */
52
+ readonly searchable?: boolean;
29
53
  readonly filterable?: boolean;
30
54
  readonly empty?: ReactNode;
31
55
  readonly className?: string;
32
56
  }
33
- export declare function SessionTree({ sessions, selectedId, onSelect, onCancel, onFork, filterable, empty, className }: SessionTreeProps): import("react").JSX.Element;
57
+ export declare function SessionTree({ sessions, selectedId, onSelect, onCancel, onFork, onRename, onWatch, onPin, onArchive, renderNodeActions, renderNodeBadges, showArchived, searchable, filterable, empty, className, }: SessionTreeProps): import("react").JSX.Element;
34
58
  export interface RaceCheck {
35
59
  readonly label: string;
36
60
  readonly passed: boolean;