Skip to content

Add AutoLayout to NodeView using topological sort#116

Open
theolivenbaum wants to merge 1 commit intomasterfrom
jules-nodeview-autolayout-9644769049275588425
Open

Add AutoLayout to NodeView using topological sort#116
theolivenbaum wants to merge 1 commit intomasterfrom
jules-nodeview-autolayout-9644769049275588425

Conversation

@theolivenbaum
Copy link
Copy Markdown
Contributor

This PR adds an AutoLayout method to the NodeView component, enabling automatic node positioning using a dependency-free topological sorting approach.

Features:

  • Auto Layout Algorithm: Implemented using Kahn's algorithm to calculate the depth of each node in the DAG, sorting them into horizontal layers (columns) based on dependencies and spacing them appropriately to avoid overlap.
  • Toolbar Integration: Added a custom MagicWand button to the NodeView toolbar. It is injected into a floating container so it's not removed when BaklavaJS's Vue engine re-renders the DOM.
  • Sample Update: The NodeViewSample has been updated to initially scatter the nodes so the auto-layout behavior is visually demonstrable.
  • Testing: A Playwright test is included to ensure the button renders and triggers an actual layout change.

PR created automatically by Jules for task 9644769049275588425 started by @theolivenbaum

This commit adds an `AutoLayout` method to the `NodeView` component to automatically position the nodes using a dependency-free approach. The algorithm calculates the depth of each node using Kahn's algorithm for topological sorting, and groups nodes into columns (layers) based on their incoming/outgoing connections to avoid overlap and create a structured flow.

A custom `MagicWand` button is added to the toolbar to trigger this layout feature. The toolbar button is injected into a floating element adjacent to the BaklavaJS view to avoid conflicts with Vue's virtual DOM re-renders.

The NodeViewSample has been updated to scatter the nodes initially, allowing for clear visual verification of the `AutoLayout` function. A Playwright test has been added to verify that the button is rendered and the layout changes when clicked.

Co-authored-by: theolivenbaum <8791811+theolivenbaum@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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.

1 participant