Three fixtures rebuilt the Rom literal that _add_rom already assembles, and
the RomFile boilerplate repeated six times. Adds _add_file, drops the
dict[str, object] cast that forced a type: ignore, and trims the comments.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
master landed 0108_roms_primary_region on the same parent, so the index
migration moves to 0109 and revises that one.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Each of the three provider surfaces had hand-rolled the same section
labels and the same order-and-partition block. The setup wizard's step
and the scan info dialog held byte-identical `GROUP_LABELS` maps, so
those move to `SETUP_GROUP_LABELS`, and the partition becomes
`groupProviders()` with a unit test. The settings view keeps its own
labels, since its `settings.*` keys and section icons differ.
Trims the comments that explained the taxonomy instead of recording what
the code cannot say.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The helper had a single caller, so the stored-ID branch now sits in
fetch_hltb_rom like the Flashpoint and MobyGames fetchers. Its tests move
with it and drive the same six cases through scan_rom.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Cut the rationale that was repeated at every caller down to one line on
the store method, drop the change-history comment from the store test,
and narrow errors with `axios.isAxiosError` the way the rest of the
frontend does instead of a hand-written cast.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The with_files path computes multi_file, top_level_file_count and
has_soundtrack in Python; the other path reads them from correlated
subqueries. The differential test asserts both answer the same for a
flat file, a folder with two top-level files, a nested single file, a
soundtrack folder and a rom with no files at all, so neither predicate
can be edited without the other.
Also assert a rom's files load in a fixed number of queries rather than
one per file.
Claude-Session: https://claude.ai/code/session_01J1pbRJBY3PatzkB5skQNEU
`in` walks the prototype chain, so metadataProviderGroup("toString")
returned the inherited function rather than undefined, breaking the
declared return type. Object.hasOwn keeps the lookup to the map's own
keys.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
MetadataProviderKeyIn claimed a consumer would get a compile error when
a group grew a member, but the hash-matcher code branched on the key:
setHashMatcher treated every non-Hasheous key as Playmatch, so a third
proxy would silently share Playmatch's stored flag and be missing from
the switch list.
Both now hang off a Record keyed by HashMatcherKey, so adding a proxy to
the map fails to compile until it declares its own stored flag and its
name/logo/gate. providerKeysInGroup returns the narrowed union to make
that possible, and the catalog filter asks the taxonomy for the group
instead of matching against the proxy key list.
Payload wiring stays hand-written: which slot a matcher fills is set by
its backend gate, not by the taxonomy.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The "general catalogs vs specialised sources vs hash proxies" split was
declared four separate times, each with its own shape: the scan
composable's key sets, and the provider arrays in the setup wizard's
metadata step, the settings view and the scan info dialog. Adding Steam
in #4241 filed it as specialised in three of them while the composable
treated it as general, and the fix took two passes because the first
sweep only found two of the three stragglers.
Provider slug to group now lives in one map, and each surface derives
its sections from it instead of declaring them, so the three near
identical markup blocks per surface collapse into one loop. Per-surface
presentation data (logos, locale keys, websites, docs URLs, heartbeat
wiring, section icons) stays where it is used. The hash matcher key
list and union are derived from the proxy group too.
Rendered providers, their order and their fields are unchanged; rows
and sections gained data-provider / data-group attributes as test
hooks.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The docstring read as though a stored ID always wins, but the ID branch is
scoped to UPDATE and to UNMATCHED with no metadata. Say so, and cover the
COMPLETE fall-through with a test so the exclusion reads as deliberate.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Remove loader-option and query work the list endpoint discards:
- Batch the has_notes flag instead of eager-loading Rom.notes, whose
backrefs to roms and users are both lazy="joined".
- noload RomUser.user everywhere rom_users feeds RomUserSchema, which
carries no user fields.
- noload Rom.platform and Rom.metadatum in get_siblings_for_roms, where
load_only narrows columns but not relationships.
- Let callers that resolve siblings themselves skip the sibling
relationship load entirely.
- Eager-load RomFile.track_meta in get_files_for_roms, matching every
other call site.
- Order the page over bare ids and fetch rows by primary key when the rom
id index is off, instead of sorting the entity through a filesort.
- Derive the file-stat flags from the page's files when with_files is
set, instead of running three correlated subqueries per row.
- Index rom_files on (rom_id, category).
Claude-Session: https://claude.ai/code/session_01J1pbRJBY3PatzkB5skQNEU
fetch_hltb_rom called the fuzzy filename search unconditionally, so an
UPDATE scan re-guessed the match even when rom.hltb_id was already set. Any
other game scoring above the similarity floor replaced an ID the user had
pinned by hand in Edit ROM.
get_rom_by_id has existed since #2926 was fixed, but only the Edit ROM path
called it. Extract resolve_hltb_rom as a module-level function, following
resolve_launchbox_rom, so the ID-first branch is covered by tests rather
than trapped in a closure over scan_rom's frame.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A 404 or 403 on the per-collection read is the server saying the collection
is gone or off limits, so falling back to the cached copy kept a deleted
collection on screen (and a virtual one that a rescan took below the ROM
threshold that generates it). Those two statuses now drop the cached entry,
which is what makes the caller read not-found, while any other failure still
leaves the cached copy to fall back on.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Three holes in the refresh flow, from PR review:
A refresh asked for while a virtual-collection fetch was in flight hit the
in-flight guard and was dropped, so the pre-change response stayed cached
for the session. It is now queued behind the fetch and runs when it settles.
The refresh promise rejected on a failed request while both callers fire it
in the background, which surfaced as an unhandled rejection and a second
console error. It resolves empty instead, leaving the cached slice alone.
The per-navigation read gave the loader an await before it wrote the page
and drove the gallery, so a slow read could land after the route moved on
and show a collection nobody was looking at. Only the newest load may write
now, which also drops the duplicate gallery load the route guard and the
route watch used to cause between them.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A collection's ROM count was rendered from the collections store, whose
lists are fetched once per session and never refreshed. Virtual collection
membership is derived from ROM metadata, so every scan and every metadata
match moves it with no collection write to update that copy from, leaving
a stale count in the head band next to a gallery that fetches live.
The collection page now re-reads the collection it is opening from the
server, falling back to the cached copy only when that request fails, and
the store re-reads its loaded virtual collections when a scan settles or a
metadata write lands, so the tiles and the open page follow along.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
region_names_for_priority expanded the configured shortcodes into a flat
list of region names and _region_rank turned each name's index into its
rank. Two names claiming one shortcode ("nl" for both Holland and
Netherlands) therefore ranked unequally, so a Holland-tagged rom always
beat a Netherlands-tagged one instead of both falling through to the
filename tiebreak. The helper's own comment claimed otherwise.
It now returns name -> rank keyed on the shortcode's position, so aliases
tie. Unknown and repeated shortcodes still contribute nothing rather than
shifting the ranks after them, which is now covered by tests too.
Reported by Greptile and Copilot on #4260.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The group_by_meta_id dedup window ordered each sibling group by
is_main_sibling then fs_name_no_ext, so absent a manual override the
gallery entry went to whichever filename sorted first: "(Demo)" beat
"(Europe)" beat "(USA)".
Two ordering terms now sit between those: a full release outranks a
pre-release, then the configured scan.priority.region order decides.
Release status comes first because a demo is not a substitute for the
game, so a Japanese release wins over a USA demo.
scan.priority.region already existed but only steered metadata and
artwork selection, so its description is reworded across all locales.
Regions live in a JSON column that no covering index can carry, and 0107
measured what one uncovered reference costs this window: the plan drops
from `type=index, Using index` to `type=ALL, key=NULL`, four times per
gallery page load. 0108 adds a STORED generated column over regions[0]
and covers it in idx_roms_sibling_cover instead, so the ranking reads a
scalar. The engine keeps it in sync and ALTER TABLE populates existing
rows, so no scan hook and no backfill are needed.
Pre-release detection matches the filename rather than the parsed `tags`
column: tags keep the dumper's casing, and fs_name_no_ext is already in
the index.
Reordering the priority list changes which rom represents a group, so the
cached gallery sidecars are dropped when the setting changes.
Closes#1528
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Drop the `exclude-newer-package` pin that froze starlette resolution at
1.0.1, and widen the version specifier to allow the 1.6.x line.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Each row in Settings > Server Stats > Platforms now navigates to that
platform's gallery. Rows render as anchors so modifier-click opens a new
tab, and a plain click runs the same platform-icon morph the Platforms
index rows use. The regions expand toggle stops its click so expanding
regions never navigates.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The v2 player read `player:<rom_id>:core` and `player:<platform_slug>:core` at
mount but never wrote either, so picking a core applied for that session only
and was forgotten on reload. The v1 player writes both on launch, so v2 was
missing that half.
Arcade is where this bites: its core list starts with mame2003, and resolution
falls back to the first entry, so a library that only runs under mame2003_plus
had no way to make the switch stick.
Both directions now go through one module, so the read and the write cannot
drift apart on the key format.
Fixes#4248
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Layer 3 is ephemeral state, so telling agents to write it to localStorage
contradicted the layer it sits under. Per-entity device preferences are their
own thing: they persist per device like layer 1 but stay keyed by entity and
out of user.ui_settings, so they get their own paragraph.
Ordering: review-polish renames things and edits tests, so it has to run
before the stack checks rather than after trunk. State the order explicitly.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Categorized the 54 commits pushed on top of contributor work across the 37
most recent approved PRs, and wrote the recurring patterns down.
The dominant one is comment and docstring trimming: 17 of the 54 commits do
nothing else, and CLAUDE.md already forbids it in three separate rules. The
new skill names the shapes that keep landing (change history, restatements of
the adjacent line, defences of an obvious choice, comparisons to the
alternative not taken) and carries the counter-rule too, since over-extracted
constants get trimmed the same way.
The stack-specific patterns go to the skills that already own them: alembic
numbering collisions and if_not_exists to backend-development, snapshot-before-
await and narrow watch sources to frontend-v2-patterns, the trunk fmt step and
its recurring hits to pre-pr-verification, en_US spelling to frontend-i18n.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The store's defaults report every source as off, so a backend that is
down or refusing the heartbeat used to render as a confirmed
ScreenScraper misconfiguration.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Developer credentials are injected at build time, so a build made
outside our CI (packaged from source, e.g. nixpkgs) has none and
ScreenScraper refuses every request whatever the user account is.
The heartbeat now reports whether they are set, and the v2 metadata
sources page shows a warning banner naming the two environment
variables to set.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>