gemini-cli-extensions / gemini-cli-extensions/workspace

bug: shouldLaunchBrowser() returns true on WSL2 because WSLg sets DISPLAY/WAYLAND_DISPLAY

Open Beginner friendly
#355 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
638
Forks
107
PR merge metrics
No merged PRs in 30d

Description

Problem

On WSL2 with WSLg enabled (the default on Windows 11), shouldLaunchBrowser() in workspace-server/src/utils/secure-browser-launcher.ts returns true because WSLg pre-populates DISPLAY and WAYLAND_DISPLAY. The server then takes the GUI path and calls open() / xdg-open for OAuth, which from WSL is unreliable — typically no browser the user is actually watching surfaces, and getAuthenticatedClient() ends up stalling until its ~5-minute timeout.

The headless flow added in #227 is the correct path for WSL2, but it is never reached because WSL is misclassified as GUI-capable.

Reproduce

  1. Run the MCP server inside WSL2 on Windows 11 (WSLg defaults).
  2. Confirm echo \$DISPLAY and echo \$WAYLAND_DISPLAY both return values.
  3. Clear credentials and trigger any tool that requires fresh auth (e.g. gmail.search).
  4. The server takes the GUI-launch branch and hangs / times out instead of returning the headless OAuth URL.

Proposed fix

In shouldLaunchBrowser(), treat WSL as headless by checking for WSL_DISTRO_NAME or WSL_INTEROP (set by WSL2 but not by native Linux). This routes WSL users through the existing headless flow.

Happy to send a small PR (one function, plus a test) if the maintainers are open to this approach.

Environment

  • WSL2 on Windows 11 (WSLg defaults)
  • Latest `main`

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in workspace-server/src/utils/secure-browser-launcher.ts at shouldLaunchBrowser(), then review the headless flow introduced in issue #227. Use the WSL2 environment variables described in the issue to verify that WSL takes the headless OAuth path and add the corresponding test; done means WSL no longer uses open() or xdg-open for authentication.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
authentication, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
84/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.