Skip to content

feat: add showAllProviders, offerResetCredits and showAllProvidersCacheMinutes to /usage - #4

Open
postpersonality wants to merge 3 commits into
specode:mainfrom
postpersonality:feat/usage-all-providers
Open

postpersonality wants to merge 3 commits into
specode:mainfrom
postpersonality:feat/usage-all-providers

Conversation

@postpersonality

@postpersonality postpersonality commented Nov 16, 2026 •

Copy link
Copy Markdown

Independent of #3: based on main, no Mistral code in the diff.

Two /usage settings, both off the default path:

  • showAllProviders lists the other providers Pi is signed in to.
  • offerResetCredits (on by default) turns off the "Reset Credits: N Available" prompt.
  • showAllProvidersCacheMinutes sets how long the list reuses a provider's report, five minutes by default.

showAllProviders

/usage reports the active provider only. This adds an opt-in setting that lists the other providers Pi is signed in to as well:

{
  "showAllProviders": true
}

Default stays as it is: without the setting, /usage prints the active provider alone.

Mistral
  Vibe Code:
    1m Window      ████████████  100% left · $299.43/$300.00 · resets 12/01 03:00

  API:
    1m Window      ████████████  100% left · $30.00/$30.00 · resets 12/01 03:00

  Account:
    Plan           Individual
    Pay-as-you-go  off

OpenAI Codex
  Shared Across Models:
    1w Window     █████░░░░░░░   45% left · resets 11/18 14:12

  Account:
    Email         user@example.com
    Plan          self_serve_business_prolite
    Resets Left   3
    Extra Credit  none

Antigravity
  Gemini Models:
    5h Window  ███████████░   88% left · resets 11/17 02:54
    1w Window  █████████░░░   75% left · resets 11/21 15:48
  ...

offerResetCredits

/usage asks whether to redeem a reset credit whenever the active OpenAI or Codex account has one. With offerResetCredits: false the question is skipped; the account section still lists how many tickets are left. The check sits before the provider and status work, so nothing else about /usage changes.

{
  "offerResetCredits": false
}

showAllProvidersCacheMinutes

The providers after the active one reused a fixed five-minute cache. showAllProvidersCacheMinutes sets that window in minutes, 5 by default; 0 fetches every time. The footer keeps its own five-minute refresh, so the setting only changes how stale the list may be.

{
  "showAllProvidersCacheMinutes": 10
}

Behavior

  • The active provider is first and is still forced, so its numbers are fresh. The others read the five-minute cache and share the failure backoff, so a list does not turn every /usage into a burst of requests.
  • A provider Pi holds no credential for is skipped instead of being reported as an auth failure, so the list contains only signed-in providers.
  • Claude has no endpoint to query. When pi-claude-bridge registers models in the session, it appears as Waiting until Claude Code reports usage in that session.
  • The footer keeps tracking the active provider, and reset credits are still offered for the active OpenAI or Codex account only.

Implementation

  • src/config-core.ts: the three keys, each defaulted, project overriding global, with the same warning path as displayMode.
  • src/usage.ts: queryAdapterState returns undefined when Pi holds no credential; the single-provider path turns that into the existing No Pi runtime credential available state, so nothing else changes. showUsage appends the other providers when the setting is on.
  • test/usage-all.test.ts: extension-level tests for the default, the list, the cache (including 0), and the skip of providers without a credential. test/usage-reset-credits.test.ts covers the reset prompt with the setting on and off. test/config.test.ts covers parsing and precedence of all three keys.
  • README.md, README.zh-CN.md: a key table in the Configuration section and the matching notes in /usage and Reset Credits.

Verification

  • node --test test/*.test.ts: 126 pass, 1 fail. The failure is test/claude-bridge.test.ts "extension shows observed Claude usage without any request", which also fails on main at cff2bdd (its fixture resets are in the past); this branch does not touch it.
  • Live run in RPC mode with three signed-in providers (Mistral, OpenAI Codex, Antigravity): the list above is that run, with the account emails replaced. The same run without the setting printed the active provider alone.

@postpersonality
postpersonality force-pushed the feat/usage-all-providers branch from f31cd51 to 2ee49c3 Compare November 16, 2026 22:12
@postpersonality postpersonality changed the title feat: list every signed-in provider in /usage behind showAllProviders feat: add showAllProviders and offerResetCredits to /usage Nov 16, 2026
Nikolay Seliverstov added 2 commits November 17, 2026 01:23
`/usage` reports the active provider only. A new `showAllProviders`
setting in `subscription-usage.json` lists the other providers Pi is
signed in to as well, each rendered as its usual block.

The active provider stays first and is still forced, so its numbers are
fresh; the others read the five-minute cache and share the failure
backoff, so a list does not turn every `/usage` into a burst of requests.
Providers without a Pi credential are skipped rather than reported as
auth failures, which is what "signed in" means here. Claude has no
endpoint to query, so it appears as `Waiting` once the bridge registers
models in the session.

The footer keeps tracking the active provider, and reset credits are
still offered for the active OpenAI or Codex account only.

`queryAdapterState` now returns undefined when Pi holds no credential,
and the single-provider path turns that into the existing
`No Pi runtime credential available` state, so nothing else changes.
`/usage` asks whether to redeem a reset credit whenever the active
OpenAI or Codex account has one. The new `offerResetCredits` setting,
on by default, turns that question off for people who would rather not
be asked: the account section still lists how many tickets are left, and
redeeming needs the setting turned back on.

The prompt is skipped before any provider or status work, so nothing
else about `/usage` changes.
@postpersonality
postpersonality force-pushed the feat/usage-all-providers branch from c363584 to b2aa4cd Compare November 16, 2026 22:24
@postpersonality
postpersonality marked this pull request as ready for review November 16, 2026 22:24
The providers after the active one in `/usage` reused a fixed
five-minute cache. `showAllProvidersCacheMinutes` sets that window in
minutes, five by default; `0` fetches every time. The footer keeps its
own five-minute refresh, so the setting only changes how stale the list
may be.

The cache accepts a per-read window now and keeps entries as long as the
longest window anyone asks for.
@postpersonality
postpersonality force-pushed the feat/usage-all-providers branch from 8650996 to e623a3e Compare November 16, 2026 22:35
@postpersonality postpersonality changed the title feat: add showAllProviders and offerResetCredits to /usage feat: add showAllProviders, offerResetCredits and showAllProvidersCacheMinutes to /usage Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant