diff --git a/README.md b/README.md
index 41489d7..e25b491 100644
--- a/README.md
+++ b/README.md
@@ -342,7 +342,7 @@ npm install
SONDA_URL=http://127.0.0.1:8080 npm run dev # open http://localhost:5173, /api is proxied to Sonda
```
-What it does today: sign in (and create the first account of a new server), browse artists, albums and songs, search, and play with a queue, shuffle, repeat, media keys, a volume slider with mute (remembered in the browser) and a full-screen player. Artist pages show the Wikipedia text, similar artists and tags when those providers are on, each with its credit, and the photo credit next to the photo. It reports one listen per play. Playlists have a page of their own: make one, put a song in it with the button next to any song (or make a new playlist right there), play it, rename it, delete it, move a song up or down and take one out; a song whose files are gone is shown as not available and skipped when the playlist plays. Discover suggests artists from the ones you pick, or from your listening only after you allow it (a dialog says that their names go to Last.fm), explains each score, and keeps your wishlist and the artists you are not interested in. An admin who set up the `lidarr` provider gets a "Request on Lidarr" button on an artist's page and on the Discover cards: it asks first, then sends that one artist to their own Lidarr, which does the downloading (the web app downloads nothing; the page of an artist reads what Lidarr has, the cards ask nothing until you send). An admin also gets an Admin area to add, rename, move and remove libraries and to start a scan (of one library or all, optionally reading every file again) and follow it, and to manage accounts: add one by email, give or take away the admin role, reset a password (which ends that person's sessions) and delete an account. The last admin cannot be changed, and your own account has no buttons there. Providers have a card each that says what the provider is sent: turning one on asks first, the API key is write-only (never shown, and gone from the page once saved), and there are a test of the key, the contact or address, removing what a provider gave, and, for Lidarr, the profiles and root folder to use when an artist is added. The bulk jobs (album covers, artist pictures, artist descriptions) each have a card that says what the job sends and to whom: starting one asks first and says it goes through the whole library, reading everything again is a separate choice, a job whose providers are off cannot be started, and the page follows its progress and can stop it. There are six themes (Sonda, Tokyo Night, Gruvbox dark, Gruvbox light, Dracula and Neon) and two languages (English and Italian), both chosen in Settings.
+What it does today: sign in (and create the first account of a new server), browse artists, albums and songs, search, and play with a queue, shuffle, repeat, media keys, a volume slider with mute (remembered in the browser) and a full-screen player. Artist pages show the Wikipedia text, similar artists and tags when those providers are on, each with its credit, and the photo credit next to the photo. It reports one listen per play. Playlists have a page of their own: make one, put a song in it with the button next to any song (or make a new playlist right there), play it, rename it, delete it, move a song up or down and take one out; a song whose files are gone is shown as not available and skipped when the playlist plays. Mixes have a page too: a card for each mix (the ones from your listening first, then one for each genre), and on a mix its songs, Play, Shuffle again (another set of songs) and Save as playlist, which keeps what you see as a playlist of your own. Discover suggests artists from the ones you pick, or from your listening only after you allow it (a dialog says that their names go to Last.fm), explains each score, and keeps your wishlist and the artists you are not interested in. An admin who set up the `lidarr` provider gets a "Request on Lidarr" button on an artist's page and on the Discover cards: it asks first, then sends that one artist to their own Lidarr, which does the downloading (the web app downloads nothing; the page of an artist reads what Lidarr has, the cards ask nothing until you send). An admin also gets an Admin area to add, rename, move and remove libraries and to start a scan (of one library or all, optionally reading every file again) and follow it, and to manage accounts: add one by email, give or take away the admin role, reset a password (which ends that person's sessions) and delete an account. The last admin cannot be changed, and your own account has no buttons there. Providers have a card each that says what the provider is sent: turning one on asks first, the API key is write-only (never shown, and gone from the page once saved), and there are a test of the key, the contact or address, removing what a provider gave, and, for Lidarr, the profiles and root folder to use when an artist is added. The bulk jobs (album covers, artist pictures, artist descriptions) each have a card that says what the job sends and to whom: starting one asks first and says it goes through the whole library, reading everything again is a separate choice, a job whose providers are off cannot be started, and the page follows its progress and can stop it. There are six themes (Sonda, Tokyo Night, Gruvbox dark, Gruvbox light, Dracula and Neon) and two languages (English and Italian), both chosen in Settings.
More commands, all run in `web/`: `npm test`, `npm run build`, and `npm run gen:api`, which rebuilds `src/api/schema.d.ts` from the OpenAPI spec (it fetches the generator with `npx`, so it needs the network once). `npm run build` writes to `internal/webui/dist` (git-ignored), not to `web/dist`.
diff --git a/web/src/api/mixes.ts b/web/src/api/mixes.ts
new file mode 100644
index 0000000..74a7588
--- /dev/null
+++ b/web/src/api/mixes.ts
@@ -0,0 +1,36 @@
+import { keepPreviousData, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
+import { api } from './client'
+import { refresh as refreshPlaylists, type Playlist } from './playlists'
+import type { components } from './schema'
+
+export type Mix = components['schemas']['Mix']
+export type MixWithTracks = components['schemas']['MixWithTracks']
+
+/** The id goes in the path, and a genre mix has the genre in it (`genre:hard rock`). */
+const path = (id: string) => `/mixes/${encodeURIComponent(id)}`
+
+/** The mixes made for me now. */
+export function useMixes() {
+ return useQuery({ queryKey: ['mixes'], queryFn: () => api.get<{ items: Mix[] }>('/mixes').then((r) => r.items) })
+}
+
+/**
+ * A mix with its songs. `variant` 0 is the mix of the day and is not sent; every other number is another set of songs.
+ * The songs on screen stay until the next ones arrive.
+ */
+export function useMix(id: string, variant: number) {
+ return useQuery({
+ queryKey: ['mix', id, variant],
+ queryFn: () => api.get(path(id), variant > 0 ? { variant } : undefined),
+ placeholderData: keepPreviousData,
+ })
+}
+
+/** Keeps the songs of a mix as a playlist of mine. */
+export function useSaveMix() {
+ const client = useQueryClient()
+ return useMutation({
+ mutationFn: ({ id, ...body }: { id: string; name: string; variant: number }) => api.post(`${path(id)}/playlist`, body),
+ onSuccess: () => refreshPlaylists(client),
+ })
+}
diff --git a/web/src/api/playlists.ts b/web/src/api/playlists.ts
index c3d2a7e..cc959f1 100644
--- a/web/src/api/playlists.ts
+++ b/web/src/api/playlists.ts
@@ -24,7 +24,7 @@ export function usePlaylistItems(id: number) {
}
/** Every list and page of playlists is read again: a change moves a playlist to the top and changes its size. */
-function refresh(client: QueryClient) {
+export function refresh(client: QueryClient) {
return client.invalidateQueries({
predicate: (query) => {
const key = query.queryKey[0]
diff --git a/web/src/components/layout/Sidebar.tsx b/web/src/components/layout/Sidebar.tsx
index 196f5ec..0bbbbe7 100644
--- a/web/src/components/layout/Sidebar.tsx
+++ b/web/src/components/layout/Sidebar.tsx
@@ -10,6 +10,7 @@ const LINKS = [
{ to: '/artists', key: 'nav.artists', end: false, adminOnly: false },
{ to: '/albums', key: 'nav.albums', end: false, adminOnly: false },
{ to: '/songs', key: 'nav.songs', end: false, adminOnly: false },
+ { to: '/mixes', key: 'nav.mixes', end: false, adminOnly: false },
{ to: '/playlists', key: 'nav.playlists', end: false, adminOnly: false },
{ to: '/admin', key: 'nav.admin', end: false, adminOnly: true },
{ to: '/settings', key: 'nav.settings', end: false, adminOnly: false },
diff --git a/web/src/i18n/locales/en.json b/web/src/i18n/locales/en.json
index 3407c87..85b3bb9 100644
--- a/web/src/i18n/locales/en.json
+++ b/web/src/i18n/locales/en.json
@@ -11,6 +11,7 @@
"artists": "Artists",
"albums": "Albums",
"songs": "Songs",
+ "mixes": "Mixes",
"playlists": "Playlists",
"admin": "Admin",
"settings": "Settings"
@@ -523,7 +524,9 @@
"playlist_not_found": "This playlist does not exist.",
"limit_reached": "Limit reached: a user can have 1000 playlists, and a playlist up to 10000 songs.",
"track_not_found": "This song no longer exists.",
- "invalid_position": "That place no longer exists. Reload the playlist."
+ "invalid_position": "That place no longer exists. Reload the playlist.",
+ "mix_not_found": "This mix is not available now.",
+ "mix_empty": "This mix has no songs to keep."
},
"playlists": {
"empty": "You have no playlists yet. Make one below, or put a song in a new one with the playlist button next to it.",
@@ -555,5 +558,22 @@
"newName": "New playlist name",
"createAndAdd": "Create and add",
"added": "Added to {{name}}."
+ },
+ "mixes": {
+ "forYou": "Made for you",
+ "byGenre": "By genre",
+ "empty": "No mixes yet. They appear when your library has songs with a genre, or songs you have not heard.",
+ "kind": {
+ "favourites": "Your favourites",
+ "rediscover": "Rediscover",
+ "unheard": "New to you"
+ },
+ "genreMix": "{{genre}} Mix",
+ "with": "With {{artists}}",
+ "notFound": "This mix is not available now. Mixes change with what you listen to.",
+ "shuffle": "Shuffle again",
+ "save": "Save as playlist",
+ "saved": "Saved as “{{name}}”.",
+ "open": "Open the playlist"
}
}
diff --git a/web/src/i18n/locales/it.json b/web/src/i18n/locales/it.json
index e1076ee..cd9c39e 100644
--- a/web/src/i18n/locales/it.json
+++ b/web/src/i18n/locales/it.json
@@ -11,6 +11,7 @@
"artists": "Artisti",
"albums": "Album",
"songs": "Brani",
+ "mixes": "Mix",
"playlists": "Playlist",
"admin": "Admin",
"settings": "Impostazioni"
@@ -523,7 +524,9 @@
"playlist_not_found": "Questa playlist non esiste.",
"limit_reached": "Limite raggiunto: un utente può avere 1000 playlist e una playlist fino a 10000 brani.",
"track_not_found": "Questo brano non esiste più.",
- "invalid_position": "Quel posto non esiste più. Ricarica la playlist."
+ "invalid_position": "Quel posto non esiste più. Ricarica la playlist.",
+ "mix_not_found": "Questo mix ora non è disponibile.",
+ "mix_empty": "Questo mix non ha brani da salvare."
},
"playlists": {
"empty": "Non hai ancora nessuna playlist. Creane una qui sotto, oppure metti un brano in una nuova con il pulsante accanto al brano.",
@@ -555,5 +558,22 @@
"newName": "Nome della nuova playlist",
"createAndAdd": "Crea e aggiungi",
"added": "Aggiunto a {{name}}."
+ },
+ "mixes": {
+ "forYou": "Fatti per te",
+ "byGenre": "Per genere",
+ "empty": "Ancora nessun mix. Compaiono quando la libreria ha brani con un genere, o brani che non hai ancora ascoltato.",
+ "kind": {
+ "favourites": "I tuoi preferiti",
+ "rediscover": "Riscopri",
+ "unheard": "Nuovi per te"
+ },
+ "genreMix": "Mix {{genre}}",
+ "with": "Con {{artists}}",
+ "notFound": "Questo mix ora non è disponibile. I mix cambiano con quello che ascolti.",
+ "shuffle": "Rimescola",
+ "save": "Salva come playlist",
+ "saved": "Salvato come “{{name}}”.",
+ "open": "Apri la playlist"
}
}
diff --git a/web/src/pages/MixPage.tsx b/web/src/pages/MixPage.tsx
new file mode 100644
index 0000000..62da825
--- /dev/null
+++ b/web/src/pages/MixPage.tsx
@@ -0,0 +1,92 @@
+import { ListPlus, Play, Shuffle } from 'lucide-react'
+import { useState } from 'react'
+import { useTranslation } from 'react-i18next'
+import { Link, useParams } from 'react-router-dom'
+import { ApiError } from '@/api/client'
+import { useMix, useSaveMix } from '@/api/mixes'
+import { EmptyMessage, ErrorMessage, Loading } from '@/components/Status'
+import TrackList from '@/components/TrackList'
+import { Button } from '@/components/ui/button'
+import { errorMessageKey } from '@/i18n'
+import { formatTime } from '@/lib/time'
+import { usePlayer } from '@/player/store'
+import { mixTitle } from './mixTitle'
+
+export default function MixPage() {
+ const id = useParams().id ?? ''
+ // Another mix starts again from the mix of the day.
+ return
+}
+
+function MixView({ id }: { id: string }) {
+ const { t } = useTranslation()
+ const [variant, setVariant] = useState(0)
+ const query = useMix(id, variant)
+ const save = useSaveMix()
+ const playTracks = usePlayer((s) => s.playTracks)
+
+ if (query.isError) {
+ if (query.error instanceof ApiError && query.error.status === 404) return {t('mixes.notFound')}
+ return query.refetch()} />
+ }
+ if (!query.data) return
+ const mix = query.data
+ const title = mixTitle(t, mix)
+ const empty = mix.tracks.length === 0
+ // The songs shown are still the old ones while the next come: nothing is kept or shuffled then.
+ const waiting = query.isPlaceholderData
+ const duration = mix.tracks.reduce((sum, track) => sum + track.duration_ms, 0)
+
+ return (
+