posit-dev / posit-dev/shinychat
Store both the UI and chat turns
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 139
- Forks
- 28
- Avg merge
- 23h 44m
- Merged PRs (30d)
- 50
Description
Originally posted by @cpsievert in https://github.com/posit-dev/shinychat/pull/28#discussion_r2105423207
We should probably have a big ol' warning/disclaimer somewhere around here that this currently only works as intended when the UI content matches what is stored in the
ellmerturns.PS. I know we're considering
localstorageas a potential long-term solution to this issue, which would be great.Just throw it out there, something I just thought of is that if the append knew about the
chat_client:chat_append_message("id", chat_client$stream("foo"), chat_client)Then, when the message ends, we could do something like:
turns <- chat$get_turns() # When the stream gets exhausted, the last turn represents "this" assistant turn last_turn <- turns[[length(turns)]] key <- rlang::hash(last_turn@contents) session$userData[[key]] <- final_ui_content_stringThen, when restoring the bookmark, we could do a lookup from
session$userData? There is a small risk of hash collisions doing it just based on contents, but we can probably workaround that? Anyway, just wanted to offer it as an idea to consider at this point and see what you think.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing chat_append_message, chat_client$stream, chat$get_turns(), and session$userData during message completion and bookmark restoration. The issue needs an agreed design for retaining both UI content and ellmer turns, with restored conversations remaining consistent even when their displayed content differs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- full-stack
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100