diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rs index 4196c3925c..3a9a13dd7f 100644 --- a/codex-rs/tui/src/bottom_pane/chat_composer.rs +++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs @@ -488,12 +488,8 @@ impl ChatComposer { // If the user already typed positional args on the first line, // expand immediately and submit; otherwise insert "/name " so // they can type args. - let first_line = self - .textarea - .text() - .lines() - .next() - .unwrap_or(""); + let first_line = + self.textarea.text().lines().next().unwrap_or(""); let args = extract_args_for_prompt(first_line, &prompt.name); if !args.is_empty() { let expanded = @@ -503,8 +499,7 @@ impl ChatComposer { } else { let text = format!("/{} ", prompt.name); self.textarea.set_text(&text); - self.textarea - .set_cursor(self.textarea.text().len()); + self.textarea.set_cursor(self.textarea.text().len()); } } // Popup visibility will be synchronized by the caller after this returns. @@ -910,6 +905,7 @@ impl ChatComposer { if self .paste_burst .newline_should_insert_instead_of_submit(now) + && !in_slash_context { self.textarea.insert_str("\n"); self.paste_burst.extend_window(now); @@ -942,10 +938,8 @@ impl ChatComposer { return (InputResult::None, true); } }; - let mut applied_named = false; if let Some(expanded) = expanded_prompt { text = expanded; - applied_named = true; } else { // Fallback to numeric/positional placeholder expansion if this is a // slash command referring to a known custom prompt. diff --git a/codex-rs/tui/src/bottom_pane/prompt_args.rs b/codex-rs/tui/src/bottom_pane/prompt_args.rs index 699d4c3992..4f0f2d91bd 100644 --- a/codex-rs/tui/src/bottom_pane/prompt_args.rs +++ b/codex-rs/tui/src/bottom_pane/prompt_args.rs @@ -130,6 +130,11 @@ pub fn expand_custom_prompt( None => return Ok(None), }; let rest = stripped[name_end..].trim(); + // If the prompt has no named placeholders, defer to positional handling. + let required = prompt_argument_names(&prompt.content); + if required.is_empty() { + return Ok(None); + } let inputs = parse_prompt_inputs(rest).map_err(|error| PromptExpansionError::Args { command: format!("/{name}"), error,