codex: order websocket initialize readiness after handshake (#13593)

This commit is contained in:
Ahmed Ibrahim
2026-03-07 02:39:20 -08:00
parent 93af8e0d57
commit 0de39cd7ce
2 changed files with 17 additions and 11 deletions

View File

@@ -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) => {

View File

@@ -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;
}
}