From c85369db7859b9e09a829445b8c91ea2db1c611d Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Wed, 30 Jul 2025 16:14:19 -0700 Subject: [PATCH] compact --- codex-rs/core/src/codex.rs | 8 +++++--- codex-rs/tui/src/chatwidget.rs | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index 90f1fe91c3..b8b6c7c30f 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -895,9 +895,11 @@ async fn submission_loop( // Attempt to inject input into current task if let Err(items) = sess.inject_input(summarization_prompt) { - // No current task, spawn a new one - let task = AgentTask::spawn(sess.clone(), sub.id, items); - sess.set_task(task); + run_task(sess.clone(), sub.id, items).await; + // only keep the last input item and clear the rest + let mut pending_input = sess.state.lock().unwrap().pending_input.clone(); + pending_input.truncate(1); + sess.state.lock().unwrap().pending_input = pending_input; } } Op::Shutdown => { diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index fde6978634..43f49395e9 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -158,7 +158,7 @@ impl ChatWidget<'_> { self.bottom_pane.handle_paste(text); } - fn add_to_history(&mut self, cell: HistoryCell) { + pub(crate) fn add_to_history(&mut self, cell: HistoryCell) { self.app_event_tx .send(AppEvent::InsertHistory(cell.plain_lines())); }