From d712bccb91b7eabc5d2fdf542e890f9baf119e93 Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Mon, 2 Feb 2026 17:04:36 -0800 Subject: [PATCH] fix: all paths should be nix --- src-tauri/src/commands.rs | 18 +++++++++++++++--- src-tauri/src/wsl_bridge.rs | 13 +++++++++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index f71b265..3ef1055 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -162,10 +162,17 @@ pub async fn validate_directory( )); } - // Return the canonicalized (absolute) path + // Return the canonicalized (absolute) path with forward slashes expanded_path .canonicalize() - .map(|p| p.to_string_lossy().to_string()) + .map(|p| { + // Convert to string and normalize path separators to forward slashes + let path_str = p.to_string_lossy().to_string(); + // On Windows, replace backslashes with forward slashes + #[cfg(target_os = "windows")] + let path_str = path_str.replace('\\', "/"); + path_str + }) .map_err(|e| format!("Failed to resolve path: {}", e)) } @@ -437,9 +444,14 @@ pub async fn list_directory(path: String) -> Result, String> { continue; } + let path_str = path.to_string_lossy().to_string(); + // On Windows, replace backslashes with forward slashes + #[cfg(target_os = "windows")] + let path_str = path_str.replace('\\', "/"); + file_entries.push(FileEntry { name, - path: path.to_string_lossy().to_string(), + path: path_str, is_directory: path.is_dir(), }); } diff --git a/src-tauri/src/wsl_bridge.rs b/src-tauri/src/wsl_bridge.rs index 75292f2..d1062ab 100644 --- a/src-tauri/src/wsl_bridge.rs +++ b/src-tauri/src/wsl_bridge.rs @@ -136,7 +136,12 @@ impl WslBridge { }); let working_dir = &options.working_dir; - self.working_directory = working_dir.clone(); + // Normalize path separators to forward slashes + #[cfg(target_os = "windows")] + let normalized_dir = working_dir.replace('\\', "/"); + #[cfg(not(target_os = "windows"))] + let normalized_dir = working_dir.clone(); + self.working_directory = normalized_dir; emit_connection_status( &app, @@ -183,7 +188,7 @@ impl WslBridge { })?; eprintln!("[DEBUG] Found claude at: {}", claude_path); - eprintln!("[DEBUG] Working dir: {}", working_dir); + eprintln!("[DEBUG] Working dir: {}", &self.working_directory); let mut cmd = Command::new(&claude_path); cmd.args([ @@ -225,7 +230,7 @@ impl WslBridge { } } - cmd.current_dir(working_dir); + cmd.current_dir(&self.working_directory); // Set API key as environment variable if specified if let Some(ref api_key) = options.api_key { @@ -241,7 +246,7 @@ impl WslBridge { let mut cmd = Command::new("wsl"); // Build the claude command with all arguments - let mut claude_cmd = format!("cd '{}' && ", working_dir); + let mut claude_cmd = format!("cd '{}' && ", &self.working_directory); // Set API key as environment variable if specified if let Some(ref api_key) = options.api_key {