From cc8fd0ff65b603133304db268dd4b7a86b304dc3 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Fri, 3 Apr 2026 08:39:26 -0700 Subject: [PATCH] Fix stale /copy output after commentary-only turns (#16648) Addresses #16454 Problem: `/copy` could keep stale output after a turn with commentary-only assistant text. Solution: Cache the latest non-empty agent message during a turn and promote it on turn completion. --- codex-rs/tui/src/chatwidget.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index 02429e9d9..b0ddb631b 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -777,7 +777,7 @@ pub(crate) struct ChatWidget { plan_stream_controller: Option, // Latest completed user-visible Codex output that `/copy` should place on the clipboard. last_copyable_output: Option, - // Final-answer agent message observed during the active turn. App-server turn completion + // Latest agent message observed during the active turn. App-server turn completion // notifications do not repeat this payload, so we promote it when the turn completes. pending_turn_copyable_output: Option, running_commands: HashMap, @@ -4041,10 +4041,7 @@ impl ChatWidget { self.finalize_completed_assistant_message( (!message.is_empty()).then_some(message.as_str()), ); - if self.agent_turn_running - && !message.is_empty() - && matches!(item.phase, Some(MessagePhase::FinalAnswer) | None) - { + if self.agent_turn_running && !message.is_empty() { self.pending_turn_copyable_output = Some(message.clone()); } self.pending_status_indicator_restore = match item.phase {