[codex] exec-server honors remote environment cwd and shell (#28122)

## Why

Next slice needed to make progress on the `remote_env_windows` test is
to support passing a Windows cwd for the remote environment and using
that environment's native shell. This lets the test run a real Windows
process instead of only recording an early path or shell mismatch.

## What

- change `TurnEnvironmentSelection.cwd` from `AbsolutePathBuf` to
`PathUri`
- convert local cwd values to URIs when constructing selections
- preserve a remote primary cwd instead of replacing it with the local
legacy fallback
- prefer the selected environment's discovered shell for unified exec,
falling back to the session shell when unavailable
- convert back to a host-native absolute path at current native-only
consumer boundaries
- reject or deny unsupported foreign cwd values at the existing
request-permissions boundary, with TODOs for its future migration
- extend the hermetic Wine test to execute Windows PowerShell in
`C:\windows` and verify successful process completion
- record the current app-server rejection against the same Wine-backed
remote Windows fixture when its cwd is supplied as a native Windows path
This commit is contained in:
Adam Perry @ OpenAI
2026-06-13 23:07:46 -07:00
committed by GitHub
Unverified
parent 5e9249ec02
commit efbd00f21f
22 changed files with 300 additions and 96 deletions
+10 -3
View File
@@ -52,6 +52,7 @@ use crate::request_permissions::RequestPermissionsResponse;
use crate::request_user_input::RequestUserInputResponse;
use crate::user_input::UserInput;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_path_uri::PathUri;
use schemars::JsonSchema;
use serde::Deserialize;
use serde::Serialize;
@@ -105,11 +106,14 @@ pub const COLLABORATION_MODE_CLOSE_TAG: &str = "</collaboration_mode>";
pub const REALTIME_CONVERSATION_OPEN_TAG: &str = "<realtime_conversation>";
pub const REALTIME_CONVERSATION_CLOSE_TAG: &str = "</realtime_conversation>";
pub const USER_MESSAGE_BEGIN: &str = "## My request for Codex:";
const LOCAL_ENVIRONMENT_ID: &str = "local";
// TODO(anp): Replace `TurnEnvironmentSelection` with `PathUri` once path URIs carry environment
// identifiers.
#[derive(Debug, Clone, PartialEq)]
pub struct TurnEnvironmentSelection {
pub environment_id: String,
pub cwd: AbsolutePathBuf,
pub cwd: PathUri,
}
#[derive(Debug, Clone, PartialEq)]
@@ -132,10 +136,13 @@ impl TurnEnvironmentSelections {
}
fn sync_primary_environment_cwd(&mut self) {
let legacy_fallback_cwd = PathUri::from_abs_path(&self.legacy_fallback_cwd);
// Keep remote environments' native cwd instead of replacing it with the local fallback.
if let Some(turn_environment) = self.environments.first_mut()
&& turn_environment.cwd != self.legacy_fallback_cwd
&& turn_environment.environment_id == LOCAL_ENVIRONMENT_ID
&& turn_environment.cwd != legacy_fallback_cwd
{
turn_environment.cwd = self.legacy_fallback_cwd.clone();
turn_environment.cwd = legacy_fallback_cwd;
}
}
}