fix: resolve FBD editor infinite render loop causing high CPU#651
Conversation
Strip hasDivergence UI property from store comparisons to prevent isEqual mismatch (undefined vs false) that triggered continuous re-renders. Use selective Zustand selectors and memoize divergence computation in FbdEditor wrapper. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Case-sensitivity mismatch in type filtering: getVariableRestrictionType returns user-defined types in original case (e.g. "Irrigation_State") but the filter lowercased only the variable side, causing the comparison to always fail. Normalize both sides with .toLowerCase(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
Disabled knowledge base sources:
WalkthroughThe PR fixes case-sensitivity issues in autocomplete variable type filtering across FBD and ladder editors, and refactors divergence calculation logic in FBD components using memoization while introducing data cleaning to strip divergence flags from node state. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
hasDivergenceUI property from store comparisons inupdateRungStateto preventisEqualmismatch (undefinedvsfalse) that triggered a continuous render loopFbdEditorwrapper instead of whole-store destructuring to avoid unnecessary re-rendersuseMemoto prevent recalculation on every renderstyledEdgesdependencies from entireprojectobject to onlypouRef?.data.variablesandproject.data.configuration.resource.instancesThese are the same fixes applied in openplc-web (PR #266, merged).
Root Cause
The
hasDivergenceproperty was set on nodes for UI display but leaked into store comparisons.isEqual({hasDivergence: undefined}, {hasDivergence: false})always returnedfalse, causingupdateRungStateto write back to the store on every comparison cycle, which triggeredflow.updated = true→updatePou→ pous change → FbdEditor re-render → loop.Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Performance