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
Sync dirty property between clients #11525
Conversation
Thanks for making a pull request to jupyterlab! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @hbcarlos
@hbcarlos could you add a gif demo? I think it did not work for me on binder yesterday. |
Benchmark reportThe execution time (in milliseconds) are grouped by test file, test type and browser. The mean relative comparison is computed with 95% confidence. Results table
Changes are computed with expected as reference. |
Sure, I recorded a screencast from binder: dirty-property.mp41 - When saving the document from a client, it changes for every client. |
Sorry about the delay here.
So it seems that it was the |
Please ignore the repro above it was tainted by the use of unconstrainted Sorry about the bad recording quality. Maybe the state is not synced properly when opening the notebook? It looks like the [1] prompt is missing in the newly opened notebook. |
Wow! Thanks for caching that one @krassowski! |
The problem was that the dirty className was added multiple times to the title and removed once. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good on binder now, thanks!
@meeseeksdev please backport to 3.2.x |
Co-authored-by: Carlos Herrero <carlosherrerocontact@gmail.com>
@@ -29,6 +29,9 @@ export class DocumentModel | |||
const filemodel = new models.YFile() as models.ISharedFile; | |||
this.switchSharedModel(filemodel, true); | |||
this.value.changed.connect(this.triggerContentChange, this); | |||
|
|||
(this.sharedModel as models.YFile).dirty = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hbcarlos We should avoid parsing to the concrete Y*
implementations because that is non-ideomatic.
In general, when you work with an abstraction, you shouldn't cast to the concrete implementation just to manipulate properties of the concrete implementation because that will eventually lead to issues.
In this case, we explicitly don't want to initialize shared properties whenever a user joins a session. Properties on the concrete Yjs implementation must only be initialized on the create
and createStandalone
methods.
Solves a minor bug with the dirty property when saving the document.
References
I think we never opened an issue, and I can not find the issue/PR where this bug was detected, but @jasongrout detected a bug in the dirty property while working on something else.
Code changes
Sync the dirty property using the SharedDocument and improve the initialization.
User-facing changes
Now when someone saves the document, this change is notified to every client.
Backwards-incompatible changes
Not sure. Added a new property in SharedDocument and removed a private one from DocumentWidget.
[@fcollonval] This is ok as you added something to the public API (no changes, nor deletion)