Skip to content

Add show_confirmation_toasts option to silence routine confirmations - #55

Closed
tocDK wants to merge 1 commit into
r11a:mainfrom
tocDK:feat/disable-confirmation-toasts
Closed

Add show_confirmation_toasts option to silence routine confirmations#55
tocDK wants to merge 1 commit into
r11a:mainfrom
tocDK:feat/disable-confirmation-toasts

Conversation

@tocDK

@tocDK tocDK commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Refs #54

This is a suggestion, not a fix

The original issue asks for an "off switch" for the routine confirmation toasts that cover other UI controls (the screenshot shows "Player Selected" eating the volume slider). This PR adds that off switch
as an opt-in setting exposed in YAML, the visual editor, and the in-card Settings panel. Default keeps existing behavior. Happy to drop / rename / re-scope on review.

What the option does

  • New optional boolean: show_confirmation_toasts (default true, matches existing behavior).
  • When set to false, the central _toast() method short-circuits any info or success variant. Error toasts always render regardless, so genuine failures stay visible.
  • Implemented as a small gate at the top of _toast() in src/core/base-music-card.js — all existing call sites (~60 across the codebase) inherit the behavior with no churn.

Three surfaces, one effect

  • YAML / visual editor (config): show_confirmation_toasts: false
  • In-card Settings panel (Display section): an Enabled / Disabled pill the user can flip without editing YAML. Persisted per browser in localStorage as homeii_music_flow_mobile_show_confirmation_toasts.

The in-card toggle takes precedence over the YAML default once the user has touched it: a concrete state value wins; undefined falls back to config. Matches the pattern users expect — install with a
default, opt out from the card itself if it gets in the way.

Naming choice

Considered disable_confirmation_toasts: true (negative-sense, default false) but landed on show_confirmation_toasts: false (positive-sense, default true) so the option matches the existing
convention in the schema where every other boolean reads positively (show_ma_button, ambient_light_enabled, mobile_show_up_next, hotel_mode).

Wiring

  • src/config/validators.js: assertBooleanIfDefined for the new field.
  • src/config/editor-forms.js: visual-editor field in both base and mobile card forms, alongside hotel_mode, with label + helper text in the labels/helpers maps.
  • src/homeii-music-flow.js: state init, localStorage hydration, _showConfirmationToasts() helper (state-then-config precedence), pill HTML in the Display section of _settingsMenuHtml, click handler
    appended to _handleMobileMenuClick, persist line in _persistMobileAppearance.
  • src/core/base-music-card.js: small gate at the top of _toast() that checks state, falls back to config, and early-returns for non-error variants. Includes a comment explaining why the precedence logic
    is inlined here rather than delegating to the subclass helper (base class can't reach subclass methods; the two locations must change together).
  • src/localization/*.js: two new i18n keys (ui.show_confirmation_toasts, ui.show_confirmation_toasts_helper) in all 8 bundled locales. English and Danish are native; es, fr, he, it, lt, zh
    are DeepL with the recurring "player" → "media player" hand-correction (DeepL defaults to "sports player").
  • tests/config-validation.test.js: new option added to the valid-fixture; a rejects-invalid test (show_confirmation_toasts: "yes" → boolean error) mirrors the hotel_mode pattern.

What is NOT in this PR

  • No per-category granularity. It's a single binary on the assumption that users who want it off want it all off. Easy to refactor into a list if you'd prefer.
  • pointer-events: none on the .toast element itself, which would also fix the volume-slider blocking the original issue describes — without removing the toasts. Left out to keep this PR focused on the
    explicit "off switch" the issue asks for. Happy to add as a separate change.
  • Toast position / placement changes the issue author also mentioned as an alternative.
  • No migration logic. This patch has never been merged or published, so no users exist with stale config or localStorage keys to migrate from.

Validation

  • npm run check — 134/134 tests pass.
  • npm run build — clean.
  • Manual on a dev HA: with the option enabled (default), all three toast variants render normally; with the option disabled (via the in-card Settings pill), info + success are suppressed and only error
    toasts render; localStorage persists the choice across page reloads; the state override correctly takes precedence over the YAML default when the two disagree.

Out of scope

  • No visual changes to the toast itself.
  • No rush on merge — happy to queue behind beta hotfix work or rework on review.

Adds a new opt-in setting that, when disabled, suppresses info + success
toast variants — the routine confirmation messages like "Player Selected"
or "Added to liked" that briefly cover other UI controls (volume slider,
transport buttons). Error toasts always show regardless, so genuine
failures stay visible.

The setting is exposed in three places that all share the same effect:

- YAML / visual editor (config): show_confirmation_toasts: true|false
  (default true — existing behavior preserved)
- In-card Settings panel (Display section): an Enabled / Disabled pill
  the user can flip without editing YAML. Persisted per browser in
  localStorage as homeii_music_flow_mobile_show_confirmation_toasts.

The in-card toggle takes precedence over the YAML default once the user
has touched it (any concrete state value wins; undefined falls back to
config). Matches the pattern users expect: install with a default, opt
out from the card itself if it gets in the way.

Wiring:

- src/core/base-music-card.js: small gate at the top of _toast() that
  checks state, falls back to config, and early-returns for non-error
  variants when the effective decision is "do not show". A comment
  explains why the precedence is inlined rather than calling the
  subclass helper.
- src/config/validators.js: assertBooleanIfDefined for the new field.
- src/config/editor-forms.js: visual editor field in both base and
  mobile card forms, alongside hotel_mode.
- src/homeii-music-flow.js: state init, localStorage hydrate, helper
  _showConfirmationToasts(), pill HTML in the Display section of
  _settingsMenuHtml, click handler in _handleMobileMenuClick, and the
  persist line in _persistMobileAppearance.
- src/localization/*.js: ui.show_confirmation_toasts and
  ui.show_confirmation_toasts_helper added to all 8 bundled locales.
  English and Danish are native; the other 6 (es, fr, he, it, lt, zh)
  are DeepL with "player" hand-corrected away from sports-player.
- tests/config-validation.test.js: new option added to the valid-fixture
  and a rejects-invalid test mirroring the hotel_mode pattern.

Default behavior is unchanged. Existing users see no difference until
they explicitly disable the option.

Validated end-to-end on a dev HA: with the option enabled (default),
all three toast variants render normally; with it disabled (via the
Settings pill), info and success are suppressed and only error toasts
render; the localStorage value survives a page reload and overrides the
config default if the two disagree. Full vitest suite (134/134) passes,
lint passes, vite build clean.

Refs r11a#54
@r11a

r11a commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Thank you for this PR. The issue behind it is handled differently in 5.9.0: the player-selected confirmation toast was moved so it no longer covers the volume slider.

For now I’m not adding a new global toast-disable setting, because I want to avoid adding another option unless users still need it after the 5.9.0 change.

I’m closing this one without merging, but if the new behavior is still not enough, we can revisit this idea later.

@r11a r11a closed this Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants