Keep messages only this device has when a grouped channel list refreshes by gpunto · Pull Request #6728 · GetStream/stream-chat-android · GitHub
Skip to content

Keep messages only this device has when a grouped channel list refreshes - #6728

Merged
gpunto merged 3 commits into
developfrom
fix/grouped-refresh-keeps-local-messages
Sep 28, 2026
Merged

gpunto merged 3 commits into
developfrom
fix/grouped-refresh-keeps-local-messages

Conversation

@gpunto

@gpunto gpunto commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Goal

When a grouped channel list refreshes its first page (for example on every reconnect), each row is replaced with the
server's copy, so messages that exist only on this device disappear from the channel preview. One example is a send the
backend answers with a type="error" message it never stores. The regular channel list keeps them.

Port of #6726 to develop.

Part of AND-1564

Implementation

  • On the grouped first page, only remove the existing channels that are missing from the new page, and skip the removal
    when none are. Channels still in the page keep their current copy, so joinMessages merges it with the server's, as
    the regular refresh does.
  • Channel order is unchanged: the list is sorted by its comparator, and the cids are still reset from the page.

Testing

QueryChannelsLogicGroupedTest checks that only the channels dropped from the page are removed, and that nothing is
removed when every channel is still in the page. A test on the real state logic seeds a retained channel with a
local-only message, refreshes it with an empty message list, and checks the message survives while the channel's own
fields come from the server.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Grouped channel refreshes now remove only channels absent from the results, keeping channels that remain in the page.
    • Locally held messages are preserved when refreshed channel data contains no messages.

@gpunto gpunto added the pr:bug Bug fix label Sep 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 6.09 MB 6.09 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.40 MB 11.40 MB 0.00 MB 🟢
stream-chat-android-compose 13.07 MB 13.07 MB 0.00 MB 🟢

@gpunto
gpunto marked this pull request as ready for review September 25, 2026 06:48
@gpunto
gpunto requested a review from a team as a code owner September 25, 2026 06:48
@coderabbitai

coderabbitai Bot commented Sep 25, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 7aea5c23-d42b-4b03-b9d7-c1ca9ea96fda

📥 Commits

Reviewing files that changed from the base of the PR and between e590dda and 735d9af.

📒 Files selected for processing (2)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/internal/state/plugin/logic/querychannels/internal/QueryChannelsLogic.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/internal/state/plugin/logic/querychannels/internal/QueryChannelsLogicGroupedTest.kt

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.


Walkthrough

Grouped first-page results now remove only existing channels absent from the response. Tests cover retained and omitted channels, including preservation of local messages when refreshed channel data has no messages.

Changes

Grouped query refresh

Layer / File(s) Summary
Refresh behavior and validation
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/internal/state/plugin/logic/querychannels/internal/QueryChannelsLogic.kt, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/internal/state/plugin/logic/querychannels/internal/QueryChannelsLogicGroupedTest.kt
First-page refreshes remove channels not present in the response. Tests check retained and omitted channels, updated channel data, and preservation of a local message when refreshed data has no messages.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Suggested reviewers: velikovpetar

Merge Risk: ⚪ Minimal · up to 735d9

The grouped refresh preserves local-only messages while updating returned channels. No issue identified here needs resolution before merge.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 735d9

The change affects which messages remain visible on this device after a refresh. It does not appear to add a new access path, but behavior across overlapping requests and app restarts is not fully established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed retention path is confined to returned channel IDs in the selected group's client state; the inspected code does not introduce a new external caller or server-side authorization decision.

Trust Boundaries and Controls

  • observed — The grouped result enters through the internal listener, which selects group-keyed query logic; the apply method rejects a non-grouped identifier. These controls do not themselves establish whether a server-omitted message should be retained or removed.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: retaining device-only messages when a grouped channel list refreshes.
Description check ✅ Passed The description explains the goal, implementation, issue reference, and testing coverage. UI sections and checklist items are omitted, but they are not critical for this non-UI bug fix.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

A rabbit checks the channel stream,
And keeps each match within the team.
The absent ones hop out of sight,
Local messages stay tucked in tight.
Fresh channel names arrive just right.

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

@andremion andremion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. One optional note inline.

@gpunto
gpunto enabled auto-merge September 25, 2026 13:48
@gpunto
gpunto added this pull request to the merge queue Sep 28, 2026
Merged via the queue into develop with commit d9afbc2 Sep 28, 2026
20 of 22 checks passed
@gpunto
gpunto deleted the fix/grouped-refresh-keeps-local-messages branch September 28, 2026 10:38
@stream-public-bot stream-public-bot added the released Included in a release label Sep 30, 2026
@stream-public-bot

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:bug Bug fix released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants