Fix Codex official login and temp auth persistence#159
Merged
SaladDay merged 1 commit intoSaladDay:mainfrom May 6, 2026
Merged
Fix Codex official login and temp auth persistence#159SaladDay merged 1 commit intoSaladDay:mainfrom
SaladDay merged 1 commit intoSaladDay:mainfrom
Conversation
41f6638 to
969f727
Compare
There was a problem hiding this comment.
Pull request overview
This PR improves Codex “temp launch” behavior by ensuring the temporary Codex home created during cc-switch start codex is persisted back into the provider snapshot deterministically, while also preventing hidden internal commands from being blocked by startup recovery.
Changes:
- Add a hidden
__internal capture-codex-tempCLI command and bypass startup recovery for internal commands. - Persist Codex temp launch
auth.json/config.tomlback into the provider snapshot, storing an explicit empty auth snapshot whenauth.jsonis missing and stripping runtime MCP tables from stored config. - Add regression tests covering internal-command startup bypass and auth/config snapshot capture behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src-tauri/src/services/provider/tests.rs |
Adds tests asserting temp-launch snapshot capture persists auth/config and clears auth when auth.json is missing. |
src-tauri/src/services/provider/codex.rs |
Introduces capture_codex_temp_launch_snapshot and adds an explicit error for official Codex providers when the stored auth snapshot is empty. |
src-tauri/src/main.rs |
Routes the new internal command and exempts it from startup recovery; adds tests for the startup-state gate behavior. |
src-tauri/src/cli/mod.rs |
Adds the hidden __internal top-level subcommand to the CLI. |
src-tauri/src/cli/commands/mod.rs |
Exposes the new internal command module. |
src-tauri/src/cli/commands/internal.rs |
Implements __internal capture-codex-temp execution path that captures the Codex temp launch snapshot. |
src-tauri/src/cli/codex_temp_launch.rs |
Extends the Unix handoff wrapper to invoke the internal capture command before removing the temp Codex home. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
79bdd21 to
af4d9be
Compare
af4d9be to
0e6739a
Compare
Owner
|
LGTM, THANKS! |
Contributor
Author
|
Thanks for the quick review and merge! Really appreciate the fast turnaround. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
This PR fixes the
openai-officialCodex provider flow in two parts.1. Switching to
openai-officialshould not break Codex TUI startupBefore this PR, switching to the OpenAI official provider could write an empty live
~/.codex/auth.json. That is different from having no auth file at all: Codex sees the file, tries to load account credentials from it during TUI bootstrap, and then fails with the account/read error instead of entering its normal login flow.This PR treats an empty auth snapshot for an official Codex provider as "no saved login". When applying
openai-official, cc-switch removes the live~/.codex/auth.jsoninstead of writing{}. With no live auth file present, Codex follows its normal official login path, so the TUI no longer trips over an empty auth file during startup.2. Temporary
cc-switch start codex openai-officiallogin state should be written backcc-switch start codex openai-officiallaunches Codex with an isolated temporaryCODEX_HOMEseeded from the selected provider. This avoids mutating the user's global Codex home while the temporary start session is running.After Codex exits, cc-switch captures useful state from that temporary home back into the selected provider. If the user logs in during the temporary start session, the temp
auth.jsonis saved back into theopenai-officialprovider so the next start can reuse it.If the provider was already logged in and the user logs out during the temporary start session, Codex removes the temp
auth.json. The capture step records that logout state in the provider, and later applying or startingopenai-officialkeepsauth.jsonabsent rather than writing an empty{}file. This preserves logout without reintroducing the TUI startup error.Summary
~/.codex/auth.jsonwhen switching to an official Codex provider with an empty auth snapshot, so Codex can prompt for login normally instead of failing during TUI startup.cc-switch start codex openai-officialwith a temporaryCODEX_HOMEseeded from the selected provider snapshot.auth.jsonandconfig.tomlback into the selected provider snapshot.auth.jsonas logout state, and make later live/temp application delete or omitauth.jsonrather than writing an empty{}file.config.tomlbefore saving it back into the provider.internalcommand name instead of__internalto avoid Bash completion generation panics.Tests
cargo fmtcargo test codex_temp_launchcargo test internal_commands_bypass_future_schema_database_gatecargo test commands_that_skip_startup_state_do_not_touch_future_schema_databasecargo test completionscargo run --quiet -- completions bashcargo build --release/home/timidly/.local/bin/cc-switch --version/home/timidly/.local/bin/cc-switch completions bash