Fix the appearance theme toggle making other open project windows…#250
Merged
Conversation
… (#2042) With multiple projects open, switching Light/Dark/System made every other window rapidly flip between light and dark before settling. ConfigProvider's effect that mirrors the config theme into next-themes listed setTheme in its deps. next-themes' setTheme identity churns on every theme-state change and writes the shared localStorage, and all OK windows share one localStorage. So on a non-primary window a cross-window storage event (from another window's optimistic flip) churned setTheme, re-fired the effect, re-applied the briefly-stale config value, and wrote it back to the shared localStorage, re-broadcasting to every window in a feedback loop until all configs converged. Extract the bridge into useApplyConfigTheme, depending on [themeValue] only, so a cross-window flip is honored and never reverted. Adds a jsdom regression test that reproduces the storm: red with setTheme in deps, green without. GitOrigin-RevId: b938db4b077fa4fee73685a0c3a2e79d8f8dc38b
Contributor
There was a problem hiding this comment.
Automated approval from agents-private public-mirror-sync (run: https://github.com/inkeep/agents-private/actions/runs/28121753401). Source of truth is the monorepo; direct edits on inkeep/open-knowledge are overwritten on next sync.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix the appearance theme toggle making other open project windows flicker between light and dark before settling. With more than one project open, switching
Light/Dark/Systemwould strobe every other window. The cause was an app-layer feedback loop: when a window observed another window's theme change, it re-applied its own briefly-stale saved theme and wrote that stale value back to the shared theme storage, which re-triggered every window until all windows caught up. Theme changes now propagate across windows cleanly, with no cross-window flicker. (A companion change separately reduces redundant macOS window-chrome translucency work on the same switch.)