Repository navigation
fix(status-bar): show usage from the host that owns the accounts - #29430
Merged
Merged
Conversation
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit details
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 |
With an SSH-managed or paired Orca server owning the focused workspace's accounts, the usage badges read that host's accounts snapshot instead of this device's local poll. An older host that publishes no usage reads "Usage unavailable", and loss of contact is an unverifiable verdict.
…s and owner switches
nwparker
force-pushed
the
nwparker/env-aware-usage
branch
from
October 16, 2026 04:49
d09cb33 to
0105794
Compare
This was referenced Oct 16, 2026
This was referenced Oct 18, 2026
This was referenced Oct 24, 2026
This was referenced Nov 17, 2026
[Feature]: Show Claude and Codex usage and rate limits for accounts on SSH remote hosts (VPS)
#22675
Closed
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.
ELI5
When the Claude/Codex agents run on another machine (an SSH host running Orca's managed server, or a paired Orca server), the usage badges in the status bar should show that machine's usage. Until now they always showed the usage of the laptop you're looking at, which usually runs no agents. This makes the badges read usage from the machine that owns the accounts.
What Changed
Mechanism:
useOwnerUsageRateLimitshook (use-owner-usage-rate-limits.ts). It resolves the account owner with the existinguseActiveAccountOwner. For a remote owner it watches the existingaccounts.subscribestream (watchProviderAccounts), whose snapshot has carried the host's fullRateLimitStatefor a long time. Refresh calls the existingaccounts.list({ refreshUsage: true }); a refresh that finishes after an owner switch is dropped. Each snapshot is tagged with the owner it came from, so switching from host A to host B never shows A's numbers under B's name. The stream is reopened every 5 minutes, because an SSH-managed server does not poll usage on its own and each subscribe makes it refresh stale usage. A stream that closes after its first snapshot counts as lost contact and reconnects after 5 seconds (watchProviderAccountsgains an optionalonClosedAfterSnapshot).resolveOwnerUsageRateLimits(owner-usage-rate-limits.ts). It maps the owner state (local / pending / remote / unverifiable) to theRateLimitStatethe status bar renders. Providers and flags an older host omits count as "not configured on that host", not as this device's values.use-status-bar-controller.tsrenders the resolved state. With a remote owner, which bars appear comes from the host's snapshot alone: this device's PATH detection, managed accounts and setup flags describe the viewer, not the host. Pending and lost-contact states never borrow the viewer's setup flags either.usage-error-copy.ts: a renderer-onlyusageMetadata.unverifiableOwnerflag makes the badge say "Usage unavailable" rather than "Refresh failed". Hosts never set this flag.Why
Root cause: the status bar destructured providers straight from the local
rateLimitsstore slice, which only the localRateLimitServicefills. Its refresh target type (initial-account-rate-limit-target.ts,RateLimitRuntimeTarget) only knowshost/wsl, so remote owners had no way in. The accounts roster beside it was already owner-aware, so the two disagreed.Alternatives considered:
ssh/environmentruntime toRateLimitRuntimeTargetand having this desktop's main process fetch the host's usage. Rejected: the execution host already computes its own usage with its own credentials and publishes it. Having the desktop proxy that would duplicate the host's work and widen the IPC surface.use-status-bar-controller.ts, keys off the global Active Server rather than the focused workspace's owner (so SSH-managed workspaces would stay local), and misses the newer Cursor and ZCode providers. This PR carries over its correctness points (no local numbers while pending, owner-tagged snapshots, an honest unreachable verdict, keeping the bars the host vouched for) on top of current main.Wire compatibility: no new RPC method, field, or stream opcode. A host whose snapshot has no
rateLimitsshows "Usage unavailable", not an error.Linked Issue
Fixes #15798
Linear: STA-5049, STA-5468
Visual Proof
Not attached: this environment has no paired or SSH-managed host to render against. What to check:
orca account list --jsonon that host.···placeholder, never this device's percentages.Codex review
Testing
owner-usage-rate-limits.test.ts: local passthrough; remote numbers replace local ones; providers an older host omits; nothing local shown while pending; an older host without usage reads "Usage unavailable" and is not an error; an unreachable host keeps only the bars it vouched for.use-owner-usage-rate-limits.test.tsx: no watcher for a local owner; the stream drives the badges; a snapshot without usage reads unavailable; loss of contact is unverifiable; host A → B never shows A's numbers, even from a late callback; Refresh callsaccounts.list({ refreshUsage: true })on the owner.Existing
usage-error-copyandstatus-bar-provider-visibilitytests pass.pnpm tc:webandpnpm run check:code-quality:changedare clean. macOS only.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
accounts.subscribewhile a remote owner is focused, closed when the owner changes. Nothing new runs for local owners.Known follow-ups (out of scope): the Claude/Codex switcher popovers' inactive-account rows and host/WSL toggle still read this device's store under a remote owner, and direct (non-managed) SSH connections still show local usage.
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)