Commit Graph

2321 Commits

Author SHA1 Message Date
Sam Dornan
4ffc7c5ce1 style: apply the formatting requires-python already implies (#4638) 2026-09-19 12:33:45 -04:00
zurdi
aeef54d044 fix(covers): derive cover sizes off the event loop (Greptile review)
Addresses Greptile's review of #4613:
- Write the small cover and the WebP copies in a worker thread, since
  Pillow's work now scales with an animation's frames.
- Annotate the new converter fixture and the artwork test's tmp_path.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-18 11:20:41 +02:00
zurdi
9424347708 style(covers): trim animated cover comments (review-polish)
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-18 11:01:04 +02:00
zurdi
0318f078ae refactor(covers): simplify animated cover handling (simplify)
Simplify pass over the animated cover change:
- Encode animated small covers as WebP whatever the source, which drops
  the per-format GIF/APNG blending params and makes their WebP copy a
  plain file copy.
- Fold the is_animated gate into frame_durations and decode the small
  cover's frames in the same pass that reads their durations.
- Write uploaded animated artwork through the atomic write_file.
- Share test fixture constants and the animation encoder, and pin the
  per-frame pixel budget with a GIF whose canvas grows mid-animation.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-18 11:00:14 +02:00
zurdi
88a82a729f fix(covers): bound and harden animated cover processing (code-review)
Code-review pass over the animated cover change:
- Cap the pixels decoded across an animation (MAX_ANIMATION_PIXELS),
  counted per frame since a GIF canvas can grow mid-animation, so an
  oversized animation falls back to its first frame.
- Fall back to the first frame when a later frame fails to decode,
  instead of dropping the cover or escaping the error handlers.
- Store uploaded animated artwork as uploaded, like downloaded covers.
- Re-encode composited frames so each replaces the last (no GIF/APNG
  ghost trails), and keep GIF loop counts when converting to WebP.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-18 10:45:29 +02:00
zurdi
b326e66db9 fix(covers): keep animated covers animated after applying them
The small cover and the WebP copies were written through PIL, which keeps
only the first frame, so an animated SteamGridDB cover showed as a still
image everywhere once applied. Resize and convert every frame with its
timing, copy WebP sources instead of re-encoding them, and keep all
frames of uploaded animated artwork.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-18 10:22:02 +02:00
Sam Dornan
c2ee769df7 fix(roms): load the parent rom alongside a rom file so the schema validates (#4593)
`GET /api/roms/{id}/files` 500'd on its success path: `RomFileSchema` reads
`is_top_level`, which needs `file.rom`, and `get_rom_file_by_id` only loaded
`track_meta` and `doc_meta`. Validation happens after `begin_session` closes,
so the lazy load raised `DetachedInstanceError`. The parent rom now comes
along in the same load, narrowed to the columns `Rom.full_path` needs.

`last_modified` is nullable in the column but was required in the schema, so
a row added outside a scan validated to nothing. It is now nullable to match,
and the regenerated frontend type follows.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-17 12:20:16 -05:00
Sam Dornan
bba15f95f4 perf(backend): resolve roms without the related load in the file and props routes (#4590)
* perf(backend): resolve roms without the related load in the file and props routes

Eleven routes opened with `get_rom(id)` to reach two scalars: `id` for the
404 and `id` plus `platform_id` for `assert_rom_visible`. `get_rom` runs the
whole `with_details` eager load, so each request paid for the platform,
files, metadata, saves, states, screenshots, rom_users, siblings,
collections and notes of the rom. The bulk delete was worse: it ran inside a
per-id loop, so an N-id delete ran the graph N times.

Three narrow projections replace it, alongside the `get_rom_visibility` that
#4587 added for the rom-note routes:

  `get_rom_visibility`        id, platform_id
  `get_rom_visibility_label`  the above plus the name pair the file-delete
                              log lines print
  `get_rom_deletion_target`   the above plus fs_path and the joined platform
                              label the bulk delete logs when a rom's file is
                              already missing from disk

`assert_rom_visible` accepts either narrow row as well as a full `Rom`, so
the check itself is unchanged for every other caller.

Statement counts per request, captured with the `executed_statements`
fixture in `tests/endpoints/roms/test_visibility_loads.py`:

  PUT  /api/roms/{id}/props                       19 ->  9
  GET  /api/roms/{id}/soundtracks/metadata        15 ->  5
  GET  /api/roms/{rom_id}/files/{file_id}/progress 20 ->  8
  DELETE manuals / walkthroughs / screenshots /
         soundtracks files                         20 ->  8 each
  DELETE /api/roms/{rom_id}/files/{file_id}        20 ->  8
  GET  /api/roms/{id}/files (hidden 404)           25 -> 13
  GET  /api/roms/{id}/files/content/{name}         25 -> 13
  POST /api/roms/delete, 1 id                      16 ->  6
  POST /api/roms/delete, 5 ids                     64 -> 14

The marginal cost of each extra id in a bulk delete falls from 12 statements
to 2.

The upload handlers on the same routers are left alone: `receive_rom_file`
hands the rom to `prepare_upload_destination`, so they need the full entity.
`Rom.fs_resources_path` moves its format string into a module-level function
so `RomDeletionTarget` can compute the same value.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(backend): trim the change rationale out of the new docstrings

Greptile flagged the module docstring in the new test file, `_rom_lookup` and
`RomDeletionTarget` for carrying the reasoning behind the change rather than
describing what the code does. The rationale lives in the commit message and
the PR body, so the docstrings keep only the one sentence a reader needs.

The `assert_rom_visible` docstring loses the paragraph added alongside the
widened type union, which restated what the signature already shows.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(roms): share one rom factory in the visibility-load guard

Step 3 of the pr-ready gauntlet (simplify). The bulk-delete test built its
three roms from an inline `Rom(...)` literal; `test_random.py` already keeps a
module-local `_add_rom(platform, name)` for exactly this, so the guard grows
the same helper instead of a second copy of the field list.

`_flat` had one caller, so it folds into `_rom_lookup`.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-17 12:18:22 -05:00
Sam Dornan
dd6303418b fix(collections): project identifier columns instead of loading whole collections (#4589)
* fix(collections): project identifier columns instead of loading whole collections

`GET /api/collections/identifiers` reads only ids, owners and visibility, but
the accessor it called eagerly loaded every rom of every collection
(`@with_roms`) and built a full `User` per row (`Collection.user` is
`lazy="joined"`). A column projection drops both, while `load_only` cannot
cancel either one.

Measured on a seeded database of 100 collections and 200 roms (20,000
memberships): rows read 20,100 to 100, statements 2 to 1, SQL text 1,172 to
113 bytes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(collections): keep the new identifier assertions to one-line comments

The repo caps comments at one line when the rationale is not recoverable
from the code, and test docstrings at one sentence, so the m2m reasoning
belongs in the PR body rather than repeated at the call sites.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-17 11:42:00 -05:00
Sam Dornan
d120602342 perf(backend): check rom-note visibility without the related load (#4587)
* perf(backend): check rom-note visibility without the related load

The five `/api/roms/{id}/notes*` routes each opened with `get_rom(id)` to
reach two scalars: `id` for the 404 and `id` plus `platform_id` for
`assert_rom_visible`. `get_rom` runs the whole `with_details` eager load, so
every note read or write paid for the platform, files, metadata, saves,
states, screenshots, rom_users, siblings, collections and notes of the rom,
about 12 statements.

`DBRomsHandler.get_rom_visibility` selects those two columns and nothing
else, and `assert_rom_visible` now takes the `RomVisibility` row it returns
as well as a full `Rom`, so no other caller of the check changes.

Measured on a 3,000-rom library with 300 notes on the target rom, one admin
request:

  GET  /api/roms/{id}/notes/identifiers  17 statements / 30,059 bytes -> 5 / 8,066
  POST /api/roms/{id}/notes              17 statements / 23,209 bytes -> 5 / 1,216

The server-side `Questions` delta per request falls from 33 to 21.

The `executed_statements` fixture moves to `tests/conftest.py` so the new
endpoint tests can use it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(roms): match the rom lookup across dialects

The notes-load guard pinned the exact SQL text of the visibility lookup,
including MariaDB's `?` bind placeholder. psycopg renders the same query
as `%(id_1)s::INTEGER`, so the assertion could never match on the
PostgreSQL leg of the CI matrix and all three tests would have failed
there. Compare a dialect-independent prefix instead.

Step 2 of the pr-ready gauntlet: correctness fix plus the comment and
docstring trims it flagged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test: drop the second copy of the statement-capture fixture

`test_released_days.py` carried its own `captured_sql`, the same
before_cursor_execute listener the notes-load guard now shares as
`executed_statements` from tests/conftest.py. Point that file at the
shared fixture and drop the now-unused imports.

Step 3 of the pr-ready gauntlet: reuse and simplification fixes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test: name the notes auth helper as the other endpoint tests do

Seven endpoint test modules already define `_auth` for the bearer header;
this file introduced a third name for the same one-liner.

Step 4 of the pr-ready gauntlet: review-polish consistency pass, after
trunk fmt and the affected-suite run.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-17 11:30:33 -05:00
Sam Dornan
fd9a33bc35 fix(backend): return identifiers without building an ORM row per id (#4586)
* fix(backend): project the identifier endpoints onto the id column

The `/identifiers` routes for saves, states, firmware, platforms, smart
collections and rom notes each asked their handler for entities with
`only_fields=[Model.id]`. `load_only` narrows the selected columns but does
not cancel an eager relationship, so a `lazy="joined"` join still fired and a
full entity was still built for every row. The platforms route was the worst
of the six: `with_firmware` eager-loads every firmware row and its platform,
and `load_only` does not cancel that either.

Each handler grows a small query builder shared by its existing accessor and a
new `*_ids` accessor that projects onto the id column with
`with_only_columns`, which drops the entity and with it the eager joins. The
firmware accessor already applied `noload`, so its SQL is unchanged; it moves
to the projection only to stop building rows.

`/api/users/identifiers` and the two `/collections` callers that use more than
an id are left alone, because nothing eager fires for them.

The `executed_statements` fixture moves to `tests/conftest.py` so the new
endpoint tests can use it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* Update backend/tests/endpoints/test_identifier_endpoints.py

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

* style(backend): drop the leading blank line black rejects

Removing the module docstring in the GitHub edit left an empty first line,
which is the only thing black wanted to change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* test(backend): drive the note-identifier test through the endpoint

Greptile flagged the handler-level test for bypassing the route's auth,
404, and visibility checks. It now issues the request the frontend would
and asserts the id-only projection holds among the route's own reads.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* refactor(backend): fold the duplicate SQL-capture fixtures into the shared one

Step 3 of the PR-ready gauntlet (simplify). The shared
`executed_statements` fixture gains the two roms test files that still
declared byte-identical local copies, and the id-only assertions share one
statement parser instead of two.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(backend): tighten the get_platform_ids docstring to one line

Step 4 of the PR-ready gauntlet (review-polish).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2026-09-17 11:13:07 -05:00
Sam Dornan
24bc9b3da9 fix(roms): answer the id endpoints without building every Rom (#4584) 2026-09-17 09:37:38 -05:00
Georges-Antoine Assi
c39655acd0 Merge pull request #4566 from tmgast/fix/sigil-cnf-serial-shapes
fix(scan): read PSX and PS2 serials sigil missed and identify multi-disc roms by their first disc
2026-09-17 07:22:41 -04:00
Georges-Antoine Assi
05f445a4cf refactor(scan): ask the handler whether a rom is a folder
`directory_exists` and `Rom.full_path` already spell out the check the
scan does at its own call site, so the path is no longer rebuilt here.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 07:17:51 -04:00
Georges-Antoine Assi
c28059c328 chore(scan): review-polish the title id extraction pass
Name the candidate predicate for what it checks, trim the ordering
docstring, and drop the comments the moved guards made stale.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 22:02:32 -04:00
Georges-Antoine Assi
9e940e7d10 refactor(scan): simplify the title id extraction path
Sort title id sources with the natural key the models already compute,
give the compressed suffixes one home, and let SigilService reject a
container itself rather than trusting every caller to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 22:00:57 -04:00
Georges-Antoine Assi
cf8d79f9f6 fix(scan): apply pr-ready code-review findings
Order discs by their number so "Disc 2" precedes "Disc 10", test one
rule for containers sigil cannot read, and drop the unreachable
OSError handler around Path.is_file.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 21:53:31 -04:00
Georges-Antoine Assi
d16aa85968 Merge branch 'master' into streaming-patches-3
AssetList moved its timestamp into <AssetTimestamp> and gained
groupBySlot on master, so the picker's `timestamp` prop now feeds the
component's date and both props coexist. The "updated" | "created" type
and its accessor join Asset's other shared helpers in v2/utils/assets,
where AssetPreview takes them too, since the old local name collided
with the AssetTimestamp component.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 19:12:34 -04:00
Georges-Antoine Assi
d3cda9b003 Merge pull request #4534 from rommapp/claude/fix-4398-inconclusive-scan
fix(scan): don't report an unanswered lookup as a confirmed miss
2026-09-16 19:05:45 -04:00
Georges-Antoine Assi
d6eba3297a fix(scan): treat every silent provider as inconclusive
ScreenScraper catches its own rate limit and breaker, so the miss they
cause never reaches resolve_fetch and was still written up as confirmed.
Hasheous had the opposite gap: an unanswered hash lookup still counted as
attempted, so a complete rescan cleared the id the lookup could not redo,
and a disabled handler reports the same flag as an outage without ever
having been consulted.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 18:38:47 -04:00
nendo
3ca79a1205 fix(scan): reread title ids on every rescan and break sort ties by exact name 2026-09-17 07:36:21 +09:00
Georges-Antoine Assi
951ea75075 Merge pull request #4533 from LoneAngelFayt/streaming-patches-2
fix(streaming): pool same-origin webstation containers and keep a claim on its own container
2026-09-16 18:18:44 -04:00
nendo
2e6acaac3c Merge remote-tracking branch 'upstream/master' into fix/sigil-cnf-serial-shapes
# Conflicts:
#	backend/tests/utils/test_m3u.py
2026-09-17 07:09:35 +09:00
nendo
d43e4e731f chore(scan): review-polish the title id ordering comment 2026-09-17 07:01:35 +09:00
nendo
f40bd69d9d refactor(scan): resolve playlists in the sigil service and keep one stop rule 2026-09-17 07:00:49 +09:00
nendo
35f799086d fix(scan): apply code-review findings to title id source ordering 2026-09-17 06:57:17 +09:00
Georges-Antoine Assi
bf6f9db02a fix(streaming): serialize one player's claims on a platform
The ownership check and the reservation that follows it are separate Redis
round trips, so two concurrent claims from one player could each read no
session of their own and then win a different member of the pool, leaving
the second one unreachable. A per-player, per-platform gate held across the
pair makes the loser read the winner's session instead of a free container.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 17:38:47 -04:00
nendo
c6170db6bc fix(scan): identify multi-disc and playlist roms by their first disc 2026-09-17 06:14:08 +09:00
Zurdi
1444b0454a Merge pull request #4550 from rommapp/claude/unify-rom-file-uploads
chore(uploads): manual file uploads into a ROM across the Files and Media tabs
2026-09-16 17:18:37 +02:00
zurdi
1f631e7962 Bound the refresh lock wait instead of spinning on sleep
ruff ASYNC110 flags a while loop whose body is only an await sleep. The
wait is now a bounded poll that gives up with a TimeoutError once the
lock expiry has elapsed, so a stuck holder cannot hang the upload.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-16 17:09:54 +02:00
zurdi
071787311d Take the refresh lock with SET NX instead of a Lua-backed Lock
redis-py releases its Lock through a Lua script, which the fakeredis CI
runs without, so every registration failed there with an unknown evalsha
command. The lock is now a SET NX EX with an owner token, released only
by its owner, the same shape the log forwarder already uses.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-16 17:03:59 +02:00
zurdi
e869ecb6b6 Enforce media allowlists and walkthrough provenance in the shared upload path
A folder the scanner maps to a media category now refuses files that
category cannot hold inside resolve_upload_destination, so the chunked
flow the v2 tabs use gets the same allowlist the media routes had, and
those routes drop their own copies. commit_upload records an upload
provenance for walkthrough files that arrive without one and returns the
registered row, which the walkthrough route uses for author and title.
The refresh lock moves to Redis so uploads landing on different gunicorn
workers cannot drop each other rows. An empty body filename is rejected
instead of falling back to the header.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-16 16:27:38 +02:00
zurdi
e8d2e26cff fix(tasks): a worker that announced its death is not live
`has_live_worker` reads each registered worker again and skips the
ones carrying a death date as well as the suspended ones, with both
states covered in the handler test.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F9ta8rXUTP9aMdatPYKX4K
2026-09-16 16:25:13 +02:00
zurdi
be81b1c89b refactor(tasks): apply the simplify pass
`has_live_worker` asks RQ for the worker count and the suspension flag,
two constant-cost reads, instead of hydrating every registered worker.
The cleanup stats serialize through `dataclasses.asdict`, so a new
counter is declared in two places rather than three. The task endpoint
test takes the shared task fixture, the legacy-stats shim says when it
can go, and the two Settings specs share one axios-error helper under
`src/test-utils` while the games spec starts from a non-empty list.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F9ta8rXUTP9aMdatPYKX4K
2026-09-16 16:16:00 +02:00
zurdi
83569d6678 fix(tasks): read older cleanup stats, and check the worker where it enqueues
Follow-up to #4548 from the code-review pass. Stats a 5.2.0 release
stored under `platform_id` are widened to `platform_ids` when a job is
reported, so listing old finished cleanups validates again. The live
worker check moves next to the queues as `has_live_worker`, with its
own tests, and the endpoint names the queue it enqueues on so the check
and the enqueue cannot drift apart. The cleanup tasks return the typed
stats the response schemas declare. The developer setup points the RQ
commands at the backend's own Redis settings through `-c config`, and
the architecture doc mentions the 503.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F9ta8rXUTP9aMdatPYKX4K
2026-09-16 15:57:59 +02:00
zurdi
f9f68dc0f1 Unify manual file uploads into a ROM across the Files and Media tabs
The Files tab streamed chunks through /roms/upload/* and registered the
result with the scanner listing, while each Media route (soundtracks,
screenshots, manual files, walkthrough files) carried its own copy of the
sanitize, promote, mkdir, stream, stat and DB upsert sequence. Those copies
crashed with FileNotFoundError on a file name outside Latin-1: the browser
sends the header as Latin-1 and the multipart field name as UTF-8, so the
parser target registered under the header name never received the part
and os.stat failed after the folder had been created.

handler/rom_upload.py now owns the shared ingestion (resolve and prepare
the destination, stage next to the target, move into place, refresh the
ROM's file rows through the scanner) and both the chunked completion and a
new receive_rom_file sit on it. The media routes only check the extension
and delegate; a body naming the part differently is a 400. /start gains an
optional body filename that wins over the header, so names outside Latin-1
arrive intact, and rom_id becomes optional in that body.

On the v2 frontend a single useRomFileUpload composable wraps the chunked
upload, the single-file conversion prompt, the toasts and the refetch; the
Files tab, Soundtrack panel, Screenshots subtab, Walkthrough subtab and the
manual "add to ROM folder" target all call it with their folder. The
service sends the real name in the body and a percent-encoded one in the
header. The v2-only uploadScreenshots/uploadWalkthroughFiles service
functions and the soundtrack-only toasts are gone. Media subtabs now
refuse an existing file name (409) like the Files tab, instead of
overwriting it silently.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X1FgnCzXjM3rzkxggi7g6C
2026-09-16 15:29:22 +02:00
zurdi
7deb7f8693 refactor(states): share the asset removal helpers with saves
The save and state delete endpoints carried the same row, file and
screenshot removal sequence inline. `remove_asset_file` and
`remove_screenshot` now live in the asset store, and each endpoint
keeps a one-line `_delete_save` / `_delete_state` over them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-16 10:04:51 +02:00
Zach Clendenen
4e327fd72e simplify(pr-ready step 3): cut the clears_stale_saves comments to the why
Each of them had grown a paragraph explaining where the broker flag lives
and when to reach for it, which the config example already covers.
2026-09-15 23:33:39 -05:00
Zach Clendenen
9cef7f2f29 review(pr-ready step 2): pool on the picker capability, not the raw flag
Two legacy broker containers serving the same emulator stopped pooling when
one carried a clears_stale_saves the resolver had just logged as having no
effect. Comparing supports_save_picker folds in the webstation gate, so it
is the same test for a webstation pair and inert for the rest.
2026-09-15 23:31:52 -05:00
Zach Clendenen
5e217c7f64 feat(streaming): let an operator declare whether their broker clears saves
The save picker was gated on a hardcoded set of emulators mirroring the
webstation broker's `clears_stale_saves`, a value that lives in another
repo. A broker release that turns it on for a new emulator needed a RomM
code change before the picker appeared, and an operator on a fork or a
newer broker could not turn it on at all. The other direction was worse
because it was silent: if the broker stopped clearing, the pick still
validated, the archive still uploaded, and the container's own newer
files overwrote it with no error anywhere.

`clears_stale_saves` now joins `memory_card_sync` in
PLATFORM_OVERRIDE_KEYS, resolved per container in `_resolve_one`, which
leaves the emulator table as the default rather than the authority. It
also joins the pool-interchangeability check, since the picker is
advertised from the head of the pool and a member that keeps its own
files would take the pick and discard it.
2026-09-15 23:22:27 -05:00
zurdi
76b80e0e1a refactor(player): apply the simplify pass
Slot pruning is one locked handler query that selects only the tail of
the slot by column, so an upload no longer loads every joined version;
the retention tests share their seeding helpers. Both asset lists fold
their groups through one useGroupFold composable, render the owner chip
through one AssetOwnerChip, and AssetStrip tracks each group's newest
timestamp while it builds the group. The two upload dialogs share a
PendingFilesDropzone for the drop zone and file list. The slot title
and the newest-by-timestamp lookup live in the utils next to their
siblings. The split states layout aligns its label and content rows
with a subgrid instead of hand-matched heights, so AssetPreview loses
the consumer-driven eyebrow height. Stories take explicit ids.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-16 05:21:45 +02:00
zurdi
b536aced56 fix(player): apply the code-review findings
Correctness: the upload dialog seeds dropped files immediately (three of
its tests ran vacuously), dedupes them by name, submits on Enter and
rejects a blank slot name; slotted manual uploads are new versions even
when the bytes match; the core picker sees the nightly cores the player
offers; clearing a state hands the boot back to the save it displaced;
a slot or core group can be folded even while it holds the selection
and reopens when the selection moves into it; the entrance stagger
counts only rendered rows; the stream save picker keeps its flat list;
slot retention orders by id as a tiebreaker for same-second uploads.

Reuse: asset helpers shared by both lists move to v2/utils/assets.ts,
the write slot follows the picked save in one place, the upload payload
carries its type, and the endpoint's delete sequence is one helper.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-16 05:05:29 +02:00
Georges-Antoine Assi
d800d60c32 fix(scan): don't report an unanswered lookup as a confirmed miss
lookup_rom already tells a real "nothing knows these hashes" apart from a
provider that never answered, and only the HASHES de-verify guard read it.
A 429, a 500 or a timeout therefore logged the ROM as not identified in
the same words as a genuine coverage gap, and the reporter spent two days
treating transient failures as gaps. Track the sources that gave no answer
and say so in the outcome.

Retrying in-scan, or persisting a revisit marker, would change what the
nightly QUICK scan covers, so it is deliberately not part of this.

Refs #4398

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 19:44:36 -04:00
Zach Clendenen
14f847dc57 Merge remote-tracking branch 'upstream/master' into pr-ready-851cea
# Conflicts:
#	frontend/src/v2/views/Player/Stream.vue
2026-09-15 17:29:00 -05:00
Zach Clendenen
f58a7ad7e0 polish(pr-ready step 4): trim the comments and name the resolve helper for its answer
Cut the docstrings and comments this branch added down to the one non-obvious
fact each, in the resolver and in the tests alike, and rename the new helper to
_claimable_broker_host so it says what it returns next to _derive_broker_host.
2026-09-15 17:09:59 -05:00
Zach Clendenen
1b3caebabf simplify(pr-ready step 3): flatten the container resolve and compare protocols by name
Move the three ways a raw entry fails to resolve into one helper with a guard
clause each, so none of them has to unset a broker host a sibling branch set.

The subfolder match moves onto WebstationProtocol, next to the normalization it
has to agree with, and interchangeable_with compares protocol names, the
discriminator the record already uses elsewhere.
2026-09-15 17:05:08 -05:00
Zach Clendenen
9a4b644c01 review(pr-ready step 2): let a player reclaim their own stale container
The holder gate added with the pool ran before the stale-takeover walk, so a
player whose tab crashed was refused their own container until its TTL lapsed.
Block only on a live holder, and when the holder's own session is stale narrow
the candidates to that container so the existing takeover path reclaims it.

Also widen the proxy path check to compare the host's URL path, so a container
on another origin mounted at a path that disagrees with its subfolder is
refused the same way a bare path already was.
2026-09-15 16:57:37 -05:00
Georges-Antoine Assi
fa8001c075 fix(scan): send Playmatch as a metadata source so the UI switch works
The Playmatch switch shipped its choice as a standalone `playmatch_enabled`
flag, but the backend gates the lookup on `MetadataSource.PLAYMATCH in apis`
and nothing ever read the flag, so UI-initiated scans never queried
Playmatch. Push `playmatch` into `apis` like `hasheous`, and drop the dead
flag from the payload and the scan plumbing.

Fixes #4505

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-15 17:23:21 -04:00
Zach Clendenen
df6ded2786 fix(streaming): refuse a proxied container whose host and subfolder disagree
A same-origin entry sends the browser to `host`, but activate answers with
the room URL the broker built from its own SUBFOLDER, and that is an
absolute path, so urljoin lets it replace the path `host` carries. The two
values are therefore not independent: both have to be the container's own
SUBFOLDER.

Get them wrong and nothing complains. A container mounted at /streaming-2
while declaring /streaming resolves, claims its own key, and hands the
player a URL the proxy routes to whoever owns /streaming: a different
container, mid-session, with no trace of it in either log. The likeliest
way in is a second pool member proxied at its own path with `subfolder`
left to its default.

Resolve the entry, log it, and clear broker_host so it cannot be claimed,
matching how the other unusable configurations are handled. It stays in
the fleet view, where the operator can see what is wrong with it. A full
URL `host` is untouched; it carries an origin of its own for that absolute
path to land on, so there the two are free to differ.
2026-09-15 13:30:34 -05:00
Zach Clendenen
50027b64ed fix(streaming): pool same-origin webstation containers across subfolders
interchangeable_with() compared protocol by instance identity, and
WebstationProtocol is interned per exact subfolder — so two containers
proxied at different subfolders, the normal way to run a same-origin
pool, were never recognized as pool members. Compare by type instead;
capabilities are class-level constants, so type equality is what
"same shape" actually means.
2026-09-15 12:49:08 -05:00