fix(core): truncate channel state before reloading latest messages#2690
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 due to trivial changes (1)
📝 WalkthroughWalkthroughCalls channel.state?.truncate() before reloading latest messages so reload replaces the existing pagination window; adds widget tests verifying truncation-order, pagination args (no around anchors), and that old messages are dropped; updates CHANGELOG. ChangesreloadChannel Truncation and Reload
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
4822e25 to
9452ad4
Compare
`StreamChannel.reloadChannel` was leaving the previously loaded window in place and merging the latest page on top of it via `channel.query`. After a `loadChannelAtMessage(...)` jump, that left the around-message window glued to the freshly loaded latest 30 — older messages from before the reload were still in `channel.state.messages`, and the "scroll to bottom" FAB landed the user on a state that didn't match a fresh open of the channel. Truncate the existing state before the `_queryAtMessage()` call so a reload behaves like the initial open. Adds two tests: - `truncates the existing window before querying the latest messages` - `queries with no around-anchor (loads the latest page)` Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
9452ad4 to
efa259c
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2690 +/- ##
=======================================
Coverage 65.33% 65.33%
=======================================
Files 423 423
Lines 26646 26648 +2
=======================================
+ Hits 17408 17410 +2
Misses 9238 9238 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
StreamChannel.reloadChannelwas leaving the previously loaded window in place and merging the latest page on top of it viachannel.query. After aloadChannelAtMessage(...)jump, that left the around-message window glued to the freshly loaded latest 30 — older messages from before the reload were still inchannel.state.messages, and the "scroll to bottom" FAB landed the user on a state that didn't match a fresh open of the channel.Repro
loadChannelAtMessage(Y)runs; channel state becomes the around-Y window — X is no longer loaded.StreamMessageListViewcallsreloadChannel()because!_upToDate.What changed
The truncate has no effect on persistence — only the in-memory loaded window is cleared. Persistence still hydrates older messages on a fresh session.
The three callers of
reloadChannel()semantically want "reset to latest":MessageListCore.paginate*StreamMessageInput-style send-from-stale-stateStreamMessageListView.scrollToBottomDefaultTapAction!_upToDateTest plan
flutter test packages/stream_chat_flutter_core/test/stream_channel_test.dart— 25/25 pass (2 new)flutter test packages/stream_chat_flutter_core— 191/191 passdart analyze --fatal-infos packages/stream_chat_flutter_core/lib/src/stream_channel.dart— cleanNew tests
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests