Make the channel preview deterministic when the last message is deleted - #6577
Conversation
… preview The preview selection returned the first of the messages tied on createdAt, so backends with second-precision timestamps made the deleted-message preview depend on send timing. Prefer the later list element, which is the newer message. Also make the preview fixture dates strictly increasing so the Paparazzi goldens stop depending on initialization timing.
The test expected the previous message, which predates the channel list redesign and current iOS behavior. It only passed when the mock server's second-precision timestamps made the two messages tie.
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
|
@CodeRabbit review |
✅ Action performedReview finished.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (14)
📒 Files selected for processing (7)
WalkthroughChannel preview message selection now handles deleted messages and equal timestamps deterministically. Compose previews and snapshots cover deleted-message states, while the end-to-end test expects the “Message deleted” placeholder. ChangesDeleted message preview behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
SDK Size Comparison 📏
|
…w fixtures The preview fixture dates are now strictly increasing, so the channel list preview renders message2 as the newest message instead of depending on initialization timing.
|
|
🚀 Available in v7.7.0 |



Goal
The e2e test that covers the channel preview after deleting the last message fails intermittently (3 of the last 200 nightly runs). The investigation showed two problems. First, the preview selection in
getLastMessageIncludingDeletedpicks the first of the messages that tie oncreatedAt, so with second-precision timestamps (the mock server) the shown preview depends on whether two messages land in the same second. Second, the test still expects the previous message, an expectation that predates the channel list redesign. Since the redesign, the preview intentionally shows the "Message deleted" placeholder when the newest message is soft-deleted, and current iOS behaves the same (its e2e suite asserts this exact scenario).Resolves AND-1314
Implementation
getLastMessageIncludingDeletednow prefers the later list element when creation times are equal, so the selection is deterministic. Against the real backend, timestamps carry sub-second precision and ties do not occur, so production behavior does not change.test_channelPreviewShowsMessageDeleted_whenLastMessageIsDeletedand expects the placeholder, mirroring the sibling only-message test and the iOS suite.PreviewMessageDatafixture dates are now strictly increasing instead of init-timeDate(), so Paparazzi goldens no longer depend on initialization timing. The updated goldens now showmessage2as the newest message, which matches the fixture order.ChannelItemsnapshots (deleted last message with an older message present, and only message deleted) and threeChannelUtilsTestunit tests, including the tie case.🎨 UI Changes
No UI changes. The selection change only affects messages with identical creation times, which does not happen against the real backend.
Testing
./gradlew :stream-chat-android-compose:testDebugUnitTest --tests "*.ChannelUtilsTest"passes../gradlew :stream-chat-android-compose:verifyPaparazziDebugpasses.Local verification: both e2e tests ran 10 times each against the mock server after the fix, 20 of 20 passed. Before the fix, the failure reproduced whenever the two messages crossed a second boundary (verified in 6 of 6 instrumented runs and in all 3 nightly failures).
Summary by CodeRabbit
Bug Fixes
Tests