Chat UI Component for 'shiny'
Overview
Provides a scrolling chat interface with multiline input, suitable for creating chatbot apps based on Large Language Models (LLMs). Designed to work particularly well with the 'ellmer' R package for calling LLMs.
API additions
- Added
chat_server()as the new primary way to wire up server-side chat logic. Pair it withchat_ui()by matchingid, e.g.chat_ui("chat")withchat_server("chat", client). It does the same job aschat_mod_server()but runs directly in the caller's session scope rather than creating its own module scope, and it enables many of the features under *New features and improvements* below automatically.chat_mod_server()andchat_mod_ui()are now soft-deprecated in favor ofchat_server()andchat_ui(). (#264) - Added
page_chat()for full-window chat pages with persistent chat navigation, responsive sidebars, and drawers. Register secondary pages withchat_nav_panel(), configure sidebars withchat_sidebar(), and add a drawer withchat_drawer(), controllable from the server viachat_drawer_show(),chat_drawer_update(),chat_drawer_hide(), andchat_drawer_toggle(). Related additions:chat_ui_history()for mounting conversation history outside the chat, apage_chat_theme()baseline theme, anddrawer/show_historyoptions onchat_ui(). (#329) - The page shell also supports standard bslib programmatic navigation (e.g.
bslib::nav_select()), with the active page readable server-side asinput$<id>_page. - Added slash commands: a typeahead command palette that lets users trigger named shortcuts directly from the chat input (type
/to open it). Commands can expand into LLM prompts, trigger server-side side effects (clear chat, open a modal, export transcript), or be handled entirely client-side via the cancelableshiny:chat-slash-commandDOM event. Register commands with theslash_command()method of the object returned bychat_server(); itsechoparameter controls whether an invocation is recorded as a user message and triggers a loading state. (#239) - Added
chat_get_greeting()for reading the current greeting (and whether the user dismissed it) from the server, along with a newinput$<id>_greeting_dismissedevent. Server-set greetings now also survive Shiny bookmarking round-trips. (#254)
New features and improvements
chat_server()gets multi-conversation history automatically: a drawer for starting new chats and returning to previous ones, with LLM-generated titles, search, rename, and delete. Conversations are persisted per-user (or a custom scope) via a pluggable store (the defaultFileConversationStoreworks out of the box, including on Posit Connect). Customize withhistory = history_options(...)— e.g. how the active conversation is restored across reloads (browser storage, URL, or Shiny bookmarking) and callbacks to keep app state synced to it — or opt out withhistory = FALSE. The history object also offers programmatic control, including a reactive conversation ID and an explicitsave()method. For apps that can't usechat_server(), wire it up manually withchat_enable_history(). (#266, #307, #328)- You can now edit and resend a message after sending it. Editing forks the conversation from that point — the original branch is kept as a sibling, and
‹ 1 / 2 ›controls let you switch between versions at any time, including after reloading the page or returning from the history drawer. Requires history to be enabled (the default withchat_server()). (#269) - Cancelling an in-progress response is now automatic with
chat_server(): the stop button appears by default and cancellation is handled for you. (#264) - Added file attachment support: users can upload images, PDFs, and text files alongside their messages.
chat_server()enables attachments by default and automatically converts uploads into ellmerContentobjects for the model. For non-chat_server()usage, enable withallow_attachments = TRUE(or a MIME allow-list). The maximum combined attachment size defaults to approximately 30 MB and can be configured via theSHINYCHAT_MAX_ATTACHMENT_SIZEenvironment variable. (#250) - When attachments are enabled,
input$<id>_user_inputis a list of ellmerContentobjects (typed text, if present, followed by one object per attachment) rather than a plain string — forward it to a chat method by splicing with!!!, e.g.chat$stream_async(!!!input$<id>_user_input). Thelast_inputreactive returned bychat_server()mirrors this shape.
Show all changes in 0.5.0Hide the rest of the changes in 0.5.0
- Web search and web fetch responses from ellmer now show their activity and citations directly in the chat. Readers can open a citation beside its claim or use the message-wide Sources pill.
ContentCitation@grounded_spanlinks each citation to the answer text it supports. (#280) - Citations are powered by a new
<shiny-aside>markup convention that any assistant message can use to attach source details to specific claims — useful for custom RAG workflows. See theAsidessection in?chat_append. (#278) - Tool call displays have been reworked to be more concise and to intelligently group multiple calls together. By default, calls render as a condensed activity row; expand a group row to see each call, then drill into a call for its full request/result card. (#283)
- Added
tool_result_display(), a constructor for thedisplayobject passed asextra = list(display = ...)on anellmer::ContentToolResult(a bare named list with the same fields still works). Newlabelandvalue_previewfields (e.g. a filename, and "1,204 rows") are shown in the activity row. - A tool's definition
title(from its annotations) and its resulttitle(fromtool_result_display()) are now shown as-is, without client-side tense conjugation — the old"Running {title}"/"{title} failed"templates are gone. The definition title shows while the call is running; for a single-call row, the result title (if provided) replaces it when the result arrives, and failures are shown via a separate status cue. If a title now reads oddly while running, write it in the present tense (e.g. "Running R code"). - Control grouping with the
tool_groupingparameter ofchat_ui():"tool"(default) groups calls to the same tool within a tool-calling loop,"all"groups every call in the loop together, and"none"shows one activity row per call (thinking or prose starts a new loop). Individual tools can override the chat-level setting with agroupingtool annotation, e.g.tool(..., annotations = tool_annotations(grouping = "all")). - Set
open_style = "framed"intool_result_display()to draw a border around an open tool result's header and contents — a better fit for results with a footer or fullscreen toggle. (#331) - Fully custom tool-result UI returned from a
contents_shinychat()method is now paired with its tool request: while the tool runs it appears in the activity row, and once the result arrives the custom UI renders as standalone output. Custom results are also preserved when preloading or restoring conversations. - Added
submit_keyparameter tochat_ui():"enter"(default, Enter submits) or"enter+modifier"(Ctrl/Cmd+Enter submits, plain Enter inserts a line break). The input remains editable while a response is streaming — only submission is blocked, not typing. (#251) - The send button is easier to customize: a new
icon_sendparameter onchat_ui()swaps the submit icon, and adata-stateattribute exposes the button's current state for styling. (#350) - Styling is more customizable via CSS custom properties: the set of public
--shiny-chat-*variables has grown to cover the send button, history drawer, page layout, thinking display, and more, and all of them can now be overridden from:root(previously, element-level defaults always won). (#350, #355) - Single tildes no longer trigger strikethrough in markdown. Text like
(~$1.50)and~/Documentsnow renders as literal text; only~~text~~produces strikethrough. (#349, #353)
Breaking changes
chat_app()now configures its full-window page throughpage_chat(). Arguments in...are passed topage_chat()instead ofshiny::shinyApp(): useapp_optionsinstead ofoptions,bookmark_storeinstead ofenableBookmarking, and composepage_chat()withchat_server()when you needonStartoruiPattern.chat_app()now owns the page layout, so itstitle,icon, andidconfigure the page-chat shell. Existing layouts that embed chat should usechat_ui()andchat_server()directly. (#329)- The
messagesparameter is deprecated in favor of the conversation-history feature:chat_ui(messages = ...)now warns, andchat_app(messages = ...)errors when history is enabled (the default). Usegreetingfor a startup message,chat_append()to replay messages, orhistory = FALSEif you manage state yourself. (#381) - CSS classes and custom properties used by the external-link dialog, thinking display, and tool-result images/PDFs now use the
.shiny-chat-*prefix instead of.shinychat-*. Update any custom CSS that targets these identifiers. (#285, #286)
Changes
chat_ui()andpage_chat()no longer show an assistant icon by default. Passicon_assistant = TRUEto restore the built-in robot icon, or supply your own icon as before. (#345)chat_ui()now uses a wider default content width on large displays while preserving its existing width on smaller windows. (#364)- The
dismissibleparameter ofchat_greeting()has been renamed topersistentwith an inverted value.dismissible = FALSE(greeting stays visible) is nowpersistent = TRUE. The olddismissibleargument still works but warns. (#260)
Bug fixes
- Fixed a security issue where model-authored Markdown could create or escape into shinychat's raw-HTML islands (
<shiny-chat-raw-html>), potentially injecting arbitrary HTML into the page. As part of this,output_markdown_stream()/markdown_stream()now track which parts of a mixed value are trusted server-rendered HTML versus untrusted text. (#287, #360) - A response that fails before it streams anything (e.g. an exhausted quota, an over-long context, or a dropped connection) is now reported in the chat instead of leaving a loading indicator that never resolves and a locked composer. The
chat_server()return also gainedlast_error, a reactive holding the condition from the most recent failed response, since both a finished and a failed response report"idle"instatus. (#304, #314) - Fixed
output_markdown_stream()permanently stopping following new content after the user scrolled back to the bottom. (#282) - Fixed expanding or collapsing a tool result yanking the chat's scroll position away from what you were reading. (#348)
chat_app()no longer renders a close button or registers astopApp()observer when deployed to a server. Both are now gated onrlang::is_interactive(), preventing session crashes in multi-user deployments. (#265)- Fixed control-only inputs (the close button, cancel button, and greeting-requested signal) leaking into bookmarked state. (#258, #259)
- Fixed
set_client()failing when the conversation contains an htmlwidget ortagList(). (#362, #369) - Fixed suggestion cards and the greeting overflowing the chat container in narrow spaces such as sidebars. (#255)
- Fixed the copy button on code blocks not working in some embedded contexts. (@thisisnic, #247)
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-04
- NOTE12 OK, 1 NOTE2026-08-01
- OK14 OK2026-03-10
Documentation
- Help pages
- 32 (2 internal)includes a package overview page
- Examples that run
- 92%12 run in a plain check (11 of them under a condition) · 1 never run
- Exported functions with examples
- 42%
- Documented parameters
- 97%
- Return-value docs
- 87%
- Help pages citing references
- 0%
Downloads
Repository
- PRs merged (all time)
- 89%
- Median days to close, 50 most recently updated closed issues
- 4
- Median days to close, 50 most recently updated closed PRs
- 0
Stars over time
Forks over time
Releases over time
Issues over time
PRs over time
Commits over time
Commit identities over time
7 development-tooling and community-health practices detected across 5 families in the upstream repository
Checks run against github.com/posit-dev/shinychat on 2026-10-11.
GitHub Pages site last deployed 2026-09-24 · The repository has a site deploy workflow
Show all practicesHide 1 practice
This repository shows signs of AI coding tools.
- Claude Codefirst seen 2026-03-06Seen in the repository: CLAUDE.mdPull request it wrote: opened by a project memberCommits: at least 13 crediting it in the message
- Claude Opus 4.612 commits · Mar to Apr 2026
- Claude Sonnet 4.61 commit · Apr 2026
Dependencies
Installing shinychat adds 43 packages (27 with compiled code, 33 MB of source tarballs). Heaviest: bslib 5.6 MB, promises 3.1 MB, ellmer 3.0 MB.
Code & Tests
People & History
Previously maintained by Joe Cheng (0.1.1).
Pick two releases to compare their code metrics.
- 0.5.0Latest2026-09-09 · current release · diff ↗ ·
added 19 exports
ContentSlashCommand, ConversationStore, FileConversationStore, chat_attachment, chat_drawer, chat_drawer_hide, chat_drawer_show, chat_drawer_toggle, chat_drawer_update, chat_enable_history, chat_get_greeting, chat_nav_panel, chat_server, chat_sidebar, chat_ui_history, history_options, page_chat, page_chat_theme, tool_result_display - 0.4.0
- RR 4.6.0 released · 2026-04-24
- 0.3.0
- 0.2.02025-05-16 · diff ↗ ·
added 6 exports
chat_app, chat_clear, chat_mod_server, chat_mod_ui, markdown_stream, output_markdown_stream - RR 4.5.0 released · 2025-04-11
- 0.1.12024-12-18
- RR 4.4.0 released · 2024-04-24
Package metadata
- First published
- 2024-12-18
- Total releases
- 5 / 2 yrs
- License
- MIT + file LICENSE OSI
- Download size
- 2.1 MB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("shinychat")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-19, which the citation names so these numbers can be found later. More on citing and the projects behind them.