From d2317ff8069272d43923c2dd76e304a26834abc5 Mon Sep 17 00:00:00 2001 From: iceweasel-oai Date: Wed, 15 Apr 2026 05:29:03 -0700 Subject: [PATCH] fix(windows-sandbox): skip WindowsApps helper roots --- .../src/setup_orchestrator.rs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs b/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs index e0a5a063f9..ca87c64b3d 100644 --- a/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs +++ b/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs @@ -341,10 +341,20 @@ fn profile_read_roots(user_profile: &Path) -> Vec { .collect() } +fn is_windowsapps_install_path(path: &Path) -> bool { + path.components().any(|component| { + component + .as_os_str() + .to_string_lossy() + .eq_ignore_ascii_case("WindowsApps") + }) +} + fn gather_helper_read_roots(codex_home: &Path) -> Vec { let mut roots = Vec::new(); if let Ok(exe) = std::env::current_exe() && let Some(dir) = exe.parent() + && !is_windowsapps_install_path(dir) { roots.push(dir.to_path_buf()); } @@ -867,6 +877,7 @@ mod tests { use std::collections::HashMap; use std::collections::HashSet; use std::fs; + use std::path::Path; use std::path::PathBuf; use tempfile::TempDir; @@ -1060,6 +1071,16 @@ mod tests { assert!(roots.contains(&expected)); } + #[test] + fn windowsapps_install_paths_are_skipped_for_helper_roots() { + assert!(is_windowsapps_install_path(Path::new( + r"C:\Program Files\WindowsApps\OpenAI.Codex_1.0.0_x64__token\app\resources" + ))); + assert!(!is_windowsapps_install_path(Path::new( + r"C:\Program Files\OpenAI\Codex\app\resources" + ))); + } + #[test] fn restricted_read_roots_skip_platform_defaults_when_disabled() { let tmp = TempDir::new().expect("tempdir");