Commit graph

114 commits

Author SHA1 Message Date
tgiachi
71b0b39a07 feat(web): a card for a Discover suggestion with its score explained
Shows the score in percent, the seeds it comes from, a part-by-part explanation (a missing genre is not a zero), and the wishlist and not-interested actions.
2026-11-12 14:06:49 +01:00
tgiachi
3cd0ef7150 feat(web): a switch in Settings for starting Discover from your listening
Turning it on shows a dialog that says the names of the most played artists go to Last.fm. Turning it off asks nothing, and a failed change leaves the switch as it was.
2026-11-12 14:05:49 +01:00
tgiachi
63ed483936 feat(web): data hooks for Discover, the wishlist, dismissed artists, taste and own settings
Suggestions are kept five minutes and cancelled when nobody looks. Wishlist and dismiss change the suggestions at once and go back if the call fails.
2026-11-12 14:04:16 +01:00
tgiachi
54b19d6d4f feat(web): lists in query values, request cancelling and Retry-After in the API client
A list value is sent once per item (seed=1&seed=2). A signal can cancel a request and a cancelled call rejects with AbortError, not as a lost connection. ApiError keeps Retry-After in seconds.
2026-11-12 14:03:11 +01:00
squidd
64c14a51c5 Merge pull request 'feat(web): a button for browser full screen' (#59) from feat/fullscreen-button into main 2026-11-12 12:35:41 +01:00
squidd
5d143ca444 Merge pull request 'feat(docker): an image of sondad and a compose example' (#60) from feat/docker-image into main 2026-11-12 12:31:40 +01:00
tgiachi
95ba06311e fix(docker): keep the secret, quiet health checks, and tighter files
- The README keeps the JWT secret in a file that is passed every time, so an upgrade
  does not make a new one and sign everybody out.
- A health check that succeeds is logged at debug level, so a container does not write
  thousands of lines a day; any other answer, and every other request, still goes at info.
- .dockerignore patterns match in every folder, as .gitignore does.
- compose.yaml waits 15 seconds for Sonda to stop (it allows itself 10) and requires
  MUSIC_DIR instead of creating an empty folder.
- The README says that the library path is the one inside the container, that the health
  check follows SONDA_LISTEN, and that a sonda.toml in /data works as a secrets file.
2026-11-12 12:29:38 +01:00
tgiachi
075e000fd8 feat(web): a button for browser full screen
- one button in the player bar and one in the full-screen player puts the whole page in full screen and takes it out
- it follows the browser: Esc and F11 flip it back, a refused request leaves the page as it was
- left out where the browser has no Fullscreen API (for example iPhone Safari)
- English and Italian labels
2026-11-12 12:28:15 +01:00
tgiachi
ddabcd3bb3 feat(docker): an image of sondad and a compose example
- A multi-stage Dockerfile: Sonda has no CGO, so the binary is static and the final
  image (alpine, 69 MB) holds only it, the CA certificates and the time zones.
- It runs as an ordinary user (uid 10001), keeps the database and the files it makes
  under /data (a volume), listens on 0.0.0.0:8080 inside the container, and does not
  start without SONDA_JWT_SECRET.
- A health check on /api/v1/health that follows SONDA_LISTEN.
- compose.yaml as an example: the secret comes from .env (which is not committed), the
  music is mounted read-only, and the port is published on this machine only.
- .dockerignore keeps the web client, the databases and the agent files out of the build.
- The README says how to build, run and back up, and how to use a host folder.
2026-11-12 12:23:41 +01:00
squidd
2d478055f2 Merge pull request 'feat(web): web app with player, library browsing, themes and languages (F1)' (#55) from feat/web-f1 into main 2026-11-12 12:15:12 +01:00
tgiachi
241c1efc5d feat(web): Neon theme
- colour in the surfaces too: deep indigo ground, saturated violet panels, electric yellow accent
- checked by the same contrast test as the other themes
- README lists six themes
2026-11-12 12:10:36 +01:00
tgiachi
0d5805fd37 feat(web): Dracula theme
- a livelier dark theme: violet ground, hot pink accent
- covered by the same contrast test as the others
- README lists five themes
2026-11-12 12:08:54 +01:00
tgiachi
d7bd2c75db style(web): squarer corners
- base radius from 10px to 4px; one value (--radius in src/index.css) sets every corner
- no fully round shapes any more: play button, search box, pills and artist photos are squares with small corners
2026-11-12 12:03:53 +01:00
squidd
995ff4befe Merge pull request 'feat(discover): one Discover at a time for each listener, three at once on the server' (#56) from feat/discover-limit into main 2026-11-12 12:03:00 +01:00
tgiachi
69da67065d fix(discover): refusals do not wait for a turn, and waiting for one has an end
- The gate now comes after what only the database decides (a seed that is not an
  artist, no seed and no permission), so those answers are not held up by three
  slow Discovers and do not make the listener "busy".
- A request that waits more than 30 seconds for a turn answers 429 instead of
  hanging for as long as the providers are slow.
- The spec and the README say that a waiting request counts as running.
2026-11-12 12:00:18 +01:00
tgiachi
80a26aeb4a fix(web): keep the player bar on screen, label the settings choices, compact menu on phones
- the player bar stays at the bottom on long pages (sticky sits on its wrapper, not on the bar)
- theme and language groups in Settings have a visible label
- on a phone the menu is a row of links instead of a tall card, and the privacy note is left out there
- the full-screen player is centred vertically
Found by running the app in a real browser against a real server.
2026-11-12 11:58:48 +01:00
tgiachi
63fee32271 feat(discover): one Discover at a time for each listener, three at once on the server
A cold Discover can make dozens of provider requests, and nothing stopped one
listener, or a client that keeps opening and cancelling requests, from lining up
work for the providers and slowing everyone else's.

- A listener who already has a Discover running gets 429 `discover_busy` with
  Retry-After, at once.
- At most three Discovers run at the same time, whoever asks; the others wait for
  their turn, and one that stops waiting does no work and keeps no place.
- The place and the turn are given back when a Discover fails or ends.
- Spec and README describe it; the fakes of the tests are safe for parallel runs.
2026-11-12 11:52:20 +01:00
tgiachi
9eb9341593 fix(web): renew the session in the background, work over plain HTTP, and do not carry a queue to the next sign-in
- the token is renewed in the background when under 3 minutes are left, so the stream URL of the next track is never built from an expired token
- a renewal adopts a session from another tab only when it differs from the one in memory
- listen keys no longer need crypto.randomUUID, which does not exist on pages opened over plain HTTP on a local network
- signing out, or closing the app, stops the music and empties the queue, and the play in progress is reported first
- a provider address that is not an http(s) address is shown as text, never as a link
2026-11-12 11:48:32 +01:00
tgiachi
e0c42dd5ac docs(web): how to run and build the web app
- README section for the web client: how to run it next to sondad, what it does today, the commands
- the greeting on Home is read once per visit (lint: no Date during render)
- checked against a real sondad: login, renewal and spent refresh tokens, media URLs with Range, listens, search, and the provider-off answers
2026-11-12 11:45:20 +01:00
tgiachi
005d0808e9 feat(web): settings for theme, language and password
- theme and language as radio groups, each theme with a preview of its colours, the choice remembered
- change password: 8 to 256 bytes checked before sending; a changed password signs this session out, as the server ends every session
- account name and role, and sign out
2026-11-12 11:41:14 +01:00
tgiachi
3a93c65574 feat(web): home page
- greeting by the hour, recently played songs from the listening history (each song once), shelves of albums and artists
- an empty history, an empty library and a song that is gone each get their own short message
- a shelf that cannot be loaded does not hide the others
2026-11-12 11:39:56 +01:00
squidd
5a3761ca0c Merge pull request 'feat(lidarr): send an artist to Lidarr and see whether it has it' (#54) from feat/lidarr-artist into main 2026-11-12 11:38:18 +01:00
tgiachi
77d60664bb feat(web): search
- search page with a 250 ms pause after typing, the text kept in the address, and at most 200 characters sent
- artists, albums and songs in three groups of six, each with a link to the full list
- accents and capitals are left to the server, which ignores them
- list hooks can take a smaller page size and stay switched off until there is something to ask
2026-11-12 11:38:10 +01:00
tgiachi
e2899c6647 feat(web): artists, albums and songs pages with provider data and attribution
- lists of artists, albums and songs, loaded 50 at a time, with the search text taken from the address
- album page and artist page; a click on a song plays the list from there
- artist page shows a Wikipedia text, similar artists and tags with their credits, and the photo credit
- providers that are off, unreachable or without an id give a short explanation, never an error page
- artists a provider named, with nothing to play, still have a page
2026-11-12 11:36:35 +01:00
tgiachi
22cd0aecd4 fix(lidarr): protect Lidarr from many asks, refuse bad ids, give up when the request does
- Asking whether Lidarr has an artist keeps the answer for a minute, asks once however
  many ask at once, and has at most four questions on their way; what cannot be
  answered is not kept, and a send forgets what was kept.
- An id that is not a MusicBrainz id (one that a provider named and that was only
  cleaned) is no id: it is refused or shown as no_id instead of becoming a 500.
- A send that waits for its turn gives up when its request does.
- A bad answer after the add also says the artist may have been added; a canceled
  send ends like the other canceled requests.
- The README says which artists can be sent.
2026-11-12 11:35:28 +01:00
tgiachi
20856f2ec6 feat(web): player bar and full-screen player
- bar at the bottom of every page with cover, artists, controls, seek and time
- full-screen player in a dialog: big cover, bar-style seek control, up next, focus kept inside, Escape closes
- Space plays and pauses unless the key belongs to a field, a button or a link
- songs list row, seek control and time formatting
- jumpTo in the queue store for a click on an upcoming track
2026-11-12 11:32:29 +01:00
tgiachi
4ab5f8ace9 feat(web): report listens, one event per play
- one event per play with its own idempotency key: complete, skip, or play when the page closes
- a failed send is retried with the same body and key after 1, 4 and 16 seconds; a 400 or 404 is final
- closing the page sends the open play and anything waiting for a retry with keepalive
- a hidden tab keeps playing, so only pagehide ends a play early
2026-11-12 11:28:50 +01:00
tgiachi
8160c33960 feat(lidarr): send an artist to Lidarr and see whether it has it
- POST /artists/{id}/lidarr (admin) adds the artist to the admin's own Lidarr by its
  MusicBrainz id, never by name, with the profiles, the folder and the monitor
  option the admin chose. It works for any artist that has an id, also one that
  Sonda only learned of from a list of similar artists. It can be repeated: an artist
  that Lidarr already has changes nothing. Two sends at once go one after the other.
- GET /artists/{id}/lidarr (signed in) says whether Lidarr has the artist and
  monitors it; what stops the answer is a status (disabled, no_id, not_configured,
  error), as for the descriptions.
- It needs the provider switched on and the profiles and folder chosen; a timeout
  says the artist may have been added anyway.
- Spec, contract test and README, which also say that Sonda downloads nothing.
2026-11-12 11:28:15 +01:00
tgiachi
92d9c8ed78 feat(web): audio engine that survives token renewal
- drives the audio element from the player store: load, play, pause, seek, next on end
- a renewed access token swaps the stream URL and resumes at the same second, playing or paused
- reports start, listened time (in steps of at most two seconds) and finish for the listen reporter
- media keys and lock screen through the Media Session API
2026-11-12 11:26:54 +01:00
tgiachi
cffa8f1976 feat(web): player queue store
- queue with next, previous, seek, repeat (off, all, one), shuffle that keeps the original order, enqueue, play next and remove
- seek and restart requests are explicit, so the audio engine can follow them
2026-11-12 11:24:55 +01:00
tgiachi
3ffd07c546 feat(web): app shell, sidebar and routes
- sidebar with the current page marked, privacy note, and a main area that wraps on narrow screens
- routes for home, search, artists, albums, songs and settings, and a not-found page
2026-11-12 11:23:24 +01:00
tgiachi
1250fd4eac feat(web): catalog hooks, covers and artist photos with fallbacks
- paged lists for artists, albums and songs, 50 at a time, with search text and artist/album filters
- cover and artist photo that fall back to rings or an initial, and retry when the token is renewed
2026-11-12 11:22:16 +01:00
tgiachi
1c5b4a4fa0 feat(web): API client, session with cross-tab refresh, login screen
- fetch client with bearer token, one retry after a renewal, ApiError with the server code
- session kept in localStorage; renewal is single-flight in a tab and under a Web Lock across tabs, and a tab adopts a session another tab already renewed
- a refused refresh token signs out once; an unreachable server keeps the session
- mediaUrl and onTokenChange for audio and image URLs that carry the token
- sign-in and first-account screen, and a gate that shows the app only when signed in
2026-11-12 11:21:06 +01:00
tgiachi
7363b80ebd feat(web): English and Italian UI text
- i18next with en and it, language from the stored choice, then the browser, then English
- a test keeps both files on the same keys with no empty text
- API error codes map to error.<code>, with error.unknown as the fallback
2026-11-12 11:18:34 +01:00
tgiachi
abeef4e30f feat(web): four themes with a contrast test
- Sonda, Tokyo Night, Gruvbox dark and Gruvbox light as CSS variables with shadcn token names
- contrast test: text 4.5:1, accent and form outlines 3:1 in every theme
- Gruvbox dark muted text lightened to pass
- theme choice is stored in localStorage and survives it being blocked
2026-11-12 11:17:41 +01:00
tgiachi
f1da4b5aaf feat(web): scaffold the React app with Vite, Tailwind and shadcn/ui
- Vite, React 19 and TypeScript in web/, Vitest with jsdom and Testing Library
- Tailwind v4 and shadcn/ui, with Figtree and Fraunces bundled locally
- npm run gen:api builds src/api/schema.d.ts from the OpenAPI spec
- dev server proxies /api to sondad (SONDA_URL, default 127.0.0.1:8080)
- mockFetch test helper that refuses unmatched requests
2026-11-12 11:15:50 +01:00
squidd
7027eca946 Merge pull request 'feat(lidarr): set up Lidarr as a provider and read what it offers' (#53) from feat/lidarr-client into main 2026-11-12 11:13:58 +01:00
tgiachi
4dbe1074ba fix(lidarr): saved defaults, conflicts, no proxy, readable addresses
- Setting the address alone now stores the default options (monitor all, search
  for missing albums), so what is shown is what will be sent.
- A 409 from Lidarr, when two adds of the same artist cross, means the artist is
  already there; only "an artist with this ID was not found" is an unknown artist.
- The client never goes through a proxy named by the environment, since Lidarr is
  on the admin's own network and the key travels in a header.
- An address that cannot be read back (an IPv6 zone) is refused instead of being
  stored and reported as "not configured".
- A deadline asking Lidarr is a bad gateway, not an internal error; a redirect is
  reported with a hint to use the final address; the request schema of the Lidarr
  options is closed.
2026-11-12 11:11:35 +01:00
tgiachi
fb9e923197 feat(lidarr): set up Lidarr as a provider and read what it offers
Lidarr is a server of the user's own that looks for and downloads music. Sonda
never downloads; this is the first piece of letting an admin send it an artist.

- The `lidarr` provider, off by default: an address, an API key (32 hexadecimal
  characters, never returned) and, chosen once, a quality profile, a metadata
  profile, a root folder, the monitor option and whether to search for missing
  albums. It cannot be enabled without an address and a key.
- The address is checked: http or https, no user and password, no query, no
  fragment, no closing slash.
- A small client of its own, apart from the outbound one (which only makes plain
  GETs): the key travels in a header, no redirect is ever followed, answers and
  time are bounded, and the address and key are read for every request.
  Status, options, artist by MusicBrainz id and add (lookup, then the add that
  Lidarr's own screen sends).
- `GET /providers/lidarr/options` lists the profiles and root folders; the test of
  the provider checks the address and the key (`no_address` when it has none).
- Migration 0017 adds the address and the options to the provider settings.
- OpenAPI, contract test and README say what is sent and where.
2026-11-12 11:04:53 +01:00
squidd
227e267d73 Merge pull request 'feat(search): search ignores accents' (#50) from feat/search-accents into main 2026-11-12 10:25:23 +01:00
tgiachi
4ec3ae3bb0 fix(search): empty folded queries, compatibility forms, final sigma, start-up log
- A search text that has nothing left once its accents are taken off matches
  nothing instead of everything.
- The search key folds compatibility forms (the ligature "fi", full-width
  letters) and the Greek final sigma.
- The start-up refresh of the keys logs when it starts and how long it took, since
  it can take a while on a big library the first time.
- More tests: a retitled track is found by its new title, a refresh fixes both
  keys and keeps "Beyoncé" and "Beyonce" apart, more cases for the key.
2026-11-12 10:24:44 +01:00
tgiachi
271c88743c feat(search): search ignores accents
- A search key apart from the key that identifies artists, albums and tracks:
  lower case, accents taken off (Latin, Greek and Cyrillic marks only, so kana
  and Hangul stay intact), and letters like ß, æ, ø, ł written plain.
- GET /artists, /albums and /tracks look in it, so "bjork" finds "Björk" and
  "strasse" finds "Straße".
- "Beyoncé" and "Beyonce" stay two artists: the identity key keeps accents.
- Migration 0016 adds the column on SQLite and PostgreSQL; RefreshMatchKeys
  fills it for existing rows at start.
- golang.org/x/text is now a direct dependency.
2026-11-12 10:17:21 +01:00
squidd
bea1158e68 Merge pull request 'feat(jobs): background jobs for artist photos and descriptions' (#48) from feat/artist-jobs into main 2026-11-12 10:10:35 +01:00
tgiachi
9323702b1e fix(jobs): a stop or a panic never wedges a job, a bad download never replaces a good picture
- A panic while counting no longer leaves the job marked as running; a panic in the
  work of one item is a failure of that item, and a panic in the list ends the job
  with a reason.
- A stop while the items are counted is recorded as a stop instead of a 500, and a
  count that fails leaves the status as the previous job left it.
- An artist that lost its MusicBrainz id since it was listed is skipped by the
  pictures job, as the spec says, instead of counting as a failure.
- A picture that cannot be used now (refused download, bytes that are not an image)
  is a failure when a good picture is stored, so a refresh never throws it away.
- The outcomes the artist jobs report share their constants in the jobs package.
- The spec no longer calls each job "the one request" that goes through the library.
- The test that waited with a sleep for the count now waits for a signal.
2026-11-12 10:09:46 +01:00
tgiachi
e3843ad7d6 feat(jobs): background jobs for artist photos and descriptions
Add one engine, internal/jobs, that runs the jobs which go through the whole
library: start, stop, progress, one at a time, give up after five failures in
a row, end at once when a provider is off.

- The covers job now runs on the engine; its API is unchanged.
- POST/GET/DELETE /library/artist-images looks for the picture of every
  artist of the library that has a MusicBrainz id.
- POST/GET/DELETE /library/descriptions does the same for the Wikipedia
  description.
- ?refresh=true searches everything again and never replaces a stored result
  by a failure; artists without an id are never touched, nothing is looked up
  by name.
- images.Service.EnsureArtistImage and about.Service.Ensure do the work for one
  artist; the lists come from ImageRepo and DiscoveryRepo.
- jobs.Runner binds a job to the application context, replacing the two
  hand-written controls.
- OpenAPI, contract test and README describe the new endpoints and say that
  they are bulk requests.
2026-11-12 09:58:45 +01:00
squidd
1c3c2d017b Merge pull request 'feat(images): a background job that builds all the covers' (#46) from feat/covers-job into main 2026-11-12 09:44:33 +01:00
tgiachi
345ad8eecb fix(images): a refresh never wipes covers, the job sees outages and starts cleanly
- A refresh (or any rebuild) while the Cover Art Archive is switched off, but its data
  not taken back, no longer turns the covers it gave into "no cover" and deletes their
  files: the stored cover is kept and its date renewed, so the files are not searched
  again at every request.
- When none of an album's files and folders can be looked at (an unmounted disk, a
  permission), that is ErrFilesUnreadable (503 files_unreadable), not "no picture": nothing
  is remembered, nothing built is touched, the archive is not asked, and the job counts it
  as a failure and gives up after five. A link that leaves the library is still just refused.
- The job calls the build for every album that is not good yet and does not serve an older
  cover on an outage, so a dead provider shows as failures and trips the limit instead of
  being reported as covers from the archive.
- Start marks the job as running before counting the albums and does not hold the lock
  meanwhile; a stop that comes back as a plain driver error is not a failure; a job that
  finished by itself is never marked stopped.
- Spec and README say so; the tests cover each case, including a list that fails midway.
2026-11-12 09:43:51 +01:00
tgiachi
548ee03d83 feat(images): a background job that builds all the covers
- POST /library/covers (admin) starts, in the background and one at a time like a scan,
  a job that builds the cover of every album that has something to play and no cover that
  is still good; GET /library/covers shows the progress and how the last job ended;
  DELETE /library/covers stops it. ?refresh=true searches every album again.
- For each album it does what opening its cover does: the user's own files first, then the
  Cover Art Archive if the provider is on. It gives up, and says why, when the provider
  fails for five albums in a row; an album that vanished is skipped, not a failure.
- This is the one request that goes through the whole library, and the README and the
  provider text say so: with the archive on it sends the release group id of each album with
  no picture in its files, one after the other, spaced out.
- NewRouter now refuses to build when a service was not wired, naming it, instead of
  panicking at the first request (the wiring of this job in main had been missed, which no
  test could see).
- The outbound spacing test measures where the request leaves the client, so a busy
  machine cannot make it fail.
- Spec, contract and HTTP tests, README updated.

Closes #45
2026-11-12 09:34:27 +01:00
squidd
75c887c931 Merge pull request 'feat(images): album covers from the Cover Art Archive' (#44) from feat/cover-art-archive into main 2026-11-12 09:22:01 +01:00
tgiachi
5fecd394e4 fix(images): purge removes every archive cover, the id of an emptied album moves on
- The covers that come from the Cover Art Archive now live in a folder of their own
  (images/album-remote). Taking the provider's data back deletes that folder, so nothing
  from the archive is left whatever became of its records: a rescan makes a record stale
  and a later search that finds nothing replaces it, and neither of those used to remove
  the files. A cover that moves between the user's files and the archive, or goes away,
  no longer leaves the old files behind.
- A redirect to a place that is not allowed is an outage (502, not remembered, an older
  cover served), not "no cover" for a day for every album. A picture over the limit is
  still "no cover".
- A track that moves to another album (a fixed title) leaves the first with no track: it
  gives up its release group id, so the album the track went to can take it. An album
  that has an id keeps it; an id another album owns is not given twice.
- Waiting for a local slot is no longer reported as the provider being unreachable, and a
  build whose reads were purged three times is not served with files that were never written.
- README and spec no longer say covers never contact anybody.
- Tests: the new folder and the purge after a rescan, files left by a replaced cover, the
  local wait, repeated purges, a refused redirect, the update path with a taken id and the
  emptied album.
2026-11-12 09:21:11 +01:00