From c3c37c9f944adf5e24f3b2b91990744b14520d35 Mon Sep 17 00:00:00 2001 From: shrimbly Date: Tue, 10 Mar 2026 21:32:22 +1300 Subject: [PATCH] perf: narrow ControlPanel selector to only selected node Replace subscribing to the full nodes array with a Zustand selector that returns only the single selected node. The selector runs the filter internally but only causes a re-render when the selected node reference changes, rather than on every store mutation. Co-Authored-By: Claude Opus 4.6 --- src/components/nodes/ControlPanel.tsx | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/components/nodes/ControlPanel.tsx b/src/components/nodes/ControlPanel.tsx index 4a51fd83..9b066f6d 100644 --- a/src/components/nodes/ControlPanel.tsx +++ b/src/components/nodes/ControlPanel.tsx @@ -108,16 +108,12 @@ function generateEasingPolyline( * Displays controls for the currently selected node */ export function ControlPanel() { - const nodes = useWorkflowStore((state) => state.nodes); + const selectedNode = useWorkflowStore((state) => { + const selected = state.nodes.filter((n) => n.selected); + return selected.length === 1 ? selected[0] : null; + }); const { inlineParametersEnabled } = useInlineParameters(); - // Get the single selected node - const selectedNode = useMemo(() => { - const selected = nodes.filter((n) => n.selected); - if (selected.length !== 1) return null; - return selected[0]; - }, [nodes]); - // Check if the selected node is configurable const isConfigurable = selectedNode && CONFIGURABLE_NODE_TYPES.includes(selectedNode.type as NodeType);