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

Typing indicator not rendering while waiting on a delayed activity #2451

Open
stevkan opened this issue Feb 14, 2024 · 0 comments
Open

Typing indicator not rendering while waiting on a delayed activity #2451

stevkan opened this issue Feb 14, 2024 · 0 comments
Labels
Bug Your classic code defect

Comments

@stevkan
Copy link
Collaborator

stevkan commented Feb 14, 2024

Version

4.14.1 & 4.14.1-371583 (nightly)

Describe the bug

Whether using a JS or a .NET bot, when the ShowTypingMiddleware is utilized, if the message activity to be sent by the bot is delayed, the typing indicator fails to render. However, the activity is still logged in the network activity window and the activity can be selected in the transcript window.

Similarly, with_out_ using ShowTypingMiddleware, when sending a typing activity, followed by a delay activity, and finally a message activity the typing activity will fail to render.

To Reproduce

(In a JS-based bot)

Option 1 steps to reproduce the behavior:

  1. Open the 02.echo-bot sample
  2. In the index.js file, add .use(new ShowTypingMiddleware(500, 1000)) to the adapter
  3. In the bot.js file, change the this.onMessage handler to the following:
this.onMessage(async (context, next) => {
    const replyText = `Echo: ${ context.activity.text }`;

    await asyncTimeout(
        async () =>
            await context.sendActivity(MessageFactory.text(replyText, replyText)),
        4000
    );
   await next();
}
  1. In the bot.js file, add this function at the end:
const asyncTimeout = async (callback, ms) =>
    new Promise((resolve, reject) => {
        const timeout = setTimeout(async () => {
            if (await callback()) {
                resolve(null);
                clearTimeout(timeout);
            } else {
                reject();
                clearTimeout(timeout);
            }
        }, ms);
    });
  1. Run the bot and test in Emulator

Option 2 steps to reproduce the behavior:

  1. Open the 02.echo-bot sample
  2. In the bot.js file, change the this.onMessage handler to the following:
await context.sendActivity({ type: 'typing' });
await context.sendActivity({ type: 'delay', value: 4000 });
await context.sendActivity({ type: 'message', text: 'Some message' });
  1. Run the bot and test in Emulator

Expected behavior

The typing indicator should render whenever a delay prevents the next activity from immediately being sent.

Additional context

Presently, Emulator uses an older version of Web Chat which may be a factor. When using an updated instance of Web Chat this behavior is not present.

Additionally, the delay activity type isn't used or recognized by Web Chat whereas it does appear to be recognized by Emulator. Updating the Web Chat version in Emulator may affect this.

[bug]

@stevkan stevkan added the Bug Your classic code defect label Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Your classic code defect
Projects
None yet
Development

No branches or pull requests

1 participant