Skip to content

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

Open
gpunto wants to merge 2 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 2 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 and shadowed ones from anyone, so none of them can resolve a mark-read call. Silent is documented as not marking a channel unread, so a channel holding only silent messages has nothing to mark read.

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 silent, which the gate now keys on, so the gate-dependent tests and the nowMessage helper pin it explicitly. This includes the two unread-label tests that only exist here, one of which asserts state computed inside the branch the gate guards.

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

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 6.02 MB 6.02 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.32 MB 11.32 MB 0.00 MB 🟢
stream-chat-android-compose 12.80 MB 12.80 MB 0.00 MB 🟢

@sonarqubecloud

Copy link
Copy Markdown

@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
Title check ✅ Passed The title clearly and concisely summarizes the mark-read guard change.
Description check ✅ Passed The description includes clear goal, implementation, and testing details; optional UI, checklist, and GIF sections are not completed.
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.
✨ 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
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.

1 participant