From 97bcd94066e7b0eba0b00ba848e320f314f2a689 Mon Sep 17 00:00:00 2001 From: Brent Traut Date: Mon, 18 May 2026 19:24:46 -0700 Subject: [PATCH] app-server: simplify deferred cleanup emission --- .../app-server/src/bespoke_event_handling.rs | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/codex-rs/app-server/src/bespoke_event_handling.rs b/codex-rs/app-server/src/bespoke_event_handling.rs index 3eb834290d..a220eab99f 100644 --- a/codex-rs/app-server/src/bespoke_event_handling.rs +++ b/codex-rs/app-server/src/bespoke_event_handling.rs @@ -1608,16 +1608,14 @@ async fn handle_turn_complete( thread_state: &Arc>, ) { let turn_summary = find_and_remove_turn_summary(thread_state).await; - emit_terminal_plan_cleanup( - conversation_id, - if preserve_terminal_plan_progress { - Vec::new() - } else { - take_pending_terminal_plan_cleanup(thread_state).await - }, - outgoing, - ) - .await; + if !preserve_terminal_plan_progress { + emit_terminal_plan_cleanup( + conversation_id, + take_pending_terminal_plan_cleanup(thread_state).await, + outgoing, + ) + .await; + } let (status, error) = match turn_summary.last_error { Some(error) => (TurnStatus::Failed, Some(error)), @@ -1648,16 +1646,14 @@ async fn handle_turn_interrupted( thread_state: &Arc>, ) { let turn_summary = find_and_remove_turn_summary(thread_state).await; - emit_terminal_plan_cleanup( - conversation_id, - if preserve_terminal_plan_progress { - Vec::new() - } else { - take_pending_terminal_plan_cleanup(thread_state).await - }, - outgoing, - ) - .await; + if !preserve_terminal_plan_progress { + emit_terminal_plan_cleanup( + conversation_id, + take_pending_terminal_plan_cleanup(thread_state).await, + outgoing, + ) + .await; + } emit_turn_completed_with_status( conversation_id,