diff --git a/core/index.d.ts b/core/index.d.ts
index 3cc31dbaf..9b83d5d8b 100644
--- a/core/index.d.ts
+++ b/core/index.d.ts
@@ -57,6 +57,7 @@ export interface IndexingProgressUpdate {
| "disabled"
| "cancelled";
debugInfo?: string;
+ warnings?: string[];
}
// This is more or less a V2 of IndexingProgressUpdate for docs etc.
diff --git a/core/indexing/CodeSnippetsIndex.ts b/core/indexing/CodeSnippetsIndex.ts
index bf79b093e..d04eca7ee 100644
--- a/core/indexing/CodeSnippetsIndex.ts
+++ b/core/indexing/CodeSnippetsIndex.ts
@@ -35,7 +35,8 @@ type SnippetChunk = ChunkWithoutID & { title: string; signature: string };
export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
relativeExpectedTime: number = 1;
- artifactId = "codeSnippets";
+ static artifactId = "codeSnippets";
+ artifactId: string = CodeSnippetsCodebaseIndex.artifactId;
constructor(private readonly ide: IDE) {}
@@ -220,7 +221,6 @@ export class CodeSnippetsCodebaseIndex implements CodebaseIndex {
// Compute
for (let i = 0; i < results.compute.length; i++) {
const compute = results.compute[i];
-
let snippets: SnippetChunk[] = [];
try {
snippets = await this.getSnippetsInFile(
diff --git a/core/indexing/CodebaseIndexer.ts b/core/indexing/CodebaseIndexer.ts
index d2de0c512..e867399fd 100644
--- a/core/indexing/CodebaseIndexer.ts
+++ b/core/indexing/CodebaseIndexer.ts
@@ -48,6 +48,16 @@ export class CodebaseIndexer {
private codebaseIndexingState: IndexingProgressUpdate;
private readonly pauseToken: PauseToken;
+ private getUserFriendlyIndexName(artifactId: string): string {
+ if (artifactId === FullTextSearchCodebaseIndex.artifactId)
+ return "Full text search";
+ if (artifactId === CodeSnippetsCodebaseIndex.artifactId)
+ return "Code snippets";
+ if (artifactId === ChunkCodebaseIndex.artifactId) return "Chunking";
+ if (artifactId.startsWith("vectordb")) return "Embedding";
+ return artifactId; // fallback to original
+ }
+
// Note that we exclude certain Sqlite errors that we do not want to clear the indexes on,
// e.g. a `SQLITE_BUSY` error.
errorsRegexesToClearIndexesOn = [
@@ -314,6 +324,7 @@ export class CodebaseIndexer {
status: "loading",
};
const beginTime = Date.now();
+ let collectedWarnings: string[] = [];
for (const directory of dirs) {
const dirBasename = getUriPathBasename(directory);
@@ -344,45 +355,52 @@ export class CodebaseIndexer {
const repoName = await this.ide.getRepoName(directory);
let nextLogThreshold = 0;
- try {
- for await (const updateDesc of this.indexFiles(
- directory,
- directoryFiles,
- branch,
- repoName,
- )) {
- // Handle pausing in this loop because it's the only one really taking time
- if (abortSignal.aborted) {
- yield {
- progress: 0,
- desc: "Indexing cancelled",
- status: "cancelled",
- };
- return;
- }
- if (this.pauseToken.paused) {
- yield* this.yieldUpdateAndPause();
- }
- yield updateDesc;
- if (updateDesc.progress >= nextLogThreshold) {
- // log progress every 2.5%
- nextLogThreshold += 0.025;
- this.logProgress(
- beginTime,
- Math.floor(directoryFiles.length * updateDesc.progress),
- updateDesc.progress,
- );
- }
+ for await (const updateDesc of this.indexFiles(
+ directory,
+ directoryFiles,
+ branch,
+ repoName,
+ )) {
+ // Handle pausing in this loop because it's the only one really taking time
+ if (abortSignal.aborted) {
+ yield {
+ progress: 0,
+ desc: "Indexing cancelled",
+ status: "cancelled",
+ };
+ return;
+ }
+ if (this.pauseToken.paused) {
+ yield* this.yieldUpdateAndPause();
+ }
+
+ // Collect warnings from indexFiles
+ if (updateDesc.warnings && updateDesc.warnings.length > 0) {
+ collectedWarnings = [...updateDesc.warnings];
+ }
+
+ yield updateDesc;
+ if (updateDesc.progress >= nextLogThreshold) {
+ // log progress every 2.5%
+ nextLogThreshold += 0.025;
+ this.logProgress(
+ beginTime,
+ Math.floor(directoryFiles.length * updateDesc.progress),
+ updateDesc.progress,
+ );
}
- } catch (err) {
- yield this.handleErrorAndGetProgressUpdate(err);
- return;
}
}
+
+ // Final completion message with preserved warnings
yield {
progress: 1,
- desc: "Indexing Complete",
+ desc:
+ collectedWarnings.length > 0
+ ? `Indexing completed with ${collectedWarnings.length} warning(s)`
+ : "Indexing Complete",
status: "done",
+ warnings: collectedWarnings.length > 0 ? collectedWarnings : undefined,
};
this.logProgress(beginTime, 0, 1);
}
@@ -490,6 +508,8 @@ export class CodebaseIndexer {
const indexesToBuild = await this.getIndexesToBuild();
let completedIndexCount = 0;
let progress = 0;
+ const warnings: string[] = [];
+
for (const codebaseIndex of indexesToBuild) {
const tag: IndexTag = {
directory,
@@ -500,45 +520,101 @@ export class CodebaseIndexer {
progress: progress,
desc: `Planning changes for ${codebaseIndex.artifactId} index...`,
status: "indexing",
+ warnings: warnings.length > 0 ? [...warnings] : undefined,
};
- const [results, lastUpdated, markComplete] =
- await getComputeDeleteAddRemove(
- tag,
- { ...stats },
- (filepath) => this.ide.readFile(filepath),
- repoName,
- );
- const totalOps = this.totalIndexOps(results);
- let completedOps = 0;
- // Don't update if nothing to update. Some of the indices might do unnecessary setup work
- if (totalOps > 0) {
- for (const subResult of this.batchRefreshIndexResults(results)) {
- for await (const { desc } of codebaseIndex.update(
+ try {
+ const [results, lastUpdated, markComplete] =
+ await getComputeDeleteAddRemove(
tag,
- subResult,
- markComplete,
+ { ...stats },
+ (filepath) => this.ide.readFile(filepath),
repoName,
- )) {
- yield {
- progress,
- desc,
- status: "indexing",
- };
- }
- completedOps +=
- subResult.compute.length +
- subResult.del.length +
- subResult.addTag.length +
- subResult.removeTag.length;
- progress =
- (completedIndexCount + completedOps / totalOps) *
- (1 / indexesToBuild.length);
- }
- }
+ );
+ const totalOps = this.totalIndexOps(results);
+ let completedOps = 0;
- await markComplete(lastUpdated, IndexResultType.UpdateLastUpdated);
- completedIndexCount += 1;
+ // Don't update if nothing to update. Some of the indices might do unnecessary setup work
+ if (totalOps > 0) {
+ for (const subResult of this.batchRefreshIndexResults(results)) {
+ try {
+ for await (const { desc } of codebaseIndex.update(
+ tag,
+ subResult,
+ markComplete,
+ repoName,
+ )) {
+ yield {
+ progress,
+ desc,
+ status: "indexing",
+ warnings: warnings.length > 0 ? [...warnings] : undefined,
+ };
+ }
+ completedOps +=
+ subResult.compute.length +
+ subResult.del.length +
+ subResult.addTag.length +
+ subResult.removeTag.length;
+ progress =
+ (completedIndexCount + completedOps / totalOps) *
+ (1 / indexesToBuild.length);
+ } catch (err) {
+ // Collect non-fatal errors as warnings and continue
+ const warningMsg =
+ err instanceof Error ? err.message : String(err);
+ const friendlyName = this.getUserFriendlyIndexName(
+ codebaseIndex.artifactId,
+ );
+ warnings.push(`${friendlyName}: ${warningMsg}`);
+ console.warn(`${friendlyName}: ${warningMsg}`, err);
+
+ // Complete this batch and continue with next
+ completedOps +=
+ subResult.compute.length +
+ subResult.del.length +
+ subResult.addTag.length +
+ subResult.removeTag.length;
+ progress =
+ (completedIndexCount + completedOps / totalOps) *
+ (1 / indexesToBuild.length);
+ }
+ }
+ }
+
+ await markComplete(lastUpdated, IndexResultType.UpdateLastUpdated);
+ completedIndexCount += 1;
+ } catch (err) {
+ // Handle errors during planning phase
+ const cause = getRootCause(err as Error);
+ if (cause instanceof LLMError) {
+ // LLM errors are critical, re-throw them
+ throw cause;
+ }
+
+ // Collect planning errors as warnings and continue to next index
+ const errorMsg = err instanceof Error ? err.message : String(err);
+ const friendlyName = this.getUserFriendlyIndexName(
+ codebaseIndex.artifactId,
+ );
+ warnings.push(`${friendlyName}: ${errorMsg}`);
+ console.warn(
+ `Warning during ${codebaseIndex.artifactId} planning:`,
+ err,
+ );
+ completedIndexCount += 1;
+ progress = completedIndexCount * (1 / indexesToBuild.length);
+ }
+ }
+
+ // Final update with any collected warnings
+ if (warnings.length > 0) {
+ yield {
+ progress: 1,
+ desc: `Indexing completed with ${warnings.length} warning(s)`,
+ status: "done",
+ warnings: [...warnings],
+ };
}
}
diff --git a/core/indexing/FullTextSearchCodebaseIndex.ts b/core/indexing/FullTextSearchCodebaseIndex.ts
index 1bac74e4a..8016d04d3 100644
--- a/core/indexing/FullTextSearchCodebaseIndex.ts
+++ b/core/indexing/FullTextSearchCodebaseIndex.ts
@@ -55,7 +55,6 @@ export class FullTextSearchCodebaseIndex implements CodebaseIndex {
for (let i = 0; i < results.compute.length; i++) {
const item = results.compute[i];
-
// Insert chunks
const chunks = await db.all(
"SELECT * FROM chunks WHERE path = ? AND cacheKey = ?",
@@ -68,7 +67,7 @@ export class FullTextSearchCodebaseIndex implements CodebaseIndex {
[item.path, chunk.content],
);
await db.run(
- `INSERT INTO fts_metadata (id, path, cacheKey, chunkId)
+ `INSERT INTO fts_metadata (id, path, cacheKey, chunkId)
VALUES (?, ?, ?, ?)
ON CONFLICT(id) DO UPDATE SET
path = excluded.path,
diff --git a/core/indexing/README.md b/core/indexing/README.md
index 2a7375f00..94bf196aa 100644
--- a/core/indexing/README.md
+++ b/core/indexing/README.md
@@ -20,10 +20,10 @@ The indexing process does the following:
All indexes must be returned by `getIndexesToBuild` in [`CodebaseIndexer.ts`](./CodebaseIndexer.ts) if they are to be used.
-`CodeSnippetsCodebaseIndex`: uses tree-sitter queries to get a list of functions, classes, and other top-level code objects in each file
+`CodeSnippetsIndex`: uses tree-sitter queries to get a list of functions, classes, and other top-level code objects in each file
`FullTextSearchCodebaseIndex`: creates a full-text search index using SQLite FTS5
-`ChunkCodebaseIndex`: chunks files recursively by code structure, for use in other embeddings providers like `LanceDbCodebaseIndex`
-`LanceDbCodebaseIndex`: calculates embeddings for each chunk and adds them to the LanceDB vector database, with metadata going into SQLite. Note that for each branch, a unique table is created in LanceDB.
+`ChunkCodebaseIndex`: chunks files recursively by code structure, for use in other embeddings providers like `LanceDbIndex`
+`LanceDbIndex`: calculates embeddings for each chunk and adds them to the LanceDB vector database, with metadata going into SQLite. Note that for each branch, a unique table is created in LanceDB.
## Known problems
diff --git a/gui/src/pages/config/IndexingProgress/IndexingProgress.tsx b/gui/src/pages/config/IndexingProgress/IndexingProgress.tsx
index 7b80f7dde..6347409c1 100644
--- a/gui/src/pages/config/IndexingProgress/IndexingProgress.tsx
+++ b/gui/src/pages/config/IndexingProgress/IndexingProgress.tsx
@@ -1,17 +1,18 @@
import { IndexingProgressUpdate } from "core";
+import { usePostHog } from "posthog-js/react";
import { useContext, useEffect, useState } from "react";
import { useDispatch } from "react-redux";
-import { IdeMessengerContext } from "../../../context/IdeMessenger";
-import { isJetBrains } from "../../../util";
-import { useWebviewListener } from "../../../hooks/useWebviewListener";
-import IndexingProgressBar from "./IndexingProgressBar";
-import IndexingProgressIndicator from "./IndexingProgressIndicator";
-import IndexingProgressTitleText from "./IndexingProgressTitleText";
-import IndexingProgressSubtext from "./IndexingProgressSubtext";
-import { usePostHog } from "posthog-js/react";
+
import ConfirmationDialog from "../../../components/dialogs/ConfirmationDialog";
-import { setShowDialog, setDialogMessage } from "../../../redux/slices/uiSlice";
+import { IdeMessengerContext } from "../../../context/IdeMessenger";
+import { useWebviewListener } from "../../../hooks/useWebviewListener";
+import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
+import { isJetBrains } from "../../../util";
+import IndexingProgressBar from "./IndexingProgressBar";
import IndexingProgressErrorText from "./IndexingProgressErrorText";
+import IndexingProgressIndicator from "./IndexingProgressIndicator";
+import IndexingProgressSubtext from "./IndexingProgressSubtext";
+import IndexingProgressTitleText from "./IndexingProgressTitleText";
export function getProgressPercentage(
progress: IndexingProgressUpdate["progress"],
@@ -119,7 +120,8 @@ function IndexingProgress() {