Centralize turn environment selection state (#38461)

## What changed

- Store `TurnEnvironmentSelection` directly on each resolved `TurnEnvironment`
  instead of copying its environment ID, working directory, and workspace roots
  into separate fields.
- Update environment resolution, tool execution, approvals, and related tests to
  access selection state through the retained value.

GitOrigin-RevId: ab723d21e112b8af5bcaf1f772a5e376553312bc
This commit is contained in:
sayan-oai authored and copyberry committed 2026-08-14 00:22:54 +00:00
1 parent 18bbb585e7
commit 535795f7d1
31 files changed
+159 -146

No files matched your search

+4 -12
View File
@@ -15,7 +15,6 @@ use crate::guardian::review::guardian_review_session_config;
use crate::guardian::review::routes_approval_to_guardian_with_reviewer;
use crate::session::session::Session;
use crate::session::turn_context::TurnContext;
use crate::session::turn_context::TurnEnvironment;
use crate::test_support;
use codex_analytics::GuardianApprovalRequestSource;
use codex_config::ConfigLayerStack;
@@ -631,17 +630,10 @@ async fn build_guardian_prompt_includes_parent_turn_denied_reads() -> anyhow::Re
};
environment.config.permission_profile =
PermissionProfileSnapshot::legacy(environment_permission_profile);
*environment = TurnEnvironment::new(
environment.environment_id.clone(),
Arc::clone(&environment.environment),
environment.cwd().clone(),
vec![
PathUri::from_abs_path(&workspace_root),
PathUri::from_abs_path(&second_workspace_root),
],
environment.shell.clone(),
environment.config.clone(),
);
environment.selection.workspace_roots = vec![
PathUri::from_abs_path(&workspace_root),
PathUri::from_abs_path(&second_workspace_root),
];
let session = Arc::new(session);
let turn = Arc::new(turn);
seed_guardian_parent_history(&session, &turn).await;