Repository navigation
refactor(html5/chat): Log high scroll activity - #23527
gustavotrott merged 7 commits into
Conversation
|
""" WalkthroughThe changes introduce scroll activity monitoring and control in the chat message list component by adding state and refs to handle programmatic scroll disabling, scroll event counting, and scroll end detection via animation frame polling. A periodic timer calculates scroll event frequency, logging a warning if excessive scrolling is detected, including detailed chat, user, and device/browser info. The scroll and wheel event handlers are updated to respect the scrolling-disabled state and improve event target usage. The unread notification is moved inside the message list as a child element. Additionally, a Sequence Diagram(s)sequenceDiagram
participant User
participant ChatMessageList
participant Logger
participant DeviceInfo
participant BrowserInfo
User->>ChatMessageList: scroll event
ChatMessageList->>ChatMessageList: update sentinel visibility
ChatMessageList->>ChatMessageList: start scroll activity check (if not running)
ChatMessageList->>ChatMessageList: initiate scroll end polling
ChatMessageList->>ChatMessageList: increment scroll event count
Note over ChatMessageList: Every 1 second (timer)
ChatMessageList->>ChatMessageList: calculate scroll frequency
alt frequency > 100/sec
ChatMessageList->>DeviceInfo: get device info
ChatMessageList->>BrowserInfo: get browser info
ChatMessageList->>Logger: log warning with details
end
alt scroll end detected (via polling)
ChatMessageList->>ChatMessageList: reset scroll tracking state
ChatMessageList->>ChatMessageList: clear interval
end
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/component.tsx (1)🧬 Code Graph Analysis (1)bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/component.tsx (3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
🔇 Additional comments (10)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/component.tsx (1)
563-601: Consider adding error handling for DOM queriesThe scroll activity monitoring implementation is well-designed. However, consider wrapping the DOM query operation in a try-catch block to prevent potential errors from interrupting the scroll monitoring.
const startScrollActivityCheck = useCallback(() => { userStartedScrollingAt.current = Date.now(); scrollActivityCheckInterval.current = setInterval(() => { if (userStartedScrollingAt.current === null) return; const now = Date.now(); const timeEllapsedInSeconds = (now - userStartedScrollingAt.current) / 1000; const scrollRatio = scrollEventCount.current / timeEllapsedInSeconds; if (scrollRatio > 50) { + try { const messageElements = Array.from(document.querySelectorAll('#chat-list [data-message-type]')) as HTMLElement[]; const messageTypeCount = messageElements.reduce((acc, element) => { const { messageType } = element.dataset; if (messageType) { if (acc[messageType]) { acc[messageType] += 1; } else { acc[messageType] = 1; } } return acc; }, {} as Record<string, number | undefined>); logger.warn({ logCode: 'high_scroll_activity_in_chat', extraInfo: { userLoadedMessagesByType: { totalMessages: messageElements.length, ...messageTypeCount, }, userId: currentUser?.userId, browserName: browserInfo.browserName, browserVersion: browserInfo.browserVersion, deviceName: deviceInfo.osName, deviceVersion: deviceInfo.osVersion, }, }, 'User performed high scroll activity in chat'); + } catch (error) { + logger.error({ + logCode: 'scroll_activity_check_error', + extraInfo: { error }, + }, 'Error during scroll activity check'); + } } }, 1000); }, [currentUser?.userId]);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/component.tsx(3 hunks)bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/page/chat-message/component.tsx(1 hunks)bigbluebutton-html5/imports/utils/browserInfo.js(4 hunks)bigbluebutton-html5/imports/utils/deviceInfo.js(3 hunks)
🧰 Additional context used
🧠 Learnings (1)
bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/page/chat-message/component.tsx (1)
Learnt from: kepstin
PR: bigbluebutton/bigbluebutton#21894
File: record-and-playback/video/playback/video/js/popcorn.chattimeline.js:72-76
Timestamp: 2024-12-12T20:20:58.714Z
Learning: In `popcorn.chattimeline.js`, the `options.message` field is provided by the recording system and is pre-sanitized, so assigning it directly to `innerHTML` is acceptable.
🧬 Code Graph Analysis (2)
bigbluebutton-html5/imports/utils/browserInfo.js (1)
bigbluebutton-html5/imports/utils/deviceInfo.js (4)
window(3-3)window(3-3)BOWSER_RESULTS(4-4)BOWSER_RESULTS(4-4)
bigbluebutton-html5/imports/utils/deviceInfo.js (1)
bigbluebutton-html5/imports/utils/browserInfo.js (2)
window(4-4)BOWSER_RESULTS(5-5)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: build-package (others)
- GitHub Check: build-package (bbb-html5)
- GitHub Check: build-package (bbb-playback-record)
- GitHub Check: build-package (bbb-graphql-server)
🔇 Additional comments (11)
bigbluebutton-html5/imports/utils/deviceInfo.js (4)
3-3: LGTM! Consistent with browserInfo.jsThe destructuring assignment aligns with the same pattern used in
browserInfo.js.
12-12: LGTM! Useful for diagnosticsAdding OS version information enhances the diagnostic capabilities, especially for the scroll activity logging feature.
13-13: Good type safety improvementUsing strict equality is a better practice. Since
osNameis always a string from Bowser, this change is safe.
25-25: LGTM! Completes the osVersion exportAdding
osVersionto the default export maintains consistency with the named export.bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/page/chat-message/component.tsx (1)
804-804: LGTM! Enables message type trackingThe
data-message-typeattribute enables the scroll monitoring feature to categorize messages by type when logging high scroll activity.bigbluebutton-html5/imports/utils/browserInfo.js (2)
4-4: LGTM! Consistent destructuring patternThe destructuring assignment maintains consistency with the updated
deviceInfo.js.
14-14: LGTM! Browser version for enhanced diagnosticsAdding
browserVersionto the exports provides valuable information for debugging scroll-related issues across different browser versions.Also applies to: 52-52
bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/component.tsx (4)
40-41: LGTM! Required imports for logging device infoThe imports are necessary for the enhanced logging functionality.
521-524: LGTM! Appropriate use of refs for scroll trackingUsing refs for scroll tracking state is the correct approach as these values don't need to trigger re-renders.
526-549: LGTM! Well-implemented scroll end detectionThe polling mechanism correctly uses
requestAnimationFrameand waits for stability before triggering the scroll end callback. The 20-frame threshold is reasonable.
617-636: LGTM! Proper integration of scroll monitoringThe scroll handler correctly:
- Uses
currentTargetinstead oftargetfor consistent scroll position reading- Prevents multiple activity check intervals
- Properly cleans up resources when scrolling ends
- Maintains existing scroll functionality
|
I was expecting the button "More messages" would no longer impact in the size of the chat messages area. Screencast.from.2025-07-11.10-17-39.mp4 |
|
It feels like scrolling with a number greater than 50 is too easy. Screencast.from.2025-07-11.10-24-23.mp4 |
Should be fixed by now: Screencast.from.2025-07-11.11-20-43.webm |
I agree that 50 is too low and sensible. I also managed to reproduce it too easily. Just sent two commits including the scroll ration in the logs and increasing the minimum scroll ratio to 100. |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/component.tsx (2)
578-589: Consider performance impact of DOM queries in interval.The DOM query for message elements runs every second during scroll activity, which could impact performance with large message lists.
Consider memoizing the message type count or using a more efficient approach:
- const messageElements = Array.from(document.querySelectorAll('#chat-list [data-message-type]')) as HTMLElement[]; + const messageElements = Array.from(messageListRef.current?.querySelectorAll('[data-message-type]') || []) as HTMLElement[];
624-648: Consider breaking down complex scroll event handler.The scroll event handler is quite complex, handling multiple concerns (scroll disabling, activity monitoring, sentinel visibility). Consider extracting some logic into separate functions for better maintainability.
Consider extracting the scroll activity monitoring logic:
const handleScrollActivity = useCallback(() => { if (scrollActivityCheckInterval.current == null) { startScrollActivityCheck(); } startScrollEndEventPolling(() => { userStartedScrollingAt.current = null; scrollEventCount.current = 0; clearInterval(scrollActivityCheckInterval.current); scrollActivityCheckInterval.current = undefined; }); scrollEventCount.current += 1; }, [startScrollActivityCheck, startScrollEndEventPolling]);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/component.tsx(6 hunks)bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/styles.ts(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/component.tsx (1)
Learnt from: kepstin
PR: bigbluebutton/bigbluebutton#22200
File: docs/src/components/APITableComponent/index.tsx:79-80
Timestamp: 2025-02-05T20:23:17.109Z
Learning: In the BigBlueButton documentation site components, React key properties are not required for mapped elements as the pages are statically generated and don't require runtime reconciliation.
🧬 Code Graph Analysis (2)
bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/styles.ts (1)
bigbluebutton-html5/imports/ui/stylesheets/styled-components/general.js (1)
smPaddingX(5-5)
bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/component.tsx (1)
bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/styles.ts (3)
Content(57-62)MessageList(15-34)PageWrapper(55-55)
🪛 Biome (1.9.4)
bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/component.tsx
[error] 614-614: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
(lint/correctness/useJsxKeyInIterable)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: build-package (others)
- GitHub Check: build-package (bbb-freeswitch)
- GitHub Check: build-package (bbb-graphql-server)
- GitHub Check: build-package (bbb-html5)
- GitHub Check: build-package (bbb-playback-record)
🔇 Additional comments (11)
bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/styles.ts (4)
11-13: LGTM! Interface correctly supports RTL layout.The new
UnreadButtonPropsinterface properly supports right-to-left layouts for the unread button positioning.
20-23: LGTM! Positioning changes support floating button behavior.The
width: 100%andposition: absolutechanges align with the PR objective to make the message list take full available space while allowing the unread button to float over it.
36-53: LGTM! RTL-aware absolute positioning implemented correctly.The UnreadButton styling correctly implements absolute positioning with RTL support. The conditional left/right positioning based on
isRTLprop ensures proper button placement in both LTR and RTL layouts.
57-62: LGTM! Content wrapper provides proper layout structure.The new
Contentstyled component serves as a proper container wrapper with relative positioning and controlled overflow, supporting the new layout structure.bigbluebutton-html5/imports/ui/components/chat/chat-graphql/chat-message-list/component.tsx (7)
41-42: LGTM! Correct imports for device and browser info.The imports for
browserInfoanddeviceInfoutilities are properly added for the scroll activity logging feature.
211-211: LGTM! State for controlling scroll behavior.The
isScrollingDisabledstate properly controls scroll behavior during programmatic animations.
404-404: LGTM! Scroll disabling during animation prevents conflicts.The scroll disabling mechanism prevents user scroll events from interfering with programmatic scroll animations, improving the user experience.
Also applies to: 413-413
527-531: LGTM! Refs for scroll monitoring state management.The refs are properly defined for tracking scroll activity state without causing unnecessary re-renders.
532-555: LGTM! Scroll end detection using animation frames.The
pollScrollEndEventfunction uses requestAnimationFrame for efficient scroll end detection with a stability threshold. The recursive approach is appropriate for this use case.
557-567: LGTM! Proper animation frame management.The
startScrollEndEventPollingfunction correctly cancels previous frames before starting new polling, preventing memory leaks.
614-732: LGTM! Restructured layout with Content wrapper.The JSX structure correctly implements the new layout with the Content wrapper, moving the unread notification inside the message list container as intended. The MessageList now includes proper event handlers for scroll monitoring.
|
Automated tests Summary✅ All the CI tests have passed! |
|
Example of log I spot in the server:
|



What does this PR do?
In order to detect and track down scroll bugs in the chat, this PR adds a mechanism for logging both browser and chat details every time the user's client performs high scroll activity on the chat. Every time the user starts scrolling the chat, it checks the scroll activity on the chat every second and log the details if needed. The calculation is done by considering the number of scroll events per second. A ratio greater than
100means high scroll activity (based on manual tests).This PR also implement two improvements related to the 'More messages below' button:
Closes Issue(s)
n/a
Motivation
This will help us narrow down scroll bugs that are often seen in production by users.
How to test
Just go crazy on scrolling the chat, see the browser console to see if there is any log with
logCode: high_scroll_activity_in_chat.More