Skip to content

Reduce Full-Page Re-renders Triggered by Server-Sent Event (SSE) Updates #248

Description

@arpit2006

Type

Performance

Severity

Medium

Location

frontend/src/app/pages/dashboard.tsx (around lines 220 and 314)

Description

The dashboard receives live scan progress updates through Server-Sent Events (SSE) during repository and organization scans. The onmessage callbacks update top-level state using setSingleScanState and setOrgStatusData approximately every 1.5 seconds.

Since these state hooks are managed within the root Dashboard component, each incoming event triggers a re-render of the entire dashboard, including components unrelated to scan progress.

As the number of UI elements on the dashboard grows, these frequent full-page re-renders can negatively impact rendering performance and responsiveness.


User Impact

  • Reduced UI responsiveness during long-running scans.
  • Noticeable frame drops or animation stuttering on lower-end devices.
  • Unnecessary rendering of components unrelated to scan progress.
  • Increased CPU usage and reduced rendering efficiency.

Steps to Reproduce

  1. Open the dashboard.
  2. Start a repository or organization scan.
  3. Allow the scan to run while live progress updates are received via SSE.
  4. Monitor component re-renders using React DevTools Profiler or browser performance tools.
  5. Observe that the entire Dashboard component re-renders on each SSE update instead of only the progress-related UI.

Expected Behavior

Only the components responsible for displaying scan progress (such as progress indicators and scanning dialogs) should re-render when new SSE events are received.


Current Behavior

  • Each SSE onmessage event updates top-level dashboard state.
  • The root Dashboard component re-renders for every progress update.
  • Components unrelated to scanning are unnecessarily re-rendered.

Recommended Fix

Refactor the scan progress logic to minimize unnecessary rendering.

Possible improvements include:

  • Extract scanning dialogs and progress indicators into isolated child components.
  • Move SSE state management closer to the components that consume it.
  • Wrap progress-related components with React.memo where appropriate.
  • Use stable callbacks (useCallback) and memoized values (useMemo) to prevent unnecessary child updates.
  • Keep unrelated dashboard state independent of scan progress updates.

Acceptance Criteria

  • SSE progress updates do not trigger full dashboard re-renders.
  • Only scan-related components update when new progress events are received.
  • Dashboard interactions remain responsive during active scans.
  • React DevTools Profiler shows a significant reduction in unnecessary component renders.
  • Existing scan functionality and live progress updates continue to work correctly.
  • No regressions are introduced in the scanning workflow.

Definition of Done

  • Scan progress UI extracted into isolated components.
  • SSE state localized to relevant components.
  • Rendering optimized using appropriate memoization techniques.
  • Performance profiling confirms reduced re-renders.
  • Regression testing completed for repository and organization scans.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions