feat: genre mixes — a daily playlist per genre you listen to, on a "Your genres" Home row (#6904)
release / web (push) Successful in 1m24s
release / go (push) Successful in 1m47s
release / govulncheck (push) Successful in 25s
release / integration (push) Failing after 4m38s
release / android (push) Successful in 4m3s
release / Build signed APK (push) Successful in 4m34s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
release / web (push) Successful in 1m24s
release / go (push) Successful in 1m47s
release / govulncheck (push) Successful in 25s
release / integration (push) Failing after 4m38s
release / android (push) Successful in 4m3s
release / Build signed APK (push) Successful in 4m34s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped
A new system playlist kind, genre_mix: up to 10 "{Genre} mix" playlists per
user, rebuilt daily with the other system mixes.
Which genres: library genres with at least 25 playable tracks across 3
artists, ranked in tiers — taste-profile genres first (matched
case-insensitively, so ID3 "Post-Punk" and folksonomy "post-punk" are one),
then genres the user has played or liked, then the rest of the library, which
only tops a short shelf up to 4. A genre whose artist set is a near
duplicate of one already picked (Jaccard >= 0.5) is skipped, so "Lo-Fi" and
"Lo-Fi Hip Hop" don't both appear but "Alternative Rock" survives "Rock". A
genre that can't fill 15 tracks gives way to the next.
Each mix is 50 tracks: 3 in 5 the user already knows (played through or
liked), the rest unheard in that genre, interleaved, with the usual
per-album/per-artist caps. Tracks skipped twice and more often than played
are left out. The order changes daily and holds within a day. Picks are
stamped taste / taste_unheard, and genre_mix plays count toward rotation and
the recommendation metrics.
Migration 0102 adds genre_mix to the playlists variant constraints.
Web and Android each get a "Your genres" row in name order, hidden until a
mix exists. Kinds with several playlists per user now play by playlist id
wherever the client used to test seed_artist_id (web card, detail page
self-heal), keyed on the server's refreshable flag; on Android genre_mix
joins songs_like_artist as not refreshable. The web detail page's
"mix was rebuilt" reload now finds a Songs-like or genre mix by name instead
of calling the by-kind shuffle, which those kinds don't have.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -67,13 +67,12 @@
|
||||
try {
|
||||
const variant = playlist.system_variant;
|
||||
// systemShuffle keys by variant alone, which only works for
|
||||
// SINGLE-instance variants (for_you, discover, deep_cuts, …).
|
||||
// songs_like_artist has one playlist PER seed artist; using
|
||||
// the variant alone would return the wrong one (or fail).
|
||||
// For those, fall through to getPlaylist so the play handler
|
||||
// hits the exact playlist the user clicked on. Detect via
|
||||
// seed_artist_id which is non-null only for per-artist mixes.
|
||||
const isPerArtist = playlist.seed_artist_id != null;
|
||||
// SINGLE-instance variants (for_you, discover, deep_cuts, …) — the
|
||||
// ones the server reports as refreshable. A kind with several
|
||||
// playlists per user (songs_like_artist, genre_mix) would get the
|
||||
// wrong one, so those fall through to getPlaylist and play the exact
|
||||
// playlist the user clicked on.
|
||||
const isPerArtist = !playlist.refreshable;
|
||||
if (variant != null && !isPerArtist) {
|
||||
// Server returns the rotation-aware order (unplayed
|
||||
// this rotation first). Play it as-is — no client shuffle —
|
||||
|
||||
@@ -266,6 +266,7 @@ describe('PlaylistCard', () => {
|
||||
...base,
|
||||
kind: 'system',
|
||||
system_variant: 'for_you',
|
||||
refreshable: true,
|
||||
name: 'For You'
|
||||
};
|
||||
render(PlaylistCard, { props: { playlist: forYouPlaylist } });
|
||||
@@ -280,6 +281,34 @@ describe('PlaylistCard', () => {
|
||||
);
|
||||
});
|
||||
|
||||
test('genre-mix play fetches that playlist by id, tagged genre_mix', async () => {
|
||||
// Several genre mixes per user: the variant alone can't address one,
|
||||
// so the card plays the exact playlist it shows.
|
||||
const { getPlaylist, systemShuffle } = await import('#lib/api/playlists.js');
|
||||
const { playQueue } = await import('#lib/player/store.svelte.js');
|
||||
vi.mocked(getPlaylist).mockClear();
|
||||
vi.mocked(systemShuffle).mockClear();
|
||||
const jazzMix: Playlist = {
|
||||
...base,
|
||||
id: 'gm-jazz',
|
||||
kind: 'system',
|
||||
system_variant: 'genre_mix',
|
||||
refreshable: false,
|
||||
name: 'Jazz mix'
|
||||
};
|
||||
render(PlaylistCard, { props: { playlist: jazzMix } });
|
||||
await fireEvent.click(screen.getByLabelText(/Play Jazz mix/i));
|
||||
await new Promise(resolve => setTimeout(resolve, 10));
|
||||
|
||||
expect(getPlaylist).toHaveBeenCalledWith('gm-jazz');
|
||||
expect(systemShuffle).not.toHaveBeenCalled();
|
||||
expect(playQueue).toHaveBeenCalledWith(
|
||||
expect.any(Array),
|
||||
0,
|
||||
expect.objectContaining({ source: 'genre_mix' })
|
||||
);
|
||||
});
|
||||
|
||||
test('user-playlist play uses getPlaylist + plain playQueue (no source)', async () => {
|
||||
const { getPlaylist, systemShuffle } = await import('#lib/api/playlists.js');
|
||||
const { playQueue } = await import('#lib/player/store.svelte.js');
|
||||
|
||||
@@ -8,8 +8,8 @@ import { playlistTrackToRef } from './playlistTrackToRef';
|
||||
// current snapshot and resume.
|
||||
//
|
||||
// Single-instance variants (for_you, discover, deep_cuts, …) re-pull by
|
||||
// variant via the rotation-aware shuffle endpoint. Per-artist mixes
|
||||
// (songs_like_artist — one playlist per seed artist) can't be addressed by
|
||||
// variant via the rotation-aware shuffle endpoint. Kinds with several
|
||||
// playlists per user (songs_like_artist, genre_mix) can't be addressed by
|
||||
// variant alone, so they re-pull by playlist id. Mirrors the play routing
|
||||
// in PlaylistCard.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user