login: open the Windows browser under WSL, with device-flow fallback#1708
Open
torbjorn wants to merge 3 commits into
Open
login: open the Windows browser under WSL, with device-flow fallback#1708torbjorn wants to merge 3 commits into
torbjorn wants to merge 3 commits into
Conversation
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
Contributor
There was a problem hiding this comment.
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 throughwslview(or a Windows launcher fallback) instead ofxdg-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 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1707. Makes
entire loginunder WSL open the Windows browser (where users are already signed in) and recover when the OAuth redirect can't reach WSL.loginFlowFactspattern with awslfact, mirroring its SSH fallback)entire expertsalso opens the Windows browser-race)