Skip to content

Commit 64a3ca4

Browse files
fix(web,mobile): limit bars use each provider's chart color (pingdotgg#16936)
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
1 parent af134ab commit 64a3ca4

4 files changed

Lines changed: 14 additions & 21 deletions

File tree

‎apps/mobile/src/features/usage/UsageLimitsPooled.tsx‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { ProviderIcon } from "../../components/ProviderIcon";
2424
import { SettingsScreen } from "../settings/components/SettingsScreen";
2525
import { environmentPresentations } from "../../state/presentation";
2626
import { ResetCredits } from "./UsageLimitsSection";
27-
import { useProviderColors } from "./usageProviders";
27+
import { usageProviderKind, useProviderColors } from "./usageProviders";
2828

2929
const DRIVER_LABEL: Partial<Record<string, string>> = {
3030
codex: "Codex",
@@ -283,13 +283,7 @@ export function UsageLimitsSection({
283283
<PoolWindowCard
284284
key={`${window.kind}:${window.id}`}
285285
pool={window}
286-
color={
287-
pool.driver === "claudeAgent"
288-
? colors.claude
289-
: pool.driver === "antigravity"
290-
? colors.antigravity
291-
: colors.codex
292-
}
286+
color={colors[usageProviderKind(pool.driver) ?? "codex"]}
293287
now={now}
294288
environmentIds={
295289
selectedEnvironmentIds === null ? null : [...selectedEnvironmentIds]

‎apps/mobile/src/features/usage/UsageLimitsSection.tsx‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
type ServerProvider,
99
type ServerProviderResetCredits,
1010
type ServerProviderUsageWindow,
11-
type UsageProviderKind,
1211
} from "@t3tools/contracts";
1312
import {
1413
elapsedShare,
@@ -28,16 +27,15 @@ import { environmentPresentations } from "../../state/presentation";
2827
import { serverEnvironment } from "../../state/server";
2928
import { readEnvironmentScope, useEnvironmentScope } from "../../state/session";
3029
import { useAtomCommand } from "../../state/use-atom-command";
31-
import { useProviderColors } from "./usageProviders";
30+
import { usageProviderKind, useProviderColors } from "./usageProviders";
3231

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

3534
type Driver = ServerProvider["driver"];
3635

3736
function useBarColor(driver: Driver): string | null {
3837
const colors = useProviderColors();
39-
const kind: UsageProviderKind | null =
40-
driver === "codex" ? "codex" : driver === "claudeAgent" ? "claude" : null;
38+
const kind = usageProviderKind(driver);
4139
return kind ? colors[kind] : null;
4240
}
4341

‎apps/mobile/src/features/usage/usageProviders.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ export const PROVIDER_ORDER: readonly UsageProviderKind[] = [
1111
"pi",
1212
];
1313

14+
/** The usage series a provider driver reports under, or null for drivers without one. */
15+
export function usageProviderKind(driver: string): UsageProviderKind | null {
16+
if (driver === "claudeAgent") return "claude";
17+
return PROVIDER_ORDER.find((kind) => kind === driver) ?? null;
18+
}
19+
1420
export const PROVIDER_LABEL: Record<UsageProviderKind, string> = {
1521
claude: "Claude Code",
1622
codex: "Codex",

‎apps/web/src/components/usage/UsageLimits.tsx‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,10 @@ const PACE: Record<LimitPace, { readonly label: string; readonly icon: typeof Ga
4747
};
4848

4949
export function barColor(driver: ServerProvider["driver"]): string {
50-
const kind: UsageProviderKind | undefined =
51-
driver === "codex"
52-
? "codex"
53-
: driver === "claudeAgent"
54-
? "claude"
55-
: driver === "antigravity"
56-
? "antigravity"
57-
: undefined;
58-
return kind ? PROVIDER_PRESENTATION[kind].color : "var(--foreground)";
50+
const presentation = Object.values(PROVIDER_PRESENTATION).find(
51+
(entry) => entry.driverKind === driver,
52+
);
53+
return presentation?.color ?? "var(--foreground)";
5954
}
6055

6156
export function PaceIcon({ pace }: { readonly pace: LimitPace }) {

0 commit comments

Comments
 (0)