Skip to content

Commit 3834be6

Browse files
kevin-dpclaude
andcommitted
fix(agents-server-ui): keep token/model detail in the gauge's aria-label [review #4596]
Switching the indicator to a HoverCard moved the token/window/model detail into hover-only popover content, so the trigger's aria-label dropped to just the percent — a small accessibility regression for keyboard/screen-reader users, who could previously read those numbers from the old Tooltip's label. Restore the `<used> / <window> tokens · <model>` summary to the trigger's own aria-label. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 5dd6e3b commit 3834be6

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

packages/agents-server-ui/src/components/ContextUsageIndicator.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
parseContextBreakdown,
77
contextUsageLevel,
88
formatContextUsagePercent,
9+
formatTokenCount,
910
} from '@electric-ax/agents-runtime/client'
1011
import type { EntityStreamDBWithActions } from '@electric-ax/agents-runtime/client'
1112
import { HoverCard } from '../ui/HoverCard'
@@ -82,6 +83,15 @@ export function ContextUsageIndicator({
8283

8384
const level = contextUsageLevel(usage.ratio)
8485
const percent = formatContextUsagePercent(usage.ratio)
86+
// Keep the essential numbers in the trigger's own label: the breakdown popover
87+
// is hover-only (Base UI PreviewCard), so keyboard/screen-reader users would
88+
// otherwise get only the percent from the trigger.
89+
const tokensLabel = `${formatTokenCount(usage.usedTokens)} / ${formatTokenCount(
90+
usage.contextWindow
91+
)} tokens`
92+
const ariaLabel = `Context used: ${percent} (${tokensLabel}${
93+
usage.modelId ? ` · ${usage.modelId}` : ``
94+
}) — hover for breakdown`
8595

8696
return (
8797
<HoverCard.Root>
@@ -91,7 +101,7 @@ export function ContextUsageIndicator({
91101
className={[styles.indicator, styles[level]]
92102
.filter(Boolean)
93103
.join(` `)}
94-
aria-label={`Context used: ${percent} — hover for breakdown`}
104+
aria-label={ariaLabel}
95105
>
96106
<ContextUsageRing ratio={usage.ratio} />
97107
<span className={styles.percent}>{percent}</span>

0 commit comments

Comments
 (0)