fix(codex): use relative filename for model_catalog_json#3614
Merged
farion1231 merged 2 commits intoJun 3, 2026
Conversation
Instead of writing an absolute path (which breaks on WSL/symlink setups), write only the filename "cc-switch-model-catalog.json" to config.toml. Codex CLI resolves relative paths from the config directory, and both files always reside in the same directory (~/.codex/). This eliminates the need for UNC-to-Linux path translation and makes the config portable across Windows, WSL, and symlinked directories. Also simplifies ownership checks in resolve_cc_switch_catalog_path() and set_codex_model_catalog_json_field() by removing dead string-equality comparisons that never matched on WSL. Closes farion1231#3573 Related: farion1231#3569
steponeerror
force-pushed
the
fix/wsl-codex-model-catalog-path
branch
2 times, most recently
from
June 2, 2026 15:10
36d75d7 to
438a72d
Compare
Owner
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Wrap a >100-col UNC-path line and remove a trailing blank line that broke 'cargo fmt --check' in Backend CI. Style-only, no logic change.
2 tasks
AnXiYiZhi
pushed a commit
to AnXiYiZhi/DevCLaw-old
that referenced
this pull request
Jun 9, 2026
…3614) * fix(codex): use relative filename for model_catalog_json Instead of writing an absolute path (which breaks on WSL/symlink setups), write only the filename "cc-switch-model-catalog.json" to config.toml. Codex CLI resolves relative paths from the config directory, and both files always reside in the same directory (~/.codex/). This eliminates the need for UNC-to-Linux path translation and makes the config portable across Windows, WSL, and symlinked directories. Also simplifies ownership checks in resolve_cc_switch_catalog_path() and set_codex_model_catalog_json_field() by removing dead string-equality comparisons that never matched on WSL. Closes farion1231#3573 Related: farion1231#3569 * style(codex): fix rustfmt violations in model_catalog tests Wrap a >100-col UNC-path line and remove a trailing blank line that broke 'cargo fmt --check' in Backend CI. Style-only, no logic change. --------- Co-authored-by: steponeerror <[email protected]> Co-authored-by: Jason <[email protected]>
gfunc
pushed a commit
to gfunc/cc-switch
that referenced
this pull request
Jun 19, 2026
…3614) * fix(codex): use relative filename for model_catalog_json Instead of writing an absolute path (which breaks on WSL/symlink setups), write only the filename "cc-switch-model-catalog.json" to config.toml. Codex CLI resolves relative paths from the config directory, and both files always reside in the same directory (~/.codex/). This eliminates the need for UNC-to-Linux path translation and makes the config portable across Windows, WSL, and symlinked directories. Also simplifies ownership checks in resolve_cc_switch_catalog_path() and set_codex_model_catalog_json_field() by removing dead string-equality comparisons that never matched on WSL. Closes farion1231#3573 Related: farion1231#3569 * style(codex): fix rustfmt violations in model_catalog tests Wrap a >100-col UNC-path line and remove a trailing blank line that broke 'cargo fmt --check' in Backend CI. Style-only, no logic change. --------- Co-authored-by: steponeerror <[email protected]> Co-authored-by: Jason <[email protected]>
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.
Closes #3573
Related: #3569
Problem / 问题描述
When cc-switch runs on Windows and the Codex config directory is a WSL path (e.g.
\\wsl.localhost\Ubuntu\home\user\.codex), the generatedconfig.tomlcontains a Windows UNC path inmodel_catalog_json:当 cc-switch 在 Windows 上运行,且 Codex 配置目录是 WSL 路径时,生成的
config.toml中model_catalog_json字段包含 Windows UNC 路径:Codex CLI runs inside WSL and cannot resolve UNC paths. Additionally, users who symlink their
.codexdirectory across Windows/WSL (e.g.ln -s /mnt/c/Users/xxx/.codex ~/.codex) will break with any absolute path format.Codex CLI 在 WSL 中运行,无法解析 UNC 路径。此外,通过符号链接跨系统共享
.codex目录的用户,无论使用 Linux 还是 Windows 绝对路径,都会在某一端失效。Summary / 方案概述
Write only the filename
cc-switch-model-catalog.json(relative path) toconfig.toml. Sinceconfig.tomland the catalog file always reside in the same directory (~/.codex/), Codex CLI correctly resolves relative paths from the config directory.仅写入文件名
cc-switch-model-catalog.json(相对路径)到config.toml。由于config.toml和 catalog 文件始终在同一目录下,Codex CLI 会从配置目录解析相对路径。This eliminates the need for platform-specific path translation and makes the config portable across Windows, WSL, and symlinked directories.
这消除了平台特定路径转换的需求,使配置在 Windows、WSL 和符号链接目录之间可移植。
Key Changes / 主要变更
set_codex_model_catalog_json_field():Somearm writes onlyCC_SWITCH_CODEX_MODEL_CATALOG_FILENAMEinstead of the full absolute pathresolve_cc_switch_catalog_path(): Removed dead string-equality comparison that never matched on WSLset_codex_model_catalog_json_field()None arm: Ownership is now determined solely by filename matchDeleted
wsl_unc_to_linux_path()helper and all its tests (no longer needed)set_codex_model_catalog_json_field():Some分支仅写入CC_SWITCH_CODEX_MODEL_CATALOG_FILENAME而非完整绝对路径resolve_cc_switch_catalog_path():移除了在 WSL 上永远不匹配的字符串相等比较set_codex_model_catalog_json_field()None 分支:所有权判断仅通过文件名匹配删除了
wsl_unc_to_linux_path()辅助函数及其所有测试(不再需要)Test Plan / 测试计划
model_catalog_json_field_writes_relative_filename— verifies relative output / 验证相对路径输出set_catalog_json_field_writes_filename_for_any_path— verifies any input path produces filename / 验证任意输入路径生成文件名set_catalog_json_field_writes_filename_ignoring_unc_path— Windows-only, verifies UNC path input / 仅 Windows,验证 UNC 路径输入set_catalog_json_none_removes_cc_switch_owned_by_filename— backward compat with absolute paths / 向后兼容绝对路径set_catalog_json_none_removes_relative_path— verifies removal of new relative path format / 验证移除新的相对路径格式set_catalog_json_none_preserves_user_owned_catalog— verifies user catalogs untouched / 验证用户自有 catalog 不受影响resolve_catalog_finds_relative_filename— verifies read path handles relative / 验证读取路径处理相对路径resolve_catalog_ignores_user_owned_relative— verifies user catalogs ignored / 验证用户自有 catalog 被忽略Supersedes #3574 (that approach used UNC-to-Linux path translation instead of relative paths)
取代 #3574(该方案使用 UNC 转 Linux 路径翻译,而非相对路径)