feat!(pkg-r): add chat_server(), deprecate chat_mod_server() and chat_mod_ui() - #264
Merged
Conversation
…existing modules Soft-deprecates chat_mod_server() and chat_mod_ui().
cpsievert
marked this pull request as draft
June 25, 2026 01:29
cpsievert
marked this pull request as ready for review
June 25, 2026 14:21
cpsievert
commented
Jun 25, 2026
gadenbuie
reviewed
Jun 25, 2026
…s in chat_server() chat_server() + chat_ui() now replace chat_mod_server() + chat_mod_ui() throughout docs, examples, vignettes, and test apps. To preserve the same batteries-included behavior, enable_cancel and allow_attachments in chat_ui() now default to NULL (defer to server) rather than FALSE. chat_server() sends update_cancel and update_upload actions at init, automatically enabling both features — matching Python's tri-state pattern. Explicit TRUE/FALSE in chat_ui() still wins; FALSE now emits the attribute as "false" so the server cannot override an explicit opt-out.
cpsievert
force-pushed
the
feat/chat-server
branch
from
June 25, 2026 23:11
6d20b17 to
21c5354
Compare
`?chat_mod_ui` now has a standalone deprecated page (with lifecycle badge and migration guidance) rather than appearing on `?chat_app`.
chat_server(), deprecate chat_mod_server() and chat_mod_ui()
2 tasks
simonpcouch
pushed a commit
to posit-dev/commons
that referenced
this pull request
Jul 21, 2026
…er() (#38) shinychat deprecated chat_mod_ui()/chat_mod_server() in favor of chat_ui()/chat_server(), which run in the caller's own session scope instead of a private module scope (posit-dev/shinychat#264). commons_ui()/ commons_server() replace commons_mod_ui()/commons_mod_server() to match. Since chat_server() now handles history persistence automatically, commons_server() no longer takes bookmark_on_input/bookmark_on_response. Fixes a bug introduced by dropping the module wrapper: the provenance-pill messages targeted a hardcoded "chat" id (previously correct only because session$ns() was scoped to the module id), so pills silently failed to attach for any chat id other than "chat". They now resolve the id the same way shinychat's own chat_server() internals do, via session$ns(id).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
chat_server()replaceschat_mod_server()as the primary way to wire up server-side chat logic.The original module-based API (
chat_mod_ui()/chat_mod_server()) was more structure than the use case needs. The goal of this API is simple: you hand us an ellmer client and we hook up all the server logic most people want — streaming, cancellation, bookmarking, etc. A fullmoduleServer()scope isn't required to deliver that. Furthermore, since part of the ID namespace is private/implicit, downstream logic that depends on the chat's ID (e.g., slash command JS events) need workarounds to work in the way users might expect. This change also better aligns the R package with the Python API where no modules are needed to get the "batteries included" experience.chat_server()does the same job but runs directly in the caller's session scope. If you're already inside amoduleServer(), you pass that session in — no extra nesting, no doubled namespaces.What changed
chat_server(id, client, ..., session)— new exported function with the same logic aschat_mod_server(), but runs in the provided session scope rather than creating its own. Takes an explicitsessionparameter (defaults togetDefaultReactiveDomain()).chat_mod_server()— soft-deprecated (0.5.0). Now a thin wrapper aroundchat_server().chat_mod_ui()— soft-deprecated (0.5.0). Replace withchat_ui(NS(id, "chat"), ...)in your module UI.Migration
The simplest case — no module needed at all:
If you're embedding chat inside an existing module, pass that module's
sessionexplicitly:Existing code using
chat_mod_server()continues to work with a deprecation notice.