Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(config-sync): strip the Windows extended-length prefix before mapping (#1693)

chengzhi-ce2b808321eea
diff --git a/crates/host-core/src/activation.rs b/crates/host-core/src/activation.rs
index 4877ef908..635573092 100644
--- a/crates/host-core/src/activation.rs
+++ b/crates/host-core/src/activation.rs
@@ -77,23 +77,11 @@ impl ActivationScope {
}
/// Storage spelling of a project path: forward slashes, no trailing separator.
-/// Mirrors `normalize_project_path` in `db.rs` so scope entries compare equal to
-/// the `projects` table.
+/// Delegates to `db::normalize_project_path` so scope entries compare equal to
+/// the `projects` table, including paths carrying the Windows extended-length
+/// prefix.
pub fn normalize_project_path(path: &str) -> String {
- let trimmed = path.trim();
- if trimmed.is_empty() {
- return String::new();
- }
- let mut normalized = trimmed.replace('\\', "/");
- while normalized.len() > 1
- && normalized.ends_with('/')
- && !normalized
- .strip_suffix('/')
- .is_some_and(|prefix| prefix.ends_with(':'))
- {
- normalized.pop();
- }
- normalized
+ crate::db::normalize_project_path(path).unwrap_or_default()
}
/// Case-insensitive path comparison: macOS and Windows both hand us
@@ -181,4 +169,12 @@ mod tests {
assert_eq!(normalize_project_path("C:\\"), "C:/");
assert_eq!(normalize_project_path("C:\\work\\app\\"), "C:/work/app");
}
+
+ #[test]
+ fn windows_extended_length_scope_matches_plain_drive_path() {
+ let scope = projects(&[r"\\?\E:\work\app"]);
+
+ assert_eq!(normalize_project_path(r"\\?\E:\work\app"), "E:/work/app");
+ assert!(scope.matches(Some("E:/work/app/child")));
+ }
}
diff --git a/crates/host-core/src/agent_capabilities.rs b/crates/host-core/src/agent_capabilities.rs
index bc761fc48..e2ae41d58 100644
--- a/crates/host-core/src/agent_capabilities.rs
+++ b/crates/host-core/src/agent_capabilities.rs
@@ -290,21 +290,12 @@ pub fn capability_dir(
}
}
+/// Storage spelling of a project path: forward slashes, no trailing separator.
+/// Delegates to `db::normalize_project_path` so capability records key on the
+/// same spelling the `projects` table stores — including the Windows
+/// extended-length prefix `canonicalize` answers with.
pub fn normalize_project_path(path: &str) -> String {
- let trimmed = path.trim();
- if trimmed.is_empty() {
- return String::new();
- }
- let mut normalized = trimmed.replace('\\', "/");
- while normalized.len() > 1
- && normalized.ends_with('/')
- && !normalized
- .strip_suffix('/')
- .is_some_and(|prefix| prefix.ends_with(':'))
- {
- normalized.pop();
- }
- normalized
+ crate::db::normalize_project_path(path).unwrap_or_default()
}
fn same_path(a: &str, b: &str) -> bool {
diff --git a/crates/host-core/src/agent_capabilities/tests.rs b/crates/host-core/src/agent_capabilities/tests.rs
index 96bc0749b..6e638a438 100644
--- a/crates/host-core/src/agent_capabilities/tests.rs
+++ b/crates/host-core/src/agent_capabilities/tests.rs
@@ -79,6 +79,28 @@ fn state_defaults_on_and_is_project_specific() {
assert!(orphaned.enabled("skills", CapabilityLevel::Global, "review", Some("/a")));
}
+#[test]
+fn project_capability_state_matches_extended_length_drive_paths() {
+ let dir = tempdir().unwrap();
+ let mut state = CapabilityState::new(dir.path(), "skills");
+ state
+ .set_enabled(
+ "skills",
+ CapabilityLevel::Global,
+ "review",
+ Some("E:/work/app"),
+ false,
+ )
+ .unwrap();
+
+ assert!(!state.enabled(
+ "skills",
+ CapabilityLevel::Global,
+ "review",
+ Some(r"\\?\E:\work\app"),
+ ));
+}
+
#[test]
fn suffix_keeps_the_preferred_id_when_it_is_free() {
let taken = HashSet::new();