fix(operations): cache the usage endpoint (avoid 429) + show weekly-Sonnet not Opus
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 3s

Two follow-ups to the usage-% feature:

1. The /api/oauth/usage endpoint 429s when polled often — /operations refreshes
   every 5s and each refresh hit it (plus the supervisor + ad-hoc calls). Cache
   the last good payload on the host bridge for 60s and serve it; only re-fetch
   when stale, so Anthropic sees ~1 req/min regardless of dashboard polling. On
   a fetch failure (e.g. a transient 429) serve the last good payload instead of
   blanking the card. The 5-hour window moves slowly, so 60s stays fresh.

2. The third meter showed weekly-Opus, which is null on this account (the
   per-model weekly cap that's actually populated is Sonnet). Switched the
   display to seven_day_sonnet / "שבועי · Sonnet". (The supervisor keeps gating
   on seven_day_opus — the halacha drain runs Opus, so the Opus cap is the
   correct gate even when it's null/inactive.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-13 10:43:57 +00:00
parent 17460044ac
commit 693126484b
2 changed files with 27 additions and 6 deletions

View File

@@ -83,7 +83,7 @@ function SubscriptionUsagePanel({ usage }: { usage: SubscriptionUsage }) {
<div className="grid gap-6 sm:grid-cols-3">
<UsageMeter label="חלון 5-שעות" w={usage.five_hour} />
<UsageMeter label="שבועי · כל המודלים" w={usage.seven_day} />
<UsageMeter label="שבועי · Opus" w={usage.seven_day_opus} />
<UsageMeter label="שבועי · Sonnet" w={usage.seven_day_sonnet} />
</div>
<div className="mt-3 border-t border-rule-soft pt-2.5 text-[11.5px] text-ink-muted">
המנוי המשותף שמפעיל את כל הסוכנים והדריינרים. הפס נצבע בענבר מעל 75%