Skip to content

refactor: replace config-bus subscribers outside the test with store effects (C2) (@miodec) - #8526

Open
Miodec wants to merge 6 commits into
masterfrom
c2-config-effects
Open

Miodec wants to merge 6 commits into
masterfrom
c2-config-effects

Conversation

@Miodec

@Miodec Miodec commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Roadmap C2: config-bus subscribers outside the test become effects on config store keys.

 theme-controller
-  configEvent.subscribe(per-key branches + fullConfigChange suppression)
+  createRoot
+    configured theme = autoSwitch ? themeLight/Dark : customTheme ? "custom" : theme
+    effect(configured theme, customThemeColors) -> clearRandom, clearPreview, set
+    effect(randomTheme) -> changeThemeList / clearRandom
+    effect(theme keys, favThemes) -> updateThemeIndicator
 sound-controller      configEvent -> effects on playSoundOnClick, soundVolume
 quotes-controller     configEvent -> effect on quoteLength
 challenge-controller  configEvent -> effect on the 14 test-setting keys -> clearActive
 commandline/themes    configEvent -> effect on favThemes

Auto switch off on a manual pick moves from ThemeController.set to config metadata:

 theme / customTheme / customThemeColors
+  overrideConfig: autoSwitchTheme on -> { autoSwitchTheme: false } + notice
 applyConfig lastConfigsToApply
+  "autoSwitchTheme"   # else theme would turn it off on sign-in / preset

Behaviour changes:

  • Effects only run on a changed value: re-picking the current setting no longer clears a challenge or reshuffles the quote queue. Theme pickers (commandline lists, settings custom buttons) call clearRandom themselves, so re-picking still drops a random theme.
  • Whole-config apply resolves the theme once; a preset with an unchanged theme keeps an active random theme.
  • randomizeTheme writes customTheme: false before picking, so the theme effect doesn't clear the new random theme.
  • Dead showLiveWpm key dropped from the challenge list.

Evidence

  • Before: no tests for these reactions.
    After: spec per controller (__tests__/controllers/*, __tests__/commandline/lists/themes.spec.ts), plus override and apply-order cases in config specs. Full suite 1641 passing.

    Mutation checks (reverted fix → test fails):

    theme effect awaiting its chain    -> "keeps the random theme over a custom theme" fails
    autoSwitchTheme not applied last   -> "applyConfig keeps auto switch theme next to a theme" fails
    picker without clearRandom         -> "drops the random theme when the configured theme is re-picked" fails
    
  • Browser (dev): theme / custom / auto switch apply; picking a theme with auto switch on disables it with the notice; reload with auto switch on keeps it, no notice; random theme over custom works and re-picking the configured theme restores it; challenge survives load and volume change, clears on punctuation; commandline theme list puts new favorites first.

Merge Danger

Door: two-way

Pure frontend refactor, no persisted data shape change. Revert restores the bus subscribers.

Blast Radius: theming

Theme application on boot, sign-in, preset load, random theme and auto switch; challenge clearing; quote queue; click sounds.

🤖 Generated with Claude Code

…effects (C2)

Theme, sound, quotes and challenge controllers and the commandline theme
list react via effects on config store keys instead of configEvent.
Theme resolves one configured theme; picking a theme turns auto switch
off via overrideConfig, so whole-config apply sets autoSwitchTheme last.
Effects only run on changed values: theme pickers clear the random
theme themselves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 26, 2026 15:48
@monkeytypegeorge monkeytypegeorge added frontend User interface or web stuff docs Related to Markdown files and documentation labels Oct 26, 2026
@github-actions github-actions Bot added the waiting for review Pull requests that require a review before continuing label Oct 26, 2026
@Miodec Miodec changed the title refactor: replace config-bus subscribers outside the test with store effects (C2) refactor: replace config-bus subscribers outside the test with store effects (C2) (@miodec) Oct 26, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The reactive rewrite spans the whole theming blast radius and introduces a real regression where an internal randomizeTheme write now disables auto switch theme, so a human should confirm the intended override semantics.

1 open issue
What changed in this PR

Roadmap step C2: this PR replaces the imperative configEvent bus subscribers in the theme, sound, quotes and challenge controllers (and the commandline theme list) with SolidJS store effects (createEffectOn inside a createRoot) that react to individual getConfig keys. Because effects only run on an actual value change, re-picking the same setting no longer re-runs its reaction, so theme pickers now call the newly-exported clearRandom() themselves, and the "auto switch off on a manual theme pick" behaviour moves from ThemeController.set into config metadata overrideConfig.

Changes:

  • Convert five config-bus subscribers to deferred store effects; export ThemeController.clearRandom and call it from theme pickers.
  • Move auto-switch-off side effect into a shared disableAutoSwitchTheme override on theme/customTheme/customThemeColors, and apply autoSwitchTheme last in whole-config apply.
  • Add per-controller spec files plus override/apply-order config spec cases; drop the dead showLiveWpm key from the challenge list.
File Description
frontend/​src/​ts/​controllers/​theme-controller.ts Replace config-bus subscriber with memo + deferred effects; export clearRandom; reorder randomizeTheme customTheme write
frontend/​src/​ts/​controllers/​sound-controller.ts Effects on playSoundOnClick/soundVolume
frontend/​src/​ts/​controllers/​quotes-controller.ts Effect on quoteLength
frontend/​src/​ts/​controllers/​challenge-controller.ts Effect on 14 test keys; drop dead showLiveWpm
frontend/​src/​ts/​config/​metadata.tsx disableAutoSwitchTheme override on theme keys (source of the reported bug)
frontend/​src/​ts/​config/​lifecycle.ts Apply autoSwitchTheme last so theme overrides don't disable it on apply
frontend/​src/​ts/​components/​pages/​settings/​custom-setting/​Theme.tsx Call clearRandom() from preset/custom/custom-theme buttons
frontend/​src/​ts/​commandline/​lists/​themes.ts Effect on favThemes; clearRandom() in exec
frontend/​src/​ts/​commandline/​lists/​custom-themes-list.ts clearRandom() in exec
frontend/​__tests__/​... (6 files) New controller/commandline specs + override/apply-order config cases
docs/​specs/​solid-monkeytype/​roadmap.md Document C2 behaviour changes

Review effort: Balanced

Comment thread frontend/src/ts/config/metadata.tsx Outdated
Miodec and others added 4 commits October 27, 2026 22:33
…e writes

randomizeTheme rewrites customTheme: false (nosave) after every result,
which turned auto switch off for users with random theme on. Picking a
preset while the custom theme was on also showed the notice twice: the
theme override disabled auto switch and so did the customTheme: false it
set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NZNRfGDYsGYMUTp2zYUTrv
# Conflicts:
#	docs/specs/solid-monkeytype/roadmap.md
#	frontend/src/ts/controllers/theme-controller.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Related to Markdown files and documentation frontend User interface or web stuff waiting for review Pull requests that require a review before continuing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants