From de2d0c187ffe460b3fe75849f787277b07a3fe18 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 5 Jul 2025 09:53:53 -0700 Subject: [PATCH] parse incorrectly formatted vectors so we can salvage broken indexes --- core/indexing/LanceDbIndex.ts | 19 ++++++++++++++++++- gui/src/redux/slices/sessionSlice.ts | 1 - 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/core/indexing/LanceDbIndex.ts b/core/indexing/LanceDbIndex.ts index facaba2f1..e01518629 100644 --- a/core/indexing/LanceDbIndex.ts +++ b/core/indexing/LanceDbIndex.ts @@ -234,6 +234,23 @@ export class LanceDbIndex implements CodebaseIndex { return results; } + /** + * Due to a bug in indexing, some indexes have vectors + * without the surrounding []. These would fail to parse + * but this allows such existing indexes to function properly + */ + private parseVector(vector: string): number[] { + try { + return JSON.parse(vector); + } catch (err) { + try { + return JSON.parse(`[${vector}]`); + } catch (err2) { + throw new Error(`Failed to parse vector: ${vector}`, { cause: err2 }); + } + } + } + async *update( tag: IndexTag, results: RefreshIndexResults, @@ -297,7 +314,7 @@ export class LanceDbIndex implements CodebaseIndex { const lanceRows: LanceDbRow[] = []; for (const item of cachedItems) { try { - const vector = JSON.parse(item.vector); + const vector = this.parseVector(item.vector); const { uuid, startLine, endLine, contents } = item; lanceRows.push({ diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 6cd96dd8e..45d68b456 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -405,7 +405,6 @@ export const sessionSlice = createSlice({ } } else if (message.role === "thinking" && message.signature) { if (lastMessage.role === "thinking") { - console.log("add signature", message.signature); lastMessage.signature = message.signature; } } else if (