diff --git a/codex-rs/tui/src/tui.rs b/codex-rs/tui/src/tui.rs index 39849471b5..2b4e67e6af 100644 --- a/codex-rs/tui/src/tui.rs +++ b/codex-rs/tui/src/tui.rs @@ -1,6 +1,7 @@ use std::io::IsTerminal; use std::io::Result; use std::io::Stdout; +use std::io::stdin; use std::io::stdout; use std::pin::Pin; use std::sync::Arc; @@ -131,6 +132,9 @@ pub fn restore() -> Result<()> { /// Initialize the terminal (inline viewport; history stays in normal scrollback) pub fn init() -> Result { + if !stdin().is_terminal() { + return Err(std::io::Error::other("stdin is not a terminal")); + } if !stdout().is_terminal() { return Err(std::io::Error::other("stdout is not a terminal")); } @@ -490,7 +494,7 @@ impl Tui { } } - std::io::stdout().sync_update(|_| { + stdout().sync_update(|_| { #[cfg(unix)] { if let Some(prepared) = prepared_resume.take() {