Emulator displays all of a turn's messages at the same time
Version
4.12.0
Describe the bug
When Emulator sends a request to the bot, it waits for an HTTP response before it updates the UI with all the messages the bot sent to the Emulator
To Reproduce
- Run a bot that sends multiple messages in one turn with a delay between them
- Connect to the bot in Emulator
- Observe that the messages are all displayed at the same time
Here is some Python code that can reproduce the problem. Note that the problem is not Python-specific, and can be reproduced with any language.
async def on_message_activity(self, turn_context: TurnContext):
start = time.time()
elapsed = time.time() - start
print(f"Message received after {elapsed:.1f} seconds")
await turn_context.send_activity(f"Message received after {elapsed:.1f} seconds")
await asyncio.sleep(2)
elapsed = time.time() - start
print(f"Finished after {elapsed:.1f} seconds!")
await turn_context.send_activity(f"Finished after {elapsed:.1f} seconds!")
Expected behavior
Emulator should display messages immediately as it receives them, the same as any channel.
Screenshots
This is the problem in Emulator:

Here you can see that the print statements are displayed at the right time while the send_activity statements aren't:

This is the correct behavior in Web Chat (which can be seen in any other channel as well):

Additional context
Related Stack Overflow thread: https://stackoverflow.com/questions/67172737/botbuilder-display-message-while-waiting-for-blocking-function
[bug]
Related https://github.com/microsoft/BotFramework-Emulator/issues/2206