mirror of
https://github.com/pbakaus/impeccable.git
synced 2026-09-12 06:06:37 +03:00
Three concrete bugs from the diagnostic logs: 1. saveSession was writing scrollY alongside state, so every call during resumeSession clobbered the Go-time value with whatever the browser had left us at (typically 0). Move scrollY to its own localStorage key, touched only at Go and on user-scroll reanchor. 2. history.scrollRestoration='manual' was being set inside init() at DOMContentLoaded — by then the browser has already started animating its restore, especially with scroll-behavior: smooth on html. Apply it at script parse time, and apply the saved scrollY immediately there too, before the browser's animation starts. 3. Corrections only fired on MutationObserver. A programmatic smooth scroll (browser restore animation, or another script calling scrollIntoView) produces zero DOM mutations — so we never caught it walking scrollY from 0 up to 4800+ in the recorded session. Snap back on every scroll event, gated by a 250ms user-gesture window so we don't fight real user scrolls. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>