diff --git a/codex-rs/exec-server/src/client.rs b/codex-rs/exec-server/src/client.rs index 9830771a00..52c7da824d 100644 --- a/codex-rs/exec-server/src/client.rs +++ b/codex-rs/exec-server/src/client.rs @@ -3,6 +3,7 @@ use std::time::Duration; use tokio::io::AsyncRead; use tokio::io::AsyncWrite; +use tokio::sync::mpsc; use tokio::time::timeout; use tokio_tungstenite::connect_async; use tracing::warn; @@ -17,6 +18,7 @@ use crate::protocol::InitializeResponse; use crate::rpc::RpcCallError; use crate::rpc::RpcClient; use crate::rpc::RpcClientEvent; +use crate::rpc::RpcNotificationSender; mod local_backend; use local_backend::LocalBackend; @@ -126,7 +128,10 @@ impl ExecServerClient { pub async fn connect_in_process( options: ExecServerClientConnectOptions, ) -> Result { - let backend = LocalBackend::new(crate::server::ExecServerHandler::new()); + let (outgoing_tx, _outgoing_rx) = mpsc::channel(1); + let backend = LocalBackend::new(crate::server::ExecServerHandler::new( + RpcNotificationSender::new(outgoing_tx), + )); let inner = Arc::new(Inner { backend: ClientBackend::InProcess(backend), reader_task: tokio::spawn(async {}), diff --git a/codex-rs/exec-server/src/server/handler.rs b/codex-rs/exec-server/src/server/handler.rs index 4d033030b8..6a8119b274 100644 --- a/codex-rs/exec-server/src/server/handler.rs +++ b/codex-rs/exec-server/src/server/handler.rs @@ -2,15 +2,18 @@ use codex_app_server_protocol::JSONRPCErrorError; use crate::protocol::InitializeResponse; use crate::protocol::PROTOCOL_VERSION; +use crate::rpc::RpcNotificationSender; pub(crate) struct ExecServerHandler { + _notifications: RpcNotificationSender, initialize_requested: bool, initialized: bool, } impl ExecServerHandler { - pub(crate) fn new() -> Self { + pub(crate) fn new(notifications: RpcNotificationSender) -> Self { Self { + _notifications: notifications, initialize_requested: false, initialized: false, } diff --git a/codex-rs/exec-server/src/server/processor.rs b/codex-rs/exec-server/src/server/processor.rs index aa4da92d0f..ddb7978be4 100644 --- a/codex-rs/exec-server/src/server/processor.rs +++ b/codex-rs/exec-server/src/server/processor.rs @@ -20,8 +20,8 @@ pub(crate) async fn run_connection(connection: JsonRpcConnection) { let (json_outgoing_tx, mut incoming_rx, _connection_tasks) = connection.into_parts(); let (outgoing_tx, mut outgoing_rx) = mpsc::channel::(CHANNEL_CAPACITY); - let handler = Arc::new(Mutex::new(ExecServerHandler::new())); - let _notifications = RpcNotificationSender::new(outgoing_tx.clone()); + let notifications = RpcNotificationSender::new(outgoing_tx.clone()); + let handler = Arc::new(Mutex::new(ExecServerHandler::new(notifications))); let outbound_task = tokio::spawn(async move { while let Some(message) = outgoing_rx.recv().await {