diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts index ce0fa48205..be8c521521 100644 --- a/packages/opencode/src/config/config.ts +++ b/packages/opencode/src/config/config.ts @@ -20,7 +20,7 @@ import { parse as parseJsonc, printParseErrorCode, } from "jsonc-parser" -import { Instance, type Info as InstanceInfo } from "../project/instance" +import { Instance, type InstanceContext } from "../project/instance" import { LSPServer } from "../lsp/server" import { BunProc } from "@/bun" import { Installation } from "@/installation" @@ -78,7 +78,7 @@ export namespace Config { return merged } - async function loadState(ctx: InstanceInfo) { + async function loadState(ctx: InstanceContext) { const auth = await Auth.all() // Config loading order (low -> high precedence): https://opencode.ai/docs/config#precedence-order @@ -157,8 +157,8 @@ export namespace Config { deps.push( iife(async () => { - const ok = await needsInstall(dir) - if (ok) await installDependencies(dir) + const shouldInstall = await needsInstall(dir) + if (shouldInstall) await installDependencies(dir) }), ) @@ -1474,21 +1474,19 @@ export namespace Config { }) } - function disposed() { - GlobalBus.emit("event", { - directory: "global", - payload: { - type: Event.Disposed.type, - properties: {}, - }, - }) - } - export async function invalidate(wait = false) { resetGlobal() const task = Instance.disposeAll() .catch(() => undefined) - .finally(disposed) + .finally(() => + GlobalBus.emit("event", { + directory: "global", + payload: { + type: Event.Disposed.type, + properties: {}, + }, + }), + ) if (wait) return task void task } diff --git a/packages/opencode/src/effect/instance-state.ts b/packages/opencode/src/effect/instance-state.ts index 88b3b97f88..6873ec255c 100644 --- a/packages/opencode/src/effect/instance-state.ts +++ b/packages/opencode/src/effect/instance-state.ts @@ -1,5 +1,5 @@ import { Effect, ScopedCache, Scope } from "effect" -import { Instance, type Info as InstanceInfo } from "@/project/instance" +import { Instance, type InstanceContext } from "@/project/instance" import { registerDisposer } from "./instance-registry" const TypeId = "~opencode/InstanceState" @@ -11,7 +11,7 @@ export interface InstanceState { export namespace InstanceState { export const make = ( - init: (ctx: InstanceInfo) => Effect.Effect, + init: (ctx: InstanceContext) => Effect.Effect, ): Effect.Effect>, never, R | Scope.Scope> => Effect.gen(function* () { const cache = yield* ScopedCache.make({ diff --git a/packages/opencode/src/project/instance.ts b/packages/opencode/src/project/instance.ts index eeac40d6ea..5dddfe627f 100644 --- a/packages/opencode/src/project/instance.ts +++ b/packages/opencode/src/project/instance.ts @@ -7,14 +7,14 @@ import { Context } from "../util/context" import { Project } from "./project" import { State } from "./state" -export interface Info { +export interface InstanceContext { directory: string worktree: string project: Project.Info } -const context = Context.create("instance") -const cache = new Map>() +const context = Context.create("instance") +const cache = new Map>() const disposal = { all: undefined as Promise | undefined, @@ -53,7 +53,7 @@ function boot(input: { directory: string; init?: () => Promise; project?: P }) } -function track(directory: string, next: Promise) { +function track(directory: string, next: Promise) { const task = next.catch((error) => { if (cache.get(directory) === task) cache.delete(directory) throw error