Skip to content

fix(switching): improve account switching reliability and UX#22

Open
Fzhiyu1 wants to merge 1 commit intoLampese:mainfrom
Fzhiyu1:fix/switch-account-feedback
Open

fix(switching): improve account switching reliability and UX#22
Fzhiyu1 wants to merge 1 commit intoLampese:mainfrom
Fzhiyu1:fix/switch-account-feedback

Conversation

@Fzhiyu1
Copy link

@Fzhiyu1 Fzhiyu1 commented Mar 11, 2026

Summary

  • improve account switching UX with an in-app confirmation modal and a Switch New Sessions Only option
  • ignore Codex.app app-server when detecting blocking Codex foreground processes and surface switching failures in the UI
  • reclaim stale ~/.codex/auth.json.lock files left behind by dead processes

Test Plan

  • node --test --experimental-strip-types tests/switching.test.ts
  • pnpm build
  • cargo test auth::fs_utils::tests::acquire_reclaims_stale_lock_file
  • cargo test commands::account::tests
  • cargo test commands::process::tests

@Fzhiyu1 Fzhiyu1 force-pushed the fix/switch-account-feedback branch from 124adf6 to 20cc287 Compare March 11, 2026 03:16
@Fzhiyu1 Fzhiyu1 changed the title Improve account switching reliability and UX fix(switching): improve account switching reliability and UX Mar 11, 2026
@Lampese Lampese requested a review from joonshakya March 11, 2026 19:57
@joonshakya
Copy link
Collaborator

joonshakya commented Mar 12, 2026

In my testing, I was not able to get the account switched properly without needing to quit codex.
I've made a video with the result I found. Can you please let me know if I am missing something?
The video has audio as well.

2026-03-12_09-57-06_compressed_50fps.mp4

@Fzhiyu1
Copy link
Author

Fzhiyu1 commented Mar 12, 2026

I watched the video and your observations are basically correct.

What this PR is trying to do is not hot-switch the currently running Codex app / CLI process. The non-restart path is only meant to update the auth for the next launch / next new process, without forcing the current one to restart immediately.

So for Codex.app, needing to fully quit and reopen before the change takes effect is expected with the current implementation.

And for CLI, I also agree with your point about Restart and Switch being disruptive. That was actually the reason I added the non-restart option, because killing an active TUI / terminal session is pretty rough.

I think the confusing part here is the wording. Switch New Sessions Only probably sounds like a new chat inside the already running app should pick up the new account, but that is not what this implementation does.

If that behavior is too confusing or not a good fit for the project, I'm okay reducing the scope of the PR and removing that part.

@joonshakya
Copy link
Collaborator

Hi @Fzhiyu1
The previous commit in PR #15 had caused some issues so we're trying to revert that commit in PR #23 .

That version of codex-switcher used to gray out account switching option when Codex.app or Codex CLI was running in the background which is I think the more stable flow.
We do like the idea of switching the model in next session of Codex CLI.

Could you take a look at the code in the main branch and make refinements there, If your changes still align with how the app works right now?
Sorry for the inconvenience.

Thank you for your contribution.

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.

2 participants