Skip to content

Open a WSL pane's port in Playwright from its Windows path - #1356

Open
nedtwigg wants to merge 1 commit into
mainfrom
fix/wsl-playwright-screencast
Open

nedtwigg wants to merge 1 commit into
mainfrom
fix/wsl-playwright-screencast

Conversation

@nedtwigg

@nedtwigg nedtwigg commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Problem

Opening a port as a Playwright screencast from a WSL (Ubuntu) pane failed with ENOENT: no such file or directory, lstat 'C:\home'. agent-browser worked because it is not project-scoped.

The port menu (openContextPort) passed the pane's reported cwd, a Linux path like /home/me/app, to the Windows browser host as the binding cwd. The Playwright host's workspace lookup (playwrightWorkspace → realpathSync) resolved it as C:\home\me\app. A Git Bash pane's MSYS /c/... cwd has the same problem.

dor playwright run inside WSL was unaffected: the launcher already sends PWD translated to \wsl.localhost\<distro>\....

Fix

  • Sidecar (pty-core.js):
    • Each session records its WSL distro (from wsl.exe -d <distro>).
    • A new hostDirectory terminal-context op translates a directory the pane reported:
      • A WSL pane's /mnt/c/x and Git Bash's /c/x become C:\x.
      • Other WSL paths become \wsl.localhost\<distro>\..., the same path dor sends from that directory.
      • Everything else passes through unchanged.
    • openDirectory (Explore) translates through it too. Explore's existing validation still refuses UNC paths, so this only enables /mnt/<drive> and MSYS drive paths there.
  • Renderer (Wall.tsx): openContextPort and a Tool's Break ask for the translated cwd before building the browser params (hostCwdOf). If the host can't answer, they fall back to the reported path.
  • Spec: one line in dor-browser.md → Pane Context Menu Connect.

A Playwright pane already opened with the bad cwd keeps it in its saved params. Close it and reopen the port.

Testing

  • New sidecar test covers WSL /home and /mnt paths, Git Bash, pass-through and Explore. The sidecar suite passes: 214 pass, 0 fail.
  • lib/src/components/Wall.test.tsx passes (188).
  • tsc passes for lib, standalone and vscode-ext; spec-lint OK.
  • On this machine, the translated \wsl.localhost\Ubuntu\home\<user> resolves with realpathSync, as the Playwright host needs.
  • The full GUI flow has not been run.

🤖 Generated with Claude Code

A WSL pane reports Linux directories, and the port menu handed that cwd to
the Windows browser host as is: Playwright's workspace lookup realpaths it,
and `/home/me` resolved as `C:\home\me` (ENOENT). Git Bash's MSYS `/c/...`
had the same problem.

The sidecar now records a pane's WSL distro and answers a `hostDirectory`
context op: `/mnt/c/x` and Git Bash's `/c/x` become `C:\x`, other WSL paths
the distro's `\wsl.localhost\<distro>\...` share (the path `dor` sends from
the same directory). The port menu and a Tool's Break use it, and Explore
translates through it too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7492cbb
Status: ✅  Deploy successful!
Preview URL: https://475d6d77.mouseterm.pages.dev
Branch Preview URL: https://fix-wsl-playwright-screencas.mouseterm.pages.dev

View logs

This branch has not been deployed

No deployments
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