Skip to content

Add Codex all-accounts menu mode and sorting#633

Open
monterrr wants to merge 3 commits intosteipete:mainfrom
monterrr:codex-all-accounts-menu-mode
Open

Add Codex all-accounts menu mode and sorting#633
monterrr wants to merge 3 commits intosteipete:mainfrom
monterrr:codex-all-accounts-menu-mode

Conversation

@monterrr
Copy link
Copy Markdown
Contributor

@monterrr monterrr commented Apr 1, 2026

Context

This is the remaining follow-up to the Codex multi-account work around #545, first proposed in #588 and partially landed in #613.

The same-email / workspace correctness gap is being handled in #629. This PR focuses on the remaining menu-side work: a simple all-accounts overview, cached loading, and the old sort modes.

Once multiple Codex accounts are available, the current menu still makes you inspect them one by one. In practice that means repeated switching just to answer simple questions like which account still has room left, which one resets first, and which one is already close to empty.

Screenshots

All mode: compact passive quota cards with sort control.
codex-all-accounts-mode

Single mode: the detailed card stays in place, with the new All | Single control above it.
codex-single-mode

Summary

This PR adds a simple All | Single mode for Codex.

Without an all-accounts view, multi-account support still leaves a practical gap: the data exists, but the user still has to hop through accounts one at a time to compare them.

  • Single keeps the current detailed account card
  • All shows a compact overview of every visible Codex account
  • the overview uses passive stacked cards, keeps only the key quota information, and supports the same simple sort modes from the earlier multi-account work
  • background refresh and cached per-account snapshots keep switching and menu-open behavior responsive without mutating the active account selection

What this adds

  • All | Single mode toggle for Codex, hidden when only one visible account exists
  • in Single mode, the current detailed card and account pills stay in place
  • in All mode, the account switcher is hidden and replaced with passive compact cards that show only:
    • compact account label
    • Session
    • Weekly
  • simple sort control in All mode with the 6 existing sort modes:
    • Name A-Z
    • Name Z-A
    • Session left down
    • Session reset soonest
    • Weekly left down
    • Weekly reset soonest
  • cached per-account Codex snapshots so switching back and forth feels immediate
  • bounded background refresh for the remaining visible accounts when All mode opens
  • stale deleted-account recovery when a removed managed Codex account was still selected and there is an unambiguous replacement

Validation

  • corepack pnpm check
  • ./Scripts/compile_and_run.sh
  • focused Codex tests covering the changed surfaces, including:
    • swift test --filter StatusMenuCodexSwitcherTests
    • swift test --filter CodexManagedOpenAIWebTests
    • swift test --filter CodexManagedRoutingTests
    • swift test --filter CodexAccountScopedRefreshTests

monterrr and others added 3 commits March 31, 2026 11:19
Co-Authored-By: Craft Agent <agents-noreply@craft.do>
Co-Authored-By: Craft Agent <agents-noreply@craft.do>
Co-Authored-By: Craft Agent <agents-noreply@craft.do>
Copy link
Copy Markdown

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

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: df30db742e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +438 to +442
guard let model = self.menuCardModel(
for: context.currentProvider,
snapshotOverride: cached?.snapshot,
errorOverride: cached?.error,
isRefreshingOverride: cached == nil && self.store.codexAllAccountsRefreshInFlight)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid falling back to active snapshot in all-account cards

When an account has no cached entry (or only a cached error), this passes nil as snapshotOverride, and menuCardModel then falls back to the global Codex snapshot for the currently selected account. In All mode this makes other account cards temporarily render the active account’s usage/identity data, so users can see duplicated or incorrect quota values until each fetch finishes (or while a fetch error persists). Build the all-accounts card model without provider fallback when cached?.snapshot is missing.

Useful? React with 👍 / 👎.

let usage = try await context.fetcher.loadLatestUsage(keepCLISessionsAlive: keepAlive)
var usage = try await context.fetcher.loadLatestUsage(keepCLISessionsAlive: keepAlive)
if let credentials = try? CodexOAuthCredentialsStore.load(env: context.env) {
let resolvedWorkspaceIdentity = try? await CodexOpenAIWorkspaceResolver.resolve(credentials: credentials)
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 Keep CLI usage refresh non-blocking for workspace lookup

This now awaits workspace resolution on every CLI fetch, which couples a local usage read to an extra network request. Since the resolver uses an HTTP call with a 20-second timeout, slow/offline environments can have each refresh delayed even when usage data is already available. Workspace identity enrichment should be best-effort (cache-first / background update) so a transient account-lookup failure does not stall normal Codex usage polling.

Useful? React with 👍 / 👎.

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