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
This commit is contained in:
jif
2026-09-04 12:48:10 +00:00
committed by copyberry
parent 1cd78651e2
commit 97e46694e1
+24 -2
View File
@@ -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::<String>()
)
})??;
// 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::<String>()
)
})??;
assert!(
output.contains("\x1b[>5u"),
"expected safe Ghostty/tmux keyboard flags: {output}"