Skip to content

Live DOM push: MutationObserver → dom_change events - #21

Draft
shehrii9 wants to merge 1 commit into
mainfrom
cursor/dom-mutation-observer-ec5e
Draft

shehrii9 wants to merge 1 commit into
mainfrom
cursor/dom-mutation-observer-ec5e

Conversation

@shehrii9

Copy link
Copy Markdown
Owner

Summary

Implements roadmap item #1 — live DOM push stream for SPA-heavy pages.

  • On attach and tab switches, the runtime installs an in-page MutationObserver that batches DOM mutations and emits debounced dom_change events on the existing event bus.
  • Agents consume via GET /events?type=dom_change or GET /events/stream (SSE), then follow with browser_diff / GET /diff for semantic signal/button deltas (no full observe on every mutation).
  • Opt out with BER_DOM_WATCH=0; tune Node-side debounce with BER_DOM_WATCH_DEBOUNCE_MS (default 400ms).

Testing

  • Unit tests for batch merge + env flags
  • Browser smoke: fixtures/dom-mutate.html verifies dom_change after delayed DOM injection
  • npm test and npm run test:browser pass locally
Open in Web Open in Cursor 

Install a debounced in-page MutationObserver on attach and tab switches.
Agents can poll GET /events or SSE /events/stream for dom_change bursts,
then call browser_diff for semantic deltas. Disable with BER_DOM_WATCH=0.

Co-authored-by: Shaharyar Ahmad <shehrii9@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants