mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-17 05:26:47 +03:00
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:
committed by
GitHub
Unverified
parent
e1bba47bc3
commit
c3a73eca34
@@ -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)
|
||||
})
|
||||
Reference in New Issue
Block a user