mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 09:29:39 +08:00
#648 kept code-block appearance state in three places — AppShellContext, SettingsContext (a duplicate useState mirror + direct cross-context setters), and the appearance page (its own useState + a storage/event listener) — kept in sync via a custom event and belt-and-suspenders direct setters that a test comment admitted papered over an effect-ordering worry. Collapse to one owner. AppShellContext (already consumed by RichCodeBlock) holds the state and hydrates it after the SSR-safe first render. SettingsContext now reads the values from useAppShell and its update* setters delegate to the AppShell setters (which normalize, persist to localStorage, and notify) before mirroring to the backend; it keeps no local copy. The appearance page reads the values from the settings context and drops its local mirror + event listener. Behavior is unchanged (same values render, same persistence); there is just one source of truth instead of three. Tests updated to assert the new wiring; full web test suite green (211). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>