mirror of
https://github.com/openai/codex.git
synced 2026-11-18 22:20:48 +00:00
codex: address PR review feedback (#28146)
This commit is contained in:
@@ -253,9 +253,10 @@ fn resolved_local_environments<const N: usize>(
|
||||
Environment::create_for_tests(/*exec_server_url*/ None)
|
||||
.expect("local environment"),
|
||||
),
|
||||
cwd,
|
||||
PathUri::from_abs_path(&cwd),
|
||||
/*shell*/ None,
|
||||
)
|
||||
.expect("turn environment")
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
|
||||
@@ -157,14 +157,15 @@ impl ThreadEnvironments {
|
||||
let mut turn_environment = TurnEnvironment::new(
|
||||
environment_id,
|
||||
environment,
|
||||
selected_environment.cwd.to_abs_path().map_err(|err| {
|
||||
CodexErr::InvalidRequest(format!(
|
||||
"turn environment cwd `{}` is not valid on this host: {err}",
|
||||
selected_environment.cwd
|
||||
))
|
||||
})?,
|
||||
selected_environment.cwd.clone(),
|
||||
shell,
|
||||
);
|
||||
)
|
||||
.map_err(|err| {
|
||||
CodexErr::InvalidRequest(format!(
|
||||
"turn environment cwd `{}` is not valid on this host: {err}",
|
||||
selected_environment.cwd
|
||||
))
|
||||
})?;
|
||||
let task = shell_snapshot
|
||||
.clone()
|
||||
.build(turn_environment.clone())
|
||||
@@ -560,7 +561,7 @@ url = "ws://127.0.0.1:8765"
|
||||
Arc::clone(&local_manager),
|
||||
&[TurnEnvironmentSelection {
|
||||
environment_id: LOCAL_ENVIRONMENT_ID.to_string(),
|
||||
cwd: cwd_uri,
|
||||
cwd: cwd_uri.clone(),
|
||||
}],
|
||||
)
|
||||
.await;
|
||||
@@ -570,12 +571,15 @@ url = "ws://127.0.0.1:8765"
|
||||
.expect("remote environment"),
|
||||
);
|
||||
let remote = TurnEnvironmentSnapshot {
|
||||
turn_environments: vec![TurnEnvironment::new(
|
||||
REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
remote_environment.clone(),
|
||||
cwd.clone(),
|
||||
/*shell*/ None,
|
||||
)],
|
||||
turn_environments: vec![
|
||||
TurnEnvironment::new(
|
||||
REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
remote_environment.clone(),
|
||||
cwd_uri.clone(),
|
||||
/*shell*/ None,
|
||||
)
|
||||
.expect("remote turn environment"),
|
||||
],
|
||||
};
|
||||
let multiple = TurnEnvironmentSnapshot {
|
||||
turn_environments: vec![
|
||||
@@ -583,9 +587,10 @@ url = "ws://127.0.0.1:8765"
|
||||
TurnEnvironment::new(
|
||||
REMOTE_ENVIRONMENT_ID.to_string(),
|
||||
remote_environment,
|
||||
cwd.clone(),
|
||||
cwd_uri,
|
||||
/*shell*/ None,
|
||||
),
|
||||
)
|
||||
.expect("remote turn environment"),
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
@@ -5697,9 +5697,10 @@ async fn request_permissions_tool_resolves_relative_paths_against_selected_envir
|
||||
turn_context_mut.environments.turn_environments[0] = TurnEnvironment::new(
|
||||
"remote".to_string(),
|
||||
current_environment.environment,
|
||||
environment_cwd.clone(),
|
||||
codex_utils_path_uri::PathUri::from_abs_path(&environment_cwd),
|
||||
current_environment.shell,
|
||||
);
|
||||
)
|
||||
.expect("remote turn environment");
|
||||
|
||||
let call_id = "call-1".to_string();
|
||||
let handler = RequestPermissionsHandler;
|
||||
@@ -6316,15 +6317,15 @@ async fn primary_environment_uses_first_turn_environment() {
|
||||
let first_environment = turn_context.environments.turn_environments[0].clone();
|
||||
#[allow(deprecated)]
|
||||
let second_cwd = turn_context.cwd.join("second");
|
||||
turn_context
|
||||
.environments
|
||||
.turn_environments
|
||||
.push(TurnEnvironment::new(
|
||||
turn_context.environments.turn_environments.push(
|
||||
TurnEnvironment::new(
|
||||
"second".to_string(),
|
||||
Arc::clone(&first_environment.environment),
|
||||
second_cwd.clone(),
|
||||
codex_utils_path_uri::PathUri::from_abs_path(&second_cwd),
|
||||
/*shell*/ None,
|
||||
));
|
||||
)
|
||||
.expect("second turn environment"),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
turn_context
|
||||
|
||||
@@ -64,18 +64,18 @@ impl TurnEnvironment {
|
||||
pub(crate) fn new(
|
||||
environment_id: String,
|
||||
environment: Arc<Environment>,
|
||||
cwd: AbsolutePathBuf,
|
||||
cwd_uri: PathUri,
|
||||
shell: Option<shell::Shell>,
|
||||
) -> Self {
|
||||
let cwd_uri = PathUri::from_abs_path(&cwd);
|
||||
Self {
|
||||
) -> std::io::Result<Self> {
|
||||
let cwd = cwd_uri.to_abs_path()?;
|
||||
Ok(Self {
|
||||
environment_id,
|
||||
environment,
|
||||
cwd,
|
||||
cwd_uri,
|
||||
shell,
|
||||
shell_snapshot: futures::future::ready(None).boxed().shared(),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn shell_snapshot(&self, cwd: &AbsolutePathBuf) -> Option<AbsolutePathBuf> {
|
||||
|
||||
@@ -288,9 +288,10 @@ mod tests {
|
||||
turn.environments.turn_environments[0] = TurnEnvironment::new(
|
||||
current.environment_id,
|
||||
current.environment,
|
||||
cwd,
|
||||
PathUri::from_abs_path(&cwd),
|
||||
current.shell,
|
||||
);
|
||||
)
|
||||
.expect("turn environment");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -19,9 +19,10 @@ fn test_turn_environment(environment_id: &str) -> crate::session::turn_context::
|
||||
crate::session::turn_context::TurnEnvironment::new(
|
||||
environment_id.to_string(),
|
||||
std::sync::Arc::new(codex_exec_server::Environment::default_for_tests()),
|
||||
std::env::temp_dir().abs(),
|
||||
PathUri::from_abs_path(&std::env::temp_dir().abs()),
|
||||
/*shell*/ None,
|
||||
)
|
||||
.expect("turn environment")
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -597,9 +597,10 @@ async fn zsh_fork_unified_exec_keeps_shell_parameter_when_remote_environment_ava
|
||||
))
|
||||
.expect("remote test environment"),
|
||||
),
|
||||
remote_cwd,
|
||||
codex_utils_path_uri::PathUri::from_abs_path(&remote_cwd),
|
||||
/*shell*/ None,
|
||||
),
|
||||
)
|
||||
.expect("remote turn environment"),
|
||||
);
|
||||
})
|
||||
.await;
|
||||
|
||||
Reference in New Issue
Block a user