in src/components/Widget/index.js [212:240]
newMessageTimeout(message) {
const { dispatch, customMessageDelay } = this.props;
this.delayedMessage = message;
this.messageDelayTimeout = setTimeout(() => {
this.dispatchMessage(message);
this.delayedMessage = null;
this.applyCustomStyle();
dispatch(triggerMessageDelayed(false));
this.onGoingMessageDelay = false;
this.popLastMessage();
// Hide WIP bubble only if:
// 1. No more messages in queue
// 2. Last bot_uttered had is_final:true
// Add small delay to allow React to render buttons/replies before hiding WIP
logger.debug('newMessageTimeout check:', {
messagesLength: this.messages.length,
lastIsFinal: this.lastIsFinal,
willHideWIP: this.messages.length === 0 && this.lastIsFinal
});
if (this.messages.length === 0 && this.lastIsFinal) {
setTimeout(() => {
logger.debug('Hiding WIP after message displayed');
dispatch(setBotProcessing(false));
// Clear timeout when hiding WIP after final message
clearBotProcessingTimeout();
}, 100);
}
}, customMessageDelay(message.text || ''));
}