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