import { cn } from "@/lib/utils"; import { Gauge } from "lucide-react"; import type { TaskChatUsageItem } from "./task-chat-model"; /** * Second-tier live token/cost readout (ACP UsageUpdate). Concrete progress — * context fill %, tokens, and cost — rather than an indeterminate spinner. * Recedes to metadata weight so it never competes with message content. */ export function TaskChatUsageReadout({ item }: { item: TaskChatUsageItem }) { const { used, size, inputTokens, outputTokens, costUsd } = item.usage; const contextWindowSize = typeof size === "number" && size > 0 ? size : null; const pct = contextWindowSize ? Math.min(100, Math.round((used / contextWindowSize) * 100)) : 0; return (
{item.label ? {item.label} : null} {contextWindowSize ? ( {used.toLocaleString()}/{contextWindowSize.toLocaleString()} ctx ({pct}%) ) : null} {inputTokens != null || outputTokens != null ? ( · ↑{(inputTokens ?? 0).toLocaleString()} ↓{(outputTokens ?? 0).toLocaleString()} ) : null} {costUsd != null ? · ${costUsd.toFixed(4)} : null}
{item.detail ?
{item.detail}
: null} {contextWindowSize ? (
) : null}
); }