From b15f1593c07e55d220ac0e7476bba3878acac8a0 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Sat, 4 Apr 2026 11:52:29 -0400 Subject: [PATCH] refactor(effect): scope read tool warmup Capture Scope.Scope in the read tool effect and fork LSP warmup into that scope instead of using runFork inside Effect.sync. This keeps the fire-and-forget behavior while matching the surrounding Effect patterns. --- packages/opencode/src/tool/read.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/opencode/src/tool/read.ts b/packages/opencode/src/tool/read.ts index 0118c389df..a6cb725bea 100644 --- a/packages/opencode/src/tool/read.ts +++ b/packages/opencode/src/tool/read.ts @@ -1,5 +1,5 @@ import z from "zod" -import { Effect } from "effect" +import { Effect, Scope } from "effect" import { createReadStream } from "fs" import { open } from "fs/promises" import * as path from "path" @@ -32,6 +32,7 @@ export const ReadTool = Tool.defineEffect( const instruction = yield* Instruction.Service const lsp = yield* LSP.Service const time = yield* FileTime.Service + const scope = yield* Scope.Scope const miss = Effect.fn("ReadTool.miss")(function* (filepath: string) { const dir = path.dirname(filepath) @@ -77,9 +78,7 @@ export const ReadTool = Tool.defineEffect( }) const warm = Effect.fn("ReadTool.warm")(function* (filepath: string, sessionID: Tool.Context["sessionID"]) { - yield* Effect.sync(() => { - void Effect.runFork(lsp.touchFile(filepath, false)) - }) + yield* lsp.touchFile(filepath, false).pipe(Effect.ignore, Effect.forkIn(scope)) yield* time.read(sessionID, filepath) })