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.
This commit is contained in:
Eric Traut
2026-04-03 08:39:26 -07:00
committed by GitHub
Unverified
parent af8a9d2d2b
commit cc8fd0ff65
+2 -5
View File
@@ -777,7 +777,7 @@ pub(crate) struct ChatWidget {
plan_stream_controller: Option<PlanStreamController>,
// Latest completed user-visible Codex output that `/copy` should place on the clipboard.
last_copyable_output: Option<String>,
// 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<String>,
running_commands: HashMap<String, RunningCommand>,
@@ -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 {