Skip to content

fix: keep auth listener alive when browser fails to open (#89)#92

Merged
dubadub merged 2 commits into
mainfrom
fix/login-keep-listener-on-browser-open-failure
May 27, 2026
Merged

fix: keep auth listener alive when browser fails to open (#89)#92
dubadub merged 2 commits into
mainfrom
fix/login-keep-listener-on-browser-open-failure

Conversation

@dubadub

@dubadub dubadub commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes Login in browser fails on Pop_OS 24.04 #89: login fails on Pop_OS 24.04 / Cosmic where xdg-open exits with code 4 even when a browser is installed.
  • Previously open::that(&login_url)? propagated the error and dropped the local TCP listener bound on 127.0.0.1:<port>, so even pasting the URL manually couldn't complete the OAuth callback.
  • Now we keep the listener alive when open fails, and surface the URL through multiple channels so users don't have to dig through logs.

Fallbacks when the browser doesn't open

  • Always (all platforms): print the login URL to stdout before trying to open the browser, matching cookcli login behaviour — terminal users see it whether the auto-open works or not.
  • All platforms: native desktop notification ("couldn't open browser — URL has been shown on screen").
  • Linux only (where the daemon's stdout isn't visible when launched from the tray):
    • Try wl-copy / xclip to copy the URL to the clipboard automatically.
    • Show a zenity --info dialog with the URL (selectable text), telling the user whether the clipboard copy succeeded.

Test plan

  • cargo fmt
  • cargo clippy --all-targets -- -D warnings -A dead_code
  • cargo test
  • Manual on Linux: temporarily break xdg-open (e.g. PATH=/dev/null cook-sync login) and confirm: URL prints to stdout, zenity dialog appears, clipboard receives URL, callback completes after manual paste.
  • Manual on macOS / Windows: confirm normal login is unaffected and stdout shows the URL up front.

dubadub added 2 commits May 27, 2026 19:52
When open::that() failed (e.g. xdg-open exit 4 on Pop_OS / Cosmic), the
? operator dropped the local TCP listener, so even pasting the auth URL
manually couldn't complete the callback. Now we log the failure, print
the URL for manual copy, surface a notification, and keep the listener
running until the timeout.

Refs #89
Daemon-launched logins (from the tray) have no visible stdout, so a
notification or log message was easy to miss. Now when open::that()
fails on Linux we additionally:

  - try to copy the URL to the clipboard (wl-copy / xclip)
  - show a zenity --info dialog with the URL and a hint about clipboard

Also print the URL up front (before the open attempt) on all platforms
so terminal users always see it, matching cookcli's behaviour.

Refs #89
@dubadub dubadub merged commit f867ee9 into main May 27, 2026
2 checks passed
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.

Login in browser fails on Pop_OS 24.04

1 participant