Centralize thread environment selection state (#38423)

## What changed

- Make `ThreadEnvironments` the source of truth for live environment selections and use it when building configuration snapshots, permission profiles, per-turn configuration, and MCP refresh inputs.
- Keep settings previews side-effect free while applying accepted environment updates consistently to subsequent turns.
- Move `EnvironmentConfig` into `codex-protocol` so environment ownership no longer depends on a core-only type.

## Testing

- Cover environment previews and snapshots, accepted and rejected steer updates, and active-turn environment stability.

GitOrigin-RevId: 7bcf8fb5df1215f720e4e9c419541a51a871aa5e
This commit is contained in:
sayan-oai authored and copyberry committed 2026-08-13 19:25:05 +00:00
1 parent 588e18aae5
commit 781445f7c6
16 files changed
+428 -327

No files matched your search

+12 -1
View File
@@ -5,12 +5,23 @@ use codex_exec_server::SelectedCapabilityRootsStatus;
use codex_protocol::capabilities::CapabilityRootLocation;
use codex_protocol::error::CodexErr;
use codex_protocol::error::Result as CodexResult;
use codex_protocol::protocol::EnvironmentConfig;
use codex_protocol::protocol::TurnEnvironmentSelection;
use crate::environment_config::EnvironmentConfig;
use crate::config::ConstraintResult;
use crate::session::session::Session;
use crate::session::session::SessionConfiguration;
use crate::session::session::SessionSettingsUpdate;
impl Session {
pub(super) fn apply_session_settings(
&self,
current: &SessionConfiguration,
updates: &SessionSettingsUpdate,
) -> ConstraintResult<SessionConfiguration> {
current.apply(updates, &self.services.turn_environments.selections())
}
pub(crate) async fn environment_ready(
&self,
selection: &TurnEnvironmentSelection,