From 97e46694e1459f758fe03c297e31f40ba1384cd4 Mon Sep 17 00:00:00 2001 From: jif Date: Fri, 4 Sep 2026 12:33:16 +0000 Subject: [PATCH] Stabilize the interactive tmux startup safety test (#42755) ## What changed - Wait for the directory trust prompt before shutting down the TUI. - Retry the decline key while the trust screen drains pending input, and keep consuming PTY output until the process exits. - Include captured TUI output when shutdown times out. GitOrigin-RevId: cb88523a72915787a436da4f16fb13450fa7a175 --- codex-rs/cli/tests/doctor_path_safety.rs | 26 ++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/codex-rs/cli/tests/doctor_path_safety.rs b/codex-rs/cli/tests/doctor_path_safety.rs index cce1addf42..96530ca952 100644 --- a/codex-rs/cli/tests/doctor_path_safety.rs +++ b/codex-rs/cli/tests/doctor_path_safety.rs @@ -4,6 +4,8 @@ use std::ffi::OsString; use std::path::PathBuf; use std::time::Duration; +#[cfg(unix)] +use anyhow::Context; use anyhow::Result; use app_test_support::TestAppServer; use codex_app_server_protocol::RequestId; @@ -242,14 +244,34 @@ async fn interactive_tmux_startup_does_not_execute_workspace_helpers() -> Result anyhow::bail!("TUI exited before trust prompt") }) .await; - session.terminate(); - let _ = timeout(Duration::from_secs(/*secs*/ 10), spawned.exit_rx).await?; ready.map_err(|_| { anyhow::anyhow!( "trust prompt timed out: {}", output.chars().take(/*n*/ 4000).collect::() ) })??; + // The trust screen discards pending input after its first draw. Retry the quit key + // until that drain has finished, and keep consuming output during normal shutdown. + let mut quit_retry = tokio::time::interval(Duration::from_millis(/*millis*/ 250)); + let mut exit_rx = spawned.exit_rx; + timeout(Duration::from_secs(/*secs*/ 10), async { + loop { + tokio::select! { + result = &mut exit_rx => return result, + _ = quit_retry.tick() => { + let _ = writer.send(b"2".to_vec()).await; + } + Some(_) = output_rx.recv() => {} + } + } + }) + .await + .with_context(|| { + format!( + "TUI did not exit after declining directory trust: {}", + output.chars().take(/*n*/ 4000).collect::() + ) + })??; assert!( output.contains("\x1b[>5u"), "expected safe Ghostty/tmux keyboard flags: {output}"