Skip to content
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

Merged
merged 2 commits into from
Feb 10, 2025

Conversation

billcookie
Copy link
Contributor

@billcookie billcookie commented Feb 10, 2025

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

  • New Features
    • Enhanced workflow management by integrating connection handling with node selections, ensuring that only relevant relationships are maintained during workflow additions.

Copy link
Contributor

coderabbitai bot commented Feb 10, 2025

Walkthrough

This 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

File Change Summary
ui/src/lib/yjs/useYWorkflow.ts Added import for yEdgeConstructor from ./conversions and type YEdgesArray from ./types; modified handleYWorkflowAddFromSelection to retrieve, filter, map, clear, and reinsert workflow edges.

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
Loading

Possibly related PRs

Suggested labels

worker

Suggested reviewers

  • KaWaite

Poem

I’m a bunny coding on a sunny day,
Hopping through changes in a clever new way.
Edges and nodes dance in a rhythmic spree,
With yEdgeConstructor, they’re joyful and free.
Leaping through commits with a heart so light,
Celebrating our updates with a bunny delight! 🐰

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Feb 10, 2025

Deploy Preview for reearth-flow canceled.

Name Link
🔨 Latest commit dc402b4
🔍 Latest deploy log https://app.netlify.com/sites/reearth-flow/deploys/67a94d87b66734000841fb43

@billcookie billcookie marked this pull request as ready for review February 10, 2025 00:51
@billcookie billcookie requested a review from KaWaite as a code owner February 10, 2025 00:51
Copy link
Contributor

@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)
ui/src/lib/yjs/useYWorkflow.ts (1)

243-245: Consider adding error handling and documentation.

  1. Add error handling for undefined parentWorkflowEdges
  2. 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

📥 Commits

Reviewing files that changed from the base of the PR and between 30b65c2 and dc402b4.

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

  1. Retrieves edges from parent workflow
  2. Filters out edges connected to selected nodes
  3. Cleans up and re-inserts remaining edges

Also applies to: 251-258, 259-259, 265-265

@billcookie billcookie merged commit 9a54b82 into main Feb 10, 2025
19 checks passed
@billcookie billcookie deleted the ui/subworkflow-select-deletion-edges-fix branch February 10, 2025 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants