Skip to content

fix(shared): normalize a bare Windows drive root the same as C:\ / C:/ - #6189

Merged
juliusmarminge merged 1 commit into
pingdotgg:mainfrom
arhxam:fix/windows-drive-root-normalization
Aug 11, 2026
Merged

fix(shared): normalize a bare Windows drive root the same as C:\ / C:/#6189
juliusmarminge merged 1 commit into
pingdotgg:mainfrom
arhxam:fix/windows-drive-root-normalization

Conversation

@arhxam

@arhxam arhxam commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

What Changed

isRootPath (packages/shared/src/path.ts) now requires the drive separator (^[a-zA-Z]:[/\\]$ instead of [/\\]?), so a bare C: normalizes to the drive root like C:\ and C:/. Added a test.

Why

With the separator optional, a bare C: was treated as 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 the 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 expressed as C:\.

Requiring the separator makes a bare C: fall through to the existing canonicalizer, which appends the separator, so C:, C:\, and C:/ all normalize to the same root. This is also more correct semantically: bare C: 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/shared toolchain green (vp test, tsgo, vp lint, vp fmt).

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • No UI changes

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.ts is tightened so C:, C:\, and C:/ compare as the same project location.

isRootPath now only treats drive roots that include a separator (^[a-zA-Z]:[/\\]$), not a bare C:. That lets bare C: go through the existing trim/canonicalize path (which appends \), aligning with how normalizeProjectPathForComparison and normalizeProjectPathForDispatch are 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 isRootPath to treat bare Windows drive C: as non-root

A bare drive specifier like C: was incorrectly treated as a Windows drive root. The fix tightens the regex in isRootPath (path.ts) to require a trailing separator, so only C:\ or C:/ match as roots. As a result, normalizeProjectPathForDispatch("C:") now returns "C:\\" and normalizeProjectPathForComparison("C:") returns "c:\\"

Macroscope summarized 487219f.

`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>
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2b6a41a1-7976-4a8b-94e2-9648e6b62ad1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Aug 11, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved 487219f

Straightforward bug fix that corrects Windows drive root path normalization. The regex change ensures C: (current directory on C:) is normalized to C:\ for consistent comparison with C:\ and C:/. Small, focused change with comprehensive test coverage.

You can customize Macroscope's approvability policy. Learn more.

@juliusmarminge
juliusmarminge enabled auto-merge (squash) August 11, 2026 15:51
@juliusmarminge
juliusmarminge merged commit 6befe42 into pingdotgg:main Aug 11, 2026
17 of 18 checks passed
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Aug 11, 2026
## 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants