Skip to content

Commit d9729f0

Browse files
fix(web,mobile): limit bars use each provider's chart color
Limit bars are meant to use the usage chart's series color for each provider so the two views read as one, but only Codex and Claude were mapped. On web, Cursor, Grok, OpenCode, and Antigravity bars on Usage → Limits and in the /usage-limits result fell back to the plain foreground color. On mobile, the same providers fell back to the foreground in limit rows and to Codex's color in pooled limits. Web now looks the driver up in PROVIDER_PRESENTATION, the table the chart uses. Mobile gains usageProviderKind for the same lookup against its chart colors. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 701fc83 commit d9729f0

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",
@@ -269,13 +269,7 @@ export function UsageLimitsSection({
269269
<PoolWindowCard
270270
key={`${window.kind}:${window.id}`}
271271
pool={window}
272-
color={
273-
pool.driver === "claudeAgent"
274-
? colors.claude
275-
: pool.driver === "antigravity"
276-
? colors.antigravity
277-
: colors.codex
278-
}
272+
color={colors[usageProviderKind(pool.driver) ?? "codex"]}
279273
now={now}
280274
environmentIds={
281275
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
@@ -7,7 +7,6 @@ import {
77
type ServerProvider,
88
type ServerProviderResetCredits,
99
type ServerProviderUsageWindow,
10-
type UsageProviderKind,
1110
} from "@t3tools/contracts";
1211
import {
1312
elapsedShare,
@@ -27,7 +26,7 @@ import { environmentPresentations } from "../../state/presentation";
2726
import { serverEnvironment } from "../../state/server";
2827
import { readEnvironmentScope, useEnvironmentScope } from "../../state/session";
2928
import { useAtomCommand } from "../../state/use-atom-command";
30-
import { useProviderColors } from "./usageProviders";
29+
import { usageProviderKind, useProviderColors } from "./usageProviders";
3130

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

@@ -36,8 +35,7 @@ type Driver = ServerProvider["driver"];
3635
/** The series colour the usage chart uses for this driver, so the two views read as one. */
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
@@ -15,6 +15,12 @@ export const PROVIDER_ORDER: readonly UsageProviderKind[] = [
1515
"pi",
1616
];
1717

18+
/** The usage series a provider driver reports under, or null for drivers without one. */
19+
export function usageProviderKind(driver: string): UsageProviderKind | null {
20+
if (driver === "claudeAgent") return "claude";
21+
return PROVIDER_ORDER.find((kind) => kind === driver) ?? null;
22+
}
23+
1824
export const PROVIDER_LABEL: Record<UsageProviderKind, string> = {
1925
claude: "Claude Code",
2026
codex: "Codex",

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

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

4949
/** The series colour the cost chart uses for this driver, so the two views read as one. */
5050
export function barColor(driver: ServerProvider["driver"]): string {
51-
const kind: UsageProviderKind | undefined =
52-
driver === "codex"
53-
? "codex"
54-
: driver === "claudeAgent"
55-
? "claude"
56-
: driver === "antigravity"
57-
? "antigravity"
58-
: undefined;
59-
return kind ? PROVIDER_PRESENTATION[kind].color : "var(--foreground)";
51+
const presentation = Object.values(PROVIDER_PRESENTATION).find(
52+
(entry) => entry.driverKind === driver,
53+
);
54+
return presentation?.color ?? "var(--foreground)";
6055
}
6156

6257
/** Pace as a glyph with the words on hover. */

0 commit comments

Comments
 (0)