diff --git a/codex-rs/app-server/src/bespoke_event_handling.rs b/codex-rs/app-server/src/bespoke_event_handling.rs index 41e0b49f02..485f8e1445 100644 --- a/codex-rs/app-server/src/bespoke_event_handling.rs +++ b/codex-rs/app-server/src/bespoke_event_handling.rs @@ -3492,6 +3492,17 @@ mod tests { ThreadId::new(), ); let thread_state = new_thread_state(); + handle_error( + conversation_id, + TurnError { + misalignment: None, + message: "conversation is not running".to_string(), + codex_error_info: Some(V2CodexErrorInfo::Other), + additional_details: None, + }, + &thread_state, + ) + .await; let event = turn_complete_event(&event_turn_id); { let mut state = thread_state.lock().await; @@ -3648,6 +3659,18 @@ mod tests { let conversation_id = ThreadId::new(); let event_turn_id = "complete_err1".to_string(); let thread_state = new_thread_state(); + thread_state.lock().await.track_current_turn_event( + &event_turn_id, + &EventMsg::TurnStarted(codex_protocol::protocol::TurnStartedEvent { + turn_attribution: None, + turn_id: event_turn_id.clone(), + root_turn_id: None, + trace_id: None, + started_at: Some(42), + model_context_window: None, + collaboration_mode_kind: Default::default(), + }), + ); handle_error( conversation_id, TurnError { diff --git a/codex-rs/app-server/src/thread_state.rs b/codex-rs/app-server/src/thread_state.rs index a712ee2f47..ab0464f2f8 100644 --- a/codex-rs/app-server/src/thread_state.rs +++ b/codex-rs/app-server/src/thread_state.rs @@ -235,7 +235,10 @@ impl ThreadState { pub(crate) fn track_current_turn_event(&mut self, event_turn_id: &str, event: &EventMsg) { if let EventMsg::TurnStarted(payload) = event { - self.turn_summary.started_at = payload.started_at; + self.turn_summary = TurnSummary { + started_at: payload.started_at, + ..Default::default() + }; } if let EventMsg::ItemCompleted(payload) = event && let CoreTurnItem::AgentMessage(item) = &payload.item