Skip to content

Conversation

@jcheng5
Copy link
Collaborator

@jcheng5 jcheng5 commented Jun 28, 2025

Before this commit:

  1. Call chat_app(client) (or ellmer::live_browser(client), which passes through to chat_app)
  2. Chat with the bot a little bit
  3. Hit Reload in the browser window

The discussion you have disappears, but the state is still present in the client--the UI and server state have gotten out of sync.

If you Ctrl+C out of the app, and then call chat_app(client) again, the existing messages are now displayed. But if you talk more, and then hit Reload, you'll be reverted back to the UI state that was correct at the time chat_app(client) was most recently called.

This is fixed by calling chat_ui at page load time, not at chat_app() invocation time.

(Note that it's unsafe to use a chat_app() from multiple browser windows simultaneously, since every chat will mutate the same client object. Might be worth putting in a tiny bit of code that closes existing sessions when a new session arrives.)

Copy link
Collaborator

@gadenbuie gadenbuie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch and simple fix. Thanks!

@gadenbuie gadenbuie merged commit b59f075 into main Jun 30, 2025
5 checks passed
@gadenbuie gadenbuie deleted the chat_app-stale-ui branch June 30, 2025 13:36
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.

3 participants