Skip to content

⚡ Bolt: NodeInputs Edge Selection Optimization#2109

Open
georgi wants to merge 1 commit intomainfrom
bolt-nodeinputs-perf-2389702828674086179
Open

⚡ Bolt: NodeInputs Edge Selection Optimization#2109
georgi wants to merge 1 commit intomainfrom
bolt-nodeinputs-perf-2389702828674086179

Conversation

@georgi
Copy link
Collaborator

@georgi georgi commented Mar 14, 2026

⚡ Bolt: NodeInputs Edge Selection Optimization

💡 What

Refactored NodeInputs.tsx to use a custom memoized selector useConnectedEdgesSelector instead of subscribing directly to state.edges via useNodes and filtering inline.

🎯 Why

NodeInputs previously subscribed to the entire state.edges array. Because React Flow updates the node/edge state on every frame during drag operations (60fps), state.edges constantly changed reference.
This caused all node input components to fully re-render on any graph edge change, even if the new edge was completely unrelated to that node.
By using a dedicated selector that returns a stable array reference when connected edges are identical, we eliminate these O(N*E) re-renders during interactions.

📊 Impact

  • Eliminates Unnecessary Computations: Prevents O(N*E) array iterations per graph update.
  • Prevents Unnecessary Re-renders: Fixes NodeInputs so it only re-renders when its specific connection state changes, not on any graph edge change.
  • Improved Responsiveness: Frees up main thread time for smoother graph interactions, particularly when dragging nodes with many dynamic inputs.

🔬 Measurement

Verified using a performance regression test.

  • Before: Adding an unrelated edge caused NodeInputs wrapper to re-render.
  • After: Adding an unrelated edge does NOT cause NodeInputs wrapper to re-render.

🧪 Testing

  • Created web/src/hooks/nodes/__tests__/useConnectedEdges.test.ts to verify stable references.
  • Created web/src/components/node/__tests__/NodeInputs.performance.test.tsx to verify NodeInputs render counts.
  • Ran cd web && npm run typecheck: Passed.
  • Ran cd web && npm run lint: Passed.
  • Ran make test-web: All tests passed.

PR created automatically by Jules for task 2389702828674086179 started by @georgi

Co-authored-by: georgi <19498+georgi@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@cloudflare-workers-and-pages
Copy link

Deploying nodetool with  Cloudflare Pages  Cloudflare Pages

Latest commit: 40a4058
Status: ✅  Deploy successful!
Preview URL: https://bacb73cd.nodetool.pages.dev
Branch Preview URL: https://bolt-nodeinputs-perf-2389702.nodetool.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

Deploying nodetool-staging with  Cloudflare Pages  Cloudflare Pages

Latest commit: 40a4058
Status: ✅  Deploy successful!
Preview URL: https://2e7280af.nodetool-staging.pages.dev
Branch Preview URL: https://bolt-nodeinputs-perf-2389702.nodetool-staging.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant