Cache Badge
Annotates a result as served from the semantic cache, optionally with the hit latency (e.g. "cached · 12ms").
Cache Badge
The Cache Badge annotates a result as served from the semantic cache, optionally with the hit latency (e.g. "cached · 12ms"). Local apps cache responses on-device; surfacing a cache hit makes that invisible speedup legible. Drive cached/latencyMs from your useSemanticCache lookup result. It renders nothing when cached is false, so it is safe to drop next to any result.
Preview
Installation
pnpm dlx shadcn@latest add @localmode/ui/local-first/cache-badgenpx shadcn@latest add @localmode/ui/local-first/cache-badgeyarn dlx shadcn@latest add @localmode/ui/local-first/cache-badgebunx --bun shadcn@latest add @localmode/ui/local-first/cache-badgeDependencies
lucide-react— iconsclsx+tailwind-merge— via the sharedcn()util (installed automatically as a registry dependency)
Files installed
cache-badge.tsx— theCacheBadgecomponentlib/utils.ts— thecn()helper (if not already present)
Props
CacheBadge
Prop
Type
Examples
Annotate a cached reply
const result = await cache.lookup({ prompt, modelId });
<CacheBadge cached={result.hit} latencyMs={result.durationMs} />Customization
Uses the emerald palette to read as a positive signal. Because it returns null when cached is false, you can render it unconditionally next to every result. Styled entirely with shadcn/ui CSS-variable utilities so it inherits your theme — because you own the copied file, every class and threshold is yours to change.
Network Badge
A reactive online/offline indicator plus an OfflineReady badge that signals the app can run with no network.
Context Usage Meter
A token / context-window budget meter breaking down input / output / reasoning / cache tokens against the model context limit. No cost field — local models have no billing.