From de7f50ec6ba3176ce3553dd869a1976d3c39b6aa Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 3 Mar 2026 00:07:04 +0000 Subject: [PATCH] fix: use forkDetach for background upstream refresh to prevent scope interruption Effect.forkScoped ties the background fiber's lifetime to the enclosing scope. When wsServer wraps checkoutBranch in Effect.scoped, the scope closes immediately after checkout completes, interrupting the background git fetch. Switch to Effect.forkDetach so the background refresh runs independently, remove the now-unnecessary Scope.Scope requirement from checkoutBranch, and drop Effect.scoped from the WebSocket handler. Co-authored-by: Julius Marminge --- apps/server/src/git/Layers/GitCore.ts | 2 +- apps/server/src/git/Services/GitCore.ts | 4 ++-- apps/server/src/wsServer.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/server/src/git/Layers/GitCore.ts b/apps/server/src/git/Layers/GitCore.ts index f62f9dc9f0..54ae474a9b 100644 --- a/apps/server/src/git/Layers/GitCore.ts +++ b/apps/server/src/git/Layers/GitCore.ts @@ -1161,7 +1161,7 @@ const makeGitCore = Effect.gen(function* () { }); // Refresh upstream refs in the background so checkout remains responsive. - yield* Effect.forkScoped( + yield* Effect.forkDetach( refreshCheckedOutBranchUpstream(input.cwd).pipe(Effect.catch(() => Effect.void)), ); }); diff --git a/apps/server/src/git/Services/GitCore.ts b/apps/server/src/git/Services/GitCore.ts index 399dee8f7b..b392f3856d 100644 --- a/apps/server/src/git/Services/GitCore.ts +++ b/apps/server/src/git/Services/GitCore.ts @@ -7,7 +7,7 @@ * @module GitCore */ import { ServiceMap } from "effect"; -import type { Effect, Scope } from "effect"; +import type { Effect } from "effect"; import type { GitCheckoutInput, GitCreateBranchInput, @@ -151,7 +151,7 @@ export interface GitCoreShape { */ readonly checkoutBranch: ( input: GitCheckoutInput, - ) => Effect.Effect; + ) => Effect.Effect; /** * Initialize a repository in the provided directory. diff --git a/apps/server/src/wsServer.ts b/apps/server/src/wsServer.ts index 3f2c5734d2..e5624cf6a7 100644 --- a/apps/server/src/wsServer.ts +++ b/apps/server/src/wsServer.ts @@ -689,7 +689,7 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return< case WS_METHODS.gitCheckout: { const body = stripRequestTag(request.body); - return yield* Effect.scoped(git.checkoutBranch(body)); + return yield* git.checkoutBranch(body); } case WS_METHODS.gitInit: {