diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 8a96453f..2c0ce287 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -24,6 +24,10 @@ - Unified collision reporting with `ResourceDiagnostic` type for all resource types ([#645](https://github.com/badlogic/pi-mono/issues/645)) - Show provider alongside the model in the footer if multiple providers are available +### Fixed + +- Off-by-one error in bash output "earlier lines" count caused by counting spacing newline as hidden content ([#921](https://github.com/badlogic/pi-mono/issues/921)) + ### Changed - `/reload` now re-renders the entire scrollback so updated extension components are visible immediately diff --git a/packages/coding-agent/src/modes/interactive/components/tool-execution.ts b/packages/coding-agent/src/modes/interactive/components/tool-execution.ts index 0df2f4d0..52bda96d 100644 --- a/packages/coding-agent/src/modes/interactive/components/tool-execution.ts +++ b/packages/coding-agent/src/modes/interactive/components/tool-execution.ts @@ -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;