Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

usageProviders.ts

60 lines1.9 KB

1import type { UsageProviderKind } from "@t3tools/contracts";
2import { useAppearancePreferences } from "../settings/appearance/AppearancePreferencesProvider";
3​
4/**
5 * Series and table order. The chart stacks providers from the bottom in this
6 * order, so it also fixes which band sits on top of the bars.
7 */
8export const PROVIDER_ORDER: readonly UsageProviderKind[] = [
9 "codex",
10 "claude",
11 "grok",
12 "cursor",
13 "opencode",
14 "antigravity",
15];
16​
17export const PROVIDER_LABEL: Record<UsageProviderKind, string> = {
18 claude: "Claude Code",
19 codex: "Codex",
20 grok: "Grok Build",
21 cursor: "Cursor",
22 opencode: "OpenCode",
23 antigravity: "Antigravity",
24};
25​
26/**
27 * Claude's brand orange holds in both themes; Codex and Grok are neutrals and
28 * must flip with the theme or their bars vanish against the matching background.
29 */
30export function useProviderColors(): Record<UsageProviderKind, string> {
31 const { themeAppearance: scheme } = useAppearancePreferences();
32 return {
33 claude: "#d97757",
34 codex: scheme === "dark" ? "#e6e6e6" : "#3c3c43",
35 grok: scheme === "dark" ? "#a1a1aa" : "#52525b",
36 cursor: "#8b8b8b",
37 opencode: "#5b9bbd",
38 antigravity: "#8c7bd1",
39 };
41​
42/**
43 * Neutral steps for cost and token mixes, so they never borrow a provider's
44 * color. Matches the web steps: oklab mixes of the codex ink into the
45 * background, above the 15 ΔE separation floor for adjacent segments.
46 */
47export function useUsageMixColors() {
48 const { themeAppearance: scheme } = useAppearancePreferences();
49 const dark = scheme === "dark";
50 return {
51 input: dark ? "#737373" : "#848484",
52 cacheRead: dark ? "#282828" : "#c0c0c0",
53 cacheWrite: dark ? "#949494" : "#6d6d6d",
54 output: dark ? "#e6e6e6" : "#3c3c43",
55 other: dark ? "#494949" : "#a3a3a3",
56 standard: dark ? "#313131" : "#b8b8b8",
57 fast: dark ? "#838383" : "#797979",
58 ultrafast: dark ? "#e6e6e6" : "#3c3c43",
59 };