Repository navigation
Conversation
With a remote Active Server, the usage badges kept polling the local
device: the accounts roster next to them was already environment-aware
('Showing accounts managed by <server>'), but the numbers came from the
local rate-limits slice, so the badges sat on 'Refresh failed' forever —
or worse, showed valid-looking numbers describing a machine that runs
no agents (stablyai#15798).
The provider-accounts snapshot the roster already consumes carries the
server's full RateLimitState; the status bar now watches that snapshot
when a remote environment owns accounts and renders its numbers. The
manual refresh re-fetches the snapshot instead of the local poll. Until
the first snapshot lands, Claude/Codex rows degrade to a fetching state
rather than flashing local numbers; without a remote owner nothing
changes.
📝 WalkthroughWalkthroughThe status bar now detects remote active-server ownership and subscribes to provider-account snapshots. It resolves effective rate limits from local state or remote snapshots. It marks Claude and Codex as fetching before the first remote snapshot. Manual refresh fetches remote snapshots for remote-owned usage and retains local refresh behavior otherwise. Provider segments and usage-configuration flags use the effective rate-limit state. Unit tests cover source selection and fallback behavior. Merge Risk: 🟡 Moderate · up to The change can show usage from the wrong active server after switching, refresh the wrong server's data, or hide locally configured MiniMax and Grok badges when remote data arrives. The PR is not merge-ready until these bounded correctness issues are addressed. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/status-bar/StatusBar.tsx (1)
2128-2154: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winInclude the remote selection in
handleRefreshdependencies.
handleRefreshcapturesremoteUsageOwnerandactiveRuntimeEnvironmentId, but omits both dependencies. After a server change, the next refresh can use the previous owner mode or request the previous server's snapshot. Add both dependencies and a regression test that switches servers before refresh.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 03260c64-e656-474d-ae0a-d59ee1fe50ba
📒 Files selected for processing (3)
src/renderer/src/components/status-bar/StatusBar.tsxsrc/renderer/src/components/status-bar/usage-rate-limits-source.test.tssrc/renderer/src/components/status-bar/usage-rate-limits-source.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| const remoteUsageOwner = hasRemoteProviderAccountOwner(settings) | ||
| const activeRuntimeEnvironmentId = settings?.activeRuntimeEnvironmentId?.trim() || null | ||
| const [remoteRateLimits, setRemoteRateLimits] = useState<RateLimitState | null>(null) | ||
| useEffect(() => { | ||
| if (!remoteUsageOwner) { | ||
| setRemoteRateLimits(null) | ||
| return | ||
| } | ||
| const watcher = watchProviderAccounts( | ||
| { activeRuntimeEnvironmentId }, | ||
| { | ||
| onSnapshot: (snapshot) => { | ||
| if (snapshot.rateLimits) { | ||
| setRemoteRateLimits(snapshot.rateLimits) | ||
| } | ||
| }, | ||
| onError: (error) => { | ||
| console.error('Failed to stream remote usage snapshot:', error) | ||
| } | ||
| } | ||
| ) | ||
| return () => { | ||
| watcher.close() | ||
| } | ||
| }, [remoteUsageOwner, activeRuntimeEnvironmentId]) | ||
| const effectiveRateLimits = resolveStatusBarUsageRateLimits( | ||
| rateLimits, | ||
| remoteRateLimits, | ||
| remoteUsageOwner | ||
| ) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Scope remote rate limits to the active server.
When the user switches from remote server A to remote server B, remoteUsageOwner stays true and remoteRateLimits still contains server A data. The new watcher starts, but the status bar renders server A usage until server B sends its first snapshot.
Clear the state when the active server changes, or store the owner ID with the snapshot and ignore data whose owner does not match activeRuntimeEnvironmentId.
| if (remoteRateLimits) { | ||
| return remoteRateLimits |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Preserve local durability flags for remote usage.
Lines 21-22 replace minimaxCookieConfigured and grokAuthConfigured with remote values. StatusBar.tsx uses these effective values for visibility. This can hide locally configured MiniMax or Grok bars after the remote snapshot arrives.
Keep remote usage fields, but overwrite these two flags with localRateLimits values. Update the remote-snapshot test to assert this contract. The PR objective requires these durability flags to remain local for visibility rules.
Proposed fix
if (remoteRateLimits) {
- return remoteRateLimits
+ return {
+ ...remoteRateLimits,
+ minimaxCookieConfigured: localRateLimits.minimaxCookieConfigured,
+ grokAuthConfigured: localRateLimits.grokAuthConfigured
+ }
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (remoteRateLimits) { | |
| return remoteRateLimits | |
| if (remoteRateLimits) { | |
| return { | |
| ...remoteRateLimits, | |
| minimaxCookieConfigured: localRateLimits.minimaxCookieConfigured, | |
| grokAuthConfigured: localRateLimits.grokAuthConfigured | |
| } |
|
Thanks for this @yzxcj797 — you found the right lever. Reusing Fork PRs in this repo only get the I did add fixes on top, the main one being: Really appreciate the contribution — please don't close this one; I'll link it from #15880. |
Summary
What
When a remote Active Server owns provider accounts (
hasRemoteProviderAccountOwner), the status-bar usage badges now render the server'sRateLimitState— taken from the provider-accounts snapshot the neighboring account roster already consumes (snapshot.rateLimits), which the status bar now watches for the pane's lifetime. The manual refresh button re-fetches that snapshot instead of running the local poll. Until the first remote snapshot lands, the Claude/Codex rows degrade to a fetching state rather than flashing local numbers; durability flags (minimax cookie / grok auth configured) stay local so bar visibility rules keep working. Without a remote owner, nothing changes.Why
#15798 — the accounts list is environment-aware ("Showing accounts managed by ") while the usage badges beside it polled the local device, so they sat on
Refresh failed/Refreshing sign-in…forever against stale local logins — and when local logins happened to be valid, they showed numbers describing a machine that runs no agents, which looks correct while being wrong.The data was already flowing: the runtime's accounts snapshot carries the full server-side
RateLimitState(streamed with its 5-minute poll), and the AccountsPane subscribed to the same watcher but dropped therateLimitsfield. The status bar now consumes it.Testing
usage-rate-limits-source.test.ts(4 cases): local owner sees the local state untouched; remote owner sees the remote snapshot verbatim; before the first snapshot the Claude/Codex rows readfetching— never the stale localerror— while durability flags stay local; a null provider stays null through the degrade. 4/4.resource-session-classification-parity) is pre-existing on main (verified identical with this change stashed; it scansmergeSnapshotAndSessionssource, untouched here).pnpm run typecheckclean.Fixes #15798