window.matchMedia() returns a new object on every call, so the code meant to remove the auto-mode handler removes it from a freshly created object rather than from the one that holds it. An explicit light or dark choice is therefore overridden the next time the system scheme flips, even though the saved mode still says otherwise, and selecting auto repeatedly stacks handlers, so a single flip notifies every listener once per selection.
window.matchMedia()returns a new object on every call, so the code meant to remove the auto-mode handler removes it from a freshly created object rather than from the one that holds it. An explicitlightordarkchoice is therefore overridden the next time the system scheme flips, even though the saved mode still says otherwise, and selectingautorepeatedly stacks handlers, so a single flip notifies every listener once per selection.