fix(cli): don't crash auth login when no browser opener is available (#56082)

Co-authored-by: thdxr <thdxr@users.noreply.github.com>
This commit is contained in:
opencode-agent[bot]
2026-10-16 13:42:50 +00:00
committed by GitHub
Unverified
parent e1bba47bc3
commit c3a73eca34
2 changed files with 10 additions and 1 deletions
+2 -1
View File
@@ -17,7 +17,8 @@ export function requireInteractive(message: string) {
export const openUrl = Effect.fn("cli.prompt.open-url")(function* (url: string) {
const browser = yield* Effect.promise(() => import("@opencode/util/open"))
yield* Effect.promise(() => browser.openUrl(url)).pipe(Effect.ignore)
// Best effort: headless environments may lack a browser opener, and the caller already printed the URL.
yield* Effect.tryPromise(() => browser.openUrl(url)).pipe(Effect.ignore)
})
export function handlePromptErrors<A, E, R>(effect: Effect.Effect<A, E, R>) {
@@ -0,0 +1,8 @@
import { expect, test } from "bun:test"
import { Effect, Exit } from "effect"
import { openUrl } from "../src/ui/prompt"
test("suppresses browser open failures so the printed URL stays usable", async () => {
const exit = await Effect.runPromiseExit(openUrl("not-a-browser-url"))
expect(Exit.isSuccess(exit)).toBe(true)
})