Skip to content

Skip mark-read when the server tracks none of the loaded messages - #6654

Open
gpunto wants to merge 4 commits into
developfrom
and-1395-develop-silent-shadowed-gate
Open

Skip mark-read when the server tracks none of the loaded messages#6654
gpunto wants to merge 4 commits into
developfrom
and-1395-develop-silent-shadowed-gate

Conversation

@gpunto

@gpunto gpunto commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Goal

Develop port of #6646. The mark-read guard from #6644 skips whenever the last item in the list is the current user's own local-only message, which also suppresses legitimate mark-read in channels the server does have messages for. An error message is terminal, so a rejected or moderation-bounced send stays the last item and keeps those channels unread indefinitely.

Skip only when the server tracks none of the loaded messages. Read state leaves out our own not-yet-persisted messages, and silent, shadowed and deleted ones from anyone, so none of them can resolve a mark-read call. Silent is documented as not marking a channel unread, and a deleted message is removed from read state by HandleMessageDeleted, so a channel holding only those has nothing to mark read. Deleted for the current user only does not count, since the message stays in the channel for everyone else.

Part of AND-1395

Implementation

  • MessageListController.markLastMessageReadInternal: replace the "last item is our own local-only message" check with "no loaded message is one the server tracks", via a new Message.isInServerReadState predicate covering local-only, silent and shadowed.
  • Tests: error and ephemeral cases now hold only our own local-only message, plus new cases for a silent-only channel, a shadowed-only channel, a silent message following a tracked one, and a server-side message preceding the echo.
  • randomMessage randomises both silent and deletedAt, which the gate now keys on, so gate-dependent tests build their messages through a trackedMessage helper that pins them, and the nowMessage helper pins them too. This includes the two unread-label tests that only exist here, one of which asserts state computed inside the branch the gate guards.
  • The shadowed case cannot occur today (the server clears the flag for the author, and ChannelStateImpl.shouldIgnoreUpsertion drops other users' shadowed messages). The check stays as defensive cover and its test says so.

The deleted case will be ported to v6 separately, since #6646 merged without it.

Testing

  • Unit tests as above, with the ui-common suite rerun to confirm the gate no longer depends on a randomised field.
  • The same change was verified on device on the v6 branch (Skip mark-read only when the server has no message in the channel #6646): with no server-side message the guard rejects and no read request is sent, and with server-side messages the request goes out and the emitted event carries a populated last_read_message_id.

Summary by CodeRabbit

  • Bug Fixes
    • Improved message read tracking to exclude silent and shadowed messages from server read state.
    • Corrected read-status handling when silent messages, shadowed messages, or error echoes appear in the message list.
  • Tests
    • Added coverage for read tracking and unread indicators across these message scenarios.

@gpunto gpunto added the pr:bug Bug fix label Aug 20, 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 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.

@github-actions

github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 6.06 MB 6.06 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.36 MB 11.36 MB 0.00 MB 🟢
stream-chat-android-compose 12.84 MB 12.84 MB 0.00 MB 🟢

@gpunto
gpunto marked this pull request as ready for review August 20, 2026 12:23
@gpunto
gpunto requested a review from a team as a code owner August 20, 2026 12:23
@coderabbitai

coderabbitai Bot commented Aug 20, 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: efbadfc6-07c2-44b1-86e8-25f13f178d0c

📥 Commits

Reviewing files that changed from the base of the PR and between 0aee066 and d363f4a.

📒 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

MessageListController now excludes silent and shadowed messages from server read-state marking. Tests cover error echoes, silent-only and shadowed-only channels, silent messages after tracked messages, and deterministic non-silent fixtures.

Changes

Read-state eligibility

Layer / File(s) Summary
Server read-state eligibility
stream-chat-android-ui-common/src/main/kotlin/.../MessageListController.kt
markLastMessageReadInternal uses Message.isInServerReadState. The predicate excludes own local-only, silent, and shadowed messages.
Mark-read behavior coverage
stream-chat-android-ui-common/src/test/kotlin/.../MessageListControllerTests.kt
Tests cover error echoes, silent and shadowed messages, message ordering, and explicit non-silent fixtures.

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

Merge Risk: ⚪ Minimal · up to d363f

The change narrows mark-read suppression to channels with no server-tracked messages and adds focused coverage for the affected cases; no actionable merge-blocking risk remains after normal checks and review.

Possibly related PRs

Suggested labels: pr:test

Suggested reviewers: velikovpetar, andremion, aleksandar-apostolov

Poem

A rabbit checks each message in the stream,
Silent and shadowed fade from the read-state dream.
Error echoes leave the last-seen trail,
Clear fixtures make the tests prevail.
Hop, hop—read marks now know the scheme!

🚥 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 skip mark-read when no loaded messages are tracked by the server.
Description check ✅ Passed The description explains the goal, implementation, testing, affected scenarios, and issue context; omitted UI and checklist sections are not critical for this non-visual change.
✨ 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 and-1395-develop-silent-shadowed-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.

@gpunto
gpunto enabled auto-merge August 20, 2026 12:58

@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 scope question and one nit inline, both optional.

@sonarqubecloud

Copy link
Copy Markdown

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