feat(settings): MusicBrainz opt-out + gate MB-dependent sections

MusicBrainz was hardcoded ON in the core client with no toggle, no
persistence and no startup wiring, so it could never be turned off. Add a
persisted opt-out (default ON: ui_prefs.musicbrainz_enabled +
Settings>Integrations toggle) that seeds the core client at startup and
flips it live via handle_bool.

Gate the MB-dependent surfaces when off: the artist Network/Scene sidebar
marks itself unavailable and opens on the MB-independent Magazine tab;
the playlist "Suggest songs" CTA hides and activate() early-outs; and the
musician page tolerates a disabled/failed MB resolve, falling through to
the Qobuz fallback instead of rendering blank.

cc
This commit is contained in:
vicrodh committed 2026-06-27 14:11:25 -06:00
1 parent bf4ffbd601
commit 270850e352
10 files changed
+107 -12

No files matched your search

+14 -5
View File
@@ -2571,11 +2571,20 @@ impl<A: FrontendAdapter + Send + Sync + 'static> QbzCore<A> {
name: &str,
role: &str,
) -> Result<ResolvedMusician, CoreError> {
let resolved_artist = self
.musicbrainz
.resolve_artist(name)
.await
.map_err(|e| CoreError::Internal(e.to_string()))?;
// MusicBrainz opt-out / unavailable: a disabled or failed resolve is NOT
// fatal here — fall through to the Qobuz exact-name / appears-on fallback
// below so the musician page still degrades cleanly when MB is off. (Was
// `?`, which propagated the disabled-client Err before the Qobuz fallback
// and left the musician page blank/stuck when MB is disabled.)
let resolved_artist = match self.musicbrainz.resolve_artist(name).await {
Ok(found) => found,
Err(e) => {
log::debug!(
"musicbrainz_resolve_musician: MB resolve unavailable for {name:?}: {e}"
);
None
}
};
let normalized_target = name.trim().to_lowercase();
let artist_results = self.search_artists(name, 10, 0, None).await?;
+3 -2
View File
@@ -6,7 +6,7 @@
import { Theme } from "../foundation/semantic-colors.slint";
import { Typography } from "../foundation/typography.slint";
import { Radius } from "../foundation/radius.slint";
import { PlaylistState, PlaylistActions, DragState, NavState, OfflineState, BulkAction } from "../state.slint";
import { PlaylistState, PlaylistActions, DragState, NavState, OfflineState, BulkAction, SettingsState } from "../state.slint";
import { PlaylistSuggestionsState, PlaylistSuggestionsActions, PlaylistSuggestionRow, TooltipState } from "../state.slint";
import { QbzIcon } from "../primitives/QbzIcon.slint";
import { CircleAction } from "../primitives/CircleAction.slint";
@@ -680,7 +680,8 @@ export component PlaylistView inherits Rectangle {
// auto-computes — large playlists shouldn't pay for it).
if PlaylistState.is-owner && !PlaylistState.is-local
&& PlaylistState.track-count > 0
&& PlaylistState.track-count < 2000: VerticalLayout {
&& PlaylistState.track-count < 2000
&& SettingsState.musicbrainz-enabled: VerticalLayout {
horizontal-stretch: 0;
alignment: center;
CircleAction {
@@ -86,6 +86,25 @@ export component IntegrationsSettings inherits VerticalLayout {
}
}
// ===================================================================
// METADATA — MusicBrainz opt-out (default on). Enriches artist pages
// (relationships, origin/scene) and playlist song suggestions. No telemetry.
// ===================================================================
Rectangle { height: 12px; }
GroupHeader { text: @tr("METADATA"); }
Rectangle { height: 4px; }
SettingRow {
label: @tr("MusicBrainz");
description: @tr("Enable artist relationships and enhanced metadata from MusicBrainz. No telemetry — it only matches releases to enrich artist pages and playlist song suggestions. Turn off to disable those sections.");
QbzToggle {
checked: SettingsState.musicbrainz-enabled;
toggled(v) => {
SettingsState.musicbrainz-enabled = v;
root.settings-bool("musicbrainz", v);
}
}
}
// ===================================================================
// SCROBBLERS — master header: title + master toggle + collapse chevron.
// Body renders only when `enabled && !ui-collapsed`.
+5
View File
@@ -2723,6 +2723,11 @@ export global SettingsState {
// Discover — opt-out: show the external "Recommendations" tab. Default on.
// Seeded from persisted discover prefs at session start (crate::discover_prefs).
in-out property <bool> show-recommendations: true;
// MusicBrainz metadata — opt-out (default on). Drives the core client's
// enabled flag, the artist Network/Scene sidebar (mb-available), and the
// playlist Suggested-Songs CTA. Seeded from ui_prefs at session start
// (crate::discover_prefs::seed); persisted via the "musicbrainz" key.
in-out property <bool> musicbrainz-enabled: true;
in-out property <bool> streaming-only: false;
// Volume normalization (loudness leveling). Applied in the shared player
// and bypassed automatically when bit-perfect is active. Surfaced in the
+11 -4
View File
@@ -20,7 +20,7 @@ use crate::home::CardData;
use crate::{
AlbumCardItem, TrackItem, AppWindow, ArtistReleaseSection, ArtistState, DiscoveryArtist,
JumpNavTab, LabelEntry, MbOriginData, MbRelationship, MbRelationshipsData,
NetworkSidebarState, ShellState, SimilarEntry, StoryItem,
NetworkSidebarState, SettingsState, ShellState, SimilarEntry, StoryItem,
};
/// Plain, `Send` artist data produced on the worker thread.
@@ -1195,11 +1195,18 @@ pub fn reset_network_sidebar(window: &AppWindow) {
// (the same signal AlbumView + the ArtistPageView `net-cramped`
// handlers use). Constrained => keep collapsed.
let constrained = window.global::<ShellState>().get_content_constrained();
// MusicBrainz opt-out: when MB is off the Network tab (relationships /
// discovery / origin) has nothing to show, so mark it unavailable and open
// on the MB-independent Magazine/Stories tab instead of an empty Network
// tab. The internal core guards (load_mb_metadata, musicbrainz_*) stay as
// belt-and-suspenders.
let mb_on = window.global::<SettingsState>().get_musicbrainz_enabled();
let state = window.global::<NetworkSidebarState>();
state.set_open(!constrained);
// Always (re)open a new artist on the Network tab.
state.set_active_tab("network".into());
state.set_mb_available(true);
// (Re)open a new artist on the Network tab when MB is on, else Magazine.
let default_tab = if mb_on { "network" } else { "magazine" };
state.set_active_tab(default_tab.into());
state.set_mb_available(mb_on);
state.set_mb_mbid("".into());
state.set_origin_loading(false);
state.set_origin(MbOriginData::default());
+6
View File
@@ -235,6 +235,12 @@ pub fn seed(window: &AppWindow) {
window
.global::<SettingsState>()
.set_show_recommendations(prefs.show_recommendations);
// MusicBrainz opt-out lives in ui_prefs (not the discover prefs store).
// Seed it here so both SettingsState seed sites (main.rs:320/554) populate
// the toggle that gates the artist sidebar + playlist suggestions.
window
.global::<SettingsState>()
.set_musicbrainz_enabled(crate::ui_prefs::load().musicbrainz_enabled);
push_descriptors(window, &prefs);
}
+12
View File
@@ -5439,6 +5439,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}
}
// MusicBrainz opt-out seed — drive the core client's enabled flag from the
// persisted UI pref (default ON). Without this the client stays hardcoded ON
// and the Settings toggle can't turn it off. main() is sync, so spawn on the
// runtime; this runs before the first artist / playlist-suggestions load.
{
let runtime = app_runtime.clone();
tokio_rt.spawn(async move {
let mb_on = crate::ui_prefs::load().musicbrainz_enabled;
runtime.core().musicbrainz_set_enabled(mb_on).await;
});
}
// Shared QBZ image cache for album artwork; trim it on startup.
let image_cache = artwork::open_cache();
artwork::spawn_evict(image_cache.clone());
+15 -1
View File
@@ -27,7 +27,7 @@ use slint::{ComponentHandle, Model, ModelRc, VecModel};
use crate::adapter::SlintAdapter;
use crate::artwork::{ArtworkJob, ArtworkTarget};
use crate::{AppWindow, PlaylistSuggestionRow, PlaylistSuggestionsState, PlaylistState};
use crate::{AppWindow, PlaylistSuggestionRow, PlaylistSuggestionsState, PlaylistState, SettingsState};
type Runtime = std::sync::Arc<AppRuntime<SlintAdapter>>;
type Handle = tokio::runtime::Handle;
@@ -431,6 +431,20 @@ fn maybe_auto_expand(runtime: Runtime, weak: Weak, handle: Handle) {
/// Launch suggestions for the open playlist: gather the seed artists + excludes
/// off the loaded Qobuz tracks, then fetch the first pool page. UI thread.
pub fn activate(window: &AppWindow, runtime: Runtime, handle: Handle) {
// MusicBrainz opt-out: the suggestion engine resolves each seed artist via
// MusicBrainz, so with MB off it can only ever return an empty pool. Skip the
// fetch entirely and present the closed/empty state. The wand CTA is also
// hidden in PlaylistView.slint when MB is off, so this is belt-and-suspenders.
if !window.global::<SettingsState>().get_musicbrainz_enabled() {
let state = window.global::<PlaylistSuggestionsState>();
state.set_activated(false);
state.set_loading(false);
state.set_loading_more(false);
state.set_is_empty(true);
state.set_rows(ModelRc::new(VecModel::from(Vec::<PlaylistSuggestionRow>::new())));
return;
}
let playlist_id = window
.global::<PlaylistState>()
.get_id()
+11
View File
@@ -871,6 +871,17 @@ pub async fn handle_bool(
crate::discover_prefs::set_show_recommendations(value);
Ok(Apply::None)
}
"musicbrainz" => {
// Opt-out toggle (default ON). Persist to ui_prefs (Option B,
// mirrors system_notifications) and drive the core client's
// in-memory enabled flag so the artist Network/Scene sidebar and
// playlist Suggested-Songs gate immediately.
let mut prefs = crate::ui_prefs::load();
prefs.musicbrainz_enabled = value;
crate::ui_prefs::save(&prefs);
runtime.core().musicbrainz_set_enabled(value).await;
Ok(Apply::None)
}
"persist-session" => {
let r = with_playback(&ctx.playback, |s| s.set_persist_session(value))
.map(|_| Apply::None);
+11
View File
@@ -119,6 +119,10 @@ fn default_system_notifications() -> bool {
true
}
fn default_musicbrainz_enabled() -> bool {
true
}
fn default_nav_in_sidebar() -> bool {
true
}
@@ -240,6 +244,12 @@ pub struct UiPrefs {
/// Default ON (the notify backend ships default-on; this is the user gate).
#[serde(default = "default_system_notifications")]
pub system_notifications: bool,
/// Whether MusicBrainz metadata enrichment is enabled (opt-out, default ON).
/// Drives the core client's enabled flag at startup and gates the artist
/// Network/Scene sidebar + playlist Suggested-Songs. Serde-default means an
/// older prefs file without the field deserializes to ON (zero migration).
#[serde(default = "default_musicbrainz_enabled")]
pub musicbrainz_enabled: bool,
/// Discord Rich Presence "now listening" opt-in. Default OFF — external
/// integrations are opt-in. (Tauri scoped this per Qobuz user; here it is a
/// per-machine app preference — your Discord client is per-machine.)
@@ -441,6 +451,7 @@ impl Default for UiPrefs {
album_header_gradient: default_album_header_gradient(),
intelligent_search: default_intelligent_search(),
system_notifications: default_system_notifications(),
musicbrainz_enabled: default_musicbrainz_enabled(),
discord_rpc_enabled: false,
show_purchases: false,
nav_tb_purchases: false,