Skip to content

fix: preserve Codex Desktop config during provider switches#4698

Open
jiangliushi666 wants to merge 1 commit into
farion1231:mainfrom
jiangliushi666:codex/preserve-codex-plugin-config
Open

fix: preserve Codex Desktop config during provider switches#4698
jiangliushi666 wants to merge 1 commit into
farion1231:mainfrom
jiangliushi666:codex/preserve-codex-plugin-config

Conversation

@jiangliushi666

Copy link
Copy Markdown

Summary

  • preserve Codex Desktop-owned config.toml sections (plugins, marketplaces, desktop, projects, tui, windows, notice) when switching Codex providers
  • keep provider-owned routing (model_provider, model_providers, endpoint, bearer token) sourced from the selected provider to avoid cross-provider leakage
  • strip Codex Desktop-owned sections during switch-away backfill so provider snapshots do not store stale local plugin/Desktop state
  • add regression coverage for provider switching with a superpowers@openai-api-curated plugin section

Root cause

Codex provider switching rebuilt ~/.codex/config.toml from the selected provider's stored settings_config.config. If Codex Desktop later wrote plugin or marketplace state directly into the live config, that live-only state was not present in CC Switch's stored provider snapshot and was overwritten on the next provider switch. The plugin cache remained on disk, but the [plugins."superpowers@openai-api-curated"] enabled = true section disappeared from config.toml, making Codex Desktop prompt for the plugin again.

Testing

  • git diff --check
  • Not run: cargo test --features test-hooks ... because this local shell does not have cargo/rustc installed or on PATH.

@farion1231

Copy link
Copy Markdown
Owner

@codex review

@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: 335b877d44

ℹ️ 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 +2191 to +2195
crate::codex_config::preserve_codex_desktop_owned_config_sections(
target_config,
existing_config,
)
.map_err(|e| format!("保留 Codex Desktop 配置失败: {e}"))?;

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 Merge Desktop sections from live takeover config

In the proxy hot-switch path, this helper is called from update_live_backup_from_provider_inner with existing_config loaded from get_live_backup, not from the current live ~/.codex/config.toml. When Codex Desktop writes [plugins]/[marketplaces] while takeover is active and the user then switches providers, the live proxy config is refreshed from the current live file, but the restore backup saved here keeps only the stale Desktop sections from the old backup; disabling takeover later restores that backup and drops the plugin/marketplace state added during takeover. The backup update needs to merge these Codex Desktop-owned sections from current live as well, or this preservation is incomplete for proxy-mode switches.

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.

2 participants