diff --git a/Cargo.lock b/Cargo.lock index cd8cdea4d6..157d53311e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2173,6 +2173,7 @@ dependencies = [ "dashmap", "derive_more", "derive_setters", + "dunce", "fake", "forge_app", "forge_domain", diff --git a/Cargo.toml b/Cargo.toml index 12e3fbc1d1..c14ccced03 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,6 +40,7 @@ derive_setters = "0.1.9" dirs = "6.0.0" dissimilar = "1.0.9" dotenvy = "0.15.7" +dunce = "1.0.5" fzf-wrapped = "0.1.4" futures = "0.3.32" gh-workflow = "0.8.1" diff --git a/crates/forge_services/Cargo.toml b/crates/forge_services/Cargo.toml index ccee3506bd..d7b93c0118 100644 --- a/crates/forge_services/Cargo.toml +++ b/crates/forge_services/Cargo.toml @@ -21,6 +21,7 @@ handlebars.workspace = true forge_fs.workspace = true dashmap.workspace = true anyhow.workspace = true +dunce.workspace = true futures.workspace = true reqwest.workspace = true derive_more.workspace = true diff --git a/crates/forge_services/src/context_engine.rs b/crates/forge_services/src/context_engine.rs index 51299ca6bf..a966bb6fa6 100644 --- a/crates/forge_services/src/context_engine.rs +++ b/crates/forge_services/src/context_engine.rs @@ -219,8 +219,7 @@ impl ForgeWorkspaceS emit(SyncProgress::Starting).await; let (token, user_id) = self.get_workspace_credentials().await?; - let path = path - .canonicalize() + let path = dunce::canonicalize(&path) .with_context(|| format!("Failed to resolve path: {}", path.display()))?; // Initialize workspace (finds existing or creates new) @@ -412,8 +411,7 @@ impl ForgeWorkspaceS where F: WorkspaceIndexRepository, { - let canonical_path = path - .canonicalize() + let canonical_path = dunce::canonicalize(&path) .with_context(|| format!("Failed to resolve path: {}", path.display()))?; // Get all workspaces from remote server @@ -604,7 +602,9 @@ impl ForgeWorkspaceS match result { Ok(content) => { let hash = compute_hash(&content); - let absolute_path_str = absolute_path.to_string_lossy().to_string(); + let absolute_path_str = dunce::simplified(&absolute_path) + .to_string_lossy() + .to_string(); yield Ok(FileNode { file_path: absolute_path_str, content, hash }); } Err(e) => { @@ -618,8 +618,7 @@ impl ForgeWorkspaceS async fn _init_workspace(&self, path: PathBuf) -> Result<(bool, WorkspaceId)> { let (token, _user_id) = self.get_workspace_credentials().await?; - let path = path - .canonicalize() + let path = dunce::canonicalize(&path) .with_context(|| format!("Failed to resolve path: {}", path.display()))?; // Find workspace by exact match or ancestor from remote server