fix(cli): add OAuth copy-url fallback when browser open fails#173
Open
RocketBoyMusic wants to merge 1 commit intodavis7dotsh:mainfrom
Open
fix(cli): add OAuth copy-url fallback when browser open fails#173RocketBoyMusic wants to merge 1 commit intodavis7dotsh:mainfrom
RocketBoyMusic wants to merge 1 commit intodavis7dotsh:mainfrom
Conversation
Contributor
Additional Comments (1)
Prompt To Fix With AIThis is a comment left during a code review.
Path: apps/cli/src/tui/components/connect-wizard.tsx
Line: 426:428
Comment:
**Null URL key crash**
If the OAuth browser auto-open succeeds, `oauthFallbackUrl` stays `null`, but the new `c` key handler still runs `copy(oauthFallbackUrl)` and then does `setAuthStepStatus(...)` in the callback. Passing `null` to the clipboard helper will throw (or at least copy the string `"null"`), which can break the auth step even though the primary flow is working. Guard the handler (and the UI hint) behind `oauthFallbackUrl != null`, or early-return with a friendly message when it’s absent.
How can I resolve this? If you propose a fix, please make it concise. |
Author
|
Okay, I double checked this path and we do guard it before copy: So copyToClipboard only runs when a fallback URL exists in the auth step. So I don't see any problem personally, luckily :) |
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.
Summary
On Windows, OAuth browser auto-open can fail on some setups, which leaves users stuck in the TUI flow.
This PR adds a manual fallback path so users can copy the authorization URL and continue authentication without restarting.
Changes
open,cmd /c start,xdg-open).ckey shortcut in auth step to copy URL to clipboard.Why
This keeps OAuth usable on Windows environments where browser launch is unreliable, while preserving current behavior on systems where browser open works.
Validation
bun run --cwd apps/cli checkGreptile Overview
Greptile Summary
This PR improves the CLI OAuth flow by detecting failures to auto-open the authorization URL (notably on Windows) and exposing hooks so the TUI can present a manual fallback.
On the library side (
apps/cli/src/lib/opencode-oauth.ts), the OAuth login now reports the auth URL and browser-open failures via optional callbacks while continuing the underlying OAuth polling/verification.On the TUI side (
apps/cli/src/tui/components/connect-wizard.tsx), the connect wizard stores the fallback URL, shows user guidance, and adds acshortcut to copy the URL to the clipboard.One issue to address before merge: the new
ckey handler can still fire when there is no fallback URL (browser open succeeded), which can crash or behave incorrectly when attempting to copy a null URL.Confidence Score: 3/5
Important Files Changed
Context used:
dashboard- AGENTS.md (source)