* fix(provider): mark a window one model's own as capped, as routing holds it
Routing held an account at its usage cap when any window that counts the
model was at or past it, Opus's own window included: CapHeld walks the
allowance with Limit.applies, and a window naming one model counts every
request whose id holds that word. WithCapped, which tells the GUI which
windows a cap counts, left those windows out — it marked a window only
when it named no model. So a Claude account kept at 70% whose Opus week
was at 90% was barred, and then answered 429 with nothing left when it was
the only account, while the Providers page showed the account in use, no
"At its cap" note and no tick on that window's meter. The rows said the
opposite of what routing was doing, and the cap look broken.
WithCapped now marks a window as capping as CapHeld holds it: not Aside,
not Unlimited, one model's own window like the rest. The GUI needs no
change: capHeldOf, capHeldNote and capMark already read Capped, and a
mark on a per-model window says the cap holds that window's model — the
window's row already names its model. The 429-when-every-account-capped
path is untouched: capReached counts only the windows that stop an
account for every model, as its comment says, and is not what WithCapped
marks.
TestWithCappedMarksPerModelWindows fails on the old rule with "the window
one model's own is not marked" and passes: the account-wide window, a
window naming "opus", on-demand spending (Aside) and an unlimited one are
marked, not marked, not marked and not marked, and the windows handed in
are left as they were. TestCapHeld, which spells out that Opus's window
counts for Opus alone, and the rest of the cap tests are unchanged.
Validation on Windows: go test ./internal/provider passes whole;
TestWithCappedMarksPerModelWindows fails without the change. go vet
./internal/... and the darwin, GOOS=linux and GOOS=windows builds pass.
The full go test -tags nogui -count=1 ./... under a temp HOME leaves the
same Unix-only failures as the base commit does on Windows (Keychain,
mode bits, shell-script CLIs, skills' folders); the provider package
passes whole. account-cap.test.cjs's fixtures carry capped on
account-wide windows, so the data change does not touch them; Playwright
is not installed in this worktree, so it was not run.
* gui: an account held at its cap for some models says which, not that it is held
A window that counts some models only (Opus's week, a pool's) is now
marked Capped, so the Providers page said "At its cap" and "sends
requests to the other accounts" for an account routing still used for
every other model. WithCapped also sets CapsSome on such a window;
capHeldOf tells those from the account's own windows, and an account
held by them alone reads "Opus week at its cap · back in 3h", its
tooltip saying other models still use it. When an account-wide window
holds it, that window's renewal is the time it is back.
account-cap.test.cjs: a Codex account whose five hours and week are
under its 70% cap but whose Opus week is at 90% names the Opus week, in
English and Chinese; it fails on the PR's head.
---------
Co-authored-by: yetone <yetoneful@gmail.com>