From 5cf6f7f3e4d6f21b80c30d59c0776f3ebe294c49 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sun, 5 Apr 2026 17:46:12 -0700 Subject: [PATCH] Run git status refresh in server background scope Co-authored-by: codex --- apps/server/src/ws.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/server/src/ws.ts b/apps/server/src/ws.ts index c8e52bb719..5bd18b2f24 100644 --- a/apps/server/src/ws.ts +++ b/apps/server/src/ws.ts @@ -1,4 +1,4 @@ -import { Cause, Effect, Layer, Option, Queue, Ref, Schema, Stream } from "effect"; +import { Cause, Effect, Exit, Layer, Option, Queue, Ref, Schema, Scope, Stream } from "effect"; import { CommandId, EventId, @@ -67,8 +67,9 @@ const WsRpcLayer = WsRpcGroup.toLayer( const workspaceEntries = yield* WorkspaceEntries; const workspaceFileSystem = yield* WorkspaceFileSystem; const projectSetupScriptRunner = yield* ProjectSetupScriptRunner; - const services = yield* Effect.services(); - const runPromise = Effect.runPromiseWith(services); + const wsBackgroundScope = yield* Effect.acquireRelease(Scope.make(), (scope) => + Scope.close(scope, Exit.void), + ); const serverCommandId = (tag: string) => CommandId.makeUnsafe(`server:${tag}:${crypto.randomUUID()}`); @@ -353,11 +354,9 @@ const WsRpcLayer = WsRpcGroup.toLayer( }); const refreshGitStatus = (cwd: string) => - Effect.sync(() => { - setTimeout(() => { - void runPromise(gitStatusBroadcaster.enqueueRefreshStatus(cwd)); - }, 0); - }); + gitStatusBroadcaster + .enqueueRefreshStatus(cwd) + .pipe(Effect.ignoreCause({ log: true }), Effect.forkIn(wsBackgroundScope), Effect.asVoid); return WsRpcGroup.of({ [ORCHESTRATION_WS_METHODS.getSnapshot]: (_input) =>