jupyterlab / jupyter-collaboration

A Jupyter Server Extension Providing Support for Y Documents
https://jupyterlab-realtime-collaboration.readthedocs.io/en/latest/
Other
157 stars 30 forks source link

Support suggestions #292

Open davidbrochart opened 5 months ago

davidbrochart commented 5 months ago

Supersedes #239 (after #280 I preferred openning a new PR rather than rebasing).

See https://github.com/jupyterlab/jupyterlab/issues/16008.

This PR adds a menu to the Notebook page (it should add it to every shared document in the future), which allows to choose between "Editing" and "Suggesting". The former is the current state (edit document directly), and the later is an editing mode where edits become suggestions, which is the purpose of this PR. When entering the suggesting mode, the root provider for the shared document is retrieved and a request to fork the document is done with context.model.sharedModel.provider.fork(). This triggers a PUT /api/collaboration/fork_room request with the root room ID of the document in the body. The response gives back a fork ID, which is the room ID for the forked document that is created in the backend. The forked document is a dependency of the root room, and it is kept in sync with the root document: updates to the root document are applied to the forked document, but not the other way around. The shared document is disconnected from the root provider, and connected to a new provider for the forked document. The forked document is advertised on the root Y document as a new state entry fork_{forkId}, so that other users can connect to the forked room. They can do that by calling WebSocketProvider.connect(forkId, sharedModel) on their current provider. JupyterLab shows a notification when a client enters the suggestion mode, and the user can choose to view the suggestion or remain on the root document. When viewing the suggestion, changes are synchronized with the suggester and it is also possible to collaborate on the suggestion, since it is a regular room. A user (not the suggester) can merge the suggestion or discard it in the Review menu. When merged, a PUT /api/collaboration/merge_room request is done with the fork room ID and the root room ID in the body. A menu shows which room the document is currently connect to. It can be "Root" for the root room, or the ID of a fork. Users can connect to anyone of them at any time.

github-actions[bot] commented 5 months ago

Binder :point_left: Launch a Binder on branch _davidbrochart/jupytercollaboration/suggestions2