refactor(core): consolidate filesystem services (#30447)

This commit is contained in:
Dax
2026-06-02 16:09:26 -04:00
committed by GitHub
parent b93963e462
commit 604a5f781f
153 changed files with 2553 additions and 4312 deletions

View File

@@ -12,7 +12,7 @@ import {
HttpServerRequest,
HttpServerResponse,
} from "effect/unstable/http"
import { AppFileSystem } from "@opencode-ai/core/filesystem"
import { FSUtil } from "@opencode-ai/core/fs-util"
import { RuntimeFlags } from "../../src/effect/runtime-flags"
import { ServerAuth } from "../../src/server/auth"
import { authorizationRouterMiddleware } from "../../src/server/routes/instance/httpapi/middleware/authorization"
@@ -42,7 +42,7 @@ const testStateLayer = Layer.effectDiscard(
}),
)
const it = testEffect(Layer.mergeAll(testStateLayer, AppFileSystem.defaultLayer, RuntimeFlags.layer()))
const it = testEffect(Layer.mergeAll(testStateLayer, FSUtil.defaultLayer, RuntimeFlags.layer()))
function restoreEnv(key: string, value: string | undefined) {
if (value === undefined) {
@@ -89,7 +89,7 @@ function uiApp(input?: {
const handler = HttpRouter.toWebHandler(
HttpRouter.use((router) =>
Effect.gen(function* () {
const fs = yield* AppFileSystem.Service
const fs = yield* FSUtil.Service
const client = yield* HttpClient.HttpClient
const flags = yield* RuntimeFlags.Service
yield* router.add("*", "/*", (request) =>
@@ -99,7 +99,7 @@ function uiApp(input?: {
).pipe(
Layer.provide(authorizationRouterMiddleware.layer.pipe(Layer.provide(ServerAuth.Config.defaultLayer))),
Layer.provide([
AppFileSystem.defaultLayer,
FSUtil.defaultLayer,
input?.client ?? httpClient(new Response("ui")),
RuntimeFlags.layer({ disableEmbeddedWebUi: input?.disableEmbeddedWebUi ?? false }),
HttpServer.layerServices,
@@ -132,7 +132,7 @@ function routeOrderingApp() {
const handler = HttpRouter.toWebHandler(
HttpRouter.use((router) =>
Effect.gen(function* () {
const fs = yield* AppFileSystem.Service
const fs = yield* FSUtil.Service
const client = yield* HttpClient.HttpClient
const flags = yield* RuntimeFlags.Service
yield* router.add("GET", "/session/:sessionID", () =>
@@ -144,7 +144,7 @@ function routeOrderingApp() {
}),
).pipe(
Layer.provide([
AppFileSystem.defaultLayer,
FSUtil.defaultLayer,
RuntimeFlags.layer({ disableEmbeddedWebUi: true }),
httpClient(new Response("ui"), (request) => {
proxiedUrl = request.url
@@ -210,7 +210,7 @@ describe("HttpApi UI fallback", () => {
let proxiedUrl: string | undefined
const response = yield* Effect.gen(function* () {
const fs = yield* AppFileSystem.Service
const fs = yield* FSUtil.Service
const client = yield* HttpClient.HttpClient
const flags = yield* RuntimeFlags.Service
return yield* serveUIEffect(HttpServerRequest.fromWeb(new Request("http://localhost/assets/app.js")), {
@@ -260,7 +260,7 @@ describe("HttpApi UI fallback", () => {
it.live("strips upstream transfer-encoding header from proxied assets", () =>
Effect.gen(function* () {
const response = yield* Effect.gen(function* () {
const fs = yield* AppFileSystem.Service
const fs = yield* FSUtil.Service
const client = yield* HttpClient.HttpClient
const flags = yield* RuntimeFlags.Service
return yield* serveUIEffect(HttpServerRequest.fromWeb(new Request("http://localhost/")), {
@@ -303,7 +303,7 @@ describe("HttpApi UI fallback", () => {
Effect.gen(function* () {
let readPath: string | undefined
const fs = yield* AppFileSystem.Service
const fs = yield* FSUtil.Service
const response = yield* serveEmbeddedUIEffect(
"/assets/app.js",
{
@@ -330,7 +330,7 @@ describe("HttpApi UI fallback", () => {
Effect.gen(function* () {
const script = 'document.documentElement.dataset.theme = "dark"'
const fs = yield* AppFileSystem.Service
const fs = yield* FSUtil.Service
const response = yield* serveEmbeddedUIEffect(
"/",
{