diff --git a/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs b/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs index 01d9e34f4a..3d8e3f989c 100644 --- a/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs +++ b/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs @@ -340,10 +340,16 @@ fn profile_read_roots(user_profile: &Path) -> Vec { .collect() } +fn should_include_current_exe_read_root(dir: &Path) -> bool { + let key = canonical_path_key(dir); + !key.starts_with("c:/program files/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() + && should_include_current_exe_read_root(dir) { roots.push(dir.to_path_buf()); } @@ -840,6 +846,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; @@ -1033,6 +1040,20 @@ mod tests { assert!(roots.contains(&expected)); } + #[test] + fn current_exe_read_root_skips_windowsapps_store_installs() { + assert!(!should_include_current_exe_read_root(Path::new( + r"C:\Program Files\WindowsApps\OpenAI.Codex_26.409.1734.0_x64__2p2nqsd0c76g0\app\resources" + ))); + } + + #[test] + fn current_exe_read_root_keeps_non_store_install_dirs() { + assert!(should_include_current_exe_read_root(Path::new( + r"C:\Users\dev\AppData\Local\Programs\Codex\resources" + ))); + } + #[test] fn restricted_read_roots_skip_platform_defaults_when_disabled() { let tmp = TempDir::new().expect("tempdir");