From 87478b6e929abbfb661dbe191d2e17a2fb4f7a0c Mon Sep 17 00:00:00 2001 From: sanasif786ka Date: Tue, 7 Jul 2026 22:34:12 +0530 Subject: [PATCH] fix(telegram): keep raw markdown in overflow stream buffer tail Send the overflow tail message with HTML parse_mode, but persist the unrendered markdown chunk in buf.text so later deltas and stream_end re-render correctly via _split_telegram_markdown_html(). --- nanobot/channels/telegram.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nanobot/channels/telegram.py b/nanobot/channels/telegram.py index 272b1ef6..2dbfe2b3 100644 --- a/nanobot/channels/telegram.py +++ b/nanobot/channels/telegram.py @@ -1077,13 +1077,14 @@ class TelegramChannel(BaseChannel): self._app.bot.send_message, chat_id=chat_id, text=chunk, parse_mode="HTML", **thread_kwargs, ) - tail = html_chunks[-1] + markdown_tail = chunks[-1] + tail_html = html_chunks[-1] sent = await self._call_with_retry( self._app.bot.send_message, - chat_id=chat_id, text=tail, parse_mode="HTML", **thread_kwargs, + chat_id=chat_id, text=tail_html, parse_mode="HTML", **thread_kwargs, ) buf.message_id = sent.message_id - buf.text = tail + buf.text = markdown_tail async def _on_start(self, update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: """Handle /start command."""