Skip to content

fix(web): protect proxy identities and show account usage - #751

Merged
nixuuu merged 5 commits into
devfrom
fix/blur-proxy-account-emails
Nov 14, 2026
Merged

nixuuu merged 5 commits into
devfrom
fix/blur-proxy-account-emails

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Change

CLIProxyAPI account identities in Settings → Proxies now use the same click-to-reveal privacy component as Providers. Hidden values have no plaintext title, tooltip or accessible name; keyboard activation reveals the accessible value, Escape hides it, and the existing 30-second timeout remains. Truncated identities keep their layout on reveal. Account detail messages also use privacy protection because upstream messages can repeat a login.

The sidebar Provider usage popover lists each proxy account with its provider, limit windows, percentage, compact bars, reset time and non-Active status. Accounts are grouped by provider, with the most-used windows first. A bounded internal scroller keeps large lists compact. Checked timestamps, loading, empty and error states use the existing cached data. No polling or refresh request was added; the shared ListProxies cache, overview feed and gateway lease remain responsible for reads.

Identity audit

  • Settings → Proxies: account labels and detail messages protected; plaintext title removed.
  • Settings → Providers and sign-in completion: existing AccountStatusRow already uses Sensitive for emails; shared reveal behavior retained.
  • Sidebar limits and provider usage: direct providers show instance labels and computer names, not account email fields; their meters remain unchanged. Proxy account identities use the same protected row as Settings.
  • Proxy pickers select saved connections and contain no upstream account identities.
  • Thread import and provider sign-in flows do not separately render upstream account emails or logins. Explicit entry fields are unchanged.

Validation

nice install, typecheck, lint, format:check, web build and gen:check passed. Focused gateway/domain unit checks: 8 passing tests, 47 assertions. No UI test suite added. Browser review uses a disposable isolated stack and synthetic identities: light/dark, desktop/phone, DPR 1/2, short/typical/long emails, 1/6/30 accounts, internal scrolling, reveal/Escape and accessibility attribute inspection. The measured short email stayed 55.5 px wide on reveal; no hidden identity or host appeared in title/aria attributes.

Window parsing now follows the reported duration, including daily, monthly and custom periods. A weekly-only Codex plan can put its weekly window in primary; an empty secondary is not a second quota. Empty zero watermarks are dropped for Codex and Claude. Plan names cross the gateway boundary as a closed enum; Codex's sanitized id_token.plan_type and passive plan header are supported. Other providers show a plan only if management exposes a recognized name. Raw JWTs are never decoded or downloaded. Additive proto fields and generated code are included. See docs/proxies.md for source links and limitations.

Proxy hosts are also protected: the card, all three agent mapping lines, the edit form's read-only mappings, and the selected connection in proxy pickers. Scheme, port and path remain visible. Editable URL inputs remain readable. Plain URL picker descriptions were removed to avoid leaking through option tooltips or accessible labels.

Copy audit

New privacy labels: “Account identity”, “Account details”, “Proxy host” and “Proxy URL”; these describe hidden values without disclosing them. Proxy usage reuses “Through …”, “Checked …”, limit/reset labels, account statuses and the existing empty state. Error recovery adds “Open proxy settings to check access, then refresh.” New loading state: “Checking accounts…”. Plan labels use established subscription names (Free, Plus, Pro, Team, Business, Enterprise, Max, Max 5x/20x, Ultra, Other plan). Window names use “Daily”, “Monthly”, a numeric duration, or “Primary limit”/“Secondary limit” when only a slot is known. Sentence case, active voice, short sentences, action after errors, no new jargon or glossary terms, no humor, and no color-only meaning. Reviewed short/typical/long values at desktop and phone width.

Related: #728, #731, #745

Reset timestamp follow-up

The stage 1 review fixture used 2099-01-01T00:00:00Z, causing the 26,345-day countdown. This was fixture data, not a seconds/milliseconds conversion defect. Corrected browser fixtures use resets one day and three hours ahead.

The gateway now rejects reset timestamps more than 400 days ahead, and the shared formatter also hides implausible dates already cached. Codex reset-at and Claude reset headers remain epoch seconds; Codex reset-after-seconds remains relative to the quota observation. Realistic gateway fixtures cover these three paths, accidental millisecond epochs, the 400-day boundary and cached invalid 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). Corrected stage 1 browser review confirmed one-day and three-hour countdowns.

Copy audit: no new UI wording; unknown reset times omit the existing reset label while retaining usage readings.

The CI integration fixture also contained an obsolete 2033 reset (2000000000 epoch seconds), which the 400-day guard correctly discarded. The management integration suite now fixes its clock to the quota observation and uses a three-hour reset, restoring the real clock during cleanup. PostgreSQL lease timing continues to use real elapsed time. No production behavior or UI wording changed in this fixture correction.

Repeated local validation: proxy-accounts.test.ts, proxies.test.ts and the gateway management tests passed together three consecutive times (24 tests, 177 assertions per run); the management integration and gateway tests also passed in an initial focused run. Typecheck, lint and format:check passed after the fixture correction.

@nixuuu
nixuuu added this pull request to stack #754 November 14, 2026 20:24
@nixuuu
nixuuu marked this pull request as ready for review November 14, 2026 20:46
@nixuuu
nixuuu force-pushed the fix/blur-proxy-account-emails branch from 548f2f9 to 66b5bb4 Compare November 14, 2026 20:55
@nixuuu
nixuuu force-pushed the fix/blur-proxy-account-emails branch from 35dfb88 to b38e777 Compare November 14, 2026 21:24
@nixuuu
nixuuu merged commit 344d2b0 into dev Nov 14, 2026
11 checks passed
@nixuuu
nixuuu deleted the fix/blur-proxy-account-emails branch November 14, 2026 21:41
nixuuu added a commit that referenced this pull request Nov 14, 2026
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

- The domain owns one source-documented weight table and pure
aggregation. Missing/expired/nonnumeric readings do not enter a window's
denominator. Reporting counts make incomplete coverage explicit.
- Disabled, sign-in, error and unknown account states are excluded.
Cooling accounts or accounts with any current reached limit have zero
available units in their measured windows, preserving the denominator
until fresh data arrives.
- Unknown weights count as ×1 and are marked “Unknown plan”; known
subscription labels remain visible even when their capacity ratio is
unverified. Legacy Claude Max 5x/20x labels use the current names
Max/Ultra. Empty window lists stay empty. Unknown periods remain in
account details and never enter a provider aggregate; standard periods
combine older cache entries without duration metadata.
- Only Claude, Codex and Grok are shown. Unsupported identities and
subscriptions are excluded from Settings → Proxies, the popover,
summaries and the indicator; only their count remains.

## Subscription research — 2026-11-14

| Provider | Applied weights | Source and limits |
| --- | --- | --- |
| Claude | Pro ×1; Max/Max 5x ×5 for 5-hour and weekly; Ultra/legacy Max
20x ×10 weekly |
[Max](https://support.claude.com/en/articles/11049741-what-is-the-max-plan),
[Ultra](https://support.claude.com/en/articles/17728952-what-is-the-ultra-plan).
Verified Ultra has no 5-hour limit; no absent window is invented. Other
window/plan combinations are unverified. |
| Codex | Plus ×1; other plans use flagged ×1 fallback | [Current Pro
tiers](https://help.openai.com/en/articles/9793128-about-chatgpt-pro-tiers),
[pricing](https://learn.chatgpt.com/docs/pricing). Current Pro
100/200/500 allowances have changed, and these current pages do not
publish a numerical ratio to Plus. Generic `pro` cannot identify a price
tier. Explicit Pro 100/200/500 plan names are additive enum values; no
price or capacity is inferred from a token. |
| Grok | Flagged ×1 fallback for proxy API limits |
[Pricing](https://x.ai/pricing), [usage
limits](https://docs.x.ai/x-subscription/usage-limits). Consumer
Plus/Premium/Super/Ultra weekly pools advertise ×1/4/15/50, but API
usage is billed separately and does not draw from that pool. Those
ratios are not applied to proxy API observations. |

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.
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
nixuuu added a commit that referenced this pull request Nov 15, 2026
## Change

Center proxy account emails vertically with their provider icons in
Settings → Proxies. The identity container now uses flex layout,
removing the extra inline baseline space that placed the email 3.5 px
above the icon. Alignment stays consistent when revealing a hidden email
or truncating a long address. Updated `docs/proxies.md` and its status
line.

## Verification

- Passed: `bun run lint --
apps/web/src/lib/features/proxies/ProxyAccountRow.svelte`, targeted
formatting, and `git diff --check`.
- Inspected the actual component in Chromium with synthetic account
data: light/dark, widths 360, 390, 768 and 1280 px,
short/typical/long/empty identities, hidden and revealed values. Email
and icon centers match; long addresses truncate correctly. No browser
errors.
- Full repository checks and builds are left to GitHub CI. No UI test
suite added.

Copy audit: no UI wording changed.

Fixes: #751
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