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 suggestions #292

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

Conversation

davidbrochart
Copy link
Collaborator

@davidbrochart davidbrochart commented Apr 19, 2024

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

See jupyterlab/jupyterlab#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.

Copy link
Contributor

Binder 👈 Launch a Binder on branch davidbrochart/jupyter_collaboration/suggestions2

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.

2 participants