@linxiraos/pi-tui 1.4.11 → 1.4.13
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 +30 -233
- package/README.md +4 -1
- package/THIRD-PARTY-NOTICES.txt +4 -5
- 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/hotkeys-markdown.d.ts +2 -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/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 +9 -2
- 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 +1 -1
- package/src/overlays/settings-selector.ts +17 -3
- 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 +22 -4
- 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.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/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
|
@@ -1,7 +1,19 @@
|
|
|
1
|
+
import { RunTrace } from "@linxiraos/pi-natives";
|
|
2
|
+
import { isShellTrace, type ShellTrace, type ShellVizPreferences, type ShellVizPresentation } from "@linxiraos/pi-wire";
|
|
3
|
+
import { defaultShellVizPreferences, readShellPresentation, shellVisualization } from "../tools/shell-viz";
|
|
4
|
+
import { changeShellVizPreferences, shellVizEventAction } from "../tools/shell-trace";
|
|
5
|
+
import { ShellVisualizer } from "../apps/shell-visualizer";
|
|
6
|
+
import { chatTranscriptDisplayPreferences } from "./display-preferences";
|
|
1
7
|
import type { ImageContent } from "@linxiraos/pi-ai";
|
|
2
8
|
import type { AgentTool } from "@linxiraos/pi-agent-core";
|
|
3
9
|
import { Box } from "../components/box";
|
|
4
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
onSpinnerIntervalChange,
|
|
12
|
+
sharedSpinnerFrame,
|
|
13
|
+
spinnerAnimated,
|
|
14
|
+
spinnerInterval,
|
|
15
|
+
spinnerTickDelay,
|
|
16
|
+
} from "../spinner-clock";
|
|
5
17
|
import { Image } from "../components/image";
|
|
6
18
|
import { Spacer } from "../components/spacer";
|
|
7
19
|
import { Text } from "../components/text";
|
|
@@ -29,8 +41,8 @@ import {
|
|
|
29
41
|
type NativeUiEvent,
|
|
30
42
|
rootToggleExpanded,
|
|
31
43
|
} from "../native/node";
|
|
32
|
-
import { plainText } from "../native/spans";
|
|
33
|
-
import { diagnosticsSection, displayPath, toolHead } from "../tools/native-view";
|
|
44
|
+
import { plainLine, plainText } from "../native/spans";
|
|
45
|
+
import { diagnosticsSection, displayPath, resultText, toolHead } from "../tools/native-view";
|
|
34
46
|
import type { FileDiagnosticsResult } from "../tools/lsp";
|
|
35
47
|
import { NativeImageCache, readMediaPath, shownMedia } from "../native/blobs";
|
|
36
48
|
import { imageLinksEnabled, linkedImageText } from "../prompt/image-references";
|
|
@@ -50,9 +62,12 @@ import type { XdevMountedState } from "../tools/xdev";
|
|
|
50
62
|
import { isFramedBlockComponent, markFramedBlockComponent, renderStatusLine, WidthAwareText } from "../render/index";
|
|
51
63
|
import { cachedPngConversion, convertImageToPngShared, imagePayloadKey } from "./image-loading";
|
|
52
64
|
import { FenceFigure } from "./fence-figure";
|
|
65
|
+
import { SpotlightNotices } from "./spotlight";
|
|
53
66
|
import { sanitizeWithOptionalSixelPassthrough } from "../render/sixel";
|
|
54
67
|
import { renderDiff } from "../chrome/diff";
|
|
55
68
|
import { type AnimationFrame, trimBlankEdges } from "../chrome/transcript-container";
|
|
69
|
+
import { LateDiagnosticsMessageComponent } from "./late-diagnostics-message";
|
|
70
|
+
import { compactRows, presentNative, TranscriptPresentationState } from "./transcript-presentation";
|
|
56
71
|
|
|
57
72
|
/** Resolves the canonical renderer key while retaining the provider's wire name in message history. */
|
|
58
73
|
export function toolRenderName(wireName: string, tool: AgentTool | undefined): string {
|
|
@@ -127,7 +142,7 @@ function cardPreview(preview: NativeToolView["preview"]): TspPreview | undefined
|
|
|
127
142
|
type ToolDescriber = Pick<ToolRenderer, "describeCall" | "describeResult" | "mergeCallAndResult">;
|
|
128
143
|
|
|
129
144
|
/** Optional kinds of the host's vocabulary the describe hooks branch on. */
|
|
130
|
-
type NativeHostKinds = Required<Pick<RenderResultContextOptions, "media" | "json">>;
|
|
145
|
+
type NativeHostKinds = Required<Pick<RenderResultContextOptions, "media" | "json" | "shell">>;
|
|
131
146
|
|
|
132
147
|
class SafeToolRendererComponent implements Component {
|
|
133
148
|
#toolName: string;
|
|
@@ -214,12 +229,17 @@ export interface ToolExecutionUi {
|
|
|
214
229
|
requestComponentRender(component: Component): void;
|
|
215
230
|
resetDisplay(): void;
|
|
216
231
|
imageBudget?: TUI["imageBudget"];
|
|
232
|
+
showOverlay?: TUI["showOverlay"];
|
|
233
|
+
setFocus?: TUI["setFocus"];
|
|
234
|
+
terminal?: { readonly rows: number };
|
|
217
235
|
}
|
|
218
236
|
|
|
219
237
|
export interface ToolExecutionOptions {
|
|
220
238
|
showImages?: boolean; // default: true (only used if terminal supports images)
|
|
221
239
|
/** Allow the name-keyed renderer registry only when the active tool is the built-in implementation. */
|
|
222
240
|
useBuiltInRenderer?: boolean;
|
|
241
|
+
/** Ask the extension transcript presenters; false for a replayed transcript (overlays). Default: true. */
|
|
242
|
+
transcriptPresenters?: boolean;
|
|
223
243
|
}
|
|
224
244
|
|
|
225
245
|
/** A tool result or progress frame as a card shows it. */
|
|
@@ -242,6 +262,9 @@ export interface ToolExecutionHandle extends Component {
|
|
|
242
262
|
seal(): void;
|
|
243
263
|
}
|
|
244
264
|
|
|
265
|
+
/** {@link ToolExecutionComponent.nativeTrailers} of a hidden call without late diagnostics. */
|
|
266
|
+
const EMPTY_TRAILERS: readonly Component[] = [];
|
|
267
|
+
|
|
245
268
|
/** Tools whose returned call hands its card to the background job it started (see {@link parksAsBackground}). */
|
|
246
269
|
const JOB_CARD_TOOLS: Record<string, "always" | "native"> = { task: "always", bash: "native", eval: "native" };
|
|
247
270
|
|
|
@@ -295,26 +318,27 @@ const NATIVE_STATUS_TONE: Record<TspCardStatus, TspTone | undefined> = {
|
|
|
295
318
|
cancelled: "info",
|
|
296
319
|
};
|
|
297
320
|
|
|
298
|
-
/** Phase-locked spinner glyph index shared by every live tool block so parallel
|
|
299
|
-
* spinners advance in lockstep instead of each tracking its own start time. */
|
|
300
|
-
export function sharedSpinnerFrame(frameCount: number, now: number = performance.now()): number {
|
|
301
|
-
return frameCount > 0 ? Math.floor(now / SPINNER_ADVANCE_MS) % frameCount : 0;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
321
|
/** Live tool blocks currently driving a spinner. A single shared ticker (below)
|
|
305
322
|
* advances and repaints every registered block per glyph step, so N concurrent
|
|
306
|
-
* live/streaming blocks — e.g. parallel `task` subagents — cost one
|
|
307
|
-
* and one coalesced render frame per tick instead of N
|
|
308
|
-
* each independently waking the render scheduler
|
|
323
|
+
* live/streaming blocks — e.g. parallel `task` subagents — cost one timer at the
|
|
324
|
+
* shared spinner cadence and one coalesced render frame per tick instead of N
|
|
325
|
+
* unsynchronized timers each independently waking the render scheduler
|
|
326
|
+
* (issue #8731). The glyph index comes from `sharedSpinnerFrame`, so blocks
|
|
327
|
+
* stay in phase with every other spinner on the clock. */
|
|
309
328
|
const liveSpinnerBlocks = new Set<ToolExecutionComponent>();
|
|
310
329
|
let sharedSpinnerTimer: NodeJS.Timeout | undefined;
|
|
311
330
|
|
|
312
|
-
/**
|
|
331
|
+
/**
|
|
332
|
+
* Arm the shared ticker if it is not already running and spinners animate. Ticks land on the shared
|
|
333
|
+
* clock's boundaries, so this ticker and the working row repaint in the same frame. Each tick re-reads
|
|
334
|
+
* the period; a tick under a static spinner paints frame 0 and leaves the ticker stopped.
|
|
335
|
+
*/
|
|
313
336
|
function ensureSharedSpinnerTicker(): void {
|
|
314
|
-
if (sharedSpinnerTimer || isNativeRendering()) return;
|
|
315
|
-
sharedSpinnerTimer =
|
|
316
|
-
|
|
317
|
-
//
|
|
337
|
+
if (sharedSpinnerTimer || isNativeRendering() || !spinnerAnimated()) return;
|
|
338
|
+
sharedSpinnerTimer = setTimeout(() => {
|
|
339
|
+
sharedSpinnerTimer = undefined;
|
|
340
|
+
// A native surface opened while blocks were live: the terminal clocks their spinners, so the
|
|
341
|
+
// repaint ticker has nothing left to do — drop the live blocks and stay stopped.
|
|
318
342
|
if (isNativeRendering()) {
|
|
319
343
|
stopSharedSpinnerTicker();
|
|
320
344
|
return;
|
|
@@ -322,8 +346,13 @@ function ensureSharedSpinnerTicker(): void {
|
|
|
322
346
|
const frame = sharedSpinnerFrame(theme.spinnerFrames.length);
|
|
323
347
|
// Removing the current block mid-iteration is safe on a Set.
|
|
324
348
|
for (const block of liveSpinnerBlocks) block.tickSpinner(frame);
|
|
325
|
-
|
|
349
|
+
if (liveSpinnerBlocks.size > 0) ensureSharedSpinnerTicker();
|
|
350
|
+
}, spinnerTickDelay(spinnerInterval()));
|
|
326
351
|
}
|
|
352
|
+
// Static → animated: nothing is ticking, so restart.
|
|
353
|
+
onSpinnerIntervalChange(() => {
|
|
354
|
+
if (liveSpinnerBlocks.size > 0) ensureSharedSpinnerTicker();
|
|
355
|
+
});
|
|
327
356
|
|
|
328
357
|
/** Register a live block with the shared ticker, starting it on first use. */
|
|
329
358
|
function registerSpinnerBlock(block: ToolExecutionComponent): void {
|
|
@@ -335,24 +364,30 @@ function registerSpinnerBlock(block: ToolExecutionComponent): void {
|
|
|
335
364
|
function unregisterSpinnerBlock(block: ToolExecutionComponent): void {
|
|
336
365
|
if (!liveSpinnerBlocks.delete(block)) return;
|
|
337
366
|
if (liveSpinnerBlocks.size === 0 && sharedSpinnerTimer) {
|
|
338
|
-
|
|
367
|
+
clearTimeout(sharedSpinnerTimer);
|
|
339
368
|
sharedSpinnerTimer = undefined;
|
|
340
369
|
}
|
|
341
370
|
}
|
|
342
371
|
|
|
343
372
|
/** Stop the shared spinner ticker and drop every registered live block.
|
|
344
373
|
* Called on interactive-mode teardown so a stray live block cannot keep the
|
|
345
|
-
* process-wide
|
|
374
|
+
* process-wide spinner timer alive past shutdown (lingering event-loop
|
|
346
375
|
* handles pin the process; cf. `postmortem.quit`). Test files that assert on
|
|
347
376
|
* ticker arming also use this to start from a clean slate. */
|
|
348
377
|
export function stopSharedSpinnerTicker(): void {
|
|
349
378
|
liveSpinnerBlocks.clear();
|
|
350
379
|
if (sharedSpinnerTimer) {
|
|
351
|
-
|
|
380
|
+
clearTimeout(sharedSpinnerTimer);
|
|
352
381
|
sharedSpinnerTimer = undefined;
|
|
353
382
|
}
|
|
354
383
|
}
|
|
355
384
|
|
|
385
|
+
/** Whether the shared spinner ticker has a tick armed. Test seam: other timers on a fake clock
|
|
386
|
+
* (collab relay heartbeats) make a raw timer count ambiguous. */
|
|
387
|
+
export function sharedSpinnerTickerArmed(): boolean {
|
|
388
|
+
return sharedSpinnerTimer !== undefined;
|
|
389
|
+
}
|
|
390
|
+
|
|
356
391
|
// Stable per-instance counter so each tool execution's inline images get a
|
|
357
392
|
// graphics id that survives child re-creation (the image budget keys off it).
|
|
358
393
|
let toolExecutionInstanceSeq = 0;
|
|
@@ -361,6 +396,19 @@ let toolExecutionInstanceSeq = 0;
|
|
|
361
396
|
* Component that renders a tool call with its result (updateable)
|
|
362
397
|
*/
|
|
363
398
|
export class ToolExecutionComponent extends Container {
|
|
399
|
+
#shellPreferences: ShellVizPreferences = defaultShellVizPreferences();
|
|
400
|
+
#shellPendingTrace: RunTrace | undefined;
|
|
401
|
+
#shellPendingScript: string | undefined;
|
|
402
|
+
#shellPresentation: ShellVizPresentation | undefined;
|
|
403
|
+
#shellPresentationKey: string | undefined;
|
|
404
|
+
#shellTrace: ShellTrace | undefined;
|
|
405
|
+
#shellTraceDetails: unknown;
|
|
406
|
+
#shellReplayTimer: NodeJS.Timeout | undefined;
|
|
407
|
+
#shellReplayAt = 0;
|
|
408
|
+
#shellReplayNs = 0;
|
|
409
|
+
#shellReplayPositioned = false;
|
|
410
|
+
#shellReplayEpoch = 0;
|
|
411
|
+
#shellInspector: { hide(): void } | undefined;
|
|
364
412
|
#contentBox: Box; // Used for custom tools and bash visual truncation
|
|
365
413
|
#contentText: WidthAwareText; // Generic fallback (no custom/built-in renderer)
|
|
366
414
|
// Which container the constructor mounted: bespoke/built-in renderers use
|
|
@@ -458,11 +506,36 @@ export class ToolExecutionComponent extends Container {
|
|
|
458
506
|
#executionStartedAtNow: number | undefined;
|
|
459
507
|
// When the call settled (final result or seal), same clock; freezes the native elapsed timer.
|
|
460
508
|
#executionEndedAtNow: number | undefined;
|
|
461
|
-
|
|
509
|
+
#toolCallId: string | undefined;
|
|
462
510
|
readonly #native = new Memo();
|
|
463
511
|
// LSP diagnostics that arrived after the result (native only), shown in the frame.
|
|
464
512
|
#lateDiagnostics: readonly FileDiagnosticsResult[] | undefined;
|
|
513
|
+
/** The standalone block showing {@link #lateDiagnostics} while the card is not drawn in full. */
|
|
514
|
+
#lateDiagnosticsBlock:
|
|
515
|
+
| { files: readonly FileDiagnosticsResult[]; block: LateDiagnosticsMessageComponent }
|
|
516
|
+
| undefined;
|
|
517
|
+
/** Whether presenters draw this card (not a replayed transcript). */
|
|
518
|
+
#presented = true;
|
|
519
|
+
/** What the presenters chose; an expanded card always draws in full. */
|
|
520
|
+
readonly #presentation = new TranscriptPresentationState(
|
|
521
|
+
() =>
|
|
522
|
+
this.#presented
|
|
523
|
+
? {
|
|
524
|
+
type: "toolCall",
|
|
525
|
+
id: this.#toolCallId ?? "",
|
|
526
|
+
toolName: this.#toolName,
|
|
527
|
+
args: this.#args,
|
|
528
|
+
result: this.#result ? { content: this.#result.content, details: this.#rawDetails } : undefined,
|
|
529
|
+
isError: this.#result?.isError === true,
|
|
530
|
+
isPartial: this.#result === undefined || this.#isPartial,
|
|
531
|
+
}
|
|
532
|
+
: undefined,
|
|
533
|
+
() => this.#expanded,
|
|
534
|
+
this,
|
|
535
|
+
);
|
|
465
536
|
readonly #nativeImages = new NativeImageCache();
|
|
537
|
+
// The Spotlight notice drawn after the card in a native transcript (see nativeTrailers).
|
|
538
|
+
readonly #spotlight = new SpotlightNotices();
|
|
466
539
|
// Wall clock captured whenever a task card is rebuilt.
|
|
467
540
|
#taskRenderNowMs = Date.now();
|
|
468
541
|
// Set on each `render()` when the last painted pending shape must be
|
|
@@ -478,6 +551,9 @@ export class ToolExecutionComponent extends Container {
|
|
|
478
551
|
argsComplete?: boolean;
|
|
479
552
|
executionStarted?: boolean;
|
|
480
553
|
renderContext?: Record<string, unknown>;
|
|
554
|
+
shellPresentation?: ShellVizPresentation;
|
|
555
|
+
shellTrace?: ShellTrace;
|
|
556
|
+
shellReplayEpoch?: number;
|
|
481
557
|
/** Live: read at render time, so a ticking spinner advances it. */
|
|
482
558
|
readonly elapsedMs?: number;
|
|
483
559
|
} = {
|
|
@@ -507,6 +583,7 @@ export class ToolExecutionComponent extends Container {
|
|
|
507
583
|
this.#toolLabel = tool?.label ?? toolName;
|
|
508
584
|
this.#renderer = options.useBuiltInRenderer === false ? undefined : toolRenderers[toolName];
|
|
509
585
|
this.#showImages = options.showImages ?? true;
|
|
586
|
+
this.#presented = options.transcriptPresenters ?? true;
|
|
510
587
|
this.#tool = tool;
|
|
511
588
|
this.#ui = ui;
|
|
512
589
|
this.#args = args;
|
|
@@ -537,6 +614,148 @@ export class ToolExecutionComponent extends Container {
|
|
|
537
614
|
this.#updateDisplay();
|
|
538
615
|
}
|
|
539
616
|
|
|
617
|
+
#updateShellTrace(details: unknown): void {
|
|
618
|
+
if (this.#toolName !== "bash" || details === this.#shellTraceDetails) return;
|
|
619
|
+
this.#shellTraceDetails = details;
|
|
620
|
+
const candidate = isRecord(details) ? details.trace : undefined;
|
|
621
|
+
if (candidate === undefined || candidate === this.#shellTrace) return;
|
|
622
|
+
const next = isShellTrace(candidate) ? candidate : undefined;
|
|
623
|
+
const old = this.#shellTrace;
|
|
624
|
+
if (old === next) return;
|
|
625
|
+
if (this.#shellPreferences.cursor !== undefined) {
|
|
626
|
+
const applied = old?.history?.[this.#shellPreferences.cursor - 1]?.seq;
|
|
627
|
+
const records = next?.history ?? [];
|
|
628
|
+
this.#shellPreferences = {
|
|
629
|
+
...this.#shellPreferences,
|
|
630
|
+
cursor:
|
|
631
|
+
applied === undefined
|
|
632
|
+
? Math.min(this.#shellPreferences.cursor, records.length)
|
|
633
|
+
: records.filter(record => record.seq <= applied).length,
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
this.#shellTrace = next;
|
|
637
|
+
if (next?.historyTruncated && this.#shellPreferences.cursor === 0 && this.#shellReplayPositioned) {
|
|
638
|
+
this.#shellReplayNs = Math.max(this.#shellReplayNs, next.history?.[0]?.t_ns ?? 0);
|
|
639
|
+
}
|
|
640
|
+
this.#shellPresentationKey = undefined;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
#getShellPresentation(): ShellVizPresentation | undefined {
|
|
644
|
+
if (this.#toolName !== "bash" || !chatTranscriptDisplayPreferences.shellVisualization) return undefined;
|
|
645
|
+
const script =
|
|
646
|
+
this.#shellTrace?.script ??
|
|
647
|
+
(isRecord(this.#args) && typeof this.#args.command === "string" ? this.#args.command : undefined);
|
|
648
|
+
if (!script) return undefined;
|
|
649
|
+
if (script !== this.#shellPendingScript) {
|
|
650
|
+
this.#shellPendingTrace = undefined;
|
|
651
|
+
this.#shellPendingScript = script;
|
|
652
|
+
this.#shellPresentationKey = undefined;
|
|
653
|
+
}
|
|
654
|
+
const key = `${this.#resultVersion}|${this.#displayInputVersion}`;
|
|
655
|
+
if (this.#shellPresentation && key === this.#shellPresentationKey) return this.#shellPresentation;
|
|
656
|
+
const source = this.#shellTrace
|
|
657
|
+
? shellVisualization(this.#shellTrace)
|
|
658
|
+
: (this.#shellPendingTrace ??= new RunTrace(script));
|
|
659
|
+
this.#shellPresentation = readShellPresentation(
|
|
660
|
+
source,
|
|
661
|
+
this.#shellPreferences,
|
|
662
|
+
this.#shellTrace,
|
|
663
|
+
this.#result ? resultText(this.#result) : undefined,
|
|
664
|
+
);
|
|
665
|
+
this.#shellPresentationKey = key;
|
|
666
|
+
return this.#shellPresentation;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
#shellChanged(): void {
|
|
670
|
+
this.#shellPresentationKey = undefined;
|
|
671
|
+
this.#displayInputVersion++;
|
|
672
|
+
this.#blockVersion++;
|
|
673
|
+
this.#updateDisplay();
|
|
674
|
+
this.#ui.requestRender();
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
#stopShellReplay(): void {
|
|
678
|
+
clearInterval(this.#shellReplayTimer);
|
|
679
|
+
this.#shellReplayTimer = undefined;
|
|
680
|
+
this.#shellPreferences = { ...this.#shellPreferences, playing: false };
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/** Handle exactly the shared native action vocabulary; inspector uses this same controller. */
|
|
684
|
+
shellVizAction(action: string): void {
|
|
685
|
+
if (this.#toolName !== "bash" || !chatTranscriptDisplayPreferences.shellVisualization) return;
|
|
686
|
+
if (action === "inspect") {
|
|
687
|
+
this.openShellVisualizer();
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
const before = this.#shellPreferences;
|
|
691
|
+
const wasPlaying = before.playing;
|
|
692
|
+
const history = this.#shellTrace?.history ?? [];
|
|
693
|
+
const now = performance.now();
|
|
694
|
+
if (wasPlaying) this.#shellReplayNs += (now - this.#shellReplayAt) * 1_000_000 * before.speed;
|
|
695
|
+
this.#shellPreferences = changeShellVizPreferences(before, action, history.length);
|
|
696
|
+
const seeking = action === "reset" || action === "step" || /^seek:[0-9]+$/.test(action);
|
|
697
|
+
const restarting = action === "play" && (before.cursor === undefined || before.cursor >= history.length);
|
|
698
|
+
if (action === "reset" || action === "live" || /^seek:[0-9]+$/.test(action) || restarting)
|
|
699
|
+
this.#shellReplayEpoch++;
|
|
700
|
+
if (action === "live") this.#shellReplayPositioned = false;
|
|
701
|
+
else if (seeking || restarting || (!this.#shellReplayPositioned && this.#shellPreferences.playing)) {
|
|
702
|
+
const cursor = this.#shellPreferences.cursor ?? 0;
|
|
703
|
+
this.#shellReplayNs =
|
|
704
|
+
history[cursor - 1]?.t_ns ?? (this.#shellTrace?.historyTruncated ? (history[0]?.t_ns ?? 0) : 0);
|
|
705
|
+
this.#shellReplayPositioned = true;
|
|
706
|
+
}
|
|
707
|
+
if (this.#shellPreferences.playing) {
|
|
708
|
+
this.#shellReplayAt = now;
|
|
709
|
+
if (!this.#shellReplayTimer) {
|
|
710
|
+
this.#shellReplayTimer = setInterval(() => {
|
|
711
|
+
const history = this.#shellTrace?.history ?? [];
|
|
712
|
+
const now = performance.now();
|
|
713
|
+
this.#shellReplayNs += (now - this.#shellReplayAt) * 1_000_000 * this.#shellPreferences.speed;
|
|
714
|
+
this.#shellReplayAt = now;
|
|
715
|
+
let cursor = this.#shellPreferences.cursor ?? 0;
|
|
716
|
+
while (cursor < history.length && history[cursor].t_ns <= this.#shellReplayNs) cursor++;
|
|
717
|
+
if (cursor === history.length) this.#stopShellReplay();
|
|
718
|
+
if (cursor !== this.#shellPreferences.cursor || !this.#shellPreferences.playing) {
|
|
719
|
+
this.#shellPreferences = { ...this.#shellPreferences, cursor };
|
|
720
|
+
this.#shellChanged();
|
|
721
|
+
}
|
|
722
|
+
}, 80);
|
|
723
|
+
this.#shellReplayTimer.unref();
|
|
724
|
+
}
|
|
725
|
+
} else this.#stopShellReplay();
|
|
726
|
+
this.#shellChanged();
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/** Open the focused inspector without intercepting composer input while it is closed. */
|
|
730
|
+
openShellVisualizer(): void {
|
|
731
|
+
if (this.#toolName !== "bash" || !chatTranscriptDisplayPreferences.shellVisualization || !this.#ui.showOverlay)
|
|
732
|
+
return;
|
|
733
|
+
if (this.#shellInspector) return;
|
|
734
|
+
const inspector = new ShellVisualizer({
|
|
735
|
+
presentation: () => this.#getShellPresentation(),
|
|
736
|
+
replayEpoch: () => this.#shellReplayEpoch,
|
|
737
|
+
liveOrigin: () => this.#executionStarted,
|
|
738
|
+
action: action => this.shellVizAction(action),
|
|
739
|
+
close: () => {
|
|
740
|
+
this.#stopShellReplay();
|
|
741
|
+
this.#shellInspector?.hide();
|
|
742
|
+
this.#shellInspector = undefined;
|
|
743
|
+
this.#shellChanged();
|
|
744
|
+
},
|
|
745
|
+
requestRender: () => this.#ui.requestRender(),
|
|
746
|
+
height: () => this.#ui.terminal?.rows ?? 24,
|
|
747
|
+
});
|
|
748
|
+
this.#shellInspector = this.#ui.showOverlay(inspector, {
|
|
749
|
+
anchor: "top-left",
|
|
750
|
+
width: "100%",
|
|
751
|
+
maxHeight: "100%",
|
|
752
|
+
fullscreen: true,
|
|
753
|
+
margin: 0,
|
|
754
|
+
});
|
|
755
|
+
this.#ui.setFocus?.(inspector);
|
|
756
|
+
this.#ui.requestRender();
|
|
757
|
+
}
|
|
758
|
+
|
|
540
759
|
updateArgs(args: unknown, _toolCallId?: string): void {
|
|
541
760
|
// Reference-equality short-circuit before any further work. Callers
|
|
542
761
|
// always allocate a new arg object on each streamed delta (see
|
|
@@ -544,6 +763,7 @@ export class ToolExecutionComponent extends Container {
|
|
|
544
763
|
// signals "nothing meaningful changed" and the renderer can skip.
|
|
545
764
|
if (args === this.#args) return;
|
|
546
765
|
this.#args = args;
|
|
766
|
+
this.#presentation.markStale();
|
|
547
767
|
this.#displayInputVersion++;
|
|
548
768
|
this.#updateSpinnerAnimation();
|
|
549
769
|
this.#updateDisplay();
|
|
@@ -645,6 +865,7 @@ export class ToolExecutionComponent extends Container {
|
|
|
645
865
|
this.#firstResultViewportRepaintShapePainted = false;
|
|
646
866
|
this.#partialResultShapePainted = false;
|
|
647
867
|
this.#rawDetails = result.details;
|
|
868
|
+
this.#updateShellTrace(result.details);
|
|
648
869
|
// Renderers receive sanitized details for display; raw paths are available
|
|
649
870
|
// separately for links and media through the built-in render context.
|
|
650
871
|
const details = sanitizeTextDeep(result.details);
|
|
@@ -652,7 +873,13 @@ export class ToolExecutionComponent extends Container {
|
|
|
652
873
|
this.#resultVersion++;
|
|
653
874
|
this.#blockVersion++;
|
|
654
875
|
this.#isPartial = isPartial;
|
|
876
|
+
this.#presentation.markStale();
|
|
877
|
+
// A final frame can land after the card retired to scrollback, which is never drawn again.
|
|
878
|
+
if (!isPartial) this.#presentation.recheck();
|
|
655
879
|
this.#displaceableByToolName = displaceableToolName(this.#toolName, result, isPartial);
|
|
880
|
+
if (!isPartial && this.#toolCallId !== undefined) {
|
|
881
|
+
this.#spotlight.set(this.#toolCallId, result.details, resultText(result));
|
|
882
|
+
}
|
|
656
883
|
// When tool is complete, ensure args are marked complete so spinner stops
|
|
657
884
|
if (!isPartial) {
|
|
658
885
|
this.#argsComplete = true;
|
|
@@ -866,6 +1093,7 @@ export class ToolExecutionComponent extends Container {
|
|
|
866
1093
|
isTranscriptBlockPending(): boolean {
|
|
867
1094
|
return (
|
|
868
1095
|
this.#toolActivityVisible &&
|
|
1096
|
+
this.#presentation.shown.mode === "full" &&
|
|
869
1097
|
((this.#showImages && this.#kittyConversionsAwaited.size > 0) || this.#figure?.pending === true)
|
|
870
1098
|
);
|
|
871
1099
|
}
|
|
@@ -942,6 +1170,9 @@ export class ToolExecutionComponent extends Container {
|
|
|
942
1170
|
* interval alive and keep being repainted.
|
|
943
1171
|
*/
|
|
944
1172
|
override dispose(): void {
|
|
1173
|
+
this.#stopShellReplay();
|
|
1174
|
+
this.#shellInspector?.hide();
|
|
1175
|
+
this.#shellInspector = undefined;
|
|
945
1176
|
this.stopAnimation();
|
|
946
1177
|
super.dispose();
|
|
947
1178
|
}
|
|
@@ -969,10 +1200,60 @@ export class ToolExecutionComponent extends Container {
|
|
|
969
1200
|
|
|
970
1201
|
/** Mirrors the card collapsed or expanded in the terminal, so `Ctrl+O` and native toggles share one state. */
|
|
971
1202
|
handleNativeEvent(event: NativeUiEvent): void {
|
|
1203
|
+
if (this.#toolName === "bash" && chatTranscriptDisplayPreferences.shellVisualization) {
|
|
1204
|
+
const action = shellVizEventAction(event, this.#shellPreferences);
|
|
1205
|
+
if (action) {
|
|
1206
|
+
this.shellVizAction(action);
|
|
1207
|
+
return;
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
972
1210
|
const expanded = rootToggleExpanded(event);
|
|
973
1211
|
if (expanded !== undefined) this.setExpanded(expanded);
|
|
974
1212
|
}
|
|
975
1213
|
|
|
1214
|
+
/**
|
|
1215
|
+
* Blocks of their own right after the card: the result's Spotlight notice (visible while it is
|
|
1216
|
+
* collapsed), and late diagnostics the card absorbed while a presenter compacts or hides it, so
|
|
1217
|
+
* they stay visible.
|
|
1218
|
+
*/
|
|
1219
|
+
nativeTrailers(): readonly Component[] {
|
|
1220
|
+
const mode = this.#presentation.shown.mode;
|
|
1221
|
+
const late = this.#lateDiagnostics;
|
|
1222
|
+
// Drawn in full, the card shows its diagnostics itself: the notices' own (stable) list.
|
|
1223
|
+
if (mode === "full" || late === undefined) return mode === "hidden" ? EMPTY_TRAILERS : this.#spotlight.list();
|
|
1224
|
+
if (this.#lateDiagnosticsBlock?.files !== late) {
|
|
1225
|
+
this.#lateDiagnosticsBlock = { files: late, block: new LateDiagnosticsMessageComponent([...late]) };
|
|
1226
|
+
}
|
|
1227
|
+
const diagnostics = this.#lateDiagnosticsBlock.block;
|
|
1228
|
+
// Not a transcript child: the transcript-wide visibility reaches it only through this card.
|
|
1229
|
+
diagnostics.setToolActivityVisible(this.#toolActivityVisible);
|
|
1230
|
+
// A call a presenter hides takes its notice with it.
|
|
1231
|
+
return mode === "hidden" ? [diagnostics] : [...this.#spotlight.list(), diagnostics];
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
refreshTranscriptPresentation(ids?: ReadonlySet<string>): boolean {
|
|
1235
|
+
if (!this.#presentation.refresh(ids)) return false;
|
|
1236
|
+
this.#blockVersion++;
|
|
1237
|
+
super.invalidate();
|
|
1238
|
+
return true;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
/** The streamed call's id changed (or an empty one was filled in): presenters see, and refresh by, the new one. */
|
|
1242
|
+
renameToolCallId(toolCallId: string): void {
|
|
1243
|
+
if (toolCallId === this.#toolCallId) return;
|
|
1244
|
+
this.#toolCallId = toolCallId;
|
|
1245
|
+
this.#presentation.markStale();
|
|
1246
|
+
this.#blockVersion++;
|
|
1247
|
+
super.invalidate();
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
isTranscriptBlockCompact(): boolean {
|
|
1251
|
+
if (!this.#toolActivityVisible || this.#allocation === 0 || (this.#toolName === "wait" && this.#isBenignSkip())) {
|
|
1252
|
+
return false;
|
|
1253
|
+
}
|
|
1254
|
+
return this.#presentation.shown.mode === "compact";
|
|
1255
|
+
}
|
|
1256
|
+
|
|
976
1257
|
/** The file paths this call targets (edit/write/apply_patch args), display-relative. */
|
|
977
1258
|
#targetPaths(): string[] {
|
|
978
1259
|
const args = this.#args;
|
|
@@ -1019,15 +1300,21 @@ export class ToolExecutionComponent extends Container {
|
|
|
1019
1300
|
* `elapsed` timer in the head and terminal-local collapse clamped to the
|
|
1020
1301
|
* view's preview. Renderers without describe hooks (and extension tools
|
|
1021
1302
|
* with only render hooks) get the generic card. Hidden tool activity stays
|
|
1022
|
-
* mounted so toggling it is one prop change.
|
|
1303
|
+
* mounted so toggling it is one prop change; a presenter's answer applies on top.
|
|
1023
1304
|
*/
|
|
1024
1305
|
override describe(cx?: DescribeContext): NativeNode {
|
|
1025
1306
|
if (this.#toolName === "wait" && this.#isBenignSkip()) return EMPTY_NODE;
|
|
1026
1307
|
const dataFirst = cx?.supports("tool") === true;
|
|
1027
|
-
const host: NativeHostKinds = {
|
|
1308
|
+
const host: NativeHostKinds = {
|
|
1309
|
+
media: cx?.supports("media") === true,
|
|
1310
|
+
json: cx?.supports("json") === true,
|
|
1311
|
+
shell: cx?.supports("shell") === true,
|
|
1312
|
+
};
|
|
1313
|
+
const presentation = this.#presentation.draw();
|
|
1028
1314
|
const key = [
|
|
1029
1315
|
dataFirst,
|
|
1030
1316
|
this.#resultVersion,
|
|
1317
|
+
this.#toolCallId,
|
|
1031
1318
|
this.#expanded,
|
|
1032
1319
|
this.#isPartial,
|
|
1033
1320
|
this.#argsComplete,
|
|
@@ -1035,15 +1322,24 @@ export class ToolExecutionComponent extends Container {
|
|
|
1035
1322
|
this.#sealed,
|
|
1036
1323
|
this.#parkedBackground,
|
|
1037
1324
|
this.#showImages,
|
|
1325
|
+
this.#toolName === "bash" && chatTranscriptDisplayPreferences.shellVisualization,
|
|
1038
1326
|
this.#displayInputVersion,
|
|
1039
1327
|
this.#toolActivityVisible,
|
|
1040
1328
|
host.media,
|
|
1041
1329
|
host.json,
|
|
1330
|
+
host.shell,
|
|
1042
1331
|
getThemeEpoch(),
|
|
1332
|
+
presentation,
|
|
1043
1333
|
];
|
|
1044
|
-
return this.#native.get(key, () =>
|
|
1045
|
-
|
|
1046
|
-
|
|
1334
|
+
return this.#native.get(key, () => {
|
|
1335
|
+
const full = dataFirst ? this.#describeTool(host) : this.#describeCard(host);
|
|
1336
|
+
const shown = presentNative(full, presentation, {
|
|
1337
|
+
role: `zeta.tool.${this.#toolName}`,
|
|
1338
|
+
title: this.#toolLabel,
|
|
1339
|
+
target: this.#activitySummary().detail,
|
|
1340
|
+
});
|
|
1341
|
+
return withHidden(shown, !this.#toolActivityVisible);
|
|
1342
|
+
});
|
|
1047
1343
|
}
|
|
1048
1344
|
|
|
1049
1345
|
/** Milliseconds since execution started (running) or its total (settled); undefined before it starts. */
|
|
@@ -1224,6 +1520,9 @@ export class ToolExecutionComponent extends Container {
|
|
|
1224
1520
|
elapsedMs: this.#elapsedMs(status),
|
|
1225
1521
|
cancelled: status === "cancelled",
|
|
1226
1522
|
renderContext: this.#buildRenderContext(),
|
|
1523
|
+
shellPresentation: this.#getShellPresentation(),
|
|
1524
|
+
shellTrace: this.#shellTrace,
|
|
1525
|
+
shellReplayEpoch: this.#shellReplayEpoch,
|
|
1227
1526
|
};
|
|
1228
1527
|
// Custom tools (MCP, extensions) carry their own describe hooks, mirroring
|
|
1229
1528
|
// the ANSI path's preference for the tool's renderCall/renderResult.
|
|
@@ -1318,6 +1617,8 @@ export class ToolExecutionComponent extends Container {
|
|
|
1318
1617
|
|
|
1319
1618
|
setToolActivityVisible(visible: boolean): void {
|
|
1320
1619
|
this.#toolActivityVisible = visible;
|
|
1620
|
+
this.#spotlight.setHidden(!visible);
|
|
1621
|
+
this.#lateDiagnosticsBlock?.block.setToolActivityVisible(visible);
|
|
1321
1622
|
super.invalidate();
|
|
1322
1623
|
}
|
|
1323
1624
|
|
|
@@ -1336,7 +1637,7 @@ export class ToolExecutionComponent extends Container {
|
|
|
1336
1637
|
// TUI startup, so a result rendered before it lands must re-shape once it
|
|
1337
1638
|
// does (it gates Image children vs text fallback in #rebuildDisplay); keyed
|
|
1338
1639
|
// here for the same reason markdown.ts keys its render cache on it.
|
|
1339
|
-
const key = `${this.#resultVersion}|${this.#expanded}|${this.#isPartial}|${this.#argsComplete ? "1" : "0"}|${this.#executionStarted ? "1" : "0"}|${this.#spinnerFrame ?? "-"}|${this.#showImages}|${getThemeEpoch()}|${this.#displayInputVersion}|${TERMINAL.imageProtocol ?? "-"}|${this.#imageSizeKey()}|${imageLinksEnabled()}`;
|
|
1640
|
+
const key = `${this.#resultVersion}|${this.#expanded}|${this.#isPartial}|${this.#argsComplete ? "1" : "0"}|${this.#executionStarted ? "1" : "0"}|${this.#spinnerFrame ?? "-"}|${this.#showImages}|${getThemeEpoch()}|${this.#displayInputVersion}|${TERMINAL.imageProtocol ?? "-"}|${this.#imageSizeKey()}|${imageLinksEnabled()}|${this.#toolName === "bash" && chatTranscriptDisplayPreferences.shellVisualization}`;
|
|
1340
1641
|
if (key === this.#lastDisplayKey && this.#displayBuilt) return;
|
|
1341
1642
|
this.#lastDisplayKey = key;
|
|
1342
1643
|
|
|
@@ -1382,6 +1683,15 @@ export class ToolExecutionComponent extends Container {
|
|
|
1382
1683
|
if (!this.#toolActivityVisible || this.#allocation === 0 || (this.#toolName === "wait" && this.#isBenignSkip())) {
|
|
1383
1684
|
return [];
|
|
1384
1685
|
}
|
|
1686
|
+
const presentation = this.#presentation.draw();
|
|
1687
|
+
if (presentation.mode === "hidden") return [];
|
|
1688
|
+
if (presentation.mode === "compact") {
|
|
1689
|
+
// A squeezed allocation keeps the head (identity, spinner) and as many rows as fit.
|
|
1690
|
+
return compactRows(this.#compactText(width), presentation, width, this.#compactGlyph()).slice(
|
|
1691
|
+
0,
|
|
1692
|
+
this.#allocation,
|
|
1693
|
+
);
|
|
1694
|
+
}
|
|
1385
1695
|
let lines = super.render(width);
|
|
1386
1696
|
if (this.#allocation < 3) {
|
|
1387
1697
|
// A squeezed allocation degrades only blocks that genuinely overflow it.
|
|
@@ -1398,9 +1708,12 @@ export class ToolExecutionComponent extends Container {
|
|
|
1398
1708
|
return lines;
|
|
1399
1709
|
}
|
|
1400
1710
|
|
|
1401
|
-
|
|
1711
|
+
/** The one-row summary: bold label, muted detail, and the elapsed seconds of a running call. */
|
|
1712
|
+
#compactText(width: number): string {
|
|
1402
1713
|
const summary = this.#activitySummary();
|
|
1403
|
-
|
|
1714
|
+
// Raw call input (a bash command): stripped of ANSI and control characters before theming.
|
|
1715
|
+
const shownDetail = summary.detail ? plainLine(summary.detail) : "";
|
|
1716
|
+
const detail = shownDetail ? theme.fg("muted", ` · ${shownDetail}`) : "";
|
|
1404
1717
|
// Elapsed ticks only while the call is genuinely running; a settled
|
|
1405
1718
|
// placeholder row must not read as live ("Todo · running 0s").
|
|
1406
1719
|
const elapsed =
|
|
@@ -1410,15 +1723,21 @@ export class ToolExecutionComponent extends Container {
|
|
|
1410
1723
|
` ${Math.max(0, Math.floor((this.#presentationFrame.now - this.#executionStartedAtNow) / 1000))}s`,
|
|
1411
1724
|
)
|
|
1412
1725
|
: "";
|
|
1413
|
-
|
|
1414
|
-
`${theme.fg("toolTitle", theme.bold(summary.label))}${detail}${elapsed}`,
|
|
1726
|
+
return truncateToWidth(
|
|
1727
|
+
`${theme.fg("toolTitle", theme.bold(plainLine(summary.label)))}${detail}${elapsed}`,
|
|
1415
1728
|
Math.max(1, width - 4),
|
|
1416
1729
|
);
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
/** The one-row form's lead glyph: the spinner while it animates, else a dim bullet. */
|
|
1733
|
+
#compactGlyph(): string {
|
|
1734
|
+
const glyph = this.#spinnerFrame === undefined ? "•" : (theme.spinnerFrames[this.#spinnerFrame] ?? "•");
|
|
1735
|
+
return theme.fg(this.#spinnerFrame === undefined ? "dim" : "muted", glyph);
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
#renderCompact(width: number): readonly string[] {
|
|
1739
|
+
const text = this.#compactText(width);
|
|
1740
|
+
if (this.#allocation === 1) return [truncateToWidth(`${this.#compactGlyph()} ${text}`, width)];
|
|
1422
1741
|
return [truncateToWidth(`${theme.fg("dim", "╭─")} ${text}`, width), theme.fg("dim", "╰")];
|
|
1423
1742
|
}
|
|
1424
1743
|
|
|
@@ -1862,6 +2181,9 @@ export class ToolExecutionComponent extends Container {
|
|
|
1862
2181
|
context.rawDetails = this.#rawDetails;
|
|
1863
2182
|
}
|
|
1864
2183
|
if (this.#toolName === "bash") {
|
|
2184
|
+
this.#renderState.shellPresentation = this.#getShellPresentation();
|
|
2185
|
+
this.#renderState.shellTrace = this.#shellTrace;
|
|
2186
|
+
this.#renderState.shellReplayEpoch = this.#shellReplayEpoch;
|
|
1865
2187
|
// Bash needs render context even before a result exists. The renderer uses the pending-call args
|
|
1866
2188
|
// plus this context to keep the inline command preview visible while tool-call JSON is still streaming.
|
|
1867
2189
|
if (this.#result) {
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* the interactive host registers the one handler that runs omp's existing
|
|
5
5
|
* commands for them, so a click and the key binding take the same path.
|
|
6
6
|
*/
|
|
7
|
+
import type { SpotlightDetails } from "./spotlight";
|
|
7
8
|
export type TranscriptAction =
|
|
8
9
|
/** Retry the last failed turn (`app.retry`). */
|
|
9
10
|
{
|
|
@@ -26,6 +27,16 @@ export type TranscriptAction =
|
|
|
26
27
|
| {
|
|
27
28
|
readonly act: "copy";
|
|
28
29
|
readonly text: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Open the Spotlight sheet of a shaped tool result: its original beside `reduced`, the text the model saw (a
|
|
33
|
+
* held-out result's sheet shows the would-be text its trace's `shapedUrl` names instead).
|
|
34
|
+
*/
|
|
35
|
+
| {
|
|
36
|
+
readonly act: "spotlight";
|
|
37
|
+
readonly toolCallId: string;
|
|
38
|
+
readonly spotlight: SpotlightDetails;
|
|
39
|
+
readonly reduced: string;
|
|
29
40
|
};
|
|
30
41
|
type Handler = (action: TranscriptAction) => void;
|
|
31
42
|
/** Register (or clear, with `undefined`) the host's handler. */
|