From afc377bae545398b0d41f9dcc7e541b191a8960e Mon Sep 17 00:00:00 2001 From: Jeremy Rose <172423086+nornagon-openai@users.noreply.github.com> Date: Thu, 14 Aug 2025 20:01:19 -0400 Subject: [PATCH] clear running commands in various places (#2325) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit we have a very unclear lifecycle for the chatwidget—this should only have to be added in one place! but this fixes the "hanging commands" issue where the active_exec_cell wasn't correctly cleared when commands finished. To repro w/o this PR: 1. prompt "run sleep 10" 2. once the command starts running, press Esc 3. prompt "run echo hi" Expected: ``` ✓ Completed └ ⌨️ echo hi codex hi ``` Actual: ``` ⚙︎ Working └ ⌨️ echo hi ▌ Ask Codex to do anything ``` i.e. the "Working" never changes to "Completed". The bug is fixed with this PR. --- codex-rs/tui/src/chatwidget.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index 3fa78279e..7cd7e6fad 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -182,6 +182,7 @@ impl ChatWidget<'_> { } // Mark task stopped and request redraw now that all content is in history. self.bottom_pane.set_task_running(false); + self.running_commands.clear(); self.mark_needs_redraw(); } @@ -198,6 +199,7 @@ impl ChatWidget<'_> { fn on_error(&mut self, message: String) { self.add_to_history(&history_cell::new_error_event(message)); self.bottom_pane.set_task_running(false); + self.running_commands.clear(); self.stream.clear_all(); self.mark_needs_redraw(); } @@ -473,6 +475,7 @@ impl ChatWidget<'_> { fn interrupt_running_task(&mut self) { if self.bottom_pane.is_task_running() { self.active_exec_cell = None; + self.running_commands.clear(); self.bottom_pane.clear_ctrl_c_quit_hint(); self.submit_op(Op::Interrupt); self.bottom_pane.set_task_running(false);