Repository navigation
feat(menubar): say whether a quota window lasts until its reset - #1287
ozymandiashh wants to merge 1 commit into
Conversation
The Plan tab has answered "am I going to make it?" since getagentseal#726/getagentseal#728, but the two surfaces people actually glance at — the Capacity Dock's window columns and the agent-tab quota hover card — still only said when the window resets, which is the one fact that does not answer the question. Both now draw one line under the bar, off the same projection: `Lasts until reset` while the linear projection lands at or under 100% at reset, `Runs out in 2d 8h` when it overflows on a window long enough for a whole-window rate to be defensible, and `Won't last until reset` when it overflows on a window of 6 hours or less, which keeps getagentseal#726's ETA suppression rather than crying wolf over one burst. It stays silent in the first 3% of a window, on an exhausted window, without a reset time, and on clock skew — the same guards `QuotaPace.evaluate` already has, which stays the only pace math in the app. `QuotaSummary.Window` carries no window length, so rather than thread one through ~15 adapter call sites the length is inferred from the normalized label the adapters already derive from the exact API duration ("Weekly", "5-hour", "Weekly · Opus", "Monthly usage limit"). Calendar months are measured back from the reset date in UTC, mirroring how the Codex spend window is derived; a label that implies no length keeps the row silent rather than guessing one. The dock reserves the line's height whether or not a column has a verdict, because the glance panel's frame is computed rather than fitted: a projection crossing in or out of silence must not resize the bubble under the pointer. The hover card is fitted, so there the line collapses. Closes getagentseal#1215
|
Leaving this open rather than merging, and it is not because the code is wrong: the math checks out on every real window on this machine and the tests are mutation-proven. Two reasons. First, #1267 writes a pace caption into the same slot under the same window columns, carries a real windowSeconds from the adapter instead of reverse-engineering the length from the display label, has a freshness and connection gate, and treats short windows as on pace / deficit / reserve the way #726 intended. The two cannot both ship, and on those axes #1267 is the stronger base. Second, the label round trip breaks on Grok Build: its label is chosen from the distance to reset, so a monthly cycle passing through the 4 to 12 day band is labeled Weekly and the pace is computed against a 7 day window. The agent-tab hover-card placement and the plainer wording here are worth porting onto #1267's QuotaPacePresentation. Happy to take a rework in that direction. |
Ports the two parts of getagentseal#1287 the maintainer asked to keep, expressed through this branch's `QuotaPacePresentation` rather than through `QuotaPace.Verdict`: - Placement: `QuotaDetailRow` in the agent-tab quota hover card becomes a VStack and draws the pace line under the bar, indented past the label column, with the three tones the dock already uses. The card is fitted, so a silent caption collapses there instead of reserving a slot the way the dock's computed frame must. - Wording: the long-window caption drops "est. N% at reset" / "est. out in X" for the plain "Lasts until reset" / "Runs out in X", and the exhausted state becomes "Limit reached". The projected percentage it came from stays in the hover text, which has room for the reasoning. Short windows keep the on-pace / deficit / reserve stage (getagentseal#726), and the freshness, connection and duration gates are untouched. `QuotaPace.inferredWindowSeconds(label:)` is deliberately NOT ported. Grok Build chooses its window label from the distance to the reset, so a monthly cycle passing through the 4-12 day band is labeled "Weekly" and a label round trip paces a month's budget against seven days. The adapter's real `windowSeconds` is the only source here, and a new test pins that shape: 72% used with six days to a monthly reset reads "Lasts until reset", while the same sample against an inferred 7-day window overflows and would have printed "Runs out in 9h 20m". The same test asserts a window with no duration metadata stays silent rather than falling back to its label. Verified with a standalone swiftc harness over QuotaPace, QuotaPacePresentation and QuotaSummary: this host has Command Line Tools only, so `swift test` cannot load the Testing module. Closes getagentseal#1267
|
Closing in favour of #1267, exactly as you suggested. The hover-card placement and the plainer wording are ported there on top of You were right about Grok Build, and it is worse than a wording issue: deriving the window from the display label means a monthly cycle sitting in the 4-to-12-day band is measured against 7 days, so the caption is confidently wrong on a real provider. #1267 carries a regression test for that exact shape, and a nil |
Summary
Lasts until reset,Runs out in 2d 8h, orWon't last until reseton windows of 6 hours or less, where a linear run-out ETA is not defensible.QuotaPace.evaluatestays the only pace math in the app, and this is a(text, willOverflow)reduction of its result — so the three surfaces cannot disagree. All of menubar: quota windows show no pace — add run-out projection (deficit, lasts-to-reset / runs-out-in) #726's guards come along: silent in the first 3% of a window, on an exhausted window, without a reset time, and on clock skew, with the <= 6h ETA suppression kept rather than crying wolf over one burst.QuotaSummary.Windowcarries no window length, so rather than thread one through ~15 adapter call sites,QuotaPace.inferredWindowSeconds(label:resetsAt:)reads it from the normalized label the adapters already derive from the exact API duration (Weekly,5-hour,Weekly · Opus,Monthly usage limit). Calendar months are measured back from the reset date in UTC, mirroring how the Codex spend window is derived. A label that implies no length (Copilot'sPremium requests, Cursor'sTeam pool) keeps the row silent instead of guessing.Closes #1215
Testing
npm testpasses — not applicable, no TypeScript touched;cd mac && swift buildsucceeds (Build complete, 53.76s)npm run buildsucceeds — not applicable; macOS target onlymac/Tests/CodeBurnMenubarTests/QuotaPaceVerdictTests.swiftadds 12 XCTest cases over the pure(utilization, elapsed fraction, window length) -> String?mapping: all four outcomes(lasts / runs out with an ETA / won't last on a 5h and on an exactly-6h window / silent), the
early-window silence at 2% and 1% elapsed with 5% speaking, exhausted, missing reset and clock
skew, the countdown wording, the
percent0...1 conversion, and label inference includingWeekly · Opus,GPT-5.3-Codex-Spark · 5-hour,Gemini Models · Five-hour,Monthly usage limitagainst a February-in-UTC reset, and the bucket labels that must staysilent.
CapacityDockGlanceTestsis updated for the three hard-coded panel heights thereserved line moves.
Note: my machine has a CLT-only Swift toolchain with no swift-testing module, so the test
target does not compile locally (
error: no such module 'Testing'from an existing test file)and I could not run
swift test. To avoid shipping unverified assertions I executed everyexpectation in the new file against the real
QuotaPace.swiftthrough a standaloneswiftcharness — 43/43 pass — but CI's
swift testis the real check here.