fix: tool call UI cleanup (#515)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Charles Packer
2026-01-11 12:22:22 -08:00
committed by GitHub
parent ab3d429925
commit c07a5edd88
6 changed files with 110 additions and 29 deletions

View File

@@ -401,7 +401,7 @@ export function AdvancedDiffRenderer(
<Text dimColor></Text>
</Text>
</Box>
<Box flexGrow={1}>
<Box flexGrow={1} width={Math.max(0, columns - noChangesGutter)}>
<Text wrap="wrap">{header}</Text>
</Box>
</Box>
@@ -410,7 +410,7 @@ export function AdvancedDiffRenderer(
<Box width={noChangesGutter} flexShrink={0}>
<Text>{" "}</Text>
</Box>
<Box flexGrow={1}>
<Box flexGrow={1} width={Math.max(0, columns - noChangesGutter)}>
<Text dimColor>
No changes to <Text bold>{relative}</Text> (file content
identical)
@@ -435,7 +435,7 @@ export function AdvancedDiffRenderer(
<Text dimColor></Text>
</Text>
</Box>
<Box flexGrow={1}>
<Box flexGrow={1} width={Math.max(0, columns - toolResultGutter)}>
<Text wrap="wrap">{header}</Text>
</Box>
</Box>
@@ -443,7 +443,7 @@ export function AdvancedDiffRenderer(
<Box width={toolResultGutter} flexShrink={0}>
<Text>{" "}</Text>
</Box>
<Box flexGrow={1}>
<Box flexGrow={1} width={Math.max(0, columns - toolResultGutter)}>
<Text
dimColor
>{`Showing ~${ADV_DIFF_CONTEXT_LINES} context line${ADV_DIFF_CONTEXT_LINES === 1 ? "" : "s"}`}</Text>

View File

@@ -69,10 +69,12 @@ export const ToolCallMessage = memo(
line,
precomputedDiffs,
lastPlanFilePath,
isStreaming,
}: {
line: ToolCallLine;
precomputedDiffs?: Map<string, AdvancedDiffSuccess>;
lastPlanFilePath?: string | null;
isStreaming?: boolean;
}) => {
const columns = useTerminalWidth();
@@ -124,14 +126,36 @@ export const ToolCallMessage = memo(
}
}
// Format arguments for display using the old formatting logic
// Pass rawName to enable special formatting for file tools
const formatted = formatArgsDisplay(argsText, rawName);
// Hide args for question tool (shown in result instead)
const args = isQuestionTool(rawName) ? "" : `(${formatted.display})`;
const rightWidth = Math.max(0, columns - 2); // gutter is 2 cols
// Determine args display:
// - Question tool: hide args (shown in result instead)
// - Still streaming + phase "ready": args may be incomplete, show ellipsis
// - Phase "running"/"finished" or stream done: args complete, show formatted
let args = "";
if (!isQuestionTool(rawName)) {
// Args are complete once running, finished, or stream is done
const argsComplete =
line.phase === "running" || line.phase === "finished" || !isStreaming;
if (!argsComplete) {
args = "(…)";
} else {
const formatted = formatArgsDisplay(argsText, rawName);
// Normalize newlines to spaces to prevent forced line breaks
const normalizedDisplay = formatted.display.replace(/\n/g, " ");
// For max 2 lines: boxWidth * 2, minus parens (2) and margin (2)
const argsBoxWidth = rightWidth - displayName.length;
const maxArgsChars = Math.max(0, argsBoxWidth * 2 - 4);
const needsTruncation = normalizedDisplay.length > maxArgsChars;
const truncatedDisplay = needsTruncation
? `${normalizedDisplay.slice(0, maxArgsChars - 1)}`
: normalizedDisplay;
args = `(${truncatedDisplay})`;
}
}
// If name exceeds available width, fall back to simple wrapped rendering
const fallback = displayName.length >= rightWidth;