feat(windows): warn in the header when a provider is running out of quota

A capsule under a tab only speaks when you are looking at that tab. The mac
puts a compact row under the wordmark listing every connected provider at or
over the warning threshold with its worst window, so the answer to "am I about
to hit a wall" is on screen the moment the popover opens.

Ported from QuotaWarningRow in MenuBarContent.swift, including the wording
that reads "Claude over limit (105%)" for a single provider past its cap
rather than the awkward "105% of quota used", and the icon ladder from
info circle through exclamation circle and triangle to the octagon.
This commit is contained in:
iamtoruk 2026-09-01 17:10:15 -07:00
parent b6f711f1ba
commit fd7bc47547
4 changed files with 72 additions and 0 deletions

View file

@ -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<MenubarPayload>()
@ -296,6 +297,7 @@ export function App() {
<span className="brand-accent">Burn</span>
</div>
<div className="subhead">AI Coding Cost Tracker</div>
{!cliBlocked && !showSettings && <QuotaWarningRow quota={quota} />}
</header>
{!cliBlocked && !showSettings && (

View file

@ -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 <Svg {...p}><circle cx="8" cy="8" r="6" /><path d="M8 7.3v3.4M8 5.2v.2" /></Svg>
}
export function ExclamationCircleIcon(p: IconProps) {
return <Svg {...p}><circle cx="8" cy="8" r="6" /><path d="M8 5.1v3.5M8 10.7v.2" /></Svg>
}
export function OctagonIcon(p: IconProps) {
return <Svg {...p}><path d="M5.9 2h4.2L13 4.9v4.2L10.1 12H5.9L3 9.1V4.9z" /></Svg>
}
export function ArrowUpRight(p: IconProps) {
return <Svg {...p}><path d="M4.5 11.5 11.5 4.5M6 4.5h5.5V10" /></Svg>
}

View file

@ -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<Severity, ComponentType<{ size: number }>> = {
normal: InfoCircleIcon,
warning: ExclamationCircleIcon,
critical: props => <WarningIcon {...props} filled={false} />,
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 (
<div className={`quota-warning is-${tone}`} role="status">
<Icon size={11} />
<span>{message(warnings, tone)}</span>
</div>
)
}
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(' · ')
}

View file

@ -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;