Skip to content

refactor(llc): extract the message merge algebra into MessageMerging - #2944

Draft
VelikovPetar wants to merge 7 commits into
masterfrom
refactor/FLU-724_extract_message_merging
Draft

refactor(llc): extract the message merge algebra into MessageMerging#2944
VelikovPetar wants to merge 7 commits into
masterfrom
refactor/FLU-724_extract_message_merging

Conversation

@VelikovPetar

@VelikovPetar VelikovPetar commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Submit a pull request

Linear: FLU-724

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)

Important

#2930 and #2942 are merged. Still depends on #2943 — merge that first, after which this PR's diff reduces to the five files below.

Replaces #2913, which could not be rebased: 99% of its channel.dart diff (281 of 282 lines) was inside the block #2930 moved into channel_client_state.dart.

channel_client_state.dart now lives at src/client/channel/. message_merging.dart and message_predicates.dart stay under src/core/util/, since they are channel-agnostic.

Description of the pull request

Moves the pure message/pin/live-location merge and removal operations (formerly private on ChannelClientState) verbatim into a new unexported static holder MessageMerging under lib/src/core/util/, following the MessageRules precedent. The two message predicates (isShownInChannel and hasValidPin, formerly the top-level _pinIsValid and inline filters) live in a separate unexported MessagePredicates extension on Message.

  • Call sites in channel_client_state.dart are requalified (16 MessageMerging.* calls, 4 MessagePredicates usages); the stateful orchestrators and persistence writes stay put.
  • The thread orchestrators preserve their exact write/no-write emission behavior via an identical() guard.
  • Adds pure unit-test suites (41 tests across message_merging_test.dart and message_predicates_test.dart) covering the merge semantics directly, including previously untested pin-expiry filtering and the thread phantom-guard / empty-thread-pruning rules.
  • Zero public API change (lib/stream_chat.dart untouched); no CHANGELOG entry since there is no observable behavior change.

ChannelClientState drops from 1,272 to 1,032 lines, and all nine of the private merge/removal helpers are gone.

Test instructions: cd packages/stream_chat && dart test — full package suite passes (1,855 tests), including the existing through-state merge characterization and #2942's event coverage.

Groundwork for the v11 shared merge-semantics rail.

Follow-up worth considering

MessagePredicates is now the natural home for other message predicates that remain inline in the channel state. Not done here to keep the diff a faithful re-derivation.

Screenshots / Videos

No UI changes.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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 and others added 4 commits September 7, 2026 20:11
…mutations

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…annel directory

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
VelikovPetar and others added 3 commits September 7, 2026 21:30
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@VelikovPetar
VelikovPetar force-pushed the refactor/FLU-724_extract_message_merging branch from 655430a to d9cb260 Compare September 7, 2026 19:31
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.

1 participant