feat(pkg-r): Support streaming ContentThinking#167
Open
simonpcouch wants to merge 6 commits intoposit-dev:mainfrom
Open
feat(pkg-r): Support streaming ContentThinking#167simonpcouch wants to merge 6 commits intoposit-dev:mainfrom
ContentThinking#167simonpcouch wants to merge 6 commits intoposit-dev:mainfrom
Conversation
simonpcouch
commented
Dec 19, 2025
pkg-r/R/contents_shinychat.R
Outdated
| compact(map(content@contents, contents_shinychat)) | ||
| contents <- content@contents | ||
|
|
||
| # Consolidate adjacent ContentThinking into single blocks |
Contributor
Author
```
- pkg-r/inst/lib/shiny/thinking/thinking.js:68-75 – Map entries aren’t cleared when a thinking block completes
(only deleted for empty text). Each streamed thinking block leaves a live entry holding DOM nodes, so a long
session will leak memory. Delete the entry on done regardless of content.
- pkg-r/inst/lib/shiny/thinking/thinking.js:39-45 – The retry loop (setTimeout) runs forever if a start
arrives after the streaming message has disappeared (e.g., chat cleared or race on disconnect). Add a stop
condition (max retries / bail when the chat container is gone) or drop the message when no streaming target
exists.
```
Contributor
Author
|
I'm unable to request reviews on this repo, but cc @gadenbuie :) |
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.


Addresses #76, but only on the R side. Adds support for displaying
ContentThinkingduring streaming and on reload.Without corresponding changes in ellmer, this PR doesn't do anything; with
mainellmer, shinychat behaves as it currently does, just streaming the thinking content as if it were normal assistant text content. With an incoming ellmer PR (that adds a Remotes on this PR), this is how the content streams + reloads:ellmer-shinychat-thinking.mp4
Here's the script I was using the test in that video: