@linxiraos/pi-tui 1.4.6 → 1.4.7
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 +194 -195
- package/README.md +34 -34
- package/dist/types/app-keybindings.d.ts +15 -0
- package/dist/types/apps/session-picker.d.ts +5 -0
- package/dist/types/charts/chart-plan.d.ts +9 -7
- package/dist/types/chat/assistant-message.d.ts +15 -3
- package/dist/types/chat/bash-execution.d.ts +2 -0
- package/dist/types/chat/display-preferences.d.ts +2 -0
- package/dist/types/chat/extension-types.d.ts +31 -0
- package/dist/types/chat/reply-write.d.ts +48 -0
- package/dist/types/chat/table-chart.d.ts +4 -3
- package/dist/types/chat/tool-execution.d.ts +1 -2
- package/dist/types/chat/transcript-outline.d.ts +7 -0
- package/dist/types/chat/transcript-render-helpers.d.ts +2 -0
- package/dist/types/chrome/index.d.ts +1 -0
- package/dist/types/chrome/transcript-notice.d.ts +35 -0
- package/dist/types/chrome/transcript-status.d.ts +20 -8
- package/dist/types/components/editor.d.ts +8 -0
- package/dist/types/components/markdown.d.ts +7 -0
- package/dist/types/native/blobs.d.ts +2 -1
- package/dist/types/native/picker.d.ts +4 -4
- package/dist/types/overlays/annotation-overlay.d.ts +7 -1
- package/dist/types/overlays/annotation-types.d.ts +28 -0
- package/dist/types/overlays/login-dialog.d.ts +5 -1
- package/dist/types/overlays/model-browser.d.ts +10 -1
- package/dist/types/overlays/oauth-selector.d.ts +23 -0
- package/dist/types/overlays/plan-review-overlay.d.ts +2 -0
- package/dist/types/overlays/rewind-selector.d.ts +1 -1
- package/dist/types/overlays/session-selector.d.ts +22 -2
- package/dist/types/prompt/composer.d.ts +43 -0
- package/dist/types/prompt/interactive-context-helpers.d.ts +10 -3
- package/dist/types/render/extension-links.d.ts +65 -0
- package/dist/types/render/hyperlink.d.ts +25 -7
- package/dist/types/render/index.d.ts +1 -0
- package/dist/types/setup/scenes/glyph.d.ts +1 -1
- package/dist/types/setup/scenes/model.d.ts +1 -1
- package/dist/types/setup/scenes/outro.d.ts +5 -4
- package/dist/types/setup/scenes/sign-in.d.ts +13 -8
- package/dist/types/setup/scenes/types.d.ts +16 -1
- package/dist/types/setup/startup-splash.d.ts +1 -1
- package/dist/types/setup/wizard-overlay.d.ts +11 -7
- package/dist/types/setup/wizard.d.ts +5 -1
- package/dist/types/status-line/component.d.ts +1 -1
- package/dist/types/status-line/context-usage.d.ts +28 -6
- package/dist/types/status-line/host.d.ts +6 -2
- package/dist/types/theme/theme.d.ts +0 -23
- package/dist/types/tools/bash-interactive.d.ts +6 -0
- package/dist/types/tools/bash.d.ts +2 -0
- package/dist/types/tools/default-renderer.d.ts +6 -4
- package/dist/types/tools/irc.d.ts +6 -0
- package/dist/types/tools/json-tree.d.ts +23 -4
- package/dist/types/tools/lsp.d.ts +2 -0
- package/dist/types/tools/mcp.d.ts +6 -5
- package/dist/types/tools/native-view.d.ts +1 -1
- package/dist/types/tools/renderer.d.ts +2 -0
- package/dist/types/tools/streaming-output.d.ts +11 -0
- package/dist/types/tools/task.d.ts +9 -1
- package/dist/types/tools/url-scheme-host.d.ts +17 -0
- package/dist/types/tools/yield.d.ts +1 -1
- package/dist/types/tui.d.ts +7 -2
- package/package.json +10 -14
- package/src/app-keybindings.d.ts +15 -0
- package/src/app-keybindings.ts +15 -0
- package/src/apps/session-picker.ts +7 -0
- package/src/charts/chart-plan.d.ts +9 -7
- package/src/charts/chart-plan.ts +20 -50
- package/src/chat/advisor-message.ts +2 -0
- package/src/chat/assistant-message.d.ts +15 -3
- package/src/chat/assistant-message.ts +137 -19
- package/src/chat/background-tan-message.ts +4 -0
- package/src/chat/bash-execution.d.ts +2 -0
- package/src/chat/bash-execution.ts +6 -0
- package/src/chat/chat-transcript-builder.ts +58 -28
- package/src/chat/compaction-summary-message.ts +2 -1
- package/src/chat/display-preferences.d.ts +2 -0
- package/src/chat/display-preferences.ts +3 -0
- package/src/chat/extension-types.d.ts +31 -0
- package/src/chat/extension-types.ts +34 -0
- package/src/chat/reply-write.d.ts +48 -0
- package/src/chat/reply-write.ts +127 -0
- package/src/chat/table-chart.d.ts +4 -3
- package/src/chat/table-chart.ts +10 -4
- package/src/chat/tool-execution.d.ts +1 -2
- package/src/chat/tool-execution.ts +20 -13
- package/src/chat/transcript-outline.d.ts +7 -0
- package/src/chat/transcript-outline.ts +27 -0
- package/src/chat/transcript-render-helpers.d.ts +2 -0
- package/src/chat/transcript-render-helpers.ts +66 -24
- package/src/chrome/index.ts +1 -0
- package/src/chrome/transcript-notice.d.ts +35 -0
- package/src/chrome/transcript-notice.ts +83 -0
- package/src/chrome/transcript-status.d.ts +20 -8
- package/src/chrome/transcript-status.ts +29 -29
- package/src/components/editor.d.ts +8 -0
- package/src/components/editor.ts +10 -1
- package/src/components/markdown.d.ts +7 -0
- package/src/components/markdown.ts +116 -6
- package/src/hotkeys-markdown.ts +1 -0
- package/src/native/backend.ts +5 -66
- package/src/native/blobs.d.ts +2 -1
- package/src/native/blobs.ts +3 -2
- package/src/native/picker.d.ts +4 -4
- package/src/native/picker.ts +4 -4
- package/src/overlays/advisor-config.ts +1 -10
- package/src/overlays/annotation-overlay.ts +125 -37
- package/src/overlays/annotation-types.ts +24 -0
- package/src/overlays/hook-selector.ts +2 -2
- package/src/overlays/login-dialog.ts +31 -5
- package/src/overlays/mcp-add-wizard.ts +1 -1
- package/src/overlays/model-browser.ts +37 -0
- package/src/overlays/model-hub.ts +1 -7
- package/src/overlays/model-picker.ts +1 -10
- package/src/overlays/oauth-selector.ts +44 -6
- package/src/overlays/plan-review-overlay.ts +13 -2
- package/src/overlays/rewind-selector.ts +29 -12
- package/src/overlays/session-selector.ts +313 -42
- package/src/overlays/usage-dashboard.ts +5 -12
- package/src/prompt/composer.ts +216 -1
- package/src/prompt/custom-editor.ts +6 -1
- package/src/prompt/emoji-autocomplete.ts +0 -2
- package/src/prompt/interactive-context-helpers.ts +29 -4
- package/src/render/extension-links.d.ts +65 -0
- package/src/render/extension-links.ts +214 -0
- package/src/render/hyperlink.d.ts +25 -7
- package/src/render/hyperlink.ts +65 -9
- package/src/render/index.d.ts +1 -0
- package/src/render/index.ts +1 -0
- package/src/setup/scenes/composer.ts +2 -0
- package/src/setup/scenes/glyph.ts +3 -1
- package/src/setup/scenes/model.ts +192 -29
- package/src/setup/scenes/outro.ts +33 -15
- package/src/setup/scenes/sign-in.ts +196 -400
- package/src/setup/scenes/theme.ts +2 -0
- package/src/setup/scenes/types.ts +18 -1
- package/src/setup/startup-splash.ts +8 -7
- package/src/setup/wizard-overlay.ts +164 -35
- package/src/setup/wizard.ts +11 -2
- package/src/status-line/component.ts +4 -10
- package/src/status-line/context-usage.ts +72 -21
- package/src/status-line/host.ts +6 -2
- package/src/terminal.ts +24 -2
- package/src/theme/defaults.json +1 -0
- package/src/theme/loader.ts +1 -1
- package/src/theme/theme.d.ts +0 -23
- package/src/theme/theme.ts +2 -75
- package/src/tools/bash-interactive.d.ts +49 -0
- package/src/tools/bash-interactive.ts +6 -1
- package/src/tools/bash.d.ts +2 -0
- package/src/tools/bash.ts +2 -0
- package/src/tools/default-renderer.d.ts +6 -4
- package/src/tools/default-renderer.ts +9 -6
- package/src/tools/eval.ts +14 -4
- package/src/tools/irc.d.ts +6 -0
- package/src/tools/irc.ts +6 -0
- package/src/tools/job-widget.ts +13 -1
- package/src/tools/json-tree.d.ts +23 -4
- package/src/tools/json-tree.ts +132 -42
- package/src/tools/lsp.d.ts +2 -0
- package/src/tools/lsp.ts +36 -15
- package/src/tools/mcp.d.ts +6 -5
- package/src/tools/mcp.ts +20 -12
- package/src/tools/native-view.d.ts +1 -1
- package/src/tools/native-view.ts +1 -1
- package/src/tools/renderer.d.ts +2 -0
- package/src/tools/renderer.ts +2 -0
- package/src/tools/streaming-output.d.ts +11 -0
- package/src/tools/streaming-output.ts +41 -0
- package/src/tools/task.d.ts +9 -1
- package/src/tools/task.ts +59 -16
- package/src/tools/url-scheme-host.d.ts +17 -0
- package/src/tools/url-scheme-host.ts +21 -0
- package/src/tools/yield.d.ts +1 -1
- package/src/tools/yield.ts +18 -9
- package/src/tui.d.ts +7 -2
- package/src/tui.ts +43 -15
- package/dist/types/theme/defaults/index.d.ts +0 -10289
- package/src/theme/defaults/alabaster.json +0 -103
- package/src/theme/defaults/amethyst.json +0 -106
- package/src/theme/defaults/anthracite.json +0 -103
- package/src/theme/defaults/basalt.json +0 -101
- package/src/theme/defaults/birch.json +0 -105
- package/src/theme/defaults/dark-abyss.json +0 -101
- package/src/theme/defaults/dark-arctic.json +0 -114
- package/src/theme/defaults/dark-aurora.json +0 -105
- package/src/theme/defaults/dark-catppuccin.json +0 -117
- package/src/theme/defaults/dark-cavern.json +0 -101
- package/src/theme/defaults/dark-celestial.json +0 -116
- package/src/theme/defaults/dark-copper.json +0 -105
- package/src/theme/defaults/dark-cosmos.json +0 -100
- package/src/theme/defaults/dark-cyberpunk.json +0 -112
- package/src/theme/defaults/dark-dracula.json +0 -108
- package/src/theme/defaults/dark-eclipse.json +0 -101
- package/src/theme/defaults/dark-ember.json +0 -105
- package/src/theme/defaults/dark-equinox.json +0 -100
- package/src/theme/defaults/dark-forest.json +0 -106
- package/src/theme/defaults/dark-github.json +0 -115
- package/src/theme/defaults/dark-gruvbox.json +0 -122
- package/src/theme/defaults/dark-lavender.json +0 -105
- package/src/theme/defaults/dark-lunar.json +0 -99
- package/src/theme/defaults/dark-midnight.json +0 -105
- package/src/theme/defaults/dark-monochrome.json +0 -104
- package/src/theme/defaults/dark-monokai.json +0 -108
- package/src/theme/defaults/dark-nebula.json +0 -100
- package/src/theme/defaults/dark-neon-noir.json +0 -110
- package/src/theme/defaults/dark-nord.json +0 -108
- package/src/theme/defaults/dark-ocean.json +0 -111
- package/src/theme/defaults/dark-one.json +0 -110
- package/src/theme/defaults/dark-poimandres.json +0 -125
- package/src/theme/defaults/dark-rainforest.json +0 -101
- package/src/theme/defaults/dark-reef.json +0 -101
- package/src/theme/defaults/dark-retro.json +0 -102
- package/src/theme/defaults/dark-rose-pine.json +0 -106
- package/src/theme/defaults/dark-sakura.json +0 -105
- package/src/theme/defaults/dark-slate.json +0 -105
- package/src/theme/defaults/dark-solarized.json +0 -107
- package/src/theme/defaults/dark-solstice.json +0 -100
- package/src/theme/defaults/dark-starfall.json +0 -101
- package/src/theme/defaults/dark-sunset.json +0 -109
- package/src/theme/defaults/dark-swamp.json +0 -100
- package/src/theme/defaults/dark-synthwave.json +0 -113
- package/src/theme/defaults/dark-taiga.json +0 -101
- package/src/theme/defaults/dark-terminal.json +0 -105
- package/src/theme/defaults/dark-tokyo-night.json +0 -111
- package/src/theme/defaults/dark-tundra.json +0 -101
- package/src/theme/defaults/dark-twilight.json +0 -101
- package/src/theme/defaults/dark-volcanic.json +0 -101
- package/src/theme/defaults/graphite.json +0 -102
- package/src/theme/defaults/index.d.ts +0 -10289
- package/src/theme/defaults/index.ts +0 -203
- package/src/theme/defaults/light-arctic.json +0 -117
- package/src/theme/defaults/light-aurora-day.json +0 -101
- package/src/theme/defaults/light-canyon.json +0 -101
- package/src/theme/defaults/light-catppuccin.json +0 -116
- package/src/theme/defaults/light-cirrus.json +0 -100
- package/src/theme/defaults/light-coral.json +0 -105
- package/src/theme/defaults/light-cyberpunk.json +0 -106
- package/src/theme/defaults/light-dawn.json +0 -100
- package/src/theme/defaults/light-dunes.json +0 -101
- package/src/theme/defaults/light-eucalyptus.json +0 -105
- package/src/theme/defaults/light-forest.json +0 -110
- package/src/theme/defaults/light-frost.json +0 -105
- package/src/theme/defaults/light-github.json +0 -125
- package/src/theme/defaults/light-glacier.json +0 -101
- package/src/theme/defaults/light-gruvbox.json +0 -118
- package/src/theme/defaults/light-haze.json +0 -100
- package/src/theme/defaults/light-honeycomb.json +0 -105
- package/src/theme/defaults/light-lagoon.json +0 -101
- package/src/theme/defaults/light-lavender.json +0 -105
- package/src/theme/defaults/light-meadow.json +0 -101
- package/src/theme/defaults/light-mint.json +0 -105
- package/src/theme/defaults/light-monochrome.json +0 -111
- package/src/theme/defaults/light-ocean.json +0 -109
- package/src/theme/defaults/light-one.json +0 -109
- package/src/theme/defaults/light-opal.json +0 -101
- package/src/theme/defaults/light-orchard.json +0 -101
- package/src/theme/defaults/light-paper.json +0 -105
- package/src/theme/defaults/light-poimandres.json +0 -125
- package/src/theme/defaults/light-prism.json +0 -100
- package/src/theme/defaults/light-retro.json +0 -108
- package/src/theme/defaults/light-sand.json +0 -105
- package/src/theme/defaults/light-savanna.json +0 -101
- package/src/theme/defaults/light-solarized.json +0 -112
- package/src/theme/defaults/light-soleil.json +0 -100
- package/src/theme/defaults/light-sunset.json +0 -109
- package/src/theme/defaults/light-synthwave.json +0 -108
- package/src/theme/defaults/light-tokyo-night.json +0 -121
- package/src/theme/defaults/light-wetland.json +0 -101
- package/src/theme/defaults/light-zenith.json +0 -99
- package/src/theme/defaults/limestone.json +0 -104
- package/src/theme/defaults/mahogany.json +0 -107
- package/src/theme/defaults/marble.json +0 -103
- package/src/theme/defaults/obsidian.json +0 -101
- package/src/theme/defaults/onyx.json +0 -101
- package/src/theme/defaults/pearl.json +0 -103
- package/src/theme/defaults/porcelain.json +0 -101
- package/src/theme/defaults/quartz.json +0 -106
- package/src/theme/defaults/sandstone.json +0 -105
- package/src/theme/defaults/titanium.json +0 -100
|
@@ -5,6 +5,7 @@ import { Image, type ImageBudget } from "../components/image";
|
|
|
5
5
|
import { ImageProtocol, TERMINAL } from "../terminal-capabilities";
|
|
6
6
|
import {
|
|
7
7
|
type DefaultTextStyle,
|
|
8
|
+
endsInsideOpenFence,
|
|
8
9
|
holdPartialTableRow,
|
|
9
10
|
Markdown,
|
|
10
11
|
type MarkdownTheme,
|
|
@@ -14,10 +15,10 @@ import {
|
|
|
14
15
|
} from "../components/markdown";
|
|
15
16
|
import { Spacer } from "../components/spacer";
|
|
16
17
|
import { Text } from "../components/text";
|
|
17
|
-
import { formatDuration, formatNumber } from "@linxiraos/pi-utils";
|
|
18
|
+
import { formatDuration, formatNumber, logger } from "@linxiraos/pi-utils";
|
|
18
19
|
import chalk from "@linxiraos/pi-utils/chalk";
|
|
19
20
|
import { LRUCache } from "@linxiraos/pi-utils/lru";
|
|
20
|
-
import type { AssistantThinkingRenderer } from "./extension-types";
|
|
21
|
+
import type { AssistantTextRenderer, AssistantTextRendering, AssistantThinkingRenderer } from "./extension-types";
|
|
21
22
|
import { ensureThemeSync, getMarkdownTheme, getMarkdownThemeWithLinkTargets, getThemeEpoch, theme } from "../theme";
|
|
22
23
|
import { card, col, elapsed, node, span, text } from "../native/describe";
|
|
23
24
|
import { hasTranscriptActions, runTranscriptAction } from "./transcript-actions";
|
|
@@ -51,6 +52,8 @@ import { chartFence, hasChartTable, lookupTableChart, splitTableCharts } from ".
|
|
|
51
52
|
*/
|
|
52
53
|
const MAX_TRANSCRIPT_ERROR_ROWS = 8;
|
|
53
54
|
const EMPTY_STABLE_RENDER: readonly string[] = [];
|
|
55
|
+
/** Text renderers that threw once; each failure is logged once per renderer, not per frame. */
|
|
56
|
+
const failedTextRenderers = new WeakSet<AssistantTextRenderer>();
|
|
54
57
|
|
|
55
58
|
/** The native head of a finished thinking block: "Thought for 12s", or "Thought" when it was never seen streaming. */
|
|
56
59
|
function thoughtLabel(clock: { start: number; end?: number } | undefined): string {
|
|
@@ -245,6 +248,19 @@ function lerpHex(from: string, to: string, t: number): string {
|
|
|
245
248
|
return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`;
|
|
246
249
|
}
|
|
247
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Drop the closing border the renderer draws for a source that ends inside an
|
|
253
|
+
* open fence. That row is not part of the message yet: the live block reaches
|
|
254
|
+
* it only when the closer arrives, so publishing it would make the settled
|
|
255
|
+
* prefix disagree with the block render and freeze mid-stream retirement.
|
|
256
|
+
*/
|
|
257
|
+
function trimFabricatedCloser(rows: readonly string[], source: string): readonly string[] {
|
|
258
|
+
if (!endsInsideOpenFence(source)) return rows;
|
|
259
|
+
let last = rows.length;
|
|
260
|
+
while (last > 0 && rows[last - 1]!.trim() === "") last--;
|
|
261
|
+
return last > 0 ? rows.slice(0, last - 1) : rows;
|
|
262
|
+
}
|
|
263
|
+
|
|
248
264
|
/**
|
|
249
265
|
* Renders an assistant message; streaming content remains mutable until the
|
|
250
266
|
* provider finalizes it because later deltas can revise earlier Markdown.
|
|
@@ -390,8 +406,10 @@ export class AssistantMessageComponent extends Container {
|
|
|
390
406
|
#reactionTarget: ReactionTarget | undefined;
|
|
391
407
|
/** Reaction lifted from the reply's opening emoji, once resolved. */
|
|
392
408
|
#reaction: string | undefined;
|
|
393
|
-
/** Display form of {@link #lastMessage} (reaction handled) the native description is built from. */
|
|
409
|
+
/** Display form of {@link #lastMessage} (reaction handled, extension text renderers applied) the native description is built from. */
|
|
394
410
|
#displayedMessage: AssistantMessage | undefined;
|
|
411
|
+
/** {@link #displayedMessage} before extension text renderers: the reply as written, which thinking state and the native Copy follow. */
|
|
412
|
+
#answerMessage: AssistantMessage | undefined;
|
|
395
413
|
/** Thinking-extension components per content index, recorded when the slow path mounts them. */
|
|
396
414
|
#thinkingExtensions = new Map<number, Component[]>();
|
|
397
415
|
/** Collapse state of thinking sections toggled in the terminal, by content index; cleared by {@link setHideThinkingBlock}. */
|
|
@@ -523,9 +541,65 @@ export class AssistantMessageComponent extends Container {
|
|
|
523
541
|
content[index] = { ...block, text };
|
|
524
542
|
return { ...message, content };
|
|
525
543
|
}
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Display form with the extension text renderers applied, in registration order: each gets the
|
|
547
|
+
* previous one's output. A renderer that throws or returns a non-string leaves its input drawn;
|
|
548
|
+
* a throw is logged once per renderer. A block whose text and `streaming` flag are unchanged
|
|
549
|
+
* since its last render reuses that output: a block sealed at a tool call keeps receiving
|
|
550
|
+
* updates while the call's arguments stream. {@link rerenderMessage} and
|
|
551
|
+
* {@link setTextRenderers} drop the reused output.
|
|
552
|
+
*/
|
|
553
|
+
#renderText(message: AssistantMessage, streaming: boolean): AssistantMessage {
|
|
554
|
+
const rendering = this.#textRendering;
|
|
555
|
+
if (!rendering) return message;
|
|
556
|
+
// Renderers are display-only: hand them a deep copy so no edit, however nested, reaches the stored message.
|
|
557
|
+
let view: AssistantMessage | undefined;
|
|
558
|
+
let content: AssistantMessage["content"] | undefined;
|
|
559
|
+
// Blocks stream in order: only the last one can still grow.
|
|
560
|
+
const tail = message.content.length - 1;
|
|
561
|
+
for (let index = 0; index < message.content.length; index++) {
|
|
562
|
+
const block = message.content[index]!;
|
|
563
|
+
if (block.type !== "text" || block.text.length === 0) continue;
|
|
564
|
+
const blockStreaming = streaming && index === tail;
|
|
565
|
+
const cached = this.#renderedText.get(index);
|
|
566
|
+
let text: string;
|
|
567
|
+
if (cached?.input === block.text && cached.streaming === blockStreaming) {
|
|
568
|
+
text = cached.output;
|
|
569
|
+
} else {
|
|
570
|
+
view ??= structuredClone(message);
|
|
571
|
+
text = block.text;
|
|
572
|
+
for (const renderer of rendering.renderers) {
|
|
573
|
+
try {
|
|
574
|
+
const rendered = renderer({
|
|
575
|
+
message: view,
|
|
576
|
+
contentIndex: rendering.contentOffset + index,
|
|
577
|
+
text,
|
|
578
|
+
streaming: blockStreaming,
|
|
579
|
+
});
|
|
580
|
+
if (typeof rendered === "string") text = rendered;
|
|
581
|
+
} catch (error) {
|
|
582
|
+
if (failedTextRenderers.has(renderer)) continue;
|
|
583
|
+
failedTextRenderers.add(renderer);
|
|
584
|
+
logger.warn("Assistant text renderer failed; drawing its input", { error: String(error) });
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
this.#renderedText.set(index, { input: block.text, streaming: blockStreaming, output: text });
|
|
588
|
+
}
|
|
589
|
+
if (text === block.text) continue;
|
|
590
|
+
content ??= message.content.slice();
|
|
591
|
+
content[index] = { ...block, text };
|
|
592
|
+
}
|
|
593
|
+
return content ? { ...message, content } : message;
|
|
594
|
+
}
|
|
526
595
|
#hideThinkingBlock: boolean;
|
|
527
596
|
readonly #onImageUpdate?: () => void;
|
|
528
597
|
readonly #thinkingRenderers: readonly AssistantThinkingRenderer[];
|
|
598
|
+
#textRendering: AssistantTextRendering | undefined;
|
|
599
|
+
/** Index in the full reply's `content` of this component's first block, kept across renderer swaps. */
|
|
600
|
+
readonly #textContentOffset: number;
|
|
601
|
+
/** Last renderer output per content index, reused while the block's input and `streaming` flag hold; see {@link #renderText}. */
|
|
602
|
+
readonly #renderedText = new Map<number, { input: string; streaming: boolean; output: string }>();
|
|
529
603
|
readonly #imageBudget?: ImageBudget;
|
|
530
604
|
#proseOnlyThinking: boolean;
|
|
531
605
|
#expandThinkingBlocks: boolean;
|
|
@@ -539,11 +613,14 @@ export class AssistantMessageComponent extends Container {
|
|
|
539
613
|
proseOnlyThinking = true,
|
|
540
614
|
linkTargets?: ReadonlyMap<string, string>,
|
|
541
615
|
expandThinkingBlocks = false,
|
|
616
|
+
textRendering?: AssistantTextRendering,
|
|
542
617
|
) {
|
|
543
618
|
super();
|
|
544
619
|
this.#hideThinkingBlock = hideThinkingBlock;
|
|
545
620
|
this.#onImageUpdate = onImageUpdate;
|
|
546
621
|
this.#thinkingRenderers = thinkingRenderers;
|
|
622
|
+
this.#textRendering = textRendering?.renderers.length ? textRendering : undefined;
|
|
623
|
+
this.#textContentOffset = textRendering?.contentOffset ?? 0;
|
|
547
624
|
this.#imageBudget = imageBudget;
|
|
548
625
|
this.#proseOnlyThinking = proseOnlyThinking;
|
|
549
626
|
this.#expandThinkingBlocks = expandThinkingBlocks;
|
|
@@ -792,8 +869,9 @@ export class AssistantMessageComponent extends Container {
|
|
|
792
869
|
return this.#transcriptBlockFinalized;
|
|
793
870
|
}
|
|
794
871
|
|
|
795
|
-
/**
|
|
872
|
+
/** Hold image and figure rendering until the completed block can enter immutable scrollback. */
|
|
796
873
|
isTranscriptBlockPending(): boolean {
|
|
874
|
+
if (this.#showImages && this.#kittyConversionsAwaited.size > 0) return true;
|
|
797
875
|
for (const block of this.#figureBlocks.values()) if (block.pending) return true;
|
|
798
876
|
return false;
|
|
799
877
|
}
|
|
@@ -815,7 +893,7 @@ export class AssistantMessageComponent extends Container {
|
|
|
815
893
|
*/
|
|
816
894
|
override describe(cx?: DescribeContext): NativeNode {
|
|
817
895
|
const media = cx?.supports("media") === true;
|
|
818
|
-
const tail = this.#
|
|
896
|
+
const tail = this.#answerMessage ? this.#thinkingTailIndex(this.#answerMessage) : undefined;
|
|
819
897
|
const rate =
|
|
820
898
|
tail !== undefined && this.#lastUpdateTransient && this.#thinkingRateLive
|
|
821
899
|
? Math.round(Math.min(SPEED_MAX, sharedSpeedTracker.getSpeed()) * 10) / 10
|
|
@@ -886,13 +964,15 @@ export class AssistantMessageComponent extends Container {
|
|
|
886
964
|
let answered = false;
|
|
887
965
|
if (message) {
|
|
888
966
|
const live = !this.#transcriptBlockFinalized && this.#lastUpdateTransient;
|
|
967
|
+
// Which block streams, and whether there is an answer to copy, follow the reply as written:
|
|
968
|
+
// text renderers change only how it is drawn (one may hide all of it).
|
|
969
|
+
const answer = this.#answerMessage ?? message;
|
|
889
970
|
let tailIndex = -1;
|
|
890
|
-
for (let index = 0; index <
|
|
891
|
-
const content =
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
) {
|
|
971
|
+
for (let index = 0; index < answer.content.length; index++) {
|
|
972
|
+
const content = answer.content[index]!;
|
|
973
|
+
const answerText = content.type === "text" && canonicalizeMessage(content.text) !== "";
|
|
974
|
+
answered ||= answerText;
|
|
975
|
+
if (answerText || (content.type === "thinking" && canonicalizeMessage(content.thinking))) {
|
|
896
976
|
tailIndex = index;
|
|
897
977
|
}
|
|
898
978
|
}
|
|
@@ -900,7 +980,6 @@ export class AssistantMessageComponent extends Container {
|
|
|
900
980
|
const content = message.content[index]!;
|
|
901
981
|
const streaming = live && index === tailIndex;
|
|
902
982
|
if (content.type === "text" && canonicalizeMessage(content.text)) {
|
|
903
|
-
answered = true;
|
|
904
983
|
// A native terminal sizes table columns by every row it gets: send a growing row once
|
|
905
984
|
// its line ends. Hold before trimming, which would drop the newline ending a finished row.
|
|
906
985
|
const source = (streaming ? holdPartialTableRow(content.text) : content.text).trim();
|
|
@@ -1157,7 +1236,7 @@ export class AssistantMessageComponent extends Container {
|
|
|
1157
1236
|
/** The answer as the transcript shows it: its text blocks' markdown, a blank line apart, without thinking or tool calls. */
|
|
1158
1237
|
#answerText(): string {
|
|
1159
1238
|
const blocks: string[] = [];
|
|
1160
|
-
for (const content of this.#
|
|
1239
|
+
for (const content of this.#answerMessage?.content ?? []) {
|
|
1161
1240
|
if (content.type === "text" && canonicalizeMessage(content.text)) blocks.push(content.text.trim());
|
|
1162
1241
|
}
|
|
1163
1242
|
return blocks.join("\n\n");
|
|
@@ -1219,7 +1298,8 @@ export class AssistantMessageComponent extends Container {
|
|
|
1219
1298
|
* every guard skips publication and nothing ever retracts it.
|
|
1220
1299
|
*/
|
|
1221
1300
|
#publishStableSnapshot(rendered: readonly string[], width: number): void {
|
|
1222
|
-
|
|
1301
|
+
// Extension text renderers may rewrite text they already drew, and published rows never retract.
|
|
1302
|
+
if (!this.#midStreamPublication || this.#textRendering) return;
|
|
1223
1303
|
const parts = this.#currentStableSnapshot();
|
|
1224
1304
|
if (!parts) return;
|
|
1225
1305
|
const last = parts.at(-1);
|
|
@@ -1364,12 +1444,12 @@ export class AssistantMessageComponent extends Container {
|
|
|
1364
1444
|
const renderer = role === "head" ? head : role === "replay" ? replay : head?.index === index ? head : replay;
|
|
1365
1445
|
if (renderer?.index === index && renderer.kind === kind) {
|
|
1366
1446
|
renderer.md.setText(trimmed);
|
|
1367
|
-
return renderer.md.render(width);
|
|
1447
|
+
return trimFabricatedCloser(renderer.md.render(width), trimmed);
|
|
1368
1448
|
}
|
|
1369
1449
|
const md = this.#createMarkdown(kind, trimmed);
|
|
1370
1450
|
if (role === "head") this.#stableHeadRenderer = { index, kind, md };
|
|
1371
1451
|
else if (role === "replay") this.#stableReplayRenderer = { index, kind, md };
|
|
1372
|
-
return md.render(width);
|
|
1452
|
+
return trimFabricatedCloser(md.render(width), trimmed);
|
|
1373
1453
|
}
|
|
1374
1454
|
|
|
1375
1455
|
/** Markdown for a text or thinking block; live children and stable-row renders share it so stable rows prefix the block render. */
|
|
@@ -1496,11 +1576,30 @@ export class AssistantMessageComponent extends Container {
|
|
|
1496
1576
|
this.#stopThinkingAnimation();
|
|
1497
1577
|
// If the live pulse was on screen when the block sealed, drop the fast path
|
|
1498
1578
|
// and rebuild so the placeholder is removed — finalized blocks never animate.
|
|
1579
|
+
// A sealed block's text is also complete and can retire to scrollback before the
|
|
1580
|
+
// reply's final update reaches it: give the text renderers their final call now
|
|
1581
|
+
// (sealed renders pass `streaming: false`).
|
|
1582
|
+
const sealRenderers = this.#textRendering !== undefined && this.#lastUpdateTransient;
|
|
1499
1583
|
if (this.#thinkingDots) {
|
|
1500
1584
|
this.#fastPathKey = undefined;
|
|
1501
1585
|
this.#fastPathItems = undefined;
|
|
1502
|
-
if (this.#lastMessage) this.updateContent(this.#lastMessage, { transient: this.#lastUpdateTransient });
|
|
1503
1586
|
}
|
|
1587
|
+
if ((this.#thinkingDots || sealRenderers) && this.#lastMessage) {
|
|
1588
|
+
this.updateContent(this.#lastMessage, { transient: this.#lastUpdateTransient });
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
/**
|
|
1593
|
+
* Swap the extension text renderers (the setting enabling them changed) and redraw with them.
|
|
1594
|
+
* Enabling them also drops rows already published as stable, since a renderer may rewrite them;
|
|
1595
|
+
* callers MUST pair this with a scrollback-clearing display reset, as for
|
|
1596
|
+
* {@link resetTranscriptStableRows}.
|
|
1597
|
+
*/
|
|
1598
|
+
setTextRenderers(renderers: readonly AssistantTextRenderer[]): void {
|
|
1599
|
+
this.#textRendering = renderers.length ? { renderers, contentOffset: this.#textContentOffset } : undefined;
|
|
1600
|
+
this.#renderedText.clear();
|
|
1601
|
+
if (this.#textRendering) this.resetTranscriptStableRows();
|
|
1602
|
+
if (this.#lastMessage) this.updateContent(this.#lastMessage, { transient: this.#lastUpdateTransient });
|
|
1504
1603
|
}
|
|
1505
1604
|
|
|
1506
1605
|
applyRetryRecovery(retryRecovery: AssistantMessage["retryRecovery"]): void {
|
|
@@ -1509,6 +1608,18 @@ export class AssistantMessageComponent extends Container {
|
|
|
1509
1608
|
this.updateContent({ ...this.#lastMessage, retryRecovery });
|
|
1510
1609
|
}
|
|
1511
1610
|
|
|
1611
|
+
/**
|
|
1612
|
+
* Draw the current message again when it is the reply sent at `timestamp`, re-running the
|
|
1613
|
+
* extension text renderers; returns whether it was. The caller schedules the frame.
|
|
1614
|
+
*/
|
|
1615
|
+
rerenderMessage(timestamp: number): boolean {
|
|
1616
|
+
if (this.#lastMessage?.timestamp !== timestamp) return false;
|
|
1617
|
+
// The renderers' state may have changed: run them again rather than reuse their last output.
|
|
1618
|
+
this.#renderedText.clear();
|
|
1619
|
+
this.updateContent(this.#lastMessage, { transient: this.#lastUpdateTransient });
|
|
1620
|
+
return true;
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1512
1623
|
messagePersistenceKey(): string | undefined {
|
|
1513
1624
|
if (!this.#lastMessage) return undefined;
|
|
1514
1625
|
return [
|
|
@@ -1620,6 +1731,7 @@ export class AssistantMessageComponent extends Container {
|
|
|
1620
1731
|
})
|
|
1621
1732
|
.catch(() => {
|
|
1622
1733
|
this.#kittyConversionsAwaited.delete(key);
|
|
1734
|
+
this.#onImageUpdate?.();
|
|
1623
1735
|
});
|
|
1624
1736
|
}
|
|
1625
1737
|
}
|
|
@@ -1811,6 +1923,12 @@ export class AssistantMessageComponent extends Container {
|
|
|
1811
1923
|
// verbatim message so re-renders re-derive the reaction deterministically.
|
|
1812
1924
|
// Narration the provider returned as thinking renders as answer text.
|
|
1813
1925
|
message = this.#displayMessage(presentNarrationAsAnswer(message), this.#lastUpdateTransient);
|
|
1926
|
+
this.#answerMessage = message;
|
|
1927
|
+
// A sealed block (closed at a tool call) keeps receiving transient updates; its text is final.
|
|
1928
|
+
// Thinking state below reads `answer`: renderers transform display only, so one that hides the
|
|
1929
|
+
// streaming text must not make the closed thought before it look live again.
|
|
1930
|
+
const answer = message;
|
|
1931
|
+
message = this.#renderText(message, this.#lastUpdateTransient && !this.#transcriptBlockFinalized);
|
|
1814
1932
|
this.#displayedMessage = message;
|
|
1815
1933
|
|
|
1816
1934
|
// Streaming-speed gauge: only a live, in-flight render of the single
|
|
@@ -1828,7 +1946,7 @@ export class AssistantMessageComponent extends Container {
|
|
|
1828
1946
|
// Native terminals show the live rate on visible thinking too, not only the hidden pulse.
|
|
1829
1947
|
const isThinkingNow =
|
|
1830
1948
|
this.#lastUpdateTransient &&
|
|
1831
|
-
(isNativeRendering() ? this.#thinkingTailIndex(
|
|
1949
|
+
(isNativeRendering() ? this.#thinkingTailIndex(answer) !== undefined : this.#shouldAnimateThinking(answer));
|
|
1832
1950
|
if (isThinkingNow) {
|
|
1833
1951
|
const currentTokens = message.usage.reasoningTokens ?? message.usage.output;
|
|
1834
1952
|
this.#thinkingTokens = currentTokens;
|
|
@@ -1931,7 +2049,7 @@ export class AssistantMessageComponent extends Container {
|
|
|
1931
2049
|
if (this.#figureBlocks.get(index) !== block) block.dispose();
|
|
1932
2050
|
}
|
|
1933
2051
|
|
|
1934
|
-
if (this.#shouldAnimateThinking(
|
|
2052
|
+
if (this.#shouldAnimateThinking(answer)) {
|
|
1935
2053
|
if (hasVisibleContent) this.#contentContainer.addChild(new Spacer(1));
|
|
1936
2054
|
this.#thinkingDots = new Text(this.#thinkingDotsLabel(), 1, 0);
|
|
1937
2055
|
this.#contentContainer.addChild(this.#thinkingDots);
|
|
@@ -3,6 +3,7 @@ import { replaceTabs } from "../render/render-utils";
|
|
|
3
3
|
import { theme } from "../theme";
|
|
4
4
|
import type { TranscriptBlock } from "../chrome/transcript-container";
|
|
5
5
|
import { TranscriptStatusBlock } from "../chrome/transcript-status";
|
|
6
|
+
import { span } from "../native/describe";
|
|
6
7
|
|
|
7
8
|
const TAN_WORK_PREVIEW_LENGTH = 56;
|
|
8
9
|
|
|
@@ -22,6 +23,8 @@ export function createBackgroundTanDispatchBlock(message: CustomMessage<unknown>
|
|
|
22
23
|
const details = (message as CustomMessage<Partial<BackgroundTanDispatchDetails>>).details;
|
|
23
24
|
const jobId = details?.jobId ?? "unknown";
|
|
24
25
|
const work = details?.work ? previewWork(details.work) : undefined;
|
|
26
|
+
const spans = [span("Tangent dispatched"), span(" · ", "dim"), span(`task ${jobId}`, "dim")];
|
|
27
|
+
if (work) spans.push(span(" · ", "dim"), span(work, "dim"));
|
|
25
28
|
return new TranscriptStatusBlock([
|
|
26
29
|
{
|
|
27
30
|
parts: [
|
|
@@ -30,6 +33,7 @@ export function createBackgroundTanDispatchBlock(message: CustomMessage<unknown>
|
|
|
30
33
|
{ text: jobId, color: "accent" },
|
|
31
34
|
work ? { text: `${theme.format.dash} ${work}`, color: "dim" } : undefined,
|
|
32
35
|
],
|
|
36
|
+
native: { tone: "info", icon: "output", message: spans },
|
|
33
37
|
},
|
|
34
38
|
]);
|
|
35
39
|
}
|
|
@@ -37,6 +37,8 @@ export declare class BashExecutionComponent extends Container {
|
|
|
37
37
|
appendOutput(chunk: string): void;
|
|
38
38
|
/** Switch to PTY rendering and feed raw terminal bytes through the vterm replay. */
|
|
39
39
|
appendPtyChunk(chunk: string): void;
|
|
40
|
+
/** Bytes a terminal would send for a key event, honoring the command's cursor-key mode; "" for key releases. */
|
|
41
|
+
encodePtyInput(data: string): string;
|
|
40
42
|
setComplete(exitCode: number | undefined, cancelled: boolean, options?: {
|
|
41
43
|
output?: string;
|
|
42
44
|
truncation?: TruncationMeta;
|
|
@@ -16,6 +16,7 @@ import type { TruncationMeta } from "../tools/output-meta";
|
|
|
16
16
|
import { resolveImageOptions } from "../render/render-utils";
|
|
17
17
|
import { OutputPane } from "../render/output-pane";
|
|
18
18
|
import { loadXtermTerminal, readTerminalRows, styleTerminalRow } from "../tools/terminal-output";
|
|
19
|
+
import { normalizeInputForPty } from "../tools/bash-interactive";
|
|
19
20
|
import { getSixelLineMask, isSixelPassthroughEnabled, sanitizeWithOptionalSixelPassthrough } from "../render/sixel";
|
|
20
21
|
import {
|
|
21
22
|
buildExecutionFrame,
|
|
@@ -286,6 +287,11 @@ export class BashExecutionComponent extends Container {
|
|
|
286
287
|
this.#drainPtyQueue();
|
|
287
288
|
}
|
|
288
289
|
|
|
290
|
+
/** Bytes a terminal would send for a key event, honoring the command's cursor-key mode; "" for key releases. */
|
|
291
|
+
encodePtyInput(data: string): string {
|
|
292
|
+
return normalizeInputForPty(data, this.#ptyTerminal?.modes.applicationCursorKeysMode ?? false);
|
|
293
|
+
}
|
|
294
|
+
|
|
289
295
|
#drainPtyQueue(): void {
|
|
290
296
|
const terminal = this.#ptyTerminal;
|
|
291
297
|
if (!terminal || this.#ptyWriting) return;
|
|
@@ -65,8 +65,9 @@ import {
|
|
|
65
65
|
routeLateDiagnostics,
|
|
66
66
|
} from "./late-diagnostics-message";
|
|
67
67
|
import { groupedReadUsageCallIds, ReadToolGroupComponent, readArgsCollapseIntoGroup } from "./read-tool-group";
|
|
68
|
+
import { isReplyWrite, ReplyWriteComponent, replyDisplayMessage, toolResultReplies } from "./reply-write";
|
|
68
69
|
import { SkillMessageComponent } from "./skill-message";
|
|
69
|
-
import { ToolExecutionComponent } from "./tool-execution";
|
|
70
|
+
import { ToolExecutionComponent, type ToolExecutionHandle } from "./tool-execution";
|
|
70
71
|
import { TranscriptContainer } from "../chrome/transcript-container";
|
|
71
72
|
import { createUsageRowBlock, TurnUsageTally, turnElapsedMs } from "../overlays/usage-row";
|
|
72
73
|
import { CollapsedSyntheticMessageComponent, UserMessageComponent } from "./user-message";
|
|
@@ -90,7 +91,7 @@ export interface ChatTranscriptBuilderDeps {
|
|
|
90
91
|
|
|
91
92
|
export class ChatTranscriptBuilder {
|
|
92
93
|
readonly container = new TranscriptContainer();
|
|
93
|
-
#pendingTools = new Map<string,
|
|
94
|
+
#pendingTools = new Map<string, ToolExecutionHandle>();
|
|
94
95
|
#readArgs = new Map<string, Record<string, unknown>>();
|
|
95
96
|
#readGroup: ReadToolGroupComponent | null = null;
|
|
96
97
|
#pendingUsage: Usage | undefined;
|
|
@@ -203,6 +204,15 @@ export class ChatTranscriptBuilder {
|
|
|
203
204
|
this.#expandables.push(component);
|
|
204
205
|
}
|
|
205
206
|
|
|
207
|
+
/** Append assistant prose (a reply, a post-tool segment, or an `out://` reply write) with the transcript's display preferences. */
|
|
208
|
+
#mountProse(component: AssistantMessageComponent): void {
|
|
209
|
+
component.setImagesVisible(displayPreferences.showImages);
|
|
210
|
+
component.setToolResultImagesVisible(!displayPreferences.hideToolActivity);
|
|
211
|
+
component.setTableChartsVisible(this.#deps.tableCharts !== false);
|
|
212
|
+
this.#trackExpandable(component);
|
|
213
|
+
this.container.addChild(component);
|
|
214
|
+
}
|
|
215
|
+
|
|
206
216
|
/** A `wait` showing all-running is displaced by the next `wait` call. */
|
|
207
217
|
#resolveWaitingPoll(nextToolName?: string): void {
|
|
208
218
|
const previous = this.#waitingPoll;
|
|
@@ -417,12 +427,8 @@ export class ChatTranscriptBuilder {
|
|
|
417
427
|
this.#deps.linkTargets,
|
|
418
428
|
expandThinkingBlocks,
|
|
419
429
|
);
|
|
420
|
-
assistantComponent.setImagesVisible(displayPreferences.showImages);
|
|
421
|
-
assistantComponent.setToolResultImagesVisible(!displayPreferences.hideToolActivity);
|
|
422
|
-
assistantComponent.setTableChartsVisible(this.#deps.tableCharts !== false);
|
|
423
|
-
this.#trackExpandable(assistantComponent);
|
|
424
430
|
assistantComponent.pickReactionTarget(this.container.children);
|
|
425
|
-
this
|
|
431
|
+
this.#mountProse(assistantComponent);
|
|
426
432
|
let lastAssistantComponent = assistantComponent;
|
|
427
433
|
|
|
428
434
|
if (displayPreferences.cacheMissMarker) {
|
|
@@ -456,11 +462,7 @@ export class ChatTranscriptBuilder {
|
|
|
456
462
|
this.#deps.linkTargets,
|
|
457
463
|
expandThinkingBlocks,
|
|
458
464
|
);
|
|
459
|
-
component
|
|
460
|
-
component.setToolResultImagesVisible(!displayPreferences.hideToolActivity);
|
|
461
|
-
component.setTableChartsVisible(this.#deps.tableCharts !== false);
|
|
462
|
-
this.#trackExpandable(component);
|
|
463
|
-
this.container.addChild(component);
|
|
465
|
+
this.#mountProse(component);
|
|
464
466
|
lastAssistantComponent = component;
|
|
465
467
|
};
|
|
466
468
|
|
|
@@ -492,22 +494,37 @@ export class ChatTranscriptBuilder {
|
|
|
492
494
|
|
|
493
495
|
this.#readGroup?.seal();
|
|
494
496
|
this.#readGroup = null;
|
|
495
|
-
const
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
{
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
this.#
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
497
|
+
const builtIn = this.#deps.isBuiltInTool?.(content.name) ?? true;
|
|
498
|
+
let component: ToolExecutionHandle;
|
|
499
|
+
if (builtIn && isReplyWrite(content.name, content.arguments) === true) {
|
|
500
|
+
const reply = new ReplyWriteComponent({
|
|
501
|
+
requestRender: () => this.#deps.requestRender(),
|
|
502
|
+
imageBudget: this.#deps.ui.imageBudget,
|
|
503
|
+
linkTargets: this.#deps.linkTargets,
|
|
504
|
+
});
|
|
505
|
+
reply.updateArgs(content.arguments);
|
|
506
|
+
reply.setArgsComplete();
|
|
507
|
+
this.#mountProse(reply);
|
|
508
|
+
component = reply;
|
|
509
|
+
} else {
|
|
510
|
+
const card = new ToolExecutionComponent(
|
|
511
|
+
content.name,
|
|
512
|
+
content.arguments,
|
|
513
|
+
{
|
|
514
|
+
useBuiltInRenderer: builtIn,
|
|
515
|
+
// Stable ids and Kitty placeholder cells keep images anchored
|
|
516
|
+
// while the transcript viewport scrolls and reflows.
|
|
517
|
+
showImages: displayPreferences.showImages,
|
|
518
|
+
},
|
|
519
|
+
this.#deps.getTool?.(content.name),
|
|
520
|
+
this.#deps.ui,
|
|
521
|
+
this.#deps.cwd,
|
|
522
|
+
content.id,
|
|
523
|
+
);
|
|
524
|
+
this.#trackExpandable(card);
|
|
525
|
+
this.container.addChild(card);
|
|
526
|
+
component = card;
|
|
527
|
+
}
|
|
511
528
|
|
|
512
529
|
if (hasErrorStop && errorMessage) {
|
|
513
530
|
component.updateResult(
|
|
@@ -549,6 +566,19 @@ export class ChatTranscriptBuilder {
|
|
|
549
566
|
this.#readArgs.delete(message.toolCallId);
|
|
550
567
|
return;
|
|
551
568
|
}
|
|
569
|
+
for (const reply of toolResultReplies(message.details)) {
|
|
570
|
+
this.#mountProse(
|
|
571
|
+
new AssistantMessageComponent(
|
|
572
|
+
replyDisplayMessage(reply),
|
|
573
|
+
false,
|
|
574
|
+
() => this.#deps.requestRender(),
|
|
575
|
+
[],
|
|
576
|
+
this.#deps.ui.imageBudget,
|
|
577
|
+
true,
|
|
578
|
+
this.#deps.linkTargets,
|
|
579
|
+
),
|
|
580
|
+
);
|
|
581
|
+
}
|
|
552
582
|
if (!pending) return;
|
|
553
583
|
pending.updateResult(message, false, message.toolCallId);
|
|
554
584
|
this.#pendingTools.delete(message.toolCallId);
|
|
@@ -10,6 +10,7 @@ import type { TspSpan } from "@linxiraos/pi-wire";
|
|
|
10
10
|
import { md, node, span, text } from "../native/describe";
|
|
11
11
|
import { type NativeChild, type NativeNode, type NativeUiEvent, rootToggleExpanded } from "../native/node";
|
|
12
12
|
import { Memo } from "../native/memo";
|
|
13
|
+
import { noticeRow } from "../chrome/transcript-notice";
|
|
13
14
|
|
|
14
15
|
/** Divider labels per compaction method; unknown/legacy methods fall back to "compacted". */
|
|
15
16
|
const COMPACTION_METHOD_LABELS: Record<string, string> = {
|
|
@@ -237,7 +238,7 @@ function compactionNativeDetail(message: CompactionSummaryMessage): NativeChild[
|
|
|
237
238
|
? `Summary · ${frames} snapcompact frame${frames === 1 ? "" : "s"} attached`
|
|
238
239
|
: "Summary of the earlier conversation";
|
|
239
240
|
const detail: NativeChild[] = [text([span(caption, "dim")], { role: "zeta.compaction.caption", key: "caption" })];
|
|
240
|
-
if (message.warning) detail.push(
|
|
241
|
+
if (message.warning) detail.push(noticeRow("warning", message.warning, { key: "warning" }));
|
|
241
242
|
detail.push(md(message.summary, { key: "summary" }));
|
|
242
243
|
return detail;
|
|
243
244
|
}
|
|
@@ -6,6 +6,8 @@ export interface ChatTranscriptDisplayPreferences {
|
|
|
6
6
|
cacheMissMarker: boolean;
|
|
7
7
|
showTokenUsage: boolean;
|
|
8
8
|
showTurnTime: boolean;
|
|
9
|
+
/** Max rows a collapsed advisor card shows below its header; 0 = no cap. */
|
|
10
|
+
advisorCollapsedLines: number;
|
|
9
11
|
}
|
|
10
12
|
/** Current transcript display preferences. */
|
|
11
13
|
export declare const chatTranscriptDisplayPreferences: ChatTranscriptDisplayPreferences;
|
|
@@ -6,6 +6,8 @@ export interface ChatTranscriptDisplayPreferences {
|
|
|
6
6
|
cacheMissMarker: boolean;
|
|
7
7
|
showTokenUsage: boolean;
|
|
8
8
|
showTurnTime: boolean;
|
|
9
|
+
/** Max rows a collapsed advisor card shows below its header; 0 = no cap. */
|
|
10
|
+
advisorCollapsedLines: number;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
/** Current transcript display preferences. */
|
|
@@ -16,6 +18,7 @@ export const chatTranscriptDisplayPreferences: ChatTranscriptDisplayPreferences
|
|
|
16
18
|
cacheMissMarker: false,
|
|
17
19
|
showTokenUsage: false,
|
|
18
20
|
showTurnTime: false,
|
|
21
|
+
advisorCollapsedLines: 0,
|
|
19
22
|
};
|
|
20
23
|
|
|
21
24
|
/** Apply host display preferences without pulling settings into the renderer. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AssistantMessage } from "@linxiraos/pi-ai";
|
|
1
2
|
import type { Component, TUI } from "../tui";
|
|
2
3
|
import type { Theme } from "../theme/theme";
|
|
3
4
|
import type { CustomMessage, HookMessage } from "./messages";
|
|
@@ -17,6 +18,36 @@ export interface AssistantThinkingRenderContext {
|
|
|
17
18
|
requestRender(): void;
|
|
18
19
|
}
|
|
19
20
|
export type AssistantThinkingRenderer = (context: AssistantThinkingRenderContext, theme: Theme) => Component | undefined;
|
|
21
|
+
export interface AssistantTextRenderContext {
|
|
22
|
+
/**
|
|
23
|
+
* The message being drawn; `message.timestamp` identifies the reply for `ctx.ui.rerenderMessage()`.
|
|
24
|
+
* After a tool call this is only the segment drawn there, so its `content` does not hold the whole reply.
|
|
25
|
+
* A deep copy: editing it, at any depth, cannot change the stored reply.
|
|
26
|
+
*/
|
|
27
|
+
message: AssistantMessage;
|
|
28
|
+
/**
|
|
29
|
+
* The text block's index in the full reply's `content`, also when the reply is drawn in segments
|
|
30
|
+
* around tool calls; not an index into `message.content` for a segment. It counts the content as
|
|
31
|
+
* currently stored: a transcript rebuild that drops tool calls left without a result shifts later
|
|
32
|
+
* blocks down, so do not persist it as a permanent key.
|
|
33
|
+
*/
|
|
34
|
+
contentIndex: number;
|
|
35
|
+
/** The block's markdown as drawn so far, after any earlier renderer. */
|
|
36
|
+
text: string;
|
|
37
|
+
/** True while the block may still grow; false for its final render, a block sealed at a tool call, and later redraws. */
|
|
38
|
+
streaming: boolean;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Display-only transform of one assistant text block: returns the markdown to draw, or `undefined`
|
|
42
|
+
* to draw `context.text` unchanged. The session, exports and model context keep the original text.
|
|
43
|
+
*/
|
|
44
|
+
export type AssistantTextRenderer = (context: AssistantTextRenderContext) => string | undefined;
|
|
45
|
+
/** Extension text renderers for one assistant component, and where its content starts in the full reply. */
|
|
46
|
+
export interface AssistantTextRendering {
|
|
47
|
+
renderers: readonly AssistantTextRenderer[];
|
|
48
|
+
/** Index in the full reply's `content` of this component's first block; a segment after a tool call starts past it. */
|
|
49
|
+
contentOffset: number;
|
|
50
|
+
}
|
|
20
51
|
export interface HookMessageRenderOptions {
|
|
21
52
|
/** Whether the view is expanded */
|
|
22
53
|
expanded: boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AssistantMessage } from "@linxiraos/pi-ai";
|
|
1
2
|
import type { Component, TUI } from "../tui";
|
|
2
3
|
import type { Theme } from "../theme/theme";
|
|
3
4
|
import type { CustomMessage, HookMessage } from "./messages";
|
|
@@ -30,6 +31,39 @@ export type AssistantThinkingRenderer = (
|
|
|
30
31
|
theme: Theme,
|
|
31
32
|
) => Component | undefined;
|
|
32
33
|
|
|
34
|
+
export interface AssistantTextRenderContext {
|
|
35
|
+
/**
|
|
36
|
+
* The message being drawn; `message.timestamp` identifies the reply for `ctx.ui.rerenderMessage()`.
|
|
37
|
+
* After a tool call this is only the segment drawn there, so its `content` does not hold the whole reply.
|
|
38
|
+
* A deep copy: editing it, at any depth, cannot change the stored reply.
|
|
39
|
+
*/
|
|
40
|
+
message: AssistantMessage;
|
|
41
|
+
/**
|
|
42
|
+
* The text block's index in the full reply's `content`, also when the reply is drawn in segments
|
|
43
|
+
* around tool calls; not an index into `message.content` for a segment. It counts the content as
|
|
44
|
+
* currently stored: a transcript rebuild that drops tool calls left without a result shifts later
|
|
45
|
+
* blocks down, so do not persist it as a permanent key.
|
|
46
|
+
*/
|
|
47
|
+
contentIndex: number;
|
|
48
|
+
/** The block's markdown as drawn so far, after any earlier renderer. */
|
|
49
|
+
text: string;
|
|
50
|
+
/** True while the block may still grow; false for its final render, a block sealed at a tool call, and later redraws. */
|
|
51
|
+
streaming: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Display-only transform of one assistant text block: returns the markdown to draw, or `undefined`
|
|
56
|
+
* to draw `context.text` unchanged. The session, exports and model context keep the original text.
|
|
57
|
+
*/
|
|
58
|
+
export type AssistantTextRenderer = (context: AssistantTextRenderContext) => string | undefined;
|
|
59
|
+
|
|
60
|
+
/** Extension text renderers for one assistant component, and where its content starts in the full reply. */
|
|
61
|
+
export interface AssistantTextRendering {
|
|
62
|
+
renderers: readonly AssistantTextRenderer[];
|
|
63
|
+
/** Index in the full reply's `content` of this component's first block; a segment after a tool call starts past it. */
|
|
64
|
+
contentOffset: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
33
67
|
export interface HookMessageRenderOptions {
|
|
34
68
|
/** Whether the view is expanded */
|
|
35
69
|
expanded: boolean;
|