ChatbotX icon indicating copy to clipboard operation
ChatbotX copied to clipboard

Webchat: typing indicator never clears after the bot reply (no typing:false is ever sent)

Open grupoarcos opened this issue 2 months ago • 0 comments

Environment

Self-hosted, images ghcr.io/chatbotxio/chatbotx-{builder,worker,realtime}:latest built 2026-09-08. The same code is on main @ 2c59740 (2026-09-11).

Steps to reproduce

  1. Set an AI agent as the default reply (any automated response that calls sendTypingToChannel works too).
  2. Open the webchat widget on a page and send "hi".
  3. The typing dots appear while the reply is generated; the reply arrives; the dots stay on screen until the iframe is reloaded.

Root cause

  • Worker automated-response (ar-index.ts): sendTyping() posts { typing: true, seconds: 5 } immediately and every 4 s with setInterval; the finally block only does clearInterval. Nothing ever posts { typing: false }.
  • Widget apps/builder/src/features/integration-webchat/webchat-realtime.tsx: case RealtimeEventType.typing: setIsTyping(data.typing), while case messageCreated: handleNewMessage(data) does not touch isTyping.
  • apps/realtime/src/parties/guests.ts only broadcasts the payload; nothing honors seconds.

Net effect: isTyping becomes true on the first bot reply and never goes back to false.

Realtime log for one exchange (room = the guest conversation):

12:48:54  POST /parties/guests/<room>   (typing: true)
12:48:58  POST /parties/guests/<room>   (typing: true, 4 s interval)
12:48:59  POST /parties/guests/<room>   (messageCreated, outgoing)
(nothing afterwards)

Expected

Dots visible only while the bot is generating; cleared when the outgoing message arrives (or after seconds).

Suggested fix

Either side is enough:

  • Widget: clear isTyping when an outgoing messageCreated arrives (PR incoming).
  • Worker: send { typing: false } after clearInterval in the finally block.

grupoarcos avatar Sep 11 '26 13:09 grupoarcos