feat: per-model weekly limit segment (Fable) from the OAuth usage endpoint
Ask
A per-model weekly segment next to 5h / 7d, for models that carry their own weekly cap (currently Fable). Rendered with the same battery bar, ⏰ countdown and →NN% projection so it reads as a third window:
5h[ 94% ]⏰1h39m →100%·8m | 7d[ 46% ]⏰3d08h →100%·2d18h | Fable[ 81% ]⏰3d08h →100%·20h32m | Fable 5.1(79.1k/1.0M) | cache 59m55s
Why it can't come from stdin
Claude Code's statusLine payload only carries rate_limits.five_hour and rate_limits.seven_day. The per-model cap is exposed only by the OAuth usage endpoint that the Claude desktop / web usage panels use:
GET https://api.anthropic.com/api/oauth/usage
authorization: Bearer <accessToken from ~/.claude/.credentials.json>
anthropic-beta: oauth-2025-04-20
Relevant part of the response (macOS, Max plan, 2026-09-03):
"limits": [
{"kind": "session", "group": "session", "percent": 76, "severity": "warning", "resets_at": "...", "scope": null, "is_active": false},
{"kind": "weekly_all", "group": "weekly", "percent": 45, "severity": "normal", "resets_at": "...", "scope": null, "is_active": false},
{"kind": "weekly_scoped", "group": "weekly", "percent": 77, "severity": "warning", "resets_at": "...",
"scope": {"model": {"id": null, "display_name": "Fable"}, "surface": null}, "is_active": true}
]
five_hour / seven_day in the same response match what stdin reports, so the endpoint is the same data with one extra row. A scoped limit is a sub-cap of the weekly pool, not extra quota (Anthropic's Fable help page: up to 50% of the weekly allowance on Max).
Design questions before any code
- Token access. cs does network today (balance, IP risk) but never reads
~/.claude/.credentials.json. Is reading the OAuth token in scope? Read-only, never written, never logged; on macOS the token may live in the login Keychain instead of the file. - Endpoint stability. It is undocumented. Proposal: hidden by default,
show_per_modelopt-in, and the segment silently disappears if the response shape changes — never an error in the bar. - Where the fetch lives. The daemon's refresh cycle next to
_balance_refresh.py, cached withcache_ttl_seconds, so the render fast-path stays stdin-only and never blocks on the network. - Projection.
project_windowover the 7d window length reproduces the→NN%·ETAchip; the full bucket-learned 7d model could be reused later if wanted.
Prototype
I have a working out-of-tree version: a wrapper that runs cs render and splices a Fable[…] segment built with _build_dimension, window_severity_rgb and _render_projection, with the endpoint response cached on disk for 300 s. It renders identically to 7d and degrades to plain cs render if any import or the endpoint breaks. Happy to turn it into a proper PR along the lines above if you're open to it.
Shipped in v3.42.0 (e6e53ae), thanks for the writeup.
Implementation is src/claude_statusbar/scoped_usage.py: it reads the OAuth token (~/.claude/.credentials.json, falling back to the macOS login Keychain), calls https://api.anthropic.com/api/oauth/usage in the background, and keeps only the kind == "weekly_scoped" rows, labelled by scope.model.display_name — so Fable and any other per-model cap the endpoint returns show up without a hardcoded model list.
Enable it with:
cs config set show_per_model true
Deliberate constraints, since this touches credentials:
- Off by default; turning it on is the explicit consent to read the OAuth credential.
- The token stays on a private pipe — never in argv, logs, or any cache.
- Requests are account-scoped and cached for 5 minutes, issued from background collection only, never on the render path.
- Relay / no-quota sessions never make the request; an unsupported response just hides the segment.
- Values are validated before render (percent finite and 0–100, label ≤40 chars with no control characters, max 8 rows).
The segment renders on its own line under the main usage row, sharing the battery style and the projection setting. Docs: README "Optional model-specific weekly limits".
Upgrade with cs upgrade. Closing — please reopen if the Fable row doesn't appear for your account.