Repository navigation
feat(discord): allow album artist in status name - #1373
Conversation
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
| artists: artist, | ||
| artist_refs: track_artist_refs, | ||
| album: album_name, | ||
| album_artist: album_artist.clone().unwrap_or_default(), |
There was a problem hiding this comment.
Backfill track.album_artist for cached tracks restored from the index.
Rows written before this change deserialize with an empty track.album_artist, because Track uses a struct-level serde default. They are not reread, so the empty value persists until the file changes. Discord then shows "Music" for those tracks instead of the stored album credit.
Suggested fix
-
- let tagged = serde_json::from_str::<Tagged>(track).ok(); + let mut tagged = serde_json::from_str::<Tagged>(track).ok(); + if let Some(entry) = tagged.as_mut() { + if entry.track.album_artist.is_empty() { + entry.track.album_artist = entry.album_artist.clone().unwrap_or_default(); + } + }
Closes #1372.
Summary
The Discord status name dropdown (Settings, Discord, Status name) now has an Album artist option next to Artist. It names the status after whoever the playing track's album is credited to, and it changes with the track. Tracks now carry an album artist, filled in by the providers whose responses already name one. When it is missing, the status says "Music", the same as the other track options do.
Scope
In:
album_artistfield onmusic::Track, empty when the provider doesn't name oneOut:
playstable has fixed columns andstoragehas no migrations, so a track replayed from History has no album artist (see open questions).Which providers can fill it in:
displayAlbumArtist/albumArtists). Empty on a plain Subsonic server.Overlap
I searched open PRs for "discord", "rpc", "album artist" and "1372". The only Discord PR is #1349 (Navidrome artwork on the status). It edits
state/src/discord/mod.rsandviews/src/screens/settings/discord.rs, but it changes artwork, not the status name. Whichever lands second may need a small rebase inshown(). The "album artist" matches (#1358, #1280, #1134, #1249, #1275, #986, #1241, #1310, #1322, #1250) are unrelated provider or UI work. Nothing covers this issue.What I did
state/src/discord/mod.rs) and the setting (state/src/settings.rs,DiscordName). Also read the dropdown (views/src/screens/settings/discord.rs) and its preview (views/src/screens/settings/preview/{mod,discord}.rs), plus the Fluent keyssettings-discord-name-*.music/src/models.rsand found thatTrackhad no album artist. Then read each provider's track builder:local/wire.rs,subsonic/wire.rs(withopensubsonic0.7'sChild),spotify/collection.rs,spotify/pathfinder/album.rs,tidal/wire.rs,deezer/wire.rs,youtube/wire.rsandapple/wire.rs. Also read where tracks are stored:state/src/queue.rsandstate/src/history.rs, against thestorageschema.cargo test --workspace --locked: 444 passed, 0 failed, 17 ignored. My first try overlapped with my first edit, so I reverted the edit and ran the baseline again on a clean tree.Files changed:
crates/music/src/models.rs:Track::album_artistcrates/music/src/{local/wire.rs,subsonic/wire.rs,spotify/collection.rs,spotify/pathfinder/album.rs}: fill it incrates/music/src/{tidal,deezer,youtube,apple}/wire.rs: set it to empty, with a comment saying whycrates/music/src/local/client.rs: test helpercrates/music/src/local/{wire,index}.rs:Tagged::restoredcopies the stored album artist tag onto tracks the index saved before this changecrates/state/src/settings.rs:DiscordName::AlbumArtist(album-artist)crates/state/src/discord/mod.rs: status name moved intolistening(), plus testscrates/state/src/queue.rs:Stub::album_artistcrates/state/src/search.rs,crates/views/src/screens/search.rs:Hit::Song(Box<Track>). The biggerTracktripped clippy'slarge_enum_variant.crates/views/src/screens/settings/preview/{mod,discord}.rsassets/i18n/en-US/main.ftl:settings-discord-name-album-artist = Album artistCHANGELOG.mdDecisions
How it reaches the status. Each provider sets
Track::album_artistwhen it builds the track, from the response it already gets. Playback keeps thatTrack, the saved queue keeps a copy, andDiscord::shownreads it again on every playback change. So the status follows the track as it changes. The name now comes from one pure function,listening(name, track, provider), which is what the tests call.When it is missing. An empty album artist stays empty. It is never filled in from the track artists, so it can't disagree with what the provider reports. Discord needs a name, so an empty value falls back to "Music", as Title, Artist and Artist - Title already do. The details line, artist line, cover and timestamps of the status are unchanged. The settings preview falls back the same way.
No lookups of its own. Sonora doesn't fetch an album, or guess from the album name, to find an album artist. A provider that doesn't name one leaves it empty.
Dropdown accessibility. The new entry is one more
MenuItemin the existingPicker, so it getsRole::MenuItemlike every item there. Its id comes fromDiscordName::id(album-artist), and its name comes from Fluent, resolved in render. Nothing new was added to the UI, soa11y_tree.rsdoesn't change.Testing
New tests:
state::discord::tests::the_album_artist_names_the_status: Album artist gives the album artist, not the track artistsstate::discord::tests::a_missing_album_artist_says_music_rather_than_the_track_artists: a blank album artist gives "Music", not the track artiststate::discord::tests::the_track_artists_still_name_the_status: Artist and Artist - Title are unchangedmusic::subsonic::wire::tests::an_opensubsonic_song_names_its_album_artist: fromdisplayAlbumArtist, fromalbumArtists, and fromalbumArtistswhendisplayAlbumArtistis blankmusic::subsonic::wire::tests::a_plain_subsonic_song_leaves_the_album_artist_emptymusic::local::wire::tests::a_row_stored_before_the_track_named_its_album_artist_names_it_once_restored: a local file indexed before this change gets its album artist from the stored tag, without a rescanResults (Windows, MSVC):
cargo test --workspace --locked: 450 passed, 0 failed, 17 ignored (baseline 444 / 0 / 17)cargo fmt --check: cleancargo check --workspace: cleancargo clippy --workspace --all-targets: clean, after boxingHit::SongNot verified
TRACK_V4extended metadata lists its artists, as the protobuf allows. If it doesn't, Spotify tracks loaded that way would show "Music". Tracks from the album page use the album header's artists either way.Open questions for maintainers
playsworth it?storagehas no migrations yet, so it would need the first one.Hit::Songis now boxed to keep clippy clean asTrackgrows. Fine, or would you rather box elsewhere?DiscordNamevalue has the same effect, and nothing in this PR can change how an older release loads settings. Do you want a separate change that makes the settings loader tolerate unknown values option by option, so future releases downgrade safely?