You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(accounts): show a server's per-account usage in its chats' account menu - #44478
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.
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.
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
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
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.
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
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: 4
Check name
Status
Explanation
Title check
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
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
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
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.
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
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.
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.
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
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
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.
What Changed
Before:
observedProviderAccounts, a secondaccounts.subscribestream that kept the account lists and threw away the host'srateLimits.After:
useOwnerUsageRateLimitsbecomesuseAccountOwnerUsage(owner, local). The status bar passes its active owner, as before. The chat menu passes the chat's host.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-publishedfor 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.getOwnerAccountRows.getOwnerAccountRowsalso 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.observedProviderAccountshas no reader left and is removed.useProviderAccountListloses 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:
rateLimitstoobservedProviderAccounts. That keeps two stream implementations with different reconnect rules.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.tsxrenders the real menus with the real owner hook over a mocked accounts stream. One test added: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
rateLimitsalready reads asusage-not-publishedin this hook. Its rows show no numbers, as before, and its roster still lists.Level: Low
AI Disclosure
Review
Two rounds (Codex and Claude).
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform 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)