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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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.
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>
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>