Fix quote reply becoming invalid after source message edit#30453
Fix quote reply becoming invalid after source message edit#30453overpathz wants to merge 1 commit into
Conversation
When a user selects text and uses Quote & Reply, then the original message is edited; the stored quote_text could become stale. Sending would fail with QUOTE_TEXT_INVALID from the server. Now on message edit the quote is re-validated: if the quoted fragment still exists at the same offset, entities are refreshed; if the fragment no longer exists, the quote is cleared and a plain reply is kept instead.
| const auto editId = _editMsgId.current(); | ||
| if (editId) { |
There was a problem hiding this comment.
| const auto editId = _editMsgId.current(); | |
| if (editId) { | |
| if (const auto editId = _editMsgId.current()) { |
| [[nodiscard]] bool ExtractCurrentQuote( | ||
| not_null<HistoryItem*> item, | ||
| const FullReplyTo &reply, | ||
| TextWithEntities &result) { |
There was a problem hiding this comment.
We try to avoid doing that.
If you need to get two results from a function (in this case, bool and TextWithEntities), define a structure with two fields at the top that the function will return.
| auto updated = reply; | ||
| updated.quote = TextWithEntities(); | ||
| updated.quoteOffset = 0; | ||
| _replyTo = updated; |
There was a problem hiding this comment.
What's the point of all this moving from one empty place to another?
|
I guess you did not test your changes? |
|
@23rd Related to testing - yep, I didn't test it. |
just follow the instruction linked in the bottom of readme and if you have any problems, use |
Problem
When user A sends a message, user B selects part of it and chooses
Quote & Reply, then user A edits that message — user B's send gets
stuck with QUOTE_TEXT_INVALID error from the server.
Root cause
The quote_text stored in reply state was never invalidated when the
source message was edited. The client sent a stale quote to the
server which no longer matched the current message text.
Fix
Subscribe to message edit updates for the reply target. On edit,
re-validate the stored quote against the current message text.
If valid but entities changed — update them. If the quoted fragment
no longer exists — clear the quote and fall back to plain reply.
Steps to reproduce
Video repro
Screen.Recording.2026-03-16.at.21.57.47.mov
Business Value / UX Impact
Prevents a frustrating "dead end" UX where user messages get permanently stuck in a sending state. By gracefully falling back to a standard reply, this fix ensures uninterrupted communication flow and makes the app feel more reliable during active, real-time chats.
Repro details
User A -- iOS, IPhone 14 Pro
tg version: 12.5.2
User B -- MacBook Pro, Apple M1 Pro, 2021. Tg version: 6.6.3 Beta