Remove document's content from ModelDB #11602
Labels
api-change
A change that should be accompanied by a major version increase
enhancement
tag:Real Time Collaboration
Follows #11434
Problem
Currently, we have the document's content triplicated in the editor, ModelDB and YJS. I.e., the same content is mirrored in different data structures. This means that every time one of the models changes, we must update all other models to keep them in sync. This approach is very complex and prone to bugs. As commented several times, we need to remove the content from ModelDB and use only the shared models to manipulate it. This will allow us to simplify the existing code. For extension authors, this means that the API will change.
Proposed Solution
The idea is to open multiple PRs to remove attributes from ModelDB and keep them only in the shared models. Some of the changes are:
Remove document's content:
Remove document's metadata:
IObservableJSON
namedmetadata
. We want to remove this attribute from ModelDB to use its equivalent from the shared model:jupyterlab/packages/notebook/src/model.ts
Line 108 in 014091f
jupyterlab/packages/shared-models/src/ymodels.ts
Line 472 in 014091f
jupyterlab/packages/cells/src/model.ts
Lines 185 to 187 in 014091f
jupyterlab/packages/shared-models/src/ymodels.ts
Line 625 in 014091f
readonly metadata: IObservableJSON
->readonly metadata: nbformat.INotebookMetadata
jupyterlab/packages/notebook/src/model.ts
Line 65 in 014091f
jupyterlab/packages/notebook/src/model.ts
Lines 165 to 167 in 014091f
jupyterlab/packages/cells/src/model.ts
Line 65 in 014091f
jupyterlab/packages/cells/src/model.ts
Lines 251 to 253 in 014091f
IObservableJSON
extends fromIObservableMap
, this means that we can change and listen to changes in specific attributes of the metadata. With the new implementation, this won't be possible since in the shared models we need to replace the whole metadata object every time we want to add|remove|update an attribute. The reason is to avoid inconsistent states of the metadata, for example when one client is changing the execution count while another is switching the type of the cell to a markdown. The metadata could end up being a markdown cell with the attributeexecutionCount
.Remove cell's outputs:
The text was updated successfully, but these errors were encountered: