influxdata / ui

UI for InfluxDB
92 stars 41 forks source link

move notebook storage layer to yjs #2818

Open drdelambre opened 2 years ago

drdelambre commented 2 years ago

we currently store our notebooks in localstorage, pool the change events, and push changes to persist in postgres. This effectively has a "last save wins" resource model on the api level, where the last user to save an open notebook without refreshing the state will wipe out the work of all other users. As a prereq for multiple users being able to work off the same notebook, we need a persistance model that isn't so prone to data loss through update collisions. This is typically done through either resource locking (only one person can edit at a time), operational transforms (atomic collision resolution), or crdts (magic). of these solutions, the one that offers the best user experience with the least ux intrusion, and with fun things like offline support (surviving a phone going through a tunnel while typing, not like.. off grid notebooks) or audit logging / undo history for notebooks, would be an implementation of CRDT using the yjs library.

to fully get sharing, we're going to have to implement a redis chatroom server over websockets, but before we can start iterating on that design, we need the frontend storage mechanism to be defined in yjs so that we can start generating the events.

the outcome of this should keep the notebooks current feature of syncing between tabs on the same browser, and still save notebooks to postgres while we write the chat room nodes

asalem1 commented 2 years ago

Y.doc() should be a reference on the IDs for the flows list and the panels list

asalem1 commented 2 years ago

Moving this back into in progress since we're now trying to transition to syncing data a little differently

asalem1 commented 2 years ago

Moving this into blocked until we can figure out what the heck is going on with the services

asalem1 commented 2 years ago

Finished this with the latest PR to the API.