The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 11:00 UTC
fix(web): screen readers announce each Usage figure with its label (#37241)
Julius Marminge committed
Nov 15, 2026 at 06:55 UTC
b5d9c71e1c31fb42c6f449671f6622d9960ec362
3 files changed
+80
-21
apps/web/src/components/usage/UsageModelDialog.browser.test.tsx
new
+59
@@ -0,0 +1,59 @@
1
+import { describe, expect, it } from "vite-plus/test";
2
+import { page } from "vite-plus/test/browser";
3
+
4
+import { render } from "../../../test/render";
5
+import { UsageModelDialog } from "./UsageModelDialog";
6
+
7
+describe("UsageModelDialog", () => {
8
+ it("exposes each stat as its own label and value to screen readers", async () => {
9
+ await using _screen = await render(
10
+ <UsageModelDialog
11
+ model={{
12
+ model: "claude-sonnet-4-5",
13
+ provider: "claude",
14
+ costUsd: 2,
15
+ totalTokens: 1_000_000,
16
+ tokens: {
17
+ uncachedInputTokens: 100_000,
18
+ cachedInputTokens: 900_000,
19
+ cacheCreationTokens: 0,
20
+ outputTokens: 0,
21
+ reasoningTokens: 0,
22
+ },
23
+ records: 1,
24
+ unpricedRecords: 0,
25
+ unpricedTokens: 0,
26
+ costShare: 1,
27
+ tokenShare: 1,
28
+ }}
29
+ environments={[]}
30
+ metric="cost"
31
+ chartWindow={{
32
+ days: [],
33
+ hours: [],
34
+ resolution: "day",
35
+ timeZone: "UTC",
36
+ referenceTime: undefined,
37
+ hour12: false,
38
+ }}
39
+ onSetPrice={() => {}}
40
+ onClose={() => {}}
41
+ />,
42
+ );
43
+
44
+ const dialog = page.getByRole("dialog");
45
+ for (const [label, value] of [
46
+ ["Cost", "$2.00"],
47
+ ["Tokens", "1M"],
48
+ ["Per 1M tokens", "$2.00"],
49
+ ["Cache hit", "90.0%"],
50
+ ] as const) {
51
+ await expect
52
+ .element(dialog.getByRole("term").getByText(label, { exact: true }))
53
+ .toBeVisible();
54
+ await expect
55
+ .element(dialog.getByRole("definition").getByText(value, { exact: true }).first())
56
+ .toBeVisible();
57
+ }
58
+ });
59
+});
apps/web/src/components/usage/UsageModelDialog.tsx
+4
-4
@@ -88,14 +88,14 @@ export function UsageModelDialog({
88
</DialogHeader>
89
<DialogPanel>
90
<div className="flex flex-col gap-8">
91
- <div className="grid grid-cols-2 gap-x-6 gap-y-4 sm:grid-cols-4">
91
+ <dl className="grid grid-cols-2 gap-x-6 gap-y-4 sm:grid-cols-4">
92
{stats.map((stat) => (
93
<div key={stat.label} className="flex min-w-0 flex-col gap-0.5">
94
- <span className="text-xs text-muted-foreground">{stat.label}</span>
95
- <span className="text-2xl font-semibold text-foreground">{stat.value}</span>
94
+ <dt className="text-xs text-muted-foreground">{stat.label}</dt>
95
+ <dd className="text-2xl font-semibold text-foreground">{stat.value}</dd>
96
</div>
97
))}
98
- </div>
98
+ </dl>
99
100
{/* Unpriced cost is unknown, not zero, so its trend shows tokens. */}
101
<UsageProviderChart
apps/web/src/components/usage/UsagePage.tsx
+17
-17
@@ -658,15 +658,15 @@ function UsageOverview({
658
<section className="grid gap-6 lg:grid-cols-[minmax(0,18rem)_minmax(0,1fr)]">
659
<div className="flex min-w-0 flex-col gap-5">
660
<div className="flex flex-col gap-1">
661
- <span
661
+ <p
662
className={cn(
663
"text-4xl font-semibold text-foreground tabular-nums",
664
figureClass(loadingPartial),
665
)}
666
>
667
{metric === "cost" ? formatUsd(merged.costUsd) : formatTokens(merged.totalTokens)}
668
- </span>
669
- <span className="inline-flex items-center gap-1 text-xs text-muted-foreground">
668
+ </p>
669
+ <p className="inline-flex items-center gap-1 text-xs text-muted-foreground">
670
<span>
671
<span className={figureClass(loadingPartial)}>
672
{formatCount(merged.sessions)} sessions
@@ -688,7 +688,7 @@ function UsageOverview({
688
</PopoverPopup>
689
</Popover>
690
)}
691
- </span>
691
+ </p>
692
</div>
693
694
{showChatGptSharing ? (
@@ -709,8 +709,8 @@ function UsageOverview({
709
const awaitingData = providerLoading && !providersWithData.has(provider);
710
return (
711
<div key={provider} className="flex flex-col gap-1">
712
- <div className="flex items-baseline justify-between gap-4">
713
- <span className="flex min-w-0 items-center gap-2 text-sm text-foreground">
712
+ <dl className="flex items-baseline justify-between gap-4">
713
+ <dt className="flex min-w-0 items-center gap-2 text-sm text-foreground">
714
<span
715
aria-hidden
716
className="size-2 shrink-0 rounded-full"
@@ -731,8 +731,8 @@ function UsageOverview({
731
{sessionLabel}
732
</span>
733
</span>
734
- </span>
735
- <span
734
+ </dt>
735
+ <dd
736
className={cn(
737
"shrink-0 text-sm font-medium text-foreground tabular-nums",
738
figureClass(providerLoading),
@@ -743,9 +743,9 @@ function UsageOverview({
743
: metric === "cost"
744
? formatUsd(totals?.costUsd ?? 0)
745
: formatTokens(totals?.totalTokens ?? 0)}
746
- </span>
747
- </div>
748
- <span
746
+ </dd>
747
+ </dl>
748
+ <p
749
className={cn(
750
"text-xs text-muted-foreground",
751
figureClass(providerLoading),
@@ -755,7 +755,7 @@ function UsageOverview({
755
{metric === "cost"
756
? `${formatPercent(share)} of cost · ${formatTokens(totals?.totalTokens ?? 0)} tokens`
757
: `${formatPercent(share)} of tokens · ${formatUsd(totals?.costUsd ?? 0)}`}
758
- </span>
758
+ </p>
759
</div>
760
);
761
})}
@@ -783,7 +783,7 @@ function UsageOverview({
783
784
<section className="flex flex-col gap-2">
785
<h2 className="text-sm font-medium text-foreground">Totals</h2>
786
- <div className="grid grid-cols-2 gap-x-6 gap-y-4 py-1 md:grid-cols-5">
786
+ <dl className="grid grid-cols-2 gap-x-6 gap-y-4 py-1 md:grid-cols-5">
787
<Metric
788
loading={loadingPartial}
789
label="Processed tokens"
@@ -809,7 +809,7 @@ function UsageOverview({
809
label="Cache savings"
810
value={formatUsd(merged.costQuality.cacheSavingsUsd)}
811
/>
812
- </div>
812
+ </dl>
813
</section>
814
815
{merged.totalTokens > 0 ? (
@@ -1056,12 +1056,12 @@ function Metric({
1056
}) {
1057
return (
1058
<div className="flex min-w-0 flex-col gap-0.5">
1059
- <span className="text-xs text-muted-foreground">{label}</span>
1060
- <span
1059
+ <dt className="text-xs text-muted-foreground">{label}</dt>
1060
+ <dd
1061
className={cn("text-base font-medium text-foreground tabular-nums", figureClass(loading))}
1062
>
1063
{value}
1064
- </span>
1064
+ </dd>
1065
</div>
1066
);
1067
}