fix(ui): skip markThreadRead for reply-less thread parents - #2807
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthrough
ChangesThread read gating
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2807 +/- ##
==========================================
+ Coverage 71.08% 71.24% +0.15%
==========================================
Files 429 429
Lines 26892 26893 +1
==========================================
+ Hits 19117 19159 +42
+ Misses 7775 7734 -41 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Opening a thread on a parent with no replies produced a guaranteed StreamChatNetworkError 404 (`Can't find thread with id ...`), because the server-side thread object doesn't exist until the first reply lands. Guard `_maybeMarkMessagesAsRead` in thread mode against a zero `replyCount` on the parent — matching the iOS SDK's precedent in `ChatThreadVC.shouldMarkThreadRead`. Fixes #2806. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Opening a thread on a parent with no replies produced a guaranteed StreamChatNetworkError 404 (`Can't find thread with id ...`), because the server-side thread object doesn't exist until the first reply lands. Guard `_maybeMarkMessagesAsRead` in thread mode against a zero `replyCount` on the parent — matching the iOS SDK's precedent in `ChatThreadVC.shouldMarkThreadRead`. v9 backport of #2807. Fixes #2806. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
b65a0c8 to
fb21f13
Compare
Summary
Opening a thread on a parent with no replies produced a guaranteed
StreamChatNetworkError404 (Can't find thread with id ...) every time._maybeMarkMessagesAsReadunconditionally calledchannel.markThreadRead(parentId)when in a thread, but the server-side thread object only exists after the first reply lands.Guard added to
_maybeMarkMessagesAsReadin thread mode: skip when the parent'sreplyCountis 0. Matches the iOS SDK's precedent inChatThreadVC.shouldMarkThreadRead(if messageController.replies.isEmpty { return false }, comment: "If there are no replies, no thread is yet created").Fixes #2806.
Why
replyCounton the parentreplyCountis server-owned and populated viamessage.updatedon the parent — nothing in the LLC bumps it locally, so it stays at0for optimistic-only replies too. Both "no replies" and "one local-only reply" produce the samereplyCount == 0, and both cases want the same behavior: skip → no 404.channel.state.threads[parentId]?.isEmpty) is less robust — the client's thread map is only populated once thread messages are paged in.Test plan
mark_read_test.dart:does NOT fire when parentMessage.replyCount is 0— the load-bearing guard.fires when parentMessage.replyCount > 0— happy path.does NOT fire markRead (channel-level) when in a thread— invariant guard.masterwithout the guard (MockChannel.markThreadRead(parent-id) was called) and passes with the guard.dart analyzeclean,dart formatclean.Follow-up
bug/skip_mark_thread_read_when_no_replies_v9).MessageListController.markLastMessageReadInternal) has the same latent bug and no explicit guard — worth tracking as a separate ticket if not already.🤖 Generated with Claude Code
Summary by CodeRabbit