Repository navigation
feat(proxies): summarize weighted provider capacity - #753
Merged
nixuuu merged 2 commits intoNov 14, 2026
Merged
Conversation
nixuuu
marked this pull request as ready for review
November 14, 2026 20:46
nixuuu
force-pushed
the
feat/proxy-weighted-capacity
branch
from
November 14, 2026 20:51
5205a2a to
1925ba1
Compare
nixuuu
force-pushed
the
feat/proxy-weighted-capacity
branch
2 times, most recently
from
November 14, 2026 21:10
745a45b to
1638535
Compare
nixuuu
force-pushed
the
feat/proxy-weighted-capacity
branch
from
November 14, 2026 21:24
1638535 to
24f7651
Compare
nixuuu
added a commit
that referenced
this pull request
Nov 14, 2026
Brings mobile Settings → Providers, Settings → Proxies and the drawer's provider usage sheet to parity with web (#751, #753). JS only: no dependencies, native modules or config-plugin changes. ## Differences found (web → mobile before this PR) **Proxies** 1. Heading and empty state differed ("Shared connections…" notice, "No proxies yet"); no shared-configuration notices. 2. Card showed the raw kind value and the full base URL; the host was not masked. 3. "Secret: Set/Not set" instead of the "Secret set / Secret missing" badge; "No providers" instead of "Used by … / No profiles yet". 4. No **Management key** field (set / replace / clear), so accounts could not be enabled from mobile. 5. New proxies defaulted to WebSockets on (web: HTTP/SSE); different WebSockets description; no Kind compatibility hint, placeholders or the encryption note. 6. Secret used a "Replace saved secret" toggle instead of Set / Replace / Keep current. 7. Accounts were plain text: no provider mark, plan + weight, status badge, meters, masked identity or masked detail, no "Showing N of M", Refresh error unhandled. 8. "How agents use this proxy" only inside the form; unmasked URLs. 9. Test result was one notice for the whole page with different wording; delete confirmation differed. **Providers** 10. Harness filter + per-instance button bar instead of web's single list of all instances with mark, name, version, status dot and on/off switch per scope. 11. No instance detail: header (harness · id · connection, Built-in, threads), Status section, per-worker status list, Workers access, definition form, models and delete section were split across sheets with different wording. 12. No "Checking… / Checked just now", "Not checked: …" or offline-worker notice; no "Deleted on another computer" notices. 13. Account line showed the email unmasked (also Workers → Provider accounts and the config directory); no plan meters per worker. 14. Proxy chooser listed raw base URLs; worker override used a free-text **Proxy ID** field instead of the proxy picker with "Use the instance's proxy" and Add proxy. 15. Connection descriptions were not harness-specific; the form showed a "Saved key" row web does not have. **Provider usage (drawer footer)** 16. Only "Through <proxy>: N accounts · M cooling down"; no weighted capacity, nearest reset, low-capacity warning, "N of M accounts reporting", unknown-plan note, per-account limits, plan badges, masked identities; glance bars ignored proxy capacity; window names ignored their length. ## What changed - `@canopy/domain/provider-instances` (new): `harnessName`, `instanceName`, `kindLabel`, `statusOn`, `statusAcross`, `versionsOf`, `hasAccountStatus`, `accountStateLabel`, moved from web; web re-exports them. `proxyKinds` and `supportsHarness` moved to `@canopy/domain/proxy-accounts`. Capacity maths stays in `@canopy/domain/proxy-capacity` (no copy in the app). - Mobile `Sensitive` / `SensitiveUrl` (`src/ui/Sensitive.tsx`): the hidden value is never rendered (one bullet per character), so screenshots, screen sharing and the accessibility tree cannot read it; the label says "… hidden". Tap reveals for 30 s, a second tap hides; leaving the foreground, a new value and unmounting hide it. Proxy hosts are masked with scheme and path kept. - Proxies: `ProxyEntry`, `ProxyForm` (management key, `SecretValue`, defaults as web), `ProxyMappings`, rewritten `ProxyAccounts` with `ProxyAccountRow`. - Providers: `InstanceRow`, `InstanceDetail`, `InstanceStatus`, `ProviderAccountRow`, `ProxyThrough`, `ProxyPicker`, `WorkerOverrides` (was `ProviderWorker`), aligned `ProviderForm`, add sheet with agent choice. - Usage sheet: `ProxyUsageAccounts` + `ProxyCapacitySummary` per provider, "Account limits" disclosure, `proxyCapacityGlance` for the footer bars, shared `UsageMeters` (window names with their length), scroll height bound to 55% of the window. - Docs: `proxies.md`, `provider-accounts.md`. ## Copy audit (docs/copy.md §8) All new mobile strings are web's existing strings (same source text), except: - "Could not read the proxy's accounts. Try again." (Refresh failure; web shows the raw error, mobile never shows transport diagnostics) — what happened, then what to do. - "Proxy host hidden" / "Account email hidden" + hint "Double-tap to reveal / hide" (accessibility labels; web: "hidden, activate to reveal"). - Before → after: "Shared connections for your agent providers…" → "Save a connection once, then choose it in any compatible provider instance." (web heading); "No proxies yet" → "One connection for your agents" + one sentence (empty state: title + ≤2 sentences); "Delete proxy?" → "Delete Team proxy?" with the same verb on the button; "Refresh accounts" → "Refresh"; "Edit proxy" → "Edit"; "Edit definition"/"Edit worker settings" → the instance detail; "Save definition" → "Save for all workers"; "Proxy ID" field → proxy picker; "Saved key" row removed (repeated fact); "Supports WebSockets" description → web's. - Buttons start with a verb; no banned synonyms; no new glossary terms; no "soul" sentences; status never relies on colour alone (dot + words, badges with text). - Long texts: rows truncate to one line (names, identities, versions), details wrap; not checked on a device (below). ## Verification - `bun install`, `bun run gen:check`, `bun run typecheck`, `bun run lint`, `bun run format:check`, web build: clean. - `expo export` for Android and iOS: both Hermes bundles build. - Native fingerprint: `@expo/fingerprint` source hashes for Android and iOS are identical to the base (60/60 sources); only JS changed. - `bun run check:tmp`: 3156 pass, 1 fail — `apps/worker/src/providers/codex/connections.test.ts` "Codex keeps full history when resuming across device login and proxy connections" (the local Codex CLI rejects `thread/resume` with a model-provider change). This PR does not touch the worker. - **Not verified on a device:** the local host has no Android SDK, MacStudio's device hub did not answer, and EAS simulators need an `eas build`. Light/dark, phone/foldable widths and 1/6/30 accounts were not checked on screen; no screenshots.
nixuuu
added a commit
that referenced
this pull request
Nov 15, 2026
## 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 <proxy>" 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 <proxy>" 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
This was referenced Nov 16, 2026
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.
Proxy usage now summarizes supported accounts in weighted capacity units per provider and limit window. The sidebar indicator includes the most constrained cached proxy window for each provider; the compact popover shows remaining percentage, remaining/total units, nearest reset and reporting coverage, with expandable private account limits below each provider. Direct-provider usage keeps its existing display. No new polling or reads are added.
This is stage 2, stacked on #751. Merge the complete stack together.
Capacity rules
Subscription research — 2026-11-14
procannot identify a price tier. Explicit Pro 100/200/500 plan names are additive enum values; no price or capacity is inferred from a token.These findings differ from the proposed Claude Plus/Pro/Max/Ultra ×1/5/10/20 table: Claude Pro is the base, Max is ×5 and Ultra is ×10 weekly. Current official sources do not establish the proposed Codex Prolite/Pro/Promax ratios, and Grok's consumer ratios do not describe API capacity. No guessed multipliers or price ratios are shipped.
Copy audit
New text: “Account limits”, “% left”, “X of Y units left”, “Low capacity”, “X of Y accounts reporting”, “Unknown plan”, “unknown plans counted as ×1”, “capacity counted as ×1”, “No comparable limit readings.”, “unavailable accounts excluded”, and the unsupported-provider account count. Subscription labels add Pro 100/200/500, Premium and Super; legacy Claude Max 5x/20x display as Max/Ultra, with a separate weight. Existing privacy, Checked and recovery labels remain. Sentence case, concise labels, explicit missing-data and exclusion wording, no color-only warning, no humor or new glossary terms. Long identities remain private and truncate; supported provider names are a closed set.
Validation
Install, typecheck (zero Svelte errors/warnings), lint, format:check, gen:check and web build passed with lowered priority and temporary files outside the checkout. Focused domain/gateway unit checks: 13 tests, 73 assertions, covering weighted units, missing/expired readings, excluded/cooling/reached accounts, unknown plans, unsupported providers, matching periods across old/new cached records, distinct custom durations and combined indicators. No UI test suite added.
Manual browser review used synthetic accounts and an isolated disposable stack: light/dark, desktop/phone, 1/6/30 accounts, compact collapsed summaries and expanded account limits, bounded internal scrolling, long identity truncation, privacy attributes, status and missing-report coverage. With 30 accounts the inner scroller stayed 384 CSS px high for 2235 px of expanded content, with no horizontal page overflow. Privacy stays on the shared click-to-reveal component from #751. Before/after PNGs remain outside the repository. Self-review completed; no extra polling, leases or refresh timers were added.
Related: #745, #751
Reset timestamp follow-up
Rebased onto the reset sanity guard in #751. The earlier stage 1 screenshot used a 2099 fixture date; epoch and relative seconds are parsed correctly. Resets more than 400 days ahead now remain unknown, including old cached dates.
Follow-up checks: install, gen:check, typecheck, lint, format:check and web build passed. Focused gateway and capacity tests passed (11 tests, 74 assertions). No additional UI wording.
Restacked onto #751's deterministic integration fixture correction: the old 2033 epoch now uses a three-hour reset against a fixed suite clock. The production sanity guard remains unchanged.
Repeated local validation: proxy integration and gateway management checks passed three consecutive times (24 tests, 177 assertions per run), plus an initial focused management run. Typecheck, lint and format:check passed after the fixture correction.