diff --git a/src/bot/index.js b/src/bot/index.js index 66e01e82..b269216b 100644 --- a/src/bot/index.js +++ b/src/bot/index.js @@ -1087,13 +1087,10 @@ export async function initBot(config, api, tools, skills, agents) { logger.info(`${prefix} ${user}: ${text.substring(0, 80)}…`); await queueRequest(key, text, async () => { - // ── Typing indicator: keep pinging until first stream token arrives ── - let firstTokenArrived = false; + // ── Typing indicator: keep pinging until response is fully complete ── const typingInterval = setInterval(async () => { - if (firstTokenArrived) return; try { await ctx.api.sendChatAction(ctx.chat.id, 'typing'); - logger.debug('⌨️ typing ping'); } catch (e) { logger.warn(`⌨️ typing error: ${e.message}`); } }, 4000); // Telegram typing expires after 5s, refresh every 4s try { @@ -1121,7 +1118,6 @@ export async function initBot(config, api, tools, skills, agents) { // Wrap chatWithAI with self-correction + streaming const chatWithCorrection = withSelfCorrection(async (msgs) => { return await chatWithAI(msgs, { onDelta: (token) => { - if (!firstTokenArrived) firstTokenArrived = true; consumer.onDelta(token); }}); }); @@ -1133,7 +1129,6 @@ export async function initBot(config, api, tools, skills, agents) { if (result) await conversation.add(chatKey, 'assistant', result); // Stop typing indicator - firstTokenArrived = true; clearInterval(typingInterval); logger.info('⌨️ typing stopped (response complete)');