feat(tools): integrated terminal rendering into launch tool output
- Updated `launch` tool to utilize `renderTerminalOutput` for improved log formatting. - Added `terminalRows` to `LaunchToolDetails` to support structured virtual terminal rendering. - Refactored `BashInteractiveOverlayComponent` to consolidate terminal line reading and styling logic. - Applied sanitization to log text in `toolContent` to prevent rendering issues. - Integrated `styleTerminalRow` in the `launch` tool renderer to maintain consistent UI theme application.
This commit is contained in:
@@ -19,6 +19,7 @@ import { OutputSink, type OutputSummary } from "../session/streaming-output";
|
||||
import { sanitizeWithOptionalSixelPassthrough } from "../utils/sixel";
|
||||
import { resolveOutputMaxColumns, resolveOutputSinkHeadBytes } from "./output-meta";
|
||||
import { formatStatusIcon, replaceTabs } from "./render-utils";
|
||||
import { readTerminalRows, styleTerminalRow } from "./terminal-output";
|
||||
|
||||
export interface BashInteractiveResult extends OutputSummary {
|
||||
exitCode: number | undefined;
|
||||
@@ -225,14 +226,10 @@ class BashInteractiveOverlayComponent implements Component {
|
||||
|
||||
#readViewport(innerWidth: number, maxContentRows: number): string[] {
|
||||
this.#terminal.resize(innerWidth, maxContentRows);
|
||||
const buffer = this.#terminal.buffer.active;
|
||||
const viewportY = buffer.viewportY;
|
||||
const visibleLines: string[] = [];
|
||||
for (let i = 0; i < maxContentRows; i++) {
|
||||
const line = buffer.getLine(viewportY + i)?.translateToString(true) ?? "";
|
||||
visibleLines.push(truncateToWidth(replaceTabs(sanitizeText(line)), innerWidth));
|
||||
}
|
||||
return visibleLines;
|
||||
const viewportY = this.#terminal.buffer.active.viewportY;
|
||||
return readTerminalRows(this.#terminal, viewportY, maxContentRows).map(line =>
|
||||
truncateToWidth(styleTerminalRow(line, this.uiTheme.getFgAnsi("toolOutput")), innerWidth),
|
||||
);
|
||||
}
|
||||
render(width: number): readonly string[] {
|
||||
const safeWidth = Math.max(20, width);
|
||||
|
||||
Reference in New Issue
Block a user