Change summary
crates/agent_ui/src/connection_view.rs | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
Detailed changes
@@ -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());