fix(core): Fix backwards pagination not working if channel was never opened - #2812
Conversation
…opened Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 @@
## v9 #2812 +/- ##
=====================================
Coverage ? 66.86%
=====================================
Files ? 429
Lines ? 27102
Branches ? 0
=====================================
Hits ? 18121
Misses ? 8981
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Submit a pull request
Linear: FLU-563
Github Issue: #
CLA
Description of the pull request
Backport of
master→v9of commit1a90e921105fa9edad3985828868fadc22f39d2d(PR #2789, Fixes FLU-563).The bug
When a user enters a channel with
unread_count > 0but the server-side read state is the "never explicitly read" sentinel (last_read_message_id = nullandlast_read = 0001-01-01T00:00:00Z— Go'stime.Time{}zero value),StreamChannelState._maybeInitChannelunconditionally calledloadChannelAtTimestamp(currentUserRead.lastRead).The backend silently ignores the zero-time
created_at_around(viaIsZero()) and returns the channel tail. The client then mis-infers boundaries via_inferBoundariesFromAnchorTimestamp: because year-1 precedes every loaded message, it concludesendOfPrependReached: true, sets_topPaginationEnded = true, and backwards pagination is permanently dead on the channel.The fix
Guard the timestamp branch on
currentUserRead.lastRead.isAfter(_minValidLastRead)(DateTime.utc(1970)). When it's the zero sentinel, the code falls through to the existing catch-all — stay on the cached latest window if up-to-date, otherwise reload the latest page.Adds a
_maybeInitChanneltest group with four regression guards:idAroundforlastReadMessageId,createdAtAroundfor real timestamps, no query for the Go zero-time case when up-to-date, and a latest-page reload for the Go zero-time case when stale.Backport notes
_maybeInitChannellogic onv9was byte-for-byte identical to master's pre-fix state, butv9andmasterdiverge inanalysis_options.yaml:v9drops thepage_width: 120formatter block (reverting to the 80-col default) and enables theavoid_redundant_argument_valueslint. A raw cherry-pick would have imported master's formatting/lint style.DateTime.utc(1970, 1, 1)/DateTime.utc(1, 1, 1)are written asDateTime.utc(1970)/DateTime.utc(1)here (semantically identical) to satisfy v9's enabledavoid_redundant_argument_valueslint.v9before the fix, then pass after.dart format,dart analyze --fatal-infos, and all 30 tests instream_channel_test.dartare green.Screenshots / Videos
No UI changes. (See the before/after videos on the original master PR #2789.)