diff --git a/codex-rs/tui/src/app.rs b/codex-rs/tui/src/app.rs index 40b91406ca..02186b015b 100644 --- a/codex-rs/tui/src/app.rs +++ b/codex-rs/tui/src/app.rs @@ -507,7 +507,7 @@ impl App { } fn open_new_conversation_prompt(&mut self) { - let (initial_prompt, initial_images) = self.chat_widget.take_composer_draft(); + let (initial_prompt, initial_images) = self.chat_widget.composer_draft(); let tx = self.app_event_tx.clone(); let initial_prompt = Arc::new(initial_prompt); @@ -998,6 +998,7 @@ impl App { return Ok(true); } }; + self.chat_widget.set_composer_text(String::new()); let conversation_id = created.conversation_id; if !self.conversation_order.contains(&conversation_id) { diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rs index 0d5fe44064..2597021b7f 100644 --- a/codex-rs/tui/src/bottom_pane/chat_composer.rs +++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs @@ -414,6 +414,13 @@ impl ChatComposer { images.into_iter().map(|img| img.path).collect() } + pub(crate) fn attached_image_paths(&self) -> Vec { + self.attached_images + .iter() + .map(|img| img.path.clone()) + .collect() + } + pub(crate) fn flush_paste_burst_if_due(&mut self) -> bool { self.handle_paste_burst_flush(Instant::now()) } diff --git a/codex-rs/tui/src/bottom_pane/mod.rs b/codex-rs/tui/src/bottom_pane/mod.rs index 7634f699aa..ec10a0fce2 100644 --- a/codex-rs/tui/src/bottom_pane/mod.rs +++ b/codex-rs/tui/src/bottom_pane/mod.rs @@ -549,6 +549,10 @@ impl BottomPane { self.composer.take_recent_submission_images() } + pub(crate) fn composer_attached_image_paths(&self) -> Vec { + self.composer.attached_image_paths() + } + fn as_renderable(&'_ self) -> RenderableItem<'_> { if let Some(view) = self.active_view() { RenderableItem::Borrowed(view) diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index 5bdf81dcd8..e6d5c5ccb8 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -3559,11 +3559,11 @@ impl ChatWidget { .unwrap_or_default() } - pub(crate) fn take_composer_draft(&mut self) -> (String, Vec) { - let text = self.bottom_pane.composer_text(); - let images = self.bottom_pane.take_recent_submission_images(); - self.bottom_pane.set_composer_text(String::new()); - (text, images) + pub(crate) fn composer_draft(&self) -> (String, Vec) { + ( + self.bottom_pane.composer_text(), + self.bottom_pane.composer_attached_image_paths(), + ) } pub(crate) fn conversation_id(&self) -> Option {