Skip to content

fix(status-bar): refresh inactive Claude account usage on popover open and Refresh - #18746

Closed
Tauri-EPO wants to merge 2 commits into
stablyai:mainfrom
Tauri-EPO:Tauri-EPO/claude-usage-triggers
Closed

Tauri-EPO wants to merge 2 commits into
stablyai:mainfrom
Tauri-EPO:Tauri-EPO/claude-usage-triggers

Conversation

@Tauri-EPO

@Tauri-EPO Tauri-EPO commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Orca only looked up the usage of your other saved Claude accounts when you expanded the "Switch to" list. Opening the Claude usage popover or pressing Refresh did nothing for them, so they stayed blank or showed old numbers. Now both of those also ask for the saved accounts' usage.

What Changed

  • ClaudeSwitcherMenu.tsx: opening the Claude popover calls fetchInactiveClaudeAccountUsage (same gate as the "Switch to" expansion: skipped while a remote environment owns the accounts). The expansion trigger stays; the service's 60 s on-open debounce makes the second call a no-op.
  • use-status-bar-controller.ts: the status bar Refresh button also runs fetchInactiveClaudeAccountUsage and fetchInactiveCodexAccountUsage, under the same remote-environment gate. Codex is included because Refresh is provider-wide; its inactive probes keep their own 60 s debounce and stagger in the service.
  • New test use-status-bar-controller-refresh.test.tsx (real store, renderHook): Refresh fans out to both inactive fetches locally, and leaves them alone when activeRuntimeEnvironmentId is set.

Why

Point 6 of #14833: "Fetch inactive accounts when the user opens Switch to, when they open the Usage popover, and on explicit refresh — not only on switcher expand." The main-side fetch already exists with its own debounce, so this is two call sites, no new polling.

Linked Issue

Part of #14833 (point 6). Does not close it.

Visual Proof

N/A: no visible element changes; the existing rows fill in earlier. The popover-open path reuses the exact call the "Switch to" expansion already makes.

Testing

Platforms: Windows 11 (local). Renderer-only, platform-neutral.

  • vitest run --config config/vitest.config.ts src/renderer/src/components/status-bar: 52 files, 338 tests passed (includes the 2 new).

  • pnpm tc:web: clean. oxlint and oxfmt --check on the three changed files: clean.

  • pnpm build:desktop: exit 0 (full typecheck, relay, CLI, electron-vite, web projection).

  • Not covered by a test: the popover-open call in ClaudeSwitcherMenu. The component is not rendered in isolation anywhere in the suite today, and it is a one-line addition to an existing handler with the same gate as the expansion path.

  • I manually tested these changes locally

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

AI Disclosure

Implementation and tests by Claude (Fable 5.1) via Claude Code, driven and verified by me.

Review

Agent code-review summary:

  • Cross-platform: none; renderer store calls only.
  • SSH / remote: both call sites skip when activeRuntimeEnvironmentId is set, matching the existing expansion trigger, because remote-owned accounts have no local cache to fill.
  • Agents / integrations: Claude popover open touches Claude only; Refresh touches Claude and Codex inactive caches. The Codex probe spawns a real codex per inactive account, which is why it keeps the service-side debounce and stagger; Refresh within 60 s of a previous probe is a no-op.
  • Performance: no new timers. Worst case one extra usage GET per inactive Claude account per minute if the user keeps reopening the popover; the usage endpoint's 429 handling in the service already covers that.
  • UI: no change.
  • Security: none.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Review follow-up (c47dcac): the inactive fetches are fired without awaiting, so the Refresh spinner tracks only the active-provider refresh.

Independent of #18732 and #18736 (separate call sites). With #18732 the fetch actually succeeds for expired tokens; with #18736 a failed fetch shows a reason instead of a blank row.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • 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)

Author

X: @EnricoPin

…n and Refresh

Inactive-account usage was fetched only when "Switch to" expanded, so the
Claude usage popover and the Refresh button left saved accounts blank or
stale. Fetch them when the Claude popover opens and when Refresh runs (both
Claude and Codex), keeping the service's on-open debounce and skipping the
local caches while a remote environment owns the accounts.

Part of stablyai#14833 (point 6).
@coderabbitai

coderabbitai Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 7cd96a71-db2d-4a60-81e1-fa84233a1dd4

📥 Commits

Reviewing files that changed from the base of the PR and between f16cfb1 and c47dcac.

📒 Files selected for processing (2)
  • src/renderer/src/components/status-bar/use-status-bar-controller-refresh.test.tsx
  • src/renderer/src/components/status-bar/use-status-bar-controller.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The status bar refresh now includes inactive Claude and Codex account usage when no active runtime environment exists. The refresh spinner no longer waits for inactive-account fetches. Remote runtime environments skip these fetches. The Claude switcher menu also fetches inactive Claude account usage when it opens under the same condition. Tests cover these behaviors.

Merge Risk: ⚪ Minimal · up to c47dc

Status-bar refresh now updates inactive local Claude and Codex usage without extending the refresh spinner, while remote runtime environments remain excluded. No current merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the main change: refreshing inactive Claude account usage when the status-bar popover opens and when the user presses Refresh.
Description check ✅ Passed The description is complete and closely follows the repository template. It explains the change and reason, links the related issue, documents testing and platform coverage, provides visual-proof just…
  • Fix all pre-merge checks with AI

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.

@pullfrog pullfrog 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.

ℹ️ No critical issues — one minor suggestion inline.

Reviewed changes

  • ClaudeSwitcherMenu popover-open fetch — handleOpenChange now fires fetchInactiveClaudeAccountUsage() on open (gated on !hasActiveRuntimeEnvironment), alongside the retained handleAccountsExpandedToggle trigger.
  • useStatusBarController Refresh fan-out — handleRefresh adds fetchInactiveClaudeAccountUsage() and fetchInactiveCodexAccountUsage() to its Promise.all, gated on the same remote-environment check.
  • New test — use-status-bar-controller-refresh.test.tsx pins that Refresh fans out to both inactive fetches locally and skips them under a remote environment.

The change is well scoped: both call sites route through the existing main-side fetchInactiveClaudeAccountsOnOpen / fetchInactiveCodexAccountsOnOpen, which already carry the 60s debounce and (for Codex) the 2s-per-account probe stagger, so this adds no polling. The remote-environment gate matches the pre-existing expansion trigger, and the tests assert exact call counts rather than truthiness, so they would actually fail against a regression. I verified refresh() (active) does not already refresh inactive accounts, so the additions are genuinely new work rather than redundant.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

…ctive probes

Review follow-up on stablyai#18746: fire the inactive-account fetches without
awaiting them, like the switcher does, so isRefreshing tracks only the
active-provider refresh instead of the per-account Codex probe stagger.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

  • Fire-and-forget inactive probes on Refresh — handleRefresh now invokes fetchInactiveClaudeAccountUsage() and fetchInactiveCodexAccountUsage() with void rather than folding them into the Promise.all, so the Refresh spinner clears once the active providers finish and no longer waits out the Codex per-account stagger.
  • Regression test — new does not hold the spinner on the staggered inactive probes case holds a Codex probe pending and asserts isRefreshing is already false, pinning the fire-and-forget behavior.

The prior review's single concern (the spinner held open on the staggered inactive probes) is resolved cleanly. The void pattern matches the switcher and the store slices swallow their own errors, so the unawaited promises can't reject. The added test asserts exact call counts and observable state rather than truthiness, so it would catch a regression.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@Tauri-EPO

Copy link
Copy Markdown
Contributor Author

Closing; this has been conflicting since September. The gap it addressed, refreshing an inactive Claude account's usage when the popover opens, is still open after #33542, which lists it as a separate concern. #14833 keeps tracking it.

@Tauri-EPO Tauri-EPO closed this Oct 31, 2026
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