diff --git a/packages/kilo-indexing/src/indexing/manager.ts b/packages/kilo-indexing/src/indexing/manager.ts index 132db65b8ee..77b5797787d 100644 --- a/packages/kilo-indexing/src/indexing/manager.ts +++ b/packages/kilo-indexing/src/indexing/manager.ts @@ -461,6 +461,7 @@ export class CodeIndexManager { baselinePath, }) await this._recreateServices() + if (this._disposed) return await this._orchestrator?.startIndexing("background") })().finally(() => { this._baselineRefresh = undefined @@ -483,6 +484,7 @@ export class CodeIndexManager { const store = factory.createVectorStore(this.baselinePath) if (!store.openExisting) throw new Error("The configured vector store cannot open a shared baseline") + // Validate compatibility without keeping every worktree baseline connection open. await store.openExisting() await store.close?.() diff --git a/packages/opencode/src/kilocode/indexing-worker.ts b/packages/opencode/src/kilocode/indexing-worker.ts index 1121c4a48ed..bfbca31e99f 100644 --- a/packages/opencode/src/kilocode/indexing-worker.ts +++ b/packages/opencode/src/kilocode/indexing-worker.ts @@ -94,7 +94,10 @@ onmessage = (event: MessageEvent) => { context.run(request.key, () => { if (request.method !== "init") return handle(request) const next = initQueue.then(() => handle(request)) - initQueue = next + initQueue = next.then( + () => undefined, + () => undefined, + ) return next }), ) diff --git a/packages/opencode/src/kilocode/tool/registry.ts b/packages/opencode/src/kilocode/tool/registry.ts index 492074f4ed1..a404c8ba60a 100644 --- a/packages/opencode/src/kilocode/tool/registry.ts +++ b/packages/opencode/src/kilocode/tool/registry.ts @@ -9,7 +9,6 @@ import { Effect } from "effect" import * as Log from "@opencode-ai/core/util/log" import { Agent } from "@/agent/agent" import * as Truncate from "@/tool/truncate" -import { Instance } from "@/project/instance" import type { Config } from "@/config/config" const log = Log.create({ service: "kilocode-tool-registry" }) @@ -66,8 +65,7 @@ export namespace KiloToolRegistry { const ready = yield* (deps.indexing === undefined ? (() => { const indexing = loaders.indexing ?? (() => import("@/kilocode/indexing")) - const check = Instance.bind((mod: Awaited>) => mod.KiloIndexing.ready()) - return Effect.tryPromise(() => indexing().then(check)).pipe( + return Effect.tryPromise(() => indexing().then((mod) => mod.KiloIndexing.ready())).pipe( Effect.catch((err) => Effect.sync(() => { log.warn("semantic search unavailable", { err }) diff --git a/packages/opencode/src/tool/registry.ts b/packages/opencode/src/tool/registry.ts index f2bdba5aad4..c16b3f9839e 100644 --- a/packages/opencode/src/tool/registry.ts +++ b/packages/opencode/src/tool/registry.ts @@ -263,7 +263,7 @@ export const layer: Layer.Layer< const kilo = yield* KiloToolRegistry.build(kiloToolInfos, { agent: agents, truncate, - ...(indexing === undefined ? {} : { indexing }), + indexing: indexing ?? false, }) // kilocode_change end diff --git a/packages/opencode/test/kilocode/indexing-worktree.test.ts b/packages/opencode/test/kilocode/indexing-worktree.test.ts index 8c7daa2f9a5..234ef1724ce 100644 --- a/packages/opencode/test/kilocode/indexing-worktree.test.ts +++ b/packages/opencode/test/kilocode/indexing-worktree.test.ts @@ -57,13 +57,14 @@ describe("indexing worktrees", () => { await WithInstance.provide({ directory: worktree, fn: async () => { + await KiloIndexing.search("worktree") expect((await KiloIndexing.current()).state).toBe("Complete") expect(await KiloIndexing.available()).toBe(true) }, }) expect(calls).toEqual([{ directory: worktree, baseline: tmp.path }]) - }) + }, 15_000) test("does not classify an ordinary directory from its pathname", async () => { await using tmp = await tmpdir({ git: true, config: cfg })