From 1baea40acba33d8b7884f5b80dcfc2d1086b0a1f Mon Sep 17 00:00:00 2001 From: David Wiesen Date: Fri, 22 May 2026 09:57:40 -0700 Subject: [PATCH] windows-sandbox: surface refresh helper failures --- .../src/setup_orchestrator.rs | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs b/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs index ef952a4e03..c16dc4f83c 100644 --- a/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs +++ b/codex-rs/windows-sandbox-rs/src/setup_orchestrator.rs @@ -190,10 +190,26 @@ fn run_setup_refresh_inner( let json = serde_json::to_vec(&payload)?; let b64 = BASE64_STANDARD.encode(json); let exe = find_setup_exe(); + let sandbox_log_dir = sandbox_dir(request.codex_home); + let cleared_report = match clear_setup_error_report(request.codex_home) { + Ok(()) => true, + Err(err) => { + log_note( + &format!( + "setup orchestrator: failed to clear setup_error.json before refresh launch: {err}" + ), + Some(&sandbox_log_dir), + ); + false + } + }; // Refresh should never request elevation; ensure verb isn't set and we don't trigger UAC. let mut cmd = Command::new(&exe); - cmd.arg(&b64).stdout(Stdio::null()).stderr(Stdio::null()); - let cwd = std::env::current_dir().unwrap_or_else(|_| request.codex_home.to_path_buf()); + let cwd = request.codex_home.to_path_buf(); + cmd.arg(&b64) + .current_dir(&cwd) + .stdout(Stdio::null()) + .stderr(Stdio::null()); log_note( &format!( "setup refresh: spawning {} (cwd={}, payload_len={})", @@ -201,14 +217,14 @@ fn run_setup_refresh_inner( cwd.display(), b64.len() ), - Some(&sandbox_dir(request.codex_home)), + Some(&sandbox_log_dir), ); let status = cmd .status() .map_err(|e| { log_note( &format!("setup refresh: failed to spawn {}: {e}", exe.display()), - Some(&sandbox_dir(request.codex_home)), + Some(&sandbox_log_dir), ); e }) @@ -216,9 +232,21 @@ fn run_setup_refresh_inner( if !status.success() { log_note( &format!("setup refresh: exited with status {status:?}"), - Some(&sandbox_dir(request.codex_home)), + Some(&sandbox_log_dir), + ); + return Err(report_helper_failure( + request.codex_home, + cleared_report, + status.code(), + )); + } + if let Err(err) = clear_setup_error_report(request.codex_home) { + log_note( + &format!( + "setup orchestrator: failed to clear setup_error.json after refresh success: {err}" + ), + Some(&sandbox_log_dir), ); - return Err(anyhow!("setup refresh failed with status {status}")); } Ok(()) }