diff --git a/codex-rs/app-server/src/lib.rs b/codex-rs/app-server/src/lib.rs index 3505f432d5..aa018be1c4 100644 --- a/codex-rs/app-server/src/lib.rs +++ b/codex-rs/app-server/src/lib.rs @@ -711,7 +711,6 @@ pub async fn run_main_with_transport( request, transport, &mut connection_state.session, - &connection_state.outbound_initialized, ) .await; if let Ok(mut opted_out_notification_methods) = connection_state @@ -734,7 +733,15 @@ pub async fn run_main_with_transport( std::sync::atomic::Ordering::Release, ); if !was_initialized && connection_state.session.initialized { - processor.send_initialize_notifications().await; + processor + .send_initialize_notifications_to_connection( + connection_id, + ) + .await; + processor.connection_initialized(connection_id).await; + connection_state + .outbound_initialized + .store(true, std::sync::atomic::Ordering::Release); } } JSONRPCMessage::Response(response) => { diff --git a/codex-rs/app-server/src/message_processor.rs b/codex-rs/app-server/src/message_processor.rs index f56e12467f..5bdc31e14c 100644 --- a/codex-rs/app-server/src/message_processor.rs +++ b/codex-rs/app-server/src/message_processor.rs @@ -1,8 +1,6 @@ use std::collections::HashSet; use std::sync::Arc; use std::sync::RwLock; -use std::sync::atomic::AtomicBool; -use std::sync::atomic::Ordering; use crate::codex_message_processor::CodexMessageProcessor; use crate::codex_message_processor::CodexMessageProcessorArgs; @@ -230,7 +228,6 @@ impl MessageProcessor { request: JSONRPCRequest, transport: AppServerTransport, session: &mut ConnectionSessionState, - outbound_initialized: &AtomicBool, ) { let request_span = crate::app_server_tracing::request_span(&request, transport, connection_id, session); @@ -346,10 +343,6 @@ impl MessageProcessor { self.outgoing.send_response(request_id, response).await; session.initialized = true; - outbound_initialized.store(true, Ordering::Release); - self.codex_message_processor - .connection_initialized(connection_id) - .await; return; } } @@ -467,10 +460,16 @@ impl MessageProcessor { self.codex_message_processor.thread_created_receiver() } - pub(crate) async fn send_initialize_notifications(&self) { + pub(crate) async fn send_initialize_notifications_to_connection( + &self, + connection_id: ConnectionId, + ) { for notification in self.config_warnings.iter().cloned() { self.outgoing - .send_server_notification(ServerNotification::ConfigWarning(notification)) + .send_server_notification_to_connections( + &[connection_id], + ServerNotification::ConfigWarning(notification), + ) .await; } }