@@ -1444,6 +1444,9 @@ def enable_bookmarking(
14441444 root_session = session .root_scope ()
14451445 root_session .bookmark .exclude .append (self .id + "_user_input" )
14461446
1447+ # ###########
1448+ # Bookmarking
1449+
14471450 if bookmark_on is not None :
14481451
14491452 # When ever the bookmark is requested, update the query string (indep of store type)
@@ -1467,7 +1470,7 @@ async def _():
14671470 await session .bookmark ()
14681471
14691472 ###############
1470- # On Bookmark
1473+ # Client Bookmarking
14711474
14721475 @root_session .bookmark .on_bookmark
14731476 async def _on_bookmark_client (state : BookmarkState ):
@@ -1479,6 +1482,18 @@ async def _on_bookmark_client(state: BookmarkState):
14791482 with reactive .isolate ():
14801483 state .values [resolved_bookmark_id_str ] = await get_state ()
14811484
1485+ @root_session .bookmark .on_restore
1486+ async def _on_restore_client (state : RestoreState ):
1487+ if resolved_bookmark_id_str not in state .values :
1488+ return
1489+
1490+ # Retrieve the chat turns from the bookmark state
1491+ info = state .values [resolved_bookmark_id_str ]
1492+ await set_state (info )
1493+
1494+ ###############
1495+ # UI Bookmarking
1496+
14821497 @root_session .bookmark .on_bookmark
14831498 def _on_bookmark_ui (state : BookmarkState ):
14841499 if resolved_bookmark_id_msgs_str in state .values :
@@ -1494,21 +1509,9 @@ def _on_bookmark_ui(state: BookmarkState):
14941509 format = MISSING
14951510 )
14961511
1497- ###############
1498- # On Restore
1499-
15001512 # Attempt to stop the initialization of the `ui.Chat(messages=)` messages
15011513 self ._init_chat .destroy ()
15021514
1503- @root_session .bookmark .on_restore
1504- async def _on_restore_client (state : RestoreState ):
1505- if resolved_bookmark_id_str not in state .values :
1506- return
1507-
1508- # Retrieve the chat turns from the bookmark state
1509- info = state .values [resolved_bookmark_id_str ]
1510- await set_state (info )
1511-
15121515 @root_session .bookmark .on_restore
15131516 async def _on_restore_ui (state : RestoreState ):
15141517 # Do not call `self.clear_messages()` as it will clear the
0 commit comments