Skip to content

app-server: preserve remote environment cwd#28146

Draft
anp-oai wants to merge 17 commits into
codex/cross-platform-path-renderingfrom
codex/app-server-remote-environment-cwd
Draft

app-server: preserve remote environment cwd#28146
anp-oai wants to merge 17 commits into
codex/cross-platform-path-renderingfrom
codex/app-server-remote-environment-cwd

Conversation

@anp-oai

@anp-oai anp-oai commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

Why

App-server environment selections can target an OS different from the app-server host. Applying host-native path rules at the API boundary rejects or rewrites a Windows cwd before it reaches a Windows exec-server, so a remote turn cannot reliably preserve its selected working directory and shell.

This is stacked on #27819, which provides host-independent path rendering. It is okay for the earlier exec-server cwd fix to remain visible in this diff.

What

  • Carry exec-server and turn-environment cwd values as PathUri until the execution or sandbox boundary.
  • Accept environment-native cwd strings in app-server thread/start and turn/start, infer their absolute path convention, and convert them to PathUri before core selection validation.
  • Use the selected remote environment's shell and cwd for unified exec.
  • Extend the Wine-backed Windows environment test through typed app-server thread/turn requests and a real PowerShell command that verifies C:\windows is the execution cwd.
  • Seed a remote AGENTS.md fixture and pin the thread-start metadata fields that still use host fallback values, with separate follow-up TODOs.

Testing

  • bazel test //codex-rs/core/tests/remote_env_windows:smoke-test --test_output=errors
  • just test -p codex-app-server
  • just test -p codex-app-server-protocol
  • focused codex-core environment-selection tests

@anp-oai anp-oai force-pushed the codex/app-server-remote-environment-cwd branch from 2ea8378 to 0899d52 Compare June 14, 2026 02:08
);
}

#[test]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for human reviewers: this layer can't enforce that absolute paths are required anymore, this is moved to a thread start test

Comment thread codex-rs/app-server/tests/suite/v2/thread_start.rs
Comment thread codex-rs/app-server/README.md Outdated
Comment thread codex-rs/core/src/environment_selection.rs Outdated
Comment thread codex-rs/core/tests/remote_env_windows/remote_env_windows_test.rs
Comment thread codex-rs/core/tests/remote_env_windows/remote_env_windows_test.rs
@anp-oai anp-oai marked this pull request as ready for review June 14, 2026 03:20
@anp-oai anp-oai requested a review from a team as a code owner June 14, 2026 03:20
@anp-oai anp-oai marked this pull request as draft June 14, 2026 03:20
@anp-oai anp-oai removed the request for review from a team June 14, 2026 03:20

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 167b3b9a5a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

pub argv: Vec<String>,
pub cwd: PathBuf,
/// Working directory URI, interpreted using the exec-server host's path rules at launch time.
pub cwd: PathUri,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep cwd wire encoding backward-compatible

PathUri changes process/start.cwd from a plain path to file:///...; during mixed-version remote exec-server rollouts, older servers still parse it as PathBuf and launch in a literal/invalid file: path. Accept both encodings or version-gate the client. guidance

Useful? React with 👍 / 👎.

let cwd_uri = PathUri::from_abs_path(&cwd);
Self {
) -> std::io::Result<Self> {
let cwd = cwd_uri.to_abs_path()?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve remote cwd URIs until target-host launch

to_abs_path() parses cwd_uri using the current host's path rules, so a Linux/macOS app-server rejects a Windows UNC URI before it can reach a remote Windows exec-server. That makes the remote exec path non-portable; keep the URI until the target-host launch boundary. guidance

Useful? React with 👍 / 👎.

codex-protocol = { workspace = true }
codex-shell-command = { workspace = true }
codex-utils-absolute-path = { workspace = true }
codex-utils-path-uri = { workspace = true }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update the Bazel lockfile for the new dependency

Adding this workspace dependency without updating MODULE.bazel.lock leaves Bazel lock state behind Cargo, so Bazel builds or lock checks can fail even though Cargo resolves the new crate. Please run just bazel-lock-update and commit the lockfile update. guidance

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant