Keep the Windows sandbox command runner hidden (#42801)

## What changed

- Build `codex-command-runner` as a Windows-subsystem binary outside tests.
- Launch non-TTY sandbox commands without a console window.
- Suppress the busy cursor when creating the elevated runner process.

GitOrigin-RevId: fc6b70059add7dea642805030bd508915367fe44
This commit is contained in:
chess
2026-09-04 16:55:31 +00:00
committed by copyberry
parent 80ab0ffafe
commit 89a4eec6da
3 changed files with 5 additions and 8 deletions

View File

@@ -1,3 +1,5 @@
#![cfg_attr(all(target_os = "windows", not(test)), windows_subsystem = "windows")]
#[cfg(target_os = "windows")]
mod win;

View File

@@ -77,9 +77,6 @@ use windows_sys::Win32::System::Threading::PROCESS_INFORMATION;
use windows_sys::Win32::System::Threading::TerminateProcess;
use windows_sys::Win32::System::Threading::WaitForSingleObject;
// Kept in sync with codex_exec_server::CODEX_FS_HELPER_ARG1 without introducing
// a dependency cycle.
const FS_HELPER_ARG: &str = "--codex-run-as-fs-helper";
const READ_ACL_MUTEX_NAME: &str = "Local\\CodexSandboxReadAcl";
const TERMINATION_WAIT_MS: u32 = 5_000;
const WAIT_TIMEOUT: u32 = 0x0000_0102;
@@ -355,11 +352,7 @@ fn spawn_ipc_process(req: &SpawnRequest) -> Result<IpcSpawnedProcess> {
&req.env,
stdin_mode,
StderrMode::Separate,
if req.command.get(1).is_some_and(|arg| arg == FS_HELPER_ARG) {
ConsoleMode::NoWindow
} else {
ConsoleMode::Inherit
},
ConsoleMode::NoWindow,
desktop,
Some(log_dir.as_path()),
)?;

View File

@@ -43,6 +43,7 @@ use windows_sys::Win32::System::Threading::CreateProcessWithLogonW;
use windows_sys::Win32::System::Threading::GetCurrentProcess;
use windows_sys::Win32::System::Threading::GetCurrentThread;
use windows_sys::Win32::System::Threading::PROCESS_INFORMATION;
use windows_sys::Win32::System::Threading::STARTF_FORCEOFFFEEDBACK;
use windows_sys::Win32::System::Threading::STARTUPINFOW;
use windows_sys::Win32::System::Threading::TerminateProcess;
use windows_sys::Win32::System::Threading::WaitForSingleObject;
@@ -350,6 +351,7 @@ pub(crate) fn spawn_runner_transport(
let password_w = to_wide(&sandbox_creds.password);
let mut si: STARTUPINFOW = unsafe { std::mem::zeroed() };
si.cb = std::mem::size_of::<STARTUPINFOW>() as u32;
si.dwFlags = STARTF_FORCEOFFFEEDBACK;
let mut pi: PROCESS_INFORMATION = unsafe { std::mem::zeroed() };
let env_block: Option<Vec<u16>> = None;