fix: tool call UI cleanup (#515)
Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user