feat: Your genres leads with the genres you play most, not A to Z
release / web (push) Successful in 1m8s
release / go (push) Successful in 1m40s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 3m43s
release / android (push) Successful in 4m21s
release / Build signed APK (push) Successful in 4m55s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 22s
release / Verify release artifacts (tag releases only) (push) Skipped

The genre mix builder already ranks genres by how much you listen to
them (taste profile, then plays and likes, then library size), but the
rank was lost when the mixes were stored and both apps sorted the shelf
by name. Each playlist now has a shelf_rank (migration 0107), which the
genre builder fills 1..n in that listening order, even where it picked a
narrower genre before a broader one. The list and detail endpoints carry
it, and the web and Android Home sort the genre shelf by it, unranked
playlists after by name. Android's playlist cache gains the column
(Room v14).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-24 18:10:08 -05:00
co-authored by Claude Opus 5.5
parent 7cc14da1a7
commit 104f9fd141
25 changed files with 220 additions and 41 deletions
+4
View File
@@ -80,6 +80,10 @@ export type Playlist = {
// /api/albums/{id}/cover. Absent when the playlist has none. A home shelf
// gives each tile an album no earlier tile shows (lib/playlists/shelf.ts).
cover_album_ids?: string[];
// A system mix's place on its home shelf, 1 first: genre mixes are
// numbered by how much the user listens to each genre. Absent for
// playlists the client orders itself (lib/playlists/shelf.ts byShelfRank).
shelf_rank?: number;
track_count: number;
duration_sec: number;
created_at: string;
+28 -1
View File
@@ -1,6 +1,14 @@
import { describe, expect, test } from 'vitest';
import type { Playlist } from '#lib/api/types.js';
import { assignShelfCovers, refreshedLabel, shelfMeta, shelfTileWidth, songsLikeArtist, washTone } from './shelf.js';
import {
assignShelfCovers,
byShelfRank,
refreshedLabel,
shelfMeta,
shelfTileWidth,
songsLikeArtist,
washTone
} from './shelf.js';
function pl(over: Partial<Playlist>): Playlist {
return {
@@ -149,3 +157,22 @@ describe('shelfTileWidth', () => {
expect(shelfTileWidth(100, 5, 150, 16)).toBe(150);
});
});
describe('byShelfRank', () => {
test('ranked mixes lead in rank order, the unranked follow by name', () => {
const shelf = [
pl({ name: 'Ambient mix', shelf_rank: 3 }),
pl({ name: 'Zydeco mix' }),
pl({ name: 'Pop mix', shelf_rank: 1 }),
pl({ name: 'Blues mix' }),
pl({ name: 'Jazz mix', shelf_rank: 2 })
];
expect([...shelf].sort(byShelfRank).map((p) => p.name)).toEqual([
'Pop mix',
'Jazz mix',
'Ambient mix',
'Blues mix',
'Zydeco mix'
]);
});
});
+9
View File
@@ -66,6 +66,15 @@ export function shelfMeta(playlists: Playlist[], now: Date = new Date()): string
return line.charAt(0).toUpperCase() + line.slice(1);
}
// Orders a shelf by the rank the server gave each mix (1 first; genre mixes
// lead with the genres the user listens to most). Unranked playlists follow
// in name order, as do ranked ones should two share a rank.
export function byShelfRank(a: Playlist, b: Playlist): number {
const ra = a.shelf_rank || Number.MAX_SAFE_INTEGER;
const rb = b.shelf_rank || Number.MAX_SAFE_INTEGER;
return ra - rb || a.name.localeCompare(b.name);
}
// "Songs like Low Tide Choir" → "Low Tide Choir": a Songs like tile labels
// the artist under its circle, so the prefix would only repeat the shelf.
export function songsLikeArtist(p: Playlist): string {
+3 -3
View File
@@ -12,7 +12,7 @@
import { createPlaylistsQuery } from '#lib/api/playlists.js';
import { createSystemPlaylistsStatusQuery } from '#lib/api/me.js';
import type { Playlist } from '#lib/api/types.js';
import { assignShelfCovers, shelfMeta } from '#lib/playlists/shelf.js';
import { assignShelfCovers, byShelfRank, shelfMeta } from '#lib/playlists/shelf.js';
const queryStore = createHomeQuery();
const query = $derived($queryStore);
@@ -52,12 +52,12 @@
);
// Genre mixes: one "{Genre} mix" per genre the user listens to, on their
// own row in name order so the shelf reads like a stable channel list.
// own row, the genres listened to most first (the server's shelf_rank).
// Mirrors Android's buildGenreMixRow (HomeScreen.kt).
const genreMixPlaylists = $derived(
(systemPlaylistsQ.data?.owned ?? [])
.filter((p) => p.system_variant === 'genre_mix')
.sort((a, b) => a.name.localeCompare(b.name))
.sort(byShelfRank)
);
// Secondary system kinds the server generates that don't get pinned