Commit Graph

10861 Commits

Author SHA1 Message Date
Spinnich
f69e4756a7 perf(stats): aggregate server-stats breakdowns from roms_facets
The Server Stats page ran two full scans of the multi-gigabyte `roms`
table on every visit: the metadata-coverage breakdown counted eleven
provider-id columns per platform, and the region breakdown pulled every
row's regions into Python. Both were returned in the same request as the
cheap summary counts, so the whole page stayed blank until they finished.

Mirror the provider match ids into the narrow `roms_facets` table
(migration 0102, kept in sync by the same triggers as the existing facet
columns) and read both breakdowns from it, so neither query touches
`roms`. Split the v2 Server Stats view into a summary-first request and a
separate breakdown request so the six top cards render immediately.

Fixes #3901

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 17:27:09 +00:00
Georges-Antoine Assi
2e93509828 Merge pull request #3900 from rommapp/fix/stable-rom-file-ids-on-rescan
fix(scan): reconcile rom_files in place instead of purging them
2026-07-23 10:46:29 -04:00
Georges-Antoine Assi
559cc7f7ea fix(scan): keep a soundtrack cover path when its unlink fails
remove_persisted_cover swallowed OSError, so clearing cover_path
regardless dropped the only reference to a file still on disk. It now
reports whether the file is gone, and the path is kept for the next scan
to retry when it isn't.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 10:41:30 -04:00
Georges-Antoine Assi
5548f314d5 refactor(scan): fold track metadata into the rom file reconciliation
The two halves always ran together, and the column copy they shared is
now a single helper.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 10:32:26 -04:00
Georges-Antoine Assi
58286db20e Merge pull request #3899 from Spinnich/fix/server-stats-empty-platforms
fix(v2): hide empty platforms in Server Stats breakdown
2026-07-23 10:14:51 -04:00
Georges-Antoine Assi
1ee41f9a66 fix(scan): don't write NULL over NOT NULL columns when reconciling files
A scanned row leaves unset columns as None and the model defaults only
apply on insert, so the reconciliation path could write NULL into
file_size_bytes or has_embedded_cover. Unset values now leave the stored
value alone.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 10:08:01 -04:00
Georges-Antoine Assi
5a109135a9 cleanup 2026-07-23 10:07:48 -04:00
Georges-Antoine Assi
d9050eb4cc fix(scan): unlink soundtrack covers orphaned by dropped track metadata
A file that stopped carrying audio tags, or vanished from disk, had its
track_meta row dropped (directly or by cascade), leaving its persisted
cover on disk with nothing pointing at it.

sync_rom_files now reports those cover paths so the scan unlinks them,
keeping filesystem work out of the database handler.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 09:44:12 -04:00
Georges-Antoine Assi
21cc044bf1 fix(scan): clear a soundtrack cover that's gone from the audio file
Reusing the file row across rescans meant a track that kept its tags but
lost its embedded cover held on to the old cover_path, so the music API
kept serving an obsolete image and its file was never removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 09:24:19 -04:00
Georges-Antoine Assi
83ad2b3132 fix(scan): reconcile rom_files in place instead of purging them
Rescans deleted and re-inserted every rom_files row, so file ids churned
on each scan and anything keyed on them (track metadata, persisted
soundtrack covers) was orphaned.

Rows are now matched by path first, then by content hash so a file
renamed or moved inside the ROM keeps its id, mirroring the ROM-level
reassociation. Only changed columns are written, vanished files are
deleted, and archive_members is carried over (the hand-written copy
dropped it).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 08:54:50 -04:00
Spinnich
5ac3d07a7d fix(v2): hide empty platforms in Server Stats breakdown
The per-platform breakdown rendered the raw allPlatforms list, so empty
(0-game) platforms left in the DB leaked through. The Platforms page, Home
screen, and this page's own summary counter all exclude them, so the list
disagreed with everything else.

Switch to the shared filledPlatforms getter (rom_count > 0) so the list is
consistent by construction with the rest of the app.

Fixes #3897

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 12:35:05 +00:00
Georges-Antoine Assi
5edf6bc4f7 Merge pull request #3892 from Spinnich/fix/asset-cache-headers
fix(nginx): cache only fingerprinted assets, revalidate the rest
2026-07-23 08:17:29 -04:00
Georges-Antoine Assi
42059a41d6 Merge pull request #3887 from rommapp/fix/rar-archive-hashing
fix(archives): read RAR archives through bsdtar so they can be hashed
2026-07-23 08:08:37 -04:00
Georges-Antoine Assi
c70f7d1df3 cleanup 2026-07-23 08:06:42 -04:00
Georges-Antoine Assi
dfc4f6a6f5 fix(archives): end bsdtar options before the member argument
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 07:48:05 -04:00
Georges-Antoine Assi
969d9b3f9e fix(archives): fail archive hashing when a member can't be read
A member that failed or timed out mid-archive ended the member stream
silently, so the caller kept the composite hash built from the members
that happened to succeed. Raise ArchiveReadError instead and fall back to
hashing the archive's raw bytes, with no archive_members recorded.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-23 07:37:39 -04:00
Georges-Antoine Assi
31483225ba Merge pull request #3886 from rommapp/perf/materialize-virtual-collections
perf(backend): materialize virtual collection membership
2026-07-22 22:00:25 -04:00
Georges-Antoine Assi
91e098614e perf(backend): look up virtual collection covers per collection
_attach_covers ranked every membership row with a window function and
only then kept the first five per collection, so the collection list kept
a full scan proportional to library size (0.77s of a 0.92s list on a 50k
rom library) even though the view lookup itself is now indexed.

Each collection instead gets its own primary-key lookup capped at
MAX_VIRTUAL_COLLECTION_COVERS, batched into UNION ALL statements, so the
cost follows the number of collections. The covers returned are
unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 21:52:59 -04:00
Georges-Antoine Assi
535668f593 rename file 2026-07-22 20:35:13 -04:00
Georges-Antoine Assi
15554f905e Merge branch 'master' into perf/materialize-virtual-collections 2026-07-22 20:17:16 -04:00
Georges-Antoine Assi
abe0ed4aa5 Merge pull request #3885 from rommapp/perf/roms-facets-table
perf(backend): mirror ROM filter values into a narrow trigger-maintained table
2026-07-22 20:00:43 -04:00
Georges-Antoine Assi
2c1e12a7ad perf(backend): backfill roms_facets before installing the triggers
Migrations run at startup before the app serves traffic, so no write can
race the backfill. Populating the empty table first means no row can
conflict, dropping the per-engine upsert guards and collapsing the two
backfill statements into one.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 19:51:08 -04:00
Spinnich
61c3dd1e4c fix(nginx): cache only fingerprinted assets, revalidate the rest
RomM's nginx served everything under /assets, plus the root favicons and
manifest, with no Cache-Control, so browsers re-fetched or revalidated the
frontend bundle and every cover image on repeat visits.

Only some of these assets are safe to cache long-term, so a blanket immutable
rule is unsafe. Cache by fingerprint instead:

- Content-hashed bundles (index-<hash>.js) and library resources that carry a
  cache-busting query (covers ?ts=, manuals ?v=) -> public, max-age=31536000,
  immutable.
- Query-less library resources (screenshots and RA badges, which reuse stable
  filenames and are overwritten on re-scrape), the bundled EmulatorJS/Ruffle
  runtimes, and other static files under /assets -> public, max-age=3600,
  must-revalidate.
- index.html and the root favicons/manifest/service worker -> no-cache, so a
  new deploy's bundles and any updated runtime are picked up at once.

The resources split is driven by an $is_args map, so a resource is frozen only
while its URL carries a busting query.

Fixes #3890

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 22:23:21 +00:00
Georges-Antoine Assi
7038fabaf4 fix(backend): install the facets triggers before the backfill
A ROM written between the backfill and the trigger creation was captured by
neither, leaving its facet row missing or stale until the next write. The
triggers now go in first and the backfill skips rows they already wrote,
since those were built from the write itself.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 16:23:03 -04:00
Georges-Antoine Assi
dc981f51c8 fix(archives): read RAR archives through bsdtar so they can be hashed
The bundled 7zz is built without the RAR codec (unRAR license), so it can
neither list nor extract RAR members. Every content-based match silently
came up empty for .rar: no RetroAchievements hash and no CRC/MD5/SHA-1 for
hash-database providers.

RAR listing and extraction now go through libarchive's bsdtar, added to the
images as libarchive-tools. Listing uses an mtree rewrite (libarchive's only
machine-readable listing) and member names are escaped before being handed
back to bsdtar, which matches them as globs.

Fixes #3884

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 10:13:50 -04:00
Georges-Antoine Assi
753556af7b perf(backend): materialize virtual collection membership
virtual_collections was a view that unnested five JSON arrays per rom on
every read, so both the collection list and opening a single collection
scanned the whole library. Opening a collection with a handful of roms
cost as much as one with thousands, since the name is computed inside the
view and nothing can be narrowed down early.

Membership now lives in virtual_collection_roms, one narrow row per
(type, name, rom_id) plus that rom's covers, derived from the generated_*
columns and maintained by triggers on roms (deletions ride the foreign
key cascade). The view becomes a plain aggregate over that table, so the
model, schemas and API shape are unchanged, and filtering roms by a
virtual collection is an indexed subquery instead of an IN list of every
member id.

Covers are no longer aggregated in the view, which materialized every
member's cover path on every request; the handler resolves at most five
per collection, matching the smart collection cap and what both UIs
render.

On a synthetic 50k-rom library the list goes from 1.42s to 0.128s and a
single collection from 0.111s to 0.0006s, with identical output.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 10:06:05 -04:00
Georges-Antoine Assi
6224c9e48c perf(backend): mirror ROM filter values into a narrow trigger-maintained table
Building the filter dropdowns aggregated the facet columns straight off
`roms`. Those columns are cheap to compute since #3826, but they sit inline
with the raw provider-metadata blobs, so the aggregation read every row of a
multi-gigabyte table: seconds of pure disk reading on any database whose
buffer pool is smaller than the table (the stock 128-256 MB defaults always
are on a large library).

`roms_facets` holds only the filter values and is kept in sync by AFTER
INSERT/UPDATE triggers on `roms`, so every write path stays consistent
without an application hook. Deletes ride the ON DELETE CASCADE foreign key.

Fixes #3882

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 10:05:07 -04:00
Georges-Antoine Assi
ab59f32e93 Merge pull request #3878 from rommapp/fix/v2-hotkeys-emulator-keyboard-owner
fix(v2): take the hotkey-mute playing flag from EmulatorJS' start hook
5.1.0-alpha.2
2026-07-22 09:08:00 -04:00
Georges-Antoine Assi
f7701e26db Merge pull request #3872 from rommapp/chore/security-audit-skill
chore: add security-audit skill for vetting diffs
2026-07-22 08:54:23 -04:00
Georges-Antoine Assi
27b243ccf0 fix(v2): flag the playing state from EmulatorJS' own start hook
Replaces the DOM-level keyboard-owner heuristic: instead of sniffing for
canvases, emulator containers and fullscreen elements, take the running
state from EJS_onGameStart. One source of truth (the playing store), no
false positives on the 3D box art canvas, videos or fullscreen UI.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 08:37:15 -04:00
Georges-Antoine Assi
c89f435227 Merge pull request #3880 from rommapp/feat/win9x-platform
feat(platforms): add windows9x support
2026-07-22 08:34:04 -04:00
Georges-Antoine Assi
e4cad6144d Merge pull request #3879 from rommapp/fix/mariadb-12.3-str-to-date-vcol
fix(db): don't use STR_TO_DATE in a generated column (MariaDB 12.3)
2026-07-22 08:31:03 -04:00
Georges-Antoine Assi
b36da2725b fix(db): reject calendar-invalid gamelist dates before conversion
The 8+6 digit regex still admits values like 20201301T000000, and feeding
one to TIMESTAMPDIFF raises "Incorrect datetime value" under the default
STRICT_TRANS_TABLES, aborting the migration on an existing row or a later
insert. CAST(... AS DATETIME), which would yield NULL, is itself barred
from a generated column, so the components are range-checked (including
leap years) in the CASE guard and invalid dates fall through to NULL.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 07:37:02 -04:00
Georges-Antoine Assi
2f28da980a feat(platforms): add windows9x support
Adds a `win9x` universal platform slug, mapped to ScreenScraper system
137 (PC Win9X), so Windows 9x libraries can be scanned and matched.

The ES-DE config example gains the `windows9x` folder mapping, plus the
`windows3x` mapping that was missing.

Closes #3875

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 07:26:37 -04:00
Georges-Antoine Assi
57e207cff2 fix(db): don't use STR_TO_DATE in a generated column
MariaDB 12.3 enforces that STR_TO_DATE (which reads lc_time_names) cannot
appear in a GENERATED ALWAYS AS clause, so migration 0098 failed with
error 1901 and RomM could not start. Earlier releases up to 12.2 accepted
it, which is why the problem only surfaced on 12.3.

The gamelist value is already pinned to a fixed-width "YYYYMMDDThhmmss" by
the regex guard, so it is reshaped into a canonical datetime literal with
SUBSTRING/CONCAT and fed to the existing TIMESTAMPDIFF. Stored values and
their time-zone independence are unchanged.

Fixes #3873

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 07:25:35 -04:00
Georges-Antoine Assi
757471c056 fix(v2): don't fire global hotkeys while an emulator owns the keyboard
Typing "/" at a DOSBox prompt (e.g. "mount A / -t floppy") navigated to
the search page. Emulator canvases take keystrokes off window/document
rather than through a focused form control, so the keypress looked like
a plain "/" on <body> to the global hotkey handler.

The playing store flag already gates the handler, but it depends on each
player view keeping it current. Add a DOM-level guard that holds even
when the flag is stale: ignore keys whose target or activeElement sits
inside an emulator container (EmulatorJS, Ruffle), a canvas or a video,
and ignore everything while an element is fullscreen.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 07:14:59 -04:00
Georges-Antoine Assi
b3ec5d0a1f chore: tighten security-audit skill range setup and deep-review threshold
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 07:12:24 -04:00
Georges-Antoine Assi
ac8b2684d2 chore: add security-audit skill for vetting diffs
Adds a reusable skill that encodes a two-speed workflow (fast direct
sweeps plus fanned-out parallel deep review) for auditing a release tag
range or PR diff for malicious changes or security regressions: supply
chain, egress/exfiltration, auth/injection/traversal, CI/infra, and
commit provenance. Registered in the CLAUDE.md skills table.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-21 22:32:12 -04:00
Georges-Antoine Assi
ace658306e Merge pull request #3867 from rommapp/feat/v2-launch-status-and-confirm
feat(v2): auto-mark now-playing on launch + confirm launching shelved games
5.1.0-alpha.1
2026-07-21 18:11:22 -04:00
Georges-Antoine Assi
e87571d7f5 fix(v2): send exit-time play session with keepalive so it survives reload
Leaving EmulatorJS triggers a full page reload (to reset COOP/COEP) that
aborts the in-flight play-session POST. Add an ingestPlaySessionsKeepalive
variant using fetch with keepalive (plus the session cookie and CSRF header),
and have usePlaySession.flush() use it so the session is recorded even as the
document unloads.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-21 16:51:57 -04:00
Georges-Antoine Assi
2cc8c02101 feat(v2): record EmulatorJS play sessions in the v2 shell, not v1 Player
Wire usePlaySession into the v2 EmulatorJS view so a session is recorded on
any exit path (in-emulator Exit/Save & Quit, back nav, or route change),
starting when the game goes live and flushing on unmount. flush() is
idempotent so overlapping exit paths can't double-submit.

Remove the play-session ingest from the shared v1 Player component so there
is a single source of truth and no double-recording. immediateExit now only
navigates back to the game details view.

Note: Player.vue is also mounted by the v1 EmulatorJS view, which no longer
records sessions as a result; acceptable while v1 is frozen and slated for
removal.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-21 16:32:39 -04:00
Georges-Antoine Assi
b720781f87 more cleanup 2026-07-21 16:15:02 -04:00
Georges-Antoine Assi
58ec1c4aa8 feat(v2): drive rom_user status from play sessions, not launch write
Move the per-play status update (last_played, now_playing, and the
finished/empty -> incomplete rewind) off the optimistic launch-time write
and onto play-session ingest, so it reflects real play and is recorded once.

Backend: ingest now updates rom_user status when a session is the newest
play, leaving deliberate statuses (completed_100 / retired / never_playing)
untouched and skipping backfilled older sessions so they can't resurrect
now_playing.

Frontend: new usePlaySession composable records a session and ingests it on
exit; wired into Ruffle and Stream. EmulatorJS already ingests via the
embedded v1 Player, so its launch-time recordLaunch is dropped. The dead
recordLaunch / applyLaunchStatus helpers are removed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-21 15:56:28 -04:00
Georges-Antoine Assi
2baf81914b Merge pull request #3871 from rommapp/fix/collection-settings-visibility-toggle-revert
fix(v2): keep collection visibility toggle in sync after save
2026-07-21 15:46:37 -04:00
Georges-Antoine Assi
ed811c7c51 Merge pull request #3870 from rommapp/fix/collection-mosaic-lazy-loading
fix(collections): lazy-load collection mosaic artwork
2026-07-21 15:46:01 -04:00
Georges-Antoine Assi
55f9eb6165 fix(collections): lazy-load collection mosaic artwork
The Collections tab renders every collection tile's artwork through
CollectionMosaic, but its <img> tags lacked loading="lazy"/decoding="async".
With hundreds of virtual collections the browser eagerly fetched every cover,
flooding the server with image requests for off-screen tiles.

Add the same lazy hints GameCover already uses to both image branches so
artwork is only fetched near the viewport. CollectionListRow reuses this
component, so grid and list layouts both benefit.

Fixes #3865

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-21 15:00:21 -04:00
Georges-Antoine Assi
098672395d fix(v2): keep collection visibility toggle in sync after save
The collection Settings tab re-snapshotted the form from `props.collection`
right after a successful PUT, but that prop only receives the fresh value
on the next microtask (store array-replace + parent ref reassign). So the
snapshot read the pre-save object and reverted `form.isPublic` to its old
value, leaving `dirty` true and the Apply button visible even though the
change was persisted.

Snapshot from the update response instead: `snapshot()` now accepts an
optional source collection, and `save()` passes the returned `data`.

Fixes #3864

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-21 15:00:19 -04:00
Georges-Antoine Assi
7ce5a4719c Merge remote-tracking branch 'origin/master' into feat/v2-launch-status-and-confirm
# Conflicts:
#	frontend/src/composables/useUISettings.ts
#	frontend/src/v2/views/Settings/UserInterface.vue
2026-07-21 09:57:15 -04:00
Georges-Antoine Assi
ccb4a3986a fix(v2): decouple stream launch-status write from the claim transaction
Move recordLaunch out of the claimSession try/catch and run it after a
successful claim (gated on playerState === "playing"). The launch-status
write is incidental metadata, so keeping it inside the launch transaction
risked coupling it to the claimed-session lifecycle; running it afterward
ensures it can never affect play or leave a claimed session needing cleanup.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-21 09:04:50 -04:00
Georges-Antoine Assi
44c467524e fix(v2): revert local status and handle rejection when a launch write fails
The launch write optimistically mutated the shared rom_user but was
fire-and-forget, so a network/authorization/server failure produced an
unhandled rejection while the client kept status values that were never
persisted. Introduce a shared recordLaunch() helper that snapshots the
fields, applies the optimistic update, and on failure reverts them and logs
instead of leaving the rejection unhandled. Use it in all three v2 players
(EmulatorJS, Ruffle, Stream) so the behavior is consistent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-21 09:00:13 -04:00