Skip to content

feat(mobile): match web provider and proxy settings and usage - #760

Merged
nixuuu merged 1 commit into
devfrom
feat/mobile-provider-proxy-parity
Nov 14, 2026
Merged

nixuuu merged 1 commit into
devfrom
feat/mobile-provider-proxy-parity

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 14, 2026

Copy link
Copy Markdown
Member

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 : 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
nixuuu marked this pull request as ready for review November 14, 2026 22:21
@nixuuu
nixuuu merged commit 64ba430 into dev Nov 14, 2026
12 checks passed
@nixuuu
nixuuu deleted the feat/mobile-provider-proxy-parity branch November 14, 2026 22:21
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
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