Repository navigation
🐛 Fix: Remove lag when copying and pasting nodes - #436
Conversation
…or better notification handling
|
MFA-X-AI
left a comment
There was a problem hiding this comment.
Other than the short comment, it does seem to be working.
I was worried that
const getEngine = useCallback(() => xircuitsApp.getDiagramEngine(), [xircuitsApp]);
useNodeNotice(getEngine);
this implementation could be triggered on every render, but it properly only triggers on notification errors. I confirm that the other notifications spawns properly too.
So aside from that small case update, could you also update the outdated main PR message to reflect the changes? Just copy paste the comment you've made after the requested fixes.
|
Thanks for the review! |
Description
Cause of the issue:
Introduced in PR #424 — In
xircuitsbodywidget, the line:CustomPortModel.attachEngine(deserializedModel, engine);
caused noticeable lag during copy/paste because it iterated over all ports in the diagram after deserialization and reassigned the engine to them all at once.
What was done:
Replaced all
showNodeCenteringNotificationcalls insideCustomPortModel.tsonly withemitPortNotice.Added a listener in the UI (
XircuitsBodyWidget.tsx) using theuseNodeNoticehook to receive events and callshowNodeCenteringNotificationwith the current engine.Prevent passing/storing the
engineinside ports (caused previous lag/memory leak).Filter notifications using
modelIdto ensure they appear only in the correct canvas when multiple tabs are open.CustomPortModelnow triggersemitPortNotice({ message, nodeId, modelId })instead of direct calls.In
XircuitsBodyWidget.tsx, kept usingshowNodeCenteringNotificationfor places that already have anenginereference.Left
showNodeCenteringNotificationcalls in.tsxfiles that own theenginesince this is safe and doesn't cause memory leaks.Pull Request Type
Type of Change
Tests
0. Performance Stress Test
1. In-to-In Port Connection Check
InPortstogether."Link cannot be created between inPorts."2. Triangle Port Link Check
"Flow ports (▶) can only connect to other flow ports (▶)."3. Invalid Link Direction
"Link should be created from an outPort to an inPort."4. Data Type Mismatch
5. InPort Already Connected
"You can only create one link for this inPort..."6. Last Node is Not “Finish”
"Please make sure this \"<name>\" node ends with a \"Finish\" node."7. Unconnected ★ InPort
"Please make sure the [★]COMPULSORY InPorts are connected."8. Component Path Error
"Component could not be loaded from path..."Tested on? Specify Version.