fix: hidden message list drains the entire room history behind a full-width contextual bar
Proposed changes (including videos or screenshots)
On screens narrower than 600px (the sm breakpoint), opening any contextual bar (e.g. the thread view) makes it take the full room width and RoomLayout hides the message body with display: none while keeping it mounted.
The hidden scroller then reads scrollTop: 0 / clientHeight: 0, which the "near top" check in useGetMore mistakes for "scrolled to top" (0 <= 0 / 3). Each getMore inserts a page of messages, the DOM mutation re-triggers the MutationObserver, and the cycle repeats until the entire room history is loaded behind the overlay — mounting every message and firing media requests for all their attachments (images, video metadata, avatars) while nothing is visible.
The fix bails out of the position check while the container has no size, which also covers any future zero-height scroller (tab switches, animations, other layouts).
Issue(s)
Steps to test or reproduce
- Create a channel with more messages than one history page (50+) including some file attachments, and at least one thread
- Make the window narrower than 600px
- Scroll the message list once, then open the thread view (or any contextual bar tab)
- Without the fix, the network tab shows
loadHistoryfiring in a loop and every attachment in the room being downloaded while the message list is hidden; with the fix, no history is loaded until the bar is closed
Covered by a unit test (zero-size container never triggers getMore) and an e2e test (message count stays stable while the list is hidden behind the full-width thread view — verified failing against an unpatched server).
Further comments
An alternative would be pausing the observers on visibility change, but guarding the geometry check where every trigger (resize, mutation, scroll) already converges is smaller and covers the whole class.
Summary by CodeRabbit
-
Bug Fixes
- Prevented hidden message lists from loading additional room history or attachments when covered by full-width contextual bars.
- Improved small-screen thread views by avoiding unnecessary background history requests.
-
Tests
- Added coverage for zero-sized message containers and small-screen thread navigation.
- Verified that thread replies remain visible while hidden message lists avoid loading additional history.