Since the track lists page in, the panel's header and footer were counting
only what had loaded so far — a platform with 321 tracks read "200 tracks"
next to a sidebar saying 321.
The panel now takes the queue's total and reports that. The running time
stays hidden until every page is in, since only loaded tracks have
durations; short queues that arrive in one page are unchanged.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Folds the standalone soundtrack seeder into generate_test_data.py, where
the rest of the fake library is built: a share of roms (--soundtrack-share,
default 8%) now get tagged audio files plus their track_meta rows, so the
music endpoints and the jukebox have something to read.
Two pre-existing bugs in that script surfaced while verifying this, both
of which made it fail outright on MariaDB:
- bulk_insert used executemany, whose MariaDB bulk path silently drops all
but the first row when a column mixes NULL and non-NULL across the batch.
Every rom batch inserted one rom, and the rom_files insert then failed the
foreign key. Multi-VALUES statements per chunk keep the speed without it.
- with rows actually landing, the small title pools collide on the unique
(platform_id, fs_name) index, so repeats are now disambiguated.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Play-all and the browse selections still resolved their whole queue up
front, which on a large library meant ~100 parallel /music/tracks
requests before anything rendered.
They now load one 200-track page and fetch the next only as the viewer
scrolls toward the end of what is loaded, or as playback approaches it.
The panel reports the furthest index reached and the new useTrackPager
turns that into at most one in-flight page, dropping any page that
arrives after the selection changed.
getAllFavorites goes away with its last caller; getAllTracks stays for
the one list that is small by construction (a single game's soundtrack).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Addresses the deeper issues left open by the previous cleanup pass: the
jukebox downloaded the whole track catalog on mount and re-derived every
facet client-side, and the view had grown to hold all of that state plus
eight screens' worth of markup.
Backend — close the gaps that forced the client-side grouping:
- filter tracks by the owning game's genre and by a year range
- facet games, platforms and game genres, so each sidebar is a paginated
server query with counts instead of a grouping over the full catalog
- a stats endpoint for the home cards' totals
- game genres are counted per rom then folded in Python, mirroring how
the ROM filters aggregate their JSON arrays
Frontend:
- Jukebox becomes a shell over HomeMode / BrowseMode / SessionMode; the
five browse dimensions share one component and differ only by the facet
they load and the filter they pass
- the soundtrack panel takes one normalized PanelTrack[] instead of a
rom-or-catalog prop union, and moves to components/Soundtrack/
- its track list is virtualised, so rows (and their menus) scale with the
viewport rather than the library
- favorites move into a store, ending the four-way hand-fanned copies
- new composables for rom soundtracks, delete confirmation and URL state
- CardRow moves to shared/; platform and jukebox tiles share one Tile
composite instead of two copies of the same chrome
Also fixes a viewer-permission test that the jukebox's PLAYLIST_EDIT
action key had been failing since it was added.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Quality pass over the jukebox feature: extract helpers the diff had
duplicated, collapse copy-pasted template blocks, and remove wasted work
on paths that run per render or per keystroke.
Reuse:
- share shuffled() from utils instead of two Fisher-Yates copies
- add v2/utils/errorMessage.ts and v2/utils/jukebox.ts so the mode list
has one owner instead of three hand-maintained copies
- game_cover_url reuses MusicTrackSchema.cover_url_for
Simplification:
- launch tiles and the session-mode ternary become data-driven
- drop unused order options from the music service and the unreachable
romId fallback in deleteSoundtrack
- extract buildPlayerPayload() from its two call sites
Efficiency:
- count music tracks over a single-column projection
- group tracks with push instead of rebuilding each bucket array
- precompute track rows so the list stops rescanning per render
- page the catalog and the panel's two fetches in parallel
- update a favorite in place rather than rebuilding three arrays
- debounce the search URL write alongside the fetch
Also adds freeRadio tests and fixes a vue-tsc error on route.query.game.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Watching the eligible user's id instead of the whole user object lets
Vue dedupe the reconcile, so the manual once-per-login flag goes away.
Move the remaining in-flight guard next to the code that reads it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Collection.vue and Platform.vue each carried an identical manual
`unmounted` flag to keep a late random pick from navigating a component
that had already gone away. Replace both with a shared composable built
on `onScopeDispose`, so the guard also works outside a component.
VueUse's `useMounted` is not a substitute: it only flips to `true` on
mount and never back to `false` on teardown.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The sort key and the launchbox inverted-title matcher each carried their
own copy of the same 16 articles. Build both patterns from a single
ARTICLES tuple, and point the frontend's hand-synced copy at it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Addresses review feedback on #4142.
`authStore.user` is null at install in the real flow, since AppLayout
mounts while /users/me is still in flight, and the watch is what catches
the arrival. That path had no coverage, and couldn't have: the auth mock
was a plain object, so the watch never fired on change. Making it
reactive exposed a second problem, that the host component was never
unmounted, leaving earlier tests' watchers alive to reconcile again on
the shared state. Unmount in afterEach.
Also swap the double-nextTick settle for an explicit flushPromises, and
optional-chain `running.meta` since the task status is a JSON boundary
where a missing snapshot should mean "no counters yet", not a throw.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
get_cover() called _store_cover() once for CoverSize.SMALL and once for
CoverSize.BIG with the same URL, and each call performed a complete fetch.
The small cover has no distinct source: it is the large image downloaded in
full and then resized in place, so the second request only re-retrieved bytes
already on disk. Every cover cost twice the bandwidth, doubled the load on
every provider, and on ScreenScraper spent a second request from the
account's quota, since media is served from the same authenticated api2
endpoints as metadata lookups.
_store_cover() now takes no size: it fetches once into big.png and derives
small.png from it, the way store_artwork() already did.
A missing small cover no longer triggers a fetch at all. get_cover()
downloads only when overwriting or when the large cover is absent, and
otherwise rebuilds the small one from the large one already on disk via
_derive_small_cover(). That drops the half-written pair case from one request
to none, and keeps a good large cover out of the blast radius of a download
that might fail. The derive path resolves its source through _get_cover_path,
so an uploaded big.jpg or a converted big.webp yields a matching small file
rather than assuming a .png extension.
Failure paths now clean up both destinations. Undecodable bytes are
discarded rather than left on disk, where they satisfy cover_exists() and
stop any later scan from refetching a working cover, and a discarded
chroma-key placeholder also clears a small cover left by an earlier scan.
_derive_small_cover() is the exception: it did not write those bytes, so a
large cover it cannot decode is left in place and only the partial small one
is dropped.
Fixes#4102
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Scan state was built up purely from socket events, so a tab that loaded
while a scan was running started at `scanning: false`: /scan rendered its
empty state with an armed Start button and the navbar pill stayed hidden.
Two changes:
`scan:update_stats` now flips `scanning` on. It is the only event a scan
emits continuously, since `scanning_platform` fires once per platform and
`scanning_rom` only for ROMs the scan actually adds, so an update scan
over a settled library emits nothing else for long stretches.
`reconcileWithRunningScan` asks /api/tasks/status on install and seeds
`scanning` plus `scanStats` from the running job's meta, so a refresh or
a second tab is correct immediately rather than eventually. Gated on the
`tasks.run` scope, the same one the scan socket handler requires. Guards
cover a terminal event landing mid-request and live stats being fresher
than the job snapshot.
The per-platform live log is unchanged: it only ever exists in the
originating tab's memory, so it fills in from the next platform onward.
Fixes#4141
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Both blocks ended on a counterfactual about what storing raw text would
do, which explains the change rather than the behaviour. State what the
code does instead.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Lookups strip the term they search for (and lowercase it where the index
is lowercased), but the import task keyed entries off raw XML text. The
dump has no padded values today, so nothing is broken, but if LaunchBox
ever pretty-printed one of these files the affected index would go dark
with no way to tell from the outside.
The fixture now pads one entry per index the way a pretty-printed dump
would, and the assertions check key text rather than just call counts, so
a regression here fails the test instead of quietly shipping.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
LaunchBox lookups are exact key reads, so a filename that doesn't already
read like a LaunchBox title misses. Three gaps closed:
- No-Intro inverts leading articles ("Legend of Zelda, The - Ocarina of
Time"), LaunchBox keeps them in front, so the de-inverted form is now
tried against the name and alternate-name indexes as well. Measured over
the No-Intro sets: N64 unmatched 200 -> 171, SNES 461 -> 318, Genesis
285 -> 191, GBA 683 -> 576.
- Files.xml, a filename-to-title index the dump already ships and the
update task already caches, was never read by any lookup. It now runs
ahead of the name search, which is the only route to titles whose files
are named nothing like them (MS-DOS, Amiga, Arcade). Its cache key gains
the platform, since the same dump filename exists on several systems.
- A local LaunchBox install was only reachable by an exact filename,
extension included, or by a stem equal to the title. A library of `.zip`
archives could never match an install pointing at `.z64`, and a No-Intro
stem still carries region tags. Both sides now reduce to shared forms.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A scan preferred the LaunchBox ID Playmatch reports and, when the metadata
store could not resolve it, stopped there. Playmatch answers with an ID for
nearly every ROM on some platforms (38/40 sampled N64 dumps, 39/40 SNES,
against 4/40 GBA), so those platforms never reached the filename lookup and
were left with no LaunchBox metadata at all, while a manual match still
found the game.
The branch moves out of the scan closure into `resolve_launchbox_rom` so it
can be tested without a database. An ID already stored on the ROM is still
never traded for a filename guess: it usually came from a manual match.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The debug log printed the session headers and the honeypot pair verbatim.
The token decodes to "<issued-at>::<public IP>|<user agent>|<key>|<hmac>",
so anyone pasting DEBUG logs into a bug report published their host's public
IP address. Logs are also downloadable through /api/logs.
Redact the session headers and drop the honeypot entry from the logged
payload, keeping the URL, search terms and timeout that make the line useful.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Addresses review feedback on concurrent scans (SCAN_WORKERS > 1), where the
handler singleton is shared across in-flight ROM lookups.
Read the session after awaiting the rate limiter rather than before, so a
request paced behind a peer's renewal uses the current session instead of the
one that was live when it queued, and bails out if the session went away.
Acquire the limiter before the /init renewal as well, so a wave of concurrent
403s can't burst past the cap that search requests respect. The endpoint
fixture fetch is left unpaced: it targets GitHub, not HLTB.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
HLTB sessions are short-lived and pinned to the requesting IP address and
user agent. The handler fetched one session at the start of a scan and never
renewed it, so once HLTB rejected it every remaining lookup failed for the
rest of the scan.
Retry with a renewed session on 403, and back off and retry on 429. Report
the actual cause instead of mapping every HTTP error to "check your internet
connection", which is now used only for genuine connect and timeout errors.
Also fixes two adjacent bugs:
- The honeypot key was written into the caller's payload dict in place. That
key rotates with the session, so a renewal would leave the dead key in the
body alongside the new one.
- heartbeat() sent no user agent. HLTB rejects requests without one, and the
httpx default only happens to be accepted today.
initialize() is now async so the session can be renewed from the async
request path, and uses the shared context httpx client.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ScreenScraper's box-2D was the only media type that never got a local
file: it fed url_cover and nothing else. When any other provider won the
cover (the default, since SCAN_ARTWORK_PRIORITY puts ss fourth), the box
front was recorded as a URL and never downloaded, leaving it unreachable
from the UI. Enabling box2d_back/box2d_side could only be made to look
right by forcing ss to the top of scan.priority.cover.
box-2D now records a box2d_path when box2d is listed in scan.media, like
every sibling media type. The Artwork subtab lists the box front, and
the interactive 3D box takes its front face from that scan (falling back
to the rom cover), so all three faces come from the same source and the
3D box no longer depends on cover priority.
Fixes#4127
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The staleness check added in #4113 asks whether a different gallery is
loaded, not whether the user is still in the gallery they clicked from.
Leaving for a non-gallery route never runs `resetGallery()` and never
clears `Collection.vue`'s local `currentCollection` ref, so the captured
scope id still matches: the pick navigates away from wherever the user
went, and a failed pick toasts on that unrelated page.
Treat the view being torn down as stale and OR that into the existing
`stale()` closure, so both symptoms go through the same gate. This also
covers hopping between collection kinds, which are separate route
records whose local ref the id check could never see go stale.
Fixes#4114
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The platforms index only matched the display name, so a platform you
know by its folder on disk, its slug, or its family stayed unreachable
unless you guessed the name RomM shows.
Match the term against the display name, slug, fs_slug, category and
family name. Category contributes both the raw stored value and the
prettified label, since the label is what the list column and the group
heading show while the raw value is what the app stores.
The placeholder now names the searchable fields, in the same style the
ROM search uses.
Non-hero GameCards render at a fixed height with a natural width, which
`.r-gc__art` took from GameCover's `aspect-ratio` via `width: auto`. That
makes the width depend on the aspect-ratio transferred size, and inside a
shrink-to-fit ancestor (the Match ROM dialog's grid cell) the resolution is
circular. WebKit collapses it to a few pixels, so covers render as thin
slivers of the image.
Multiply the height by the cover ratio instead. Both are already CSS
variables on the element, so the width lands on the same number with
nothing left for the engine to resolve.
44ef5cf5 addressed the same report by making the cell a flex container.
That changed where the width was resolved but left the transfer in place,
so the covers still collapsed on 5.1.0.
Fixes#3761
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>