Skip to content

fix(chat): prevent preview link DOM mutation loops - #193

Merged
cxxxxxn (cxxxxxn) merged 1 commit into
microsoft:mainfrom
cxxxxxn:fix/chat-link-dom-loop
Sep 16, 2026
Merged

cxxxxxn (cxxxxxn) merged 1 commit into
microsoft:mainfrom
cxxxxxn:fix/chat-link-dom-loop

Conversation

@cxxxxxn

Copy link
Copy Markdown
Contributor

Summary

Fixes #192.

  • Remove the plugin that walks anchors and writes nodrag on every ProseMirror view update.
  • Configure Milkdown's native linkAttr instead, preserving inherited attributes and letting ProseMirror render the class. Add the existing commonmark package as a direct dependency; no editor version upgrade.
  • Add bounded Chromium regressions using the production Milkdown factory and document the rendering contract.

Why

In editable drag-only Chat previews, post-render link attribute writes feed ProseMirror's DOM observer back into the plugin and can monopolize the main thread. Initial linked history and links introduced by later content updates both trigger the defect. A class-presence guard was insufficient in the production-factory browser reproduction, so this change removes the post-render DOM writes entirely.

Validation

  • Before the fix: all four browser regressions failed; both drag-only cases reached the 40-write safety cap.
  • After the fix on current main: 4 Chromium cases passed, covering linked/link-free mount, content replacement, selection, link removal, navigation, and unchanged Markdown serialization in read-only and drag-only modes. No classList.add(nodrag) calls occur.
  • 96 focused link and preview tests passed.
  • Root pnpm typecheck, pnpm format, and pnpm lint:fix passed (0 lint errors, 271 warnings).
  • git diff --check passed.
  • Browser tests use dedicated ports and temporary storage, not the developer's active workspace. The original reported Agent conversation was not replayed.

Scope

This is an independent bugfix based on main; #191 is already merged. It does not change link click policy, cursors, navigation destinations, double-click handling, or block dragging. Chat/Note interaction unification, canvas Cmd/Ctrl-click navigation, and the editable Note link hover/edit UI are follow-up work, not part of this PR.

Replace the view-update nodrag patch with Milkdown's native linkAttr configuration so ProseMirror owns link rendering. Preserve current navigation and drag behavior.

Add bounded Chromium regressions for initial and updated content in read-only and drag-only previews, and document the rendering contract. Fixes microsoft#192.
@cxxxxxn
cxxxxxn (cxxxxxn) merged commit 8b7e1b6 into microsoft:main Sep 16, 2026
2 checks passed
Yuqing (mydmdm) added a commit that referenced this pull request Sep 16, 2026
Include the ChatPanel link mutation fix from #193. Follow main's frontend restore behavior while retaining server-owned Agent Node lifecycle and association safeguards.

Co-authored-by: Copilot <223556219+Copilot@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.

[Bug]: ChatPanel freezes on links due to a ProseMirror DOM mutation loop

1 participant