Fix quote reply becoming invalid after source message edit#30453
Open
overpathz wants to merge 1 commit intotelegramdesktop:devfrom
Open
Fix quote reply becoming invalid after source message edit#30453overpathz wants to merge 1 commit intotelegramdesktop:devfrom
overpathz wants to merge 1 commit intotelegramdesktop:devfrom
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.
23rd
reviewed
Mar 25, 2026
Comment on lines
+417
to
+418
| const auto editId = _editMsgId.current(); | ||
| if (editId) { |
Collaborator
There was a problem hiding this comment.
Suggested change
| const auto editId = _editMsgId.current(); | |
| if (editId) { | |
| if (const auto editId = _editMsgId.current()) { |
23rd
reviewed
Mar 25, 2026
| [[nodiscard]] bool ExtractCurrentQuote( | ||
| not_null<HistoryItem*> item, | ||
| const FullReplyTo &reply, | ||
| TextWithEntities &result) { |
Collaborator
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.
23rd
reviewed
Mar 25, 2026
| auto updated = reply; | ||
| updated.quote = TextWithEntities(); | ||
| updated.quoteOffset = 0; | ||
| _replyTo = updated; |
Collaborator
There was a problem hiding this comment.
What's the point of all this moving from one empty place to another?
Collaborator
|
I guess you did not test your changes? |
Author
|
@23rd Related to testing - yep, I didn't test it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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