From 5a549cc7da4d5da4661a084ef3ee71b957cdb0e3 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Sun, 7 Dec 2025 01:14:57 +0100 Subject: [PATCH] Restore TUI warning notices for truncated tool output Warnings now shown at bottom of tool execution (outside collapsed area) so users can see truncation occurred even when content is collapsed. --- .../coding-agent/src/tui/tool-execution.ts | 81 +++++++++++++++++-- 1 file changed, 76 insertions(+), 5 deletions(-) diff --git a/packages/coding-agent/src/tui/tool-execution.ts b/packages/coding-agent/src/tui/tool-execution.ts index 6dd9d872..e0071806 100644 --- a/packages/coding-agent/src/tui/tool-execution.ts +++ b/packages/coding-agent/src/tui/tool-execution.ts @@ -128,7 +128,23 @@ export class ToolExecutionComponent extends Container { } } - // Truncation notice is now in the text content itself, TUI just shows it + // Show truncation warning at the bottom (outside collapsed area) + const truncation = this.result.details?.truncation; + const fullOutputPath = this.result.details?.fullOutputPath; + if (truncation?.truncated || fullOutputPath) { + const warnings: string[] = []; + if (fullOutputPath) { + warnings.push(`Full output: ${fullOutputPath}`); + } + if (truncation?.truncated) { + if (truncation.truncatedBy === "lines") { + warnings.push(`Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines`); + } else { + warnings.push(`Truncated: ${truncation.outputLines} lines shown (30KB limit)`); + } + } + text += "\n" + theme.fg("warning", `[${warnings.join(". ")}]`); + } } } else if (this.toolName === "read") { const path = shortenPath(this.args?.file_path || this.args?.path || ""); @@ -158,7 +174,22 @@ export class ToolExecutionComponent extends Container { text += theme.fg("toolOutput", `\n... (${remaining} more lines)`); } - // Truncation notice is now in the text content itself + // Show truncation warning at the bottom (outside collapsed area) + const truncation = this.result.details?.truncation; + if (truncation?.truncated) { + if (truncation.firstLineExceedsLimit) { + text += "\n" + theme.fg("warning", `[First line exceeds 30KB limit]`); + } else if (truncation.truncatedBy === "lines") { + text += + "\n" + + theme.fg( + "warning", + `[Truncated: showing ${truncation.outputLines} of ${truncation.totalLines} lines]`, + ); + } else { + text += "\n" + theme.fg("warning", `[Truncated: ${truncation.outputLines} lines shown (30KB limit)]`); + } + } } } else if (this.toolName === "write") { const path = shortenPath(this.args?.file_path || this.args?.path || ""); @@ -237,7 +268,19 @@ export class ToolExecutionComponent extends Container { } } - // Truncation notice is now in the text content itself + // Show truncation warning at the bottom (outside collapsed area) + const entryLimit = this.result.details?.entryLimitReached; + const truncation = this.result.details?.truncation; + if (entryLimit || truncation?.truncated) { + const warnings: string[] = []; + if (entryLimit) { + warnings.push(`${entryLimit} entries limit`); + } + if (truncation?.truncated) { + warnings.push("30KB limit"); + } + text += "\n" + theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`); + } } } else if (this.toolName === "find") { const pattern = this.args?.pattern || ""; @@ -267,7 +310,19 @@ export class ToolExecutionComponent extends Container { } } - // Truncation notice is now in the text content itself + // Show truncation warning at the bottom (outside collapsed area) + const resultLimit = this.result.details?.resultLimitReached; + const truncation = this.result.details?.truncation; + if (resultLimit || truncation?.truncated) { + const warnings: string[] = []; + if (resultLimit) { + warnings.push(`${resultLimit} results limit`); + } + if (truncation?.truncated) { + warnings.push("30KB limit"); + } + text += "\n" + theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`); + } } } else if (this.toolName === "grep") { const pattern = this.args?.pattern || ""; @@ -301,7 +356,23 @@ export class ToolExecutionComponent extends Container { } } - // Truncation notice is now in the text content itself + // Show truncation warning at the bottom (outside collapsed area) + const matchLimit = this.result.details?.matchLimitReached; + const truncation = this.result.details?.truncation; + const linesTruncated = this.result.details?.linesTruncated; + if (matchLimit || truncation?.truncated || linesTruncated) { + const warnings: string[] = []; + if (matchLimit) { + warnings.push(`${matchLimit} matches limit`); + } + if (truncation?.truncated) { + warnings.push("30KB limit"); + } + if (linesTruncated) { + warnings.push("some lines truncated"); + } + text += "\n" + theme.fg("warning", `[Truncated: ${warnings.join(", ")}]`); + } } } else { // Generic tool