t3code icon indicating copy to clipboard operation
t3code copied to clipboard

feat: display provider usage limits in settings

Open Aditya190803 opened this issue 7 months ago • 30 comments

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

  • [x] This PR is small and focused
  • [x] 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 short-lived PTY/CLI probes and extra Codex/OpenCode RPCs, which can slow or flake health checks but does not change auth or billing paths.

Overview Adds subscription/quota usage to provider snapshots and surfaces it in Settings on each provider instance card.

Contracts & snapshot plumbing: Introduces ServerProviderUsageLimits / usage windows on ServerProvider, threaded through ProviderProbeResult and buildServerProvider.

Per-provider collection during status checks:

  • Codex — reads account/rateLimits/read from the app-server probe and maps primary/secondary windows (API-key accounts get an explicit unavailable reason).
  • Claude — optional PTY probe runs claude --print /usage (JSON); API-key auth skips probing.
  • Cursor — optional PTY probe drives the agent TUI /usage panel and parses “Included” utilization.
  • Grok — ACP auth/check_subscription for auth metadata plus optional PTY /usage for weekly limits; unauthenticated snapshots warn with a login message.
  • OpenCode — derives windows from connected OpenCode Go / Zen inventory usage fields; falls back to unavailable when connected providers omit usage.

Infrastructure: Shared providerUsageLimits normalization, ptyProbeSupport for ANSI stripping and probe timeouts, and PtyAdapter wired into driver creation/hydration so Claude/Cursor/Grok probes can run where a PTY exists.

UI: ProviderUsageBars on ProviderInstanceCard shows per-window progress, remaining %, and reset times (or the server’s unavailable reason).

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

[!NOTE]

Display provider usage limits and progress bars in settings

  • Adds usageLimits to the ServerProvider contract, including structured usage windows (session/weekly), usedPercent, resetsAt, and availability metadata.
  • Implements per-provider usage probes: probeClaudeUsageLimits parses Claude CLI /usage output (including print-mode JSON with IANA time zones), probeCursorUsageLimits and probeGrokUsageLimits drive PTY sessions to collect usage data, and resolveCodexRateLimitSnapshotUsageLimits converts Codex app-server rate limit snapshots.
  • Adds ProviderUsageBars to ProviderInstanceCard in the settings UI, rendering color-coded progress bars (green/warning/destructive at 70%/90%) with remaining percent and optional reset date per window.
  • Threads PtyAdapter into driver creation context so Claude, Cursor, and Grok probes can spawn TUI processes during status checks.
  • Risk: PTY-based probes add latency to provider status checks; spawn failures are handled gracefully by returning an unavailable snapshot rather than erroring.

Macroscope summarized 1993350.


Open in Devin Review

Aditya190803 avatar Apr 04 '26 10:04 Aditya190803

[!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.

coderabbitai[bot] avatar Apr 04 '26 10:04 coderabbitai[bot]

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

Aditya190803 avatar Apr 04 '26 10:04 Aditya190803

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.

macroscopeapp[bot] avatar Apr 04 '26 11:04 macroscopeapp[bot]

Hey @juliusmarminge, could you take a look at this PR when you get a moment? Thanks!

Aditya190803 avatar Apr 06 '26 04:04 Aditya190803

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.

Marve10s avatar Apr 06 '26 21:04 Marve10s

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

Marve10s avatar Apr 06 '26 21:04 Marve10s

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!

juliusmarminge avatar Apr 06 '26 21:04 juliusmarminge

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

Marve10s avatar Apr 06 '26 21:04 Marve10s

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

juliusmarminge avatar Apr 06 '26 22:04 juliusmarminge

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

juliusmarminge avatar Apr 06 '26 22:04 juliusmarminge

@juliusmarminge, pushed updates for the usage limits changes.

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

Aditya190803 avatar Apr 18 '26 10:04 Aditya190803

Just use codexbar, so much easier

brrock avatar Apr 18 '26 14:04 brrock

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

Aditya190803 avatar Apr 18 '26 14:04 Aditya190803

I meant just use it instead of having to do this

brrock avatar Apr 18 '26 14:04 brrock

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

Aditya190803 avatar Apr 18 '26 14:04 Aditya190803

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

Aditya190803 avatar Apr 23 '26 10:04 Aditya190803

@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

juliusmarminge avatar Apr 23 '26 18:04 juliusmarminge

just merged my broader provider changes so if you can get this up to date and resolve the conflcits i can review it after that !

juliusmarminge avatar Apr 29 '26 23:04 juliusmarminge

@juliusmarminge Done! I’ve updated everything and resolved the conflicts. Could you take a look when you get a chance?

Aditya190803 avatar Apr 30 '26 05:04 Aditya190803

Fails to load Claude usage? And when am i expected to see OpenCode usage? Also can we return Resets at ? Just the percentage isn't the most useful thing if you don't know when it refreshes?

CleanShot 2026-04-30 at 22 56 00@2x

juliusmarminge avatar May 01 '26 05:05 juliusmarminge