fix: add typing indicator debug logging

This commit is contained in:
admin
2026-05-05 19:05:06 +00:00
Unverified
parent 709071106c
commit 09f5ce080b

View File

@@ -1091,9 +1091,15 @@ export async function initBot(config, api, tools, skills, agents) {
let firstTokenArrived = false; let firstTokenArrived = false;
const typingInterval = setInterval(async () => { const typingInterval = setInterval(async () => {
if (firstTokenArrived) return; if (firstTokenArrived) return;
try { await ctx.api.sendChatAction(ctx.chat.id, 'typing'); } catch {} 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 }, 4000); // Telegram typing expires after 5s, refresh every 4s
await ctx.api.sendChatAction(ctx.chat.id, 'typing'); // initial ping try {
await ctx.api.sendChatAction(ctx.chat.id, 'typing');
logger.info('⌨️ typing started');
} catch (e) { logger.warn(`⌨️ initial typing error: ${e.message}`); }
try { try {
// ── Load conversation history for this chat ── // ── Load conversation history for this chat ──
@@ -1129,6 +1135,7 @@ export async function initBot(config, api, tools, skills, agents) {
// Stop typing indicator // Stop typing indicator
firstTokenArrived = true; firstTokenArrived = true;
clearInterval(typingInterval); clearInterval(typingInterval);
logger.info('⌨️ typing stopped (response complete)');
// Signal completion and wait for final edit // Signal completion and wait for final edit
consumer.finish(); consumer.finish();