breadboard-ai / breadboard

A library for prototyping generative AI applications.
Apache License 2.0
190 stars 26 forks source link

Save graph window (x,y,width,height) in graph metadata #3161

Open dglazkov opened 1 month ago

dglazkov commented 1 month ago

Especially with the larger graphs, the default starting view is too zoomed out, and it's cumbersome to keep zooming in every time I reload the page (especially noticeable in vite autoreload)

image

Also wondering if we coul remember the last position of the node in the board, so that restoring/reloading brings you right where it was. Maybe this could be in the graph metadata? I could write an API.

paullewis commented 1 month ago

Maybe this could be in the graph metadata? I could write an API

That would be ideal, I think, because we currently store it per open tab in the editor, which isn't persistent. I suspect a window property on the graph metadata's visual property would be a good place to start? If it stores x, y, width, and height I can figure out the transform needed when we load the graph.

dglazkov commented 1 month ago

We now have GraphMetadata.visual.window!

Not sure what to do next though. It sounds like if we save last window position, then the graph will be edited/saved every time I zoom/pan/scroll. That sounds ... excessive maybe? Or not? Not sure.

paullewis commented 1 month ago

Well, we could differentiate saves based on visualOnly, but yeah currently every change triggers a save action. For local changes this is relatively immaterial, but for remote board servers it could get a bit chatty. We currently debounce the save so that we wait for a bit before attempting it just in case we get a burst of activity in a short space of time.

dglazkov commented 1 month ago

ok, let's try it :D