Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-jupyter-server-ydoc for 
openSUSE:Factory checked in at 2026-11-26 15:53:45
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-jupyter-server-ydoc (Old)
 and      /work/SRC/openSUSE:Factory/.python-jupyter-server-ydoc.new.1340718 
(New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-jupyter-server-ydoc"

Thu Nov 26 15:53:45 2026 rev:7 rq:1400592 version:3.0.4

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-jupyter-server-ydoc/python-jupyter-server-ydoc.changes
    2026-05-28 17:28:59.580819910 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-jupyter-server-ydoc.new.1340718/python-jupyter-server-ydoc.changes
       2026-11-26 15:54:04.673459563 +0100
@@ -1,0 +2,37 @@
+Wed Nov 25 14:16:52 UTC 2026 - Ana Guerrero <[email protected]>
+
+- Update to 3.0.4
+  * New subpackage version for jupyter-collaboration 5.0.4
+  * Sync the test extra with upstream: add coverage, require
+    httpx-ws >= 0.9.0 and drop the obsolete importlib_metadata
+    conditional
+  * Fix the version requirement of the jupyter-server-ydoc
+    metapackage
+- Update to 3.0.3
+  * New subpackage version for jupyter-collaboration 5.0.3
+  * Pass errorReason to the client
+- Update to 3.0.2
+  * New subpackage version for jupyter-collaboration 5.0.2
+  * Fix file rename
+- Update to 3.0.1
+  * New subpackage version for jupyter-collaboration 5.0.1
+  * Fix file rename
+- Update to 3.0.0
+  * New subpackage version for jupyter-collaboration 5.0.0
+  * Use jupyter-ydoc v4
+  * Require jupyter-server >= 2.19.0 and pycrdt-websocket >= 0.16.4
+  * GHSA-8w8w-78q2-76qw: authentication and authorization checks
+    for the RTC timeline handler; the WebSocket and undo/redo
+    handlers get the same checks
+  * Configurable session_store_path
+  * Start serving WebSocket after document initialization
+- Update to 2.4.2
+  * GHSA-8w8w-78q2-76qw: authentication and authorization checks
+    for the RTC timeline handler; the WebSocket and undo/redo
+    handlers get the same checks
+- Update to 2.4.1
+  * Do not crash on out of band change when the room is
+    disconnected and ystore deleted (or no-op)
+  * Reduce noisy monitor logs
+
+-------------------------------------------------------------------

Old:
----
  jupyter_server_ydoc-2.4.0.tar.gz

New:
----
  jupyter_server_ydoc-3.0.4.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-jupyter-server-ydoc.spec ++++++
--- /var/tmp/diff_new_pack.GnP81h/_old  2026-11-26 15:54:05.591498563 +0100
+++ /var/tmp/diff_new_pack.GnP81h/_new  2026-11-26 15:54:05.593498648 +0100
@@ -24,10 +24,8 @@
 %define psuffix %{nil}
 %bcond_with test
 %endif
-
-%define distversion 2.4
 Name:           python-jupyter-server-ydoc%{psuffix}
-Version:        2.4.0
+Version:        3.0.4
 Release:        0
 Summary:        Jupyter server extension integrating collaborative shared 
models
 License:        BSD-3-Clause
@@ -43,10 +41,10 @@
 Requires:       python-jsonschema >= 4.18.0
 Requires:       python-jupyter_events >= 0.11.0
 Requires:       python-pycrdt
-Requires:       (python-jupyter_server >= 2.15.0 with python-jupyter_server < 
3.0)
+Requires:       (python-jupyter_server >= 2.19.0 with python-jupyter_server < 
3.0)
 Requires:       (python-jupyter_server_fileid >= 0.7.0 with 
python-jupyter_server_fileid < 1)
-Requires:       (python-jupyter_ydoc >= 3.0.3 with python-jupyter_ydoc < 4)
-Requires:       (python-pycrdt-websocket >= 0.16.0 with 
python-pycrdt-websocket < 0.17)
+Requires:       (python-jupyter_ydoc >= 4.1.1 with python-jupyter_ydoc < 5)
+Requires:       (python-pycrdt-websocket >= 0.16.4 with 
python-pycrdt-websocket < 0.17)
 Provides:       python-jupyter_server_ydoc = %{version}-%{release}
 BuildArch:      noarch
 %if %{with test}
@@ -63,7 +61,7 @@
 
 %package -n jupyter-server-ydoc
 Summary:        Jupyter server extension integrating collaborative shared 
models
-Requires:       python3dist(jupyter-server-ydoc) = %{distversion}
+Requires:       python3dist(jupyter-server-ydoc) = %{version}
 Suggests:       python3-jupyter-server-ydoc = %{version}
 
 %description -n jupyter-server-ydoc
@@ -78,13 +76,13 @@
 %package test
 Summary:        The jupyter_server_ydoc[test] extra
 Requires:       python-anyio
+Requires:       python-coverage
 Requires:       python-dirty-equals
-Requires:       python-httpx-ws >= 0.5.2
+Requires:       python-httpx-ws >= 0.9.0
 Requires:       python-jupyter-server-fileid
-Requires:       python-jupyter-server-test >= 2.15
+Requires:       python-jupyter-server-test >= 2.19
 Requires:       python-jupyter-server-ydoc = %{version}
 Requires:       python-pytest >= 7.0
-Requires:       (python-importlib_metadata >= 4.8.3 if python-base < 3.10)
 
 %description test
 Metapackage for the jupyter_server_ydoc[test] extra requirements

++++++ jupyter_server_ydoc-2.4.0.tar.gz -> jupyter_server_ydoc-3.0.4.tar.gz 
++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jupyter_server_ydoc-2.4.0/PKG-INFO 
new/jupyter_server_ydoc-3.0.4/PKG-INFO
--- old/jupyter_server_ydoc-2.4.0/PKG-INFO      2020-02-02 01:00:00.000000000 
+0100
+++ new/jupyter_server_ydoc-3.0.4/PKG-INFO      2020-02-02 01:00:00.000000000 
+0100
@@ -1,6 +1,6 @@
-Metadata-Version: 2.4
+Metadata-Version: 2.5
 Name: jupyter-server-ydoc
-Version: 2.4.0
+Version: 3.0.4
 Summary: jupyter-server extension integrating collaborative shared models.
 Project-URL: Documentation, 
https://jupyterlab-realtime-collaboration.readthedocs.io/
 Project-URL: Repository, https://github.com/jupyterlab/jupyter-collaboration
@@ -83,17 +83,17 @@
 Requires-Dist: jsonschema>=4.18.0
 Requires-Dist: jupyter-events>=0.11.0
 Requires-Dist: jupyter-server-fileid<1,>=0.7.0
-Requires-Dist: jupyter-server<3.0.0,>=2.15.0
-Requires-Dist: jupyter-ydoc<4.0.0,>=3.4.0
+Requires-Dist: jupyter-server<3.0.0,>=2.19.0
+Requires-Dist: jupyter-ydoc<5.0.0,>=4.1.1
 Requires-Dist: pycrdt
-Requires-Dist: pycrdt-websocket<0.17.0,>=0.16.0
+Requires-Dist: pycrdt-websocket<0.17.0,>=0.16.4
 Provides-Extra: test
 Requires-Dist: anyio; extra == 'test'
 Requires-Dist: coverage; extra == 'test'
 Requires-Dist: dirty-equals; extra == 'test'
 Requires-Dist: httpx-ws>=0.9.0; extra == 'test'
 Requires-Dist: jupyter-server-fileid[test]; extra == 'test'
-Requires-Dist: jupyter-server[test]>=2.15.0; extra == 'test'
+Requires-Dist: jupyter-server[test]>=2.19.0; extra == 'test'
 Requires-Dist: pytest-cov; extra == 'test'
 Requires-Dist: pytest>=7.0; extra == 'test'
 Description-Content-Type: text/markdown
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/jupyter_server_ydoc-2.4.0/jupyter_server_ydoc/_version.py 
new/jupyter_server_ydoc-3.0.4/jupyter_server_ydoc/_version.py
--- old/jupyter_server_ydoc-2.4.0/jupyter_server_ydoc/_version.py       
2020-02-02 01:00:00.000000000 +0100
+++ new/jupyter_server_ydoc-3.0.4/jupyter_server_ydoc/_version.py       
2020-02-02 01:00:00.000000000 +0100
@@ -1 +1 @@
-__version__ = "2.4.0"
+__version__ = "3.0.4"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jupyter_server_ydoc-2.4.0/jupyter_server_ydoc/app.py 
new/jupyter_server_ydoc-3.0.4/jupyter_server_ydoc/app.py
--- old/jupyter_server_ydoc-2.4.0/jupyter_server_ydoc/app.py    2020-02-02 
01:00:00.000000000 +0100
+++ new/jupyter_server_ydoc-3.0.4/jupyter_server_ydoc/app.py    2020-02-02 
01:00:00.000000000 +0100
@@ -12,7 +12,7 @@
 from jupyter_ydoc.ybasedoc import YBaseDoc
 from pycrdt import Doc
 from pycrdt.store import BaseYStore
-from traitlets import Bool, Float, Type
+from traitlets import Bool, Float, Type, Unicode
 
 from .handlers import (
     DocForkHandler,
@@ -76,6 +76,22 @@
         Defaults to 1s, if None then the document will never be saved.""",
     )
 
+    document_load_progressively = Bool(
+        False,
+        config=True,
+        help="""Whether to progressively load documents from disk into the 
shared document.
+        When enabled, a shared document can stream its content to clients 
before the full
+        source file has finished loading.""",
+    )
+
+    notebook_output_delay_threshold_mb = Float(
+        100,
+        allow_none=True,
+        config=True,
+        help="""Output size in MB above which a shared notebook may delay 
loading outputs during
+        progressive document loading. Set to None to keep loading outputs with 
the inputs.""",
+    )
+
     ystore_class = Type(
         default_value=SQLiteYStore,
         klass=BaseYStore,
@@ -93,6 +109,17 @@
         model.""",
     )
 
+    session_store_path = Unicode(
+        None,
+        allow_none=True,
+        config=True,
+        help="""Path to the JSON file used to record collaboration session IDs 
for
+        reconnect compatibility checks. When unset, defaults to
+        ``<server_root_dir>/.jupyter/collaboration_sessions.json``. Set this to
+        relocate the file (for example into a dedicated data directory) so the
+        server root stays free of generated state.""",
+    )
+
     _room_locks: dict[str, asyncio.Lock] = defaultdict(asyncio.Lock)
 
     def initialize(self):
@@ -107,7 +134,12 @@
                 "collaborative_file_poll_interval": self.file_poll_interval,
                 "collaborative_document_cleanup_delay": 
self.document_cleanup_delay,
                 "collaborative_document_save_delay": self.document_save_delay,
+                "collaborative_document_load_progressively": 
self.document_load_progressively,
+                "collaborative_notebook_output_delay_threshold_mb": (
+                    self.notebook_output_delay_threshold_mb
+                ),
                 "collaborative_ystore_class": self.ystore_class,
+                "collaborative_session_store_path": self.session_store_path,
             }
         )
 
@@ -154,6 +186,10 @@
                     {
                         "document_cleanup_delay": self.document_cleanup_delay,
                         "document_save_delay": self.document_save_delay,
+                        "document_load_progressively": 
self.document_load_progressively,
+                        "notebook_output_delay_threshold_mb": (
+                            self.notebook_output_delay_threshold_mb
+                        ),
                         "file_loaders": self.file_loaders,
                         "ystore_class": ystore_class,
                         "ywebsocket_server": self.ywebsocket_server,
@@ -246,11 +282,13 @@
                     self.log,
                     exception_handler=exception_logger,
                     save_delay=self.document_save_delay,
+                    
document_load_progressively=self.document_load_progressively,
+                    
notebook_output_delay_threshold_mb=self.notebook_output_delay_threshold_mb,
                 )
-                await room.initialize()
                 try:
                     await self.ywebsocket_server.start_room(room)
                     self.ywebsocket_server.add_room(room_id, room)
+                    await room.initialize()
                     self.log.info(f"Created and started room: {room_id}")
                 except Exception as e:
                     self.log.error("Room %s failed to start on websocket 
server", room_id)
@@ -267,6 +305,8 @@
 
         if isinstance(room, DocumentRoom):
             if copy:
+                if room._document_load_progressively:
+                    await room._document_progressively_loaded
                 update = room.ydoc.get_update()
 
                 fork_ydoc: Doc = Doc()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/jupyter_server_ydoc-2.4.0/jupyter_server_ydoc/handlers.py 
new/jupyter_server_ydoc-3.0.4/jupyter_server_ydoc/handlers.py
--- old/jupyter_server_ydoc-2.4.0/jupyter_server_ydoc/handlers.py       
2020-02-02 01:00:00.000000000 +0100
+++ new/jupyter_server_ydoc-3.0.4/jupyter_server_ydoc/handlers.py       
2020-02-02 01:00:00.000000000 +0100
@@ -11,6 +11,7 @@
 from uuid import uuid4
 
 from jupyter_server.auth import authorized
+from jupyter_server.auth.decorator import ws_authenticated
 from jupyter_server.base.handlers import APIHandler, JupyterHandler
 from jupyter_server.utils import ensure_async
 from jupyter_ydoc import ydocs as YDOCS
@@ -65,6 +66,10 @@
        receiving a message.
     """
 
+    # `JupyterHandler` does not define `auth_resource` (only `APIHandler` 
does),
+    # so it has to be set explicitly for `@authorized` to work
+    auth_resource = "contents"
+
     _message_queue: asyncio.Queue[Any]
     _background_tasks: set[asyncio.Task]
     _session_file_lock = asyncio.Lock()
@@ -137,6 +142,10 @@
                         self.log,
                         exception_handler=exception_logger,
                         save_delay=self._document_save_delay,
+                        
document_load_progressively=self._document_load_progressively,
+                        notebook_output_delay_threshold_mb=(
+                            self._notebook_output_delay_threshold_mb
+                        ),
                     )
 
                 else:
@@ -181,6 +190,8 @@
         room_locks: dict[str, asyncio.Lock] | None = None,
         document_cleanup_delay: float | None = 60.0,
         document_save_delay: float | None = 1.0,
+        document_load_progressively: bool = False,
+        notebook_output_delay_threshold_mb: float | None = 100,
     ) -> None:
         self._background_tasks = set()
         # File ID manager cannot be passed as argument as the extension may 
load after this one
@@ -189,6 +200,8 @@
         self._ystore_class = ystore_class
         self._cleanup_delay = document_cleanup_delay
         self._document_save_delay = document_save_delay
+        self._document_load_progressively = document_load_progressively
+        self._notebook_output_delay_threshold_mb = 
notebook_output_delay_threshold_mb
         self._websocket_server = ywebsocket_server
         self._message_queue = asyncio.Queue()
         self._room_id = ""
@@ -221,25 +234,24 @@
             raise StopAsyncIteration()
         return message
 
+    @ws_authenticated
+    @authorized
     async def get(self, *args, **kwargs):
         """
-        Overrides default behavior to check whether the client is 
authenticated or not.
+        Overrides default behavior to check whether the client is authenticated
+        and authorized to read the document.
         """
-        if self.current_user is None:
-            self.log.warning("Couldn't authenticate WebSocket connection")
-            raise web.HTTPError(403)
         return await super().get(*args, **kwargs)
 
     async def open(self, room_id: str) -> None:  # type:ignore[override]
         """
         On connection open.
         """
-        self.create_task(self._websocket_server.serve(self))
-
         if isinstance(self.room, DocumentRoom):
             # Close the connection if the document session expired
             session_id = self.get_query_argument("sessionId", "")
             root_dir = self.settings.get("server_root_dir", os.getcwd())
+            session_store_path = 
self.settings.get("collaborative_session_store_path")
             document_version = getattr(self.room._document, "version", None)
 
             # Persist the current session so future reconnects can validate it
@@ -249,6 +261,7 @@
                 YDOC_SERVER_VERSION,
                 self._session_file_lock,
                 document_version=document_version,
+                session_store_path=session_store_path,
             )
             if SERVER_SESSION != session_id:
                 cannot_reconnect, reason = check_session_compatibility(
@@ -256,6 +269,7 @@
                     session_id,
                     YDOC_SERVER_VERSION,
                     current_document_version=document_version,
+                    session_store_path=session_store_path,
                 )
                 if cannot_reconnect:
                     # Must ask the user to reload
@@ -277,6 +291,7 @@
                 # Initialize the room
                 async with self._room_lock(self._room_id):
                     await self.room.initialize()
+                self.create_task(self._websocket_server.serve(self))
                 self._emit_awareness_event(self.current_user.username, "join")
             except Exception as e:
                 _, _, file_id = decode_file_path(self._room_id)
@@ -312,6 +327,7 @@
                             {
                                 "reason": "initialization_error",
                                 "reloadable": False,
+                                "errorReason": str(e),
                             }
                         ),
                     )
@@ -324,6 +340,7 @@
 
             self._emit(LogLevel.INFO, "initialize", "New client connected.")
         else:
+            self.create_task(self._websocket_server.serve(self))
             if self._room_id != "JupyterLab:globalAwareness":
                 self._emit_awareness_event(self.current_user.username, "join")
 
@@ -545,12 +562,16 @@
 
 
 class TimelineHandler(APIHandler):
+    auth_resource = "contents"
+
     def initialize(
         self, ystore_class: type[BaseYStore], ywebsocket_server: 
JupyterWebsocketServer
     ) -> None:
         self.ystore_class = ystore_class
         self.ywebsocket_server = ywebsocket_server
 
+    @web.authenticated
+    @authorized  # type: ignore[misc]
     async def get(self, path: str) -> None:
         idx = uuid4().hex
         file_id_manager = self.settings["file_id_manager"]
@@ -608,9 +629,13 @@
 
 
 class UndoRedoHandler(APIHandler):
+    auth_resource = "contents"
+
     def initialize(self, ywebsocket_server: JupyterWebsocketServer) -> None:
         self._websocket_server = ywebsocket_server
 
+    @web.authenticated
+    @authorized
     async def put(self, room_id):
         try:
             action = 
str(self.request.query_arguments.get("action")[0].decode("utf-8"))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/jupyter_server_ydoc-2.4.0/jupyter_server_ydoc/loaders.py 
new/jupyter_server_ydoc-3.0.4/jupyter_server_ydoc/loaders.py
--- old/jupyter_server_ydoc-2.4.0/jupyter_server_ydoc/loaders.py        
2020-02-02 01:00:00.000000000 +0100
+++ new/jupyter_server_ydoc-3.0.4/jupyter_server_ydoc/loaders.py        
2020-02-02 01:00:00.000000000 +0100
@@ -179,7 +179,7 @@
                 # saving is shielded so that it cannot be cancelled
                 # otherwise it could corrupt the file
                 done_saving = asyncio.Event()
-                task = asyncio.create_task(self._save_content(model, 
done_saving))
+                task = asyncio.create_task(self._save_content(model, 
done_saving, path))
                 saved_model = None
                 try:
                     saved_model = await asyncio.shield(task)
@@ -193,24 +193,44 @@
                 raise OutOfBandChanges
 
     async def _save_content(
-        self, model: dict[str, Any], done_saving: asyncio.Event
+        self, model: dict[str, Any], done_saving: asyncio.Event, path: str
     ) -> dict[str, Any]:
         try:
-            m = await ensure_async(self._contents_manager.save(model, 
self.path))
-            self.last_modified = m["last_modified"]
-            # TODO, get rid of the extra `get` here once upstream issue:
-            # https://github.com/jupyter-server/jupyter_server/issues/1453 is 
resolved
-            model_with_hash = await ensure_async(
-                self._contents_manager.get(
-                    self.path,
-                    content=False,
-                    require_hash=True,
-                )
-            )
-            return {**m, "hash": model_with_hash["hash"]}
+            try:
+                return await self._save_content_at_path(model, path)
+            except Exception as save_error:
+                # The file may have been renamed after the metadata check in
+                # maybe_save_content but before the save reached the contents
+                # manager. Retry only if the stable file ID now resolves to a
+                # different path; errors for deleted files must still surface.
+                try:
+                    new_path = self.path
+                except Exception:
+                    # Deleting a file also removes its file ID. Do not replace
+                    # the original contents manager error with the path lookup
+                    # failure in that case.
+                    raise save_error from None
+                if new_path == path:
+                    raise
+                self._log.info("File moved while saving: %s -> %s; retrying", 
path, new_path)
+                return await self._save_content_at_path(model, new_path)
         finally:
             done_saving.set()
 
+    async def _save_content_at_path(self, model: dict[str, Any], path: str) -> 
dict[str, Any]:
+        m = await ensure_async(self._contents_manager.save(model, path))
+        self.last_modified = m["last_modified"]
+        # TODO, get rid of the extra `get` here once upstream issue:
+        # https://github.com/jupyter-server/jupyter_server/issues/1453 is 
resolved
+        model_with_hash = await ensure_async(
+            self._contents_manager.get(
+                path,
+                content=False,
+                require_hash=True,
+            )
+        )
+        return {**m, "hash": model_with_hash["hash"]}
+
     async def _watch_file(self) -> None:
         """
         Async task for watching a file.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/jupyter_server_ydoc-2.4.0/jupyter_server_ydoc/pytest_plugin.py 
new/jupyter_server_ydoc-3.0.4/jupyter_server_ydoc/pytest_plugin.py
--- old/jupyter_server_ydoc-2.4.0/jupyter_server_ydoc/pytest_plugin.py  
2020-02-02 01:00:00.000000000 +0100
+++ new/jupyter_server_ydoc-3.0.4/jupyter_server_ydoc/pytest_plugin.py  
2020-02-02 01:00:00.000000000 +0100
@@ -317,6 +317,7 @@
                 store,
                 None,
                 save_delay,
+                document_load_progressively=False,
             ),
         )
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/jupyter_server_ydoc-2.4.0/jupyter_server_ydoc/rooms.py 
new/jupyter_server_ydoc-3.0.4/jupyter_server_ydoc/rooms.py
--- old/jupyter_server_ydoc-2.4.0/jupyter_server_ydoc/rooms.py  2020-02-02 
01:00:00.000000000 +0100
+++ new/jupyter_server_ydoc-3.0.4/jupyter_server_ydoc/rooms.py  2020-02-02 
01:00:00.000000000 +0100
@@ -4,18 +4,23 @@
 from __future__ import annotations
 
 import asyncio
+import json
 from collections.abc import Callable
 from logging import Logger
 from typing import Any
 
 from jupyter_events import EventLogger
 from jupyter_ydoc import ydocs as YDOCS
-from pycrdt import Doc
+from pycrdt import (
+    Channel,
+    Doc,
+    Encoder,
+)
 from pycrdt.store import BaseYStore, YDocNotFound
 from pycrdt.websocket import YRoom
 
 from .loaders import FileLoader
-from .utils import JUPYTER_COLLABORATION_EVENTS_URI, LogLevel, OutOfBandChanges
+from .utils import JUPYTER_COLLABORATION_EVENTS_URI, LogLevel, MessageType, 
OutOfBandChanges
 
 YFILE = YDOCS["file"]
 
@@ -35,6 +40,8 @@
         ystore: BaseYStore | None,
         log: Logger | None,
         save_delay: float | None = None,
+        document_load_progressively: bool = False,
+        notebook_output_delay_threshold_mb: float | None = 100,
         exception_handler: Callable[[Exception, Logger], bool] | None = None,
     ):
         super().__init__(ready=False, ystore=ystore, 
exception_handler=exception_handler, log=log)
@@ -48,17 +55,28 @@
 
         self._logger = logger
         self._save_delay = save_delay
+        self._document_load_progressively = document_load_progressively
+        self._notebook_output_delay_threshold_mb = 
notebook_output_delay_threshold_mb
+        if (
+            document_load_progressively
+            and notebook_output_delay_threshold_mb is not None
+            and notebook_output_delay_threshold_mb < 0
+        ):
+            raise ValueError("notebook_output_delay_threshold_mb must be >=0 
or None")
 
         self._update_lock = asyncio.Lock()
         self._cleaner: asyncio.Task | None = None
         self._saving_document: asyncio.Task | None = None
         self._messages: dict[str, asyncio.Lock] = {}
         self._background_tasks = set()
+        self._document_progressively_loaded: asyncio.Future[None] = 
asyncio.Future()
 
         # Listen for document changes
         self._document.observe(self._on_document_change)
         self._file.observe(self.room_id, self._on_outofband_change, 
self._on_filepath_change)
 
+        self.on_message_error = self._handle_sync_message_error
+
     @property
     def file_format(self) -> str:
         """Document file format."""
@@ -112,7 +130,9 @@
 
         model = await self._file.load_content(self._file_format, 
self._file_type)
 
-        async with self._update_lock:
+        await self._update_lock.acquire()
+        release_update_lock = True
+        try:
             # try to apply Y updates from the YStore for this document
             read_from_source = True
             loaded_from_store = False
@@ -164,18 +184,71 @@
                     self._file.path,
                 )
                 if not loaded_from_store:
-                    await 
self._apply_deterministic_source_content(model["content"])
+                    if self._document_load_progressively:
+                        release_update_lock = False
+                        initialized = asyncio.Event()
+                        finish = asyncio.Event()
+                        self.create_task(
+                            self._finish_progressive_initialization(
+                                model["content"], initialized, finish
+                            )
+                        )
+                        await initialized.wait()
+                        if (
+                            self._document_progressively_loaded.done()
+                            and (exc := 
self._document_progressively_loaded.exception()) is not None
+                        ):
+                            raise exc
+                        self.ready = True
+                        await self.ydoc_observed.wait()
+                        finish.set()
+                        self._emit(LogLevel.INFO, "initialize", "Room 
initialized")
+                        return
+                    else:
+                        await 
self._apply_deterministic_source_content(model["content"])
                 else:
                     await self._document.aset(model["content"])
 
                 if self.ystore:
                     await self.ystore.encode_state_as_update(self.ydoc)
 
-            self._document.dirty = False
             self.ready = True
             self._emit(LogLevel.INFO, "initialize", "Room initialized")
+        finally:
+            if release_update_lock:
+                self._update_lock.release()
+
+    async def _finish_progressive_initialization(
+        self, content: Any, initialized: asyncio.Event, finish: asyncio.Event
+    ) -> None:
+        try:
+            await self._apply_deterministic_source_content(
+                content, progressive=True, initialized=initialized, 
finish=finish
+            )
+            if self.ystore:
+                await self.ystore.encode_state_as_update(self.ydoc)
+        except Exception as e:
+            msg = f"Error loading content from file: {self._file.path}\n{e!r}"
+            self.log.error(msg, exc_info=e)
+            self._emit(LogLevel.ERROR, None, msg)
+            self._document_progressively_loaded.set_exception(e)
+        else:
+            self._document_progressively_loaded.set_result(None)
+            if await self._document.aget() != content:
+                # that means there were user changes while progressively 
loading, save the document
+                self._saving_document = asyncio.create_task(
+                    self._maybe_save_document(self._saving_document, 
save_now=True)
+                )
+        finally:
+            self._update_lock.release()
 
-    async def _apply_deterministic_source_content(self, content: Any) -> None:
+    async def _apply_deterministic_source_content(
+        self,
+        content: Any,
+        progressive: bool = False,
+        initialized: asyncio.Event | None = None,
+        finish: asyncio.Event | None = None,
+    ) -> None:
         """Load source content using a deterministic update.
 
         Rooms rebuilt from disk must recreate the same Yjs history for 
identical
@@ -185,11 +258,22 @@
         The client ID needs to be fixed to a deterministic value, see:
         
https://discuss.yjs.dev/t/initial-offline-value-of-a-shared-document/465
         """
-
         source_ydoc: Doc = Doc(client_id=0)
         source_document = YDOCS.get(self._file_type, YFILE)(source_ydoc)
-        await source_document.aset(content)
-        self.ydoc.apply_update(source_ydoc.get_update())
+        if progressive:
+            subscription = source_ydoc.observe(lambda event: 
self.ydoc.apply_update(event.update))
+            try:
+                await source_document.aset_progressively(
+                    content,
+                    initialized=initialized,
+                    finish=finish,
+                    
delay_outputs_above_mb=self._notebook_output_delay_threshold_mb,
+                )
+            finally:
+                source_ydoc.unobserve(subscription)
+        else:
+            await source_document.aset(content)
+            self.ydoc.apply_update(source_ydoc.get_update())
 
     def _emit(self, level: LogLevel, action: str | None = None, msg: str | 
None = None) -> None:
         data = {"level": level.value, "room": self._room_id, "path": 
self._file.path}
@@ -229,6 +313,32 @@
         except asyncio.CancelledError:
             pass
 
+    async def _handle_sync_message_error(
+        self, exc: Exception, message: bytes, channel: Channel
+    ) -> bool:
+        """Handle errors raised by handle_sync_message.
+
+        Intercepts InvalidParent conflicts caused by a stale client 
reconnecting
+        after the room was evicted and rebuilt from a modified file. Sends a 
RAW
+        conflict notification so the client can offer a resolution dialog, and
+        returns True so the serve loop continues for the remaining clients.
+        """
+        if not message or message[0] != MessageType.SYNC:
+            return False
+        if not (isinstance(exc, RuntimeError) and "block parent" in str(exc)):
+            return False
+        self.log.warning(
+            "Conflict in room %s from %s: %s",
+            self._room_id,
+            channel.path,
+            exc,
+        )
+        encoder = Encoder()
+        encoder.write_var_uint(MessageType.RAW)
+        encoder.write_var_string(json.dumps({"type": "conflict"}))
+        await channel.send(encoder.to_bytes())
+        return True
+
     async def _on_outofband_change(self) -> None:
         """
         Called when the file got out-of-band changes.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/jupyter_server_ydoc-2.4.0/jupyter_server_ydoc/utils.py 
new/jupyter_server_ydoc-3.0.4/jupyter_server_ydoc/utils.py
--- old/jupyter_server_ydoc-2.4.0/jupyter_server_ydoc/utils.py  2020-02-02 
01:00:00.000000000 +0100
+++ new/jupyter_server_ydoc-3.0.4/jupyter_server_ydoc/utils.py  2020-02-02 
01:00:00.000000000 +0100
@@ -87,8 +87,23 @@
     return encoded_path.split("/")[-1]
 
 
-def _get_jupyter_session_store(root_dir: str) -> Path:
-    """Return path to the session store file in .jupyter folder."""
+def _get_jupyter_session_store(root_dir: str, session_store_path: str | None = 
None) -> Path:
+    """Return path to the session store file.
+
+    If ``session_store_path`` is provided it is honored as-is (its parent
+    directory is created on demand). Otherwise the default location
+    ``<root_dir>/.jupyter/collaboration_sessions.json`` is used.
+    """
+    if session_store_path:
+        try:
+            target = Path(session_store_path).expanduser()
+            target.parent.mkdir(parents=True, exist_ok=True)
+            return target
+        except OSError:
+            # Configured path is unwritable — fall through to /dev/null so the
+            # server stays up; callers tolerate write failures already.
+            return Path(os.devnull)
+
     try:
         expanded = Path(root_dir).expanduser()
         resolved = expanded.resolve()
@@ -100,9 +115,9 @@
         return Path(os.devnull)
 
 
-def _load_previous_sessions(root_dir: str) -> dict:
+def _load_previous_sessions(root_dir: str, session_store_path: str | None = 
None) -> dict:
     """Load previous session records from .jupyter folder."""
-    store_path = _get_jupyter_session_store(root_dir)
+    store_path = _get_jupyter_session_store(root_dir, session_store_path)
     if store_path.exists():
         try:
             sessions = json.loads(store_path.read_text())
@@ -125,12 +140,13 @@
     version: str,
     lock: asyncio.Lock,
     document_version: str | None = None,
+    session_store_path: str | None = None,
 ) -> None:
     """Persist the current session ID, server version, and optionally
-    document version to .jupyter folder."""
+    document version to the session store."""
     async with lock:
-        store_path = _get_jupyter_session_store(root_dir)
-        sessions = _load_previous_sessions(root_dir)
+        store_path = _get_jupyter_session_store(root_dir, session_store_path)
+        sessions = _load_previous_sessions(root_dir, session_store_path)
 
         sessions[session_id] = {
             "version": version,
@@ -154,6 +170,7 @@
     client_session_id: str,
     current_version: str,
     current_document_version: str | None = None,
+    session_store_path: str | None = None,
 ) -> tuple[bool, str]:
     """
     Determine whether a client carrying an old session ID can reconnect or not.
@@ -164,7 +181,7 @@
     if client_session_id == SERVER_SESSION:
         return False, ""
 
-    previous_sessions = _load_previous_sessions(root_dir)
+    previous_sessions = _load_previous_sessions(root_dir, session_store_path)
 
     # Session ID not in our records at all → unknown origin, reject
     if client_session_id not in previous_sessions:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/jupyter_server_ydoc-2.4.0/jupyter_server_ydoc/websocketserver.py 
new/jupyter_server_ydoc-3.0.4/jupyter_server_ydoc/websocketserver.py
--- old/jupyter_server_ydoc-2.4.0/jupyter_server_ydoc/websocketserver.py        
2020-02-02 01:00:00.000000000 +0100
+++ new/jupyter_server_ydoc-3.0.4/jupyter_server_ydoc/websocketserver.py        
2020-02-02 01:00:00.000000000 +0100
@@ -148,12 +148,16 @@
         #### Note:
             This method runs in a coroutine for debugging purposes.
         """
+        prev_clients_nb = 0
         while True:
             try:
                 await asyncio.sleep(60)
             except asyncio.CancelledError:
                 break
             clients_nb = sum(len(room.clients) for room in self.rooms.values())
-            self.log.info("Processed %s Y patches in one minute", 
self.ypatch_nb)
-            self.log.info("Connected Y users: %s", clients_nb)
-            self.ypatch_nb = 0
+            if self.ypatch_nb:
+                self.log.debug("Processed %s Y patches in one minute", 
self.ypatch_nb)
+                self.ypatch_nb = 0
+            if clients_nb != prev_clients_nb:
+                self.log.debug("Connected Y users: %s", clients_nb)
+            prev_clients_nb = clients_nb
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jupyter_server_ydoc-2.4.0/pyproject.toml 
new/jupyter_server_ydoc-3.0.4/pyproject.toml
--- old/jupyter_server_ydoc-2.4.0/pyproject.toml        2020-02-02 
01:00:00.000000000 +0100
+++ new/jupyter_server_ydoc-3.0.4/pyproject.toml        2020-02-02 
01:00:00.000000000 +0100
@@ -28,10 +28,10 @@
     { name = "Jupyter Development Team", email = "[email protected]" },
 ]
 dependencies = [
-    "jupyter_server>=2.15.0,<3.0.0",
-    "jupyter_ydoc>=3.4.0,<4.0.0",
+    "jupyter_server>=2.19.0,<3.0.0",
+    "jupyter_ydoc >=4.1.1,<5.0.0",
     "pycrdt",
-    "pycrdt-websocket>=0.16.0,<0.17.0",
+    "pycrdt-websocket>=0.16.4,<0.17.0",
     "jupyter_events>=0.11.0",
     "jupyter_server_fileid>=0.7.0,<1",
     "jsonschema>=4.18.0"
@@ -49,7 +49,7 @@
 test = [
     "coverage",
     "dirty-equals",
-    "jupyter_server[test]>=2.15.0",
+    "jupyter_server[test]>=2.19.0",
     "jupyter_server_fileid[test]",
     "pytest>=7.0",
     "pytest-cov",
@@ -71,3 +71,6 @@
 
 [tool.check-wheel-contents]
 ignore = ["W002"]
+
+[tool.hatch.metadata]
+allow-direct-references = true
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jupyter_server_ydoc-2.4.0/tests/test_app.py 
new/jupyter_server_ydoc-3.0.4/tests/test_app.py
--- old/jupyter_server_ydoc-2.4.0/tests/test_app.py     2020-02-02 
01:00:00.000000000 +0100
+++ new/jupyter_server_ydoc-3.0.4/tests/test_app.py     2020-02-02 
01:00:00.000000000 +0100
@@ -16,6 +16,8 @@
     assert settings["file_poll_interval"] == 1
     assert settings["document_cleanup_delay"] == 60
     assert settings["document_save_delay"] == 1
+    assert settings["document_load_progressively"] is False
+    assert settings["notebook_output_delay_threshold_mb"] == 100
     assert settings["ystore_class"] == SQLiteYStore
 
 
@@ -55,6 +57,24 @@
     assert settings["document_save_delay"] == 10
 
 
+def 
test_settings_should_change_document_progressive_loading(jp_configurable_serverapp):
+    argv = ["--YDocExtension.document_load_progressively=True"]
+
+    app = jp_configurable_serverapp(argv=argv)
+    settings = app.web_app.settings["jupyter_server_ydoc_config"]
+
+    assert settings["document_load_progressively"] is True
+
+
+def 
test_settings_should_change_notebook_output_delay_threshold(jp_configurable_serverapp):
+    argv = ["--YDocExtension.notebook_output_delay_threshold_mb=50"]
+
+    app = jp_configurable_serverapp(argv=argv)
+    settings = app.web_app.settings["jupyter_server_ydoc_config"]
+
+    assert settings["notebook_output_delay_threshold_mb"] == 50
+
+
 def test_settings_should_change_ystore_class(jp_configurable_serverapp):
     argv = 
["--YDocExtension.ystore_class=jupyter_server_ydoc.stores.TempFileYStore"]
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jupyter_server_ydoc-2.4.0/tests/test_documents.py 
new/jupyter_server_ydoc-3.0.4/tests/test_documents.py
--- old/jupyter_server_ydoc-2.4.0/tests/test_documents.py       2020-02-02 
01:00:00.000000000 +0100
+++ new/jupyter_server_ydoc-3.0.4/tests/test_documents.py       2020-02-02 
01:00:00.000000000 +0100
@@ -10,13 +10,42 @@
 from jupyter_server_ydoc.loaders import FileLoader
 from jupyter_server_ydoc.rooms import DocumentRoom
 from jupyter_server_ydoc.test_utils import FakeContentsManager, 
FakeEventLogger, FakeFileIDManager
+from jupyter_server_ydoc.utils import MessageType
 from jupyter_ydoc import YNotebook
-from pycrdt import Provider
+from pycrdt import Channel, Provider, YMessageType, YSyncMessageType, 
write_message
 from pycrdt.websocket.websocket import HttpxWebsocket
 
 jupyter_ydocs = {ep.name: ep.load() for ep in 
entry_points(group="jupyter_ydoc")}
 
 
+class _SingleMessageChannel:
+    """Mock channel that delivers one message to the room then stops 
iteration."""
+
+    def __init__(self, message: bytes) -> None:
+        self._message = message
+        self._sent: list[bytes] = []
+        self._iter_done = False
+
+    @property
+    def path(self) -> str:
+        return "mock://test"
+
+    def __aiter__(self) -> Channel:
+        return self
+
+    async def __anext__(self) -> bytes:
+        if self._iter_done:
+            raise StopAsyncIteration
+        self._iter_done = True
+        return self._message
+
+    async def send(self, message: bytes) -> None:
+        self._sent.append(message)
+
+    async def recv(self) -> bytes:
+        raise StopAsyncIteration
+
+
 @pytest.fixture
 def rtc_document_save_delay():
     return 0.5
@@ -35,9 +64,14 @@
 
     websocket, room_name = await rtc_connect_doc_client(file_format, 
file_type, file_path)
     async with websocket as ws, Provider(jupyter_ydoc.ydoc, HttpxWebsocket(ws, 
room_name)):
-        for _ in range(2):
+        for _ in range(3):
             jupyter_ydoc.dirty = True
             await sleep(rtc_document_save_delay * 1.5)
+            # the server might not be ready to receive updates from this 
client yet
+            # if it is, it should clear the dirty state
+            if not jupyter_ydoc.dirty:
+                return
+        else:
             assert not jupyter_ydoc.dirty
 
 
@@ -135,6 +169,7 @@
         None,
         None,
         None,
+        document_load_progressively=False,
     )
     await room.initialize()
     return room, loader
@@ -169,3 +204,74 @@
         await recreated_loader.clean()
 
     assert len(merged["cells"]) == 1
+
+
+async def 
test_notebook_reconnect_sends_conflict_when_cell_structure_changes_between_restarts():
+    """When cell structure changes between room restarts, serve() must not 
crash.
+
+    _apply_deterministic_source_content uses Doc(client_id=0) so that Yjs item
+    clocks are stable across room restarts for identical content.  That
+    assumption breaks when the on-disk notebook changes structure between the
+    client's last sync and the next room creation: adding a primitive value
+    inside a cell (e.g. a kernel marks the cell trusted via
+    {"metadata": {"trusted": True}}) inserts one extra ItemContent::Any before
+    the source Text branch.  This shifts clock position 4 from
+    ItemContent::Type (the source Text) in the original room to
+    ItemContent::Any in the recreated room.
+
+    A client that made local edits against the original layout holds a parent
+    reference to (client_id=0, clock=4) which is no longer a valid container,
+    so yrs raises "block parent <0#4> must be deleted or shared ref type.
+    Type: 8" when that update is applied.
+
+    The server must catch this, keep the room intact, and send a CONFLICT
+    message back to the client so the frontend can offer Save As / View Diff.
+    """
+    notebook_before = _notebook_model()
+    room_a, loader_a = await _create_notebook_room(notebook_before, 
"meta-change-before")
+    client_doc = YNotebook()
+    try:
+        # Client connects to room A and receives all client_id=0 items.
+        client_doc.ydoc.apply_update(room_a.ydoc.get_update())
+        # Client edits the cell source, creating an item whose parent is the
+        # source Text branch — a client_id=0 item at clock position 4.
+        client_doc.ycells[0]["source"] += "new content"
+    finally:
+        await room_a.stop()
+        await loader_a.clean()
+
+    # Disk content changes: cell metadata gains "trusted": True.
+    # _apply_deterministic_source_content will now allocate clock 4 to the
+    # "trusted" Any value instead of the source Text branch.
+    notebook_after = deepcopy(notebook_before)
+    notebook_after["cells"][0]["metadata"] = {"trusted": True}
+    room_b, loader_b = await _create_notebook_room(notebook_after, 
"meta-change-after")
+    try:
+        # Build a SYNC_UPDATE message carrying the client's conflicting edit.
+        client_update = client_doc.ydoc.get_update()
+        sync_update_msg = bytes([YMessageType.SYNC, 
YSyncMessageType.SYNC_UPDATE]) + write_message(
+            client_update
+        )
+        channel = _SingleMessageChannel(sync_update_msg)
+
+        # serve() must complete without raising even though apply_update would 
crash.
+        await room_b.serve(channel)
+
+        # The room must have sent at least a SYNC_STEP2 and a RAW conflict 
message.
+        message_types = [msg[0] for msg in channel._sent]
+        assert (
+            MessageType.RAW in message_types
+        ), f"Expected a RAW conflict message, got types: {message_types}"
+
+        # The RAW conflict message encodes a JSON payload with type=conflict.
+        conflict_msg = next(m for m in channel._sent if m[0] == 
MessageType.RAW)
+        assert b'"type": "conflict"' in conflict_msg
+        assert len(conflict_msg) > 1
+
+        # The room itself must remain coherent — still one cell.
+        server_notebook = YNotebook()
+        server_notebook.ydoc.apply_update(room_b.ydoc.get_update())
+        assert len(server_notebook.get(deduplicate=False)["cells"]) == 1
+    finally:
+        await room_b.stop()
+        await loader_b.clean()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jupyter_server_ydoc-2.4.0/tests/test_loaders.py 
new/jupyter_server_ydoc-3.0.4/tests/test_loaders.py
--- old/jupyter_server_ydoc-2.4.0/tests/test_loaders.py 2020-02-02 
01:00:00.000000000 +0100
+++ new/jupyter_server_ydoc-3.0.4/tests/test_loaders.py 2020-02-02 
01:00:00.000000000 +0100
@@ -7,8 +7,10 @@
 import logging
 from datetime import datetime, timedelta, timezone
 
+import pytest
 from jupyter_server_ydoc.loaders import FileLoader, FileLoaderMapping
 from jupyter_server_ydoc.test_utils import FakeContentsManager, 
FakeFileIDManager
+from tornado.web import HTTPError
 
 
 async def test_FileLoader_with_watcher():
@@ -136,6 +138,64 @@
         await loader.clean()
 
 
+async def test_FileLoader_retries_save_after_rename():
+    id = "file-4567"
+    old_path = "myfile.txt"
+    new_path = "renamed.txt"
+    file_id_manager = FakeFileIDManager({id: old_path})
+
+    class RenameDuringSaveContentsManager(FakeContentsManager):
+        def __init__(self):
+            super().__init__({"last_modified": datetime.now(timezone.utc), 
"writable": True})
+            self.saved_paths: list[str] = []
+
+        def save(self, model, path):
+            self.saved_paths.append(path)
+            if path == old_path:
+                file_id_manager.move(id, new_path)
+                raise HTTPError(404, f"File not found: {path}")
+            return self.model
+
+    cm = RenameDuringSaveContentsManager()
+    loader = FileLoader(id, file_id_manager, cm)
+    await loader.load_content("text", "file")
+
+    saved_model = await loader.maybe_save_content(
+        {"format": "text", "type": "file", "content": "content"}
+    )
+
+    assert saved_model is not None
+    assert saved_model["hash"] == "fake_hash"
+    assert cm.saved_paths == [old_path, new_path]
+
+
+async def test_FileLoader_does_not_retry_save_after_delete():
+    id = "file-4567"
+    path = "myfile.txt"
+    file_id_manager = FakeFileIDManager({id: path})
+    save_error = HTTPError(404, f"File not found: {path}")
+
+    class DeleteDuringSaveContentsManager(FakeContentsManager):
+        def __init__(self):
+            super().__init__({"last_modified": datetime.now(timezone.utc), 
"writable": True})
+            self.save_count = 0
+
+        def save(self, model, path):
+            self.save_count += 1
+            del file_id_manager.mapping[id]
+            raise save_error
+
+    cm = DeleteDuringSaveContentsManager()
+    loader = FileLoader(id, file_id_manager, cm)
+    await loader.load_content("text", "file")
+
+    with pytest.raises(HTTPError, match="File not found") as exc_info:
+        await loader.maybe_save_content({"format": "text", "type": "file", 
"content": "content"})
+
+    assert exc_info.value is save_error
+    assert cm.save_count == 1
+
+
 async def test_FileLoaderMapping_with_watcher():
     id = "file-4567"
     path = "myfile.txt"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/jupyter_server_ydoc-2.4.0/tests/test_session_store.py 
new/jupyter_server_ydoc-3.0.4/tests/test_session_store.py
--- old/jupyter_server_ydoc-2.4.0/tests/test_session_store.py   2020-02-02 
01:00:00.000000000 +0100
+++ new/jupyter_server_ydoc-3.0.4/tests/test_session_store.py   2020-02-02 
01:00:00.000000000 +0100
@@ -2,6 +2,7 @@
 # Distributed under the terms of the Modified BSD License.
 
 import asyncio
+import json
 
 from jupyter_server_ydoc.utils import (
     YDOC_SERVER_VERSION,
@@ -102,3 +103,51 @@
     )
     assert cannot_reconnect is False
     assert reason == ""
+
+
+async def test_session_store_path_override_persists_records(tmp_path):
+    """Saved sessions land under the override path and reconnects honor it."""
+    override = tmp_path / "elsewhere" / "sessions.json"
+    await save_current_session(
+        str(tmp_path),
+        "override-session",
+        YDOC_SERVER_VERSION,
+        asyncio.Lock(),
+        session_store_path=str(override),
+    )
+
+    assert override.exists()
+    payload = json.loads(override.read_text())
+    assert "override-session" in payload
+    # The default ``.jupyter`` directory should never be created when an 
override is set.
+    assert not (tmp_path / ".jupyter").exists()
+
+    cannot_reconnect, reason = check_session_compatibility(
+        str(tmp_path),
+        "override-session",
+        YDOC_SERVER_VERSION,
+        session_store_path=str(override),
+    )
+    assert cannot_reconnect is False
+    assert reason == ""
+
+
+async def test_session_store_path_override_isolated_from_default(tmp_path):
+    """Records saved with an override are invisible to the default lookup."""
+    override = tmp_path / "elsewhere" / "sessions.json"
+    await save_current_session(
+        str(tmp_path),
+        "override-session",
+        YDOC_SERVER_VERSION,
+        asyncio.Lock(),
+        session_store_path=str(override),
+    )
+
+    # Without the override, the default lookup should treat the session as 
unknown.
+    cannot_reconnect, reason = check_session_compatibility(
+        str(tmp_path),
+        "override-session",
+        YDOC_SERVER_VERSION,
+    )
+    assert cannot_reconnect is True
+    assert reason == "unknown_session"

Reply via email to