From 0a53f8e084d0cdf576b21c2c44c3c0c000c7bf85 Mon Sep 17 00:00:00 2001 From: Adam <2363879+adamdotdevin@users.noreply.github.com> Date: Wed, 11 Mar 2026 13:56:16 -0500 Subject: [PATCH] chore: cleanup --- packages/opencode/src/file/watcher.ts | 13 +++++-------- packages/opencode/src/lsp/client.ts | 3 +-- packages/opencode/src/project/instance.ts | 7 ------- packages/opencode/src/pty/index.ts | 13 +++++-------- 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/packages/opencode/src/file/watcher.ts b/packages/opencode/src/file/watcher.ts index 3bb478e1c9..3797c16270 100644 --- a/packages/opencode/src/file/watcher.ts +++ b/packages/opencode/src/file/watcher.ts @@ -48,7 +48,6 @@ export namespace FileWatcher { const state = Instance.state( async () => { log.info("init") - const dir = Instance.directory const cfg = await Config.get() const backend = (() => { if (process.platform === "win32") return "windows" @@ -66,13 +65,11 @@ export namespace FileWatcher { const subscribe: ParcelWatcher.SubscribeCallback = (err, evts) => { if (err) return - void Instance.run(dir, () => { - for (const evt of evts) { - if (evt.type === "create") Bus.publish(Event.Updated, { file: evt.path, event: "add" }) - if (evt.type === "update") Bus.publish(Event.Updated, { file: evt.path, event: "change" }) - if (evt.type === "delete") Bus.publish(Event.Updated, { file: evt.path, event: "unlink" }) - } - }) + for (const evt of evts) { + if (evt.type === "create") Bus.publish(Event.Updated, { file: evt.path, event: "add" }) + if (evt.type === "update") Bus.publish(Event.Updated, { file: evt.path, event: "change" }) + if (evt.type === "delete") Bus.publish(Event.Updated, { file: evt.path, event: "unlink" }) + } } const subs: ParcelWatcher.AsyncSubscription[] = [] diff --git a/packages/opencode/src/lsp/client.ts b/packages/opencode/src/lsp/client.ts index 21364627b3..084ccf831e 100644 --- a/packages/opencode/src/lsp/client.ts +++ b/packages/opencode/src/lsp/client.ts @@ -41,7 +41,6 @@ export namespace LSPClient { export async function create(input: { serverID: string; server: LSPServer.Handle; root: string }) { const l = log.clone().tag("serverID", input.serverID) - const dir = Instance.directory l.info("starting client") const connection = createMessageConnection( @@ -59,7 +58,7 @@ export namespace LSPClient { const exists = diagnostics.has(filePath) diagnostics.set(filePath, params.diagnostics) if (!exists && input.serverID === "typescript") return - void Instance.run(dir, () => Bus.publish(Event.Diagnostics, { path: filePath, serverID: input.serverID })) + Bus.publish(Event.Diagnostics, { path: filePath, serverID: input.serverID }) }) connection.onRequest("window/workDoneProgress/create", (params) => { l.info("window/workDoneProgress/create", params) diff --git a/packages/opencode/src/project/instance.ts b/packages/opencode/src/project/instance.ts index 56dc4a44a5..df44a3a229 100644 --- a/packages/opencode/src/project/instance.ts +++ b/packages/opencode/src/project/instance.ts @@ -79,13 +79,6 @@ export const Instance = { return input.fn() }) }, - async run(directory: string, fn: () => R): Promise { - const existing = cache.get(Filesystem.resolve(directory)) - if (!existing) return - const ctx = await existing.catch(() => undefined) - if (!ctx) return - return context.provide(ctx, fn) - }, get directory() { return context.use().directory }, diff --git a/packages/opencode/src/pty/index.ts b/packages/opencode/src/pty/index.ts index 4096ee5c4a..7014cb6f0c 100644 --- a/packages/opencode/src/pty/index.ts +++ b/packages/opencode/src/pty/index.ts @@ -118,7 +118,6 @@ export namespace Pty { export async function create(input: CreateInput) { const id = Identifier.create("pty", false) - const dir = Instance.directory const command = input.command || Shell.preferred() const args = input.args || [] if (command.endsWith("sh")) { @@ -195,13 +194,11 @@ export namespace Pty { session.bufferCursor += excess }) ptyProcess.onExit(({ exitCode }) => { - void Instance.run(dir, () => { - if (session.info.status === "exited") return - log.info("session exited", { id, exitCode }) - session.info.status = "exited" - Bus.publish(Event.Exited, { id, exitCode }) - remove(id) - }) + if (session.info.status === "exited") return + log.info("session exited", { id, exitCode }) + session.info.status = "exited" + Bus.publish(Event.Exited, { id, exitCode }) + remove(id) }) Bus.publish(Event.Created, { info }) return info