Skip to content

fix(ui): preserve last-message preview during channel-state reloads - #2811

Merged
VelikovPetar merged 1 commit into
v9from
port/master-to-v9/FLU-549_preserve-last-message-preview
Jul 14, 2026
Merged

VelikovPetar merged 1 commit into
v9from
port/master-to-v9/FLU-549_preserve-last-message-preview

Conversation

@VelikovPetar

Copy link
Copy Markdown
Contributor

Submit a pull request

Linear: FLU-549

Github Issue: #

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

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:) runs state.truncate() (emits an empty messages list) immediately followed by updateChannelState() (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 _currentLastMessage cache field meant to absorb that transient empty emission, but in _ChannelLastMessageTextState it was declared and never assigned — making the absorber a no-op, so the flash was visible.

The fix

Assign _currentLastMessage = message on every build, gated on channelState.isUpToDate, and compute it before .latest so the freshly-stored value participates in the selector:

  • While isUpToDate is false (the idAround truncate mid-load), fall back to the cached message so the preview keeps showing the real latest message.
  • A real channel.truncated event keeps isUpToDate == true, so the cache correctly clears and the empty-state surfaces.

Manual port (not a clean cherry-pick)

  • The source file was renamed on master (stream_channel_list_item.dart) vs v9 (stream_channel_list_tile.dart).
  • Master applied the same fix to two widgets (_ChannelLastMessageWithStatus and ChannelLastMessageText). _ChannelLastMessageWithStatus does not exist on v9, so only the ChannelLastMessageText hunk was ported (there is no cache to fix in v9's inline sending-indicator path).
  • The regression tests were extended into the existing v9 stream_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.
  • The empty-state string differs on v9 ("There are no messages currently" vs master's "No messages yet"), so the test constant was adapted accordingly.

Verification

  • melos run format → 0 changed
  • dart analyze --fatal-infos → no issues
  • 8/8 tests pass in stream_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.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9a9a3eca-a362-408c-99b4-1481ee3a1ec1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch port/master-to-v9/FLU-549_preserve-last-message-preview

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@VelikovPetar
VelikovPetar marked this pull request as ready for review July 14, 2026 07:47
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (v9@1d7a5a7). Learn more about missing BASE report.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@VelikovPetar
VelikovPetar merged commit f3ceb35 into v9 Jul 14, 2026
29 checks passed
@VelikovPetar
VelikovPetar deleted the port/master-to-v9/FLU-549_preserve-last-message-preview branch July 14, 2026 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants