fix: preserve Codex Desktop config during provider switches#4698
fix: preserve Codex Desktop config during provider switches#4698jiangliushi666 wants to merge 1 commit into
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 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".
| crate::codex_config::preserve_codex_desktop_owned_config_sections( | ||
| target_config, | ||
| existing_config, | ||
| ) | ||
| .map_err(|e| format!("保留 Codex Desktop 配置失败: {e}"))?; |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
config.tomlsections (plugins,marketplaces,desktop,projects,tui,windows,notice) when switching Codex providersmodel_provider,model_providers, endpoint, bearer token) sourced from the selected provider to avoid cross-provider leakagesuperpowers@openai-api-curatedplugin sectionRoot cause
Codex provider switching rebuilt
~/.codex/config.tomlfrom the selected provider's storedsettings_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 = truesection disappeared fromconfig.toml, making Codex Desktop prompt for the plugin again.Testing
git diff --checkcargo test --features test-hooks ...because this local shell does not havecargo/rustcinstalled or on PATH.