Support JupyterLab v4.6 (Jupyter YDoc v4)#264
Merged
dlqqq merged 6 commits intoJul 8, 2026
Merged
Conversation
Widen the @jupyter/ydoc (npm) and jupyter_ydoc (Python) dependency ranges to accept v4 alongside v3, so the extension works on JupyterLab 4.6+, which ships @jupyter/ydoc v4 as its shared singleton. - package.json: @jupyter/ydoc "^2.1.3 || ^3.0.0" -> "^3.0.0 || ^4.0.0" - package.json: pin @jupyter/ydoc to ^4.0.0 in resolutions so the dev/CI build dedupes to a single v4 copy (transitive @jupyterlab/* still declare ^3); ydoc is a webpack singleton at runtime so this is build-time only. - pyproject.toml: jupyter_ydoc ">=3.0.0,<4.0.0" -> ">=3.0.0,<5.0.0" Also removes the temporary 'jupyterlab<4.6' CI ceilings added to unblock main, restoring 'jupyterlab>=4.0.0,<5' now that JSD supports ydoc v4. Closes jupyter-ai-contrib#262
45f6038 to
c242921
Compare
This was referenced Jul 7, 2026
pycrdt >=0.14 / yrs >=0.27 defers observer removal: dropping a subscription only queues the callback for removal, drained lazily on the next observe/transaction. On an idle room being torn down that drain never happens, so observer callbacks -- bound methods capturing the YRoom and its YDoc -- are never released, leaking the room. - Add rooms/yroom_utils.drain_observer_removals(): forces the pending queue to drain across every shared type reachable from the doc. - YRoom.stop(): fire on_stop callbacks first, then drain observers only after all callbacks (incl. async ones, now awaited) have completed, so consumers that unsubscribe from a stop callback are covered. Draining runs in a scheduled _finalize_stop task awaited by until_saved; stop() stays synchronous. - Bump requires-python to >=3.10. - Tests: test_yroom_utils.py (drain releases doc/root/nested observers, content-neutral, empty-doc safe) and test_yroom_gc.py (3x2 matrix: consumer freed after stop, per observer level x stop mode). This is a temporary workaround; remove once fixed upstream in pycrdt/yrs.
The YDoc v4 frontends only ship in jupyter-collaboration v5 (docprovider / collaboration-ui 3.x) and JupyterLab 4.6+. Widen the relevant bounds so JSD resolves and its labextension federates against that stack: - pyproject.toml: jupyter-collaboration-ui / jupyter-docprovider <3 -> <4 (admits the 3.x line that declares @jupyter/ydoc v4). - package.json: @jupyter/docprovider + @jupyter/collaborative-drive allow ^5.0.0-alpha.0 alongside ^4.4.0, so the built labextension shares the docprovider singleton collaboration v5 requires (^5.0.0-alpha.0). - ui-tests: bump @jupyterlab/galata ^5.4.0 -> ^5.6.0 to match JupyterLab 4.6 (5.5.x targets 4.5 and its readiness fixture hangs on 4.6).
Extend the room GC coverage so leaks in the Jupyter YDoc shared models themselves (not just consumer-added observers) are caught -- e.g. YChat previously never removed its __init__ observers, leaking the room. - test_yroom_gc.py: add TestYRoomGC (the YRoom is collected after stop) and TestYRoomSharedModelGC (the YBaseDoc model is collected), each parametrized over file/notebook/chat x graceful/immediate. The chat cases skip when jupyterlab_chat is not installed. - conftest: make_room_file / make_yroom take a (file|notebook|chat), build the right file + room_id, and create rooms via the manager factory (so YNotebookRoom is used for notebooks). Track rooms weakly so the fixture never pins a room. Give MockServerDocsApp an outputs_manager=None attribute so notebook rooms load with the outputs service disabled (the default). - unit-tests CI: install jupyterlab-chat so the YChat GC tests run. The YChat cases require the observer-cleanup fix in jupyter-chat >=0.23.0a2 (jupyterlab/jupyter-chat#463); until that releases these tests fail in CI, surfacing the leak.
Collaborator
Author
|
The new memory-leak tests added here discovered a memory leak in Jupyter Chat, fixed by jupyterlab/jupyter-chat#463. This test suite is expected to fail until that PR is merged and released as Also, although not required by this PR, jupyterlab/jupyter-chat#462 will be required for Jupyter AI v3.1 to support JupyterLab v4.6. |
Run every Python version even if one fails, so a failure on one version doesn't cancel and mask the others.
0.23.0a2 supports jupyter-collaboration v5 (so it no longer drags in a pre-YDoc-v4 stack that downgrades pycrdt to 0.13) and removes YChat's observers on unobserve() (jupyterlab/jupyter-chat#462 + #463).
Collaborator
Author
|
Jupyter Chat v0.23.0a2 is now released, downstream tests should pass. |
Collaborator
Author
|
Excellent! Merging this and releasing it now as JSD v0.3.0. This will not get pulled in automatically by Jupyter AI users as v3.0.1 has a version ceiling now. We will continue to iterate on JSD v0.3 as we approach the Jupyter AI v3.1 official release. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for Jupyter YDoc v4 to Jupyter Server Documents, along with the Jupyter Collaboration v5 / JupyterLab 4.6 stack it depends on, and hardens the project against observer-related memory leaks introduced by that upgrade.
Description
Raised version ceilings to include
jupyter_ydoc~=4.0,pycrdt~=0.14, andjupyter_collaboration~=5.0.0a0across both the lab and server extension. Identified a memory leak regression introduced bypycrdt==0.14.0(described in #270) and applied a workaround to ensure no memory leaks exist in JSD.Testing
Added a comprehensive suite of tests that rigorously guard against future memory leak regressions — coverage across different observer levels (document, root shared type, and nested shared type), and rooms backed by every shared model (
YFile,YNotebook, andYChat), asserting that consumers, rooms, and the shared models themselves are all garbage collected on teardown. CI now installs Jupyter Chat so theYChatcases run, and the E2E integration tests were updated to run against JupyterLab v4.6.Closes #262