Radio: estaciones en vivo mientras entrenás
Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s

Música tiene una sección **Radio**: estaciones en vivo por género (Workout/Rave,
Techno/House, R&B/Soul, Latina, Hip-Hop, Reggae, Chill, Jazz, Rock, Electrónica),
sin publicidad primero —SomaFM y Radio Paradise— y detrás el directorio público de
radio-browser. Nada de esto suma dependencias: la lista la arma api/radio.js.

Tres decisiones que no se ven en la pantalla y son las que hacen que funcione:

- **El audio no pasa por el servidor.** La api entrega la lista y después no ve un
  byte: el teléfono habla con la estación. Sin ancho de banda, sin disco, sin copias.
- **La URL del stream viene resuelta en la lista**, porque iOS sólo deja arrancar
  audio dentro del gesto del toque: cualquier cosa asíncrona entre el dedo y el
  play() es un botón que no hace nada, sin error en ninguna parte.
- **El `<audio>` vive fuera de React** (lib/radio-player.js): un elemento dentro de
  un componente se desmonta con él, y eso es la música cortándose al cambiar de
  pantalla — justo lo que no puede pasar en medio de una serie.

Barra arriba de la barra de pestañas con pausa (deja la estación donde estaba) y
parar; Media Session pone estación, pista y controles en la pantalla bloqueada, y
las canciones siguen con el teléfono en el bolsillo. Qué suena lo dicen SomaFM y
Radio Paradise y nadie más: en el resto la barra muestra la estación en vez de
inventar una pista.

api/test/server-radio.test.js guarda las dos puertas (sesión obligatoria, `src`+`id`
reconstruidos en vez de confiar en el objeto del cliente); RadioBar.test.jsx y el
caso de la fila en Music.test.jsx guardan lo demás.

También: radio.js en el COPY del Dockerfile —importar un archivo que no está copiado
es un contenedor que arranca en ERR_MODULE_NOT_FOUND—, /api/radio y /api/radio/now
(con /api/music/lookup, que faltaba) en la especificación, y docs/RADIO.md.
This commit is contained in:
dsantillan committed 2026-09-23 20:38:19 -04:00
1 parent e1d28f971d
commit 48cf976635
22 files changed
+1662 -15

No files matched your search

+15 -7
View File
@@ -27,7 +27,8 @@ mcp/ optional MCP server — read-only stdio bridge exposing a user's work
media/ exercise img/gif, gitignored, fetched at runtime by the `media` compose service.
website/ static marketing site (plain HTML/CSS/JS) — not deployed for this fork; built by hand
when someone wants it (node scripts/build-api-docs.mjs fills in api.html).
docs/ SELF_HOSTING.md, MOBILE.md, AI_COACH.md, HEALTH.md (Apple Health ingest).
docs/ SELF_HOSTING.md, MOBILE.md, AI_COACH.md, HEALTH.md (Apple Health ingest),
RADIO.md (live stations).
```
## Commands
@@ -89,6 +90,10 @@ would catch is a change nothing checks here.
stores numbers; this decides how they read.
- `music.js` — reading and validating the Apple Music share links a profile keeps. Apple has no
API for somebody else's public playlists, so a playlist here is a link, not an integration.
- `radio-player.js` — the single `<audio>` element and Media Session, held **outside React** on
purpose: an element owned by a component unmounts with it, which is how a player stops when
somebody changes screens. `play()` is called synchronously from the tap because iOS only allows
audio to start inside a gesture — see `docs/RADIO.md` before touching any of it.
- `api.js` — the only place that talks to the backend (`fetch` wrapper, session cookie flows).
- CONTRIBUTING.md is explicit: **anything that decides what you lift next, or reads a logged
session back, is a pure helper here with a unit test beside it** — not verifiable by
@@ -122,12 +127,15 @@ gated by env vars: `ADMIN_UIDS` (admin dashboard), `INVITE_ONLY` (signup needs a
`data/audit.log` (JSONL) for sign-in/admin events. Web Push (`web-push`, VAPID keys
auto-generated into `data/vapid.json`) drives rest-timer-over and day-reminder notifications.
`vitals.js` and `music.js` sit beside `server.js` as the modules with real logic on the API side:
HAE parsing, the idempotent merge (the reason a 5-minute automation does not double a day of steps)
and retention in the first; reading what a public Apple Music page says about itself, behind a host
allowlist, in the second. `server.js` owns the sockets; those files own the parsing, which is why
they are testable without a phone or a network. Both are listed in the Dockerfile's `COPY` — an
import of a file that is not copied there is a container that boots into ERR_MODULE_NOT_FOUND.
`vitals.js`, `music.js` and `radio.js` sit beside `server.js` as the modules with real logic on the
API side: HAE parsing, the idempotent merge (the reason a 5-minute automation does not double a day
of steps) and retention in the first; reading what a public Apple Music page says about itself,
behind a host allowlist, in the second; the live-station directory — SomaFM, Radio Paradise and
radio-browser — in the third, which is also where the rule lives that **audio is never proxied**: the
api hands out a resolved stream URL and the phone talks to the station directly. `server.js` owns the
sockets; those files own the parsing, which is why they are testable without a phone or a network.
All of them are listed in the Dockerfile's `COPY` — an import of a file that is not copied there is a
container that boots into ERR_MODULE_NOT_FOUND.
### MCP server (`mcp/src`)