Skip to content

fix(proxies): read codex pro plans and simplify the usage popover - #763

Merged
nixuuu merged 2 commits into
devfrom
fix/proxy-usage-simple-plans
Nov 15, 2026
Merged

nixuuu merged 2 commits into
devfrom
fix/proxy-usage-simple-plans

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Problem

  1. Every account showed "unknown plan". Codex auth files carry OpenAI's own plan identifier in X-Codex-Plan-Type: prolite, pro, promax, plus. Canopy knew pro_100/pro_500 but not prolite/promax, so they fell back to Other and counted as ×1. Claude auth files from upstream CLIProxyAPI have no plan identifier at all.
  2. The Provider usage popover was too busy: account-limit disclosures, "N unknown plans counted as ×1", "N of M accounts reporting", units text and a separate "Through " heading.

Changes

Plans (gateway)

  • Codex: prolite → Pro 100, pro → Pro 200 (the original $200 Pro), promax → Pro 500, plus → Plus. For Codex the response header wins over a stored id_token claim, because it describes the latest response.
  • Claude: upstream CLIProxyAPI (checked 2026-11-15) exposes no plan or profile identifier in auth-files. Signals are only Anthropic-Ratelimit-Unified-* and Retry-After (also in model_quotas), account_type is oauth/api_key, and id_token is Codex-only. Claude plans therefore stay unknown and count as ×1. Canopy does not guess them.
  • A proxy's own multiplier fields are not read. Plans come only from provider identifiers.
  • For account_type: api_key, CLIProxyAPI puts the key itself in account. That field is no longer used as the account label.

Weights (@canopy/domain/proxy-capacity), from the providers' statements, reviewed 2026-11-15:

Plan Weekly 5-hour
Claude Pro / Max 5x / Ultra (Max 20x) 1 / 5 / 10 1 / 5 / no cap
Codex Plus / Pro 100 / Pro 200 / Pro 500 1 / 10 / 20 / 50 1 / no cap

Popover (web) and usage sheet (mobile): new @canopy/domain/usage-summary, one row per provider:

  • provider mark and name, % left of the weighted capacity, one bar;
  • the window and its nearest reset as secondary text;
  • a shorter window (for example 5-hour) on the same line, only when it binds;
  • low capacity shows as the number and bar colour plus "Low".

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.
  • Domain: Codex weights, summary rows (merge, binding window, notes).

Browser review

A separate machine ran a gateway and web from source, with a fake CLIProxyAPI management endpoint (fake accounts, Codex prolite/promax/pro/plus headers, 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)

Before After Reason
Through <proxy> (heading link) removed Per-proxy detail lives in Settings → Proxies.
0.9 of 2 units left removed Units are an internal measure; % left says it once.
2 unknown plans counted as ×1 removed Internal weighting detail; it is a minor gap (§5).
1 of 2 accounts reporting removed Detail for Settings, not for a glance.
Account limits (disclosure) removed No disclosures in the summary.
Low capacity (extra line) Low (one word next to the number) One fact once; colour has a word (§7).
N unavailable accounts excluded, No comparable limit readings. removed; providers without a reading have no row Minor gap, skipped silently (§5).
— Weekly · Resets in 2 d 6 h Existing window names and reset format.
— 5-hour: 12% left Shown only when the shorter window binds.
— No limit readings yet. Shown only when nothing has a reading.
proxy hint lines Canopy can’t read accounts from “Team”. + Check proxy settings link What happened, then what to do.
— Checking accounts from “Team”… Ongoing action uses ….

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

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
nixuuu marked this pull request as ready for review November 15, 2026 00:52
@nixuuu
nixuuu merged commit ac134a3 into dev Nov 15, 2026
13 checks passed
@nixuuu
nixuuu deleted the fix/proxy-usage-simple-plans branch 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
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]>
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