Commit Graph

10286 Commits

Author SHA1 Message Date
zurdi
9234efd386 Merge remote-tracking branch 'origin/master' into chore/permissions-system-rework
# Conflicts:
#	backend/handler/database/stats_handler.py
2026-06-29 11:33:03 +00:00
Georges-Antoine Assi
e8aebbf006 Merge pull request #3615 from Spinnich/feat/filter-by-metadata-provider
feat(roms): filter games by matched metadata provider
2026-06-29 07:12:40 -04:00
Spinnich
d546165814 style: normalize collections_handler.py to LF line endings
This was the only CRLF-encoded file in the backend; every other Python
source uses LF. The earlier minimal-diff workaround left it mixed, so
convert it fully to LF (the repo standard) for internal consistency.

No logic changes in this commit. The only behavioural change to this file
in the PR remains the two lines added to get_smart_collection_roms
(metadata_providers + metadata_providers_logic).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 10:44:54 +00:00
Spinnich
345a690c82 refactor(roms): deduplicate metadata-provider definitions (PR review)
Addresses review feedback on #3615:

- Backend: merge the new filter column map with stats_handler's
  `_METADATA_SOURCE_COLUMNS` into a single `METADATA_SOURCE_COLUMNS` in
  models/rom.py, imported by both. It's the union of the two prior sets,
  so the stats coverage breakdown now also reports `libretro`.
- Frontend: drop the duplicated provider list from utils; derive the
  filter options from the `METADATA_PROVIDERS` registry via
  `METADATA_PROVIDER_FILTER_OPTIONS` (added a `name` brand field). Both
  filter drawers import from the registry now.
- collections_handler.py: revert the stray CRLF->LF normalization so the
  diff is just the two smart-collection lines.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 10:35:59 +00:00
zurdi
e6225e582a refactor(permissions): replace get_permissions checks with assert_platform_visible and assert_rom_visible for better clarity and maintainability 2026-06-29 10:11:02 +00:00
Georges-Antoine Assi
f3ca3def72 Merge pull request #3623 from rommapp/claude/github-issue-3610-0wpp47
Fix ROM name handling in UNMATCHED scans to replace placeholders
2026-06-28 22:38:25 -04:00
Georges-Antoine Assi
41f77cd5b4 Merge pull request #3622 from rommapp/claude/github-issue-3621-i8o7r6
Normalize Sony serial codes to uppercase before cache lookup
2026-06-28 22:35:50 -04:00
Georges-Antoine Assi
ada593628a Merge pull request #3609 from rommapp/claude/github-issue-3600-l8pa3u
fix(ra): hash PSP compressed-ISO containers natively (#3600)
2026-06-28 22:35:09 -04:00
Georges-Antoine Assi
25d0bb38fb Merge pull request #3624 from rommapp/claude/issue-2319-investigation-y44bmi
Fix state/save injection timing and corruption in EmulatorJS
2026-06-28 22:34:52 -04:00
Georges-Antoine Assi
aa3de6e396 Merge branch 'master' into claude/github-issue-3610-0wpp47 2026-06-28 22:29:27 -04:00
Georges-Antoine Assi
0f485b45eb Merge branch 'master' into claude/github-issue-3621-i8o7r6 2026-06-28 22:29:15 -04:00
Georges-Antoine Assi
04f6d29e26 Merge branch 'master' into claude/github-issue-3600-l8pa3u 2026-06-28 22:28:52 -04:00
Georges-Antoine Assi
e3c736dc80 Merge pull request #3625 from rommapp/rm-pytest-reports
Stop spamming PRs with coverage reports
2026-06-28 22:28:25 -04:00
Georges-Antoine Assi
c9779a6302 Stop spamming PRs with coverage reports 2026-06-28 22:13:57 -04:00
Georges-Antoine Assi
6b423e2d34 extend catch except 2026-06-28 21:48:50 -04:00
Claude
e8a7ae3fee fix(emulation): make save state capture and restore reliable
Save states were inconsistently saved and frequently failed to load,
especially on threaded cores (SNES, N64). Two timing races were the
cause:

- On game start, a selected state was applied after a fixed 10ms delay
  with no check that the core was ready. Heavier cores aren't booted in
  that window, so the state applied partially and left a black screen.
  Replace the fixed delay with a gameManager readiness poll plus a short
  settle window before applying the state (mirrors the console player).

- The Save & Quit handler read the state from a running emulator. On
  threaded cores the worker thread mutates emulator memory while
  getState() reads it, producing torn/corrupt buffers that are then
  stored permanently. Capture the screenshot while running, then pause
  before serializing the state and save file.

Also refuse to upload zero-length state buffers so a failed capture
can't overwrite good states on the server.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PoAdK2fmqHGmGuXWaKN1HT
2026-06-28 20:00:38 +00:00
Claude
0b20ca331e fix(scan): replace placeholder filename with matched provider name
A ROM's name defaults to its raw filename (extension included) when it is
first discovered. On UNMATCHED and UPDATE rescans, the block that preserves
existing base fields kept that placeholder name even after a metadata
provider finally matched the ROM, leaving the filename (with its ".zip"
extension and region tags) as the title.

Treat a name equal to the ROM's filename as "no name" so a freshly matched
provider name replaces it, while still preserving user-edited names.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Shf4omKSP6dHC3dC2Jjg7b
2026-06-28 18:31:30 +00:00
Claude
5845971331 fix: normalize Sony serial casing before Redis lookup
Sony serial codes captured from filenames preserved their original casing.
Dash-separated slug filenames (e.g. game-u-slus-00431-.rar) yield a
lowercase serial, but the serial index keys in Redis are uppercase, so the
lookup missed and the ROM went unidentified.

Uppercase the serial before the hget so PS1/PS2/PSP serial matching works
regardless of filename casing.

Closes #3621

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VHtzKWXK7nbUDgEmHxpnKc
2026-06-28 18:21:16 +00:00
Georges-Antoine Assi
699d9ee670 Merge pull request #3604 from rommapp/claude/github-issue-3591-gedicl
fix(v2): stop gamepad B/cancel from backing out of controller test and games
2026-06-28 08:11:15 -04:00
zurdi
7d45795408 fix(permissions): address gantoine review + Postgres-safe single migration
Visibility-coverage gaps (404-mask hidden entities, mirroring the existing
delete/read paths):
- update_rom (PUT /roms/{id}) and update_rom_user (PUT /roms/{id}/props)
- add_firmware: platform-hide now cascades to firmware uploads
- patch_rom: resolve the parent rom of both the base and patch files and
  404 when hidden, so a hidden rom's bytes can no longer be streamed back
- activity feeds (get_all_activity / get_rom_activity): drop sessions whose
  rom is hidden from the caller

Migration: make the role enum -> varchar narrowing Postgres-safe. The cast
now uses postgresql_using, the orphaned native role type is dropped on
upgrade, and downgrade recreates it explicitly (create_type=False) before
re-typing the column. Verified up/down/up on Postgres 16 and MariaDB.

Also collapses the two permission migrations into a single 0092 and notes
the override own_only replacement granularity limit in the resolver.

AI assistance: implemented with Claude Code (review-fix pass).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 22:10:00 +00:00
zurdi
5303130d15 Merge remote-tracking branch 'origin/master' into chore/permissions-system-rework 2026-06-26 15:35:41 +00:00
Spinnich
983f016efe feat(roms): filter games by matched metadata provider
Adds a "Metadata provider" gallery filter so a library can be narrowed by
which providers each ROM matched (IGDB, MobyGames, ScreenScraper, etc.),
mirroring the existing multi-value filters (player count, age rating).

Backend:
- New `_filter_by_metadata_providers` keyed off each provider's id column
  on Rom, with any/all/none logic; wired through filter_roms,
  get_roms_scalar, the /roms endpoint, and the unscoped cache gate.
- Smart collections apply the criterion via get_smart_collection_roms.
- Unknown provider slugs are ignored (no-op) so stale bookmarks or
  hand-edited URLs don't error.

Frontend (v1 + v2):
- Shared METADATA_PROVIDER_OPTIONS registry; provider list is a fixed set
  rather than data-derived, so options are static.
- Wired into the galleryFilter store, rom API service, request cache key,
  both filter drawers, v2 URL persistence, the v2 refetch watcher, and
  smart-collection serialization/summary.
- Added the `platform.metadata-provider` key to all locales.

Tests:
- Backend handler, endpoint, and smart-collection coverage (any/all/none
  plus unknown-slug).
- Frontend smartCollectionCriteria serialization/summary coverage.

Also normalized collections_handler.py to LF (it was the only CRLF file in
the backend, which tripped git-diff-check on the edited lines).

AI assistance: implemented with Claude Code (Anthropic).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 13:52:19 +00:00
zurdi
4e686e1d74 fix(permissions): address PR review (Copilot + adversarial) findings
Resolves the CI blocker and a cluster of opt-out visibility "fail-open"
gaps surfaced in review of the granular permission system.

Security / correctness:
- admin oauth_scopes projection keeps canonical FULL_SCOPES order
  (order_scopes) instead of sorting alphabetically, fixing the red
  test_user.py::test_admin on MariaDB + Postgres.
- default-group hides no longer fail open: the resolver resolves the
  effective (own-or-default) group before the hidden-entity lookup.
- /roms/by-hash and /roms/by-metadata-provider now 404-mask hidden roms.
- USERS-entity grant no longer enables admin creation: add_user and
  invite-link require a real admin to mint admin accounts.

Visibility leaks closed on secondary read paths:
- feeds, sibling roms (list query + single-rom schemas), /stats counts
  and per-platform breakdowns, collection rom_ids/rom_count, search_rom.

Hardening / cleanups:
- firmware/platform PUT 404-mask hidden entities; group rename conflict
  returns 400 not 500; guard against removing the last default group;
  kiosk read-only enforced at the fine layer; add_hidden_entity rejects
  non-cascading entity types.

Frontend:
- permissionGroups.ensureLoaded coalesces concurrent callers on one
  in-flight request; permissions.setGrants resets isAdmin/hidden;
  CreateUserDialog no longer orphans a user when group assignment fails;
  HiddenGamesPicker search rows are native buttons (keyboard/gamepad);
  invite-role labels and group swatch aria-label use i18n; drop dead code
  (originalRole, unused permissionsApi export).

AI assistance: changes authored with Claude Code (Claude Opus), driven by
the Copilot review and a multi-agent adversarial review, then verified
(backend pytest, frontend typecheck/vitest, i18n parity, trunk).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-26 12:37:58 +00:00
Georges-Antoine Assi
a79c11965c Merge pull request #3608 from rommapp/claude/github-issue-3598-nu61ay
fix(v2): correct route name when navigating after platform/collection delete
2026-06-25 20:46:49 -04:00
Georges-Antoine Assi
0af24b3fab Merge pull request #3607 from rommapp/claude/github-issue-3599-ye41l1
fix(scan): make scan tracker totals reflect platforms actually scanned
2026-06-25 20:40:22 -04:00
Georges-Antoine Assi
8405e574be fix(scan): reuse fetched platforms for NEW_PLATFORMS totals
Compute the "new platforms" totals from the platforms already loaded via
get_platforms() instead of issuing one get_platform_by_fs_slug query per
platform. Fix the test fixture to report the existing platform through
get_platforms() so the mocked data matches the code path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 19:59:52 -04:00
Georges-Antoine Assi
f818586b7d fix(scan): use get_platform_by_fs_slug for NEW_PLATFORMS totals
Compute the "new platforms" totals from the same existence check used
per-platform in _identify_platform, so the tracker totals match what is
actually scanned.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 19:58:13 -04:00
Claude
302288e62f fix(v2): use correct route name when navigating after delete
Deleting a platform or collection in the v2 UI showed "Failed to
delete: unknown error" even though the deletion succeeded. The success
handler navigated to a non-existent route name ("platforms" /
"collections"), and Vue Router threw on the unknown name, which the
catch block surfaced as a generic error.

Navigate to the real index routes (PLATFORMS_INDEX / COLLECTIONS_INDEX)
instead.

Fixes #3598

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cv77VUJgPe1H7ipSRitjpH
2026-06-25 23:54:44 +00:00
Georges-Antoine Assi
009725e585 cleanup 2026-06-25 19:50:23 -04:00
Georges-Antoine Assi
cfff9f30e1 Merge pull request #3606 from rommapp/claude/github-issue-3590-tkdirn
fix(scan): prevent duplicate ROM entries from racing scans
2026-06-25 19:39:59 -04:00
Georges-Antoine Assi
ba6d0ef9db cleanup 2026-06-25 19:17:26 -04:00
Claude
e4660aca4c fix(scan): prevent duplicate ROM entries from racing scans
The patcher uploads the patched ROM and then fires a platform scan to
register it. When a second scan runs against the same platform around the
same time (a filesystem-watcher rescan, a scheduled rescan, or another
manual scan on a multi-worker setup), both scans could see the new file as
absent from the DB and each insert it, producing two identical library
entries for one patched file.

A platform folder can't physically hold two entries with the same name, so
a ROM is uniquely identified by (platform_id, fs_name). Enforce that with a
unique index instead of the previous plain index, which makes the duplicate
impossible. The scan's early ROM insert now adopts the row created by a
concurrent scan (catching the integrity error and skipping) instead of
failing, and ROM rename pre-checks for a name collision so it returns a
clean 409 rather than hitting the constraint.

Includes a migration that removes any pre-existing duplicates (keeping the
lowest id; dependents cascade) before upgrading the index to unique.

Fixes #3590

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0135UV8Xn2XHkRhjzhm9UptP
2026-06-25 23:01:37 +00:00
Claude
4f9117d9f8 fix(ra): hash PSP compressed-ISO containers natively (#3600)
PSP games stored as .cso (and .ciso/.zso/.dax) never matched on
RetroAchievements because RomM hands these files to the external RAHasher
binary, which can't read CSO/ZISO/DAX compressed-ISO containers and fails
with "Could not open track". The game was then left without an RA link.

The PSP RA hash does not depend on the whole disc: rcheevos computes it as
MD5(PSP_GAME/PARAM.SFO + PSP_GAME/SYSDIR/EBOOT.BIN), each file capped at
64 MiB. Those containers are block-indexed, so we can decompress just the
blocks those two files occupy and hash them in-process, producing the
identical hash RA stores (and PPSSPP computes).

Add utils/psp_hasher.py: a seekable block-decoder for CISO/ZISO (deflate
and LZ4) and DAX containers, a minimal ISO9660 reader to locate the two
files, and calculate_psp_ra_hash(). RAHasherService now computes the hash
natively for PSP .cso/.ciso/.zso/.dax files, falling back to RAHasher on
any failure. Raw .iso PSP discs still go to RAHasher, which reads them fine.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KsyrT6n8WYWWxR2XGoEASs
2026-06-25 22:58:56 +00:00
Claude
fb6f6affad fix(scan): make scan tracker totals reflect platforms actually scanned
The scan tracker computed total_platforms and total_roms over every
filesystem platform, ignoring both the selected platforms and the scan
type. For a "new platforms" scan, existing platforms are skipped inside
_identify_platform, so their ROMs never count toward scanned_roms, yet
they were all included in total_roms. This made the tracker wildly
overcount (the whole library instead of just the new platform).

Resolve the platform list before computing totals and, for NEW_PLATFORMS
scans, exclude platforms that already exist in the database so the totals
match what is actually processed.

Fixes #3599

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0158RJnc7MmAbwRz6Qiyrj5a
2026-06-25 22:53:46 +00:00
zurdi
bf801cb314 feat(permissions): narrow user role to admin/user and adapt v1
Collapse the Role enum from viewer/editor/admin to two kinds (admin/user);
non-admin access now comes entirely from permission groups + overrides.

Backend:
- Role -> StrEnum {USER, ADMIN}, VARCHAR-backed (native_enum=False); Role.coerce
  maps legacy/unknown strings (incl. in-flight invites) to USER.
- Resolver: group-less users fall back to the default group (dropped the
  role-based legacy fallback); kiosk caps all non-admins to read-only.
- OIDC editor/viewer claims both map to USER (env var names unchanged).
- Migration 0092 converts the native enum to VARCHAR and normalizes
  ADMIN->admin, VIEWER/EDITOR->user.
- Updated endpoints, conftest fixtures, role/oidc/parity/db-handler tests, tools.

Frontend:
- v2 + v1 user management now use admin/user (dropdowns, defaults, getRoleIcon).
- Regenerated types (Role = 'user' | 'admin'); added role-user i18n to all locales.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-25 22:42:51 +00:00
Georges-Antoine Assi
4d8d85c0ff Merge pull request #3603 from rommapp/fix/cover-video-fit-and-dev-hmr
fix(frontend): contain hover-video to miximage frame + restore dev HMR
2026-06-25 18:15:33 -04:00
zurdi
de3f35df6e feat: added foundational work for the new permissions system 2026-06-25 21:49:00 +00:00
Georges-Antoine Assi
fb4f153fa0 cleanup comment 2026-06-25 17:17:23 -04:00
Georges-Antoine Assi
f6bc5264d5 fix(frontend): contain hover-video to miximage frame + restore dev HMR
The miximage hover video had no height bound, so a tall/narrow source
overflowed the cover. Match the miximage frame's box and `object-fit:
cover` it so the clip fills the bezel screen and crops instead of
spilling past it.

Also gate the PWA dev service worker behind DEV_PWA: it intercepted dev
requests and forced full page reloads on every edit (CSS included),
defeating HMR. Default dev now gets working HMR; set DEV_PWA=true to test
the PWA in dev.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 17:16:00 -04:00
Claude
c456034657 fix(v2): stop gamepad B/cancel from backing out of controller test and games
The global useGamepad loop translated every button into a built-in
action regardless of context. On the controller-test screen this meant
pressing B (or Circle / Nintendo-A, which share the standard B index)
fired "back" and left the page before the press could be inspected. The
same happened while a game was running: the emulator owns the pad, but
useGamepad still ran "back" on B and quit the game.

Suppress the built-in translation in two contexts:
- While a game is running (storePlaying.playing), so the emulator owns
  the pad entirely.
- On the controller-test route, so every button can be pressed and
  inspected in place.

Because the test screen no longer exits on B, ControllerDebug owns its
own escape: hold a back button (B / Circle or Back / Share) for 700ms to
navigate away, with an on-screen hint and a fill indicator. A short tap
just registers in the inspector.

Fixes #3591

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EdiAR2HMM5pCMVfn2Zhbrx
2026-06-25 20:25:40 +00:00
Georges-Antoine Assi
a5e3150187 Merge pull request #3602 from rommapp/fix/webp-convert-on-startup
fix(webp): backfill cover conversion on startup when enabled
2026-06-25 16:09:47 -04:00
Georges-Antoine Assi
be8de5d0c3 cleanup comment 2026-06-25 16:09:15 -04:00
Georges-Antoine Assi
1ae49b6420 fix(webp): backfill cover conversion on startup when enabled
The frontend rewrites every cover URL to .webp as soon as the heartbeat
reports ENABLE_SCHEDULED_CONVERT_IMAGES_TO_WEBP, but existing covers have
no .webp sibling until the scheduled cron eventually runs (the inline
conversion only covers art fetched after enabling). This produced 404s on
all existing covers until the cron fired.

Enqueue a one-off backfill run of the conversion task on startup when the
feature is enabled, mirroring the recompute-save-hashes pattern. A fixed
job_id + Job.exists guard prevents duplicate jobs across restarts, and the
task already skips covers that have a .webp sibling so repeated runs are
cheap.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 14:46:08 -04:00
Georges-Antoine Assi
64b42d2206 Merge pull request #3597 from rommapp/fix/platform-update-422
fix(platform): accept embedded custom_name body on platform update
2026-06-25 10:01:49 -04:00
zurdi
8d75474890 Merge remote-tracking branch 'origin/master' into chore/permissions-system-rework 2026-06-25 13:44:38 +00:00
Zurdi
f5d5691f52 Merge pull request #3596 from rommapp/fix/light-theme
fix: Light theme
2026-06-25 15:33:30 +02:00
Georges-Antoine Assi
0158097389 fix(platform): accept embedded custom_name body on platform update
Removing the aspect_ratio body field left update_platform with a single
scalar Body() param. FastAPI stops embedding a lone scalar body, so the
endpoint began expecting a bare JSON string while the frontend keeps
sending {"custom_name": "..."}, producing a 422 when editing a
platform's display name in v2.

Restore the embedded-key contract with Body(embed=True), matching the
frontend payload and every sibling update endpoint. Regenerate the
frontend types (restores the Body_update_platform model) and add an
endpoint regression test.

AI assistance: written with Claude Code (Opus 4.8).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 09:21:10 -04:00
Georges-Antoine Assi
deb2c278bc Merge pull request #3595 from rommapp/perf/roms-list-query-optimizations
perf(roms): speed up the gallery/search list endpoint on large libraries
2026-06-25 09:18:42 -04:00
Georges-Antoine Assi
6e3ef32815 fix(roms): gate sidecar caching on all active filters
The char index and rom id index sidecars are cached under a key that
encodes only user/order/grouping. is_unscoped previously excluded only
scope and search, so metadata/tag/status filters and the bool flags
applied to the query bypassed the gate: a filtered all-games request
stored a narrowed id list under the shared "all" key and later
unfiltered (or differently-filtered) requests read it back, showing the
wrong set and count of games.

Treat any narrowing parameter as scoped so those sets compute live.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 09:10:58 -04:00
Georges-Antoine Assi
bd22a46eda refactor(roms): extract unscoped sidecar cache key into a helper
Deduplicate the identical cache key expression used by the char index,
filter values, and rom id index sidecars so the key scheme stays
consistent across them.

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