Commit Graph

11205 Commits

Author SHA1 Message Date
Georges-Antoine Assi
36295e6ad7 fix: narrow await_args before attribute access in moby handler tests
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-16 12:11:41 -04:00
Georges-Antoine Assi
e1de724421 chore: trim comments in moby_handler
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-16 11:33:34 -04:00
Justin
8f809a10a6 fix: remove double URL-encoding of MobyGames search terms
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>
2026-08-10 19:05:48 +02:00
Georges-Antoine Assi
392cc9b0e2 Merge pull request #4143 from Spinnich/fix/cover-downloaded-twice
fix(resources): fetch each cover once instead of once per size
2026-08-08 12:05:48 -04:00
Georges-Antoine Assi
97b3a32148 cleanup 2026-08-08 11:23:53 -04:00
Georges-Antoine Assi
7e5a3492eb Merge pull request #4142 from sdornan/claude/scan-page-missing-active-display-30873c
fix(v2): show a running scan on pages loaded mid-scan
2026-08-08 09:40:25 -04:00
Georges-Antoine Assi
23d0042ffb refactor(v2): narrow the scan reconcile watch source
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>
2026-08-07 19:27:05 -04:00
Georges-Antoine Assi
0f9d2fc53b Merge pull request #4139 from sdornan/claude/github-issue-4127-dd46eb
fix(ss): store the ScreenScraper box-2D front locally
2026-08-07 18:59:15 -04:00
Georges-Antoine Assi
ba6e63e408 Merge pull request #4138 from Spinnich/fix/random-pick-non-gallery-route
fix(v2): drop a random pick that lands after leaving the gallery
2026-08-07 18:50:57 -04:00
Georges-Antoine Assi
3e97df0db8 docs(v2): trim the useIsAlive header comment
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-07 18:46:16 -04:00
Georges-Antoine Assi
3eb199363d refactor(v2): extract the alive-scope guard into useIsAlive
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>
2026-08-07 18:41:07 -04:00
Georges-Antoine Assi
704b0b23fb Merge pull request #4136 from Spinnich/feat/platforms-search-fields
feat(v2): search platforms by slug, folder, category and family
2026-08-07 16:06:04 -04:00
Georges-Antoine Assi
04b2974ddc Update frontend/src/v2/views/PlatformsIndex.vue 2026-08-07 15:52:32 -04:00
Georges-Antoine Assi
30a04e088e Merge pull request #4125 from sdornan/claude/hltb-api-503-error-806ce9
fix(hltb): renew rejected HLTB sessions instead of failing the scan
2026-08-07 14:50:13 -04:00
Georges-Antoine Assi
e8993c1d4d run fmt 2026-08-07 14:37:11 -04:00
Georges-Antoine Assi
a5854b557e Merge pull request #4121 from sdornan/claude/launchbox-n64-matching-b7ce16
fix(launchbox): match ROMs during a scan the way Match ROM does
2026-08-07 11:24:23 -04:00
Georges-Antoine Assi
4a6a461ef3 run fmt 2026-08-07 08:44:46 -04:00
Georges-Antoine Assi
4b574ee284 refactor: share one article list across sort and launchbox matching
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>
2026-08-07 08:42:14 -04:00
Georges-Antoine Assi
05dc9eab46 Merge pull request #4130 from Spinnich/fix/screenscraper-credential-errors
fix(screenscraper): report rejected credentials instead of a bare 403
2026-08-07 08:24:03 -04:00
Sam Dornan
2122875d9c test(v2): cover the deferred-auth reconcile path
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>
2026-08-06 15:48:10 -05:00
Spinnich
d8522991e3 fix(resources): fetch each cover once instead of once per size
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>
2026-08-06 20:35:18 +00:00
Sam Dornan
9c339336a9 fix(v2): show a running scan on pages loaded mid-scan
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>
2026-08-06 15:24:39 -05:00
Sam Dornan
26505ccca4 docs: tighten the launchbox key-normalization comments
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>
2026-08-06 12:50:24 -05:00
Sam Dornan
3fb2e36350 fix(launchbox): normalize every metadata store key on write
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>
2026-08-06 12:50:24 -05:00
Sam Dornan
94f6b16ec1 fix(launchbox): match dump filenames against the metadata store
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>
2026-08-06 12:50:24 -05:00
Sam Dornan
ff2026c66d fix(launchbox): retry by filename when a Playmatch ID resolves to nothing
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>
2026-08-06 12:50:24 -05:00
Sam Dornan
4e149fb707 fix(hltb): redact session material from the request debug log
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>
2026-08-06 12:48:59 -05:00
Sam Dornan
39d7fa0b0f fix(hltb): read the session after pacing, and pace renewals too
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>
2026-08-06 12:48:59 -05:00
Sam Dornan
24d990f21a fix(hltb): renew rejected HLTB sessions instead of failing the scan
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>
2026-08-06 12:48:59 -05:00
Sam Dornan
d758c8f472 fix(ss): store the box-2D front locally so it survives cover priority
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>
2026-08-06 12:38:35 -05:00
Spinnich
237a16a54a fix(v2): drop a random pick that lands after leaving the gallery
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>
2026-08-06 16:35:08 +00:00
Georges-Antoine Assi
46d2114563 fix(screenscraper): restore the login-error marker constant
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-06 11:56:27 -04:00
Georges-Antoine Assi
a0e315e91d manual cleanup 2026-08-06 10:28:15 -04:00
Georges-Antoine Assi
960e18df77 Merge pull request #4131 from sdornan/claude/romm-file-copy-errors-3667f5
fix(media): stop recording paths for media that never landed
2026-08-06 10:19:57 -04:00
Georges-Antoine Assi
9c18eab1ad comment clenaup 2026-08-06 10:09:01 -04:00
Georges-Antoine Assi
9a18aca025 Merge pull request #4135 from sdornan/claude/safari-image-rendering-b90a15
fix(v2): compute game-card cover width instead of deriving it
2026-08-06 09:50:06 -04:00
Georges-Antoine Assi
802c24c667 Merge pull request #4129 from sdornan/claude/github-issue-4126-852db9
fix(hashing): extract CHD SHA-1 for folder-based ROMs
2026-08-06 09:38:39 -04:00
Spinnich
9e9cefac6e feat(v2): search platforms by slug, folder, category and family
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.
2026-08-06 12:48:00 +00:00
Sam Dornan
e9fe52a108 fix(v2): compute game-card cover width instead of deriving it
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>
2026-08-05 21:39:06 -05:00
Sam Dornan
63aa82566e refactor(hashing): call CHD probe inline instead of via a thread
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 21:21:21 -05:00
Georges-Antoine Assi
234c5b3ea2 Merge pull request #4120 from sdornan/claude/romm-playmatch-disabled-bug-60843f
fix(v2): keep Playmatch selectable when providers are set to All
2026-08-05 21:34:47 -04:00
Georges-Antoine Assi
a5097b67b2 Merge pull request #4112 from TowyTowy/fix/state-reupload-emulator-desync
fix(states): repoint the row when a re-upload changes emulator
2026-08-05 20:41:52 -04:00
Georges-Antoine Assi
b0b07c4f85 Merge pull request #4096 from wadiebs/feat/v2-header-provider-ratings
feat(Rating): show provider ratings
2026-08-05 20:36:04 -04:00
Georges-Antoine Assi
d64c6d7ec5 cleanup 2026-08-05 20:31:01 -04:00
Georges-Antoine Assi
78c3b4b588 fix(v2): restore MobyGames 0-10 score scaling
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>
2026-08-05 20:25:39 -04:00
Georges-Antoine Assi
6f8b509b71 refactor(v2): show provider ratings on metadata source cards
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>
2026-08-05 20:25:29 -04:00
Sam Dornan
198f471e75 docs: drop em-dashes from the scan-provider comments
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>
2026-08-05 19:16:17 -05:00
Sam Dornan
984c40c158 fix(media): clear a recorded media path that has no URL to fetch from
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>
2026-08-05 15:07:16 -05:00
Sam Dornan
656c5d7d23 fix(media): stop recording paths for media that never landed
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>
2026-08-05 14:54:45 -05:00
Sam Dornan
a3d6fef4ac Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-08-05 14:05:57 -05:00