From 71cc624f59cb73dbe1609815515428d9362cc95b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Catriel=20M=C3=BCller?= Date: Thu, 11 Jun 2026 14:59:37 -0300 Subject: [PATCH] fix: fix test --- .../kilocode/server/config-overlay.test.ts | 52 ++++++------------- script/check-opencode-promise-facades.ts | 1 - 2 files changed, 16 insertions(+), 37 deletions(-) diff --git a/packages/opencode/test/kilocode/server/config-overlay.test.ts b/packages/opencode/test/kilocode/server/config-overlay.test.ts index ffda3e135a..a92aa17808 100644 --- a/packages/opencode/test/kilocode/server/config-overlay.test.ts +++ b/packages/opencode/test/kilocode/server/config-overlay.test.ts @@ -6,8 +6,6 @@ import { Server } from "../../../src/server/server" import { Config } from "../../../src/config/config" import { KilocodeConfigOverlay } from "../../../src/kilocode/config/overlay" import { Permission } from "../../../src/permission" -import { AppRuntime } from "../../../src/effect/app-runtime" -import { Effect } from "effect" import { resetDatabase } from "../../fixture/db" import { disposeAllInstances, tmpdir } from "../../fixture/fixture" @@ -27,7 +25,6 @@ type Agent = { afterEach(async () => { ;(Global.Path as { config: string }).config = original - await AppRuntime.runPromise(Config.Service.use((svc) => svc.invalidate())) await disposeAllInstances() await resetDatabase() }) @@ -65,12 +62,13 @@ async function config(dir: string, value: unknown) { await Bun.write(path.join(dir, "kilo.json"), JSON.stringify(value, null, 2)) } -async function invalidate() { - await AppRuntime.runPromise( - Effect.gen(function* () { - const svc = yield* Config.Service - yield* svc.invalidate() - yield* svc.getGlobal() +async function setGlobal(dir: string, value: Config.Info) { + ;(Global.Path as { config: string }).config = dir + await json( + await request(Server.Default().app, undefined, "/config/overlay", { + method: "PATCH", + headers: { "content-type": "application/json" }, + body: JSON.stringify({ scope: "global", set: value }), }), ) } @@ -94,13 +92,11 @@ describe("config overlay routes", () => { test.serial("marks global values inherited in project scope", async () => { await using global = await tmpdir() await using project = await tmpdir() - ;(Global.Path as { config: string }).config = global.path - await config(global.path, { + await setGlobal(global.path, { model: "kilo/global-model", permission: { bash: "ask" }, mcp: { shared: { type: "local", command: ["node", "shared.js"], enabled: true } }, }) - await invalidate() const body = await json(await req(project.path, "/config/overlay?scope=project")) @@ -118,15 +114,13 @@ describe("config overlay routes", () => { test.serial("marks global indexing values inherited in project scope", async () => { await using global = await tmpdir() await using project = await tmpdir() - ;(Global.Path as { config: string }).config = global.path - await config(global.path, { + await setGlobal(global.path, { indexing: { enabled: true, provider: "ollama", ollama: { baseUrl: "http://localhost:11434" }, }, }) - await invalidate() const body = await json(await req(project.path, "/config/overlay?scope=project")) @@ -175,9 +169,7 @@ describe("config overlay routes", () => { test.serial("writes project indexing overrides to .kilo/kilo.jsonc", async () => { await using global = await tmpdir() await using project = await tmpdir() - ;(Global.Path as { config: string }).config = global.path - await config(global.path, { indexing: { enabled: true, provider: "openai" } }) - await invalidate() + await setGlobal(global.path, { indexing: { enabled: true, provider: "openai" } }) await json( await req(project.path, "/config/overlay", { @@ -207,9 +199,7 @@ describe("config overlay routes", () => { test.serial("removes local scalar override and falls back to global", async () => { await using global = await tmpdir() await using project = await tmpdir({ config: { model: "kilo/project-model", username: "alice" } }) - ;(Global.Path as { config: string }).config = global.path - await config(global.path, { model: "kilo/global-model" }) - await invalidate() + await setGlobal(global.path, { model: "kilo/global-model" }) await json( await req(project.path, "/config/overlay", { @@ -229,11 +219,9 @@ describe("config overlay routes", () => { test.serial("writes project mcp overrides without copying inherited servers", async () => { await using global = await tmpdir() await using project = await tmpdir() - ;(Global.Path as { config: string }).config = global.path - await config(global.path, { + await setGlobal(global.path, { mcp: { shared: { type: "local", command: ["node", "shared.js"], enabled: true } }, }) - await invalidate() await json( await req(project.path, "/config/overlay", { @@ -255,11 +243,9 @@ describe("config overlay routes", () => { test.serial("disables inherited mcp server with a minimal local override", async () => { await using global = await tmpdir() await using project = await tmpdir() - ;(Global.Path as { config: string }).config = global.path - await config(global.path, { + await setGlobal(global.path, { mcp: { shared: { type: "local", command: ["node", "shared.js"], enabled: true } }, }) - await invalidate() await json( await req(project.path, "/config/overlay", { @@ -278,9 +264,7 @@ describe("config overlay routes", () => { test.serial("refreshes effective config after project permission update", async () => { await using global = await tmpdir() await using project = await tmpdir() - ;(Global.Path as { config: string }).config = global.path - await config(global.path, { permission: { edit: "allow" } }) - await invalidate() + await setGlobal(global.path, { permission: { edit: "allow" } }) const before = await json(await req(project.path, "/agent")) expect(Permission.evaluate("edit", "*", before.find((item) => item.name === "code")?.permission ?? []).action).toBe( @@ -313,9 +297,7 @@ describe("config overlay routes", () => { test.serial("refreshes agent permissions after global permission update", async () => { await using global = await tmpdir() await using project = await tmpdir() - ;(Global.Path as { config: string }).config = global.path - await config(global.path, { permission: { edit: "allow" } }) - await invalidate() + await setGlobal(global.path, { permission: { edit: "allow" } }) const before = await json(await req(project.path, "/agent")) expect(Permission.evaluate("edit", "*", before.find((item) => item.name === "code")?.permission ?? []).action).toBe( @@ -347,9 +329,7 @@ describe("config overlay routes", () => { async () => { await using global = await tmpdir() await using project = await tmpdir() - ;(Global.Path as { config: string }).config = global.path - await config(global.path, { permission: { edit: "ask" } }) - await invalidate() + await setGlobal(global.path, { permission: { edit: "ask" } }) await disposeAllInstances() const target = app(value) diff --git a/script/check-opencode-promise-facades.ts b/script/check-opencode-promise-facades.ts index 01d5f29460..009bf05c2f 100644 --- a/script/check-opencode-promise-facades.ts +++ b/script/check-opencode-promise-facades.ts @@ -34,7 +34,6 @@ const testAllow: Record = { "kilocode/config-resilience.test.ts": { count: 4, reason: "existing runtime integration test" }, "kilocode/config-validation.test.ts": { count: 2, reason: "existing runtime integration test" }, "kilocode/plan-followup.test.ts": { count: 4, reason: "existing runtime integration test" }, - "kilocode/server/config-overlay.test.ts": { count: 3, reason: "server config cache integration test" }, "kilocode/session/platform-attribution.test.ts": { count: 5, reason: "existing runtime integration test" }, "kilocode/session-prompt-queue.test.ts": { count: 5, reason: "prompt queue legacy instance bridge regression" }, "kilocode/session/session.test.ts": { count: 5, reason: "existing runtime integration test" },