Skip to content

Store both the UI and chat turns #61

@schloerke

Description

@schloerke

Originally posted by @cpsievert in #28 (comment)

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 ellmer turns.

PS. I know we're considering localstorage as 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_string

Then, 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions