You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(desktop): keep WSL distros whose names start or end with a dot or hyphen - #35971
The single DISTRO_NAME_PATTERN in apps/desktop/src/wsl/wslPathParsing.ts (used by isValidDistroName -> DesktopAppSettings.normalizeWslDistro, extractDistroFromUncPath and wslUncPathToLinuxPath) required \w at both ends, so WSL-valid names like "Ubuntu-", "Ubuntu.", ".Ubuntu", "-Ubuntu" were rejected: the settings setter stored null (default distro) and UNC paths in those distros mapped to null. The pattern is now /^(?!.{1,2}$)[\w.-](?:[\w .-]*[\w.-])?$/: dot and hyphen are allowed at either end, while a leading or trailing space and any other character (controls, /, !, ;) are still rejected. The names "." and ".." are explicitly excluded so the UNC distro segment can never act as a relative path segment; one assertion for that was added to the existing rejection test. The repro branch's tests (including the updated #2751 isValidDistroName test) are kept and pass. Worst case on adversarial input: linear. There is one bounded lookahead (at most 3 characters) and a single variable-length character class followed by one terminal character class, so there is no nested or overlapping quantifier and no catastrophic backtracking. Not verified on a Windows host (native picker, WSL backend launch).
On origin/main 0c4b1d8 I ran the desktop app on Linux with T3CODE_DEV_SEED=0 ELECTRON_DISABLE_SANDBOX=1 T3CODE_DESKTOP_REMOTE_DEBUGGING_PORT=<port> headless-desktop vp run dev:desktop (fresh worktree database). Over CDP I called the renderer's real window.desktopBridge.setWslDistro IPC, the same call the Settings distro picker makes, selecting "Debian" first and then each name. Result: setWslDistro("Ubuntu-24.04") returned distro "Ubuntu-24.04" (control), while setWslDistro("Ubuntu-"), ("Ubuntu."), (".Ubuntu") and ("-Ubuntu") each returned distro null, so the earlier explicit selection was replaced by the system default. Unit level: wslUncPathToLinuxPath(\\wsl.localhost\Ubuntu-\home\josh) returns null and isValidDistroName("Ubuntu-") returns false. Two new tests on factory/repro-35955 fail on main. Without a Windows host I could not observe the native picker listing these distros or the WSL backend launching on the default distro.
Evidence
Select Debian, then each of Ubuntu-24.04, Ubuntu-, Ubuntu., .Ubuntu, and -Ubuntu through the real desktopBridge setter; read the selection back through IPC. Linux Electron, fresh databases, identical 1200×850 viewport. Captures show a labeled diagnostic overlay, not the Windows picker.
Permanent blocker: A Windows host with installed edge-case WSL distros is needed to demonstrate native picker enumeration, backend launch into the selected distro, and UNC-path mapping in the real workflow; this VM is Linux.
Tests
vp test run src/wsl/wslPathParsing.test.ts src/settings (apps/desktop): 4 files, 39 tests passed. vp run check:changed: format, lint, knip, typecheck (2 packages), and tests all passed.
Who did the work
Written by Claude Opus 5.5, in Claude Code
Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5
WSL registers names made of letters, digits, dots, underscores and
hyphens without requiring an alphanumeric first or last character, but
isValidDistroName and the UNC helpers reject them, so settings
normalizes such a selection to the default distro.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… hyphen
The distro name check required a letter, digit or underscore at both
ends, but WSL registers names like "Ubuntu-" or ".Ubuntu". Selecting one
in settings fell back to the default distro, and UNC paths inside it
were not mapped. Allow dot and hyphen at either end, still rejecting "."
and ".." so the UNC distro segment cannot be a relative path segment.
Fixes#35955
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
These cases repeat the same name validation already tested at the lower isValidDistroName layer. Could you remove this wrapper test and keep the cases at that layer?
Suggested change
it("maps UNC paths of distros whose names start or end with a dot or hyphen",()=>{
Macroscope's review found this PR approvable — This preserves WSL distro names with leading or trailing dots or hyphens in settings and path handling, while still rejecting '.' and '..'. The compatibility change is narrowly scoped and leaves product defaults unchanged.
You can add or adjust custom eligibility rules. Learn more.
No actionable comments were generated in the recent review.
Walkthrough
The WSL distro-name pattern now accepts names beginning or ending with a dot or hyphen. Tests cover UNC path mapping for those names and confirm that . and .. remain invalid.
Changes: WSL distro-name validation
Layer / File(s)
Summary
Distro-name validation and path tests apps/desktop/src/wsl/wslPathParsing.ts, apps/desktop/src/wsl/wslPathParsing.test.ts
The pattern accepts leading or trailing dots and hyphens while still rejecting . and ... Tests cover UNC path mapping, valid dot- and hyphen-prefixed or suffixed names, and rejection of trailing whitespace.
WSL distros with names that start or end with a dot or hyphen can now be selected and keep their name in settings, and distro-scoped path mapping works for them. No new risk was found. The native picker and backend launch have not been checked on a Windows host.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: WSL distro names that start or end with a dot or hyphen are now kept. The changeset updates DISTRO_NAME_PATTERN and its tests to allow those names, which matches the t…
Linked Issues check
Directly linked issue #35955 has three coding requirements. (1) Accept WSL-valid names with a leading or trailing dot or hyphen: the head replaces DISTRO_NAME_PATTERN in apps/desktop/src/wsl/wslPathPa…
Out of Scope Changes check
The whole-PR diff against the merge base 0c4b1d8 touches two files. wslPathParsing.ts changes only the DISTRO_NAME_PATTERN regex and adds one comment. wslPathParsing.test.ts updates the rejection…
Description check
The description covers the problem (DISTRO_NAME_PATTERN rejects WSL-valid names such as Ubuntu-, Ubuntu., .Ubuntu, -Ubuntu), the change (new pattern allowing dots and hyphens at either end, with . and…
Full details: Title check
Explanation
The title names the main change: WSL distro names that start or end with a dot or hyphen are now kept. The changeset updates DISTRO_NAME_PATTERN and its tests to allow those names, which matches the title's fix(desktop) scope.
Full details: Linked Issues check
Explanation
Directly linked issue #35955 has three coding requirements. (1) Accept WSL-valid names with a leading or trailing dot or hyphen: the head replaces DISTRO_NAME_PATTERN in apps/desktop/src/wsl/wslPathParsing.ts with /^(?!.{1,2}$)[\w.-](?:[\w .-]*[\w.-])?$/, which accepts Ubuntu-, Ubuntu., .Ubuntu and -Ubuntu. The new test in wslPathParsing.test.ts asserts isValidDistroName returns true for these names. (2) Preserve the selected name in settings: the PR description states DesktopAppSettings.normalizeWslDistro uses isValidDistroName, so the fixed predicate also fixes the settings fallback. I did not read the settings source at head; this rests on the PR description and the src/settings tests reported as passing. (3) Distro-scoped UNC helpers keep the distro and Linux path: the new test asserts wslUncPathToLinuxPath(\wsl.localhost<name>\home\josh) returns /home/josh for all four names. Leading or trailing spaces and other disallowed characters remain rejected, and the names '.' and '..' are excluded. The Windows native picker and WSL backend launch are not verified, as the issue also notes. Those are runtime checks outside the coding requirements above.
Full details: Out of Scope Changes check
Explanation
The whole-PR diff against the merge base 0c4b1d8 touches two files. wslPathParsing.ts changes only the DISTRO_NAME_PATTERN regex and adds one comment. wslPathParsing.test.ts updates the rejection test to drop the dot and hyphen cases, adds accepting tests for the four names, and adds a rejection assertion for '..'. All changes serve issue #35955. The pattern is also linear on adversarial input, because the ^ anchor limits matching to one start position. The PR description's claim of 'no overlapping quantifiers' is imprecise, since [\w .-]* and the terminal [\w.-] overlap, but this does not change the result. No unrelated changes were found.
Full details: Description check
Explanation
The description covers the problem (DISTRO_NAME_PATTERN rejects WSL-valid names such as Ubuntu-, Ubuntu., .Ubuntu, -Ubuntu), the change (new pattern allowing dots and hyphens at either end, with . and .. excluded), and scope (links issue #35955 and fixes it). Verification is detailed: a before/after reproduction on main through the real desktopBridge IPC, unit test results (39 tests passed), and a check:changed run. It also states what was not verified (Windows host picker and WSL backend launch). The template's Problem, Change, Scope, and Verification sections are all present and substantively filled. The model and harness attribution line is also present. Minor gap: the description uses a long reproduction log and extra sections beyond the template, but the required information is complete.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Reviewing files that changed from the base of the PR and between 99224f0 and ed92374.
Files selected for processing: 2
apps/desktop/src/wsl/wslPathParsing.test.ts
apps/desktop/src/wsl/wslPathParsing.ts
Included review availability: This review used your included allowance. 2 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:XS0-9 changed lines (additions + deletions).vouch:trustedAuthor is trusted by repo permissions or the VOUCHED list.
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The single DISTRO_NAME_PATTERN in apps/desktop/src/wsl/wslPathParsing.ts (used by isValidDistroName -> DesktopAppSettings.normalizeWslDistro, extractDistroFromUncPath and wslUncPathToLinuxPath) required \w at both ends, so WSL-valid names like "Ubuntu-", "Ubuntu.", ".Ubuntu", "-Ubuntu" were rejected: the settings setter stored null (default distro) and UNC paths in those distros mapped to null. The pattern is now /^(?!.{1,2}$)[\w.-](?:[\w .-]*[\w.-])?$/: dot and hyphen are allowed at either end, while a leading or trailing space and any other character (controls, /, !, ;) are still rejected. The names "." and ".." are explicitly excluded so the UNC distro segment can never act as a relative path segment; one assertion for that was added to the existing rejection test. The repro branch's tests (including the updated #2751 isValidDistroName test) are kept and pass. Worst case on adversarial input: linear. There is one bounded lookahead (at most 3 characters) and a single variable-length character class followed by one terminal character class, so there is no nested or overlapping quantifier and no catastrophic backtracking. Not verified on a Windows host (native picker, WSL backend launch).
Fixes #35955
Reproduction on main
On origin/main 0c4b1d8 I ran the desktop app on Linux with
T3CODE_DEV_SEED=0 ELECTRON_DISABLE_SANDBOX=1 T3CODE_DESKTOP_REMOTE_DEBUGGING_PORT=<port> headless-desktop vp run dev:desktop(fresh worktree database). Over CDP I called the renderer's realwindow.desktopBridge.setWslDistroIPC, the same call the Settings distro picker makes, selecting "Debian" first and then each name. Result: setWslDistro("Ubuntu-24.04") returned distro "Ubuntu-24.04" (control), while setWslDistro("Ubuntu-"), ("Ubuntu."), (".Ubuntu") and ("-Ubuntu") each returned distro null, so the earlier explicit selection was replaced by the system default. Unit level: wslUncPathToLinuxPath(\\wsl.localhost\Ubuntu-\home\josh) returns null and isValidDistroName("Ubuntu-") returns false. Two new tests on factory/repro-35955 fail on main. Without a Windows host I could not observe the native picker listing these distros or the WSL backend launching on the default distro.Evidence
Select Debian, then each of
Ubuntu-24.04,Ubuntu-,Ubuntu.,.Ubuntu, and-Ubuntuthrough the real desktopBridge setter; read the selection back through IPC. Linux Electron, fresh databases, identical 1200×850 viewport. Captures show a labeled diagnostic overlay, not the Windows picker.Identical CDP driver · Base responses · Head responses
Not shown:
Tests
vp test run src/wsl/wslPathParsing.test.ts src/settings (apps/desktop): 4 files, 39 tests passed. vp run check:changed: format, lint, knip, typecheck (2 packages), and tests all passed.
Who did the work
Run by the t3code factory in T3 Code.