Every surface that enumerates roms to point at their files was fetching the
whole platform and discarding the file-less ones in Python. Give filter_roms a
`physical` filter to sit alongside `missing`, and pair the two in
HAS_FILE_ON_DISK_FILTERS, the query-side twin of Rom.has_file_on_disk.
- The device feeds lose _servable_roms(); the three get_roms_scalar calls spread
the filters instead, so the dropped roms no longer get their RomFile rows
selectin-loaded just to be thrown away.
- Both exporters filter in SQL. Pegasus was collecting and copying assets for
roms it went on to skip, and the ES-DE guard's `not rom` arm was dead.
- The bulk zip download applies them to its platform/collection selector. A
physical game contributes no files, so it only inflated the rom count in the
log line, the generated "N ROMs (crc).zip" filename, and the bulk cache
namespace. Roms named by explicit id still bypass this.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Physical games encoded file-lessness as is_physical=True with
missing_from_fs=False, while every consumer asked the same question through
missing_from_fs alone. Each of those consumers was therefore wrong for a
physical game, and each would have needed its own is_physical rider.
Add Rom.has_file_on_disk, covering both reasons a rom has no file, expose it
on RomSchema, and route the file-dependent surfaces through it:
- The ES-DE and Pegasus exporters no longer emit entries whose path points at
the .physical sentinel folder.
- The device feeds gain a single _servable_roms() seam, so all three entry
points that enumerate roms drop the ones with no file rather than minting
download URLs for them.
- GET /roms/{id}/content answers 404 with a reason instead of falling through
to the generic "no files found".
- v2 gates Play, Download, copy-link and the QR share on the flag, in
useCanPlay and useGameActions rather than at each of the surfaces.
The is_physical exclusions in mark_missing_roms stay: they are what maintains
the invariant that a physical game is never flagged missing, and the one in
the missing filter keeps a stray flag away from the cleanup task that
hard-deletes.
Also translate the physical-game and barcode strings, which had been copied
into eleven locales as English.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Backend:
- Drop the post-scan re-assert of is_physical/upc/fs_path in
create_physical_rom; scan_rom already forwards them in rom_attrs. The test
fake was written to drop those fields to exercise the dead path, so it now
matches the real scan_rom contract.
- Extract build_hashless_fs_rom() and use it from both the physical endpoint
and the scan socket, which built the same FSRom literal by hand.
- Return added_rom instead of re-fetching it; add_rom is already decorated
with @with_details, so get_rom repeated the whole eager-load fan-out.
- Pair invalidate_filter_values_cache() with refresh_affected_smart_collections(),
as every other rom-mutating endpoint does.
- Reword the 409 detail: build_physical_fs_name uniquifies the name, so an
IntegrityError can only mean a concurrent add.
- upc_handler: inline the single-use base_url and hoist the minimum title
length to a module constant.
Frontend:
- Load BarcodeScannerDialog lazily. GlobalDialogs is mounted on every page, so
the static import chain put ZXing (~438 KB) in the eager layout chunk. The
scanner's watcher now runs immediate/post so it still starts when mounted
behind a v-if.
- Guard the scanner against a teardown that races the decodeFromConstraints
await; closing during the permission prompt left the camera on and the
decode loop running.
- Render the UPC scan trigger through RTextField's append-inner adornment
instead of a hand-built flex row.
- Type the createPhysicalRom payload with the generated PhysicalRomCreateForm
and drop the metadataSources argument, which had no caller.
- Declare @zxing/library directly; it was imported but resolved transitively.
- Drop two write-only refs, scope the reader local to startCamera, and trim
comments that restate the code.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Unify manuals and walkthroughs on one document model instead of a
separate walkthrough subsystem. Walkthroughs are RomFiles under a new
WALKTHROUGH category with an optional RomFileDocMeta provenance sidecar,
and reading progress is a per-user RomFileUser row keyed on rom_file_id
so the same mechanism covers manuals and walkthroughs.
Backend:
- models: RomFileCategory.WALKTHROUGH, DocSource, RomFileDocMeta,
RomFileUser; migration 0110 (enum value + two tables, cross-DB)
- serve .txt/.html documents inline (HTML under a sandboxing CSP);
add .txt to allowed manual files
- endpoints: walkthrough upload / GameFAQs fetch / delete, and per-user
reading-progress GET (ROMS_READ) / PUT (ROMS_USER_WRITE, like notes, so a
kiosk guest capped to the read scopes cannot write)
- last_page is range-checked, so an out-of-range value is a 400 rather than
an integer column overflow
- the guide body is read under the size cap instead of being buffered in
full and truncated afterwards
- GameFAQs import extracts text only (stored as .txt); no remote HTML is
persisted or served. Host-allowlisted on top of the SSRF-safe client
- a Cloudflare bot challenge is detected and reported as "open it in your
browser and upload the text" instead of an opaque 403
- reading-progress upsert retries as an update on a unique-constraint
race, so concurrent saves for one user/file can't 500
- a GameFAQs guide is removed from disk again if indexing it fails,
rather than being left unreferenced
- tests for CRUD, progress, the GameFAQs parser/URL validation, and
hidden-rom masking on every walkthrough route
Frontend (v2):
- TextViewer (.txt/.html), useReadingProgress composable, WalkthroughSubtab
(upload + add-from-GameFAQs-URL + delete + progress), wired into MediaTab
- ManualSubtab renders .txt manuals; walkthrough category surfaced in
FilesTab; regenerated types; i18n keys across all locales
- a pending scroll position is committed before the viewer follows a new
document, so switching files mid-debounce no longer drops it
- WalkthroughSubtab gates upload, the GameFAQs URL field, and delete on
useCan("rom.edit"), as ManualSubtab already does
AI assistance: implemented with Claude Code (Opus 4.8). The data-model
design, backend, migration, tests, and v2 UI were AI-authored under human
direction. Alternative approach to #2892.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The previous test built its own AsyncOAuth2Client and passed an explicit
code_verifier, so it asserted Authlib's behaviour rather than RomM's and
passed with or without the fix.
Drive oauth.openid.authorize_redirect (what /api/login/openid calls) and
assert the challenge on the redirect matches the verifier saved to the
session, which is the pair the callback needs to redeem the code.
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>
CLAUDE.md caps a comment at one or two lines and a docstring at one
sentence. The rationale that was inline (the failure mode, the
backwards-compatibility argument, the OAuth 2.1 reference) belongs in the
PR body, so what stays is the one fact the code cannot convey: Authlib
derives no code_verifier unless code_challenge_method is set.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Authlib only derives a code_verifier when `code_challenge_method` is set
on the client, so the OIDC client registered in `decorators/auth.py` sent
no `code_challenge` at all. Against a provider that mandates PKCE the user
authenticates successfully and is then redirected back without a `code`,
which surfaces as a generic login failure with nothing useful in the logs.
Set `code_challenge_method: "S256"` in `client_kwargs`. Providers that do
not support PKCE ignore the extra parameters (OIDC Core 3.1.2.1), so this
is backwards-compatible, and OAuth 2.1 requires PKCE of every client.
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>