From 9f7f415dd55c6919fc2d4e69a4897bc1c2f597a8 Mon Sep 17 00:00:00 2001 From: Vedant Mahajan Date: Sun, 8 Mar 2026 09:04:25 +0530 Subject: [PATCH] perf: Optimize array traversal for empty memory-graph documents (#770) --- apps/web/components/memory-graph/memory-graph.tsx | 2 +- packages/memory-graph/src/components/memory-graph.tsx | 2 +- packages/ui/memory-graph/memory-graph.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/web/components/memory-graph/memory-graph.tsx b/apps/web/components/memory-graph/memory-graph.tsx index cb17104c..f0ac58bb 100644 --- a/apps/web/components/memory-graph/memory-graph.tsx +++ b/apps/web/components/memory-graph/memory-graph.tsx @@ -446,7 +446,7 @@ export const MemoryGraph = ({ /> {!isLoading && - nodes.filter((n) => n.type === "document").length === 0 && + !nodes.some((n) => n.type === "document") && children}
n.type === "document").length === 0) && ( + (!data || !nodes.some((n) => n.type === "document")) && ( <>{children} )} diff --git a/packages/ui/memory-graph/memory-graph.tsx b/packages/ui/memory-graph/memory-graph.tsx index 07895a20..97b0a604 100644 --- a/packages/ui/memory-graph/memory-graph.tsx +++ b/packages/ui/memory-graph/memory-graph.tsx @@ -410,7 +410,7 @@ export const MemoryGraph = ({ {/* Show welcome screen when no memories exist */} {!isLoading && - (!data || nodes.filter((n) => n.type === "document").length === 0) && ( + (!data || !nodes.some((n) => n.type === "document")) && ( <>{children} )}