({
toolName,
state,
args,
result,
isLatestMessage,
status,
}: ToolInvocationProps)
| 24 | } |
| 25 | |
| 26 | export function ToolInvocation({ |
| 27 | toolName, |
| 28 | state, |
| 29 | args, |
| 30 | result, |
| 31 | isLatestMessage, |
| 32 | status, |
| 33 | }: ToolInvocationProps) { |
| 34 | const [isExpanded, setIsExpanded] = useState(false); |
| 35 | |
| 36 | const variants = { |
| 37 | collapsed: { |
| 38 | height: 0, |
| 39 | opacity: 0, |
| 40 | }, |
| 41 | expanded: { |
| 42 | height: "auto", |
| 43 | opacity: 1, |
| 44 | }, |
| 45 | }; |
| 46 | |
| 47 | const getStatusIcon = () => { |
| 48 | if (state === "call") { |
| 49 | if (isLatestMessage && status !== "ready") { |
| 50 | return <Loader2 className="animate-spin h-3.5 w-3.5 text-primary/70" />; |
| 51 | } |
| 52 | return ( |
| 53 | <Circle className="h-3.5 w-3.5 fill-muted-foreground/10 text-muted-foreground/70" /> |
| 54 | ); |
| 55 | } |
| 56 | return <CheckCircle2 size={14} className="text-primary/90" />; |
| 57 | }; |
| 58 | |
| 59 | const getStatusClass = () => { |
| 60 | if (state === "call") { |
| 61 | if (isLatestMessage && status !== "ready") { |
| 62 | return "text-primary"; |
| 63 | } |
| 64 | return "text-muted-foreground"; |
| 65 | } |
| 66 | return "text-primary"; |
| 67 | }; |
| 68 | |
| 69 | const formatContent = (content: any): string => { |
| 70 | try { |
| 71 | if (typeof content === "string") { |
| 72 | try { |
| 73 | const parsed = JSON.parse(content); |
| 74 | return JSON.stringify(parsed, null, 2); |
| 75 | } catch { |
| 76 | return content; |
| 77 | } |
| 78 | } |
| 79 | return JSON.stringify(content, null, 2); |
| 80 | } catch { |
| 81 | return String(content); |
| 82 | } |
| 83 | }; |
nothing calls this directly
no test coverage detected