Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat: display provider usage limits in settings #1732

ClosedAditya190803(GitHub profile, opens in a new tab)wants to merge 21 commits intomain fromrefs/pull/1732/headopened View on GitHub

Fixes #228.

What Changed

Added provider usage limits to the settings flow end to end for all 4 providers (Codex, Claude, Cursor, OpenCode):

  • the shared contract now includes the usage-limits schema
  • the server persists and exposes provider usage limits
  • the web app renders the limits in Settings

Note: For OpenCode, only the official OpenCode-managed providers (OpenCode Go, OpenCode Zen) are shown.

Why

Users need a visible place to confirm provider usage limits without digging through logs or backend state. This keeps the value available across sessions and makes the current limits easy to inspect from the UI.

UI Changes

The Settings panel now shows provider usage limits in the provider section.

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

Note

Medium Risk Provider status checks now spawn PTY/CLI probes and merge live rate-limit events into published snapshots; failures degrade to “unavailable” but add complexity and timing sensitivity around concurrent refreshes.

Overview Adds provider subscription quota data to provider snapshots and surfaces it in the mobile Usage screen, with server-side probing and live refresh so limits stay current between status checks.

Server: Each major driver (Claude, Codex, Cursor, Grok, OpenCode) now attaches usageLimits during status probes—via Codex app-server account/rateLimits/read, Claude claude --print /usage, Cursor/Grok PTY /usage TUI automation, and OpenCode Go/Zen inventory fields. Optional PtyAdapter is threaded into Claude/Cursor/Grok driver checks so PTY-based probes work when the server layer provides it. applyUsageLimits on managed provider snapshots patches quota windows from runtime account.rate-limits.updated events (ProviderUsageLimitsIngestionLive), with epoch merging so in-flight probes do not overwrite fresher live updates.

Mobile: New Provider limits section on the usage route shows per-environment provider bars, reset dates, and notices (e.g. Grok free tier, unavailable API-key accounts).

Hygiene: Ignores .claude-work-test/ so Claude usage probe tests do not commit session files.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit ea3c1ce0340e5fdd1925a5c1c2af6c944c239595. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add provider usage limits display to Usage page with CLI probing and runtime ingestion

  • Adds ServerProviderUsageLimits schema to server.ts with validated usage windows (session, weekly, monthly), percent clamping to 0–100, and forward-compatible decoding that drops invalid windows instead of failing the provider
  • Adds per-provider usage probes that launch provider CLIs in a PTY and parse their /usage or TUI output: Claude (claudeUsageProbe.ts, 15s timeout), Cursor (cursorUsageProbe.ts, 25s timeout), Grok (grokTuiUsageProbe.ts, 10s timeout), Codex via app server rate-limits API (codexUsageProbe.ts), and OpenCode managed providers (openCodeUsageLimits.ts)
  • Adds ProviderUsageLimitsIngestionLive layer in server.ts that subscribes to account.rate-limits.updated events, parses runtime telemetry via runtimeUsageLimits.ts, and calls applyUsageLimits on the provider instance to patch live snapshots
  • Updates makeManagedServerProvider.ts to expose applyUsageLimits, track per-window patch epochs, and preserve live-patched usage windows across concurrent refresh and enrichment
  • Renders usage bars with colored thresholds, reset dates, and tier notices in ProviderQuotaLimits.tsx on the web Usage page and in UsageRouteScreen.tsx on mobile
  • Improves PTY adapters: NodePtyAdapter.ts and BunPtyAdapter.ts now cache and replay exit events to late subscribers; Windows kill() uses taskkill /T /F for process-tree termination
  • Behavioral Change: NodePtyProcess constructor now requires a platform argument; Windows kill behavior switched from process.kill to taskkill with process.kill fallback. Provider snapshots now carry an optional usageLimits field; invalid usage windows are silently dropped during decode rather than failing the provider
Macroscope summarized ea3c1ce.

Open in Devin Review
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      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 Plus

      Run ID: 1ee2bf19-dba6-4b48-840f-cced02ce3deb

      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

      Warning

      Your free Security trial is over. An organization admin can activate Security or dismiss this notice.


      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. For now, I’ve added two images to illustrate the UI:

      1. Free tier view

      This screenshot reflects my current setup. I don’t have subscriptions to Codex or Claude Code, I’m using Copilot Pro (available to me as a student). It shows how the weekly usage limit appears in the interface.

      Free Tier Screenshot

      2. Pro tier (mocked example)

      This second screenshot uses dummy data to demonstrate how the UI could look for users on a Pro plan (Codex or Claude Code). It includes both session-based limits and weekly limits for clarity.

      Pro Tier Mock Screenshot

    4. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: 80515efa38

      ℹ️ 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".

    5. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR introduces a substantial cross-provider usage-limit capability with new CLI/PTY probes, live runtime ingestion, shared snapshot concurrency logic, and web/mobile UI changes. Its broad production impact and several unresolved comments describing concrete runtime or display risks require human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. Hey @juliusmarminge, could you take a look at this PR when you get a moment? Thanks!

    7. Randomly found this PR because wanted to add usage to T3. I think this is great as a user but also I think the UI should match the Codex App usage,it's minimal and clean, would be better than AI tabs image

      You would need to redo the settings button though,something Julius needs to approve. I genuinely think settings button should match Codex App, would love to open PR for that.

    8. Marve10s(GitHub profile, opens in a new tab)commented

      A few concerns after checking the code:

      1. Codex can prefer stale persisted usage over freshly probed usage in the same refresh path. checkCodexProviderStatus() reads cachedUsageLimits first, then later resolves account state, but ultimately uses cachedUsageLimits ?? accountUsageLimits. That means a refresh can still emit an older persisted value even when the same refresh just fetched newer limits from the provider probe. If the goal is to show the freshest available snapshot, I think the precedence likely needs to be reversed, or persisted data should only be used when no fresh usage was fetched.
      2. The persisted cache looks too coarse-grained for account/config changes. The new table is keyed only by provider_name, and the repo API is also getByProvider only. That seems risky if the user changes auth state, swaps Codex homePath, changes binary path, or otherwise changes the effective account behind a provider. In those cases we can still surface previously persisted usage for the provider even though it may belong to a different account/config. Is that safe, or should this cache be scoped more tightly (for example by provider + account/config fingerprint) or suppressed when provider health/auth no longer matches the cached source?
      3. A usage-limit update currently looks like it can trigger full provider refresh work. ProviderService persists account.rate-limits.updated, then ProviderRegistry listens to repository changes and calls refresh(change.provider). That refresh path eventually reruns the provider's checkProvider flow rather than just updating already-known snapshot state. For a quota-bar style UI update, this feels heavier than necessary and could add extra CLI churn to a hot path. Would it be simpler to keep usage attached to the provider snapshot/update flow directly instead of going through persistence -> repository stream -> provider refresh?

      I can test further and commit to this PR if you're okay with it, @Aditya190803. Genuinely want to see this merged - it would be super useful

    9. this is on my list to review still! Just dealing with some larger prep work so haven't had time yet.

      As for the "it must be more visible and sjhould be 1:1 like codex app":

      How often do you guys check your limits to warrant it being one click ??? I check it at most a few times a week, so hiding it in settings next to the provider status is fine!

    10. this is on my list to review still! Just dealing with some larger prep work so haven't had time yet.

      As for the "it must be more visible and sjhould be 1:1 like codex app":

      How often do you guys check your limits to warrant it being one click ??? I check it at most a few times a week, so hiding it in settings next to the provider status is fine!

      I've been checking usage a lot in Codex - a couple of times daily since I was on the $20 plan with 2x limits till April, so I was curious how it was going. My take is that the current settings are genuinely fine, but I think it'll get crowded soon. With usage, OpenCode and Cursor support, and I'm sure there are PRs that extend the settings further it's going to contain a lot of content before long. Codex shows a small tab with everything you need: usage, general info, and language (something I'd tuck away in settings). I think the Cursor settings approach is a good reference here too.

      image
    11. Yes when the single settings page gets too large we'll split it to subpages. We already did the work adding the sidebar when adding the archive

    12. can't see claude limits: CleanShot 2026-04-06 at 15 21 34@2x

    13. juliusmarminge reviewed

      implementation seems way overcomplicated.

      why cache the data? the provider check runs once per minute. we can get fresh data on every tick?

      how i imaagined this working:

      • extend the checkProvider probe in ServerProvider to include a new usageLimits property.
      • on the auth check probes (app server / claude), extract usage data
      • stream it down to client as part of the normal provider snapshot
      • render the UI on settings page

      given i haven't looked into exactly what's possible to probe and not, why is this PR so much more than that?

    14. @juliusmarminge, pushed updates for the usage limits changes.

      Also, should OpenCode show usage for all providers or just the OpenCode-maintained ones?

    15. brrock(GitHub profile, opens in a new tab)commented

      Just use codexbar, so much easier

    16. @brrock Please explain how this can be integrated since the entire app is written in Swift. How can it be incorporated into this app?

    17. I meant just use it instead of having to do this

    18. It can only be used by people using a Mac. What about those using Windows or Linux?

    19. @juliusmarminge I've added Cursor and OpenCode usage limits to the PR could you take a look when you get a moment? Thanks!

    20. @juliusmarminge I've added Cursor and OpenCode usage limits to the PR could you take a look when you get a moment? Thanks!

      Will review next week when I'm back from Miami

Sign in to join this conversation.