diff --git a/windows/src/App.tsx b/windows/src/App.tsx index f43e4dab..ea2695dd 100644 --- a/windows/src/App.tsx +++ b/windows/src/App.tsx @@ -31,6 +31,7 @@ import { PeriodTabs, PERIOD_LABELS } from './components/PeriodTabs' import type { Period } from './components/PeriodTabs' import { FooterBar } from './components/FooterBar' import { ErrorToast } from './components/ErrorToast' +import { QuotaWarningRow } from './components/QuotaWarningRow' import { SettingsPanel, type ThemeChoice } from './components/SettingsPanel' const payloadCache = new PayloadCache() @@ -296,6 +297,7 @@ export function App() { Burn
AI Coding Cost Tracker
+ {!cliBlocked && !showSettings && } {!cliBlocked && !showSettings && ( diff --git a/windows/src/components/Icons.tsx b/windows/src/components/Icons.tsx index ae433822..65ede47c 100644 --- a/windows/src/components/Icons.tsx +++ b/windows/src/components/Icons.tsx @@ -122,6 +122,20 @@ export function WarningIcon({ filled = true, ...p }: IconProps & { filled?: bool ) } +/// The rest of the severity ladder the quota warning row climbs, standing in for the mac's +/// info.circle, exclamationmark.circle and octagon (WarningIcon covers the triangle). +export function InfoCircleIcon(p: IconProps) { + return +} + +export function ExclamationCircleIcon(p: IconProps) { + return +} + +export function OctagonIcon(p: IconProps) { + return +} + export function ArrowUpRight(p: IconProps) { return } diff --git a/windows/src/components/QuotaWarningRow.tsx b/windows/src/components/QuotaWarningRow.tsx new file mode 100644 index 00000000..03be7604 --- /dev/null +++ b/windows/src/components/QuotaWarningRow.tsx @@ -0,0 +1,38 @@ +import type { ComponentType } from 'react' +import { quotaWarnings, severity, type QuotaState, type Severity } from '../lib/quota' +import { ExclamationCircleIcon, InfoCircleIcon, OctagonIcon, WarningIcon } from './Icons' + +/// Port of QuotaWarningRow in mac/Sources/CodeBurnMenubar/Views/MenuBarContent.swift. Lists +/// every connected provider at or over the threshold with its worst window, so the reader +/// knows whether to slow down on one tool or on several. + +const ICONS: Record> = { + normal: InfoCircleIcon, + warning: ExclamationCircleIcon, + critical: props => , + danger: OctagonIcon, +} + +export function QuotaWarningRow({ quota }: { quota: QuotaState }) { + const warnings = quotaWarnings(quota) + if (warnings.length === 0) return null + + const tone = severity(warnings[0].percent) + const Icon = ICONS[tone] + return ( +
+ + {message(warnings, tone)} +
+ ) +} + +function message(warnings: Array<{ name: string; percent: number }>, tone: Severity): string { + const parts = warnings.map(w => `${w.name} ${Math.round(w.percent)}%`) + if (parts.length === 1) { + // Reads "Claude over limit (105%)" rather than the awkward "Claude 105% of quota used". + if (tone === 'danger') return `${warnings[0].name} over limit (${Math.round(warnings[0].percent)}%)` + return `${parts[0]} of quota used` + } + return parts.join(' ยท ') +} diff --git a/windows/src/styles.css b/windows/src/styles.css index c0da2f67..29e619b4 100644 --- a/windows/src/styles.css +++ b/windows/src/styles.css @@ -215,6 +215,24 @@ code { font-family: var(--font-mono); } .brand-primary { color: var(--label); } .brand-accent { color: var(--brand-accent); } .subhead { font-size: 10.5px; color: var(--label-2); } +/* Quota warning row: sits under the wordmark, above the strip, tinted by the worst + connected provider's severity. */ +.quota-warning { + display: flex; + align-items: center; + gap: 6px; + margin-top: 6px; + padding: 5px 8px; + border-radius: 5px; + font-size: 10.5px; + font-weight: 500; + font-variant-numeric: tabular-nums; + color: var(--label-2); + background: var(--fill-08); +} +.quota-warning.is-warning { color: var(--sev-warning-ink); background: rgba(217, 143, 41, 0.12); } +.quota-warning.is-critical { color: var(--sev-critical-ink); background: rgba(255, 149, 0, 0.12); } +.quota-warning.is-danger { color: var(--sev-danger-ink); background: rgba(255, 59, 48, 0.12); } .main-content { position: relative;