diff --git a/codex-rs/app-server/src/startup_config.rs b/codex-rs/app-server/src/startup_config.rs index 9b81861e54..2781ef5b84 100644 --- a/codex-rs/app-server/src/startup_config.rs +++ b/codex-rs/app-server/src/startup_config.rs @@ -116,15 +116,18 @@ async fn read_startup_config( Ok(config) => config, // Recovery retains local credential settings when cloud policy is unavailable. Err(_) if sign_out => loaded.bootstrap.clone(), - Err(error) - if manager - .current_managed_config_loader() - .config_server() - .is_some_and(|server| server.oauth.is_some()) => - { - return Err(config_server_error(error)); + Err(error) => { + let loader = manager.current_managed_config_loader(); + let server = loader + .config_server_resolution() + .map(|resolution| &resolution.resolved) + .or_else(|| loader.config_server()); + return Err(if server.is_some_and(|server| server.oauth.is_some()) { + config_server_error(error) + } else { + startup_error(error) + }); } - Err(error) => return Err(startup_error(error)), }; let config = if sign_out { // Preserve local credential authority while using the effective HTTP route. diff --git a/codex-rs/app-server/src/startup_config/oauth.rs b/codex-rs/app-server/src/startup_config/oauth.rs index 94f87aeef1..bc85b0861b 100644 --- a/codex-rs/app-server/src/startup_config/oauth.rs +++ b/codex-rs/app-server/src/startup_config/oauth.rs @@ -47,6 +47,7 @@ async fn discover_session( bootstrap.config_layer_stack.requirements_toml(), ) .await + .map(|session| session.and_then(|(_, manager)| manager)) .map_err(|_| config_server_login_failed("Could not initialize configuration server sign-in")) } diff --git a/codex-rs/cli/src/cloud_config.rs b/codex-rs/cli/src/cloud_config.rs index 8a0f1f374b..d9b00e02c7 100644 --- a/codex-rs/cli/src/cloud_config.rs +++ b/codex-rs/cli/src/cloud_config.rs @@ -17,11 +17,20 @@ use codex_utils_cli::CliConfigOverrides; pub async fn load_config( config_overrides: &CliConfigOverrides, loader_overrides: LoaderOverrides, +) -> Result { + load_config_with_resolution(config_overrides, loader_overrides, /*resolution*/ None).await +} + +pub(crate) async fn load_config_with_resolution( + config_overrides: &CliConfigOverrides, + loader_overrides: LoaderOverrides, + resolution: Option<&codex_config::ConfigServerResolution>, ) -> Result { let mut config = config_builder( config_overrides, loader_overrides, ConfigOverrides::default(), + resolution, ) .await? .build() @@ -36,6 +45,7 @@ pub async fn config_builder( config_overrides: &CliConfigOverrides, loader_overrides: LoaderOverrides, harness_overrides: ConfigOverrides, + resolution: Option<&codex_config::ConfigServerResolution>, ) -> Result { let network_policy = EmbeddedNetworkPolicy::load(&loader_overrides).await; let cli_overrides = config_overrides @@ -66,6 +76,7 @@ pub async fn config_builder( ), bootstrap_config.config_layer_stack.requirements_toml(), /*enable_codex_api_key_env*/ false, + resolution, ) .await .context("failed to initialize cloud configuration authentication")?; diff --git a/codex-rs/cli/src/doctor.rs b/codex-rs/cli/src/doctor.rs index b26ea9f38c..16b1e1fa9f 100644 --- a/codex-rs/cli/src/doctor.rs +++ b/codex-rs/cli/src/doctor.rs @@ -649,6 +649,7 @@ async fn load_config( &root_config_overrides, LoaderOverrides::default(), overrides, + /*resolution*/ None, ) .await? .build() diff --git a/codex-rs/cli/src/login.rs b/codex-rs/cli/src/login.rs index d91a012cd2..4e951a5350 100644 --- a/codex-rs/cli/src/login.rs +++ b/codex-rs/cli/src/login.rs @@ -187,10 +187,16 @@ async fn sign_in_to_config_server_and_reload_config( .await; let bootstrap_auth = network.bind_bootstrap_auth(config.auth_config()); let auth_route_config = bootstrap_auth.auth_route_config.clone(); - codex_cloud_config::ensure_config_server_login(bootstrap_auth, requirements, method).await?; - *config = crate::cloud_config::load_config(cli_config_overrides, Default::default()) - .await - .map_err(|error| std::io::Error::other(format!("{error:#}")))?; + let resolution = + codex_cloud_config::ensure_config_server_login(bootstrap_auth, requirements, method) + .await?; + *config = crate::cloud_config::load_config_with_resolution( + cli_config_overrides, + Default::default(), + resolution.as_ref(), + ) + .await + .map_err(|error| std::io::Error::other(format!("{error:#}")))?; network.activate(config); config.application_auth_route_config = Some(auth_route_config); Ok(()) @@ -592,8 +598,8 @@ async fn logout_config_server( ) .await? { - Some(manager) => manager.logout().await, - None => Ok(false), + Some((_, Some(manager))) => manager.logout().await, + Some((_, None)) | None => Ok(false), } } diff --git a/codex-rs/cli/src/marketplace_cmd.rs b/codex-rs/cli/src/marketplace_cmd.rs index d942de63e0..e4584227f5 100644 --- a/codex-rs/cli/src/marketplace_cmd.rs +++ b/codex-rs/cli/src/marketplace_cmd.rs @@ -133,6 +133,7 @@ impl MarketplaceCli { &config_overrides, LoaderOverrides::default(), ConfigOverrides::default(), + /*resolution*/ None, ) .await?; let config = builder.clone().build().await?; diff --git a/codex-rs/cli/src/plugin_cmd.rs b/codex-rs/cli/src/plugin_cmd.rs index 94756be4b7..bc65acaf94 100644 --- a/codex-rs/cli/src/plugin_cmd.rs +++ b/codex-rs/cli/src/plugin_cmd.rs @@ -773,6 +773,7 @@ async fn load_plugin_command_context( overrides, LoaderOverrides::default(), ConfigOverrides::default(), + /*resolution*/ None, ) .await? .build() diff --git a/codex-rs/cloud-config/src/bundle_loader.rs b/codex-rs/cloud-config/src/bundle_loader.rs index f295a38811..bd1cf3987e 100644 --- a/codex-rs/cloud-config/src/bundle_loader.rs +++ b/codex-rs/cloud-config/src/bundle_loader.rs @@ -6,6 +6,7 @@ use crate::service::CLOUD_CONFIG_BUNDLE_TIMEOUT; use crate::service::CloudConfigBundleService; use codex_config::CloudConfigBundleLoader; use codex_config::ConfigRequirementsToml; +use codex_config::ConfigServerResolution; use codex_http_client::HttpClientFactory; use codex_login::AuthConfig; use codex_login::AuthManager; @@ -24,12 +25,13 @@ const CONFIG_SERVER_LOGIN_FAILURE: &str = pub async fn managed_config_auth_manager( auth: AuthConfig, requirements: &ConfigRequirementsToml, -) -> std::io::Result> { +) -> std::io::Result)>> { let Some(service_config) = requirements.config_server.as_ref() else { return Ok(None); }; crate::config_server_auth_manager(service_config, auth.codex_home, &auth.auth_route_config) .await + .map(Some) } /// How to sign in when the config server has no saved OAuth grant. @@ -43,11 +45,14 @@ pub async fn ensure_config_server_login( auth: AuthConfig, requirements: &ConfigRequirementsToml, method: ConfigServerLoginMethod, -) -> std::io::Result<()> { - let Some(manager) = managed_config_auth_manager(auth, requirements).await? else { - return Ok(()); +) -> std::io::Result> { + let Some((resolution, manager)) = managed_config_auth_manager(auth, requirements).await? else { + return Ok(None); }; - ensure_config_server_login_with_manager(&manager, method).await + if let Some(manager) = manager { + ensure_config_server_login_with_manager(&manager, method).await?; + } + Ok(Some(resolution)) } pub(crate) async fn ensure_config_server_login_with_manager( @@ -88,6 +93,7 @@ pub async fn managed_config_bundle_loader( service_config.clone(), codex_home, &codex_login::AuthRouteConfig::from_http_client_factory(factory), + /*previous*/ None, ) .await; } @@ -109,12 +115,14 @@ pub async fn managed_config_bundle_loader_for_storage( auth_config: AuthConfig, requirements: &ConfigRequirementsToml, enable_codex_api_key_env: bool, + resolution: Option<&ConfigServerResolution>, ) -> std::io::Result { if let Some(service_config) = requirements.config_server.as_ref() { return Ok(crate::config_server_bundle_loader( service_config.clone(), auth_config.codex_home, &auth_config.auth_route_config, + resolution, ) .await); } @@ -205,6 +213,7 @@ pub async fn managed_config_bundle_loader_for_auth( config, requirements, /*enable_codex_api_key_env*/ false, + /*resolution*/ None, ) .await; } diff --git a/codex-rs/cloud-config/src/config_server.rs b/codex-rs/cloud-config/src/config_server.rs index 2addef71bc..397e8c3e8c 100644 --- a/codex-rs/cloud-config/src/config_server.rs +++ b/codex-rs/cloud-config/src/config_server.rs @@ -18,6 +18,7 @@ use codex_config::CloudConfigBundleLoader; use codex_config::CloudConfigBundlePolicy; use codex_config::CloudConfigBundleSnapshot; use codex_config::ConfigServer; +use codex_config::ConfigServerResolution; use codex_http_client::HttpClientFactory; use codex_keyring_store::DefaultKeyringStore; use codex_login::AuthRouteConfig; @@ -37,20 +38,18 @@ pub async fn config_server_bundle_loader( config: ConfigServer, codex_home: PathBuf, routes: &AuthRouteConfig, + previous: Option<&ConfigServerResolution>, ) -> CloudConfigBundleLoader { - let service = create_config_server_service(&config, &codex_home, routes).await; - - let loader = match service { - Ok(service) => { + match create_config_server_service(&config, &codex_home, routes, previous).await { + Ok((service, resolution)) => { let (loader, _) = managed_config_bundle_loader_for_service(service); - loader + loader.with_config_server_resolution(resolution) } Err(error) => { config_server_loader_after_failure(config.clone(), codex_home, routes.clone(), error) + .with_config_server(config) } - }; - - loader.with_config_server(config) + } } /// Git must apply the same policy as Codex without opening the OS keyring. @@ -60,7 +59,9 @@ pub async fn anonymous_config_server_bundle_loader( codex_home: PathBuf, routes: &AuthRouteConfig, ) -> std::io::Result { - let resolved = resolve_config_server(config, routes).await?; + let resolved = resolve_config_server(config, routes, /*previous*/ None) + .await? + .resolved; if resolved.oauth.is_some() { return Err(std::io::Error::other( "Git cannot verify Codex workspace policy using a protected login", @@ -76,8 +77,15 @@ async fn create_config_server_service( config: &ConfigServer, codex_home: &Path, routes: &AuthRouteConfig, -) -> Result, CloudConfigBundleLoadError> { - let resolved = resolve_config_server(config, routes) + previous: Option<&ConfigServerResolution>, +) -> Result< + ( + CloudConfigBundleService, + ConfigServerResolution, + ), + CloudConfigBundleLoadError, +> { + let resolution = resolve_config_server(config, routes, previous) .await .map_err(|error| { CloudConfigBundleLoadError::new( @@ -87,7 +95,8 @@ async fn create_config_server_service( ) })?; - config_server_service(resolved, codex_home, routes) + let service = config_server_service(resolution.resolved.clone(), codex_home, routes)?; + Ok((service, resolution)) } fn config_server_service( @@ -134,8 +143,13 @@ fn config_server_loader_after_failure( None => { initialized .get_or_try_init(|| async move { - let mut service = - create_config_server_service(&config, &codex_home, &routes).await?; + let (mut service, _) = create_config_server_service( + &config, + &codex_home, + &routes, + /*previous*/ None, + ) + .await?; service.policy = policy; let (loader, _) = managed_config_bundle_loader_for_service(service); Ok(loader) @@ -167,10 +181,12 @@ pub async fn config_server_auth_manager( service_config: &ConfigServer, codex_home: PathBuf, routes: &AuthRouteConfig, -) -> std::io::Result> { - let resolved = resolve_config_server(service_config, routes).await?; - let factory = config_server_http_client_factory(&resolved, routes); - oauth_session_manager(resolved.oauth.as_deref(), codex_home, &factory) +) -> std::io::Result<(ConfigServerResolution, Option)> { + let resolution = resolve_config_server(service_config, routes, /*previous*/ None).await?; + let factory = config_server_http_client_factory(&resolution.resolved, routes); + let manager = + oauth_session_manager(resolution.resolved.oauth.as_deref(), codex_home, &factory)?; + Ok((resolution, manager)) } fn config_server_http_client_factory( diff --git a/codex-rs/cloud-config/src/config_server_tests.rs b/codex-rs/cloud-config/src/config_server_tests.rs index 7530c5e4db..2e2a070a5d 100644 --- a/codex-rs/cloud-config/src/config_server_tests.rs +++ b/codex-rs/cloud-config/src/config_server_tests.rs @@ -118,6 +118,65 @@ async fn device_endpoint_failure_points_to_config_server_oauth() { ); } +#[tokio::test] +async fn policy_reload_reuses_discovery_only_for_the_same_config_server() { + let home = tempdir().unwrap(); + let mut auth = codex_core::config::Config::load_default_with_cli_overrides_for_codex_home( + home.path().into(), + vec![], + ) + .await + .unwrap() + .auth_config(); + // Any attempt to rediscover metadata during reload will fail. + let default = HttpClientFactory::new(codex_http_client::OutboundProxyPolicy::ReqwestDefault); + let blocked = default + .clone() + .with_network_policy(codex_http_client::NetworkPolicyController::default().policy()); + auth.auth_route_config = AuthRouteConfig::from_http_client_factory(blocked); + let base_url = "https://config.example"; + let server = |url: &str| ConfigServer { + base_url: url.into(), + oauth: None, + }; + let requirements = codex_config::ConfigRequirementsToml { + config_server: Some(server(base_url)), + ..Default::default() + }; + let oauth = Box::new(oauth_config("https://login.example")); + let system = HttpClientFactory::new(codex_http_client::OutboundProxyPolicy::RespectSystemProxy); + let fallback = default.clone().with_system_proxy_fallback(); + for (previous_url, discovered_oauth, factory, reuse) in [ + (base_url, Some(oauth.clone()), &default, true), + (base_url, None, &default, true), + ("https://other.example", None, &default, false), + (base_url, Some(oauth), &system, false), + (base_url, None, &fallback, false), + ] { + let previous = ConfigServerResolution { + outbound_proxy_policy: factory.outbound_proxy_policy(), + system_proxy_fallback: factory.allows_system_proxy_fallback(), + configured: server(previous_url), + resolved: ConfigServer { + oauth: discovered_oauth, + ..server(previous_url) + }, + }; + let loader = crate::managed_config_bundle_loader_for_storage( + auth.clone(), + &requirements, + /*enable_codex_api_key_env*/ false, + Some(&previous), + ) + .await + .unwrap(); + assert_eq!( + loader.config_server_resolution(), + reuse.then_some(&previous) + ); + } +} + #[tokio::test] async fn policy_fetch_uses_replacement_config_server_credentials() { let server = MockServer::start().await; diff --git a/codex-rs/cloud-config/src/discovery.rs b/codex-rs/cloud-config/src/discovery.rs index 983cf3f4ae..7157c32b02 100644 --- a/codex-rs/cloud-config/src/discovery.rs +++ b/codex-rs/cloud-config/src/discovery.rs @@ -2,6 +2,7 @@ //! Explicit OAuth settings take precedence, and discovered settings stay in memory. use codex_config::ConfigServer; +use codex_config::ConfigServerResolution; use codex_exec_server::RouteAwareHttpClient; use codex_login::AuthRouteConfig; use codex_login::OAuthSessionConfig; @@ -16,8 +17,23 @@ const DISCOVERY_TIMEOUT: Duration = Duration::from_secs(5); pub(crate) async fn resolve_config_server( config: &ConfigServer, routes: &AuthRouteConfig, -) -> io::Result { + previous: Option<&ConfigServerResolution>, +) -> io::Result { config.validated_base_url().map_err(io::Error::other)?; + let factory = routes.bootstrap_http_client_factory(); + let outbound_proxy_policy = factory.outbound_proxy_policy(); + let system_proxy_fallback = factory.allows_system_proxy_fallback(); + if let Some(previous) = previous + && previous.configured == *config + && previous.outbound_proxy_policy == outbound_proxy_policy + && previous.system_proxy_fallback == system_proxy_fallback + { + previous + .resolved + .validated_base_url() + .map_err(io::Error::other)?; + return Ok(previous.clone()); + } let mut resolved = config.clone(); if config.oauth.is_none() @@ -27,7 +43,12 @@ pub(crate) async fn resolve_config_server( resolved.validated_base_url().map_err(io::Error::other)?; } - Ok(resolved) + Ok(ConfigServerResolution { + outbound_proxy_policy, + system_proxy_fallback, + configured: config.clone(), + resolved, + }) } async fn discover_oauth( diff --git a/codex-rs/cloud-config/src/discovery_tests.rs b/codex-rs/cloud-config/src/discovery_tests.rs index e408603b75..3a63f5975e 100644 --- a/codex-rs/cloud-config/src/discovery_tests.rs +++ b/codex-rs/cloud-config/src/discovery_tests.rs @@ -120,7 +120,10 @@ async fn preserves_explicit_oauth_without_discovery() { oauth: Some(Box::new(explicit_oauth)), }; assert_eq!( - resolve_config_server(&config, &routes).await.unwrap(), + resolve_config_server(&config, &routes, /*previous*/ None) + .await + .unwrap() + .resolved, config ); let home = tempfile::tempdir().unwrap(); diff --git a/codex-rs/config/src/cloud_config_bundle.rs b/codex-rs/config/src/cloud_config_bundle.rs index 46ccbdbcb3..650fca7f92 100644 --- a/codex-rs/config/src/cloud_config_bundle.rs +++ b/codex-rs/config/src/cloud_config_bundle.rs @@ -428,6 +428,7 @@ pub struct CloudConfigBundleLoader { snapshot_getter: Option>, ema_policy: Option, config_server: Option, + config_server_resolution: Option>, } impl CloudConfigBundleLoader { @@ -454,6 +455,7 @@ impl CloudConfigBundleLoader { snapshot_getter: None, ema_policy: None, config_server: None, + config_server_resolution: None, } } @@ -503,9 +505,24 @@ impl CloudConfigBundleLoader { pub fn with_config_server(mut self, service_config: crate::ConfigServer) -> Self { self.config_server = Some(service_config); + self.config_server_resolution = None; self } + pub fn with_config_server_resolution( + mut self, + resolution: crate::ConfigServerResolution, + ) -> Self { + self.config_server = Some(resolution.configured.clone()); + self.config_server_resolution = Some(Arc::new(resolution)); + self + } + + /// Successful discovery, including anonymous configuration, for the retained loader. + pub fn config_server_resolution(&self) -> Option<&crate::ConfigServerResolution> { + self.config_server_resolution.as_deref() + } + pub fn config_server(&self) -> Option<&crate::ConfigServer> { self.config_server.as_ref() } diff --git a/codex-rs/config/src/config_server.rs b/codex-rs/config/src/config_server.rs index 00c5213860..a748f63dad 100644 --- a/codex-rs/config/src/config_server.rs +++ b/codex-rs/config/src/config_server.rs @@ -15,6 +15,15 @@ pub struct ConfigServer { pub oauth: Option>, } +/// Successful runtime resolution, kept separate from administrator requirements. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ConfigServerResolution { + pub outbound_proxy_policy: codex_http_client::OutboundProxyPolicy, + pub system_proxy_fallback: bool, + pub configured: ConfigServer, + pub resolved: ConfigServer, +} + #[derive(Deserialize)] #[serde(deny_unknown_fields)] struct ConfigServerInput { diff --git a/codex-rs/config/src/lib.rs b/codex-rs/config/src/lib.rs index 2964d24281..694d04aa66 100644 --- a/codex-rs/config/src/lib.rs +++ b/codex-rs/config/src/lib.rs @@ -155,6 +155,7 @@ pub use config_requirements::apply_otel_requirements; pub use config_requirements::sandbox_mode_requirement_for_permission_profile; pub use config_server::ConfigServer; pub use config_server::ConfigServerOAuth; +pub use config_server::ConfigServerResolution; pub use config_toml::effective_sandbox_mode; pub use constraint::Constrained; pub use constraint::ConstraintError; diff --git a/codex-rs/exec/src/lib.rs b/codex-rs/exec/src/lib.rs index f1ac42c314..b2123ac03f 100644 --- a/codex-rs/exec/src/lib.rs +++ b/codex-rs/exec/src/lib.rs @@ -446,6 +446,7 @@ pub async fn run_main(cli: Cli, arg0_paths: Arg0DispatchPaths) -> anyhow::Result .bind_bootstrap_auth(bootstrap_auth_config(&codex_home, &gate_bootstrap)?), gate_bootstrap.config_layer_stack.requirements_toml(), /*enable_codex_api_key_env*/ false, + /*resolution*/ None, ) .await?; let gate_config = ConfigBuilder::default() @@ -546,6 +547,7 @@ pub async fn run_main(cli: Cli, arg0_paths: Arg0DispatchPaths) -> anyhow::Result bootstrap_auth_config, bootstrap_config.config_layer_stack.requirements_toml(), /*enable_codex_api_key_env*/ false, + /*resolution*/ None, ) .await?; if let Some(worktree) = managed_worktree.as_ref() { diff --git a/codex-rs/tui/src/lib.rs b/codex-rs/tui/src/lib.rs index 38843bf611..f8ff0d96d0 100644 --- a/codex-rs/tui/src/lib.rs +++ b/codex-rs/tui/src/lib.rs @@ -1063,6 +1063,7 @@ async fn cloud_config_bundle_for_app_server_target( bootstrap_config: &ConfigTomlLoadResult, codex_home: &Path, embedded_network_policy: &codex_app_server_client::EmbeddedNetworkPolicy, + resolution: Option<&codex_config::ConfigServerResolution>, ) -> std::io::Result { managed_config_bundle_loader_for_storage( embedded_network_policy @@ -1071,6 +1072,7 @@ async fn cloud_config_bundle_for_app_server_target( )), bootstrap_config.config_layer_stack.requirements_toml(), /*enable_codex_api_key_env*/ false, + resolution, ) .await } @@ -1505,6 +1507,10 @@ async fn run_ratatui_app( embedded_network_policy.bind_bootstrap_auth(initial_config.auth_config()), initial_config.config_layer_stack.requirements_toml(), /*enable_codex_api_key_env*/ false, + // The server may have started requiring OAuth during onboarding. + cloud_config_bundle + .config_server_resolution() + .filter(|resolution| resolution.resolved.oauth.is_some()), ) .await?; } diff --git a/codex-rs/tui/src/session_archive_commands.rs b/codex-rs/tui/src/session_archive_commands.rs index 4b75123d4e..ba0e62aab1 100644 --- a/codex-rs/tui/src/session_archive_commands.rs +++ b/codex-rs/tui/src/session_archive_commands.rs @@ -342,6 +342,7 @@ pub(super) async fn start_app_server_for_session_command( &bootstrap_config, codex_home.as_path(), &embedded_network_policy, + /*resolution*/ None, ) .await?; diff --git a/codex-rs/tui/src/startup_orchestration.rs b/codex-rs/tui/src/startup_orchestration.rs index 7b4e1e1e50..c5f9c487e2 100644 --- a/codex-rs/tui/src/startup_orchestration.rs +++ b/codex-rs/tui/src/startup_orchestration.rs @@ -181,6 +181,7 @@ pub(super) async fn run_main_inner( &validation_bootstrap, &codex_home, &embedded_network_policy, + /*resolution*/ None, ) .await? } else { @@ -313,7 +314,7 @@ pub(super) async fn run_main_inner( err } })?; - if std::io::stdin().is_terminal() && std::io::stdout().is_terminal() { + let resolution = if std::io::stdin().is_terminal() && std::io::stdout().is_terminal() { codex_cloud_config::ensure_config_server_login( embedded_network_policy.bind_bootstrap_auth(bootstrap_auth_config( &codex_home, @@ -325,8 +326,10 @@ pub(super) async fn run_main_inner( .requirements_toml(), codex_cloud_config::ConfigServerLoginMethod::Browser, ) - .await?; - } + .await? + } else { + None + }; // Keep normal terminal signals available until local configuration is ready. Once raw // mode begins, StartupDraft immediately takes ownership of input. let (initialized_terminal, terminal_restore_guard) = tokio::task::spawn_blocking(|| { @@ -402,6 +405,7 @@ pub(super) async fn run_main_inner( &bootstrap_config, &codex_home, &embedded_network_policy, + resolution.as_ref(), )) .await??; let bootstrap_config_toml = &bootstrap_config.config_toml; @@ -537,6 +541,7 @@ pub(super) async fn run_main_inner( ), config.config_layer_stack.requirements_toml(), /*enable_codex_api_key_env*/ false, + cloud_config_bundle.config_server_resolution(), )) .await?? }; diff --git a/codex-rs/tui/src/worktree_startup.rs b/codex-rs/tui/src/worktree_startup.rs index df836630f5..3f4f855015 100644 --- a/codex-rs/tui/src/worktree_startup.rs +++ b/codex-rs/tui/src/worktree_startup.rs @@ -129,7 +129,7 @@ pub(super) async fn prepare( strict_config: bool, target: &AppServerTarget, arg0_paths: &Arg0DispatchPaths, - source_bundle: CloudConfigBundleLoader, + mut source_bundle: CloudConfigBundleLoader, embedded_network_policy: &codex_app_server_client::EmbeddedNetworkPolicy, ) -> color_eyre::Result<(Config, CloudConfigBundleLoader, ManagedTuiWorktree)> { if let Some(id_or_name) = cli.fork_session_id.as_deref() { @@ -202,11 +202,12 @@ pub(super) async fn prepare( CloudConfigBundleLoader::default(), ) .await; - let source_bundle = cloud_config_bundle_for_app_server_target( + source_bundle = cloud_config_bundle_for_app_server_target( target, &bootstrap, &source.codex_home, embedded_network_policy, + source_bundle.config_server_resolution(), ) .await?; overrides.cwd = Some(cwd.into_path_buf()); @@ -214,7 +215,7 @@ pub(super) async fn prepare( cli_overrides.clone(), overrides.clone(), loader_overrides.clone(), - source_bundle, + source_bundle.clone(), strict_config, ) .await; @@ -279,6 +280,7 @@ pub(super) async fn prepare( &bootstrap, &source.codex_home, embedded_network_policy, + source_bundle.config_server_resolution(), ) .await?; managed