Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Chat()'s loading message removal (on error) #1679

Merged
merged 4 commits into from
Sep 12, 2024

Conversation

cpsievert
Copy link
Collaborator

@cpsievert cpsievert commented Sep 11, 2024

After #1607, chat._remove_loading_message() isn't working as intended, which means the loading message doesn't get removed when an error is thrown at the start of a stream (or if a transform returns None). For a simple reprex, notice how the loading message here doesn't get removed when the error happens:

from shiny import reactive
from shiny.express import input, ui

ui.page_opts(
    title="Hello Shiny Chat",
    fillable=True,
    fillable_mobile=True,
)

chat = ui.Chat(id="chat")
chat.ui()


class FailingIterator:
    def __iter__(self):
        return self

    def __next__(self):
        raise Exception("Boom!")


@chat.on_user_submit
async def _():
    await chat.append_message_stream(FailingIterator())
Screenshot 2024-09-11 at 10 42 04 AM

@cpsievert cpsievert merged commit 5419472 into main Sep 12, 2024
48 checks passed
@cpsievert cpsievert deleted the fix/chat-loading-message-removal branch September 12, 2024 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant