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 — feat: track provider usage and project weekly quota by Aditya190803 · Pull Request #1605 · pingdotgg/t3code

Conversation

@Aditya190803

@Aditya190803 Aditya190803 commented Mar 31, 2026 •
edited by cursor Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

What Changed

  • Added provider usage normalization and merge utilities for Codex/Claude quota payloads.
  • Extended provider snapshots and websocket config/update flow to carry normalized usage buckets.
  • Fixed usage percent math to avoid double-scaling low percentages derived from usage/limit.
  • Fixed usage cache merge behavior so stale cached usage is dropped when a newer provider snapshot omits usage.
  • Added/updated tests covering usage normalization, merge behavior, and stale cache handling.

Why

Issue #228 asks for accurate quota visibility. This PR adds provider usage projection and makes it robust under incremental updates so UI quota values stay correct. The follow-up fixes address reviewer-reported edge cases that could misreport low usage percentages or retain stale usage after newer snapshots.

UI Changes

  • Settings provider quota bars now render normalized usage/reset data from provider snapshots.
  • No layout redesign.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Closes #228

Note

Track provider rate limit usage and display weekly quota in settings

  • Adds ServerProviderUsage contract with fiveHour and weekly buckets, normalizing rate-limit payloads from both Claude and Codex providers into a standard shape via normalizeProviderUsageFromRateLimits in providerUsage.ts.
  • Extends Claude and Codex provider status probes to collect account metadata and rate-limit snapshots, attaching account, rateLimits, and usage fields to provider snapshots.
  • Adds probeCodexAccountState in codexAppServer.ts to request account/rateLimits/read alongside account data, with a grace window for missing rate-limit responses.
  • Renders a ProviderUsageRows component in the settings panel showing a progress bar, remaining percentage, and reset timestamp for each provider quota bucket.
  • Client in serverState.ts now eagerly requests a provider refresh on config snapshot receipt, applying results immediately without waiting for stream updates.

Macroscope summarized c44983f.


Note

Medium Risk
Medium risk because it extends provider probing/status snapshots and client refresh behavior, which can affect provider startup/perf and the accuracy of displayed quota data across Codex/Claude.

Overview
Adds first-class provider quota tracking by introducing ServerProviderUsage (with normalized fiveHour/weekly buckets) and wiring it through provider status snapshots.

Updates Codex and Claude provider probes to collect account metadata plus rate-limit payloads, normalize them into usage, and include these fields on ServerProvider snapshots; Codex’s app-server probe now requests account/rateLimits/read with a short grace window for missing responses.

Surfaces the data in the web settings UI via quota progress rows, and updates the client to eagerly call refreshProviders() on initial config load/snapshot so quota/usage appears without waiting for stream updates. Tests are added/updated across contracts, provider registry/probes, ingestion activity projection, and usage normalization/merge edge cases.

Reviewed by Cursor Bugbot for commit c44983f. Bugbot is set up for automated code reviews on this repo. Configure here.

Sorry, something went wrong.

Uh oh!

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

All reactions
@coderabbitai

coderabbitai Bot commented Mar 31, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d3cfd9df-b826-4476-b7a1-fb3de2204c9d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands and usage tips.

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot added size:XL 500-999 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list. labels Mar 31, 2026
@Aditya190803
Aditya190803 marked this pull request as draft March 31, 2026 11:08
@Aditya190803
Aditya190803 marked this pull request as ready for review March 31, 2026 11:13
macroscopeapp[bot]
macroscopeapp Bot reviewed Mar 31, 2026
View reviewed changes
Comment thread apps/server/src/provider/providerUsage.ts Resolved

Uh oh!

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

chatgpt-codex-connector[bot]
chatgpt-codex-connector Bot reviewed Mar 31, 2026
View reviewed changes

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11eab91d87

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread apps/server/src/wsServer.ts Outdated
Comment on lines +137 to +140
const mergedUsage = mergeProviderUsage(cachedUsage, provider.usage);
if (mergedUsage !== undefined) {
nextCache[provider.provider] = mergedUsage;
continue;

@chatgpt-codex-connector chatgpt-codex-connector Bot Mar 31, 2026

Copy link
Copy Markdown

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.

P1 Badge Drop stale usage cache when provider snapshot has no usage

In mergeUsageCacheFromProviders, stale entries are never evicted because mergeProviderUsage(cachedUsage, provider.usage) returns cachedUsage whenever the new snapshot omits usage, so the mergedUsage !== undefined branch always keeps the cache and bypasses shouldKeepCachedUsage. This means a newer provider snapshot (checkedAt later than cached updatedAt) can still be served with outdated quota buckets via serverGetConfig and server.providersUpdated.

Useful? React with 👍 / 👎.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread apps/server/src/provider/providerUsage.ts
Comment on lines +76 to +77
if (limit !== null && limit > 0) {
return normalizePercent((usage / limit) * 100);

@chatgpt-codex-connector chatgpt-codex-connector Bot Mar 31, 2026

Copy link
Copy Markdown

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.

P1 Badge Avoid double-scaling low usage percentages

derivePercentFromUsage converts absolute usage to percent with (usage / limit) * 100, then passes that result to normalizePercent, which multiplies any value <= 1 by 100 again. For low-but-valid percentages (for example usage=1, limit=1000), this reports 10% instead of 0.1%, causing major quota misreporting near the start of a window.

Useful? React with 👍 / 👎.

Sorry, something went wrong.

Uh oh!

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

All reactions
cursor[bot]
cursor Bot reviewed Mar 31, 2026
View reviewed changes
Comment thread apps/server/src/wsServer.ts Resolved

Uh oh!

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

Comment thread apps/server/src/provider/providerUsage.ts Resolved

Uh oh!

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

cursor[bot]
cursor Bot reviewed Apr 1, 2026
View reviewed changes
Comment thread apps/server/src/provider/codexAppServer.ts Resolved

Uh oh!

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

@github-actions github-actions Bot added size:XXL 1,000+ changed lines (additions + deletions). and removed size:XL 500-999 changed lines (additions + deletions). labels Apr 1, 2026
cursor[bot]
cursor Bot reviewed Apr 1, 2026
View reviewed changes
Comment thread apps/server/src/provider/codexAppServer.test.ts Resolved

Uh oh!

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

@Aditya190803
Aditya190803 force-pushed the feat/weekly-usage branch from 2c50e2d to 6b8ed4d Compare April 1, 2026 06:05
@Aditya190803 Aditya190803 mentioned this pull request Apr 1, 2026
feat: add usage / quota visibility for Codex sessions and accounts #228
Closed
@Aditya190803

Aditya190803 commented Apr 1, 2026

Copy link
Copy Markdown
Contributor Author

I cleaned up the branch history to reduce review noise and make the change set easier to reason about.

What changed:

  1. Rebased onto latest main.
  2. Removed merge/sync churn from feature history.
  3. Squashed follow-up fixups into logical commits.
  4. Kept implementation scope unchanged (no new feature surface beyond already discussed fixes).

Current commit structure:

  1. feat(contracts): add normalized provider usage and quota bucket schemas
  2. feat(server): normalize provider rate-limit usage and stabilize usage cache updates
  3. feat(web): render provider quota usage buckets in settings

Behavior/correctness included in this cleaned history:

  1. Fix low-percent double-scaling risk in usage normalization.
  2. Drop stale cached usage when newer provider snapshots omit usage.
  3. Clamp over-limit utilization and suppress no-op provider update pushes.
  4. Preserve tests across contracts/server/web for quota projection and cache behavior.

Validation run locally:

  1. bun fmt
  2. bun lint
  3. bun typecheck

No functional intent change; this is primarily a history hygiene pass for clearer review.

All reactions

Sorry, something went wrong.

Uh oh!

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

@juliusmarminge

juliusmarminge commented Apr 1, 2026

Copy link
Copy Markdown
Member

Please add screenshots

All reactions

Sorry, something went wrong.

Uh oh!

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

@github-actions github-actions Bot added size:XL 500-999 changed lines (additions + deletions). and removed size:XXL 1,000+ changed lines (additions + deletions). labels Apr 1, 2026
cursor[bot]
cursor Bot reviewed Apr 1, 2026
View reviewed changes
Comment thread apps/server/src/provider/providerUsage.ts Resolved

Uh oh!

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

Aditya190803 added 4 commits April 2, 2026 11:50
@Aditya190803
feat(contracts): add normalized provider usage and quota bucket schemas
2c04af8
@Aditya190803
feat(server): normalize provider rate-limit usage and stabilize usage…
7c0eff8
… cache updates
@Aditya190803
feat(web): render provider quota usage buckets in settings
af9b91a
@Aditya190803
feat: reduce probe timeouts and add refreshProviders to server API
00875eb
@Aditya190803
Aditya190803 force-pushed the feat/weekly-usage branch from d9e0e20 to 00875eb Compare April 2, 2026 06:22
@Aditya190803
feat: enhance provider status checks and normalize usage labels
0065213
macroscopeapp[bot]
macroscopeapp Bot reviewed Apr 2, 2026
View reviewed changes
Comment thread apps/server/src/provider/providerUsage.ts Resolved

Uh oh!

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

cursor[bot]
cursor Bot reviewed Apr 2, 2026
View reviewed changes
Comment thread apps/server/src/provider/providerUsage.ts Resolved

Uh oh!

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

@macroscopeapp

macroscopeapp Bot commented Apr 2, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR introduces substantial new functionality for tracking and displaying provider usage quotas across Claude and Codex providers. There are unresolved review comments identifying potential bugs in usage percentage calculations and cache staleness handling that warrant human attention before merging.

You can customize Macroscope's approvability policy. Learn more.

All reactions

Sorry, something went wrong.

Uh oh!

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

Aditya190803 and others added 2 commits April 2, 2026 12:58
@Aditya190803
Merge branch 'main' into feat/weekly-usage
a15ce97
@Aditya190803
feat: add test for deriving usedPercent from absolute remaining counts
283e68d
macroscopeapp[bot]
macroscopeapp Bot reviewed Apr 2, 2026
View reviewed changes
Comment thread apps/server/src/provider/providerUsage.ts Resolved

Uh oh!

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

Aditya190803 and others added 2 commits April 2, 2026 13:28
@Aditya190803
Merge branch 'pingdotgg:main' into feat/weekly-usage
6db0956
@Aditya190803
feat: add test for preference of remaining percentages over counts in…
c37fa7c
… provider usage normalization
cursor[bot]
cursor Bot reviewed Apr 2, 2026
View reviewed changes

@cursor cursor 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.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread apps/server/src/provider/providerUsage.ts Resolved

Uh oh!

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

Comment thread apps/server/src/provider/providerUsage.ts Resolved

Uh oh!

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

Aditya190803 added 3 commits April 3, 2026 11:37
@Aditya190803
Merge branch 'main' into feat/weekly-usage
a2faf1e
@Aditya190803
Merge branch 'pingdotgg:main' into feat/weekly-usage
8308571
@Aditya190803
Merge branch 'pingdotgg:main' into feat/weekly-usage
c44983f
@Aditya190803

Aditya190803 commented Apr 4, 2026

Copy link
Copy Markdown
Contributor Author

@juliusmarminge this branch got pretty janky and inconsistent so i rebuilt it cleanly

new PR here: #1732

closing this one to avoid confusion

All reactions

Sorry, something went wrong.

Uh oh!

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

@Aditya190803 Aditya190803 closed this Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@macroscopeapp macroscopeapp[bot] macroscopeapp[bot] left review comments
@chatgpt-codex-connector chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] left review comments
@cursor cursor[bot] cursor[bot] left review comments

Uh oh!

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

Assignees

No one assigned

Labels

size:XL 500-999 changed lines (additions + deletions). 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.

feat: add usage / quota visibility for Codex sessions and accounts

Uh oh!

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

2 participants

@Aditya190803 @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.