Skip to content

Conversation

psychedelicious
Copy link
Collaborator

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update
  • Community Node Submission

Description

feat: make primitive node titles consistent

fix(ui): fix context menu on workflow editor

There is a tricky mouse event interaction between chakra's useOutsideClick() hook (used by chakra <Menu />) and reactflow. The hook doesn't work when you click the main reactflow area.

To get around this, I've used a dirty hack, copy-pasting the simple context menu component we use, and extending it slightly to respond to a global contextMenusClosed redux action.

fix(ui): improve node rendering performance

Previously the editor was using prop-drilling node data and templates to get values deep into nodes. This ended up causing very noticeable performance degradation. For example, any text entry fields were super laggy.

Refactor the whole thing to use memoized selectors via hooks. The hooks are mostly very narrow, returning only the data needed.

Data objects are never passed down, only node id and field name - sometimes the field kind ('input' or 'output').

The end result is a much smoother node editor with very minimal rerenders. This ended up being a fairly large change but the perf was unacceptable.

Before (note the terrible lag when editing the notes):

Screen.Recording.2023-08-16.at.10.19.25.pm.mov

After:

Screen.Recording.2023-08-16.at.10.20.48.pm.mov

There is a tricky mouse event interaction between chakra's `useOutsideClick()` hook (used by chakra `<Menu />`) and reactflow. The hook doesn't work when you click the main reactflow area.

To get around this, I've used a dirty hack, copy-pasting the simple context menu component we use, and extending it slightly to respond to a global `contextMenusClosed` redux action.
Previously the editor was using prop-drilling node data and templates to get values deep into nodes. This ended up causing very noticeable performance degradation. For example, any text entry fields were super laggy.

Refactor the whole thing to use memoized selectors via hooks. The hooks are mostly very narrow, returning only the data needed.

Data objects are never passed down, only node id and field name - sometimes the field kind ('input' or 'output').

The end result is a *much* smoother node editor with very minimal rerenders.
@psychedelicious psychedelicious enabled auto-merge (rebase) August 16, 2023 12:58
@psychedelicious psychedelicious merged commit a7ba142 into main Aug 16, 2023
@psychedelicious psychedelicious deleted the feat/nodes-phase-2 branch August 16, 2023 13:04
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.

2 participants