Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

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

Josh McKinney3ea33a061650
diff --git a/codex-rs/tui/src/tui.rs b/codex-rs/tui/src/tui.rs
index d758996d26..7cbf252e7f 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<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"));
}