types.HistoryOptions
types.HistoryOptions(
restore_mode='browser',
store='auto',
scope=None,
title='auto',
max_store_mb=100.0,
)Configuration for :class:~shinychat.Chat conversation history.
Pass an instance to Chat(history=...).
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| restore_mode | "Literal['browser', 'url', 'none', 'bookmark']" | How a previous conversation is reloaded when the page opens. "browser" (the default) stores the active conversation ID in localStorage so it survives page reloads without changing the URL. "url" keeps the active conversation ID as a plain ?shinychat_conversation_id=<id> query parameter so users can bookmark or share a link to a specific conversation; no Shiny server bookmarking is required. "none" disables automatic restore entirely. "bookmark" participates in Shiny server bookmarking: after every LLM response a fresh server bookmark is minted and the address bar updates to ?_state_id_=.... Requires bookmark_store="server" in the Shiny app. On in-session conversation switches, navigates to the target conversation’s bookmark URL if one exists. Use this mode when the app uses Shiny bookmarks to capture full input state alongside the chat. The values dict captured by @chat.history.on_save callbacks is restored by @chat.history.on_restore in every restore mode, including "bookmark". Callbacks run after the target conversation becomes active. Raw Shiny input values (sliders, text boxes, etc.) are not synced automatically; use on_restore to update them on both page-load restores and in-session switches. |
'browser' |
| store | "ConversationStore | Literal['auto', 'memory', 'file']" | Where conversations are persisted. "auto" (the default) picks FileConversationStore in most environments and defers to the platform on Posit Connect. "memory" keeps conversations in process only (useful for testing). "file" always uses the file system. Pass a fully-constructed ConversationStore instance for custom back-ends. |
'auto' |
| scope | 'str | Callable[…, str] | None' | Storage namespace for conversations. A string or a callable that returns a string. When None (the default) the authenticated session.user is used; for unauthenticated sessions a per-browser localStorage token is used instead. Pass a shared string to allow multiple users to share history — for example session.groups[0] to scope by group, or a constant like "global" to share across all users. |
None |
| title | "TitleFn | Literal['auto'] | None" | Controls how a new conversation is named. "auto" (the default) generates a title from the first exchange using the LLM. Pass a TitleFn callable to use custom logic instead. Pass None to skip LLM titling entirely — the conversation keeps its initial timestamp-based name. |
'auto' |