jupyter-server / pycrdt

CRDTs based on Yrs.
https://jupyter-server.github.io/pycrdt
MIT License
49 stars 14 forks source link

Rehyrdating remote Doc data structures #194

Closed benrudolph closed 3 hours ago

benrudolph commented 3 days ago

Description

When applying an update from one doc to another, the second doc loses its data structures. This makes it challenging to read the original text.

Reproduce

See:

In [17]: from pycrdt import Doc as YDoc

In [18]: doc = YDoc()

In [19]: doc['text'] = Text('Hello world')

In [20]: other = YDoc()

In [21]: other.apply_update(doc.get_update())

In [22]: dict(doc)
Out[22]: {'text': <pycrdt._text.Text at 0x2a7224910>}

In [23]: dict(other)
Out[23]: {'text': None}

In the example above, you can't actually get the text in the text key. It just returns None.

Expected behavior

I would expect a Text object to be returned.

Context

davidbrochart commented 1 day ago

Unfortunately this is not possible in Yrs, see: