import { useState } from "react"; import { cn } from "@/lib/utils"; import { Check, ChevronRight, Loader2, ShieldCheck, ShieldX, X, } from "lucide-react"; import type { TaskChatToolItem } from "./task-chat-model"; import { toolTaxonomy } from "./tool-taxonomy"; const STATUS_ICON = { pending: { Icon: Loader2, spin: false, tone: "text-muted-foreground" }, in_progress: { Icon: Loader2, spin: true, tone: "text-(--status-agent-running)" }, completed: { Icon: Check, spin: false, tone: "text-muted-foreground" }, failed: { Icon: X, spin: false, tone: "text-destructive" }, } as const; /** * Tool invocation as a flat activity row (v7): [glyph] [name] [mono target] … * [hover chevron] [status]. No card chrome — activity is metadata, not * content. Clicking toggles the mono result/detail block (left-rail inset); * diffs render as an inset panel below the row. */ export function TaskChatToolCard({ item }: { item: TaskChatToolItem }) { const { Icon, spin, tone } = STATUS_ICON[item.status]; const RowIcon = toolTaxonomy(item.rawName ?? item.name).icon; const [showDetail, setShowDetail] = useState(false); const expandable = Boolean(item.detail); return (
{item.detail}
) : null}
{item.diff ? (
{item.diff.lines.map((l, i) => (
{l.kind === "add" ? "+" : l.kind === "remove" ? "−" : " "} {l.text}
))}
) : null}