Fix: Properly truncate terminal output including stderr lines #7933
+52
−21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
In the CLI TUI, when the
runTerminalCommand
tool returned output that included both stdout and stderr, the truncation logic inToolResultSummary
was incorrectly only counting stderr lines for truncation, not the total combined output lines.This meant that commands producing many lines of stdout + stderr would not show the '... +N lines' truncation indicator, potentially overwhelming the terminal display.
Root Cause
The
runTerminalCommand
tool combines stdout and stderr in this format:stdout_content
stdout_content\nStderr: stderr_content
However, the
ToolResultSummary
component had faulty logic that would:Solution
Fixed by:
content.split('\n').length
)Testing
Verified the fix handles these cases correctly:
Files Changed
extensions/cli/src/ui/ToolResultSummary.tsx
: Fixed bash output truncation logicSummary by cubic
Fixes terminal output truncation for Bash tool results by counting both stdout and stderr lines, so the “… +N lines” indicator shows correctly and long outputs don’t flood the TUI. Preserves proper color coding for stdout (white) and stderr (red).