diff --git a/codex-rs/app-server-protocol/src/protocol/v2.rs b/codex-rs/app-server-protocol/src/protocol/v2.rs index e3c9fc0558..f1d8392135 100644 --- a/codex-rs/app-server-protocol/src/protocol/v2.rs +++ b/codex-rs/app-server-protocol/src/protocol/v2.rs @@ -1294,6 +1294,7 @@ pub struct TurnDiffUpdatedNotification { #[serde(rename_all = "camelCase")] #[ts(export_to = "v2/")] pub struct TurnPlanUpdatedNotification { + pub thread_id: String, pub turn_id: String, pub explanation: Option, pub plan: Vec, diff --git a/codex-rs/app-server/src/bespoke_event_handling.rs b/codex-rs/app-server/src/bespoke_event_handling.rs index b4dd16b9a6..df4cdb8980 100644 --- a/codex-rs/app-server/src/bespoke_event_handling.rs +++ b/codex-rs/app-server/src/bespoke_event_handling.rs @@ -661,6 +661,7 @@ pub(crate) async fn apply_bespoke_event_handling( } EventMsg::PlanUpdate(plan_update_event) => { handle_turn_plan_update( + conversation_id, &event_turn_id, plan_update_event, api_version, @@ -693,6 +694,7 @@ async fn handle_turn_diff( } async fn handle_turn_plan_update( + conversation_id: ConversationId, event_turn_id: &str, plan_update_event: UpdatePlanArgs, api_version: ApiVersion, @@ -700,6 +702,7 @@ async fn handle_turn_plan_update( ) { if let ApiVersion::V2 = api_version { let notification = TurnPlanUpdatedNotification { + thread_id: conversation_id.to_string(), turn_id: event_turn_id.to_string(), explanation: plan_update_event.explanation, plan: plan_update_event @@ -1422,7 +1425,16 @@ mod tests { ], }; - handle_turn_plan_update("turn-123", update, ApiVersion::V2, &outgoing).await; + let conversation_id = ConversationId::new(); + + handle_turn_plan_update( + conversation_id, + "turn-123", + update, + ApiVersion::V2, + &outgoing, + ) + .await; let msg = rx .recv() @@ -1430,6 +1442,7 @@ mod tests { .ok_or_else(|| anyhow!("should send one notification"))?; match msg { OutgoingMessage::AppServerNotification(ServerNotification::TurnPlanUpdated(n)) => { + assert_eq!(n.thread_id, conversation_id.to_string()); assert_eq!(n.turn_id, "turn-123"); assert_eq!(n.explanation.as_deref(), Some("need plan")); assert_eq!(n.plan.len(), 2);