Apply permission profile updates to future turn environments (#37031)

## What changed

- Include the current permission profile in each turn environment's configuration.
- Refresh retained environment configurations when session settings change, while preserving the configuration already captured by active turns.
- Keep environment connection and shell snapshot resolution reusable across configuration updates.

## Testing

- Cover permission profile updates applied through both session settings updates and per-turn updates.
- Verify that pending environment resolutions use the configuration captured by their turn and that configuration-only updates do not retry failed environments.

GitOrigin-RevId: 923694f0729b87a118d7635ade3a8ca9bcd4e7b1
This commit is contained in:
sayan-oai authored and copyberry committed 2026-08-05 05:30:51 +00:00
1 parent 56b82e676c
commit 30d99232f4
15 files changed
+339 -116

No files matched your search

+6 -8
View File
@@ -217,7 +217,6 @@ mod tests {
use super::*;
use crate::environment_selection::TurnEnvironmentState;
use crate::session::tests::make_session_and_context;
use crate::session::turn_context::EnvironmentConfig;
use crate::session::turn_context::TurnContext;
use crate::session::turn_context::TurnEnvironment;
use codex_utils_absolute_path::AbsolutePathBuf;
@@ -316,22 +315,21 @@ mod tests {
.await
.expect("write local file");
set_primary_environment_cwd(&mut turn_context, dir.path());
let selection = turn_context
let environment = turn_context
.environments
.primary()
.expect("ready primary environment")
.selection();
.expect("ready primary environment");
let selection = environment.selection();
let environment_config = environment.config.clone();
let environments = crate::environment_selection::ThreadEnvironments::new(
session.services.turn_environments.environment_manager(),
crate::shell::default_user_shell(),
EnvironmentConfig {
allow_login_shell: turn_context.config.permissions.allow_login_shell,
},
environment_config.clone(),
crate::shell_snapshot::ShellSnapshot::disabled(),
Default::default(),
/*non_blocking_snapshots*/ true,
);
environments.update_selections(std::slice::from_ref(&selection));
environments.update_selections(std::slice::from_ref(&selection), &environment_config);
turn_context.environments = environments.snapshot().await;
turn_context
.environments