@oh-my-pi/pi-coding-agent 16.3.5 → 16.3.6
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 +18 -0
- package/dist/cli.js +3388 -3374
- package/dist/types/edit/file-snapshot-store.d.ts +4 -2
- package/dist/types/edit/renderer.d.ts +0 -1
- package/dist/types/extensibility/custom-tools/types.d.ts +2 -0
- package/dist/types/extensibility/shared-events.d.ts +8 -1
- package/dist/types/modes/components/assistant-message.d.ts +15 -10
- package/dist/types/modes/components/bash-execution.d.ts +6 -0
- package/dist/types/modes/components/eval-execution.d.ts +6 -0
- package/dist/types/modes/components/tool-execution.d.ts +3 -13
- package/dist/types/modes/components/transcript-container.d.ts +26 -28
- package/dist/types/modes/utils/transcript-render-helpers.d.ts +15 -6
- package/dist/types/session/agent-session.d.ts +2 -0
- package/dist/types/tools/bash.d.ts +0 -2
- package/dist/types/tools/browser/tab-supervisor.d.ts +10 -0
- package/dist/types/tools/eval-render.d.ts +0 -2
- package/dist/types/tools/renderers.d.ts +0 -20
- package/dist/types/tools/ssh.d.ts +0 -2
- package/dist/types/tools/write.d.ts +1 -1
- package/package.json +12 -12
- package/src/edit/file-snapshot-store.ts +5 -2
- package/src/edit/renderer.ts +0 -5
- package/src/extensibility/custom-tools/types.ts +2 -0
- package/src/extensibility/shared-events.ts +9 -1
- package/src/modes/components/assistant-message.ts +134 -82
- package/src/modes/components/bash-execution.ts +9 -0
- package/src/modes/components/chat-transcript-builder.ts +8 -4
- package/src/modes/components/eval-execution.ts +9 -0
- package/src/modes/components/tool-execution.ts +4 -50
- package/src/modes/components/transcript-container.ts +82 -432
- package/src/modes/components/tree-selector.ts +9 -3
- package/src/modes/controllers/command-controller.ts +0 -3
- package/src/modes/controllers/event-controller.ts +74 -14
- package/src/modes/controllers/extension-ui-controller.ts +0 -1
- package/src/modes/controllers/input-controller.ts +4 -10
- package/src/modes/interactive-mode.ts +12 -8
- package/src/modes/utils/transcript-render-helpers.ts +40 -13
- package/src/modes/utils/ui-helpers.ts +12 -7
- package/src/sdk.ts +1 -0
- package/src/session/agent-session.ts +148 -1
- package/src/session/session-context.ts +7 -0
- package/src/tools/bash.ts +0 -4
- package/src/tools/browser/tab-supervisor.ts +47 -3
- package/src/tools/eval-render.ts +0 -20
- package/src/tools/read.ts +63 -20
- package/src/tools/renderers.ts +0 -20
- package/src/tools/ssh.ts +0 -16
- package/src/tools/write.ts +13 -6
|
@@ -4,9 +4,9 @@ import { formatNumber } from "@oh-my-pi/pi-utils";
|
|
|
4
4
|
import chalk from "chalk";
|
|
5
5
|
import type { AssistantThinkingRenderer } from "../../extensibility/extensions/types";
|
|
6
6
|
import { getMarkdownTheme, theme } from "../../modes/theme/theme";
|
|
7
|
-
import { resolveAbortLabel, shouldRenderAbortReason } from "../../session/messages";
|
|
8
7
|
import { getPreviewLines, resolveImageOptions, TRUNCATE_LENGTHS } from "../../tools/render-utils";
|
|
9
8
|
import { canonicalizeMessage, formatThinkingForDisplay, hasDisplayableThinking } from "../../utils/thinking-display";
|
|
9
|
+
import { resolveAssistantErrorPresentation } from "../utils/transcript-render-helpers";
|
|
10
10
|
import { type CacheInvalidation, CacheInvalidationMarkerComponent } from "./cache-invalidation-marker";
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -18,15 +18,6 @@ import { type CacheInvalidation, CacheInvalidationMarkerComponent } from "./cach
|
|
|
18
18
|
*/
|
|
19
19
|
const MAX_TRANSCRIPT_ERROR_LINES = 8;
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* A GFM table delimiter row (`| --- | :--: |`, with or without bounding pipes).
|
|
23
|
-
* The header row alone does not render a table — this delimiter is what makes
|
|
24
|
-
* Markdown lay one out, and a streaming table re-aligns its columns as rows
|
|
25
|
-
* arrive. Requires at least one column pipe so a bare thematic break (`---`)
|
|
26
|
-
* does not match.
|
|
27
|
-
*/
|
|
28
|
-
const MARKDOWN_TABLE_DELIMITER = /^ {0,3}\|?(?:[ \t]*:?-+:?[ \t]*\|)+[ \t]*:?-*:?[ \t]*$/;
|
|
29
|
-
|
|
30
21
|
/** Opening or closing fence of a code block: ≥3 backticks/tildes plus info string. */
|
|
31
22
|
const CODE_FENCE_LINE = /^ {0,3}(`{3,}|~{3,})(.*)$/;
|
|
32
23
|
|
|
@@ -48,20 +39,15 @@ function resolveThinkingDisplay(block: ThinkingContentBlock, proseOnly: boolean)
|
|
|
48
39
|
}
|
|
49
40
|
|
|
50
41
|
/**
|
|
51
|
-
* Whether `text`
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* inside ordinary fenced code (shell pipes, ASCII separators, doc examples) are
|
|
58
|
-
* ignored so a long streamed code block is never held out of native scrollback.
|
|
59
|
-
* A delimiter counts only directly under a pipe-bearing header row, outside any
|
|
60
|
-
* code fence.
|
|
42
|
+
* Whether `text` contains a ` ```mermaid ` fence (open or closed) outside
|
|
43
|
+
* ordinary code fences. Mermaid defers native-scrollback settling wholesale
|
|
44
|
+
* (see {@link AssistantMessageComponent.getTranscriptBlockSettledRows}): its
|
|
45
|
+
* ASCII rendering resolves asynchronously, so even a completed fence can
|
|
46
|
+
* re-layout rows that already looked settled. Fence-aware so a mermaid
|
|
47
|
+
* example inside a regular code block never triggers the deferral.
|
|
61
48
|
*/
|
|
62
|
-
function
|
|
49
|
+
function containsMermaidFence(text: string): boolean {
|
|
63
50
|
let fence: string | null = null;
|
|
64
|
-
let prevLine = "";
|
|
65
51
|
for (const line of text.split("\n")) {
|
|
66
52
|
const fenceMatch = CODE_FENCE_LINE.exec(line);
|
|
67
53
|
if (fence !== null) {
|
|
@@ -79,11 +65,7 @@ function detectLiveReflowingMarkdown(text: string): boolean {
|
|
|
79
65
|
if (fenceMatch) {
|
|
80
66
|
if (/^mermaid\b/.test(fenceMatch[2]!.trim())) return true;
|
|
81
67
|
fence = fenceMatch[1]!;
|
|
82
|
-
prevLine = "";
|
|
83
|
-
continue;
|
|
84
68
|
}
|
|
85
|
-
if (prevLine.includes("|") && MARKDOWN_TABLE_DELIMITER.test(line)) return true;
|
|
86
|
-
prevLine = line;
|
|
87
69
|
}
|
|
88
70
|
return false;
|
|
89
71
|
}
|
|
@@ -194,14 +176,16 @@ export class AssistantMessageComponent extends Container {
|
|
|
194
176
|
#kittyConversionsInFlight = new Set<string>();
|
|
195
177
|
#transcriptBlockFinalized: boolean;
|
|
196
178
|
/**
|
|
197
|
-
* True while
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
* {@link
|
|
202
|
-
*
|
|
179
|
+
* True while any rendered item carries a ` ```mermaid ` fence. Mermaid's
|
|
180
|
+
* ASCII form resolves asynchronously and can re-layout rows that already
|
|
181
|
+
* looked settled, so settling defers until the message finalizes. See
|
|
182
|
+
* {@link getTranscriptBlockSettledRows}. Recomputed in
|
|
183
|
+
* {@link updateContent} ahead of the fast-path return, so it tracks every
|
|
184
|
+
* stream tick. Streaming GFM tables need no gate: they live in markdown's
|
|
185
|
+
* unfrozen tail while re-aligning and render deterministically once their
|
|
186
|
+
* block completes.
|
|
203
187
|
*/
|
|
204
|
-
#
|
|
188
|
+
#containsMermaidSource = false;
|
|
205
189
|
/**
|
|
206
190
|
* When true, the turn-ending `Error: …` line for `stopReason === "error"` is
|
|
207
191
|
* suppressed because the same error is currently shown in the pinned banner
|
|
@@ -222,6 +206,9 @@ export class AssistantMessageComponent extends Container {
|
|
|
222
206
|
/** Whether the last updateContent carried an in-flight streaming partial; such
|
|
223
207
|
* renders bypass the markdown module LRU (see Markdown.transientRenderCache). */
|
|
224
208
|
#lastUpdateTransient = false;
|
|
209
|
+
/** Width of the most recent render(); the settled-rows walk reads child
|
|
210
|
+
* renders at exactly this width (L1 cache hits). */
|
|
211
|
+
#lastRenderWidth = 0;
|
|
225
212
|
// Fast-path state: reuse Markdown children when message shape is stable during streaming.
|
|
226
213
|
#fastPathKey: string | undefined;
|
|
227
214
|
#fastPathItems:
|
|
@@ -299,6 +286,11 @@ export class AssistantMessageComponent extends Container {
|
|
|
299
286
|
}
|
|
300
287
|
}
|
|
301
288
|
|
|
289
|
+
override render(width: number): readonly string[] {
|
|
290
|
+
this.#lastRenderWidth = width;
|
|
291
|
+
return super.render(width);
|
|
292
|
+
}
|
|
293
|
+
|
|
302
294
|
setHideThinkingBlock(hide: boolean): void {
|
|
303
295
|
this.hideThinkingBlock = hide;
|
|
304
296
|
}
|
|
@@ -415,18 +407,44 @@ export class AssistantMessageComponent extends Container {
|
|
|
415
407
|
}
|
|
416
408
|
|
|
417
409
|
/**
|
|
418
|
-
*
|
|
419
|
-
*
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
*
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
410
|
+
* Settled leading rows for mid-stream native-scrollback commits (see
|
|
411
|
+
* `FinalizableBlock.getTranscriptBlockSettledRows`). Completed content
|
|
412
|
+
* blocks render in final form (non-transient) and settle in full; the
|
|
413
|
+
* actively streaming markdown contributes its rendered frozen-token
|
|
414
|
+
* prefix. The walk stops at the first child that is not declared
|
|
415
|
+
* byte-stable (the animated thinking pulse, extension components, images,
|
|
416
|
+
* error rows), and a cache-invalidation marker above the content defers
|
|
417
|
+
* settling entirely. Mermaid anywhere defers wholesale — its ASCII
|
|
418
|
+
* rendering resolves asynchronously and can re-layout settled-looking
|
|
419
|
+
* rows. Reads only L1-cached child renders at the width recorded by this
|
|
420
|
+
* frame's render().
|
|
427
421
|
*/
|
|
428
|
-
|
|
429
|
-
|
|
422
|
+
getTranscriptBlockSettledRows(): number {
|
|
423
|
+
if (this.#transcriptBlockFinalized || !this.#lastUpdateTransient) return 0;
|
|
424
|
+
if (this.#containsMermaidSource) return 0;
|
|
425
|
+
if (this.#markerSlot.children.length > 0) return 0;
|
|
426
|
+
const items = this.#fastPathItems;
|
|
427
|
+
const width = this.#lastRenderWidth;
|
|
428
|
+
if (!items || items.length === 0 || width <= 0) return 0;
|
|
429
|
+
const streaming = items[items.length - 1]!.md;
|
|
430
|
+
// Items are captured in child order: match completed mds positionally.
|
|
431
|
+
let itemIndex = 0;
|
|
432
|
+
let settled = 0;
|
|
433
|
+
for (const child of this.#contentContainer.children) {
|
|
434
|
+
if (child === streaming) return settled + streaming.getLastRenderSettledRows();
|
|
435
|
+
if (itemIndex < items.length - 1 && items[itemIndex]!.md === child) {
|
|
436
|
+
itemIndex++;
|
|
437
|
+
settled += child.render(width).length;
|
|
438
|
+
continue;
|
|
439
|
+
}
|
|
440
|
+
if (child instanceof Spacer) {
|
|
441
|
+
settled += child.render(width).length;
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
// Not declared byte-stable: the boundary stops here.
|
|
445
|
+
return settled;
|
|
446
|
+
}
|
|
447
|
+
return settled;
|
|
430
448
|
}
|
|
431
449
|
|
|
432
450
|
getTranscriptBlockVersion(): number {
|
|
@@ -445,6 +463,24 @@ export class AssistantMessageComponent extends Container {
|
|
|
445
463
|
}
|
|
446
464
|
}
|
|
447
465
|
|
|
466
|
+
applyRetryRecovery(retryRecovery: AssistantMessage["retryRecovery"]): void {
|
|
467
|
+
if (!this.#lastMessage || !retryRecovery) return;
|
|
468
|
+
this.setErrorPinned(false);
|
|
469
|
+
this.updateContent({ ...this.#lastMessage, retryRecovery });
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
messagePersistenceKey(): string | undefined {
|
|
473
|
+
if (!this.#lastMessage) return undefined;
|
|
474
|
+
return [
|
|
475
|
+
"assistant",
|
|
476
|
+
this.#lastMessage.timestamp,
|
|
477
|
+
this.#lastMessage.provider,
|
|
478
|
+
this.#lastMessage.model,
|
|
479
|
+
this.#lastMessage.responseId ?? "",
|
|
480
|
+
this.#lastMessage.stopReason,
|
|
481
|
+
].join(":");
|
|
482
|
+
}
|
|
483
|
+
|
|
448
484
|
/**
|
|
449
485
|
* Render a turn-ending provider error inline. Drops blank lines, clamps the
|
|
450
486
|
* line count to {@link MAX_TRANSCRIPT_ERROR_LINES}, and width-truncates each
|
|
@@ -454,7 +490,7 @@ export class AssistantMessageComponent extends Container {
|
|
|
454
490
|
#appendErrorBlock(message: string): void {
|
|
455
491
|
const lines = getPreviewLines(message, MAX_TRANSCRIPT_ERROR_LINES, TRUNCATE_LENGTHS.LINE);
|
|
456
492
|
if (lines.length === 0) lines.push("Unknown error");
|
|
457
|
-
|
|
493
|
+
// The caller owns the separating Spacer; adding one here doubled the gap.
|
|
458
494
|
this.#contentContainer.addChild(new Text(theme.fg("error", `Error: ${lines[0]}`), 1, 0));
|
|
459
495
|
for (const line of lines.slice(1)) {
|
|
460
496
|
this.#contentContainer.addChild(new Text(theme.fg("error", ` ${line}`), 1, 0));
|
|
@@ -587,15 +623,11 @@ export class AssistantMessageComponent extends Container {
|
|
|
587
623
|
if (content.type === "toolCall") return false;
|
|
588
624
|
}
|
|
589
625
|
if (this.#toolImagesByCallId.size > 0) return false;
|
|
590
|
-
|
|
591
|
-
if (
|
|
592
|
-
if (
|
|
593
|
-
message.errorMessage &&
|
|
594
|
-
shouldRenderAbortReason(message) &&
|
|
595
|
-
message.stopReason !== "aborted" &&
|
|
596
|
-
message.stopReason !== "error"
|
|
597
|
-
)
|
|
626
|
+
const errorPresentation = resolveAssistantErrorPresentation(message);
|
|
627
|
+
if (errorPresentation.kind === "compact-recovered") return false;
|
|
628
|
+
if (errorPresentation.kind === "full" && !(message.stopReason === "error" && this.#errorPinned)) {
|
|
598
629
|
return false;
|
|
630
|
+
}
|
|
599
631
|
// Extension stability: if thinking renderers exist and any tracked thinking
|
|
600
632
|
// block's text changed, extensions may produce a different child count.
|
|
601
633
|
if (this.thinkingRenderers.length > 0 && this.#fastPathItems) {
|
|
@@ -626,8 +658,9 @@ export class AssistantMessageComponent extends Container {
|
|
|
626
658
|
}
|
|
627
659
|
const transient = opts?.transient === true;
|
|
628
660
|
// Shape is identical — setText only on Markdown children whose source changed.
|
|
629
|
-
|
|
630
|
-
|
|
661
|
+
this.#applyItemTransience(transient);
|
|
662
|
+
for (let i = 0; i < this.#fastPathItems.length; i++) {
|
|
663
|
+
const item = this.#fastPathItems[i]!;
|
|
631
664
|
const content = message.content[item.contentIndex];
|
|
632
665
|
if (!content) {
|
|
633
666
|
this.#fastPathKey = undefined;
|
|
@@ -645,6 +678,14 @@ export class AssistantMessageComponent extends Container {
|
|
|
645
678
|
return false;
|
|
646
679
|
}
|
|
647
680
|
if (newText !== item.lastText) {
|
|
681
|
+
// Only the last (actively streaming) block may mutate in place: a
|
|
682
|
+
// delta into an earlier block would invalidate rows the settled
|
|
683
|
+
// walk already declared final, so tear down and rebuild instead.
|
|
684
|
+
if (i < this.#fastPathItems.length - 1) {
|
|
685
|
+
this.#fastPathKey = undefined;
|
|
686
|
+
this.#fastPathItems = undefined;
|
|
687
|
+
return false;
|
|
688
|
+
}
|
|
648
689
|
item.md.setText(newText);
|
|
649
690
|
item.lastText = newText;
|
|
650
691
|
}
|
|
@@ -698,14 +739,19 @@ export class AssistantMessageComponent extends Container {
|
|
|
698
739
|
this.#thinkingRateLive = false;
|
|
699
740
|
}
|
|
700
741
|
|
|
701
|
-
//
|
|
702
|
-
//
|
|
703
|
-
//
|
|
704
|
-
// parser only resolves
|
|
705
|
-
//
|
|
706
|
-
this.#
|
|
707
|
-
|
|
708
|
-
|
|
742
|
+
// Mermaid ASCII rendering resolves asynchronously, so a fence anywhere
|
|
743
|
+
// in the rendered source (text or visible thinking) defers settling; see
|
|
744
|
+
// getTranscriptBlockSettledRows. Detected from raw source — a Markdown
|
|
745
|
+
// parser only resolves the fence once it closes, but the stale commits
|
|
746
|
+
// would happen mid-stream.
|
|
747
|
+
this.#containsMermaidSource = message.content.some(content => {
|
|
748
|
+
if (content.type === "text") return containsMermaidFence(content.text);
|
|
749
|
+
if (content.type === "thinking" && !this.hideThinkingBlock) {
|
|
750
|
+
const display = resolveThinkingDisplay(content, this.proseOnlyThinking);
|
|
751
|
+
return display.visible && containsMermaidFence(display.text);
|
|
752
|
+
}
|
|
753
|
+
return false;
|
|
754
|
+
});
|
|
709
755
|
|
|
710
756
|
// Fast path: reuse Markdown children when shape is stable during streaming
|
|
711
757
|
if (this.#tryFastPathUpdate(message, opts)) return;
|
|
@@ -781,37 +827,43 @@ export class AssistantMessageComponent extends Container {
|
|
|
781
827
|
}
|
|
782
828
|
|
|
783
829
|
this.#renderToolImages();
|
|
784
|
-
|
|
785
|
-
// But only if there are no tool calls (tool execution components will show the error)
|
|
830
|
+
const errorPresentation = resolveAssistantErrorPresentation(message);
|
|
786
831
|
const hasToolCalls = message.content.some(c => c.type === "toolCall");
|
|
787
|
-
if (
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
832
|
+
if (errorPresentation.kind === "compact-recovered") {
|
|
833
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
834
|
+
this.#contentContainer.addChild(new Text(theme.fg("dim", errorPresentation.text), 1, 0));
|
|
835
|
+
} else if (!hasToolCalls && errorPresentation.kind === "full") {
|
|
836
|
+
if (!(message.stopReason === "error" && this.#errorPinned)) {
|
|
837
|
+
this.#contentContainer.addChild(new Spacer(1));
|
|
838
|
+
if (message.stopReason === "aborted") {
|
|
839
|
+
this.#contentContainer.addChild(new Text(theme.fg("error", errorPresentation.text), 1, 0));
|
|
792
840
|
} else {
|
|
793
|
-
this.#
|
|
841
|
+
this.#appendErrorBlock(errorPresentation.text);
|
|
794
842
|
}
|
|
795
|
-
this.#contentContainer.addChild(new Text(theme.fg("error", abortMessage), 1, 0));
|
|
796
|
-
} else if (message.stopReason === "error" && !this.#errorPinned) {
|
|
797
|
-
this.#appendErrorBlock(message.errorMessage || "Unknown error");
|
|
798
843
|
}
|
|
799
844
|
}
|
|
800
|
-
if (
|
|
801
|
-
message.errorMessage &&
|
|
802
|
-
shouldRenderAbortReason(message) &&
|
|
803
|
-
message.stopReason !== "aborted" &&
|
|
804
|
-
message.stopReason !== "error"
|
|
805
|
-
) {
|
|
806
|
-
this.#appendErrorBlock(message.errorMessage);
|
|
807
|
-
}
|
|
808
845
|
// Store fast-path state for next call
|
|
809
846
|
if (shouldCapture) {
|
|
810
847
|
this.#fastPathItems = captureItems;
|
|
811
848
|
this.#fastPathKey = this.#computeShapeKey(message);
|
|
849
|
+
this.#applyItemTransience(this.#lastUpdateTransient);
|
|
812
850
|
} else {
|
|
813
851
|
this.#fastPathKey = undefined;
|
|
814
852
|
this.#fastPathItems = undefined;
|
|
815
853
|
}
|
|
816
854
|
}
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* Only the actively streaming (last) markdown renders in transient mode;
|
|
858
|
+
* completed blocks render final — syntax-highlighted, module-LRU-cached,
|
|
859
|
+
* byte-stable — so their rows can settle into native scrollback mid-turn
|
|
860
|
+
* and are byte-identical to the finalize render.
|
|
861
|
+
*/
|
|
862
|
+
#applyItemTransience(transient: boolean): void {
|
|
863
|
+
const items = this.#fastPathItems;
|
|
864
|
+
if (!items) return;
|
|
865
|
+
for (let i = 0; i < items.length; i++) {
|
|
866
|
+
items[i]!.md.transientRenderCache = transient && i === items.length - 1;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
817
869
|
}
|
|
@@ -64,6 +64,15 @@ export class BashExecutionComponent extends Container {
|
|
|
64
64
|
this.#contentContainer.addChild(this.#loader);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Transcript finalization contract (see `FinalizableBlock`): the collapsed
|
|
69
|
+
* streaming preview rewrites its tail window every chunk, so the block must
|
|
70
|
+
* stay out of native scrollback until the command completes.
|
|
71
|
+
*/
|
|
72
|
+
isTranscriptBlockFinalized(): boolean {
|
|
73
|
+
return this.#status !== "running";
|
|
74
|
+
}
|
|
75
|
+
|
|
67
76
|
/**
|
|
68
77
|
* Set whether the output is expanded (shows full output) or collapsed (preview only).
|
|
69
78
|
*/
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
buildFileMentionBlock,
|
|
34
34
|
buildIrcMessageCard,
|
|
35
35
|
normalizeToolArgs,
|
|
36
|
-
|
|
36
|
+
resolveAssistantErrorPresentation,
|
|
37
37
|
} from "../utils/transcript-render-helpers";
|
|
38
38
|
import { createAdvisorMessageCard } from "./advisor-message";
|
|
39
39
|
import { AssistantMessageComponent } from "./assistant-message";
|
|
@@ -153,7 +153,7 @@ export class ChatTranscriptBuilder {
|
|
|
153
153
|
const previous = this.#waitingPoll;
|
|
154
154
|
if (!previous) return;
|
|
155
155
|
this.#waitingPoll = null;
|
|
156
|
-
if (nextToolName === "job" && previous.isDisplaceableBlock()) {
|
|
156
|
+
if (nextToolName === "job" && previous.isDisplaceableBlock() && this.container.isBlockUncommitted(previous)) {
|
|
157
157
|
this.container.removeChild(previous);
|
|
158
158
|
}
|
|
159
159
|
previous.seal();
|
|
@@ -168,7 +168,9 @@ export class ChatTranscriptBuilder {
|
|
|
168
168
|
}
|
|
169
169
|
if (previous.canBeDisplacedBy(nextToolName)) {
|
|
170
170
|
this.#todoSnapshot = null;
|
|
171
|
-
this.container.
|
|
171
|
+
if (this.container.isBlockUncommitted(previous)) {
|
|
172
|
+
this.container.removeChild(previous);
|
|
173
|
+
}
|
|
172
174
|
previous.seal();
|
|
173
175
|
return;
|
|
174
176
|
}
|
|
@@ -293,7 +295,9 @@ export class ChatTranscriptBuilder {
|
|
|
293
295
|
this.#readGroup = null;
|
|
294
296
|
}
|
|
295
297
|
|
|
296
|
-
const
|
|
298
|
+
const errorPresentation = resolveAssistantErrorPresentation(message);
|
|
299
|
+
const hasErrorStop = errorPresentation.kind === "full";
|
|
300
|
+
const errorMessage = hasErrorStop ? errorPresentation.text : null;
|
|
297
301
|
|
|
298
302
|
for (const content of message.content) {
|
|
299
303
|
if (content.type !== "toolCall") continue;
|
|
@@ -61,6 +61,15 @@ export class EvalExecutionComponent extends Container {
|
|
|
61
61
|
this.#contentContainer.addChild(this.#loader);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Transcript finalization contract (see `FinalizableBlock`): the collapsed
|
|
66
|
+
* streaming preview rewrites its tail window every chunk, so the block must
|
|
67
|
+
* stay out of native scrollback until the cell completes.
|
|
68
|
+
*/
|
|
69
|
+
isTranscriptBlockFinalized(): boolean {
|
|
70
|
+
return this.#status !== "running";
|
|
71
|
+
}
|
|
72
|
+
|
|
64
73
|
setExpanded(expanded: boolean): void {
|
|
65
74
|
this.#expanded = expanded;
|
|
66
75
|
this.#updateDisplay();
|
|
@@ -697,12 +697,12 @@ export class ToolExecutionComponent extends Container implements NativeScrollbac
|
|
|
697
697
|
/**
|
|
698
698
|
* Standalone harnesses may mount a tool component directly under `TUI`
|
|
699
699
|
* instead of inside `TranscriptContainer`. In that shape the component must
|
|
700
|
-
* report its own live-region seam
|
|
701
|
-
*
|
|
702
|
-
*
|
|
700
|
+
* report its own live-region seam while unfinalized, or the core renderer
|
|
701
|
+
* treats it like shell output and commits still-mutating preview rows to
|
|
702
|
+
* immutable native scrollback before the result replaces them.
|
|
703
703
|
*/
|
|
704
704
|
getNativeScrollbackLiveRegionStart(): number | undefined {
|
|
705
|
-
return
|
|
705
|
+
return this.isTranscriptBlockFinalized() ? undefined : 0;
|
|
706
706
|
}
|
|
707
707
|
|
|
708
708
|
/**
|
|
@@ -726,52 +726,6 @@ export class ToolExecutionComponent extends Container implements NativeScrollbac
|
|
|
726
726
|
return (this.#result.details as { async?: { state?: string } } | undefined)?.async?.state === "running";
|
|
727
727
|
}
|
|
728
728
|
|
|
729
|
-
/**
|
|
730
|
-
* Whether this still-live block's settled rows may enter native scrollback
|
|
731
|
-
* (see `FinalizableBlock.isTranscriptBlockCommitStable`). Renderers classify
|
|
732
|
-
* pending views by durability instead of by tool name: a provisional view is
|
|
733
|
-
* allowed to be useful on screen, but finalization may replace or re-anchor
|
|
734
|
-
* it wholesale, so committing any of its rows would strand stale preview
|
|
735
|
-
* bytes in immutable scrollback. Non-provisional views stream rows whose
|
|
736
|
-
* committed prefix survives the remaining transitions.
|
|
737
|
-
*/
|
|
738
|
-
isTranscriptBlockCommitStable(): boolean {
|
|
739
|
-
if (this.#displaceableByToolName) return false;
|
|
740
|
-
if (this.isTranscriptBlockFinalized()) return true;
|
|
741
|
-
// `provisionalPendingPreview` describes only the PENDING call preview
|
|
742
|
-
// (`renderCall`, before any result): the result render may re-anchor it
|
|
743
|
-
// wholesale, so its rows must never commit. Once a (streaming partial)
|
|
744
|
-
// result exists the result renderer is usually the live shape — its body
|
|
745
|
-
// is top-anchored and grows append-only, and `deriveLiveCommitState`
|
|
746
|
-
// gates per-row durability — so the block is commit-stable like any
|
|
747
|
-
// settled stream. Gating the flag on the pending phase is what keeps a
|
|
748
|
-
// collapsed streaming eval/bash/ssh whose box outgrows the viewport from
|
|
749
|
-
// stranding its head: while commit-unstable its scrolled-off top
|
|
750
|
-
// committed nowhere and repainted nowhere, so it read as truncated until
|
|
751
|
-
// ctrl+o (expanded) flipped it stable.
|
|
752
|
-
//
|
|
753
|
-
// Renderers whose partial-result chrome (header glyph, frame state)
|
|
754
|
-
// differs from the final result render set `provisionalPartialResult`
|
|
755
|
-
// to opt out of stream-commit while `isPartial` holds: the ratchet
|
|
756
|
-
// would otherwise promote the stable partial chrome to native scrollback
|
|
757
|
-
// after `STABLE_PREFIX_COMMIT_FRAMES` and leave it stranded above the
|
|
758
|
-
// final frame once the chrome flips. Once the result settles
|
|
759
|
-
// (`isPartial === false`) the block is commit-stable again.
|
|
760
|
-
if (this.#result !== undefined) {
|
|
761
|
-
if (this.#isPartial) {
|
|
762
|
-
const tool = this.#tool as { provisionalPartialResult?: boolean } | undefined;
|
|
763
|
-
const provisionalPartialResult =
|
|
764
|
-
tool?.provisionalPartialResult ?? toolRenderers[this.#toolName]?.provisionalPartialResult;
|
|
765
|
-
if (provisionalPartialResult) return false;
|
|
766
|
-
}
|
|
767
|
-
return true;
|
|
768
|
-
}
|
|
769
|
-
const tool = this.#tool as { provisionalPendingPreview?: boolean | "collapsed" } | undefined;
|
|
770
|
-
const provisionalPendingPreview =
|
|
771
|
-
tool?.provisionalPendingPreview ?? toolRenderers[this.#toolName]?.provisionalPendingPreview;
|
|
772
|
-
return provisionalPendingPreview !== true && (provisionalPendingPreview !== "collapsed" || this.#expanded);
|
|
773
|
-
}
|
|
774
|
-
|
|
775
729
|
/**
|
|
776
730
|
* Mark the tool terminal even though no result arrived (the turn aborted or
|
|
777
731
|
* abandoned it) and stop animating, so it can freeze and stops pinning the
|