Skip to content

impr(settings): re-trigger sound previews on re-click (@fehmer) - #8577

Merged
Miodec merged 2 commits into
masterfrom
sound-preview-retrigger
Nov 13, 2026
Merged

Miodec merged 2 commits into
masterfrom
sound-preview-retrigger

Conversation

@fehmer

@fehmer fehmer commented Nov 13, 2026

Copy link
Copy Markdown
Member

Solves discussion #8576: in the settings sound section, clicking an already-selected sound option did nothing, so a sound could only be heard once while deciding on it.

Summary

The option button handler early-returned for the selected option, which also skipped the preview callback. Now the preview always runs; only the config write is guarded.

 <Button active={config[key] === option}
   onClick={() => {
-    if (config[key] === option) return;
-    onOptionClick?.(option);   // preview
-    setConfig(key, option);
+    const selected = config[key] === option;
+    onOptionClick?.(option);   // always, so sounds can be re-triggered
+    if (!selected) setConfig(key, option);  // no redundant save on re-click
   }}

Polish in sound-controller.ts: previewClick and previewError now stop() before seek(0) + play() (same pattern as playTimeWarning), so rapid re-clicks restart the sample cleanly instead of layering.

Evidence

Browser verification on the dev server with AudioContext node counters (real clicks, fresh load; the running module source was confirmed to contain the change):

  • Before: re-clicking the selected option spawned no audio node (silence)
  • After: every click spawns a new source/oscillator node; the config value never changes on re-clicks
click option audio nodes config
1 beep (sample) +1 buffer source off → "2"
2, re-click beep +1 buffer source stays "2"
3, re-click beep +1 buffer source stays "2"
1 sine (oscillator) +1 oscillator → "8"
2, re-click sine +1 oscillator stays "8"
1 pentatonic (scale) +1 oscillator → "12"
2, re-click pentatonic +1 oscillator stays "12"
1 damage (error) +1 buffer source off → "1"
2, re-click damage +1 buffer source stays "1"

No console errors, no saved-indicator flash or notifications on re-clicks. pnpm vitest run __tests__/controllers/sound-controller.spec.ts → 4/4 passing; oxfmt + oxlint (--type-aware --type-check) clean.

Merge Danger

Door: two-way — small client-side preview tweak, trivially revertible.

Blast Radius: sound previews (settings buttons and the commandline play actions, which share previewClick/previewError). No effect on in-test click/error sounds or on config persistence.

@monkeytypegeorge monkeytypegeorge added the frontend User interface or web stuff label Nov 13, 2026
@fehmer fehmer changed the title impr: re-trigger sound previews on re-click in settings (@fehmer) impr(settings): re-trigger sound previews on re-click (@fehmer) Nov 13, 2026
@Miodec
Miodec merged commit f9a0cf7 into master Nov 13, 2026
14 checks passed
@Miodec
Miodec deleted the sound-preview-retrigger branch November 13, 2026 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend User interface or web stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants