fix(claude): clarify account switching and await reconciliation - #3740
Conversation
Switching Codex accounts in the segmented layout cleared the published usage and left the open menu card blank: the account-scoped refresh's phase callbacks called the generic open-menu refresh, which defers parent rebuilds while tracking and re-defers on its retry pass, so the fetched usage was only rendered after closing and reopening the menu. Route the phase callbacks through the switcher rebuild path instead. It coalesces the rapid phase notifications into one in-place rebuild, closes hosted subviews first like the selection rebuild, and clears the tracking deferral, so the open card adopts the new account's usage as soon as it arrives. Adds a regression test asserting a post-fetch rebuild while the menu stays open, and updates the provider gatekeeper allowlist for the rerouted call. Fixes #3709.
Address review feedback on the first attempt: routing the refresh phase callbacks through the switcher path would dismiss an open hosted chart submenu when a delayed phase landed. Add a dedicated helper that bumps the content version as a data-only invalidation and schedules an in-place rebuild: coalesced, deferred during native highlight, skipped while a hosted submenu is open, and reconciled when it closes. Also seed the changelog entry and cover the helper's submenu preservation contract with a focused regression test.
The account-scoped refresh can publish unrelated data-only invalidations after the final rebuild (widget snapshots, readiness resyncs), so asserting a fully-settled state at the end over-constrains the regression. The defect's crisp signal is a rebuild happening after the fetch resolves while the menu stays open.
Follow the repo's native-proof convention (AboutUpdateCommandProofTests, ClaudeWeeklyLabelsNativeProofTests): when CODEXBAR_ACCOUNT_SWITCH_PROOF_DIR is set with keychain prompt suppression, the test runs the real account- switch scheduling path with card rendering enabled and captures before/ after PNGs of the usage card plus a transcript, asserting the fetched usage is published and the open hosted submenu survives. A dispatch-only workflow runs the proof on a macOS runner and uploads the artifacts as merge evidence.
Keep account switching serialized through ambient usage and the independent account-list refresh. Show distinct progress, make chip activation explicit, and reject stale configuration or menu callbacks without cancelling credential transactions. Add isolated lifecycle regressions and opt-in native menu proof. Related to #3736.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 18, 2026, 9:58 AM ET / 13:58 UTC (Revision 2). ClawSweeper reviewWhat this changesClarifies Claude account-chip actions, displays switching and reconciliation progress in open menus, waits for account-list reconciliation, and isolates test configuration files between processes. Merge readiness✅ Ready for maintainer review This remains useful work absent from current main and v0.60.5. No actionable introduced defects were found, and the inspected native proof supports the visible improvement. The unresolved slow-refresh report remains separate. Priority: P2 Review scores
Verification
How this fits togetherCodexBar’s Claude account menu displays usage reported by the optional claude-swap executable. Explicit account activation starts an external credential transaction, then refreshes usage and account status before restoring menu controls. flowchart TD
A[Account chip or card click] --> B{Inspect or activate}
B -->|Inspect| C[Account details]
B -->|Activate| D[Serialized external switch]
D --> E[Refresh usage and account list]
E --> F{Configuration still current}
F -->|Yes| G[Update open menu and controls]
F -->|No| H[Discard stale progress]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Preserve explicit activation and source-owned account identity while keeping progress truthful and controls synchronized through reconciliation. Do we have a high-confidence way to reproduce the issue? Yes, source inspection establishes the missing adapter-task join and progress-driven menu rebuilds, supported by synthetic native before/after evidence. This review did not execute current main or reproduce the reported minute-long delay. Is this the best way to solve the issue? Yes. The patch extends the existing switch lifecycle and menu scheduler while preserving explicit repair, account ownership, and saved settings. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b6d885cab3ee. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Selecting an inactive claude-swap chip changes Claude Code's account, but the menu showed
Loading…during both the switch and the following refresh, and could keep stale controls after completion. ShowSwitching account…, thenRefreshing account status…, and update the attached menu while it remains open.The Switch Claude Code account heading and privacy-safe tooltips/accessibility labels clarify the chip action while retaining readable Account N identities. Active and unavailable chips remain inspection controls, including an active account with foreign credentials; its separate Re-authenticate action remains available.
Keep the target and transaction guard until ambient usage and the independently scheduled adapter list finish. Follow replacement list reads only while the original configuration remains current. Configuration changes discard stale progress and errors without cancelling the external credential transaction. Known switch errors retain precedence, and only the adapter's refreshed list determines the active account.
Related to #3736. Keep that issue open: the cause of the reported minute-long refresh remains unresolved. The broader account-menu redesign in #3550 remains separate.
The test config helper also uses one private config root per process, retaining same-suite reuse and explicit URL behavior. This prevents parallel worktrees from rewriting the same default test config; it does not establish the cause of any historical intermittent failure.
Validation
--switch-to,--version, and--listsubprocesses: ambient-first completion, replacement reads, configuration invalidation, blocked activation, and error precedence.make check: passed with zero violations after integrating the landed menu dependency. Independent P0–P2 review of the final 17-file scope found no actionable findings. All 16 non-changelog files are unchanged from the validated feature candidate.make test: all 1,200 selections across 111 groups passed on22f32150a3461d28e9cea58d74123680b830d894, with no retries or timeouts (1,081 seconds). This includes the Codex menu dependency and provider changes through0ead0d6.f537a864384661a1ca3467f05b65bb288323a376, without retries or timeouts (1,241 seconds). The combined lint and independent P0–P2 review are clean.37e97a7b26da0dbc94d2ad71174a1669d509e762. The merge preview onto current main exactly matches the fully tested combined treef537a864384661a1ca3467f05b65bb288323a376.Signed synthetic native proof on macOS 27.0 (26A428) clicked the actual attached Account 2 button while the same menu tracked. The control at
fc2020a236d9cdisplayedLoading…in both held stages. The candidate atfde9a0f8946dpassed strict checks for both progress labels, the heading, and completion showing Account 2 as Active with enabled chips. Account 2's 17% usage stayed visible; Account 1 remained active until synthetic reconciliation published Account 2. A disabled third-chip click produced no extra switch: exactly one switch command and one refresh, with no unexpected requests. The transaction and widget task drained before fixture cleanup.The native fixture proves visible phase transitions; the separate subprocess regressions prove the independent adapter-list lifecycle. All proof accounts and data are synthetic.
Native proof and source/binary provenance. Published images return HTTP 200 and match the inspected local files byte-for-byte.