"use client"; import * as React from "react"; import { Sparkles, Wand2 } from "lucide-react"; import type { RouteResult, RouterMode } from "@/lib/client/router"; import { ROUTER_MODES, explainRoute } from "@/lib/client/router"; import { ResponsiveDialog } from "@/components/ui/sheet"; import { Button } from "@/components/ui/button"; import { Switch } from "@/components/ui/switch"; import { Segmented } from "@/components/ui/segmented"; import { ProviderIcon } from "@/components/brand/provider-icon"; import { PROVIDERS } from "@/lib/client/providers"; import { ModelPickerLauncher } from "./model-launcher"; import { cn, formatTokens } from "@/lib/utils"; function usd(n: number | null): string { if (n === null) return "no public pricing"; return n < 0.01 ? `≈ $${n.toFixed(4)}` : `≈ $${n.toFixed(2)}`; } /** * Smart Router recommendation shown before sending when the AUTO model is selected. * Transparent by design: recommendation + why + estimated cost + alternatives. Nothing is sent * until the user taps "Use recommendation" or picks a model. */ export function RouterCard({ open, onOpenChange, result, mode, onModeChange, onUse, alwaysAuto, onAlwaysAutoChange }: { open: boolean; onOpenChange: (o: boolean) => void; result: RouteResult | null; mode: RouterMode; onModeChange: (m: RouterMode) => void; onUse: (modelKey: string) => void; alwaysAuto: boolean; onAlwaysAutoChange: (v: boolean) => void }) { const rec = result?.recommended ?? null; return ( Smart Router } description={result ? `Detected: ${result.analysis.signals.length ? result.analysis.signals.join(" · ") : `${result.analysis.task} prompt`} · ~${formatTokens(result.analysis.inputTokens)} input tokens` : undefined} size="md" footer={
} >
value={mode} onChange={onModeChange} size="sm" ariaLabel="Routing mode" className="max-w-full" options={ROUTER_MODES.map((m) => ({ value: m.value, label: m.label }))} /> {rec ? ( ) : (

No connected model fits this prompt (check vision / file / context requirements).

)} {result?.alternatives.length ? (

Alternatives

    {result.alternatives.map((a) => (
  • ))}
) : null}

Routing is computed locally from your connected models, the prompt and the mode above — no request is sent until you confirm.

); }