Skip to content

fix(codex): respect user-owned model_catalog_json when generating catalog - #454

Open
czfhhh wants to merge 1 commit into
SaladDay:mainfrom
czfhhh:fix/preserve-user-model-catalog-json
Open

fix(codex): respect user-owned model_catalog_json when generating catalog#454
czfhhh wants to merge 1 commit into
SaladDay:mainfrom
czfhhh:fix/preserve-user-model-catalog-json

Conversation

@czfhhh

@czfhhh czfhhh commented Sep 11, 2026

Copy link
Copy Markdown

Summary

Port the user-owned model-catalog fix from the desktop upstream (farion1231/cc-switch#6087). When model mapping generates the Codex catalog, cc-switch-cli currently replaces any existing model_catalog_json value with cc-switch-model-catalog.json. This PR makes the write side preserve user-managed catalog pointers.

Problem

set_codex_model_catalog_json_field in src-tauri/src/codex_config.rs has two arms:

  • The None arm already checks ownership and only removes cc-switch-owned pointers.
  • The Some arm unconditionally writes CC_SWITCH_CODEX_MODEL_CATALOG_FILENAME, clobbering user paths such as ~/.codex/model-catalog.local.json.

Starting the Codex local route with model mapping enabled therefore rewrites config.toml, breaking setups that depend on a user-managed catalog file. This builds on #265, which closed #260 by switching the same write to a relative filename.

Fix

Mirror the None arm's ownership rule in the Some arm: claim the pointer only when it is absent or already cc-switch-owned (matched by filename); otherwise leave the user's catalog path untouched. The generated cc-switch-model-catalog.json file is still written, so model-mapping based proxy routing keeps working.

Testing

  • cargo fmt --check passes.
  • cargo test --lib: 4334 passed, 0 failed, 2 ignored (CI-style sandbox environment).
  • Added two unit tests covering the Some arm:
    • set_catalog_json_some_preserves_user_owned_catalog (absolute custom path)
    • set_catalog_json_some_preserves_user_owned_relative_filename (bare custom filename)
  • Manually verified: with model mapping enabled and a user-owned model_catalog_json, enabling the Codex local route keeps the pointer in config.toml and multi-model routing continues to work.

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.

fix(codex): model_catalog_json uses absolute path and archived sessions not discoverable

1 participant