From 28698fe853035b3d1a115860a6a8ad4a40e27c51 Mon Sep 17 00:00:00 2001 From: mondaychen Date: Tue, 23 Apr 2024 10:48:46 -0400 Subject: [PATCH] fix: early filter for default knowledge without notes --- src/common/CustomKnowledgeBase/DefaultKnowledge.tsx | 9 +++++++-- src/common/CustomKnowledgeBase/HostKnowledge.tsx | 7 ------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/common/CustomKnowledgeBase/DefaultKnowledge.tsx b/src/common/CustomKnowledgeBase/DefaultKnowledge.tsx index 9d3f980..33289c6 100644 --- a/src/common/CustomKnowledgeBase/DefaultKnowledge.tsx +++ b/src/common/CustomKnowledgeBase/DefaultKnowledge.tsx @@ -16,7 +16,12 @@ import HostKnowledge from "./HostKnowledge"; const DefaultKnowledge = () => { const { isOpen, onOpen, onClose } = useDisclosure(); const defaultKnowledgeBase = fetchAllDefaultKnowledge(); - + // some default knowledge may not have notes, filter them out + const hosts = Object.keys(defaultKnowledgeBase).filter((host) => + defaultKnowledgeBase[host]?.rules?.some( + (rule) => (rule.knowledge?.notes?.length ?? 0) > 0, + ), + ); return ( <>