Skip to content

Commit 200b210

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 a9fb6a8 commit 200b210

4 files changed

Lines changed: 14 additions & 10 deletions

File tree

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

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

3030
const DRIVER_LABEL: Partial<Record<string, string>> = { codex: "Codex", claudeAgent: "Claude" };
3131
const PACE_LABEL = { ahead: "Ahead of pace", on: "On pace", under: "Under pace" } as const;
@@ -257,7 +257,7 @@ export function UsageLimitsSection({
257257
<PoolWindowCard
258258
key={`${window.kind}:${window.id}`}
259259
pool={window}
260-
color={pool.driver === "claudeAgent" ? colors.claude : colors.codex}
260+
color={colors[usageProviderKind(pool.driver) ?? "codex"]}
261261
now={now}
262262
environmentIds={
263263
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
@@ -14,6 +14,12 @@ export const PROVIDER_ORDER: readonly UsageProviderKind[] = [
1414
"antigravity",
1515
];
1616

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

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
ServerProvider,
77
ServerProviderResetCredits,
88
ServerProviderUsageWindow,
9-
UsageProviderKind,
109
} from "@t3tools/contracts";
1110
import { useAtomValue } from "@effect/atom-react";
1211
import {
@@ -48,9 +47,10 @@ const PACE: Record<LimitPace, { readonly label: string; readonly icon: typeof Ga
4847

4948
/** The series colour the cost chart uses for this driver, so the two views read as one. */
5049
export function barColor(driver: ServerProvider["driver"]): string {
51-
const kind: UsageProviderKind | undefined =
52-
driver === "codex" ? "codex" : driver === "claudeAgent" ? "claude" : undefined;
53-
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)";
5454
}
5555

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

0 commit comments

Comments
 (0)