Skip to content

Commit 7d02692

Browse files
schloerkecpsievert
andauthored
Apply suggestions from code review
Co-authored-by: Carson Sievert <[email protected]>
1 parent 45de2ae commit 7d02692

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

shiny/ui/_chat.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ def enable_bookmarking(
14271427
This method registers `on_bookmark` and `on_restore` hooks on `session.bookmark`
14281428
to save/restore chat state on both the `Chat` and `client` instances.
14291429
In order for this method to actually work correctly, a `bookmark_store`
1430-
must be specified within `shiny.App()` or `shiny.express.app_opts()`.
1430+
must be specified in `shiny.App()`.
14311431
14321432
Parameters
14331433
----------
@@ -1436,12 +1436,13 @@ def enable_bookmarking(
14361436
provider from [chatlas](https://posit-dev.github.io/chatlas/), or more
14371437
generally, an instance following the `ClientWithState` protocol.
14381438
on
1439-
The event to trigger the bookmarking on.
1439+
The event to trigger the bookmarking on. Supported values include:
14401440
1441-
When `on` is not `None`, the query string with the latest bookmark URL.
1441+
- `"response"` (the default): a bookmark is triggered when the assistant is done responding.
1442+
- `None`: no bookmark is triggered
1443+
1444+
When this method triggers a bookmark, it also updates the URL query string to reflect the bookmarked state.
14421445
1443-
When `on` is `"response"`, the session will attempt to bookmark when the
1444-
assistant is done responding.
14451446
14461447
Raises
14471448
------
@@ -1528,7 +1529,6 @@ async def _(url: str):
15281529
if on == "response":
15291530

15301531
@reactive.effect
1531-
# @reactive.event(lambda: chat.latest_message_stream.result, ignore_init=True)
15321532
@reactive.event(lambda: self.messages(format=MISSING), ignore_init=True)
15331533
async def _():
15341534
messages = self.messages(format=MISSING)
@@ -1559,7 +1559,6 @@ def _on_bookmark_ui(state: BookmarkState):
15591559
)
15601560

15611561
with reactive.isolate():
1562-
# This only contains `ui.Chat(messages=)`
15631562
# This does NOT contain the `chat.ui(messages=)` values.
15641563
# When restoring, the `chat.ui(messages=)` values will need to be kept
15651564
# and the `ui.Chat(messages=)` values will need to be reset
@@ -1683,7 +1682,7 @@ def enable_bookmarking(
16831682
This method registers `on_bookmark` and `on_restore` hooks on `session.bookmark`
16841683
to save/restore chat state on both the `Chat` and `client` instances.
16851684
In order for this method to actually work correctly, a `bookmark_store`
1686-
must be specified within `shiny.App()` or `shiny.express.app_opts()`.
1685+
must be specified in `shiny.express.app_opts()`.
16871686
16881687
Parameters
16891688
----------
@@ -1696,12 +1695,12 @@ def enable_bookmarking(
16961695
which is required for bookmarking (and `.enable_bookmarking()`). If `None`,
16971696
no value will be set.
16981697
on
1699-
The event to trigger the bookmarking on.
1698+
The event to trigger the bookmarking on. Supported values include:
17001699
1701-
When `on` is not `None`, the query string with the latest bookmark URL.
1700+
- `"response"` (the default): a bookmark is triggered when the assistant is done responding.
1701+
- `None`: no bookmark is triggered
17021702
1703-
When `on` is `"response"`, the session will attempt to bookmark when the
1704-
assistant is done responding.
1703+
When this method triggers a bookmark, it also updates the URL query string to reflect the bookmarked state.
17051704
17061705
Raises
17071706
------

0 commit comments

Comments
 (0)