Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/mobile/src/features/usage/UsageLimitsPooled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { ProviderIcon } from "../../components/ProviderIcon";
import { SettingsScreen } from "../settings/components/SettingsScreen";
import { environmentPresentations } from "../../state/presentation";
import { ResetCredits } from "./UsageLimitsSection";
import { useProviderColors } from "./usageProviders";
import { usageProviderKind, useProviderColors } from "./usageProviders";

const DRIVER_LABEL: Partial<Record<string, string>> = { codex: "Codex", claudeAgent: "Claude" };
const PACE_LABEL = { ahead: "Ahead of pace", on: "On pace", under: "Under pace" } as const;
Expand Down Expand Up @@ -257,7 +257,7 @@ export function UsageLimitsSection({
<PoolWindowCard
key={`${window.kind}:${window.id}`}
pool={window}
color={pool.driver === "claudeAgent" ? colors.claude : colors.codex}
color={colors[usageProviderKind(pool.driver) ?? "codex"]}
now={now}
environmentIds={
selectedEnvironmentIds === null ? null : [...selectedEnvironmentIds]
Expand Down
6 changes: 2 additions & 4 deletions apps/mobile/src/features/usage/UsageLimitsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
type ServerProvider,
type ServerProviderResetCredits,
type ServerProviderUsageWindow,
type UsageProviderKind,
} from "@t3tools/contracts";
import {
elapsedShare,
Expand All @@ -27,7 +26,7 @@ import { environmentPresentations } from "../../state/presentation";
import { serverEnvironment } from "../../state/server";
import { readEnvironmentScope, useEnvironmentScope } from "../../state/session";
import { useAtomCommand } from "../../state/use-atom-command";
import { useProviderColors } from "./usageProviders";
import { usageProviderKind, useProviderColors } from "./usageProviders";

const PACE_LABEL = { ahead: "ahead of pace", on: "on pace", under: "under pace" } as const;

Expand All @@ -36,8 +35,7 @@ type Driver = ServerProvider["driver"];
/** The series colour the usage chart uses for this driver, so the two views read as one. */
function useBarColor(driver: Driver): string | null {
const colors = useProviderColors();
const kind: UsageProviderKind | null =
driver === "codex" ? "codex" : driver === "claudeAgent" ? "claude" : null;
const kind = usageProviderKind(driver);
return kind ? colors[kind] : null;
}

Expand Down
6 changes: 6 additions & 0 deletions apps/mobile/src/features/usage/usageProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export const PROVIDER_ORDER: readonly UsageProviderKind[] = [
"antigravity",
];

/** The usage series a provider driver reports under, or null for drivers without one. */
export function usageProviderKind(driver: string): UsageProviderKind | null {
if (driver === "claudeAgent") return "claude";
return PROVIDER_ORDER.find((kind) => kind === driver) ?? null;
}

export const PROVIDER_LABEL: Record<UsageProviderKind, string> = {
claude: "Claude Code",
codex: "Codex",
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/usage/UsageLimits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
ServerProvider,
ServerProviderResetCredits,
ServerProviderUsageWindow,
UsageProviderKind,
} from "@t3tools/contracts";
import { useAtomValue } from "@effect/atom-react";
import {
Expand Down Expand Up @@ -48,9 +47,10 @@ const PACE: Record<LimitPace, { readonly label: string; readonly icon: typeof Ga

/** The series colour the cost chart uses for this driver, so the two views read as one. */
export function barColor(driver: ServerProvider["driver"]): string {
const kind: UsageProviderKind | undefined =
driver === "codex" ? "codex" : driver === "claudeAgent" ? "claude" : undefined;
return kind ? PROVIDER_PRESENTATION[kind].color : "var(--foreground)";
const presentation = Object.values(PROVIDER_PRESENTATION).find(
(entry) => entry.driverKind === driver,
);
return presentation?.color ?? "var(--foreground)";
}

/** Pace as a glyph with the words on hover. */
Expand Down
Loading