diff --git a/codex-rs/core/src/unified_exec/session_manager.rs b/codex-rs/core/src/unified_exec/session_manager.rs index b56cfbdd86..5429a9fbb1 100644 --- a/codex-rs/core/src/unified_exec/session_manager.rs +++ b/codex-rs/core/src/unified_exec/session_manager.rs @@ -90,10 +90,11 @@ fn strip_ansi_escape_sequences(input: &str) -> String { break; } if c == '\u{1b}' - && let Some('\\') = iter.peek().copied() { - let _ = iter.next(); - break; - } + && let Some('\\') = iter.peek().copied() + { + let _ = iter.next(); + break; + } } } Some(_) => { @@ -211,7 +212,10 @@ impl UnifiedExecSessionManager { let wall_time = Instant::now().saturating_duration_since(start); let raw_text = String::from_utf8_lossy(&collected).to_string(); + #[cfg(target_os = "windows")] let text = normalize_unified_exec_text(&raw_text); + #[cfg(not(target_os = "windows"))] + let text = raw_text; let output = formatted_truncate_text(&text, TruncationPolicy::Tokens(max_tokens)); let has_exited = session.has_exited(); let exit_code = session.exit_code(); @@ -334,7 +338,10 @@ impl UnifiedExecSessionManager { let wall_time = Instant::now().saturating_duration_since(start); let raw_text = String::from_utf8_lossy(&collected).to_string(); + #[cfg(target_os = "windows")] let text = normalize_unified_exec_text(&raw_text); + #[cfg(not(target_os = "windows"))] + let text = raw_text; let output = formatted_truncate_text(&text, TruncationPolicy::Tokens(max_tokens)); let original_token_count = approx_token_count(&text); let chunk_id = generate_chunk_id(); diff --git a/codex-rs/core/tests/suite/unified_exec.rs b/codex-rs/core/tests/suite/unified_exec.rs index 852f735fe4..96ad6ae93f 100644 --- a/codex-rs/core/tests/suite/unified_exec.rs +++ b/codex-rs/core/tests/suite/unified_exec.rs @@ -2390,23 +2390,14 @@ async fn windows_unified_exec_escape_output_snapshot() -> Result<()> { let raw_output = parsed.output.as_str(); - // assert!( - // raw_output.contains("UEXEC-WINDOWS-ESCAPES"), - // "expected marker string in unified_exec output, got {raw_output:?}" - // ); - // assert!( - // !raw_output.contains('\u{1b}'), - // "expected unified_exec output to be stripped of ANSI escape sequences on Windows, got {raw_output:?}" - // ); - - // Intentionally failing assertion so CI logs show the raw PTY output, - // including any escape sequences produced by ConPTY / PowerShell. - let expected = "UEXEC-WINDOWS-ESCAPES\n"; - assert_eq!( - raw_output, expected, - "raw unified_exec PTY output on Windows (expected simple marker, got full stream)" + assert!( + raw_output.contains("UEXEC-WINDOWS-ESCAPES"), + "expected marker string in unified_exec output, got {raw_output:?}" + ); + assert!( + !raw_output.contains('\u{1b}'), + "expected unified_exec output to be stripped of ANSI escape sequences on Windows, got {raw_output:?}" ); - assert!(false); Ok(()) }