Skip to content

Commit d2e34c9

Browse files
authored
fix: improve tool argument display truncation and formatting (#715)
1 parent 46eed4f commit d2e34c9

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/ui/AgentProgress/NestedMessage.tsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ function formatToolArgs(
7575
const firstLine = cmd.split('\n')[0];
7676
const truncated =
7777
firstLine.length > 60 ? `${firstLine.substring(0, 60)}...` : firstLine;
78-
return cmd.includes('\n') ? `${truncated}` : truncated;
78+
const result = cmd.includes('\n') ? `${truncated}` : truncated;
79+
80+
// Final length protection to ensure max 200 characters
81+
return result.length > 200 ? `${result.substring(0, 200)}...` : result;
7982
}
8083
}
8184

@@ -122,6 +125,18 @@ export function LogItemRenderer({ item }: LogItemRendererProps) {
122125
? toolUse.description || formatToolArgs(toolUse.name, toolUse.input, true)
123126
: toolUse.description ||
124127
formatToolArgs(toolUse.name, toolUse.input, false);
128+
129+
// Final args length protection for normal mode (handle description case)
130+
// Also ensure single line display by taking only first line
131+
let displayArgs = args;
132+
if (!transcriptMode) {
133+
const firstLine = args.split('\n')[0];
134+
displayArgs =
135+
firstLine.length > 200
136+
? `${firstLine.substring(0, 200)}...`
137+
: firstLine;
138+
}
139+
125140
const resultText = toolResult
126141
? extractResultText(toolResult).trim()
127142
: '...';
@@ -146,7 +161,7 @@ export function LogItemRenderer({ item }: LogItemRendererProps) {
146161
<Text color="cyan" bold>
147162
{toolUse.name}
148163
</Text>
149-
<Text color="gray">({args})</Text>
164+
<Text color="gray">({displayArgs})</Text>
150165
</Box>
151166
{toolResult && (
152167
<Box paddingLeft={2}>

0 commit comments

Comments
 (0)