From 324b1d5263b128ff302351f0f8386d6e61e0ffd8 Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Sat, 28 Feb 2026 00:11:06 +0100 Subject: [PATCH] acp: Fix session loading paths for wsl (#50307) Release Notes: - N/A --- crates/agent_ui/src/connection_view.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/agent_ui/src/connection_view.rs b/crates/agent_ui/src/connection_view.rs index f5efa8aa2834829630bd60dd3ef012a92a33cb17..9b3c3cd4270722ca309de3f18c0a61894029c3df 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());