BotFramework-Emulator icon indicating copy to clipboard operation
BotFramework-Emulator copied to clipboard

Emulator displays all of a turn's messages at the same time

Open v-kydela opened this issue 4 years ago • 1 comments

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

  1. Run a bot that sends multiple messages in one turn with a delay between them
  2. Connect to the bot in Emulator
  3. 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:

Emulator

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

Console

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

WebChat

Additional context

Related Stack Overflow thread: https://stackoverflow.com/questions/67172737/botbuilder-display-message-while-waiting-for-blocking-function

[bug]

v-kydela avatar Apr 23 '21 23:04 v-kydela

Related https://github.com/microsoft/BotFramework-Emulator/issues/2206

EricDahlvang avatar May 06 '21 14:05 EricDahlvang