From 8a3f640950850d2561a49cd47a9b99ea33f04975 Mon Sep 17 00:00:00 2001 From: David Wiesen Date: Tue, 21 Apr 2026 10:21:08 -0700 Subject: [PATCH] Clarify Windows sandbox helper cancellation --- .../src/setup_orchestrator.rs | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs b/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs index ef952a4e03..311b10fd5f 100644 --- a/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs +++ b/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs @@ -596,6 +596,17 @@ fn report_helper_failure( } } +fn setup_helper_launch_failure_message(last_error: u32) -> String { + if last_error == ERROR_CANCELLED { + "Windows canceled the sandbox setup helper launch (Win32 error 1223). \ +This usually means the Administrator/UAC prompt was dismissed, denied, or blocked by policy; \ +try again and approve the elevation request." + .to_string() + } else { + format!("ShellExecuteExW failed to launch setup helper: {last_error}") + } +} + fn run_setup_exe( payload: &ElevationPayload, needs_elevation: bool, @@ -682,7 +693,7 @@ fn run_setup_exe( }; return Err(failure( code, - format!("ShellExecuteExW failed to launch setup helper: {last_error}"), + setup_helper_launch_failure_message(last_error), )); } unsafe { @@ -950,6 +961,7 @@ mod tests { use super::offline_proxy_settings_from_env; use super::profile_read_roots; use super::proxy_ports_from_env; + use super::setup_helper_launch_failure_message; use crate::helper_materialization::helper_bin_dir; use crate::policy::SandboxPolicy; use codex_utils_absolute_path::AbsolutePathBuf; @@ -1454,4 +1466,13 @@ mod tests { .all(|path| roots.contains(&path)) ); } + + #[test] + fn canceled_helper_launch_message_is_actionable() { + let message = setup_helper_launch_failure_message(super::ERROR_CANCELLED); + + assert!(message.contains("Win32 error 1223")); + assert!(message.contains("Administrator/UAC prompt")); + assert!(message.contains("approve the elevation request")); + } }