From 3ea33a06165018a83d6838e36eea938c55e4ccdf Mon Sep 17 00:00:00 2001 From: Josh McKinney Date: Fri, 21 Nov 2025 14:17:40 -0800 Subject: [PATCH] fix(tui): Fail when stdin is not a terminal (#6382) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Piping to codex fails to do anything useful and locks up the process. We currently check for stdout, but not stdin ``` ❯ echo foo|just c cargo run --bin codex -- "$@" Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.21s Running `target/debug/codex` Error: stdin is not a terminal error: Recipe `codex` failed on line 10 with exit code 1 ``` --- codex-rs/tui/src/tui.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/codex-rs/tui/src/tui.rs b/codex-rs/tui/src/tui.rs index d758996d2..7cbf252e7 100644 --- a/codex-rs/tui/src/tui.rs +++ b/codex-rs/tui/src/tui.rs @@ -2,6 +2,7 @@ use std::fmt; use std::io::IsTerminal; use std::io::Result; use std::io::Stdout; +use std::io::stdin; use std::io::stdout; use std::panic; use std::pin::Pin; @@ -127,6 +128,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")); }