CodexBar icon indicating copy to clipboard operation
CodexBar copied to clipboard

Claude multi-account: switching account tabs shows the previous account's stale data; Refresh/Cmd-R doesn't update it — only re-clicking the active tab (full re-draw) does (v0.35.0)

Open markiewiczsergei opened this issue 5 months ago • 1 comments

Environment

  • CodexBar 0.35.0 (build 85), macOS (Apple Silicon)
  • Claude provider, Usage source = Web API (cookies), cookieSource: manual
  • Two Claude web token-accounts (personal Max + corporate Team), each with its own sessionKey and organizationId pinned per the #848 fix. Each account fetches its own correct usage data (verified — see workaround below).

Summary

With two Claude token-account tabs, switching to a tab does not refresh the displayed rows: the menu shows the previously selected account's data under the newly selected tab's label (off-by-one). The data is correct and reachable — re-clicking the already-active tab forces a full re-draw and then shows the right label AND data. Pressing Refresh / Cmd-R does NOT fix it (spins, says "Updated just now", but the visible rows stay stale).

Steps to reproduce

  1. Configure two Claude web token accounts (e.g. Perso = Max, CT = Team), each with its own sessionKey + organizationId.
  2. Open the CodexBar menu — the last-selected tab renders correctly (right label + right data).
  3. Click the other account tab. → The label switches, but the usage/plan/cost shown is still the previous account's data (stale).
  4. Press Refresh (Cmd-R). → Spinner + "Updated just now", but the displayed rows do not change; still stale.
  5. Click the now-active tab again (re-select it). → The whole bar re-draws; now both the label and the data are correct for that account.

Expected

Clicking a different account tab (and/or Cmd-R) should rebuild/refresh the visible rows for the newly-selected account — same result as the re-click full re-draw.

Actual

A tab switch updates the selected-tab label but renders cached content for the previously-shown account. Only a full re-draw (re-clicking the active tab → re-runs the full populate) updates the rows. Cmd-R/Refresh updates the store but not the visible rows during menu tracking.

Likely related

This looks like the same "menu rows are not rebuilt during menu tracking → displayed stats stay stale until the menu is reopened" mechanism noted in #1516 (and the populate/rebuild path in #1374). Here it manifests specifically on account-tab switching in a multi-token-account Claude setup, and reproduces on 0.35.0. Re-clicking the active tab is the only in-menu workaround; Cmd-R is not.

Impact

Can't reliably read two accounts' usage by switching tabs — every switch needs an extra "re-click the active tab" to get truthful data, which is error-prone when the whole point is monitoring personal vs corporate burn.

markiewiczsergei avatar Jun 14 '26 17:06 markiewiczsergei

Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 14, 2026, 1:07 PM ET / 17:07 UTC.

Summary Keep open. Current main has a related manual-refresh value-update fix, but the segmented token-account switch path still updates the active tab, rebuilds immediately with the existing provider snapshot, and then defers the post-fetch parent-menu rebuild, so the selected tab and visible usage rows can still get out of sync.

Reproducibility: yes. from source-level evidence, though not from a live Claude account run. The token-account click updates the selected index and rebuilds before the selected-account fetch completes, then the post-fetch parent-menu refresh is deferred during tracking.

Next step This is a bounded source-reproducible menu/state bug with clear likely files and a focused regression-test path, but it should be repaired carefully around the tracked-menu deferral policy.

Review details

Best possible solution:

Make segmented token-account selection account-siloed in the open menu by either rebuilding after the selected-account snapshot lands or driving a scoped live-card invalidation that cannot reuse the previous account's rows, with regression coverage for the selected tab and visible data matching.

Do we have a high-confidence way to reproduce the issue?

Yes from source-level evidence, though not from a live Claude account run. The token-account click updates the selected index and rebuilds before the selected-account fetch completes, then the post-fetch parent-menu refresh is deferred during tracking.

Is this the best way to solve the issue?

Yes, a narrow fix in the token-account switch/open-menu refresh seam is the best path. It should preserve the existing tracked-menu deferral policy while preventing a hosted card from keeping the previous account's provider snapshot.

AGENTS.md: found and applied where relevant.

Remaining risk / open question:

  • I did not run a live Claude multi-account repro because repository policy warns against real provider/keychain validation unless explicitly requested.
  • A fix must preserve the tracked-menu responsiveness protections while ensuring the displayed card is account-siloed after token-account selection.
  • The open opt-in popover work at https://github.com/steipete/CodexBar/pull/1428 may change the long-term menu state model, but it is not a merged fix for the current default NSMenu path.

Codex review notes: model internal, reasoning high; reviewed against fe210acb57da.

Label changes

Label changes:

  • add P2: This is a normal-priority UI correctness bug with limited blast radius but real risk of users reading the wrong Claude account usage.
  • add impact:auth-provider: The issue concerns selected token-account routing and provider account data being shown under the wrong Claude account tab.
  • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
  • add clawsweeper:source-repro: Current issue advisory state selects this label.

Label justifications:

  • P2: This is a normal-priority UI correctness bug with limited blast radius but real risk of users reading the wrong Claude account usage.
  • impact:auth-provider: The issue concerns selected token-account routing and provider account data being shown under the wrong Claude account tab.
Evidence reviewed

Acceptance criteria:

  • swift test --filter StatusMenuTokenAccountSwitcherTests
  • swift test --filter StatusMenuPersistentRefreshTests
  • swift test --filter StatusMenuOpenRefreshTests
  • make check

What I checked:

  • Repository policy read: AGENTS.md was read fully; its provider-data siloing guidance and warning against live provider/keychain probes are relevant to reviewing this Claude multi-account display bug from source and tests. (AGENTS.md:1, fe210acb57da)
  • Vision fit: VISION.md identifies provider limits/usage and fast refreshes as core CodexBar scope, with bounded bug fixes in the merge-by-default lane. (VISION.md:1, fe210acb57da)
  • Token-account switch path: The token account switcher sets the active account, schedules a visible menu rebuild immediately, then starts an async provider refresh and only calls refreshOpenMenuIfStillVisible after that fetch completes. (Sources/CodexBar/StatusItemController+Menu.swift:1021, fe210acb57da)
  • Selected-account snapshot application: The selected token account's fetched outcome is applied only after refreshTokenAccounts completes; before that point store.snapshot(for:) can still be the previous account's provider snapshot. (Sources/CodexBar/UsageStore+TokenAccounts.swift:391, fe210acb57da)
  • Post-fetch open-menu refresh defers parent rebuild: refreshOpenMenuIfStillVisible invalidates the parent menu with deferOpenParentMenuRebuild: true, and the refresh path records the open parent menu as deferred instead of scheduling an immediate rebuild. (Sources/CodexBar/StatusItemController+MenuTracking.swift:371, fe210acb57da)
  • Related manual-refresh fix is only partial for this report: The merged manual-refresh fix added MenuCardRefreshMonitor and compatible live model replacement, but that path is keyed around manual refresh state and does not by itself prove segmented token-account switching refreshes the hosted card after the selected-account fetch. (Sources/CodexBar/MenuCardRefreshMonitor.swift:22, b40c3537c65d)

Likely related people:

  • steipete: Current blame and merged PR history tie this handle to the token-account switcher, current v0.35.0 menu implementation, and the same-day manual-refresh live card update. (role: recent area contributor and committer; confidence: high; commits: 9d3c354df9ba, b40c3537c65d, 24ba34eb3a0b; files: Sources/CodexBar/StatusItemController+Menu.swift, Sources/CodexBar/StatusItemController+SwitcherViews.swift, Sources/CodexBar/MenuCardRefreshMonitor.swift)
  • Jang Isaac: History shows this contributor authored the tracked-menu refresh deferral behavior that the token-account post-fetch refresh currently routes through. (role: adjacent menu tracking contributor; confidence: medium; commits: e97bfb0db9eb; files: Sources/CodexBar/StatusItemController+MenuTracking.swift, Sources/CodexBar/StatusItemController+ProviderNavigation.swift, Tests/CodexBarTests/StatusMenuOpenRefreshTests.swift)
  • Zeko369: The closed related pull request proposed the provider-scoped token-account refresh and open-menu refresh idea that was later adapted into the current code path, making this handle useful historical context even though the branch itself did not merge. (role: prior related fix proposer; confidence: medium; files: Sources/CodexBar/StatusItemController+Menu.swift, Tests/CodexBarTests/StatusMenuTokenAccountSwitcherTests.swift)
How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

clawsweeper[bot] avatar Jun 14 '26 17:06 clawsweeper[bot]