⚡ Bolt: Optimize KnowledgeGraph search and node filtering#281
Conversation
Co-authored-by: hadsern <5723837+hadsern@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Pre-indexed
nodesinto a Map (nodeMap) and a pre-lowercased string array (searchableNodes) within thefiltereduseMemoblock inKnowledgeGraph.tsx. This avoids repeatedly iterating the entire node list and allocating massive amounts of newtoLowerCase()strings on every single keydown stroke.🎯 Why: Filtering nodes array and continuously executing
toLowerCase()strings inside array iterations causes heavy CPU pressure and UI typing lag when the user queries large node datasets within the component.📊 Impact: Changing the text search loop to use pre-lowercased strings, and the specific exact-match node focus lookups to a
Mapprovides an O(1) performance and drastically removes O(N) array-scanning overheads and repetitive garbage collection from the main thread during typing events.🔬 Measurement: Verify optimization by interacting with the Filter/Find inputs in the
KnowledgeGraphcomponent and confirming no functional changes to search behavior but with eliminatedtoLowerCasestring processing overheads.PR created automatically by Jules for task 4897619608573371061 started by @hadsern