Repository navigation
perf(dom-fence): limit observer maintenance to affected roots - #341
Merged
taekchef merged 1 commit intoOct 21, 2026
Merged
Conversation
Track dirty mounts and diagnostics while preserving full source/session invalidation and the slow safety sweep. Add regression coverage for operation counts, structural recovery, and retained input/action state. Refs omdsh-dev#321 AI-assisted implementation, tests, and review.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scope
Refs #321, specifically the first remaining optimization in the maintainer's comment: incremental maintenance of existing DOM-fence mounts and diagnostics. This does not close the whole streaming-performance report.
The narrow scope was confirmed in #321 (comment).
Changes
WeakMap, rather than searching every root.The observer still filters composer/plugin-owned mutations per record, including mixed batches. Removed-only code-body updates remain discoverable. Discovery of child-list targets is limited to code/tag-text contexts, avoiding irrelevant host-row discovery targets generated by plugin-container insertion.
Regression evidence
The new tests use real React roots and MutationObserver in jsdom. The operation-count fixtures preserve real rAF and suppress only the explicit 1-second safety interval. The pre-frame repair test additionally holds rAF callbacks to assert that repair completes before a frame.
On unchanged upstream
e64819af5968cf98e8bd28fd72a1cda977309214, the same final 11-test regression file gives 5 expected failures and 6 passes:Coverage also includes diagnostics, sibling insertion/removal/replacement, detached multi-root wrappers, pre-frame wipe/reparent repair, preserved input/action state, removed-only bodies, language/streaming transitions, source/session invalidation, and the full slow-sweep fallback. These are operation counts in synthetic fixtures, not elapsed-time benchmarks.
Validation
pnpm run check: typecheck, 104 test files / 1349 tests, build, and standalone bundle checks passed with one Vitest worker. Two additional regressions and direct body-read assertions were then added; the final focused run passed 3 files / 125 tests, including all 113 existing DOM-fence tests, 11 new maintenance tests, and the rAF-cleanup test. The implementation logic was unchanged during these runs.node scripts/verify-pack.mjs: passed, 3.29 MB tarball / 10.82 MB unpacked / 236 files. Only process-local worker/heap/cache settings were used after resource-limited attempts; package limits and scripts were unchanged.git diff --check: passed.Limits and follow-up
Source notifications deliberately retain full invalidation. A host that publishes a source snapshot for every token may therefore still perform O(M) maintenance per token. Large structural changes can still traverse the changed subtree synchronously; this is not a hard frame-time guarantee. The anchorless ordinal cache, Safari-specific behavior, real DSH host/model integration, and the original Windows/display-plugin frame-rate/INP report are not claimed as verified or fixed here.
AI assistance was material to implementation, test design, and review. The resulting diff and evidence also received a separate review; no human review is implied by that statement.