Skip to content

Update the quoted message preview in threads when the quoted message is deleted or edited#6584

Merged
andremion merged 3 commits into
developfrom
andrerego/and-272-chatcompose-quoted-message-is-not-updated-after-deleting-a
Jul 23, 2026
Merged

Update the quoted message preview in threads when the quoted message is deleted or edited#6584
andremion merged 3 commits into
developfrom
andrerego/and-272-chatcompose-quoted-message-is-not-updated-after-deleting-a

Conversation

@andremion

@andremion andremion commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Goal

When a message quoted by a thread reply is deleted or edited, the quoted preview inside the thread is not updated. The channel message list already handles this case, but the thread message list keeps showing the old content. This change applies the same update to the thread state.

Resolves AND-272

Implementation

The channel path refreshes quote previews when the message.updated / message.deleted WebSocket event arrives: ChannelEventHandlerImpl calls ChannelStateImpl.updateQuotedMessageReferences, which rewrites the replyTo of every quoting message. The thread path (EventHandlerSequential.updateThreadState -> ThreadLogic.handleMessageEvents) only upserted the changed message itself, so quoting thread replies kept a stale replyTo.

  • ThreadStateLogic: new updateQuotedMessageReferences(quotedMessage) and deleteQuotedMessageReferences(quotedMessageId). They scan the in-memory thread messages for replyTo?.id / replyMessageId matches instead of maintaining a quotedMessagesMap like the channel state does, since the thread list is small and fully in memory.
  • ThreadLogic.handleMessageEvents: after the existing upsert, MessageUpdatedEvent and soft MessageDeletedEvent refresh the replyTo of quoting messages with the enriched message, and a hard delete clears the replyTo. This mirrors the channel event handler contract. ThreadLogic is shared by the new and legacy channel logic modes, so both are covered.
  • Removed the @Ignore from test_originalQuoteIsDeletedByUser_deletedMessageIsShown_InThread, as required by the ticket.
  • Added a randomMessageDeletedEvent builder to the shared test fixtures.

One intentional difference from the channel counterpart: attachment URLs of the old replyTo are not preserved when rewriting it. Thread state upserts never preserve attachment URLs today, so this follows the existing thread module behavior.

This also aligns with the iOS SDK, where the quote is a database relationship: quoting messages always render the current content of the quoted message, and a hard delete nullifies the reference.

Testing

Covered by new unit tests (ThreadLogicTest, ThreadStateLogicTest) and by the re-enabled e2e test QuotedReplyTests#test_originalQuoteIsDeletedByUser_deletedMessageIsShown_InThread. The e2e test passes locally with this change and fails without it (verified by running both builds against the mock server).

Manual steps:

  1. Open a channel and start a thread on one of its messages.
  2. Inside the thread, quote the root message (long press > Reply) and send the reply.
  3. Delete the original quoted message.
  4. Expected: the quoted bubble inside the thread reply shows "Message deleted". Before this change it kept the old text.
  5. Editing works the same way: edit the quoted message and the quoted bubble shows the updated text.

Summary by CodeRabbit

  • Bug Fixes

    • Improved thread consistency when quoted messages are edited or deleted.
    • Updated quoted replies appropriately for soft deletions and removed references for permanent deletions.
    • Ensured quoted-message updates are reflected across thread messages.
  • Tests

    • Added coverage for quoted-message updates and deletions.
    • Enabled end-to-end coverage for displaying deleted quoted messages in threads.

@andremion andremion added the pr:bug Bug fix label Jul 21, 2026
@andremion

Copy link
Copy Markdown
Contributor Author

@CodeRabbit review

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Changes

Quoted message reference handling

Layer / File(s) Summary
Thread quote reference state
stream-chat-android-client/.../ThreadStateLogic.kt, stream-chat-android-client/.../ThreadStateLogicTest.kt
Thread messages quoting an updated message receive the latest replyTo; hard deletion clears matching references.
Message event dispatch and coverage
stream-chat-android-client/.../ThreadLogic.kt, stream-chat-android-client-test/.../Mother.kt, stream-chat-android-client/.../ThreadLogicTest.kt
Update, soft-delete, and hard-delete events invoke the corresponding reference operations, with event fixtures and tests covering each path.
End-to-end validation
stream-chat-android-compose-sample/.../QuotedReplyTests.kt
The original-quote deletion test is enabled.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: pr:test

Suggested reviewers: velikovpetar

Poem

A rabbit saw quotes hop and change,
Their little references rearrange.
Soft delete keeps the trail in sight,
Hard delete clears it clean and white.
Tests now run beneath the moon—
“Hop-fully green results come soon!”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change to quoted message previews in threads.
Description check ✅ Passed The description covers Goal, Implementation, and Testing with concrete details aligned to the template.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch andrerego/and-272-chatcompose-quoted-message-is-not-updated-after-deleting-a

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.95 MB 5.95 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.21 MB 11.21 MB 0.00 MB 🟢
stream-chat-android-compose 12.69 MB 12.69 MB 0.00 MB 🟢

@andremion
andremion marked this pull request as ready for review July 21, 2026 10:08
@andremion
andremion requested a review from a team as a code owner July 21, 2026 10:08
@andremion
andremion enabled auto-merge (squash) July 21, 2026 10:09
@sonarqubecloud

Copy link
Copy Markdown

@andremion
andremion merged commit 135beb0 into develop Jul 23, 2026
19 checks passed
@andremion
andremion deleted the andrerego/and-272-chatcompose-quoted-message-is-not-updated-after-deleting-a branch July 23, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants