Repository navigation
fix(proxies): read codex pro plans and simplify the usage popover - #763
Merged
Merged
Conversation
Codex auth files report OpenAI's plan identifiers in X-Codex-Plan-Type (prolite, pro, promax, plus). prolite and promax fell back to an unknown plan. They now map to Pro 100 and Pro 500, plain pro to Pro 200, and the header wins over an older stored claim. Weekly weights follow the providers' own statements: Codex Plus 1, Pro 100/200/500 10/20/50; Claude Pro 1, Max 5, Ultra 10. Upstream CLIProxyAPI has no Claude plan identifier, so Claude plans stay unknown and count as 1. API-key credentials carry the key itself in `account`; it is no longer used as the account label. The Provider usage popover and the mobile sheet now show one row per provider: % left, one bar, the window and its reset, and a shorter window only when it binds. Account lists, units, reporting counts and unknown-plan lines stay in Settings. Related: #751, #753, #760
nixuuu
marked this pull request as ready for review
November 15, 2026 00:52
nixuuu
added a commit
that referenced
this pull request
Nov 15, 2026
Persist owner-scoped account plan choices and apply them to weighted capacity across web and mobile. Related: #763
nixuuu
added a commit
that referenced
this pull request
Nov 15, 2026
## Change Proxy accounts with undetectable plans can now use a manual plan in Settings → Proxies → Accounts on web and mobile. For example, Claude Ultra counts as ×10 and Team as ×5. Automatic keeps detection as the default; a manual choice takes precedence over later detection until reset, with a subtle “Set manually” hint. - Migration 0149 stores the choices on the owner-scoped proxy row, keyed by a hash of provider + upstream stable ID (fallback: auth_index). Missing accounts are ignored. Refresh and gateway restarts retain the choices; deleting the proxy deletes them. - The effective plan reaches ListProxies, overview updates and the shared weighted capacity calculation used by the sidebar indicator, usage popover and mobile sheet. Detection remains separately available. - Additive RPC and account fields; regenerated contracts. Team already existed in the enum, so its numeric value is preserved. Its Claude ×5 weight is explicitly documented as a user-provided equivalence dated 2026-11-15, not independently confirmed by Anthropic. - Claude and Codex offer the requested known plans. Grok currently has no known weights in the table, so its picker offers Automatic only. No fork-specific multiplier or plan field was added. ## Verification Local checks passed: - `bun run gen`. - `bun run check:tmp` for `tests/integration/proxy-account-plans.test.ts`, `tests/integration/proxy-accounts.test.ts`, gateway `management-plan.test.ts` and `management.test.ts`, domain `proxy-capacity.test.ts`, and DB `schema.test.ts`: 48 tests passed across the focused runs, with no temporary files left. The new integration test covers set/clear, later detection precedence, weighted capacity, foreign-owner read/write refusal, refresh with changed email/runtime index, and removed accounts. - Typechecks for gateway, contracts, db, domain, mobile and web; Svelte reports 0 errors and 0 warnings. Lint and formatting on edited files; diff/content/link review. - Real browser review using an isolated remote gateway/web and PostgreSQL plus fake management accounts: light/dark at desktop (1280 px), phone (390 px) and narrow phone (320 px). Short, typical and long emails remain blurred; dropdown/sheet selection, reset, Refresh, and a failed save with rollback/retry were checked. Review processes and container are cleaned up. Screenshots stay outside the repository. Rebased onto current dev after #803, #804, #806 and #807. Renumbered the migration to 0149 and regenerated the combined proto. Focused tests and affected typechecks were repeated. The web row keeps the provider mark, blurred identity and status on its first line. A muted, borderless kit trigger occupies one 20 px plan line below, followed inline by “· Set manually”. There is no empty hint line. Switching to Automatic leaves row height unchanged on desktop and at 320 px. Browser shots were refreshed at desktop, 390 px and 320 px in light/dark with short and long identities. The final visual-only change passed web typecheck and edited-file lint/format; the 48 focused backend tests remain valid for unchanged backend inputs. Full frozen install, gen:check, repository-wide typecheck/lint/format, complete check:tmp suite and selected builds remain with CI. No UI test suite was added. Native mobile was typechecked but not run on an iOS/Android device. ## Copy audit — docs/copy.md §8 | Before | After | Reason | | --- | --- | --- | | Unknown plan with no way to set it | Automatic · Unknown plan; provider plan options with × multipliers | Offers a concrete choice without guessing detection. | | Repeated plan label beside the picker | One selected plan in the picker | One fact once; account identity keeps its space. | | — | Set manually | Short, subtle status; meaning does not rely on colour. | | — | Saving plan… | Present ongoing action with the standard ellipsis. | | — | Could not save the plan. Choose it again to retry. | What happened, followed by an action; no transport details. | Checklist 1–10 passed: short active sentences, sentence case and punctuation; existing plan/account glossary; menu entries are selection values, not commands; errors end with an action; no new empty states, duplicate facts, jargon, or “soul” copy. Automatic preserves honest unknown detection. Short/typical/long identities checked at desktop and phone widths with blur intact. Accessible “Account plan”, status text and numbers carry meaning without colour or position. No failing items. Related: #763
This was referenced Nov 16, 2026
nixuuu
added a commit
that referenced
this pull request
Nov 24, 2026
## Summary Use the same text size for the main and shorter-window percentages in the web and desktop Provider usage panel. The main percentage keeps its medium weight. Fixes: #763 ## Verification - Checked the panel in Chromium with sample Claude and Codex readings at 320 px and 1280 px in light and dark mode. All percentages used the same size at each width, and the labels fit. - Ran oxfmt and oxlint on the edited component, plus `git diff --check`. - Full verification runs in CI.
nixuuu
added a commit
that referenced
this pull request
Nov 27, 2026
## What **Provider usage popover (web and mobile)** - A bar for every shorter general limit some account reports (e.g. 5-hour) now sits **above** the weekly bar. - Every account keeps the same column, at its weekly plan width, in each bar of a row. An account without a 5-hour limit (Claude Ultra, Codex Pro) leaves an empty gap in the 5-hour bar, so that bar appears only over the accounts it belongs to. - Each bar's caption now carries its own reset and `% left`. The header keeps the provider, account count and `Low` / `Extra usage`. **Sidebar indicator** - The bar now fills to the weekly limit, matching the popover's weekly bar. Before, it filled to the tighter 5-hour limit, so Claude looked almost empty (3%) while the popover showed 74% weekly left. - A tighter shorter limit still sets the bar's colour, like the `Low` label. **Implementation** - `usage-summary.ts` builds per-account columns. `CapacitySegment` now carries its proxy account, so accounts line up across bars and equal ids on two proxies stay apart. - A small shared `UsageSummaryMeter` renders one bar plus its caption on web and on mobile. - `docs/proxies.md` is updated. Related: #763 ## Verification Ran locally: - `bun test packages/domain/src/sidebar-usage.test.ts packages/domain/src/proxy-capacity.test.ts`. The summary test now checks the aligned 5-hour columns, the empty column for an account without that limit, and that the sidebar indicator follows the weekly window. - `apps/web` typecheck (svelte-check). - `apps/mobile` typecheck. - oxlint and oxfmt on the changed files. - Rendered the real web row components with fixture data in a browser, in dark and light themes. Left to CI: the full gate. Not checked: mobile on a device. ## Copy audit (docs/copy.md §8) 1. Pass: no new strings. Captions reuse the existing formatters (`5-hour · Resets in 3 h`, `3% left`, `Weekly · …`). 2. Pass: no new terms. 3. n/a: no buttons changed. 4. n/a: no errors changed. 5. n/a: no empty states changed. 6. Pass: the weekly `% left` moved from the header to the weekly caption, so it is not shown twice. The binding-only `5-hour: 3% left` line is replaced by the 5-hour bar's caption. 7. n/a. 8. n/a. 9. Pass: checked with one and two accounts, with and without a 5-hour limit, and at 3%–75% left in the 21rem popover. 10. Pass: low capacity keeps the `Low` word next to the colour. The accessible label lists each window as text, e.g. `5-hour: 3% left · Resets in 3 h`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
X-Codex-Plan-Type:prolite,pro,promax,plus. Canopy knewpro_100/pro_500but notprolite/promax, so they fell back to Other and counted as ×1. Claude auth files from upstream CLIProxyAPI have no plan identifier at all.Changes
Plans (gateway)
prolite→ Pro 100,pro→ Pro 200 (the original $200 Pro),promax→ Pro 500,plus→ Plus. For Codex the response header wins over a storedid_tokenclaim, because it describes the latest response.auth-files. Signals are onlyAnthropic-Ratelimit-Unified-*andRetry-After(also inmodel_quotas),account_typeisoauth/api_key, andid_tokenis Codex-only. Claude plans therefore stay unknown and count as ×1. Canopy does not guess them.account_type: api_key, CLIProxyAPI puts the key itself inaccount. That field is no longer used as the account label.Weights (
@canopy/domain/proxy-capacity), from the providers' statements, reviewed 2026-11-15:Popover (web) and usage sheet (mobile): new
@canopy/domain/usage-summary, one row per provider:Direct instances and proxy accounts merge into the same row, keeping the lower reading per window. The sidebar indicator uses the same rows (most restrictive window). Removed: the account-limit disclosure, unknown-plan and reporting lines, units text and the "Through " heading. Per-account detail stays in Settings → Proxies and Providers. A proxy in use whose accounts can't be read gets one sentence with a link. Mobile changes are JS only; the native fingerprint is unchanged.
Tests
apps/gateway/src/proxies/management-plan.test.ts: realistic auth-file fixtures (fake data): Codex prolite/promax/pro/plus headers, a stale claim, Claude with and without extra proxy fields, malformed extra fields (the account is still read), and an API-key credential.Browser review
A separate machine ran a gateway and web from source, with a fake CLIProxyAPI management endpoint (fake accounts, Codex
prolite/promax/pro/plusheaders, Claude unified headers). Covered: light and dark, desktop and phone width, 1 and 2 providers, 1, 6 and 30 accounts, a low/binding 5-hour window, and an unreadable proxy. Before (dev): both Codex Pro accounts counted as unknown ×1, and the popover had the account and plan lines. After: one row per provider, Codex weighted 10/50. Mobile wasn't run on a device; it is JS only and the native fingerprint is unchanged.Copy audit (docs/copy.md §8)
Through <proxy>(heading link)0.9 of 2 units left2 unknown plans counted as ×11 of 2 accounts reportingAccount limits(disclosure)Low capacity(extra line)Low(one word next to the number)N unavailable accounts excluded,No comparable limit readings.Weekly · Resets in 2 d 6 h5-hour: 12% leftNo limit readings yet.Canopy can’t read accounts from “Team”.+Check proxy settingslinkChecking accounts from “Team”…….Checklist: active voice and sentence case. No banned glossary terms (proxy, account). The link starts with a verb. No fact repeated. Colour always has a word or number. Checked with short and long proxy names at desktop and phone width.
Related: #751, #753, #760