pi-render-btw 0.6.14 → 0.6.16
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 +10 -0
- package/README.md +2 -2
- package/extensions/btw/tool-output.test.ts +87 -0
- package/extensions/btw/tool-output.ts +182 -0
- package/extensions/btw-transcript.test.ts +6 -2
- package/extensions/btw.ts +47 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.16 — 2026-09-18
|
|
4
|
+
|
|
5
|
+
- Extract textual tool-result content for readable Tool Output instead of rendering the raw `{ content: [...] }` envelope.
|
|
6
|
+
- Omit duplicated Details content while preserving structured metadata such as duration and diffs.
|
|
7
|
+
|
|
8
|
+
## 0.6.15 — 2026-09-18
|
|
9
|
+
|
|
10
|
+
- Use one local Cc-style Input/Output card renderer for Peek and read-only Tool Output, including stable input key/value rows, rails, error styling, and width-safe synchronous highlighting.
|
|
11
|
+
- Keep complete tool output in the card and let the existing outer viewport/scrollbar provide scrolling and hidden-line affordances.
|
|
12
|
+
|
|
3
13
|
## 0.6.14 — 2026-09-18
|
|
4
14
|
|
|
5
15
|
- Keep BTW, Peek, and read-only Tool Output rendering aligned with Pi Markdown/tool colors and syntax highlighting, including safe terminal-text sanitization.
|
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ with **full markdown rendering** (syntax highlighting, bold, code blocks, lists,
|
|
|
22
22
|
- lets you inject the full thread, or a summary of it, back into the main agent
|
|
23
23
|
- optionally saves an individual BTW exchange as a visible session note with `--save`
|
|
24
24
|
- includes an internal Peek mode for browsing the current BTW side thread
|
|
25
|
-
-
|
|
25
|
+
- uses a consistent Cc-style Input/Output card renderer in Peek and read-only Tool Output, while keeping BTW's native-style right-hand scrollbar with `↑ N more` / `↓ N more` affordances at the viewport edges
|
|
26
26
|
|
|
27
27
|
## ✨ Markdown rendering
|
|
28
28
|
|
|
@@ -98,7 +98,7 @@ pi install /path/to/pi-render-btw
|
|
|
98
98
|
- the composer uses Pi's native editor behavior for undo, paste, prompt history, and Tab file-path completion (including `@` prefixes) relative to the BTW working directory; `Alt+Up` (`a-up`/`alt+up`) recalls a submitted draft
|
|
99
99
|
- `Esc` still dismisses BTW immediately while the overlay is focused
|
|
100
100
|
- hovering and left-clicking a transcript row focuses one shared USER/ASSISTANT/Tool target; clicking a Tool row toggles its compact details and double-clicking collapses it
|
|
101
|
-
- with a focused Tool row, `Ctrl+O` opens a read-only Input/Output viewer; while the runtime emits partial tool updates it shows the latest provided data with a `STREAMING` marker, and after tool completion it switches to the final result
|
|
101
|
+
- with a focused Tool row, `Ctrl+O` opens a read-only Input/Output viewer using the same structured card style as Peek; while the runtime emits partial tool updates it shows the latest provided data with a `STREAMING` marker, and after tool completion it switches to the final result
|
|
102
102
|
- if the runtime has not provided tool output yet, the viewer shows an explicit no-output state rather than inventing content; its wheel, `j/k`, arrows, `g/G`, PageUp/PageDown, and `Esc` controls stay inside the viewer
|
|
103
103
|
- BTW opens top-centered so the main session remains visible underneath it
|
|
104
104
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { visibleWidth } from "@earendil-works/pi-tui";
|
|
3
|
+
import {
|
|
4
|
+
formatBtwToolInputArgs,
|
|
5
|
+
renderBtwToolOutput,
|
|
6
|
+
type BtwToolOutputTheme,
|
|
7
|
+
} from "./tool-output.ts";
|
|
8
|
+
|
|
9
|
+
const theme: BtwToolOutputTheme = {
|
|
10
|
+
fg: (_name, value) => value,
|
|
11
|
+
bold: (value) => value,
|
|
12
|
+
italic: (value) => value,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
describe("BTW tool output renderer", () => {
|
|
16
|
+
it("renders the Cc-style input and output card", () => {
|
|
17
|
+
const result = renderBtwToolOutput({
|
|
18
|
+
input: { value: 1, name: "tool" },
|
|
19
|
+
output: "ok",
|
|
20
|
+
width: 60,
|
|
21
|
+
isError: false,
|
|
22
|
+
}, theme);
|
|
23
|
+
|
|
24
|
+
expect(result.lines).toEqual([
|
|
25
|
+
" ├ Input",
|
|
26
|
+
" │ name: tool",
|
|
27
|
+
" │ value: 1",
|
|
28
|
+
" │",
|
|
29
|
+
" └ Output",
|
|
30
|
+
" ok",
|
|
31
|
+
]);
|
|
32
|
+
expect(result.lineSections).toEqual([null, "input", "input", null, null, "output"]);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("formats preferred keys first and preserves multiline values", () => {
|
|
36
|
+
expect(formatBtwToolInputArgs({ z: "last", content: "a\nb", path: "a.ts" })).toBe(
|
|
37
|
+
"path: a.ts\ncontent:\n a\n b\nz: last",
|
|
38
|
+
);
|
|
39
|
+
expect(formatBtwToolInputArgs("compact input")).toBe("compact input");
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("sanitizes captured text and renders empty output as Done", () => {
|
|
43
|
+
const result = renderBtwToolOutput({
|
|
44
|
+
input: "\u001b]0;title\u0007",
|
|
45
|
+
output: "",
|
|
46
|
+
width: 40,
|
|
47
|
+
isError: false,
|
|
48
|
+
}, theme);
|
|
49
|
+
|
|
50
|
+
expect(result.lines.join("\n")).not.toContain("title");
|
|
51
|
+
expect(result.lines).toContain(" └ Output");
|
|
52
|
+
expect(result.lines).toContain(" Done");
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("supports bounded sections without affecting the full-output default", () => {
|
|
56
|
+
const output = ["one", "two", "three"].join("\n");
|
|
57
|
+
const full = renderBtwToolOutput({
|
|
58
|
+
input: {},
|
|
59
|
+
output,
|
|
60
|
+
width: 40,
|
|
61
|
+
isError: false,
|
|
62
|
+
}, theme);
|
|
63
|
+
const bounded = renderBtwToolOutput({
|
|
64
|
+
input: {},
|
|
65
|
+
output,
|
|
66
|
+
width: 40,
|
|
67
|
+
maxOutputLines: 1,
|
|
68
|
+
isError: false,
|
|
69
|
+
}, theme);
|
|
70
|
+
|
|
71
|
+
expect(full.lines).toContain(" three");
|
|
72
|
+
expect(full.showMoreRows).toEqual({});
|
|
73
|
+
expect(bounded.lines).toContain(" … +2 more lines");
|
|
74
|
+
expect(bounded.showMoreRows.output).toBeDefined();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("keeps rendered rows within the requested visible width", () => {
|
|
78
|
+
const result = renderBtwToolOutput({
|
|
79
|
+
input: { command: "echo a very long command that must wrap safely" },
|
|
80
|
+
output: "a very long output line that must wrap safely",
|
|
81
|
+
width: 24,
|
|
82
|
+
isError: false,
|
|
83
|
+
}, theme);
|
|
84
|
+
|
|
85
|
+
expect(result.lines.every((line) => visibleWidth(line) <= 24)).toBe(true);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import type { ThemeColor } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
|
|
3
|
+
import type { BtwTheme } from "./render-utils.ts";
|
|
4
|
+
import { renderBtwToolText, sanitizeBtwText } from "./render-utils.ts";
|
|
5
|
+
|
|
6
|
+
export type BtwToolIoSection = "input" | "output";
|
|
7
|
+
export type BtwToolOutputTheme = BtwTheme;
|
|
8
|
+
|
|
9
|
+
export interface BtwToolOutputOptions {
|
|
10
|
+
input: unknown;
|
|
11
|
+
output: string;
|
|
12
|
+
width: number;
|
|
13
|
+
isError: boolean;
|
|
14
|
+
maxInputLines?: number;
|
|
15
|
+
maxOutputLines?: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface BtwToolOutputRenderResult {
|
|
19
|
+
lines: string[];
|
|
20
|
+
lineSections: Array<BtwToolIoSection | null>;
|
|
21
|
+
showMoreRows: Partial<Record<BtwToolIoSection, number>>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const PREFERRED_INPUT_KEYS = [
|
|
25
|
+
"path",
|
|
26
|
+
"file_path",
|
|
27
|
+
"command",
|
|
28
|
+
"query",
|
|
29
|
+
"pattern",
|
|
30
|
+
"url",
|
|
31
|
+
"name",
|
|
32
|
+
"message",
|
|
33
|
+
"content",
|
|
34
|
+
"old_string",
|
|
35
|
+
"new_string",
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
function safeJson(value: unknown): string {
|
|
39
|
+
try {
|
|
40
|
+
return JSON.stringify(value, null, 2) ?? "";
|
|
41
|
+
} catch {
|
|
42
|
+
return String(value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function parsedInput(value: unknown): unknown {
|
|
47
|
+
if (typeof value !== "string") return value;
|
|
48
|
+
const source = sanitizeBtwText(value).trim();
|
|
49
|
+
if (!source) return "";
|
|
50
|
+
try {
|
|
51
|
+
return JSON.parse(source);
|
|
52
|
+
} catch {
|
|
53
|
+
return source;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Format arguments as stable, readable key/value rows for the Input rail. */
|
|
58
|
+
export function formatBtwToolInputArgs(args: unknown, maxChars = 8_000): string {
|
|
59
|
+
const parsed = parsedInput(args);
|
|
60
|
+
if (parsed === undefined || parsed === null) return "";
|
|
61
|
+
if (typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
62
|
+
const rendered = typeof parsed === "string" ? sanitizeBtwText(parsed) : safeJson(parsed);
|
|
63
|
+
return rendered.length > maxChars ? `${rendered.slice(0, maxChars)}…` : rendered;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const entries = Object.entries(parsed as Record<string, unknown>)
|
|
67
|
+
.filter(([, value]) => value !== undefined)
|
|
68
|
+
.sort(([left], [right]) => {
|
|
69
|
+
const leftIndex = PREFERRED_INPUT_KEYS.indexOf(left);
|
|
70
|
+
const rightIndex = PREFERRED_INPUT_KEYS.indexOf(right);
|
|
71
|
+
if (leftIndex < 0 && rightIndex < 0) return left.localeCompare(right);
|
|
72
|
+
if (leftIndex < 0) return 1;
|
|
73
|
+
if (rightIndex < 0) return -1;
|
|
74
|
+
return leftIndex - rightIndex;
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const lines: string[] = [];
|
|
78
|
+
for (const [key, value] of entries) {
|
|
79
|
+
const safeKey = sanitizeBtwText(key);
|
|
80
|
+
const rendered = typeof value === "string" ? sanitizeBtwText(value) : safeJson(value);
|
|
81
|
+
if (rendered.includes("\n")) {
|
|
82
|
+
lines.push(`${safeKey}:`);
|
|
83
|
+
lines.push(...rendered.split("\n").map((line) => ` ${line}`));
|
|
84
|
+
} else {
|
|
85
|
+
lines.push(`${safeKey}: ${rendered}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const result = lines.join("\n");
|
|
89
|
+
return result.length > maxChars ? `${result.slice(0, Math.max(0, maxChars - 1))}…` : result;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function serializedInput(value: unknown): string {
|
|
93
|
+
const parsed = parsedInput(value);
|
|
94
|
+
return typeof parsed === "string" ? parsed : safeJson(parsed);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function toolViewportWidth(width: number): number {
|
|
98
|
+
return Math.max(1, Math.floor(Number.isFinite(width) ? width : 1));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function styledInputLine(line: string, theme: BtwToolOutputTheme): string {
|
|
102
|
+
const match = line.match(/^([A-Za-z_][\w.-]*)(:\s*)(.*)$/);
|
|
103
|
+
if (!match) return theme.fg("muted", line);
|
|
104
|
+
return theme.fg("dim", `${match[1]}${match[2]}`) + theme.fg("muted", match[3] ?? "");
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Render the Pi Cc-style Input/Output card without owning viewport state. */
|
|
108
|
+
export function renderBtwToolOutput(
|
|
109
|
+
options: BtwToolOutputOptions,
|
|
110
|
+
theme: BtwToolOutputTheme,
|
|
111
|
+
): BtwToolOutputRenderResult {
|
|
112
|
+
const width = toolViewportWidth(options.width);
|
|
113
|
+
const contentWidth = Math.max(1, width - visibleWidth(" │ "));
|
|
114
|
+
const lines: string[] = [];
|
|
115
|
+
const lineSections: Array<BtwToolIoSection | null> = [];
|
|
116
|
+
const showMoreRows: Partial<Record<BtwToolIoSection, number>> = {};
|
|
117
|
+
const maxInputLines = Math.max(1, Math.floor(options.maxInputLines ?? Number.MAX_SAFE_INTEGER));
|
|
118
|
+
const maxOutputLines = Math.max(1, Math.floor(options.maxOutputLines ?? Number.MAX_SAFE_INTEGER));
|
|
119
|
+
const color = (name: ThemeColor, value: string): string => theme.fg(name, value);
|
|
120
|
+
const push = (line: string, section: BtwToolIoSection | null): void => {
|
|
121
|
+
lines.push(truncateToWidth(line, width, ""));
|
|
122
|
+
lineSections.push(section);
|
|
123
|
+
};
|
|
124
|
+
const pushHeader = (corner: "├" | "└", title: string): void => {
|
|
125
|
+
push(color("dim", ` ${corner} `) + color("accent", theme.bold(title)), null);
|
|
126
|
+
};
|
|
127
|
+
const pushRail = (line: string, section: BtwToolIoSection, continued: boolean): void => {
|
|
128
|
+
push(color("dim", continued ? " │ " : " ") + line, section);
|
|
129
|
+
};
|
|
130
|
+
const pushBody = (
|
|
131
|
+
body: string,
|
|
132
|
+
section: BtwToolIoSection,
|
|
133
|
+
limit: number,
|
|
134
|
+
input: boolean,
|
|
135
|
+
): void => {
|
|
136
|
+
const raw = sanitizeBtwText(body).replace(/\t/g, " ").replace(/\n+$/, "");
|
|
137
|
+
if (!raw.trim()) {
|
|
138
|
+
pushRail(color("dim", "(empty)"), section, input);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const sourceLines = raw.split("\n");
|
|
143
|
+
const wrapped: string[] = [];
|
|
144
|
+
if (!input) {
|
|
145
|
+
// renderBtwToolText already performs ANSI-safe wrapping for every source
|
|
146
|
+
// line; keep all wrapped rows instead of indexing by source line.
|
|
147
|
+
wrapped.push(...renderBtwToolText(
|
|
148
|
+
raw,
|
|
149
|
+
contentWidth,
|
|
150
|
+
theme,
|
|
151
|
+
serializedInput(options.input),
|
|
152
|
+
options.isError,
|
|
153
|
+
));
|
|
154
|
+
} else {
|
|
155
|
+
for (const sourceLine of sourceLines) {
|
|
156
|
+
const rendered = styledInputLine(sourceLine, theme);
|
|
157
|
+
const wrappedLines = wrapTextWithAnsi(rendered, contentWidth);
|
|
158
|
+
wrapped.push(...(wrappedLines.length > 0 ? wrappedLines : [rendered]));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const truncated = wrapped.length > limit;
|
|
163
|
+
const visible = truncated ? wrapped.slice(0, limit) : wrapped;
|
|
164
|
+
for (const line of visible) pushRail(line, section, input);
|
|
165
|
+
if (truncated) {
|
|
166
|
+
const hidden = wrapped.length - visible.length;
|
|
167
|
+
pushRail(color("dim", `… +${hidden} more lines`), section, input);
|
|
168
|
+
showMoreRows[section] = lines.length - 1;
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const inputText = formatBtwToolInputArgs(options.input);
|
|
173
|
+
if (inputText.trim()) {
|
|
174
|
+
pushHeader("├", "Input");
|
|
175
|
+
pushBody(inputText, "input", maxInputLines, true);
|
|
176
|
+
push(color("dim", " │"), null);
|
|
177
|
+
}
|
|
178
|
+
pushHeader("└", "Output");
|
|
179
|
+
pushBody(options.output.trim() ? options.output : "Done", "output", maxOutputLines, false);
|
|
180
|
+
|
|
181
|
+
return { lines, lineSections, showMoreRows };
|
|
182
|
+
}
|
|
@@ -370,7 +370,8 @@ describe("BTW transcript message layout", () => {
|
|
|
370
370
|
expect((component as any).expandedToolId).toBeNull();
|
|
371
371
|
component.handleInput("w");
|
|
372
372
|
const preview = component.render(80).join("\n");
|
|
373
|
-
expect(preview).toContain("Input
|
|
373
|
+
expect(preview).toContain("Input");
|
|
374
|
+
expect(preview).toContain("├ Input");
|
|
374
375
|
expect(preview).toContain("Output");
|
|
375
376
|
component.handleInput("g");
|
|
376
377
|
const beforeWheel = (component as any).peekToolPreviewScrollOffset as number;
|
|
@@ -541,7 +542,7 @@ describe("BTW transcript message layout", () => {
|
|
|
541
542
|
isError: false,
|
|
542
543
|
input: { path: "full.txt" },
|
|
543
544
|
output: { content: [{ type: "text", text: "full output" }] },
|
|
544
|
-
details: { durationMs: 3 },
|
|
545
|
+
details: { content: [{ type: "text", text: "full output" }], durationMs: 3 },
|
|
545
546
|
diff: "@@ -1 +1 @@\n",
|
|
546
547
|
};
|
|
547
548
|
let dismissed = 0;
|
|
@@ -583,7 +584,10 @@ describe("BTW transcript message layout", () => {
|
|
|
583
584
|
const output = component.render(80).join("\n");
|
|
584
585
|
expect(output).toContain("BTW Tool Output");
|
|
585
586
|
expect(output).toContain("full.txt");
|
|
587
|
+
expect(output).toContain("full output");
|
|
586
588
|
expect(output).toContain("durationMs");
|
|
589
|
+
expect(output).not.toContain('"content"');
|
|
590
|
+
expect(output).not.toContain('"text"');
|
|
587
591
|
expect(output).toContain("Diff:");
|
|
588
592
|
component.handleInput("\x1b");
|
|
589
593
|
expect((component as any).toolPreviewParent).toBeNull();
|
package/extensions/btw.ts
CHANGED
|
@@ -56,6 +56,7 @@ import {
|
|
|
56
56
|
renderBtwScrollRule,
|
|
57
57
|
renderBtwToolText,
|
|
58
58
|
} from "./btw/render-utils.ts";
|
|
59
|
+
import { renderBtwToolOutput } from "./btw/tool-output.ts";
|
|
59
60
|
import {
|
|
60
61
|
BTW_TRANSCRIPT_SCHEMA_VERSION,
|
|
61
62
|
BtwTranscriptStore,
|
|
@@ -434,8 +435,23 @@ function buildBtwSeedState(
|
|
|
434
435
|
};
|
|
435
436
|
}
|
|
436
437
|
|
|
438
|
+
function extractToolText(value: unknown): string | undefined {
|
|
439
|
+
if (Array.isArray(value)) {
|
|
440
|
+
const text = value
|
|
441
|
+
.filter((item): item is Record<string, unknown> => isRecord(item) && item.type === "text" && typeof item.text === "string")
|
|
442
|
+
.map((item) => item.text as string)
|
|
443
|
+
.join("\n");
|
|
444
|
+
return text || undefined;
|
|
445
|
+
}
|
|
446
|
+
if (!isRecord(value)) return undefined;
|
|
447
|
+
if (Array.isArray(value.content)) {
|
|
448
|
+
return extractToolText(value.content);
|
|
449
|
+
}
|
|
450
|
+
return value.type === "text" && typeof value.text === "string" ? value.text : undefined;
|
|
451
|
+
}
|
|
452
|
+
|
|
437
453
|
function formatToolPreview(value: unknown): string {
|
|
438
|
-
if (value === undefined) {
|
|
454
|
+
if (value === undefined || value === null) {
|
|
439
455
|
return "";
|
|
440
456
|
}
|
|
441
457
|
|
|
@@ -443,8 +459,11 @@ function formatToolPreview(value: unknown): string {
|
|
|
443
459
|
return value;
|
|
444
460
|
}
|
|
445
461
|
|
|
462
|
+
const text = extractToolText(value);
|
|
463
|
+
if (text !== undefined) return text;
|
|
464
|
+
|
|
446
465
|
try {
|
|
447
|
-
const preview = JSON.stringify(value);
|
|
466
|
+
const preview = JSON.stringify(value, null, 2);
|
|
448
467
|
if (!preview || preview === "{}") {
|
|
449
468
|
return "";
|
|
450
469
|
}
|
|
@@ -457,6 +476,20 @@ function formatToolPreview(value: unknown): string {
|
|
|
457
476
|
}
|
|
458
477
|
}
|
|
459
478
|
|
|
479
|
+
function formatToolDetails(value: unknown, output: string): string {
|
|
480
|
+
if (!isRecord(value) || !Array.isArray(value.content)) {
|
|
481
|
+
return formatToolPreview(value);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
const content = extractToolText(value);
|
|
485
|
+
const remaining = Object.fromEntries(
|
|
486
|
+
Object.entries(value).filter(([key]) => key !== "content"),
|
|
487
|
+
);
|
|
488
|
+
const remainingText = formatToolPreview(remaining);
|
|
489
|
+
if (content === output || !remainingText) return remainingText;
|
|
490
|
+
return formatToolPreview(value);
|
|
491
|
+
}
|
|
492
|
+
|
|
460
493
|
function createEmptyTranscriptState(): BtwTranscriptState {
|
|
461
494
|
return {
|
|
462
495
|
entries: [],
|
|
@@ -2085,21 +2118,23 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
2085
2118
|
|
|
2086
2119
|
private buildToolPreviewLines(block: PeekBlock, innerWidth: number): string[] {
|
|
2087
2120
|
// Keep the preview read-only and complete. The viewport, not the data,
|
|
2088
|
-
// supplies the bound: only the visible slice is emitted below.
|
|
2089
|
-
//
|
|
2090
|
-
|
|
2121
|
+
// supplies the bound: only the visible slice is emitted below. The local
|
|
2122
|
+
// renderer owns the complete Input/Output card while the outer frame owns
|
|
2123
|
+
// the viewport and scrollbar.
|
|
2091
2124
|
const input = block.toolInput || (block.type === "tool-call" ? block.text : "") || "(no input)";
|
|
2092
2125
|
const output = block.toolOutput || (block.type === "tool-result" ? block.text : "") || "(no output)";
|
|
2126
|
+
const rendered = renderBtwToolOutput({
|
|
2127
|
+
input,
|
|
2128
|
+
output,
|
|
2129
|
+
width: Math.max(1, innerWidth - 1),
|
|
2130
|
+
isError: block.isError === true,
|
|
2131
|
+
}, this.theme);
|
|
2093
2132
|
const lines: string[] = [];
|
|
2094
2133
|
if (block.streaming) {
|
|
2095
2134
|
lines.push(this.theme.fg("warning", "Status: STREAMING"));
|
|
2096
2135
|
lines.push("");
|
|
2097
2136
|
}
|
|
2098
|
-
lines.push(
|
|
2099
|
-
lines.push(...renderBtwToolText(input, bodyWidth, this.theme).map((line) => ` ${line}`));
|
|
2100
|
-
lines.push("");
|
|
2101
|
-
lines.push(this.theme.fg(block.isError ? "error" : "toolTitle", this.theme.bold(`Output${block.isError ? " (error)" : ""}:`)));
|
|
2102
|
-
lines.push(...renderBtwToolText(output, bodyWidth, this.theme, block.toolInput, block.isError).map((line) => ` ${line}`));
|
|
2137
|
+
lines.push(...rendered.lines);
|
|
2103
2138
|
return lines.length > 0 ? lines : ["(no tool data)"];
|
|
2104
2139
|
}
|
|
2105
2140
|
|
|
@@ -2111,10 +2146,10 @@ export class BtwOverlayComponent extends Container implements Focusable {
|
|
|
2111
2146
|
const hydrated = { ...block };
|
|
2112
2147
|
const input = formatToolPreview(artifact.input);
|
|
2113
2148
|
const output = formatToolPreview(artifact.output);
|
|
2114
|
-
const details =
|
|
2149
|
+
const details = formatToolDetails(artifact.details, output);
|
|
2115
2150
|
if (input) hydrated.toolInput = input;
|
|
2116
2151
|
if (output) hydrated.toolOutput = output;
|
|
2117
|
-
if (details) {
|
|
2152
|
+
if (details && details.trim() !== output.trim()) {
|
|
2118
2153
|
hydrated.toolOutput = `${hydrated.toolOutput || "(no output)"}\n\nDetails:\n${details}`;
|
|
2119
2154
|
}
|
|
2120
2155
|
if (artifact.diff) {
|
package/package.json
CHANGED