[codex] Use managed defaults for TUI threads (#30147)

## Why

#29683 exposes managed defaults for new-thread model settings through
`configRequirements/read` without applying them server-wide. The TUI is
an app-server client, so it should explicitly consume those defaults
when it creates a fresh thread.

This lets plain `codex` start on the managed model while preserving the
existing ability to change model settings within the thread.

## What changed

- Read `requirements.models.newThread` during TUI app-server bootstrap.
- Apply the managed model, reasoning effort, and service tier to the
initial fresh thread and subsequent `/new` or `/clear` threads.
- Keep explicit launch overrides above the managed defaults.
- Normalize the managed `fast` service tier to the `priority` request
value.
- Leave resumed and forked threads unchanged.

The application logic lives in a small TUI-only module; app-server
`thread/start` behavior remains unchanged for other clients.

## User experience

- Plain `codex` starts with the managed new-thread settings.
- A user can still change settings with `/model` or the existing
service-tier controls.
- Starting another fresh thread reapplies the managed defaults.
- Explicit launch choices such as `codex -m <model>` continue to win.

## Validation

- `just test -p codex-tui managed_new_thread_defaults`
- `just fix -p codex-tui`

Depends on #29683.
This commit is contained in:
hefuc-oai authored and GitHub committed 2026-06-26 19:27:31 +00:00
1 parent 79a8ffdbf7
commit cf36c688b3
6 files changed
+205 -2

No files matched your search

+13 -1
View File
@@ -51,6 +51,7 @@ use crate::legacy_core::config::ConfigBuilder;
use crate::legacy_core::config::ConfigOverrides;
use crate::legacy_core::config::PermissionProfileSnapshot;
use crate::legacy_core::config::edit::ConfigEditsBuilder;
use crate::managed_new_thread_defaults::apply_managed_new_thread_defaults;
use crate::model_catalog::ModelCatalog;
use crate::model_migration::ModelMigrationOutcome;
use crate::model_migration::migration_copy_for_models;
@@ -794,7 +795,18 @@ impl App {
None => app_server.bootstrap(&config).await?,
};
let bootstrap_ms = bootstrap.duration.as_millis();
let mut model = bootstrap.default_model;
if matches!(
&session_selection,
SessionSelection::StartFresh | SessionSelection::Exit
) {
apply_managed_new_thread_defaults(
&mut config,
app_server.managed_new_thread_defaults(),
&cli_kv_overrides,
&harness_overrides,
);
}
let mut model = config.model.clone().unwrap_or(bootstrap.default_model);
let available_models = bootstrap.available_models;
let remote_connection = crate::status::remote_connection::remote_connection_status_value(
&app_server_target,