fix: normalize Windows paths to lowercase for case-insensitive session matching#1768
Conversation
📋 Review SummaryThis PR addresses issue #1760 by normalizing Windows paths to lowercase before hashing, ensuring that paths like 🔍 General Feedback
🎯 Specific Feedback🟢 Medium
🔵 Low
✅ Highlights
|
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
…n matching Fixes #1760 Windows file system is case-insensitive (e:\work equals E:\work), but string hashing is case-sensitive, causing different session directories for the same physical path. Solution: normalize paths to lowercase on Windows before hashing to ensure consistent session directory across different case variations.
Ensures consistent Windows path normalization across all path hashing. Previously Storage used its own getFilePathHash() which didn't apply Windows lowercase normalization, causing test failures on Windows CI.
48e33ed to
37c3a38
Compare
|
Thanks a lot! Beyond that it just came to my mind that macOS by default also uses a case insensitive file system. I don't have a Mac, but please consider if there could also be situations where Qwen Code checks paths in different cases so the fix would also be needed on macOS. |
|
@tillrathmann Hi, |
TLDR
Fixes #1760 by normalizing Windows paths to lowercase before hashing, ensuring that paths like
e:\workandE:\workmap to the same session directory.Dive Deeper
Root Cause Analysis
Different operating systems handle file path case sensitivity differently:
macOS/Linux (Case-Sensitive File Systems):
/home/user/project≠/HOME/USER/PROJECT(different paths)process.cwd()returns the exact path as enteredWindows (Case-Insensitive File System):
C:\Work=c:\work=C:\WORK(same physical location)process.cwd()returns the path with the case as it was originally created or as entered in the command linecd e:\workvscd E:\Work)The Problem
The
getProjectHash()function generates SHA256 hashes directly from path strings:Since string hashing is always case-sensitive, Windows users experienced:
e:\work→ hash A → session directory AE:\work→ hash B → session directory BThe Solution
Normalize paths to lowercase on Windows before hashing:
This ensures:
Files Modified
packages/core/src/utils/paths.ts- CoregetProjectHash()implementationpackages/vscode-ide-companion/src/services/qwenSessionManager.ts- VSCode session managerpackages/vscode-ide-companion/src/services/qwenSessionReader.ts- VSCode session readerpackages/core/src/utils/paths.test.ts- Added 5 comprehensive test casesReviewer Test Plan
Automated Tests
npm test --workspace=packages/core -- paths.test.tsAll 105 tests pass, including 5 new tests specifically for this fix:
Manual Testing (Windows Only)
Test case-insensitive session matching:
Test mixed case scenarios:
Expected Behavior
Testing Matrix
Note: Tested on macOS. All core tests pass (3631 tests). Windows-specific behavior verified through unit tests with platform mocking.
Linked issues / bugs
Fixes #1760