import type { ToolCallMessagePartComponent } from "@assistant-ui/react"; import { CheckIcon, ChevronDownIcon, ChevronUpIcon, XCircleIcon } from "lucide-react"; import { useState } from "react"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; export const ToolFallback: ToolCallMessagePartComponent = ({ toolName, argsText, result, status, }) => { const [isCollapsed, setIsCollapsed] = useState(true); const isCancelled = status?.type === "incomplete" && status.reason === "cancelled"; const cancelledReason = isCancelled && status.error ? typeof status.error === "string" ? status.error : JSON.stringify(status.error) : null; return (
{isCancelled ? "Cancelled tool: " : "Used tool: "} {toolName}
Cancelled reason:
{cancelledReason}
{argsText}
Result:
{typeof result === "string" ? result : JSON.stringify(result, null, 2)}