[FEATURE]: Automatically launch WSL terminals when in WSL directories [Desktop] #8983

Open
opened 2026-02-16 18:11:19 -05:00 by yindo · 0 comments
Owner

Originally created by @kowanietz on GitHub (Feb 10, 2026).

Originally assigned to: @adamdotdevin on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Feature: Auto-detect WSL directories and launch terminals in WSL

Problem

On the Windows Desktop app, opening a terminal from a WSL directory (e.g. \\wsl$\Ubuntu\home\user\project) always launches PowerShell/CMD. Users must manually run wsl every time to get back into their Linux environment. This breaks the workflow for anyone developing primarily in WSL.

Proposed Solution

Detect when the current working directory is a WSL path and automatically spawn the terminal using wsl.exe instead of the Windows shell.

Detection Logic

A directory is a WSL path if it matches:

  • \\wsl$\<distro>\...
  • \\wsl.localhost\<distro>\...

Extract the distro name from the path to pass to wsl.exe -d <distro>.

Implementation

packages/opencode/src/pty/index.ts

  • Before calling Shell.preferred(), check if the CWD matches a WSL path pattern
  • If WSL detected: spawn wsl.exe -d <distro> --cd <linux_path> as the PTY command instead of the default Windows shell
  • Convert the Windows UNC path back to a Linux-native path (strip \\wsl$\<distro> prefix, flip backslashes)
  • Fall back to default Shell.preferred() behavior if detection fails or WSL isn't available

Platform guard

  • Only run detection on process.platform === 'win32'
  • Optionally verify WSL is installed via wsl.exe --list --quiet (cache the result)
Originally created by @kowanietz on GitHub (Feb 10, 2026). Originally assigned to: @adamdotdevin on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request ## Feature: Auto-detect WSL directories and launch terminals in WSL ### Problem On the Windows Desktop app, opening a terminal from a WSL directory (e.g. `\\wsl$\Ubuntu\home\user\project`) always launches PowerShell/CMD. Users must manually run `wsl` every time to get back into their Linux environment. This breaks the workflow for anyone developing primarily in WSL. ### Proposed Solution Detect when the current working directory is a WSL path and automatically spawn the terminal using `wsl.exe` instead of the Windows shell. ### Detection Logic A directory is a WSL path if it matches: - `\\wsl$\<distro>\...` - `\\wsl.localhost\<distro>\...` Extract the distro name from the path to pass to `wsl.exe -d <distro>`. ### Implementation **`packages/opencode/src/pty/index.ts`** - Before calling `Shell.preferred()`, check if the CWD matches a WSL path pattern - If WSL detected: spawn `wsl.exe -d <distro> --cd <linux_path>` as the PTY command instead of the default Windows shell - Convert the Windows UNC path back to a Linux-native path (strip `\\wsl$\<distro>` prefix, flip backslashes) - Fall back to default `Shell.preferred()` behavior if detection fails or WSL isn't available **Platform guard** - Only run detection on `process.platform === 'win32'` - Optionally verify WSL is installed via `wsl.exe --list --quiet` (cache the result)
yindo added the windowsdiscussionweb labels 2026-02-16 18:11:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8983