fix(opencode): always print MCP OAuth URL (#33716)

This commit is contained in:
Aiden Cline 2026-06-24 17:24:16 -05:00 committed by GitHub
commit 49ea8a9455
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 22 deletions

View file

@ -163,10 +163,10 @@ const trackBrowserOpenFailed = Effect.gen(function* () {
return event
})
const authenticateScoped = (name: string) =>
const authenticateScoped = (name: string, onAuthorization?: (authorizationUrl: string) => void) =>
Effect.gen(function* () {
const mcp = yield* service
yield* mcp.authenticate(name).pipe(
yield* mcp.authenticate(name, onAuthorization).pipe(
Effect.ignore,
Effect.catchCause(() => Effect.void),
Effect.forkScoped,
@ -225,12 +225,19 @@ mcpTest.instance(
const opened = yield* trackBrowserOpen
const event = yield* trackBrowserOpenFailed
yield* authenticateScoped("test-oauth-server-3")
const authorization = yield* Deferred.make<string>()
yield* authenticateScoped("test-oauth-server-3", (url) => Deferred.doneUnsafe(authorization, Effect.succeed(url)))
const url = yield* awaitWithTimeout(Deferred.await(opened), "Timed out waiting for open()", "5 seconds")
const authorizationUrl = yield* awaitWithTimeout(
Deferred.await(authorization),
"Timed out waiting for authorization URL",
"5 seconds",
)
const failure = yield* Deferred.await(event).pipe(Effect.timeoutOption("700 millis"))
expect(failure).toEqual(Option.none())
expect(authorizationUrl).toBe(url)
expect(typeof url).toBe("string")
expect(url).toContain("https://")
expect(transportCalls.at(-1)?.options.requestInit?.headers).toEqual({ "X-Custom-Header": "custom-value" })