Two bugs fixed: 1. Hydration flash: The effect's schedule-idle called rebuild-preview on initial hydration, which cleared the SSR HTML and re-rendered (flashing raw SX source or blank). Fix: skip rebuild-preview on initial render — the SSR content is already correct. Only rebuild when stepping. 2. Stepping structure: After do-back calls rebuild-preview, the DOM stack was reset to just [container]. Subsequent do-step calls appended elements to the wrong parent (e.g. "sx" span outside h1). Fix: compute the correct stack depth by replaying open/close step counts, then walk the rendered DOM tree that many levels deep via lastElementChild to find the actual DOM nodes. Proven by harness test: compute-depth returns 3 at step 10 (inside div > h1 > span), 2 at step 8 (inside div > h1), 0 at step 16 (all closed). Playwright test: lake never shows raw SX (~tw, :tokens) during hydration — now passes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3.1 KiB
3.1 KiB