Skip to content

Commit 10fafc4

Browse files
committed
fix(usage): keep failure notices private and reveals accessible
1 parent aab6515 commit 10fafc4

4 files changed

Lines changed: 29 additions & 3 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { expect, it } from "vite-plus/test";
2+
import { userEvent } from "vite-plus/test/browser";
3+
4+
import { render } from "../../../test/render";
5+
import { RedactedSensitiveText } from "./RedactedSensitiveText";
6+
7+
it("exposes the value to assistive technology only while revealed", async () => {
8+
await using screen = await render(
9+
<RedactedSensitiveText
10+
11+
ariaLabel="Toggle account email visibility"
12+
revealTooltip="Click to reveal email"
13+
hideTooltip="Click to hide email"
14+
/>,
15+
);
16+
const button = screen.getByRole("button");
17+
await expect.element(button).toHaveAccessibleName("Toggle account email visibility");
18+
await expect.element(button).toHaveAttribute("aria-pressed", "false");
19+
await userEvent.click(button);
20+
await expect.element(button).toHaveAccessibleName("[email protected]");
21+
await expect.element(button).toHaveAttribute("aria-pressed", "true");
22+
await userEvent.click(button);
23+
await expect.element(button).toHaveAccessibleName("Toggle account email visibility");
24+
await expect.element(button).toHaveAttribute("aria-pressed", "false");
25+
});

‎apps/web/src/components/settings/RedactedSensitiveText.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ export function RedactedSensitiveText(props: {
4949
props.className,
5050
)}
5151
onClick={() => setRevealed((current) => !current)}
52-
aria-label={props.ariaLabel}
52+
aria-label={revealed ? value : props.ariaLabel}
53+
aria-pressed={revealed}
5354
>
5455
{revealed ? value : redacted}
5556
</button>

‎packages/shared/src/usageLimits.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ describe("pools", () => {
736736
expect(collected.map((entry) => entry.limits.windows.length)).toEqual([1, 0]);
737737
expect(collectLimitPools(collected, Date.parse(checkedAt))[0]?.accounts).toHaveLength(2);
738738
expect(collectLimitNotices(input)).toEqual([
739-
`Desktop · hub · [email protected]: ${unavailable.message ?? "Could not read limits."}`,
739+
`Desktop · hub · Claude: ${unavailable.message ?? "Could not read limits."}`,
740740
]);
741741
input.delete(EnvironmentId.make("env-a"));
742742
expect(collectLimitAccounts(input)).toHaveLength(2);

‎packages/shared/src/usageLimits.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ export function collectLimitNotices(presentations: LimitPresentations): readonly
423423
if (account.usageLimits.unavailable?.reason === "unsupported") continue;
424424
const notice = limitsNotice(account.usageLimits);
425425
if (notice) {
426-
const name = `${source.label} · ${account.email || hubAccountName(account)}`;
426+
const name = `${source.label} · ${PROVIDER_DISPLAY_NAMES[account.driver] ?? account.driver}`;
427427
notices.push(`${label(environmentLabel, name)}: ${notice}`);
428428
}
429429
}

0 commit comments

Comments
 (0)