Skip to content

fix(llc): handle per-channel notification.mark_read events again - #2891

Merged
xsahil03x merged 3 commits into
v9from
port/master-to-v9/FLU-693_notification-mark-read
Aug 14, 2026
Merged

fix(llc): handle per-channel notification.mark_read events again#2891
xsahil03x merged 3 commits into
v9from
port/master-to-v9/FLU-693_notification-mark-read

Conversation

@xsahil03x

@xsahil03x xsahil03x commented Aug 14, 2026

Copy link
Copy Markdown
Member

Submit a pull request

Linear: FLU-693

Fixes: #2886

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested

Description of the pull request

Backport of master commit a9b048261 — "fix(llc): handle per-channel notification.mark_read events again" (#2890).

v9 is affected: the regression landed in 9.20.0, so every v9 release from 9.20.0 onward carries it.

ChannelClientState._listenReadEvents subscribed to both message.read and notification.mark_read until the delivery-receipts refactor (#2429, 3b5e410bb) split them into separate listeners and did not carry notification.mark_read over.

That distinction is load-bearing:

  • message.read is a channel event — delivered to watchers only.
  • notification.mark_read is delivered on the reading user's own connection — so it reached the channel whether watched or not.

Channel.markRead() writes no local state itself, and channels are easily non-watched (watch is silently downgraded when there is no connection id). So marking a non-watched channel as read succeeded server-side while unreadCount stayed stale forever — the unread pill and divider survived the dismiss X, markReadWhenAtTheBottom, and every reopen, with no user action able to clear them.

Port notes

Effectively a clean cherry-pick. v9's _listenReadEvents is byte-identical to master's pre-fix version — including the thread guard and the delivery-field preservation — so the fix applies unchanged:

_channel
    .on(EventType.messageRead, EventType.notificationMarkRead)
    .listen(

Two mechanical differences from the master commit:

  1. Formatting. v9 formats at 80 cols with Dart 3.6's short style (pinned to Flutter 3.27.4 via .fvmrc), where master is 120/tall. The single-line .on(...).listen( from master is 82 chars, so it wraps across three lines. Formatted with the pinned 3.6.2 SDK rather than a newer local one, which would have restyled the entire file.
  2. CHANGELOG.md resolved manually into v9's ## 9.27.0 section (the only cherry-pick conflict).

The test file applied without conflict.

Testing

Four tests in channel_test.dart. On master I verified they actually catch the regression by reverting the one-line fix and re-running — three go red (the fourth is a negative test asserting thread-scoped reads are ignored, so it passes either way):

Test Without the fix
resets unread count on a non-watched channel fails: Expected: <0> Actual: <10>
preserves delivery info fails: Expected: <0> Actual: <10>
reconciles delivery for the current user fails: No matching calls
ignores thread-scoped mark-reads passes (guards the guard)

Verified on v9 with the pinned toolchain (Dart 3.6.2 / Flutter 3.27.4):

dart test                                   1306 passed / 2 skipped
dart analyze --fatal-infos lib test         No issues found
dart format --set-exit-if-changed lib test  226 files, 0 changed

Out of scope

Same as the master PR:

Screenshots / Videos

No UI changes — beyond the unread pill and divider now clearing, which is the bug itself.

🤖 Generated with Claude Code

`ChannelClientState._listenReadEvents` subscribed to both `message.read`
and `notification.mark_read` until the delivery-receipts refactor (#2429)
split them and dropped the latter.

`message.read` only reaches watchers, so from 9.20.0 on `markRead()` on a
non-watched channel left `unreadCount` permanently stale — the unread pill
and divider could not be cleared by any user action.

Re-adds the event type to the existing listener, which since 9.19.0 also
guards against thread-scoped reads and preserves delivery fields.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 41e52a34-3c37-4efe-8de6-96a3a8b1038b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

9.27.0 is already tagged and published, so the entry belongs in a new
Unreleased section rather than an existing released one. Matches the
sibling v9 backport (#2889).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…93_notification-mark-read

# Conflicts:
#	packages/stream_chat/CHANGELOG.md
@xsahil03x
xsahil03x enabled auto-merge (squash) August 14, 2026 13:38
@xsahil03x
xsahil03x merged commit e7e4ebe into v9 Aug 14, 2026
22 checks passed
@xsahil03x
xsahil03x deleted the port/master-to-v9/FLU-693_notification-mark-read branch August 14, 2026 13:45
@codecov

codecov Bot commented Aug 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (v9@36bde74). Learn more about missing BASE report.

Additional details and impacted files
@@          Coverage Diff          @@
##             v9    #2891   +/-   ##
=====================================
  Coverage      ?   67.30%           
=====================================
  Files         ?      431           
  Lines         ?    27390           
  Branches      ?        0           
=====================================
  Hits          ?    18434           
  Misses        ?     8956           
  Partials      ?        0           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Per-channel notification.mark_read handling was silently dropped in 9.20.0 — unreadCount never resets on non-watched channels

2 participants