Skip to content

login: open the Windows browser under WSL, with device-flow fallback#1708

Open
torbjorn wants to merge 3 commits into
entireio:mainfrom
torbjorn:wsl-windows-browser-login
Open

login: open the Windows browser under WSL, with device-flow fallback#1708
torbjorn wants to merge 3 commits into
entireio:mainfrom
torbjorn:wsl-windows-browser-login

Conversation

@torbjorn

Copy link
Copy Markdown

Fixes #1707. Makes entire login under WSL open the Windows browser (where users are already signed in) and recover when the OAuth redirect can't reach WSL.

  • Open the Windows default browser under WSL (wslview, else cmd.exe) instead of a Linux WSLg browser
  • Detect WSL from /proc/version, so detection survives hooks/services that strip WSL env vars
  • On WSL, let the user fall back to device-code sign-in when the browser redirect can't reach the loopback listener (extends the login: harden the browser sign-in fallbacks #1403 loginFlowFacts pattern with a wsl fact, mirroring its SSH fallback)
  • Shared launcher, so entire experts also opens the Windows browser
  • Non-WSL platforms unchanged; launcher selection and the fallback race are unit-tested (pass under -race)

torbjorn added 3 commits July 10, 2026 20:23
Detect WSL via /proc/version and open the Windows default browser
(wslview, else cmd.exe) instead of xdg-open, which resolves to a Linux
WSLg browser when one is installed.

Entire-Checkpoint: 01KX6MB6768R7F7CH2947GD9E7
Under WSL the Windows browser may not reach the WSL loopback listener
(depends on localhostForwarding). Race the OAuth callback against an
Enter keypress; on Enter, fall back to the device-code flow. WSL-only.

Entire-Checkpoint: 01KX6MC1W5QG8T224V579933Y8
- browserWaitError: ctx first param (revive context-as-argument, was a
  CI lint failure)
- WSL cmd.exe fallback: set working dir best-effort so a customized
  automount root (no /mnt/c) doesn't hard-fail the launch
- fallback race: prefer an already-arrived successful callback over the
  Enter signal so a completed login is never discarded

Entire-Checkpoint: 01KX69WTD49ZTZD2WQDFR2RXPG
@torbjorn
torbjorn requested a review from a team as a code owner July 10, 2026 18:28
Copilot AI review requested due to automatic review settings July 10, 2026 18:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR improves entire login behavior under WSL by opening the Windows default browser (where users already have active sessions) and adding a WSL-specific fallback from the loopback (auth-code) flow to the device-code flow when the redirect can’t reach the WSL listener.

Changes:

  • Added WSL detection via /proc/version (cached) and routed browser opening under WSL through wslview (or a Windows launcher fallback) instead of xdg-open.
  • Extended the browser (loopback) login flow under WSL to race the redirect wait against an Enter-driven fallback that switches to the device-code flow.
  • Added unit tests covering launcher selection and the WSL redirect/fallback race paths.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/entire/cli/login.go Adds WSL detection, shared browser launcher resolution, and WSL-specific browser→device fallback behavior in the login flow.
cmd/entire/cli/login_test.go Updates/extends unit tests for the new runBrowserLogin signature, WSL fallback behavior, and launcher selection logic.

Comment thread cmd/entire/cli/login.go
Comment on lines +643 to +647
if wsl {
if path, lerr := lookPath("wslview"); lerr == nil {
return path, []string{browserURL}, "", nil
}
return "cmd.exe", []string{"/c", "start", "", browserURL}, "/mnt/c", nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

entire login opens a Linux browser instead of the Windows default browser under WSL

2 participants