English | 简体中文
PowerShell helper for moving Codex Desktop history between Codex providers. History-only sync is the default; full provider switching through CC Switch is opt-in.
Codex Desktop groups conversation history by model_provider. If you only change ~/.codex/config.toml, the desktop sidebar can look empty after switching providers: the history still exists, but its local model_provider metadata points at a different bucket.
Cabbage Switch fixes that by rewriting the local model_provider label in both history stores:
~/.codex/sessions/**/*.jsonl~/.codex/state_*.sqlite, especiallythreads.model_provider
It works with any number of providers. It inspects your CC Switch Codex providers, shows you a command for each, and runs that command on demand. There are no hardcoded codex-api / codex-openai command names.
For the implementation details, see How Cabbage Switch Works.
- Windows PowerShell or PowerShell 7
- Python 3 available as
pythonorpy - Codex Desktop installed and already used at least once
- CC Switch installed and configured with Codex providers (one or more)
No API keys are stored in this repository or in the installed helper script.
Run this in PowerShell:
irm https://raw.githubusercontent.com/4sa1ary9/cabbage-switch/main/scripts/install.ps1 | iexThen reload the current shell:
. $PROFILEOr simply open a new PowerShell window.
git clone git@github.com:4sa1ary9/cabbage-switch.git
cd cabbage-switch
powershell -ExecutionPolicy Bypass -File .\scripts\install.ps1PowerShell 7 works too:
pwsh -File .\scripts\install.ps1The installer copies src/CabbageSwitch.ps1 to:
~\.cabbage-switch\CabbageSwitch.ps1
It also adds a small managed block to your PowerShell profile so the commands are loaded automatically.
First, see what Cabbage Switch detected on this machine:
cabbage-switch
# short alias:
cswitchThis prints each Codex provider found in CC Switch and the command to move history into it, for example:
Detected Codex providers:
id name history_provider
default OpenAI openai
d7486227 my api proxy tec-do [current]
Move active history to a provider bucket (history only, the default):
cabbage-switch default
cabbage-switch tec-do
Then run the command for the provider you want history moved to:
cabbage-switch default
cabbage-switch tec-doYou can use the provider id, its display name, or its model_provider value.
Include archived Codex threads as well:
cabbage-switch tec-do -IncludeArchivedSwitch the active provider through CC Switch and then sync history:
cabbage-switch tec-do -SwitchProviderInspect current detection and history state:
Show-CabbageSwitchStatusShort alias:
cs-statusCabbage Switch lists every Codex provider it finds in:
~\.cc-switch\cc-switch.db
For each provider it reads the stored Codex config payload and uses its real model_provider value as the history bucket. This keeps the tool portable across machines: it does not assume a provider named api, custom, or any fixed id.
When you pass a provider to cabbage-switch, it matches it by id, display name, or model_provider value, so you can type whatever is easiest to remember.
Before editing state_*.sqlite, the script creates a SQLite-consistent backup:
~\.codex\backups\state_5.sqlite.cabbage-switch-YYYYMMDD-HHMMSS.bak
JSONL files are updated in place and their timestamps are restored afterward.
If Codex Desktop is already open, the sync can still update the index, but you usually need to fully exit and reopen Codex Desktop before the sidebar refreshes. Closing only the window may leave Codex running in the tray.
If history still does not appear:
- Run
cs-statusand check thatstate.sqliteandjsonlcounts match the provider bucket you expect. - Fully exit Codex Desktop from the tray or Task Manager.
- Reopen Codex Desktop.
- Run
cabbage-switch <provider>again for the bucket you want history in.
If a provider is not listed by cabbage-switch, open CC Switch once and confirm it is a Codex provider. Only Codex providers appear.
If some JSONL files report Locked in the summary, Codex Desktop was still running and holding them open. Fully exit Codex Desktop (tray Quit, or end the Codex processes in Task Manager) and rerun the same command. Already-moved files are skipped on rerun; only the locked ones update.
src/CabbageSwitch.ps1 Core PowerShell functions
scripts/install.ps1 One-step installer
examples/basic-usage.ps1 Daily usage examples
docs/how-it-works.md History and provider switching internals
docs/restore.md Restore notes
This project is licensed under the MIT License.