fix(terminal): start WSL local shells from Linux home - #3412
Conversation
When launching WSL on Windows, ensure the distro starts in the Linux home if no explicit working directory was provided. Adds isWslExecutable and getWslLaunchArgs which append `--cd ~` for wsl.exe calls that lack an explicit cwd or --cd option. startLocalSession now uses getWslLaunchArgs when building shell args. Exports getWslLaunchArgs and adds a unit test verifying the behavior. This prevents WSL from failing early when the parent Windows cwd isn't mounted or accessible to the chosen distro.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eb33f78541
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Ensure WSL launch uses Linux home by inserting --cd "~" before the first bare command or --exec/-e boundary so the option is consumed by WSL rather than passed to the invoked shell/command. Early-return when not a WSL executable, when an explicit cwd is supplied, or when --cd is already present. Also account for WSL options that take a separate value (--distribution/-d, --user/-u). Adds a unit test verifying --cd is placed before --exec.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4206704cd8
ℹ️ 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".
|
@codex review |
|
@codex review |
Summary
Start Windows WSL local terminals in the Linux user's home directory when no working directory was requested. This avoids asking WSL to translate an inherited Windows home path that may be unavailable inside the selected distribution.
Preserve explicit working directories, the leading
~shorthand, legacy distribution GUID selectors, and custom Linux commands. For example,-d Ubuntu -- zsh -lbecomes-d Ubuntu --cd ~ -- zsh -l, keeping the directory option outside the Linux command.Type of Change
Related Issue (optional)
N/A
Changes Made
--cd ~before--,--exec,-e, or a bare Linux command, while preserving distribution, user and shell-type option values.startLocalSessionto the process launcher.Screenshots / Demo
No visual changes. The regression test reproduces the original malformed
-d Ubuntu -- --cd ~ zsh -llaunch and verifies-d Ubuntu --cd ~ -- zsh -lafter the fix.Behavior follows Microsoft's WSL help and WSL's argument parser.
Testing
npm run dev)npm run lint)npm test)npm run generate:capability-tools)Latest local validation on macOS:
terminalBridge.outputFlood,terminalBridge.windowsAppsAlias,shellDiscovery.windowsAppsAlias, andterminalBridge.closeReusedSession.npm run lintandgit diff --checkpassed.npm testwas not run. Current-head CI ate4b3c47c69fdfd1cd9b6ff669dc750e445834aa2passed full tests (12,047 passed, 38 conditional skips, zero failures), lint, generated-file checks, real Electron terminal rendering/performance checks, and production build. No capability catalog changes.Checklist