fix(shared): normalize a bare Windows drive root the same as C:\ / C:/ - #6189
Conversation
`isRootPath` treated the drive separator as optional (`^[a-zA-Z]:[/\\]?$`), so a bare `C:` was considered already-canonical and `trimTrailingPathSeparators` returned it unchanged as `C:`, while `C:\` and `C:/` normalize to the drive root. The canonical project-path-identity helpers `normalizeProjectPathForComparison` / `normalizeProjectPathForDispatch` (used for project matching and preference-key dedup across server, client-runtime, and web) therefore treated `C:` and `C:\` as different locations, so a project rooted at a bare drive silently failed identity/dedup checks against the same drive as `C:\`. Require the separator (`^[a-zA-Z]:[/\\]$`). A bare `C:` now falls through to the existing canonicalizer, which appends the separator, so `C:`, `C:\` and `C:/` all normalize to the same drive root. Bare `C:` is also not the drive root in Windows semantics (it means "current directory on C:"), so this is more correct. Non-root paths and the `/` and `\` roots are unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
ApprovabilityVerdict: Approved 487219f Straightforward bug fix that corrects Windows drive root path normalization. The regex change ensures You can customize Macroscope's approvability policy. Learn more. |
## What's Changed * feat(web): make environment artwork theme aware by @juliusmarminge in pingdotgg/t3code#6183 * fix(shared): normalize a bare Windows drive root the same as C:\ / C:/ by @arhxam in pingdotgg/t3code#6189 * fix(shared): detect Azure DevOps SSH remotes (ssh.dev.azure.com) by @arhxam in pingdotgg/t3code#6187 * feat(web): add back buttons for the pull requests and usage pages in the sidebar footer by @UtkarshUsername in pingdotgg/t3code#6031 * fix(web): render dropdowns above toasts by @Brechard in pingdotgg/t3code#6165 * fix(web): thread error banner dismiss survives reconnect and rerenders by @myacoub91 in pingdotgg/t3code#6123 * fix(web): use a clearer pull action icon by @extoci in pingdotgg/t3code#6194 * feat(web): use OKLCH for theme palettes by @StiensWout in pingdotgg/t3code#6036 ## New Contributors * @extoci made their first contribution in pingdotgg/t3code#6194 **Full Changelog**: pingdotgg/t3code@v0.0.34-nightly.20260811.1068...v0.0.34-nightly.20260811.1069 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.34-nightly.20260811.1069
What Changed
isRootPath(packages/shared/src/path.ts) now requires the drive separator (^[a-zA-Z]:[/\\]$instead of[/\\]?), so a bareC:normalizes to the drive root likeC:\andC:/. Added a test.Why
With the separator optional, a bare
C:was treated as already-canonical andtrimTrailingPathSeparatorsreturned it unchanged asC:, whileC:\andC:/normalize to the drive root. The canonical project-path-identity helpersnormalizeProjectPathForComparison/normalizeProjectPathForDispatch— used for project matching and preference-key dedup across the server, client-runtime, and web — therefore treatedC:andC:\as different locations, so a project rooted at a bare drive silently failed identity/dedup checks against the same drive expressed asC:\.Requiring the separator makes a bare
C:fall through to the existing canonicalizer, which appends the separator, soC:,C:\, andC:/all normalize to the same root. This is also more correct semantically: bareC:in Windows means "current directory on C:", not the drive root. Non-root paths and the//\roots are unaffected.Verified: the new test fails on current code and passes with the change (reverted-source re-run); full
packages/sharedtoolchain green (vp test,tsgo,vp lint,vp fmt).Checklist
Note
Low Risk
Small, localized path-normalization fix with a regression test; behavior change only affects edge-case Windows drive-root strings used for project identity.
Overview
Windows drive-root normalization in
packages/shared/src/path.tsis tightened soC:,C:\, andC:/compare as the same project location.isRootPathnow only treats drive roots that include a separator (^[a-zA-Z]:[/\\]$), not a bareC:. That lets bareC:go through the existing trim/canonicalize path (which appends\), aligning with hownormalizeProjectPathForComparisonandnormalizeProjectPathForDispatchare used for project matching and dedup on server, client-runtime, and web. Non-root paths and//\roots are unchanged.A focused unit test covers dispatch/comparison equality and confirms non-root trailing-separator trimming still works.
Reviewed by Cursor Bugbot for commit 487219f. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix
isRootPathto treat bare Windows driveC:as non-rootA bare drive specifier like
C:was incorrectly treated as a Windows drive root. The fix tightens the regex inisRootPath(path.ts) to require a trailing separator, so onlyC:\orC:/match as roots. As a result,normalizeProjectPathForDispatch("C:")now returns"C:\\"andnormalizeProjectPathForComparison("C:")returns"c:\\"Macroscope summarized 487219f.