`filesystem.structure` now spells out the whole layout rather than only the part
below a platform folder. A template is relative to the library root, `{platform}`
marks the platform folder, and `{game}` marks where a game begins.
Merge `{gameFile}` and `{gameDir}` into one `{game}` terminal. The information a
terminal carried was the depth, not the kind: at a declared level a file is a
game of its own and a folder is one multi-file game, which a stat answers. That
drops the two-template idiom for a level holding both, and `_discover_default_roms`
with it, since the default scan is now just `roms/{platform}/{game}`.
Retire the auto-detected `{platform}/roms` layout, along with
`filesystem.roms_folder` and `filesystem.firmware_folder`, which named one path
segment each that a template now contains. Both are refused at startup with the
template that reproduces the layout, so an instance that relied on either says so
instead of scanning an empty library and marking every rom missing. Firmware gets
its own `structure.firmware` key rather than following the rom layout implicitly.
`get_roms_fs_structure` keeps meaning the folder a platform's games start in, so
the `.physical` sentinel paths already in the database still resolve. Per-platform
overrides have to agree with `default` on where the platform folder sits;
relocating one platform needs platform discovery and the watcher to union several
roots, which is left out.
The setup wizard reports `library_ready` plus the configured template instead of
a `struct_a`/`struct_b` discriminator, so the banner shows the layout in force
rather than guessing it client-side.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Backend, wasted work:
- `_score_one` computed `content_similarity` twice per candidate on the
trim path and built `shared_reasons` for every candidate clearing the
score floor, discarding almost all of them. Compute content once and
build reasons only for the edges actually stored.
- `get_feature_rows` outer-joined `RomMetadata`, a view over the wide
`roms` table, defeating the point of reading the narrow facet mirror.
Read the generated columns off the `Rom` join already present.
- Feed cache invalidation ran a keyspace SCAN on every `rom_user` write.
Put graph and per-user version counters in the key so it is one INCR,
matching `invalidate_filter_values_cache`.
Backend, reuse:
- Route the five name comprehensions beside `_expanded_names` through it.
- `_recency_factor` reimplemented `to_utc`.
- `replace_similarity_edges` hand-rolled `itertools.batched`.
- Derive `TASTE_FACETS` from `FACET_WEIGHTS` instead of restating its keys.
Backend, dead code:
- `ScoredNeighbour`, `BuildStats.to_dict`, `delete_all_similarity_edges`,
the unread `difficulty`/`completion`/`backlogged` affinity fields,
`FACET_ORDER` and `RomInfo.rom_id`, and a no-op `column_type` ternary.
Frontend:
- Extract `RecommendationReason` from the two byte-identical copies in
`Home.vue` and `SimilarGamesGrid.vue`, dropping the repeated
`primaryReason` calls and their non-null assertions.
- Cap the caption with `--r-card-art-w` rather than a `158px` literal that
does not track the per-breakpoint card width.
- Key the similar-games fetch on the ROM id: `watchEffect` refetched on
every optimistic mutation of `currentRom`.
- One home for the similar-games limit.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Resolve conflicts in the v2 Home view and its test: keep both the
recommendations row from this branch and the live multiplayer sessions
row from master.
Master added migrations 0119 through 0121 that forked the Alembic chain
against this branch's 0119 through 0122. Renumber this branch's
migrations to 0122 through 0125 so they chain after 0121_state_disc_file.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01D9EiQ8VWDJfzhEViDdj84d
`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>
`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
Adds the files scan to the scan launchers and a direct "Refresh files"
action in the game menu, shares the socket trigger between them, refetches
the open game when a scan finishes, and routes every Files tab upload
through the chunked upload with a destination dialog for new folders.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WbesTQXohyAWWcLV5iiEN
Remove the roms_facets backfill from 0115: the steam columns are created by
that same revision, so it was a full-table UPDATE writing NULL over NULL at
container start. Migration 0114, which adds provider columns the same way,
has no backfill either.
Collapse the nine hand-written raw_*_metadata blocks in updateRom into a loop
over raw_metadata, so a new provider no longer needs a copy-pasted block.
Reuse the shared disable_metadata_rate_limiters fixture for the Steam adapter
tests instead of a second local one, move STEAM_PLATFORMS up to the constant
block it belongs to, and trim a test docstring that restated the rationale
already sitting next to resolve_steam_rom.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Teaches the streaming endpoints the webstation activate/exit contract
alongside the existing per-emulator broker mods, lets one container serve
a pool of platforms, and claims the first free container from that pool.
Sessions now sync save states, save archives and whole memory cards back
into the RomM library on release, keep every capture as browsable history,
and record the disc a state was taken on so a resume remounts it. Container
adoptions track a card the container already held so it is never wiped
without asking.
Adds the MemoryCard/MemoryCardVersion models and migration, a database
handler, and the /api/memory-cards endpoints for creating, renaming,
sharing, downloading and uploading a card. Cards are scoped to a user
and emulator rather than a rom, since one card holds every game's saves.
Also streams zip entries when hashing so a compression bomb cannot
exhaust memory, and adds a CLI helper for importing an existing card.
Renumber the two migrations onto master's head: 0108/0109 collided with
0108_roms_primary_region and 0109_rom_files_category_index, leaving the
chain with two heads. They are now 0114 and 0115 behind 0113.
Both rebuild the roms_facets sync triggers from a hardcoded column list,
so add the publishers and developers columns 0112 introduced. Without
them the rebuilt triggers would have silently stopped mirroring the two.
Adopt master's provider taxonomy. METADATA_PROVIDER_GROUPS now carries
demozoo, pouet, and csdb as catalogs, which replaces the branch's own
GENERAL_PROVIDER_KEYS set and feeds the setup wizard, the scan dialog,
and Settings from one registry. CSDb reaches the scan explainer for the
first time; it was already selectable there.
Regenerate the frontend types: DetailedRomSchema was missing the three
metadata blobs the backend has always declared on RomSchema, and the
blobs are now typed rather than Record<string, unknown>.
Correct the setup strings that still called the three sources enabled by
default, and sort the locale keys.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Cuts the multi-line rationale headers down to the one fact a reader
cannot recover from the code, and hoists RECENTLY_ADDED_LIMIT out of
the two views that each declared it into utils/jukebox.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Play-all and the browse selections still resolved their whole queue up
front, which on a large library meant ~100 parallel /music/tracks
requests before anything rendered.
They now load one 200-track page and fetch the next only as the viewer
scrolls toward the end of what is loaded, or as playback approaches it.
The panel reports the furthest index reached and the new useTrackPager
turns that into at most one in-flight page, dropping any page that
arrives after the selection changed.
getAllFavorites goes away with its last caller; getAllTracks stays for
the one list that is small by construction (a single game's soundtrack).
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Addresses the deeper issues left open by the previous cleanup pass: the
jukebox downloaded the whole track catalog on mount and re-derived every
facet client-side, and the view had grown to hold all of that state plus
eight screens' worth of markup.
Backend — close the gaps that forced the client-side grouping:
- filter tracks by the owning game's genre and by a year range
- facet games, platforms and game genres, so each sidebar is a paginated
server query with counts instead of a grouping over the full catalog
- a stats endpoint for the home cards' totals
- game genres are counted per rom then folded in Python, mirroring how
the ROM filters aggregate their JSON arrays
Frontend:
- Jukebox becomes a shell over HomeMode / BrowseMode / SessionMode; the
five browse dimensions share one component and differ only by the facet
they load and the filter they pass
- the soundtrack panel takes one normalized PanelTrack[] instead of a
rom-or-catalog prop union, and moves to components/Soundtrack/
- its track list is virtualised, so rows (and their menus) scale with the
viewport rather than the library
- favorites move into a store, ending the four-way hand-fanned copies
- new composables for rom soundtracks, delete confirmation and URL state
- CardRow moves to shared/; platform and jukebox tiles share one Tile
composite instead of two copies of the same chrome
Also fixes a viewer-permission test that the jukebox's PLAYLIST_EDIT
action key had been failing since it was added.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Quality pass over the jukebox feature: extract helpers the diff had
duplicated, collapse copy-pasted template blocks, and remove wasted work
on paths that run per render or per keystroke.
Reuse:
- share shuffled() from utils instead of two Fisher-Yates copies
- add v2/utils/errorMessage.ts and v2/utils/jukebox.ts so the mode list
has one owner instead of three hand-maintained copies
- game_cover_url reuses MusicTrackSchema.cover_url_for
Simplification:
- launch tiles and the session-mode ternary become data-driven
- drop unused order options from the music service and the unreachable
romId fallback in deleteSoundtrack
- extract buildPlayerPayload() from its two call sites
Efficiency:
- count music tracks over a single-column projection
- group tracks with push instead of rebuilding each bucket array
- precompute track rows so the list stops rescanning per render
- page the catalog and the panel's two fetches in parallel
- update a favorite in place rather than rebuilding three arrays
- debounce the search URL write alongside the fetch
Also adds freeRadio tests and fixes a vue-tsc error on route.query.game.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Edit ROM had a complete Steam UI - an ID field and a raw-metadata tab -
but `updateRom` serializes a fixed field list, and Steam was in neither
it nor the `raw_metadata` type. The endpoint preserves the stored value
for any field the form omits, so both edits returned 200 and changed
nothing.
The raw-metadata half escaped the typechecker because RawMetadataPanel
writes through a computed key, which widens the member type.
Cover the serializer, which had no tests at all: both lists are asserted
per provider, so the next provider to be added fails here rather than
silently dropping saves. Add the matching endpoint tests for the Steam ID
refetch, its disabled-handler path and the clear path, and extend the
unmatch sweep to Steam.
Master's #3898 landed the publisher/developer split, which this branch had
built its own narrower version of. Drop ours and rebuild on top of theirs:
- Delete 0113_company_role_columns; 0112_publisher_developer_split supersedes
it and derives the roles from all seven providers rather than two.
- Renumber 0110/0111/0112 to 0113/0114/0115 behind master's new head.
- Carry generated_publishers/generated_developers through the view and facet
trigger rebuilds in 0114/0115, which would otherwise drop them.
- Order 0115's view projections as 0114 leaves them: PostgreSQL rejects a
CREATE OR REPLACE VIEW that renames an existing column.
- Take master's IGDB role extraction; extract_tokens already dedupes.
Metadata providers (ScreenScraper, RetroAchievements, LaunchBox,
Flashpoint, gamelist, IGDB) distinguish the publisher from the developer
of a game, but RomM amalgamated both into a single `companies` list at
ingestion, so the distinction was unrecoverable. This adds `publishers`
and `developers` as new, refined fields end to end while keeping
`companies` (the merged union) working exactly as before.
Backend:
- Handlers now emit publishers/developers alongside the unchanged
companies list; IGDB requests the involved_companies developer/
publisher flags to split by role.
- Migration 0112 adds generated_publishers/generated_developers columns
on roms, projects them through the roms_metadata view, mirrors them
into roms_facets, and adds publisher/developer virtual-collection
types (triggers/functions rebuilt for MariaDB/MySQL + PostgreSQL).
- Filters, facets, endpoints, smart collections and the gamelist/pegasus
exporters all carry the new fields; exporters prefer the explicit
split and fall back to the companies heuristic for un-rescanned ROMs.
Frontend (v2):
- Shared filter store + API service, gallery filter drawer, URL
persistence, game detail display (Developers/Publishers with a
Companies fallback), edit dialog, smart-collection criteria, and a
publisher/developer "group virtual collections by" option.
- Also relabels the confusing "company"->"Developer" group-by option
to "Company" now that a proper Developer option exists.
Fixes#3518
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Physical games were addable and visible but not selectable: nothing let a user
ask "what do I own on a shelf?" or exclude shelf entries from a view of what is
actually on disk.
Expose the handler's `physical` filter as a `GET /roms` query param and carry it
through the v2 gallery the way `filterSoundtrack` is carried: a tri-state row in
the filter drawer (all / physical only / file-backed only), the toolbar's active
count, `?filterPhysical=` in the URL so a filtered view stays bookmarkable, and
the smart-collection criteria plus their summary row.
Reuses mdi-cube-outline, already this feature's icon, with cube-off-outline as
the negative. Translated into all 18 locales, taking each one's existing term
for a physical game from rom.json.
Verified against the dev library (74898 roms): physical=1, file-backed=74897,
an exact partition, with the filtered gallery showing only the physical entry in
both themes and the control reachable by keyboard.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Backend:
- Drop the post-scan re-assert of is_physical/upc/fs_path in
create_physical_rom; scan_rom already forwards them in rom_attrs. The test
fake was written to drop those fields to exercise the dead path, so it now
matches the real scan_rom contract.
- Extract build_hashless_fs_rom() and use it from both the physical endpoint
and the scan socket, which built the same FSRom literal by hand.
- Return added_rom instead of re-fetching it; add_rom is already decorated
with @with_details, so get_rom repeated the whole eager-load fan-out.
- Pair invalidate_filter_values_cache() with refresh_affected_smart_collections(),
as every other rom-mutating endpoint does.
- Reword the 409 detail: build_physical_fs_name uniquifies the name, so an
IntegrityError can only mean a concurrent add.
- upc_handler: inline the single-use base_url and hoist the minimum title
length to a module constant.
Frontend:
- Load BarcodeScannerDialog lazily. GlobalDialogs is mounted on every page, so
the static import chain put ZXing (~438 KB) in the eager layout chunk. The
scanner's watcher now runs immediate/post so it still starts when mounted
behind a v-if.
- Guard the scanner against a teardown that races the decodeFromConstraints
await; closing during the permission prompt left the camera on and the
decode loop running.
- Render the UPC scan trigger through RTextField's append-inner adornment
instead of a hand-built flex row.
- Type the createPhysicalRom payload with the generated PhysicalRomCreateForm
and drop the metadataSources argument, which had no caller.
- Declare @zxing/library directly; it was imported but resolved transitively.
- Drop two write-only refs, scope the reader local to startCamera, and trim
comments that restate the code.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Unify manuals and walkthroughs on one document model instead of a
separate walkthrough subsystem. Walkthroughs are RomFiles under a new
WALKTHROUGH category with an optional RomFileDocMeta provenance sidecar,
and reading progress is a per-user RomFileUser row keyed on rom_file_id
so the same mechanism covers manuals and walkthroughs.
Backend:
- models: RomFileCategory.WALKTHROUGH, DocSource, RomFileDocMeta,
RomFileUser; migration 0110 (enum value + two tables, cross-DB)
- serve .txt/.html documents inline (HTML under a sandboxing CSP);
add .txt to allowed manual files
- endpoints: walkthrough upload / GameFAQs fetch / delete, and per-user
reading-progress GET (ROMS_READ) / PUT (ROMS_USER_WRITE, like notes, so a
kiosk guest capped to the read scopes cannot write)
- last_page is range-checked, so an out-of-range value is a 400 rather than
an integer column overflow
- the guide body is read under the size cap instead of being buffered in
full and truncated afterwards
- GameFAQs import extracts text only (stored as .txt); no remote HTML is
persisted or served. Host-allowlisted on top of the SSRF-safe client
- a Cloudflare bot challenge is detected and reported as "open it in your
browser and upload the text" instead of an opaque 403
- reading-progress upsert retries as an update on a unique-constraint
race, so concurrent saves for one user/file can't 500
- a GameFAQs guide is removed from disk again if indexing it fails,
rather than being left unreferenced
- tests for CRUD, progress, the GameFAQs parser/URL validation, and
hidden-rom masking on every walkthrough route
Frontend (v2):
- TextViewer (.txt/.html), useReadingProgress composable, WalkthroughSubtab
(upload + add-from-GameFAQs-URL + delete + progress), wired into MediaTab
- ManualSubtab renders .txt manuals; walkthrough category surfaced in
FilesTab; regenerated types; i18n keys across all locales
- a pending scroll position is committed before the viewer follows a new
document, so switching files mid-debounce no longer drops it
- WalkthroughSubtab gates upload, the GameFAQs URL field, and delete on
useCan("rom.edit"), as ManualSubtab already does
AI assistance: implemented with Claude Code (Opus 4.8). The data-model
design, backend, migration, tests, and v2 UI were AI-authored under human
direction. Alternative approach to #2892.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add the three sources to Classic and v2 settings, Scan, and Edit ROM.
Edit ROM accepts a production URL or a bare id. Metadata tab extra
links render only http(s) hrefs.
"Similar games" now reads the recommendations index instead of
`igdb_metadata.similar_games`, so every entry is a game the server actually
holds. That also drops the per-card `by-metadata-provider` lookup the IGDB
stubs needed: the endpoint returns real ROMs, so the cards are ordinary
interactive GameCards rather than synthetic ones.
Adds a "Recommended for you" row to Home, each card captioned with why it
was suggested, behind a `showRecommendations` UI setting. An unbuilt index
or a library too small to relate anything is a normal state, so both
surfaces stay hidden rather than surfacing an error.
Structural IGDB relations (expansions, DLC, remakes, remasters) are
untouched -- those are facts about a game, not recommendations.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The "Recently added" and "Recently played" rows each ask for 15 games and
render 15 covers, but both requests still made the server count every game
in the library and then discarded the number. On a large library that count
is the expensive part of the request, so opening the home page paid for two
whole-library counts nobody sees.
Both rows now send with_total=false, the option added for the gallery in
#4062.
The flag has to reach the request and the cache-clear pattern together: the
pattern is matched against the cache key by substring, so adding it to only
one side would leave the row permanently stale. The cached service now
builds both from a single parameter map per row so they cannot drift, and
the tests assert the clear pattern still matches the key the request writes.
Fixes#4099
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A scan flags firmware whose file vanished, but nothing could act on the
flag: stale BIOS entries could only be found by opening each platform's
Firmware tab one at a time, the player still offered them (auto-selecting
the sole entry, so the game failed to boot with nothing pointing at the
BIOS), and platform firmware counts included them.
Adds a `missing` filter to the firmware list endpoint, a
`cleanup_missing_firmware` manual task alongside the ROM one, and a
Missing firmware tab in Library management that lists every flagged entry
library-wide with a bulk cleanup. The player now asks for present
firmware only, and firmware selection moved to a `playerFirmware` util
that never picks a missing entry. `firmware_count` counts only firmware
present on disk; the rows themselves still ship so the Firmware tab can
strike them through.
`FirmwareSchema` gains `platform_id` so the library-wide list can group
by platform.
Fixes#4075
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The Home "Random Pick" widget asked the API for the library total, then
for the single row at a random offset. Paging to offset N makes the
database walk and discard the N rows before it, so the pick got slower
the bigger the library: measured on an 83,000-game instance, 1.7s at the
median offset and 6.9s deep into the list, on every home page visit.
Adds GET /api/roms/random. It offers the query a batch of random primary
keys and takes any that exist, which is one index lookup per candidate
and unbiased, since every id in the table is equally likely to be
offered. A batch only misses when the query matches too little of the id
space, and it then falls back to counting the set and taking the row at a
random position, reading index entries rather than rows because the
statement selects nothing but the id. Both paths are uniform.
On the same 83,000-game library: 2.9ms median for an unscoped pick
(0.6% of picks take the fallback, 236ms), 19-25ms scoped to a platform.
The widget now resolves a pick in one request.
The endpoint takes the platform / collection scope parameters so the
gallery "Random ROM" buttons (#4068) can move onto it too.
Fixes#4066
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Opting out of the rom id index made the endpoint fall back to a COUNT
over the whole filtered set, so every scroll batch re-derived a total
the page already had from its bootstrap.
Add a with_total flag that skips that count, and have the v2 gallery's
window fetch pass it alongside the sidecar opt-outs it already sends.
total comes back null there, which the store's existing guard leaves
alone rather than applying over the size it knows.
Fixes#4053
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Protected routes answered 403 both when there was no session and when the
authenticated user lacked the required scope. The frontend read every 403
as session expiry, cleared the session cookie and redirected to /login, so
a permission denial (for instance saving a state without the save scope)
tore down whatever the user was doing, including a running emulator.
`protected_route` now uses its own scope guard that raises 401 with a
`WWW-Authenticate` header when the caller is unauthenticated, and 403 when
the caller is authenticated but under-scoped. The axios interceptor only
redirects on 401 and lets 403s surface inline to the caller, refreshing the
CSRF cookie when the backend rejected the CSRF token.
Endpoint assertions for unauthenticated requests move from 403 to 401;
authenticated under-scoped cases stay 403.
Fixes#4045
Leaving EmulatorJS triggers a full page reload (to reset COOP/COEP) that
aborts the in-flight play-session POST. Add an ingestPlaySessionsKeepalive
variant using fetch with keepalive (plus the session cookie and CSRF header),
and have usePlaySession.flush() use it so the session is recorded even as the
document unloads.
Co-Authored-By: Claude Opus 4.8 (1M context) <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>
A platform folder created on disk (optionally bound in Library
Management) has no database row until its first scan imports a ROM, so
it was invisible to the scan platform picker and a first scan could not
be triggered for it. The picker also filtered to rom_count > 0, hiding
even zero-ROM database platforms (e.g. those created via romm-cli).
Backend:
- Add GET /platforms/filesystem returning folders on disk without a
database row yet (locally-resolved metadata, id -1, rom_count 0).
- scan_platforms / the scan socket now accept platform_fs_slugs so a
folder can be scanned by slug; database platforms stay accepted by id.
Frontend (v2):
- Fetch filesystem folders, key the scan picker by fs_slug, include
zero-ROM database platforms, and tag never-scanned folders.
Fixes#3832
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>