Commit Graph

5631 Commits

Author SHA1 Message Date
Georges-Antoine Assi
fbff4347ac Merge pull request #4815 from rommapp/fix/local-time-asset-names
fix(saves): stamp save and state file names with local time
2026-09-26 17:22:51 -04:00
Sam Dornan
cbfc904a48 fix(ra): count RomM's own RA hash match as RetroAchievements verification (#4816)
* fix(ra): count RomM's own RA hash match as RetroAchievements verification

The RetroAchievements verification chip, the header Verified badge and the
library verified filter only read Hasheous' `ra_match` flag. RetroAchievements
hashes only part of some ROMs (NDS, PSP), so Hasheous never flags those from
their file hashes, and a ROM RomM matched to its RA game by RA hash still
showed a grey chip.

The RA handler now records `hash_match` in `ra_metadata` whenever the ROM's
RA hash is one RetroAchievements lists for the matched game, whichever route
found the game (hash lookup, Hasheous-supplied id, filename tag, update scan
or a manual edit). The frontend verification helper and the backend verified
filter count it alongside Hasheous' flag. Existing ROMs pick it up on their
next scan.

Fixes #4801

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

* style: satisfy trunk isort and no-emdash-in-comment

Sort imports with the repo's .isort.cfg and replace the comment em-dashes
in MetadataTab.vue that trunk flags once the file is modified.

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

* fix(ra): address code-review findings on the RA hash match

- A HASHES rescan whose RA lookup ran and found nothing clears
  `hash_match`, mirroring the Hasheous guard; a lookup that errored keeps it.
- A manual RA id change that can't be resolved no longer keeps the previous
  game's `hash_match`.
- `_search_rom` no longer caches a failed hash-list download ({}) as an
  empty index for the whole refresh window.
- Update the `verified` filter description and trim the romVerification
  header comment.

Step: pr-ready code-review (xhigh --fix)

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

* fix(ra): don't let a failed hash check block an RA ID lookup

`get_rom_by_id` now treats the hash-list check as secondary: on failure it
logs, keeps a match already recorded for the same game, and still returns
the game. A failed hash-list download raises "RetroAchievements
unavailable" instead of reading as "no match", so scans treat RA as
inconclusive and keep the stored flag.

Addresses the Copilot and Greptile review findings on ra_handler.py.

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

* refactor(ra): simplify the RA hash-match verification

- Cache the parsed RA hash index per platform, keyed by the cache file's
  mtime, so a scan parses it once instead of once per ROM.
- Check the hash only after `get_rom_by_id` has resolved the game.
- Give each frontend verification database its own `matches(rom)`, which
  drops the `ra_match` special case in the shared helper along with
  `matchesDatabase` and `VERIFICATION_KEYS`.

Step: pr-ready simplify

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

* style(v2): polish romVerification naming and comment

Rename the Hasheous matcher factory to `anyHasheousFlag` and trim the
VERIFICATION_DATABASES comment to two lines.

Step: pr-ready review-polish

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

* fix(ra): keep a recorded hash match only for the same RA hash

When the hash-list check fails, `get_rom_by_id` now keeps a stored
`hash_match` only if both the game and the ROM's RA hash are unchanged, so
a rehashed ROM isn't left verified by a hash nobody checked. The
romVerification tests build on the shared typed `SimpleRom` fixture
instead of casting a bare object.

Addresses the Greptile review findings on ra_handler.py and
romVerification.test.ts.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 15:33:55 -05:00
Georges-Antoine Assi
8c3874a5b0 Merge remote-tracking branch 'origin/master' into HEAD
# Conflicts:
#	backend/tests/endpoints/test_saves.py
2026-09-26 16:08:30 -04:00
Sam Dornan
5b3d0bf544 feat(sync): record a per-device save baseline to prove what did not change (#4768)
compare_save_state decides a side changed from its timestamp, and
emulators rewrite a save on exit, so an untouched save looks new and a
server change elsewhere turns into a false conflict.

device_save_sync now records what each side held at the last sync
(last_sync_hash from the device, last_sync_server_hash from the server,
migration 0140). A baseline match proves that side unchanged; a mismatch
or NULL falls back to the timestamp logic, so this only removes
conflicts. It runs after the removed_at check in compare_save_state.

- Baselines are recorded only for versions the device provably holds:
  confirm_download pins to the served version, update_save records the
  client hash only when the file was uploaded, deduplicated uploads and
  pushed saves record against the surviving save, and push-pull no-ops
  record hashes only for identical content.
- Identical-content no-ops in negotiate and the watcher record a
  boundary without re-tracking untracked saves.
- The SSH push-pull and file-transfer watcher paths hash device saves
  through hash_save_file, matching compute_content_hash for zipped
  saves, and treat unreadable saves as unknown.

Squashes rommapp/romm#4768 onto master.



Claude-Session: https://claude.ai/code/session_01WAKUdfLb6fyduEqaFbf5A8

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 15:05:57 -05:00
Georges-Antoine Assi
c19dca87e7 Merge pull request #4811 from rommapp/fix/wrap-grid-nav-scroll-up
fix(v2): keep the focused platform tile in view when moving up the grid
2026-09-26 16:00:40 -04:00
Georges-Antoine Assi
e877ec71ee fix(v2): clear the fixed bars when centring index tiles
Addresses Greptile review on #4811:
- IndexShell gives focus-keyed tiles a scroll-margin matching the top bar,
  pinned toolbar and bottom tab bar, so a centred tile taller than the
  uncovered band no longer lands under the chrome on short viewports.
- Cover the saved-focus restore path with a test.
- Drop the comparison with "nearest" from the scroll comment.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 15:55:42 -04:00
Georges-Antoine Assi
8f505f129e Merge pull request #4810 from rommapp/fix/upload-scan-while-scanning
fix(v2): skip the post-upload scan while a scan is already running
2026-09-26 15:41:51 -04:00
Georges-Antoine Assi
26c6c181d5 Merge pull request #4796 from LoneAngelFayt/streaming-patches-8
feat(streaming): name containers by their label, and harden import archives
2026-09-26 15:39:39 -04:00
Sam Dornan
3750d6ff70 chore(mypy): require full annotations outside tests, type the setup responses (#4795) 2026-09-26 15:31:00 -04:00
Georges-Antoine Assi
71776206a1 Merge pull request #4809 from rommapp/fix/crt-mode-mobile-images
fix(v2): drop the CRT overlay's backdrop grade on phones
2026-09-26 14:27:33 -04:00
Georges-Antoine Assi
4ec4247e20 fix(player): address Greptile review on gamepad replay
Shorten the replay comment to two lines, and make the replay test assert
the pad lands in a player slot through a listener shaped like EmulatorJS's,
not just that dispatchEvent was called.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 14:10:43 -04:00
Georges-Antoine Assi
b6c03e79eb fix(saves): stamp save and state file names with local time
State names were built with toISOString() in the browser, and save,
streaming save and memory card names with datetime.now(timezone.utc) on
the server, so every timestamp in an asset's file name was UTC. States
now use the browser's local time and server-named assets use the
server's local time (the container's TZ). Matching and ordering read the
stored file_name and the DB timestamps, so existing files are unaffected.

Fixes #4726

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 13:58:54 -04:00
Georges-Antoine Assi
bca922d608 fix(v2): skip the post-upload scan while a scan is already running
The upload view and the patcher's "upload to RomM" emitted a scan
unconditionally. With a library scan in flight the backend refuses it with
scan:done_ko, which flipped the UI out of the scanning state and showed a
failure until the running scan's next progress event flipped it back.
Both now go through useScanTrigger, which warns instead of emitting.

Fixes #4690

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 13:55:04 -04:00
Georges-Antoine Assi
11b34ae18c fix(v2): center the row the wrap-grid nav moves to
Moving up the platforms/collections grid scrolled with block "nearest",
which parks the row at the viewport top edge, under the fixed top bar and
pinned toolbar, so focus ended up hidden. Vertical moves and focus
restoration now center the target row, matching useGridNav.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 13:55:01 -04:00
Georges-Antoine Assi
e7ee22f51c fix(v2): drop the CRT overlay's backdrop grade on phones
On Chromium for Android, the full-viewport backdrop-filter on the CRT
overlay left platform and collection images unpainted until touched.
The xs breakpoint keeps scanlines, vignette and flicker but skips the
saturation/contrast grade. Also swaps the file's em-dashes for
punctuation so it passes the no-emdash lint.

Fixes #4770

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 13:54:12 -04:00
Georges-Antoine Assi
16005c9474 fix(player): assign a gamepad already connected when EmulatorJS boots
EmulatorJS's GamepadHandler polls navigator.getGamepads() once inside its
constructor, before the emulator registers its "connected" listener. A pad
the page already knows about (such as the one that pressed Play) lands in
the handler's list without ever being assigned to a player slot, so its
input is dropped until it disconnects and reconnects.

Replay the "connected" event for those pads from the EJS_emulator
assignment trap, right after the constructor returns.

Fixes #4797

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 13:53:52 -04:00
Georges-Antoine Assi
81ff4599a7 fix(v2): show media pin button only on hover, even when pinned
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 13:21:37 -04:00
Georges-Antoine Assi
9815723844 style(v2): drop em-dashes from pinned media comments
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 12:54:40 -04:00
Georges-Antoine Assi
c6ffa3ca57 Merge remote-tracking branch 'origin/master' into feat/pinned-media
# Conflicts:
#	backend/tests/test_migrations.py
2026-09-26 12:45:12 -04:00
Sam Dornan
d1ce4e3db2 fix(sync): make deleted-save tracking exact, complete, and effective on filled slots (#4789) 2026-09-26 12:33:54 -04:00
Georges-Antoine Assi
14e03181a6 fix: stop whole rom_user writes from reverting pinned media
The player last-played updates now send an empty payload, the v1 main
sibling toggle sends only its field, and the v1 personal tab leaves
pinned_media out of its debounced save.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 11:24:03 -04:00
Georges-Antoine Assi
9f80d800ef fix(v2): review-polish pass on pinned media
Put the unpinned pin on the overlay scrim so it reads over artwork, and
trim the header comments this PR touches to two lines.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 11:02:44 -04:00
Georges-Antoine Assi
d946af0539 refactor(auth): replace is_system with system_key
is_system was true exactly when system_key is set, so 0137 now drops it
after backfilling the key, and downgrade rebuilds it from the key. The
group API returns system_key instead, and the admin UI reads it for the
system tag and edit warning.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 10:58:21 -04:00
Georges-Antoine Assi
c79db61cb2 refactor(v2): simplify pinned media
Build each media source once per resolve, gate isPinned on scope inside
the composable, sync cached ROM copies on pin writes, require pinKey on
screenshot items, and share the order-preserving dedupe validator.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 10:52:32 -04:00
Georges-Antoine Assi
4f31df90f0 fix(v2): apply code-review fixes to pinned media
Cap the default selection at the pin limit, settle writes on the live
rom_user, gate pin controls on roms.user.write, dedupe keys server-side,
store resets as SQL NULL, and reuse MediaShelfItem for artwork entries.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 10:45:41 -04:00
Georges-Antoine Assi
a852d774c2 fix(v2): address Greptile review on pinned media
- Share one write queue per ROM across the Overview, Screenshots and
  Artwork tabs, so pins from different tabs reach the server in order.
- On a failed write, restore the last server-confirmed pins only when no
  newer write is queued, instead of a stale pre-toggle snapshot.
- Refuse a pin past PINNED_MEDIA_MAX_ITEMS client-side with a snackbar,
  rather than sending a list the API rejects with 422.
- Trim MediaShelf comments to the repo's comment rules.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 10:23:55 -04:00
Georges-Antoine Assi
7840dd3a29 Merge remote-tracking branch 'origin/master' into feat/pinned-media
# Conflicts:
#	backend/endpoints/roms/__init__.py
#	backend/tests/test_migrations.py
2026-09-26 10:18:34 -04:00
Georges-Antoine Assi
0fe3b356b6 Merge pull request #4731 from rommapp/claude/docker-dev-rolling-tag-dmqssl
ci: nightly image, index annotations and SBOMs
2026-09-26 10:14:20 -04:00
Georges-Antoine Assi
f7c57372da Merge pull request #4741 from yiannias/fix/amiga-puae-kickstart-firmware
fix(player): make all Amiga Kickstarts available to PUAE
2026-09-26 10:11:35 -04:00
Georges-Antoine Assi
93f1107db2 refactor(frontend): simplify firmware externalFiles helper
Simplify pass. Move firmwareExternalFiles into v2/utils/playerFirmware
next to resolveInitialFirmware so one module owns the player's firmware
logic and FirmwareLike stays private, replace the single-member core set
with a direct check, and fold the filename guards into one regex.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 09:59:49 -04:00
Georges-Antoine Assi
2484d8f30f fix(player): limit firmware externalFiles to PUAE and cover console mode
Code review follow-up. Drop the all-firmware fallback for other cores:
a cleared picker there means "no BIOS" on purpose, and the fallback
refetched every platform file uncached on each launch. PUAE again gets
every Kickstart, including the selected one, as originally tested.
Console mode's player now sets EJS_externalFiles too, so #4733 is fixed
there as well.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 09:56:19 -04:00
Georges-Antoine Assi
0d817a51e9 chore(frontend): apply code-review fixes to firmware helper
Reuse FirmwareLike instead of a duplicate type, correct the archive
comment for the nightly EmulatorJS build, and cover the dot-name filter
and URL encoding in tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 09:54:39 -04:00
Georges-Antoine Assi
ae7b1cb22b ci: build the rolling master image nightly and tag it nightly
A cron run replaces the per-push build, so the tag is renamed from
`edge` to `nightly` (and `nightly-slim`), using metadata-action's
`type=schedule`. The version string becomes `nightly-<short sha>`.
The concurrency guard is dropped since scheduled runs can't overlap.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 08:06:17 -04:00
Georges-Antoine Assi
401b732e3d fix(player): pass all firmware to EmulatorJS when none is selected
Generalize the PUAE helper to any core. Filename-selecting cores (PUAE)
still receive every firmware file in the system directory, minus the one
already loaded through EJS_biosUrl. Every other core now receives all
firmware next to the game when no file is selected, the case where
EJS_biosUrl previously loaded nothing. Archives are skipped because
EJS_externalFiles writes them unextracted; they keep loading through the
picker.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 08:05:38 -04:00
Georges-Antoine Assi
72a1cd0201 Merge pull request #4792 from rommapp/fix/platform-icon-manifest
fix(frontend): only request platform icons that ship
2026-09-25 22:05:07 -04:00
Georges-Antoine Assi
a35391f77d chore(frontend): trim platform icon comments (review-polish)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 21:47:39 -04:00
Georges-Antoine Assi
5269e942a6 refactor(frontend): simplify platform icon resolution
- Move the slug-to-URL resolver into src/v2/utils/platformIcons so
  PlatformIcon no longer pulls in the blob cache, and normalize slugs
  through one helper.
- Keep PlatformIcon's tooltip as title or alt, which drops the three
  :show-tooltip="false" overrides the slug fallback needed.
- Drop the plugin's unused directory argument, the redundant onError
  guards and the doubled fsSlug lookup, and shorten the test helper.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 21:45:59 -04:00
Georges-Antoine Assi
d5e73dae5b fix(frontend): address code-review findings on platform icons
- Emit the slug-to-file map from the manifest plugin and reload it when
  icons change under the dev server.
- Default the plugin's icon directory so both configs share one path.
- Keep decorative platform icons at an empty alt, and turn off the slug
  tooltip where the display name already sits next to the icon.
- Clean up the manifest test's temp dir and cover CachedPlatformIcon.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 21:31:34 -04:00
Georges-Antoine Assi
89c06c9836 refactor(storybook): pin input modality in useInputModality
simplify pass:
- useInputModality gains pin(), which gates setModality so pinned modes
  ignore the listeners (and useGamepad) instead of a watcher undoing their
  writes; drops the manual data-input write and the HMR dispose
- one INPUT_DEFAULT shared by initialGlobals and the decorator fallback
- the Input Navigation stories share one render on meta

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 21:19:50 -04:00
Georges-Antoine Assi
90693fab59 fix(storybook): address code-review findings on the input toolbar
code-review (xhigh) pass:
- lazy-load useGamepad so vitest.setup.ts no longer caches it ahead of
  useGamepad/index.test.ts's vue-router mock (5 failures in the full suite)
- drop flush: "sync" on the re-pin watcher, which ran between setModality's
  ref write and DOM write and let a listener's data-input win
- stop the re-pin watcher on HMR
- test that a pin survives the live listeners, and assert data-input in play()

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 21:15:13 -04:00
Georges-Antoine Assi
ffb6dc62f9 fix(frontend): only request platform icons that ship
The v2 platform icon components probed /assets/platforms/<slug>.svg, then
.ico, and let the browser 404 on every miss before settling on default.ico.
A build-time manifest of the shipped filenames (virtual:platform-icons) now
picks the right file up front, so unknown slugs go straight to the default
and the prefetch cache makes at most one request per shipped slug.

The manifest is a Vite virtual module rather than an eager import.meta.glob,
which would emit hashed copies of all ~240 icons and inline the small ones
into the lib chunk just to read their names.

RPlatformIcon moves out of lib/ to components/shared/PlatformIcon, since it
now depends on platform-specific asset knowledge. Its tooltip also falls
back to the slug when no title or alt is given (the empty-string alt default
used to short-circuit the `??` chain).

Based on the approach in #4728 by @andest01.

Fixes #4671

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 21:08:43 -04:00
Georges-Antoine Assi
c5320928a4 feat(storybook): add an input modality toolbar
Stories had no data-input on <html>, so the key/pad focus rings and other
modality-gated styles never rendered in Storybook. The new Input toolbar
pins data-input to mouse, touch, key or pad, or tracks live devices with
the real useInputModality + useGamepad stack so a connected controller
drives the story. An Input Navigation story demos a useWrapGridNav grid
and covers arrow-key movement in play().

Slimmed-down take on the idea in #4695.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 20:58:17 -04:00
Georges-Antoine Assi
939861094e Merge pull request #4691 from LoneAngelFayt/streaming-patches-6
feat(streaming): resume from a foreign emulator's save or state via declared import
2026-09-25 20:46:07 -04:00
Zach Clendenen
9ade9dfdb8 simplify(pr-ready step 3): collapse duplicated branches and dead code
- config: one _keys_by_label grouping serves both the unique-label map
  and the shared-label warning.
- claim_session: one abort-and-raise for either refused pick; the
  newest-save lookup is a single conditional expression.
- launch: pick refusal fields off one optional ImportRefusedError.
- imports: skip_state is always true for a foreign save archive; drop an
  unreachable KeyError and the unused str form of _read_member.
- webstation: ImportSpec.state_channel is a Literal.
- Stream.vue: the 400 refusal hint folds into the generic server branch;
  pickableStates drops a guard nativeStreamStates already has.
2026-09-25 19:20:30 -05:00
Zach Clendenen
b6f2abb30f review(pr-ready step 2): harden import archives and fix review findings
Security (from the step 1 audit):
- Inflate zip entries a chunk at a time, so an entry whose header
  understates its size fails the CRC check instead of inflating in full.
- Cap the broker manifest at 1 MiB before reading it.
- Rebuild copied entries as regular files, keeping only permission bits,
  so a symlink entry cannot ride into the container.

Code review (xhigh):
- Bound the broker error body read at 1 MiB and truncate what is logged
  and returned.
- De-duplicate refusal hints in Stream.vue.
- Unpack only save members as zips; a zip-shaped state stays whole.
- Pick the newest state off an archive by created_at.
- Run newest_restorable off the event loop.
- Name a carried base entry by its staged path in the manifest.
2026-09-25 19:15:38 -05:00
Zach Clendenen
cf4353e9e2 Merge branch 'feature/streaming-container-names' into streaming-patches-8
# Conflicts:
#	backend/endpoints/streaming.py
#	backend/handler/streaming/config.py
2026-09-25 18:04:31 -05:00
Sam Dornan
8b0f11aceb fix(soundtrack): fall back to the default cover when a game has no artwork (#4779)
The backend's Rom.path_cover_large/path_cover_small return "" rather than
null for a ROM without a cover, and a complete rescan resets url_cover to "".
resolveSoundtrackGameArtwork chained them with ??, so the empty string won
and the v2 mini player rendered <img src=""> instead of the default album
cover. The same value also leaked into the soundtrack panel's header art.

Treat empty strings as missing in resolveSoundtrackGameArtwork and in
playerCoverUrl, with tests for both.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 15:42:19 -05:00
Zach Clendenen
d748bd5219 feat(streaming): name the container by its label in the desktop URL 2026-09-25 15:24:51 -05:00
Zach Clendenen
c9f1d5e33b feat(streaming): offer only the foreign picks a broker imports, and honour the picked state over an older save's exit state
The streaming config now ships import_kinds per container, from the broker's
cached import-spec, so the picker hides foreign saves and states a broker would
refuse instead of failing them after the launch starts.

On DuckStation and RPCS3, a save pick other than the newest archive no longer
lets that archive's own exit state stand in for the picked state: the state
rides the import archive, or the resume is reported lost where the broker
cannot import it.
2026-09-25 12:53:04 -05:00
Sam Dornan
3a1f1f0e9c feat(sync): tell a device when the save it holds was deleted here (#4674)
* Tell a device when the save it holds was deleted here

Deleting a save took its row, its file and its device pairings, leaving nothing
that says it ever existed. A negotiation then read a client still holding the
save as a client with a save the server lacks, answered "upload", and the next
launch put the deleted save back. There was no way to say "this is gone": the
protocol's actions are upload, download, conflict and no_op.

So a slot emptied on purpose is now remembered. `deleted_saves` keeps one row
per (user, rom, slot) with what the slot held and when it was emptied, written
by the delete endpoint, which is the only place a deletion is the owner's
decision rather than housekeeping: autocleanup rotating a version out leaves
newer rows in the slot and is never recorded.

Negotiation reads it only when the slot has no row left, and answers the new
"delete" action when the client's copy is the one that went: the same content
hash, or a copy last written before the deletion. Anything written after it is
progress the server never held, so that still answers "upload" -- emptying a
slot is not a licence to delete a newer save.

The generated frontend models are hand-edited to match: this environment has
only CPython 3.14.0rc2, which the locked pydantic cannot import, so the backend
will not start for `npm run generate`. Both edits are mechanical (the new
literal in the union, the new count field), and `npm run typecheck` passes
against them.

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

* Decide a deletion by identity, and record it before the row goes

Three real findings from the review, and the layering rule.

The record was written after the save row and its file were gone, with two
transactions and a filesystem removal between them. Anything failing in that
window left a deletion nothing remembered, which is the resurrection this
change exists to prevent. It is written first now: a record for a save that is
somehow still there is never read, because a negotiation only consults it when
the slot has no row left.

The client's copy was matched on its own timestamp against the server's
deletion time. Those clocks are not comparable, and a device running slow
would have been told to delete progress it made after the deletion. The match
is now identity alone: the slot remembers every version it lost, capped at the
twenty most recent, and a client holding any of them is told to drop it.
Anything else is offered back, which costs a deletion that does not reach that
device rather than a save that is gone.

Recording replaced the row with a delete and an insert, which two deletions of
the same slot could race into a uniqueness error. It locks the row and merges
into it, with the house savepoint-and-catch for the case where there is no row
yet to lock.

The comparison itself moves to handler/sync/comparison.py beside
compare_save_state, where the endpoint delegates to it and the rule is tested
on its own.

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

* Trim the new comments to the repo's rule

One or two lines each, with the rationale in the commit messages and the PR
description where the rule puts it. The model's docstring is one sentence, and
the comparison keeps its Args and Returns.

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

* Sort comparison imports

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

* Widen the window a deletion is remembered in

A slot's record keeps a bounded list of the versions it lost, and the trim
drops the oldest, which are exactly the ones a long-offline device is
likeliest to still hold. At twenty, a device that missed twenty
delete-and-refill cycles of one slot comes back with a digest that has
aged out and is answered `upload`, which puts a deleted save back.

Raised to a hundred, where the device would have had to miss a hundred
manual deletions of the same slot. The residual is deliberate and cannot
be designed away by a longer list alone: past the bound the server does
not know those bytes were deleted, and the answer degrades to `upload`,
which fails by not propagating a deletion rather than by destroying a
save. A test now names that case so the next reader meets it as a choice
rather than as an oversight.

Found by Greptile on #4674.

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

* Trim the retention comments back to the rule

Both were over the two-line limit, and the constant's was a six-line
design essay of exactly the kind the last round of this review already
removed from this PR. The reasoning belongs in the commit that made the
change and in the pull request, where it is.

What stays is the part the code cannot say: the trim drops the oldest,
and past the bound a device is answered `upload` rather than `delete`.

Found by Greptile on #4674.

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

* Name the deletion record for assets, not only saves

Unreleased, so the table can take a name that states can share later
without another migration.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Apply code-review fixes to deletion records

Record a deletion in short separate transactions so concurrent first
deletions no longer deadlock on MariaDB, hash a save that never
recorded one, keep a re-deleted version from being trimmed, scope the
negotiation's read to emptied slots, and require total_delete.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Simplify deletion records

Drop the unread deleted_at column, record from _delete_save so every
caller of it is covered, skip a record no hash could ever match, let
comparison decide delete vs upload with its reason, count actions once,
and fold the near-duplicate tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* Polish the deletion record's index comment

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com>
2026-09-25 12:21:46 -05:00