refactor(server): simplify listener lifecycle (#27413)

This commit is contained in:
Kit Langton
2026-05-14 20:00:52 -04:00
committed by GitHub
parent 78769010a1
commit 195f592640
20 changed files with 449 additions and 216 deletions

View File

@@ -16,7 +16,7 @@ import { AppFileSystem } from "@opencode-ai/core/filesystem"
import { RuntimeFlags } from "../../src/effect/runtime-flags"
import { ServerAuth } from "../../src/server/auth"
import { authorizationRouterMiddleware } from "../../src/server/routes/instance/httpapi/middleware/authorization"
import { ExperimentalHttpApiServer } from "../../src/server/routes/instance/httpapi/server"
import { HttpApiApp } from "../../src/server/routes/instance/httpapi/server"
import { serveEmbeddedUIEffect, serveUIEffect } from "../../src/server/shared/ui"
import { testEffect } from "../lib/effect"
@@ -54,7 +54,7 @@ function restoreEnv(key: string, value: string | undefined) {
function app(input?: { password?: string; username?: string }) {
const handler = HttpRouter.toWebHandler(
ExperimentalHttpApiServer.routes.pipe(
HttpApiApp.routes.pipe(
Layer.provide(
ConfigProvider.layer(
ConfigProvider.fromUnknown({
@@ -72,7 +72,7 @@ function app(input?: { password?: string; username?: string }) {
Promise.resolve(
handler(
input instanceof Request ? input : new Request(new URL(input, "http://localhost"), init),
ExperimentalHttpApiServer.context,
HttpApiApp.context,
),
),
)
@@ -119,7 +119,7 @@ function uiApp(input?: {
Promise.resolve(
handler(
input instanceof Request ? input : new Request(new URL(input, "http://localhost"), init),
ExperimentalHttpApiServer.context,
HttpApiApp.context,
),
),
)
@@ -161,7 +161,7 @@ function routeOrderingApp() {
Promise.resolve(
handler(
input instanceof Request ? input : new Request(new URL(input, "http://localhost"), init),
ExperimentalHttpApiServer.context,
HttpApiApp.context,
),
),
)
@@ -184,7 +184,7 @@ function responseText(response: Response) {
}
describe("HttpApi UI fallback", () => {
it.live("serves the web UI through the experimental backend", () =>
it.live("serves the web UI through the HTTP API app", () =>
Effect.gen(function* () {
let proxiedUrl: string | undefined