From 82f6d87adb4848fbe54dd07c7053cc34abc11879 Mon Sep 17 00:00:00 2001 From: ved015 Date: Fri, 6 Mar 2026 22:52:17 +0530 Subject: [PATCH] perf(memory-graph): optimize empty document node check using some() --- 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 cb17104c2..f0ac58bbd 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 07895a201..97b0a604b 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} )}