fix: normalize Windows drive letter casing in extractCwd#126
Conversation
CLI uses uppercase (C:\...) while VS Code extension uses lowercase (c:\...), causing sessions from the same project to be split into different groups. Fixes #123 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an inconsistency in how Windows drive letters are handled, specifically between the CLI and VS Code extension, which previously caused project sessions to be miscategorized. By introducing a path normalization utility that forces drive letters to uppercase, the change ensures that current working directories are consistently represented, thereby correctly grouping related sessions. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a function to normalize Windows drive letter casing, addressing an issue where different casings caused session splitting. The implementation is straightforward, but the normalization logic should be specific to the Windows platform to prevent unintended side effects on other operating systems. I've provided a suggestion to add a platform check to the normalization function.
| * CLI uses uppercase (C:\...) while VS Code extension uses lowercase (c:\...). | ||
| */ | ||
| function normalizeDriveLetter(p: string): string { | ||
| if (p.length >= 2 && p[1] === ':') { |
There was a problem hiding this comment.
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 checking process.platform === 'win32'. The process object is globally available in Node.js, so no import is needed.
| if (p.length >= 2 && p[1] === ':') { | |
| if (process.platform === 'win32' && p.length >= 2 && p[1] === ':') { |
Windows may hold file handles briefly after stream close, causing ENOTEMPTY on rmSync. Adding maxRetries with retryDelay resolves this. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses Windows-specific session grouping issues by normalizing drive-letter casing when extracting cwd from session JSONL files, ensuring sessions from the same project don’t split into separate groups due to C:\... vs c:\....
Changes:
- Add a helper to normalize Windows drive letters to uppercase.
- Apply drive-letter normalization to the
cwdreturned byextractCwd().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * CLI uses uppercase (C:\...) while VS Code extension uses lowercase (c:\...). | ||
| */ | ||
| function normalizeDriveLetter(p: string): string { | ||
| if (p.length >= 2 && p[1] === ':') { |
There was a problem hiding this comment.
normalizeDriveLetter() currently uppercases the first character of any string whose second character is ':'. This will also match non-Windows strings like 'a:b' (valid relative path on POSIX) and could mutate a real cwd on case-sensitive filesystems. Consider tightening the check to only treat Windows drive prefixes (e.g., /^[A-Za-z]:/ and optionally requiring a following path separator).
| if (p.length >= 2 && p[1] === ':') { | |
| if (process.platform === 'win32' && p.length >= 2 && /^[A-Za-z]:/.test(p)) { |
| if ('cwd' in entry && entry.cwd) { | ||
| rl.close(); | ||
| fileStream.destroy(); | ||
| return entry.cwd; | ||
| return normalizeDriveLetter(entry.cwd); | ||
| } |
There was a problem hiding this comment.
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughNormalize Windows drive-letter casing by uppercasing the drive letter in extracted cwd values; tests updated to retry rm on cleanup. Changes
Possibly related issues
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7f5fbdab09
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| rl.close(); | ||
| fileStream.destroy(); | ||
| return entry.cwd; | ||
| return normalizeDriveLetter(entry.cwd); |
There was a problem hiding this comment.
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 👍 / 👎.
CLI uses uppercase (C:...) while VS Code extension uses lowercase (c:...), causing sessions from the same project to be split into different groups.
Fixes #123
Summary by CodeRabbit