Conversation
…hile ignoring trailing base-class/type suffixes
WalkthroughIntroduces a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/ui/src/utils/genericHelper.js (1)
354-368: LGTM! Well-designed helper for flexible handle matching.The logic correctly addresses the use case where base-class suffixes may vary (e.g.,
A|B|CvsA|B) but should still be considered matching anchors. The example provided is clear and the implementation handles edge cases properly.Optional micro-optimization: Consider moving
stripPipeSuffixoutsidehandlesEqualto avoid recreating the closure on every call:+// Strip trailing base-class suffix if it contains pipes +const stripPipeSuffix = (s) => { + if (!s) return s + const lastDash = s.lastIndexOf('-') + if (lastDash === -1) return s + const suffix = s.substring(lastDash + 1) + return suffix.includes('|') ? s.substring(0, lastDash) : s +} + // Helper to compare handle/anchor IDs while ignoring trailing base-class/type suffixes // Example: // azureChatOpenAI_0-output-azureChatOpenAI-A|B|C vs azureChatOpenAI_0-output-azureChatOpenAI-A|B // We compare by stripping the last "-..." segment if it contains pipes. const handlesEqual = (a, b) => { if (a === b) return true - const stripPipeSuffix = (s) => { - if (!s) return s - const lastDash = s.lastIndexOf('-') - if (lastDash === -1) return s - const suffix = s.substring(lastDash + 1) - return suffix.includes('|') ? s.substring(0, lastDash) : s - } return stripPipeSuffix(a) === stripPipeSuffix(b) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/ui/src/utils/genericHelper.js(3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build
- GitHub Check: build (ubuntu-latest, 18.15.0)
🔇 Additional comments (1)
packages/ui/src/utils/genericHelper.js (1)
381-382: Verify edge preservation behavior through manual testing.The
handlesEqualimplementation at lines 358–368 correctly handles base-class suffix variations by stripping trailing "-...|..." segments before comparison. All four usages (lines 381, 382, 398, 402) apply the flexible matching consistently to determine which edges should be removed when handles no longer exist in updated node data. The logic is sound.Please manually verify through testing that:
- Edges are correctly preserved when nodes update with modified base classes (e.g.,
A|B|C→A|B)- Edges are still removed when inputs/outputs are genuinely deleted
- No false positives occur where incompatible edges remain connected
New helper function
handlesEqualto compare handle and anchor IDs while ignoring trailing base-class/type suffixesSummary by CodeRabbit