Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Y bridge between YDocs #15

Open
davidbrochart opened this issue May 10, 2022 · 1 comment
Open

Y bridge between YDocs #15

davidbrochart opened this issue May 10, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@davidbrochart
Copy link
Collaborator

Problem

One document may have different YDoc structures, e.g. a Jupyter notebook can be opened in JupyterLab as a notebook (and it will be shown nicely with cells etc.) or as a plain text document. While the text document has a relatively simple YDoc, with only a YText for the whole content, the notebook has a YArray for cells, a YMap for metadata, etc. This finer-grained structure allows to observe changes to e.g. a cell source only, and react accordingly.
While a YDoc can be synced with another YDoc of the same structure, for instance between two browsers showing the same notebook, the same document cannot be synced when opened as two different YDocs (e.g. in text/as a notebook) in the same JupyterLab.

Proposed Solution

We could create a "Y bridge", that would make syncing the two "incompatible" YDocs possible. Something that observes changes to a YDoc and translates them to the other. It will require some interpretation, e.g. when changing the cell source in a text document, we need to do the update in the appropriate cell structure in a notebook.

cc @dmonad @hbcarlos

Additional context

See jupyterlab/jupyterlab#12360 (comment).

@dmonad
Copy link

dmonad commented May 11, 2022

Interesting idea! We can do this now, as we need a central peer to perform these changes.

However, there are "invalid" document states. E.g., when the text-representation of the JSON is not formatted correctly. In this case we mustn't update the complex shared-model representation. But it would be possible to ignore invalid document states.

It might take some time to get this right. Currently, we show a warning dialog that the file has been modified on the filesystem when this happens. This is not ideal, but it is a very clean and understandable UI experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants