Skip to content

Commit 6ba15c0

Browse files
fix: hide email-bearing account labels in usage limits (pingdotgg#10668)
1 parent a37c664 commit 6ba15c0

2 files changed

Lines changed: 52 additions & 7 deletions

File tree

‎apps/mobile/src/features/usage/UsageLimitsSection.tsx‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,29 @@ function WindowRow(props: {
9797
);
9898
}
9999

100+
function AccountInstanceLabel({ value }: { readonly value: string }) {
101+
const [revealed, setRevealed] = useState(false);
102+
if (!value.includes("@")) {
103+
return (
104+
<Text className="shrink text-xs text-foreground-tertiary" numberOfLines={1}>
105+
· {value}
106+
</Text>
107+
);
108+
}
109+
return (
110+
<Pressable
111+
className="shrink active:opacity-60"
112+
accessibilityRole="button"
113+
accessibilityLabel={revealed ? "Hide account label" : "Reveal account label"}
114+
onPress={() => setRevealed((current) => !current)}
115+
>
116+
<Text className="text-xs text-foreground-tertiary" numberOfLines={1}>
117+
· {revealed ? value : "••••••@••••••"}
118+
</Text>
119+
</Pressable>
120+
);
121+
}
122+
100123
/** One account: icon, name and plan on a single line, then its windows. */
101124
export function AccountLimits(props: {
102125
readonly driver: Driver;
@@ -128,9 +151,7 @@ export function AccountLimits(props: {
128151
<View className="min-w-0 flex-1 flex-row items-baseline gap-2">
129152
<Text className="text-base font-t3-medium text-foreground">{props.label}</Text>
130153
{props.instanceLabel !== props.label ? (
131-
<Text className="shrink text-xs text-foreground-tertiary" numberOfLines={1}>
132-
· {props.instanceLabel}
133-
</Text>
154+
<AccountInstanceLabel key={props.instanceLabel} value={props.instanceLabel} />
134155
) : null}
135156
{props.detail ? (
136157
<Text className="shrink text-sm text-foreground-muted" numberOfLines={1}>

‎apps/web/src/components/chat/ComposerUsageLimits.tsx‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { limitsNotice } from "@t3tools/shared/usageLimits";
33
import { GaugeIcon } from "lucide-react";
44

55
import { getDriverOption } from "../settings/providerDriverMeta";
6+
import { RedactedSensitiveText } from "../settings/RedactedSensitiveText";
67
import { LimitWindows, ResetCredits } from "../usage/UsageLimits";
78
import { ComposerBanner } from "./ComposerBanner";
89
import type { ComposerBannerStackItem } from "./ComposerBannerStack";
@@ -20,6 +21,27 @@ function accountLabel(account: UsageLimitsReport["accounts"][number]): string {
2021
: driver;
2122
}
2223

24+
function AccountSummary({ account }: { readonly account: UsageLimitsReport["accounts"][number] }) {
25+
const label = accountLabel(account);
26+
return (
27+
<>
28+
{label.includes("@") ? (
29+
<RedactedSensitiveText
30+
key={label}
31+
value={label}
32+
ariaLabel="Toggle account label visibility"
33+
revealTooltip="Click to reveal account"
34+
hideTooltip="Click to hide account"
35+
className="max-w-full truncate align-bottom font-sans text-xs leading-normal"
36+
/>
37+
) : (
38+
label
39+
)}
40+
{account.plan ? ` · ${account.plan}` : null}
41+
</>
42+
);
43+
}
44+
2345
/** The /usage-limits result as a composer notice: it stacks under warnings and dismisses like one. */
2446
export function usageLimitsBannerItem(
2547
id: string,
@@ -29,9 +51,11 @@ export function usageLimitsBannerItem(
2951
): ComposerBannerStackItem {
3052
const [first] = report.accounts;
3153
const single = report.accounts.length === 1 && first ? first : null;
32-
const summary = single
33-
? [accountLabel(single), single.plan].filter(Boolean).join(" · ")
34-
: `${report.accounts.length} accounts`;
54+
const summary = single ? (
55+
<AccountSummary account={single} />
56+
) : (
57+
`${report.accounts.length} accounts`
58+
);
3559
return {
3660
id,
3761
variant: "info",
@@ -65,7 +89,7 @@ function UsageLimitsBannerBody({
6589
<div key={account.id} className="flex min-w-0 flex-col gap-1">
6690
{report.accounts.length > 1 ? (
6791
<span className="truncate text-xs text-muted-foreground">
68-
{[accountLabel(account), account.plan].filter(Boolean).join(" · ")}
92+
<AccountSummary account={account} />
6993
</span>
7094
) : null}
7195
{notice ? (

0 commit comments

Comments
 (0)