@linxiraos/pi-tui 1.4.10 → 1.4.12
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 +34 -237
- package/README.md +4 -1
- package/THIRD-PARTY-NOTICES.txt +99 -0
- package/dist/types/apps/shell-visualizer.d.ts +24 -0
- package/dist/types/autocomplete.d.ts +20 -0
- package/dist/types/chat/cache-invalidation-marker.d.ts +15 -7
- package/dist/types/chat/chat-transcript-builder.d.ts +5 -3
- package/dist/types/chat/display-preferences.d.ts +2 -0
- package/dist/types/chat/extension-types.d.ts +72 -1
- package/dist/types/chat/image-loading.d.ts +2 -2
- package/dist/types/chat/messages.d.ts +2 -3
- package/dist/types/chat/read-tool-group.d.ts +15 -2
- package/dist/types/chat/skill-message.d.ts +1 -0
- package/dist/types/chat/spotlight.d.ts +203 -0
- package/dist/types/chat/tool-execution.d.ts +26 -5
- package/dist/types/chat/transcript-actions.d.ts +11 -0
- package/dist/types/chat/transcript-browser.d.ts +9 -0
- package/dist/types/chat/transcript-presentation.d.ts +164 -0
- package/dist/types/chat/ttsr-notification.d.ts +2 -0
- package/dist/types/chrome/message-frame.d.ts +2 -0
- package/dist/types/chrome/transcript-container.d.ts +27 -6
- package/dist/types/components/loader.d.ts +0 -2
- package/dist/types/components/markdown.d.ts +11 -1
- package/dist/types/components/settings-list.d.ts +12 -2
- package/dist/types/frame-rate.d.ts +18 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/keybinding-matchers.d.ts +4 -1
- package/dist/types/kitty-graphics.d.ts +1 -1
- package/dist/types/motion-effects.d.ts +10 -0
- package/dist/types/native/encode.d.ts +2 -0
- package/dist/types/native/measure.d.ts +10 -0
- package/dist/types/native/overlay.d.ts +1 -1
- package/dist/types/native/quiet.d.ts +5 -0
- package/dist/types/native/reconcile.d.ts +6 -1
- package/dist/types/native/spans.d.ts +6 -0
- package/dist/types/native/state.d.ts +4 -0
- package/dist/types/overlays/agent-hub.d.ts +6 -0
- package/dist/types/overlays/link-browser.d.ts +55 -0
- package/dist/types/overlays/running-subagent-badge.d.ts +1 -4
- package/dist/types/overlays/settings-selector.d.ts +1 -1
- package/dist/types/overlays/snapcompact-shape-preview.d.ts +1 -1
- package/dist/types/overlays/spotlight-sheet.d.ts +36 -0
- package/dist/types/prompt/composer-attachments.d.ts +5 -2
- package/dist/types/prompt/composer-cache.d.ts +7 -2
- package/dist/types/prompt/composer.d.ts +6 -11
- package/dist/types/prompt/custom-editor.d.ts +8 -2
- package/dist/types/prompt/gradient-highlight.d.ts +2 -2
- package/dist/types/prompt/magic-keywords.d.ts +2 -0
- package/dist/types/prompt/model-mention-autocomplete.d.ts +9 -7
- package/dist/types/prompt/model-mention-syntax.d.ts +6 -0
- package/dist/types/prompt/prompt-action-autocomplete.d.ts +2 -1
- package/dist/types/prompt/welcome.d.ts +19 -0
- package/dist/types/render/extension-links.d.ts +0 -6
- package/dist/types/render/index.d.ts +1 -0
- package/dist/types/render/link-hints.d.ts +78 -0
- package/dist/types/render/render-utils.d.ts +0 -2
- package/dist/types/setup/scenes/types.d.ts +8 -0
- package/dist/types/setup/scenes/updates.d.ts +6 -0
- package/dist/types/setup/wizard.d.ts +7 -2
- package/dist/types/spinner-clock.d.ts +34 -0
- package/dist/types/status-line/component.d.ts +8 -4
- package/dist/types/status-line/host.d.ts +62 -0
- package/dist/types/status-line/index.d.ts +1 -0
- package/dist/types/status-line/prompt-cache.d.ts +14 -0
- package/dist/types/status-line/schema.d.ts +1 -1
- package/dist/types/status-line/startup.d.ts +6 -0
- package/dist/types/status-line/types.d.ts +8 -21
- package/dist/types/theme/schema.d.ts +28 -1
- package/dist/types/theme/symbols.d.ts +1 -1
- package/dist/types/theme/theme-class.d.ts +12 -2
- package/dist/types/theme/theme.d.ts +1 -1
- package/dist/types/theme/tui-adapters.d.ts +7 -0
- package/dist/types/thinking.d.ts +12 -0
- package/dist/types/tools/ask.d.ts +1 -1
- package/dist/types/tools/bash.d.ts +21 -0
- package/dist/types/tools/find.d.ts +9 -1
- package/dist/types/tools/grep.d.ts +2 -1
- package/dist/types/tools/grouped-file-output.d.ts +17 -0
- package/dist/types/tools/job-widget.d.ts +2 -2
- package/dist/types/tools/lsp.d.ts +4 -2
- package/dist/types/tools/native-view.d.ts +4 -0
- package/dist/types/tools/renderer.d.ts +9 -1
- package/dist/types/tools/shell-trace.d.ts +10 -0
- package/dist/types/tools/shell-viz-render.d.ts +6 -0
- package/dist/types/tools/shell-viz.d.ts +16 -0
- package/dist/types/tools/wait.d.ts +2 -2
- package/dist/types/tools/web-search-types.d.ts +1 -0
- package/dist/types/tools/write.d.ts +2 -0
- package/dist/types/tui.d.ts +15 -1
- package/package.json +15 -11
- package/src/apps/shell-visualizer.d.ts +24 -0
- package/src/apps/shell-visualizer.ts +167 -0
- package/src/autocomplete.d.ts +20 -0
- package/src/autocomplete.ts +14 -0
- package/src/chat/assistant-message.ts +11 -6
- package/src/chat/cache-invalidation-marker.d.ts +15 -7
- package/src/chat/cache-invalidation-marker.ts +18 -9
- package/src/chat/chat-transcript-builder.d.ts +5 -3
- package/src/chat/chat-transcript-builder.ts +16 -12
- package/src/chat/display-preferences.d.ts +2 -0
- package/src/chat/display-preferences.ts +3 -0
- package/src/chat/extension-types.d.ts +72 -1
- package/src/chat/extension-types.ts +74 -1
- package/src/chat/image-loading.d.ts +2 -2
- package/src/chat/image-loading.ts +2 -2
- package/src/chat/messages.d.ts +2 -3
- package/src/chat/messages.ts +3 -8
- package/src/chat/read-tool-group.d.ts +15 -2
- package/src/chat/read-tool-group.ts +201 -41
- package/src/chat/skill-message.d.ts +1 -0
- package/src/chat/skill-message.ts +4 -0
- package/src/chat/spotlight.d.ts +203 -0
- package/src/chat/spotlight.ts +460 -0
- package/src/chat/tool-execution.d.ts +26 -5
- package/src/chat/tool-execution.ts +360 -38
- package/src/chat/transcript-actions.d.ts +11 -0
- package/src/chat/transcript-actions.ts +13 -1
- package/src/chat/transcript-browser.d.ts +9 -0
- package/src/chat/transcript-browser.ts +18 -0
- package/src/chat/transcript-presentation.d.ts +164 -0
- package/src/chat/transcript-presentation.ts +642 -0
- package/src/chat/ttsr-notification.d.ts +25 -0
- package/src/chat/ttsr-notification.ts +5 -0
- package/src/chrome/message-frame.d.ts +2 -0
- package/src/chrome/message-frame.ts +7 -0
- package/src/chrome/message-notice.d.ts +58 -0
- package/src/chrome/transcript-container.d.ts +27 -6
- package/src/chrome/transcript-container.ts +317 -66
- package/src/components/editor.ts +25 -1
- package/src/components/loader.d.ts +0 -2
- package/src/components/loader.ts +30 -18
- package/src/components/markdown.d.ts +11 -1
- package/src/components/markdown.ts +41 -16
- package/src/components/settings-list.d.ts +12 -2
- package/src/components/settings-list.ts +29 -13
- package/src/frame-rate.d.ts +18 -0
- package/src/frame-rate.ts +36 -0
- package/src/hotkeys-markdown.ts +4 -1
- package/src/index.d.ts +3 -0
- package/src/index.ts +3 -0
- package/src/keybinding-matchers.d.ts +4 -1
- package/src/keybinding-matchers.ts +13 -12
- package/src/kitty-graphics.d.ts +1 -1
- package/src/kitty-graphics.ts +3 -2
- package/src/motion-effects.d.ts +10 -0
- package/src/motion-effects.ts +27 -0
- package/src/native/backend.ts +66 -7
- package/src/native/encode.d.ts +2 -0
- package/src/native/encode.ts +2 -0
- package/src/native/measure.d.ts +10 -0
- package/src/native/measure.ts +185 -0
- package/src/native/overlay.d.ts +1 -1
- package/src/native/overlay.ts +1 -1
- package/src/native/quiet.d.ts +5 -0
- package/src/native/quiet.ts +105 -0
- package/src/native/reconcile.d.ts +6 -1
- package/src/native/reconcile.ts +16 -10
- package/src/native/spans.d.ts +6 -0
- package/src/native/spans.ts +40 -0
- package/src/native/state.d.ts +4 -0
- package/src/native/state.ts +18 -0
- package/src/overlays/agent-hub.ts +15 -2
- package/src/overlays/ask-dialog.ts +1 -0
- package/src/overlays/btw-history-panel.ts +73 -6
- package/src/overlays/link-browser.ts +295 -0
- package/src/overlays/running-subagent-badge.ts +2 -9
- package/src/overlays/settings-defs.ts +2 -1
- package/src/overlays/settings-selector.ts +18 -4
- package/src/overlays/snapcompact-shape-preview.ts +1 -1
- package/src/overlays/spotlight-sheet.ts +478 -0
- package/src/overlays/usage-dashboard.ts +6 -5
- package/src/prompt/composer-attachments.d.ts +5 -2
- package/src/prompt/composer-attachments.ts +6 -6
- package/src/prompt/composer-cache.ts +17 -16
- package/src/prompt/composer.ts +30 -123
- package/src/prompt/custom-editor.ts +17 -13
- package/src/prompt/gradient-highlight.d.ts +2 -2
- package/src/prompt/gradient-highlight.ts +5 -4
- package/src/prompt/magic-keywords.d.ts +2 -0
- package/src/prompt/magic-keywords.ts +4 -1
- package/src/prompt/model-mention-autocomplete.ts +73 -20
- package/src/prompt/model-mention-syntax.d.ts +6 -0
- package/src/prompt/model-mention-syntax.ts +9 -0
- package/src/prompt/prompt-action-autocomplete.ts +49 -33
- package/src/prompt/tips.txt +1 -0
- package/src/prompt/welcome.ts +104 -2
- package/src/render/extension-links.d.ts +0 -6
- package/src/render/extension-links.ts +0 -20
- package/src/render/index.d.ts +1 -0
- package/src/render/index.ts +1 -0
- package/src/render/link-hints.d.ts +78 -0
- package/src/render/link-hints.ts +299 -0
- package/src/render/render-utils.d.ts +0 -2
- package/src/render/render-utils.ts +0 -5
- package/src/setup/scenes/glyph.ts +1 -1
- package/src/setup/scenes/types.ts +8 -0
- package/src/setup/scenes/updates.ts +116 -0
- package/src/setup/wizard.ts +19 -8
- package/src/spinner-clock.d.ts +34 -0
- package/src/spinner-clock.ts +79 -0
- package/src/status-line/component.ts +145 -53
- package/src/status-line/host.ts +51 -0
- package/src/status-line/index.ts +1 -0
- package/src/status-line/presets.ts +3 -1
- package/src/status-line/prompt-cache.ts +154 -0
- package/src/status-line/schema.ts +1 -1
- package/src/status-line/segments.ts +33 -22
- package/src/status-line/startup.ts +23 -5
- package/src/status-line/types.ts +8 -22
- package/src/stdin-buffer.ts +89 -46
- package/src/terminal-capabilities.ts +3 -3
- package/src/terminal.ts +1 -8
- package/src/theme/loader.ts +3 -2
- package/src/theme/schema-validation.ts +1 -1
- package/src/theme/schema.d.ts +28 -1
- package/src/theme/schema.ts +30 -1
- package/src/theme/symbols.d.ts +1 -1
- package/src/theme/symbols.ts +15 -3
- package/src/theme/theme-class.d.ts +12 -2
- package/src/theme/theme-class.ts +23 -0
- package/src/theme/theme-schema.json +1 -1
- package/src/theme/theme.d.ts +1 -1
- package/src/theme/theme.ts +3 -7
- package/src/theme/tui-adapters.d.ts +7 -0
- package/src/theme/tui-adapters.ts +33 -1
- package/src/thinking.d.ts +12 -0
- package/src/thinking.ts +31 -0
- package/src/tools/ask.d.ts +1 -1
- package/src/tools/ask.ts +99 -38
- package/src/tools/ast-edit.ts +51 -32
- package/src/tools/ast-grep.ts +31 -19
- package/src/tools/bash.d.ts +21 -0
- package/src/tools/bash.ts +166 -24
- package/src/tools/find.d.ts +9 -1
- package/src/tools/find.ts +23 -2
- package/src/tools/grep.d.ts +2 -1
- package/src/tools/grep.ts +52 -36
- package/src/tools/grouped-file-output.d.ts +17 -0
- package/src/tools/grouped-file-output.ts +20 -2
- package/src/tools/job-widget.d.ts +2 -2
- package/src/tools/job-widget.ts +2 -2
- package/src/tools/lsp.d.ts +4 -2
- package/src/tools/lsp.ts +537 -642
- package/src/tools/native-view.d.ts +4 -0
- package/src/tools/native-view.ts +8 -2
- package/src/tools/renderer.d.ts +9 -1
- package/src/tools/renderer.ts +9 -1
- package/src/tools/shell-trace.d.ts +10 -0
- package/src/tools/shell-trace.ts +80 -0
- package/src/tools/shell-viz-render.d.ts +6 -0
- package/src/tools/shell-viz-render.ts +156 -0
- package/src/tools/shell-viz.d.ts +16 -0
- package/src/tools/shell-viz.ts +181 -0
- package/src/tools/streaming-output.ts +18 -8
- package/src/tools/task.ts +1 -1
- package/src/tools/wait.d.ts +2 -2
- package/src/tools/wait.ts +39 -34
- package/src/tools/web-search-types.d.ts +1 -0
- package/src/tools/web-search-types.ts +1 -0
- package/src/tools/write.d.ts +2 -0
- package/src/tools/write.ts +2 -0
- package/src/tui.d.ts +15 -1
- package/src/tui.ts +63 -6
- package/src/windows-input-mode.ts +7 -1
- package/dist/types/chat/collab-prompt-message.d.ts +0 -14
- package/dist/types/chrome/collab-qrcode.d.ts +0 -35
- package/src/chat/collab-prompt-message.d.ts +0 -14
- package/src/chat/collab-prompt-message.ts +0 -46
- package/src/chrome/collab-qrcode.ts +0 -99
|
@@ -21,27 +21,30 @@ import {
|
|
|
21
21
|
PREVIEW_LIMITS,
|
|
22
22
|
shortenPath,
|
|
23
23
|
} from "../render/render-utils";
|
|
24
|
-
import { fileHyperlink, renderCodeCell, renderMarkdownCell } from "../render";
|
|
24
|
+
import { fileHyperlink, renderCodeCell, renderMarkdownCell, urlHyperlinkAlways } from "../render";
|
|
25
25
|
import { wrapTreeLine } from "../render/hanging-wrap";
|
|
26
26
|
import { wrapTextWithAnsi } from "../utils";
|
|
27
27
|
import { canonicalizeMessage } from "./thinking-display";
|
|
28
28
|
import { internalUrlSchemeSpec, splitUrlScheme } from "../tools/url-scheme-host";
|
|
29
|
+
import { SpotlightNotices } from "./spotlight";
|
|
29
30
|
import type { ToolExecutionHandle } from "./tool-execution";
|
|
30
31
|
import { formatUsageRow } from "../overlays/usage-row";
|
|
31
32
|
import { formatCount, isUrlLikePath, sanitizeText, sanitizeTextDeep } from "@linxiraos/pi-utils";
|
|
32
33
|
import type { TspCardStatus, TspSpan, TspText } from "@linxiraos/pi-wire";
|
|
33
34
|
import type { NativeToolHead } from "../tools/renderer";
|
|
34
|
-
import { card, code, keyed, md, node, span, text, withHidden } from "../native/describe";
|
|
35
|
+
import { card, code, col, keyed, md, node, span, text, withHidden } from "../native/describe";
|
|
35
36
|
import {
|
|
36
37
|
type DescribeContext,
|
|
37
38
|
type NativeChild,
|
|
38
39
|
type NativeNode,
|
|
39
40
|
type NativeUiEvent,
|
|
41
|
+
leafKey,
|
|
40
42
|
rootToggleExpanded,
|
|
41
43
|
} from "../native/node";
|
|
42
44
|
import { plainText } from "../native/spans";
|
|
43
45
|
import { Memo } from "../native/memo";
|
|
44
|
-
import { fileHref, fileRow, inlineErrorView, urlHref } from "../tools/native-view";
|
|
46
|
+
import { fileHref, fileRow, inlineErrorView, resultText, urlHref } from "../tools/native-view";
|
|
47
|
+
import { compactHead, compactRows, presentNative, TranscriptPresentationState } from "./transcript-presentation";
|
|
45
48
|
|
|
46
49
|
/**
|
|
47
50
|
* Extract the read call's target path. `path` is the canonical arg; `file_path`
|
|
@@ -110,6 +113,8 @@ type ReadToolSuffixResolution = {
|
|
|
110
113
|
|
|
111
114
|
type ReadToolGroupOptions = {
|
|
112
115
|
showContentPreview?: boolean;
|
|
116
|
+
/** Ask the extension transcript presenters; false for a replayed transcript (overlays). Default: true. */
|
|
117
|
+
transcriptPresenters?: boolean;
|
|
113
118
|
};
|
|
114
119
|
|
|
115
120
|
function getSuffixResolution(details: ReadToolDetails | undefined): ReadToolSuffixResolution | undefined {
|
|
@@ -137,6 +142,15 @@ type ReadEntry = {
|
|
|
137
142
|
conflictCount?: number;
|
|
138
143
|
codeStartLine?: number;
|
|
139
144
|
codeLineNumbers?: Array<number | null>;
|
|
145
|
+
/** The call as presenters see it. */
|
|
146
|
+
args?: unknown;
|
|
147
|
+
result?: { content: readonly unknown[]; details?: unknown };
|
|
148
|
+
presentation: TranscriptPresentationState;
|
|
149
|
+
/**
|
|
150
|
+
* The user opened this read (Ctrl+O, the `full` rows' toggle or its own compact row): it draws
|
|
151
|
+
* in full whatever presenters answer, its content preview unclamped.
|
|
152
|
+
*/
|
|
153
|
+
expanded: boolean;
|
|
140
154
|
};
|
|
141
155
|
|
|
142
156
|
/**
|
|
@@ -386,6 +400,8 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
386
400
|
#usageRows = new Map<string, ReadUsageRow>();
|
|
387
401
|
#usageBatchByToolCallId = new Map<string, string>();
|
|
388
402
|
#text: Text;
|
|
403
|
+
/** Whether presenters draw these reads (not a replayed transcript). */
|
|
404
|
+
#presented: boolean;
|
|
389
405
|
#expanded = false;
|
|
390
406
|
#toolActivityVisible = true;
|
|
391
407
|
#showContentPreview: boolean;
|
|
@@ -405,21 +421,85 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
405
421
|
#blockVersion = 0;
|
|
406
422
|
#displayVersion = 0;
|
|
407
423
|
readonly #native = new Memo();
|
|
408
|
-
|
|
409
|
-
#
|
|
424
|
+
// The reads' Spotlight notices, drawn after the group in a native transcript (see nativeTrailers).
|
|
425
|
+
readonly #spotlight = new SpotlightNotices();
|
|
410
426
|
|
|
411
427
|
constructor(options: ReadToolGroupOptions = {}) {
|
|
412
428
|
super();
|
|
413
429
|
this.#showContentPreview = options.showContentPreview ?? false;
|
|
430
|
+
this.#presented = options.transcriptPresenters ?? true;
|
|
414
431
|
this.#text = new Text("", 0, 0);
|
|
415
432
|
this.addChild(this.#text);
|
|
416
433
|
this.#updateDisplay();
|
|
417
434
|
}
|
|
418
435
|
|
|
436
|
+
/**
|
|
437
|
+
* Reads a presenter leaves full draw as the group, at the first full read's place; a compact
|
|
438
|
+
* read is a row of its own; hidden draws nothing.
|
|
439
|
+
*/
|
|
419
440
|
override render(width: number): readonly string[] {
|
|
420
441
|
if (!this.#toolActivityVisible) return [];
|
|
421
|
-
|
|
442
|
+
const entries = [...this.#entries.values()];
|
|
443
|
+
const drawn = entries.map(entry => entry.presentation.draw());
|
|
444
|
+
if (drawn.every(shown => shown.mode === "full")) return super.render(width);
|
|
445
|
+
const lines: string[] = [];
|
|
446
|
+
let fullDrawn = false;
|
|
447
|
+
for (const [index, entry] of entries.entries()) {
|
|
448
|
+
const shown = drawn[index]!;
|
|
449
|
+
if (shown.mode === "compact") {
|
|
450
|
+
const glyph = entry.status === "success" ? undefined : formatStatusIcon(entry.status, theme);
|
|
451
|
+
lines.push(...compactRows(compactHead("Read", shortenPath(entry.path)), shown, width, glyph));
|
|
452
|
+
} else if (shown.mode === "full" && !fullDrawn) {
|
|
453
|
+
fullDrawn = true;
|
|
454
|
+
lines.push(...super.render(width));
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return lines;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
refreshTranscriptPresentation(ids?: ReadonlySet<string>): boolean {
|
|
461
|
+
const entries = [...this.#entries.values()];
|
|
462
|
+
const before = entries.map(entry => entry.presentation.resolved);
|
|
463
|
+
let changed = false;
|
|
464
|
+
for (const entry of entries) {
|
|
465
|
+
if (entry.presentation.refresh(ids)) changed = true;
|
|
466
|
+
}
|
|
467
|
+
// Rebuild the full subset even for a group not drawn yet, so its first draw is current.
|
|
468
|
+
if (changed || entries.some((entry, index) => entry.presentation.resolved !== before[index])) {
|
|
469
|
+
this.#updateDisplay();
|
|
470
|
+
}
|
|
471
|
+
if (!changed) return false;
|
|
472
|
+
this.#blockVersion++;
|
|
473
|
+
return true;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
#newEntry(toolCallId: string, displayPath: string): ReadEntry {
|
|
477
|
+
const entry: ReadEntry = {
|
|
478
|
+
toolCallId,
|
|
479
|
+
path: displayPath,
|
|
480
|
+
status: "pending",
|
|
481
|
+
presentation: new TranscriptPresentationState(
|
|
482
|
+
() =>
|
|
483
|
+
!this.#presented
|
|
484
|
+
? undefined
|
|
485
|
+
: {
|
|
486
|
+
type: "toolCall",
|
|
487
|
+
id: entry.toolCallId,
|
|
488
|
+
toolName: "read",
|
|
489
|
+
args: entry.args,
|
|
490
|
+
result: entry.result,
|
|
491
|
+
isError: entry.status === "error",
|
|
492
|
+
isPartial: entry.status === "pending",
|
|
493
|
+
},
|
|
494
|
+
() => entry.expanded,
|
|
495
|
+
this,
|
|
496
|
+
),
|
|
497
|
+
// A read joining an open group opens too: the group's own Ctrl+O, or any read the user opened.
|
|
498
|
+
expanded: this.#entries.size === 0 ? this.#expanded : [...this.#entries.values()].some(read => read.expanded),
|
|
499
|
+
};
|
|
500
|
+
return entry;
|
|
422
501
|
}
|
|
502
|
+
|
|
423
503
|
isTranscriptBlockFinalized(): boolean {
|
|
424
504
|
if (this.#sealed) return true;
|
|
425
505
|
if (!this.#finalized) return false;
|
|
@@ -430,6 +510,18 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
430
510
|
return !this.#hasPendingEntries();
|
|
431
511
|
}
|
|
432
512
|
|
|
513
|
+
/** Compact only while every read it draws is a compact row. */
|
|
514
|
+
isTranscriptBlockCompact(): boolean {
|
|
515
|
+
if (!this.#toolActivityVisible) return false;
|
|
516
|
+
let compact = false;
|
|
517
|
+
for (const entry of this.#entries.values()) {
|
|
518
|
+
const mode = entry.presentation.shown.mode;
|
|
519
|
+
if (mode === "full") return false;
|
|
520
|
+
if (mode === "compact") compact = true;
|
|
521
|
+
}
|
|
522
|
+
return compact;
|
|
523
|
+
}
|
|
524
|
+
|
|
433
525
|
#hasPendingEntries(): boolean {
|
|
434
526
|
for (const entry of this.#entries.values()) {
|
|
435
527
|
if (entry.status === "pending") return true;
|
|
@@ -462,14 +554,12 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
462
554
|
const rawPath =
|
|
463
555
|
typeof args.file_path === "string" ? args.file_path : typeof args.path === "string" ? args.path : "";
|
|
464
556
|
const displayPath = sanitizeText(rawPath);
|
|
465
|
-
const entry
|
|
466
|
-
toolCallId,
|
|
467
|
-
path: displayPath,
|
|
468
|
-
status: "pending",
|
|
469
|
-
};
|
|
557
|
+
const entry = this.#entries.get(toolCallId) ?? this.#newEntry(toolCallId, displayPath);
|
|
470
558
|
entry.path = displayPath;
|
|
471
559
|
entry.linkPath = path.isAbsolute(rawPath) ? rawPath : undefined;
|
|
472
560
|
entry.raw = args.raw === true;
|
|
561
|
+
entry.args = args;
|
|
562
|
+
entry.presentation.markStale();
|
|
473
563
|
this.#entries.set(toolCallId, entry);
|
|
474
564
|
this.#updateDisplay();
|
|
475
565
|
}
|
|
@@ -485,6 +575,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
485
575
|
const entry = this.#entries.get(oldId);
|
|
486
576
|
if (!entry || this.#entries.has(newId)) return;
|
|
487
577
|
entry.toolCallId = newId;
|
|
578
|
+
entry.presentation.markStale();
|
|
488
579
|
const reordered = [...this.#entries].map(([key, value]): [string, ReadEntry] => [
|
|
489
580
|
key === oldId ? newId : key,
|
|
490
581
|
value,
|
|
@@ -496,6 +587,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
496
587
|
/** Remove one call without discarding successful siblings in the shared group. */
|
|
497
588
|
removeEntry(toolCallId: string): boolean {
|
|
498
589
|
if (!this.#entries.delete(toolCallId)) return this.#entries.size === 0;
|
|
590
|
+
this.#spotlight.set(toolCallId, undefined, "");
|
|
499
591
|
this.#updateDisplay();
|
|
500
592
|
return this.#entries.size === 0;
|
|
501
593
|
}
|
|
@@ -510,6 +602,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
510
602
|
if (!entry) return;
|
|
511
603
|
if (isPartial) return;
|
|
512
604
|
this.#blockVersion++;
|
|
605
|
+
this.#spotlight.set(toolCallId, result.details, resultText(result));
|
|
513
606
|
// `details` can contain raw file text and filesystem paths. Keep the
|
|
514
607
|
// latter for links while only the sanitized copy supplies display labels.
|
|
515
608
|
const rawDetails = result.details as ReadToolDetails | undefined;
|
|
@@ -529,6 +622,8 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
529
622
|
typeof details?.conflictCount === "number" && details.conflictCount > 0 ? details.conflictCount : undefined;
|
|
530
623
|
entry.conflictCount = conflictCount;
|
|
531
624
|
entry.status = result.isError ? "error" : suffixResolution ? "warning" : "success";
|
|
625
|
+
entry.result = { content: result.content, details: rawDetails };
|
|
626
|
+
entry.presentation.markStale();
|
|
532
627
|
entry.contentType = details?.contentType;
|
|
533
628
|
// Store clean display content for preview/expanded display when the read
|
|
534
629
|
// tool provides it; fall back to model-facing text for legacy results.
|
|
@@ -540,6 +635,8 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
540
635
|
entry.codeLineNumbers = displayContent?.lineNumbers;
|
|
541
636
|
}
|
|
542
637
|
this.#updateDisplay();
|
|
638
|
+
// A late result can land after the group retired to scrollback, which is never drawn again.
|
|
639
|
+
entry.presentation.recheck();
|
|
543
640
|
}
|
|
544
641
|
|
|
545
642
|
/**
|
|
@@ -586,17 +683,25 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
586
683
|
}
|
|
587
684
|
|
|
588
685
|
setExpanded(expanded: boolean): void {
|
|
589
|
-
|
|
686
|
+
const entries = [...this.#entries.values()];
|
|
687
|
+
if (this.#expanded !== expanded || entries.some(entry => entry.expanded !== expanded)) this.#blockVersion++;
|
|
590
688
|
this.#expanded = expanded;
|
|
591
|
-
|
|
689
|
+
for (const entry of entries) entry.expanded = expanded;
|
|
592
690
|
this.#updateDisplay();
|
|
593
691
|
}
|
|
594
692
|
|
|
595
693
|
setToolActivityVisible(visible: boolean): void {
|
|
596
694
|
this.#toolActivityVisible = visible;
|
|
695
|
+
this.#spotlight.setHidden(!visible);
|
|
597
696
|
super.invalidate();
|
|
598
697
|
}
|
|
599
698
|
|
|
699
|
+
/** The reads' Spotlight notices, in order: blocks of their own right after the group's card. */
|
|
700
|
+
nativeTrailers(): readonly Component[] {
|
|
701
|
+
// A read a presenter hides takes its notice with it.
|
|
702
|
+
return this.#spotlight.list(id => this.#entries.get(id)?.presentation.shown.mode !== "hidden");
|
|
703
|
+
}
|
|
704
|
+
|
|
600
705
|
getComponent(): Component {
|
|
601
706
|
return this;
|
|
602
707
|
}
|
|
@@ -604,7 +709,8 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
604
709
|
/**
|
|
605
710
|
* Mirrors the terminal's toggles: the `tool` head (the group's root) is
|
|
606
711
|
* `Ctrl+O`'s expansion; a fallback preview card collapses on its own
|
|
607
|
-
* (`setExpanded` resets those).
|
|
712
|
+
* (`setExpanded` resets those). A compact read's row (`c<id>`) opens that
|
|
713
|
+
* read; the full rows beside compact ones (`full`) open and close their reads.
|
|
608
714
|
*/
|
|
609
715
|
handleNativeEvent(event: NativeUiEvent): void {
|
|
610
716
|
const expanded = rootToggleExpanded(event);
|
|
@@ -612,11 +718,34 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
612
718
|
this.setExpanded(expanded);
|
|
613
719
|
return;
|
|
614
720
|
}
|
|
615
|
-
if (event.type !== "toggle"
|
|
616
|
-
const
|
|
617
|
-
if (
|
|
618
|
-
|
|
619
|
-
|
|
721
|
+
if (event.type !== "toggle") return;
|
|
722
|
+
const key = leafKey(event.key);
|
|
723
|
+
if (key === "full") {
|
|
724
|
+
const open = !event.collapsed;
|
|
725
|
+
const reads = [...this.#entries.values()].filter(
|
|
726
|
+
entry => entry.presentation.shown.mode === "full" && entry.expanded !== open,
|
|
727
|
+
);
|
|
728
|
+
if (reads.length === 0) return;
|
|
729
|
+
for (const entry of reads) entry.expanded = open;
|
|
730
|
+
this.#blockVersion++;
|
|
731
|
+
this.#updateDisplay();
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
const opened = key.startsWith("c") ? this.#entries.get(key.slice(1)) : undefined;
|
|
735
|
+
if (opened) {
|
|
736
|
+
if (event.collapsed) return;
|
|
737
|
+
opened.expanded = true;
|
|
738
|
+
this.#blockVersion++;
|
|
739
|
+
this.#updateDisplay();
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
// `p<id>`: the fallback card's preview; `m<id>`: a Markdown preview's own card.
|
|
743
|
+
if (!key.startsWith("p") && !key.startsWith("m")) return;
|
|
744
|
+
const preview = this.#entries.get(key.slice(1));
|
|
745
|
+
if (!preview || preview.expanded === !event.collapsed) return;
|
|
746
|
+
preview.expanded = !event.collapsed;
|
|
747
|
+
this.#blockVersion++;
|
|
748
|
+
this.#updateDisplay();
|
|
620
749
|
}
|
|
621
750
|
|
|
622
751
|
/**
|
|
@@ -624,14 +753,40 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
624
753
|
* the fallback: a bare `card` (role `zeta.tool.read`) with `Read <path>` or
|
|
625
754
|
* `Read (N)` in the head, a `list` of path items (status tone, link,
|
|
626
755
|
* correction and conflict detail, nested usage) and a clamped preview per
|
|
627
|
-
* read when content previews are on.
|
|
756
|
+
* read when content previews are on. Compact reads become rows of their
|
|
757
|
+
* own (keyed `c<toolCallId>`) beside that group.
|
|
628
758
|
*/
|
|
629
759
|
override describe(cx?: DescribeContext): NativeNode {
|
|
630
760
|
const dataFirst = cx?.supports("tool") === true;
|
|
631
761
|
const key = [dataFirst, this.#displayVersion, this.#toolActivityVisible, this.#sealed];
|
|
632
|
-
return this.#native.get(key, () =>
|
|
633
|
-
|
|
634
|
-
|
|
762
|
+
return this.#native.get(key, () => {
|
|
763
|
+
const describeEntries = (entries: readonly ReadEntry[]): NativeNode =>
|
|
764
|
+
dataFirst ? this.#describeTool(entries) : this.#describeGroup(entries);
|
|
765
|
+
const entries = [...this.#entries.values()];
|
|
766
|
+
const drawn = new Map(entries.map(entry => [entry, entry.presentation.draw()]));
|
|
767
|
+
const full = entries.filter(entry => drawn.get(entry)!.mode === "full");
|
|
768
|
+
const visible = entries.filter(entry => drawn.get(entry)!.mode !== "hidden");
|
|
769
|
+
if (full.length === entries.length) return withHidden(describeEntries(full), !this.#toolActivityVisible);
|
|
770
|
+
if (visible.length === 0) return withHidden(describeEntries(entries), true);
|
|
771
|
+
const children: NativeNode[] = [];
|
|
772
|
+
let fullDrawn = false;
|
|
773
|
+
for (const entry of visible) {
|
|
774
|
+
const shown = drawn.get(entry)!;
|
|
775
|
+
if (shown.mode === "compact") {
|
|
776
|
+
const own = presentNative(describeEntries([entry]), shown, {
|
|
777
|
+
role: "zeta.tool.read",
|
|
778
|
+
title: "Read",
|
|
779
|
+
target: shortenPath(entry.path) || "…",
|
|
780
|
+
});
|
|
781
|
+
children.push(keyed(own, `c${entry.toolCallId}`));
|
|
782
|
+
} else if (!fullDrawn) {
|
|
783
|
+
fullDrawn = true;
|
|
784
|
+
children.push(keyed(describeEntries(full), "full"));
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
// Always the column: each child keeps its key, so its toggle reaches only its own reads.
|
|
788
|
+
return withHidden(col(children, { role: "zeta.tool.read" }), !this.#toolActivityVisible);
|
|
789
|
+
});
|
|
635
790
|
}
|
|
636
791
|
|
|
637
792
|
/**
|
|
@@ -641,8 +796,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
641
796
|
* (glyph, dim dir, strong name, range). Each content preview is numbered
|
|
642
797
|
* code or rendered Markdown, clamped per file while collapsed.
|
|
643
798
|
*/
|
|
644
|
-
#describeTool(): NativeNode {
|
|
645
|
-
const entries = [...this.#entries.values()];
|
|
799
|
+
#describeTool(entries: readonly ReadEntry[]): NativeNode {
|
|
646
800
|
const rows = this.#buildSummaryRows(this.#displayTargetsForEntries(entries));
|
|
647
801
|
const status = this.#groupStatus(entries);
|
|
648
802
|
const previews = entries.filter(entry => entry.status !== "error" && this.#shouldRenderPreview(entry));
|
|
@@ -701,7 +855,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
701
855
|
tone: status === "error" ? "error" : undefined,
|
|
702
856
|
frame: "inline",
|
|
703
857
|
collapsible,
|
|
704
|
-
collapsed: collapsible ? !
|
|
858
|
+
collapsed: collapsible ? !entries.some(entry => entry.expanded) : undefined,
|
|
705
859
|
preview: collapsible ? TRIMMED_BODY_PREVIEW : undefined,
|
|
706
860
|
},
|
|
707
861
|
body,
|
|
@@ -764,20 +918,23 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
764
918
|
#nativePreview(entry: ReadEntry): NativeChild[] {
|
|
765
919
|
if (previewsMarkdown(entry)) {
|
|
766
920
|
return [
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
921
|
+
keyed(
|
|
922
|
+
card(
|
|
923
|
+
{
|
|
924
|
+
variant: "bare",
|
|
925
|
+
collapsible: true,
|
|
926
|
+
collapsed: !entry.expanded,
|
|
927
|
+
preview: { lines: COLLAPSED_PREVIEW_LINES },
|
|
928
|
+
},
|
|
929
|
+
[md(entry.contentText ?? "")],
|
|
930
|
+
),
|
|
931
|
+
`m${entry.toolCallId}`,
|
|
775
932
|
),
|
|
776
933
|
];
|
|
777
934
|
}
|
|
778
935
|
const split = splitPathAndSel(entry.path);
|
|
779
936
|
const lines = (entry.contentText ?? "").split("\n");
|
|
780
|
-
const shown =
|
|
937
|
+
const shown = entry.expanded ? lines.length : Math.min(lines.length, COLLAPSED_PREVIEW_LINES);
|
|
781
938
|
const blocks: NativeChild[] = readContentCode(
|
|
782
939
|
lines.slice(0, shown).join("\n"),
|
|
783
940
|
entry.codeStartLine ?? firstSelectorLine(split.sel) ?? 1,
|
|
@@ -793,8 +950,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
793
950
|
return blocks;
|
|
794
951
|
}
|
|
795
952
|
|
|
796
|
-
#describeGroup(): NativeNode {
|
|
797
|
-
const entries = [...this.#entries.values()];
|
|
953
|
+
#describeGroup(entries: readonly ReadEntry[]): NativeNode {
|
|
798
954
|
const rows = this.#buildSummaryRows(this.#displayTargetsForEntries(entries));
|
|
799
955
|
const usageByRow = this.#usageRowsBySummaryRow(rows);
|
|
800
956
|
const previews = entries.filter(entry => this.#shouldRenderPreview(entry));
|
|
@@ -850,7 +1006,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
850
1006
|
tone: READ_STATUS_TONE[entry.status],
|
|
851
1007
|
head: pathValue ? [title, span(" "), span(pathValue, "path")] : [title],
|
|
852
1008
|
collapsible: true,
|
|
853
|
-
collapsed:
|
|
1009
|
+
collapsed: !entry.expanded,
|
|
854
1010
|
preview: { lines: COLLAPSED_PREVIEW_LINES },
|
|
855
1011
|
},
|
|
856
1012
|
[
|
|
@@ -917,7 +1073,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
917
1073
|
|
|
918
1074
|
#updateDisplay(): void {
|
|
919
1075
|
this.#displayVersion++;
|
|
920
|
-
const entries = [...this.#entries.values()];
|
|
1076
|
+
const entries = [...this.#entries.values()].filter(entry => entry.presentation.shown.mode === "full");
|
|
921
1077
|
const displayTargets = this.#displayTargetsForEntries(entries);
|
|
922
1078
|
const displayRows = this.#buildSummaryRows(displayTargets);
|
|
923
1079
|
|
|
@@ -972,7 +1128,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
972
1128
|
}
|
|
973
1129
|
}
|
|
974
1130
|
|
|
975
|
-
#displayTargetsForEntries(entries: ReadEntry[]): ReadDisplayTarget[] {
|
|
1131
|
+
#displayTargetsForEntries(entries: readonly ReadEntry[]): ReadDisplayTarget[] {
|
|
976
1132
|
const targets: ReadDisplayTarget[] = [];
|
|
977
1133
|
for (const entry of entries) {
|
|
978
1134
|
const pathSpecs: ReadDisplayPathSpec[] =
|
|
@@ -1183,6 +1339,10 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
1183
1339
|
if (filePath && options.linkPath) {
|
|
1184
1340
|
const linkOptions = options.line !== undefined ? { line: options.line } : undefined;
|
|
1185
1341
|
pathDisplay = fileHyperlink(options.linkPath, pathDisplay, linkOptions);
|
|
1342
|
+
} else if (filePath && isUrlLikePath(target.path)) {
|
|
1343
|
+
// Text mode needs the same URL fallback as the native head, or a
|
|
1344
|
+
// transcript without native rendering keeps the URL unclickable.
|
|
1345
|
+
pathDisplay = urlHyperlinkAlways(urlHref(target.path) ?? target.path, pathDisplay);
|
|
1186
1346
|
}
|
|
1187
1347
|
if (selectors) pathDisplay += theme.fg(paint.selectors, selectors);
|
|
1188
1348
|
if (options.correctedFrom) {
|
|
@@ -1221,7 +1381,7 @@ export class ReadToolGroupComponent extends Container implements ToolExecutionHa
|
|
|
1221
1381
|
cachedWidth = undefined;
|
|
1222
1382
|
cachedLines = undefined;
|
|
1223
1383
|
};
|
|
1224
|
-
const expanded =
|
|
1384
|
+
const expanded = entry.expanded;
|
|
1225
1385
|
const component: Component = {
|
|
1226
1386
|
render: (width: number) => {
|
|
1227
1387
|
if (cachedLines && cachedWidth === width) return cachedLines;
|
|
@@ -18,6 +18,7 @@ export declare class SkillMessageComponent extends Container {
|
|
|
18
18
|
#private;
|
|
19
19
|
constructor(message: CustomMessage<SkillPromptDetails>, imageLinks?: readonly (string | undefined)[]);
|
|
20
20
|
setExpanded(expanded: boolean): void;
|
|
21
|
+
isExpanded(): boolean;
|
|
21
22
|
handleNativeEvent(event: NativeUiEvent): void;
|
|
22
23
|
/**
|
|
23
24
|
* A user-toned card (role `zeta.skill`): the skill chip (linked to its
|
|
@@ -63,6 +63,10 @@ export class SkillMessageComponent extends Container {
|
|
|
63
63
|
this.#disclosure?.setExpanded(expanded);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
isExpanded(): boolean {
|
|
67
|
+
return this.#expanded;
|
|
68
|
+
}
|
|
69
|
+
|
|
66
70
|
handleNativeEvent(event: NativeUiEvent): void {
|
|
67
71
|
if (event.type === "toggle" && event.key === "prompt") this.setExpanded(!event.collapsed);
|
|
68
72
|
}
|