Repository navigation
fix: stop Markdown annotation highlights mutating React DOM - #11446
bolichen97 merged 1 commit into
Conversation
Design Review (Fable 5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Half the PR is phantom: the title and description claim backend CI-contract fixes (Fargate, ledger, completion-sound) that this diff does not contain. Watch
The annotation change itself is the right shape: it fixes the root cause (React-owned DOM mutation) with the same paint-only mechanism find already uses, the per-owner range aggregation is pinned by new multi-tab tests, the no-paint degradation and lost 2px radius are stated and shown in the rendered before/after evidence. [DESIGN-REVIEWED] fa4b85b |
GPT 5.6 Review (fork) — ✅ no blocking findingsReviewed Review detailsFINDING -- website/src/components/MarkdownPanel.tsx:59 -- the diff adds only the Markdown |
UX Review (Fable 5, fork) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS On browsers without CSS Custom Highlight the annotation passage now paints no highlight at all — users typing a comment lose sight of which text it targets. Watch
[UX-REVIEWED] fa4b85b |
First Principles Review (Fable 5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS This diff ships only the Markdown fix — the "restore CI contracts" half of the title/description already landed on main (#11442, #11445; What this change shipsInventory (6 items) — 6 justifiedIntent: stop the companion Markdown preview crashing (
The fix sits at cause level: it removes the DOM mutation itself, reusing the find machinery already in [FIRST-PRINCIPLES-REVIEWED] fa4b85b |
Opus 4.8 Review (fork) — ✅ no blocking findingsReviewed |
4547d0b to
d290c89
Compare
d290c89 to
93ccb5a
Compare
b57fc3c to
7f561a4
Compare
7f561a4 to
fa4b85b
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Reviewed the full diff on head fa4b85b as part of the 2026-09-17 readiness audit (evidence: pr-ready-audit-20260917-0835). Verified before approving: readiness: passed in place, required status PR Readiness success on this head, no CHANGES_REQUESTED, no unresolved human hold, main-drift checked against files this PR touches, last push by Skymore. Merge follows through the normal protected path (no bypass).
…ev#11446) Co-authored-by: Rui Tao <ruit@amazon.com>
Problem / Motivation
Markdown annotation highlights wrap selected text in
<mark>elements insidereact-markdownoutput. When an agent streams an artifact update that rewrites the annotated passage, React can reconcile against nodes thatsurroundContents(),removeChild(), ornormalize()already moved or replaced and crash the preview withNotFoundError: Failed to execute 'removeChild' on 'Node'.Why it matters
A normal comment-and-edit workflow can hard-crash the companion Markdown preview while the agent is updating the document. The error boundary limits the blast radius to the panel, but the user loses the live preview until it is reopened.
What changed
Annotation highlighting now stores selected text segments as
Rangeobjects in a CSS Custom Highlight rather than inserting and removing React-owned nodes. Clearing or changing a selection updates the registry only.Multiple mounted file tabs contribute independently to the shared annotation highlight. Closing or unmounting one tab removes only its own ranges, and the generic panel-unmount cleanup no longer deletes the global annotation entry after per-owner cleanup has republished surviving ranges.
When CSS Custom Highlight is unavailable, annotation remains functional but is not painted. The DOM-mutating fallback is intentionally not retained because it reintroduces the crash. The accent fill is preserved; the old 2px
<mark>radius is absent because CSS highlights do not paint box geometry.Tests
<mark>insertion.Manual verification
Rendered a deterministic before/after fixture using the production light and dark theme tokens. The annotation accent fill and current find-match fill remain unchanged; only the unsupported 2px annotation radius differs.
Screenshots / video
Related Issues
Fixes #11025
Pattern harvest
Rule candidate: review-prompt
Pattern: Visual decoration inside React-rendered content must not structurally mutate React-owned DOM; use a paint-only API or an isolated non-React container.
Checklist
Contribution License Agreement
N/A — repository CLA wording is not yet available.