Repository navigation
feat(oauth): report an explicit account plan field for OAuth providers - #4146
Conversation
The OpenAI/Codex provider reports a per-account plan string, so a consumer can weight each account's remaining quota by its seat size. The OAuth providers reported no such field at all, so a multi-account Anthropic pool had no meaningful aggregate capacity number and every account looked identical in tier terms. Add plan to the OAuth account summary, the management route response and the CLI DTO, using the same name and placement as the Codex side so consumers need no per-provider branching. The field is always present and is null when the tier is unknown. That distinction is the point: an ABSENT key means the proxy predates the field, while null means this version looked and the provider did not report a tier. Omitting it collapses the two and invites a consumer to assume a tier -- which is exactly the workaround the reporter was maintaining by hand. For Anthropic the value is null today, and that is an upstream gap rather than an unfinished mapping. /api/oauth/usage returns quota buckets only (five_hour, seven_day, the model-scoped weekly windows and limits[]) with no subscription or tier field, and the OAuth token response yields only account.uuid and account.email_address. No tier is inferred from what is there: quota percentages are normalized per account, so a Max x5 seat at 50% is indistinguishable from a Max x20 seat at 50%, and a model-scoped window tracks entitlement rather than seat size. The reasoning is recorded at fetchAnthropicUsageQuota so a future reader does not read null as an oversight. Closes #3777
|
✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe change adds a nullable ChangesOAuth account plan field
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to The nullable OAuth plan behavior is implemented, but the added API test currently fails to compile because of a duplicate declaration. Fix this before merge. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files. (1 skipped: 1 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
리뷰 · 우선순위 58 / 80설명 이 PR은 이슈 문제의 핵심은 이렇다. OpenAI/Codex 쪽은 이미 계정마다 이 PR이 하는 일은 단순하다. Anthropic 값이 오늘 현재 라인 src/cli/account-api.ts fetchOAuthRows - 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
…unt-plan-3777 Closes lidge-jun#3777. Adds an explicit plan field to the OAuth account summary, the management route, the CLI DTO and the Anthropic dashboard rows, matching how the OpenAI provider already exposes plan.\n\nThe Anthropic usage endpoint carries no subscription tier field, so Anthropic accounts land plan: null rather than a tier inferred from usage percentages. That is recorded at the source and in the docs so a future reader does not read null as an oversight, and a test pins the present-versus-null distinction.\n\nExact-head CI at dae5d14: Cross-platform CI success, enforce-target success x2, PR hygiene success x2, PR Labeler success x2, React Doctor success.
Summary
Closes #3777.
The OpenAI/Codex provider reports a per-account
planstring, so a consumer can weight each account's remaining quota by its seat size. The OAuth providers reported no such field at all, so a multi-account Anthropic pool had no meaningful aggregate capacity number and every account looked identical in tier terms. The reporter was maintaining a hand-written account-id to tier map that silently rots whenever a subscription changes.planis now reported on the OAuth account summary, the management route (GET /api/oauth/accounts) and the CLI DTO (ocx account list <provider> --json), using the same field name and placement as the Codex side so consumers need no per-provider branching.The field is always present, and
nullwhen the tier is unknown. That distinction is the substance of the change, not a detail: an absent key means the proxy predates this field, whilenullmeans this version looked and the provider did not report a tier. Collapsing the two is what lets a consumer quietly assume a tier, which is the failure mode the issue describes. The CLI forwards the server's answer verbatim rather than normalizingnullaway.For Anthropic the value is
null, and that is upstream, not unfinishedStating this plainly so a future reader does not read it as an oversight or a TODO.
GET https://api.anthropic.com/api/oauth/usagereturns quota buckets only —five_hour,seven_day, the model-scoped weekly windows (seven_day_fable/_opus/_sonnet) and alimitsarray — and carries no subscription or tier field. The OAuth token response carries none either:src/oauth/anthropic.tsgetsaccount.uuidandaccount.email_addressand nothing else. There is no tier in anything this proxy receives, so nothing is mapped.No tier is inferred from what is there, and the issue is explicit about why that would be wrong. Quota percentages are normalized per account, so a Max x5 seat at 50% is byte-identical to a Max x20 seat at 50%. The presence of a model-scoped weekly window tracks entitlement rather than seat size, so keying a tier off it would produce a confident wrong answer that is indistinguishable from data. A guess here is worse than
null, becausenullis something a consumer can handle correctly and a wrong tier is not.The reasoning is recorded in a comment at
fetchAnthropicUsageQuotaand in the providers guide, so the next person to look does not re-derive it. If upstream later returns the tier, populating this field is a one-line change at that call site with no contract change anywhere above it.Issue item 4 (surfacing the tier in the dashboard Anthropic rows) is deliberately not included. There is nothing to display while every value is
null, so it would be a GUI change with no user-visible effect; it belongs with the upstream field if it appears.Verification
bun run test,test:changed,typecheck,build:gui,lint:guiorbun install. The exact-head remote CI on this PR is the gate, and the branch was pushed with--no-verify.tests/oauth/oauth-accounts-api.test.ts-> "GET reports an explicit null plan for an Anthropic account", which asserts"plan" in accountandplan === null. Asserting presence separately from the value is what pins the contract this change exists to create; a test that only checked the value would still pass if the key were dropped.docs-site/src/content/docs/guides/providers.mdunder "Switching accounts from the terminal". English only; no translated locale is contradicted, since none of them describe this field.gui/files are touched.Checklist
src/oauth/index.ts, so specifically: the added field is a constantnulland carries no credential-derived data; no token, refresh grant, account id or email reaches a new surface; the account summary's existing email masking is untouched; and the change is read-only with respect to the credential store.Summary by CodeRabbit
New Features
planfield for every OAuth account.nullwhen the subscription tier is unknown, including for Anthropic accounts.Documentation
planfield, its possible values, and compatibility behavior across account-listing interfaces.Tests
plan: nullwhen no tier is available.