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>
Both routes passed every caller-supplied platform_id straight to the
exporter. A permission group can grant platforms.write while hiding
individual platforms, so such a caller could export a platform hidden
from them -- reading its metadata and rewriting its gamelist.xml or
metadata.pegasus.txt.
Resolve and check every platform up front, the way update_platform and
delete_platform already do, so a rejected request writes nothing at all
rather than failing part way through a batch. A missing platform 404s
like a hidden one, so the response is not an oracle for whether the
platform exists.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Both export endpoints write into the library -- gamelist.xml and
metadata.pegasus.txt in the platform directory, plus media copied into
the per-type folders -- but were gated on roms.read, so any Viewer or
any roms.read client token could trigger a library write. Since #4368
those writes also merge the file already on disk, which makes a read
scope an even poorer fit.
platforms.write is the scope that already gates the sibling library
configuration writes in endpoints/configs.py, including the PUT /config/scan
that toggles the auto-export these endpoints mirror.
No UI change: nothing calls exportGamelistXml/exportPegasus, and the
generated frontend types carry no paths or scopes.
Co-Authored-By: Claude Opus 5 (1M context) <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>
A MariaDB server configured with --character-set-server=utf8 makes the roms
table, string literals and JSON_TABLE columns utf8mb3, which breaks three
places that a default utf8mb4 server accepts:
- 0096/0101 pin `COLLATE utf8mb4_general_ci` on view output columns. An
explicit utf8mb4 collation on a utf8mb3 value is rejected outright, so
upgrading fails with "COLLATION 'utf8mb4_general_ci' is not valid for
CHARACTER SET 'utf8mb3'". Each operand now goes through CONVERT(... USING
utf8mb4) first, keeping the strong coercibility that 3758 needed.
- 0098 compares JSON_UNQUOTE output against string literals in NOT IN, REGEXP
and NULLIF. JSON_UNQUOTE resolves under the connection charset while a
literal in a generated-column expression takes the table's collation, so the
two are an illegal mix. All of them now route through _maria_text, which
wraps the value in CAST(... AS CHAR).
CI only ever exercised the default collation, so none of this was visible. The
migrations workflow now runs MariaDB as a matrix over utf8mb4_general_ci and
utf8mb3_unicode_ci. Service containers take docker create options and cannot
pass --character-set-server, so the server is started from a step instead.
MariaDB moves to 11.3.2 everywhere in CI, matching docker-compose. That image
dropped the mysqladmin symlink, so the service health checks move to the
image's own healthcheck.sh.
Verified on mariadb:11.3.2: alembic upgrade head reaches head under both
collations, and the generated_* columns and virtual_collections rows are
identical between them.
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>
Pegasus logo and marquee both land in ES-DE's marquees folder. With the
same extension the second copy was skipped as already present, and the
metadata pointed both keys at the first file. A destination already
claimed by another source now gets the asset key appended to its name.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Dye15Zspts7hBruKYsPuT
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>
MariaDB pins the return collation of JSON_TYPE to utf8mb3_general_ci. In a
generated-column expression the literal it is compared against inherits the
table's collation instead of the connection's, so on a server started with
--character-set-server=utf8 --collation-server=utf8_unicode_ci the roms table
is utf8mb3_unicode_ci and the comparison is an illegal mix of two COERCIBLE
utf8mb3 collations. Migration 0098 then aborts and the app never starts.
CAST(... AS CHAR) re-derives the collation from the surrounding context, so
the comparison resolves on any table collation. The same pattern in the
roms_metadata views of 0074 and the 0098 downgrade is hardened too; it only
survives today because view literals resolve under the utf8mb4 connection.
Verified against ghcr.io/mariadb/mariadb:12.2.2-noble with the reporter's
charset flags: alembic upgrade head fails at 0098 without this change, and
reaches head with it, both from scratch and resuming a DB left at the failure.
Fixes#4350
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>
Exporting for both ES-DE and Pegasus after a scan wrote every media file
twice: once into the ES-DE per-type folders beside the ROMs, and once into
a parallel assets/ tree with Pegasus's own folder names. Pegasus resolves
media from the paths written in metadata.pegasus.txt, so it has no need
for a layout of its own. The exporter now copies into the same folders
the gamelist export uses and references them from the metadata file,
leaving one copy of each file and no assets/ directory.
Existing assets/ trees are left in place; the scan already excludes them.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Dye15Zspts7hBruKYsPuT
i18n.yml was the only workflow reaching for actions/setup-python; the
other five use uv. Both locale checks are stdlib-only, so run them with
`uv run --no-project` rather than resolving the backend project.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The runtime moved to 3.14 but the pinned versions did not, so packages
without cp314 wheels silently resolved to their pure-Python universal
wheels. Bump each to the first release that ships cp314 wheels, all
within the existing pyproject specs:
- SQLAlchemy 2.0.41 -> 2.0.52 (cyextension, and greenlet is back so
sqlalchemy.ext.asyncio is functional rather than merely importable)
- multidict, propcache, frozenlist (aiohttp/yarl accelerators)
- wrapt 1.17.2 -> 1.17.3 (OpenTelemetry instrumentation proxies)
- coverage 7.9.2 -> 7.16.0 (CTracer, and CI runs the suite under --cov)
- mysql-connector-python 9.3.0 -> 9.7.0 (C extension protocol)
- debugpy 1.8.14 -> 1.8.21 (pydevd accelerators)
- pyinstrument 5.0.3 -> 5.1.3 (no longer compiled from sdist on every
`uv sync --all-extras`, which broke the no-toolchain dev setup)
- anyio 4.9.0 -> 4.14.2, dropping a PEP 765 SyntaxWarning printed on
every process start
Run pytest and the migrations workflow when the runtime or the lock
changes: nothing in the 3.14 bump lives under `backend/`, so neither
workflow triggered on it. `e2e.yml` already listed those paths.
Make `.python-version` the single home for the version: `uv python
install` and `actions/setup-python` both read it. In the dev Dockerfile
that also fixes the interpreter layer not being invalidated when the pin
changes, and the sigil install now derives site-packages from the venv.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The webstation stack hardcoded a macOS uid/gid and its own copy of the
broker secret, and both optional stacks join romm_default, which resolved
to the checkout directory's name.
- PUID/PGID and BROKER_SECRET now come from .env, the latter following
STREAMING_BROKER_SECRET so both sides of the broker handshake agree
- pin the dev stack's project name so romm_default is deterministic
- document both stacks and their ordering in DEVELOPER_SETUP.md
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Authentik, its worker, and the Postgres instance backing it only matter when
working on OIDC, so they no longer start with every dev stack. The new file
follows the streaming one: its own compose project, joining romm_default so
Authentik reaches the dev Valkey and the backend reaches the issuer by name.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The webstation migration guide belongs in rommapp/docs, where users reading
about emulator streaming will find it (rommapp/docs#128). The deprecation
warning and the protocol module now link to the published page.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
endpoints/streaming.py had grown to 3778 lines, but only about a third of
that was routes. The rest was a second copy of the layer handler/streaming
already exists to hold: broker verbs, webstation protocol translation,
state and save and memory-card transfer, session teardown.
Split it along those seams rather than by route, and give claim_session
the same treatment: its 406 lines are now four named phases.
Cross-module calls go through the module (states.pull_state_to_library,
commands.stop) instead of imported names, so one definition site is what
tests patch and what every caller reads.
No route path, scope or response model changed, so the OpenAPI schema is
untouched.
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>
`endpoints/streaming.py` held a general-purpose Redis session store and an HTTP
client alongside its routes, so both were reachable only through the ASGI test
client and neither could serve a second caller. They now sit in
`handler/streaming/` next to the container and protocol modules, matching how
`handler/netplay_handler.py` already owns its Redis room state.
- `session_store.py`: the keys, TTLs, compare-and-set helpers, drain markers,
staleness rule and termination notices. Its names are public now, because the
module boundary is the privacy boundary.
- `broker.py`: the urllib transport, its bounded reads and byte caps, and the
translation of a transport failure into the 502/503 the frontend parses.
The endpoint module drops from 5157 lines to 3616 and keeps the routes, the
claim and teardown flows, and the asset sync.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`endpoints/states.py` wrote the same write-scan-upsert sequence twice for
screenshots and once for states, and the streaming sync had written its own
third copy of each. The sequence now lives in `handler/asset_store.py`, which
both callers use.
What differs between them stays with the caller: the upload route still owns
its filename validation and last-played bump, and the streaming sync still owns
its byte-identical dedup and its retention limit. `store_state_file` takes a
`fields` map for columns only one caller owns, so the upload path can never
clear the disc the streaming path recorded.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Two shapes of streaming broker were branched on at 19 call sites, and every
consumer re-derived a container's host, key, emulator, capabilities and card
sync from the raw YAML on each call. `_containers_for_platform` re-ran host
parsing and the operator's misconfiguration warnings on every request, and
`_container_label` re-read config.yml once per listed row.
`handler/streaming/`:
- `protocol.py` gives each broker shape a class owning its route prefixes,
timeouts, response dialect, stream-URL assembly and capability flags. A call
site now asks `protocol.supports_disc_swap` or `protocol.save_state_accepted`
instead of re-testing `protocol: webstation`. Instances are interned per
subfolder so identical configs share one object.
- `capabilities.py` holds the per-platform and per-emulator slot tables and the
state transfer limits, keyed purely by platform and emulator.
- `config.py` turns the raw list into frozen `ResolvedContainer` records with
every question already answered, memoized until the config changes, so the
warnings fire once per config rather than once per lookup. A container RomM
cannot dial still resolves, with an empty key: unclaimable, but visible in
the admin fleet view where the operator can see why.
`endpoints/streaming.py` drops ~700 lines and takes records rather than dicts
throughout; `container.emulator` and `container.protocol.session_route(...)`
replace the derivations that used to run per call.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>