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. Note: only the values dict captured by @chat.history.on_save callbacks is restored on in-session conversation switches — raw Shiny input values (sliders, text boxes, etc.) are not synced automatically. For "browser" and "url" modes, use @chat.history.on_restore to update them on both page-load and in-session switches. For "bookmark" mode, @chat.history.on_restore does not fire — Shiny’s native bookmark restore handles app state. Use session.bookmark.on_restore directly if you need to restore auxiliary UI state alongside the conversation. Values captured by @chat.history.on_save are persisted in the conversation record in this mode, but are never passed to on_restore. |
'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' |