Commit Graph

11049 Commits

Author SHA1 Message Date
Georges-Antoine Assi
702aa00a2d fix(player): drop the resumeFrom prop and let the state win
Keep the save prop as the write-back target for "Save & Quit" without
adding a second prop to say which asset boots: when both a save and a
state are selected, the session resumes from the state.

The save is no longer loaded right before a state overwrites it, so the
outcome is the same but without the discarded SRAM injection.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 21:43:51 -04:00
Georges-Antoine Assi
20e416e752 fix(player): resume from the picked asset instead of always the state
The v2 player armed a save and a state independently and handed both to
<Player>, which applied the save and then the state. A savestate restores
the whole machine (SRAM included), so the save was always discarded when
any compatible state existed.

Split the two roles the `save` prop was serving: it stays the write-back
target for "Save & Quit", while a new `resumeFrom` prop says which asset
actually boots. The v2 shell passes the visible tab, so the AssetPreview
("Resume from save/state") and what loads can no longer disagree.

v1 keeps save and state mutually exclusive, so it leaves `resumeFrom`
unset and falls back to the previous precedence.

Fixes #4010

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 21:03:54 -04:00
Georges-Antoine Assi
7d9ca7dc4e Merge pull request #4017 from XenuIsWatching/perf/single-file-hash-once
perf(scan): stop hashing single-file ROMs twice
2026-07-30 19:40:22 -04:00
Georges-Antoine Assi
2b6853a221 Merge pull request #4015 from rommapp/fix/scan-region-language-reorder
Reorderable region and language priority lists in scan settings
2026-07-30 19:28:15 -04:00
Georges-Antoine Assi
7228165b6f Merge pull request #4014 from rommapp/fix/rselect-menu-overflow-and-separator
fix(v2): keep RSelect menus inside the viewport and tidy the selection text
2026-07-30 19:25:46 -04:00
Georges-Antoine Assi
117f420dca Merge pull request #4013 from rommapp/fix/hashes-scan-rematches-hasheous
fix(backend): re-run the Hasheous hash lookup on a hashes scan
2026-07-30 19:23:56 -04:00
Georges-Antoine Assi
50d4372b2b refactor(backend): drop redundant comment on the hashes scan gate
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 19:18:40 -04:00
Georges-Antoine Assi
11f570fede fix(backend): clear a stale Hasheous match when a rehash no longer matches
A rehashed ROM whose new hashes no longer match Hasheous kept its old
`hasheous_id` and `hasheous_metadata`: the merge loop only writes truthy
values, so an empty match cannot overwrite the values seeded from the
existing ROM, and the verification flags stayed on a ROM that no longer
earned them.

Clearing on any empty match would be wrong, though: `lookup_rom` returns the
same empty fallback whether Hasheous answered "unknown hashes" or was simply
unreachable (#2236), so an outage would silently de-verify a whole library.
Have `lookup_rom` return whether it reached a definitive answer, mirroring
`meta_ss_handler.lookup_rom`, and only clear the match on a conclusive miss.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 19:13:57 -04:00
Georges-Antoine Assi
8f2a361c79 Merge pull request #4012 from rommapp/fix/v2-prev-next-game-buttons
feat(v2): previous / next game buttons on the details page
2026-07-30 19:05:36 -04:00
Georges-Antoine Assi
aae4d1d9f4 fix(v2): gate prev/next arrows on real gallery provenance
The gallery store keeps `romIdIndex` alive after the user leaves the gallery,
so membership in that list wasn't evidence the user was still browsing it: a
ROM opened from Home, Activity or a scan result could inherit the previous
gallery's neighbours and offer to step through a list it has nothing to do
with. Track how the details chain was entered and require a gallery
click-through, while leaving rom-to-rom hops and play sessions armed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 18:37:16 -04:00
Georges-Antoine Assi
1a4bf1b8dd Merge pull request #3993 from rommapp/fix/permission-gaps-5.1.0
fix(security): close three permission gaps found auditing 5.1.0
2026-07-30 18:30:58 -04:00
Georges-Antoine Assi
eba61d9d3a Merge remote-tracking branch 'origin/master' into fix/permission-gaps-5.1.0
# Conflicts:
#	backend/tests/tasks/test_cleanup_orphaned_resources.py
2026-07-30 18:22:50 -04:00
Georges-Antoine Assi
c67e49c461 fix(tasks): gate the orphaned-resources cleanup on its config flag
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 18:21:39 -04:00
Georges-Antoine Assi
fee2724a0e Merge pull request #3989 from Spinnich/feat/screenscraper-quota-awareness
feat(screenscraper): pace and report scans against the account's reported limits
2026-07-30 17:52:10 -04:00
Georges-Antoine Assi
f8bbb8af18 chore(screenscraper): tighten the quota wording and comments
Name the reset timezone by its shortcode, and drop comments that either
restate the code or explain a change rather than the behaviour.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 17:43:37 -04:00
Georges-Antoine Assi
a55d50998e refactor(screenscraper): move the scan reporting into ss_handler
Priming the account, the quota lines and the end-of-scan skip list are
ScreenScraper's own bookkeeping, so they move out of the scan socket and
behind begin_scan(), log_quota() and log_scan_summary(). The scan keeps
only the decision it owns: whether this scan uses ScreenScraper at all.

The quota-line bookkeeping joins the skipped ROMs in a _ScanState
instance, so the tracking that resets together lives together and needs
no global statement.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 17:43:32 -04:00
Georges-Antoine Assi
7168f5895c refactor(screenscraper): bundle the per-scan state in one object
The account limits, the two one-shot advisory flags and the daily-quota
breaker all reset together at the start of a scan, so they now live
together in a _ScanState instance. Mutating its attributes needs no
global statement, and reset() walks the dataclass fields so a new one
cannot be left out.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 17:29:56 -04:00
Ryan McClelland
b785a457f5 perf(scan): stop hashing single-file ROMs twice
Every chunk was streamed through two independent sets of hashers: one for
the RomFile and one accumulating the ROM-level hash. That second set is
only meaningful for a multi-file ROM, whose hash spans the concatenation
of its top-level files and so cannot be derived from the per-file digests.

For a single-file ROM the two sets see identical bytes and produce
identical digests, so the ROM-level pass was pure duplicate work. Nested
files inside a multi-file ROM were worse: they were fed through throwaway
accumulators whose results were discarded at the call site.

Make the accumulators optional and skip them where they are not needed,
reusing the file's own hashers as the ROM-level values for a single-file
ROM. Multi-file top-level files keep the second pass, since theirs is the
case that needs it.

Measured on a Raspberry Pi 4 against a 134 MB Nintendo 3DS ROM, page
cache warmed, best of three, comparing CPU time to exclude contention:
36.5 MB/s -> 60.3 MB/s, a 1.65x speedup, with byte-identical CRC, MD5 and
SHA1 at both the file and ROM level. Most libraries are predominantly
single-file, so this applies broadly rather than to an edge case.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-30 13:56:10 -07:00
Georges-Antoine Assi
7ce4f1d255 Merge pull request #4005 from Spinnich/fix/missing-tab-sidecar-perf
perf(roms): stop the Missing tab scanning the whole library
2026-07-30 15:06:59 -04:00
Georges-Antoine Assi
440cc6fa2d docs(roms): drop two redundant comments
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 14:58:42 -04:00
Georges-Antoine Assi
4dc3b75d30 feat(v2): reorderable region and language priority lists
The region and language fields in scan settings used a chip combobox,
which only appended at the end and removed from the end: reordering or
dropping a middle entry meant clearing the field and retyping it.

Both now use ScanPriorityList, the same ordered-row control the metadata
and artwork provider lists use, so entries can be dragged, moved with the
up/down buttons, and removed individually.

ScanPriorityList grows an `allow-custom` mode for these open sets: a
free-text field commits on Enter, splits comma or whitespace separated
input, and lowercases and deduplicates to match how the backend stores
the codes. The known codes stay available as one-click suggestions.

Fixes #3999

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 14:56:02 -04:00
Georges-Antoine Assi
6fd2d9576c fix(backend): re-run the Hasheous hash lookup on a hashes scan
A ROM's "verified" state comes entirely from the Hasheous signature match
flags in `hasheous_metadata`, but `ScanType.HASHES` was missing from both
Hasheous gates in `scan_rom`. A rehash recomputed the file hashes and then
never re-asked Hasheous about them, so the verification chips stayed dark
(#4001). RetroAchievements was already gated in, which is why its provider
icon appeared while nothing lit up.

A follow-up update scan didn't help either: that branch is gated on
`rom.hasheous_id`, which is never set for a ROM that has yet to match.

Add `HASHES` to `fetch_hasheous_hash_match` and `fetch_hasheous_rom`, and
to the "don't overwrite existing base fields" branch: Hasheous now returns
a name/cover/summary on a rehash, and `_identify_rom` short-circuits before
the cover download, so a changed `url_cover` would point at an image that
is never fetched.

Fixes #4001

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 14:53:46 -04:00
Georges-Antoine Assi
1dd36cc58d feat(v2): previous / next game buttons on the details page
Restores the v1 gallery-stepping affordance in the v2 details view. A new
PrevNextNav composite reads the current ROM's position from the v2 gallery
store's ordered `romIdIndex`, so the order matches whatever gallery the user
came from (filters, sort, grouping included), and hides itself when the ROM
isn't part of a list (direct link, related-game jump, Home row).

Fixes #3998

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 14:53:42 -04:00
Georges-Antoine Assi
8ddf855fc5 fix(v2): keep RSelect menus inside the viewport and tidy the selection text
The `size` middleware capped the panel with
`min(360px, var(--available-height, 360px))`, but `--available-height` is
never defined, so the cap was always a hard 360px no matter how much room
the activator actually had. `flip` then placed a 360px panel into a
smaller gap and the menu spilled past the viewport edge: at a 500px
viewport the search field could land 66px above the top, or the list 106px
below the bottom. Use floating-ui's real `availableHeight`, as RMenu
already does.

A multi-select without chips rendered each title and each "," separator as
a direct child of `.r-select__value`, a flex row with a 6px gap, so the
separator picked the gap up on both sides and the activator read "A , B".
Give the run its own box.

Also focus the in-panel search field with `preventScroll`: it autofocuses
on mount, which is before floating-ui places the panel, so the UA would
scroll to the panel's pre-placement box at the viewport origin.

The 2D/3D media labels disagreed in every locale ("Box art (2D)" vs
"3D box art"); settle on the parenthesised form.

Fixes #4000

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 14:53:37 -04:00
Spinnich
65a5aec5e0 fix(screenscraper): pace at the budget the account reports
ScreenScraper's FAQ gives the per-minute budget as `threads x 50`, while
`maxrequestspermin` came back as `1024 x (threads + 1)` on every account
measured. Reading the field as the unreliable one, pacing took the lower of
the two, pinning a 9-thread account to 450 requests per minute against a real
allowance of 10240.

ScreenScraper confirms the API was changed without the documentation
following it, and that the reported field is the authoritative one, so pace
at it and drop the formula.

That leaves no basis for a default rate either. Until the account reports,
the one-thread default is the guard: a single in-flight request cannot outrun
any budget ScreenScraper hands out, and priming reads the account before the
first ROM, so at most one request is ever unpaced.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-30 16:26:41 +00:00
Georges-Antoine Assi
2c8009dc53 Merge pull request #4004 from rommapp/fix/sgdb-skip-dmca-locked-grids
Skip DMCA-locked grids when scraping SteamGridDB
2026-07-30 10:48:12 -04:00
Georges-Antoine Assi
2882f9711a Restore DMCA placeholder comment on the grid filter
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 10:41:55 -04:00
Georges-Antoine Assi
77925db009 Drop redundant DMCA placeholder comments
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 10:41:16 -04:00
Georges-Antoine Assi
ea677be6af Align cleanup task tests with unconditional cron string
The scheduled cleanup task now always carries the configured cron string,
so assert that instead of expecting None, and set the cron string to None
explicitly to exercise the unschedule branch in init().

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 10:38:56 -04:00
Spinnich
0526ded376 test(roms): drop the tautological index assertion
Asserting the model declares the index only restates `models/rom.py`. The
migration test covers what matters: the index exists in a database the
migrations built. Also pin the predicate test to the literal it compiles
to, so an unrelated `IS NOT NULL` elsewhere in the query cannot fail it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-30 14:24:21 +00:00
Georges-Antoine Assi
6217235c4e Skip DMCA-locked grids when scraping SteamGridDB
SteamGridDB does not remove assets taken down under DMCA; it returns them
with "lock": true and strips the URL signature, so the CDN serves a
placeholder image reading "This asset has been removed in response to a
DMCA takedown notice" for both the full asset and its thumbnail.

Filter locked grids in _get_game_covers, the single funnel for scan
matching, ID lookups and the manual cover picker.

Closes #4003

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-30 10:21:00 -04:00
Spinnich
fdb000576a perf(roms): stop the Missing tab scanning the whole library
Settings -> Library Management -> Missing made three whole-library passes
per request, two of which produced data the page never renders, and none
of which could be cached because "missing" counts as a filter.

- The tab now opts out of the char index, the filter values and the
  ordered id index, so the endpoint serves its total from a plain COUNT.
- `missing_from_fs` gets a composite index with `name_sort_key`, and the
  filter compiles to an equality: MariaDB does not treat `IS NOT FALSE`
  as indexable, so the index would otherwise only ever be scanned end to
  end. The column is NOT NULL, so both forms match the same rows.
- The filter-value list is keyed on the scope (search / platform /
  collection) alone. It is built from a query that never applies the
  row-level filters, so a filtered request now answers with, and warms,
  the same whole-library entry an unfiltered one does.

Fixes #3992

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-30 12:13:03 +00:00
Georges-Antoine Assi
426be64dc7 fix(security): close three permission gaps from the 5.1.0 audit
Restrict ROM file deletion to the ROMS/DELETE grant. The new
DELETE /roms/{rom_id}/files/{file_id} route gated on ROMS_WRITE alone and,
unlike its manual/soundtrack/screenshot siblings, carried no category guard,
so a group holding write-but-not-delete could remove game files from disk
while whole-ROM deletion still required ROMS/DELETE.

Gate mutating streaming routes on ROMS_USER_WRITE instead of ROMS_READ,
matching the play-session routes. ROMS_USER_WRITE is always-on for
authenticated users, but absent from READ_SCOPES, which is all KIOSK_MODE
grants an anonymous visitor. Kiosk visitors all share user_id=-1, so session
ownership could not separate them and any visitor could claim sessions and
overwrite another's save states.

Restore the ENABLE_SCHEDULED_CLEANUP_ORPHANED_RESOURCES gate on the cleanup
task's cron_string. It was dropped in 06cafd4b1, whose message refers to
update_switch_titledb, leaving the documented opt-out inert and scheduling a
destructive task nightly. That commit also broke two of the task's own tests.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-29 18:28:04 -04:00
Georges-Antoine Assi
06cafd4b10 fix cron_string in update_switch_titledb 5.1.0 2026-07-29 17:41:52 -04:00
Georges-Antoine Assi
443c796f1e reduce freegosy text 2026-07-29 16:55:22 -04:00
Spinnich
c7284f02d2 Merge remote-tracking branch 'upstream/master' into feat/screenscraper-quota-awareness
# Conflicts:
#	backend/endpoints/sockets/scan.py
2026-07-29 14:01:06 +00:00
Spinnich
c2786429fd fix(screenscraper): address review feedback on quota awareness
Four points from the PR review:

- Leave the process-global ScreenScraper state alone when a scan does not use
  ScreenScraper. DEV_MODE runs scans in-process, so overlapping scans could
  otherwise clear each other's learned limits and skipped ROMs.
- Return pacing to the defaults when the per-scan state resets. Priming re-reads
  the account moments later; should that fail, the conservative default is safe
  for whatever account the credentials now name, whereas the previous scan's
  allowance may be more than this one is entitled to.
- Stop a rate-limited ROM from trying the next lookup. A refusal that survives
  the retry now propagates out of the handler and is caught once per ROM in
  fetch_ss_rom, instead of being swallowed per call site and sending the caller
  on to spend another retried request against a budget that is already gone.
  _is_daily_quota_error excludes the rate-limit 429 so the two stay distinct.
- Hand the request slot back before inspecting and re-encoding a cover, so
  local image work no longer holds a ScreenScraper thread.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-29 13:55:19 +00:00
Georges-Antoine Assi
ff8d4d0d5d Merge pull request #3986 from rommapp/fix/launchbox-cloud-empty-store
fix(launchbox): stop the cloud provider from silently matching nothing
2026-07-28 23:09:10 -04:00
Georges-Antoine Assi
57f4fd21d0 cleanup 2026-07-28 23:01:07 -04:00
Georges-Antoine Assi
49f2b48f5f Merge pull request #3987 from rommapp/fix/gallery-placeholder-row-overflow
fix(gallery): pack placeholder covers at the active boxart ratio
2026-07-28 22:57:39 -04:00
Georges-Antoine Assi
e8aa2f5afd fix(gallery): pack placeholder covers at the active boxart ratio
The grid flow-packs rows in JS from each card's real width
(cardHeight * coverRatio), and rows render nowrap with flex-shrink: 0 —
so an underestimated width overflows the viewport instead of wrapping.
Ratios are measured on cover load, but a rom with no cover paints its
placeholder at the boxart style's ratio and never measures, so the
packer's hardcoded 2/3 under-reserved its width and let an extra card
into the row.

The packer now takes the style ratio as its fallback for any position
without a measured cover, which also covers the pre-load paint of every
card in a non-2/3 gallery.

Fixes #3984

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 22:36:39 -04:00
Georges-Antoine Assi
ad07bafbd1 fix(tasks): load the task list when the tasks page opens
The list was fetched once at app boot, inside a bootstrap that runs
before anyone is logged in. /tasks needs the tasks.run scope, so any
session established after boot (any login without a reload) left the
watcher, scheduled and manual lists empty for the rest of the page load,
in both UIs. For a logged-in non-admin the same call 403'd on every page
load and tripped the interceptor's redirect to login.

Fetch on mount from the pages that need it instead.

Fixes #3981

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 22:22:13 -04:00
Georges-Antoine Assi
8c12ac86a1 fix(launchbox): keep the heartbeat honest during a first import
The store is written in batches, so an initial import answers for the
names committed so far long before it holds the whole dump. Checking
that the name index exists reported the provider healthy off a fraction
of the entries, and a run that died partway left it that way for good.

Flag the initial import and clear it once a run completes, so only a
finished import counts as healthy. A refresh keeps serving the previous
dump, so it is not flagged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 22:22:06 -04:00
Georges-Antoine Assi
963e4cab48 Merge pull request #3983 from rommapp/fix/valkey-snapshot-write-amplification
fix(docker): stop valkey rewriting its whole RDB every few minutes
2026-07-28 22:02:39 -04:00
Spinnich
e1225c8a9c fix(screenscraper): don't repeat an unchanged quota line
The last platform's quota readout and the end-of-scan summary both call
_log_ss_quota, so a completed scan printed the same numbers twice in a row.
Skip a line identical to the previous one, resetting at the start of each scan
so a new run always reports.
2026-07-29 01:30:18 +00:00
Georges-Antoine Assi
f4984fb218 cleanup 2026-07-28 21:28:09 -04:00
Georges-Antoine Assi
7f0636aed5 Apply suggestion from @greptile-apps[bot]
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-07-28 21:26:15 -04:00
Georges-Antoine Assi
79a64c473e Merge pull request #3982 from rommapp/fix/platforms-index-hide-empty
fix(platforms): hide empty platforms behind a toolbar filter
2026-07-28 21:06:13 -04:00
Georges-Antoine Assi
85351739e8 fix(platforms): use a clearer icon for the include-empty filter
mdi-select-all is a marquee-selection glyph, so it read as an action
rather than a filter state. mdi-asterisk carries the wildcard
"everything" meaning the segment actually has.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 20:11:09 -04:00
Georges-Antoine Assi
52940ea3d4 fix(launchbox): stop the cloud provider from silently matching nothing
LaunchBox cloud lookups read from a Redis store that only the metadata
update task fills, but nothing surfaced when that store was empty. The
provider reported healthy, every search returned zero results, and the
logs said nothing.

- heartbeat now reports unhealthy until the store is populated, and an
  empty store logs what to set to fix it
- the update task can be run manually whenever LAUNCHBOX_API_ENABLED is
  on, instead of also requiring the scheduled-update flag
- the ~600k entry dump was buffered into a single pipeline, peaking at
  1.7GB of RSS and writing nothing at all if the job was killed part way
  through. Writes now go out in batches and parsed elements are dropped
  as they are consumed, which caps the run at ~260MB. The task also gets
  its own timeout, since the default 5 minutes does not cover a 100MB
  download plus a 500MB parse
- alternate name lookups ignored the platform, so "Super Mario World" on
  PlayStation matched Super Mario Bros.
- Coleco ADAM was spelled wrong, and Famicom / Super Famicom pointed at
  platform names LaunchBox does not use

Fixes #3981

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 19:55:16 -04:00