Reuse config server discovery when loading managed policy (#63473)

## Why

CLI login and interactive TUI startup could look up the same config server's
OAuth metadata again when loading managed policy, even after resolving it
for sign-in.

## What changed

- Carry the resolved config server settings in memory from sign-in to policy
  loading and through TUI startup and worktree setup. Reuse them only when
  the configured server, outbound proxy policy, and system proxy fallback
  setting match.
- Rediscover anonymous servers after onboarding so the TUI can pick up a
  newly enabled OAuth requirement.
- Use discovered OAuth settings to classify app-server startup errors as
  config server errors when applicable.

## Testing

Add a regression test that blocks discovery requests and checks reuse for
matching OAuth and anonymous resolutions, as well as cache misses when the
server or either proxy setting changes.

GitOrigin-RevId: 28b5c8ffdb80db09dd8bbae3c1e187189ea393bf
This commit is contained in:
vishnu-oai
2026-11-24 00:11:35 +00:00
committed by copyberry
parent 6a33df4e0a
commit 83077214a4
20 changed files with 221 additions and 46 deletions
+2
View File
@@ -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() {