| 15 | import type { ModelsResponse, PricingResponse } from "./types"; |
| 16 | |
| 17 | function PricingSourceCard({ pricing }: { pricing: PricingResponse | null }) { |
| 18 | if (!pricing) return null; |
| 19 | const sourceLabel = |
| 20 | pricing.source === "cache" |
| 21 | ? "OpenRouter (cached fetch)" |
| 22 | : "bundled snapshot (offline fallback)"; |
| 23 | return ( |
| 24 | <Card> |
| 25 | <CardHeader> |
| 26 | <CardTitle>Model pricing source</CardTitle> |
| 27 | </CardHeader> |
| 28 | <CardContent> |
| 29 | <div className="tss-meta-strip"> |
| 30 | <Badge>{sourceLabel}</Badge> |
| 31 | <Badge>{fmtTokens(pricing.model_count)} models</Badge> |
| 32 | {pricing.fetched_at && <Badge>fetched {timeAgo(pricing.fetched_at)}</Badge>} |
| 33 | {pricing.offline && <Badge>TRACEDECAY_OFFLINE=1 — network disabled</Badge>} |
| 34 | </div> |
| 35 | <p className="tss-chart-hint"> |
| 36 | Prices come from OpenRouter’s public model list, cached at{" "} |
| 37 | <code>{pricing.cache_path || "~/.tracedecay/model-prices.json"}</code>{" "} |
| 38 | and refreshed in the background at most once per day. When the cache |
| 39 | is missing and the network is unavailable, a snapshot bundled with |
| 40 | the binary keeps this tab working. Transcript model ids are |
| 41 | fuzzy-matched to OpenRouter slugs; unmatched models show{" "} |
| 42 | <em>no price data</em>. |
| 43 | </p> |
| 44 | </CardContent> |
| 45 | </Card> |
| 46 | ); |
| 47 | } |
| 48 | |
| 49 | export default function ModelsPanel({ |
| 50 | data, |