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

feat: dynamic threshold + dismissable surprising connections

nash_su7c85dede15da
diff --git a/src/components/graph/graph-view.tsx b/src/components/graph/graph-view.tsx
index e6e6bec6..a89efe89 100644
--- a/src/components/graph/graph-view.tsx
+++ b/src/components/graph/graph-view.tsx
@@ -3,7 +3,7 @@ import Graph from "graphology"
import { SigmaContainer, useLoadGraph, useRegisterEvents, useSigma } from "@react-sigma/core"
import "@react-sigma/core/lib/style.css"
import forceAtlas2 from "graphology-layout-forceatlas2"
-import { Network, RefreshCw, ZoomIn, ZoomOut, Maximize, Layers, Tag, Lightbulb, AlertTriangle, Link2 } from "lucide-react"
+import { Network, RefreshCw, ZoomIn, ZoomOut, Maximize, Layers, Tag, Lightbulb, AlertTriangle, Link2, X } from "lucide-react"
import { Button } from "@/components/ui/button"
import { useWikiStore } from "@/stores/wiki-store"
import { readFile } from "@/commands/fs"
@@ -308,6 +308,7 @@ export function GraphView() {
const [colorMode, setColorMode] = useState<ColorMode>("type")
const [showInsights, setShowInsights] = useState(false)
const [highlightedNodes, setHighlightedNodes] = useState<Set<string>>(new Set())
+ const [dismissedInsights, setDismissedInsights] = useState<Set<string>>(new Set())
const lastLoadedVersion = useRef(-1)
const loadGraph = useCallback(async () => {
@@ -428,7 +429,7 @@ export function GraphView() {
<Layers className="h-3 w-3" />
Community
</Button>
- {(surprisingConns.length > 0 || knowledgeGaps.length > 0) && (
+ {(surprisingConns.filter((c) => !dismissedInsights.has(c.key)).length > 0 || knowledgeGaps.length > 0) && (
<Button
variant={showInsights ? "secondary" : "ghost"}
size="sm"
@@ -443,7 +444,7 @@ export function GraphView() {
<Lightbulb className="h-3 w-3" />
Insights
<span className="rounded bg-muted px-1 text-[10px]">
- {surprisingConns.length + knowledgeGaps.length}
+ {surprisingConns.filter((c) => !dismissedInsights.has(c.key)).length + knowledgeGaps.length}
</span>
</Button>
)}
@@ -580,16 +581,28 @@ export function GraphView() {
Surprising Connections
</div>
<div className="flex flex-col gap-1.5">
- {surprisingConns.map((conn, i) => {
+ {surprisingConns
+ .filter((conn) => !dismissedInsights.has(conn.key))
+ .map((conn, i) => {
const ids = new Set([conn.source.id, conn.target.id])
const isActive = highlightedNodes.size === ids.size &&
[...ids].every((id) => highlightedNodes.has(id))
return (
<div
key={i}
- className={`rounded border px-2 py-1.5 cursor-pointer transition-colors ${isActive ? "bg-blue-500/15 border-blue-500/40" : "bg-muted/30 hover:bg-muted/50"}`}
+ className={`rounded border px-2 py-1.5 cursor-pointer transition-colors relative group ${isActive ? "bg-blue-500/15 border-blue-500/40" : "bg-muted/30 hover:bg-muted/50"}`}
onClick={() => setHighlightedNodes(isActive ? new Set() : ids)}
>
+ <button
+ className="absolute top-1 right-1 hidden group-hover:block p-0.5 rounded hover:bg-muted"
+ onClick={(e) => {
+ e.stopPropagation()
+ setDismissedInsights((prev) => new Set([...prev, conn.key]))
+ if (isActive) setHighlightedNodes(new Set())
+ }}
+ >
+ <X className="h-3 w-3 text-muted-foreground" />
+ </button>
<div className="font-medium text-foreground">
{conn.source.label} ↔ {conn.target.label}
</div>
diff --git a/src/lib/graph-insights.ts b/src/lib/graph-insights.ts
index 5f1f74c3..d87fd5c4 100644
--- a/src/lib/graph-insights.ts
+++ b/src/lib/graph-insights.ts
@@ -9,6 +9,7 @@ export interface SurprisingConnection {
target: GraphNode
score: number
reasons: string[]
+ key: string // stable ID for dismiss tracking
}
export interface KnowledgeGap {
@@ -40,6 +41,10 @@ export function findSurprisingConnections(
// Structural pages that link to everything — exclude from analysis
const STRUCTURAL_IDS = new Set(["index", "log", "overview"])
+ // Dynamic threshold: as wiki grows, require higher score to surface
+ const nodeCount = nodes.length
+ const dynamicThreshold = nodeCount < 20 ? 3 : nodeCount < 50 ? 4 : 5
+
const scored: SurprisingConnection[] = []
for (const edge of edges) {
@@ -90,8 +95,9 @@ export function findSurprisingConnections(
reasons.push("weak but present connection")
}
- if (score >= 3 && reasons.length > 0) {
- scored.push({ source, target, score, reasons })
+ if (score >= dynamicThreshold && reasons.length > 0) {
+ const key = [source.id, target.id].sort().join(":::")
+ scored.push({ source, target, score, reasons, key })
}
}