diff --git a/extensions/cli/src/ui/ToolResultSummary.tsx b/extensions/cli/src/ui/ToolResultSummary.tsx index 9e2de082435..d22be229ba3 100644 --- a/extensions/cli/src/ui/ToolResultSummary.tsx +++ b/extensions/cli/src/ui/ToolResultSummary.tsx @@ -72,28 +72,59 @@ const ToolResultSummary: React.FC = ({ // Handle terminal command output specially if (toolName === "Bash") { - const isStderr = content.startsWith("Stderr:"); - const actualOutput = isStderr ? content.slice(7).trim() : content; - const outputLines = actualOutput.split("\n"); - - if (outputLines.length <= MAX_BASH_OUTPUT_LINES) { - // Show actual output for MAX_BASH_OUTPUT_LINES lines or fewer - return ( - - - - Terminal output: + // Parse the combined stdout + stderr output + // Format is either: + // - just stdout + // - stdout + "\nStderr: " + stderr + const allLines = content.split("\n"); + const totalLines = allLines.length; + + if (totalLines <= MAX_BASH_OUTPUT_LINES) { + // Show full output for MAX_BASH_OUTPUT_LINES lines or fewer + // Parse out stdout and stderr sections for proper coloring + const stderrIndex = content.indexOf("\nStderr: "); + if (stderrIndex !== -1) { + const stdout = content.slice(0, stderrIndex); + const stderr = content.slice(stderrIndex + 9); // Skip "\nStderr: " + return ( + + + + Terminal output: + + + {stdout && ( + + {stdout.trimEnd()} + + )} + {stderr && ( + + Stderr: {stderr.trimEnd()} + + )} + - - - {actualOutput.trimEnd()} - + ); + } else { + // Only stdout + return ( + + + + Terminal output: + + + + {content.trimEnd()} + + - - ); + ); + } } else { - // Show first MAX_BASH_OUTPUT_LINES lines with ellipsis for more lines - const firstLines = outputLines.slice(0, MAX_BASH_OUTPUT_LINES).join("\n"); + // Show first MAX_BASH_OUTPUT_LINES lines with truncation indicator + const firstLines = allLines.slice(0, MAX_BASH_OUTPUT_LINES).join("\n"); return ( @@ -101,13 +132,13 @@ const ToolResultSummary: React.FC = ({ Terminal output: - + {firstLines.trimEnd()} - ... +{outputLines.length - MAX_BASH_OUTPUT_LINES} lines + ... +{totalLines - MAX_BASH_OUTPUT_LINES} lines