fix(metrics): web and Android tag plays with one source vocabulary, so a surface reads the same on either (#8075)

The recommendation metrics judge each surface against a baseline of manual
plays. The web tagged only system mixes, so its radio, album, artist and
history plays all sat in the baseline; Android tagged nearly everything, and
its search, Liked-list, library-shuffle and artist-top plays fell to Other.
The surface deltas depended on which client someone listened on.

- The web sends the vocabulary Android uses: radio:<seed>, album:<id>,
  artist:<id>, artist-top:<id>, home:most_played and history, kept in
  web/src/lib/player/playSource.ts.
- The baseline is now named in one place (isManualSource): no source, a
  search pick, or a Liked-list pick.
- library_shuffle gets its own row, the random baseline the mixes exist to
  beat; artist-top counts as an artist play.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 00:08:37 -05:00
co-authored by Claude Opus 5.5
parent 0c9faeca9f
commit 5939248bef
18 changed files with 111 additions and 28 deletions
+2
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import { playSource } from '#lib/player/playSource.js';
import { pageTitle } from '#lib/branding.js';
import { createHomeQuery } from '#lib/api/home.js';
import HorizontalScrollRow from '#lib/components/HorizontalScrollRow.svelte';
@@ -380,6 +381,7 @@
{track}
sectionTracks={data.most_played_tracks}
index={globalIdx}
source={playSource.home('most_played')}
/>
{/snippet}
</HorizontalScrollRow>
+4 -3
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import { playSource } from '#lib/player/playSource.js';
import { plural } from '#lib/utils/plural.js';
import PageColumn from '#lib/components/PageColumn.svelte';
import { page } from '$app/state';
@@ -37,7 +38,7 @@
if (isStartingPlay || !data || data.tracks.length === 0) return;
isStartingPlay = true;
try {
playQueue(data.tracks, 0);
playQueue(data.tracks, 0, { source: playSource.album(id) });
} finally {
isStartingPlay = false;
}
@@ -48,7 +49,7 @@
if (isStartingPlay || !data || data.tracks.length === 0) return;
isStartingPlay = true;
try {
playQueue(shuffled(data.tracks), 0);
playQueue(shuffled(data.tracks), 0, { source: playSource.album(id) });
} finally {
isStartingPlay = false;
}
@@ -168,7 +169,7 @@
{:else}
<TrackList>
{#each album.tracks as track, i (track.id)}
<TrackRow tracks={album.tracks} index={i} showAlbum={false} />
<TrackRow tracks={album.tracks} index={i} showAlbum={false} source={playSource.album(id)} />
{/each}
</TrackList>
{/if}
+3 -2
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import { playSource } from '#lib/player/playSource.js';
import { plural } from '#lib/utils/plural.js';
import PlayActions from '#lib/components/PlayActions.svelte';
import { shuffled } from '#lib/utils/shuffle.js';
@@ -50,7 +51,7 @@
try {
const tracks = await api.get<TrackRef[]>(`/api/artists/${id}/tracks`);
if (tracks.length === 0) return;
playQueue(order(tracks), 0);
playQueue(order(tracks), 0, { source: playSource.artist(id) });
} finally {
isStartingPlay = false;
}
@@ -134,7 +135,7 @@
<section class="space-y-3">
<HorizontalScrollRow rows={[top]} title="Top tracks" ariaLabel={`Top tracks for ${detail.name}`}>
{#snippet item(track: TrackRef, globalIdx: number)}
<CompactTrackCard {track} sectionTracks={top} index={globalIdx} />
<CompactTrackCard {track} sectionTracks={top} index={globalIdx} source={playSource.artistTop(id)} />
{/snippet}
</HorizontalScrollRow>
</section>
+1 -1
View File
@@ -162,7 +162,7 @@ describe('artist detail page', () => {
(api.get as ReturnType<typeof vi.fn>).mockResolvedValue(tracks);
render(ArtistPage);
await fireEvent.click(screen.getByRole('button', { name: 'Play Alice' }));
await waitFor(() => expect(playQueue).toHaveBeenCalledWith(tracks, 0));
await waitFor(() => expect(playQueue).toHaveBeenCalledWith(tracks, 0, { source: 'artist:abc' }));
});
test('Shuffle queues every track', async () => {
+2 -1
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import { playSource } from '#lib/player/playSource.js';
import PageColumn from '#lib/components/PageColumn.svelte';
import { pageTitle } from '#lib/branding.js';
import {
@@ -157,7 +158,7 @@
{:else}
<TrackList>
{#each fTracks as t, i (t.id)}
<TrackRow tracks={fTracks} index={i} />
<TrackRow tracks={fTracks} index={i} source={playSource.liked} />
{/each}
</TrackList>
<ListContinuation