fix(plugin): reuse active server for client requests

Temporarily route plugin SDK calls through the active listener so they reuse its instance store instead of initializing plugins again through the default app. Keep the in-process fallback for commands without a listener. This is intentionally a narrow bridge until v2 owns plugin clients in the correct shared server runtime.
This commit is contained in:
Dax Raad
2026-06-14 13:28:48 -04:00
parent 3f81402663
commit 87c33b3d85
3 changed files with 70 additions and 8 deletions
+3 -2
View File
@@ -138,11 +138,12 @@ export const layer = Layer.effect(
const { Server } = yield* Effect.promise(() => import("../server/server"))
const serverUrl = Server.url
const client = createOpencodeClient({
baseUrl: "http://localhost:4096",
baseUrl: serverUrl?.toString() ?? "http://localhost:4096",
directory: ctx.directory,
headers: ServerAuth.headers(),
fetch: async (...args) => Server.Default().app.fetch(...args),
...(serverUrl ? {} : { fetch: async (...args) => Server.Default().app.fetch(...args) }),
})
const cfg = yield* config.get()
const input: PluginInput = {