From 5e007ccff47444fa280e5948803ff53d4313130d Mon Sep 17 00:00:00 2001 From: Brent Traut Date: Mon, 18 May 2026 19:57:54 -0700 Subject: [PATCH] app-server: inline pending cleanup check --- .../app-server/src/bespoke_event_handling.rs | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/codex-rs/app-server/src/bespoke_event_handling.rs b/codex-rs/app-server/src/bespoke_event_handling.rs index 410620324b..73a4209e59 100644 --- a/codex-rs/app-server/src/bespoke_event_handling.rs +++ b/codex-rs/app-server/src/bespoke_event_handling.rs @@ -183,12 +183,13 @@ pub(crate) async fn apply_bespoke_event_handling( outgoing.abort_pending_server_requests().await; respond_to_pending_interrupts(&thread_state, &outgoing).await; let turn_failed = thread_state.lock().await.turn_summary.last_error.is_some(); - let preserve_terminal_plan_progress = - terminal_plan_cleanup_may_be_needed(&thread_state).await - && should_preserve_terminal_plan_progress( - conversation.as_ref(), - conversation_id, - ) + let has_pending_terminal_plan_cleanup = !thread_state + .lock() + .await + .pending_terminal_plan_cleanups + .is_empty(); + let preserve_terminal_plan_progress = has_pending_terminal_plan_cleanup + && should_preserve_terminal_plan_progress(conversation.as_ref(), conversation_id) .await; thread_watch_manager .note_turn_completed(&conversation_id.to_string(), turn_failed) @@ -1381,14 +1382,6 @@ async fn emit_turn_plan_updated( .await; } -async fn terminal_plan_cleanup_may_be_needed(thread_state: &Arc>) -> bool { - !thread_state - .lock() - .await - .pending_terminal_plan_cleanups - .is_empty() -} - async fn take_flushable_pending_terminal_plan_cleanup( thread_state: &Arc>, ) -> Vec {