From c64dd9319345bbe22f82c7ee2892132cbf845809 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Fri, 27 Jun 2025 17:44:49 +0530 Subject: [PATCH 01/23] add new `indexTypes` for context indexing --- core/context/providers/CodeContextProvider.ts | 2 +- .../providers/CodebaseContextProvider.ts | 1 + .../providers/FolderContextProvider.ts | 2 +- core/index.d.ts | 7 ++- core/indexing/CodebaseIndexer.ts | 58 +++++++++++++------ core/protocol/webview.ts | 2 +- gui/src/context/SubmenuContextProviders.tsx | 17 +++--- 7 files changed, 58 insertions(+), 31 deletions(-) diff --git a/core/context/providers/CodeContextProvider.ts b/core/context/providers/CodeContextProvider.ts index b746199b0..0a3c361a3 100644 --- a/core/context/providers/CodeContextProvider.ts +++ b/core/context/providers/CodeContextProvider.ts @@ -16,7 +16,7 @@ class CodeContextProvider extends BaseContextProvider { displayTitle: "Code", description: "Type to search", type: "submenu", - dependsOnIndexing: true, + indexTypes: ["chunk", "codeSnippets"], }; async getContextItems( diff --git a/core/context/providers/CodebaseContextProvider.ts b/core/context/providers/CodebaseContextProvider.ts index 51881f457..682a65a1f 100644 --- a/core/context/providers/CodebaseContextProvider.ts +++ b/core/context/providers/CodebaseContextProvider.ts @@ -13,6 +13,7 @@ class CodebaseContextProvider extends BaseContextProvider { description: "Automatically find relevant files", type: "normal", renderInlineAs: "", + indexTypes: ["embeddings", "fullTextSearch", "chunk"], }; async getContextItems( diff --git a/core/context/providers/FolderContextProvider.ts b/core/context/providers/FolderContextProvider.ts index b4d2e0e09..981ca8579 100644 --- a/core/context/providers/FolderContextProvider.ts +++ b/core/context/providers/FolderContextProvider.ts @@ -19,7 +19,7 @@ class FolderContextProvider extends BaseContextProvider { displayTitle: "Folder", description: "Type to search", type: "submenu", - dependsOnIndexing: true, + indexTypes: ["embeddings"], }; async getContextItems( diff --git a/core/index.d.ts b/core/index.d.ts index 4aea44fd4..68cf3aba6 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -165,6 +165,11 @@ export interface ModelInstaller { } export type ContextProviderType = "normal" | "query" | "submenu"; +export type ContextIndexingType = + | "chunk" + | "embeddings" + | "fullTextSearch" + | "codeSnippets"; export interface ContextProviderDescription { title: ContextProviderName; @@ -172,7 +177,7 @@ export interface ContextProviderDescription { description: string; renderInlineAs?: string; type: ContextProviderType; - dependsOnIndexing?: boolean; + indexTypes?: ContextIndexingType[]; } export type FetchFunction = (url: string | URL, init?: any) => Promise; diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index d2de0c512..880284e46 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -1,7 +1,12 @@ import * as fs from "fs/promises"; import { ConfigHandler } from "../config/ConfigHandler.js"; -import { IDE, IndexingProgressUpdate, IndexTag } from "../index.js"; +import { + ContextIndexingType, + IDE, + IndexingProgressUpdate, + IndexTag, +} from "../index.js"; import type { FromCoreProtocol, ToCoreProtocol } from "../protocol"; import type { IMessenger } from "../protocol/messenger"; import { extractMinimalStackTraceInfo } from "../util/extractMinimalStackTraceInfo.js"; @@ -123,28 +128,43 @@ export class CodebaseIndexer { return []; } - const indexes: CodebaseIndex[] = [ - new ChunkCodebaseIndex( - this.ide.readFile.bind(this.ide), - continueServerClient, - embeddingsModel.maxEmbeddingChunkSize, - ), // Chunking must come first - ]; - - const lanceDbIndex = await LanceDbIndex.create( - embeddingsModel, - this.ide.readFile.bind(this.ide), + const indexTypesToBuild = new Set( // use set to remove duplicates + config.contextProviders + .map((provider) => provider.description.indexTypes) + .filter((indexType) => Array.isArray(indexType)) // remove undefined indexTypes + .flat(), ); - if (lanceDbIndex) { - indexes.push(lanceDbIndex); + const indexTypeToIndexerMapping: Record< + ContextIndexingType, + () => Promise + > = { + chunk: async () => + new ChunkCodebaseIndex( + this.ide.readFile.bind(this.ide), + continueServerClient, + embeddingsModel.maxEmbeddingChunkSize, + ), + codeSnippets: async () => new CodeSnippetsCodebaseIndex(this.ide), + fullTextSearch: async () => new FullTextSearchCodebaseIndex(), + embeddings: async () => { + const lanceDbIndex = await LanceDbIndex.create( + embeddingsModel, + this.ide.readFile.bind(this.ide), + ); + return lanceDbIndex; + }, + }; + + const indexes: CodebaseIndex[] = []; + // not parallelizing to avoid race conditions in sqlite + for (const indexType of indexTypesToBuild) { + const index = await indexTypeToIndexerMapping[indexType](); + if (index) { + indexes.push(index); + } } - indexes.push( - new FullTextSearchCodebaseIndex(), - new CodeSnippetsCodebaseIndex(this.ide), - ); - return indexes; } diff --git a/core/protocol/webview.ts b/core/protocol/webview.ts index 1a8d40313..b43bf271f 100644 --- a/core/protocol/webview.ts +++ b/core/protocol/webview.ts @@ -24,7 +24,7 @@ export type ToWebviewFromIdeOrCoreProtocol = { "indexing/statusUpdate": [IndexingStatus, void]; // Docs, etc. refreshSubmenuItems: [ { - providers: "all" | "dependsOnIndexing" | ContextProviderName[]; + providers: "all" | "indexTypes" | ContextProviderName[]; }, void, ]; diff --git a/gui/src/context/SubmenuContextProviders.tsx b/gui/src/context/SubmenuContextProviders.tsx index cf3939c48..87428ddba 100644 --- a/gui/src/context/SubmenuContextProviders.tsx +++ b/gui/src/context/SubmenuContextProviders.tsx @@ -115,7 +115,7 @@ export const SubmenuContextProvidersProvider = ({ const interval = setInterval(refreshOpenFiles, 2000); - refreshOpenFiles(); // Initial call + void refreshOpenFiles(); // Initial call return () => { isMounted = false; @@ -227,7 +227,7 @@ export const SubmenuContextProvidersProvider = ({ ); const loadSubmenuItems = useCallback( - async (providers: "dependsOnIndexing" | "all" | ContextProviderName[]) => { + async (providers: "indexTypes" | "all" | ContextProviderName[]) => { await Promise.allSettled( submenuContextProviders.map( async (description: ContextProviderDescription) => { @@ -236,12 +236,13 @@ export const SubmenuContextProvidersProvider = ({ const refreshProvider = providers === "all" ? true - : providers === "dependsOnIndexing" - ? description.dependsOnIndexing + : providers === "indexTypes" + ? description.indexTypes && + description.indexTypes?.length > 0 : providers.includes(description.title); if (!refreshProvider) { - if (providers === "dependsOnIndexing") { + if (providers === "indexTypes") { console.debug( `Skipping ${description.title} provider due to disabled indexing`, ); @@ -351,7 +352,7 @@ export const SubmenuContextProvidersProvider = ({ useWebviewListener( "refreshSubmenuItems", async (data) => { - loadSubmenuItems(data.providers); + void loadSubmenuItems(data.providers); }, [loadSubmenuItems], ); @@ -360,7 +361,7 @@ export const SubmenuContextProvidersProvider = ({ "indexProgress", async (data) => { if (data.status === "done") { - loadSubmenuItems("dependsOnIndexing"); + void loadSubmenuItems("indexTypes"); } }, [loadSubmenuItems], @@ -379,7 +380,7 @@ export const SubmenuContextProvidersProvider = ({ ) .map((provider) => provider.title); if (newTitles.length > 0) { - loadSubmenuItems(newTitles); + void loadSubmenuItems(newTitles); } lastProviders.current = submenuContextProviders; }, [loadSubmenuItems, submenuContextProviders]); From 4c0e2b3cc6453d99bee8098913ddb91b4ad35061 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Mon, 30 Jun 2025 23:48:52 +0530 Subject: [PATCH 02/23] rename to dependsOnIndexing --- core/context/providers/CodeContextProvider.ts | 2 +- core/context/providers/FolderContextProvider.ts | 2 +- core/index.d.ts | 2 +- core/indexing/CodebaseIndexer.ts | 2 +- core/protocol/webview.ts | 2 +- gui/src/context/SubmenuContextProviders.tsx | 12 ++++++------ 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core/context/providers/CodeContextProvider.ts b/core/context/providers/CodeContextProvider.ts index 0a3c361a3..db3b81664 100644 --- a/core/context/providers/CodeContextProvider.ts +++ b/core/context/providers/CodeContextProvider.ts @@ -16,7 +16,7 @@ class CodeContextProvider extends BaseContextProvider { displayTitle: "Code", description: "Type to search", type: "submenu", - indexTypes: ["chunk", "codeSnippets"], + dependsOnIndexing: ["chunk", "codeSnippets"], }; async getContextItems( diff --git a/core/context/providers/FolderContextProvider.ts b/core/context/providers/FolderContextProvider.ts index 981ca8579..48efcb121 100644 --- a/core/context/providers/FolderContextProvider.ts +++ b/core/context/providers/FolderContextProvider.ts @@ -19,7 +19,7 @@ class FolderContextProvider extends BaseContextProvider { displayTitle: "Folder", description: "Type to search", type: "submenu", - indexTypes: ["embeddings"], + dependsOnIndexing: ["embeddings", "fullTextSearch", "chunk"], }; async getContextItems( diff --git a/core/index.d.ts b/core/index.d.ts index 2f3766d24..6f18e1c32 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -177,7 +177,7 @@ export interface ContextProviderDescription { description: string; renderInlineAs?: string; type: ContextProviderType; - indexTypes?: ContextIndexingType[]; + dependsOnIndexing?: ContextIndexingType[]; } export type FetchFunction = (url: string | URL, init?: any) => Promise; diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index 880284e46..f2fabb90c 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -130,7 +130,7 @@ export class CodebaseIndexer { const indexTypesToBuild = new Set( // use set to remove duplicates config.contextProviders - .map((provider) => provider.description.indexTypes) + .map((provider) => provider.description.dependsOnIndexing) .filter((indexType) => Array.isArray(indexType)) // remove undefined indexTypes .flat(), ); diff --git a/core/protocol/webview.ts b/core/protocol/webview.ts index b43bf271f..1a8d40313 100644 --- a/core/protocol/webview.ts +++ b/core/protocol/webview.ts @@ -24,7 +24,7 @@ export type ToWebviewFromIdeOrCoreProtocol = { "indexing/statusUpdate": [IndexingStatus, void]; // Docs, etc. refreshSubmenuItems: [ { - providers: "all" | "indexTypes" | ContextProviderName[]; + providers: "all" | "dependsOnIndexing" | ContextProviderName[]; }, void, ]; diff --git a/gui/src/context/SubmenuContextProviders.tsx b/gui/src/context/SubmenuContextProviders.tsx index 87428ddba..9f6bcd55c 100644 --- a/gui/src/context/SubmenuContextProviders.tsx +++ b/gui/src/context/SubmenuContextProviders.tsx @@ -227,7 +227,7 @@ export const SubmenuContextProvidersProvider = ({ ); const loadSubmenuItems = useCallback( - async (providers: "indexTypes" | "all" | ContextProviderName[]) => { + async (providers: "dependsOnIndexing" | "all" | ContextProviderName[]) => { await Promise.allSettled( submenuContextProviders.map( async (description: ContextProviderDescription) => { @@ -236,13 +236,13 @@ export const SubmenuContextProvidersProvider = ({ const refreshProvider = providers === "all" ? true - : providers === "indexTypes" - ? description.indexTypes && - description.indexTypes?.length > 0 + : providers === "dependsOnIndexing" + ? description.dependsOnIndexing && + description.dependsOnIndexing?.length > 0 : providers.includes(description.title); if (!refreshProvider) { - if (providers === "indexTypes") { + if (providers === "dependsOnIndexing") { console.debug( `Skipping ${description.title} provider due to disabled indexing`, ); @@ -361,7 +361,7 @@ export const SubmenuContextProvidersProvider = ({ "indexProgress", async (data) => { if (data.status === "done") { - void loadSubmenuItems("indexTypes"); + void loadSubmenuItems("dependsOnIndexing"); } }, [loadSubmenuItems], From 5a9b9db915624a51f9a8229fbd98dbaa0cdcc016 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 1 Jul 2025 00:03:01 +0530 Subject: [PATCH 03/23] type correction --- core/context/providers/CodebaseContextProvider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/context/providers/CodebaseContextProvider.ts b/core/context/providers/CodebaseContextProvider.ts index 682a65a1f..43eaec433 100644 --- a/core/context/providers/CodebaseContextProvider.ts +++ b/core/context/providers/CodebaseContextProvider.ts @@ -13,7 +13,7 @@ class CodebaseContextProvider extends BaseContextProvider { description: "Automatically find relevant files", type: "normal", renderInlineAs: "", - indexTypes: ["embeddings", "fullTextSearch", "chunk"], + dependsOnIndexing: ["embeddings", "fullTextSearch", "chunk"], }; async getContextItems( From 2df3f1307fc8d3f9830923f85ae507f44e9208df Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 1 Jul 2025 00:56:37 +0530 Subject: [PATCH 05/23] fix typecheck --- core/indexing/CodebaseIndexer.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index f2fabb90c..2706f0c1e 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -159,9 +159,11 @@ export class CodebaseIndexer { const indexes: CodebaseIndex[] = []; // not parallelizing to avoid race conditions in sqlite for (const indexType of indexTypesToBuild) { - const index = await indexTypeToIndexerMapping[indexType](); - if (index) { - indexes.push(index); + if (indexType && indexType in indexTypeToIndexerMapping) { + const index = await indexTypeToIndexerMapping[indexType](); + if (index) { + indexes.push(index); + } } } From 085f76602854b00bcd2903bad4d1e160581d724c Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 31 Jul 2025 11:59:21 +0530 Subject: [PATCH 06/23] write tests for "getIndexesToBuild" --- core/indexing/CodebaseIndexer.test.ts | 90 +++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index 63822bea9..aee2fbebb 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -688,4 +688,94 @@ describe("CodebaseIndexer", () => { }); }); }); + + describe("getIndexesToBuild", () => { + let indexer: CodebaseIndexer; + let mockConfig: any; + let mockEmbeddingsModel: any; + let mockIdeSettings: any; + + beforeEach(() => { + indexer = new CodebaseIndexer( + testConfigHandler, + testIde, + mockMessenger as any, + false, + ); + + mockEmbeddingsModel = { + maxEmbeddingChunkSize: 1000, + model: "test-model", + provider: "test-provider", + }; + + mockIdeSettings = { + remoteConfigServerUrl: "http://test.com", + userToken: "test-token", + }; + + mockConfig = { + selectedModelByRole: { + embed: mockEmbeddingsModel, + }, + contextProviders: [], + }; + + jest.spyOn(testIde, "getIdeSettings").mockResolvedValue(mockIdeSettings); + }); + + afterEach(() => { + jest.clearAllMocks(); + }); + + test("should create specific indexTypes for the requested context providers", async () => { + mockConfig.contextProviders = [ + { + description: { + dependsOnIndexing: ["chunk", "codeSnippets"], + }, + }, + ]; + + jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ + config: mockConfig, + errors: [], + configLoadInterrupted: false, + }); + + const indexes = (await ( + indexer as any + ).getIndexesToBuild()) as CodebaseIndex[]; + + expect(indexes).toHaveLength(2); + expect(indexes[0].artifactId).toBe("chunks"); + expect(indexes[1].artifactId).toBe("codeSnippets"); + }); + + test("should handle duplicate contexts", async () => { + mockConfig.contextProviders = [ + { + description: { + dependsOnIndexing: ["codeSnippets"], + }, + }, + { + description: { + dependsOnIndexing: ["codeSnippets"], + }, + }, + ]; + + jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ + config: mockConfig, + errors: [], + configLoadInterrupted: false, + }); + + const indexes = await (indexer as any).getIndexesToBuild(); + + expect(indexes).toHaveLength(1); + expect(indexes[0].artifactId).toBe("codeSnippets"); + }); + }); }); From cdc71422a96427a3580dc4a8604bc046884fb59b Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 7 Aug 2025 11:56:28 +0530 Subject: [PATCH 08/23] revert tests --- core/indexing/CodebaseIndexer.test.ts | 90 --------------------------- 1 file changed, 90 deletions(-) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index c15e2b062..e6b2c2055 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -710,94 +710,4 @@ describe("CodebaseIndexer", () => { }); }); }); - - describe("getIndexesToBuild", () => { - let indexer: CodebaseIndexer; - let mockConfig: any; - let mockEmbeddingsModel: any; - let mockIdeSettings: any; - - beforeEach(() => { - indexer = new CodebaseIndexer( - testConfigHandler, - testIde, - mockMessenger as any, - false, - ); - - mockEmbeddingsModel = { - maxEmbeddingChunkSize: 1000, - model: "test-model", - provider: "test-provider", - }; - - mockIdeSettings = { - remoteConfigServerUrl: "http://test.com", - userToken: "test-token", - }; - - mockConfig = { - selectedModelByRole: { - embed: mockEmbeddingsModel, - }, - contextProviders: [], - }; - - jest.spyOn(testIde, "getIdeSettings").mockResolvedValue(mockIdeSettings); - }); - - afterEach(() => { - jest.clearAllMocks(); - }); - - test("should create specific indexTypes for the requested context providers", async () => { - mockConfig.contextProviders = [ - { - description: { - dependsOnIndexing: ["chunk", "codeSnippets"], - }, - }, - ]; - - jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ - config: mockConfig, - errors: [], - configLoadInterrupted: false, - }); - - const indexes = (await ( - indexer as any - ).getIndexesToBuild()) as CodebaseIndex[]; - - expect(indexes).toHaveLength(2); - expect(indexes[0].artifactId).toBe("chunks"); - expect(indexes[1].artifactId).toBe("codeSnippets"); - }); - - test("should handle duplicate contexts", async () => { - mockConfig.contextProviders = [ - { - description: { - dependsOnIndexing: ["codeSnippets"], - }, - }, - { - description: { - dependsOnIndexing: ["codeSnippets"], - }, - }, - ]; - - jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ - config: mockConfig, - errors: [], - configLoadInterrupted: false, - }); - - const indexes = await (indexer as any).getIndexesToBuild(); - - expect(indexes).toHaveLength(1); - expect(indexes[0].artifactId).toBe("codeSnippets"); - }); - }); }); From 2c2db8f967e7d363ec87ef3d000467f5725fe581 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 7 Aug 2025 12:02:11 +0530 Subject: [PATCH 09/23] Revert "revert tests" This reverts commit cdc71422a96427a3580dc4a8604bc046884fb59b. --- core/indexing/CodebaseIndexer.test.ts | 90 +++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index e6b2c2055..c15e2b062 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -710,4 +710,94 @@ describe("CodebaseIndexer", () => { }); }); }); + + describe("getIndexesToBuild", () => { + let indexer: CodebaseIndexer; + let mockConfig: any; + let mockEmbeddingsModel: any; + let mockIdeSettings: any; + + beforeEach(() => { + indexer = new CodebaseIndexer( + testConfigHandler, + testIde, + mockMessenger as any, + false, + ); + + mockEmbeddingsModel = { + maxEmbeddingChunkSize: 1000, + model: "test-model", + provider: "test-provider", + }; + + mockIdeSettings = { + remoteConfigServerUrl: "http://test.com", + userToken: "test-token", + }; + + mockConfig = { + selectedModelByRole: { + embed: mockEmbeddingsModel, + }, + contextProviders: [], + }; + + jest.spyOn(testIde, "getIdeSettings").mockResolvedValue(mockIdeSettings); + }); + + afterEach(() => { + jest.clearAllMocks(); + }); + + test("should create specific indexTypes for the requested context providers", async () => { + mockConfig.contextProviders = [ + { + description: { + dependsOnIndexing: ["chunk", "codeSnippets"], + }, + }, + ]; + + jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ + config: mockConfig, + errors: [], + configLoadInterrupted: false, + }); + + const indexes = (await ( + indexer as any + ).getIndexesToBuild()) as CodebaseIndex[]; + + expect(indexes).toHaveLength(2); + expect(indexes[0].artifactId).toBe("chunks"); + expect(indexes[1].artifactId).toBe("codeSnippets"); + }); + + test("should handle duplicate contexts", async () => { + mockConfig.contextProviders = [ + { + description: { + dependsOnIndexing: ["codeSnippets"], + }, + }, + { + description: { + dependsOnIndexing: ["codeSnippets"], + }, + }, + ]; + + jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ + config: mockConfig, + errors: [], + configLoadInterrupted: false, + }); + + const indexes = await (indexer as any).getIndexesToBuild(); + + expect(indexes).toHaveLength(1); + expect(indexes[0].artifactId).toBe("codeSnippets"); + }); + }); }); From c1013ee18dd7eb1ce3ed89e38bfc687b5538b8a6 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 7 Aug 2025 12:02:42 +0530 Subject: [PATCH 10/23] test only codebaseindexer --- .github/workflows/pr-checks.yaml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr-checks.yaml b/.github/workflows/pr-checks.yaml index 63afde345..1b4a41d87 100644 --- a/.github/workflows/pr-checks.yaml +++ b/.github/workflows/pr-checks.yaml @@ -44,17 +44,18 @@ jobs: component: core include-root: true - - name: Type check and lint - run: | - cd core - npx tsc --noEmit - npm run lint - env: - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + # - name: Type check and lint + # run: | + # cd core + # npx tsc --noEmit + # npm run lint + # env: + # OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - name: Run tests run: | cd core + npm test -- CodebaseIndexer npm test npm run vitest env: From 7a80e793d4dfb58b302ca0e2f26c34e23a5b13e8 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 7 Aug 2025 12:12:24 +0530 Subject: [PATCH 11/23] rerun tests --- core/indexing/CodebaseIndexer.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index c15e2b062..95ba7bc97 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -717,7 +717,7 @@ describe("CodebaseIndexer", () => { let mockEmbeddingsModel: any; let mockIdeSettings: any; - beforeEach(() => { + beforeEach(async () => { indexer = new CodebaseIndexer( testConfigHandler, testIde, @@ -774,7 +774,7 @@ describe("CodebaseIndexer", () => { expect(indexes[1].artifactId).toBe("codeSnippets"); }); - test("should handle duplicate contexts", async () => { + test.skip("should handle duplicate contexts", async () => { mockConfig.contextProviders = [ { description: { From 36755840d6fd4170fba5b6822ea32d52232f85c2 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 7 Aug 2025 12:14:02 +0530 Subject: [PATCH 12/23] rerun tests --- core/indexing/CodebaseIndexer.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index 95ba7bc97..cf4102bd7 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -750,7 +750,7 @@ describe("CodebaseIndexer", () => { jest.clearAllMocks(); }); - test("should create specific indexTypes for the requested context providers", async () => { + test.skip("should create specific indexTypes for the requested context providers", async () => { mockConfig.contextProviders = [ { description: { From 3713a4d61c37f28c1fe6925318655d0733cd7ac0 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 7 Aug 2025 12:17:26 +0530 Subject: [PATCH 13/23] wait for logs to cleanup --- core/indexing/CodebaseIndexer.test.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index cf4102bd7..b9c24519a 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -746,11 +746,12 @@ describe("CodebaseIndexer", () => { jest.spyOn(testIde, "getIdeSettings").mockResolvedValue(mockIdeSettings); }); - afterEach(() => { + afterEach(async () => { jest.clearAllMocks(); + await new Promise((resolve) => setTimeout(resolve, 500)); // wait for error logs to cleanup }); - test.skip("should create specific indexTypes for the requested context providers", async () => { + test("should create specific indexTypes for the requested context providers", async () => { mockConfig.contextProviders = [ { description: { @@ -774,7 +775,7 @@ describe("CodebaseIndexer", () => { expect(indexes[1].artifactId).toBe("codeSnippets"); }); - test.skip("should handle duplicate contexts", async () => { + test("should handle duplicate contexts", async () => { mockConfig.contextProviders = [ { description: { From 050078fa5cb14d8af4ae986b0e1c4b8e61811af2 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 7 Aug 2025 12:21:11 +0530 Subject: [PATCH 14/23] rerun tests --- core/indexing/CodebaseIndexer.test.ts | 157 +++++++++++++------------- 1 file changed, 79 insertions(+), 78 deletions(-) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index b9c24519a..16671861a 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -709,96 +709,97 @@ describe("CodebaseIndexer", () => { ]); }); }); - }); - describe("getIndexesToBuild", () => { - let indexer: CodebaseIndexer; - let mockConfig: any; - let mockEmbeddingsModel: any; - let mockIdeSettings: any; + describe("getIndexesToBuild", () => { + let indexer: CodebaseIndexer; + let mockConfig: any; + let mockEmbeddingsModel: any; + let mockIdeSettings: any; - beforeEach(async () => { - indexer = new CodebaseIndexer( - testConfigHandler, - testIde, - mockMessenger as any, - false, - ); + beforeEach(async () => { + indexer = new CodebaseIndexer( + testConfigHandler, + testIde, + mockMessenger as any, + false, + ); - mockEmbeddingsModel = { - maxEmbeddingChunkSize: 1000, - model: "test-model", - provider: "test-provider", - }; + mockEmbeddingsModel = { + maxEmbeddingChunkSize: 1000, + model: "test-model", + provider: "test-provider", + }; - mockIdeSettings = { - remoteConfigServerUrl: "http://test.com", - userToken: "test-token", - }; + mockIdeSettings = { + remoteConfigServerUrl: "http://test.com", + userToken: "test-token", + }; - mockConfig = { - selectedModelByRole: { - embed: mockEmbeddingsModel, - }, - contextProviders: [], - }; - - jest.spyOn(testIde, "getIdeSettings").mockResolvedValue(mockIdeSettings); - }); - - afterEach(async () => { - jest.clearAllMocks(); - await new Promise((resolve) => setTimeout(resolve, 500)); // wait for error logs to cleanup - }); - - test("should create specific indexTypes for the requested context providers", async () => { - mockConfig.contextProviders = [ - { - description: { - dependsOnIndexing: ["chunk", "codeSnippets"], + mockConfig = { + selectedModelByRole: { + embed: mockEmbeddingsModel, }, - }, - ]; + contextProviders: [], + }; - jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ - config: mockConfig, - errors: [], - configLoadInterrupted: false, + jest + .spyOn(testIde, "getIdeSettings") + .mockResolvedValue(mockIdeSettings); }); - const indexes = (await ( - indexer as any - ).getIndexesToBuild()) as CodebaseIndex[]; - - expect(indexes).toHaveLength(2); - expect(indexes[0].artifactId).toBe("chunks"); - expect(indexes[1].artifactId).toBe("codeSnippets"); - }); - - test("should handle duplicate contexts", async () => { - mockConfig.contextProviders = [ - { - description: { - dependsOnIndexing: ["codeSnippets"], - }, - }, - { - description: { - dependsOnIndexing: ["codeSnippets"], - }, - }, - ]; - - jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ - config: mockConfig, - errors: [], - configLoadInterrupted: false, + afterEach(() => { + jest.clearAllMocks(); }); - const indexes = await (indexer as any).getIndexesToBuild(); + test("should create specific indexTypes for the requested context providers", async () => { + mockConfig.contextProviders = [ + { + description: { + dependsOnIndexing: ["chunk", "codeSnippets"], + }, + }, + ]; - expect(indexes).toHaveLength(1); - expect(indexes[0].artifactId).toBe("codeSnippets"); + jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ + config: mockConfig, + errors: [], + configLoadInterrupted: false, + }); + + const indexes = (await ( + indexer as any + ).getIndexesToBuild()) as CodebaseIndex[]; + + expect(indexes).toHaveLength(2); + expect(indexes[0].artifactId).toBe("chunks"); + expect(indexes[1].artifactId).toBe("codeSnippets"); + }); + + test("should handle duplicate contexts", async () => { + mockConfig.contextProviders = [ + { + description: { + dependsOnIndexing: ["codeSnippets"], + }, + }, + { + description: { + dependsOnIndexing: ["codeSnippets"], + }, + }, + ]; + + jest.spyOn(testConfigHandler, "loadConfig").mockResolvedValue({ + config: mockConfig, + errors: [], + configLoadInterrupted: false, + }); + + const indexes = await (indexer as any).getIndexesToBuild(); + + expect(indexes).toHaveLength(1); + expect(indexes[0].artifactId).toBe("codeSnippets"); + }); }); }); }); From cf496bb768067186fb417190f64e6dc23b64b402 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 7 Aug 2025 12:22:57 +0530 Subject: [PATCH 15/23] revert ci changes --- .github/workflows/pr-checks.yaml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr-checks.yaml b/.github/workflows/pr-checks.yaml index 1b4a41d87..63afde345 100644 --- a/.github/workflows/pr-checks.yaml +++ b/.github/workflows/pr-checks.yaml @@ -44,18 +44,17 @@ jobs: component: core include-root: true - # - name: Type check and lint - # run: | - # cd core - # npx tsc --noEmit - # npm run lint - # env: - # OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} + - name: Type check and lint + run: | + cd core + npx tsc --noEmit + npm run lint + env: + OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} - name: Run tests run: | cd core - npm test -- CodebaseIndexer npm test npm run vitest env: From fc2c0d2657f302e2f0d0acd312d54772d6d75e0d Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 19 Aug 2025 17:13:57 +0530 Subject: [PATCH 16/23] refreshcodebase index when indexes were changed --- core/core.ts | 20 ++++++---- core/indexing/CodebaseIndexer.test.ts | 53 +++++++++++++++++++++++++++ core/indexing/CodebaseIndexer.ts | 9 +++++ 3 files changed, 75 insertions(+), 7 deletions(-) diff --git a/core/core.ts b/core/core.ts index 1e5b2a74b..b96e27689 100644 --- a/core/core.ts +++ b/core/core.ts @@ -175,6 +175,13 @@ export class Core { } }; + this.codeBaseIndexer = new CodebaseIndexer( + this.configHandler, + this.ide, + this.messenger, + this.globalContext.get("indexingPaused"), + ); + this.configHandler.onConfigUpdate((result) => { void (async () => { const serializedResult = @@ -187,6 +194,12 @@ export class Core { selectedOrgId: this.configHandler.currentOrg?.id ?? null, }); + if (await this.codeBaseIndexer.wasIndexesChanged()) { + await this.codeBaseIndexer.refreshCodebaseIndex( + await this.ide.getWorkspaceDirs(), + ); + } + // update additional submenu context providers registered via VSCode API const additionalProviders = this.configHandler.getAdditionalSubmenuContextProviders(); @@ -198,13 +211,6 @@ export class Core { })(); }); - this.codeBaseIndexer = new CodebaseIndexer( - this.configHandler, - this.ide, - this.messenger, - this.globalContext.get("indexingPaused"), - ); - // Dev Data Logger const dataLogger = DataLogger.getInstance(); dataLogger.core = this; diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index 16671861a..783202add 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -802,4 +802,57 @@ describe("CodebaseIndexer", () => { }); }); }); + + describe("wasIndexesChanged", () => { + let testIndexer: TestCodebaseIndexer; + let mockGetIndexesToBuild: jest.MockedFunction; + + beforeEach(() => { + testIndexer = new TestCodebaseIndexer( + testConfigHandler, + testIde, + mockMessenger as any, + false, + ); + + // Mock getIndexesToBuild to control what indexes should be built + mockGetIndexesToBuild = jest + .spyOn(testIndexer as any, "getIndexesToBuild") + .mockResolvedValue([]); + }); + + afterEach(() => { + jest.clearAllMocks(); + }); + + test("should return true when indexes to build differ from built indexes", async () => { + const mockIndex1 = new TestCodebaseIndex(); + const mockIndex2 = new TestCodebaseIndex(); + mockGetIndexesToBuild.mockResolvedValue([mockIndex1]); + (testIndexer as any).builtIndexes = [mockIndex2]; + + const result = await testIndexer.wasIndexesChanged(); + expect(result).toBe(true); + }); + + test("should return true when there are more indexes to build than built indexes", async () => { + const mockIndex1 = new TestCodebaseIndex(); + const mockIndex2 = new TestCodebaseIndex(); + mockGetIndexesToBuild.mockResolvedValue([mockIndex1, mockIndex2]); + (testIndexer as any).builtIndexes = [mockIndex1]; + + const result = await testIndexer.wasIndexesChanged(); + expect(result).toBe(true); + }); + + test("should return false when there are fewer indexes to build than built indexes", async () => { + const mockIndex1 = new TestCodebaseIndex(); + const mockIndex2 = new TestCodebaseIndex(); + mockGetIndexesToBuild.mockResolvedValue([mockIndex1]); + (testIndexer as any).builtIndexes = [mockIndex1, mockIndex2]; + + const result = await testIndexer.wasIndexesChanged(); + expect(result).toBe(false); + }); + }); }); diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index 585261c3a..072755b61 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -61,6 +61,7 @@ export class CodebaseIndexer { private indexingCancellationController: AbortController; private codebaseIndexingState: IndexingProgressUpdate; private readonly pauseToken: PauseToken; + private builtIndexes: CodebaseIndex[] = []; private getUserFriendlyIndexName(artifactId: string): string { if (artifactId === FullTextSearchCodebaseIndex.artifactId) @@ -208,6 +209,7 @@ export class CodebaseIndexer { } } + this.builtIndexes = indexes; return indexes; } @@ -722,6 +724,13 @@ export class CodebaseIndexer { } } + public async wasIndexesChanged() { + const indexes = await this.getIndexesToBuild(); + return !indexes.every((index) => + this.builtIndexes.some((builtIndex) => builtIndex === index), + ); + } + public async refreshCodebaseIndex(paths: string[]) { if (!this.indexingCancellationController.signal.aborted) { this.indexingCancellationController.abort(); From 660bda004bd167b8f71464125b03f359ed91128f Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Wed, 20 Aug 2025 08:58:47 +0530 Subject: [PATCH 17/23] check equality for artifact id --- core/indexing/CodebaseIndexer.test.ts | 7 ++++--- core/indexing/CodebaseIndexer.ts | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index 783202add..a49cca85d 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -21,6 +21,7 @@ import CodebaseContextProvider from "../context/providers/CodebaseContextProvide import { ContinueConfig } from "../index.js"; import { localPathToUri } from "../util/pathToUri.js"; import { CodebaseIndexer } from "./CodebaseIndexer.js"; +import { FullTextSearchCodebaseIndex } from "./FullTextSearchCodebaseIndex.js"; import { getComputeDeleteAddRemove } from "./refreshIndex.js"; import { TestCodebaseIndex } from "./TestCodebaseIndex.js"; import { CodebaseIndex } from "./types.js"; @@ -827,7 +828,7 @@ describe("CodebaseIndexer", () => { test("should return true when indexes to build differ from built indexes", async () => { const mockIndex1 = new TestCodebaseIndex(); - const mockIndex2 = new TestCodebaseIndex(); + const mockIndex2 = new FullTextSearchCodebaseIndex(); mockGetIndexesToBuild.mockResolvedValue([mockIndex1]); (testIndexer as any).builtIndexes = [mockIndex2]; @@ -837,7 +838,7 @@ describe("CodebaseIndexer", () => { test("should return true when there are more indexes to build than built indexes", async () => { const mockIndex1 = new TestCodebaseIndex(); - const mockIndex2 = new TestCodebaseIndex(); + const mockIndex2 = new FullTextSearchCodebaseIndex(); mockGetIndexesToBuild.mockResolvedValue([mockIndex1, mockIndex2]); (testIndexer as any).builtIndexes = [mockIndex1]; @@ -847,7 +848,7 @@ describe("CodebaseIndexer", () => { test("should return false when there are fewer indexes to build than built indexes", async () => { const mockIndex1 = new TestCodebaseIndex(); - const mockIndex2 = new TestCodebaseIndex(); + const mockIndex2 = new FullTextSearchCodebaseIndex(); mockGetIndexesToBuild.mockResolvedValue([mockIndex1]); (testIndexer as any).builtIndexes = [mockIndex1, mockIndex2]; diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index 072755b61..266c7ddcc 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -727,7 +727,9 @@ export class CodebaseIndexer { public async wasIndexesChanged() { const indexes = await this.getIndexesToBuild(); return !indexes.every((index) => - this.builtIndexes.some((builtIndex) => builtIndex === index), + this.builtIndexes.some( + (builtIndex) => builtIndex.artifactId === index.artifactId, + ), ); } From d7066bed4ba4040feea4d19cdcaa99a2d5818620 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Thu, 4 Sep 2025 20:35:22 +0530 Subject: [PATCH 18/23] when there are fewer indexes return true --- core/indexing/CodebaseIndexer.test.ts | 2 +- core/indexing/CodebaseIndexer.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index 2d7ac48af..169aa4eb5 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -819,7 +819,7 @@ describe("CodebaseIndexer", () => { (testIndexer as any).builtIndexes = [mockIndex1, mockIndex2]; const result = await testIndexer.wasIndexesChanged(); - expect(result).toBe(false); + expect(result).toBe(true); }); }); }); diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index d67db7d9b..057979fa8 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -716,6 +716,9 @@ export class CodebaseIndexer { public async wasIndexesChanged() { const indexes = await this.getIndexesToBuild(); + if (indexes.length < this.builtIndexes.length) { + return true; + } return !indexes.every((index) => this.builtIndexes.some( (builtIndex) => builtIndex.artifactId === index.artifactId, From 361a627a249bae58dbbad64b6101a6d882db97bb Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 9 Sep 2025 01:42:30 +0530 Subject: [PATCH 19/23] Revert "when there are fewer indexes return true" This reverts commit d7066bed4ba4040feea4d19cdcaa99a2d5818620. --- core/indexing/CodebaseIndexer.test.ts | 2 +- core/indexing/CodebaseIndexer.ts | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index 169aa4eb5..2d7ac48af 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -819,7 +819,7 @@ describe("CodebaseIndexer", () => { (testIndexer as any).builtIndexes = [mockIndex1, mockIndex2]; const result = await testIndexer.wasIndexesChanged(); - expect(result).toBe(true); + expect(result).toBe(false); }); }); }); diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index 057979fa8..d67db7d9b 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -716,9 +716,6 @@ export class CodebaseIndexer { public async wasIndexesChanged() { const indexes = await this.getIndexesToBuild(); - if (indexes.length < this.builtIndexes.length) { - return true; - } return !indexes.every((index) => this.builtIndexes.some( (builtIndex) => builtIndex.artifactId === index.artifactId, From 4129c94cd09ecad768b184d0496f4d863187a2e0 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 9 Sep 2025 01:43:45 +0530 Subject: [PATCH 20/23] rename to wasAnyOneIndexAdded --- core/core.ts | 2 +- core/indexing/CodebaseIndexer.test.ts | 8 ++++---- core/indexing/CodebaseIndexer.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/core.ts b/core/core.ts index 03c7d3add..cf43448aa 100644 --- a/core/core.ts +++ b/core/core.ts @@ -194,7 +194,7 @@ export class Core { selectedOrgId: this.configHandler.currentOrg?.id ?? null, }); - if (await this.codeBaseIndexer.wasIndexesChanged()) { + if (await this.codeBaseIndexer.wasAnyOneIndexAdded()) { await this.codeBaseIndexer.refreshCodebaseIndex( await this.ide.getWorkspaceDirs(), ); diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index 2d7ac48af..a2d5013f8 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -770,7 +770,7 @@ describe("CodebaseIndexer", () => { }); }); - describe("wasIndexesChanged", () => { + describe("wasAnyOneIndexAdded", () => { let testIndexer: TestCodebaseIndexer; let mockGetIndexesToBuild: jest.MockedFunction; @@ -798,7 +798,7 @@ describe("CodebaseIndexer", () => { mockGetIndexesToBuild.mockResolvedValue([mockIndex1]); (testIndexer as any).builtIndexes = [mockIndex2]; - const result = await testIndexer.wasIndexesChanged(); + const result = await testIndexer.wasAnyOneIndexAdded(); expect(result).toBe(true); }); @@ -808,7 +808,7 @@ describe("CodebaseIndexer", () => { mockGetIndexesToBuild.mockResolvedValue([mockIndex1, mockIndex2]); (testIndexer as any).builtIndexes = [mockIndex1]; - const result = await testIndexer.wasIndexesChanged(); + const result = await testIndexer.wasAnyOneIndexAdded(); expect(result).toBe(true); }); @@ -818,7 +818,7 @@ describe("CodebaseIndexer", () => { mockGetIndexesToBuild.mockResolvedValue([mockIndex1]); (testIndexer as any).builtIndexes = [mockIndex1, mockIndex2]; - const result = await testIndexer.wasIndexesChanged(); + const result = await testIndexer.wasAnyOneIndexAdded(); expect(result).toBe(false); }); }); diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts index d67db7d9b..a7eb28047 100644 --- a/core/indexing/CodebaseIndexer.ts +++ b/core/indexing/CodebaseIndexer.ts @@ -714,7 +714,7 @@ export class CodebaseIndexer { } } - public async wasIndexesChanged() { + public async wasAnyOneIndexAdded() { const indexes = await this.getIndexesToBuild(); return !indexes.every((index) => this.builtIndexes.some( From ca8c8c79ebad2329ea5d5e9a0aa370e28172a7b4 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 9 Sep 2025 17:48:32 +0530 Subject: [PATCH 21/23] skip codebaseindex test --- core/indexing/CodebaseIndexer.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index a2d5013f8..04951b175 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -87,7 +87,7 @@ type MockMessengerType = { // These are more like integration tests, whereas we should separately test // the individual CodebaseIndex classes -describe("CodebaseIndexer", () => { +describe.skip("CodebaseIndexer", () => { // Replace mockProgressReporter with mockMessenger const mockMessenger: MockMessengerType = { send: jest.fn(), From e30a6613f4ebe662947aec6f384d52a05fb79cdf Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 9 Sep 2025 17:54:28 +0530 Subject: [PATCH 22/23] try skipping specific tests --- core/indexing/CodebaseIndexer.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index 04951b175..e9a42a680 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -87,7 +87,7 @@ type MockMessengerType = { // These are more like integration tests, whereas we should separately test // the individual CodebaseIndex classes -describe.skip("CodebaseIndexer", () => { +describe("CodebaseIndexer", () => { // Replace mockProgressReporter with mockMessenger const mockMessenger: MockMessengerType = { send: jest.fn(), @@ -677,7 +677,7 @@ describe.skip("CodebaseIndexer", () => { }); }); - describe("getIndexesToBuild", () => { + describe.skip("getIndexesToBuild", () => { let indexer: CodebaseIndexer; let mockConfig: any; let mockEmbeddingsModel: any; @@ -770,7 +770,7 @@ describe.skip("CodebaseIndexer", () => { }); }); - describe("wasAnyOneIndexAdded", () => { + describe.skip("wasAnyOneIndexAdded", () => { let testIndexer: TestCodebaseIndexer; let mockGetIndexesToBuild: jest.MockedFunction; From 9091e77cfd807fdf2fa21f9419a3059c540ddade Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Tue, 9 Sep 2025 19:08:24 +0530 Subject: [PATCH 23/23] fix by mocking not needed refreshCodebaseIndex --- core/indexing/CodebaseIndexer.test.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/indexing/CodebaseIndexer.test.ts b/core/indexing/CodebaseIndexer.test.ts index e9a42a680..fba10db8c 100644 --- a/core/indexing/CodebaseIndexer.test.ts +++ b/core/indexing/CodebaseIndexer.test.ts @@ -677,7 +677,7 @@ describe("CodebaseIndexer", () => { }); }); - describe.skip("getIndexesToBuild", () => { + describe("getIndexesToBuild", () => { let indexer: CodebaseIndexer; let mockConfig: any; let mockEmbeddingsModel: any; @@ -770,7 +770,7 @@ describe("CodebaseIndexer", () => { }); }); - describe.skip("wasAnyOneIndexAdded", () => { + describe("wasAnyOneIndexAdded", () => { let testIndexer: TestCodebaseIndexer; let mockGetIndexesToBuild: jest.MockedFunction; @@ -786,6 +786,10 @@ describe("CodebaseIndexer", () => { mockGetIndexesToBuild = jest .spyOn(testIndexer as any, "getIndexesToBuild") .mockResolvedValue([]); + + jest + .spyOn(testIndexer, "refreshCodebaseIndex") + .mockImplementation(async () => {}); }); afterEach(() => {