Skip to content

fix(acp): drop an inherited CODEX_PATH so Codex uses its bundled CLI - #920

Open
Frank-zhu2000 wants to merge 1 commit into
spacering-net:mainfrom
Frank-zhu2000:fix/656-code-mode-host-duration
Open

Frank-zhu2000 wants to merge 1 commit into
spacering-net:mainfrom
Frank-zhu2000:fix/656-code-mode-host-duration

Conversation

@Frank-zhu2000

Copy link
Copy Markdown

Fixes #656

Root cause

The shell_command failure (unknown field code_mode_host_duration_ns) is a serde error raised inside Codex, not by codeg's parser. Codeg's Codex child process inherits CODEX_PATH from the user's environment. When it is set, codex-acp spawns that binary instead of the @openai/codex bundled with the adapter. A desktop/CLI install at Codex ≤0.151 decodes the code-mode IPC Result with deny_unknown_fields and only knows cell_id, content_items, error_text. The newer codex-code-mode-host (0.152+) also sends code_mode_host_duration_ns, so decoding fails before shell_command runs.

Change

src-tauri/src/acp/connection.rs: the Codex env policy now pushes an empty CODEX_PATH. The existing spawn layer already turns an empty value into env_remove, so codex-acp falls back to its matched bundled pair. A non-empty CODEX_PATH set explicitly in the runtime env still wins. Unit tests cover the new behavior (one test was red before the fix).

Verification (src-tauri, Linux)

  • cargo test --features test-utils --lib codex_env_policy_: 6 passed (the new test failed before the fix)
  • cargo test --features test-utils: exit 0
  • cargo clippy --all-targets --features test-utils -- -D warnings: exit 0
  • cargo test --no-default-features --features server-bin --bin codeg-server --lib: exit 0 (run with CARGO_BUILD_JOBS=1 because of local memory)
  • cargo clippy --no-default-features --features server-bin --bin codeg-server --lib -- -D warnings: exit 0
  • Frontend jobs: not run, because no frontend or lockfile files changed.
  • Note: cargo fmt --check with rustfmt 1.99 already reports differences on the untouched base tree. CI does not run fmt, and the new code is not in those hunks.

I couldn't reproduce this on Windows locally. The analysis comes from reading the codex-acp and openai/codex sources (rust-v0.151.0 vs rust-v0.152.0 payload).

This change was prepared with help from an AI coding assistant and reviewed by me.

codex-acp spawns CODEX_PATH instead of the @openai/codex shipped with the
adapter. A desktop or CLI install can pair an older client, whose decoder
expects only cell_id, content_items, and error_text, with a newer
codex-code-mode-host that sends code_mode_host_duration_ns. Every code-mode
shell_command then fails before it runs (spacering-net#656). An empty value is the spawn
layer's env_remove. An explicit non-empty runtime CODEX_PATH still wins.
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.

shell_command 调用因未知字段 code_mode_host_duration_ns 解析失败

1 participant