Skip to content

fix(providers): hide plan limits for proxy and endpoint instances - #725

Merged
nixuuu merged 1 commit into
devfrom
fix/proxy-usage-limits
Nov 14, 2026
Merged

nixuuu merged 1 commit into
devfrom
fix/proxy-usage-limits

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 14, 2026

Copy link
Copy Markdown
Member

Harness rate limits through a proxy, an API key or a custom endpoint describe whichever upstream account the endpoint picked, not the user's plan. Before this change, Settings → Providers showed a "Weekly · 1% used" meter on one worker of a CLIProxyAPI-backed Codex instance.

  • Worker: reportsPlanUsage turns off usage reports and failure-code enrichment for cliproxyapi instances and for instances whose env has an API key or base URL (ANTHROPIC_*, OPENAI_*, CODEX_*, CLIPROXY_API_KEY).
  • Gateway: ProviderUsage.report/read accept and return only native instances without a proxy (instance or worker override), so older workers can't bring the meters back.
  • Migration 0143_provider_usage_endpoints deletes stored snapshots of such instances.
  • Failure card: kept for real limit failures. Through a proxy it no longer names a plan window, and the explanation reads "The proxy reported a usage limit…". Mobile TurnEnd now gets proxy, matching web.
  • Docs: docs/provider-accounts.md.

Fixes: #697

Tests

  • tests/integration/provider-usage.test.ts: a proxy instance never exposes or stores plan windows. Its limit failure names no plan window, and an older-worker report is dropped. I checked that this test fails without the worker change.
  • Also run: packages/db/test/schema.test.ts, provider-usage-bots.test.ts, proxies.test.ts, gen:check, typecheck, lint, format:check, web build, mobile export (android, ios).

Copy audit (§8)

Before After Reason
(proxy) "Weekly limit reached · resets …" "Usage limit reached" The window belongs to an unknown upstream account
(proxy) "A usage or turn limit was reached. Wait for it to reset or check your plan, then retry." "The proxy reported a usage limit. Wait for it to reset or check the proxy's accounts, then retry." Doesn't claim the user's plan. Says what happened, then what to do. Two sentences, each ≤ 13 words. Uses "proxy" from the glossary.

Harness rate limits through a proxy, an API key or a custom endpoint belong to
whatever upstream account the endpoint picked, so they never describe the
user's plan. The worker no longer reports them or puts a plan window into the
failure code, the gateway drops and hides such reports from older workers,
and migration 0143 clears stored snapshots. The limit failure card stays,
worded as a proxy limit.

Fixes: #697
@nixuuu
nixuuu force-pushed the fix/proxy-usage-limits branch from 61e07e8 to 8f0902c Compare November 14, 2026 15:10
@nixuuu
nixuuu merged commit 48065ce into dev Nov 14, 2026
11 checks passed
@nixuuu
nixuuu deleted the fix/proxy-usage-limits branch November 14, 2026 15:22
nixuuu added a commit that referenced this pull request Nov 14, 2026
Adds `render_html` beside `render_visual`, storing HTML as an immutable,
owner-scoped visual version. The existing item, GetVisual,
expected_version, citation and export pipeline remains the source of
truth. Old clients reject kit version 2; workers and gateways negotiate
`thread_html_v1` additively.

The shared compiler rebuilds untrusted HTML, attempts to remove embedded
documents, navigation attributes, inline handlers and external/module
scripts, and prefixes each classic script with lockdown before hashing
it. Removal is best-effort: parser differences and reparsing can restore
markup (mXSS); CSP is the execution/resource boundary. Foreign
MathML/SVG style elements are additionally discarded. Script CSP is
hash-only; there is no unsafe-eval or unsafe-hashes. The trusted shell
also restricts child navigation. Web/mobile residual network risk is
explicitly accepted: matching-SRI external scripts and DNS hints can
still send data. Desktop adds a separate network-denied browser process
in #718.

Validation: install, generation, typecheck, lint and formatting passed.
The focused compiler/inbox/migration/gateway/harness run passed 58
tests. Tests cover pre-parse/UTF-8 limits, CSP hashes, stripped
permissive metas, script-only sandbox, cyclic/invalid/flooded messages,
owner scoping, version conflicts and format preservation. Migration is
now **0144_thread_html** (file, index and schema expectation), following
dev's 0143 from #725. The CLIProxyAPI stack moves to 0145; this stack
merges first. Protocol remains additive.

Security review fixes: the CSP meta, style and bootstrap scripts are
inserted as parse5 tree nodes. Regression tests cover `<html
data-x="<head>">`, a leading `<!-- <head> -->`, and `</body>` text in
attributes/comments: exactly one CSP meta is first in the real head and
every executable script has an authorized hash. Gateway publishing
applies the same depth100/script64 limits as clients; rejected documents
leave no stored version. The shell relay forwards only
`JSON.parse(text).message`; an 8 MiB ArrayBuffer regression proves the
original clone is not forwarded. Shared iframe permissions explicitly
deny PiP and clipboard features.

The focused security/gateway/three-harness run passed 38/38; channel
identity tests passed 3/3. Per-platform probe evidence is recorded on
#718, including the DNS positive control and protected result. The
independent security re-check recommended merge. Copy audit: no new UI
copy in this layer; tool instructions state inline-only code,
addEventListener, size/script/depth limits, theme variables and no
secrets.

Previous-head full check:tmp was green in [CI run
43605016001](https://github.com/itsoltech/canopy/actions/runs/43605016001),
head `cc18c0b7d86ae78ddd7d1cdff1af221107910367`.

Pre-merge update: rebased onto origin/dev including #723, #725 and #730,
preserving the new visual kit/gallery compiler and provider migration.
The shell's own hash-authorized script now starts with the shared
network lockdown, including when copied into a fresh realm. Only the
trusted mobile shell retains its own message bridge; opaque agent realms
have none and also remove ReactNativeWebView. Regression tests exercise
web/native relay, locked RTC/fetch properties, the shell hash prefix and
MathML/SVG reparsing with script-src-attr none. Final-head checks:
schema/compiler 51/51, visuals/three-harness integration 16/16, both
with empty temp directories; gen:check, full typecheck, lint and
format:check passed. Immediately before the final push, origin/dev was
re-fetched at d2af937 and its highest migration confirmed as 0143.
New-head full CI is pending. All four PRs are ready, as requested; no
merge performed.
nixuuu added a commit that referenced this pull request Nov 14, 2026
Offers `render_html` through the shared tool catalog on Claude Agent
SDK, Codex app-server and Grok ACP. The worker announces
`thread_html_v1`; an older gateway gets an actionable update response
instead of an unknown-tool call.

Validation: fake adapters for all three harnesses publish HTML through
WorkerLink into PostgreSQL. Existing component-tool coverage is
retained. The focused compiler/inbox/migration/gateway/harness run
passed 58 tests; install, generation, typecheck, lint and formatting
passed.

Security/gateway/three-harness run passed 38/38, including fake adapters
publishing through WorkerLink. Platform probes are recorded on #718.
Gateway depth100/script64 errors reach the tool before storage. The
independent security re-check recommended merge. Copy audit:
model-facing description prefers components for standard
charts/cards/tables, requires addEventListener rather than inline
handlers/eval, inline libraries/assets, no network or secrets, bounded
documents and Canopy theme variables. No UI copy changes in this layer.

Previous-head full check:tmp was green in [CI run
43605016001](https://github.com/itsoltech/canopy/actions/runs/43605016001),
head `cc18c0b7d86ae78ddd7d1cdff1af221107910367`.

Pre-merge update: rebased onto origin/dev including #723, #725 and #730,
with render_html migration 0144 after the provider migration 0143. The
shared compiler/shell P3 fixes and regression evidence are described in
#716 and #718. Final-head schema/compiler tests: 51/51;
gateway/three-harness visuals integration: 16/16; both temp checks
clean. Generation, typecheck, lint and formatting passed. New-head full
CI is pending. All four PRs are ready; no merge performed.
nixuuu added a commit that referenced this pull request Nov 14, 2026
HTML visuals run inside an opaque `sandbox="allow-scripts"` iframe, with
hash-only scripts prefixed by lockdown. The card identifies agent
content and warns against entering passwords or secrets. Web and mobile
require an explicit **Run**; desktop requires opening a separate viewer.
The main window CSP is unchanged.

### Independent security review fixes

- CSP and bootstrap insertion now uses parse5 tree nodes. Regression
tests cover `<head>` inside an HTML attribute and a leading comment, and
misleading `</body>` text. Exactly one CSP meta is first in the actual
head; every executable script is hashed. Downloads include CSP and
lockdown.
- The shell forwards only the JSON-checked copy, never the original
structured-clone object. A regression test sends an 8 MiB ArrayBuffer
and verifies it cannot reach the parent relay.
- Gateway publishing rejects depth >100 and >64 scripts before storing a
version. Both frames deny PiP, clipboard, capture and other permissions
explicitly.
- HTML does not auto-run on web/mobile. A watchdog failure persists
across reactive updates; explicit Retry is required.
Revisiting/remounting starts at Run again. Same-process engines can
still freeze their host after Run; the watchdog cannot guarantee
recovery there.
- Desktop fixes the native title, compiles in a worker thread with
bounded heap/time, and serves the compiled document at a private session
protocol URL rather than a size-limited data URL.

### Desktop DNS boundary

The DNS finding reproduced: runtime `dns-prefetch` escaped CSP, proxy
and webRequest. A renderer additionalArguments Blink flag did not
reliably reach the renderer and did not stop it. The viewer therefore
runs in a **separate Electron browser process**, configured before ready
with `host-resolver-rules=MAP * ~NOTFOUND`. The network boundary is the
resolver rules plus the refusing proxy plus webRequest cancellation. The
unsupported `disable-network-prediction` switch has been removed. This
applies to every viewer frame without changing the main app's flags,
session or CSP. The independent security re-check verified the resolver
block and judged it sufficient.

The child retains a dedicated ephemeral session with deny proxy, request
cancellation, denied permissions/devices/downloads/navigation/popups and
`disable_non_proxied_udp`. It receives only bounded source, title and
theme through private process IPC and a curated OS/display environment.
It has no app services, app profile or credentials. One viewer is
allowed; parent exit closes it and its temporary profile is removed.

### Review-fix probes

Electron 45.2.1, Linux, headless Ozone; actual viewer/compiler
implementation:

| Probe | Observed result |
|---|---|
| Runtime dns-prefetch and preconnect via rel/href properties,
setAttribute, innerHTML and template insertion | Positive control
recorded speculative HOST_RESOLVER_MANAGER_REQUEST/JOB events for a
unique canary. Final protected run: `DNS_CANARY_EVENTS []`. |
| Matching-hash/SRI external script, remote image, fetch, RTC |
`HTTP_CANARY_REQUESTS []`; image CSP violation; fetch/RTC undefined and
calls throw TypeError. |
| canvas.captureStream → video.requestPictureInPicture with user
activation | SecurityError: disallowed by Permissions Policy. |
| Agent document.title mutation | Native title stays `Custom HTML from
the agent — Canopy`. |
| 524236-byte source expanding beyond 2 MB when compiled | Actual
production sidecar renders 524188 text characters, first head child is
CSP, RTC undefined, protocol URL length 63. Healthy frame survives 11
seconds without a false watchdog. |
| while(true) in actual production sidecar | Watchdog terminates all
owned frame renderer PIDs, including the hung OOPIF, destroys the old
window and opens one safe warning window. CDP returns `This visual
stopped responding.` |

DNS evidence uses Chromium netlog with a positive control, **not packet
capture**: tcpdump was unavailable and privileged capture was not
available. It demonstrates no canary resolver events in the protected
run; it is not a claim of observing port 53. The direct diagnostic
harness used `--no-sandbox`; the actual production sidecar
startup/large-document/loop probes ran without that flag in the child.

### Earlier compiler/shell probes retained

Chromium 155.0.8059.84 against the actual compiler/shell:

| Attempt | Observed result |
|---|---|
| fetch, XHR, WebSocket, EventSource, WebTransport, beacon,
mediaDevices, listed RTC constructors | Removed/locked; fetch and RTC
calls throw TypeError. |
| cookie, top navigation, popup | SecurityError, SecurityError, null. |
| Remote image, form submit, self navigation | No canary HTTP request;
trusted parent's frame-src blocks self navigation. |
| eval, Function, string timer, inline handler, blob import | EvalError
/ no execution / TypeError. |
| Worker | CSP blocks execution. |
| object/embed, data/blob frames | CSP blocks loading. |
| Nested srcdoc and empty srcdoc/about:blank | Realms can exist; parent
access throws SecurityError and arbitrary unapproved scripts do not
execute. |
| Exact authorized script copied into nested srcdoc | Lockdown runs in
that realm; RTC is undefined. |
| document.write into nested realm | SecurityError. |
| Agent permissive CSP meta | Does not widen policy. |
| parent.postMessage spam | No host action; inbox tests validate rate
limits and invalid/cyclic messages. |
| Matching hash + SRI external script on ordinary web | **Accepted
residual risk reproduced:** GET containing user-input canary reaches the
server. |

Web/mobile also retain DNS-hint, pastejacking, file-export and
same-process engine risks, documented in Polish in docs/agent-visuals.md
§9. Source, cache and live-frame counts are bounded; no hard browser
renderer memory quota is claimed. Exported HTML includes CSP/lockdown
but executes JS outside the Canopy iframe sandbox when opened as a file.

### Validation

Install, gen:check, full typecheck (Svelte: zero errors/warnings), lint,
format:check, focused security/gateway/three-harness tests (38/38),
channel identity tests (3/3), web build and iOS/Android exports passed.
Fingerprints remain iOS `138e0c6b171c82b4933e86808cdfef56da73b8c6`,
Android `906dc944f94eb8333fa384ed9f198834fdd30d13`.

**Previous-head full check:tmp was green in [CI run
43605016001](https://github.com/itsoltech/canopy/actions/runs/43605016001)**
on `cc18c0b7d86ae78ddd7d1cdff1af221107910367`: all four check:tmp shards
passed, and the final job verified that every test file actually ran
exactly once. Static checks and web/Linux build were green too. The
redundant local full run was interrupted after this complete CI result;
it is not claimed as a local full-suite success.

Actual VisualFrame fixture reviewed in Chromium at 1280px/390px,
light/dark: no iframe before Run; counter increments after Run; warning
wraps within the card. A button-triggered infinite loop shows the
stopped warning; resizing does not remount, and remounting the component
shows Run with no iframe. Screenshots were inspected. The fixture is
isolated from a gateway; this does not certify an authenticated
timeline, long-title header, or version-picker flow. Native iOS/Android
hostile-document probes remain unverified; mobile exports do not
establish native runtime behavior. The independent security re-check
recommended merge.

Pre-merge update: rebased onto origin/dev including #723, #725 and #730,
with render_html migration 0144 after the provider migration 0143. The
shell's hash-authorized executable now begins with network lockdown,
preventing its inherited hash from authorizing an unlocked fresh realm.
Markup removal is best-effort: MathML/SVG and browser reparsing can
recreate removed elements/attributes (mXSS), so CSP, not sanitization
completeness, is the boundary. Foreign-content style nodes are
additionally stripped. Regression tests check the retained restrictive
policy, absence of reparsed handlers, shell prefix/hash, immutable
RTC/fetch removal in a fresh VM realm and preserved trusted native
relay. Final-head schema/compiler: 51/51; gateway/three-harness visuals
integration: 16/16, both temp checks clean. Generation, full typecheck,
lint and formatting passed. The pinned Electron binary contains the
host-resolver-rules switch token, with no disable-network-prediction
token found. New-head full CI is pending. All four PRs are ready; no
merge performed.

Copy audit (§8): **Run** is the explicit action that starts agent JS.
“Custom HTML from the agent. Don't enter passwords or secrets.”
identifies the source and gives one concrete instruction. “This visual
stopped responding.” names the failure and retains an explicit Retry.
Desktop's action describes opening a separate window. No jargon, humor
or color-only meaning in these strings.
nixuuu added a commit that referenced this pull request Nov 14, 2026
HTML visuals now start as an inert warning card with an explicit **Run**
action. No HTML compilation or WebView mount occurs before Run. Watchdog
failure requires explicit Retry; revisiting/remounting starts inert
again. The existing WebView shell and per-mount token envelope use the
same hash-only CSP, lockdown and explicit denied-feature permissions as
web. Existing fullscreen, version picker, citations and save/share HTML
use the shared visual pipeline.

No native modules, native patches or WebView upgrade. Baseline/current
fingerprints match exactly: iOS
`138e0c6b171c82b4933e86808cdfef56da73b8c6`, Android
`906dc944f94eb8333fa384ed9f198834fdd30d13`. Both platform exports
passed.

### Platform evidence and accepted gaps

| Platform | Evidence |
|---|---|
| Web | Chromium 155 hostile-document probes on the renderer PR: opaque
isolation, hash/eval restrictions, denied known networking APIs, nested
realm tests and responsive host under an infinite loop. Matching-SRI
external-script request remains an accepted exfil path. |
| Desktop | Electron 45.2.1 separate browser process with resolver
denial: runtime dns-prefetch/preconnect produce no canary resolver
events; image/fetch/RTC/matching-SRI attempts produce no canary HTTP
requests; canvas PiP throws SecurityError. Production sidecar loop
recovery and >2MB compiled-document probes passed. Measurement details
and limitations are on #718. |
| iOS / Android | **Device probes not run.** device_open failed with
“Device list failed: Could not communicate with device support. Try
refreshing devices.” One refresh returned the same error. JS exports and
shared shell tests do not substitute for WKWebView/Android WebView
runtime probes. |

As explicitly agreed, mobile accepts the browser residual network risk.
RN WebView 14.0.1 exposes neither Android subresource interception nor
iOS WKContentRuleList. File/universal access off, incognito, blocked
navigation, no shared cookies/storage/windows and the token envelope are
retained. iOS mediaCapturePermissionGrantType denies capture. On Android
the library can auto-grant camera/microphone permissions already granted
by the OS; lockdown mediaDevices and the opaque iframe permissions
boundary are the available defenses without a native change. A hard
network block and complete native permission denial require a later
native build. These gaps are documented in Polish in
docs/agent-visuals.md.

Focused security/gateway/three-harness checks passed 38/38. iOS/Android
exports passed after review fixes; fingerprints above remain unchanged.
Validation is recorded on #718. The independent security re-check
recommended merge. Native hostile-document probes and native
light/dark/phone-width acceptance remain unverified. No hard renderer
memory quota is claimed. Same-process WebViews can freeze the app after
Run, preventing the watchdog from firing; click-to-run prevents
automatic re-entry on later visits. DNS hints, matching-SRI
exfiltration, pastejacking and exported-file execution remain documented
browser/mobile risks.

Copy audit (§8): **Run** explicitly starts execution. “Custom HTML from
the agent. Don't enter passwords or secrets.” gives source plus a direct
instruction, plain English, no jargon or humor. “This visual stopped
responding.” reuses the existing Retry action. Theme-aware text colors
and app-owned framing preserve meaning without depending on color.
Device layout/accessibility review remains blocked, not claimed as
passed.

Previous-head full check:tmp was green in [CI run
43605016001](https://github.com/itsoltech/canopy/actions/runs/43605016001),
head `cc18c0b7d86ae78ddd7d1cdff1af221107910367`.

Pre-merge update: rebased onto origin/dev including #723, #725 and #730,
with render_html migration 0144 after the provider migration 0143. The
shell executable now starts with shared network lockdown while retaining
its trusted native message bridge; the native/web relay regression
passes in both modes. Markup stripping is best-effort and CSP remains
the boundary against mXSS; foreign MathML/SVG style nodes are discarded.
No native change. Final-head schema/compiler tests: 51/51;
gateway/three-harness visuals integration: 16/16, both temp checks
clean. Generation, full typecheck, lint and formatting passed. New-head
full CI is pending. All four PRs are ready; no merge performed.
nixuuu added a commit that referenced this pull request Nov 14, 2026
Stage 1 of 2: the gateway reads a CLIProxyAPI proxy's upstream accounts
through its management API. Base: dev (#725 merged, 0143 on dev).
Migration 0145 (0144_thread_html is on dev).

- **Credential:** an optional **management key** per CLIProxyAPI proxy
(`SaveProxyRequest.management_key`). Omitted keeps it, empty removes it.
It's encrypted like the proxy secret (`proxies.management_secret_id`,
migration `0145_proxy_management`).
  - Only `Proxy.management_key_set` is returned.
- The key never reaches workers, models, logs, linked-computer sync or
the audit (`proxy.management_key_replaced/removed`, no values).
- **Read:** `GET <root>/v0/management/auth-files` (CLIProxyAPI v8.0.x)
with a Bearer header, `redirect: "error"`, a 10 s timeout, a 4 MiB body
cap and a 200-account cap. The response is decoded with a schema at the
boundary, and entries with the wrong type are skipped.
- Text is sanitized: control characters and `<>` removed, credentials
redacted, length capped.
- Status (`active`, `cooling_down`, `disabled`, `sign_in`, `error`),
cooldown end, success/failure counts.
- Passive limit windows come from the Codex `x-codex-*` and Claude
`anthropic-ratelimit-unified-*` headers the proxy saw.
  - `usage-queue` is not used, because it pops records from the queue.
- **States:** `ok`, `no_key`, `unauthorized`, `remote_disabled`,
`unavailable`, `unreachable`, `invalid_response`. The proxy itself keeps
working in every state.
- **Polling (`ProxyAccountsMonitor`, in memory):**
- `RefreshProxyAccounts` on view open reuses a read under 60 s old.
`force` (Refresh button) reads at most every 5 s.
- Proxies that have a key and are used by a profile are checked every 5
min, backing off to 1 h after failures.
  - A new key or URL reads again.
- CLIProxyAPI bans an address for 30 min after five wrong keys, so
`unauthorized`, `remote_disabled` and `no_key` are never retried
automatically.
- **Delivery:** `OverviewUpdate.proxy_accounts = 831` carries one
proxy's accounts. `OverviewInvalidation` patches the shared
`ListProxies` cache in place on web and mobile. BFF: `POST
/api/proxies/accounts`.
- **Proto (additive only):** `ProxyAccount`, `ProxyAccounts`,
`RefreshProxyAccountsRequest`, `Proxy.management_key_set = 9`,
`Proxy.accounts = 10`, `SaveProxyRequest.management_key = 8`, `rpc
RefreshProxyAccounts`.
- **Docs:** `docs/proxies.md` (Konta upstream), `docs/ui-api.md`.

## Tests
`tests/integration/proxy-accounts.test.ts` runs against a fake
management server. It covers:
- parsed and sanitized accounts (including hostile HTML, control
characters and tokens), plus an incremental push;
- no repeat request within the fresh window;
- the key absent from RPC responses, the database (ciphertext) and the
audit;
- a wrong key read once and never retried on its own;
- remote management turned off, an oversized body, a non-JSON body and
an unreachable host;
- no key;
- owner scoping;
- the periodic check reading only proxies in use.

Also run: `proxies.test.ts`, `schema.test.ts`, gen:check, typecheck,
lint, format:check.

## Security review fixes
- **Echoed secrets:** the exact management key and proxy secret are
redacted from every account text field before truncation, raw,
URL-encoded, base64 and base64url. A proxy that echoes a key in `email`,
`label`, `status_message` or `id` cannot hand it to clients. Tested with
a fake server echoing each form in each field.
- **Bounded bodies:** every body, including a 403, goes through a
bounded reader. Only a 512-byte prefix of an error is read and the rest
is cancelled. Tested with an endless 403 body.
- **Persisted state:** the last read is stored with the proxy
(`management_status`) together with the key/URL identity it used (`<key
secret id>|<url>`). A rejected key stays rejected across restarts and
gateway processes until the key changes or Refresh is pressed.
- **Cross-process lease:** a lease in the same row
(`management_read_at`, `management_read_identity`) lets one process
start a read of an identity at most once per 60 s, or 5 s for Refresh.
Tested with fresh monitors (a restart and a second process) after a
rejection, and with two monitors racing for one read.
- **Other processes:** `proxies_changed` now also reflects reads made by
another gateway process.
nixuuu added a commit that referenced this pull request Nov 14, 2026
Stage 2 of 2, on #727. UI for CLIProxyAPI upstream accounts on web and
mobile.

- **Settings → Proxies (web):**
- A **Management key** field for CLIProxyAPI proxies (optional;
Replace/Clear like other secrets).
- **Accounts** on the proxy card: compact rows with the provider mark,
account (truncated), status badge, the limits the proxy last saw (the
same meters as plan limits), cooldown end and last message (two lines at
most), **Refresh** and "Checked …".
- Without a key, or in an error state, one short hint instead of the
list. Texts render as text only.
- **Settings → Providers (web):** a proxy-backed instance shows "Through
<proxy> · 2 Codex accounts · 1 cooling down", with a link to the proxy
card. It replaces the plan meters #725 removed.
- **Mobile, read-only:**
- The proxy row lists accounts with status, limits and message, plus
Refresh accounts.
  - Provider instance rows add the "Through …" line.
  - JS only, so the OTA fingerprint is unchanged.
- Shared labels, hints and summary: `@canopy/domain/proxy-accounts`.
- The view reads once on open (the gateway answers from a read under 60
s old). Changes arrive incrementally through
`OverviewUpdate.proxy_accounts`.
- Docs: `docs/proxies.md` (UI), `docs/copy.md` glossary (`proxy
account`, `management key`).

## Browser review
Reviewed on a separate review machine, with a fake CLIProxyAPI giving 6
accounts:
- typical and very long emails, a long cooldown message, HTML and a
token in a message;
- Codex and Claude limit headers;
- Gemini and Grok accounts.

Checked in light and dark, at 1280 px and a 390 px phone width:
- no horizontal scroll;
- long names truncate;
- messages clamp;
- the badge stays on the right without shifting rows;
- Refresh shows progress only when pressed.

The review found two problems, both fixed in this stack:
- The on-open read re-fired when its own result updated the proxy
object. It's now keyed on a primitive; one request per open, verified
with resource timing.
- Proxy messages showed tag remnants. The gateway now strips whole tags
(#727).

## Checks
gen:check, typecheck, lint, format:check, web build, `expo export`
(android, ios). Tests: `proxy-accounts`, `proxies`, `provider-usage`,
`provider-usage-bots`, `schema`, domain and worker unit tests. No UI
tests, per policy.

## Copy audit (§8)
| Before | After | Reason |
| --- | --- | --- |
| (none) | Field "Management key": "Optional. Lets Canopy show the
proxy's accounts and their status. Encrypted in the gateway." | Says
what it does, then where it's kept. New glossary term. |
| (none) | "Accounts · 6", "Checked just now", "Showing 20 of 240.",
"The proxy has no accounts yet." | Short; no repeated facts. |
| (none) | Badges: Active, Cooling down, Off, Sign in again, Error |
Sentence case. Each badge has text, so color is never the only cue. |
| (none) | "Add a management key to see this proxy's accounts." | What
to do, in one sentence. |
| (none) | "The proxy rejected the management key. Replace it, then
refresh." | What happened, then what to do. |
| (none) | "The proxy allows management only from its own computer. Turn
on remote management there." | Plain words instead of
`allow-remote-management`. |
| (none) | "The proxy's management API is off or unavailable." / "Canopy
could not reach the proxy's management API." / "The proxy sent an
account list Canopy cannot read." | Errors without raw bodies. |
| Plan meter on a proxy instance | "Through Team proxy · 2 Codex
accounts · 1 cooling down" | Names the proxy; the counts are about its
accounts, not the user's plan. |

Glossary: added `proxy account` (not "auth file" or "credential") and
`management key` (not "admin key").

## Also
- Mobile bot-chat failure card gets the proxy wording for proxy
instances (web already had it).
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