import { useTranslation } from "react-i18next"; import { LuShieldAlert, LuCheck, LuX } from "react-icons/lu"; import { Button } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import { formatToolName } from "@/utils/chatUtil"; import type { PendingToolCall, ToolDecision } from "@/types/chat"; type ToolApprovalCardProps = { toolCall: PendingToolCall; decision?: ToolDecision; onApprove: (id: string) => void; onAlwaysAllow: (id: string, name: string) => void; onReject: (id: string) => void; }; /** * Prompt shown when the assistant wants to run a state-changing tool. * Renders the call's arguments and approve / always allow / reject actions; * once decided it collapses into a status line. */ export function ToolApprovalCard({ toolCall, decision, onApprove, onAlwaysAllow, onReject, }: ToolApprovalCardProps) { const { t } = useTranslation(["views/chat"]); const displayName = formatToolName(toolCall.name); const hasArguments = Object.keys(toolCall.arguments ?? {}).length > 0; return (
{JSON.stringify(toolCall.arguments, null, 2)}
)}
{decision ? (