Repository navigation
fix(proxies): share account reads before acquiring the lease - #745
Merged
Merged
Conversation
nixuuu
added a commit
that referenced
this pull request
Nov 14, 2026
nixuuu
added a commit
that referenced
this pull request
Nov 14, 2026
nixuuu
added a commit
that referenced
this pull request
Nov 14, 2026
nixuuu
added a commit
that referenced
this pull request
Nov 14, 2026
## 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
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.
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.
Saving a management key starts a background accounts read. A concurrent
RefreshProxyAccountscould lose the database lease and return an empty account state in two orderings: while the winner was acquiring its lease, or after a stale target lookup outlived the completed winner. Register the shared promise before claiming the lease and reload the committed snapshot after a refused claim. Keep cached and forced refresh decisions unchanged.The original proxy test and its assertions are unchanged. Add a regression with explicit target/lease gates that holds a stale lookup until the winning refresh has committed. Restoring the stale-snapshot fallback makes this regression fail deterministically with an empty account state; restoring the fix makes it pass.
For the Claude usage test, coordinate the fake CLI and WatchThread explicitly: the CLI announces turn admission, then waits for the watch's initial snapshot before emitting the existing limit events and result. The existing 10-second watch budget and 60-second test budget are unchanged, as are all five assertions. Include the caller's proxy credential variable in fixture environment isolation so native plan reporting remains enabled in developer/agent shells.
Repeated focused runs
All runs used
nice -n 10, with temporary files under a private directory in/var/tmp. Each 200-run sample consists of four batches of 50 using--rerun-each=50and the exact test-name filter.The proxy baseline failures returned
state: "",total: 0rather than the sanitized account snapshot, matching the fast CI failure. The Claude cancellation in Release run 43622538704 was not reproduced locally; ten additional runs with the preceding gateway-restart test also passed. Its change removes scheduling of CLI startup and stream subscription from the timed event-observation phase; it does not claim a provider product fix.Standalone Docker-per-iteration baselines also encountered 12 proxy and 4 Claude teardown-hook timeouts, separate from the test-body counts above. Final repeated runs and focused files use the repository's
check:tmprunner, which shares PostgreSQL across iterations and checks cleanup.Validation
nice -n 10 bun installnice -n 10 bun run typechecknice -n 10 bun run lintnice -n 10 bun run format:checknice -n 10 bun run check:tmp tests/integration/proxy-accounts.test.ts tests/integration/provider-usage.test.ts tests/integration/provider-usage-bots.test.ts— 16 passed, 0 failed; no temp directories leftFixes: #727
Related: #697