Skip to content

menubar: Codex Plan tab doesn't surface limit-reset credits (count and expiries) #723

Closed

Description

@avs-io

Problem

ChatGPT/Codex accounts accrue limit-reset credits — grants that restore a rate-limit window early, each with its own expiry. The account backend exposes them at GET /backend-api/wham/rate-limit-reset-credits (same bearer token and ChatGPT-Account-Id header the existing /wham/usage fetch in CodexSubscriptionService already sends), returning { credits: [{ id, reset_type, status, granted_at, expires_at, ... }], available_count }.

The menubar's Codex Plan view currently shows the usage windows and the credits balance, but not these. A user at 58% weekly usage deciding whether to push through or throttle back has no way to see that they're holding 4 resets — or that the next one expires in 16 hours and will be wasted if unused.

Proposal

  • Fetch reset credits alongside the existing usage fetch in CodexSubscriptionService, with a short timeout and strictly non-fatal failure: on any error or unexpected shape, the Plan view renders exactly as it does today. This endpoint must never be able to break the quota display.
  • Model just what the UI needs: availableCount plus the expiry dates of available credits.
  • UI: one compact row in the Codex Plan section — e.g. Limit resets: 4 available · next expires in 16h — using the same relative-date style as the existing window reset labels.
  • Decode tests over fixture payloads: full shape, missing expires_at, unknown status values, empty list, malformed document (→ feature hidden, fetch still succeeds).

Working on this; PR to follow.

Activity

  1. iamtoruk commented on Jul 17, 2026

    @iamtoruk
    Member

    Green light, and good timing: this lands squarely on the quota-visibility direction we want the Plan surfaces to grow toward. The precedent holds up in the code: the same bearer plus ChatGPT-Account-Id flow already serves /wham/usage in CodexSubscriptionService, so this is the same API family and the same accepted fragility class, with your strictly-non-fatal rendering rule being the load-bearing requirement.

    Two constraints to bake in from the start, both born from #702 which just landed:

    1. The new fetch must ride the existing refresh lifecycle rather than add a second polling loop: same single-flight, same failure backoff, and it must honor Retry-After if the endpoint 429s. One extra request per existing usage refresh is fine; an independent cadence is how we re-earn the rate limits menubar: honor Retry-After on Claude quota 429s, back off failed refreshes #702 just fixed.

    2. Cache the last good credits payload alongside the usage snapshot so a transient credits-endpoint failure degrades to slightly stale data rather than a vanishing row, consistent with how the quota display behaves.

    The expires-in phrasing matching the window reset labels is right. One UI nit to consider: when availableCount is zero, render nothing rather than a zero row, so the section only spends a line when there is something actionable. Looking forward to the PR.

  2. iamtoruk commented on Jul 17, 2026

    @iamtoruk
    Member

    For context: the reset-credits row from #724 is the first surface brick of a broader direction now tracked in the quota-intelligence epic #725 (live remaining, burn-rate forecast, pre-flight awareness). Your best-effort companion-fetch pattern here is exactly the shape Part 1 and Part 3 build on.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions