GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat(usage): show provider subscription limits on the usage page by jakeleventhal · Pull Request #9263 · pingdotgg/t3code Conversation
|
| Before | After: light | After: dark |
|---|---|---|
| No limit information anywhere on the usage page. | ![]() |
![]() |
Full page, light and dark. Codex figures are live from the signed-in CLI; Claude figures came from a real turn run through the dev server.
![]() |
![]() |
usageLimits.test.ts (13 tests): Codex and Claude payload parsing, per-bucket ids, runtime event routing, window merging, persistence across a store restart, no-op refresh while Codex is disabledusageMerge.test.ts (+3) and usageFormat.test.ts (+3): freshest-environment selection, stale-version exclusion, window labels, reset countdowns, reading ageCreated with Claude Fable 5.1 using the Claude Code harness in T3 Code.
🤖 Generated with Claude Code
Note
Medium Risk
Usage scans can spawn a short-lived Codex app-server and block up to 3s for limits; layer ordering ties limits to the provider event stream. Additive contract v6 is backward-compatible for merge, but changes server behavior on every usage read.
Overview
Adds subscription limits to the usage experience on web and mobile: rolling windows with % used, reset timing, plan name, and “updated … ago,” plus copy when a provider cannot report (Codex sign-in, Claude after a turn, Grok unsupported).
Contract & merge: UsageSummary bumps to v6 with a limits array (UsageProviderLimits / UsageLimitWindow). Older servers decode as empty limits. mergeUsage picks the freshest reading per provider across environments so one account is not blended.
Server: New UsageLimitsStore merges account.rate-limits.updated events (Codex + Claude), persists to usage-limits.json, and on each usage scan triggers a single-flight Codex account/rateLimits/read via a shared connectCodexAppServer helper (also used by the skills probe). UsageService.readSummary starts that refresh in parallel with the transcript scan and waits up to 3s before returning limits. Runtime wiring moves usage/limits ahead of provider runtime so the store can subscribe to provider events.
Shared UI helpers: formatLimitWindowLabel, formatLimitReset, formatObservedAgo, latestObservedAt power labels and progress bars (danger styling at ≥90%).
Reviewed by Cursor Bugbot for commit cea798e. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
UsageLimitWindow and UsageProviderLimits contract schemas, bumps usage contract to version 6 (additive, compatible with v4+), and includes a limits array in UsageSummary defaulting to empty for legacy summariesUsageLimitsStore, refreshes enabled Codex limits on-demand via the app-server protocol with an 8-second timeout, and shares concurrent refreshes via single-flightUsageService.make readSummary now triggers a detached limits refresh before scanning and waits up to 3 seconds for it after aggregation, returning known limits in the summaryusageMerge selects the freshest complete provider reading across environments, and shared formatters render window labels, reset countdowns, observation age, and progress bars with danger styling at ≥90%UsageService.make now resolves UsageLimitsStore and blocks up to 3 seconds on the first refresh; existing usage scans that previously returned no limits now include an empty (or populated) limits array, which clients decoding with the v6 contract handle via the default empty listMacroscope summarized cea798e.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
One convention finding, inline. Everything else in the new Effect service (subpath namespace imports, inline Context.Service interface, Foo["Service"] method typings, environment-acquired dependencies, layer/layerTest exports) matches the repository conventions.
Posted via Macroscope — Effect Service Conventions
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| const spawner = yield* ChildProcessSpawner.ChildProcessSpawner; | ||
|
|
||
| const filePath = path.join(config.stateDir, "usage-limits.json"); | ||
| const byProvider = new Map<UsageProviderKind, UsageProviderLimits>(); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Medium usage/usageLimits.ts:365
byProvider stores all instances under one UsageProviderKind, so readings from multiple Codex or Claude accounts are merged and one account can overwrite the other's limits. Preserve providerInstanceId through the event parsing and key the store by that instance so the usage page reports each account separately.
In file @apps/server/src/usage/usageLimits.ts around line 365:
`byProvider` stores all instances under one `UsageProviderKind`, so readings from multiple Codex or Claude accounts are merged and one account can overwrite the other's limits. Preserve `providerInstanceId` through the event parsing and key the store by that instance so the usage page reports each account separately.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Not changing this one. The usage page is keyed by provider kind end to end: the transcript scan reads the single configured Codex and Claude home, the contract has no instance dimension, and the UI has one row per provider. Keying limits by instance would need the whole feature to grow an instance axis; that is a follow-up across usage, not something to bolt onto limits alone. The refresh now resolves the same instance config the runtime launches (see the 8d7e59d8c reply below), so the live Codex reading always describes the active instance.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This PR adds a substantial provider-integration and persistence workflow across the server, contracts, shared code, and web/mobile clients rather than making a small isolated change. An unresolved issue can merge limits from multiple provider instances, and the test suite adds a static-analysis suppression, so the change needs human review. Not approved because:
Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
The usage page had no view of how much of a plan's rolling windows were spent. Each environment now reports per-provider limits alongside the transcript scan: Codex answers account/rateLimits/read live on every page load, Claude Code's rate-limit event from the latest turn is recorded and persisted, and Grok Build is labelled as not reporting. Web and mobile render a Subscription limits section with one bar per window, percent used, reset time, and reading age. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ponse path Serialize limit folds and their file write behind one permit so a page-load refresh and the provider event stream cannot interleave and persist an older snapshot. Fork the Codex read detached and give the response a short grace wait for it instead of holding every usage answer for a stalled handshake. Compare observation instants as time rather than text, and launch the Codex refresh from the same instance config the runtime resolves. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…uckets Concurrent usage requests now wait on a single in-flight Codex read instead of each launching a CLI. A complete read replaces the provider's window set so a bucket the account stopped reporting disappears, while partial turn events still merge. An older observation no longer relabels the plan. Co-Authored-By: Claude Fable 5.1 <[email protected]>
f514ed6 to
cea798e
Compare
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cea798e. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| homePath: codex.homePath, | ||
| launchArgs: resolveCodexLaunchArgs(codex.launchArgs, process.env), | ||
| cwd: process.cwd(), | ||
| environment: process.env, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
High Severity
The on-demand Codex limits read launches with raw homePath and process.env. The runtime instead uses resolveCodexHomeLayout (shadow home as CODEX_HOME) and mergeProviderInstanceEnvironment. Account credentials live in the shadow auth.json, so a configured shadow home or instance env makes the page show another account's limits or ask the user to sign in.
Reviewed by Cursor Bugbot for commit cea798e. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ); | ||
| // A delayed older observation must not relabel the plan either. | ||
| const plan = next.plan !== null && nextIsNewest ? next.plan : (previous?.plan ?? null); | ||
| return { provider: next.provider, plan, windows }; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Medium Severity
mergeProviderLimits with complete: true starts from an empty set and inserts every incoming window even when that snapshot is older. The Codex refresh also stamps observedAt before the up-to-8s handshake, so a complete write can replace newer turn windows and then lose to another environment's later turn in mergeLimits, dropping separately metered buckets such as Spark.
Reviewed by Cursor Bugbot for commit cea798e. Configure here.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| launchArgs: resolveCodexLaunchArgs(codex.launchArgs, process.env), | ||
| cwd: process.cwd(), | ||
| environment: process.env, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is production service construction, so the host environment and working directory should come from the Effect environment rather than the process globals. UsageService.make in this same directory does exactly that (const hostEnvironment = yield* HostProcessEnvironment;), and config is already yielded here so config.cwd is available for cwd.
Suggest adding import { HostProcessEnvironment } from "@t3tools/shared/hostProcess";, acquiring const hostEnvironment = yield* HostProcessEnvironment; alongside the other dependencies in make, and passing hostEnvironment for launchArgs/environment and config.cwd for cwd. That also lets suites override the env the same way UsageService.test.ts already does.
Posted via Macroscope — Effect Service Conventions
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Superseded by #9507 (Limits tab for Codex/Claude subscription limits on the usage page), which has merged to main. Closing this PR in favor of that work. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.