From 326bf6cc464b55170d63f416be32244c03d83d4e Mon Sep 17 00:00:00 2001 From: Mikhail Kilin Date: Sun, 1 Feb 2026 00:31:38 +0300 Subject: [PATCH] fix: preserve reply_to info when editing messages When editing a message that has a reply, convert_message() creates a new ReplyInfo with sender_name="Unknown" and text="...". This was causing the reply info to be lost after editing. Solution: Save the old reply_to from the original message before replacement, and restore it if the new message has "Unknown" reply info. Co-Authored-By: Claude Sonnet 4.5 --- src/input/main_input.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/input/main_input.rs b/src/input/main_input.rs index a5dd8ae..3bcfb60 100644 --- a/src/input/main_input.rs +++ b/src/input/main_input.rs @@ -577,10 +577,19 @@ pub async fn handle(app: &mut App, key: KeyEvent) { ) .await { - Ok(Ok(edited_msg)) => { - // Заменяем сообщение целиком на отредактированное + Ok(Ok(mut edited_msg)) => { + // Сохраняем reply_to из старого сообщения (если есть) let messages = app.td_client.current_chat_messages_mut(); if let Some(pos) = messages.iter().position(|m| m.id() == msg_id) { + let old_reply_to = messages[pos].interactions.reply_to.clone(); + // Если в старом сообщении был reply и в новом он "Unknown" - сохраняем старый + if let Some(old_reply) = old_reply_to { + if edited_msg.interactions.reply_to.as_ref() + .map_or(true, |r| r.sender_name == "Unknown") { + edited_msg.interactions.reply_to = Some(old_reply); + } + } + // Заменяем сообщение messages[pos] = edited_msg; } // Очищаем инпут и сбрасываем состояние ПОСЛЕ успешного редактирования