Skip to content

fix(terminal): start WSL local shells from Linux home - #3412

Merged
binaricat merged 4 commits into
binaricat:mainfrom
OOKAMISAMA:main
Sep 18, 2026
Merged

binaricat merged 4 commits into
binaricat:mainfrom
OOKAMISAMA:main

Conversation

@OOKAMISAMA

@OOKAMISAMA OOKAMISAMA commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

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 -l becomes -d Ubuntu --cd ~ -- zsh -l, keeping the directory option outside the Linux command.

Type of Change

  • Bug fix
  • New feature
  • Refactor / code cleanup
  • Documentation update
  • Build / CI change
  • Other (please describe):

Related Issue (optional)

N/A

Changes Made

  • Default WSL local shells to Linux home only when no directory is explicitly requested.
  • Keep --cd ~ before --, --exec, -e, or a bare Linux command, while preserving distribution, user and shell-type option values.
  • Distinguish WSL directory options from similarly named Linux command arguments.
  • Cover parameter handling and the arguments passed by startLocalSession to the process launcher.
  • Leave non-WSL shells and explicit working directories unchanged.

Screenshots / Demo

No visual changes. The regression test reproduces the original malformed -d Ubuntu -- --cd ~ zsh -l launch and verifies -d Ubuntu --cd ~ -- zsh -l after the fix.

Behavior follows Microsoft's WSL help and WSL's argument parser.

Testing

  • I have tested these changes locally (npm run dev)
  • Linting passes (npm run lint)
  • Tests pass (npm test)
  • Generated capability tool specs are updated when applicable (npm run generate:capability-tools)
  • No new console errors or warnings, if this affects app behavior

Latest local validation on macOS:

  • 21 focused tests passed, with test concurrency limited to 1: terminalBridge.outputFlood, terminalBridge.windowsAppsAlias, shellDiscovery.windowsAppsAlias, and terminalBridge.closeReusedSession.
  • Full npm run lint and git diff --check passed.
  • Windows behavior is simulated at the process-launch boundary. Real Windows/WSL launch validation was not available on this host; no claim of live WSL verification is made.
  • Full local npm test was not run. Current-head CI at e4b3c47c69fdfd1cd9b6ff669dc750e445834aa2 passed 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

  • My code follows the existing project style
  • I have added or updated relevant documentation
  • I have not introduced any breaking changes (or I have described them above)

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread electron/bridges/terminalBridge.cjs Outdated
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.
@binaricat

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-16T08:34:52.535380Z 4206704 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread electron/bridges/terminalBridge.cjs Outdated
@binaricat

Copy link
Copy Markdown
Owner

@codex review

@binaricat

Copy link
Copy Markdown
Owner

@codex review

@binaricat
binaricat merged commit f841ab4 into binaricat:main Sep 18, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants