Problem
Current hot reload does a full location.reload() on file change. This loses:
- Scroll position
- Form input values
- Modal/dropdown state
- WASM component state
Proposed Solution
Instead of full reload, inject the new HTML via morphdom-style DOM diffing:
- Server sends changed HTML over SSE
- Client-side diffing patches only the changed nodes
- Scroll position, form values, and focus are preserved
Implementation sketch
- SSE sends the re-rendered page body (not a reload signal)
- A tiny (~2KB) client-side diff script patches the DOM
- For WASM components: serialize state before patch, restore after
Complexity
Low-medium. The SSE infrastructure exists. The main work is the DOM diffing logic.
Problem
Current hot reload does a full
location.reload()on file change. This loses:Proposed Solution
Instead of full reload, inject the new HTML via morphdom-style DOM diffing:
Implementation sketch
Complexity
Low-medium. The SSE infrastructure exists. The main work is the DOM diffing logic.