fix(core): send legacy console.opencode.ai credentials to opencode.ai/console (#57588)

This commit is contained in:
Dax
2026-10-20 21:48:07 -04:00
committed by GitHub
Unverified
parent adcda1b84f
commit 7d3752c14c
2 changed files with 23 additions and 1 deletions
@@ -601,7 +601,10 @@ function credentialHeaders(value: Credential.Key | Credential.OAuth): Record<str
}
function serverUrl(value: Credential.Value) {
return typeof value.metadata?.server === "string" ? value.metadata.server : defaultServer
const server = typeof value.metadata?.server === "string" ? value.metadata.server : defaultServer
// Credentials saved before August 2026 store the retired console.opencode.ai host, which maps path-for-path onto
// the default server; rewriting it lets that host be shut down without forcing those users to reconnect.
return server.replace(/^https:\/\/console\.opencode\.ai(?=\/|$)/, defaultServer)
}
function withoutCredentials<Value>(body: Readonly<Record<string, Value>> | undefined) {
@@ -1313,6 +1313,25 @@ describe("OpencodePlugin", () => {
}),
)
it.effect("sends credentials saved with the retired console.opencode.ai host to the default Console", () =>
Effect.gen(function* () {
const credentials = yield* Credential.Service
const requests: string[] = []
const http = HttpClient.make((request) => {
requests.push(request.url)
return Effect.succeed(HttpClientResponse.fromWeb(request, new Response(null, { status: 404 })))
})
yield* credentials.create({
integrationID: Integration.ID.make("opencode"),
value: Credential.Key.make({ type: "key", key: "secret", metadata: { server: "https://console.opencode.ai" } }),
})
yield* addPlugin().pipe(Effect.provideService(HttpClient.HttpClient, http))
yield* drain
expect(requests).toEqual(["https://opencode.ai/console/api/v2/config"])
}),
)
it.effect("reports a rejected Console refresh token as signed out without removing the credential", () =>
Effect.acquireUseRelease(
Effect.sync(() =>