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>
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>
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>
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>
Move the now-playing / last_played write into the nextTick after the Ruffle
player is created and the SWF load is issued, so a failed player creation or
load no longer leaves the game marked playing (or rewinds its status).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
rom.screenshots has no guaranteed order, so indexing into it picked a
different row on PostgreSQL than on MariaDB and failed CI. Fetch the
original screenshot by its known id instead.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
In DEV_MODE the content endpoints serve a single-file ROM straight through
FileResponse, which raises a RuntimeError at send time when the file no
longer exists on disk (e.g. a renamed or moved ROM whose old entry is now
missing). Check the path first and raise a clean 404 instead.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds unit tests for the shared applyLaunchStatus helper (now-playing flag,
empty/finished -> incomplete rewind, and protection of completed/retired/
never-playing) and for useGameActions.play()'s confirmation gate (normal
launch skips the prompt, retired/never-playing launches prompt and abort on
cancel or proceed on confirm, and the per-user preference disables it).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
When more than one missing entry shares the same CRC/MD5/SHA1 (e.g.
duplicate content stored twice), limit(1) returned an arbitrary row, so
reassociation could move user data onto the wrong game nondeterministically.
Fetch up to two matches and reassociate only when exactly one exists;
otherwise fall back to creating a new entry.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The reassociation lookup OR'd the individual hashes across the Rom and its
RomFiles, so a lone CRC32 collision (or one shared child-file hash) could
move an unrelated missing entry onto the scanned file, attaching the wrong
collections, notes, and assets. Require all three of CRC, MD5, and SHA1 to
match on the ROM row instead; any missing hash yields no match.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Launching a game now advances its per-user status: it is marked "now
playing" and an empty or "finished" status rewinds to "incomplete", while
statuses the user set on purpose (completed 100% / retired / never playing)
are left untouched. This is applied at the authoritative launch write of all
three v2 players (EmulatorJS, Ruffle, Stream); Ruffle and Stream previously
persisted nothing on launch, so they now also refresh last_played.
Launching a game marked Retired or Never Playing now asks for confirmation
first, so an accidental Play does not silently reactivate a game the user
deliberately shelved. Gated by a new per-user preference
(confirmProtectedLaunch, on by default) exposed as a Gameplay toggle in
Settings > User Interface.
Adds the shared applyLaunchStatus helper and 5 i18n keys across all 18
locales.
Part of #3721.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Point the collection random-ROM button and error snackbar at the
existing platform.random-rom* keys and drop the duplicate keys from
collection.json across all locales. Bail out of onRandomGame's
navigation if the active collection changes while a request is in
flight, so a pick started in one collection can't open a ROM after the
user has moved on.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
When a ROM file is renamed or moved, the scan matched files to DB rows
solely by (platform_id, fs_name), so the old row was flagged missing and
the renamed file became a brand-new entry, orphaning all user data
(collections, notes, per-user status, uploaded saves/states/screenshots).
Now, when a scanned file matches no existing fs_name, the scan hashes it
first and looks for an existing missing_from_fs entry on the same platform
with a matching hash. On a match it moves that entry onto the new file and
clears its missing state, preserving user data linked by rom_id, instead
of inserting a duplicate. Empty hashes never match, so non-hashable
platforms and SKIP_HASH_CALCULATION fall back to creating a new entry.
File hashing is hoisted so it runs once per new file and is reused for
both the reassociation probe and the downstream scan.
Fixes#3618
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add a random-game shortcut to the v2 collection view, mirroring the one
platforms already have. Works for regular, virtual, and smart
collections by scoping the getRoms filter param to the collection kind.
No backend changes: getRoms already accepts collection/virtual/smart ids.
Fixes#3718
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Port the v1 home behaviour to the v2 home: smart and virtual
(autogenerated) collections can now be surfaced as their own rows,
each toggled independently from the regular collections row.
- Add `showSmartCollections` UI setting; wire the existing
`showVirtualCollections` / `virtualCollectionType` settings into v2.
- Fetch smart/virtual collections on the home view only when their
toggle is on, so the expensive virtual "all" fetch is skipped when
disabled.
- Render Smart and Virtual CardRows reusing the CollectionTile pattern.
- Move the smart/virtual visibility toggles into the "Home sections"
settings group; the "Virtual collections" section keeps only the
collection-type selector.
- Add `settings.show-smart-collections` (+ desc) to all 18 locales.
Closes#3720
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
RDialog and RDrawer each mutated body { overflow: hidden } but tracked
it with their own counter and saved-overflow key (rDialogOpenCount vs
rOverlayOpenCount). A dialog stacked over a drawer (or vice versa) would
restore overflow off its own count when it closed and clobber the other
overlay's lock, leaving the page scrollable while an overlay was still
open, or permanently locked once all closed.
Extract a single reference-counted lock (createBodyScrollLock) that
every overlay shares, so the body only unlocks once the last overlay
closes, in any close order. RDialog's z-index stack depth now reads the
shared overlay count (drawers sit below dialogs, so relative dialog
ordering is unchanged). Add a unit test covering the cross-overlay case.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Extended mode used a fixed 420px card with a repeat(3, 1fr) grid. Since
values don't shrink, large numbers (84,283, 290.6 TB) consumed the
column and the label clipped via text-overflow ("Screenshots" -> screens,
"Size on Disk" -> "Size o"). Size the card to its content (max-content)
with auto columns, and let the label flex to keep values right-aligned
without ever truncating. The rail already scrolls horizontally.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
RDialog/RDrawer locked `body { overflow: hidden }` from their
`modelValue` watcher but only unlocked it in the watcher's close
branch. Consumers that null a `v-if` entity in the same tick as `show`
(e.g. EditRomDialog's closeDialog) unmount the overlay before that
branch runs, so the lock leaked and the page could no longer scroll.
Guard each instance with `holdsLock` so lock/unlock are idempotent, and
release in `onBeforeUnmount` as a safety net.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Move the SearchCoverDialog filtering/sorting logic into a
useCoverFilters composable. Drop the "All sources" dropdown (and its
locale key), turn the sort control into a left-floated toggle with a
Relevance/Most votes label, rename the providers-covers key to
metadata-providers, and stop resetting filters on every re-search.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Adds client-side filters to the v2 manual cover-search dialog so users
can narrow SteamGridDB results without endless scrolling:
- Source (SteamGridDB / each metadata provider)
- Resolution (dynamically built from the results present)
- Style (alternate / blurred / material / no logo / white logo)
- Uploader (searchable list of contributors)
- Content toggles (NSFW / humor / epilepsy, NSFW off by default)
- Sort by relevance or most votes
Backend surfaces the rich per-cover metadata SGDB already returned but
was discarding: SGDBResource / SearchCoverSchema now carry width,
height, style, author, score and content flags, and the cover-search
path fetches every content variant so the picker can toggle them
client-side. Auto-scan cover selection is unchanged and stays
safe-by-default.
New keys translated across all 18 locales.
Closes#3749
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Found while testing the v2 form: saving only a description also wrote
`custom_name`, because the merged save always sent the name field. The
previous name-only form bailed unless the name was dirty, so `custom_name`
was written just on a real rename.
The effect was invisible (`display_name` falls back to `name`, so it looked
unchanged) but not harmless: the platform gained an explicit custom name
that would shadow later upstream metadata renames.
Each field is now sent only when it actually changed. Covered by a component
test that fails if the name is written unconditionally.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The previous commit changed the shared updatePlatform signature, which
forced a matching edit in the v1 platform drawer and tripped the
check-v1-frozen CI gate.
Keep the platform-object argument so the v1 call site compiles unchanged,
and make `description` an opt-in second field instead. Callers that only
rename still send custom_name alone, which is exactly the pre-existing
behaviour and keeps them from replaying a stale description.
The fully explicit signature is the nicer shape and worth revisiting once
v1 is deleted.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Bound the user-authored fields. `description` (TEXT) and `custom_name`
(VARCHAR(400)) had no length constraint, so an oversized value reached the
database and surfaced as an unhandled DataError, turning a bad request into
a 500. Both are now validated against the column limits, which are defined
next to the columns so the bounds can't drift from the schema. The
`custom_name` case predates this branch but shares the line of code.
Make platform updates a true partial update. The shared API service took a
whole Platform object and sent every field, so the v1 rename drawer replayed
whatever description it happened to be holding; if another client had changed
the description in the meantime, renaming silently reverted it. The service
now takes explicit optional fields, so omitting one means "leave it alone"
rather than "write back my cached copy".
Watch the two form fields independently. Re-seeding both whenever either
canonical value changed meant a socket update touching only the name threw
away an unsaved description edit, and vice versa.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Custom platforms could only be distinguished by name, which is often not
enough context (e.g. a "Sega - Genesis/Mega Drive (Unofficial)" folder
holding aftermarket and unlicensed dumps). Platforms now carry an
optional free-text description, mirroring collections.
The column is nullable and defaults to "", matching custom_name, so a
rescan (which merges a freshly scanned Platform over the existing row)
leaves it untouched. update_platform patches only the fields sent, so an
omitted description is preserved and an empty string clears it.
Surfaced in the v2 UI only: the Settings tab name form now covers both
custom_name and description, and PlatformHead renders the description as
a chip alongside the metadata chips. v1 is frozen and gets no new UI, but
round-trips the field unchanged through the shared API service.
Closes#3402
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Expose the scan.* section of config.yml (metadata & artwork priority,
per-field artwork overrides, region priority, language priority, media
types, gamelist and pegasus export) in an editable v2 Settings page.
Backend:
- Add PUT /api/config/scan (platforms.write) with a validated
ScanSettingsPayload and ConfigManager.update_scan_settings().
- Expose GAMELIST_AUTO_EXPORT_ON_SCAN and PEGASUS_AUTO_EXPORT_ON_SCAN
in ConfigResponse / GET /api/config.
- Preserve the streaming section on runtime config writes (previously
dropped on every write).
Frontend:
- New Settings/ScanSettings.vue page + ScanPriorityList.vue reorderable
list (drag + up/down for keyboard/gamepad); region/language use
RComboboxField.
- Wire the scan-settings route, permissions, and sidebar entry.
- Regenerate OpenAPI types; add all new strings to every locale.
Closes#3849
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Several endpoints authorized cross-user access by the is_public flag (or
by scope alone for streaming) without re-checking whether the parent ROM
or platform is hidden from the caller. A user blocked from a ROM/platform
could still download a public save/state/screenshot attached to it, or
claim a streaming session for it, by supplying the asset/ROM id directly.
Route all four through the existing assert_rom_visible() 404-masking
helper, right after loading the record and before any file access or
broker launch, matching the ROM detail/content endpoints.
- saves.py / states.py / screenshots.py download_* : public sharing no
longer overrides the hidden-resource boundary.
- streaming.py claim_session : hidden ROM/platform can no longer be
launched via its id; broker is never contacted.
Regression tests cover hidden-ROM and hidden-platform cascade for each
endpoint, plus a positive control that public sharing still works when
the ROM is visible.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>