Repository navigation
fix(web): show usage and switch Claude/Codex accounts from the paired server - #25133
gustavobragac wants to merge 2 commits into
Conversation
The web client stubbed rateLimits, claudeAccounts and codexAccounts, so the status-bar Usage menu stayed empty and account switching was a no-op. Back them with the server accounts.list / accounts.subscribe / accounts.select* RPCs.
There was a problem hiding this comment.
Important
Three things to address before merge: the changed-code quality gate goes red on type assertions in this diff, switching Codex to "System default" on a WSL lane mutates the wrong lane, and the new usage stream dies permanently after a manual disconnect.
Reviewed changes
- Web usage bridge —
web-rate-limits-api.tsreplaces the empty stubs withaccounts.list({ refreshUsage })reads and a sharedaccounts.subscribestream, publishingsnapshot.rateLimitstoonUpdatelisteners. - Web account bridge —
web-agent-accounts-api.tslists Claude/Codex accounts from the server snapshot and forwardsselect/removeto the matchingaccounts.*RPCs. - Tests — new
web-preload-api-rate-limits.test.ts(7 cases) covering reads, refresh, fallback, streaming, resubscribe and selection.
The approach is sound and the tested read/stream paths behave as described; the findings below are the concrete fallout I could verify.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe web rate-limits API now reads usage snapshots from the paired server and publishes updates from its subscription. It retries failed subscriptions and stops them after the final listener unsubscribes. The Claude and Codex account APIs now list accounts from snapshots and use runtime RPCs for removal and selection. Successful selection triggers a rate-limit refresh. Tests cover these reads, updates, subscription behaviors, and account operations. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The inspected usage-stream cleanup and account-removal update paths do not present a merge blocker. The PR is ready for normal merge checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The browser now performs account operations on its paired server. Inspected paths retain pairing checks, server-owned account mutations, and safeguards against switching the wrong runtime. No new authorization bypass was established, but concurrent recovery behavior and compatibility with older servers are not fully verified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 5.26% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 3 files. (1 skipped: 1 unsupported.)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Route a WSL Codex selection through accounts.selectCodexForTarget so a system-default switch clears that lane, not the host lane. - Refuse a WSL Claude system-default switch on the web: no targeted RPC exists and the server would read it as the host lane. - Start the accounts.subscribe stream inside the promise chain so a manually disconnected server cannot leave it stuck until reload. - Replace type assertions with checked narrowing.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed only the new commit e23f9d5 since the prior pullfrog review. It resolves every earlier finding and adds regression coverage for each.
- WSL Codex lane switching —
codexAccounts.selectnow forwardsruntime/wslDistroand routesruntime === 'wsl'toaccounts.selectCodexForTarget, so switching a WSL lane to "System default" no longer clears the host lane. - WSL Claude refusal —
claudeAccounts.selectrejects anullselection on a WSL lane with a translated error, since no targeted Claude select RPC exists; a concrete account id still reaches the server, which infers the account's own lane. - Usage stream recovery —
startStreamnow resolves the client inside the promise chain with.catch/.finally, so a manually disconnected server resetsstreamStartingand a later reconnect resubscribes instead of leaving the stream dead. - Test hardening — the type assertions the changed-code gate flagged are replaced with type guards and a
RuntimeRpcFailurehelper, plus tests for WSL Codex targeting, the Claude WSL refusal, and stream reopening after a disconnect.
Verified locally: check:code-quality:changed reports 0 new findings versus 20dc6c74f5, the 10 tests in web-preload-api-rate-limits.test.ts pass, and typecheck:web plus the localization extraction/coverage checks pass.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
…7135) The web client's usage and Claude/Codex account bridges were stubs, so the status-bar usage bars never appeared and switching accounts did nothing. Back them with the server's existing accounts.list / accounts.subscribe snapshot (which already carries rate limits) and its select/remove RPCs. Adding or re-signing accounts now fails with a reason instead of silently returning an empty roster. Harvests the approach and tests from #25133 by @gustavobragac. Co-authored-by: m4air <[email protected]> Co-authored-by: gustavobragac <[email protected]>
|
Thanks @gustavobragac! This approach and most of its tests landed in #27135 (credited as co-author), with a few additions: the last usage is kept when a refresh fails, refreshes made at the same time share one request, and add/sign-in-again are refused with a reason. Closing as superseded. |

ELI5
When you use Orca from a web browser, the bottom bar never showed how much of your Claude or Codex quota you had used, and picking a different Claude account did nothing. The server always knew these numbers, but the web page never asked for them. Now the web page asks the server, shows the same usage bars as the desktop app, and account switches are applied on the server.
What Changed
Before: in the paired web client, the status bar had no usage bars, the Usage menu was empty, and the Claude/Codex account switcher listed nothing and switched nothing.
After: the web client shows the server's usage per provider, stays up to date as the server publishes changes, refreshes on demand, and lists and switches the server's Claude and Codex accounts.
Mechanism: the web client keeps
activeRuntimeEnvironmentIdasnull, because it talks to its paired server directly. So the renderer reads usage and accounts through the "local" bridges,window.api.rateLimits,window.api.claudeAccountsandwindow.api.codexAccounts. On the web those bridges were stubs that returned empty state. This PR backs them with RPCs the server already exposes to paired clients:rateLimits.getaccounts.list { refreshUsage: false }→snapshot.rateLimitsrateLimits.refresh,refresh*ForTarget,fetchInactive*Accountsaccounts.list { refreshUsage: true }(also refreshes inactive accounts on the server)rateLimits.onUpdateaccounts.subscribestream, started with the first listener, stopped with the last, resubscribes 5s after the stream dropsclaudeAccounts/codexAccountslist,select,removeaccounts.list,accounts.selectClaude/selectCodex,accounts.removeClaude/removeCodexThese things stay as they were:
setPollingIntervalis still a no-op: the server owns its poll cadence.rateLimitspublishes nothing. The bars stay hidden instead of showing zeros.Why
The data was already on the wire: these are the RPCs the mobile app uses for the same screens, they are allowlisted for paired clients, and they need no server or protocol change. Fixing it at the web bridge keeps every renderer reader untouched: status bar, usage roster, provider details, account switcher and Accounts pane. They keep reading
window.api.*, which now returns the right data on the web. I considered routing the web client through the "remote runtime environment" code paths, which key offactiveRuntimeEnvironmentId. On the web that id is intentionallynull, so setting it would have changed unrelated behavior across the app.Linked Issue
Fixes #25132
Visual Proof
Same server, same web client, before and after this change.
Testing
Built the web client (
pnpm build:web), paired it with a realorca servehost (v1.4.216, Linux), and checked the status-bar usage, the Usage menu, the Claude details panel and the account switcher.New
src/renderer/src/web/web-preload-api-rate-limits.test.ts(7 tests) covers:rateLimits, and unsubscribing with the last listener6 of the 7 fail against the previous stubs.
pnpm typecheck,pnpm lintand the web client tests pass locally (Linux).I also ran the full
pnpm testlocally. Every failure I saw either also fails on a cleanmainon this machine or passed when rerun. The ones I could diagnose come from the local environment: gitdiff.mnemonicPrefix, nozsh, network timeouts in the cross-version harness, and the shell environment. None of them touches the files changed here, so CI is the reference for the full suite.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Investigation, implementation and tests were done with Claude Code (Claude Opus 5.5). I reviewed the changes and tested them against my own server.
Review
Self-review summary:
rateLimitsin their accounts snapshot. Older servers that omit it show no bars, the same as before.RateLimitState, so every provider the server tracks shows up.accounts.subscribestream per tab, opened only while something listens, with a fixed 5s resubscribe delay. Refresh calls go only toaccounts.list.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Web client only. No server, protocol or desktop changes.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred). Fullpnpm testis left to CI, see Testing.🤖 Generated with Claude Code