-
Notifications
You must be signed in to change notification settings - Fork 185
fix: normalize Windows drive letter casing in extractCwd #126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,6 +13,17 @@ import type { FileSystemProvider } from '../services/infrastructure/FileSystemPr | |||||
|
|
||||||
| const logger = createLogger('Util:metadataExtraction'); | ||||||
|
|
||||||
| /** | ||||||
| * Normalize Windows drive letter to uppercase for consistent path comparison. | ||||||
| * CLI uses uppercase (C:\...) while VS Code extension uses lowercase (c:\...). | ||||||
| */ | ||||||
| function normalizeDriveLetter(p: string): string { | ||||||
| if (p.length >= 2 && p[1] === ':') { | ||||||
|
||||||
| if (p.length >= 2 && p[1] === ':') { | |
| if (process.platform === 'win32' && p.length >= 2 && /^[A-Za-z]:/.test(p)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add migration for persisted project IDs after cwd normalization
For Windows users upgrading from a build that already indexed the same repo as separate c:\.../C:\... subprojects, returning a normalized cwd here changes the derived projectId on the next scan (often from composite IDs back to the plain encoded dir, or at least to a different hash). That breaks any state keyed by the old ID: pinned/hidden sessions are stored under the exact projectId in src/main/services/infrastructure/ConfigManager.ts:749-858, and restored selection/tabs are dropped when contextSlice no longer finds the saved ID in src/renderer/store/slices/contextSlice.ts:82-101. Without an alias/migration, affected users silently lose pins/hidden state and reopened tabs after upgrading.
Useful? React with 👍 / 👎.
Copilot
AI
Mar 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change alters extractCwd() behavior on Windows-style paths by normalizing the drive letter casing, but there is no test asserting that sessions with 'c:\...' and 'C:\...' are grouped together (and not split) during discovery. Adding a focused unit test (e.g., in ProjectScanner.cwdSplit.test.ts and/or ProjectPathResolver.test.ts) would prevent regressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic correctly normalizes Windows drive letters, but it will also run on other platforms like macOS and Linux. This could lead to unintended behavior if a path on a non-Windows system happens to match the pattern (e.g.,
c:foo/bar). Since this normalization is specific to Windows pathing conventions, it's safer to guard this logic to only execute on Windows by checkingprocess.platform === 'win32'. Theprocessobject is globally available in Node.js, so no import is needed.