Skip to main content

normalize_cwd_key

Function normalize_cwd_key 

Source
pub fn normalize_cwd_key(path: &Path) -> String
Expand description

v0.13.6: case-insensitive cwd-registry key on Windows.

Issue #30 (Willard repro): on Windows, two terminals in the “same” project under different drive/path casing (C:\Foo\Bar vs C:\foo\bar) hashed to DIFFERENT registry keys — the second terminal’s wire whoami missed the registry lookup, derived a phantom name, and silently fell back to the legacy default identity (e.g. did:wire:willard). Both terminals collapsed onto one shared DID, every pairing attempt between them was a self-pair, and bilateral handshake could never complete.

Fix: on Windows, lowercase the cwd before reading from OR writing to the cwd→session map. Two paths that resolve to the same on-disk directory now produce the same registry key regardless of how the shell / launcher capitalized them.

On case-sensitive filesystems (Linux / macOS HFS+ / case-sensitive APFS / NTFS in case-sensitive mode) the path is returned as-is — distinct casings legitimately point at distinct directories.

Used at every read and write of SessionRegistry.by_cwd so old non-canonical entries written by v0.13.5 still resolve under v0.13.6+ later, and new entries written under v0.13.6+ are immediately canonical.