@devries-cameron20 / t3code-1 / commits / 17dbe8dda3
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(web): show only providers with usage in usage views (#7563)

Tristan Knight committed Aug 24, 2026 at 04:03 UTC 17dbe8dda3ba87eb83804bc93fc0cb945186d204
5 files changed +74 -20
apps/web/src/components/usage/UsagePage.test.tsx
+10 -7
@@ -53,13 +53,16 @@ vi.mock("../WorkspaceBreadcrumb", () => ({
53 vi.mock("../WorkspacePageContainer", () => ({ WorkspacePageContainer: "main" }));
54 vi.mock("../WorkspacePageHeader", () => ({ WorkspacePageHeader: "header" }));
55 vi.mock("./UsageProviderChart", () => ({ UsageProviderChart: "div" }));
56 -vi.mock("./usageProviders", () => ({
57 - PROVIDER_ORDER: ["codex", "claude"],
58 - PROVIDER_PRESENTATION: {
59 - codex: { color: "white", label: "Codex", mark: "span" },
60 - claude: { color: "orange", label: "Claude Code", mark: "span" },
61 - },
62 -}));
56 +vi.mock("./usageProviders", async (importOriginal) => {
57 + const actual = await importOriginal<typeof import("./usageProviders")>();
58 + return {
59 + ...actual,
60 + PROVIDER_PRESENTATION: {
61 + codex: { color: "white", label: "Codex", mark: "span" },
62 + claude: { color: "orange", label: "Claude Code", mark: "span" },
63 + },
64 + };
65 +});
66
67 import { UsagePage } from "./UsagePage";
68
apps/web/src/components/usage/UsagePage.tsx
+27 -7
@@ -32,7 +32,7 @@ import {
32 import { WorkspacePageContainer } from "../WorkspacePageContainer";
33 import { WorkspacePageHeader } from "../WorkspacePageHeader";
34 import { UsageProviderChart, type UsageChartMetric } from "./UsageProviderChart";
35 -import { PROVIDER_ORDER, PROVIDER_PRESENTATION } from "./usageProviders";
35 +import { PROVIDER_ORDER, PROVIDER_PRESENTATION, providersWithUsage } from "./usageProviders";
36
37 const WINDOW_OPTIONS = [
38 { days: 1, label: "Past 24h" },
@@ -74,6 +74,8 @@ export function UsagePage() {
74 () => (isPast24Hours ? merged.hourly : merged.daily).toReversed(),
75 [isPast24Hours, merged.daily, merged.hourly],
76 );
77 + const activeProviders = useMemo(() => providersWithUsage(merged.providers), [merged.providers]);
78 + const timeValueColumnWidth = `${60 / (activeProviders.length + 2)}%`;
79
80 const selectWindow = (days: number) => {
81 setWindowSelection({
@@ -225,7 +227,7 @@ export function UsagePage() {
227 </span>
228 </div>
229
228 - {PROVIDER_ORDER.map((provider) => {
230 + {activeProviders.map((provider) => {
231 const totals = merged.providers.find((entry) => entry.provider === provider);
232 const share =
233 metric === "cost" ? (totals?.costShare ?? 0) : (totals?.tokenShare ?? 0);
@@ -276,6 +278,7 @@ export function UsagePage() {
278 {metric === "tokens" ? "processed tokens" : "cost"}
279 </h2>
280 <UsageProviderChart
281 + providers={activeProviders}
282 days={days}
283 daily={merged.daily}
284 hours={hours}
@@ -331,7 +334,13 @@ export function UsagePage() {
334 </div>
335
336 {breakdown === "model" ? (
334 - <table className="w-full text-sm">
337 + <table className="w-full table-fixed text-sm">
338 + <colgroup>
339 + <col className="w-2/5" />
340 + <col className="w-1/5" />
341 + <col className="w-1/5" />
342 + <col className="w-1/5" />
343 + </colgroup>
344 <thead>
345 <tr className="border-b border-border text-left text-xs text-muted-foreground">
346 <th className="py-2 font-normal">Model</th>
@@ -374,11 +383,19 @@ export function UsagePage() {
383 </tbody>
384 </table>
385 ) : (
377 - <table className="w-full text-sm">
386 + <table className="w-full table-fixed text-sm">
387 + <colgroup>
388 + <col className="w-2/5" />
389 + {activeProviders.map((provider) => (
390 + <col key={provider} style={{ width: timeValueColumnWidth }} />
391 + ))}
392 + <col style={{ width: timeValueColumnWidth }} />
393 + <col style={{ width: timeValueColumnWidth }} />
394 + </colgroup>
395 <thead>
396 <tr className="border-b border-border text-left text-xs text-muted-foreground">
397 <th className="py-2 font-normal">{isPast24Hours ? "Hour" : "Day"}</th>
381 - {PROVIDER_ORDER.map((provider) => (
398 + {activeProviders.map((provider) => (
399 <th key={provider} className="py-2 text-right font-normal">
400 {PROVIDER_PRESENTATION[provider].label}
401 </th>
@@ -390,7 +407,10 @@ export function UsagePage() {
407 <tbody>
408 {breakdownPeriods.length === 0 ? (
409 <tr>
393 - <td colSpan={5} className="py-6 text-center text-muted-foreground">
410 + <td
411 + colSpan={activeProviders.length + 3}
412 + className="py-6 text-center text-muted-foreground"
413 + >
414 No activity in this window.
415 </td>
416 </tr>
@@ -405,7 +425,7 @@ export function UsagePage() {
425 ? formatHourShort(period.hourStart, window.timeZone)
426 : formatDayShort(period.day)}
427 </td>
408 - {PROVIDER_ORDER.map((provider) => (
428 + {activeProviders.map((provider) => (
429 <td
430 key={provider}
431 className="py-2 text-right text-muted-foreground tabular-nums"
apps/web/src/components/usage/UsageProviderChart.test.ts
+12
@@ -1,6 +1,7 @@
1 import { describe, expect, it } from "vite-plus/test";
2
3 import { buildDayColumns, niceScale } from "./UsageProviderChart";
4 +import { providersWithUsage } from "./usageProviders";
5
6 describe("niceScale", () => {
7 it("never puts the peak above the top of the scale", () => {
@@ -96,6 +97,17 @@ describe("buildDayColumns", () => {
97 });
98 });
99
100 +describe("providersWithUsage", () => {
101 + it("omits providers with no cost or tokens", () => {
102 + expect(
103 + providersWithUsage([
104 + { provider: "codex", costUsd: 0, totalTokens: 0 },
105 + { provider: "claude", costUsd: 0, totalTokens: 200 },
106 + ]),
107 + ).toEqual(["claude"]);
108 + });
109 +});
110 +
111 describe("hourly chart columns", () => {
112 it("zero-fills inactive hours and preserves hourly provider values", () => {
113 const byHour = new Map([
apps/web/src/components/usage/UsageProviderChart.tsx
+7 -4
@@ -19,6 +19,7 @@ const PLOT_TOP = 8;
19 export type UsageChartMetric = "tokens" | "cost";
20
21 interface UsageProviderChartProps {
22 + readonly providers: readonly UsageProviderKind[];
23 readonly days: readonly string[];
24 readonly daily: readonly DailyTotals[];
25 readonly hours: readonly string[];
@@ -187,6 +188,7 @@ export function buildDayColumns(
188 }
189
190 export function UsageProviderChart({
191 + providers,
192 days,
193 daily,
194 hours,
@@ -209,7 +211,7 @@ export function UsageProviderChart({
211 const tooltipRef = useRef<HTMLDivElement | null>(null);
212 const hoverPositionRef = useRef<{ x: number; y: number } | null>(null);
213
212 - const { paths, series, stepX, ticks, toY } = useMemo(() => {
214 + const { paths, ticks, stepX, toY, series } = useMemo(() => {
215 if (periods.length === 0) {
216 return {
217 paths: [],
@@ -235,7 +237,8 @@ export function UsageProviderChart({
237 const toY = (value: number) =>
238 max === 0 ? VIEW_HEIGHT : VIEW_HEIGHT - (value / max) * (VIEW_HEIGHT - PLOT_TOP);
239
238 - const built = PROVIDER_ORDER.map((provider, providerIndex) => {
240 + const built = providers.map((provider) => {
241 + const providerIndex = PROVIDER_ORDER.indexOf(provider);
242 const line = curvePath(
243 smoothCurve(
244 columns.map((column, periodIndex) => ({
@@ -260,7 +263,7 @@ export function UsageProviderChart({
263 ticks: tickValues,
264 toY,
265 };
263 - }, [byPeriod, metric, periods]);
266 + }, [byPeriod, metric, periods, providers]);
267
268 const format = metric === "tokens" ? formatTokens : formatUsd;
269
@@ -422,7 +425,7 @@ export function UsageProviderChart({
425 }}
426 >
427 <div className="mb-1 text-muted-foreground">{formatTooltipPeriod(hoveredPeriod)}</div>
425 - {PROVIDER_ORDER.map((provider) => {
428 + {providers.map((provider) => {
429 const { label, mark: Mark } = PROVIDER_PRESENTATION[provider];
430 return (
431 <div key={provider} className="flex items-center justify-between gap-3">
apps/web/src/components/usage/usageProviders.ts
+18 -2
@@ -10,8 +10,8 @@ type UsageProviderPresentation = {
10
11 /**
12 * Exhaustive presentation for providers supported by the usage contract.
13 - * Declaration order is reused by every chart, table, legend, and skeleton, so
14 - * adding a provider only requires its contract support and one entry here.
13 + * Declaration order is reused by every chart and table, so adding a provider
14 + * only requires its contract support and one entry here.
15 */
16 export const PROVIDER_PRESENTATION = {
17 codex: {
@@ -28,3 +28,19 @@ export const PROVIDER_PRESENTATION = {
28
29 /** Stable provider reading order across charts, summaries, tables, and hover rows. */
30 export const PROVIDER_ORDER = Object.keys(PROVIDER_PRESENTATION) as UsageProviderKind[];
31 +
32 +/** Providers with real activity, independent of the metric currently displayed. */
33 +export function providersWithUsage(
34 + totals: readonly {
35 + readonly provider: UsageProviderKind;
36 + readonly costUsd: number;
37 + readonly totalTokens: number;
38 + }[],
39 +): readonly UsageProviderKind[] {
40 + const active = new Set(
41 + totals
42 + .filter((entry) => entry.totalTokens > 0 || entry.costUsd > 0)
43 + .map((entry) => entry.provider),
44 + );
45 + return PROVIDER_ORDER.filter((provider) => active.has(provider));
46 +}