diff --git a/ui/desktop/src/components/ToolCallWithResponse.tsx b/ui/desktop/src/components/ToolCallWithResponse.tsx index 971bfea58f5b..bda8bb31e66b 100644 --- a/ui/desktop/src/components/ToolCallWithResponse.tsx +++ b/ui/desktop/src/components/ToolCallWithResponse.tsx @@ -166,6 +166,11 @@ function ToolCallView({ // Only expand if there are actual results that need to be shown, not just for tool details const isShouldExpand = toolResults.some((v) => v.isExpandToolResults); + // Helper function to truncate long values + const truncate = (str: string, maxLength: number = 50): string => { + return str.length > maxLength ? str.substring(0, maxLength) + '...' : str; + }; + // Function to create a descriptive representation of what the tool is doing const getToolDescription = () => { const args = toolCall.arguments as Record; @@ -176,11 +181,6 @@ function ToolCallView({ return typeof value === 'string' ? value : JSON.stringify(value); }; - // Helper function to truncate long values - const truncate = (str: string, maxLength: number = 50): string => { - return str.length > maxLength ? str.substring(0, maxLength) + '...' : str; - }; - // Generate descriptive text based on tool type switch (toolName) { case 'text_editor': @@ -292,20 +292,8 @@ function ToolCallView({ return 'poking around...'; default: { - // Fallback to showing key parameters for unknown tools - const entries = Object.entries(args); - if (entries.length === 0) return null; - - // For a single parameter, show key and truncated value - if (entries.length === 1) { - const [key, value] = entries[0]; - const stringValue = getStringValue(value); - const truncatedValue = truncate(stringValue, 30); - return `${key}: ${truncatedValue}`; - } - - // For multiple parameters, just show the keys - return entries.map(([key]) => key).join(', '); + // For unknown tools, always return null to fall back to tool name + return null; } } @@ -325,8 +313,9 @@ function ToolCallView({ if (description) { return description; } - // Fallback to the original tool name formatting - return snakeToTitleCase(toolCall.name.substring(toolCall.name.lastIndexOf('__') + 2)); + // Fallback to formatted and truncated tool name using shared truncate function + const toolName = toolCall.name.substring(toolCall.name.lastIndexOf('__') + 2); + return truncate(snakeToTitleCase(toolName)); })()}