Commit Graph

385 Commits

Author SHA1 Message Date
Georges-Antoine Assi
083ea5f953 perf(gallery): match siblings on every identity id
`sibling_roms` matched on seven providers, the gallery's dedup window on
those plus `flashpoint_id`, and the recommendation feed on those plus
`steam_id`. Three lists, so a pair sharing only a Steam or Flashpoint id
was the same game to one reader and two games to another.

They are one list now. `rom_identity_keys` carries all nine providers,
which makes `provider_id` a varchar since `flashpoint_id` is a string,
and the dedup window's cover index grows by `steam_id` so the window
keeps its indexed plan.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-09 15:42:56 -04:00
Georges-Antoine Assi
dc27acd284 fix(gallery): create the identity triggers before the backfill
A rom written between the backfill and the trigger creation got no key
rows, and nothing short of a later edit to one of its identity columns
would have noticed. Both writes skip a row that is already there, so the
two steps can overlap.

Also correct the revision the docstrings point at and the claim that
IDENTITY_ID_FIELDS contains the group_by_meta_id window's columns.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-09 14:09:49 -04:00
Georges-Antoine Assi
954aa79041 Merge branch 'master' into perf/sibling-roms-materialize
Master keyed the unique roms index on the full path digest, so the
resolution keeps its two indexes and this branch's comment on
idx_roms_sibling_cover, which no longer backs the sibling_roms view.

Both sides added a 0126 revision off 0125; rom_identity_keys moves to
0127 behind master's unique_rom_full_path.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-09 13:47:47 -04:00
Georges-Antoine Assi
a8385cdaa8 style(anniversaries): trim the comments and simplify the day parser
Comment and docstring pass over the `released_days` change: cut the copies of
rationale that already live next to the thing they describe, and drop the
sentences defending obvious choices.

`RELEASED_DAY_REGEX` now carries the calendar ranges, so a match is a valid day
and `parse_released_days` needs no sentinel pair and no second range check.
`release_day_ranges` stops re-sorting what `epoch_ms_in_ranges` already sorts.
`anniversaryQuery`'s return type is a named export, so the widget imports it
instead of unwrapping a `ReturnType`, and the widget's two reset paths share
`showEmptyDay`.

`loadMore` is `loadNextPage`, since it appends one page rather than the rest.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-09 12:34:49 -04:00
Georges-Antoine Assi
976dd09930 refactor(anniversaries): read the day off the shared rom list
`GET /api/roms` already does what `/roms/anniversaries` hand-rolled: it selects
ordered ids over the filtered set, takes the total from that index, hydrates
only the page asked for, and re-projects the rows into id order. So the widget
now asks it for a page rather than owning an endpoint that pulls the whole day.

`released_days` on the list endpoint takes days as "M-D", matching any year, and
`released_before_year` bounds them. Both go through `filter_roms`, so the same
day-of-year match is available to the gallery filters and to smart-collection
criteria, and the range union stays where it was: still sargable, still a
covering index range scan on `idx_roms_generated_first_release_date`, no SQL
date function and no dialect branching. Verified on a 73k-rom database that the
plan through the list endpoint's join is unchanged: `type=range`,
`Using where; Using index`, no filesort.

The filter means exactly what it says, so the calendar policy moved to the
client, where the clock it depends on already lived. `anniversaryQuery` picks
the days and the year bound off the viewer's own date: it skips 1 January,
where several providers park year-only metadata, rolls 29 February onto 28
February in a non-leap year, and bounds the years at the viewer's own. The
server no longer has to second-guess a timezone offset, so the 31 December
asked for on 1 January UTC correction is gone rather than fixed.

Consequences for the widget: the counter is the day's real total instead of one
clipped at a 500-row ceiling that no longer exists, and a card costs one page
of 24 rather than up to 4 MB up front. Paging backwards stays in memory;
only moving past the loaded pages fetches, with the spinner on the arrow so
focus is never yanked mid-page. A failed page keeps the card on screen.

`released_days` is added to the list endpoint's unscoped-cache gate: the
sidecar keys encode no filters, so a narrowed page must not be served under the
shared "all" key. Covered by a test that primes the unscoped key first.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-09 12:02:32 -04:00
Georges-Antoine Assi
500d449382 fix(anniversaries): stabilize the ordering and recover from a failed load
The day's ordering breaks ties on the rom id. Every rom released on the
same calendar day carries the same timestamp, so without it the paging
order, and which rows the 500 ceiling keeps, varied between requests.
MariaDB plans it the same way: still a covering index range scan, no
filesort.

The widget clears the loaded day when a request fails, so the rollover
check retries it. Claiming the day up front held the error copy until
local midnight, and the card offers no way to ask again.

Also pins the clock in `test_defaults_to_todays_utc_date`, which failed
on 1 January and raised on 29 February; corrects the Czech 2-4 plural
form, which the locale's own rule reaches; and drops "scope" from the
endpoint docstring, where it read as a claim about the auth scope
declared right above it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-09 11:34:11 -04:00
Georges-Antoine Assi
b65cc76edc style(anniversaries): fit the ceiling's comment on one line
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-09 11:04:07 -04:00
Georges-Antoine Assi
68e27d866c fix(anniversaries): cap the day's result set
The endpoint answered with every match for the day, so response size
tracked the library rather than the request: the busiest real date on a
96k-rom library is 1,101 roms at roughly 8 KiB of SimpleRomSchema each,
and the 1 January early-return was the only thing holding that off
~23,000.

The ceiling goes on the id selection rather than the response, so it
bounds the hydration and the serialization too, which is where the weight
is. It rides the existing index-ordered range scan, so the plan does not
change and the engine stops early instead of walking the whole union.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-09 11:00:54 -04:00
Georges-Antoine Assi
907ae7a79f Merge branch 'master' into feat/game-anniversary-widget 2026-09-09 10:23:08 -04:00
Georges-Antoine Assi
08f294d0fa Merge pull request #3571 from rommapp/claude/kind-goodall-0b77y7
feat: Per-platform custom library structure with non-destructive identity
2026-09-08 16:46:44 -04:00
Spinnich
47e89132f7 feat(anniversaries): return every match for the day
The 24-item cap was measured against the largest library available and
does not earn its place: on a 96k-rom library the day-of-year index range
scan costs 3.7 ms whether it matches 114 rows or 22,914, so the cap saved
roughly 40 ms and 0.7 MB on a typical day while truncating every single
day of the year (median 132 matches/day, and 100% of days exceed 24).

Removing it also makes the widget's counter a real total rather than a
ceiling, which was the substance of the review comment about "24 / 24"
implying a complete list.

This makes the 1 January skip load-bearing for response size as well as
accuracy: it is the one day that would otherwise answer with 22,914 rows
(28% of all dated roms), where the busiest real day is 1,101.

Addresses the "Result cap hides anniversaries" review comment on #4396.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-08 19:11:44 +00:00
Spinnich
38f5adffc6 fix(anniversaries): take the year from the day asked for, not the server's
Clients send their own local month and day, so around the new year the
server's UTC date can name a different year. 31 December asked for on
1 January UTC bounded the search at the wrong year, letting a release
from the viewer's current year through as an anniversary of itself.

A timezone offset moves the calendar by at most a day, so 31 December /
1 January is the only pair that can disagree, and 1 January already
returns nothing.

Addresses the "Mixed clocks include new releases" review comment on #4396.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-08 17:58:46 +00:00
Spinnich
868a5c03e7 feat(home): add a game anniversary widget
Shows games released on today's date in an earlier year, one at a time,
with arrows to page through the rest. Sits in the Home widget rail beside
Random pick and Library stats, with its own Settings toggle (default on)
and an entry in the drag-reorder list.

New endpoint GET /api/roms/anniversaries, ROMS_READ, whole-library,
returning up to 24 SimpleRomSchema oldest release first. Clients send
their own local month and day so "today" matches the calendar in front of
the user rather than the server's UTC clock.

The day-of-year match is a union of one-day ranges over
generated_first_release_date rather than MONTH()/DAY() on the value.
Ranges are sargable, so idx_roms_generated_first_release_date serves both
the match and the sort as one covering range scan: 195 rows examined and
~2 ms against 63,334 rows and ~70 ms for the function predicate on a
100k-row table. Emitting no SQL date function also means no dialect
branching and no migration.

1 January returns empty. Several providers park year-only metadata there
(ScreenScraper parses a bare year with %Y, CSDb publishes nothing else,
IGDB reports year precision as 1 January), so nothing in the stored data
tells a real 1 January release apart from an unknown day. Leap-day
releases roll onto 28 February in non-leap years.

Visibility follows /random: filter on hidden platforms and roms, then
re-check each hydrated row with perms.can_see_rom.

Closes #3440

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-08 17:31:27 +00:00
Spinnich
6a3d207ece perf(gallery): resample the identity keys after a scan fills them
Migration 0126 samples `rom_identity_keys` right after its backfill, which
on a fresh install runs while the table is still empty. The first scan then
fills it through the triggers, and MariaDB keeps planning `sibling_roms`
against the empty sample: measured on 37k key rows, one gallery page's
sibling statement takes 891.7 ms in that state against 2.1 ms once resampled,
which is worse than the 550.7 ms the view it replaces cost.

InnoDB's auto-recalc does not cover it. It fires and updates the stored row
count, but the plan does not change until the table is reopened or analyzed:
90 s after a trigger-paced fill, `mysql.innodb_table_stats` was correct and
the plan was still the block-nested-loop one.

Addresses the "Fresh Installs Keep Stale Statistics" review comment on #4394.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-08 11:06:41 +00:00
Georges-Antoine Assi
f105622513 fix: address code review on the library structure unique index and relocation
Key the unique roms index on a sha256 digest of the full path. Indexing
(platform_id, fs_path, fs_name) directly is 5804 bytes of utf8mb4, which MySQL
rejects with ER_TOO_LONG_KEY and MariaDB silently demotes to a hash index; the
digest column keeps it a 260-byte BTREE on every supported driver. It is derived
by the same @validates hook that maintains the other fs_name columns, and
resynced explicitly in update_rom and convert_rom_to_folder.

Migration 0126 backfills the digest in one dialect-branched UPDATE. A Python
executemany right after the ADD COLUMN silently applies only its first parameter
set on mariadb-connector, leaving the rest NULL. test_migrations pins the SQL
expression to compute_full_path_hash so the two cannot drift.

Drop the relocation pre-pass. mark_missing_roms already runs before the identify
loop, so a moved file reaches get_matching_missing_rom, which requires all three
hashes to agree (or a title_id, covering non-hashable platforms), refuses
ambiguous matches, re-parses filename tags and emits over the socket. The
pre-pass duplicated it with a weaker CRC-only check, hashed every candidate
twice, compared folder sizes against a total that excludes filtered files, and
ran on QUICK scans.

Send uploads to a folder the platform's structure will actually discover, so the
next scan does not flag a fresh upload as missing, and refuse with a 400 when
only the user can pick the folder.

Make 0126's downgrade refuse when duplicate file names exist instead of deleting
the roms (and their saves, notes and collection membership) that carry them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 19:14:58 -04:00
Georges-Antoine Assi
9dcaf89890 fix: address PR review feedback on library structure and relocation
A grouping folder is no longer also a game. With `{gameDir}` and
`{category}/{gameFile}` declared together, the category folder was surfaced
as a multi-file game *and* descended into, listing its contents twice. A
folder any template descends into is now treated as a grouping level.

Relocation runs for every platform, not only those with a custom structure.
Dropping a platform's template moves every game back to the platform root,
which previously read as a library of new games and orphaned all the saves,
play history, favorites and collection membership. A library whose paths are
unchanged still costs one query and no hashing. This also removes the need
for a manual "apply relocation" toggle.

Physical games are excluded from relocation candidates: they have no file, so
they read as having disappeared from their path on every scan.

A near-miss on the terminal macro (`{gameFolder}` for `{gameDir}`) now names
the offending section instead of only reporting a missing terminal.

Documents two limits the QA pass asked about: a move that also compresses or
extracts the game changes its size and is not detected (the size pre-filter
runs before hashing), and how reverting to the default layout behaves.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 17:01:33 -04:00
Georges-Antoine Assi
4219f56f10 Merge branch 'master' into claude/kind-goodall-0b77y7
Conflict resolution notes:

- Locale rom.json: master sorted and reworked every file; took master's and
  re-inserted `location` / `location-copied` in sorted position. Added them to
  the new tr_TR locale.
- FSRom gained a required `fs_path`, so `build_hashless_fs_rom` now takes one
  and both call sites pass the rom's own path.
- `get_roms` keeps this branch's `_collect_fs_roms` discovery while adopting
  master's one-pass build and in-place sort.
- `mark_missing_roms` takes full paths and now also excludes physical games
  (master), and the scan loop keeps master's early missing-sync plus its
  restored-rom emit alongside this branch's relocation pass. The relocation
  filter now applies only to the identify loop, so a relocated rom is no longer
  re-flagged missing at the end of the scan.
- Relocation writes rom files through master's `sync_rom_files` (which replaced
  `purge_rom_files` / `add_rom_file`), so row ids and track metadata survive.
- Master's unique index on (platform_id, fs_name) contradicts this branch's
  premise that same-named files in different folders are distinct games.
  Migration 0126 widens it to (platform_id, fs_path, fs_name); physical games
  all share one folder, so a duplicate title is still rejected.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 16:24:59 -04:00
Georges-Antoine Assi
eef3e55d29 fix(gallery): join roms_metadata before the grouped dedup window
The genre/franchise/company/publisher/developer/collection/age-rating/
player-count filters read from `roms_metadata`, but the join was added at the
end of `filter_roms`, after the "Group ROMs" block had already derived its
dedup window from the query. The window therefore filtered on a table it never
joined: the database cross-joined `roms` against `roms_metadata` (a view over
`roms`), which SQLAlchemy reports as a cartesian product.

Besides the cost, the window then ranked every ROM in the library rather than
the matching ones, so a game whose matching version was not the group's primary
one disappeared from the gallery entirely.

Fixes #4389

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-07 16:22:18 -04:00
Georges-Antoine Assi
e78a4aa1b9 chore(recommendations): cut the comments back to what the code cannot say
The engine carried its tuning history in its comments: measurement logs for
PIVOT_B, the weight a facet held before the company split, the shape of the
cold-start feed before the Bayesian average. None of that describes what the
code does now, and it belongs in the history rather than beside the values.

Also folds serving's ROM loader into feed's, which differed only by the
visibility filter applied afterwards.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-06 14:35:15 -04:00
Sam Dornan
8494744ee7 Merge branch 'master' into claude/igdb-keywords-themes-perspectives
Resolve conflicts in the v2 Home view and its test: keep both the
recommendations row from this branch and the live multiplayer sessions
row from master.

Master added migrations 0119 through 0121 that forked the Alembic chain
against this branch's 0119 through 0122. Renumber this branch's
migrations to 0122 through 0125 so they chain after 0121_state_disc_file.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D9EiQ8VWDJfzhEViDdj84d
2026-09-06 00:24:13 +00:00
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
Sam Dornan
c1dbe3e8f6 Merge branch 'master' into claude/igdb-keywords-themes-perspectives 2026-09-03 21:37:49 -05: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
Sam Dornan
0feedde197 Merge remote-tracking branch 'origin/master' into claude/igdb-keywords-themes-perspectives 2026-09-03 09:25:03 -05: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
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
nendo
7e824d4977 Merge remote-tracking branch 'upstream/master' into feature/sigil-title-ids 2026-08-28 10:58:01 +09:00
Sam Dornan
2be8cfcb4c Merge branch 'master' into claude/igdb-keywords-themes-perspectives
Master's #3898 landed the publisher/developer split, which this branch had
built its own narrower version of. Drop ours and rebuild on top of theirs:

- Delete 0113_company_role_columns; 0112_publisher_developer_split supersedes
  it and derives the roles from all seven providers rather than two.
- Renumber 0110/0111/0112 to 0113/0114/0115 behind master's new head.
- Carry generated_publishers/generated_developers through the view and facet
  trigger rebuilds in 0114/0115, which would otherwise drop them.
- Order 0115's view projections as 0114 leaves them: PostgreSQL rejects a
  CREATE OR REPLACE VIEW that renames an existing column.
- Take master's IGDB role extraction; extract_tokens already dedupes.
2026-08-27 18:55:58 -05: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
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
Sam Dornan
3163f6a116 Merge branch 'master' into claude/igdb-keywords-themes-perspectives
Master rechained the rom_files category index onto 0108 as its own 0109, which
collides with this branch's 0109 the same way 0108 did this morning. This
branch's four migrations move to 0110 to 0113 behind it. Verified up, down to
master's head and up again on MariaDB.
2026-08-22 19:34:45 -05: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
Sam Dornan
704959b624 Merge branch 'master' into claude/igdb-keywords-themes-perspectives
Three text conflicts and one alembic head collision that git merged clean.

Master added a Ports section to the overview tab and i18n-ified the related
headings; this branch replaced the IGDB "Similar games" section with the
recommendations index. Both survive: Ports keeps its RelatedGamesGrid, and
Similar games keeps SimilarGamesGrid behind the recommendations toggle.
`rom.related-similar-games` was master's key for the section this branch
replaces, so it goes with it; `recommendations.similar-games` is its home now.

Both sides added OverviewTab.test.ts. The two suites now share one mount
helper.

Master's 0108_roms_primary_region and this branch's 0108_rom_similarity both
revised 0107, which alembic reads as two heads. This branch's four migrations
move to 0109 to 0112 behind master's. Verified up, down and up again on
MariaDB, including down past master's 0108: the generated region column, the
five new facet columns, rom_similarity and the widened sibling-cover index all
survive the round trip.
2026-08-22 10:08:05 -05:00