| ... | @@ -3,6 +3,7 @@ import { limitsNotice } from "@t3tools/shared/usageLimits"; | ... | @@ -3,6 +3,7 @@ import { limitsNotice } from "@t3tools/shared/usageLimits"; |
| 3 | import { GaugeIcon } from "lucide-react"; | 3 | import { GaugeIcon } from "lucide-react"; |
| 4 | | 4 | |
| 5 | import { getDriverOption } from "../settings/providerDriverMeta"; | 5 | import { getDriverOption } from "../settings/providerDriverMeta"; |
| | 6 | import { RedactedSensitiveText } from "../settings/RedactedSensitiveText"; |
| 6 | import { LimitWindows, ResetCredits } from "../usage/UsageLimits"; | 7 | import { LimitWindows, ResetCredits } from "../usage/UsageLimits"; |
| 7 | import { ComposerBanner } from "./ComposerBanner"; | 8 | import { ComposerBanner } from "./ComposerBanner"; |
| 8 | import type { ComposerBannerStackItem } from "./ComposerBannerStack"; | 9 | import type { ComposerBannerStackItem } from "./ComposerBannerStack"; |
| ... | @@ -20,6 +21,27 @@ function accountLabel(account: UsageLimitsReport["accounts"][number]): string { | ... | @@ -20,6 +21,27 @@ function accountLabel(account: UsageLimitsReport["accounts"][number]): string { |
| 20 | : driver; | 21 | : driver; |
| 21 | } | 22 | } |
| 22 | | 23 | |
| | 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 | |
| 23 | /** The /usage-limits result as a composer notice: it stacks under warnings and dismisses like one. */ | 45 | /** The /usage-limits result as a composer notice: it stacks under warnings and dismisses like one. */ |
| 24 | export function usageLimitsBannerItem( | 46 | export function usageLimitsBannerItem( |
| 25 | id: string, | 47 | id: string, |
| ... | @@ -29,9 +51,11 @@ export function usageLimitsBannerItem( | ... | @@ -29,9 +51,11 @@ export function usageLimitsBannerItem( |
| 29 | ): ComposerBannerStackItem { | 51 | ): ComposerBannerStackItem { |
| 30 | const [first] = report.accounts; | 52 | const [first] = report.accounts; |
| 31 | const single = report.accounts.length === 1 && first ? first : null; | 53 | const single = report.accounts.length === 1 && first ? first : null; |
| 32 | const summary = single | 54 | const summary = single ? ( |
| 33 | ? [accountLabel(single), single.plan].filter(Boolean).join(" · ") | 55 | <AccountSummary account={single} /> |
| 34 | : `${report.accounts.length} accounts`; | 56 | ) : ( |
| | 57 | `${report.accounts.length} accounts` |
| | 58 | ); |
| 35 | return { | 59 | return { |
| 36 | id, | 60 | id, |
| 37 | variant: "info", | 61 | variant: "info", |
| ... | @@ -65,7 +89,7 @@ function UsageLimitsBannerBody({ | ... | @@ -65,7 +89,7 @@ function UsageLimitsBannerBody({ |
| 65 | <div key={account.id} className="flex min-w-0 flex-col gap-1"> | 89 | <div key={account.id} className="flex min-w-0 flex-col gap-1"> |
| 66 | {report.accounts.length > 1 ? ( | 90 | {report.accounts.length > 1 ? ( |
| 67 | <span className="truncate text-xs text-muted-foreground"> | 91 | <span className="truncate text-xs text-muted-foreground"> |
| 68 | {[accountLabel(account), account.plan].filter(Boolean).join(" · ")} | 92 | <AccountSummary account={account} /> |
| 69 | </span> | 93 | </span> |
| 70 | ) : null} | 94 | ) : null} |
| 71 | {notice ? ( | 95 | {notice ? ( |