core: render remote environment cwd natively (#28152)

## Why

Model-visible `<environment_context>` should match the environment of
the executor, not of the app server.

Stacked on #28146.

## What

- Keep selected environment cwd values as `PathUri` while building
environment context.
- Render cwd text using the path convention represented by the URI, with
the canonical URI as a fallback.
- Preserve compatibility with legacy `TurnContextItem.cwd` values when
reconstructing and diffing context.
- Extend the Wine-backed remote Windows test to assert that the model
sees `powershell` and `C:\windows`.
This commit is contained in:
Adam Perry @ OpenAI
2026-06-16 16:17:47 -07:00
committed by GitHub
parent a34da3b295
commit 4c79527e31
25 changed files with 457 additions and 185 deletions
+13
View File
@@ -164,6 +164,19 @@ impl PathUri {
}
}
/// Renders this URI using the native path syntax inferred from its shape.
///
/// This is independent of the current host: a Windows URI renders with
/// Windows separators on every host. If the convention cannot be inferred
/// or the URI cannot be represented using that convention, the canonical
/// URI string is returned instead.
pub fn inferred_native_path_string(&self) -> String {
self.infer_path_convention()
.and_then(|convention| LegacyAppPathString::from_path_uri(self, convention).ok())
.map(LegacyAppPathString::into_string)
.unwrap_or_else(|| self.to_string())
}
/// Returns the decoded final URI path segment, or `None` for the URI root
/// or an opaque fallback URI created by [`Self::from_abs_path`].
///
+22
View File
@@ -100,6 +100,28 @@ fn drive_shaped_posix_uri_is_intentionally_inferred_as_windows() {
assert_eq!(path.infer_path_convention(), Some(PathConvention::Windows));
}
#[test]
fn inferred_native_path_string_uses_the_inferred_convention() {
for (uri, expected) in [
("file:///home/alice/a%20file.rs", "/home/alice/a file.rs"),
(
"file:///C:/Users/Alice%20Smith/main.rs",
r"C:\Users\Alice Smith\main.rs",
),
("file://server/share/main.rs", r"\\server\share\main.rs"),
("file://server/", "file://server/"),
("file:///%00/bad/path/YQ", "file:///%00/bad/path/YQ"),
] {
let path = PathUri::parse(uri).expect("valid path URI");
assert_eq!(
path.inferred_native_path_string(),
expected,
"rendering {uri}"
);
}
}
#[cfg(windows)]
#[test]
fn file_uri_falls_back_for_windows_prefixes_without_a_uri_representation() {