Skip to content

Bugfix/Sync Nodes Disconnect Edges#5391

Merged
HenryHengZJ merged 1 commit intomainfrom
bugfix/Sync-Nodes-Disconnect-Edge
Oct 30, 2025
Merged

Bugfix/Sync Nodes Disconnect Edges#5391
HenryHengZJ merged 1 commit intomainfrom
bugfix/Sync-Nodes-Disconnect-Edge

Conversation

@HenryHengZJ
Copy link
Contributor

@HenryHengZJ HenryHengZJ commented Oct 30, 2025

New helper function handlesEqual to compare handle and anchor IDs while ignoring trailing base-class/type suffixes

Summary by CodeRabbit

  • Bug Fixes
    • Improved identifier matching logic for nodes with type suffixes, enhancing accuracy when processing node connections with extended naming conventions.

…hile ignoring trailing base-class/type suffixes
@coderabbitai
Copy link

coderabbitai bot commented Oct 30, 2025

Walkthrough

Introduces a new handlesEqual helper function in the edge update logic that compares IDs while ignoring optional trailing segments containing pipes. The function replaces two direct ID comparison sites for more flexible matching of input and output anchors.

Changes

Cohort / File(s) Summary
Helper function for flexible ID comparison
packages/ui/src/utils/genericHelper.js
Adds handlesEqual helper to compare IDs with optional trailing "-..." suffix containing pipes ignored. Replaces two direct ID equality checks in updateOutdatedNodeEdge for locating inputParams/inputAnchors and outputAnchors options, enabling matches on IDs differing only by base-class/type suffixes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single file with isolated helper function addition
  • Applied consistently to two comparison sites
  • Logic is straightforward but requires understanding edge handle naming conventions and the purpose of trailing suffixes

Poem

A rabbit hops through node-edge connections bright,
With handlesEqual to smooth the fitting night,
Suffixes stripped like whiskers caught in snow,
IDs now dance where base-class shadows flow. 🐰✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "Bugfix/Sync Nodes Disconnect Edges" is clearly related to the changeset. The main change introduces a new handlesEqual helper function that allows proper ID comparison by ignoring trailing base-class/type suffixes, which directly addresses the issue of nodes disconnecting edges during synchronization. The title describes the functional outcome and problem being fixed, which aligns with the actual change in the codebase. While the title doesn't explicitly mention the technical implementation (the new helper function), it appropriately captures the primary business impact of the fix, making it relevant and understandable to reviewers scanning the history.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/Sync-Nodes-Disconnect-Edge

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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|C vs A|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 stripPipeSuffix outside handlesEqual to 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5df09a1 and 97adc4d.

📒 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 handlesEqual implementation 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:

  1. Edges are correctly preserved when nodes update with modified base classes (e.g., A|B|CA|B)
  2. Edges are still removed when inputs/outputs are genuinely deleted
  3. No false positives occur where incompatible edges remain connected

@HenryHengZJ HenryHengZJ merged commit c99d870 into main Oct 30, 2025
3 checks passed
@HenryHengZJ HenryHengZJ deleted the bugfix/Sync-Nodes-Disconnect-Edge branch October 31, 2025 12:07
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.

Tool sync after deployment from 2.2.7-patch to 3.0.8 breaks flow with unknown bindTool | disconnects required tool

1 participant