fix(cli): stabilize shared worktree indexing

This commit is contained in:
marius-kilocode
2026-06-12 20:28:01 +02:00
parent 973d02cfd1
commit 6e915601b2
5 changed files with 10 additions and 6 deletions
@@ -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?.()
@@ -94,7 +94,10 @@ onmessage = (event: MessageEvent<Request>) => {
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
}),
)
@@ -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<ReturnType<typeof indexing>>) => 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 })
+1 -1
View File
@@ -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
@@ -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 })