From a62e473f7c6fc1c4e549045f0044e1c4e4267b47 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sun, 15 Nov 2026 14:29:43 +0000 Subject: [PATCH] fix(web): screen readers announce each Usage figure with its label The Usage summary, provider rows, Totals row and model dialog stat tiles laid out label and value spans with CSS only, so Chromium exposed each area as one run of text. Mark them up as description lists (and the headline lines as paragraphs), matching the limits popover fix. Co-Authored-By: Claude Opus 5.5 --- .../usage/UsageModelDialog.browser.test.tsx | 59 +++++++++++++++++++ .../src/components/usage/UsageModelDialog.tsx | 8 +-- apps/web/src/components/usage/UsagePage.tsx | 34 +++++------ 3 files changed, 80 insertions(+), 21 deletions(-) create mode 100644 apps/web/src/components/usage/UsageModelDialog.browser.test.tsx diff --git a/apps/web/src/components/usage/UsageModelDialog.browser.test.tsx b/apps/web/src/components/usage/UsageModelDialog.browser.test.tsx new file mode 100644 index 0000000000000..11cc88294322b --- /dev/null +++ b/apps/web/src/components/usage/UsageModelDialog.browser.test.tsx @@ -0,0 +1,59 @@ +import { describe, expect, it } from "vite-plus/test"; +import { page } from "vite-plus/test/browser"; + +import { render } from "../../../test/render"; +import { UsageModelDialog } from "./UsageModelDialog"; + +describe("UsageModelDialog", () => { + it("exposes each stat as its own label and value to screen readers", async () => { + await using _screen = await render( + {}} + onClose={() => {}} + />, + ); + + const dialog = page.getByRole("dialog"); + for (const [label, value] of [ + ["Cost", "$2.00"], + ["Tokens", "1M"], + ["Per 1M tokens", "$2.00"], + ["Cache hit", "90.0%"], + ] as const) { + await expect + .element(dialog.getByRole("term").getByText(label, { exact: true })) + .toBeVisible(); + await expect + .element(dialog.getByRole("definition").getByText(value, { exact: true }).first()) + .toBeVisible(); + } + }); +}); diff --git a/apps/web/src/components/usage/UsageModelDialog.tsx b/apps/web/src/components/usage/UsageModelDialog.tsx index 0fb6b89ce73a4..2435f5e027de2 100644 --- a/apps/web/src/components/usage/UsageModelDialog.tsx +++ b/apps/web/src/components/usage/UsageModelDialog.tsx @@ -88,14 +88,14 @@ export function UsageModelDialog({
-
+
{stats.map((stat) => (
- {stat.label} - {stat.value} +
{stat.label}
+
{stat.value}
))} -
+ {/* Unpriced cost is unknown, not zero, so its trend shows tokens. */}
- {metric === "cost" ? formatUsd(merged.costUsd) : formatTokens(merged.totalTokens)} - - +

+

{formatCount(merged.sessions)} sessions @@ -688,7 +688,7 @@ function UsageOverview({ )} - +

{showChatGptSharing ? ( @@ -709,8 +709,8 @@ function UsageOverview({ const awaitingData = providerLoading && !providersWithData.has(provider); return (
-
- +
+
- - +
-
- + +

+

); })} @@ -783,7 +783,7 @@ function UsageOverview({

Totals

-
+
-
+
{merged.totalTokens > 0 ? ( @@ -1056,12 +1056,12 @@ function Metric({ }) { return (
- {label} - {label} +
{value} - +
); }