Commit Graph

580 Commits

Author SHA1 Message Date
Georges-Antoine Assi
a7ecfd96a9 feat!: make filesystem.structure the single library layout
`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>
2026-09-08 08:39:21 -04:00
Georges-Antoine Assi
1ff9944224 refactor(recommendations): reuse, simplification and efficiency pass
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>
2026-09-06 11:44:00 -04:00
Sam Dornan
8494744ee7 Merge branch 'master' into claude/igdb-keywords-themes-perspectives
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
2026-09-06 00:24:13 +00:00
Georges-Antoine Assi
74c77d0bb2 feat(streaming): answer the claim before the launch, and push what happens
`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>
2026-09-05 12:04:58 -04:00
Georges-Antoine Assi
1e716b381d feat(streaming): give the streaming routes typed responses
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>
2026-09-05 11:15:36 -04:00
Georges-Antoine Assi
3cacb59ee4 refactor(streaming): give the duplicated rules one home each
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>
2026-09-05 08:54:32 -04:00
Georges-Antoine Assi
15233afcb1 Merge branch 'master' into feat/streaming-webstation
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>
2026-09-05 07:49:12 -04:00
Sam Dornan
c1dbe3e8f6 Merge branch 'master' into claude/igdb-keywords-themes-perspectives 2026-09-03 21:37:49 -05:00
zurdi
d09016a485 refactor(upload): keep the start headers and take the rom target as a JSON body
`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
2026-09-03 17:15:34 -04:00
zurdi
452f0a41de refactor(upload): take the chunked upload start fields as a JSON body
`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
2026-09-03 17:15:34 -04:00
zurdi
af57e8d574 feat(v2): refresh files scan and uploads into rom folders
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
2026-09-03 17:15:33 -04:00
Sam Dornan
0feedde197 Merge remote-tracking branch 'origin/master' into claude/igdb-keywords-themes-perspectives 2026-09-03 09:25:03 -05:00
Georges-Antoine Assi
50b03f8cc7 refactor(steam): drop redundant work found in review
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>
2026-09-01 17:05:18 -04:00
Georges-Antoine Assi
a7a15754b0 Merge remote-tracking branch 'origin/master' into claude/steam-metadata-provider
# Conflicts:
#	backend/config/__init__.py
#	backend/config/config_manager.py
#	backend/endpoints/heartbeat.py
#	backend/endpoints/responses/heartbeat.py
#	backend/endpoints/responses/rom.py
#	backend/endpoints/roms/__init__.py
#	backend/handler/database/roms_handler.py
#	backend/handler/metadata/__init__.py
#	backend/handler/scan_handler.py
#	backend/models/rom.py
#	backend/tasks/scheduled/scan_library.py
#	backend/watcher.py
#	env.template
#	frontend/src/__generated__/models/Body_update_rom_api_roms__id__put.ts
#	frontend/src/__generated__/models/DetailedRomSchema.ts
#	frontend/src/__generated__/models/MetadataSourcesDict.ts
#	frontend/src/__generated__/models/SimpleRomSchema.ts
#	frontend/src/locales/bg_BG/settings.json
#	frontend/src/locales/cs_CZ/settings.json
#	frontend/src/locales/de_DE/settings.json
#	frontend/src/locales/en_GB/settings.json
#	frontend/src/locales/en_US/settings.json
#	frontend/src/locales/es_ES/settings.json
#	frontend/src/locales/fr_FR/settings.json
#	frontend/src/locales/hu_HU/settings.json
#	frontend/src/locales/it_IT/settings.json
#	frontend/src/locales/ja_JP/settings.json
#	frontend/src/locales/ko_KR/settings.json
#	frontend/src/locales/pl_PL/settings.json
#	frontend/src/locales/pt_BR/settings.json
#	frontend/src/locales/ro_RO/settings.json
#	frontend/src/locales/ru_RU/settings.json
#	frontend/src/locales/tr_TR/settings.json
#	frontend/src/locales/zh_CN/settings.json
#	frontend/src/locales/zh_TW/settings.json
#	frontend/src/services/api/rom.ts
#	frontend/src/stores/heartbeat.ts
#	frontend/src/v2/components/EditRom/MetadataIdSection.vue
#	frontend/src/v2/components/GameDetails/RelatedGameCard.vue
#	frontend/src/v2/components/GameDetails/providers.ts
#	frontend/src/v2/components/Scan/ScanInfoDialog.vue
#	frontend/src/v2/utils/metadataProviders.ts
#	frontend/src/v2/views/Settings/ScanSettings.vue
2026-09-01 16:49:24 -04:00
Zach Clendenen
77edaa16b4 feat(streaming): webstation broker protocol, container adoption and disc state
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.
2026-08-30 22:41:37 -05:00
Zach Clendenen
d9fe02bdb1 feat(memory-cards): store whole memory card images per user and emulator
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.
2026-08-30 22:41:36 -05:00
Georges-Antoine Assi
fc46c3eb1c Merge branch 'master' into feat/demozoo-pouet-phase0
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>
2026-08-30 21:32:11 -04:00
Georges-Antoine Assi
41d2858caf refactor(music): trim comments and give shared values one home
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>
2026-08-30 15:33:05 -04:00
Georges-Antoine Assi
414dea2b49 Merge remote-tracking branch 'origin/master' into agent/jukebox
# Conflicts:
#	frontend/src/stores/soundtrackPlayer.ts
#	frontend/src/v2/components/GameDetails/MediaTab.vue
#	frontend/src/v2/components/GameDetails/SoundtrackPanel.vue
2026-08-30 15:16:45 -04:00
Georges-Antoine Assi
b26c6d38e9 perf(music): page the jukebox track lists in on demand
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>
2026-08-30 08:35:40 -04:00
Georges-Antoine Assi
dc22c2239c refactor(music): serve jukebox browsing from the API
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>
2026-08-30 08:18:41 -04:00
Georges-Antoine Assi
974b2a4be7 refactor(music): simplify jukebox and share duplicated helpers
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>
2026-08-30 07:20:51 -04:00
Sam Dornan
8fced61064 fix(steam): send the Steam ID and raw metadata on save
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.
2026-08-29 17:20:40 -05:00
Georges-Antoine Assi
c45587fe7c Merge remote-tracking branch 'origin/master' into fix/missing-firmware-cleanup
# Conflicts:
#	frontend/src/locales/pt_BR/settings.json
#	frontend/src/v2/views/Player/EmulatorJS.vue
2026-08-29 15:18:00 -04:00
Sam Dornan
2be8cfcb4c Merge branch 'master' into claude/igdb-keywords-themes-perspectives
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.
2026-08-27 18:55:58 -05:00
Georges-Antoine Assi
42ebaaec49 feat: split company metadata into publishers and developers
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>
2026-08-27 14:44:30 -04:00
Georges-Antoine Assi
bc95411239 feat: filter the gallery by physical games
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>
2026-08-27 11:01:47 -04:00
Georges-Antoine Assi
08901ca3a9 cleanup: reuse, simplify and trim the physical-games feature
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>
2026-08-25 20:47:56 -04:00
Georges-Antoine Assi
69938b1cee add support for physical (DB only) games 2026-08-25 20:19:05 -04:00
Georges-Antoine Assi
3c95231294 feat: walkthrough documents with reading progress and GameFAQs import
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>
2026-08-25 19:40:20 -04:00
Axel Quack
a3f7484c0c feat(ui): surface Demozoo, Pouët, and CSDb in Setup, Scan, and Edit ROM
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.
2026-08-17 08:59:54 +01:00
wadie
5f613687e5 feat(music): add jukebox 2026-08-14 10:24:02 +02:00
Sam Dornan
550ee34f01 feat(v2): surface recommendations on game details and home
"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>
2026-08-07 20:12:45 -05:00
Spinnich
dbd213c6c9 perf(home): stop counting the whole library for the two home rows
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>
2026-08-04 17:20:23 +00:00
Spinnich
b6d43ce73c chore(roms): drop the comment on the random rom api wrapper
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-04 11:24:06 +00:00
Spinnich
3e02fb94ff fix(firmware): let missing firmware be found and cleaned up
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>
2026-08-02 23:52:21 +00:00
Spinnich
1ee6cea070 perf(roms): pick a random rom without paging to a random offset
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>
2026-08-02 19:25:36 +00:00
Georges-Antoine Assi
1e514ec273 chore(roms): drop redundant comments on the total opt-out
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 20:27:57 -04:00
Georges-Antoine Assi
43cdd0856a refactor(roms): resolve the page total in a helper
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 19:59:29 -04:00
Spinnich
0be6e3a70f perf(roms): let a gallery window fetch skip the library count
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>
2026-08-01 23:00:38 +00:00
Georges-Antoine Assi
f26c3234d7 fix(auth): return 401 for unauthenticated requests, keep 403 for missing scopes
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
2026-08-01 14:12:40 -04:00
Georges-Antoine Assi
e87571d7f5 fix(v2): send exit-time play session with keepalive so it survives reload
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>
2026-07-21 16:51:57 -04:00
Georges-Antoine Assi
0a262ebf8d Merge pull request #3855 from Spinnich/feat/platform-descriptions
feat(platforms): add editable platform descriptions
2026-07-20 19:16:52 -04:00
Georges-Antoine Assi
389e768ee8 cleanup 2026-07-20 19:04:59 -04:00
Georges-Antoine Assi
31c19f754e Merge pull request #3854 from rommapp/feat/scan-settings-v2-ui
feat: editable v2 UI for scan settings
2026-07-20 18:58:15 -04:00
Spinnich
84dd839a62 fix(platforms): keep the v1 UI untouched
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>
2026-07-20 20:10:27 +00:00
Spinnich
82caaf87a9 fix(platforms): address review feedback on PR #3855
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>
2026-07-20 20:01:05 +00:00
Spinnich
98e8ae7599 feat(platforms): add editable platform descriptions
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>
2026-07-20 19:00:30 +00:00
Georges-Antoine Assi
191cd1f24c feat(config): editable v2 UI for scan settings
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>
2026-07-20 11:24:31 -04:00
Georges-Antoine Assi
a67132a908 Surface never-scanned platform folders in the scan picker
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>
2026-07-19 22:13:16 -04:00