From b37e3db037a442af439c5183cf4937a9be630a14 Mon Sep 17 00:00:00 2001 From: tgiachi Date: Mon, 16 Nov 2026 14:33:41 +0100 Subject: [PATCH 01/13] feat: publish the Docker image for ARM as well The image is now made for amd64 and for arm64, and each tag (X.Y.Z, X.Y, latest) points at both, so a Raspberry Pi or an ARM NAS pulls the right one. - Dockerfile: the web and Go stages run on the builder and the Go program is cross-compiled (GOARCH from SONDA_ARCH or TARGETARCH); what the image needs besides the program (time zones, the user, the folders) is made in a stage of the builder, so the last stage runs no command and needs no emulation. - release workflow: the runner has no Docker and cannot run ARM, and kaniko takes the base of every stage for one platform, so the arm64 image starts from the arm64 Alpine by digest (found at each release), kaniko builds one image per architecture, and crane sets the architecture of each and joins them under the tags. --- .forgejo/workflows/release.yml | 70 +++++++++++++++++++++++++++++----- Dockerfile | 38 ++++++++++++------ README.md | 4 +- 3 files changed, 89 insertions(+), 23 deletions(-) diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml index 54ccf33..023f628 100644 --- a/.forgejo/workflows/release.yml +++ b/.forgejo/workflows/release.yml @@ -2,9 +2,10 @@ # 1. semantic-release reads the commits since the last release (Conventional Commits), works out the next version, # writes CHANGELOG.md, makes the release on the forge and tags it. A merge with nothing to release (docs, tests, ci) # makes none. -# 2. When there is a release, the image is built from the tag and pushed to git.kmalloc.org/squid/sonda as -# X.Y.Z, X.Y and latest. -# The runner has no Docker, so the image is built with kaniko, which needs no daemon. +# 2. When there is a release, the image is built from the tag, for amd64 and for arm64, and pushed to +# git.kmalloc.org/squid/sonda as X.Y.Z-ARCH; then X.Y.Z, X.Y and latest are made to point at both. +# The runner has no Docker and cannot emulate another architecture, so the images are built with kaniko, which needs no +# daemon, and the Dockerfile crosses to arm64 without running anything for it. # Secret needed: FORGEJO_TOKEN, a token of the owner with the scopes write:repository and write:package. name: release @@ -58,16 +59,37 @@ jobs: echo "version=${tag#v}" >> "$GITHUB_OUTPUT" echo "released: ${tag:-nothing}" - image: + # The Alpine of the arm64 image, by digest: kaniko, which has no emulation here, takes the base of every stage for the + # platform of the runner, so the last stage is told which one to use. + base: needs: release if: ${{ needs.release.outputs.version != '' }} runs-on: docker + container: + image: gcr.io/go-containerregistry/crane:debug + outputs: + arm64: ${{ steps.digest.outputs.arm64 }} + steps: + - id: digest + run: echo "arm64=alpine@$(crane digest --platform linux/arm64 alpine:3.22)" >> "$GITHUB_OUTPUT" + + # One image for each architecture. The Go program crosses to the other one with no emulation, and the last stage of the + # Dockerfile runs no command (see the Dockerfile). + image: + needs: [release, base] + if: ${{ needs.release.outputs.version != '' }} + runs-on: docker + strategy: + matrix: + arch: [amd64, arm64] container: image: gcr.io/kaniko-project/executor:v1.23.2-debug steps: - - name: Build the image from the tag and push it + - name: Build the image from the tag and push it as X.Y.Z-ARCH env: VERSION: ${{ needs.release.outputs.version }} + ARCH: ${{ matrix.arch }} + ARM64_BASE: ${{ needs.base.outputs.arm64 }} REGISTRY_USER: squid REGISTRY_TOKEN: ${{ secrets.FORGEJO_TOKEN }} run: | @@ -75,14 +97,42 @@ jobs: mkdir -p /kaniko/.docker auth="$(printf '%s:%s' "$REGISTRY_USER" "$REGISTRY_TOKEN" | base64 | tr -d '\n')" printf '{"auths":{"git.kmalloc.org":{"auth":"%s"}}}' "$auth" > /kaniko/.docker/config.json - image=git.kmalloc.org/squid/sonda - minor="${VERSION%.*}" + base=alpine:3.22 + if [ "$ARCH" = arm64 ]; then base="$ARM64_BASE"; fi /kaniko/executor \ --dockerfile Dockerfile \ --context "git://git.kmalloc.org/squid/sonda.git#refs/tags/v${VERSION}" \ --build-arg "VERSION=${VERSION}" \ + --build-arg "SONDA_ARCH=${ARCH}" \ + --build-arg "RUNTIME_BASE=${base}" \ --label "org.opencontainers.image.version=${VERSION}" \ - --destination "${image}:${VERSION}" \ - --destination "${image}:${minor}" \ - --destination "${image}:latest" \ + --destination "git.kmalloc.org/squid/sonda:${VERSION}-${ARCH}" \ --verbosity info + + # The tags that people use (X.Y.Z, X.Y, latest) point at a list of the two images, so that each machine takes its own. + manifest: + needs: [release, image] + if: ${{ needs.release.outputs.version != '' }} + runs-on: docker + container: + image: gcr.io/go-containerregistry/crane:debug + steps: + - name: Join the images under X.Y.Z, X.Y and latest + env: + VERSION: ${{ needs.release.outputs.version }} + REGISTRY_USER: squid + REGISTRY_TOKEN: ${{ secrets.FORGEJO_TOKEN }} + run: | + set -eu + image=git.kmalloc.org/squid/sonda + crane auth login git.kmalloc.org -u "$REGISTRY_USER" -p "$REGISTRY_TOKEN" + # Kaniko writes the architecture of the runner in both images: say the right one for each. + for arch in amd64 arm64; do + crane mutate "${image}:${VERSION}-${arch}" --set-platform "linux/${arch}" --tag "${image}:${VERSION}-${arch}" + done + crane index append \ + --tag "${image}:${VERSION}" \ + --manifest "${image}:${VERSION}-amd64" \ + --manifest "${image}:${VERSION}-arm64" + crane tag "${image}:${VERSION}" "${VERSION%.*}" + crane tag "${image}:${VERSION}" latest diff --git a/Dockerfile b/Dockerfile index 6afce61..786dc20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,11 @@ # syntax=docker/dockerfile:1 +# RUNTIME_BASE is alpine:3.22 unless the CI release asks for another architecture, with the digest of that one. +ARG RUNTIME_BASE=alpine:3.22 + # The web app: built once here, written (by its Vite config) to /src/internal/webui/dist, where the Go # build below embeds it. Nothing of Node reaches the final image. -FROM node:24-alpine AS web +FROM --platform=$BUILDPLATFORM node:24-alpine AS web WORKDIR /src/web COPY web/package.json web/package-lock.json ./ RUN npm ci @@ -12,7 +15,13 @@ RUN npm run build # Build: Sonda has no CGO (SQLite, PostgreSQL and the tag reader are pure Go), so the binary # is static and the final image needs nothing but it and the CA certificates. The web app is inside it # (-tags webui), so sondad serves it on / and the API on /api. -FROM golang:1.27-alpine AS build +FROM --platform=$BUILDPLATFORM golang:1.27-alpine AS build +# Built on the machine that builds, for the machine that runs: Go crosses to another architecture with no emulation +# (TARGETOS and TARGETARCH come from the platform asked for). +ARG TARGETOS +ARG TARGETARCH +# SONDA_ARCH is for a builder that cannot say TARGETARCH (the CI release, see .forgejo/workflows/release.yml). +ARG SONDA_ARCH WORKDIR /src COPY go.mod go.sum ./ RUN go mod download @@ -22,19 +31,26 @@ COPY migrations ./migrations COPY --from=web /src/internal/webui/dist ./internal/webui/dist # The version of the release (see .releaserc.json), as GET /version and the User-Agent of the providers say it. ARG VERSION=dev -RUN CGO_ENABLED=0 go build -tags webui -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o /out/sondad ./cmd/sondad +RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${SONDA_ARCH:-${TARGETARCH:-amd64}} go build -tags webui -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o /out/sondad ./cmd/sondad -FROM alpine:3.22 +# What the image has besides the program (the zones of tzdata, the user, the folders) is made here, on the machine that +# builds. The last stage then runs no command, so it can be built for another architecture with no emulation. +FROM --platform=$BUILDPLATFORM alpine:3.22 AS rootfs +RUN apk add --no-cache tzdata \ + && addgroup -S -g 10001 sonda \ + && adduser -S -u 10001 -G sonda -h /data -H sonda \ + && mkdir -p /out/data /out/music + +FROM ${RUNTIME_BASE} LABEL org.opencontainers.image.title="Sonda" \ org.opencontainers.image.description="A privacy-first, self-hosted music server" \ org.opencontainers.image.source="https://git.kmalloc.org/squid/sonda" -# ca-certificates: the providers an admin may switch on are reached over https. -# tzdata: log times in the zone the operator sets with TZ. -RUN apk add --no-cache ca-certificates tzdata \ - && addgroup -S -g 10001 sonda \ - && adduser -S -u 10001 -G sonda -h /data -H sonda \ - && mkdir -p /data /music \ - && chown sonda:sonda /data +# The certificates of alpine (ca-certificates-bundle) are what the providers an admin may switch on are reached with, +# over https. tzdata is for the log times in the zone the operator sets with TZ. +COPY --from=rootfs /usr/share/zoneinfo /usr/share/zoneinfo +COPY --from=rootfs /etc/passwd /etc/group /etc/shadow /etc/ +COPY --from=rootfs --chown=10001:10001 /out/data /data +COPY --from=rootfs /out/music /music COPY --from=build /out/sondad /usr/local/bin/sondad # Everything Sonda writes is under /data: the database and the files it makes (covers, pictures). diff --git a/README.md b/README.md index 6ccb018..be49736 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ A plain `go build -o bin/sondad ./cmd/sondad` needs no Node and gives the API on The image holds `sondad` with the web app inside, and nothing else: it builds the app itself, so you need no Node on your machine. It runs as an ordinary user, keeps the database and the files Sonda makes under `/data`, listens on port 8080 inside the container, and does not start without `SONDA_JWT_SECRET`. -The image is published on the registry of git.kmalloc.org, so you do not have to build it: `git.kmalloc.org/squid/sonda:latest` is the last one, and `git.kmalloc.org/squid/sonda:` (the first seven characters of a commit of `main`) is one you can stay on. Anyone can pull it, with no login. To build it yourself instead, run `docker build -t sonda .` and use `sonda` where the commands below say `git.kmalloc.org/squid/sonda:latest`. +The image is published on the registry of git.kmalloc.org, so you do not have to build it: `git.kmalloc.org/squid/sonda:latest` is the last one, and `git.kmalloc.org/squid/sonda:0.3.0` (a version from [CHANGELOG.md](CHANGELOG.md)) is one you can stay on. It runs on amd64 and on arm64 (a Raspberry Pi, an ARM NAS): one tag gives each machine its own. Anyone can pull it, with no login. To build it yourself instead, run `docker build -t sonda .` and use `sonda` where the commands below say `git.kmalloc.org/squid/sonda:latest`. ```bash docker pull git.kmalloc.org/squid/sonda:latest @@ -415,7 +415,7 @@ Every merge into `main` can make a release, by itself (`.forgejo/workflows/relea | `feat!: ...`, or `BREAKING CHANGE:` in the body | major (0.2.0 to 1.0.0) | | `docs:`, `test:`, `chore:`, `ci:`, `style:` | none by themselves | -A release adds its entry to [CHANGELOG.md](CHANGELOG.md), tags the commit (`v0.3.0`), makes the release on the forge, and the image is built from the tag and pushed to `git.kmalloc.org/squid/sonda` as `0.3.0`, `0.3` and `latest`. The version is inside the binary: `GET /version` and the User-Agent of the providers say it (a build that no release made says `dev`). The commit that writes `CHANGELOG.md` says `[skip ci]`. The runner has no Docker, so the image is built with [kaniko](https://github.com/GoogleContainerTools/kaniko). The workflow needs the secret `FORGEJO_TOKEN`: a token of the owner with the scopes `write:repository` and `write:package`. +A release adds its entry to [CHANGELOG.md](CHANGELOG.md), tags the commit (`v0.3.0`), makes the release on the forge, and the image is built from the tag and pushed to `git.kmalloc.org/squid/sonda` as `0.3.0`, `0.3` and `latest`. The version is inside the binary: `GET /version` and the User-Agent of the providers say it (a build that no release made says `dev`). The commit that writes `CHANGELOG.md` says `[skip ci]`. The image is made for amd64 and for arm64, and each tag points at both. The runner has no Docker and cannot emulate ARM, so the images are built with [kaniko](https://github.com/GoogleContainerTools/kaniko): the Go program is compiled for ARM with no emulation, the last stage of the Dockerfile runs no command, and a last job (with [crane](https://github.com/google/go-containerregistry)) says the architecture of each image and joins them. The workflow needs the secret `FORGEJO_TOKEN`: a token of the owner with the scopes `write:repository` and `write:package`. ## Development From 43200dda05208b3879b08c528b8634cd64e80e3f Mon Sep 17 00:00:00 2001 From: sonda-release Date: Mon, 16 Nov 2026 13:34:30 +0000 Subject: [PATCH 02/13] chore(release): 0.3.0 [skip ci] ## [0.3.0](https://git.kmalloc.org/squid/sonda/compare/v0.2.0...v0.3.0) (2026-11-16) ### Features * publish the Docker image for ARM as well ([b37e3db](https://git.kmalloc.org/squid/sonda/commit/b37e3db037a442af439c5183cf4937a9be630a14)) --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2eb38a3..dcd1e3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [0.3.0](https://git.kmalloc.org/squid/sonda/compare/v0.2.0...v0.3.0) (2026-11-16) + +### Features + +* publish the Docker image for ARM as well ([b37e3db](https://git.kmalloc.org/squid/sonda/commit/b37e3db037a442af439c5183cf4937a9be630a14)) + ## [0.2.0](https://git.kmalloc.org/squid/sonda/compare/v0.1.0...v0.2.0) (2026-11-16) ### Features From ee31e0ee7caf9e7510b7cfde1f4e096721966e90 Mon Sep 17 00:00:00 2001 From: tgiachi Date: Sun, 15 Nov 2026 17:31:54 +0100 Subject: [PATCH 03/13] docs: note that this repo moved to git.kmalloc.org --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index be49736..5b9cb92 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # Sonda +**This repository has moved.** Development continues at +[git.kmalloc.org/squid/sonda](https://git.kmalloc.org/squid/sonda); this +Codeberg mirror is archived and read-only. + Sonda is a privacy-first, self-hosted music server written in Go. It streams the music you already own, from your own disks, and keeps everything it knows about you on your own machine. It is a single executable, one database (SQLite by default, PostgreSQL if you prefer) and the folders that hold your music. There is no Redis, no message broker and no cloud account. From 75a7898c68ca65c8c4efa0f51b72d62ac9a4db6e Mon Sep 17 00:00:00 2001 From: tgiachi Date: Mon, 16 Nov 2026 17:38:58 +0100 Subject: [PATCH 04/13] feat(web): make Sonda feel like an app on a phone A review of the phone experience (the issue) found a desktop page made smaller. What changes: feat: - The player bar is one row on a phone (cover, title, play and next, a thin line of progress) and is not there while nothing plays. A tap or a swipe up on it opens the full-screen player. - The Back gesture closes the full-screen player instead of leaving the page under it; a swipe down closes it too. The full queue is listed on a phone. - The queue is kept in the browser: a reload, or a tab that Android throws away, comes back paused on the same song at the same second. It belongs to the person signed in and is forgotten on sign-out. - Tabs have icons; the page starts at its top on a new route and back goes to where the list was; a swipe on the page no longer reloads it. fix: - The player now knows when the system pauses the audio (another app, a headset), so the button and the lock screen no longer say it plays. - The lock screen has a working seek bar and the right play/pause state. - The player bar was not hidden by max-sm:hidden: its grid rules were outside the Tailwind layers and won. They are in the components layer now. - Song rows give the title the room on a phone (no number column). - The album header is centred and the greeting is smaller on a phone; recent songs on Home show the artist. - Thumbnails ask for the small cover (300 px) and not the 1000 px one. - Pages use dvh, the viewport covers the notch, and the tabs keep clear of the gesture bar; the update notice no longer sits on the bar. - No grey tap flash, no double-tap delay, no image menu on a long press. --- README.md | 2 +- web/index.html | 2 +- web/src/auth/AuthGate.tsx | 2 +- web/src/auth/LoginPage.tsx | 2 +- web/src/components/Cover.test.tsx | 13 +- web/src/components/Cover.tsx | 17 ++- web/src/components/PageTitle.test.tsx | 2 +- web/src/components/PageTitle.tsx | 2 +- web/src/components/RouteLoading.tsx | 2 +- web/src/components/TrackRow.tsx | 5 +- web/src/components/layout/NowPlaying.tsx | 26 ++-- web/src/components/layout/PhoneTabs.test.tsx | 9 ++ web/src/components/layout/PhoneTabs.tsx | 20 +-- web/src/components/layout/Player.test.tsx | 104 ++++++++++++- web/src/components/layout/PlayerBar.tsx | 32 +++- web/src/components/layout/PlayerControls.tsx | 18 ++- web/src/components/layout/Shell.tsx | 8 +- .../layout/useBackClosesPlayer.test.tsx | 81 ++++++++++ .../components/layout/useBackClosesPlayer.ts | 41 +++++ web/src/index.css | 56 ++++--- web/src/lib/useSwipe.ts | 41 +++++ web/src/pages/AlbumPage.tsx | 10 +- web/src/pages/HomePage.test.tsx | 16 +- web/src/pages/HomePage.tsx | 9 +- web/src/pages/mixes.test.tsx | 2 +- web/src/pages/playlists.test.tsx | 4 +- web/src/pages/smart.test.tsx | 6 +- web/src/player/engine.test.ts | 39 ++++- web/src/player/engine.ts | 14 +- web/src/player/media.ts | 9 +- web/src/player/mediaSession.test.ts | 46 +++++- web/src/player/mediaSession.ts | 28 +++- web/src/player/saved.test.ts | 128 ++++++++++++++++ web/src/player/saved.ts | 140 ++++++++++++++++++ web/src/player/usePlayer.test.tsx | 25 ++++ web/src/player/usePlayer.ts | 20 ++- web/src/pwa/UpdateNotice.tsx | 2 +- 37 files changed, 892 insertions(+), 91 deletions(-) create mode 100644 web/src/components/layout/useBackClosesPlayer.test.tsx create mode 100644 web/src/components/layout/useBackClosesPlayer.ts create mode 100644 web/src/lib/useSwipe.ts create mode 100644 web/src/player/saved.test.ts create mode 100644 web/src/player/saved.ts diff --git a/README.md b/README.md index 5b9cb92..34b5a45 100644 --- a/README.md +++ b/README.md @@ -394,7 +394,7 @@ Back up the database and `sonda.toml`. Your music stays wherever you keep it. ## Web app -A web client lives in `web/` (React, Vite and shadcn/ui). It talks only to the Sonda server: no CDN, no external fonts, no analytics. With the app built into the binary (`make build`, or the Docker image) `sondad` serves it: open the address of the server, for example `http://127.0.0.1:8080`, and sign in. The page carries a strict Content-Security-Policy (only resources of the server itself, no inline scripts), cannot be framed and sends no referrer, and a link inside the app (`/admin/users`) works when you reload it. The player draws a live picture of what is playing, in the browser, from the sound itself (Web Audio). Settings has a choice for it, kept on the device: a spectrogram (the last seconds, low notes at the bottom, the default), the classic bars with falling caps, an oscilloscope, Milkdrop, or nothing. The bars, the oscilloscope and the spectrogram take the colour of this server or, for a friend's song, the colour of the friend. Milkdrop fills the background of the full-screen player with the pictures Winamp made famous, drawn on the device with [butterchurn](https://github.com/jberg/butterchurn) (MIT) and its presets, which are part of the app: nothing is fetched from outside. It is loaded only when chosen, and anyone who asked the system for less motion gets the spectrogram instead, because the pictures flash. The player listens to the sound and changes nothing of it, and draws only while something plays. +A web client lives in `web/` (React, Vite and shadcn/ui). It talks only to the Sonda server: no CDN, no external fonts, no analytics. With the app built into the binary (`make build`, or the Docker image) `sondad` serves it: open the address of the server, for example `http://127.0.0.1:8080`, and sign in. The page carries a strict Content-Security-Policy (only resources of the server itself, no inline scripts), cannot be framed and sends no referrer, and a link inside the app (`/admin/users`) works when you reload it. The player draws a live picture of what is playing, in the browser, from the sound itself (Web Audio). Settings has a choice for it, kept on the device: a spectrogram (the last seconds, low notes at the bottom, the default), the classic bars with falling caps, an oscilloscope, Milkdrop, or nothing. The bars, the oscilloscope and the spectrogram take the colour of this server or, for a friend's song, the colour of the friend. Milkdrop fills the background of the full-screen player with the pictures Winamp made famous, drawn on the device with [butterchurn](https://github.com/jberg/butterchurn) (MIT) and its presets, which are part of the app: nothing is fetched from outside. It is loaded only when chosen, and anyone who asked the system for less motion gets the spectrogram instead, because the pictures flash. The player listens to the sound and changes nothing of it, and draws only while something plays. On a phone the player is one row at the foot of the page (and is not there while nothing plays); a tap or a swipe up opens the full-screen player, a swipe down or the Back gesture closes it, and the lock screen shows the song with its seek bar and follows play and pause. The queue is kept in the browser, so a page that is reloaded, or a tab that Android throws away, comes back paused on the same song at the same second. To work on the interface itself, run the Vite dev server next to a running `sondad` (set `SONDA_URL` to where it listens: the default is `http://127.0.0.1:8080`): diff --git a/web/index.html b/web/index.html index b6c7099..243714a 100644 --- a/web/index.html +++ b/web/index.html @@ -9,7 +9,7 @@ - + Sonda diff --git a/web/src/auth/AuthGate.tsx b/web/src/auth/AuthGate.tsx index 7f5fe51..7b24792 100644 --- a/web/src/auth/AuthGate.tsx +++ b/web/src/auth/AuthGate.tsx @@ -9,7 +9,7 @@ export default function AuthGate({ children }: { children: ReactNode }) { const { t } = useTranslation() if (status === 'loading') { - return
+ return
} if (status === 'anonymous') return return <>{children} diff --git a/web/src/auth/LoginPage.tsx b/web/src/auth/LoginPage.tsx index 3f225b9..1ad513e 100644 --- a/web/src/auth/LoginPage.tsx +++ b/web/src/auth/LoginPage.tsx @@ -31,7 +31,7 @@ export default function LoginPage() { } return ( -
+

{creating ? t('auth.registerTitle') : t('auth.signInTitle')}

diff --git a/web/src/components/Cover.test.tsx b/web/src/components/Cover.test.tsx index 7b610e0..207f55a 100644 --- a/web/src/components/Cover.test.tsx +++ b/web/src/components/Cover.test.tsx @@ -16,7 +16,7 @@ function placeholder(container: HTMLElement) { test('a cover asks for the album cover of the API', () => { const { container } = render() const img = container.querySelector('img')! - expect(img.getAttribute('src')).toBe('/api/v1/albums/12/cover') + expect(img.getAttribute('src')).toBe('/api/v1/albums/12/cover?size=small') expect(img).toHaveAttribute('loading', 'lazy') expect(img).toHaveAttribute('alt', '') expect(placeholder(container)).toBeNull() @@ -25,9 +25,9 @@ test('a cover asks for the album cover of the API', () => { test('the cover URL carries the access token and follows it when it changes', () => { sessionStore.setState({ accessToken: 'tok1' }) const { container } = render() - expect(container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/albums/12/cover?access_token=tok1') + expect(container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/albums/12/cover?size=small&access_token=tok1') act(() => sessionStore.setState({ accessToken: 'tok2' })) - expect(container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/albums/12/cover?access_token=tok2') + expect(container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/albums/12/cover?size=small&access_token=tok2') }) test('a cover that fails to load is replaced by the placeholder', () => { @@ -116,3 +116,10 @@ test('a cover that cannot be loaded falls back to the rings, and the picture hid expect(placeholder(container)).not.toBeNull() expect(container.querySelector('img')).toBeNull() }) + +test('a big cover asks for the full picture, a friend’s cover for the only one the friend has', () => { + const big = render() + expect(big.container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/albums/12/cover') + const friend = render() + expect(friend.container.querySelector('img')!.getAttribute('src')).toBe('/api/v1/friends/3/albums/12/cover') +}) diff --git a/web/src/components/Cover.tsx b/web/src/components/Cover.tsx index 1ce7bca..92e1d1c 100644 --- a/web/src/components/Cover.tsx +++ b/web/src/components/Cover.tsx @@ -19,10 +19,14 @@ const RINGS = [ { size: '68%', opacity: 0.3 }, ] as const +/** Up to this size (CSS pixels) a cover is drawn from the small picture. */ +const SMALL_UP_TO = 150 + /** The cover of an album, or the rings of Sonda when there is none (or it cannot be loaded). */ export default function Cover({ albumId, friend, size, fluid = false }: CoverProps) { useAccessToken() // the URL carries the token, so it has to follow a renewal - const src = albumId === null ? null : mediaUrl(coverPath(friend, albumId)) + // A thumbnail asks for the small picture: a phone does not need to fetch 1000 pixels to draw 56. + const src = albumId === null ? null : mediaUrl(coverPath(friend, albumId, size <= SMALL_UP_TO)) // A failure is remembered for this URL only: a renewed token makes a new URL, which is tried again. const [failed, setFailed] = useState(null) const showImage = src !== null && failed !== src @@ -36,7 +40,16 @@ export default function Cover({ albumId, friend, size, fluid = false }: CoverPro className="relative shrink-0 overflow-hidden rounded-sm bg-muted" > {showImage ? ( - setFailed(src)} /> + window.matchMedia?.('(pointer: coarse)').matches && e.preventDefault()} + className="size-full object-cover" + onError={() => setFailed(src)} + /> ) : (
+ + + diff --git a/android/www/server.js b/android/www/server.js new file mode 100644 index 0000000..d0cc46e --- /dev/null +++ b/android/www/server.js @@ -0,0 +1,16 @@ +/** Turns what was typed into the address of a Sonda server, or null when it is not one. */ +export function normalizeAddress(input) { + const text = String(input ?? '').trim() + if (text === '') return null + const withScheme = /^[a-z][a-z0-9+.-]*:\/\//i.test(text) ? text : `https://${text}` + let url + try { + url = new URL(withScheme) + } catch { + return null + } + if (url.protocol !== 'https:' && url.protocol !== 'http:') return null + if (url.hostname === '') return null + // The app lives at the root of the server: a path, a query or a fragment typed by mistake is dropped. + return url.origin +} From e11ce89b2170dee476312730186d96d9f0d7efd0 Mon Sep 17 00:00:00 2001 From: sonda-release Date: Tue, 17 Nov 2026 09:42:59 +0000 Subject: [PATCH 13/13] chore(release): 0.5.0 [skip ci] ## [0.5.0](https://git.kmalloc.org/squid/sonda/compare/v0.4.2...v0.5.0) (2026-11-17) ### Features * **android:** add an Android app ([ba10b8e](https://git.kmalloc.org/squid/sonda/commit/ba10b8ef7bbcf4fe3735e7b931d1b687259cc044)), closes [#47](https://git.kmalloc.org/squid/sonda/issues/47) * **web:** talk to the Android app ([995f2e5](https://git.kmalloc.org/squid/sonda/commit/995f2e5ae013897a56743b60eeedea909fe04db9)) ### Bug fixes * **web:** show a restored queue on the lock screen ([a2d6d2a](https://git.kmalloc.org/squid/sonda/commit/a2d6d2a925edf8de89a7a4df0afbfa82004ccf87)) --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5257286..c54bc8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## [0.5.0](https://git.kmalloc.org/squid/sonda/compare/v0.4.2...v0.5.0) (2026-11-17) + +### Features + +* **android:** add an Android app ([ba10b8e](https://git.kmalloc.org/squid/sonda/commit/ba10b8ef7bbcf4fe3735e7b931d1b687259cc044)), closes [#47](https://git.kmalloc.org/squid/sonda/issues/47) +* **web:** talk to the Android app ([995f2e5](https://git.kmalloc.org/squid/sonda/commit/995f2e5ae013897a56743b60eeedea909fe04db9)) + +### Bug fixes + +* **web:** show a restored queue on the lock screen ([a2d6d2a](https://git.kmalloc.org/squid/sonda/commit/a2d6d2a925edf8de89a7a4df0afbfa82004ccf87)) + ## [0.4.2](https://git.kmalloc.org/squid/sonda/compare/v0.4.1...v0.4.2) (2026-11-17) ### Bug fixes