From a4c8d0588eec7c7b8d33051660941e227e21b88a Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Tue, 14 Apr 2026 15:30:28 -0400 Subject: [PATCH] refactor(question): use effectful HttpApi group builder Build the question HttpApi handlers with an effectful group callback so the service is resolved once at layer construction time and the endpoint handlers close over the resulting service methods. --- packages/opencode/src/server/instance/httpapi/question.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/opencode/src/server/instance/httpapi/question.ts b/packages/opencode/src/server/instance/httpapi/question.ts index a34100451c..c694d321df 100644 --- a/packages/opencode/src/server/instance/httpapi/question.ts +++ b/packages/opencode/src/server/instance/httpapi/question.ts @@ -50,8 +50,10 @@ const Api = HttpApi.make("question") }), ) -const QuestionLive = Layer.unwrap( - Effect.gen(function* () { +const QuestionLive = HttpApiBuilder.group( + Api, + "question", + Effect.fn("QuestionHttpApi.handlers")(function* (handlers) { const svc = yield* Question.Service const list = Effect.fn("QuestionHttpApi.list")(function* () { @@ -69,7 +71,7 @@ const QuestionLive = Layer.unwrap( return true }) - return HttpApiBuilder.group(Api, "question", (handlers) => handlers.handle("list", list).handle("reply", reply)) + return handlers.handle("list", list).handle("reply", reply) }), ).pipe(Layer.provide(Question.defaultLayer))