-
-
Notifications
You must be signed in to change notification settings - Fork 36
Respect autosave setting in RTC backend #479
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
base: main
Are you sure you want to change the base?
Conversation
// Force autosave to be true by default initially | ||
if (docmanagerSettings) { | ||
void docmanagerSettings.set('autosave', true); | ||
} |
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.
Wouldn't this change user's autosave setting? I think we could just take the value as-is because autosave is the default in lab and notebook.
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.
Oh, if autosave is set to true by default, then we don't need this.
Let me go ahead and remove it.
I think this makes sense. If others agree, I wonder if we should make it clear in the UI or at very least document it somehow. |
Having autosave enabled when at least one client wants it and disabled when all clients wants it doesn't make sense to me, that's why there was no choice but having autosave enabled in the first place. I have never seen this kind of behavior anywhere. Correct me if I'm wrong but all collaborative applications have autosave enabled (Google Docs...)? |
I think we can decide how to handle autosave when multiple clients are working on a document. However, what makes the most sense to me is to be able to disable autosave when the extension is installed, but I am working alone on the document. |
The difference is you can install docprovider without using RTC, this is just to have:
Forcing non-RTC users to use autosave in that scenario is not good because they may (and in fact have, which is why we opened this PR) ran into IO limitations with large enough notebooks stalling high-performance workloads. So I think what we want to achieve is to:
Quoting my earlier comment from a month ago jupyterlab/jupyterlab#14619 (comment):
Databricks also run in issues with autosaving of large notebooks and automatically disables autosave for notebooks larger than 8 MB, see https://kb.databricks.com/notebooks/notebook-autosave Here is an interesting pattern from OnlyOffice:
https://www.onlyoffice.com/blog/2020/04/save-and-force-save-in-onlyoffice-never-lose-a-document Another, one is Collabora Office where auto-save is enabled by default but can be disabled (and interval can be configured). |
@davidbrochart did you have time to think about it a bit more? Any other thoughts/suggestions? |
@@ -291,6 +292,16 @@ async def on_message(self, message): | |||
""" | |||
On message receive. | |||
""" | |||
if message == "save_to_disc": |
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.
I think that we should use a custom message type (see here). Maybe 2
followed by save
?
packages/docprovider/src/ydrive.ts
Outdated
@@ -123,7 +126,7 @@ export class RtcContentProvider | |||
const provider = this._providers.get(key); | |||
|
|||
if (provider) { | |||
// Save is done from the backend | |||
provider.wsProvider?.ws?.send('save_to_disc'); |
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.
I think that we should use a custom message type (see here). Maybe 2
followed by save
?
Also, should we wait for a reply indicating that the file has indeed been saved? Otherwise the following get
will probably not return the state of the saved file.
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.
Otherwise the following get will probably not return the state of the saved file.
True, But since the signal below is fired after each save from server (due to hash change) and the contents model is automatically updated with the new values, it may not be necessary to wait for the reply here to update the contents model.
jupyter-collaboration/packages/docprovider/src/ydrive.ts
Lines 198 to 200 in 9059310
this._ydriveFileChanged.emit({ | |
type: 'save', | |
newValue: { ...model, hash: hashChange.newValue }, |
Fixes jupyterlab/jupyterlab#14619
Previously, documents were always written to disk on changes, even if autosave was disabled. This PR fixes that by:
The related PR in
jupyterlab
re-enables manual save in RTC mode. This allows users to save explicitly when autosave is off. On manual save, the frontend sends asave_to_disc
message via the document's WebSocket provider, triggering a backend save.Note: I didn't find a way to determine which client made the change. So if any connected client has autosave enabled, the document will be saved.
Feedback on the approach is welcome!