Skip to content

Conversation

continue[bot]
Copy link
Contributor

@continue continue bot commented Sep 23, 2025

Problem

In the CLI TUI, when the runTerminalCommand tool returned output that included both stdout and stderr, the truncation logic in ToolResultSummary 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 only: stdout_content
  • stdout + stderr: stdout_content\nStderr: stderr_content

However, the ToolResultSummary component had faulty logic that would:

  1. Check if content starts with "Stderr:" (which is wrong - it should be "\nStderr:")
  2. If so, only count the stderr portion for line truncation
  3. This missed the total line count when there was both stdout and stderr

Solution

Fixed by:

  1. Counting all lines in the combined output for truncation logic (content.split('\n').length)
  2. Maintaining proper color coding by parsing stdout vs stderr sections separately
  3. Applying truncation based on total line count, not just stderr lines

Testing

Verified the fix handles these cases correctly:

  • stdout only: counts stdout lines
  • stdout + stderr: counts stdout + stderr lines combined
  • empty stdout + stderr: counts all lines
  • Many lines with stderr: properly truncates when > MAX_BASH_OUTPUT_LINES

Files Changed

  • extensions/cli/src/ui/ToolResultSummary.tsx: Fixed bash output truncation logic

Summary 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).

  • Bug Fixes
    • Count all lines in combined output for truncation and the “+N lines” indicator.
    • Parse “\nStderr: ” to split sections and render with correct colors.
    • Truncate to the first MAX_BASH_OUTPUT_LINES across both streams; handles stdout-only and mixed outputs.

Previously, when the runTerminalCommand tool returned combined stdout + stderr output,
the TUI would only count stderr lines for truncation but not the total combined lines.
This meant that commands with many stdout lines + stderr wouldn't show the '... +N lines'
truncation indicator.

The output format from runTerminalCommand is:
- stdout only: just stdout content
- stdout + stderr: 'stdout\nStderr: stderr_content'

Fixed by counting all lines (stdout + stderr) for truncation logic, while still
maintaining proper color coding (white for stdout, red for stderr).

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <[email protected]>
@continue continue bot requested a review from a team as a code owner September 23, 2025 23:06
@continue continue bot requested review from sestinj and removed request for a team September 23, 2025 23:06
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Sep 23, 2025
Copy link

⚠️ PR Title Format

Your PR title doesn't follow the conventional commit format, but this won't block your PR from being merged. We recommend using this format for better project organization.

Expected Format:

<type>[optional scope]: <description>

Examples:

  • feat: add changelog generation support
  • fix: resolve login redirect issue
  • docs: update README with new instructions
  • chore: update dependencies

Valid Types:

feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert

This helps with:

  • 📝 Automatic changelog generation
  • 🚀 Automated semantic versioning
  • 📊 Better project history tracking

This is a non-blocking warning - your PR can still be merged without fixing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:M This PR changes 30-99 lines, ignoring generated files.
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

1 participant