Skip to content

fix(status-bar): show usage from the host that owns the accounts - #29430

Merged
nwparker merged 5 commits into
mainfrom
nwparker/env-aware-usage
Oct 16, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/env-aware-usage

Conversation

@nwparker

@nwparker nwparker commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​356 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​356
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​355 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​347

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

  • Before: with a remote workspace focused, or a remote Active Server, the status-bar usage badges kept polling this device. They showed this device's numbers (which look right but describe the wrong machine), or sat on "Refresh failed" / "Refreshing sign-in" when this device's logins had expired. Claude and Codex usage of the SSH host was never shown.
  • After: the badges show the usage of the host that owns the focused workspace's provider accounts. This is routed by the workspace's own host, not by the Active Server setting, so with no workspace focused the badges show this device. While the first answer is on its way the badges show the loading placeholder, never this device's percentages. If the host can't be reached the badge reads "Usage unavailable" with "cannot reach ". If the host is an older Orca that publishes no usage, it reads "Usage unavailable — does not report usage", not an error. The Refresh button asks the host to refresh. Local and WSL workspaces behave exactly as before.

Mechanism:

  • New useOwnerUsageRateLimits hook (use-owner-usage-rate-limits.ts). It resolves the account owner with the existing useActiveAccountOwner. For a remote owner it watches the existing accounts.subscribe stream (watchProviderAccounts), whose snapshot has carried the host's full RateLimitState for a long time. Refresh calls the existing accounts.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 (watchProviderAccounts gains an optional onClosedAfterSnapshot).
  • New pure resolver resolveOwnerUsageRateLimits (owner-usage-rate-limits.ts). It maps the owner state (local / pending / remote / unverifiable) to the RateLimitState the 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.ts renders 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-only usageMetadata.unverifiableOwner flag 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 rateLimits store slice, which only the local RateLimitService fills. Its refresh target type (initial-account-rate-limit-target.ts, RateLimitRuntimeTarget) only knows host / wsl, so remote owners had no way in. The accounts roster beside it was already owner-aware, so the two disagreed.

Alternatives considered:

  • Adding an ssh / environment runtime to RateLimitRuntimeTarget and 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.
  • Taking over fix(status-bar): source rate-limit badges from the Active Server that owns usage #15880 (held since August). It targets a status bar that has since been split into 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 rateLimits shows "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:

  1. Focus a workspace on an SSH host (managed server) or set a paired server as the Active Server. The Claude/Codex badges should match orca account list --json on that host.
  2. Right after switching, the badges show the ··· placeholder, never this device's percentages.
  3. Stop the host. Within about 15 seconds the badges read "Usage unavailable" and the popover reads "cannot reach ".
  4. A local or WSL workspace behaves as before.

Codex review

  • Round 1: (a) usage froze on SSH-managed servers that do not poll; (b) a stream closing after its first snapshot left stale numbers; (c) a late refresh from the previous owner overwrote the new owner; (d) the viewer's setup decided which remote bars appear. All fixed.
  • Round 2: viewer setup flags leaked into the lost-contact state. Fixed.
  • Round 3: a slot that was still fetching kept loading through an outage. Fixed. Also: status-bar "Manage accounts" opens Settings on its own page-level host picker rather than the usage owner. Dismissed: Settings deliberately scopes accounts through its own host control, and this predates this PR.
  • Round 4 (P2, past the review-round cap): a remote provider row can briefly hide while the host refetches after an account switch, and a null slot with a host setup flag can stay pending during an outage. Left as follow-ups.

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 calls accounts.list({ refreshUsage: true }) on the owner.

  • Existing usage-error-copy and status-bar-provider-visibility tests pass. pnpm tc:web and pnpm run check:code-quality:changed are clean. macOS only.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Review

  • SSH / remote: the host that runs the agents owns usage, and the client renders that host's snapshot. Loss of contact is an unverifiable verdict, never 0% and never an endless spinner.
  • Remote wire compatibility: no wire change, and older hosts degrade to "Usage unavailable".
  • Cross-platform: renderer state only.
  • Performance: one accounts.subscribe while 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

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e69f308f-1a30-404d-86b4-58f1e70a7373
📥 Commits

Reviewing files that changed from the base of the PR and between 90849ed and 010db46.

📒 Files selected for processing: 10
  • src/renderer/src/components/status-bar/owner-usage-rate-limits.test.ts
  • src/renderer/src/components/status-bar/owner-usage-rate-limits.ts
  • src/renderer/src/components/status-bar/status-bar-provider-visibility.ts
  • src/renderer/src/components/status-bar/usage-error-copy.ts
  • src/renderer/src/components/status-bar/use-owner-usage-rate-limits.test.tsx
  • src/renderer/src/components/status-bar/use-owner-usage-rate-limits.ts
  • src/renderer/src/components/status-bar/use-status-bar-controller.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/runtime/runtime-provider-accounts-client.ts
  • src/shared/rate-limit-types.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.
@nwparker
nwparker force-pushed the nwparker/env-aware-usage branch from d09cb33 to 0105794 Compare October 16, 2026 04:49
@nwparker
nwparker merged commit 788b806 into main Oct 16, 2026
31 of 33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant