Repository navigation
fix(gui): report consumed quota share in the per-account quota table - #9077
Conversation
The Providers Accounts table rendered 'N% left' from PoolCell.remaining (100 - usedPercent) and filled each bar to the remaining share, while Accounts & limits, ProviderCapacityQuota/QuotaBars and QuotaSummaryBar all report the consumed share. The same reading therefore appeared as '87% left' on one surface and '13% used' on another, with the bars filling in opposite directions, and the shared warn/exhaustion thresholds (isQuotaWarn, isQuotaExhausted) are expressed on the consumed share. Carry PoolCell.used (the wire value) instead of its inverse, render the existing quota.usedPercent string, and state the two threshold rewrites in the new direction: remaining <= 20 becomes used >= 80 and remaining <= 0 becomes used >= 100. Both are exactly equivalent across 0-100%. Remove the now-unused acctTable.left copy row and update the two documents that described this table as remaining per pool.
|
✅ Deterministic PR hygiene checks passed. |
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. Automatic draft conversion failed. Please convert this pull request to a draft manually until every box above is ticked. Hygiene✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
The cell hardcoded `used >= 80`, which is the value `ProviderCapacityQuota` passes to `QuotaBars`, but nothing tied the two together: changing the provider threshold would have left this table disagreeing with the cards it is being aligned to. `QUOTA_WARN_THRESHOLD` now names that value once. Also corrects the body's equivalence claim: the thresholds agree over the 101 integer percentages, not 1001, and not on fractional input (79.5 rounds to 21 remaining under the old rule and 80 used under the new one). Two new tests hold the direction: the warn boundary at the threshold, and parity with quotaBarTone for the same reading.
3a9f493 to
fa2b01d
Compare
|
Re-attested on What the new commit adds: the cell's warn tone now comes from Fresh local verification on exactly
Two of the new tests are discriminating rather than decorative: the boundary test asserts Hosted CI is still |
Both sides of that assertion called `quotaBarTone(x, QUOTA_WARN_THRESHOLD)`, so it could not fail for any implementation that imported the helper — it certified nothing beyond the import. The boundary example stays and was verified red under a strict `used > 80`. Body corrected in the same push: the fractional equivalence note now covers the exhausted guard too (99.5 shifts like 79.5 does), and the test plan lists the commands that actually ran on this head.
…n the docs The table now carries used share, so the root expectations still read the inverted remaining values. The dashboard guide and the Spanish account reference also still described the table as percentage left.
|
Maintainer integration into
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Summary
The Providers → Accounts tab reports quota with the opposite metric from every other quota surface in the dashboard.
gui/src/components/provider-workspace/AccountQuotaTable.tsxrendered{percent}% leftfrom aPoolCell.remainingfield (src/provider-workspace/account-quota-table.tscomputed100 - usedPercent), and filled each bar to the remaining share.Accounts & limits(the Codex page,CodexAccountPool→codex-account-pool-cards), the provider quota bars (ProviderCapacityQuota→QuotaBars), and the headerQuotaSummaryBarall report consumed share.So the same underlying number read
87% lefton one screen and13% usedon another, and the two bars filled in opposite directions.QuotaBars' own thresholds make this more than cosmetic: warn/critical/exhaustion (isQuotaWarn,isQuotaExhausted) are all expressed on the consumed share, so a pool column could read "healthy, 96% left" next to a card flagging the same account as near-exhausted.This PR makes the account quota table report consumed share, matching every other surface. It is a display-layer change: no probe, cache, routing or admission code is touched.
What changed
PoolCell.remaining→PoolCell.used, andclampRemaining(100 - pct)→clampUsed(pct). The cell now carries the wire value instead of its inverse.PoolBarrenderst("quota.usedPercent")(the string every other surface already uses) and fills the bar to the consumed share.remaining <= 20toused >= 80— the same point on the scale, just stated in the new direction, and it now comes fromquotaBarTone(used, QUOTA_WARN_THRESHOLD)inQuotaBarsinstead of a literal, so this cell cannot drift from the surfaces it is being aligned to.nextmarker's "skip an exhausted window" guard moves fromremaining <= 0toused >= 100(same condition).acctTable.leftis removed fromgui/src/i18n/account-probe-copy.ts; nothing else referenced it.structure/gui-and-management-api.mdanddocs-site/.../reference/cli/providers-accounts.mddescribed this table as "remaining … by pool". The Spanish reference and the dashboard guide were fixed inc83971e(thanks @lidgejun) — they still said "percentage left".I verified the two threshold rewrites by enumeration rather than by eye: over the 101 integer percentages 0–100,
remaining <= 20andused >= 80disagree 0 times, andremaining <= 0vsused >= 100disagree 0 times.They are equivalent for integer percentages, which is what the table receives after
Math.round— they are not equivalent in general. For a fractional reading,Math.roundsends the two expressions to opposite sides at exactly one point: at79.5,round(100 - 79.5) = 21is green under the old rule whileround(79.5) = 80is warn under the new one. The exhausted guard has the same half-point shift: at99.5,round(100 - 99.5) = 1is not exhausted underremaining <= 0, whileround(99.5) = 100is exhausted underused >= 100. So both boundaries move by half a point on fractional input; on integers neither moves. Enumerated over 0.0–100.0 in tenths: one divergence for the warn pair (79.5) and one for the exhausted pair (99.5), out of 1001 readings.Screenshot
Same
/api/provider-quotasdata rendered by the pre-change and post-change components (real component output, real built stylesheet):% left, bar fills to remaining% used, bar fills as it is spentTest plan
Everything below was run on head
1d65de0ee, in a worktree checked out at exactly that SHA, withgit rev-list --left-right --count HEAD...upstream/dev=6 0againstdevat9b5861c1a— i.e. this head is the currentdevtip plus this PR's 6 commits.Root suite (
bun scripts/test.ts, the repo's own runner — a separate lane fromgui/tests, and the one that caught the regression described below):bun scripts/test.ts --changed=9b5861c1a(the current merge base) → 300 pass, 0 fail, 19 files, 6.48s.tests/gui/files importing the changed modules (gui-account-quota-table,rate-limit-reset-credits,quota-bars-rows) → 74 pass, 0 fail, 179expect()calls.tests/ci-workflows/file-size-ratchet.test.ts→ 9 pass, 0 fail (needs--timeout 60000on a cold cache; the default 5000 ms trips inside this file's repo scan and reads as a failure).GUI suite (
cd gui && bun run test, i.e.scripts/test-with-pinned-bun.ts --isolate tests):For transparency: a previous head of this branch (
927baf977) produced 1 fail inprovider-first-response-guidance.test.tsx › Providers page joins /api/providers discovery with the model snapshot and refreshes on retry(stepState("models")expected"failed", got"loading"). That file is not in this PR, it passed 3/3 isolated runs on that same head, and it did not reproduce on1d65de0ee— an order-dependent flake in that suite, not this diff.Static gates on
1d65de0ee:bun run typecheck→No type errors in 2,692 filescd gui && bun run lint→ rc 0;cd gui && bun run lint:i18n→ rc 0bun run structure:check→structure/ SSOT checks passedbun run privacy:scan→Privacy scan passedcd gui && bun run build→ both bundles built (✓ built in 7.08s,✓ built in 1.95s; the >4096 kB chunk warning is pre-existing)The regression the maintainer fixed, and why my earlier verification missed it
c83971e(the maintainer's commit on this branch) correctstests/gui/gui-account-quota-table.test.tsto readusedinstead ofremaining. That was a real break I shipped, and the root cause is a verification gap worth stating: my earlier run covered onlygui/tests, while this file lives in the root lane'stests/gui/. Two different ran suites, one of them unrun.Proof it was red and not a cosmetic rename — the old head
3fe2dbadbin a throwaway worktree:Three assertions still reading the inverted field. The same file is green on
1d65de0ee(11/11, now part of the 74 above). Both lanes are in the verification list for this PR from here on.account-quota-table-stacked.test.tsxalso gained an example that does not exist to rename a string: it builds a cell whose windows read exactlyQUOTA_WARN_THRESHOLDandQUOTA_WARN_THRESHOLD - 1and requiresbar-warnon the first andbar-greenon the second. Verified red by flipping the comparison toused > 80, which turns 80% green and fails the example. (An earlier revision of this PR also added a "tones matchquotaBarTone" example; it was removed because both sides called the same function, so it could not fail.)Regression coverage: the three existing GUI tests that pinned the old wording now pin the consumed share instead, and each also exercises the direction of the change rather than just the label —
account-quota-table-stacked.test.tsxasserts0% usedfor an unspent 5-hour window and100% usedfor an exhausted weekly one,anthropic-subscription-label.test.tsxasserts37% used/18% usedfrom 37%/18% upstream readings, andprovider-auth-target-capture.test.tsxasserts20% usedfrom a 20% upstream reading.Checklist
One thing worth a maintainer's opinion:
gui/src/components/v2-accounts/account-quota-meters.tsx(withserving-summary.tsx) also renders{pct}% left, but neither file is imported anywhere right now —AccountQuotaMeters/ServingSummaryhave no callers ondev. I left that pair alone rather than change unreachable code, on the assumption it is staged for the v2 Codex accounts page. If it is about to be mounted, it will reintroduce the same inversion and should be flipped in the same direction.Review readiness
Re-attested on
1d65de0ee, after two maintainer merge commits on this branch (c83971etest/doc fix, then927baf977and1d65de0eemergingdev) reset the checklist. Those commits are the maintainer's; I did not overwrite them.1d65de0ee— the commands and results in the test plan above.devcommit —9b5861c1a, 0 behind (git rev-list --left-right --count HEAD...upstream/dev=6 0).1d65de0ee.Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
Required local validation passed; commands, results, and any full-suite exception are documented.
I pushed my PR to a recent dev commit (at most 10 behind; a maintainer may still ask for the exact tip before merge).
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.