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

When a board with no visual properties is pasted into the visual editor, the default positioning is not used #2420

Open
Mearman opened this issue Jul 4, 2024 · 2 comments

Comments

@Mearman
Copy link
Collaborator

Mearman commented Jul 4, 2024

When pasting this board:

{
  "$schema": "https://raw.githubusercontent.com/breadboard-ai/breadboard/main/packages/schema/breadboard.schema.json",
  "nodes": [
    {
      "id": "input",
      "type": "input"
    },
    {
      "id": "output",
      "type": "output"
    }
  ],
  "edges": [
    {
      "from": "input",
      "to": "output",
      "in": "input",
      "out": "output"
    }
  ]
}

Default node positioning is not used and produces this
image

After Reset layout is used
CleanShot 2024-07-04 at 10 32 41

@paullewis
Copy link
Contributor

paullewis commented Jul 5, 2024

This one isn't so obvious in terms of a fix. When you paste in nodes we have to make some assumptions about their layout, specifically that they should cursor-relative. As such we have to traverse the x & y coordinates of the pasted items and then choose the left-most, we then make set that node to be where the cursor is, and finally set all other node x & y coordinates to be relative to it.

Pasting in nodes without visual metadata is akin to posting {x: 0, y: 0}, which means what we're doing is somewhat Working As Intended. For graphs generated by the API we may want to run Dagre or something as part of the serialization process, but I don't think the right approach is to have the Editor do a layout pass because that would be very unpredictable.

@paullewis
Copy link
Contributor

To clarify the last sentence, if you paste in a load of nodes then run layout, Dagre is likely to pick a "shape" for the graph you didn't necessarily anticipate. This is especially true if there are nodes already in place in the graph, and which you may not want to have moved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants