diff --git a/app/bot/responder.ts b/app/bot/responder.ts index 66d9dc2..2845c0b 100644 --- a/app/bot/responder.ts +++ b/app/bot/responder.ts @@ -329,6 +329,7 @@ export async function handleBotAiResponse(ctx: Context): Promise { }; const sendOrEdit = (accumulated: string): void => { + clearInterval(typingInterval); streamedAccumulated = accumulated; if (isCancelled()) return; const slice = accumulated.length > MAX_MESSAGE_TEXT_LENGTH @@ -372,7 +373,19 @@ export async function handleBotAiResponse(ctx: Context): Promise { interruptedReplyCallback = sendInterruptedReply; - await sendOrEditOnce("…", "…"); + // Start with rotating typing indicator instead of static "…" + const typingFrames = ["\\", "/", "-", "|"]; + let typingIndex = 0; + + await sendOrEditOnce(typingFrames[typingIndex], typingFrames[typingIndex]); + + const typingInterval = setInterval(() => { + if (sentMessageId === null) return; + typingIndex = (typingIndex + 1) % typingFrames.length; + ctx.api + .editMessageText(chatId, sentMessageId, typingFrames[typingIndex]) + .catch(() => {}); + }, 300); result = await transmitStream( { input: text, userId, context, mode, threadContext, instructions: TELEGRAM_BOT_LENGTH_INSTRUCTION }, sendOrEdit,