@@ -1416,7 +1416,7 @@ def enable_bookmarking(
14161416 client : ClientWithState | chatlas .Chat [Any , Any ],
14171417 / ,
14181418 * ,
1419- on : Optional [Literal ["response" ]] = "response" ,
1419+ bookmark_on : Optional [Literal ["response" ]] = "response" ,
14201420 ) -> CancelCallback :
14211421 """
14221422 Enable bookmarking for the chat instance.
@@ -1432,11 +1432,11 @@ def enable_bookmarking(
14321432 The chat client instance to use for bookmarking. This can be a Chat model
14331433 provider from [chatlas](https://posit-dev.github.io/chatlas/), or more
14341434 generally, an instance following the `ClientWithState` protocol.
1435- on
1435+ bookmark_on
14361436 The event to trigger the bookmarking on. Supported values include:
14371437
1438- - `"response"` (the default): a bookmark is triggered when the assistant is done responding.
1439- - `None`: no bookmark is triggered
1438+ - `"response"` (the default): a bookmark is triggered when the assistant is done responding.
1439+ - `None`: no bookmark is triggered
14401440
14411441 When this method triggers a bookmark, it also updates the URL query string to reflect the bookmarked state.
14421442
@@ -1516,14 +1516,14 @@ async def set_chatlas_state(value: Jsonifiable) -> None:
15161516 root_session = session .root_scope ()
15171517 root_session .bookmark .exclude .append (self .id + "_user_input" )
15181518
1519- if on is not None :
1519+ if bookmark_on is not None :
15201520
15211521 # When ever the bookmark is requested, update the query string (indep of store type)
15221522 @root_session .bookmark .on_bookmarked
15231523 async def _ (url : str ):
15241524 await session .bookmark .update_query_string (url )
15251525
1526- if on == "response" :
1526+ if bookmark_on == "response" :
15271527
15281528 @reactive .effect
15291529 @reactive .event (lambda : self .messages (format = MISSING ), ignore_init = True )
@@ -1538,6 +1538,9 @@ async def _():
15381538 if last_message .get ("role" ) == "assistant" :
15391539 await session .bookmark ()
15401540
1541+ ###############
1542+ # On Bookmark
1543+
15411544 @root_session .bookmark .on_bookmark
15421545 async def _on_bookmark_client (state : BookmarkState ):
15431546 if resolved_bookmark_id_str in state .values :
@@ -1670,8 +1673,8 @@ def enable_bookmarking(
16701673 client : ClientWithState | chatlas .Chat [Any , Any ],
16711674 / ,
16721675 * ,
1673- store : Optional [BookmarkStore ] = None ,
1674- on : Optional [Literal ["response" ]] = "response" ,
1676+ bookmark_store : Optional [BookmarkStore ] = None ,
1677+ bookmark_on : Optional [Literal ["response" ]] = "response" ,
16751678 ) -> CancelCallback :
16761679 """
16771680 Enable bookmarking for the chat instance.
@@ -1687,15 +1690,15 @@ def enable_bookmarking(
16871690 The chat client instance to use for bookmarking. This can be a Chat model
16881691 provider from [chatlas](https://posit-dev.github.io/chatlas/), or more
16891692 generally, an instance following the `ClientWithState` protocol.
1690- store
1693+ bookmark_store
16911694 A convenience parameter to set the `shiny.express.app_opts(bookmark_store=)`
16921695 which is required for bookmarking (and `.enable_bookmarking()`). If `None`,
16931696 no value will be set.
1694- on
1697+ bookmark_on
16951698 The event to trigger the bookmarking on. Supported values include:
16961699
1697- - `"response"` (the default): a bookmark is triggered when the assistant is done responding.
1698- - `None`: no bookmark is triggered
1700+ - `"response"` (the default): a bookmark is triggered when the assistant is done responding.
1701+ - `None`: no bookmark is triggered
16991702
17001703 When this method triggers a bookmark, it also updates the URL query string to reflect the bookmarked state.
17011704
@@ -1705,12 +1708,12 @@ def enable_bookmarking(
17051708 If the Shiny App does have bookmarking enabled.
17061709 """
17071710
1708- if store is not None :
1711+ if bookmark_store is not None :
17091712 from ..express import app_opts
17101713
1711- app_opts (bookmark_store = store )
1714+ app_opts (bookmark_store = bookmark_store )
17121715
1713- return super ().enable_bookmarking (client , on = on )
1716+ return super ().enable_bookmarking (client , bookmark_on = bookmark_on )
17141717
17151718
17161719@add_example (ex_dir = "../api-examples/Chat" )
0 commit comments