fix: truncate bash output lines
This commit is contained in:
parent
2dd8a78738
commit
dff18c834b
1 changed files with 10 additions and 6 deletions
|
|
@ -8,6 +8,8 @@ import { getToolDisplayName } from "src/tools/index.js";
|
|||
import { ColoredDiff } from "./ColoredDiff.js";
|
||||
import { ChecklistDisplay } from "./components/ChecklistDisplay.js";
|
||||
|
||||
const MAX_BASH_OUTPUT_LINES = 4;
|
||||
|
||||
interface ToolResultSummaryProps {
|
||||
toolName?: string;
|
||||
content: string;
|
||||
|
|
@ -74,8 +76,8 @@ const ToolResultSummary: React.FC<ToolResultSummaryProps> = ({
|
|||
const actualOutput = isStderr ? content.slice(7).trim() : content;
|
||||
const outputLines = actualOutput.split("\n");
|
||||
|
||||
if (outputLines.length <= 16) {
|
||||
// Show actual output for 16 lines or fewer
|
||||
if (outputLines.length <= MAX_BASH_OUTPUT_LINES) {
|
||||
// Show actual output for MAX_BASH_OUTPUT_LINES lines or fewer
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Box>
|
||||
|
|
@ -88,8 +90,8 @@ const ToolResultSummary: React.FC<ToolResultSummaryProps> = ({
|
|||
</Box>
|
||||
);
|
||||
} else {
|
||||
// Show first 16 lines with ellipsis for more than 16 lines
|
||||
const first16Lines = outputLines.slice(0, 16).join("\n");
|
||||
// Show first MAX_BASH_OUTPUT_LINES lines with ellipsis for more lines
|
||||
const firstLines = outputLines.slice(0, MAX_BASH_OUTPUT_LINES).join("\n");
|
||||
return (
|
||||
<Box flexDirection="column">
|
||||
<Box>
|
||||
|
|
@ -97,10 +99,12 @@ const ToolResultSummary: React.FC<ToolResultSummaryProps> = ({
|
|||
<Text color="gray"> Terminal output:</Text>
|
||||
</Box>
|
||||
<Box paddingLeft={2}>
|
||||
<Text color={isStderr ? "red" : "white"}>{first16Lines}</Text>
|
||||
<Text color={isStderr ? "red" : "white"}>{firstLines}</Text>
|
||||
</Box>
|
||||
<Box paddingLeft={2}>
|
||||
<Text color="gray">...</Text>
|
||||
<Text color="gray">
|
||||
... +{outputLines.length - MAX_BASH_OUTPUT_LINES} lines
|
||||
</Text>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue