GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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

@Mnigos

@Mnigos Mnigos commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

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.

All reactions
@Mnigos
fix(shared): usage limits no longer read 0% left while room remains
02c1f83
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 27, 2026
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Explain Change →

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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

coderabbitai[bot]
coderabbitai Bot reviewed Nov 27, 2026
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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

  • Source mode: Auto
  • Repository: pingdotgg/t3code
  • Branch: main
  • File: .coderabbit.config.ts
  • Commit: 0a47638
  • Layers: Repository TS config
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4b03099c-28c6-4fd4-be12-3a996612b196
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.

All reactions
@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 27, 2026
@saipraneethpb1

saipraneethpb1 commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@juliusmarminge juliusmarminge added takeover:needs-julius Takeover done; route gate says Julius decides and removed takeover:in-progress A takeover lead is working on this PR labels Nov 27, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

size:S 10-29 changed lines (additions + deletions). takeover:needs-julius Takeover done; route gate says Julius decides vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

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.

3 participants

@Mnigos @saipraneethpb1 @juliusmarminge
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.