Skip to content

Message Filtering Creates O(n²) Rendering Performance Issue #10

@BP602

Description

@BP602

Problem

Message filtering recalculates entire message array on every render, creating O(n²) complexity with large chat histories.

Impact

  • Frame rate drops below 30fps with >100 messages
  • UI lag during active chat periods
  • Exponential performance degradation with message count

Root Cause

// MessagesHandler.jsx:27-37 - Recomputes entire filter on every render
const filteredMessages = useMemo(() => {
  return messages.filter((message) => {
    // Runs for every message on every update

Solution

  1. Implement virtual scrolling with react-virtuoso
  2. Pre-index messages by chatroom for O(1) lookup
  3. Use incremental filtering instead of full recomputation

Success Criteria

  • Maintain 45+ fps with 1000+ messages
  • O(1) message filtering implementation
  • Virtual scrolling with windowing

Files to Modify

  • src/renderer/src/components/Messages/MessagesHandler.jsx
  • Add virtual scrolling components

Priority: P1 (High)
Estimated Effort: 3-4 days

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions