Repository navigation
fix: render last-measured usage for stale reset windows - #204
Merged
Merged
Conversation
Usage cells reused the auto-switch inference that treats an elapsed resets_at as a refilled quota, so stale snapshots displayed a fake 100%. The inference stays scoped to decision code (remainingPercentAt with a resets_at > 0 bound); display cells now show the last-measured remaining percent via measuredRemainingPercent and mark missing, invalid, or elapsed reset timestamps as stale instead of a reset time or dash.
Narrow columns shortened N% (stale) to a bare N%, which passed for a live reading. The stale marker now collapses to N%! instead of shedding outright, pinned by a cell-writer test and a table width sweep.
Contributor
[Medium impact] The PR appears safe to merge; the previous stale-marker issue is fixed. SummaryThe PR separates measured usage from the reset-time guess used to choose accounts.
The previous narrow-table finding is fixed. No new actionable issues were found. Reviews (1) · Last reviewed commit: "fix: keep a compact stale flag on narrow..." · Reviewed by Greptile |
@loongphy/codex-auth-darwin-arm64
@loongphy/codex-auth-darwin-x64
@loongphy/codex-auth-linux-arm64
@loongphy/codex-auth-linux-x64
@loongphy/codex-auth-win32-arm64
@loongphy/codex-auth-win32-x64
@loongphy/codex-auth
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Usage cells reused the auto-switch inference that treats an elapsed
resets_atas a refilled quota (remainingPercentAt→ 100). When the API could not refresh, an expired snapshot displayed a fake full quota — whether the window lapsed by one minute or thirty days. This separates the decision-side inference from what the display actually measured:remainingPercentAtkeeps its optimistic elapsed-window inference for scoring, but gains aresets_at > 0bound so dirty timestamps (0, negative) no longer fabricate 100%.measuredRemainingPercentreports the stored100 - used_percentpoint value with no reset inference.formatRateLimitFullAlloc(the only usage-cell formatter, shared bylist,list --live,switch,remove) now renders the measured percent plus a reset time only when a real futureresets_atexists; missing, invalid, or elapsed timestamps render the measured percent with a stale marker instead of100%or-.N%!) instead of shortening to a bareN%that would pass for a live reading.used_percent/resets_atare emitted raw;docs/json-api.mdnow states the snapshot-staleness contract.Test plan
zig buildclean;zig build test test-helpersfull suite green.resets_at, future-reset cells unchanged,measuredRemainingPercentclamping, decision-sideremainingPercentAtsemantics, narrow-cell and table width sweeps for the compact flag.CODEX_HOMEfixture (expired / null / zero / futureresets_at):list --skip-apirenders0% (stale),70% (stale),20% (stale),90% (14:25);list --skip-api --jsonkeeps raw snapshot fields.