Skip to content

LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。

TypeScript

fix: search results scrolling + add vector search logging

nash_suaa591670eadf
diff --git a/src/components/search/search-view.tsx b/src/components/search/search-view.tsx
index 2aa6a660..2e47b551 100644
--- a/src/components/search/search-view.tsx
+++ b/src/components/search/search-view.tsx
@@ -1,6 +1,5 @@
import { useState, useEffect, useRef, useCallback } from "react"
import { Search, FileText } from "lucide-react"
-import { ScrollArea } from "@/components/ui/scroll-area"
import { useWikiStore } from "@/stores/wiki-store"
import { readFile } from "@/commands/fs"
import { searchWiki, type SearchResult } from "@/lib/search"
@@ -59,8 +58,8 @@ export function SearchView() {
}
return (
- <div className="flex h-full flex-col">
- <div className="border-b px-4 py-3">
+ <div className="flex h-full flex-col overflow-hidden">
+ <div className="shrink-0 border-b px-4 py-3">
<div className="relative">
<Search className="absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
<input
@@ -74,7 +73,7 @@ export function SearchView() {
</div>
</div>
- <ScrollArea className="flex-1">
+ <div className="flex-1 overflow-y-auto">
{!query.trim() ? (
<div className="flex flex-col items-center justify-center gap-2 p-8 text-center text-sm text-muted-foreground">
<Search className="h-8 w-8 text-muted-foreground/30" />
@@ -101,7 +100,7 @@ export function SearchView() {
))}
</div>
)}
- </ScrollArea>
+ </div>
</div>
)
}
diff --git a/src/lib/embedding.ts b/src/lib/embedding.ts
index 180173ac..81aeb753 100644
--- a/src/lib/embedding.ts
+++ b/src/lib/embedding.ts
@@ -101,10 +101,14 @@ export async function embedPage(
): Promise<void> {
if (!embeddingConfig.enabled || !embeddingConfig.model) return
+ const t0 = performance.now()
const text = `${title}\n${content.slice(0, 1500)}`
const emb = await fetchEmbedding(text, llmConfig, embeddingConfig)
if (emb) {
await vectorUpsert(projectPath, pageId, emb)
+ console.log(`[Embedding] Indexed "${pageId}" (${emb.length}d) in ${Math.round(performance.now() - t0)}ms`)
+ } else {
+ console.log(`[Embedding] Failed to embed "${pageId}"`)
}
}
@@ -184,9 +188,12 @@ export async function searchByEmbedding(
if (!queryEmb) return []
try {
+ const t0 = performance.now()
const results = await vectorSearchLance(projectPath, queryEmb, topK)
+ console.log(`[Embedding] LanceDB search: ${results.length} results in ${Math.round(performance.now() - t0)}ms`)
return results.map((r) => ({ id: r.page_id, score: r.score }))
- } catch {
+ } catch (err) {
+ console.log(`[Embedding] LanceDB search failed: ${err instanceof Error ? err.message : err}`)
return []
}
}
diff --git a/src/lib/search.ts b/src/lib/search.ts
index 8d35cf87..5249ffc3 100644
--- a/src/lib/search.ts
+++ b/src/lib/search.ts
@@ -144,10 +144,21 @@ export async function searchWiki(
const { useWikiStore } = await import("@/stores/wiki-store")
const embCfg = useWikiStore.getState().embeddingConfig
if (embCfg.enabled && embCfg.model) {
+ const t0 = performance.now()
const { searchByEmbedding } = await import("@/lib/embedding")
const llmCfg = useWikiStore.getState().llmConfig
const vectorResults = await searchByEmbedding(pp, query, llmCfg, embCfg, 10)
+ const vectorMs = Math.round(performance.now() - t0)
+ console.log(
+ `[Vector Search] query="${query}" | ${vectorResults.length} results in ${vectorMs}ms | model=${embCfg.model}` +
+ (vectorResults.length > 0
+ ? ` | top: ${vectorResults.slice(0, 5).map((r) => `${r.id}(${r.score.toFixed(3)})`).join(", ")}`
+ : "")
+ )
+
+ let boosted = 0
+ let added = 0
const existingPaths = new Set(results.map((r) => r.path))
for (const vr of vectorResults) {
@@ -160,6 +171,7 @@ export async function searchWiki(
if (existing) {
// Boost score of existing result
existing.score += vr.score * 5
+ boosted++
} else {
// Try to find the file and add it
const dirs = ["entities", "concepts", "sources", "synthesis", "comparison", "queries"]
@@ -177,6 +189,7 @@ export async function searchWiki(
score: vr.score * 5,
})
existingPaths.add(tryPath)
+ added++
break
} catch {
// not in this directory
@@ -184,13 +197,21 @@ export async function searchWiki(
}
}
}
+
+ if (boosted > 0 || added > 0) {
+ console.log(`[Vector Search] Merged: ${boosted} boosted, ${added} new pages added`)
+ }
}
- } catch {
- // Vector search failed or not available, continue without it
+ } catch (err) {
+ console.log(`[Vector Search] Skipped: ${err instanceof Error ? err.message : "not available"}`)
}
// Sort by score descending
results.sort((a, b) => b.score - a.score)
+
+ const tokenCount = results.filter((r) => r.score > 0).length
+ console.log(`[Search] query="${query}" | ${tokenCount} token matches | ${results.length} total results`)
+
return results.slice(0, MAX_RESULTS)
}