Skip to content

Skip mark-read when the only messages are deleted - #6658

Merged
gpunto merged 3 commits into
v6from
and-1395-v6-deleted-messages-gate
Aug 24, 2026
Merged

Skip mark-read when the only messages are deleted#6658
gpunto merged 3 commits into
v6from
and-1395-v6-deleted-messages-gate

Conversation

@gpunto

@gpunto gpunto commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Goal

v6 port of the deleted-message case from #6654, which came out of review there after #6646 had merged.

The server removes a deleted message from its read state (HandleMessageDeleted calls ChannelMessagesDelete), and nothing on our side keeps a soft-deleted message out of the message list, so a channel whose only message was deleted still reached markRead with nothing for the server to resolve, and the emitted message.read carried no last_read_message_id.

Part of AND-1395

Implementation

  • Add deletedAt == null to the Message.isInServerReadState predicate the mark-read gate keys on. Deleted for the current user only does not count, since the message stays in the channel for everyone else and the server can still resolve the read state.
  • Tests: a channel holding only a deleted message skips mark-read, and a message deleted for the current user only still marks read.
  • randomMessage randomises deletedAt as well as silent, so gate-dependent tests build their messages through a trackedMessage helper that pins both, instead of pinning each field at every call site.

Testing

Unit tests as above, with the ui-common suite rerun to confirm the gate no longer depends on randomised fields.

Summary by CodeRabbit

  • Bug Fixes
    • Improved read-status handling for deleted messages.
    • Messages deleted from the server are no longer marked as read.
    • Messages deleted only for the current viewer can still be marked as read.

@gpunto gpunto added the pr:bug Bug fix label Aug 21, 2026
@github-actions

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 ignored for dependabot PRs).

🎉 Great job! This PR is ready for review.

@github-actions

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.26 MB 5.32 MB 0.05 MB 🟢
stream-chat-android-offline 5.49 MB 5.54 MB 0.04 MB 🟢
stream-chat-android-ui-components 10.64 MB 10.76 MB 0.11 MB 🟢
stream-chat-android-compose 12.87 MB 12.96 MB 0.09 MB 🟢

@gpunto
gpunto marked this pull request as ready for review August 21, 2026 08:37
@gpunto
gpunto requested a review from a team as a code owner August 21, 2026 08:37
@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 37ec0565-4160-4484-8f1f-61cb87343c17

📥 Commits

Reviewing files that changed from the base of the PR and between 77b17cd and 573cd24.

📒 Files selected for processing (2)
  • stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/messages/list/MessageListController.kt
  • stream-chat-android-ui-common/src/test/kotlin/io/getstream/chat/android/ui/common/feature/messages/list/MessageListControllerTests.kt

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

The controller now excludes server-deleted messages from server-read eligibility while retaining messages deleted only for the current user. Tests add deterministic fixtures and cover both deletion states.

Changes

Message read state

Layer / File(s) Summary
Server-read eligibility
stream-chat-android-ui-common/src/main/kotlin/.../MessageListController.kt
Messages with deletedAt are not eligible for server read marking. Messages deleted only for the current user remain eligible.
Deterministic mark-read tests
stream-chat-android-ui-common/src/test/kotlin/.../MessageListControllerTests.kt
Tests use fixed tracked-message fixtures and cover server-deleted, current-user-deleted, silent, shadowed, error, and syncing message states.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 573cd

The change skips mark-read for channels containing only deleted messages while preserving current-user-only deletion behavior; no actionable merge-blocking risk remains after normal checks and review.

Poem

I’m a rabbit with tests in my paws,
Server-deleted reads now pause.
User-only deletes still proceed,
Stable fixtures plant each seed.
Hop, hop—clear states now lead!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: skipping mark-read when all available messages are deleted.
Description check ✅ Passed The description covers the goal, implementation, tests, affected deleted-message cases, and randomized test-fixture changes.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch and-1395-v6-deleted-messages-gate

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.

@andremion andremion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. One test note and one comment-wording question inline, both optional.

@sonarqubecloud

Copy link
Copy Markdown

@gpunto
gpunto merged commit b60f58b into v6 Aug 24, 2026
19 checks passed
@gpunto
gpunto deleted the and-1395-v6-deleted-messages-gate branch August 24, 2026 12:04
@stream-public-bot stream-public-bot added the released Included in a release label Aug 24, 2026
@stream-public-bot

Copy link
Copy Markdown
Contributor

🚀 Available in v6.42.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:bug Bug fix released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants