Skip to content

fix(session-ui): reuse parsed DOM for live markdown - #55480

Open
Dante-dan wants to merge 1 commit into
anomalyco:devfrom
Dante-dan:markdown-dom
Open

Dante-dan wants to merge 1 commit into
anomalyco:devfrom
Dante-dan:markdown-dom

Conversation

@Dante-dan

@Dante-dan Dante-dan commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #54428

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Live blocks currently parse HTML for decoration, serialize the decorated DOM, then parse it again for the Solid renderer. Read the decorated DOM directly instead, preserving word keys, animation and store reconciliation. Keep the old HTML-parser repair for decoration-created nested links and session buttons in raw-text/select elements, and normalize session-link text fragments to preserve keys.

This addresses the V2 DOM round-trip identified in the issue; the store-walk change in #54427 is separate.

How did you verify your code works?

  • Session UI typecheck, eight existing markdown/parser/session-link tests, changed-file lint and diff check passed.
  • Full Session UI suite: 247 passed, three unchanged session-diff subprocess tests hit their five-second timeout.
  • Root checks: lint passed with the Bun runtime; full typecheck stopped at Astro's denied preferences-directory write. The default Node runtime also could not load the TypeScript lint plugin.
  • Existing Markdown component tests could not launch Chromium: after installing the required browser, macOS denied its Mach-port bootstrap registration.

Screenshots / recordings

Internal rendering-path change; no intended visual change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #54305

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I ran the issue's reproduction on the base and on this branch under happy-dom. On the base, every live-block delta serializes the whole block with innerHTML; with this branch that no longer happens. For a block with several session links, the node tree built from the DOM is identical to the one the old serialize-and-parse path produced, so keys and reconcile behave the same. The markdown tests in packages/session-ui (116) and the package typecheck pass. I did not measure in Chromium or the desktop app.

Public API: unchanged. createMarkdownRenderer now takes a DOM element instead of an HTML string, but it is internal to session-ui and has a single caller.

One optional suggestion: a small test that spies on the innerHTML getter while a live block is updated would stop the round-trip from creeping back in.

Related: #54305

@dcerisano

Copy link
Copy Markdown

Related but non-overlapping: #55857 (V2 port of #48432) optimizes the worker-side markdown projection in markdown-stream.ts, while this PR addresses the DOM re-parse round-trip in the renderer. Different layer, no shared code.

This branch has not been deployed

No deployments
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.

app: a streaming delta re-parses the whole markdown block, and the DOM round-trip around it dominates the visible cost

2 participants