"use client"; import * as React from "react"; import { Coins } from "lucide-react"; import type { PolyModel } from "@/lib/client/types"; import type { RouteCandidate } from "@/lib/client/router"; import type { CostEstimate } from "@/lib/client/tokens"; import { ResponsiveDialog } from "@/components/ui/sheet"; import { Button } from "@/components/ui/button"; import { ProviderIcon } from "@/components/brand/provider-icon"; import { formatTokens } from "@/lib/utils"; function usd(n: number | null): string { if (n === null) return "—"; return n < 0.01 ? `$${n.toFixed(4)}` : `$${n.toFixed(2)}`; } /** Shown before sending when the estimate exceeds `COST_CONFIRM_THRESHOLD_USD`; offers cheaper models with one-tap switching. */ export function CostConfirm({ open, onOpenChange, model, estimate, alternatives, onSend, onSwitch }: { open: boolean; onOpenChange: (o: boolean) => void; model: PolyModel | null | undefined; estimate: CostEstimate | null; alternatives: RouteCandidate[]; onSend: () => void; onSwitch: (modelKey: string) => void }) { return ( This request may cost ≈ {usd(estimate?.usd ?? null)} } description={model && estimate ? `${model.displayName} · ~${formatTokens(estimate.inputTokens)} input tokens + ~${formatTokens(estimate.outputTokens)} expected output, at provider list prices.` : undefined} size="sm" footer={
} >
{alternatives.length ? (

Cheaper alternatives

    {alternatives.map((a) => (
  • ))}

Tap a model to switch and send immediately.

) : (

No cheaper connected model can take this prompt (context, vision or file requirements).

)}
); }