You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clear the channel list and message search when the user logs out or another user connects - #6861
A channel list or message search kept alive across a logout kept the previous user's data. After disconnect, their chats stayed on screen, and when the next user connected they showed for about a second until the new result landed. The previous user's queries were also sent again for the new user.
New internal ClientState.userSessionEnds() in ui-common: emits when the connected user disconnects or is replaced by a different one. A first connect, the same user connecting again and profile updates emit nothing.
Compose and XML ChannelListViewModel and the XML SearchViewModel use it to drop the previous user's data and stop their queries and load-more requests right away, then reload once the next user is connected. Until then the list shows the same loading state as before the first connect.
Each query's state now lives as long as the query, so replaced queries stop instead of being sent again when a user connects.
With no filter passed, the default filter is rebuilt for the new user, unless the app called setFilters. An explicit filter that contains the user's id is replaced with setFilters before the list reloads; predefined filter values can't be, so those apps need a new view model per user.
Apps that disconnect and reconnect the same user now see the list reload.
The KDoc of both ChannelListViewModelFactorys says a view model serves one user at a time, and that a filter containing a user id should be replaced with setFilters before the list reloads for the next user.
Testing
ClientStateExtensionsTest, both ChannelListViewModelTests and SearchViewModelTest cover logout, a switch (including one racing a disconnect), the same user connecting again, the default filter versus a filter set by the app, old queries not being sent again, and load-more and searches in flight during a switch.
On an emulator, with the Compose and XML samples: the same user connecting again keeps the list, logout clears it, the previous user's chats never come back, and the next user gets their own channels (with no filter passed, before they got only the one shared channel).
Summary by CodeRabbit
Bug Fixes
Channel lists now reset and reload correctly when users disconnect or switch accounts.
App-selected filters are preserved across user-session changes, while default filters update for the connected user.
Stale channel queries, selections, pagination results, and searches are cleared during transitions.
Message searches wait until initialization completes and return a failure when no user is connected.
New Features
Added support for detecting when a user session ends.
Documentation
Clarified how channel lists and user-specific filters behave when users change.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
📝 Walkthrough
The change adds a flow extension that detects when a user session ends. Channel-list view models clear user-specific state and reload after the next user is ready, while preserving app-provided filters. SearchViewModel waits for initialization before searching and handles the absence of a connected user with a failure result. Tests cover disconnects, reconnects, user changes, searches, and pagination.
Priority: ➖ Normal
Merge Risk:⚪ Minimal · up to b08f9
The reported filter and search-pagination concerns do not block merging. Normal checks remain appropriate.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 13.75% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 80 functions across 10 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title clearly and concisely describes the main change: clearing channel-list and message-search data when the user logs out or another user connects.
Description check
The description includes all required sections: Goal, Implementation, Testing, and Checklist. It explains the problem, implementation details, limitations, and test coverage. The checklist items are p…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Description check
Explanation
The description includes all required sections: Goal, Implementation, Testing, and Checklist. It explains the problem, implementation details, limitations, and test coverage. The checklist items are present, although they remain unchecked.
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
Commit to this branch
Create a new PR
🧪 Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
A rabbit watched the user stream, Then cleared old channels from the dream. New filters hopped in place, Searches resumed their race. Tests fenced each session’s trail, While pagination stayed on the rail.
Comment @coderabbitai help to get the list of available commands.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
A channel list or message search kept alive across a logout kept the previous user's data. After
disconnect, their chats stayed on screen, and when the next user connected they showed for about a second until the new result landed. The previous user's queries were also sent again for the new user.Part of AND-1667
Implementation
ClientState.userSessionEnds()inui-common: emits when the connected user disconnects or is replaced by a different one. A first connect, the same user connecting again and profile updates emit nothing.ChannelListViewModeland the XMLSearchViewModeluse it to drop the previous user's data and stop their queries and load-more requests right away, then reload once the next user is connected. Until then the list shows the same loading state as before the first connect.setFilters. An explicit filter that contains the user's id is replaced withsetFiltersbefore the list reloads; predefined filter values can't be, so those apps need a new view model per user.ChannelListViewModelFactorys says a view model serves one user at a time, and that a filter containing a user id should be replaced withsetFiltersbefore the list reloads for the next user.Testing
ClientStateExtensionsTest, bothChannelListViewModelTests andSearchViewModelTestcover logout, a switch (including one racing a disconnect), the same user connecting again, the default filter versus a filter set by the app, old queries not being sent again, and load-more and searches in flight during a switch.Summary by CodeRabbit