Open History to see the last commit
1import type { UsageProviderKind } from "@t3tools/contracts";
2
3import { ClaudeAI, DevinIcon, GrokIcon, type Icon, OpenAI } from "../Icons";
4
5type UsageProviderPresentation = {
6 readonly label: string;
7 readonly color: string;
8 readonly mark: Icon;
9};
10
11/**
12 * Exhaustive presentation for providers supported by the usage contract.
13 * Declaration order is reused by every chart and table, so adding a provider
14 * only requires its contract support and one entry here.
15 */
16export const PROVIDER_PRESENTATION = {
17 codex: {
18 label: "Codex",
19 color: "var(--contrast-foreground)",
20 mark: OpenAI,
21 },
22 claude: {
23 label: "Claude Code",
24 color: "#d97757",
25 mark: ClaudeAI,
26 },
27 grok: {
28 label: "Grok Build",
29 // Contrast-aware neutral between the Codex series and muted chart chrome.
30 color: "color-mix(in oklab, var(--contrast-foreground) 72%, var(--background))",
31 mark: GrokIcon,
32 },
33 devin: {
34 label: "Devin ACP",
35 color: "#6b7cff",
36 mark: DevinIcon,
37 },
38} satisfies Record<UsageProviderKind, UsageProviderPresentation>;
39
40/** Stable provider reading order across charts, summaries, tables, and hover rows. */
41export const PROVIDER_ORDER = Object.keys(PROVIDER_PRESENTATION) as UsageProviderKind[];
42
43/** Providers with real activity, independent of the metric currently displayed. */
44export function providersWithUsage(
45 totals: readonly {
46 readonly provider: UsageProviderKind;
47 readonly costUsd: number;
48 readonly totalTokens: number;
49 }[],
50): readonly UsageProviderKind[] {
51 const active = new Set(
52 totals
53 .filter((entry) => entry.totalTokens > 0 || entry.costUsd > 0)
54 .map((entry) => entry.provider),
55 );
56 return PROVIDER_ORDER.filter((provider) => active.has(provider));
57}