Commit Graph

12963 Commits

Author SHA1 Message Date
Sam Dornan
86fa809612 fix(auth): rename seeded permission groups to Viewer and Editor
Every install showed "Viewer (legacy)" and "Editor (legacy)" as the built-in
groups, which reads as deprecated. 0092 already shipped in 5.3.0, so a new
revision renames the untouched system rows and drops the "pre-upgrade"
framing from their descriptions. It skips a group whose target name an admin
already took, and keeps a description the admin edited.

Fixes #4678

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xdb9FnfhEqP6ectkSZ2T3F
2026-09-25 00:36:34 +00:00
Georges-Antoine Assi
a63d67f539 Merge pull request #4746 from andest01/fix/oidc-stale-state-redirect
fix(auth): redirect instead of 500 when the OIDC callback is rejected
2026-09-24 19:52:21 -04:00
Georges-Antoine Assi
f41f412fbb test(auth): type the OIDC callback test client (address Greptile review)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 18:38:35 -04:00
Georges-Antoine Assi
3a63f5c5c3 refactor(auth): tighten OIDC callback docstring and reuse cookie constant (pr-ready: simplify)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 17:45:14 -04:00
Georges-Antoine Assi
b658f2fe23 fix(auth): harden the OIDC callback rejection path (pr-ready: code-review)
- Catch AuthlibBaseError so rejected id_tokens (JoseError) redirect too
- Redirect to /login?bypass_autologin=true to avoid an autologin loop,
  and honor the flag on the v2 login page like v1 does
- Treat the kiosk guest as signed out on failure
- Log the provider-supplied error fields with repr()
- Cover provider errors, id_token errors, kiosk mode, and session survival

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 17:43:19 -04:00
Georges-Antoine Assi
8e5c913824 Merge pull request #4747 from rommapp/claude/vitest-version-check-xyo7ek
Upgrade vitest and @vitest/ui to v5
2026-09-24 17:17:07 -04:00
Georges-Antoine Assi
8ebdb18c8a Merge pull request #4729 from rommapp/claude/uvicorn-upgrade-decision-i7a2ok
build(deps): bump uvicorn to 0.53 and uvicorn-worker to 0.4
2026-09-24 17:08:36 -04:00
Georges-Antoine Assi
aba5a2e1e8 Merge pull request #4762 from rommapp/fix/rom-screenshot-cache-bust
fix(v2): version ROM file URLs with the file's own timestamp
2026-09-24 17:07:19 -04:00
Georges-Antoine Assi
3706905ea0 Merge remote-tracking branch 'origin/master' into fix/rom-screenshot-cache-bust 2026-09-24 17:00:32 -04:00
Georges-Antoine Assi
15e9db0e70 fix(v2): key the manual and walkthrough PDF viewers on their URL
Addresses Greptile's review on #4762: the PDF viewers were keyed on the
ROM's updated_at, so a file-only rescan changed the URL without
remounting vue3-pdf-app.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 17:00:23 -04:00
Georges-Antoine Assi
551497f34d Merge pull request #4761 from rommapp/perf/retroarch-sync-manifest
perf(sync): batch RetroArch manifest hashing and list PROPFIND paths unhashed
2026-09-24 16:58:18 -04:00
Georges-Antoine Assi
2679603e52 fix(sync): drop the removed remove_screenshot helper from RetroArch DELETE
#4749 replaced asset_store.remove_screenshot with release_thumbnail while
#3904 was in flight, so master fails to import the RetroArch sync router.
release_thumbnail keeps a screenshot its state still shows, but a
RetroArch DELETE of `<state>.png` asks for that exact file, so delete the
row and file directly, like the save and state branches.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 16:50:28 -04:00
Georges-Antoine Assi
76c1433355 fix(v2): version ROM file URLs with the file's own timestamp
Screenshots, library artwork, manuals and walkthroughs from the game folder
were cache-busted with rom.updated_at. A rescan that replaces one of those
files keeps its RomFile row and bumps only that row's updated_at, so the
browser kept serving the old bytes. Build the URL from the file's own
updated_at via a shared versionedRomFileUrl helper, and move romFileUrl
out of soundtrackTracks into the same module.

Found while reviewing #4512.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 16:48:33 -04:00
Georges-Antoine Assi
68a3e6b262 Merge remote-tracking branch 'origin/master' into perf/retroarch-sync-manifest 2026-09-24 16:47:05 -04:00
Zurdi
404518c5e0 Merge pull request #4749 from rommapp/claude/issue-2653-7225d5
feat: rename saves and states, and one public/private look across v2
2026-09-24 22:37:54 +02:00
Georges-Antoine Assi
bb9aa28ea6 chore(sync): review-polish pass on the RetroArch manifest perf work
Rename cached_md5s to cached_hashes, since it also caches PSP member
hash maps, and keep its docstring to one line.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 16:35:59 -04:00
Georges-Antoine Assi
0c7633f4bb refactor(sync): apply simplify pass to the RetroArch manifest perf work
- Key PSP member hashes on the bundle's content hash, computed once in a
  thread, cached via the shared batch helper, and guarded only on write
- Build only the requested tree for a PROPFIND listing
- Walk blobs with iter_files, share the bundle limit check and reader
- Drop the derivable ManifestAsset.parent_path and the closure factories

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 16:34:41 -04:00
Georges-Antoine Assi
a6deb1c1d1 Merge pull request #3904 from rommapp/feat/retroarch-cloud-sync
feat(cloud-sync): serve RetroArch Cloud Sync over WebDAV
2026-09-24 16:25:46 -04:00
Georges-Antoine Assi
3d182c2d5c Merge remote-tracking branch 'origin/feat/retroarch-cloud-sync' into perf/retroarch-sync-manifest 2026-09-24 16:23:12 -04:00
Georges-Antoine Assi
258d7a8892 Merge remote-tracking branch 'origin/master' into feat/retroarch-cloud-sync 2026-09-24 16:17:32 -04:00
Georges-Antoine Assi
e3001f7e2e fix(sync): don't fail a PSP upload when caching its member hashes fails
The bundle is already written by then, and a missed cache entry is
recomputed on the next manifest.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 16:13:59 -04:00
Georges-Antoine Assi
94335b941c perf(sync): batch RetroArch manifest hashing and list PROPFIND paths unhashed
- Read every asset and blob hash from one MGET, compute misses with
  bounded concurrency and write them back in one pipeline.
- Split the manifest into a path builder and a hashing layer; PROPFIND
  of saves/ and states/ now lists paths without hashing assets, walking
  blobs or inflating PSP bundles (member names come from the zip
  central directory).
- Walk blob directories once off the event loop with os.scandir, reusing
  each entry's size and mtime for the hash cache key.
- Build PSP bundles off the event loop and prime the member-hash cache
  on write so the next manifest skips inflating them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 16:11:04 -04:00
Georges-Antoine Assi
5bf63796c0 feat(sync): keep the game library browsable for the kiosk guest
The kiosk guest may PROPFIND the root and browse or download under
roms/, as it can in the web UI. The manifest, saves, states, blobs and
OPTIONS still challenge it, so RetroArch sends credentials.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 16:09:18 -04:00
Georges-Antoine Assi
603e3b0c93 fix(sync): keep state screenshots separate per core
RetroArch names a slot's state the same under every core, and its
screenshot was filed per ROM, so two cores' `<rom>.state.png` shared
one file and one row. File them under a per-core screenshots folder,
upsert by path, and only match a state to a screenshot in its own core's
folder or the ROM-level one.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 16:02:00 -04:00
Sam Dornan
abd061f59a perf(backend): read the gallery sorts out of an index (#4647)
* perf(backend): read the nullable gallery sorts out of an index

Sorting the gallery by release date, rating or HowLongToBeat time placed
unset roms last with `ORDER BY <column> IS NULL, <column>`. The leading
term is an expression, so MariaDB and MySQL could not read the order out
of `idx_roms_<column>` and filesorted instead. PostgreSQL had the mirror
problem descending: `DESC NULLS LAST` does not match the index's own
order, so it fell back to a sequential scan.

Neither engine paid this once. v2 window fetches send no sidecars, so
each scroll window is its own `ORDER BY ... LIMIT 72 OFFSET n` over the
full filtered set, and `roms` carries a JSON metadata blob per provider
on every row.

Each column now carries a STORED `_unset` flag with an
`idx_roms_<column>_sort` pair the ascending sort leads with, and
PostgreSQL gets an `idx_roms_<column>_desc` for the descending one. Row
order is unchanged in both directions.

Measured on PostgreSQL 16 over 120k roms, first page:

  ascending    30.6 ms / 8109 buffers -> 0.074 ms / 13 buffers
  descending   33.5 ms / 8091 buffers -> 0.112 ms / 14 buffers

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NouZquWDxNBqxYyu2E2GF8

* fix(backend): rebuild a sort index MariaDB narrowed instead of dropped

Testing the previous commit against MariaDB rather than PostgreSQL alone
turned up a real bug in it.

The two engines leave a dropped generated column in different states:
PostgreSQL drops every index that reads it, while MariaDB and MySQL keep
a composite one over the columns that survive. `_restore_generated_indexes`
only created indexes missing by name, so on MariaDB the rebuild path in
`ensure_roms_columns` (a chain predating 0123) would leave
`idx_roms_<column>_sort` narrowed to the unset flag alone and the
ascending gallery sort walking half an index.

It now reconciles on the columns an index spans, not just its name, and
`_drop_index_sql` gives the two dialects their own DROP INDEX spelling.

Also corrects the flag columns' comments: MariaDB accepts no NOT NULL on
a generated column in either position, so they are nullable in the DDL on
both engines. `IS NULL` never evaluates to NULL, so no row carries one.

Verified on MariaDB 10.11 over 120k roms. The ascending page went from
`rows=116503, Using index; Using filesort` to `rows=72, Using index`,
134 ms to 6 ms, with the same plan once the rom_user join is added.
Migration, schema and flag values also checked under utf8mb3_unicode_ci,
the collation these expressions are most fragile under.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NouZquWDxNBqxYyu2E2GF8

* style(backend): give the sort-flag rationale one home

Greptile flagged the comment blocks in this PR against CLAUDE.md's
comment discipline. The length was a symptom: the same explanation of
why MariaDB cannot index the NULLS LAST emulation appeared in four
places. It now lives once, beside `SORTABLE_NULLABLE_ROM_COLUMNS`, and
the other sites say only what is local to them.

No behaviour change; the migration docstrings are left as they are,
matching the narrative style every recent revision uses.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NouZquWDxNBqxYyu2E2GF8

* fix(backend): drop the sort indexes with the rest of the catalog

Copilot pointed out that `ensure_roms_columns` installs the `_unset`
columns long before 0129 runs, so a chain that stops short and then
downgrades leaves them behind. Checking that turned up a real leak next
to it: 0108's downgrade, which the module documents as removing whatever
of the catalog such a chain still carries, was leaving two indexes.

A descending sort index reads a value column this module inherited
rather than added, so `drop_roms_columns` re-adds that column and the
index over it survives. `_drop_sort_indexes` now takes them explicitly.
PostgreSQL only, since no other engine has those indexes.

The flag columns themselves are not a leak: the catalog front-loads every
column it owns, so at 0127 the table already carries 0123's
`generated_keywords`, `generated_themes` and `generated_rating_count`
too. Verified on both engines that a 0128 to 0127 downgrade leaves the
table writable with the flags still computing, and that re-upgrading
restores the pair, narrowed index included.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NouZquWDxNBqxYyu2E2GF8

* style(backend): tighten the teardown docstrings and the test annotation

Two more from Greptile, both worth taking even though the reasoning
behind each was off.

`_drop_sort_indexes` and its test now carry a summary plus one line,
matching `drop_roms_columns` right above them, and the parametrized
metadata argument is typed instead of a bare `dict`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NouZquWDxNBqxYyu2E2GF8

* perf(backend): index the remaining gallery sorts (#4644)

* perf(backend): span the gallery sort indexes through the id tiebreak

The gallery appends `id` to every ORDER BY, but `idx_roms_<column>_sort`
stopped at the value and `idx_roms_<column>_desc` at the value alone. On
PostgreSQL that leaves every tie to be sorted, and unset metadata is a single
tie covering the whole bucket: a scroll window inside it fell back to a Seq
Scan and an external merge sort. Both indexes now carry `id` in the sort's own
direction, which InnoDB was already appending for MariaDB and MySQL.

Measured on 120k roms, a window at offset 100000 (inside the unset bucket),
all three columns, both directions:

  PostgreSQL ascending   119 ms, external merge sort  ->  15 ms, index only
  PostgreSQL descending   92 ms, incremental sort     ->  13 ms, index only
  MariaDB, both          already index-only; unchanged

No sort node remains in any of the twelve plans. Also trims the docstrings and
comments this change touches to the repo's one-or-two-line rule.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NouZquWDxNBqxYyu2E2GF8

* test(backend): pin the reflected order of the descending sort indexes

The existing assertion read column names only, which a default ascending index
satisfies just as well, and `AUTOGENERATE_EXEMPT_INDEX_NAMES` keeps the drift
check away from these. Asserts the reflected `column_sorting` instead, and its
absence on the ascending pair.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NouZquWDxNBqxYyu2E2GF8

* fix(backend): declare the unset flags nullable, as their DDL is

`Mapped[bool]` inferred NOT NULL while both engines create the column nullable,
MariaDB because it takes no NOT NULL on a generated column. The four generated
columns beside them already match their DDL. The annotation stays `bool`, since
`IS NULL` never yields NULL.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NouZquWDxNBqxYyu2E2GF8

* fix(backend): renumber the gallery sort revisions after 0132

master gained its own 0129-0132 while this branch was open, and both
chains started from 0128_hltb_main_story_column, leaving alembic with
two heads (`upgrade head` fails with MultipleHeads).

0129_indexed_gallery_sorts -> 0133, now revising 0132_audit_events;
0130_gallery_sort_indexes -> 0134. No content change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VgcWNtJy6ucWRaibqNKNJC

* fix(backend): re-chain the renamed gallery sort revisions onto 0132

The previous commit renamed the files but left their revision IDs and
parent as they were. 0133 now revises 0132_audit_events, and both IDs
match their filenames.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VgcWNtJy6ucWRaibqNKNJC

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-24 14:56:43 -05:00
zurdi
0f284c8b6a review: address Greptile's seventh pass on #4749
is_bound now resolves each name-matching save or state through the same
thumbnail lookup they use, instead of stopping at the name match. A name can
match several screenshots while the asset shows only the one its lookup
prefers, so a thumbnail nothing displays was kept after a delete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 21:56:35 +02:00
Georges-Antoine Assi
6691489773 chore(sync): review-polish pass
- Rewrite the RetroArch Cloud Sync architecture section: add the PSP,
  kiosk, size cap and missing-file behavior, drop the stale hash note
- Document SYNC_RETROARCH_PSP_SERIAL_MAP in env.template and the env table
- Trim two docstrings and reuse CLIENT_DEVICE_IDENTIFIER for the device type

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 15:53:22 -04:00
Georges-Antoine Assi
7e7e5a671d refactor(sync): apply simplify pass
- Enforce the upload size cap on streamed bytes in the middleware, so
  chunked uploads to every guarded route are bounded, not just RetroArch
- Flag vanished assets missing_from_fs from the manifest instead of
  re-hashing them every sync
- Batch state screenshot lookups, filter PSP bundles in SQL, hash files
  in one thread hop, and read only the requested PSP bundle members
- Reuse remove_screenshot and content_hash_of_bytes, merge the save and
  state PUT branches, drop dead checks and trim docstrings and tests

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 15:50:49 -04:00
Georges-Antoine Assi
918afcf1df fix(sync): apply code-review xhigh findings
- Stream RetroArch PUT bodies with a byte cap, so a chunked upload
  can't bypass the Content-Length check and exhaust memory
- Map shared core folders back to the mednafen_* ids the web player uses
- Enforce PSP bundle limits on write, return 409 for invalid bundles,
  and never delete an unreadable bundle when removing one member
- Challenge the kiosk guest so RetroArch sends credentials
- Move a slot-matched state's row with its bytes, scan saves under the
  name actually written
- Reject NUL path segments and core folder names over the emulator
  column length
- Cache PSP bundle member hashes in the manifest

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 15:34:05 -04:00
Sam Dornan
d084723bfb fix(hltb): accept token-only sessions and discover the endpoint when GitHub fails (#4758)
* fix(hltb): accept token-only sessions from /init

HowLongToBeat's /api/search/site/init now returns only a token and the
site's own search sends just x-auth-token. parse_session still required
hpKey and hpVal, so every mint read as "no session" and all HLTB lookups
(and the endpoint discovery workflow) silently returned nothing. The
honeypot pair is now optional and only sent when HLTB issues it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DHm9rRfJsxunF1RckjQqzx

* review: share the honeypot check and narrow optional mock calls

Move the both-fields honeypot check into HLTBSession.honeypot() so the
headers and body cannot drift apart, drop the historical note from its
comment, and assert mock call args are not None before reading kwargs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DHm9rRfJsxunF1RckjQqzx

* feat(hltb): discover the search endpoint from HLTB when GitHub fails

If the endpoint fixture can't be fetched from GitHub, run the same
build-manifest discovery the weekly workflow uses against HLTB itself,
and fall back to the fixture bundled in the image rather than the stale
hard-coded /api/find. The discovery helpers now log instead of printing
so their output joins RomM's logs. Search requests also send an Origin
header, as the browser does for HLTB's same-origin POST.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DHm9rRfJsxunF1RckjQqzx

* fix(hltb): keep a malformed discovery response from aborting scans

parse_session and the discovery validator called .get() on whatever JSON
HLTB returned, so a non-object body raised AttributeError out of
initialize() and aborted the scan. Both now reject non-object JSON, and
the handler logs any discovery failure and keeps the bundled endpoint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DHm9rRfJsxunF1RckjQqzx

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 14:20:47 -05:00
zurdi
7132bfed5e Keep a save's or state's thumbnail while something still shows it
Deleting a save or state removed its thumbnail row and file unconditionally,
so a save and a state sharing a stem lost the shared preview when either one
went. Every delete path (single and bulk deletes, slot pruning, streaming
history pruning) now goes through release_thumbnail, which keeps:

- a thumbnail another save or state still matches by name, checked in SQL the
  way their thumbnail lookup matches, so it follows the database collation;
- a gallery screenshot that only shares the stem by chance;
- the file, when dropping the row, if another row spells the same file in a
  different case on a case-insensitive filesystem.

Renaming reuses the same is_bound check to decide whether a thumbnail is
shared, replacing the casefold helper.

Addresses Greptile's review on #4749.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 21:16:22 +02:00
Sam Dornan
2badf9e11d fix(hltb): match search results by their aliases too (#4760)
HLTB search results carry `game_alias`, a comma-separated list of
alternate titles (often the Japanese or regional name), but only
`game_name` was scored. "Rockman X (Japan)" matched "Rockman EXE WS"
instead of "Mega Man X" (alias "Rockman X"), and "Seiken Densetsu 3
(Japan)" matched nothing although "Trials of Mana" carries that alias.

Each result is now scored against its name and every alias, keeping the
best score per game, as howlongtobeatpy does. The match still returns
the game's real name and id. Real names are listed before aliases so an
alias repeating another result's name cannot take its match.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 14:09:14 -05:00
Sam Dornan
b2833e5e66 fix(v2): handle copy to clipboard over plain HTTP in logs and files tab (#4757)
* fix(v2): copy logs through useClipboard

The log viewer called navigator.clipboard directly. Over plain HTTP (the
common self-hosted setup) that API is undefined, so every copy threw and
showed a generic "Failed to copy logs". Route both copy actions through
useClipboard, which applies the secure-context guard and shows the shared
error that explains HTTPS is required. Drop the now-unused logs.copy-error
key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ThJorfHgTUwsZ9yXHqx17J

* fix(v2): fall back to the link dialog when FilesTab can't copy

FilesTab's copy-link buttons called navigator.clipboard directly, so over
plain HTTP every copy threw and showed "download link copy failed". Check
for a usable Clipboard API first and, when it's missing or the write is
rejected, open CopyDownloadLinkDialog so the link can be copied by hand,
matching useGameActions. Drop the now-unused rom.download-link-copy-failed
key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ThJorfHgTUwsZ9yXHqx17J

* fix(v2): address review feedback on clipboard fallbacks

- useClipboard shows a neutral "Couldn't copy to clipboard" when the write
  itself is rejected; the HTTPS hint stays for a missing Clipboard API.
- FilesTab drops the empty catch in favour of a boolean result.
- Cover the selection-toolbar copy link with multiple files selected.
- Trim test comments that restated the test names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ThJorfHgTUwsZ9yXHqx17J

* fix(v2): translate clipboard-write-failed and trim FilesTab comment

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ThJorfHgTUwsZ9yXHqx17J

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 14:09:01 -05:00
Sam Dornan
164c2e39d8 fix(hltb): retry a separated title with the separator dropped (#4759)
* fix(hltb): retry a separated title with the separator dropped

get_rom rewrites " - " as ": " before searching, but HowLongToBeat
returns nothing for "pokemon: emerald version" (or the dashed form),
while "pokemon emerald version" finds "Pokémon Emerald Version". The
tail-only retry ("emerald version") scores under the 0.85 gate, so the
ROM went unmatched.

_search_and_match now retries "<head> <tail>" before the looser
tail-only search. The split is still on the colon only, so in-word
hyphens ("spider-man 2") trigger no retries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* refactor(hltb): trim the search docstring and type the test fakes

Addresses review: the docstring is one sentence, and the search_games
fakes carry the parameter and return annotations the real method has.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 14:08:22 -05:00
zurdi
9de2e8f2f6 review: address Greptile's sixth pass on #4749
Trim the RSwitch label paragraph to the two-line comment limit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 21:06:23 +02:00
Georges-Antoine Assi
638a21f88b fix(sync): don't log missing files when hashing the RetroArch manifest
Every manifest read (GET and each PROPFIND) hashes every save and state
row, and failures aren't cached, so a DB row whose file is gone logged a
debug line on every sync. A missing file is expected there; other OSErrors
are still logged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 14:50:25 -04:00
Georges-Antoine Assi
49e8d380e9 refactor(sync): rename the RetroArch blob handler to retroarch_sync
FSRetroArchSyncBlobHandler becomes FSRetroArchSyncHandler, and
SYNC_RETROARCH_BLOB_BASE_PATH becomes SYNC_RETROARCH_BASE_PATH, stored
under /romm/retroarch_sync.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 14:20:06 -04:00
zurdi
e9294e0882 review: address Greptile's fifth pass on #4749
Decide whether a shared thumbnail needs a copy from the same screenshot
lookup the renamed asset will use, instead of from the filesystem. A
collation that ignores case (MariaDB) keeps resolving the shared row, so
nothing is copied; an exact one (PostgreSQL) gets its own row. When the
filesystem ignores case too, the new spelling already names the shared
file, so only the row is added and a failed rename leaves the file alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 20:18:30 +02:00
Georges-Antoine Assi
4c85d7f263 feat(sync): register RetroArch as a device on first sync
Each manifest.server fetch creates the user's RetroArch device if it is
missing, or bumps its last_seen, so RetroArch shows up alongside the
user's other devices. RetroArch's requests carry no install identity, so
it is one device per user, deduped on client_device_identifier.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 14:10:53 -04:00
Georges-Antoine Assi
7c7f27d701 refactor(sync): mount RetroArch Cloud Sync under /api/sync/retroarch
The manifest protocol is RetroArch's own, so name it after RetroArch
rather than its WebDAV transport, and group it with the existing sync
code: endpoints/sync/ becomes a package with the RetroArch router as a
subroute, and the handlers move under handler/sync/retroarch/. Settings
move into the SYNC config section as SYNC_RETROARCH_*.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 14:07:39 -04:00
zurdi
58b61d9073 review: address Greptile's fourth pass on #4749
- Keep a shared thumbnail in place when its new name resolves to the same
  file, so a case-only rename on a case-insensitive filesystem no longer
  fails with a conflict trying to copy the thumbnail onto itself.
- Build the user in the collection dialog tests with a typed userFixture
  instead of casting a partial object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 19:59:49 +02:00
Georges-Antoine Assi
66fb93eca1 refactor(webdav-cloud-sync): rename cloud_sync to webdav_cloud_sync
Group the handler modules under handler/webdav_cloud_sync/ (sync_handler,
psp, emulator_names, browser) and rename the endpoint, blob handler, tests,
config settings, storage folders and cache keys to match. The route moves
from /api/cloud-sync to /api/webdav-cloud-sync.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 13:54:23 -04:00
Georges-Antoine Assi
67884fba8f refactor(cloud-sync): rename PSP_SERIAL_MAP to CLOUD_SYNC_PSP_SERIAL_MAP
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 13:50:31 -04:00
Georges-Antoine Assi
a28943ba14 refactor(cloud-sync): move settings into their own config section
Buffer pending PSP save files under cache/cloud_sync instead of a
top-level cloud_sync_psp_pending folder.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 13:47:36 -04:00
Sam Dornan
2ffe41c516 test(backend): catch column nullability drift between models and migrations (#4756)
* test(backend): catch column nullability drift between models and migrations

Alembic's autogenerate ignores a nullability mismatch on a generated
column whenever the model leaves `nullable=` unset, which `Mapped[...]`
inference does. Such a mismatch surfaced in review on #4647 with no
check here able to see it.

Two guards close the gap:
- a reflection test comparing every mapped column's nullability (and
  existence) against the migrated schema, skipping views;
- a static test requiring every database-filled column to pass
  `nullable=` explicitly, so autogenerate compares it again.

The five existing `FetchedValue` columns on `roms` now declare
`nullable=True`, matching their DDL. No schema change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VgcWNtJy6ucWRaibqNKNJC

* test(backend): check server_onupdate in the database-filled nullability guard

Alembic skips the nullability comparison whenever the reflected column
is generated, so a column mapped with only `server_onupdate=FetchedValue()`
is just as invisible to autogenerate as one with `server_default`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VgcWNtJy6ucWRaibqNKNJC

* test(backend): trim the drift test docstrings to one sentence

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VgcWNtJy6ucWRaibqNKNJC

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 12:41:02 -05:00
Georges-Antoine Assi
0553dcae78 fix(cloud-sync): address Greptile and CodeQL review findings
- Resolve PSP folder paths from the same bundle set the manifest lists
  (visible ROM, unslotted, newest per folder), so GET/PUT/DELETE can no
  longer hit a slotted history bundle or a hidden ROM's bundle.
- Split validate_path's base-directory case out of its startswith guard,
  so CodeQL recognizes the guard as a py/path-injection sanitizer.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 13:34:26 -04:00
Zurdi
5b3db01a9d Merge pull request #4599 from andest01/feat/v2-platform-select-promote-filled
feat: promote platforms that have games in PlatformSelect
2026-09-24 19:14:30 +02:00
Georges-Antoine Assi
65c49444fc chore(cloud-sync): review-polish pass
Trim the remaining multi-line test docstrings and blob comment, and drop
the -- dash stand-ins.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 12:01:48 -04:00
Stuart Anderson
4b67942aa5 chore: fix tsc issue in unit test 2026-09-24 10:59:59 -05:00
Georges-Antoine Assi
d5d9196db3 refactor(cloud-sync): apply simplify pass
- Hoist the file MD5 onto FSHandler; drop the blob handler copy
- Share path splitting, slot recency, cached MD5 and ROM visibility helpers
- Remove dead code (get_state_by_path, RomFile.file_ids, unused params)
- Scope WebDAV rom listing to one query; look up a single platform by slug
- Query saves once per manifest and batch ROM name resolution
- Read only the requested PSP bundle member; hash bundles from memory
- Single separator-safe lexical check in validate_path; same joined-path
  validation in write_file_streamed
- Stop stripping + on ROM rename, the download path encodes it (#2746)
- Trim comments to the repo's comment rules

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-24 11:55:32 -04:00