fix(auth): always show login URL so headless login can complete#420
Open
theFong wants to merge 1 commit into
Open
fix(auth): always show login URL so headless login can complete#420theFong wants to merge 1 commit into
theFong wants to merge 1 commit into
Conversation
On a machine with no display (e.g. an SSH'd server), login hung and timed out after 5 minutes. hasBrowser() returned true because xdg-open was installed, so browser.OpenURL was called; xdg-open printed "no DISPLAY environment variable specified" to stderr but exited 0, so OpenURL returned nil and the CLI printed "Waiting for login to complete in browser..." without ever showing the login URL. With no URL to visit, login could never complete. Follow Claude Code's pattern: always attempt to open the browser best-effort, but always print the login URL as a fallback so the user is never stranded. Discard the launcher's stderr (pkg/browser pipes it to ours) to suppress the confusing "no DISPLAY" noise. This removes the need for platform/display detection, so hasBrowser() is deleted.
84e5b32 to
5e81f25
Compare
patelspratik
approved these changes
Jul 2, 2026
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.
Problem
brev register(and any login flow) hangs and times out after 5 minutes on a headless machine (e.g. an SSH'd server):Root cause
On a machine with no display but
xdg-openinstalled:hasBrowser()returnedtrue— it only checked whetherxdg-openexisted, not whether a display was available.defaultAuthFunccalledbrowser.OpenURL(url).xdg-openprintedError: no DISPLAY environment variable specifiedto stderr but exited 0, soOpenURLreturnednil.Fix
Follow the same pattern Claude Code's CLI uses: always attempt to open the browser best-effort, but always print the login URL as a fallback, so the user is never stranded regardless of environment.
defaultAuthFunc: attemptbrowser.OpenURL(ignore the result), then alwaysshowLoginURL.showLoginURL: reframed as a fallback —Browser didn't open? Use the URL below to sign in:.browser.Stderr = io.Discard) —pkg/browserpipes it to ours, which is what leaked the confusingno DISPLAYmessage.hasBrowser()is deleted (net −9 lines).Note:
brev registeruses an in-memory device-login flow (it does not reuse~/.brevcredentials), so it always hits this path — this fix is what unblocksregisteron headless machines.Testing
go build ./...,go vet ./pkg/auth/,go test ./pkg/auth/linux/arm64and ran on a headless (noDISPLAY) arm64 box: login now prints the URL instead of hanging.