Skip to content

Give claude-swap accounts explicit precedence over Claude token-account cards#1913

Merged
steipete merged 2 commits into
steipete:mainfrom
optimiz-r:fix/claude-swap-token-account-precedence
Jul 5, 2026
Merged

Give claude-swap accounts explicit precedence over Claude token-account cards#1913
steipete merged 2 commits into
steipete:mainfrom
optimiz-r:fix/claude-swap-token-account-precedence

Conversation

@optimiz-r

@optimiz-r optimiz-r commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #1909. Multiple Claude token accounts in stacked layout rendered before the claude-swap branch and silently hid its rows.

  • Give multiple available claude-swap accounts explicit precedence over Claude token-account cards.
  • Suppress the segmented Claude token-account switcher while claude-swap account cards are active.
  • Keep zero/single-account behavior and every other provider unchanged.
  • Centralize the precedence rule in a pure model seam; avoid live NSStatusBar construction in headless tests.
  • Document and package synthetic UI proof generated with a fake cswap executable—no real accounts, credentials, or provider calls.

Stacked claude-swap account cards

Validation

Final exact head: d77749aa2f33221703efd10ea96c78b7cbf65557

  • swift test --filter 'ClaudeSwap|TokenAccountMenuDisplay|MenuCardClaudeSwapAccountTests|StatusMenuHostedSubmenuRefreshTests' — 40 tests passed across 6 suites.
  • make test — all 48 shards passed.
  • make check — documentation/locales/repository checks passed; 0 formatting or lint violations.
  • Structured review of the maintainer fix and full branch — clean, no accepted/actionable findings.

@clawsweeper

clawsweeper Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed July 5, 2026, 11:22 AM ET / 15:22 UTC.

Summary
The branch makes multiple Claude claude-swap snapshots take precedence over Claude token-account cards and the segmented token-account switcher, adds a pure precedence test, and documents the behavior with a synthetic screenshot.

Reproducibility: yes. from source inspection: current main computes token-account display and returns from the stacked token-account branch before reaching claude-swap cards when multiple Claude token accounts are configured. I did not run the macOS app in this read-only review.

Review metrics: none identified.

Root-cause cluster
Relationship: canonical
Canonical: #1913
Summary: This PR is the open follow-up for the claude-swap/token-account precedence bug left after the merged adapter PR.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit ✨ media proof bonus
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Risk before merge

  • [P1] GitHub reported mergeStateStatus UNSTABLE with several CI jobs still queued or running during review, so merge should wait for required checks on the current head.

Maintainer options:

  1. Decide the mitigation before merge
    Land this narrow precedence fix after ordinary maintainer review and green CI so claude-swap rows are the only Claude account presentation when multiple swap accounts are available.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No repair lane is needed; the branch already contains the narrow fix, leaving ordinary maintainer review and CI completion.

Security
Cleared: No concrete security or supply-chain concern found; the diff changes menu precedence logic, tests, docs, and a static screenshot only.

Review details

Best possible solution:

Land this narrow precedence fix after ordinary maintainer review and green CI so claude-swap rows are the only Claude account presentation when multiple swap accounts are available.

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

Yes from source inspection: current main computes token-account display and returns from the stacked token-account branch before reaching claude-swap cards when multiple Claude token accounts are configured. I did not run the macOS app in this read-only review.

Is this the best way to solve the issue?

Yes. Centralizing the precedence predicate and applying it at both the token display and card rendering seams is a narrow maintainable fix for the observed ordering bug.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: This fixes a limited but real Claude multi-account display bug where an opt-in adapter can be hidden by existing token-account UI.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): The PR body includes an inspected screenshot of a synthetic fake-cswap run showing stacked Claude account cards, which is sufficient visible UI proof for this menu precedence change.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes an inspected screenshot of a synthetic fake-cswap run showing stacked Claude account cards, which is sufficient visible UI proof for this menu precedence change.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The PR body includes an inspected screenshot of a synthetic fake-cswap run showing stacked Claude account cards, which is sufficient visible UI proof for this menu precedence change.
Evidence reviewed

What I checked:

Likely related people:

  • optimiz-r: Authored the merged claude-swap adapter commit that added the provider-neutral snapshots and stacked Claude account-card behavior this PR adjusts. (role: feature author and recent area contributor; confidence: high; commits: 88e8a537f266; files: Sources/CodexBar/StatusItemController+Menu.swift, Sources/CodexBar/Providers/Claude/UsageStore+ClaudeSwapRefresh.swift, Tests/CodexBarTests/MenuCardClaudeSwapAccountTests.swift)
  • steipete: Current history attributes the baseline menu/account-display files to steipete, the merged adapter commit includes steipete as co-author, and the PR head contains a stabilization commit from steipete. (role: recent area contributor and PR-head stabilizer; confidence: high; commits: e437044c32ba, 88e8a537f266, d77749aa2f33; files: Sources/CodexBar/StatusItemController+AccountMenuDisplay.swift, Sources/CodexBar/StatusItemController+Menu.swift, Tests/CodexBarTests/ClaudeSwapMenuPrecedenceTests.swift)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

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.
Review history (2 earlier review cycles)
  • reviewed 2026-07-05T14:31:07.000Z sha 15fbf68 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-05T15:15:00.615Z sha d77749a :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal priority bug or improvement with limited blast radius. labels Jul 5, 2026
optimiz-r and others added 2 commits July 5, 2026 08:01
…nt cards

Address Codex review: with multiple Claude token accounts in stacked layout,
the token-account branch rendered first and silently hid the adapter's rows.
Active claude-swap accounts now suppress Claude token-account presentation at
the display seam (stacked cards and the segmented switcher) and render first
in addMenuCards, with coverage in ClaudeSwapMenuPrecedenceTests.

Also add the packaged synthetic proof screenshot (fake cswap executable, no
real accounts or credentials) to docs/claude.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@steipete steipete force-pushed the fix/claude-swap-token-account-precedence branch from 15fbf68 to d77749a Compare July 5, 2026 15:12

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d77749aa2f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +612 to +615
if ClaudeSwapMenuPrecedence.prefersClaudeSwap(
provider: context.currentProvider,
accountCount: self.store.claudeSwapAccountSnapshots.count)
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve multi-account adjunct suppression

When Claude token accounts are configured in stacked mode and claude-swap later reports multiple accounts, this new precedence path renders all claude-swap account cards after tokenAccountMenuDisplay(for:) has been forced to nil. Because openAIWebContext is still computed only from token/codex showAll state, showAllAccounts becomes false and users with Claude cost history enabled get the aggregate menuCardCost/web adjunct appended under the per-account claude-swap cards; the previous stacked token-account path suppressed those aggregate rows. Treat this claude-swap precedence case as an all-accounts menu when building the context, or suppress those adjuncts before returning here.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 414c742: active claude-swap rows now count as an all-accounts menu — ClaudeSwapMenuPrecedence.prefersClaudeSwap is wired into the showAllAccounts computation, so aggregate cost/web adjunct rows are suppressed beneath the per-account cards exactly like the stacked token-account path. Docs updated accordingly.

@steipete steipete merged commit 6c4cf3a into steipete:main Jul 5, 2026
10 checks passed
@steipete

steipete commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Landed after maintainer hardening. Thank you, @optimiz-r!

Final proof on exact contributor head d77749aa2f33221703efd10ea96c78b7cbf65557:

  • GitHub CI: all 10 checks green, including all four macOS shards, both Linux builds, lint, changes, GitGuardian, and aggregate lint-build-test.
  • Focused proof: swift test --filter 'ClaudeSwap|TokenAccountMenuDisplay|MenuCardClaudeSwapAccountTests|StatusMenuHostedSubmenuRefreshTests' — 40 tests passed across 6 suites.
  • Full local suite: make test — all 48 shards passed.
  • Repository checks: make check — documentation/locales/repository gates passed; 0 format/lint violations.
  • Structured review of the maintainer fix and whole branch: clean, no accepted/actionable findings.

The landed version centralizes the precedence rule in a pure seam, removes brittle live-status-bar test setup, preserves zero/single-account and non-Claude behavior, and keeps the synthetic UI proof/docs aligned with the actual contract.

Squash merge: 6c4cf3a77f57236ff0f8ae1e334a2fe4baa50cf3

Changelog credit: 8e9a844dbd36d891dc28f3a089dae53087063f82

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants