Skip to content

Codex account switch cannot move running panes, and 'Restart Sessions' destroys the conversation — no Claude equivalent #19589

Closed

Description

@TheAbyss

Summary

Switching the active Codex account does not move existing Codex panes, and the offered remedy — "Restart N Sessions" — starts a fresh codex process rather than resuming the pane's conversation. The practical result is that a user cannot move a running Codex pane to a different account without destroying that pane's conversation and any unsent composer draft.

The same operation for Claude has no equivalent problem, and no equivalent machinery. That asymmetry is the core of this report.

Why it happens

A Codex pane's account identity is bound at process launch via CODEX_HOME, which cannot be changed on a running process:

  • src/main/rate-limits/codex-backend-auth.ts:71 — return codexHomePath ?? process.env.CODEX_HOME ?? join(homedir(), '.codex')
  • src/main/rate-limits/codex-auth-presence.ts:63 — same resolution order

So runtime-account-controller.ts:92 selectCodex() changes which account new panes get, while existing panes keep the old one. To cope, the app ships a stale-account/restart apparatus:

StatusBar.tsx:599-624 ("N Codex sessions are still on the old account" / "Restart N Sessions"), CodexRestartChip.tsx, codex-restart-notice-state.ts, codex-restart-status-summary.ts, codex-pane-stale.ts, codex-detached-pane-restart.ts, codex-pane-restart-eligibility.ts, codex-restart-notice-account-identity.ts, and more.

Counted in this tree: 25 non-test source files reference the Codex stale-account/restart flow. There are zero Claude analogues — no staleClaude, no claudeRestart, and no "old account" string outside Codex paths. selectClaude() takes effect without asking the user to restart anything.

The second half: restart is not resume

src/renderer/src/lib/codex-session-restart.ts — the default CODEX_ACCOUNT_RESTART_STARTUP is a fresh codex invocation, not an exact resume. TerminalPane.tsx handleRestartCodexPane clears the notice/binding, disposes the transport, and reconnects with that fresh command. The detached-pane executor has ownership/generation guards but likewise starts codex.

src/main/codex/codex-session-resume-preparation.ts can return outcome: fresh when provenance is missing, and nothing refuses that outcome before replacing the original process.

Notably, the Codex CLI already exposes codex resume <SESSION_ID> (and fork, queue, archive) — so an exact-resume restart looks achievable without new protocol work.

Third: the label reports the wrong thing

The account shown for a pane reflects the selected default, not the account that pane is actually bound to. With two accounts under the same email, panes on different accounts are indistinguishable in the UI, so a user cannot tell which panes are stale. (codex-restart-notice-account-identity.ts, CodexRestartChip.tsx.)

Reproduction

  1. Add two Codex accounts (ours share one email address, which makes step 4 clearly visible).
  2. Open several Codex panes and let them accumulate conversation.
  3. Switch the active Codex account in Settings.
  4. Observe: panes keep running on the previous account; the status bar offers "Restart N Sessions".
  5. Click it: panes come back on the new account with no conversation history and any unsent draft gone.

Impact for us

We run a large number of concurrent Codex panes across many worktrees. Because panes cannot follow an account switch, our automated account rotation moved the default while ~21 live panes stayed on the exhausted account, and the only remedy on offer would have discarded their in-flight work — including an unsent draft and a build in progress. We exhausted a full weekly Codex allowance in 41 minutes partly while working around this.

Being straight with you about how we found it: one of our own agents diagnosed this, then went further than it should have — it cloned this repository and began writing fixes across five branches, burning a substantial amount of our Codex session quota before we caught it. That was our process failure, not yours. We are not going to keep investing in fixing your code.

We are sending one of those branches as a partial fix in a separate PR, purely so the diagnosis is not wasted. It is not a complete solution and we are not proposing to maintain it — please treat it as evidence and take it wherever you think is right. Note that a second branch touching the account-identity labels failed our own source review and is deliberately not included.

What would help most

Ranked by value to us:

  1. Make an account switch either move existing panes or resume them exactly (codex resume <session-id>), so no conversation is lost.
  2. Show each pane's actual bound account, not the selected default.
  3. Reach parity with the Claude path, so Codex does not need a bespoke stale/restart apparatus at all.

Environment

  • Orca 1.4.194 (com.stablyai.orca), macOS 15 / Darwin 25.6.0, Apple Silicon
  • Codex CLI 0.153.4
  • Two Codex accounts on one email; plan types pro and self_serve_business_prolite

Activity

  1. TheAbyss commented on Sep 16, 2026

    @TheAbyss
    Author

    @brennanb2025 @nwparker — tagging you as the de-facto owners of the Codex account surface (you two authored essentially all of src/main/codex account-switch work). Sorry for the ping; this has been open 8 days with no triage and we would like to know whether it is wanted before it goes any further stale.

    Two things that have changed since filing:

    1. An independent reproduction landed. [Bug]: Restart chip does not move a running Codex pane to the newly selected account (Windows, 1.4.200) #20142 (filed 2026-09-11 by @scursel, Windows, 1.4.200) reports the same core symptom from a different user and platform: the Restart chip does not move a running Codex pane to the newly selected account. Claude account switch does not reach a running session; two panes in one worktree can run on two accounts #19900 reports the same asymmetry now showing up on Claude accounts. So this is not specific to our setup.
    2. Nothing in v1.4.199–v1.4.204 addresses it. The Codex work that shipped in that range (fix(codex): distinguish personal and enterprise accounts sharing an email #19279 personal-vs-enterprise disambiguation, fix(codex): reconcile marketplace and plugin tables through the config mirror #20150 marketplace/plugin config mirror, the structured-chat resume fixes) is adjacent but does not touch moving a running pane across an account switch, or restarting via codex resume <session-id> instead of a fresh codex.

    We are not asking anyone to take our PR. #19590 is a partial fix and we said in it that we are not maintaining the branch — CodeRabbit rated it low-priority with a merge conflict, and that is a fair call. Close it whenever you like.

    What would actually help is a one-line disposition on this issue: is the account-switch-cannot-move-a-running-pane behaviour considered a bug you intend to fix, or is it working as designed? If it is by design, we will stop treating it as one and document the wind-down-and-respawn workaround on our side instead. Either answer closes it out for us.

  2. added theissue type on Sep 19, 2026
  3. Tauri-EPO commented on Sep 22, 2026

    @Tauri-EPO
    Contributor

    Additional Windows evidence from an isolated reproduction against package version 1.4.197, source commit 197550c952563647802b844ebff643ecdf55276c. This is evidence for the existing issue, not a new duplicate report or a test of the latest release.

    The reported user workflow is: switch accounts when the old account runs out of quota, accept the restart prompt, then manually recover affected conversations through Agent History because the restarted panes are not usable as expected. With many sessions, some are missed. Claude account switching works for this user's workflow; this report does not claim a Claude regression.

    What the isolated test establishes

    • Seed a Codex pane in the real renderer store with a known synthetic providerSession and an existing synthetic PTY.
    • Mark an account A-to-B restart notice and accept it through queueCodexPaneRestarts.
    • Execute the real detached restart sweep with only window.api.pty.spawn and pty.kill mocked.
    • The replacement command is exactly codex, the previous PTY is passed to the kill mock, and the pending restart queue becomes empty. The captured conversation ID is absent from the replacement command.
    • The desired continuity assertion therefore fails. As a passing control, buildAgentResumeStartupPlan with the same session, platform: 'win32', and shell: 'powershell' emits a command containing both resume and that exact session ID.

    The shared restart startup constant and detached executor agree with the observation. The passing command-builder control does not prove that a real cross-account resume has completed successfully.

    Suggested acceptance criteria

    The accepted restart should prepare the captured conversation for the selected account's home, resume that exact conversation in its existing pane, and provide a recoverable failure if that is not possible. Starting a fresh conversation or resuming against the depleted account's home should not count as success. The existing History resume preparation and startup builder are worth reusing, with those outcomes checked explicitly.

    For orchestrated sessions, preserve logical pane/task continuity while correctly rebinding the replacement process. Do not silently retarget stale process handles; account switching needs a separate end-to-end check of that handoff. Orchestration continuity was not exercised by this test.

    No real Codex process, ConPTY, Electron window, login, credential change, or live session was used in this reproduction. It establishes the detached restart's command/state behavior, not the root cause of every Windows terminal failure.

    The complete executable fixture and its two passing controls/two failing assertions are included in #22243. That issue tracks a separate reproduced defect: one pending spawn blocks later accepted restarts in the detached sweep.

  4. nwparker commented on Oct 24, 2026

    @nwparker
    Contributor

    Thanks for the thorough report @TheAbyss. Restarting Codex sessions after an account switch now resumes the same conversation on the newly selected account (#25485, v1.4.222), and hidden-pane restarts were fixed in #31994 (v1.4.239). Could you retry on the latest build? If Restart still loses conversations or doesn't move a pane, please reply or reopen.

  5. nwparker commented on Nov 5, 2026

    @nwparker
    Contributor

    Closing as completed — Codex account-switch session resumption without losing the conversation or blanking the terminal landed in #25485 (40f9e7a3fc, fix(codex): resume account switches without blanking the terminal) and #31994.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions