-
Notifications
You must be signed in to change notification settings - Fork 6
Handle YDoc reset & out-of-band changes in notebooks #93
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
Handle YDoc reset & out-of-band changes in notebooks #93
Conversation
|
@3coins Thanks for testing & finding these issues! Really appreciate your time doing so. I was able to use this afternoon to review all of the Jupyter AI PRs that built up last week.
|
|
I can anticipate that we will get more bug reports about exceptions like this: We ought to add a |
|
Opened a new issue to track file deletion handling: #96. |
|
First bug appears related to the attempted fix for #76, i.e. saving on some I'll see if I can find a fix for #76 using a different approach. If not, I think I will revert my attempted fix to resolve the first bug, then address #76 in the future. |
Partially fixes #76 where the "unsaved changes" icon appears when a notebook is opened. The bug no longer appears after a notebook is opened for the *first* time, but still appears after closing & re-opening the notebook across the server session.
c267ceb to
7846e7e
Compare
|
@3coins Fixed the first bug that you reported. Using 2 editors for the same notebook file no longer causes an infinite loop. I will show the key line that needed to be removed in a follow-up comment. There are still a few bugs, but they are either minor or complex enough to deserve a separate PR. I'll document these here for now:
I spent an extra hour trying to fix 3), but I could not find the cause of this bug. It seems to have something to do with notebook UI virtualization, but the source code is over 2000 lines long. The exception has no impact on the user experience as far as I can tell, so I think this is safe to ignore for now. I started today at 7:30am so I have to log off. Will open issues for these once I'm back. |
|
|
||
| const state = this._sharedModel.ydoc.getMap('state'); | ||
| state.set('document_id', this._yWebsocketProvider.roomname); |
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.
Removing these lines was what fixed the first bug you reported.
Basically, opening the file in a second editor would cause ydoc.state['document_id'] to bounce back and forth between the text:file:... and json:notebook:....
I verified that ydoc.state['document_id'] is not used in JupyterLab or anywhere else. It is exclusive to the docprovider in jupyter_collaboration, which we override.
|
I also changed the implementation to not create a new So, I found a new way to refresh the notebook UI without creating a new |
3coins
left a comment
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.
@dlqqq
Thanks for the hard work on this PR, and documenting all the scenarios. I concur with all your findings, I could replicate them, but overall I think this is a huge improvement compared to before. Also, don't see any regression on the existing non oob experience. Great job! 🎉
|
@3coins Thank you as well for opening an issue for the new bug you found. I've opened 3 follow-up issues for the bugs I discovered yesterday:
Merging this PR now. 🎉 |



Description
This PR adds YDoc reset / out-of-band change handling for notebooks. To do so, this PR adds a new
ResettableNotebookclass.ResettableNotebookinherits from theNotebookwidget provided by@jupyterlab/notebook.resetSignalimplemented by a customYNotebookclass incustom_ydocs.ts.resetSignalis emitted to, as done in Handle document resets / out-of-band changes on text files #83.ResettableNotebookclass is made the default by implementing thecreateNotebook()method inRtcNotebookContentFactory, which already overrides the defaultNotebookfactory.Demo
Screen.Recording.2025-06-02.at.10.43.16.AM.mov
Technical details
@3coins This PR modifies the source code structure slightly. The
src/notebook.tsfile has been split into multiple files under thesrc/notebook-factorydirectory:Regarding issue #76: I managed to fix the issue when opening the notebook for the first time in a server session. However, after re-opening the notebook, the dirty "unsaved changes" indicator still appears. Will investigate further to see if I can find a fix.