jupyter-server / jupyter_ydoc

Jupyter document structures for collaborative editing using Yjs/pycrdt
https://jupyter-ydoc.readthedocs.io
BSD 3-Clause "New" or "Revised" License
25 stars 16 forks source link

Add optional origin to transaction, filter out 'modeldb' origin #246

Closed davidbrochart closed 1 week ago

davidbrochart commented 1 week ago

In https://github.com/jupyterlab/jupyterlab/pull/16498 JupyterLab will handle cell outputs in a better way. Previously, the assumption was that only the frontend could modify a document (apart from the initial loading), but with server-side execution this is not true anymore. Thus changes to the Y model must be observed and modelDB must be changed accordingly. But in turns, changes to modelDB must also be applied to the Y model, so in order to break this circular dependency, we must use Yjs's origins to not apply a change initiated by modelDB to modelDB again. In this PR, the origin that identifies a change from modelDB is the string "modeldb". A change with this origin will not emit a change signal.

Zsailer commented 1 week ago

Looks good to me @davidbrochart. Thanks!