The credit row broke the column alignment its own comment documents - #161
Conversation
|
Merged as part of The One gap I closed on topYour test pins I checked by mutation rather than assuming: narrowing both call sites to It is now This is the second time in two PRs that the property was pinned and the wiring was not — same shape as the double guard on #157. Worth watching for as a pattern rather than treating each as a one-off: a unit test on the function, and the thing that feeds it left in a place tests cannot reach. Gate: core 147, opencode 1378, pi 14, typecheck and biome clean. |
Follow-up to #160. Both defects were caught by looking at the rendered sidebar; neither was visible to the tests that shipped with it.
The label column overflowed
QuotaRowpadded withprops.label.padEnd(3), directly beneath a comment stating the invariant:5hand7dare two characters, so the hardcoded 3 covered them.creditsis seven —padEnd(3)is a no-op, and the bar plus its percentage started four columns right of every other row.The column belonged to the wrong scope
Deriving the width from the row set fixes one account and breaks the sidebar, because
buildQuotaRowsForDisplayis called with a single account's quota. An account with no spend control computes 3 while one with credits computes 8, so stacked accounts disagree about where the bar starts:The column is a property of the sidebar, not of a row set.
computeQuotaLabelWidthnow takes the account list and is computed once for every rendered account:Semantics: no account anywhere has a credit budget → width stays 3, byte-identical to today; any account has one → every account shares the wider column. The first half is the regression guard, since most setups have no spend control at all.
The width is
label.length + 1rather than the bare maximum. Padding to exactly the longest label leaves it with no separator (credits▓▓▓▓) — invisible for5h/7donly because the floor of 3 already exceeds them.The amounts were parsed and dropped
normalizeWhamparseslimit,used,remainingandunit; the sidebar rendered onlyusedPercent. "20%" of an unknown budget is not actionable — 20% of 2,500 credits and 20% of 50 look identical.Now
502 / 2,500 creditsin the sidebar and502 / 2,500 credits, 1,998 remainingin/openai-quota. Three details that matter:usedarrives as501.7787666320801and must not render raw; the unit comes from theunitfield rather than being assumed, so no$— these are credits, not currency; and the unit is pluralised against the quantity.Verification
Mutation proofs, each reverting one change alone:
I checked the regression guard directly rather than trusting the assertion —
computeQuotaLabelWidthreturns 3 for a two-account sidebar with no spend control anywhere, and 8 once one account has it.Worth noting why #160's tests passed through this: they assert on the row projection — labels, values, presence — which cannot see that two accounts disagree about where column two begins. Geometry needs a test that spans accounts.
Gates from the repo root: build, format:check, lint, types, test — 147 core + 1377 OpenCode (+3) + 14 Pi.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Fixes the quota sidebar so bars and percentages stay aligned across accounts even when a credit row is present.
The label column width is now computed once over the whole sidebar rather than per-account, so an account with a
creditsrow no longer shifts its own bars to the right of every other row. Accounts without a spend control keep the previous 3-character width, so rendering is byte-identical when no account has a credit budget.Also renders credit budget amounts with grouped digits and a pluralized unit —
502 / 2,500 credits— in both the sidebar and/openai-quota, replacing the previously unreadable raw502 / 2500.Written for commit ecc673b. Summary will update on new commits.