mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 07:03:25 +00:00
Fix bash execution component to limit by visual lines instead of logical lines
This commit is contained in:
parent
a38e619095
commit
d67c69c6e9
1 changed files with 20 additions and 6 deletions
|
|
@ -26,10 +26,12 @@ export class BashExecutionComponent extends Container {
|
||||||
private fullOutputPath?: string;
|
private fullOutputPath?: string;
|
||||||
private expanded = false;
|
private expanded = false;
|
||||||
private contentContainer: Container;
|
private contentContainer: Container;
|
||||||
|
private ui: TUI;
|
||||||
|
|
||||||
constructor(command: string, ui: TUI) {
|
constructor(command: string, ui: TUI) {
|
||||||
super();
|
super();
|
||||||
this.command = command;
|
this.command = command;
|
||||||
|
this.ui = ui;
|
||||||
|
|
||||||
const borderColor = (str: string) => theme.fg("bashMode", str);
|
const borderColor = (str: string) => theme.fg("bashMode", str);
|
||||||
|
|
||||||
|
|
@ -115,9 +117,8 @@ export class BashExecutionComponent extends Container {
|
||||||
const availableLines = contextTruncation.content ? contextTruncation.content.split("\n") : [];
|
const availableLines = contextTruncation.content ? contextTruncation.content.split("\n") : [];
|
||||||
|
|
||||||
// Apply preview truncation based on expanded state
|
// Apply preview truncation based on expanded state
|
||||||
const maxDisplayLines = this.expanded ? availableLines.length : PREVIEW_LINES;
|
const previewLogicalLines = availableLines.slice(-PREVIEW_LINES);
|
||||||
const displayLines = availableLines.slice(-maxDisplayLines); // Show last N lines (tail)
|
const hiddenLineCount = availableLines.length - previewLogicalLines.length;
|
||||||
const hiddenLineCount = availableLines.length - displayLines.length;
|
|
||||||
|
|
||||||
// Rebuild content container
|
// Rebuild content container
|
||||||
this.contentContainer.clear();
|
this.contentContainer.clear();
|
||||||
|
|
@ -127,9 +128,22 @@ export class BashExecutionComponent extends Container {
|
||||||
this.contentContainer.addChild(header);
|
this.contentContainer.addChild(header);
|
||||||
|
|
||||||
// Output
|
// Output
|
||||||
if (displayLines.length > 0) {
|
if (availableLines.length > 0) {
|
||||||
const displayText = displayLines.map((line) => theme.fg("muted", line)).join("\n");
|
if (this.expanded) {
|
||||||
this.contentContainer.addChild(new Text("\n" + displayText, 1, 0));
|
// Show all lines
|
||||||
|
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,
|
||||||
|
);
|
||||||
|
const visualLines = tempText.render(this.ui.terminal.columns);
|
||||||
|
const truncatedVisualLines = visualLines.slice(-PREVIEW_LINES);
|
||||||
|
this.contentContainer.addChild({ render: () => truncatedVisualLines, invalidate: () => {} });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loader or status
|
// Loader or status
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue