import { useId, useState } from "react"; import { ChevronIcon } from "@chopin/icons"; import { MotionDisclosure, MotionDisclosureIcon } from "@chopin/editor"; import { duration, summarize, toolCopy, workPhase } from "./model"; import { motionContract } from "../motion-contract"; import { motionImmediately } from "../motion-input"; import type { Chat } from "@chopin/protocol"; function ToolCall({ active, tool }: { active: boolean; tool: Chat.Activity }) { let [open, setOpen] = useState(false); let contentId = useId(); let hasDetails = tool.args !== undefined || tool.result !== undefined; let status = tool.status === "running" ? active ? "Running" : "Interrupted" : tool.status === "failed" ? "Failed" : "Done"; let row = ( <> {hasDetails && ( )} {toolCopy(tool.name)} {status} {tool.took !== undefined && {duration(tool.took)}} > ); return (
{tool.args}
{tool.result}