The MobyGames handler pre-encoded search terms with urllib's quote()
before passing them to MobyGamesService.list_games(), which encodes the
query itself via yarl's with_query(). Titles containing special
characters were therefore double-encoded and never matched:
'Sonic & Knuckles' -> title=Sonic+%2526+Knuckles
'... World + Bowser's Fury' -> title=...+%252B+Bowser%2527s+Fury
Pass the raw (unidecoded) term and let the service layer encode it
exactly once, matching how the ScreenScraper handler already works.
Adds regression tests for both the scan path (_search_rom) and the
manual-search path (get_matched_roms_by_name).
Same bug class as reported for ScreenScraper in #3467.
Co-Authored-By: Claude Fable 5 <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>
The MobyGames API returns moby_score on a 0-10 scale and the backend
stores it verbatim (handler/metadata/moby_handler.py), so a score of 5.5
was rendering as "5.5%" instead of "55%". v1 applies the same multiplier
in Details/Title.vue, as does the mock library generator.
This reverses 781e4ff0f, whose premise that the backend already returns
0-100 scores is not borne out by the recorded API responses in the
MobyGames cassettes.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Ratings had their own section in the metadata tab, duplicating the
provider list rendered right below it. Each score now sits on its
provider card, right aligned next to the external ID, and the standalone
section is gone.
Scale normalization and percent formatting move into providerRating(),
next to providerId(), so the provider registry stays the single source
of truth. Formatting itself is now Number.toLocaleString with
style: "percent" rather than toFixed plus manual trailing-zero
stripping, which also drops the NaN chips that missing metadata used to
render.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Repo style forbids em-dashes in comments and text. Also trims the
provider-categorisation comment, whose parentheticals just enumerated the
two lists below it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A *_path with no matching *_url can never be fetched, so it must not
survive when the file it names is missing. No provider produces that
state today (each gates the path on the URL), but store_metadata_media
now guarantees every path it leaves behind points at a real file.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Metadata providers record where each media file should live at match time,
and the path was persisted whether or not the download produced a file. A
non-200 response, an unexpected content type, a transport error, or a
discarded ScreenScraper chroma-key placeholder all leave nothing on disk,
so the ROM kept pointing at a file that was never there.
Local gamelist/Pegasus exports then warned once per ROM per phantom asset
and left an empty assets/<subdir>/ behind, and the frontend built box-face
URLs that 404.
store_media_file now reports whether the file is on disk afterwards, and
store_metadata_media clears the *_path entry for anything that didn't land
while keeping the *_url so a later scan can retry. Both exporters skip a
missing source quietly instead of warning, and no longer create the
destination directory before knowing the source exists.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>