Skip to content

Commit 795f2d1

Browse files
cameronhotchkiesnpub1x4hk035p3p9q39a3fcrd2fe30lpkrhr5dwe0cqzzjphxyyh8m0gsq4vqapcodex
authored
fix(discovery): inject PATH into Codex adapter planning (#2767)
## 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 <[email protected]>
1 parent 9ec08af commit 795f2d1

3 files changed

Lines changed: 37 additions & 8 deletions

File tree

‎desktop/scripts/check-file-sizes.mjs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,9 @@ const overrides = new Map([
500500
// Includes unit tests for detection, routing, and -Command body preservation.
501501
// +16: test_powershell_command_goose_catalog_dequoted proves the \$→$ escape
502502
// fix for the Goose Windows installer (PR #2680 interaction with #2750).
503-
["src-tauri/src/commands/agent_discovery.rs", 1826],
503+
// +10: pass an explicit PATH through Codex adapter install planning so unit
504+
// tests avoid the process-global login-shell PATH cache.
505+
["src-tauri/src/commands/agent_discovery.rs", 1836],
504506
// draft-persistence predicate: submit-time `loadDraft` check + inline comment
505507
// + deps-array entry in submitMessage closes the never-persisted-boundary
506508
// defect (Thufir Pass-3 finding). Load-bearing correctness fix; queued to

‎desktop/src-tauri/src/commands/agent_discovery.rs‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,19 @@ pub(crate) fn plan_adapter_install<'c>(
4444
runtime_id: &str,
4545
adapter_path: Option<&std::path::Path>,
4646
adapter_install_commands: &'c [&'c str],
47+
adapter_probe_path: Option<&str>,
4748
) -> Option<Vec<&'c str>> {
4849
match adapter_path {
4950
// Adapter present and current — no install needed.
5051
Some(_) if runtime_id != "codex" => None,
51-
Some(path) if !crate::managed_agents::codex_adapter_is_outdated(path) => None,
52+
Some(path)
53+
if !crate::managed_agents::codex_adapter_is_outdated_with_path(
54+
path,
55+
adapter_probe_path,
56+
) =>
57+
{
58+
None
59+
}
5260
// Codex adapter is outdated: uninstall the old package first so npm
5361
// doesn't hit EEXIST on the shared `codex-acp` bin-link, then install.
5462
Some(_) => Some(vec![
@@ -176,10 +184,12 @@ fn install_acp_runtime_blocking(runtime_id: &str) -> Result<InstallRuntimeResult
176184
.commands
177185
.iter()
178186
.find_map(|cmd| crate::managed_agents::resolve_command(cmd));
187+
let adapter_probe_path = crate::managed_agents::readiness::cli_probe::augmented_path();
179188
if let Some(cmds) = plan_adapter_install(
180189
runtime_id,
181190
adapter_path.as_deref(),
182191
runtime.adapter_install_commands,
192+
adapter_probe_path.as_deref(),
183193
) {
184194
let use_managed_npm =
185195
cmds.iter().any(|cmd| is_npm_global_install(cmd)) && managed_node_runtime_supported();
@@ -1180,7 +1190,7 @@ mod tests {
11801190
.expect("chmod script");
11811191

11821192
let install_cmds = &["npm install -g @agentclientprotocol/codex-acp"];
1183-
let plan = plan_adapter_install("codex", Some(&bin), install_cmds);
1193+
let plan = plan_adapter_install("codex", Some(&bin), install_cmds, Some("/usr/bin:/bin"));
11841194

11851195
assert!(
11861196
plan.is_some(),
@@ -1215,7 +1225,7 @@ mod tests {
12151225
.expect("chmod script");
12161226

12171227
let install_cmds = &["npm install -g @agentclientprotocol/codex-acp"];
1218-
let plan = plan_adapter_install("codex", Some(&bin), install_cmds);
1228+
let plan = plan_adapter_install("codex", Some(&bin), install_cmds, Some("/usr/bin:/bin"));
12191229

12201230
assert!(
12211231
plan.is_none(),
@@ -1226,7 +1236,7 @@ mod tests {
12261236
#[test]
12271237
fn test_plan_adapter_install_returns_catalog_cmds_when_no_adapter_path() {
12281238
let install_cmds = &["npm install -g @agentclientprotocol/codex-acp"];
1229-
let plan = plan_adapter_install("codex", None, install_cmds);
1239+
let plan = plan_adapter_install("codex", None, install_cmds, None);
12301240
assert!(plan.is_some(), "missing adapter must trigger install plan");
12311241
// Missing arm: use the catalog's install commands directly (no prior
12321242
// package to uninstall — fresh install, not a reinstall).
@@ -1250,7 +1260,7 @@ mod tests {
12501260
.expect("chmod script");
12511261

12521262
let install_cmds = &["npm install -g @block/goose-acp"];
1253-
let plan = plan_adapter_install("goose", Some(&bin), install_cmds);
1263+
let plan = plan_adapter_install("goose", Some(&bin), install_cmds, None);
12541264
assert!(
12551265
plan.is_none(),
12561266
"non-codex runtime with resolved binary must not trigger reinstall"

‎desktop/src-tauri/src/managed_agents/discovery.rs‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,9 +1153,26 @@ pub(crate) fn codex_adapter_availability(path: &Path) -> AcpAvailabilityStatus {
11531153
}
11541154

11551155
/// Returns `true` when the codex-acp binary at `path` is outdated (major version < 1)
1156-
/// or cannot be probed. Thin wrapper around [`codex_adapter_availability`].
1156+
/// or cannot be probed using `augmented_path`. Thin wrapper around
1157+
/// [`codex_adapter_is_outdated_with_path`].
1158+
#[cfg(test)]
11571159
pub(crate) fn codex_adapter_is_outdated(path: &Path) -> bool {
1158-
codex_adapter_availability(path) == AcpAvailabilityStatus::AdapterOutdated
1160+
codex_adapter_is_outdated_with_path(
1161+
path,
1162+
crate::managed_agents::readiness::cli_probe::augmented_path().as_deref(),
1163+
)
1164+
}
1165+
1166+
/// Returns `true` when the codex-acp binary at `path` is outdated (major version < 1)
1167+
/// or cannot be probed with the supplied PATH.
1168+
pub(crate) fn codex_adapter_is_outdated_with_path(
1169+
path: &Path,
1170+
augmented_path: Option<&str>,
1171+
) -> bool {
1172+
!matches!(
1173+
probe_codex_acp_major_version_with_path(path, augmented_path),
1174+
Some(major) if major >= 1
1175+
)
11591176
}
11601177

11611178
/// Intermediate struct built before the (potentially slow) auth probe phase.

0 commit comments

Comments
 (0)