GeezerVison is showing github.com — fix(shared): usage limits no longer read 0% left while room remains by Mnigos · Pull Request #44289 · pingdotgg/t3code
Conversation
The usage limits panel says "0% left" while a limit still has room, and "100% left" after some of it is used. With 99.6% of a Claude session used, the label, bar and tone all read as exhausted although the account can still send. With 0.4% used it reads as untouched. Web (Settings usage, thread details, pooled view) and mobile (usage section, pooled view, widget) all show this.
The cause is remainingPercent in packages/shared/src/usageLimits.ts (line 767), which returns Math.round(100 - usedPercent). Usage percents are often fractional: the Claude adapter turns stream utilization into utilization * 100 and monthly spend into used / limit * 100, so anything under 0.5% on either side rounds to the edge. The pooled remainingPercent in collectLimitPools (line 748) rounds a weighted mean the same way.
The fix keeps the rounding but clamps a window that is neither empty nor exhausted to 1..99, the same edge guard #44246 added to formatPercent. Both the per-window helper and the pooled field now go through it. Exact 0 and 100 used, integer inputs, NaN and out-of-range values behave as before. Exhaustion checks use the raw usedPercent, so nothing that blocks or switches accounts changes. paceRemainingPercent is left alone: it tracks elapsed time, not quota.
Found while reading usageLimits.ts after #44246.
New cases in usageLimits.test.ts cover the helper (0, 0.4, 40, 99.6, 100 used) and a two-account pool (0.2/0.4 and 99.5/99.8 used). On origin/main the four fractional cases fail (100 instead of 99, 0 instead of 1); with the fix all 140 tests in the shared usage test files pass, as do the web ThreadDetailsUsage and mobile widget snapshot tests that consume the helper.
Claude Opus 5.5 via T3 Code
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 27, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

Walkthrough
-
Remaining percentages for individual and pooled usage windows now use a shared calculation. Tests cover exact endpoints and fractional values near rounding boundaries.
Changes: Usage Limit Rounding
| Layer / File(s) |
Summary |
Shared remaining-percentage calculation packages/shared/src/usageLimits.ts, packages/shared/src/usageLimits.test.ts |
remainingPercent and pooled windows use a shared calculation. It clamps used percentages to 0–100 and rounds partial remaining values to 1–99. Tests cover individual and pooled usage values, including rounding boundaries. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: juliusmarminge
Merge Risk: Low · up to 02c1f
-
Usage limits no longer show 0% left while quota remains or 100% left after usage has started. Pooled windows above 100% used now show 0% remaining instead of a negative number, which differs slightly from the PR description. The impact is minor and display-only, so the change is low risk to merge.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title names the change: usage limits no longer show 0% left while quota remains. It matches the main fix in usageLimits.ts (clamping rounded remaining percentages to 1..99 for partially used windo… |
| Description check |
 |
The description follows the template. It explains the problem with the 0%/100% labels and the rounding cause, and it describes the change, including the clamp, the unchanged exhaustion checks, and the… |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Full details: Title check
-
Explanation
The title names the change: usage limits no longer show 0% left while quota remains. It matches the main fix in usageLimits.ts (clamping rounded remaining percentages to 1..99 for partially used windows). It is specific, follows the conventional commit style, and is one sentence.
Full details: Description check
-
Explanation
The description follows the template. It explains the problem with the 0%/100% labels and the rounding cause, and it describes the change, including the clamp, the unchanged exhaustion checks, and the excluded paceRemainingPercent. It names the scope as a bug fix that builds on #44246. Verification lists the new tests, the failing cases on origin/main, and the passing suites. It does not include a screenshot, but the change is a label fix, so the template does not require one. The template asks for the agent model at the end, and the author gives 'Claude Opus 5.5 via T3 Code'. The Scope section does not link a specific issue for the bug, and it gives no reason for skipping one, so this is a minor gap.
Finishing Touches
-
Generate unit tests (beta)
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional comments: 1
-
packages/shared/src/usageLimits.ts-748-748: 1
-
748-748: Minor · Functional Correctness · Quick win
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Preserve pooled out-of-range results.
For a weekly window at 120% used, the previous calculation returned -20% remaining. remainingOf now clamps it to 0%, hiding the overage. Preserve the previous pooled result for out-of-range inputs and add a regression case. The PR objective says those inputs retain their prior behavior.
Review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between 0a47638 and 02c1f83.
Files selected for processing: 2
-
packages/shared/src/usageLimits.test.ts
packages/shared/src/usageLimits.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Independently checked the proposed calculation change at 02c1f83b276f925d844abea98fe57b8c83270e4e against main 8335c0951b using additional boundary assertions in packages/shared/src/usageLimits.test.ts.
- Before the fix: 6 failures, 100 passes. Individual cases at 0.01%, 0.4%, 99.6%, and 99.99% used round to misleading endpoints; pooled cases
[0.2, 0.4] and [99.5, 99.8] also fail.
- With the proposed implementation and the same assertions: all 106 tests pass.
- Exact 0%/100%, out-of-range clamping, and the raw
usedPercent >= 100 exhaustion threshold also pass.
Command: vp test run packages/shared/src/usageLimits.test.ts.
This verifies the calculations only. Rendered clients were not verified. Verification was performed with Codex assistance.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This branch has not been deployed
No deployments
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|