Commit Graph

503 Commits

Author SHA1 Message Date
Georges-Antoine Assi
eec574b49b fix(metadata): give UniversalPlatformSlug a leaf home
Both CI failures came from one import cycle. RQ could no longer resolve
`endpoints.sockets.scan.scan_platforms`, and the e2e seed script failed the
same way, because `sigil` imports the platform slug enum, importing anything
under `handler.metadata` runs its `__init__`, that reaches `gamelist_handler`
which imports `handler.filesystem`, and `roms_handler` there imports `sigil`
back while it is still half-initialised.

The cycle predates this branch. It stayed hidden because `scan.py` reached
the enum through `utils.switch`, imported late enough that
`handler.filesystem` was already loaded; naming the adapter directly moved
that import to the top of the module and the ordering luck ran out.

So the enum moves to `utils/platform_slugs.py`, which imports nothing but
`enum`. Naming a platform no longer drags in httpx, redis and the titledb
task, and the 29 call sites point at the module that owns it rather than
picking it up from a 1000-line metadata handler that happens to re-export
it. `import adapters.services.sigil` now also works on its own, which it
did not before.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-04 14:28:49 -04:00
zurdi
fc8cfbc6f1 feat(scan): add a files scan that reconciles rom folders incrementally
Files added to an already-scanned folder ROM could only be picked up by a
complete or hashes rescan, which rehash every known file. The new `files`
scan type scans new games like quick and re-lists the files of existing
folder ROMs, hashing only new or changed files and recomputing the
ROM-level hashes only when a top-level file changed. Per-rom update and
unmatched scans reuse the same incremental mode, and the filesystem watcher
enqueues it instead of quick.

Also stores rom_files.last_modified as Double (MariaDB FLOAT rounds a
current mtime to about 128 seconds), adds the CHEAT value missing from the
PostgreSQL category enum, maps `patches/` to the patch category and
excludes upload temp files from scans.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WbesTQXohyAWWcLV5iiEN
2026-09-03 17:11:03 -04:00
Georges-Antoine Assi
97a16e2c79 refactor: tighten comments and tests on the sigil branch
Reverts the FileRow hash-chip loop. It was left over from the per-file
version chip that no longer exists, so it is unrelated to title ids.

Cuts the comments that restate the code or defend an obvious choice, and
the `Args:` block on `get_matching_missing_rom` that repeated its own
parameter names. The CNMT content-type rationale now lives only on
`CONTENT_TYPE_CATEGORIES`.

Tests exercise the production path: the title id regex is checked with
`fullmatch`, the way the caller uses it, and `test_identity` builds its
auth header the way every other endpoint test does.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-02 17:13:20 -04:00
Georges-Antoine Assi
7036ae0e9c Merge remote-tracking branch 'origin/master' into feature/sigil-title-ids 2026-09-02 16:34:48 -04:00
Georges-Antoine Assi
a7a15754b0 Merge remote-tracking branch 'origin/master' into claude/steam-metadata-provider
# Conflicts:
#	backend/config/__init__.py
#	backend/config/config_manager.py
#	backend/endpoints/heartbeat.py
#	backend/endpoints/responses/heartbeat.py
#	backend/endpoints/responses/rom.py
#	backend/endpoints/roms/__init__.py
#	backend/handler/database/roms_handler.py
#	backend/handler/metadata/__init__.py
#	backend/handler/scan_handler.py
#	backend/models/rom.py
#	backend/tasks/scheduled/scan_library.py
#	backend/watcher.py
#	env.template
#	frontend/src/__generated__/models/Body_update_rom_api_roms__id__put.ts
#	frontend/src/__generated__/models/DetailedRomSchema.ts
#	frontend/src/__generated__/models/MetadataSourcesDict.ts
#	frontend/src/__generated__/models/SimpleRomSchema.ts
#	frontend/src/locales/bg_BG/settings.json
#	frontend/src/locales/cs_CZ/settings.json
#	frontend/src/locales/de_DE/settings.json
#	frontend/src/locales/en_GB/settings.json
#	frontend/src/locales/en_US/settings.json
#	frontend/src/locales/es_ES/settings.json
#	frontend/src/locales/fr_FR/settings.json
#	frontend/src/locales/hu_HU/settings.json
#	frontend/src/locales/it_IT/settings.json
#	frontend/src/locales/ja_JP/settings.json
#	frontend/src/locales/ko_KR/settings.json
#	frontend/src/locales/pl_PL/settings.json
#	frontend/src/locales/pt_BR/settings.json
#	frontend/src/locales/ro_RO/settings.json
#	frontend/src/locales/ru_RU/settings.json
#	frontend/src/locales/tr_TR/settings.json
#	frontend/src/locales/zh_CN/settings.json
#	frontend/src/locales/zh_TW/settings.json
#	frontend/src/services/api/rom.ts
#	frontend/src/stores/heartbeat.ts
#	frontend/src/v2/components/EditRom/MetadataIdSection.vue
#	frontend/src/v2/components/GameDetails/RelatedGameCard.vue
#	frontend/src/v2/components/GameDetails/providers.ts
#	frontend/src/v2/components/Scan/ScanInfoDialog.vue
#	frontend/src/v2/utils/metadataProviders.ts
#	frontend/src/v2/views/Settings/ScanSettings.vue
2026-09-01 16:49:24 -04:00
nendo
e04b6035f2 Merge upstream master into feature/sigil-title-ids
Upstream took 0113, so the sigil migration rechains onto
0113_roms_locked_fields as 0114. The sigil build stage keeps its place
ahead of the emulator stage, which upstream renamed for js-dos.
2026-08-31 11:39:53 +09:00
Georges-Antoine Assi
fc46c3eb1c Merge branch 'master' into feat/demozoo-pouet-phase0
Renumber the two migrations onto master's head: 0108/0109 collided with
0108_roms_primary_region and 0109_rom_files_category_index, leaving the
chain with two heads. They are now 0114 and 0115 behind 0113.

Both rebuild the roms_facets sync triggers from a hardcoded column list,
so add the publishers and developers columns 0112 introduced. Without
them the rebuilt triggers would have silently stopped mirroring the two.

Adopt master's provider taxonomy. METADATA_PROVIDER_GROUPS now carries
demozoo, pouet, and csdb as catalogs, which replaces the branch's own
GENERAL_PROVIDER_KEYS set and feeds the setup wizard, the scan dialog,
and Settings from one registry. CSDb reaches the scan explainer for the
first time; it was already selectable there.

Regenerate the frontend types: DetailedRomSchema was missing the three
metadata blobs the backend has always declared on RomSchema, and the
blobs are now typed rather than Record<string, unknown>.

Correct the setup strings that still called the three sources enabled by
default, and sort the locale keys.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-30 21:32:11 -04:00
Georges-Antoine Assi
2d089fe914 Merge pull request #4309 from rommapp/fix/doom-platform-slug
fix(platforms): add doom as a platform with its standalone provider mappings
2026-08-30 15:49:37 -04:00
Georges-Antoine Assi
414dea2b49 Merge remote-tracking branch 'origin/master' into agent/jukebox
# Conflicts:
#	frontend/src/stores/soundtrackPlayer.ts
#	frontend/src/v2/components/GameDetails/MediaTab.vue
#	frontend/src/v2/components/GameDetails/SoundtrackPanel.vue
2026-08-30 15:16:45 -04:00
Georges-Antoine Assi
8029ffed2c refactor(music): review cleanup across the jukebox branch
Consolidates the three copies of the track-time formatter into a shared
formatTrackTime util (Intl.DurationFormat can't match the "2:37" format,
its digital style always pads minutes), points the six private copies of
the axios errorMessage helper at the shared util (MediaTab's was dead
code and is just removed), drops the legacy ?mode= redirect since the
jukebox never shipped with query-based modes, shrinks the free-radio
sample from 1000 tracks to the 200 that comfortably fill an hour, and
prunes redundant comments.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-30 15:05:21 -04:00
Georges-Antoine Assi
dc22c2239c refactor(music): serve jukebox browsing from the API
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>
2026-08-30 08:18:41 -04:00
Georges-Antoine Assi
974b2a4be7 refactor(music): simplify jukebox and share duplicated helpers
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>
2026-08-30 07:20:51 -04:00
Georges-Antoine Assi
ccf0640adb fix(platforms): register doom as a platform slug
RomM already ships everything needed to run Doom: the prboom core in the
EmulatorJS core map, platform icons, webrcade feed art and a console UI
theme, all keyed on the doom slug. The slug itself was never a member of
UniversalPlatformSlug, so the folder mapping picker (built by
get_supported_platforms from that enum) had no entry to auto-detect or
bind a doom folder to, and the playable filter excluded its ROMs.

No metadata provider mappings yet; those are a separate question.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-30 06:59:53 -04:00
nendo
64a1b57661 refactor(scan): name the save fields for what they address
`save_id` collided with two other meanings in the codebase: `Save` is a
model, and `DeviceSaveSync.save_id` is a foreign key to it. Neither is
what this field holds, which is the on-disk name an emulator gives a
game's saves. It becomes `save_target`, and `save_usage`, which said
nothing about what it decided, becomes `save_target_layout`. Both carry
a `doc=` so the meaning is at hand where the columns are read.

The per-file copies are gone. Nothing read `RomFile.save_id`, and the
per-file `title_id` and `title_version` only fed display chips, while
the category derived from the binary content type is what actually
drives update and DLC behaviour and stays. Save layout belongs to a
game rather than to one of its files, so a client can no longer read a
file's value and build a wrong directory from it.
2026-08-30 13:22:53 +09:00
Georges-Antoine Assi
9588287984 Merge pull request #4305 from rommapp/refactor/rom-ids-scope-assets
refactor(assets): make rom_ids the only ROM scope on saves and states
2026-08-29 17:50:23 -04:00
Georges-Antoine Assi
b75c499d8b refactor(assets): make rom_ids the only ROM scope on saves and states
The saves handler carried two ROM filters that ANDed together, and the states
handler had only the singular one, so the same "which ROMs" question had three
answers across two sibling handlers. Collapse both onto rom_ids: a single-ROM
lookup is just a one-element scope, which is what the three internal callers in
the saves endpoint now pass.

That leaves the routes to fold their own public rom_id param into the scope.
Rather than write the fold twice, narrow_rom_id_scope joins utils/validation
beside RomIdScope, keeping the documented "combined with rom_id" semantics: both
filters still apply together, so the effective scope is their intersection.

GET /api/states gains the rom_ids param GET /api/saves got in #4304, declared
with the same shared RomIdScope, so a client syncing a known set of ROMs can
discover states the same way it discovers saves, under the same cap and the same
422 on a bad scope.

One behaviour shift falls out of the handler's old falsy check: rom_id=0 used to
be ignored and return the whole library, and now scopes to nothing, which is
what RomIdScope's positive-ID rule says a zero means.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-29 17:38:08 -04:00
Sam Dornan
b2e3de4772 Merge branch 'master' into claude/steam-metadata-provider
Resolves the additive conflicts against master:

- config, handler registry and the roms endpoint imports keep both the
  Steam and the new UPC-lookup entries.
- Renumbers the Steam migration to 0113 (master took 0109) and rebases it
  onto 0112_publisher_developer_split.
- Syncs the migration's pre-Steam facet mirror list with 0112, which added
  publishers/developers to the roms_facets triggers.
- Groups SteamMetadata's publishers/developers with the shared provider
  keys, now that master has made them a shared field.
2026-08-29 16:36:58 -05:00
Georges-Antoine Assi
c0ab254c59 Merge pull request #4077 from Spinnich/fix/missing-firmware-cleanup
feat(firmware): let missing firmware be found, cleaned up, and kept out of the player
2026-08-29 17:04:23 -04:00
Georges-Antoine Assi
bec9846718 refactor(firmware): trim comments and name the platform list
Cut the comment blocks that ran past two lines, and rename
platformItems to affectedPlatforms since it holds only the platforms
that have missing firmware, unlike the all-platforms list of the same
name in MissingGamesSection.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-29 16:46:51 -04:00
Georges-Antoine Assi
65819d15b4 refactor(saves): move the rom_ids validators to utils/validation
The scope validator and its cap were sitting in the saves DB handler, which
made two endpoints the first non-test callers to import a behavioral symbol
straight through the handler.database facade, for a helper with no DB content
and that get_saves never calls. They belong beside the repo's other
endpoint-facing validators.

Fold the comma-separated ID parse into a shared parse_comma_separated_ids so
the "comma-separated integers" message the tests assert on has one home, and
call it from the ROM download route that already had it inline. Both scope
validators now raise ValidationError like the rest of the module, which lets
negotiate validate in the endpoint body next to its other request-shape
checks: the two routes reject a bad scope with the same 400 instead of one
returning 400 and the other 422.

Also narrow the sync-record lookup to the newest row per slot (superseded rows
were fetched and discarded), and share one second_rom / second_save fixture
instead of three near-identical builders across the new tests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-29 16:09:51 -04:00
Georges-Antoine Assi
841a7a2f9f fix(settings): scope a cleanup to every selected platform
The cleanup tasks took a single platform_id while both Missing tabs
offer a multi-select, so picking two platforms ran the unscoped
cleanup over the whole library. The confirmation dialog still named
the selection, so the tab deleted more than it said it would.

Take platform_ids on both cleanup tasks and filter firmware by the
whole list, so what runs matches what the dialog names.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-29 15:56:56 -04:00
Georges-Antoine Assi
e36d7646b2 feat(saves): scope save discovery to a set of ROM IDs
Sync clients that hold a subset of the library had no bounded way to ask
for the saves relevant to the ROMs on the device: `GET /api/saves` filters
one ROM at a time, and negotiation always evaluated the user's whole
slotted save set, offering downloads for ROMs the device cannot play.

Add a `rom_ids` scope to both. `GET /api/saves` takes a comma-separated
list (matching the `/roms/download` convention) and `POST /api/sync/negotiate`
takes a list in the request body, so a client with many ROMs is not bound by
URL length. Negotiation widens the scope with the ROMs the client sent saves
for, so a client save is never misread as an upload because its ROM was
omitted. The scope is read-only: an omitted ROM is outside the request, never
a deletion signal.

Both share one limit and one validation rule in the saves handler, and both
reject a scope that is non-positive or over the cap rather than truncating.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-29 15:44:44 -04:00
Georges-Antoine Assi
e32c8c68cd refactor(firmware): reuse shared helpers in the missing firmware code
Swap the hand-rolled platform picker in MissingFirmwareSection for the
shared PlatformSelect, and fold the triplicated firmware builder in the
tests into an add_firmware factory fixture.

Keep Platform out of list_firmware: the relationship is lazy="joined",
so every row also ran Platform's rom_count and fs_size_bytes aggregate
subqueries over roms, for data no caller reads.

In useTaskCompletion, the resolver already identifies the live wait, so
drop the parallel generation counter and the unused cancel export.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-29 15:42:22 -04:00
Georges-Antoine Assi
c45587fe7c Merge remote-tracking branch 'origin/master' into fix/missing-firmware-cleanup
# Conflicts:
#	frontend/src/locales/pt_BR/settings.json
#	frontend/src/v2/views/Player/EmulatorJS.vue
2026-08-29 15:18:00 -04:00
nendo
7e824d4977 Merge remote-tracking branch 'upstream/master' into feature/sigil-title-ids 2026-08-28 10:58:01 +09:00
Georges-Antoine Assi
d62452b069 refactor: give the publisher/developer derivations one home
Follow-up cleanup on the company metadata split.

- Hasheous returns `involved_companies` keyed by id, not as the list IGDB
  itself returns, so iterating it yielded the dict's string keys and raised
  on `c.get("publisher")`. Read it through the same pydash accessor the
  sibling `companies` line uses, and cover both shapes with a test.
- ss/ra/flashpoint/gamelist bind the publisher and developer lists once and
  build `companies` from them, so the merged list cannot drift from the
  split it is meant to be the union of. Follows launchbox's existing shape.
- The exporters shared one copy of the "prefer the explicit field, fall back
  to the companies ordering" rule; it now lives on `RomMetadata` as
  `primary_developer` / `primary_publisher`.
- Migration 0112 gates its two backfills on a probe. No stored blob carries
  the new keys before a re-scan, so they otherwise scan the whole roms table
  twice, and rewrite every roms_facets row, to write nothing.
- Smart collections no longer claim a `selected_publisher` legacy key that
  never shipped.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-27 18:38:02 -04:00
Georges-Antoine Assi
42ebaaec49 feat: split company metadata into publishers and developers
Metadata providers (ScreenScraper, RetroAchievements, LaunchBox,
Flashpoint, gamelist, IGDB) distinguish the publisher from the developer
of a game, but RomM amalgamated both into a single `companies` list at
ingestion, so the distinction was unrecoverable. This adds `publishers`
and `developers` as new, refined fields end to end while keeping
`companies` (the merged union) working exactly as before.

Backend:
- Handlers now emit publishers/developers alongside the unchanged
  companies list; IGDB requests the involved_companies developer/
  publisher flags to split by role.
- Migration 0112 adds generated_publishers/generated_developers columns
  on roms, projects them through the roms_metadata view, mirrors them
  into roms_facets, and adds publisher/developer virtual-collection
  types (triggers/functions rebuilt for MariaDB/MySQL + PostgreSQL).
- Filters, facets, endpoints, smart collections and the gamelist/pegasus
  exporters all carry the new fields; exporters prefer the explicit
  split and fall back to the companies heuristic for un-rescanned ROMs.

Frontend (v2):
- Shared filter store + API service, gallery filter drawer, URL
  persistence, game detail display (Developers/Publishers with a
  Companies fallback), edit dialog, smart-collection criteria, and a
  publisher/developer "group virtual collections by" option.
- Also relabels the confusing "company"->"Developer" group-by option
  to "Company" now that a proper Developer option exists.

Fixes #3518

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-27 14:44:30 -04:00
Georges-Antoine Assi
bc95411239 feat: filter the gallery by physical games
Physical games were addable and visible but not selectable: nothing let a user
ask "what do I own on a shelf?" or exclude shelf entries from a view of what is
actually on disk.

Expose the handler's `physical` filter as a `GET /roms` query param and carry it
through the v2 gallery the way `filterSoundtrack` is carried: a tri-state row in
the filter drawer (all / physical only / file-backed only), the toolbar's active
count, `?filterPhysical=` in the URL so a filtered view stays bookmarkable, and
the smart-collection criteria plus their summary row.

Reuses mdi-cube-outline, already this feature's icon, with cube-off-outline as
the negative. Translated into all 18 locales, taking each one's existing term
for a physical game from rom.json.

Verified against the dev library (74898 roms): physical=1, file-backed=74897,
an exact partition, with the filtered gallery showing only the physical entry in
both themes and the control reachable by keyboard.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-27 11:01:47 -04:00
nendo
64779f8223 fix(scan): reassociate a renamed non-hashable ROM by its title id
Reassociation matched a moved or renamed file to its existing entry by
CRC, MD5 and SHA1, and deliberately refused a partial set. Switch and
Switch 2 are never hashed, so nothing could ever match them: a renamed
file created a duplicate and stranded the original entry, holding the
user's collections and notes, as missing from the filesystem. That is
the one platform title-id embedding renames. The binary title id is the
identity those platforms do carry, so it serves when hashes cannot,
under the same single-unambiguous-match rule.
2026-08-27 13:29:30 +09:00
Georges-Antoine Assi
a5f37d32e3 refactor: drop file-less roms in the query, not after loading
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>
2026-08-26 21:42:01 -04:00
nendo
5425a227ab Merge upstream master into feature/sigil-title-ids
Upstream took 0108 through 0110, so the four sigil migrations rechain
onto 0110_walkthrough_docs as 0111 through 0114. RomFile keeps both the
title id index and upstream's new rom_id/category composite, and
models/rom.py keeps SaveUsage alongside the new document types.
2026-08-26 19:40:48 +09:00
Georges-Antoine Assi
69938b1cee add support for physical (DB only) games 2026-08-25 20:19:05 -04:00
Georges-Antoine Assi
3c95231294 feat: walkthrough documents with reading progress and GameFAQs import
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>
2026-08-25 19:40:20 -04:00
Georges-Antoine Assi
80dff4f7cf refactor(roms): fold the rom list test fixtures onto shared helpers
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>
2026-08-22 15:46:20 -04:00
Sam Dornan
6a8cb34645 feat(steam): add the Steam storefront as a metadata provider
Steam covers the PC platforms RomM otherwise has thin metadata for, and
its store payload is provider-grade on its own: title, description,
portrait capsule art, screenshots, genres, developers, publishers,
release date and Metacritic score, with no API key.

Valve documents no storefront API, so this reads the two endpoints that
back the store's own search box and app pages, paced well under the ~200
requests per 5 minutes they tolerate. Every failure path degrades to "no
match" rather than aborting a scan, and the provider is opt-in behind
STEAM_API_ENABLED, matching HowLongToBeat and Flashpoint.

Matching is gated on the platform slug so the three PC platforms are the
only ones that spend a request. The storefront's search index carries
DLC, soundtracks and tools alongside games, so hits are filtered by type
and then confirmed against the app page, which is the only place a demo
or a video is distinguishable from a game. A (steam-12345) filename tag
pins a match by hand when the title is ambiguous.

SteamMetadata reuses the key names the other providers already use for
the values they share, so wiring Steam into the generated facet columns
later is a SQL change with no stored-row reshaping.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-22 13:35:42 -05:00
Georges-Antoine Assi
217623a0c6 Merge remote-tracking branch 'origin/master' into perf/roms-list-per-page-work 2026-08-22 14:34:42 -04:00
nendo
97d2f7b5b7 perf(roms): trim per-page work on the roms list endpoint
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
2026-08-22 08:19:18 +09:00
Sam Dornan
3819c8762d fix(gallery): rank region names by their shortcode's position
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>
2026-08-21 12:11:56 -05:00
Sam Dornan
5c43a97687 feat(gallery): pick a game's default version by region priority
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>
2026-08-21 11:55:07 -05:00
Pablo Pérez Corral
795ff5c5ff apply existing metadata filters before grouping different roms versions under a single entry. 2026-08-19 15:14:01 +02:00
Axel Quack
45bcb2bed3 feat(metadata): add Demozoo, Pouët, and CSDb handlers
Identify demoscene productions as ROMs via filename tags, Edit-ROM
id/URL paste, Demozoo ?title= + rank, unique Pouët search.php 302,
and CSDb XML by id (no HTML scrape). Scene ids lock name/summary/cover
so game catalogs cannot attach a similarly titled box.

CSDb XML is parsed with defusedxml and capped; screenshot and extra
links are stored only when they are http(s).

Fixes rommapp/romm#1796 (Phase 0–2).
2026-08-17 08:59:54 +01:00
nendo
95f30b409c Merge upstream master into feature/sigil-title-ids
Resolve conflicts:
- rom_files/roms indexes: union the title-id index with upstream's new
  hash-search indexes.
- scan.py: keep upstream's ScreenScraper scan refactor, retaining the
  LIBRARY_BASE_PATH and UniversalPlatformSlug imports the body still uses.
- cleanup_orphaned_resources tests: take upstream's version.
- Renumber the sigil migrations onto upstream's 0107 head as 0108/0109/0110
  so the alembic chain stays single-headed.
2026-08-17 03:57:25 +09:00
wadie
5f613687e5 feat(music): add jukebox 2026-08-14 10:24:02 +02:00
Georges-Antoine Assi
d67dde2226 Merge pull request #4078 from Spinnich/fix/metadata-sort-perf
perf(roms): sort metadata fields on the indexed roms column
2026-08-04 08:25:30 -04:00
Spinnich
28739f93df chore(roms): trim the comments on the metadata sort columns
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 12:14:08 +00:00
Spinnich
6f167afeb8 perf(roms): sort metadata fields on the indexed roms column
Ordering the gallery by a `roms_metadata` field joined the view back in and
sorted through it. `roms_metadata` is a thin view over STORED generated
columns on `roms` (migration 0098), so that join is `roms` to itself and it
leaves the sort key on a joined table, which no index can serve: the engine
filesorts the whole library for every page.

The generated columns are already indexed, so the three that are offered as
sorts now resolve straight to them and the join goes away. On a 120k-row
table this turns a full scan plus filesort into a 72-row index walk.

The remaining view columns are JSON arrays with no index and no sort that
offers them, so they keep reading the view.

Fixes #4067

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-03 02:03:48 +00:00
Spinnich
3e02fb94ff fix(firmware): let missing firmware be found and cleaned up
A scan flags firmware whose file vanished, but nothing could act on the
flag: stale BIOS entries could only be found by opening each platform's
Firmware tab one at a time, the player still offered them (auto-selecting
the sole entry, so the game failed to boot with nothing pointing at the
BIOS), and platform firmware counts included them.

Adds a `missing` filter to the firmware list endpoint, a
`cleanup_missing_firmware` manual task alongside the ROM one, and a
Missing firmware tab in Library management that lists every flagged entry
library-wide with a bulk cleanup. The player now asks for present
firmware only, and firmware selection moved to a `playerFirmware` util
that never picks a missing entry. `firmware_count` counts only firmware
present on disk; the rows themselves still ship so the Firmware tab can
strike them through.

`FirmwareSchema` gains `platform_id` so the library-wide list can group
by platform.

Fixes #4075

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-02 23:52:21 +00:00
Spinnich
1ee6cea070 perf(roms): pick a random rom without paging to a random offset
The Home "Random Pick" widget asked the API for the library total, then
for the single row at a random offset. Paging to offset N makes the
database walk and discard the N rows before it, so the pick got slower
the bigger the library: measured on an 83,000-game instance, 1.7s at the
median offset and 6.9s deep into the list, on every home page visit.

Adds GET /api/roms/random. It offers the query a batch of random primary
keys and takes any that exist, which is one index lookup per candidate
and unbiased, since every id in the table is equally likely to be
offered. A batch only misses when the query matches too little of the id
space, and it then falls back to counting the set and taking the row at a
random position, reading index entries rather than rows because the
statement selects nothing but the id. Both paths are uniform.

On the same 83,000-game library: 2.9ms median for an unscoped pick
(0.6% of picks take the fallback, 236ms), 19-25ms scoped to a platform.
The widget now resolves a pick in one request.

The endpoint takes the platform / collection scope parameters so the
gallery "Random ROM" buttons (#4068) can move onto it too.

Fixes #4066

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-02 19:25:36 +00:00
Georges-Antoine Assi
509e4d156d fix(hasheous): keep unverified ROMs that predate a match key
`hasheous_metadata` gains keys as RomM maps more of Hasheous' signature
sources, so rows written before `mame_redump_match` existed don't carry it.
On PostgreSQL `hasheous_metadata->>'mame_redump_match'` is then NULL, the OR
chain over the match flags evaluates to NULL instead of false, and `NOT (...)`
stays NULL: the unverified filter returned nothing for those rows until they
were rescanned.

Each extraction is now coalesced to false. The JSON path is untouched, since
SQLAlchemy compiles `as_boolean()` to a CASE whose ELSE branch already folds a
missing key into false.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 19:31:32 -04:00
Georges-Antoine Assi
56f8a51e04 fix(hasheous): read the CHD and DOS signature sources
The match flags on `hasheous_metadata` are keyed off Hasheous'
`SignatureSourceType` names, and two never lined up with what its API
actually returns:

* `MAMERedump`, the source holding Redump's disc images in CHD form, was
  mapped to nothing at all. A CHD identified by its disc-data SHA1 matched,
  got its metadata, and still read as unverified because no flag was set.
* `puredos_match` looked for `PureDOS`; the source is named `PureDOSDAT`, so
  the flag was pinned to False for every ROM.

CHD matches now set `mame_redump_match`, which the verified filter counts and
which the Metadata tab folds into the existing Redump chip (same database,
different distribution format). Existing rows pick the flag up on their next
rescan.

Hasheous also exposes Pleasuredome, TotalDOSCollection, eXo, ScreenScraper and
Generic sources that RomM still maps to nothing; those are left alone since
folding them in widens what "verified" means.

Fixes #4030

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 18:10:16 -04:00