diff --git a/packages/webui/src/components/toolcalls/GenericToolCall.tsx b/packages/webui/src/components/toolcalls/GenericToolCall.tsx index 4dc00fc9c..5e92ee865 100644 --- a/packages/webui/src/components/toolcalls/GenericToolCall.tsx +++ b/packages/webui/src/components/toolcalls/GenericToolCall.tsx @@ -6,7 +6,7 @@ * Generic tool call component - handles all tool call types as fallback */ -import type { FC } from 'react'; +import { useState, type FC } from 'react'; import { ToolCallContainer, ToolCallCard, @@ -17,6 +17,45 @@ import { } from './shared/index.js'; import type { BaseToolCallProps } from './shared/index.js'; import { getToolDisplayLabel } from './labelUtils.js'; +import { MarkdownRenderer } from '../messages/MarkdownRenderer/MarkdownRenderer.js'; + +const COLLAPSED_HEIGHT = 200; +const EXPAND_THRESHOLD = 400; + +const CollapsibleOutput: FC<{ content: string }> = ({ content }) => { + const [isExpanded, setIsExpanded] = useState(false); + const isLongContent = content.length > EXPAND_THRESHOLD; + + return ( +
+
+ +
+ {isLongContent && ( +
+ +
+ )} +
+ ); +}; /** * Generic tool call component that can display any tool call type @@ -55,18 +94,13 @@ export const GenericToolCall: FC = ({ const isLong = output.length > 150; if (isLong) { - const truncatedOutput = - output.length > 300 ? output.substring(0, 300) + '...' : output; - return (
{operationText}
-
- {truncatedOutput} -
+
); diff --git a/packages/webui/src/components/toolcalls/WebFetchToolCall.tsx b/packages/webui/src/components/toolcalls/WebFetchToolCall.tsx index 7af3da775..d6ad482cf 100644 --- a/packages/webui/src/components/toolcalls/WebFetchToolCall.tsx +++ b/packages/webui/src/components/toolcalls/WebFetchToolCall.tsx @@ -16,6 +16,7 @@ import { } from './shared/index.js'; import type { BaseToolCallProps } from './shared/index.js'; import { getToolDisplayLabel } from './labelUtils.js'; +import { MarkdownRenderer } from '../messages/MarkdownRenderer/MarkdownRenderer.js'; type WebVariant = 'fetch' | 'search'; @@ -70,24 +71,28 @@ const OutputCard: FC<{ OUT
-
-              {content}
-            
+ {isError ? ( +
+                {content}
+              
+ ) : ( +
+ +
+ )}