diff --git a/docs/superpowers/specs/2026-04-21-web-ui-media-endpoints-design.md b/docs/superpowers/specs/2026-04-21-web-ui-media-endpoints-design.md index 89a2a8db..93ce07ec 100644 --- a/docs/superpowers/specs/2026-04-21-web-ui-media-endpoints-design.md +++ b/docs/superpowers/specs/2026-04-21-web-ui-media-endpoints-design.md @@ -47,7 +47,7 @@ Both routes register inside the existing `authed` chi group in `internal/api/api 2. `q.GetAlbumByID(ctx, id)`. `pgx.ErrNoRows` → 404 `not_found` "album not found". Other err → 500 `server_error`. 3. `resolveAlbumCoverPath(ctx, q, album)`: - If `album.CoverArtPath != nil` and the file stats successfully, return that path. - - Otherwise, list tracks for the album (`q.ListTracksByAlbum`) and, for the first track, look in its directory for `cover.jpg`, `cover.jpeg`, `cover.png`, `folder.jpg`, `folder.jpeg`, `folder.png` in that order. Return the first that exists; else return `""`. + - Otherwise, list tracks for the album (`q.ListTracksByAlbum`, which orders by disc/track number). For the first track in that ordered result, look in its directory for `cover.jpg`, `cover.jpeg`, `cover.png`, `folder.jpg`, `folder.jpeg`, `folder.png` in that order. Return the first file that exists; else return `""`. 4. Empty path return → 404 `not_found` "cover not found". 5. `os.Open` + `f.Stat`. File vanished since resolve → 404 `not_found` "cover not found". Stat err → 500. 6. Set `Content-Type` from `imageContentType(path)` (file-extension-based mapping). Call `http.ServeContent(w, r, filepath.Base(path), info.ModTime(), f)`. @@ -163,7 +163,7 @@ Extend `TestRoutesRegisteredInMount` (from Plan 2's Task 11) to also assert the | `internal/api/media_test.go` | Create | Integration tests for both endpoints, unit tests for mime helpers | | `internal/api/library_fixtures_test.go` | Modify | Add `seedTrackWithFile` helper | | `internal/api/api.go` | Modify | Register both new routes inside the `authed` group in `Mount` | -| `internal/api/library_test.go` | Modify | Extend `TestRoutesRegisteredInMount` to include the two new paths; extend `newLibraryRouter` so existing tests continue to compile | +| `internal/api/library_test.go` | Modify | Extend `TestRoutesRegisteredInMount` to include the two new paths; extend the `newLibraryRouter` helper to register the media routes so integration tests can exercise them through the same test harness | No migrations. No new sqlc queries (existing `GetAlbumByID`, `GetTrackByID`, `ListTracksByAlbum` are sufficient). No package-level dependencies beyond the stdlib and what `/api` already imports.