mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 10:03:27 +00:00
Fix bash tool visual line truncation
Use visual line counting (accounting for line wrapping) instead of logical line counting for bash tool output in collapsed mode. Now consistent with bash-execution.ts behavior. - Add shared truncateToVisualLines utility - Update tool-execution.ts to use Box for bash with visual truncation - Update bash-execution.ts to use shared utility - Pass TUI to ToolExecutionComponent for terminal width access Fixes #275
This commit is contained in:
parent
31f4a588fd
commit
7ad8a8c447
5 changed files with 163 additions and 58 deletions
|
|
@ -12,6 +12,7 @@ import {
|
|||
} from "../../../core/tools/truncate.js";
|
||||
import { theme } from "../theme/theme.js";
|
||||
import { DynamicBorder } from "./dynamic-border.js";
|
||||
import { truncateToVisualLines } from "./visual-truncate.js";
|
||||
|
||||
// Preview line limit when not expanded (matches tool execution behavior)
|
||||
const PREVIEW_LINES = 20;
|
||||
|
|
@ -134,15 +135,15 @@ export class BashExecutionComponent extends Container {
|
|||
const displayText = availableLines.map((line) => theme.fg("muted", line)).join("\n");
|
||||
this.contentContainer.addChild(new Text(`\n${displayText}`, 1, 0));
|
||||
} else {
|
||||
// Render preview lines, then cap at PREVIEW_LINES visual lines
|
||||
const tempText = new Text(
|
||||
`\n${previewLogicalLines.map((line) => theme.fg("muted", line)).join("\n")}`,
|
||||
1,
|
||||
0,
|
||||
// Use shared visual truncation utility
|
||||
const styledOutput = previewLogicalLines.map((line) => theme.fg("muted", line)).join("\n");
|
||||
const { visualLines } = truncateToVisualLines(
|
||||
`\n${styledOutput}`,
|
||||
PREVIEW_LINES,
|
||||
this.ui.terminal.columns,
|
||||
1, // padding
|
||||
);
|
||||
const visualLines = tempText.render(this.ui.terminal.columns);
|
||||
const truncatedVisualLines = visualLines.slice(-PREVIEW_LINES);
|
||||
this.contentContainer.addChild({ render: () => truncatedVisualLines, invalidate: () => {} });
|
||||
this.contentContainer.addChild({ render: () => visualLines, invalidate: () => {} });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue