Skip to content

Commit 917ab70

Browse files
[0.160] Backport remaining Windows console fix to frozen alpha.6 (#49386)
Backport #49308 onto the frozen 0.160.0-alpha.6 content commit c248f6d for the Windows console flashing issue #48074. That base already contains #49164, so only the missing patch is included. This does not advance the baked candidate to current main or publish stable 0.160. The cherry-pick applied cleanly and its stable patch ID matches upstream. `git diff --check` passes. Native Windows validation on this exact candidate is still pending. Keep this PR in draft pending review, required checks, and focused unelevated-sandbox smoke evidence for external processes (whoami.exe, cmd.exe, Git, nested PowerShell), alongside built-ins, with and without the managed daemon. Record exact candidate SHA, CLI/daemon versions, CODEX_HOME, configuration, command output, exit codes, duration and visible console observations. The unresolved hang report at #48074 (comment) is not proof these changes caused a regression, but requires investigation before treating the candidate as validated. Co-authored-by: Eric Traut <[email protected]>
1 parent c248f6d commit 917ab70

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

‎codex-rs/windows-sandbox-rs/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ mod windows_impl {
764764
&env_map,
765765
logs_base_dir,
766766
Some((in_r, out_w, err_w)),
767-
ConsoleMode::Inherit,
767+
ConsoleMode::NoWindow,
768768
desktop,
769769
)
770770
});

‎codex-rs/windows-sandbox-rs/src/unified_exec/backends/legacy.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ fn spawn_legacy_process(
115115
StdinMode::Closed
116116
},
117117
StderrMode::Separate,
118-
ConsoleMode::Inherit,
118+
ConsoleMode::NoWindow,
119119
launch_desktop,
120120
logs_base_dir,
121121
)?;

‎codex-rs/windows-sandbox-rs/src/unified_exec/tests.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ use windows_sys::Win32::System::Threading::WaitForSingleObject;
5050
static TEST_HOME_COUNTER: AtomicU64 = AtomicU64::new(0);
5151
static LEGACY_PROCESS_TEST_LOCK: Mutex<()> = Mutex::new(());
5252

53+
const ASSERT_NO_CONSOLE: &str = r#"Add-Type -ErrorAction Stop 'using System; using System.Runtime.InteropServices; public class ConsoleProbe { [DllImport("kernel32.dll")] public static extern IntPtr GetConsoleWindow(); }'; if ([ConsoleProbe]::GetConsoleWindow() -ne [IntPtr]::Zero) { throw 'piped sandbox process unexpectedly has a console' };"#;
54+
5355
fn legacy_process_test_guard() -> MutexGuard<'static, ()> {
5456
LEGACY_PROCESS_TEST_LOCK
5557
.lock()
@@ -460,7 +462,7 @@ fn legacy_non_tty_powershell_interrupt_terminates_process() {
460462
pwsh.display().to_string(),
461463
"-NoProfile".to_string(),
462464
"-Command".to_string(),
463-
"Write-Output LEGACY-NONTTY-DIRECT; [System.Threading.ManualResetEvent]::new($false).WaitOne()".to_string(),
465+
format!("{ASSERT_NO_CONSOLE} Write-Output LEGACY-NONTTY-DIRECT; [System.Threading.ManualResetEvent]::new($false).WaitOne()"),
464466
],
465467
cwd.as_path(),
466468
HashMap::new(),
@@ -681,7 +683,7 @@ fn legacy_capture_emits_output_and_preserves_descendant_after_normal_exit() {
681683
powershell_literal(&ready_marker),
682684
);
683685
let parent_command = format!(
684-
"Write-Output LEGACY-CAPTURE-DIRECT; {}",
686+
"{ASSERT_NO_CONSOLE} Write-Output LEGACY-CAPTURE-DIRECT; {}",
685687
start_powershell_child(&pwsh, codex_home.path(), &descendant_command, &parent_tail,),
686688
);
687689
let permission_profile = PermissionProfile::workspace_write();

0 commit comments

Comments
 (0)