opencode
opencode copied to clipboard
fix(mcp): show auth URL when browser cannot open in remote sessions
When running opencode mcp auth in headless environments (SSH, devcontainers, WSL), the browser cannot be opened automatically. Previously this would fail with a cryptic "Something went wrong" error. Now the auth URL is displayed so users can manually open it in their local browser.
The fix catches three failure modes from the open package:
- Synchronous exception: thrown when open() itself fails
- "error" event: fires when the command doesn't exist (ENOENT)
- "exit" event with non-zero code: fires when the command exists but fails (e.g., xdg-open can't connect to a display server)
What does this PR do?
Description above.
How did you verify your code works?
I tested this on my vscode devcontainer that was initially having this issue.
Fixes https://github.com/anomalyco/opencode/issues/7887