Preserve cloud requirements across TUI thread resets (#25177)

Fixes a TUI regression where thread transitions such as `/new` and
`/clear` could rebuild config without the cloud requirements loader,
allowing users to fall back to non-cloud-managed settings. The config
refresh path now preserves cloud requirements during thread
reinitialization, and config loading is moved off the deep TUI event
stack to avoid stack-overflow crashes during those reloads.

- Passes the cloud requirements loader through TUI config rebuild paths.
- Keeps cloud requirements applied for `/new`, `/clear`, `/fork`, side
conversations, and session picker transitions.
- Runs config building on a Tokio task so reloads do not occur on the
deep TUI caller stack.
- Adds regression coverage that cloud requirements survive
thread-transition config refreshes.

## Test/Repro:
  - Start Codex with a cloud requirement applied.
  - Use `/new` or `/clear`.
- The refreshed/fresh-session config should still include the cloud
requirements
  
This can be tested with any config item, at this moment for oai staff
the easiest item to test is the `mentions_v2` feature. This is currently
enabled in cloud requirements, but is not enabled by default. As a
result, prior to these changes that feature is disabled after `/new` or
`/clear`. Testing the same steps with a binary from this branch should
not drop the feature enablement.
This commit is contained in:
canvrno-oai authored and GitHub committed 2026-06-08 18:08:48 -07:00
1 parent c656cc4a83
commit 0beb5c7f32
6 files changed
+76 -2

No files matched your search

+5
View File
@@ -130,6 +130,7 @@ use codex_app_server_protocol::Turn;
use codex_app_server_protocol::TurnError as AppServerTurnError;
use codex_app_server_protocol::TurnStatus;
use codex_app_server_protocol::WriteStatus;
use codex_config::CloudConfigBundleLoader;
use codex_config::ConfigLayerStackOrdering;
use codex_config::LoaderOverrides;
use codex_config::types::ApprovalsReviewer;
@@ -490,6 +491,7 @@ pub(crate) struct App {
cli_kv_overrides: Vec<(String, TomlValue)>,
harness_overrides: ConfigOverrides,
loader_overrides: LoaderOverrides,
cloud_config_bundle: CloudConfigBundleLoader,
runtime_approval_policy_override: Option<AskForApproval>,
runtime_permission_profile_override: Option<RuntimePermissionProfileOverride>,
@@ -720,6 +722,7 @@ impl App {
cli_kv_overrides: Vec<(String, TomlValue)>,
harness_overrides: ConfigOverrides,
loader_overrides: LoaderOverrides,
cloud_config_bundle: CloudConfigBundleLoader,
initial_prompt: Option<String>,
initial_images: Vec<PathBuf>,
session_selection: SessionSelection,
@@ -754,6 +757,7 @@ impl App {
&mut config,
&cli_kv_overrides,
&harness_overrides,
&cloud_config_bundle,
entered_trust_nux,
)
.await?;
@@ -1003,6 +1007,7 @@ See the Codex keymap documentation for supported actions and examples."
cli_kv_overrides,
harness_overrides,
loader_overrides,
cloud_config_bundle,
runtime_approval_policy_override: None,
runtime_permission_profile_override: None,
file_search,