diff --git a/codex-rs/app-server/src/in_process.rs b/codex-rs/app-server/src/in_process.rs index f75a1b750c..4a81f652e6 100644 --- a/codex-rs/app-server/src/in_process.rs +++ b/codex-rs/app-server/src/in_process.rs @@ -383,6 +383,25 @@ pub async fn start(mut args: InProcessStartArgs) -> IoResult, + mut outbound_connections: HashMap, + mut shutdown_rx: oneshot::Receiver<()>, +) { + loop { + tokio::select! { + biased; + _ = &mut shutdown_rx => break, + envelope = outgoing_rx.recv() => { + let Some(envelope) = envelope else { + break; + }; + route_outgoing_envelope(&mut outbound_connections, envelope).await; + } + } + } +} + async fn start_uninitialized(args: InProcessStartArgs) -> IoResult { let channel_capacity = args.channel_capacity.max(1); let installation_id = resolve_installation_id(&args.config.codex_home).await?; @@ -390,7 +409,7 @@ async fn start_uninitialized(args: InProcessStartArgs) -> IoResult(channel_capacity); let runtime_handle = tokio::spawn(async move { - let (outgoing_tx, mut outgoing_rx) = mpsc::channel::(channel_capacity); + let (outgoing_tx, outgoing_rx) = mpsc::channel::(channel_capacity); let auth_manager = AuthManager::shared_from_config(args.config.as_ref(), args.enable_codex_api_key_env) .await; @@ -418,11 +437,12 @@ async fn start_uninitialized(args: InProcessStartArgs) -> IoResult IoResult IoResult