Open History to see the last commit
1import { useAtomValue } from "@effect/atom-react";
2import type { UsageProviderKind } from "@t3tools/contracts";
3import { CheckIcon, RefreshCwIcon, XIcon } from "lucide-react";
4import { useMemo, useState } from "react";
5
6import type { DailyTotals, HourlyTotals } from "@t3tools/shared/usageMerge";
7
8import { isElectron } from "../../env";
9import { cn } from "../../lib/utils";
10import { environmentPresentations } from "../../state/presentation";
11import { serverEnvironment } from "../../state/server";
12import { useUsage, type EnvironmentUsageStatus } from "../../state/usage";
13import { useAtomCommand } from "../../state/use-atom-command";
14import {
15 enumerateDays,
16 enumerateHourStarts,
17 formatCount,
18 formatDateTimeShort,
19 formatDayShort,
20 formatHourShort,
21 formatPercent,
22 formatTokens,
23 formatUsd,
24 makeWindow,
25} from "@t3tools/shared/usageFormat";
26import { Button } from "../ui/button";
27import { ScrollArea } from "../ui/scroll-area";
28import { Select, SelectItem, SelectPopup, SelectTrigger, SelectValue } from "../ui/select";
29import { SidebarInset } from "../ui/sidebar";
30import { Skeleton } from "../ui/skeleton";
31import { Toggle, ToggleGroup } from "../ui/toggle-group";
32import {
33 WorkspaceBreadcrumb,
34 WorkspaceBreadcrumbItem,
35 WorkspaceBreadcrumbSeparator,
36} from "../WorkspaceBreadcrumb";
37import { WorkspacePageContainer } from "../WorkspacePageContainer";
38import { WorkspacePageHeader } from "../WorkspacePageHeader";
39import { UsageLimitsSection } from "./UsageLimits";
40import { UsageProviderChart, type UsageChartMetric } from "./UsageProviderChart";
41import { PROVIDER_ORDER, PROVIDER_PRESENTATION, providersWithUsage } from "./usageProviders";
42
43type UsageMetric = UsageChartMetric | "limits";
44const METRIC_OPTIONS = [
45 { value: "cost", label: "Cost" },
46 { value: "tokens", label: "Tokens" },
47 { value: "limits", label: "Limits" },
48] as const satisfies readonly { value: UsageMetric; label: string }[];
49
50function isUsageMetric(value: string | null | undefined): value is UsageMetric {
51 return METRIC_OPTIONS.some((option) => option.value === value);
52}
53
54const WINDOW_OPTIONS = [
55 { days: 1, label: "Past 24h" },
56 { days: 7, label: "7 days" },
57 { days: 30, label: "30 days" },
58 { days: 90, label: "90 days" },
59] as const;
60
61export function UsagePage() {
62 const [windowSelection, setWindowSelection] = useState(() => ({
63 days: 30,
64 window: makeWindow(30),
65 }));
66 const [metric, setMetric] = useState<UsageMetric>("cost");
67 const showingLimits = metric === "limits";
68 const [breakdown, setBreakdown] = useState<"model" | "time">("model");
69 const { days: windowDays, window } = windowSelection;
70 const isPast24Hours = windowDays === 1;
71 const { merged, environments, isPending, isPartial, refresh } = useUsage(window);
72 const presentations = useAtomValue(environmentPresentations.presentationsAtom);
73 const refreshProviders = useAtomCommand(serverEnvironment.refreshProviders, {
74 reportFailure: false,
75 });
76
77 // Hold the content until every environment is terminal. Rendering merged
78 // totals while devices are still answering makes every number on the page
79 // jump as each one lands.
80 const settling = isPending || isPartial;
81
82 const days = useMemo(
83 () => enumerateDays(window.sinceDay, window.untilDay),
84 [window.sinceDay, window.untilDay],
85 );
86 const hours = useMemo(
87 () =>
88 window.sinceTime === undefined || window.untilTime === undefined
89 ? []
90 : enumerateHourStarts(window.sinceTime, window.untilTime),
91 [window.sinceTime, window.untilTime],
92 );
93 // Newest first: the window can run 90 periods, so the interesting end
94 // belongs at the top of the table.
95 const breakdownPeriods = useMemo<readonly (DailyTotals | HourlyTotals)[]>(
96 () => (isPast24Hours ? merged.hourly : merged.daily).toReversed(),
97 [isPast24Hours, merged.daily, merged.hourly],
98 );
99 const breakdownModels = useMemo(
100 () =>
101 breakdown === "model" && metric === "tokens"
102 ? merged.models.toSorted(
103 (left, right) => right.totalTokens - left.totalTokens || right.costUsd - left.costUsd,
104 )
105 : merged.models,
106 [breakdown, merged.models, metric],
107 );
108 const activeProviders = useMemo(() => providersWithUsage(merged.providers), [merged.providers]);
109 const timeValueColumnWidth = `${60 / (activeProviders.length + 2)}%`;
110
111 const selectWindow = (days: number) => {
112 setWindowSelection({
113 days,
114 window: makeWindow(days, undefined, days === 1 ? "hour" : "day"),
115 });
116 };
117 const refreshWindow = () => {
118 if (showingLimits) {
119 for (const [environmentId, presentation] of presentations) {
120 if (presentation.connection.phase === "connected" && presentation.serverConfig !== null) {
121 void refreshProviders({ environmentId, input: {} });
122 }
123 }
124 return;
125 }
126 const nextWindow = makeWindow(windowDays, undefined, isPast24Hours ? "hour" : "day");
127 if (
128 nextWindow.sinceDay === window.sinceDay &&
129 nextWindow.untilDay === window.untilDay &&
130 nextWindow.sinceTime === window.sinceTime &&
131 nextWindow.untilTime === window.untilTime
132 ) {
133 refresh();
134 } else {
135 setWindowSelection({ days: windowDays, window: nextWindow });
136 }
137 };
138 const windowLabel =
139 isPast24Hours && window.sinceTime !== undefined && window.untilTime !== undefined
140 ? `${formatDateTimeShort(window.sinceTime, window.timeZone)} to ${formatDateTimeShort(window.untilTime, window.timeZone)}`
141 : `${formatDayShort(window.sinceDay)} to ${formatDayShort(window.untilDay)}`;
142 const topbarContent = (
143 <div className="flex w-full min-w-0 items-center gap-3">
144 <WorkspaceBreadcrumb ariaLabel="Usage breadcrumb" className="min-w-0">
145 <WorkspaceBreadcrumbItem current>
146 <h1>Usage</h1>
147 </WorkspaceBreadcrumbItem>
148 {showingLimits ? null : (
149 <>
150 <WorkspaceBreadcrumbSeparator className="hidden md:flex" />
151 <WorkspaceBreadcrumbItem className="hidden min-w-0 shrink md:flex">
152 <span className="truncate">{windowLabel}</span>
153 </WorkspaceBreadcrumbItem>
154 </>
155 )}
156 </WorkspaceBreadcrumb>
157 <div className="ms-auto hidden min-w-0 items-center justify-end gap-2 lg:flex">
158 <ToggleGroup
159 aria-label="Usage metric"
160 variant="segmented"
161 value={[metric]}
162 onValueChange={(next) => {
163 const value = next[0];
164 if (isUsageMetric(value)) setMetric(value);
165 }}
166 >
167 {METRIC_OPTIONS.map((option) => (
168 <Toggle key={option.value} value={option.value}>
169 {option.label}
170 </Toggle>
171 ))}
172 </ToggleGroup>
173 {/* The period does not apply to Limits, so it stays in place but
174 disabled; unmounting it shifted the metric toggle ~300px. */}
175 <ToggleGroup
176 aria-label="Usage period"
177 variant="segmented"
178 value={[String(windowDays)]}
179 disabled={showingLimits}
180 onValueChange={(next) => {
181 const value = next[0];
182 if (value) selectWindow(Number(value));
183 }}
184 >
185 {WINDOW_OPTIONS.map((option) => (
186 <Toggle key={option.days} value={String(option.days)}>
187 {option.label}
188 </Toggle>
189 ))}
190 </ToggleGroup>
191 <Button
192 onClick={refreshWindow}
193 aria-label={showingLimits ? "Refresh limits" : "Refresh usage"}
194 size="icon-sm"
195 variant="ghost"
196 >
197 <RefreshCwIcon className="size-3.5" />
198 </Button>
199 </div>
200 <div className="ms-auto flex min-w-0 items-center justify-end gap-1 lg:hidden">
201 <Select
202 value={metric}
203 onValueChange={(value) => {
204 if (isUsageMetric(value)) setMetric(value);
205 }}
206 >
207 <SelectTrigger
208 aria-label="Usage metric"
209 size="compact"
210 variant="ghost"
211 className="w-auto min-w-0"
212 >
213 <SelectValue>
214 {METRIC_OPTIONS.find((option) => option.value === metric)?.label}
215 </SelectValue>
216 </SelectTrigger>
217 <SelectPopup align="end" alignItemWithTrigger={false}>
218 {METRIC_OPTIONS.map((option) => (
219 <SelectItem key={option.value} value={option.value}>
220 {option.label}
221 </SelectItem>
222 ))}
223 </SelectPopup>
224 </Select>
225 <Select
226 value={String(windowDays)}
227 disabled={showingLimits}
228 onValueChange={(value) => selectWindow(Number(value))}
229 >
230 <SelectTrigger
231 aria-label="Usage period"
232 size="compact"
233 variant="ghost"
234 className="w-auto min-w-0"
235 >
236 <SelectValue>
237 {WINDOW_OPTIONS.find((option) => option.days === windowDays)?.label}
238 </SelectValue>
239 </SelectTrigger>
240 <SelectPopup align="end" alignItemWithTrigger={false}>
241 {WINDOW_OPTIONS.map((option) => (
242 <SelectItem key={option.days} value={String(option.days)}>
243 {option.label}
244 </SelectItem>
245 ))}
246 </SelectPopup>
247 </Select>
248 <Button
249 onClick={refreshWindow}
250 aria-label={showingLimits ? "Refresh limits" : "Refresh usage"}
251 size="icon-sm"
252 variant="ghost"
253 >
254 <RefreshCwIcon className="size-3.5" />
255 </Button>
256 </div>
257 </div>
258 );
259
260 return (
261 <SidebarInset className="h-dvh min-h-0 overflow-hidden overscroll-y-none bg-background text-foreground isolate">
262 <div className="flex min-h-0 min-w-0 flex-1 flex-col bg-background text-foreground">
263 <WorkspacePageHeader electron={isElectron}>{topbarContent}</WorkspacePageHeader>
264
265 <ScrollArea className="min-h-0 flex-1">
266 <WorkspacePageContainer width="wide">
267 {showingLimits ? (
268 <UsageLimitsSection />
269 ) : settling ? (
270 <>
271 {environments.length > 1 ? <UsageDeviceStrip environments={environments} /> : null}
272 <UsageSkeleton />
273 </>
274 ) : (
275 <>
276 <UsageCoverageNotice
277 environments={environments}
278 duplicateSources={merged.duplicateSources}
279 staleEnvironments={merged.staleEnvironments}
280 />
281
282 <section className="grid gap-6 lg:grid-cols-[minmax(0,18rem)_minmax(0,1fr)]">
283 <div className="flex min-w-0 flex-col gap-5">
284 <div className="flex flex-col gap-1">
285 <span className="text-4xl font-semibold text-foreground tabular-nums">
286 {metric === "cost"
287 ? formatUsd(merged.costUsd)
288 : formatTokens(merged.totalTokens)}
289 </span>
290 <span className="text-xs text-muted-foreground">
291 {metric === "cost"
292 ? `${formatCount(merged.sessions)} sessions · API estimate`
293 : `${formatCount(merged.sessions)} sessions`}
294 </span>
295 </div>
296
297 {activeProviders.map((provider) => {
298 const totals = merged.providers.find((entry) => entry.provider === provider);
299 const share =
300 metric === "cost" ? (totals?.costShare ?? 0) : (totals?.tokenShare ?? 0);
301 const providerSessions = totals?.sessions ?? 0;
302 const sessionLabel = `${formatCount(providerSessions)} ${
303 providerSessions === 1 ? "session" : "sessions"
304 }`;
305 return (
306 <div key={provider} className="flex flex-col gap-1">
307 <div className="flex items-baseline justify-between gap-4">
308 <span className="flex min-w-0 items-center gap-2 text-sm text-foreground">
309 <span
310 aria-hidden
311 className="size-2 shrink-0 rounded-full"
312 style={{
313 backgroundColor: PROVIDER_PRESENTATION[provider].color,
314 }}
315 />
316 <ProviderMark provider={provider} className="size-4" />
317 <span className="flex min-w-0 items-baseline gap-1.5">
318 <span className="truncate">
319 {PROVIDER_PRESENTATION[provider].label}
320 </span>
321 <span className="shrink-0 whitespace-nowrap text-[11px] text-muted-foreground tabular-nums">
322 {sessionLabel}
323 </span>
324 </span>
325 </span>
326 <span className="shrink-0 text-sm font-medium text-foreground tabular-nums">
327 {metric === "cost"
328 ? formatUsd(totals?.costUsd ?? 0)
329 : formatTokens(totals?.totalTokens ?? 0)}
330 </span>
331 </div>
332 <span className="text-xs text-muted-foreground">
333 {metric === "cost"
334 ? `${formatPercent(share)} of cost · ${formatTokens(totals?.totalTokens ?? 0)} tokens`
335 : `${formatPercent(share)} of tokens · ${formatUsd(totals?.costUsd ?? 0)}`}
336 </span>
337 </div>
338 );
339 })}
340 </div>
341
342 <div className="flex min-w-0 flex-col gap-3">
343 <h2 className="text-sm font-medium text-foreground">
344 {isPast24Hours ? "Hourly" : "Daily"}{" "}
345 {metric === "tokens" ? "processed tokens" : "cost"}
346 </h2>
347 <UsageProviderChart
348 providers={activeProviders}
349 days={days}
350 daily={merged.daily}
351 hours={hours}
352 hourly={merged.hourly}
353 metric={metric}
354 referenceTime={window.untilTime}
355 resolution={isPast24Hours ? "hour" : "day"}
356 timeZone={window.timeZone}
357 />
358 </div>
359 </section>
360
361 <section className="flex flex-col gap-2">
362 <h2 className="text-sm font-medium text-foreground">Totals</h2>
363 <div className="grid grid-cols-2 gap-x-6 gap-y-4 py-1 md:grid-cols-5">
364 <Metric label="Processed tokens" value={formatTokens(merged.totalTokens)} />
365 <Metric label="Cached input" value={formatTokens(merged.cachedInputTokens)} />
366 <Metric
367 label="Uncached input"
368 value={formatTokens(merged.uncachedInputTokens)}
369 />
370 <Metric label="Output" value={formatTokens(merged.outputTokens)} />
371 <Metric
372 label="Cache savings"
373 value={formatUsd(merged.costQuality.cacheSavingsUsd)}
374 />
375 </div>
376 </section>
377
378 <section className="flex flex-col gap-3">
379 <div className="flex items-center justify-between gap-3">
380 <h2 className="text-sm font-medium text-foreground">Breakdown</h2>
381 <ToggleGroup
382 aria-label="Usage breakdown"
383 variant="segmented"
384 value={[breakdown]}
385 onValueChange={(next) => {
386 const value = next[0];
387 if (value === "model" || value === "time") setBreakdown(value);
388 }}
389 >
390 {(
391 [
392 { value: "model", label: "Model" },
393 { value: "time", label: isPast24Hours ? "Hour" : "Day" },
394 ] as const
395 ).map((option) => (
396 <Toggle key={option.value} value={option.value}>
397 {option.label}
398 </Toggle>
399 ))}
400 </ToggleGroup>
401 </div>
402
403 {breakdown === "model" ? (
404 <table className="w-full table-fixed text-sm">
405 <colgroup>
406 <col className="w-2/5" />
407 <col className="w-1/5" />
408 <col className="w-1/5" />
409 <col className="w-1/5" />
410 </colgroup>
411 <thead>
412 <tr className="border-b border-border text-left text-xs text-muted-foreground">
413 <th className="py-2 font-normal">Model</th>
414 <th className="py-2 text-right font-normal">Cost</th>
415 <th className="py-2 text-right font-normal">Share</th>
416 <th className="py-2 text-right font-normal">Tokens</th>
417 </tr>
418 </thead>
419 <tbody>
420 {breakdownModels.length === 0 ? (
421 <tr>
422 <td colSpan={4} className="py-6 text-center text-muted-foreground">
423 No activity in this window.
424 </td>
425 </tr>
426 ) : (
427 breakdownModels.map((model) => (
428 <tr
429 key={`${model.provider}:${model.model}`}
430 className="border-b border-border/50 transition-colors hover:bg-muted/50"
431 >
432 <td className="py-2 text-foreground">
433 <span className="flex items-center gap-2">
434 <ProviderMark provider={model.provider} className="size-3.5" />
435 {model.model}
436 </span>
437 </td>
438 <td className="py-2 text-right text-foreground tabular-nums">
439 {formatUsd(model.costUsd)}
440 </td>
441 <td className="py-2 text-right text-muted-foreground tabular-nums">
442 {formatPercent(model.costShare)}
443 </td>
444 <td className="py-2 text-right text-muted-foreground tabular-nums">
445 {formatTokens(model.totalTokens)}
446 </td>
447 </tr>
448 ))
449 )}
450 </tbody>
451 </table>
452 ) : (
453 <table className="w-full table-fixed text-sm">
454 <colgroup>
455 <col className="w-2/5" />
456 {activeProviders.map((provider) => (
457 <col key={provider} style={{ width: timeValueColumnWidth }} />
458 ))}
459 <col style={{ width: timeValueColumnWidth }} />
460 <col style={{ width: timeValueColumnWidth }} />
461 </colgroup>
462 <thead>
463 <tr className="border-b border-border text-left text-xs text-muted-foreground">
464 <th className="py-2 font-normal">{isPast24Hours ? "Hour" : "Day"}</th>
465 {activeProviders.map((provider) => (
466 <th key={provider} className="py-2 text-right font-normal">
467 {PROVIDER_PRESENTATION[provider].label}
468 </th>
469 ))}
470 <th className="py-2 text-right font-normal">Total</th>
471 <th className="py-2 text-right font-normal">Tokens</th>
472 </tr>
473 </thead>
474 <tbody>
475 {breakdownPeriods.length === 0 ? (
476 <tr>
477 <td
478 colSpan={activeProviders.length + 3}
479 className="py-6 text-center text-muted-foreground"
480 >
481 No activity in this window.
482 </td>
483 </tr>
484 ) : (
485 breakdownPeriods.map((period) => (
486 <tr
487 key={"hourStart" in period ? period.hourStart : period.day}
488 className="border-b border-border/50 transition-colors hover:bg-muted/50"
489 >
490 <td className="py-2 text-foreground">
491 {"hourStart" in period
492 ? formatHourShort(period.hourStart, window.timeZone)
493 : formatDayShort(period.day)}
494 </td>
495 {activeProviders.map((provider) => (
496 <td
497 key={provider}
498 className="py-2 text-right text-muted-foreground tabular-nums"
499 >
500 {formatUsd(period.byProvider.get(provider)?.costUsd ?? 0)}
501 </td>
502 ))}
503 <td className="py-2 text-right text-foreground tabular-nums">
504 {formatUsd(period.costUsd)}
505 </td>
506 <td className="py-2 text-right text-muted-foreground tabular-nums">
507 {formatTokens(period.totalTokens)}
508 </td>
509 </tr>
510 ))
511 )}
512 </tbody>
513 </table>
514 )}
515 </section>
516 </>
517 )}
518 </WorkspacePageContainer>
519 </ScrollArea>
520 </div>
521 </SidebarInset>
522 );
523}
524
525/** Brand mark for the harness a row belongs to. */
526function ProviderMark({
527 provider,
528 className,
529}: {
530 readonly provider: UsageProviderKind;
531 readonly className: string;
532}) {
533 const Mark = PROVIDER_PRESENTATION[provider].mark;
534 return <Mark className={cn("shrink-0", className)} aria-hidden />;
535}
536
537function Metric({ label, value }: { readonly label: string; readonly value: string }) {
538 return (
539 <div className="flex min-w-0 flex-col gap-0.5">
540 <span className="text-xs text-muted-foreground">{label}</span>
541 <span className="text-base font-medium text-foreground tabular-nums">{value}</span>
542 </div>
543 );
544}
545
546/**
547 * Says plainly when the totals are incomplete: an environment that failed, or
548 * one whose transcripts another environment already reported. Environments
549 * that are still answering never reach this notice; the page shows the
550 * loading skeleton until every one is terminal.
551 */
552function UsageCoverageNotice({
553 environments,
554 duplicateSources,
555 staleEnvironments,
556}: {
557 readonly environments: readonly EnvironmentUsageStatus[];
558 readonly duplicateSources: readonly string[];
559 readonly staleEnvironments: readonly string[];
560}) {
561 const failed = environments.filter((environment) => environment.error !== null);
562 const stale = environments.filter((environment) =>
563 staleEnvironments.includes(environment.environmentId),
564 );
565 if (failed.length === 0 && stale.length === 0 && duplicateSources.length === 0) {
566 return null;
567 }
568
569 return (
570 <div className="flex flex-col gap-1 border border-border px-3 py-2 text-xs text-muted-foreground">
571 {failed.map((environment) => (
572 <span key={environment.label}>{environment.label} could not report usage.</span>
573 ))}
574 {stale.map((environment) => (
575 <span key={environment.label}>
576 {environment.label} runs an older server version and is excluded from totals.
577 </span>
578 ))}
579 {duplicateSources.length > 0 ? (
580 <span>
581 Counted once across environments sharing a transcript directory:{" "}
582 {duplicateSources.join(", ")}
583 </span>
584 ) : null}
585 </div>
586 );
587}
588
589/**
590 * Per-device progress while the page waits for every environment to answer.
591 * Only rendered with two or more devices; a lone device has nothing to
592 * enumerate.
593 */
594function UsageDeviceStrip({
595 environments,
596}: {
597 readonly environments: readonly EnvironmentUsageStatus[];
598}) {
599 const scanning = environments.filter(
600 (environment) => environment.summary === null && environment.error === null,
601 );
602 return (
603 <div className="flex flex-wrap items-baseline gap-x-4 gap-y-1 border border-border px-3 py-2 text-xs">
604 {environments.map((environment) => {
605 if (environment.summary !== null) {
606 return (
607 <span
608 key={environment.environmentId}
609 className="flex items-center gap-1 text-foreground"
610 >
611 <CheckIcon className="size-3 text-emerald-600 dark:text-emerald-300/90" aria-hidden />
612 {environment.label}
613 </span>
614 );
615 }
616 if (environment.error !== null) {
617 return (
618 <span
619 key={environment.environmentId}
620 className="flex items-center gap-1 text-destructive"
621 >
622 <XIcon className="size-3" aria-hidden />
623 {environment.label}
624 </span>
625 );
626 }
627 return (
628 <span
629 key={environment.environmentId}
630 className="animate-status-pulse text-muted-foreground"
631 >
632 {environment.label}…
633 </span>
634 );
635 })}
636 <span className="ms-auto text-muted-foreground">
637 {scanning.length === 1
638 ? "1 device still scanning"
639 : `${scanning.length} devices still scanning`}
640 </span>
641 </div>
642 );
643}
644
645/**
646 * Stand-in with the loaded page's shape, using the shared `Skeleton` bars so it
647 * breathes with the same `animate-skeleton` pulse as every other loading state.
648 * Blocks fill in exactly once when the last device answers.
649 */
650function UsageSkeleton() {
651 return (
652 <>
653 <section className="grid gap-6 lg:grid-cols-[minmax(0,18rem)_minmax(0,1fr)]">
654 <div className="flex flex-col gap-5">
655 <div className="flex flex-col gap-1">
656 <Skeleton className="h-10 w-36" />
657 <Skeleton className="h-4 w-32" />
658 </div>
659 {PROVIDER_ORDER.map((provider) => (
660 <div key={provider} className="flex flex-col gap-1">
661 <div className="flex min-h-5 items-center justify-between gap-4">
662 <span className="flex items-center gap-2">
663 <Skeleton className="size-2 shrink-0 rounded-full" />
664 <Skeleton className="size-4 shrink-0 rounded-full" />
665 <Skeleton className="h-3.5 w-20" />
666 </span>
667 <Skeleton className="h-3.5 w-14" />
668 </div>
669 <Skeleton className="h-4 w-36" />
670 </div>
671 ))}
672 </div>
673
674 <div className="flex flex-col gap-3">
675 <Skeleton className="h-5 w-24" />
676 <div className="flex flex-col gap-1">
677 <Skeleton className="ml-16 h-56 bg-muted-foreground/10" />
678 <Skeleton className="ml-16 h-4 bg-muted-foreground/10" />
679 </div>
680 </div>
681 </section>
682
683 <section className="flex flex-col gap-2">
684 <h2 className="text-sm font-medium text-foreground">Totals</h2>
685 <div className="grid grid-cols-2 gap-x-6 gap-y-4 py-1 md:grid-cols-5">
686 {["Processed tokens", "Cached input", "Uncached input", "Output", "Cache savings"].map(
687 (label) => (
688 <div key={label} className="flex flex-col gap-0.5">
689 <span className="text-xs text-muted-foreground">{label}</span>
690 <Skeleton className="h-6 w-16" />
691 </div>
692 ),
693 )}
694 </div>
695 </section>
696
697 <section className="flex flex-col gap-3">
698 <div className="flex items-center justify-between gap-3">
699 <h2 className="text-sm font-medium text-foreground">Breakdown</h2>
700 <Skeleton className="h-7 w-28 rounded-lg" />
701 </div>
702 <Skeleton className="h-44 bg-muted-foreground/10" />
703 </section>
704 </>
705 );
706}