Skip to content

Ensure SyncManager respects messageLimit and memberLimit when restoring channel queries#6231

Open
VelikovPetar wants to merge 1 commit intodevelopfrom
bug/AND-1110_ensure_sync_manager_respects_channel_query_limits
Open

Ensure SyncManager respects messageLimit and memberLimit when restoring channel queries#6231
VelikovPetar wants to merge 1 commit intodevelopfrom
bug/AND-1110_ensure_sync_manager_respects_channel_query_limits

Conversation

@VelikovPetar
Copy link
Contributor

@VelikovPetar VelikovPetar commented Mar 9, 2026

Goal

When SyncManager calls queryFirstPage() to restore active channel queries after reconnect, it was hardcoding messageLimit = 1 and memberLimit = 30 instead of using the values originally provided by the caller. This caused the restored channel list to return fewer messages and members than expected.

Note: Aligns the behaviour with iOS

Implementation

queryFirstPage() now reads messageLimit and memberLimit from the previously stored currentRequest in state (set when the user's original queryChannels() call came through). If no prior request exists (first ever call), both values fall back to null, which lets the server apply its defaults.

Two unit tests were added to QueryChannelsLogicTest covering:

  • No prior request → null limits forwarded to the API
  • Prior request with custom limits → those limits are preserved in the refresh request

UI Changes

No UI changes.

Testing

Run the new unit tests in QueryChannelsLogicTest.

Summary by CodeRabbit

  • Improvements

    • Updated channel query logic to derive message and member limits dynamically from the current request state, enabling more flexible pagination behavior.
  • Tests

    • Added test coverage for channel query limit behavior, including scenarios with null limits and previously configured values.

…ng channel queries

Co-Authored-By: Claude <noreply@anthropic.com>
@VelikovPetar VelikovPetar added the pr:bug Bug fix label Mar 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled.

🎉 Great job! This PR is ready for review.

@VelikovPetar VelikovPetar added pr:improvement Improvement pr:internal Internal changes / housekeeping and removed pr:bug Bug fix pr:improvement Improvement labels Mar 9, 2026
@VelikovPetar VelikovPetar changed the title Ensure SyncManager respects messageLimit and memberLimit when restoring channel queries Ensure SyncManager respects messageLimit and memberLimit when restoring channel queries Mar 9, 2026
@VelikovPetar VelikovPetar marked this pull request as ready for review March 9, 2026 15:47
@VelikovPetar VelikovPetar requested a review from a team as a code owner March 9, 2026 15:47
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.26 MB 5.26 MB 0.00 MB 🟢
stream-chat-android-offline 5.48 MB 5.48 MB 0.00 MB 🟢
stream-chat-android-ui-components 10.63 MB 10.63 MB 0.00 MB 🟢
stream-chat-android-compose 12.85 MB 12.85 MB 0.00 MB 🟢

@coderabbitai
Copy link

coderabbitai bot commented Mar 9, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 01ef40ad-be24-4ee1-badc-cbf881b25564

📥 Commits

Reviewing files that changed from the base of the PR and between 56a1073 and 4ecc31d.

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

Walkthrough

This change replaces hardcoded message and member limit constants in QueryChannelsLogic with dynamically-derived values from the current request state. Comprehensive test coverage validates both null and populated state scenarios.

Changes

Cohort / File(s) Summary
Dynamic Query Limits
stream-chat-android-state/src/main/java/.../QueryChannelsLogic.kt, stream-chat-android-state/src/test/java/.../QueryChannelsLogicTest.kt
Removed fixed MESSAGE_LIMIT and MEMBER_LIMIT constants; queryFirstPage now derives messageLimit and memberLimit from currentRequest state. Added tests verifying behavior with null prior request (resulting in null limits) and tests validating propagation of prior limits (messageLimit=5, memberLimit=50).

Estimated Code Review Effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Constants once carved in stone so deep,
Now dance with state, their promise to keep,
Dynamic limits flow and grow,
Tests ensure the channels flow!
Query logic, lean and bright,
Rabbit-tested, burning right! ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title mentions SyncManager but the changes are only in QueryChannelsLogic; the title does not accurately reflect the actual implementation scope. Revise the title to focus on QueryChannelsLogic respecting message and member limits, or clarify how SyncManager integration relates to the actual code changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The description includes all required sections (Goal, Implementation, Testing) with clear explanations. Mentions that UI changes are absent, and unit tests are provided.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bug/AND-1110_ensure_sync_manager_respects_channel_query_limits

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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 and usage tips.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 9, 2026

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

Labels

pr:internal Internal changes / housekeeping

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant