Skip to content

fix(codex): show live usage on the active account row, including System default - #20842

Merged
nwparker merged 1 commit into
stablyai:mainfrom
moonrailgun:fix/codex-system-default-usage
Oct 26, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
moonrailgun:fix/codex-system-default-usage

Conversation

@moonrailgun

@moonrailgun moonrailgun commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

In the Codex account list, the other accounts show how much usage they have left, but the account you are actually using (including "System default") showed nothing, even though its numbers are right at the top of the same menu. Now the active row shows its usage too.

What Changed

  • Before: account rows in the Codex switcher only drew usage bars from the inactive-account usage cache. The active account, and especially "System default" (which has no managed account id, so it never gets a cache entry), had a blank row.
  • After: when this desktop owns the Codex accounts, the active row renders the live codex rate limits it already has with the existing InlineUsageBars (loading state follows codex.status === 'fetching'). No new request is made.
  • Remote guard: the switcher's rows follow this desktop's codexTarget, while a remote account owner's usage belongs to that host's target. When the active account owner is a runtime environment, the live usage stays off the desktop-selected row, so another machine's usage never shows up on the wrong row.
  • Regression tests cover a System default active row, a managed active row, and the remote-owner case.

Why

The usage was already fetched and shown in the summary at the top. Reusing it on the active row fixes the gap without adding a cache entry for System default or another usage fetch.

Linked Issue

Fixes #20841

Visual Proof

Before (main) After
Before: System default row has no usage After: System default row shows 23% 5h / 11% wk

Testing

  • I manually tested these changes locally

  • Automated tests added/updated

  • Reproduced on macOS: opened the Codex usage menu with System default active and expanded the account list. On main the active row is blank. With the fix it shows the same 5h and weekly usage as the summary (screenshots above).

  • pnpm test src/renderer/src/components/status-bar/codex-status-sign-in.test.tsx: all 8 pass, including the new active-row and remote-owner cases.

  • Ran oxlint/oxfmt and CI's anti-slop, code-quality, ast-grep, and changed-code quality gates on the touched files. All clean.

  • Renderer-only change with no platform-specific code. SSH/remote is covered by the remote-owner guard above.

Notes

Original fix by @moonrailgun in #20842, with a follow-up guard so a remote owner's usage stays off desktop-selected rows. No wire formats, stored data, or public interfaces change, so mixed-version remotes are unaffected.

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 Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: dcde10b2-523b-49b8-a191-4358fce7ad7d

📥 Commits

Reviewing files that changed from the base of the PR and between caa465d and bd1e1c8.

📒 Files selected for processing (2)
  • src/renderer/src/components/status-bar/CodexSwitcherMenu.tsx
  • src/renderer/src/components/status-bar/codex-status-sign-in.test.tsx

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

Walkthrough

The Codex account switcher now renders InlineUsageBars for active targets using Codex limits and fetching status. The test helper accepts an optional Codex state. Parameterized coverage verifies weekly usage for system-default and explicit active accounts.

Priority: Normal

Severity of issue fixed: Medium

Merge Risk: Minimal · up to bd1e1

The intended usage display is covered for both supported active-account types, with no concrete merge-blocking risk identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Issue #20841 requires usage in the active “System default” row. CodexSwitcherMenu.tsx now renders InlineUsageBars for every target.active row, using the existing codex limits and fetch status.…
Out of Scope Changes check Passed The changes stay within issue #20841. The production change renders the missing active-account usage. The test changes add coverage for System default and managed active rows and update the test helpe…
Title check Passed The title clearly and concisely describes the main change: showing live usage on the active Codex account row, including System default.
Description check Passed The description is complete and focused. It covers the user impact, implementation, rationale, linked issue, visual proof, testing, remote-owner behavior, and checklist. The unchecked full validation …
Full details: Linked Issues check

Explanation

Issue #20841 requires usage in the active “System default” row. CodexSwitcherMenu.tsx now renders InlineUsageBars for every target.active row, using the existing codex limits and fetch status. The regression test covers both null (System default) and managed active account IDs and verifies 11% used wk.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #20841. The production change renders the missing active-account usage. The test changes add coverage for System default and managed active rows and update the test helper to provide rate-limit data. No unrelated production behavior is changed.

Full details: Description check

Explanation

The description is complete and focused. It covers the user impact, implementation, rationale, linked issue, visual proof, testing, remote-owner behavior, and checklist. The unchecked full validation command item is acceptable because targeted tests and CI coverage are documented.

  • 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.

@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

  • Active account row renders live usage — CodexSwitcherMenu.tsx now checks target.active first and renders InlineUsageBars from the codex prop, so the System default row (and any managed active row) shows usage instead of falling through the inactive-usage cache that has no entry for it.
  • Regression coverage — codex-status-sign-in.test.tsx threads an optional codex override through renderSwitcherAndOpenAccounts and adds an it.each([null, 'account-1']) case asserting the active row shows 11% used wk for both the system default and a managed active account.

The data source is correct: codex is rateLimits.codex, which the service fetches from the active account's Codex home for codexTarget, and selectedGroup is derived from that same codexTarget — so the active row's account and the rendered usage can't diverge across host/WSL/remote lanes. I also confirmed the new test is falsifiable: reverting the target.active branch makes both new cases fail on within(activeRow).getByText('11% used wk'). Targeted run of the two touched suites passes 12/12.

ℹ️ The same active-row gap remains in the Claude switcher

ClaudeSwitcherMenu.tsx:282-289 still only consults inactiveClaudeAccounts, so its active row (including System default) stays blank for the exact same reason. That's deliberately outside this Codex-scoped fix, but it's the same shape and will surface as an equivalent bug report — worth a follow-up issue or a shared active-row helper rather than leaving the two switchers divergent.

Technical details
# Claude active row has no usage source

## Affected sites
- `src/renderer/src/components/status-bar/ClaudeSwitcherMenu.tsx:282` — `inactiveUsage` is `inactiveClaudeAccounts.find(...)`; the active target is never in that list, so the row renders `null`.
- Contrast with the fixed `CodexSwitcherMenu.tsx:254` `target.active` branch.

## Required outcome
- The Claude active row should render `InlineUsageBars` from the `claude` prop (the active runtime target's usage), mirroring the Codex fix.

## Open questions for the human
- Is this intentionally left out of scope for #20841, or should both switchers be aligned now (possibly via a shared active-row component)?

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

…em default

The Codex switcher only rendered usage bars on inactive account rows from
the per-account cache, so the active row (and System default, which never
has a managed account id) showed nothing. Render the live Codex usage on
the active row when this desktop owns the accounts; a remote owner's usage
belongs to that host's target and stays off desktop-selected rows.

Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
@nwparker
nwparker force-pushed the fix/codex-system-default-usage branch from bd1e1c8 to d5118c2 Compare October 26, 2026 22:20
@nwparker nwparker changed the title fix(codex): show usage for the system default account fix(codex): show live usage on the active account row, including System default Oct 26, 2026
@nwparker
nwparker merged commit 037cf27 into stablyai:main Oct 26, 2026
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

Development

Successfully merging this pull request may close these issues.

[Bug]: System default Codex account does not show usage in the account list

2 participants