fix(ui): preserve last-message preview during channel-state reloads - #2811
Conversation
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 #2811 +/- ##
=====================================
Coverage ? 66.80%
=====================================
Files ? 429
Lines ? 27100
Branches ? 0
=====================================
Hits ? 18105
Misses ? 8995
Partials ? 0 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Submit a pull request
Linear: FLU-549
Github Issue: #
CLA
Description of the pull request
Backport of master commit
36d8a1c94ab74448680c67531460ac10977f7d8a— "fix(ui): preserve last-message preview during channel-state reloads (#2774)".Why
The same last-message-preview flicker exists on
v9. When opening a channel with unreads,Channel.query(idAround:)runsstate.truncate()(emits an emptymessageslist) immediately followed byupdateChannelState()(emits the populated state), so the channel-list cell briefly flashes the empty-state text ("There are no messages currently") before snapping to the real preview.The preview widget already had a
_currentLastMessagecache field meant to absorb that transient empty emission, but in_ChannelLastMessageTextStateit was declared and never assigned — making the absorber a no-op, so the flash was visible.The fix
Assign
_currentLastMessage = messageon every build, gated onchannelState.isUpToDate, and compute it before.latestso the freshly-stored value participates in the selector:isUpToDateisfalse(theidAroundtruncate mid-load), fall back to the cached message so the preview keeps showing the real latest message.channel.truncatedevent keepsisUpToDate == true, so the cache correctly clears and the empty-state surfaces.Manual port (not a clean cherry-pick)
stream_channel_list_item.dart) vsv9(stream_channel_list_tile.dart)._ChannelLastMessageWithStatusandChannelLastMessageText)._ChannelLastMessageWithStatusdoes not exist onv9, so only theChannelLastMessageTexthunk was ported (there is no cache to fix in v9's inline sending-indicator path).v9stream_channel_list_tile_test.dart(which already covers this widget) rather than the standalone file master added. Three scenarios were added: preserves the last-known message while not up-to-date and emitting empty, rebinding to a different channel shows that channel's state, and shows the empty-state on truncate while up-to-date.v9("There are no messages currently" vs master's "No messages yet"), so the test constant was adapted accordingly.Verification
melos run format→ 0 changeddart analyze --fatal-infos→ no issuesstream_channel_list_tile_test.dart(5 existing + 3 new)Screenshots / Videos
No UI changes. (Backport of an already-reviewed fix; behaviour verified via the added regression tests.)