From 6ab3835f3fe89ee215819fe8d193463c0ae7472b Mon Sep 17 00:00:00 2001 From: Cameron Hotchkies Date: Sat, 25 Jul 2026 07:07:04 -0700 Subject: [PATCH] fix(discovery): inject PATH into Codex adapter planning (#2767) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Why The Codex adapter install-plan test depended on the process-global login-shell PATH cache, making it flaky under concurrent or loaded CI runs. ## What - Thread an explicit probe PATH through adapter install planning - Use a controlled PATH in Codex install-plan tests - Update the existing desktop file-size allowance for the focused seam ## Risk Assessment Low — production behavior keeps using the same augmented PATH; only dependency injection and deterministic tests change. ## References - Failure: https://github.com/block/buzz/actions/runs/30110680608/job/89539202266 - Validation: `just desktop-tauri-test`; `cd desktop && pnpm check`; full pre-push hooks Generated with Codex --------- Signed-off-by: npub1x4hk035p3p9q39a3fcrd2fe30lpkrhr5dwe0cqzzjphxyyh8m0gsq4vqap <356f67c681884a0897b14e06d527317fc361dc746bb2fc0042906e6212e7dbd1@buzz.block.builderlab.xyz> Co-authored-by: npub1x4hk035p3p9q39a3fcrd2fe30lpkrhr5dwe0cqzzjphxyyh8m0gsq4vqap <356f67c681884a0897b14e06d527317fc361dc746bb2fc0042906e6212e7dbd1@buzz.block.builderlab.xyz> Co-authored-by: Codex --- desktop/scripts/check-file-sizes.mjs | 4 +++- .../src-tauri/src/commands/agent_discovery.rs | 20 +++++++++++++----- .../src-tauri/src/managed_agents/discovery.rs | 21 +++++++++++++++++-- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/desktop/scripts/check-file-sizes.mjs b/desktop/scripts/check-file-sizes.mjs index 96f97126e..f34b6dc33 100644 --- a/desktop/scripts/check-file-sizes.mjs +++ b/desktop/scripts/check-file-sizes.mjs @@ -500,7 +500,9 @@ const overrides = new Map([ // Includes unit tests for detection, routing, and -Command body preservation. // +16: test_powershell_command_goose_catalog_dequoted proves the \$→$ escape // fix for the Goose Windows installer (PR #2680 interaction with #2750). - ["src-tauri/src/commands/agent_discovery.rs", 1826], + // +10: pass an explicit PATH through Codex adapter install planning so unit + // tests avoid the process-global login-shell PATH cache. + ["src-tauri/src/commands/agent_discovery.rs", 1836], // draft-persistence predicate: submit-time `loadDraft` check + inline comment // + deps-array entry in submitMessage closes the never-persisted-boundary // defect (Thufir Pass-3 finding). Load-bearing correctness fix; queued to diff --git a/desktop/src-tauri/src/commands/agent_discovery.rs b/desktop/src-tauri/src/commands/agent_discovery.rs index 7b1979d65..e3d9b2218 100644 --- a/desktop/src-tauri/src/commands/agent_discovery.rs +++ b/desktop/src-tauri/src/commands/agent_discovery.rs @@ -44,11 +44,19 @@ pub(crate) fn plan_adapter_install<'c>( runtime_id: &str, adapter_path: Option<&std::path::Path>, adapter_install_commands: &'c [&'c str], + adapter_probe_path: Option<&str>, ) -> Option> { match adapter_path { // Adapter present and current — no install needed. Some(_) if runtime_id != "codex" => None, - Some(path) if !crate::managed_agents::codex_adapter_is_outdated(path) => None, + Some(path) + if !crate::managed_agents::codex_adapter_is_outdated_with_path( + path, + adapter_probe_path, + ) => + { + None + } // Codex adapter is outdated: uninstall the old package first so npm // doesn't hit EEXIST on the shared `codex-acp` bin-link, then install. Some(_) => Some(vec![ @@ -176,10 +184,12 @@ fn install_acp_runtime_blocking(runtime_id: &str) -> Result AcpAvailabilityStatus { } /// Returns `true` when the codex-acp binary at `path` is outdated (major version < 1) -/// or cannot be probed. Thin wrapper around [`codex_adapter_availability`]. +/// or cannot be probed using `augmented_path`. Thin wrapper around +/// [`codex_adapter_is_outdated_with_path`]. +#[cfg(test)] pub(crate) fn codex_adapter_is_outdated(path: &Path) -> bool { - codex_adapter_availability(path) == AcpAvailabilityStatus::AdapterOutdated + codex_adapter_is_outdated_with_path( + path, + crate::managed_agents::readiness::cli_probe::augmented_path().as_deref(), + ) +} + +/// Returns `true` when the codex-acp binary at `path` is outdated (major version < 1) +/// or cannot be probed with the supplied PATH. +pub(crate) fn codex_adapter_is_outdated_with_path( + path: &Path, + augmented_path: Option<&str>, +) -> bool { + !matches!( + probe_codex_acp_major_version_with_path(path, augmented_path), + Some(major) if major >= 1 + ) } /// Intermediate struct built before the (potentially slow) auth probe phase.