OpenGenerativeUI icon indicating copy to clipboard operation
OpenGenerativeUI copied to clipboard

perf: MutationObserver on document.body fires on every DOM mutation

Open jerelvelarde opened this issue 8 months ago • 0 comments

Description

Severity: P2 — Fragility / Performance

In apps/app/src/components/explainer-cards.tsx:141, a MutationObserver is attached to document.body with { childList: true, subtree: true }, which fires on every DOM mutation in the entire app.

Failure mode

Performance degradation on pages with frequent DOM updates (e.g., during agent streaming).

Suggested fix

  • Narrow the observer scope: observe only the CopilotKit container element (e.g., [data-copilotkit]) instead of document.body
  • Add a debounce or requestIdleCallback to the callback

From self-review finding F06

jerelvelarde avatar Mar 14 '26 04:03 jerelvelarde