From bb4a71d9d4848ece96448a43d969dadd9e2d61da Mon Sep 17 00:00:00 2001 From: Rakshith N Date: Sun, 12 Jul 2026 00:39:15 +0530 Subject: [PATCH] fix(cli): skip indexing model validation when disabled A disabled Kilo indexing config with an invalid explicit model previously threw IndexingModelError and surfaced an Error status, bypassing the disabled branch. Guard the throw with input.enabled so disabled configs are reported as Disabled as before. --- packages/opencode/src/kilocode/indexing.ts | 2 +- .../test/kilocode/indexing-startup.test.ts | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/kilocode/indexing.ts b/packages/opencode/src/kilocode/indexing.ts index b6ae9103c43..3d145a2e8ed 100644 --- a/packages/opencode/src/kilocode/indexing.ts +++ b/packages/opencode/src/kilocode/indexing.ts @@ -101,7 +101,7 @@ async function model(input: ReturnType, auth: Kilo if (input.modelId) { const id = catalog.aliases[input.modelId] ?? input.modelId const chosen = catalog.models.find((item) => item.id === id) - if (catalog.models.length > 0 && !chosen) { + if (catalog.models.length > 0 && !chosen && input.enabled !== false) { throw new IndexingModelError({ model: input.modelId }) } if (chosen) { diff --git a/packages/opencode/test/kilocode/indexing-startup.test.ts b/packages/opencode/test/kilocode/indexing-startup.test.ts index ffa1f1f06e6..0e457848348 100644 --- a/packages/opencode/test/kilocode/indexing-startup.test.ts +++ b/packages/opencode/test/kilocode/indexing-startup.test.ts @@ -525,6 +525,49 @@ describe("indexing startup degradation", () => { }) }) + test("does not validate the indexing model when indexing is disabled", async () => { + global.fetch = (() => + Promise.resolve( + new Response( + JSON.stringify({ + defaultModel: "mistralai/mistral-embed-2312", + models: [ + { id: "mistralai/mistral-embed-2312", name: "Mistral Embed 2312", dimension: 1024, scoreThreshold: 0.35 }, + ], + aliases: {}, + }), + ), + )) as unknown as typeof global.fetch + const logger = Log.create({ service: "kilocode-indexing" }) + const warn = spyOn(logger, "warn") + const key = process.env.KILO_API_KEY + + const config: Partial = { + ...staleKilo, + indexing: { ...staleKilo.indexing, enabled: false, model: "removed/model" }, + } + await using tmp = await tmpdir({ git: true, config }) + process.env["KILO_CONFIG_DIR"] = tmp.path + process.env.KILO_API_KEY = "kilo-token" + + try { + await provideTestInstance({ + directory: tmp.path, + init: Effect.promise(() => KiloIndexing.init()), + fn: async () => { + const status = await wait(() => KiloIndexing.current(), "Disabled") + expect(status.state).toBe("Disabled") + const modelErr = warn.mock.calls.find((call) => IndexingModelError.isInstance(call[1]?.err))?.[1]?.err + expect(modelErr).toBeUndefined() + }, + }) + } finally { + if (key === undefined) delete process.env.KILO_API_KEY + else process.env.KILO_API_KEY = key + warn.mockRestore() + } + }) + test("does not allocate an engine when indexing configuration is disabled", async () => { const created: string[] = [] IndexingWorker.override((directory, root, hooks) => {