Lightweight coding agent that runs in your terminal
Rust
Keep slash command prefixes in editable composer text (#56021)
Benjamin Carlsson233119375db9
diff --git a/codex-rs/tui/src/app/owned_transcript_tests.rs b/codex-rs/tui/src/app/owned_transcript_tests.rsindex 511240d380..a68938e517 100644--- a/codex-rs/tui/src/app/owned_transcript_tests.rs+++ b/codex-rs/tui/src/app/owned_transcript_tests.rs@@ -1586,10 +1586,9 @@ async fn fullscreen_composer_mouse_copy_and_input_ownership() -> Result<()> {// A fresh composer click takes ownership away from the transcript selection.app.handle_owned_transcript_event(&mut tui, &mut server, &mouse(Down(Left), x, y))?;assert!(!app.transcript_view.has_active_interaction());- app.chat_widget.apply_external_edit("/model".into());+ app.chat_widget.apply_external_edit("/".into());assert!(!app.chat_widget.no_modal_or_popup_active());- let event = mouse(Down(Left), x, y);- assert!(app.handle_owned_transcript_event(&mut tui, &mut server, &event)?);+ assert!(app.handle_owned_transcript_event(&mut tui, &mut server, &mouse(Down(Left), x, y))?);app.handle_owned_transcript_event(&mut tui, &mut server, &mouse(Drag(Left), x + 1, y))?;assert!(app.chat_widget.no_modal_or_popup_active());app.chat_widget.open_feature_enable_prompt(Feature::Collab);diff --git a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__slash_picker_overlays_history.snap b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__slash_picker_overlays_history.snapindex 9dc62f57ba..20e5d5c268 100644--- a/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__slash_picker_overlays_history.snap+++ b/codex-rs/tui/src/app/snapshots/codex_tui__app__owned_transcript__tests__slash_picker_overlays_history.snap@@ -12,7 +12,7 @@ Transcript row 34: content behind the menu/mention mention a file/mcp list MCP tools; use /mcp verbose or /mcp login <name>-/ m+› /mgpt-test default · /tmp/projectmodel high · fastdiff --git a/codex-rs/tui/src/app/tests/unavailable_commands_tests.rs b/codex-rs/tui/src/app/tests/unavailable_commands_tests.rsindex 966c3d6a81..b762305b4a 100644--- a/codex-rs/tui/src/app/tests/unavailable_commands_tests.rs+++ b/codex-rs/tui/src/app/tests/unavailable_commands_tests.rs@@ -120,12 +120,6 @@ async fn unavailable_thread_routes_local_and_recovery_commands() -> Result<()> {TuiEvent::Key(KeyEvent::new(KeyCode::Char('u'), KeyModifiers::CONTROL)),).await?;- app.handle_tui_event(- &mut tui,- &mut session,- TuiEvent::Key(KeyCode::Backspace.into()),- )- .await?;app.chat_widget.restore_user_message_to_composer(draft.into());app.handle_tui_event(&mut tui, &mut session, TuiEvent::Key(KeyCode::Enter.into()))diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rsindex 320bcc7b8e..90e854d128 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs@@ -22,11 +22,9 @@//!//! Preset submenu hints borrow slots and reflow with the composer.//!-//! Enabled `!` and `/` command prefixes live in prompt state rather than the editable textarea;-//! canonical draft APIs reconstruct them for submission, queuing, history, and external editing.-//! Vim Replace keeps the overwritten leading grapheme recoverable until Backspace removes the-//! absorbed prefix.-//! The plain-text preset keeps both prefixes literal, so Enter and Tab submit ordinary text.+//! Vim Replace preserves the overwritten leading grapheme until Backspace removes an absorbed `!`.+//! The plain-text preset keeps command prefixes literal, including `!`, so Enter and Tab+//! submit ordinary text without enabling shell mode.//!//! # Mention Menus//!@@ -312,6 +310,7 @@ use ratatui::text::Line;use ratatui::text::Span;use ratatui::widgets::Block;use ratatui::widgets::Paragraph;+use ratatui::widgets::StatefulWidgetRef;use ratatui::widgets::Widget;use ratatui::widgets::WidgetRef;@@ -407,7 +406,6 @@ mod warning_notice;use self::attachment_state::AttachmentState;use self::draft_state::ComposerMentionBinding;use self::draft_state::DraftState;-use self::draft_state::PromptPrefix;pub(crate) use self::footer_state::CommandPopupPlacement;use self::footer_state::ComposerLayout;pub(crate) use self::footer_state::ComposerRenderOptions;@@ -451,7 +449,6 @@ use std::path::PathBuf;use std::sync::Arc;use std::time::Duration;use std::time::Instant;-use unicode_segmentation::UnicodeSegmentation;use ratatui::style::Color;@@ -705,7 +702,7 @@ impl ChatComposer {fn slash_input(&self) -> SlashInput<'_> {SlashInput::new(self.slash_commands_enabled(),- self.draft.prompt_prefix == PromptPrefix::Shell,+ self.draft.is_bash_mode,self.builtin_command_flags(),&self.service_tier_commands,)@@ -1045,7 +1042,6 @@ impl ChatComposer {}fn update_slash_command_catalog(&mut self, update: impl FnOnce(&mut Self)) {- self.unmark_slash_command_element();update(self);self.sync_popups();}@@ -1163,9 +1159,7 @@ impl ChatComposer {/// Returns true if the composer currently contains no user-entered input.pub(crate) fn is_empty(&self) -> bool {- self.draft.textarea.is_empty()- && self.draft.prompt_prefix == PromptPrefix::None- && self.attachments.is_empty()+ self.draft.textarea.is_empty() && !self.draft.is_bash_mode && self.attachments.is_empty()}/// Record local persistent-history metadata so the composer can navigate@@ -1578,7 +1572,7 @@ impl ChatComposer {self.vim_history = VimHistory::default();self.draft.textarea_state.get_mut().follow_cursor();self.draft.textarea.set_text_clearing_elements("");- self.draft.prompt_prefix = PromptPrefix::None;+ self.draft.is_bash_mode = false;self.draft.pending_pastes.clear();self.draft.mention_bindings.clear();@@ -1595,7 +1589,7 @@ impl ChatComposer {}pub(crate) fn current_cursor(&self) -> usize {- self.draft.textarea.cursor() + self.draft.prompt_prefix.len()+ self.draft.textarea.cursor() + if self.draft.is_bash_mode { 1 } else { 0 }}#[cfg(test)]@@ -1604,7 +1598,7 @@ impl ChatComposer {}fn history_navigation_cursor(&self) -> usize {- if self.draft.prompt_prefix != PromptPrefix::None && self.draft.textarea.cursor() == 0 {+ if self.draft.is_bash_mode && self.draft.textarea.cursor() == 0 {0} else if self.draft.textarea.is_vim_normal_mode()&& !self.draft.textarea.text().is_empty()@@ -1617,27 +1611,22 @@ impl ChatComposer {}pub(crate) fn set_current_cursor(&mut self, cursor: usize) {- let visible_cursor = cursor.saturating_sub(self.draft.prompt_prefix.len());+ let visible_cursor = if self.draft.is_bash_mode {+ cursor.saturating_sub(1)+ } else {+ cursor+ };self.draft.textarea.set_cursor(visible_cursor.min(self.draft.textarea.text().len()));}fn current_text_elements(&self) -> Vec<TextElement> {- let shift = self.draft.prompt_prefix.len() as isize;- let command_range = self- .draft- .slash_command_element_id- .and_then(|id| self.draft.textarea.element_range(id));+ let shift = if self.draft.is_bash_mode { 1 } else { 0 };self.draft.textarea.text_elements().into_iter()- .filter(|element| {- command_range.as_ref().is_none_or(|range| {- element.byte_range.start != range.start || element.byte_range.end != range.end- })- }).filter_map(|element| Self::shift_text_element(element, shift)).collect()}@@ -1716,37 +1705,30 @@ impl ChatComposer {/// Convert canonical composer text into the textarea's internal representation.///- /// Command modes store the leading `!` or `/` as prompt state instead of editable text,+ /// Shell mode stores the leading `!` as prompt state instead of editable text,/// so full-buffer imports must absorb that prefix before rebuilding the textarea.fn imported_text_for_textarea(&mut self,text: String,text_elements: Vec<TextElement>,) -> (String, Vec<TextElement>) {- let prefix = self.enabled_prompt_prefix_for_text(&text);- self.draft.prompt_prefix = prefix;- if prefix != PromptPrefix::None {+ if self.config.shell_commands_enabled+ && let Some(stripped) = text.strip_prefix('!')+ {+ self.draft.is_bash_mode = true;(- text[prefix.len()..].to_string(),+ stripped.to_string(),text_elements.into_iter()- .filter_map(|element| {- Self::shift_text_element(element, -(prefix.len() as isize))- })+ .filter_map(|element| Self::shift_text_element(element, /*shift*/ -1)).collect(),)} else {+ self.draft.is_bash_mode = false;(text, text_elements)}}- fn set_canonical_text_clearing_elements(&mut self, text: String) {- let (text, text_elements) = self.imported_text_for_textarea(text, Vec::new());- self.draft- .textarea- .set_text_with_elements(&text, &text_elements);- }-/// Flush buffered typing before clearing so cancellation preserves the complete draft in history.pub(crate) fn clear_for_ctrl_c(&mut self) -> Option<String> {if let Some(pasted) = self.draft.paste_burst.flush_before_modified_input() {@@ -1777,11 +1759,11 @@ impl ChatComposer {/// Get the current composer text.pub(crate) fn current_text(&self) -> String {- format!(- "{}{}",- self.draft.prompt_prefix.text(),- self.draft.textarea.text()- )+ if self.draft.is_bash_mode {+ format!("!{}", self.draft.textarea.text())+ } else {+ self.draft.textarea.text().to_string()+ }}/// Recall content at its history boundary, preserving pending pastes and omitting images@@ -3036,7 +3018,7 @@ impl ChatComposer {let input_starts_with_space = original_input.starts_with(' ');self.draft.recent_submission_mention_bindings.clear();self.draft.textarea.set_text_clearing_elements("");- self.draft.prompt_prefix = PromptPrefix::None;+ self.draft.is_bash_mode = false;if pending_paste_handling == PendingPasteHandling::Expand&& !self.draft.pending_pastes.is_empty()@@ -3200,11 +3182,11 @@ impl ChatComposer {let original_input = self.current_text();let original_text_elements = self.current_text_elements();let original_pending_pastes = self.draft.pending_pastes.clone();- let defer_slash_validation =- self.slash_input().should_parse_on_dequeue(&original_input);+ let raw_text = self.draft.textarea.text();+ let defer_slash_validation = self.slash_input().should_parse_on_dequeue(raw_text);let preserve_pending_pastes = defer_slash_validation&& !self.draft.pending_pastes.is_empty()- && parse_slash_name(&original_input)+ && parse_slash_name(raw_text).is_some_and(|(name, _, _)| name == SlashCommand::Goal.command());let pending_pastes = if preserve_pending_pastes {self.draft.pending_pastes.clone()@@ -3340,7 +3322,9 @@ impl ChatComposer {/// Check if the first line is a bare slash command (no args) and dispatch it./// Returns Some(InputResult) if a command was dispatched, None otherwise.fn try_dispatch_bare_slash_command(&mut self) -> Option<InputResult> {- let command = self.slash_input().bare_command(&self.current_text())?;+ let command = self+ .slash_input()+ .bare_command(self.draft.textarea.text())?;if self.reject_slash_command_if_unavailable(&command) {self.stage_slash_command_history(&command);self.record_pending_slash_command_history();@@ -3350,7 +3334,7 @@ impl ChatComposer {if !matches!(command, SlashCommandItem::Builtin(cmd) if cmd.requires_dispatch_validation()){self.draft.textarea.set_text_clearing_elements("");- self.draft.prompt_prefix = PromptPrefix::None;+ self.draft.is_bash_mode = false;}Some(match command {SlashCommandItem::Builtin(cmd) => InputResult::Command(cmd),@@ -3361,7 +3345,7 @@ impl ChatComposer {/// Check if the input is a slash command with args (e.g., /review args) and dispatch it./// Returns Some(InputResult) if a command was dispatched, None otherwise.fn try_dispatch_slash_command_with_args(&mut self) -> Option<InputResult> {- let text = self.current_text();+ let text = self.draft.textarea.text().to_string();let inline_command = self.slash_input().inline_command(&text)?;let command = inline_command.command;if self.reject_slash_command_if_unavailable(&command) {@@ -3375,7 +3359,7 @@ impl ChatComposer {let mut args_elements = slash_input::args_elements(inline_command.rest,inline_command.rest_offset,- &self.current_text_elements(),+ &self.draft.textarea.text_elements(),);let trimmed_rest = inline_command.rest.trim();args_elements = Self::trim_text_elements(inline_command.rest, trimmed_rest, args_elements);@@ -3439,7 +3423,7 @@ impl ChatComposer {if matches!(command, SlashCommandItem::Builtin(SlashCommand::Clear)) {return;}- self.stage_slash_command_history_text(self.current_text().trim().to_string());+ self.stage_slash_command_history_text(self.draft.textarea.text().trim().to_string());}/// Stage a popup-selected command using its canonical command text.@@ -3461,7 +3445,7 @@ impl ChatComposer {fn stage_slash_command_history_text(&mut self, text: String) {self.pending_slash_command_history = Some(HistoryEntry {text,- text_elements: self.current_text_elements(),+ text_elements: self.draft.textarea.text_elements(),local_image_paths: self.attachments.local_image_paths(),remote_image_urls: self.attachments.remote_image_urls(),mention_bindings: self.snapshot_mention_bindings(),@@ -3499,12 +3483,12 @@ impl ChatComposer {if self.handle_empty_prompt_shortcut(&key_event) {return (InputResult::None, true);}- if self.draft.prompt_prefix == PromptPrefix::Shell && key_event.code == KeyCode::Esc {+ if self.draft.is_bash_mode && key_event.code == KeyCode::Esc {if let Some(pasted) = self.draft.paste_burst.flush_before_modified_input() {self.apply_paste(pasted);}if self.draft.textarea.is_empty() {- self.draft.prompt_prefix = PromptPrefix::None;+ self.draft.is_bash_mode = false;return (InputResult::None, true);}}@@ -3529,7 +3513,7 @@ impl ChatComposer {){self.footer.mode = reset_mode_after_activity(self.footer.mode);- self.draft.prompt_prefix = PromptPrefix::Shell;+ self.draft.is_bash_mode = true;self.draft.textarea.enter_vim_insert_mode();return (InputResult::None, true);}@@ -3753,7 +3737,7 @@ impl ChatComposer {Some(self.draft.textarea.element_payloads())};- if self.draft.prompt_prefix != PromptPrefix::None+ if self.draft.is_bash_mode&& self.draft.textarea.vim_query().is_none()&& self.draft.textarea.mouse_selection_range().is_none()&& self.draft.textarea.is_delete_backward_key(input)@@ -3763,8 +3747,7 @@ impl ChatComposer {if self.draft.textarea.is_vim_replace_mode() {self.draft.textarea.input(input);}- self.draft.prompt_prefix = PromptPrefix::None;- self.sync_popups();+ self.draft.is_bash_mode = false;if started_vim_edit {self.finish_vim_edit();}@@ -3773,7 +3756,7 @@ impl ChatComposer {self.begin_vim_edit(input);self.draft.textarea.input(input);- self.sync_prompt_prefix_from_text();+ self.sync_bash_mode_from_text();if let Some(elements_before) = elements_before {self.reconcile_deleted_elements(elements_before);@@ -3799,21 +3782,13 @@ impl ChatComposer {(InputResult::None, true)}- fn sync_prompt_prefix_from_text(&mut self) {- if self.draft.prompt_prefix == PromptPrefix::None {- let prefix = self.enabled_prompt_prefix_for_text(self.draft.textarea.text());- if prefix != PromptPrefix::None {- self.draft.textarea.absorb_prompt_prefix(prefix.len());- self.draft.prompt_prefix = prefix;- }- }- }-- fn enabled_prompt_prefix_for_text(&self, text: &str) -> PromptPrefix {- match text.graphemes(/*is_extended*/ true).next() {- Some("!") if self.config.shell_commands_enabled => PromptPrefix::Shell,- Some("/") if self.slash_commands_enabled() => PromptPrefix::Slash,- _ => PromptPrefix::None,+ fn sync_bash_mode_from_text(&mut self) {+ if self.config.shell_commands_enabled+ && !self.draft.is_bash_mode+ && self.draft.textarea.text().starts_with('!')+ {+ self.draft.textarea.absorb_prompt_prefix(/*prefix_len*/ 1);+ self.draft.is_bash_mode = true;}}@@ -3931,7 +3906,7 @@ impl ChatComposer {}let allow_command_popup = self.slash_commands_enabled()- && self.draft.prompt_prefix != PromptPrefix::Shell+ && !self.draft.is_bash_mode&& file_token.is_none()&& mentions_v2_token.is_none()&& mention_target.is_none();@@ -3987,7 +3962,7 @@ impl ChatComposer {/// textarea. This must be called after every modification that can change/// the text so the popup is shown/updated/hidden as appropriate.fn sync_command_popup(&mut self, allow: bool) {- let text = self.current_text();+ let text = self.draft.textarea.text();let first_line_end = text.find('\n').unwrap_or(text.len());let first_line = &text[..first_line_end];// Keep an explicitly dismissed popup closed until the command token changes.@@ -4006,7 +3981,7 @@ impl ChatComposer {return;}// Determine whether the caret is inside the initial '/name' token on the first line.- let cursor = self.current_cursor();+ let cursor = self.draft.textarea.cursor();let caret_on_first_line = cursor <= first_line_end;let is_editing_slash_command_name = caret_on_first_line@@ -4897,10 +4872,8 @@ impl ChatComposer {}if !textarea_rect.is_empty() {let prompt = if self.draft.input_enabled {- if self.draft.prompt_prefix == PromptPrefix::Shell {- "!".light_red().bold()- } else if self.draft.prompt_prefix == PromptPrefix::Slash {- "/".fg(crate::style::accent_color_on(style.bg)).bold()+ if self.draft.is_bash_mode {+ Span::from("!").light_red().bold()} else if self.luna_reserve_active {// Reserve keeps one arrow at every reasoning effort; only its foreground changes."›"@@ -4931,8 +4904,7 @@ impl ChatComposer {if options.max_height.is_none() {state.follow_cursor();}- let textarea_is_empty =- self.draft.textarea.text().is_empty() && self.draft.prompt_prefix == PromptPrefix::None;+ let textarea_is_empty = self.draft.textarea.text().is_empty() && !self.draft.is_bash_mode;if self.draft.input_enabled {if let Some(mask_char) = mask_char {self.draft@@ -4948,13 +4920,22 @@ impl ChatComposer {.chain(self.draft.textarea.vim_search_highlights()).map(|range| (range, search_highlight_style)),);- self.draft.textarea.render_ref_styled_with_highlights(- textarea_rect,- buf,- &mut state,- Style::default(),- &highlights,- );+ if highlights.is_empty() {+ StatefulWidgetRef::render_ref(+ &(&self.draft.textarea),+ textarea_rect,+ buf,+ &mut state,+ );+ } else {+ self.draft.textarea.render_ref_styled_with_highlights(+ textarea_rect,+ buf,+ &mut state,+ Style::default(),+ &highlights,+ );+ }}}if !self.draft.input_enabled || textarea_is_empty {@@ -5463,46 +5444,6 @@ mod tests {assert_eq!(composer.cursor_pos(area), Some((6, 1)));}- #[test]- fn slash_command_cursor_uses_absorbed_prefix() {- let (tx, _rx) = unbounded_channel::<AppEvent>();- let sender = AppEventSender::new(tx);- let mut composer = ChatComposer::new(- /*has_input_focus*/ true,- sender,- /*enhanced_keys_supported*/ true,- "Ask Codex to do anything".to_string(),- /*disable_paste_burst*/ false,- );- let area = Rect::new(0, 0, 40, 5);-- composer.set_text_content("/help".to_string(), Vec::new(), Vec::new());- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::Slash);- assert_eq!(composer.draft.textarea.text(), "help");- composer.draft.textarea.set_cursor(/*pos*/ 0);- let before_command = composer.cursor_pos(area);- composer.draft.textarea.set_cursor(/*pos*/ 1);- let after_first_character = composer.cursor_pos(area);-- assert_eq!(- (before_command, after_first_character),- (Some((2, 1)), Some((3, 1)))- );- composer.set_text_content("/\u{301}help".to_string(), Vec::new(), Vec::new());- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::None);- let mut buffer = Buffer::empty(area);- composer.render(area, &mut buffer);- assert_eq!(buffer[(2, 1)].symbol(), "/\u{301}");- composer.draft.textarea.set_cursor(/*pos*/ 0);- assert_eq!(- (- composer.cursor_pos(Rect::new(0, 0, 40, 1)),- composer.cursor_pos(Rect::new(0, 0, 0, 5)),- ),- (None, None)- );- }-#[test]fn shell_command_uses_shell_accent_style() {let (tx, _rx) = unbounded_channel::<AppEvent>();@@ -5727,7 +5668,7 @@ mod tests {);type_chars_humanlike(&mut composer, &['!']);- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::Shell);+ assert!(composer.draft.is_bash_mode);assert_eq!(composer.current_text(), "!");let (result, needs_redraw) =@@ -5735,38 +5676,10 @@ mod tests {assert!(matches!(result, InputResult::None));assert!(needs_redraw);- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::None);+ assert!(!composer.draft.is_bash_mode);assert_eq!(composer.current_text(), "");}- #[test]- fn backspace_removes_absorbed_prompt_prefixes() {- use crossterm::event::KeyCode;- use crossterm::event::KeyEvent;- use crossterm::event::KeyModifiers;-- let (tx, _rx) = unbounded_channel::<AppEvent>();- let sender = AppEventSender::new(tx);- let mut composer = ChatComposer::new(- /*has_input_focus*/ true,- sender,- /*enhanced_keys_supported*/ false,- "Ask Codex to do anything".to_string(),- /*disable_paste_burst*/ true,- );-- for prefix in ["!", "/"] {- composer.set_text_content(prefix.to_string(), Vec::new(), Vec::new());- let (result, needs_redraw) =- composer.handle_key_event(KeyEvent::new(KeyCode::Backspace, KeyModifiers::NONE));-- assert_eq!(result, InputResult::None);- assert!(needs_redraw);- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::None);- assert_eq!(composer.current_text(), "");- }- }-#[test]fn esc_keeps_shell_mode_when_paste_burst_flushes_pending_text() {use crossterm::event::KeyCode;@@ -5793,7 +5706,7 @@ mod tests {assert!(matches!(result, InputResult::None));assert!(needs_redraw);- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::Shell);+ assert!(composer.draft.is_bash_mode);assert_eq!(composer.current_text(), "!g");}@@ -6151,11 +6064,8 @@ mod tests {assert!(matches!(result, InputResult::None));assert!(needs_redraw);- assert_eq!(composer.current_text(), "/");- assert_eq!(composer.draft.textarea.text(), "");- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::Slash);- assert_eq!(composer.current_cursor(), "/".len());- assert_eq!(composer.draft.textarea.cursor(), 0);+ assert_eq!(composer.draft.textarea.text(), "/");+ assert_eq!(composer.draft.textarea.cursor(), "/".len());assert!(matches!(composer.popups.active, ActivePopup::Command(_)));assert_eq!(composer.vim_mode_indicator_span(),@@ -6183,9 +6093,7 @@ mod tests {for ch in ['i', '/', 'd', 'i', 'f', 'f'] {let _ = composer.handle_key_event(KeyEvent::new(KeyCode::Char(ch), KeyModifiers::NONE));}- assert_eq!(composer.current_text(), "/diff");- assert_eq!(composer.draft.textarea.text(), "diff");- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::Slash);+ assert_eq!(composer.draft.textarea.text(), "/diff");assert!(matches!(composer.popups.active, ActivePopup::Command(_)));let (result, needs_redraw) =@@ -6268,7 +6176,7 @@ mod tests {assert!(matches!(result, InputResult::None));assert!(needs_redraw);- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::Shell);+ assert!(composer.draft.is_bash_mode);assert_eq!(composer.current_text(), "!");assert_eq!(composer.draft.textarea.text(), "");assert_eq!(@@ -6298,7 +6206,7 @@ mod tests {let _ = composer.handle_key_event(KeyEvent::new(KeyCode::Char(ch), KeyModifiers::NONE));}- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::Shell);+ assert!(composer.draft.is_bash_mode);assert_eq!(composer.current_text(), "!echo");assert_eq!(composer.draft.textarea.text(), "echo");assert!(matches!(composer.popups.active, ActivePopup::None));@@ -6552,9 +6460,7 @@ mod tests {composer.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));assert!(matches!(result, InputResult::None));- assert_eq!(composer.current_text(), "/not-a-command");- assert_eq!(composer.draft.textarea.text(), "not-a-command");- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::Slash);+ assert_eq!(composer.draft.textarea.text(), "/not-a-command");assert_eq!(composer.vim_mode_indicator_span(),Some("Vim: Insert".green())@@ -9488,7 +9394,7 @@ mod tests {terminal.draw(|f| {composer.render(f.area(), f.buffer_mut());- assert_eq!(composer.cursor_pos(f.area()), Some((4, 1)));+ assert_eq!(composer.cursor_pos(f.area()), Some((5, 1)));}).expect("draw composer");@@ -9569,12 +9475,12 @@ mod tests {composer.set_voice_command_enabled(/*enabled*/ true);type_chars_humanlike(&mut composer, &['/', 'v', 'o', 'i', 'c', 'e', ' ']);assert_eq!(composer.draft.textarea.text_elements().len(), 1);- assert!(composer.text_elements().is_empty());composer.set_voice_command_enabled(/*enabled*/ false);assert_eq!(composer.current_text(), "/voice ");assert!(composer.draft.textarea.text_elements().is_empty());+ assert!(composer.text_elements().is_empty());}fn flush_after_paste_burst(composer: &mut ChatComposer) -> bool {@@ -10051,10 +9957,7 @@ mod tests {let (_result, _needs_redraw) =composer.handle_key_event(KeyEvent::new(KeyCode::Tab, KeyModifiers::NONE));- assert_eq!(composer.current_text(), "/compact ");- assert_eq!(composer.draft.textarea.text(), "compact ");- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::Slash);- assert_eq!(composer.current_cursor(), composer.current_text().len());+ assert_eq!(composer.draft.textarea.text(), "/compact ");assert_eq!(composer.draft.textarea.cursor(),composer.draft.textarea.text().len()@@ -10084,9 +9987,7 @@ mod tests {composer.handle_key_event(KeyEvent::new(KeyCode::Tab, KeyModifiers::NONE));assert_eq!(result, InputResult::None);- assert_eq!(composer.current_text(), "/model ");- assert_eq!(composer.draft.textarea.text(), "model ");- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::Slash);+ assert_eq!(composer.draft.textarea.text(), "/model ");assert_eq!(composer.draft.textarea.cursor(),composer.draft.textarea.text().len()@@ -10115,9 +10016,7 @@ mod tests {composer.handle_key_event(KeyEvent::new(KeyCode::Char('/'), KeyModifiers::NONE));assert_eq!(result, InputResult::None);- assert_eq!(composer.current_text(), "/model ");- assert_eq!(composer.draft.textarea.text(), "model ");- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::Slash);+ assert_eq!(composer.draft.textarea.text(), "/model ");assert_eq!(composer.draft.textarea.cursor(),composer.draft.textarea.text().len()@@ -10141,9 +10040,7 @@ mod tests {type_chars_humanlike(&mut composer, &['/', 'd', 'i']);let (_res, _redraw) =composer.handle_key_event(KeyEvent::new(KeyCode::Tab, KeyModifiers::NONE));- assert_eq!(composer.current_text(), "/diff ");- assert_eq!(composer.draft.textarea.text(), "diff ");- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::Slash);+ assert_eq!(composer.draft.textarea.text(), "/diff ");// Press Enter: should dispatch the command, not submit literal text.let (result, _needs_redraw) =@@ -10187,10 +10084,9 @@ mod tests {let text = composer.draft.textarea.text().to_string();let elements = composer.draft.textarea.text_elements();- assert_eq!(composer.current_text(), "/plan ");- assert_eq!(text, "plan ");+ assert_eq!(text, "/plan ");assert_eq!(elements.len(), 1);- assert_eq!(elements[0].placeholder(&text), Some("plan"));+ assert_eq!(elements[0].placeholder(&text), Some("/plan"));}#[test]@@ -10210,30 +10106,12 @@ mod tests {let text = composer.draft.textarea.text().to_string();let elements = composer.draft.textarea.text_elements();- assert_eq!(composer.current_text(), "/Users ");- assert_eq!(text, "Users ");+ assert_eq!(text, "/Users ");assert!(elements.is_empty());}#[test]- fn unowned_element_spanning_slash_command_is_preserved() {- let (mut composer, _rx) = new_test_composer();- let text = "/review ";- let element = TextElement::new(ByteRange { start: 1, end: 7 }, Some("review".to_string()));-- composer.set_text_content(text.to_string(), vec![element.clone()], Vec::new());- composer.move_cursor_to_end();-- assert_eq!(composer.current_text(), text);- assert_eq!(composer.text_elements(), vec![element.clone()]);-- composer.sync_popups();-- assert_eq!(composer.text_elements(), vec![element]);- }-- #[test]- fn slash_command_element_removed_when_command_changes() {+ fn slash_command_element_removed_when_not_at_start() {let (tx, _rx) = unbounded_channel::<AppEvent>();let sender = AppEventSender::new(tx);let mut composer = ChatComposer::new(@@ -10248,17 +10126,15 @@ mod tests {let text = composer.draft.textarea.text().to_string();let elements = composer.draft.textarea.text_elements();- assert_eq!(composer.current_text(), "/review ");- assert_eq!(text, "review ");+ assert_eq!(text, "/review ");assert_eq!(elements.len(), 1);composer.draft.textarea.set_cursor(/*pos*/ 0);- type_chars_humanlike(&mut composer, &[' ']);+ type_chars_humanlike(&mut composer, &['x']);let text = composer.draft.textarea.text().to_string();let elements = composer.draft.textarea.text_elements();- assert_eq!(composer.current_text(), "/ review ");- assert_eq!(text, " review ");+ assert_eq!(text, "x/review ");assert!(elements.is_empty());}@@ -11290,7 +11166,7 @@ mod tests {}#[test]- fn history_navigation_from_start_of_slash_prompt_recalls_older_entry() {+ fn history_navigation_from_start_of_bang_command_recalls_older_entry() {use crossterm::event::KeyCode;use crossterm::event::KeyEvent;use crossterm::event::KeyModifiers;@@ -11310,17 +11186,14 @@ mod tests {composer.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));assert!(matches!(result, InputResult::Submitted { .. }));- type_chars_humanlike(- &mut composer,- &['/', 't', 'm', 'p', '/', 'f', 'i', 'l', 'e'],- );+ type_chars_humanlike(&mut composer, &['!', 'g', 'i', 't']);let (result, _needs_redraw) =composer.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));assert!(matches!(result, InputResult::Submitted { .. }));let (_result, _needs_redraw) =composer.handle_key_event(KeyEvent::new(KeyCode::Up, KeyModifiers::NONE));- assert_eq!(composer.current_text(), "/tmp/file");+ assert_eq!(composer.current_text(), "!git");composer.draft.textarea.set_cursor(/*pos*/ 0);let (_result, _needs_redraw) =@@ -11548,11 +11421,13 @@ mod tests {composer.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));assert!(matches!(result, InputResult::None));assert_eq!(composer.draft.pending_pastes.len(), 1);- assert_eq!(composer.current_text(), format!("/unknown {placeholder}"));+ assert_eq!(+ composer.draft.textarea.text(),+ format!("/unknown {placeholder}")+ );composer.draft.textarea.set_cursor(/*pos*/ 0);- composer.handle_key_event(KeyEvent::new(KeyCode::Backspace, KeyModifiers::NONE));- composer.draft.textarea.insert_str(" /");+ composer.draft.textarea.insert_str(" ");let (result, _) =composer.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));match result {@@ -12341,8 +12216,7 @@ mod tests {/*disable_paste_burst*/ false,);- type_chars_humanlike(&mut composer, &['/', 'd', 'i', 'f', 'f', ' ']);- assert_eq!(composer.draft.textarea.text_elements().len(), 1);+ composer.set_text_content("/diff".to_string(), Vec::new(), Vec::new());let (result, _needs_redraw) =composer.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));@@ -12353,7 +12227,6 @@ mod tests {composer.handle_key_event(KeyEvent::new(KeyCode::Up, KeyModifiers::NONE));assert_eq!(result, InputResult::None);assert_eq!(composer.current_text(), "/diff");- assert!(composer.draft.textarea.text_elements().is_empty());}#[test]@@ -12471,7 +12344,7 @@ mod tests {composer.apply_external_edit("!git status".to_string());- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::Shell);+ assert!(composer.draft.is_bash_mode);assert_eq!(composer.draft.textarea.text(), "git status");assert_eq!(composer.current_text(), "!git status");}@@ -12491,7 +12364,7 @@ mod tests {composer.apply_external_edit("git status".to_string());- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::None);+ assert!(!composer.draft.is_bash_mode);assert_eq!(composer.draft.textarea.text(), "git status");assert_eq!(composer.current_text(), "git status");}@@ -12511,7 +12384,7 @@ mod tests {composer.apply_external_edit("!git status".to_string());- assert_eq!(composer.draft.prompt_prefix, PromptPrefix::Shell);+ assert!(composer.draft.is_bash_mode);assert_eq!(composer.draft.textarea.text(), "git status");assert_eq!(composer.current_text(), "!git status");}diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/draft_state.rs b/codex-rs/tui/src/bottom_pane/chat_composer/draft_state.rsindex ce1bbd021d..b219097ee1 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer/draft_state.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer/draft_state.rs@@ -8,33 +8,10 @@ use crate::bottom_pane::paste_burst::PasteBurst;use crate::bottom_pane::textarea::TextArea;use crate::bottom_pane::textarea::TextAreaState;-#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]-pub(super) enum PromptPrefix {- #[default]- None,- Shell,- Slash,-}--impl PromptPrefix {- pub(super) fn text(self) -> &'static str {- match self {- Self::None => "",- Self::Shell => "!",- Self::Slash => "/",- }- }-- pub(super) fn len(self) -> usize {- self.text().len()- }-}-pub(super) struct DraftState {pub(super) textarea: TextArea,pub(super) textarea_state: RefCell<TextAreaState>,- pub(super) prompt_prefix: PromptPrefix,- pub(super) slash_command_element_id: Option<u64>,+ pub(super) is_bash_mode: bool,pub(super) pending_pastes: Vec<(String, String)>,pub(super) input_enabled: bool,pub(super) input_disabled_placeholder: Option<String>,@@ -49,8 +26,7 @@ impl DraftState {Self {textarea: TextArea::new(),textarea_state: RefCell::new(TextAreaState::default()),- prompt_prefix: PromptPrefix::None,- slash_command_element_id: None,+ is_bash_mode: false,pending_pastes: Vec::new(),input_enabled: true,input_disabled_placeholder: None,diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/embedded_input_tests.rs b/codex-rs/tui/src/bottom_pane/chat_composer/embedded_input_tests.rsindex ef444a31fd..0a79c52063 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer/embedded_input_tests.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer/embedded_input_tests.rs@@ -18,13 +18,6 @@ fn plain_text_composer_keeps_command_prefixes_literal() {] {composer.handle_key_event(KeyEvent::new(KeyCode::Char(prefix), modifiers));composer.handle_paste("keep this literal".into());- if prefix == '/' {- let area = Rect::new(0, 0, /*width*/ 40, /*height*/ 4);- let mut buffer = Buffer::empty(area);- composer.render(area, &mut buffer);- assert_eq!(buffer[(0, 1)].symbol(), "›");- assert_eq!(buffer[(2, 1)].symbol(), "/");- }assert_eq!(composer.handle_key_event(KeyCode::Tab.into()).0,InputResult::Submitted {diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/footer_state_tests.rs b/codex-rs/tui/src/bottom_pane/chat_composer/footer_state_tests.rsindex 558a38a652..5db883b7e6 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer/footer_state_tests.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer/footer_state_tests.rs@@ -60,7 +60,8 @@ fn text(buffer: &Buffer) -> String {#[test]fn retained_command_suggestions_yield_paint_and_cursor_to_find() {let mut composer = composer();- composer.insert_str("/");+ composer.draft.textarea.insert_str("/");+ composer.sync_popups();let original = render(&composer, /*footer*/ None);let footer = TranscriptFooter {text: vec![@@ -90,8 +91,7 @@ fn retained_command_suggestions_yield_paint_and_cursor_to_find() {.then_some((footer_area.x + 8, footer_area.y)));assert!(matches!(composer.popups.active, ActivePopup::Command(_)));- assert_eq!(composer.current_text(), "/");- assert!(composer.draft.textarea.is_empty());+ assert_eq!(composer.draft.textarea.text(), "/");frames.push(format!("{width}x{height}, cursor {cursor:?}\n{}",text(&buffer)diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/history_search.rs b/codex-rs/tui/src/bottom_pane/chat_composer/history_search.rsindex 1be819fbc7..7c55cf937c 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer/history_search.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer/history_search.rs@@ -431,7 +431,7 @@ impl ChatComposer {if !matches!(search.status, HistorySearchStatus::Match) || search.query.is_empty() {return Vec::new();}- let prefix_len = self.draft.prompt_prefix.len();+ let prefix_len = usize::from(self.draft.is_bash_mode);Self::case_insensitive_match_ranges(&self.current_text(), &search.query).into_iter().filter_map(|range| {@@ -1030,6 +1030,16 @@ mod tests {assert!(!modifier.contains(Modifier::REVERSED));assert!(!modifier.contains(Modifier::BOLD));}++ composer+ .history+ .record_local_submission(HistoryEntry::new("!git status".to_string()));+ let _ = composer.handle_key_event(KeyEvent::new(KeyCode::Char('r'), KeyModifiers::CONTROL));+ for ch in ['!', 'g', 'i', 't'] {+ let _ = composer.handle_key_event(KeyEvent::new(KeyCode::Char(ch), KeyModifiers::NONE));+ }+ assert_eq!(composer.current_text(), "!git status");+ assert_eq!(composer.history_search_highlight_ranges(), vec![0..3]);}#[test]diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/history_search_paste_tests.rs b/codex-rs/tui/src/bottom_pane/chat_composer/history_search_paste_tests.rsindex bd0610df36..2c9392fb91 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer/history_search_paste_tests.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer/history_search_paste_tests.rs@@ -117,22 +117,6 @@ fn history_search_empty_paste_preserves_selected_match() {insta::assert_snapshot!("history_search_empty_paste", terminal.backend());}-#[test]-fn history_search_highlights_absorbed_prompt_prefix_match() {- let mut composer = composer_with_history();- composer- .history- .record_local_submission(HistoryEntry::new("/review changes".to_string()));- composer.handle_key_event(KeyEvent::new(KeyCode::Char('r'), KeyModifiers::CONTROL));- composer.handle_paste("/review".to_string());-- assert_eq!(composer.current_text(), "/review changes");- assert_eq!(composer.history_search_highlight_ranges(), vec![0..6]);-- let terminal = render_composer(&composer, /*width*/ 70);- insta::assert_snapshot!("history_search_absorbed_slash", terminal.backend());-}-#[test]fn history_search_paste_shows_separators_and_matches_original_query() {let mut composer = composer_with_history();@@ -224,7 +208,7 @@ fn history_search_paste_uses_full_sanitized_text() {composer.handle_paste(pasted);assert_eq!(composer.history_search.as_ref().unwrap().query, query);- assert_eq!(composer.current_text(), query);+ assert_eq!(composer.draft.textarea.text(), query);assert!(composer.attachments.local_image_paths().is_empty());assert!(composer.draft.pending_pastes.is_empty());assert!(composer.current_text_elements().is_empty());diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/inline_input.rs b/codex-rs/tui/src/bottom_pane/chat_composer/inline_input.rsindex 7ad7202514..48f7adff59 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer/inline_input.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer/inline_input.rs@@ -5,7 +5,6 @@//! Command prefixes become escaped, editable prompt text before answers are appended.use super::super::textarea::VimPersistentState;-use super::draft_state::PromptPrefix;use super::*;impl ComposerDraft {@@ -33,19 +32,13 @@ impl ChatComposer {.swap_vim_persistent_state(&mut vim_state);let started_vim_edit = self.begin_direct_vim_edit();// Recovered answers turn the draft into a prompt, so escape any command prefix- // before appending them. Command modes store their prefix outside the textarea.- let text = self.current_text();- let slash_command_draft = self.slash_input().should_parse_on_dequeue(&text)+ // before appending them. Shell mode stores its `!` outside the textarea.+ let text = self.draft.textarea.text();+ let slash_command_draft = self.slash_input().should_parse_on_dequeue(text)&& parse_slash_name(text.trim_start()).is_none_or(|(name, _, _)| !name.contains('/'));- if self.draft.prompt_prefix == PromptPrefix::Shell- || (self.draft.prompt_prefix == PromptPrefix::Slash && slash_command_draft)- {- self.unmark_slash_command_element();- let prefix = self.draft.prompt_prefix.text();- self.draft.prompt_prefix = PromptPrefix::None;- self.draft- .textarea- .insert_str_at(/*pos*/ 0, &format!("\\{prefix}"));+ if self.draft.is_bash_mode {+ self.draft.is_bash_mode = false;+ self.draft.textarea.insert_str_at(/*pos*/ 0, "\\!");} else if self.is_bang_shell_command() || slash_command_draft {let prefix_len =self.draft.textarea.text().len() - self.draft.textarea.text().trim_start().len();diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/mouse_tests.rs b/codex-rs/tui/src/bottom_pane/chat_composer/mouse_tests.rsindex 6da43a77bc..9715d72b2c 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer/mouse_tests.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer/mouse_tests.rs@@ -88,27 +88,25 @@ fn recovery_keeps_unselected_text_after_a_held_replace_key() {#[test]fn backspace_deletes_a_body_selection_before_an_absorbed_prefix() {- for prefix in ["!", "/"] {- let (mut composer, _rx) = new_test_composer();- composer.insert_str(&format!("{prefix}review text"));- let area = Rect::new(- /*x*/ 0, /*y*/ 0, /*width*/ 80, /*height*/ 4,- );- composer.render(area, &mut Buffer::empty(area));- let (x, y) = composer.cursor_pos(area).unwrap();- for (kind, column) in [- (Down(Left), x),- (MouseEventKind::Drag(Left), x - "review text".len() as u16),- (Up(Left), x - "review text".len() as u16),- ] {- mouse(&mut composer, area, kind, column, y);- }+ let (mut composer, _rx) = new_test_composer();+ composer.insert_str("!review text");+ let area = Rect::new(+ /*x*/ 0, /*y*/ 0, /*width*/ 80, /*height*/ 4,+ );+ composer.render(area, &mut Buffer::empty(area));+ let (x, y) = composer.cursor_pos(area).unwrap();+ for (kind, column) in [+ (Down(Left), x),+ (MouseEventKind::Drag(Left), x - "review text".len() as u16),+ (Up(Left), x - "review text".len() as u16),+ ] {+ mouse(&mut composer, area, kind, column, y);+ }- composer.handle_key_event(KeyCode::Backspace.into());+ composer.handle_key_event(KeyCode::Backspace.into());- assert_eq!(composer.current_text(), prefix);- assert_eq!(composer.draft.textarea.mouse_selection_range(), None);- }+ assert_eq!(composer.current_text(), "!");+ assert_eq!(composer.draft.textarea.mouse_selection_range(), None);}#[test]diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/paste_input.rs b/codex-rs/tui/src/bottom_pane/chat_composer/paste_input.rsindex 173678e904..78db041eb2 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer/paste_input.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer/paste_input.rs@@ -28,7 +28,7 @@ impl ChatComposer {if let Some(elements_before) = elements_before {self.reconcile_deleted_elements(elements_before);}- self.sync_prompt_prefix_from_text();+ self.sync_bash_mode_from_text();self.sync_popups();if started_vim_edit {self.finish_vim_edit();@@ -48,7 +48,7 @@ impl ChatComposer {FlushResult::Typed(ch) if self.draft.textarea.is_vim_replace_mode() => {textarea.set_cursor(snapshot.cursor);if let Some(selection) = self.draft.textarea.mouse_selection_range() {- let offset = self.draft.prompt_prefix.len();+ let offset = usize::from(self.draft.is_bash_mode);textarea.replace_range(selection.start + offset..selection.end + offset,&ch.to_string(),diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/reconnect.rs b/codex-rs/tui/src/bottom_pane/chat_composer/reconnect.rsindex c7eed40764..0cefc44b11 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer/reconnect.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer/reconnect.rs@@ -5,7 +5,6 @@//! Recovery commands must occupy one line and be visible before the submit key expands pastes.//! Offline draft edits also consume the Astra sparkle opportunity before rendering.-use super::draft_state::PromptPrefix;use super::*;#[derive(Clone, Copy, PartialEq, Eq)]@@ -18,10 +17,12 @@ impl ChatComposer {/// Preserve Enter inside a paste burst without attempting submission.pub(crate) fn handle_paste_enter(&mut self, now: Instant) -> bool {let in_slash_context = self.slash_commands_enabled()- && self.draft.prompt_prefix != PromptPrefix::Shell+ && !self.draft.is_bash_mode&& (matches!(self.popups.active, ActivePopup::Command(_))|| self- .current_text()+ .draft+ .textarea+ .text().lines().next().unwrap_or("")@@ -82,10 +83,10 @@ impl ChatComposer {&& self.submit_keys.is_pressed(key){let input = self.slash_input();- let text = self.current_text();+ let text = self.draft.textarea.text();let command = input- .bare_command(&text)- .or_else(|| input.inline_command(&text).map(|command| command.command))+ .bare_command(text)+ .or_else(|| input.inline_command(text).map(|command| command.command)).filter(|_| text.trim().lines().count() == 1);if matches!(command, Some(SlashCommandItem::Builtin(command))if command == SlashCommand::Warningsdiff --git a/codex-rs/tui/src/bottom_pane/chat_composer/slash_input.rs b/codex-rs/tui/src/bottom_pane/chat_composer/slash_input.rsindex 4ea71254c1..066e56c317 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer/slash_input.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer/slash_input.rs@@ -24,7 +24,6 @@ use super::ActivePopup;use super::ChatComposer;use super::InputResult;use super::QueuedInputAction;-use super::draft_state::PromptPrefix;use super::parent_owned_command_is_allowed;#[derive(Clone, Copy, Debug, PartialEq, Eq)]@@ -245,17 +244,13 @@ impl ChatComposer {}if key_event.code == KeyCode::Esc {// Always dismiss the popup without changing the draft.- let text = self.current_text();- let first_line = text.lines().next().unwrap_or("");+ let first_line = self.draft.textarea.text().lines().next().unwrap_or("");self.popups.dismissed_command_token =command_popup_filter_text(first_line, /*cursor*/ 0);self.popups.active = ActivePopup::None;return (InputResult::None, true);}self.footer.mode = reset_mode_after_activity(self.footer.mode);- let current_text = self.current_text();- let current_cursor = self.current_cursor();- let first_line = current_text.lines().next().unwrap_or("");let ActivePopup::Command(popup) = &mut self.popups.active else {unreachable!();};@@ -289,8 +284,11 @@ impl ChatComposer {} => {// Ensure popup filtering/selection reflects the latest composer text// before applying completion.- let filter_text = command_popup_filter_text(first_line, current_cursor)- .unwrap_or_else(|| first_line.to_owned());+ let text = self.draft.textarea.text();+ let first_line = text.lines().next().unwrap_or("").to_owned();+ let cursor = self.draft.textarea.cursor();+ let filter_text = command_popup_filter_text(&first_line, cursor)+ .unwrap_or_else(|| first_line.clone());popup.on_composer_text_change(filter_text);let has_visible_items = !popup.filtered_items().is_empty();let selected_item = popup.selected_item();@@ -301,7 +299,7 @@ impl ChatComposer {{self.stage_selected_slash_command_history(&selected_cmd);self.draft.textarea.set_text_clearing_elements("");- self.draft.prompt_prefix = PromptPrefix::None;+ self.draft.is_bash_mode = false;return (InputResult::Command(*cmd), true);}@@ -314,9 +312,11 @@ impl ChatComposer {}if let Some(completed_text) =- selected_command_completion(first_line, &selected_cmd)+ selected_command_completion(&first_line, &selected_cmd){- self.set_canonical_text_clearing_elements(completed_text);+ self.draft+ .textarea+ .set_text_clearing_elements(&completed_text);if !self.draft.textarea.text().is_empty() {self.draft.textarea@@ -340,8 +340,11 @@ impl ChatComposer {} => {// Treat "/" as accepting the highlighted command as text completion// while the slash-command popup is active.- let filter_text = command_popup_filter_text(first_line, current_cursor)- .unwrap_or_else(|| first_line.to_owned());+ let text = self.draft.textarea.text();+ let first_line = text.lines().next().unwrap_or("").to_owned();+ let cursor = self.draft.textarea.cursor();+ let filter_text = command_popup_filter_text(&first_line, cursor)+ .unwrap_or_else(|| first_line.clone());popup.on_composer_text_change(filter_text);if let Some(selected_cmd) = popup.selected_item() {if self@@ -353,9 +356,12 @@ impl ChatComposer {}if let Some(completed_text) =- selected_command_completion(first_line, &selected_cmd)+ selected_command_completion(&first_line, &selected_cmd){- self.set_canonical_text_clearing_elements(completed_text);+ self.draft+ .textarea+ .set_text_clearing_elements(&completed_text);+ self.draft.is_bash_mode = false;}if !self.draft.textarea.text().is_empty() {self.draft@@ -374,10 +380,11 @@ impl ChatComposer {if let Some(sel) = popup.selected_item() {if self.blocks_direct_input {let command_is_allowed = match &sel {- CommandItem::Builtin(cmd) => parse_slash_name(¤t_text)- .is_some_and(|(_, args, _)| {- parent_owned_command_is_allowed(*cmd, args)- }),+ CommandItem::Builtin(cmd) => {+ parse_slash_name(self.draft.textarea.text()).is_some_and(+ |(_, args, _)| parent_owned_command_is_allowed(*cmd, args),+ )+ }CommandItem::ServiceTier(_) => false,};if !command_is_allowed {@@ -397,7 +404,7 @@ impl ChatComposer {if !matches!(sel, CommandItem::Builtin(cmd) if cmd.requires_dispatch_validation()){self.draft.textarea.set_text_clearing_elements("");- self.draft.prompt_prefix = PromptPrefix::None;+ self.draft.is_bash_mode = false;}return (match sel {@@ -427,9 +434,9 @@ impl ChatComposer {return false;}- let text = self.current_text();+ let text = self.draft.textarea.text();let first_line_end = text.find('\n').unwrap_or(text.len());- let cursor = self.current_cursor();+ let cursor = self.draft.textarea.cursor();if cursor > first_line_end || !text.starts_with('/') || !text.is_char_boundary(cursor) {return false;}@@ -458,8 +465,6 @@ impl ChatComposer {format!("{selected_command_text} ")};- let prefix_len = self.draft.prompt_prefix.len();- let internal_replace_end = replace_end.saturating_sub(prefix_len);let ranges_to_unmark = self.draft.textarea@@ -467,8 +472,7 @@ impl ChatComposer {.into_iter().filter_map(|element| {let range = element.byte_range.start..element.byte_range.end;- (range.start < internal_replace_end && internal_replace_end < range.end)- .then_some(range)+ (range.start < replace_end && replace_end < range.end).then_some(range)}).collect::<Vec<_>>();for range in ranges_to_unmark {@@ -476,8 +480,8 @@ impl ChatComposer {}self.draft.textarea- .replace_range(0..internal_replace_end, &replacement[prefix_len..]);- self.draft.prompt_prefix = PromptPrefix::Slash;+ .replace_range(0..replace_end, &replacement);+ self.draft.is_bash_mode = false;self.draft.textarea.set_cursor(self.draft.textarea.text().len());@@ -486,27 +490,41 @@ impl ChatComposer {/// Keep slash command elements aligned with the current first line.pub(super) fn sync_slash_command_elements(&mut self) {- self.unmark_slash_command_element();if !self.slash_commands_enabled() {return;}- let canonical_text = self.current_text();- let first_line_end = canonical_text.find('\n').unwrap_or(canonical_text.len());- let first_line = &canonical_text[..first_line_end];- let cursor = self.current_cursor();- let prefix_len = self.draft.prompt_prefix.len();- let desired_range = self- .slash_input()- .command_element_range(first_line, cursor)- .map(|range| 0..range.end.saturating_sub(prefix_len));- if let Some(range) = desired_range {- self.draft.slash_command_element_id = self.draft.textarea.add_element_range(range);+ let text = self.draft.textarea.text();+ let first_line_end = text.find('\n').unwrap_or(text.len());+ let first_line = &text[..first_line_end];+ let cursor = self.draft.textarea.cursor();+ let desired_range = self.slash_input().command_element_range(first_line, cursor);+ // Slash commands are only valid at byte 0 of the first line.+ // Any slash-shaped element not matching the current desired prefix is stale.+ let mut has_desired = false;+ let mut stale_ranges = Vec::new();+ for elem in self.draft.textarea.text_elements() {+ let Some(payload) = elem.placeholder(text) else {+ continue;+ };+ if payload.strip_prefix('/').is_none() {+ continue;+ }+ let range = elem.byte_range.start..elem.byte_range.end;+ if desired_range.as_ref() == Some(&range) {+ has_desired = true;+ } else {+ stale_ranges.push(range);+ }+ }++ for range in stale_ranges {+ self.draft.textarea.remove_element_range(range);}- }- pub(super) fn unmark_slash_command_element(&mut self) {- if let Some(id) = self.draft.slash_command_element_id.take() {- self.draft.textarea.remove_element(id);+ if let Some(range) = desired_range+ && !has_desired+ {+ self.draft.textarea.add_element_range(range);}}}@@ -620,8 +638,8 @@ mod tests {fn composer_with_text_at_cursor(text: &str, cursor: usize) -> ChatComposer {let mut composer = test_composer();- composer.set_text_content(text.to_string(), Vec::new(), Vec::new());- composer.set_current_cursor(cursor);+ composer.draft.textarea.set_text_clearing_elements(text);+ composer.draft.textarea.set_cursor(cursor);composer.sync_popups();composer}@@ -634,8 +652,8 @@ mod tests {fn unavailable_side_conversation_command_still_opens_popup() {let mut composer = test_composer();composer.set_side_conversation_active(/*active*/ true);- composer.set_text_content("/arch".to_string(), Vec::new(), Vec::new());- composer.set_current_cursor(/*cursor*/ 5);+ composer.draft.textarea.set_text_clearing_elements("/arch");+ composer.draft.textarea.set_cursor(/*pos*/ 5);composer.sync_popups();assert!(matches!(composer.popups.active, ActivePopup::Command(_)));@@ -645,12 +663,12 @@ mod tests {fn side_conversation_tab_completes_available_match_after_unavailable_rows() {let mut composer = test_composer();composer.set_side_conversation_active(/*active*/ true);- composer.set_text_content("/a".to_string(), Vec::new(), Vec::new());- composer.set_current_cursor(/*cursor*/ 2);+ composer.draft.textarea.set_text_clearing_elements("/a");+ composer.draft.textarea.set_cursor(/*pos*/ 2);composer.sync_popups();assert_eq!(press(&mut composer, KeyCode::Tab), InputResult::None);- assert_eq!(composer.current_text(), "/agents ");+ assert_eq!(composer.draft.textarea.text(), "/agents ");}#[test]@@ -658,12 +676,12 @@ mod tests {let mut composer = test_composer();composer.set_side_conversation_active(/*active*/ true);composer.set_task_running(/*running*/ true);- composer.set_text_content("/arch".to_string(), Vec::new(), Vec::new());- composer.set_current_cursor(/*cursor*/ 5);+ composer.draft.textarea.set_text_clearing_elements("/arch");+ composer.draft.textarea.set_cursor(/*pos*/ 5);composer.sync_popups();assert_eq!(press(&mut composer, KeyCode::Tab), InputResult::None);- assert_eq!(composer.current_text(), "/arch");+ assert_eq!(composer.draft.textarea.text(), "/arch");}#[test]@@ -671,8 +689,11 @@ mod tests {let mut composer = test_composer();composer.set_side_conversation_active(/*active*/ true);composer.set_task_running(/*running*/ true);- composer.set_text_content("/agents".to_string(), Vec::new(), Vec::new());- composer.set_current_cursor(/*cursor*/ 7);+ composer+ .draft+ .textarea+ .set_text_clearing_elements("/agents");+ composer.draft.textarea.set_cursor(/*pos*/ 7);composer.sync_popups();assert_eq!(@@ -692,12 +713,12 @@ mod tests {let mut composer = test_composer();composer.set_side_conversation_active(/*active*/ true);composer.set_disable_paste_burst(/*disabled*/ true);- composer.set_text_content("/new".to_string(), Vec::new(), Vec::new());- composer.set_current_cursor(/*cursor*/ 4);+ composer.draft.textarea.set_text_clearing_elements("/new");+ composer.draft.textarea.set_cursor(/*pos*/ 4);composer.sync_popups();assert_eq!(press(&mut composer, KeyCode::Char('/')), InputResult::None);- assert_eq!(composer.current_text(), "/new/");+ assert_eq!(composer.draft.textarea.text(), "/new/");}#[test]@@ -708,7 +729,7 @@ mod tests {assert_eq!(press(&mut composer, KeyCode::Esc), InputResult::None);assert!(!composer.popup_active());- assert_eq!(composer.current_text(), "/rev");+ assert_eq!(composer.draft.textarea.text(), "/rev");}#[test]@@ -718,15 +739,15 @@ mod tests {let mut composer = composer_with_draft_tail("/re", draft);assert_eq!(press(&mut composer, KeyCode::Tab), InputResult::None);- assert_eq!(composer.current_text(), expected_text);- assert_eq!(composer.current_cursor(), expected_text.len());+ assert_eq!(composer.draft.textarea.text(), expected_text);+ assert_eq!(composer.draft.textarea.cursor(), expected_text.len());let mut composer = composer_with_draft_tail("/re", draft);assert_eq!(press(&mut composer, KeyCode::Enter),InputResult::CommandWithArgs(SlashCommand::Review, draft.to_string(), Vec::new()));- assert_eq!(composer.current_text(), expected_text);+ assert_eq!(composer.draft.textarea.text(), expected_text);}#[test]@@ -737,21 +758,21 @@ mod tests {);assert_eq!(press(&mut composer, KeyCode::Tab), InputResult::None);- assert_eq!(composer.current_text(), "/status ");- assert_eq!(composer.current_cursor(), "/status ".len());+ assert_eq!(composer.draft.textarea.text(), "/status ");+ assert_eq!(composer.draft.textarea.cursor(), "/status ".len());}#[test]fn slash_completion_does_not_turn_command_suffix_into_args() {let mut composer = composer_with_text_at_cursor("/review", "/re".len());assert_eq!(press(&mut composer, KeyCode::Tab), InputResult::None);- assert_eq!(composer.current_text(), "/review ");+ assert_eq!(composer.draft.textarea.text(), "/review ");let mut composer = composer_with_text_at_cursor("/review", "/re".len());assert_eq!(press(&mut composer, KeyCode::Enter),InputResult::Command(SlashCommand::Review));- assert_eq!(composer.current_text(), "/review ");+ assert_eq!(composer.draft.textarea.text(), "/review ");}}diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__footer_state__tests__find_hides_retained_command_suggestions.snap b/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__footer_state__tests__find_hides_retained_command_suggestions.snapindex 7943f73ba4..b0436bc381 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__footer_state__tests__find_hides_retained_command_suggestions.snap+++ b/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__footer_state__tests__find_hides_retained_command_suggestions.snap@@ -1,11 +1,11 @@---source: tui/src/bottom_pane/chat_composer/footer_state_tests.rs-assertion_line: 100+assertion_line: 231expression: "frames.join(\"\\n\\n\")"---60x8, cursor Some((10, 6))-/+› /@@ -15,7 +15,7 @@ expression: "frames.join(\"\\n\\n\")"24x8, cursor Some((10, 6))-/+› /@@ -25,4 +25,4 @@ expression: "frames.join(\"\\n\\n\")"12x3, cursor None-/+› /diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__history_search__paste_tests__history_search_absorbed_slash.snap b/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__history_search__paste_tests__history_search_absorbed_slash.snapdeleted file mode 100644index ed1406f290..0000000000--- a/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__history_search__paste_tests__history_search_absorbed_slash.snap+++ /dev/null@@ -1,9 +0,0 @@-----source: tui/src/bottom_pane/chat_composer/history_search_paste_tests.rs-expression: terminal.backend()-----" "-"/ review changes "-" "-" "-" reverse-i-search: /review enter accept · esc cancel "diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__sparkle__tests__a_fresh_astra_response_waits_for_the_pending_command_to_leave.snap b/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__sparkle__tests__a_fresh_astra_response_waits_for_the_pending_command_to_leave.snapindex b60d0594be..6697092d6c 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__sparkle__tests__a_fresh_astra_response_waits_for_the_pending_command_to_leave.snap+++ b/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__sparkle__tests__a_fresh_astra_response_waits_for_the_pending_command_to_leave.snap@@ -7,7 +7,7 @@ command during startup:› /status show current session configuration and token usage/statusline configure which items appear in the status line-/ status+› /status100% context leftdiff --git a/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__status_surface__tests__slash_popup_footer_wide.snap b/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__status_surface__tests__slash_popup_footer_wide.snapindex 9b357a4402..bb446cf9e1 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__status_surface__tests__slash_popup_footer_wide.snap+++ b/codex-rs/tui/src/bottom_pane/chat_composer/snapshots/codex_tui__bottom_pane__chat_composer__status_surface__tests__slash_popup_footer_wide.snap@@ -11,7 +11,7 @@ Buffer {" /mention mention a file "," /mcp list MCP tools; use /mcp verbose or /mcp login <name> "," ",- "/ m ",+ "› /m "," "," model · high · fast ",],diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/sparkle.rs b/codex-rs/tui/src/bottom_pane/chat_composer/sparkle.rsindex c1b0787420..bb14fbe533 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer/sparkle.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer/sparkle.rs@@ -26,7 +26,6 @@ use unicode_width::UnicodeWidthStr;use super::ChatComposer;use super::FooterMode;use super::InputResult;-use super::draft_state::PromptPrefix;use crate::bottom_pane::BottomPane;use crate::terminal_palette::StdoutColorLevel;use crate::terminal_palette::default_fg;@@ -316,9 +315,7 @@ impl ChatComposer {let Some(body) = text.strip_prefix('/') else {return false;};- if !self.slash_commands_enabled()- || self.draft.prompt_prefix == PromptPrefix::Shell- || text.contains(['\n', '\r'])+ if !self.slash_commands_enabled() || self.draft.is_bash_mode || text.contains(['\n', '\r']){return false;}diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/status_surface_tests.rs b/codex-rs/tui/src/bottom_pane/chat_composer/status_surface_tests.rsindex 8e650b7670..03e761f4f0 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer/status_surface_tests.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer/status_surface_tests.rs@@ -392,7 +392,7 @@ fn slash_popup_preserves_footer_and_selection_style() {} = composer.layout_with_options(area, ComposerRenderOptions::default());assert_eq!(popup.bottom(), surface.y);assert_eq!(surface.bottom(), footer.y);- assert_eq!(composer.cursor_pos(area), Some((3, textarea.y)));+ assert_eq!(composer.cursor_pos(area), Some((4, textarea.y)));let footer_text: String = (0..width).map(|x| buf[(x, height - 1)].symbol()).collect();assert!(footer_text.contains("model · high · fast"));if !clipped && width == 80 {diff --git a/codex-rs/tui/src/bottom_pane/chat_composer/vim_history_tests.rs b/codex-rs/tui/src/bottom_pane/chat_composer/vim_history_tests.rsindex 8428b0686a..dc7ef0f7ed 100644--- a/codex-rs/tui/src/bottom_pane/chat_composer/vim_history_tests.rs+++ b/codex-rs/tui/src/bottom_pane/chat_composer/vim_history_tests.rs@@ -15,7 +15,6 @@ use super::super::ChatComposer;use super::super::InputResult;use super::super::LARGE_PASTE_CHAR_THRESHOLD;use super::super::PasteBurst;-use super::super::draft_state::PromptPrefix;use super::super::tests::new_test_composer;use super::super::tests::snapshot_composer_state_with_width;use crate::keymap::RuntimeKeymap;@@ -160,19 +159,16 @@ fn recovered_answers_undo_as_one_vim_edit() {ctrl_r(&mut composer);assert_eq!(composer.draft_snapshot(), after);}- for command in ["!echo", "/diff", "/review "] {+ for command in ["!echo", "/diff"] {let mut composer = vim_composer(command);- composer.move_cursor_to_end();- composer.sync_popups();let before = composer.draft_snapshot();composer.append_recovered_drafts("answer");assert_eq!(composer.current_text(), format!("\\{command}\n\nanswer"));- assert!(composer.draft.textarea.text_elements().is_empty());keys(&mut composer, "u");assert_eq!(composer.draft_snapshot(), before);}let mut composer = vim_composer("echo");- composer.draft.prompt_prefix = PromptPrefix::Shell;+ composer.draft.is_bash_mode = true;let before = composer.draft_snapshot();composer.append_recovered_drafts("answer");assert_eq!(composer.current_text(), "\\!echo\n\nanswer");@@ -676,7 +672,7 @@ fn vim_replace_backspace_restores_characters_in_new_slash_element() {composer.set_vim_enabled(/*enabled*/ true);composer.draft.textarea.set_cursor(/*pos*/ 0);keys(composer, "R/diff");- assert_eq!(composer.draft.textarea.element_payloads(), vec!["diff"]);+ assert_eq!(composer.draft.textarea.element_payloads(), vec!["/diff"]);for expected in [("/dife tail", 4), ("/dide tail", 3)] {let _ = composer.handle_key_event(KeyEvent::from(KeyCode::Backspace));assert_eq!(@@ -690,30 +686,13 @@ fn vim_replace_backspace_restores_characters_in_new_slash_element() {#[test]fn vim_replace_delete_backward_restores_characters_hidden_by_prompt_prefixes() {- for (original, replacement, delete_backward, repeat) in [- (- "abcde tail",- "R/diff",- KeyEvent::from(KeyCode::Backspace),- 5,- ),- (- "ébc",- "R!",- KeyEvent::new(KeyCode::Char('h'), KeyModifiers::CONTROL),- 1,- ),- ] {- let mut composer = vim_composer(original);- keys(&mut composer, replacement);- for _ in 0..repeat {- let _ = composer.handle_key_event(delete_backward);- }- assert_eq!(- (composer.current_text(), composer.current_cursor()),- (original.to_owned(), 0)- );- }+ let mut composer = vim_composer("ébc");+ keys(&mut composer, "R!");+ let _ = composer.handle_key_event(KeyEvent::new(KeyCode::Char('h'), KeyModifiers::CONTROL));+ assert_eq!(+ (composer.current_text(), composer.current_cursor()),+ ("ébc".to_owned(), 0)+ );}#[test]diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__slash_popup_mo_clipped.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__slash_popup_mo_clipped.snapindex 04294ccb9d..e92755f38e 100644--- a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__slash_popup_mo_clipped.snap+++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__slash_popup_mo_clipped.snap@@ -3,5 +3,5 @@ source: tui/src/bottom_pane/chat_composer.rsexpression: terminal.backend()---" "-"/ mo "+"› /mo "" "diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__vim_empty_normal_slash.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__vim_empty_normal_slash.snapindex 42c2791ee3..2ad183893b 100644--- a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__vim_empty_normal_slash.snap+++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__vim_empty_normal_slash.snap@@ -8,6 +8,6 @@ expression: terminal.backend()" commands "" /ide include current selection, open files, and"" "-"/ "+"› / "" "" 100% context left | Vim: Insert "diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__vim_replace_slash_recovery.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__vim_replace_slash_recovery.snapindex 0053744e91..d248b7de58 100644--- a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__vim_replace_slash_recovery.snap+++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__chat_composer__tests__vim_replace_slash_recovery.snap@@ -5,7 +5,7 @@ expression: terminal.backend()---"› /diff show git diff (including untracked files) "" "-"/ dide tail "+"› /dide tail "" "" "" "diff --git a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__tests__slash_command_popup_dismissed.snap b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__tests__slash_command_popup_dismissed.snapindex b4834dcb95..2eae5af3d3 100644--- a/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__tests__slash_command_popup_dismissed.snap+++ b/codex-rs/tui/src/bottom_pane/snapshots/codex_tui__bottom_pane__tests__slash_command_popup_dismissed.snap@@ -5,6 +5,6 @@ expression: "render_snapshot(&pane, area)"• Working (0s • esc to interrupt)-/ rev+› /revtab to queue message 100% context leftdiff --git a/codex-rs/tui/src/bottom_pane/textarea.rs b/codex-rs/tui/src/bottom_pane/textarea.rsindex 13cd890e73..e6594a55ff 100644--- a/codex-rs/tui/src/bottom_pane/textarea.rs+++ b/codex-rs/tui/src/bottom_pane/textarea.rs@@ -1684,13 +1684,6 @@ impl TextArea {.map(|element| element.id)}- pub(crate) fn element_range(&self, id: u64) -> Option<Range<usize>> {- self.elements- .iter()- .find(|element| element.id == id)- .map(|element| element.range.clone())- }-/// Renames a single text element in-place, keeping it atomic.////// Use this when the element payload is an identifier (e.g. a placeholder) that must be@@ -1810,10 +1803,6 @@ impl TextArea {len_before != self.elements.len()}- pub(crate) fn remove_element(&mut self, id: u64) {- self.elements.retain(|element| element.id != id);- }-fn next_element_id(&mut self) -> u64 {let id = self.next_element_id;self.next_element_id = self.next_element_id.saturating_add(1);diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_mantle_sol61_ultrafast.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_mantle_sol61_ultrafast.snapindex a16c4bdc77..bc71ac9a71 100644--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_mantle_sol61_ultrafast.snap+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_mantle_sol61_ultrafast.snap@@ -5,13 +5,13 @@ expression: "format!(\"Bundled catalog:\\n{bundled_view}\\n\\nCustom catalog:\\nBundled catalog:› /ultrafast The fastest available responses for latency-sensitive work.-/ ultrafast+› /ultrafastGPT-6.1 Sol default · /tmp/projectCustom catalog:› /express My custom Bedrock tier.-/ express+› /expressGPT-6.1-Sol default · /tmp/projectdiff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_mantle_ultrafast.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_mantle_ultrafast.snapindex 88ecdefff0..e0809c1682 100644--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_mantle_ultrafast.snap+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_mantle_ultrafast.snap@@ -5,13 +5,13 @@ expression: "format!(\"Bundled catalog:\\n{bundled_view}\\n\\nCustom catalog:\\nBundled catalog:› /ultrafast The fastest available responses for latency-sensitive work.-/ ultrafast+› /ultrafastGPT-6-Astra default · /tmp/projectCustom catalog:› /express My custom Bedrock tier.-/ express+› /expressGPT-6-Astra default · /tmp/projectdiff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_global_sol61_ultrafast.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_global_sol61_ultrafast.snapindex 77f4d40cad..bade4689a7 100644--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_global_sol61_ultrafast.snap+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_global_sol61_ultrafast.snap@@ -5,13 +5,13 @@ expression: "format!(\"Bundled catalog:\\n{bundled_view}\\n\\nCustom catalog:\\nBundled catalog:› /ultrafast The fastest available responses for latency-sensitive work.-/ ultrafast+› /ultrafastGPT-6.1 Sol (Global) default · /tmp/projectCustom catalog:› /express My custom Bedrock tier.-/ express+› /expressGPT-6.1-Sol default · /tmp/projectdiff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_global_ultrafast.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_global_ultrafast.snapindex 8e879e6eb9..0a2120ba85 100644--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_global_ultrafast.snap+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_global_ultrafast.snap@@ -5,13 +5,13 @@ expression: "format!(\"Bundled catalog:\\n{bundled_view}\\n\\nCustom catalog:\\nBundled catalog:› /ultrafast The fastest available responses for latency-sensitive work.-/ ultrafast+› /ultrafastGPT-6-Astra (Global) default · /tmp/projectCustom catalog:› /express My custom Bedrock tier.-/ express+› /expressGPT-6-Astra default · /tmp/projectdiff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_us_sol61_ultrafast.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_us_sol61_ultrafast.snapindex 21eb1f3c4b..900ed4f307 100644--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_us_sol61_ultrafast.snap+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_us_sol61_ultrafast.snap@@ -5,13 +5,13 @@ expression: "format!(\"Bundled catalog:\\n{bundled_view}\\n\\nCustom catalog:\\nBundled catalog:› /ultrafast The fastest available responses for latency-sensitive work.-/ ultrafast+› /ultrafastGPT-6.1 Sol (US cross-region) default · /tmp/projectCustom catalog:› /express My custom Bedrock tier.-/ express+› /expressGPT-6.1-Sol default · /tmp/projectdiff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_us_ultrafast.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_us_ultrafast.snapindex 5eb6199c48..f08ee83308 100644--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_us_ultrafast.snap+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_us_ultrafast.snap@@ -5,13 +5,13 @@ expression: "format!(\"Bundled catalog:\\n{bundled_view}\\n\\nCustom catalog:\\nBundled catalog:› /ultrafast The fastest available responses for latency-sensitive work.-/ ultrafast+› /ultrafastGPT-6-Astra (US cross-region) default · /tmp/projectCustom catalog:› /express My custom Bedrock tier.-/ express+› /expressGPT-6-Astra default · /tmp/projectdiff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__model_picker_refreshes_service_tier_controls.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__model_picker_refreshes_service_tier_controls.snapindex 98b55ab5cc..d6477eeace 100644--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__model_picker_refreshes_service_tier_controls.snap+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__model_picker_refreshes_service_tier_controls.snap@@ -2,6 +2,6 @@source: tui/src/chatwidget/tests/popups_and_settings.rsexpression: "render_bottom_popup(&chat, 80)"----/ fast+› /fastgpt-5.4 default · /tmp/projectdiff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__worktrees_command_local.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__worktrees_command_local.snapindex 933b189d35..d42eb2f2bb 100644--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__worktrees_command_local.snap+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__worktrees_command_local.snap@@ -4,6 +4,6 @@ expression: popup---› /worktree start or continue a conversation in a new worktree-/ work+› /workGPT-5.6-Sol default · /tmp/projectdiff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__worktrees_command_remote.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__worktrees_command_remote.snapindex b6d294eecf..91076caee0 100644--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__worktrees_command_remote.snap+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__worktrees_command_remote.snap@@ -3,6 +3,6 @@ source: tui/src/chatwidget/tests/slash_commands.rsassertion_line: 3091expression: popup----/ work+› /workGPT-5.6-Sol default · /tmp/projectdiff --git a/codex-rs/tui/src/chatwidget/tests/snapshots/codex_tui__chatwidget__tests__slash_commands__ultrafast_command_allowed.snap b/codex-rs/tui/src/chatwidget/tests/snapshots/codex_tui__chatwidget__tests__slash_commands__ultrafast_command_allowed.snapindex c10befa7da..6505ef3a24 100644--- a/codex-rs/tui/src/chatwidget/tests/snapshots/codex_tui__chatwidget__tests__slash_commands__ultrafast_command_allowed.snap+++ b/codex-rs/tui/src/chatwidget/tests/snapshots/codex_tui__chatwidget__tests__slash_commands__ultrafast_command_allowed.snap@@ -4,6 +4,6 @@ expression: "render_bottom_popup(&chat, 80)"---› /ultrafast ultrafast processing-/ ultra+› /ultraGPT-5.5 default · /tmp/projectdiff --git a/codex-rs/tui/src/chatwidget/tests/snapshots/codex_tui__chatwidget__tests__slash_commands__ultrafast_command_denied.snap b/codex-rs/tui/src/chatwidget/tests/snapshots/codex_tui__chatwidget__tests__slash_commands__ultrafast_command_denied.snapindex 83a81d1d9b..25210e0ac9 100644--- a/codex-rs/tui/src/chatwidget/tests/snapshots/codex_tui__chatwidget__tests__slash_commands__ultrafast_command_denied.snap+++ b/codex-rs/tui/src/chatwidget/tests/snapshots/codex_tui__chatwidget__tests__slash_commands__ultrafast_command_denied.snap@@ -2,6 +2,6 @@source: tui/src/chatwidget/tests/slash_commands.rsexpression: "render_bottom_popup(&chat, 80)"----/ ultra+› /ultraGPT-5.5 default · /tmp/projectdiff --git a/codex-rs/tui/tests/suite/worktree_stack.rs b/codex-rs/tui/tests/suite/worktree_stack.rsindex 07a6c0a236..ecec4a8955 100644--- a/codex-rs/tui/tests/suite/worktree_stack.rs+++ b/codex-rs/tui/tests/suite/worktree_stack.rs@@ -181,7 +181,7 @@ fn submit(terminal: &mut PtyCodex, input: &str) -> Result<()> {// Send one paste event so slashes in arguments cannot accept a completion// while earlier characters are still buffered by paste-burst detection.terminal.write_input(format!("\x1b[200~{input}\x1b[201~").as_bytes())?;- terminal.wait_for_screen(&input.replacen('/', "/ ", 1))?;+ terminal.wait_for_screen(input)?;// Thread startup can keep the composer in queue mode after the history is visible.let deadline = Instant::now() + Duration::from_secs(/*secs*/ 30);while terminal.screen_contains("tab to queue message") {