fix(tui): Fail when stdin is not a terminal (#6382)

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
```
This commit is contained in:
Josh McKinney 2025-11-21 14:17:40 -08:00 committed by GitHub
parent e8ef6d3c16
commit 3ea33a0616
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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<Terminal> {
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"));
}