Fall back to a JS hash when WebCrypto is unavailable (non-secure
contexts) and never let a hash or upload error escape the emitter or
the game-start hook. Comments trimmed to the style guide (no em-dashes,
one or two lines of why).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Behind a new config flag, emulatorjs.auto_save_sync (default false), the
EmulatorJS player uploads the in-game save (.srm) to the server on
EmulatorJS' own "System Save interval" tick, without Save & Quit.
EmulatorJS already runs that timer (default 300 s) and its
gameManager.saveSaveFiles() fires a "saveSaveFiles" event carrying the
SRAM bytes, but nothing listens to it, so today an in-game save reaches
the server only from Save & Quit or the Export Save File button (#4201).
This subscribes to that event from Player.vue and uploads through the
existing saveSave() when the SRAM hash is unchanged since the previous
tick (a save the core is still writing is never uploaded — the corruption
the earlier automatic upload was removed for, #2349) and differs from the
last upload (an idle session uploads nothing). The tracker is seeded from
the SRAM the core holds after the server save is applied, so a launch
never uploads the server's own file back, and the subscription is turned
off before Save & Quit, Quit and unmount.
The bytes EmulatorJS hands out are views onto the emulator heap, a
SharedArrayBuffer on threaded cores; they are copied into a plain
ArrayBuffer before hashing or uploading.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The uniform 16/9 cells letterboxed every asset into an identical tinted
box, so a 42x680 box spine and a 2:1 marquee both read as mostly empty
background. Assets now keep their real proportions under a shared height
cap and sit on a common baseline, with a drop-shadow that follows the
artwork's own silhouette (most scans are transparent PNGs) and a lift on
hover.
The details cover goes back to being inert. The Media tab's Artwork
subtab now leads with the rom's own cover, so every piece of artwork the
page holds sits in one grid and one lightbox.
Review follow-ups. CLAUDE.md bans em-dashes in anything we write, and
Vue Test Utils already refuses to dispatch on a disabled button, so the
click asserted nothing the surrounding expectations did not.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
GameCover swaps to the external `url_cover` when the primary image fails,
but the zoom re-resolved the chain itself and kept pointing at the failed
URL — clicking a visible fallback cover opened broken artwork.
Have GameCover expose the src it is rendering and ask it at click time, so
there is one home for "which artwork is on screen". The affordance keys off
`hasArtwork`, which is the separate question of whether there is anything
to zoom into at all.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
GameHeader and InfoGrid each built the same search location object; move
it to a shared `searchLocation` util so the query schema lives in one
place.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Only the outer wrapper and the stage dismissed on click, but the item box
between them fills the stage while the image letterboxes inside it. At
1440x900 the item measured 1280x774 against a 421x680 cover, so nearly
everything that read as backdrop was the item div and swallowed the
click. Give the item its own .self handler; the image itself still keeps
the lightbox open.
Fixes#4362
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The details page cover was inert in the v2 UI. Clicking it now opens the
same fullscreen RCarousel lightbox the screenshot and artwork grids use,
sourced from the resolution GameCover already runs so the zoom shows
whatever artwork is on screen (box art, physical, mix image).
A magnify hint fades in on hover and focus, and stays visible on touch
and gamepad where there is no hover. A rom with no artwork at all keeps
its procedural placeholder and the hero stays inert. The 3D box hero is
untouched: it is already interactive.
Closes#4361
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Region, language and custom tags in the details header now link into a
filtered search, the same pivot the Overview info grid already offers on
genres, companies and franchises.
Closes#4363
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Leaving a player fires teardown requests the reload would abort (the
stream save + release among them), and the backend can drop again while
the refresh waits. Trigger the refresh off the api layer's
`network-quiesced` event, capped for an app that has gone silent, and
skip it when the connection is gone again so the next reconnect handles
it instead.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The reconnect recovery refresh fired on every offline -> online
transition, so a transient network blip during play tore down the page
and killed the running emulator along with any progress it had not
synced yet.
Hold the refresh back while the playing store reports an active session
and run it once the player is left, after a short grace period so the
player's teardown requests reach the backend first.
Fixes#4356
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A broker's launch, join and desktop replies name the URL the browser loads
in an iframe, and urljoin keeps an absolute (or `javascript:`) URL verbatim,
so a container that answered with one could run script in RomM's origin
instead of its own. The three sites now share one resolver that drops a room
URL leaving the configured host, the stage refuses a source that is not
http(s), and the frame is sandboxed without allow-top-navigation so a
container page cannot steer the tab it sits in.
Also drop the shared secret from the config entry a resolution warning
prints, which named the misconfigured container by dumping it whole.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Session ownership and lifecycle, mostly around who a teardown belongs to:
- file the exit state, save states and state frames under the session's
owner rather than the caller, so an admin driving someone else's session
no longer collects their saves
- beat the heartbeat from the admin desktop view, which the stale sweep was
tearing down three minutes in
- take the claim through release_own_session when a launch aborts, instead
of deleting a key another player may already hold
- require the same claim to stamp a launch, so a late activate cannot revive
a drain marker with a six hour TTL
- pull the in-game save archive on every teardown path, not just the two
that remembered to
- skip draining keys in the admin force-release sweep
Plus: pool members must share a protocol, since the head's capabilities are
what the frontend renders; a claim clears terminations across the whole pool;
multiplayer is only recorded where the broker can actually seat a joiner; and
an unserializable config no longer caches forever on a repr() that repeats.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
- The five new modules each defined `log = logging.getLogger("romm")`, which is
what `logger.logger` already exports; they import it now.
- `ACK_TIMEOUT` had two homes. It is a protocol fact, so `protocol.py` owns it
and the endpoint imports it from there; the unused
`BROKER_LOAD_STATE_TIMEOUT` copy goes.
- Module and function docstrings trimmed to what the code cannot say: the
change history and the justifications belong in the commit messages they came
from.
- `asset_store` takes the union `write_file` accepts rather than `Any`.
- Four hand-rolled `setInterval` pairs (presence beat, session poll, exit
chord, live sessions, activity tick) become `useIntervalFn`, which also
cleared a real gap: the presence composable's timer had no scope teardown.
- The launch pushes are matched on the container the claim's 202 named, not on
the platform: a pool serves one platform from more than one container, so a
second tab could otherwise act on the first's launch.
- Test helpers typed: the push capture and the resume-claim tuple carry real
types, and an unused `_claim_ready` helper goes.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`POST /streaming/sessions` blocked for up to STREAMING_LAUNCH_TIMEOUT (10
minutes) while a broker unpacked a pkg or archive, and four mechanisms existed
to keep that survivable: a 3s status poll the client ran alongside it purely
for progress, `launch_timeout` shipped through /config so the client could size
its own axios ceiling, and a cancel-then-undo branch that re-released a session
the player had already abandoned, because a blocking POST cannot be cancelled.
The claim now answers 202 as soon as the container is reserved and everything
that can fail synchronously has (404, 409, 428 are all still the claim's own
status). The launch runs detached and pushes to the user room the
force-release notice already used:
- `streaming:launch-ready` carries the room URL and the resume outcome
- `streaming:launch-failed` carries the reason; the claim is already freed
- `streaming:launch-phase` carries the broker's extraction phase
The backend polls the broker for that phase itself, once, however many tabs are
watching, and only pushes changes. `GET /sessions/{platform}/status` stays as
the fallback for a tab that missed a push.
That retires the client's launch poll, the `launch_timeout` plumbing and the
cancel-then-undo branch. Leaving during a launch is now just a release, and the
launch-ready handler hands the container back if the player has already gone.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Every streaming route returned a bare `JSONResponse`, so none of their shapes
reached the OpenAPI schema and `services/api/streaming.ts` hand-maintained a
parallel copy of all eleven of them. A response-shape change was a silent
frontend break with nothing to catch it.
`endpoints/responses/streaming.py` declares the shapes and the routes return
them, so they generate like every other endpoint. The 428 a claim raises when a
container still holds an undecided memory card is declared too, through
`responses=`, rather than staying an undocumented `detail` dict.
The frontend types are regenerated and the hand-written interfaces become
aliases onto them. The typecheck immediately found two places they had already
drifted: the hand-written `PlatformCapabilities` was missing `has_memory_card`,
and `LiveSessionCard` passed a possibly-undefined host username where a
nullable string was expected. The termination notice had drifted on the backend
side too: it records `ended_at`, `rom_id` and `rom_name`, which the first draft
of the schema did not carry.
Releasing a session now hands its teardown to FastAPI's `BackgroundTasks`
rather than attaching it to a hand-built response, which is what lets the route
return a model.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Backend:
- One session-scan iterator (`_iter_session_keys` / `_iter_live_sessions`)
replaces three copies of the Redis scan-and-decode loop, and
`_get_live_session` replaces five independent "a drain marker is nobody's
session" checks.
- `_abort_claim` replaces seven inlined claim-abort cleanups, so a new failure
branch can no longer wedge a container and orphan a blank card.
- `_quiesce_container` and `_collect_exit_state` replace the stop-evacuate-wipe
and guarded state-pull blocks written out in all three teardown paths. The
`_record_termination` calls stay at the call sites: the three order it
differently and each has its own reason.
- `_hold_reservation` / `_drop_reservation` collapse the two
release-after-state-pull helpers into one, and absorb the third copy of that
branch inlined in the released-session teardown.
- `_load_state_broker`'s two protocol branches were byte-identical, so it now
takes its route from `_transfer_route`; `_raise_broker_http_error` and
`_raise_broker_unreachable` replace the error translation copied into
`_call_broker` and `_webstation_activate`.
- `_container_labels` builds the label map once per request rather than
re-reading and re-parsing config.yml for every listed row.
- The joinable listing fetches each ROM once, through `get_rom_simple` rather
than the `@with_details` query, for five columns.
- `store_memory_card_version` hands the hash it computed in memory to the scan,
which was reading the archive back off disk to recompute it.
- `_prune_state_history` takes the history its caller already fetched.
- `playlist_files` in utils/m3u.py is now the one home for "which files are
discs", shared by the download endpoint, the m3u generator and the swapper.
Frontend:
- `useActivityPresence` replaces the presence block copied verbatim from
EmulatorJS.vue into Stream.vue.
- `MemoryCardNameDialog` replaces three copies of the same name-entry dialog.
- The two private axios error extractors give way to the `errorMessage` util,
three hand-rolled spinners to `RSpinner`, six manual listener pairs to
`useEventListener`, and five copy-on-write Set/Map trackers to `reactive`.
- `keepaliveHeaders` moves next to the interceptor that owns the CSRF header.
- The exit chord polls at 10Hz instead of every frame, the stage measures its
offset once instead of per mousemove, `postToStream` reuses the frame list
the attach pass walked, and the admin/home polls skip a hidden tab.
- `containerLabelForPlatform` on the store replaces the two `streamLabel`
definitions that answered differently, and the stream/join action labels move
onto useGameActions so the button and the menu cannot word them differently.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Conflicts and how they were resolved:
- `useGameActions`: master renamed `useCanPlay`'s `canPlay` to `canPlayLocal`
and kept a local `canPlayStream`, while this branch moved `canPlayStream`
into `useCanPlay` and folded it into `canPlay`. Kept this branch's shape and
took master's `useScanTrigger()` call.
- `Player/Stream.vue`: kept this branch's force-release and session-poll block,
and re-placed master's `useUnloadGuard(sessionActive)` next to the
`sessionActive` watch.
- `locales/*/play.json`: kept both sides' keys, re-sorted.
- `__generated__/index.ts`: kept both sides' model exports, re-sorted.
- `test_config_loader.py`: kept both sides' tests.
Master took 0114 through 0118 while this branch was open, so its three
migrations are renumbered 0119-0121 and rechained after
`0118_rom_category_cheat_pg`, leaving alembic with a single head.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The en_US/en_GB description gained the collections page; carry that into
the other 16 locales so the toggle doesn't describe two of its three
surfaces everywhere but English.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The fallback test only read the rendered list, so it passed whether the
view cleared the query param or merely reset its local filter, and it
seeded the preference before mount so the runtime flip went uncovered.
Hold the setting in a live ref the tests can flip after mount, assert the
router.replace that drops the param, and add the turn-it-off-while-
filtered case.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The v2 collections index fetched and rendered virtual collections
regardless of the `showVirtualCollections` UI setting, so users who
turned the toggle off still got them on the page the v2 UI makes the
primary home for collections. The v2 home page already gates on it,
leaving the two sibling views disagreeing about the same preference.
Read the setting (and the virtual collection type) from useUISettings
rather than raw localStorage, skip the fetch and the list entries when
it is off, drop the virtual option from the toolbar's kind cluster, and
snap a stale `?kind=virtual` back to `all`.
Fixes#4348
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
DEFAULT_EXCLUDED_DIRS only ever seeded EXCLUDED_PLATFORMS, but its name
implied it was the general directory list, which is how the media folders
came to be added to it in the first place. Rename it and its superset to
DEFAULT_EXCLUDED_PLATFORM_DIRS and DEFAULT_EXCLUDED_MULTI_FILE_DIRS, and
spell out what a multi-file ROM is.
DEFAULT_EXCLUDED_FILES and DEFAULT_EXCLUDED_EXTENSIONS keep their generic
names: each still feeds both a single-file and a multi-file-parts exclusion.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Fold the exporter's folder map and the importer's ESDE_MEDIA_MAP into a
single GAMELIST_MEDIA_DIRS, so writing, reading and skipping a media type
is one edit. This also picks up thumbnails/, which the scan exclusions were
missing, and drops the hand-appended "images" literal.
Serve the multi-file defaults pre-unioned as DEFAULT_EXCLUDED_MULTI_DIRS so
neither UI has to re-join two lists; v1 was still mapping EXCLUDED_MULTI_FILES
to DEFAULT_EXCLUDED_DIRS and rendering the media dirs as deletable.
Collapse the per-tag asset loop and the bespoke <mix> block into one table
keyed by tag, and skip fnmatch for the exclusion patterns that hold no glob
characters, now that the multi-file list is more than twice as long.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`refetchCurrentRom` no longer reads or writes `currentRom`: `syncCachedRom`
owns that write and applies the identity guard. The name promised a function
that acts on the open rom; it fetches the rom it is given and applies it
wherever it is cached, so `refetchRom` is what it does.
Also trims the two comments that had grown past what they explain.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`scan_platforms` ends in four places, and three of them had to remember to
flush the counters a coalesced increment held back. The fourth, the early
return on a folder structure it cannot read, did not, and was correct only
because it sits above the first report. `finish` pairs the flush with the
emit so every exit gets both, including that one.
The failure path's guard around the flush goes with it. It was protecting
against an emit that fails, one line above an emit that would fail the same
way and is not protected, and `update_job_meta` already swallows its own
errors, so it bought nothing.
Also: `refetchCurrentRom` wrote `currentRom` twice, once directly and again
through `syncCachedRom`, which owns that write and applies the same identity
guard. `useRomScanRefresh` kept an `alive` check that `useSocketEvent`'s
unsubscribe already covers; its test was passing on the check rather than the
unsubscribe, so the socket mock now actually unsubscribes. DeleteManualDialog
was the tenth surface still spelling out the refetch by hand, and seven
components kept a rom store binding nothing reads any more.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
DEFAULT_EXCLUDED_DIRS feeds both EXCLUDED_PLATFORMS and
EXCLUDED_MULTI_FILES, so listing the gamelist media folders there also
hid any platform directory that happened to share a name. The media
folders now live in DEFAULT_EXCLUDED_MEDIA_DIRS and only join the
multi-file exclusions.
The config response exposes the new list so the settings UI keeps
treating those entries as read-only defaults instead of offering a
remove action that the next config load would undo.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Conflict in the v2 EmulatorJS player was an import collision only: master
added useUnloadGuard where this branch added useSnackbar. Kept both.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A failed EmulatorJS loader (both attempts exhausted) or a Ruffle launch
that cannot create a player left gameRunning set, so the browser asked
for a leave confirmation with no game behind it and input stayed muted.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Nine surfaces each spelled out "fetch the rom, write it to currentRom,
sync the caches", and they had drifted: the notes tab never synced the
gallery cache, the walkthrough subtab updated the v1 store instead of it,
and only the scan refresh guarded against the user opening another game
while the request was in flight. `useRomSync.refetchCurrentRom` does it
once, with the guard, so every asset write reconciles the same way.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The character class held a raw NUL and a raw DEL byte, and a NUL in the
first 8000 bytes makes git treat the whole file as binary: GitHub renders
no diff for it and a merge cannot go three ways. The class is unchanged.
Also drop the second paragraph of the quick scan description.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The platform sync clears `missing_from_fs` before the batch loop runs, so
a rom being scanned can no longer tell that it was missing, and the fold
left the skip path (which could tell) unreachable for a quick scan. A rom
whose file came back byte for byte therefore emitted nothing and kept its
stale badge. Collect the restored roms from the snapshot the loop already
takes, for the ones it visits as well as the ones it skips.
Cleanups on the same paths:
- hoist the quick reconcile above the metadata prelude it never reads,
which was a config file parse and a tag parse per rom
- drop the unreachable quick clause from `_should_hash_incrementally`:
`refresh_rom_files` owns that policy
- drop `RomFilesRefresh.files`, which nothing reads
- take the refresh lock without a guard that had nothing to protect
- fold the single-caller upload destination helpers into one
- give "a quick scan needs no metadata source" one home, and read the
refresh title from the key rom.json already owns
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A quick scan skipped every rom it already knew, so a file dropped into a
game folder went unnoticed until a complete or hashes rescan. This branch
answered that with a seventh scan type; letting quick reconcile the files
of the roms it knows says the same thing with less to learn.
Quick now visits every rom. New ones take the metadata pipeline as
before; existing ones only have their files reconciled against disk,
keeping the stored hashes of files whose size and mtime are unchanged. No
provider is contacted for an existing rom, so quick no longer needs a
metadata source picked, in the scan view, the platform dialog and the per
rom refresh alike.
The watcher schedules a quick scan again, and the per rom "Refresh files"
action sends quick scoped to that rom.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A files scan contacts no provider, but the scan view and the per platform
dialog both kept their start button disabled until one was picked, so the
option they had just gained could not be used. The refresh dialog already
exempted the type.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The per-ROM scan type list restated each option's own subtitle, and the
useScanTrigger header named two callers when four now share it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Backend:
- Drop the HashPolicy enum: FULL had no caller and INCREMENTAL was the
default, so refresh_rom_files uses the existing_files knob directly.
- Narrow RomFilesRefresh to the counters callers read.
- Build ParsedRomFiles once so the incremental return stops dropping the
title id fields.
- Give the assembling suffix one home in config, read by both the
assembler and the scanner's excluded extensions.
- Fold the duplicated destination collision check into one helper, and
branch /start on the upload target itself.
- Load the lighter rom for the refresh emit and the upload endpoints,
keep the flat file stat off the event loop, and reuse the directory
listing for the RA hash lookup.
Frontend:
- Route the platform scan dialog and the scan view through
useScanTrigger, so a scan started while one runs is refused rather
than emitted and rejected by the backend.
- Rename the socket payload type to ScanRequest, away from the
useScanProviders type of the same name.
- Drop the dead uploading prop and folder icon, reuse singleRomTitle,
and resolve each file's relative path once per listing.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`.r-v2-shell__app` had no minimum height, so a view shorter than the
viewport left the BottomNav anchor short and the sticky pill floated above
the real bottom edge. Match the shell's min-height so it always reaches it.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WbesTQXohyAWWcLV5iiEN
The selection actions become icon-only (download, copy link, delete, clear)
so they sit on the checkbox row instead of wrapping off-screen on narrow
viewports, and each file row gains a delete button gated on the delete grant.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WbesTQXohyAWWcLV5iiEN
`POST /api/roms/upload/start` keeps its X-Upload-* headers so existing
clients are unaffected; the new rom_id and folder travel in an optional
JSON body instead of extra headers.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WbesTQXohyAWWcLV5iiEN
`POST /api/roms/upload/start` reads platform_id, filename, total_size,
total_chunks and the optional rom_id and folder from a JSON payload instead
of X-Upload-* headers. Header values are limited to ISO-8859-1, which also
rejected non-Latin filenames in the browser.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WbesTQXohyAWWcLV5iiEN