fix: send new message if edit_text fails silently in /process
Build & Deploy ResearchOwl / build-and-push (push) Successful in 7s

If the bot restarted between sending the progress message and the
completion callback, edit_text may fail silently (Conflict/stale ref).
Store completion text and reply_text as fallback so the user always
sees the result.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ChemaVX
2026-04-28 10:53:59 +00:00
parent c4fb33fbf5
commit 5feff6073e
+12 -5
View File
@@ -465,21 +465,28 @@ async def cmd_process(update: Update, ctx: ContextTypes.DEFAULT_TYPE):
processor = ContentProcessor(db, ollama) processor = ContentProcessor(db, ollama)
completion_text = None
async def proc_progress(total_chunks, total_words): async def proc_progress(total_chunks, total_words):
try: nonlocal completion_text
await msg.edit_text( completion_text = (
f"🧠 *Processing complete!*\n" f"🧠 *Processing complete!*\n"
f"• Chunks stored: `{total_chunks}`\n" f"• Chunks stored: `{total_chunks}`\n"
f"• Words researched: `{total_words:,}`\n\n" f"• Words researched: `{total_words:,}`\n\n"
f"Ready! Use `/generate podcast|blog|report|thread`\n" f"Ready! Use `/generate podcast|blog|report|thread`"
f"_If 0 chunks: set `QUALITY_THRESHOLD=0.3` or `0` and retry_",
parse_mode=ParseMode.MARKDOWN
) )
try:
await msg.edit_text(completion_text, parse_mode=ParseMode.MARKDOWN)
completion_text = None # sent, no need to resend
except Exception: except Exception:
pass pass
await processor.process_session(session_id, topic, proc_progress) await processor.process_session(session_id, topic, proc_progress)
# Fallback: if edit_text failed silently, send a new message
if completion_text:
await update.message.reply_text(completion_text, parse_mode=ParseMode.MARKDOWN)
except Exception as e: except Exception as e:
logger.error("Process command failed", error=str(e)) logger.error("Process command failed", error=str(e))
await update.message.reply_text(f"❌ Processing failed: {str(e)[:200]}") await update.message.reply_text(f"❌ Processing failed: {str(e)[:200]}")