From 1e832a92c2982086ed5c4bcaad00883f308c5322 Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Tue, 1 Dec 2026 19:18:17 +0000 Subject: [PATCH] Fix granular approval defaults at projectless TUI startup (#65086) ## Why An `approval_policy` in the client's config could suppress the granular default when starting a projectless session with server-owned defaults. ## What changed Make the granular default available at startup so the launch code can apply it when the invocation leaves the policy unset and the server allows it. ## Testing Extend the server-defaults startup test to set the client's policy to `never` and verify that `thread/start` still requests granular approval. GitOrigin-RevId: 770aa978e2372e1e30fe778b670ea25f9c3c1cd0 --- codex-rs/tui/src/app/tests/projectless_tests.rs | 5 ++++- codex-rs/tui/src/app/tests/startup_defaults_tests.rs | 2 +- codex-rs/tui/src/projectless.rs | 6 +++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/codex-rs/tui/src/app/tests/projectless_tests.rs b/codex-rs/tui/src/app/tests/projectless_tests.rs index e5ec912154..b503bed04b 100644 --- a/codex-rs/tui/src/app/tests/projectless_tests.rs +++ b/codex-rs/tui/src/app/tests/projectless_tests.rs @@ -346,7 +346,10 @@ async fn local_projectless_defaults_respect_trust_scope_and_explicit_settings() &EnvironmentManager::default_for_tests(), ); if expected_approval.is_some() { - assert_eq!(startup.approval_policy, None); + assert!(matches!( + startup.approval_policy, + Some(Approval::Granular(_)) + )); } assert_eq!( startup.prompt_windows_sandbox, diff --git a/codex-rs/tui/src/app/tests/startup_defaults_tests.rs b/codex-rs/tui/src/app/tests/startup_defaults_tests.rs index d6a98f4a06..dc3759b992 100644 --- a/codex-rs/tui/src/app/tests/startup_defaults_tests.rs +++ b/codex-rs/tui/src/app/tests/startup_defaults_tests.rs @@ -919,7 +919,7 @@ async fn startup_with_server_defaults() -> Result<()> { let projectless_cwd = tempdir()?; std::fs::write( client_home.path().join("config.toml"), - "model = \"client-model\"\nmodel_reasoning_effort = \"low\"\n", + "model = \"client-model\"\nmodel_reasoning_effort = \"low\"\napproval_policy = \"never\"\n", )?; std::fs::write( server_home.path().join("config.toml"), diff --git a/codex-rs/tui/src/projectless.rs b/codex-rs/tui/src/projectless.rs index cf0816220d..008d42c9f3 100644 --- a/codex-rs/tui/src/projectless.rs +++ b/codex-rs/tui/src/projectless.rs @@ -76,9 +76,13 @@ pub(crate) fn apply_defaults( request_permissions: true, mcp_elicitations: true, }); + // Fresh startup checks invocation choices and server requirements separately. + // Directory transitions still use the scoped config below. let mut applied = AppliedDefaults::default(); + if defaults.approval_policy.is_none() { + applied.approval_policy = Some(granular); + } if overrides.approval_policy.is_none() && effective.get("approval_policy").is_none() { - applied.approval_policy = defaults.approval_policy.is_none().then_some(granular); let granular = defaults .approval_policy .as_ref()