Skip to content

feat(cli): add per-account quota to ocx account list - #2587

Merged
lidge-jun merged 1 commit into
devfrom
codex/account-quota-2566
Aug 25, 2026
Merged

lidge-jun merged 1 commit into
devfrom
codex/account-quota-2566

Conversation

@lidge-jun

Copy link
Copy Markdown
Owner

Summary

Closes #2566.

The proxy already probes per-credential usage (fetchProviderAccountQuotas) and exposes it
at /api/oauth/accounts?provider=…&quota=1, and the dashboard already renders it. The CLI
just never passed quota=1, so a headless or SSH session had to hand-roll an authenticated
curl against the management API — with the admin token read off disk — to answer "which
account has quota left before I start a long session".

--quota opts into the probe and adds a QUOTA column. It stays opt-in because the server
probes the upstream once per stored credential; the default listing remains a local read.
--refresh bypasses the cached result.

Two details worth naming:

  • An unprobed provider shows - and a failed probe shows unavailable. Blank would read as
    "no usage" rather than "not measured", which is the wrong thing to tell someone choosing an
    account.
  • Two DTO spellings reach the same field: the per-account probe reports fiveHourPercent
    while the Codex pool reports the same idea as shortPercent. Both render as 5h.

Verification

Against a live proxy with three Anthropic logins:

$ ocx account list anthropic --quota
PROVIDER   TYPE   ID                                PLAN/LABEL         PRIORITY  STATUS  QUOTA
anthropic  oauth  1278f8da                          a***r@big5lms.com  -                 5h 7% wk 62%
anthropic  oauth  e112f28b                          k***1@gmail.com    -         active  5h 9% wk 45%
anthropic  oauth  b245be9769d72f90b5f1d1c6c1ab4baf  l***n@gmail.com    -                 5h 0% wk 98%

Exactly the decision the issue describes: the active account is at 45% weekly while a sibling
sits at 98%.

The default listing is unchanged (no QUOTA column), and a full --quota run shows - for
providers without a per-account probe. --json carries the complete breakdown.

$ bun test tests/cli-headless-parity.test.ts
 36 pass, 0 fail

$ bun x tsc --noEmit
(clean)

Docs updated in docs-site/src/content/docs/reference/cli/providers-accounts.md.

Checklist

  • Targets dev
  • Based on the current dev head
  • Verified against a live proxy, not only in tests
  • Docs updated for the user-facing flag
  • Typecheck clean
  • Account identifiers in the output above are the CLI's own masked form

The proxy already probes per-credential usage and the dashboard already
renders it, but no CLI command exposed it: fetchOAuthRows never passed
quota=1, so a headless or SSH session had to hand-roll an authenticated
curl against the management API to answer 'which account has quota left'.

--quota opts into the probe and adds a QUOTA column; the default listing
stays a cheap local read. --refresh bypasses the server TTL. An
unprobed provider shows '-' and a failed probe shows 'unavailable',
because blank would read as no usage rather than not measured.

Two DTO spellings reach the same field - the per-account probe reports
fiveHourPercent, the Codex pool reports shortPercent - and both render
as 5h.
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner August 25, 2026 16:46
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 20 seconds.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 17ecf620-3349-412c-93c9-f01c02493a3e

📥 Commits

Reviewing files that changed from the base of the PR and between 073ae69 and ddefc73.

📒 Files selected for processing (4)
  • docs-site/src/content/docs/reference/cli/providers-accounts.md
  • src/cli/account-api.ts
  • src/cli/account.ts
  • tests/cli-headless-parity.test.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@lidge-jun
lidge-jun merged commit 11c3f7e into dev Aug 25, 2026
8 checks passed
@lidge-jun
lidge-jun deleted the codex/account-quota-2566 branch August 25, 2026 16:46
@github-actions github-actions Bot added the enhancement New feature or request label Aug 25, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ddefc7358d

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

Comment thread src/cli/account-api.ts
Comment on lines +314 to 316
quota?: { refresh?: boolean },
): Promise<FamilyRows> {
if (type === "codex") return fetchCodexRows(deps, baseUrl);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Forward quota requests to Codex account reads

When the target is openai, including the Codex rows in an unqualified list, the new quota option reaches fetchRows but this branch drops it and calls fetchCodexRows with its default false. Consequently, ocx account list openai --quota [--refresh] neither adds ?refresh=1 nor projects the returned quota, so every Codex row displays - and the newly supported shortPercent rendering is unreachable. Pass separate include-quota and refresh state into the Codex reader, and cover the command-level request/output path rather than only the formatter.

AGENTS.md reference: src/AGENTS.md:L24-L25

Useful? React with 👍 / 👎.

Comment thread src/cli/account.ts
Comment on lines +121 to +122
const wantsQuota = consumeFlag(rest, "--quota");
const refreshQuota = consumeFlag(rest, "--refresh");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject or honor refresh when quota is omitted

If an operator runs ocx account list anthropic --refresh without --quota, both flags are accepted and removed, but the request options are discarded because wantsQuota is false; the command exits successfully with an ordinary cached/non-quota listing. Since the usage nests --refresh under --quota, this unsupported combination should return a usage error, or --refresh should imply quota, with focused argument-path coverage.

AGENTS.md reference: src/AGENTS.md:L24-L25

Useful? React with 👍 / 👎.

```

### `ocx account list [provider] [--json] [--all]`
### `ocx account list [provider] [--json] [--all] [--quota [--refresh]]`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Synchronize quota documentation across translated pages

The English page now documents the new flags and conditional QUOTA column, but all seven translated copies found under docs-site/src/content/docs/{fr,ja,ko,ru,tr,zh-cn,zh-tw}/reference/cli/providers-accounts.md still publish the old list [provider] [--json] [--all] signature and six-column output. Users viewing those locales therefore cannot discover this workflow and receive a stale command contract; update each directly affected page alongside the canonical source.

AGENTS.md reference: docs-site/AGENTS.md:L15-L16

Useful? React with 👍 / 👎.

tarunravi pushed a commit to tarunravi/opencodex that referenced this pull request Sep 14, 2026
The proxy already probes per-credential usage and the dashboard already
renders it, but no CLI command exposed it: fetchOAuthRows never passed
quota=1, so a headless or SSH session had to hand-roll an authenticated
curl against the management API to answer 'which account has quota left'.

--quota opts into the probe and adds a QUOTA column; the default listing
stays a cheap local read. --refresh bypasses the server TTL. An
unprobed provider shows '-' and a failed probe shows 'unavailable',
because blank would read as no usage rather than not measured.

Two DTO spellings reach the same field - the per-account probe reports
fiveHourPercent, the Codex pool reports shortPercent - and both render
as 5h.
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
The proxy already probes per-credential usage and the dashboard already
renders it, but no CLI command exposed it: fetchOAuthRows never passed
quota=1, so a headless or SSH session had to hand-roll an authenticated
curl against the management API to answer 'which account has quota left'.

--quota opts into the probe and adds a QUOTA column; the default listing
stays a cheap local read. --refresh bypasses the server TTL. An
unprobed provider shows '-' and a failed probe shows 'unavailable',
because blank would read as no usage rather than not measured.

Two DTO spellings reach the same field - the per-account probe reports
fiveHourPercent, the Codex pool reports shortPercent - and both render
as 5h.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant