Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

acp: Fix session loading paths for wsl (#50307)

Ben Brandt324b1d5263b1
diff --git a/crates/agent_ui/src/connection_view.rs b/crates/agent_ui/src/connection_view.rs
index f5efa8aa283..9b3c3cd4270 100644
--- a/crates/agent_ui/src/connection_view.rs
+++ b/crates/agent_ui/src/connection_view.rs
@@ -570,13 +570,21 @@ impl ConnectionView {
resume
.cwd
.as_ref()
- .and_then(|cwd| util::paths::normalize_lexically(cwd).ok())
.filter(|cwd| {
- worktree_roots
- .iter()
- .any(|root| cwd.starts_with(root.as_ref()))
+ // Validate with the normalized path (rejects `..` traversals),
+ // but return the original cwd to preserve its path separators.
+ // On Windows, `normalize_lexically` rebuilds the path with
+ // backslashes via `PathBuf::push`, which would corrupt
+ // forward-slash Linux paths used by WSL agents.
+ util::paths::normalize_lexically(cwd)
+ .ok()
+ .is_some_and(|normalized| {
+ worktree_roots
+ .iter()
+ .any(|root| normalized.starts_with(root.as_ref()))
+ })
})
- .map(|path| path.into())
+ .map(|path| Arc::from(path.as_path()))
})
.or_else(|| worktree_roots.first().cloned())
.unwrap_or_else(|| paths::home_dir().as_path().into());