fix: GitHub Copilot auth fails to open browser in Desktop app (#6957)#8019
fix: GitHub Copilot auth fails to open browser in Desktop app (#6957)#8019
Conversation
GitHub Copilot device code OAuth flow was not opening the browser automatically and was hiding the verification code from Desktop users, causing them to get stuck on "Signing in..." indefinitely. **Changes:** - Added `arboard` crate for clipboard support - Modified `GithubCopilotProvider.login()` to open browser via `webbrowser::open()` and copy the user code to clipboard - Added `device_code_flow` field to `ConfigKey` to distinguish device-code OAuth from redirect-based OAuth - Added `ConfigKey::new_oauth_device_code()` constructor for device code providers - Updated Frontend to show device-code-specific help text: "A browser window will open and the verification code will be copied to your clipboard" - Regenerated OpenAPI types **Testing:** Desktop app can now successfully configure GitHub Copilot: browser opens automatically and verification code is copied to clipboard. CLI flow unchanged (backward compatible). Fixes #6957
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d4f0de56c0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if let Err(e) = webbrowser::open(&device_code_info.verification_uri) { | ||
| tracing::warn!("Failed to open browser: {}", e); |
There was a problem hiding this comment.
Avoid launching Copilot auth on the backend machine
This opens the verification URL from inside goosed, but the desktop app explicitly supports remote/external backends (ui/desktop/src/goosed.ts:194-208). In that setup the browser opens on the server host instead of the user's workstation, and /config/providers/{name}/oauth does not stream the device code back to the renderer (crates/goose-server/src/routes/config_management.rs:898-910), so GitHub Copilot sign-in is still unusable for external-backend users.
Useful? React with 👍 / 👎.
| if let Ok(mut clipboard) = arboard::Clipboard::new() { | ||
| if let Err(e) = clipboard.set_text(&device_code_info.user_code) { | ||
| tracing::warn!("Failed to copy verification code to clipboard: {}", e); | ||
| } | ||
| } |
There was a problem hiding this comment.
Surface a manual fallback when clipboard automation fails
If clipboard access is unavailable here (common in WSL/headless Linux/some sandboxed desktop sessions), the only fallback is the later println!, but the Electron wrapper stops forwarding goosed stdout after startup (ui/desktop/src/goosed.ts:306-316) and the OAuth endpoint only returns after the whole flow completes (crates/goose-server/src/routes/config_management.rs:898-910). In those environments the user still sits on "Signing in..." with no verification code to enter manually.
Useful? React with 👍 / 👎.
Signed-off-by: Douwe Osinga <douwe@squareup.com>
DOsinga
left a comment
There was a problem hiding this comment.
Removed three restating inline comments (code quality rules). Everything else looks good — the fix is sound for the common local-backend case. The Codex P1/P2 concerns (remote backend, headless clipboard) are pre-existing limitations not introduced by this PR.
Summary
GitHub Copilot device code OAuth flow was not opening the browser automatically in the Desktop app and was hiding the verification code, leaving users stuck on "Signing in..." indefinitely.
This fix enables automatic browser opening, copies the verification code to clipboard, and updates the UI to explain the device code flow.
Testing
Related Issues
Fixes #6957