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

Support document forking #218

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

davidbrochart
Copy link
Collaborator

@davidbrochart davidbrochart commented Feb 15, 2024

See jupyterlab/jupyterlab#16008.

This PR adds an ISharedDocument.provider attribute, which is an IDocumentProvider and which represents the current provider for the document. The IDocumentProvider interface is moved from jupyter-collaboration to jupyter_ydoc (see jupyterlab/jupyter-collaboration#239). I think this is fine since jupyter-collaboration depends on jupyter_ydoc. A YDocument can only have one provider at a time (as before), but the provider can change over time. This is typically done when forking a document: the initial provider (set by the YDrive) connects to the root document, and the new provider connects to the forked document.
An ISharedDocument has a root room ID rootRoomId which is set when first connecting to the root room, and a current room ID currentRoomId which can be the root room ID or any other fork of the root room. This way we can say if the document is currently on a fork or on the root, and we know to which (root) room to merge when on a fork.
An ISharedDocument has an addFork(forkId) method that sets a key fork_{forkId} on the Y document's state when the provider is asked to fork. This is a way to advertise all the forks of this document, so that any client viewing the document can be notified of a new fork and can connect to it.

@davidbrochart davidbrochart marked this pull request as draft February 15, 2024 13:38
@davidbrochart davidbrochart added the enhancement New feature or request label Feb 15, 2024
@davidbrochart davidbrochart changed the title Add YDocument.providers attribute Support document forking Feb 23, 2024
@davidbrochart davidbrochart marked this pull request as ready for review March 19, 2024 09:57
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

Successfully merging this pull request may close these issues.

1 participant