If you send a message and un-focus the window while the buddy is still responding, the app will be in a broken state when you return.
I've worked around the problem by reloading the page if app's in a detected bad state. In that case then the user comes back to same-ish screen and sees 1 button enabled by default -- the reload button, which is fixed to work for the user message being the one reload (and so adds AI msg instead of updating).
A few thoughts come to mind to address this:
Refactor to handle doing DB operations server side and save the message properly once response is finished.
Refresh renderer/client-side to get updated message
Might/Probably can't resume streaming the response, must wait until it's finished
Idea: Client can figure out if message is incomplete yeah? Then fire off an eventsource request (to new endpoint) to get message after loading
If message still loading, endpoint would first send back like { wait: true } and eventually the message itself, or just { wait: false } and the message immediately
Client can replace the message content with a spinner (or do a spinner overlay overtop original text)
If you send a message and un-focus the window while the buddy is still responding, the app will be in a broken state when you return.
I've worked around the problem by reloading the page if app's in a detected bad state. In that case then the user comes back to same-ish screen and sees 1 button enabled by default -- the reload button, which is fixed to work for the user message being the one reload (and so adds AI msg instead of updating).
A few thoughts come to mind to address this: