diff --git a/codex-rs/exec-server/src/client.rs b/codex-rs/exec-server/src/client.rs index 37f3e2455a..df068466b8 100644 --- a/codex-rs/exec-server/src/client.rs +++ b/codex-rs/exec-server/src/client.rs @@ -153,8 +153,8 @@ pub(crate) struct Session { struct Inner { client: RpcClient, - // Keep the connection alive for any transport-specific owned state such as - // the stdio child process. RpcClient only takes the runtime channels/tasks. + // Keep the underlying transport connection alive. RpcClient only takes the + // runtime channels/tasks it needs to drive the JSON-RPC client. _connection: JsonRpcConnection, // The remote transport delivers one shared notification stream for every // process on the connection. Keep a local process_id -> session registry so @@ -208,9 +208,11 @@ impl LazyRemoteExecServerClient { pub(crate) async fn get(&self) -> Result { self.client + // TODO: Add reconnect/disconnect handling here instead of reusing + // the first successfully initialized connection forever. .get_or_try_init(|| { let transport = self.transport.clone(); - async move { ExecServerClient::connect_for_environment(transport).await } + async move { ExecServerClient::connect_for_transport(transport).await } }) .await .cloned() diff --git a/codex-rs/exec-server/src/client_transport.rs b/codex-rs/exec-server/src/client_transport.rs index df9d84beab..7543d283b4 100644 --- a/codex-rs/exec-server/src/client_transport.rs +++ b/codex-rs/exec-server/src/client_transport.rs @@ -21,7 +21,7 @@ const ENVIRONMENT_CONNECT_TIMEOUT: Duration = Duration::from_secs(5); const ENVIRONMENT_INITIALIZE_TIMEOUT: Duration = Duration::from_secs(5); impl ExecServerClient { - pub(crate) async fn connect_for_environment( + pub(crate) async fn connect_for_transport( transport: crate::client_api::ExecServerTransport, ) -> Result { match transport {