mirror of
https://github.com/openai/codex.git
synced 2026-10-22 06:02:59 +00:00
core: require roots when constructing turn environments
This commit is contained in:
@@ -303,6 +303,7 @@ fn resolved_local_environments<const N: usize>(
|
||||
.expect("local environment"),
|
||||
),
|
||||
PathUri::from_abs_path(&cwd),
|
||||
Vec::new(),
|
||||
/*shell*/ None,
|
||||
)
|
||||
})
|
||||
|
||||
@@ -177,9 +177,13 @@ impl ThreadEnvironments {
|
||||
} else {
|
||||
Some(local_shell)
|
||||
};
|
||||
let mut turn_environment =
|
||||
TurnEnvironment::new(selection.environment_id, environment, selection.cwd, shell)
|
||||
.with_workspace_roots(selection.workspace_roots);
|
||||
let mut turn_environment = TurnEnvironment::new(
|
||||
selection.environment_id,
|
||||
environment,
|
||||
selection.cwd,
|
||||
selection.workspace_roots,
|
||||
shell,
|
||||
);
|
||||
let task = shell_snapshot
|
||||
.build(turn_environment.clone())
|
||||
.boxed()
|
||||
@@ -840,6 +844,7 @@ url = "ws://127.0.0.1:8765"
|
||||
selection.environment_id.clone(),
|
||||
Arc::clone(&inherited_environment),
|
||||
selection.cwd.clone(),
|
||||
Vec::new(),
|
||||
/*shell*/ None,
|
||||
);
|
||||
let manager = Arc::new(EnvironmentManager::without_environments());
|
||||
@@ -897,6 +902,7 @@ url = "ws://127.0.0.1:8765"
|
||||
REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
remote_environment.clone(),
|
||||
cwd_uri.clone(),
|
||||
Vec::new(),
|
||||
/*shell*/ None,
|
||||
)],
|
||||
starting: Vec::new(),
|
||||
@@ -908,6 +914,7 @@ url = "ws://127.0.0.1:8765"
|
||||
REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
remote_environment,
|
||||
cwd_uri,
|
||||
Vec::new(),
|
||||
/*shell*/ None,
|
||||
),
|
||||
],
|
||||
|
||||
@@ -229,6 +229,7 @@ mod tests {
|
||||
primary.environment_id.clone(),
|
||||
Arc::clone(&primary.environment),
|
||||
PathUri::from_abs_path(&cwd),
|
||||
Vec::new(),
|
||||
primary.shell.clone(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1169,6 +1169,7 @@ async fn mcp_sandbox_cwd_uses_matching_server_environment_uri() -> anyhow::Resul
|
||||
"remote".to_string(),
|
||||
environment,
|
||||
secondary_cwd.clone(),
|
||||
Vec::new(),
|
||||
/*shell*/ None,
|
||||
));
|
||||
|
||||
|
||||
@@ -6065,6 +6065,7 @@ async fn request_permissions_tool_resolves_relative_paths_against_selected_envir
|
||||
"remote".to_string(),
|
||||
current_environment.environment,
|
||||
PathUri::from_abs_path(&environment_cwd),
|
||||
Vec::new(),
|
||||
current_environment.shell,
|
||||
);
|
||||
|
||||
@@ -6697,6 +6698,7 @@ async fn primary_environment_uses_first_turn_environment() {
|
||||
"second".to_string(),
|
||||
Arc::clone(&first_environment.environment),
|
||||
second_cwd_uri.clone(),
|
||||
Vec::new(),
|
||||
/*shell*/ None,
|
||||
));
|
||||
|
||||
@@ -7919,6 +7921,7 @@ async fn record_context_updates_emits_environment_item_for_cwd_changes() {
|
||||
environment.environment_id,
|
||||
environment.environment,
|
||||
PathUri::from_abs_path(&cwd),
|
||||
Vec::new(),
|
||||
environment.shell,
|
||||
);
|
||||
|
||||
@@ -7978,6 +7981,7 @@ async fn record_context_updates_omits_environment_item_when_disabled() {
|
||||
environment.environment_id,
|
||||
environment.environment,
|
||||
PathUri::from_abs_path(&test_path_buf("/new-repo").abs()),
|
||||
Vec::new(),
|
||||
environment.shell,
|
||||
);
|
||||
|
||||
@@ -8706,6 +8710,7 @@ async fn turn_context_item_stores_local_cwd() {
|
||||
"remote".to_string(),
|
||||
environment.environment,
|
||||
cwd,
|
||||
Vec::new(),
|
||||
environment.shell,
|
||||
);
|
||||
|
||||
|
||||
@@ -55,13 +55,14 @@ impl TurnEnvironment {
|
||||
environment_id: String,
|
||||
environment: Arc<Environment>,
|
||||
cwd: PathUri,
|
||||
workspace_roots: Vec<PathUri>,
|
||||
shell: Option<shell::Shell>,
|
||||
) -> Self {
|
||||
Self {
|
||||
environment_id,
|
||||
environment,
|
||||
cwd,
|
||||
workspace_roots: Vec::new(),
|
||||
workspace_roots,
|
||||
shell,
|
||||
shell_snapshot: futures::future::ready(None).boxed().shared(),
|
||||
}
|
||||
@@ -85,11 +86,6 @@ impl TurnEnvironment {
|
||||
&self.workspace_roots
|
||||
}
|
||||
|
||||
pub(crate) fn with_workspace_roots(mut self, workspace_roots: Vec<PathUri>) -> Self {
|
||||
self.workspace_roots = workspace_roots;
|
||||
self
|
||||
}
|
||||
|
||||
pub(crate) fn selection(&self) -> TurnEnvironmentSelection {
|
||||
TurnEnvironmentSelection {
|
||||
environment_id: self.environment_id.clone(),
|
||||
|
||||
@@ -109,6 +109,7 @@ async fn shell_command_handler_to_exec_params_uses_selected_environment() {
|
||||
.environment,
|
||||
),
|
||||
PathUri::from_abs_path(&selected_cwd),
|
||||
Vec::new(),
|
||||
Some(selected_shell),
|
||||
);
|
||||
let mut expected_env = create_env(
|
||||
|
||||
@@ -270,6 +270,7 @@ mod tests {
|
||||
current.environment_id,
|
||||
current.environment,
|
||||
PathUri::from_abs_path(&cwd),
|
||||
Vec::new(),
|
||||
current.shell,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ fn test_turn_environment(environment_id: &str) -> crate::session::turn_context::
|
||||
environment_id.to_string(),
|
||||
std::sync::Arc::new(codex_exec_server::Environment::default_for_tests()),
|
||||
PathUri::from_abs_path(&std::env::temp_dir().abs()),
|
||||
Vec::new(),
|
||||
/*shell*/ None,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ async fn approval_key_includes_environment_id() {
|
||||
"remote".to_string(),
|
||||
Arc::new(Environment::default_for_tests()),
|
||||
PathUri::from_abs_path(&cwd),
|
||||
Vec::new(),
|
||||
/*shell*/ None,
|
||||
),
|
||||
shell_type: None,
|
||||
|
||||
@@ -508,6 +508,7 @@ mod tests {
|
||||
LOCAL_ENVIRONMENT_ID.to_string(),
|
||||
Arc::new(Environment::default_for_tests()),
|
||||
cwd,
|
||||
Vec::new(),
|
||||
/*shell*/ None,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -592,6 +592,7 @@ async fn zsh_fork_unified_exec_keeps_shell_parameter_when_remote_environment_ava
|
||||
.expect("remote test environment"),
|
||||
),
|
||||
remote_cwd,
|
||||
Vec::new(),
|
||||
/*shell*/ None,
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user