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: unmount sigma during panel drag resize via data attribute signal

nash_su4b59f83be255
diff --git a/src/components/graph/graph-view.tsx b/src/components/graph/graph-view.tsx
index e1ba2ac8..04863b11 100644
--- a/src/components/graph/graph-view.tsx
+++ b/src/components/graph/graph-view.tsx
@@ -409,9 +409,11 @@ export function GraphView() {
setResearchDialog(null)
}, [researchDialog])
- // Pre-emptively unmount sigma BEFORE layout changes that would resize the container.
- // Sigma's WebGL context crashes when canvas is resized ("could not find suitable program").
- // We watch the store values that cause right panel to appear/disappear.
+ // Unmount sigma when panels resize or toggle to prevent WebGL crash.
+ // Sigma crashes with "could not find suitable program for node type circle"
+ // when its canvas is resized by external layout changes.
+
+ // 1. Detect panel open/close (selectedFile, researchPanel, insights)
const selectedFileForLayout = useWikiStore((s) => s.selectedFile)
const researchPanelForLayout = useResearchStore((s) => s.panelOpen)
const layoutKey = `${!!selectedFileForLayout}-${researchPanelForLayout}-${showInsights}`
@@ -420,7 +422,6 @@ export function GraphView() {
useEffect(() => {
if (prevLayoutKey.current !== layoutKey) {
prevLayoutKey.current = layoutKey
- // Layout is about to change — unmount sigma immediately
setIsResizing(true)
const timer = setTimeout(() => {
setSigmaKey((k) => k + 1)
@@ -430,6 +431,25 @@ export function GraphView() {
}
}, [layoutKey])
+ // 2. Detect panel drag resize via data-panel-resizing attribute on body
+ useEffect(() => {
+ const observer = new MutationObserver(() => {
+ const dragging = document.body.dataset.panelResizing === "true"
+ if (dragging && !isResizing) {
+ setIsResizing(true)
+ }
+ if (!dragging && isResizing) {
+ // Drag ended — remount sigma after a tick
+ setTimeout(() => {
+ setSigmaKey((k) => k + 1)
+ setIsResizing(false)
+ }, 50)
+ }
+ })
+ observer.observe(document.body, { attributes: true, attributeFilter: ["data-panel-resizing"] })
+ return () => observer.disconnect()
+ }, [isResizing])
+
// Count nodes by type for legend
const typeCounts = nodes.reduce<Record<string, number>>((acc, n) => {
acc[n.type] = (acc[n.type] ?? 0) + 1
diff --git a/src/components/layout/app-layout.tsx b/src/components/layout/app-layout.tsx
index afc70ecf..ed8344dd 100644
--- a/src/components/layout/app-layout.tsx
+++ b/src/components/layout/app-layout.tsx
@@ -47,6 +47,7 @@ export function AppLayout({ onSwitchProject }: AppLayoutProps) {
else isDraggingRight.current = true
document.body.style.cursor = "col-resize"
document.body.style.userSelect = "none"
+ document.body.dataset.panelResizing = "true"
const handleMouseMove = (e: MouseEvent) => {
if (!containerRef.current) return
@@ -69,6 +70,7 @@ export function AppLayout({ onSwitchProject }: AppLayoutProps) {
isDraggingRight.current = false
document.body.style.cursor = ""
document.body.style.userSelect = ""
+ delete document.body.dataset.panelResizing
document.removeEventListener("mousemove", handleMouseMove)
document.removeEventListener("mouseup", handleMouseUp)
}