Elffuss BraidHub

kikocis/continue public

parse incorrectly formatted vectors so we can salvage broken indexes
Changeset070dc2895891153a3f6f4e24dab008263025af380d57cbf3129ce79c64ef4b46
AuthorNate <sestinj@gmail.com> · 2025-07-05 09:53 -07:00
CommitterNate <sestinj@gmail.com> · 2025-07-05 09:53 -07:00
Parentsf840a2b4e8a4

Browse the files at this changeset

2 files changed

modified core/indexing/LanceDbIndex.ts +18 −1
@@ -234,6 +234,23 @@
234234 return results;
235235 }
236236
237+ /**
238+ * Due to a bug in indexing, some indexes have vectors
239+ * without the surrounding []. These would fail to parse
240+ * but this allows such existing indexes to function properly
241+ */
242+ private parseVector(vector: string): number[] {
243+ try {
244+ return JSON.parse(vector);
245+ } catch (err) {
246+ try {
247+ return JSON.parse(`[${vector}]`);
248+ } catch (err2) {
249+ throw new Error(`Failed to parse vector: ${vector}`, { cause: err2 });
250+ }
251+ }
252+ }
253+
237254 async *update(
238255 tag: IndexTag,
239256 results: RefreshIndexResults,
@@ -297,7 +314,7 @@
297314 const lanceRows: LanceDbRow[] = [];
298315 for (const item of cachedItems) {
299316 try {
300- const vector = JSON.parse(item.vector);
317+ const vector = this.parseVector(item.vector);
301318 const { uuid, startLine, endLine, contents } = item;
302319
303320 lanceRows.push({
modified gui/src/redux/slices/sessionSlice.ts +0 −1
@@ -405,7 +405,6 @@
405405 }
406406 } else if (message.role === "thinking" && message.signature) {
407407 if (lastMessage.role === "thinking") {
408- console.log("add signature", message.signature);
409408 lastMessage.signature = message.signature;
410409 }
411410 } else if (