silverbullet icon indicating copy to clipboard operation
silverbullet copied to clipboard

Support for operational transformation sync instead of full-page sync (page merging)

Open jcgurango opened this issue 7 months ago • 3 comments

I use SilverBullet regularly from multiple devices - phone, multiple laptops, and my main PC. For a use case like this, the syncing feels a bit lacking - because changes need to go from device -> SilverBullet -> other devices, there's a bit of a time delay which usually isn't very long but sometimes it's long enough to disrupt anything I was writing. Additionally, if a device is temporarily offline for a few moments I could be typing something out only to see it disappear when it comes back online. I think many of these issues can be solved by implementing some sort of page merging, similar to how Google Docs or live TipTap editors do it. CodeMirror already has support for something called Operational Transformation so I think it could be integrated into SilverBullet. The basic principle is something like this:

  1. There is a central authority, in this case the SilverBullet server.
  2. When a client first opens a page, it will retrieve the full page contents.
  3. From then on, all edit operations will be recorded as atomic updates.
  4. The client will also listen and wait for any updates from the server.
  5. On sync time, instead of sending the full page contents, the client will send its pending updates.
  6. The server will then apply these changes to its own version of the page, and forward the pending updates to other clients.

For updates made to the server file system directly, the server would technically also be the client here (it would do the atomic updates and then forward that onto the clients)

I could implement this myself, but I'm opening this issue to get everybody's thoughts, any drawbacks you all might foresee, and any history of trying to implement this so I can avoid any mistakes that may have already been made in the past.

jcgurango avatar Aug 01 '24 06:08 jcgurango