fix(coding-agent): off-by-one error in bash output 'earlier lines' count

fixes #921
This commit is contained in:
Mario Zechner 2026-01-24 03:25:55 +01:00
parent 48fc57f321
commit 3235926eed
2 changed files with 7 additions and 3 deletions

View file

@ -368,7 +368,6 @@ export class ToolExecutionComponent extends Container {
this.contentBox.addChild(new Text(`\n${styledOutput}`, 0, 0));
} else {
// Use visual line truncation when collapsed with width-aware caching
const textContent = `\n${styledOutput}`;
let cachedWidth: number | undefined;
let cachedLines: string[] | undefined;
let cachedSkipped: number | undefined;
@ -376,7 +375,7 @@ export class ToolExecutionComponent extends Container {
this.contentBox.addChild({
render: (width: number) => {
if (cachedLines === undefined || cachedWidth !== width) {
const result = truncateToVisualLines(textContent, BASH_PREVIEW_LINES, width);
const result = truncateToVisualLines(styledOutput, BASH_PREVIEW_LINES, width);
cachedLines = result.visualLines;
cachedSkipped = result.skippedCount;
cachedWidth = width;
@ -387,7 +386,8 @@ export class ToolExecutionComponent extends Container {
` ${keyHint("expandTools", "to expand")})`;
return ["", hint, ...cachedLines];
}
return cachedLines;
// Add blank line for spacing (matches expanded case)
return ["", ...cachedLines];
},
invalidate: () => {
cachedWidth = undefined;