-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ui): cleanup for parentworkflow edges on sub selection creation #843
Conversation
WalkthroughThis change updates the workflow management in useYWorkflow.ts by enhancing the handling of edges. The new code imports yEdgeConstructor and the YEdgesArray type, then adjusts handleYWorkflowAddFromSelection to retrieve, filter, and map edges from the parent workflow. Before inserting the new edges, the function clears existing ones to ensure that only relevant edges are retained. The update extends functionality to manage both nodes and edges when adding workflows from a selection. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant WF as Workflow Manager
participant EC as yEdgeConstructor
U->>WF: Trigger workflow addition from selection
WF->>WF: Retrieve parent workflow edges
WF->>WF: Filter edges based on selected nodes
WF->>EC: Map filtered edges using yEdgeConstructor
WF->>WF: Clear existing parent workflow edges
WF->>WF: Insert new filtered and mapped edges
WF-->>U: Return updated workflow
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
✅ Deploy Preview for reearth-flow canceled.
|
There was a problem hiding this 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)
ui/src/lib/yjs/useYWorkflow.ts (1)
243-245
: Consider adding error handling and documentation.
- Add error handling for undefined
parentWorkflowEdges
- Add comments explaining the edge cleanup logic
+ // Get edges from parent workflow const parentWorkflowEdges = parentWorkflow?.get("edges") as | YEdgesArray | undefined; + // Ensure parent workflow edges exist + if (!parentWorkflowEdges) { + console.warn("Parent workflow edges not found"); + return; + } + // Clean up all edges before inserting remaining ones to avoid duplicates parentWorkflowEdges?.delete(0, parentWorkflowEdges.length); parentWorkflowNodes?.delete(0, parentWorkflowNodes.length); parentWorkflowNodes?.insert(0, [ ...remainingNodes, newSubworkflowNode, ]); + // Re-insert only the edges that are not connected to selected nodes parentWorkflowEdges?.insert(0, remainingEdges);Also applies to: 259-259, 265-265
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
ui/src/lib/yjs/useYWorkflow.ts
(2 hunks)
🔇 Additional comments (2)
ui/src/lib/yjs/useYWorkflow.ts (2)
16-21
: LGTM!The new imports are correctly organized and necessary for the edge handling functionality.
243-245
: LGTM! Edge handling implementation successfully addresses the PR objective.The implementation correctly:
- Retrieves edges from parent workflow
- Filters out edges connected to selected nodes
- Cleans up and re-inserts remaining edges
Also applies to: 251-258, 259-259, 265-265
Overview
When subworkflows were created via selection any edges would remain on the parent if there were edges connected to selected nodes
What I've done
Added clean up for edges on handleYWorkflowAddFromSelection.
What I haven't done
How I tested
Screenshot
Which point I want you to review particularly
Memo
Summary by CodeRabbit