From 67b66d1e08fe80fdfacccd56b7d60e3d05c52ad3 Mon Sep 17 00:00:00 2001 From: jif-oai Date: Wed, 12 Nov 2025 13:19:51 +0000 Subject: [PATCH] NIT --- codex-rs/exec/src/lib.rs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/codex-rs/exec/src/lib.rs b/codex-rs/exec/src/lib.rs index 3949cf5857..6a307152b9 100644 --- a/codex-rs/exec/src/lib.rs +++ b/codex-rs/exec/src/lib.rs @@ -101,13 +101,23 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option) -> any None => prompt.clone(), }; - let regular_prompt_opt = parent_or_resume_prompt_arg.map(|p| { - if p == "-" { - read_prompt_from_stdin_or_exit(true) - } else { - p + // Determine the regular prompt. If explicitly "-", read from stdin. + // If omitted, read from stdin when non‑TTY; otherwise exit with a message. + let regular_prompt_opt = match parent_or_resume_prompt_arg { + Some(p) => { + if p == "-" { + Some(read_prompt_from_stdin_or_exit(true)) + } else { + Some(p) + } } - }); + None => match &command { + // Review subcommand handles its own inputs later. + Some(ExecCommand::Review(_)) => None, + // Default/Resume flows: honor piped stdin or exit if TTY. + _ => Some(read_prompt_from_stdin_or_exit(false)), + }, + }; let output_schema = load_output_schema(output_schema_path); @@ -378,7 +388,10 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option) -> any .into_iter() .map(|path| UserInput::LocalImage { path }) .collect(); - let text = regular_prompt_opt.unwrap_or_default(); + let text = match regular_prompt_opt { + Some(t) => t, + None => read_prompt_from_stdin_or_exit(false), + }; items.push(UserInput::Text { text }); let id = conversation .submit(Op::UserTurn {