Skip to content

fix(accounts): show a server's per-account usage in its chats' account menu - #44478

Merged
AmoabaKelvin merged 4 commits into
mainfrom
fix/claude-menu-owner-rows
Nov 19, 2026
Merged

AmoabaKelvin merged 4 commits into
mainfrom
fix/claude-menu-owner-rows

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

The status bar's Claude and Codex account menus read one source: the accounts and usage published by the host that owns them. The account menu in a chat's usage-limit notice read a second stream that dropped the usage. So a server chat's menu listed that server's accounts with no numbers beside them. It now reads the same source as the status bar, for the chat's own host.

Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​53 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​53
Prod 11 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​237 $\color{#cf222e}{\Huge{\mathbf{−}}}$​305 $\color{#cf222e}{\Huge{\mathbf{−}}}$​68

What Changed

Before:

  • Server chat, usage-limit notice, Claude account menu: accounts listed, no usage on any row. Since fix(status-bar): show a paired server's usage on its Claude and Codex account rows #43952 the status bar shows the same server's per-account usage.
    • The roster came from observedProviderAccounts, a second accounts.subscribe stream that kept the account lists and threw away the host's rateLimits.
    • The readings came from this desktop's own store, local chats only.

After:

  • useOwnerUsageRateLimits becomes useAccountOwnerUsage(owner, local). The status bar passes its active owner, as before. The chat menu passes the chat's host.
  • The host's accounts stream moves out of the hook into owner-accounts-stream.ts, one per host shared by every reader while any is mounted. It keeps the hook's rules: reopen after 5 minutes, reconnect 5 s after loss, keep the last snapshot on failure, usage-not-published for an older host. The status bar and every usage-limited chat on that host now share one stream; on main a server chat's menu opened a second one.
  • Both menus take roster, readings and usage target only through getOwnerAccountRows.
    • A server chat's rows show that server's per-account usage, the same rows the status bar shows.
    • A local chat reads this desktop's store, as before.
  • getOwnerAccountRows also says whether a remote owner's roster has arrived, so the chat's account button stays disabled until it has, as it did with the old stream.
  • observedProviderAccounts has no reader left and is removed. useProviderAccountList loses its observe mode. The data-equality helper moves to its only caller.

Why

The brief asked these two menus to use the same owner path as the status bar instead of a second source. Building the chat's owner observation with the same hook keeps one implementation of the stream: reopen on stale, reconnect after loss, last-known on failure, older-host handling.

Alternatives considered:

  • Add rateLimits to observedProviderAccounts. That keeps two stream implementations with different reconnect rules.
  • Remember the last roster per host so the menu can show it while a fresh list loads. That is a cache the old observation deliberately did not keep. It also does not help on first open, which is where the flash happens.

Linked Issue

No issue. Follow-ups from the review of #43952.

Visual Proof

N/A: the server chat menu draws the same rows the status bar already draws for that server since #43952; no new UI. The status bar's loading state while a host's list is on its way moved to a separate PR.

Testing

  • account-switchers.remote-usage.test.tsx renders the real menus with the real owner hook over a mocked accounts stream. One test added:

    • a server chat's Claude menu shows the server's 25% on the other account's row (fails on main: no gauge).
  • Existing remote Codex and Claude row tests pass unchanged.

  • check:changed.

  • I manually tested these changes locally (not in the real app: it needs a usage-limited chat on a paired host; the component test renders the real menu over the accounts stream)

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

  • Every added test fails without this change and avoids the test anti-patterns

Risk

  • Riskiest part: the status bar's own usage stream moved from a per-hook effect into the shared per-host stream module. Same timers and failure rules. If it were wrong, the bar's meters for a remote owner would stay pending or stale.
  • Older hosts: a host whose stream carries no rateLimits already reads as usage-not-published in this hook. Its rows show no numbers, as before, and its roster still lists.
  • Local: unchanged; local rosters are always known.
  • Back out: a plain revert.

Level: Low

AI Disclosure

Review

Two rounds (Codex and Claude).

  • Fixed: one stream per host shared by the bar and every chat menu (round 1 had one per menu); a type alias that broke the renderer typecheck.
  • Rejected, P3:
    • a remote selection reply isn't written into the owner roster when the stream is down mid-switch. The stream reconnects within 5 s and republishes the roster.
    • a remote chat menu doesn't re-read the host's list when it opens. The status bar never did; the host pushes on account changes and the stream reopens every 5 minutes.
    • the chat menu's active row shows no gauge, unchanged from main.

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-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance

  • No platform branches. Phones have their own account screens.
  • SSH hosts run the same managed server, so they get the same rows.

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)
  • I stated the risk: what could break, for whom, and how to back it out
  • 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)

@AmoabaKelvin AmoabaKelvin changed the title fix(accounts): show a server's per-account usage in its chats' account menu fix(accounts): account menus read the owning host's accounts and usage Nov 19, 2026
@AmoabaKelvin AmoabaKelvin reopened this Nov 19, 2026
The usage-limit Claude menu in a chat reads its host through the same
owner observation as the status bar, so a server chat's rows carry that
server's per-account usage. A remote owner's roster is unknown until its
list arrives, so the menus no longer name System default meanwhile.
Removes the second accounts stream that dropped rate limits.
The status bar and every usage-limited chat on the same host read one
accounts.subscribe stream instead of one each.
The roster-known flag stays for the chat's account button.
@AmoabaKelvin
AmoabaKelvin force-pushed the fix/claude-menu-owner-rows branch from d0aa831 to 97ab66e Compare November 19, 2026 09:58
@AmoabaKelvin AmoabaKelvin changed the title fix(accounts): account menus read the owning host's accounts and usage fix(accounts): show a server's per-account usage in its chats' account menu Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The changes add a shared stream for owner account snapshots and usage failures. The usage hook reads that stream through an external store subscription. Provider account lists now use local state, and owner account rows report whether a roster is known. The Claude switcher uses usage data for the owner targeted by a chat action. A test checks the usage shown for an account outside the status-bar owner.

Merge Risk: Low · up to 97ab6

The remote Claude status-bar menu can briefly show "System default" and account prompts before the host's account list arrives. This is a minor display issue. The server-chat usage routing is covered by a test that does not fully separate the chat owner from the status-bar owner. Neither issue blocks merging, but both are worth tightening.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a server's per-account usage now appears in the account menu of that server's chats. The changeset routes chat menus through the owner usage path and shares one accoun…
Description check Passed The description follows the repository template closely. It has the ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Risk, AI Disclosure, Review, Agent skill boundary, Notes, and Checklis…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: a server's per-account usage now appears in the account menu of that server's chats. The changeset routes chat menus through the owner usage path and shares one accounts stream per host, which matches the title. The title uses the conventional fix(accounts) prefix and stays under 80 characters.

Full details: Description check

Explanation

The description follows the repository template closely. It has the ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, Risk, AI Disclosure, Review, Agent skill boundary, Notes, and Checklist sections. Visual Proof is marked N/A with a reason. The Risk section names the riskiest part and gives a back-out plan. The Linked Issue section says there is no issue and gives a reason, which fits the template's special-case guidance for maintainers. The Risk level is filled in as Low. The unchecked manual-testing box and the unchecked pnpm lint/typecheck/test/build item are explained in the Testing section, so they do not block the check. The 'Fixes #' line from the template was removed, which is acceptable because there is no linked issue.

  • 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Nitpick comments: 1

src/renderer/src/components/status-bar/account-switchers.remote-usage.test.tsx: 1

365-365: Trivial · Maintainability & Code Quality · Quick win

Use distinct chat and status-bar owners in this test.

useActiveAccountOwner returns mocks.owner, and chatAction.target uses the same owner. Line 370 also sends the same snapshot to every watcher. The test can therefore pass if the switcher incorrectly uses the status-bar owner.

Use a different chat target. Record each watcher's target and deliver different usage values to each owner. Keep the 25% assertion for the chat owner. This makes the test detect the routing regression described by its name.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 83330462-e7b0-4335-90d6-c1481157c0c2
Commits

Reviewing files that changed from the base of the PR and between 498ca30 and 97ab66e.

Files selected for processing: 12

  • src/renderer/src/components/status-bar/account-switchers.remote-usage.test.tsx
  • src/renderer/src/components/status-bar/accounts/ClaudeSwitcherForOwner.tsx
  • src/renderer/src/components/status-bar/accounts/ClaudeSwitcherMenu.tsx
  • src/renderer/src/components/status-bar/accounts/owner-account-rows.ts
  • src/renderer/src/components/status-bar/accounts/provider-account-sync-key.ts
  • src/renderer/src/components/status-bar/accounts/use-claude-switcher-state.ts
  • src/renderer/src/components/status-bar/accounts/use-codex-switcher-controller.ts
  • src/renderer/src/components/status-bar/accounts/use-provider-account-list.ts
  • src/renderer/src/components/status-bar/usage/owner-usage-rate-limits.ts
  • src/renderer/src/components/status-bar/usage/use-owner-usage-rate-limits.ts
  • src/renderer/src/runtime/provider-accounts/observations/observed-provider-accounts.ts
  • src/renderer/src/runtime/provider-accounts/observations/owner-accounts-stream.ts
Files with no reviewable changes: 3

  • src/renderer/src/components/status-bar/accounts/use-claude-switcher-state.ts
  • src/renderer/src/components/status-bar/accounts/use-codex-switcher-controller.ts
  • src/renderer/src/runtime/provider-accounts/observations/observed-provider-accounts.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

usageTarget: claudeTarget
} = getOwnerAccountRows('claude', ownerUsage, accounts, EMPTY_CLAUDE_ACCOUNTS)
// Why: a chat's local list loads on its own; a remote roster rides the owner's stream.
const rosterLoaded = ownerUsage.remoteOwner ? rosterKnown : accountsLoaded

@coderabbitai coderabbitai Bot Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Hide the Claude account name and switch rows until the remote roster is known.

For a remote owner without chatAction, rosterLoaded never reaches the panel. accountLabel depends only on panelShowsActiveAccount. Before the roster arrives, the empty roster produces a "System default" target. The panel then shows "System default" as the account name. The account switch area also renders its prompt, so the remote status-bar menu displays account content before the list loads.

Gate accountLabel and the account switch rows on rosterLoaded for remote owners. The menu should show no account name and no account rows until that provider's list arrives.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the status-bar loading state, which was split out of this PR on purpose: it adds UI and is waiting on design review in a follow-up PR. This PR changes only where the chat menu's rows come from.

@AmoabaKelvin
AmoabaKelvin merged commit a1bb6dc into main Nov 19, 2026
43 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

Development

Successfully merging this pull request may close these issues.

1 participant