From 8931da0b0ed8b920580c4b30f9bb17e06adb2533 Mon Sep 17 00:00:00 2001 From: Charles Packer Date: Mon, 9 Feb 2026 20:59:27 -0800 Subject: [PATCH] fix(cli): clip oversized shell tool output in collapsed tool results (#883) Co-authored-by: Letta --- src/cli/components/CollapsedOutputDisplay.tsx | 26 ++++++++++++++++++- src/cli/components/ToolCallMessageRich.tsx | 2 +- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/cli/components/CollapsedOutputDisplay.tsx b/src/cli/components/CollapsedOutputDisplay.tsx index 558a2e3..cfddf63 100644 --- a/src/cli/components/CollapsedOutputDisplay.tsx +++ b/src/cli/components/CollapsedOutputDisplay.tsx @@ -10,6 +10,7 @@ const PREFIX_WIDTH = 5; // " ⎿ " or " " interface CollapsedOutputDisplayProps { output: string; // Full output from completion maxLines?: number; // Max lines to show before collapsing (Infinity = show all) + maxChars?: number; // Max chars to show before clipping } /** @@ -22,12 +23,24 @@ export const CollapsedOutputDisplay = memo( ({ output, maxLines = DEFAULT_COLLAPSED_LINES, + maxChars, }: CollapsedOutputDisplayProps) => { const columns = useTerminalWidth(); const contentWidth = Math.max(0, columns - PREFIX_WIDTH); + let displayOutput = output; + let clippedByChars = false; + if ( + typeof maxChars === "number" && + maxChars > 0 && + output.length > maxChars + ) { + displayOutput = `${output.slice(0, maxChars)}…`; + clippedByChars = true; + } + // Keep empty lines for accurate display (don't filter them out) - const lines = output.split("\n"); + const lines = displayOutput.split("\n"); // Remove trailing empty line from final newline if (lines.length > 0 && lines[lines.length - 1] === "") { lines.pop(); @@ -75,6 +88,17 @@ export const CollapsedOutputDisplay = memo( )} + {/* Character clipping hint */} + {clippedByChars && ( + + + {" "} + + + … output clipped + + + )} ); }, diff --git a/src/cli/components/ToolCallMessageRich.tsx b/src/cli/components/ToolCallMessageRich.tsx index 85e10b6..6475a2c 100644 --- a/src/cli/components/ToolCallMessageRich.tsx +++ b/src/cli/components/ToolCallMessageRich.tsx @@ -855,7 +855,7 @@ export const ToolCallMessage = memo( line.phase === "finished" && line.resultText && line.resultOk !== false && ( - + )} {/* Tool result for non-shell tools or shell tool errors */}