Commit Graph

57 Commits

Author SHA1 Message Date
Sam Dornan
374f6dac4e Merge branch 'master' into claude/typescript-upgrade-eval-j65v0x
The overview table in docs/FRONTEND_ARCHITECTURE.md conflicted: master
updated the Vue row to 3.5 and re-wrapped the column, this branch bumped the
TypeScript row. Resolved by keeping master's table and carrying the
TypeScript 5.9.3 bump into it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SvDZhPHsNguuX5zqFjDfSD
2026-09-18 15:39:20 +00:00
Sam Dornan
896cb77f2e chore(frontend): upgrade vue-tsc to 3.x and raise the TypeScript floor
vue-tsc 2.2.x runs on the old Volar core; 3.x cuts a full typecheck of the
196k-LOC frontend from 47.2s to 36.1s with no new diagnostics.

The declared TypeScript floor of ^5.7.3 already resolved to 5.9.3, so raising
it to ^5.9.3 only makes the constraint honest and satisfies @vue/tsconfig
0.9's `typescript >= 5.8` peer.

erasableSyntaxOnly makes the existing style a compiler rule: Vite strips types
with esbuild, so enums, namespaces and parameter properties would not survive
the transform. The codebase already has none, and the flag reports 0 errors.

TypeScript 6 and 7 are deliberately not taken. 7.0 is the native port and
drops the JS compiler API, which both vue-tsc and typescript-eslint still
require, so each fails to start under it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SvDZhPHsNguuX5zqFjDfSD
2026-09-18 15:31:28 +00:00
Sam Dornan
ffd26fe6dc fix(a11y): translate the v2 primitives' own control labels (#4620)
* fix(a11y): translate the v2 primitives' own control labels

The library hard-coded 20 English strings for controls a primitive
renders on its own behalf, so screen-reader users heard English in every
locale: close on RDialog/RDrawer/RCarousel, remove on RChip/RSelect/
RComboboxField, clear on RTextField/RSelect/RComboboxField/RDateField,
RDateField's picker toggle and four month/year steppers, plus the
visible "Today" and "All" text.

The overridable-prop pattern was already there and had already failed:
RCarousel's closeLabel/prevLabel/nextLabel and RDateField's
clearLabel/todayLabel defaulted to English literals and no call site
ever passed one. Extending it would have made translation depend on
roughly 130 call sites each remembering to pass a label for a string
that is identical at every one of them.

Instead the app provides one bundle and every primitive reads it through
useChromeLabels(). The provider hands over getters that resolve via
i18n, so they run inside the reading component's render effect and a
locale switch re-renders the labels with no refs to unwrap. inject is
plain Vue, so lib still imports no i18n, and the English defaults keep a
bare mount rendering an accessible name. The existing label props stay
as per-instance overrides, now defaulting to undefined so they resolve
through the bundle.

Reuses common.close, common.clear, common.remove and common.all; adds
eight common.* keys across all 18 locales for the date-field steppers
and carousel navigation. setup.previous/next were left alone: they are
wizard step semantics ("previous step", "back"), not item navigation.

Storybook provides the same bundle, so stories exercise the real path.
Two tests guard the decay this had already suffered once: that an
injected bundle reaches a primitive's aria-label, and that every label
resolves to a real translation in every locale.

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

* refactor: tighten the chrome-label comments and use import.meta.url

Condense the module header and the test's header to the repo's comment
limit, and derive the locales directory from import.meta.url rather than
__dirname, matching the review feedback on #4619.

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

* fix(a11y): cover RAlert and RSteps, and test the real locale switch

RAlert's close button and RSteps' stepper name were missed on the first
pass: RAlert writes its label as a bound string literal
(:aria-label="'Close'") and RSteps builds "Step 2 of 5" from a template
string, neither of which the plain aria-label="Text" scan matched. Both
now read the injected bundle, which gains a step(current, total) member
backed by common.step-of across all 18 locales.

The locale-propagation test previously flipped a local variable and
called $forceUpdate, which only proved a getter re-reads on render. It
now mounts against createChromeLabels(), switches i18n.global.locale and
asserts the rendered label changes on its own, so it exercises the path
the app actually uses. RAlert and RSteps get assertions of their own.

Wrap the new skill bullet so it stops adding a markdownlint line-length
violation, and drop three comments that only restated the ?? beside them.

Reported by Copilot (RAlert) and Greptile (test, comments) on #4620.

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

* fix(a11y): put RDateField's combobox role on its focusable input

The role sat on the field's wrapper div, which is not focusable and had
no aria-controls, so the two accessibility lints on it were right:
assistive tech saw a combobox it could not reach and that pointed at no
popup. The previous comment explained why the role could not go on
RTextField, and it was accurate: RTextField binds $attrs to its outer
element, which becomes a <label> when it owns the visible label, where
the role is disallowed.

So give RTextField a typed `popup` prop that lands role="combobox",
aria-haspopup, aria-expanded and aria-controls on the native input,
where ARIA 1.2 wants them. A single object prop rather than an attribute
bag keeps arbitrary attributes off the input. RDateField passes it,
drops the role from the wrapper (keeping the keydown handler, which is
what the wrapper is actually for) and gives the teleported panel a
useId() so aria-controls resolves.

The wrapper never was a tab stop, so no tab order changes: the input it
delegates to is the same element that now carries the role.

Covers the two vuejs-accessibility errors that eslint reported against
this file on master; src/v2/lib is now lint-clean.

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

* fix(a11y): make popup and multiline exclusive, and tighten comments

The new `popup` prop rendered its combobox attributes only on the
<input> branch, so a caller that also set `multiline` type-checked but
got a plain <textarea> with none of the role, expanded state or popup
association it asked for. Binding them to the textarea instead is not an
option: ARIA in HTML allows no role override on <textarea>, so
role=combobox there would be invalid. The conflict now reports itself
through console.error rather than dropping the ARIA in silence, and the
prop documents the single-line constraint.

Adds RTextField.test.ts covering all three cases: the role landing on
the input while the <label> outer element stays clear of it, no
combobox attributes when the prop is absent, and the conflict being
reported.

Also drop a sentence recording what the code used to do, which CLAUDE.md
rules out, and shorten the RDateField template comment.

Reported by Greptile (both P2) on #4621.

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

* chore(deps): declare the Vue 3.5 floor the code already requires

useId lands in Vue 3.5 and RComboboxField has been calling it on master,
so the declared ^3.4.27 range understated the real minimum: a resolution
inside 3.4 would fail to build. The lockfile already pins 3.5.29, so
this only corrects the manifest and changes no resolved version.

RTextField carried a comment claiming the project was "on 3.4 still",
which is what made useId look like a regression in review; it is gone,
and the architecture doc's framework row now matches.

Also stop advertising aria-controls while the picker is closed. The
panel is v-if'd, so the input pointed at an element that was not in the
document; `controls` is now optional and RDateField passes it only while
the panel is mounted, with the closed state asserted.

Reported by Copilot on #4621.

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

* refactor: drop a comment recording what the code used to do

The describe name already states what the block verifies, and the rest
was change history, which CLAUDE.md rules out.

Reported by Greptile on #4620.

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

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-18 10:19:33 -05:00
Georges-Antoine Assi
b5cd86e3f7 fix(frontend): restate the player isolation URLs instead of reading nginx
The vite plugin parsed the COOP/COEP patterns out of the nginx template at
config load, but the Dockerfile's frontend-build stage copies frontend/
alone, so the config threw ENOENT and the image build failed.

Restate the two patterns in the plugin and let its test assert they still
match the template's map, which also drops the dev container mount that
existed only to feed that read.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 09:13:32 -04:00
Georges-Antoine Assi
8ecb4dd0c5 refactor(v2): fold the cleanup pass findings into the launch path
The dev server now parses the isolated URLs out of the nginx template
instead of restating them, and refuses a template that yields none.

js-dos skips the runtime preload on the leg it is about to reload away,
records its play session on pagehide, and takes the relaunch marker from
the composable that defines it.

Also drops a redundant parameter and a duplicated derivation from
applyLaunchIntent, collapses the repeated id checks in isLaunchIntent,
gives the js-dos asset bases one home, and trims the comments.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 08:18:20 -04:00
Georges-Antoine Assi
0ccda23164 fix(v2): keep the save flush and the js-dos isolation on the launch path
A full navigation out of the player aborts the route change, so the leave
guards below the view never run and the v1 player's pending save was lost.
`usePlayerExit` now settles the departing document first, and EmulatorJS
asks the v1 `Player` for its flush there.

js-dos reached its view by SPA navigation without cross-origin isolation,
although the DOSBox-X backend is a threaded build and nginx has always
isolated its URL. It now relaunches into an isolated document the way
EmulatorJS does, so the view still opens without a page load.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 08:18:20 -04:00
zurdi
8d4e856360 fix(v2): close the gaps the code review found in the player launch path
Findings from the review pass over the SPA launch change, plus the two bot
reviews on the PR.

Correctness:
- Presence stops were addressed to the device, not to a rom, so a view that
  never announced anything could clear what another tab was playing. A stop now
  needs a started session, and happens once; `useActivityPresence` grows the
  `stop()` the two call sites were spelling out by hand.
- The EmulatorJS exit read `window.EJS_emulator`, which a departure taken while
  the loader was still injecting would not see yet, so the runtime could be left
  in a document a later launch then failed to load into. It tracks the injection
  itself.
- js-dos resolved its asset base per view: a second launch in a document whose
  runtime came from the CDN looked for the payloads locally. Two views mounting
  at once could also both inject the runtime. Both now go through one
  document-level loader, which resolves with the base it served from and lets a
  later mount retry a failed load.
- A blocked sessionStorage threw while every EmulatorJS view was initialising.
  Storage that cannot be read is an absent intent, and one that cannot be
  written cancels the relaunch rather than losing the selection to it.
- Outside a secure context the headers cannot expose SharedArrayBuffer, so the
  reload only delayed the same error by a round trip. It is refused up front.
- The dev server mirrored one of the two nginx isolation entries, leaving the
  console player unisolated there.

Reuse and cover:
- `usePlayerExit` owns the whole rule again: `departing` moved in, so both views
  use `guard` rather than one of them restating it, and the `leaving` flag it
  never needed is gone.
- Resolving an intent back into a selection is a pure pair in `launchIntent.ts`
  with its own tests, rather than closures the view kept to itself.
- The Vite plugin is a script beside `precompress`, so the regexes that have to
  track nginx are tested.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R1VFUvsR5wYK3axxR1gebc
2026-09-17 05:33:30 +02:00
zurdi
3f67e0b74a feat(v2): open the EmulatorJS and js-dos launch views without a page load
Play navigated to the EmulatorJS and js-dos launch views with a full document
load, because only a directly loaded player URL carries the COOP/COEP headers
nginx attaches to it, and only a cross-origin isolated document exposes the
SharedArrayBuffer that threaded cores need. Every launch paid that reload,
while only three cores (dosbox_pure, ppsspp, azahar) need threads, and js-dos
8.4.1 does not reference SharedArrayBuffer at all.

Both views are now reached by SPA navigation with the cover morph, like the
PICO-8 and Ruffle views. When a threaded core is booted without
SharedArrayBuffer, useIsolatedLaunch keeps the pre-play selection in
sessionStorage and reloads the view into the isolated document, where it
boots straight away; a second miss reports the insecure context instead of
looping. Adding a threaded core is one entry in areThreadsRequiredForEJSCore;
another player that needs isolation uses the same composable.

Leaving a player view is a full navigation whenever the document is isolated,
since the rest of the app cannot embed third-party images under that policy
(provider covers in Match ROM, see #4522), and whenever the EmulatorJS runtime
was injected, which declares globals a second injection would clash with.
usePlayerExit holds that rule for both views; js-dos also injects its runtime
once per document. EmulatorJS closes the play session on pagehide as well,
since the full navigation unmounts nothing.

The Vite dev server mirrors the nginx header map for the player URLs.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R1VFUvsR5wYK3axxR1gebc
2026-09-17 00:03:48 +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
Sam Dornan
2be9eb4aea fix(frontend): report a failed fullscreen exit instead of swallowing it
Entry and exit failures are not the same. A rejected request is a denial
and the stage just stays windowed, but callers exit before opening a
body-teleported dialog, so a failed exit leaves that dialog painted over
by the stage with nothing said. The shared wrapper discarded both.

Uses console.error rather than the console.warn this replaced, which v2
does not allow to ship.

Also drops indexdb-monitor.ts from the frontend architecture doc's source
tree, which still listed the deleted file.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019Uo885XxwhN8wfC4oCtR48
2026-09-15 16:05:55 +00:00
Zurdi
fc75bbb722 Merge pull request #4500 from rommapp/feat/steam-cover-provider
feat: offer Steam as a cover art provider
2026-09-14 23:40:57 +02:00
zurdi
1afa59d9de feat: offer Steam as a cover art provider
The cover search dialog only reached SteamGridDB, so a PC game whose
capsule lives on Steam had no way to pick it up short of a full
re-match. Steam now joins SteamGridDB behind `GET /search/cover`,
ordered by the configured cover priority, and each result carries its
provider so the dialog can filter by source and credit the artwork.

The Steam handler builds the picker from the store search alone and
probes the CDN for the portrait capsule and the landscape header under
the same budget the match picker uses, so a slow CDN costs thumbnails
rather than the dialog. Hits with no artwork are dropped.

A failing provider costs only its own covers; a rejected SteamGridDB
key is still reported, since that is the user's to fix. The "search
cover" action in the edit dialog now opens whenever either provider is
enabled, and the game overview credits Steam-hosted covers.

The resource shape the picker consumes moves to the shared base handler
as `CoverResource` / `CoverResult`, since it is no longer SteamGridDB's
alone.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Untv32z88QMZ2yRSsTgGcC
2026-09-14 00:35:08 +02:00
Sam Dornan
9406619c4f docs: fix stale socket claim, teleport diagnostic and v2 Tailwind wording
Three more inaccuracies, all raised in review:

The patterns skill still described useSocketEvent as debt with consumers
wiring socket.on/off by hand, contradicting the debt entry removed in
54fce62. The composable has five consumers and no raw socket.on/off call
remains in v2, so the section now documents it as the mechanism.

The overlay diagnostic told the reader to check the teleport target is
body. Since the scope classes sit on <html>, any in-document target
inherits them; the real failure mode is a detached node.

The architecture doc's scope banner said v2 uses no Tailwind, which
contradicted the CSS Stack note directly below it: console/index.css
imports Tailwind and main.ts loads it app-wide. v2 uses no Tailwind
utility classes; the stylesheet is still in the bundle.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LnHWknZwwZcm89JuXjrugK
2026-09-12 15:55:25 +00:00
Sam Dornan
54fce6273c docs: correct stale Vuetify claims in v2 skills and architecture doc
The v2 skills described a Vuetify-backed component layer that v2 no longer
has: src/v2/ contains zero `from "vuetify"` imports and zero `<v-*>` tags.
Agents following the skills would write code against a layer that is gone.

Corrected across the four frontend-v2 skills:
- layout guidance (Vuetify utility classes) now describes scoped CSS + tokens
- wrapper contract reframed around attribute forwarding, not Vuetify wrapping
- RForm wraps a native <form>, not v-form; rules are plain functions
- RVirtualScroller is a custom windowed list, not a v-virtual-scroll wrapper
- overlay scope rationale now cites the primitives' own Teleport to body,
  and drops the RDialog .v-overlay__content override that no longer exists
- scroll restoration describes the scrollRestoration store actually in use

Also dropped four Known debt entries that are implemented and wired
(virtualisation migration, useGalleryFilterUrl, scroll restoration,
useSocketEvent).

FRONTEND_ARCHITECTURE.md documents v1 only but never said so, reading as
repo-wide. Added a scope banner pointing at the v2 skills, marked the
Vuetify/Tailwind rows v1-only, corrected the Tailwind version to 4.3.1,
and noted that the Tailwind import lives in console/index.css which
main.ts loads app-wide.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LnHWknZwwZcm89JuXjrugK
2026-09-12 15:44:19 +00:00
Georges-Antoine Assi
cf48d371fc feat(emulatorjs): set a default core per platform in config.yml
Add an `emulatorjs.default_cores` block mapping a platform slug to the
core the player preselects for it, so an instance can run DS software on
DeSmuME and DSi software on melonDS without every user picking a core on
every device.

The player resolves its core from the game's remembered core, then the
platform's, then the configured default, then the platform's first
supported core. Each candidate is checked against the cores the platform
actually supports, so an unknown platform or core falls through.

Playing no longer writes the resolved core back to local storage unless
the user picked a different one, so changing the configured default
reaches devices that never made a choice.

Closes #4434

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-11 08:39:55 -04:00
Sam Dornan
7b72b4d130 ci: align and manage the Docker service image pins (#4433) 2026-09-10 19:53:23 -05:00
Georges-Antoine Assi
b9d2cb491e refactor(db): pass the configured recycle value straight to the pool
Drop the `0` to `-1` remap and hand SQLAlchemy whatever the operator set,
so the knob means exactly what the pool means by it. `-1` is now the
documented way to never recycle, in both `env.template` and the env var
table.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-10 10:57:17 -04:00
Georges-Antoine Assi
6b2ca96397 fix(db): recycle pooled connections before the server drops them
The engine sets `pool_pre_ping` but no `pool_recycle`, so a connection
the database closed for being idle is still handed out, and the ping on
that half-closed socket blocks the worker until TCP gives up: tens of
seconds to minutes of an unresponsive API for every request that draws
it, while a fresh connection to the same server answers instantly.

Default to 300s, under the lowest `wait_timeout` MariaDB is commonly
configured with, and make it settable.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-09 20:25:36 -04:00
Bee
f50eacfcbd feat: add browser PICO-8 player
Add v2 browser playback for .p8 and .p8.png cartridges, backed by the
FAKE-08 WebAssembly runtime, with canvas rendering, audio, fullscreen and
keyboard, gamepad, mouse and touch input. Wires up platform detection,
play actions, routing, localization, gallery navigation, play-session
tracking and lifecycle cleanup.

The runtime is fetched in the emulator stage of docker/Dockerfile, pinned
by source commit and verified with sha256, so it is provisioned the same
way as EmulatorJS, Ruffle and js-dos rather than committed to the repo.

DISABLE_PICO8 gates the player, matching the existing DISABLE_EMULATOR_JS,
DISABLE_RUFFLE_RS and DISABLE_JSDOS toggles.

Based on #4383.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-08 17:59:52 -04:00
Georges-Antoine Assi
a7ecfd96a9 feat!: make filesystem.structure the single library layout
`filesystem.structure` now spells out the whole layout rather than only the part
below a platform folder. A template is relative to the library root, `{platform}`
marks the platform folder, and `{game}` marks where a game begins.

Merge `{gameFile}` and `{gameDir}` into one `{game}` terminal. The information a
terminal carried was the depth, not the kind: at a declared level a file is a
game of its own and a folder is one multi-file game, which a stat answers. That
drops the two-template idiom for a level holding both, and `_discover_default_roms`
with it, since the default scan is now just `roms/{platform}/{game}`.

Retire the auto-detected `{platform}/roms` layout, along with
`filesystem.roms_folder` and `filesystem.firmware_folder`, which named one path
segment each that a template now contains. Both are refused at startup with the
template that reproduces the layout, so an instance that relied on either says so
instead of scanning an empty library and marking every rom missing. Firmware gets
its own `structure.firmware` key rather than following the rom layout implicitly.

`get_roms_fs_structure` keeps meaning the folder a platform's games start in, so
the `.physical` sentinel paths already in the database still resolve. Per-platform
overrides have to agree with `default` on where the platform folder sits;
relocating one platform needs platform discovery and the watcher to union several
roots, which is left out.

The setup wizard reports `library_ready` plus the configured template instead of
a `struct_a`/`struct_b` discriminator, so the banner shows the layout in force
rather than guessing it client-side.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-08 08:39:21 -04:00
Spinnich
e090574eff perf(scan): default to 4 scan workers instead of 1
Hashing 1.96 GiB of real ROM files is 2.2x faster at 4 concurrent
workers than at 1 (108 -> 240 MiB/s on 16 cores, 108 -> 264 MiB/s
pinned to 4 cores). Pinned to 2 cores it is still 1.6x, so the new
default costs nothing on small hosts.

Metadata providers cap themselves independently of this value, so the
extra workers queue rather than exceed an allowance: ScreenScraper holds
a concurrency limiter set to the account's advertised thread count, and
the other adapters pace their own request rate. Database work in the
scan path is synchronous on the event loop, so it serializes regardless
and the connection pool is unaffected.

The compose example advised one worker per CPU, which overshoots on a
large host. Both it and env.template now say what raising this actually
buys, since metadata is paced no matter how many workers there are.

Only installs that never set SCAN_WORKERS move; any explicit value is
preserved.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-07 17:56:27 +00:00
Sam Dornan
c2e3da0fe1 docs(backend): bump the architecture guide to Python 3.14
The backend-development skill links to this guide, which still listed
Python 3.13+ after the runtime moved to 3.14.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0126sJfWPjBzC86zSNCcmHeJ
2026-09-05 14:09:41 +00:00
Sam Dornan
7512aea057 docs: name the emulation frontends whose folder names resolve automatically
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-04 11:08:08 -05:00
Sam Dornan
994fddcbe5 feat(scan): resolve Batocera, RetroBat and ES-DE folder names to platforms
Frontend system folders such as gamecube, megadrive or n3ds only became
RomM platforms after the user copied a 100+ line system.platforms map into
config.yml. A built-in alias table now covers the folder names those
frontends use, seeded from the two example configs and cross-checked
against the upstream system lists.

Resolution order is unchanged for existing users: config bindings and
versions win, a folder name that already is a slug keeps matching itself,
and only then is the alias table consulted. The two call sites that
resolved folder names by hand share one resolver.

The example configs shrink to genuine overrides. The Batocera example
also mapped odyssey2 to the original Odyssey; the alias points at
Odyssey 2.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-04 10:59:20 -05:00
Georges-Antoine Assi
72580fc5b2 refactor(scan): fold the files scan into the quick scan
A quick scan skipped every rom it already knew, so a file dropped into a
game folder went unnoticed until a complete or hashes rescan. This branch
answered that with a seventh scan type; letting quick reconcile the files
of the roms it knows says the same thing with less to learn.

Quick now visits every rom. New ones take the metadata pipeline as
before; existing ones only have their files reconciled against disk,
keeping the stored hashes of files whose size and mtime are unchanged. No
provider is contacted for an existing rom, so quick no longer needs a
metadata source picked, in the scan view, the platform dialog and the per
rom refresh alike.

The watcher schedules a quick scan again, and the per rom "Refresh files"
action sends quick scoped to that rom.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 20:14:46 -04:00
zurdi
d09016a485 refactor(upload): keep the start headers and take the rom target as a JSON body
`POST /api/roms/upload/start` keeps its X-Upload-* headers so existing
clients are unaffected; the new rom_id and folder travel in an optional
JSON body instead of extra headers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WbesTQXohyAWWcLV5iiEN
2026-09-03 17:15:34 -04:00
zurdi
452f0a41de refactor(upload): take the chunked upload start fields as a JSON body
`POST /api/roms/upload/start` reads platform_id, filename, total_size,
total_chunks and the optional rom_id and folder from a JSON payload instead
of X-Upload-* headers. Header values are limited to ISO-8859-1, which also
rejected non-Latin filenames in the browser.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WbesTQXohyAWWcLV5iiEN
2026-09-03 17:15:34 -04:00
zurdi
fc8cfbc6f1 feat(scan): add a files scan that reconciles rom folders incrementally
Files added to an already-scanned folder ROM could only be picked up by a
complete or hashes rescan, which rehash every known file. The new `files`
scan type scans new games like quick and re-lists the files of existing
folder ROMs, hashing only new or changed files and recomputing the
ROM-level hashes only when a top-level file changed. Per-rom update and
unmatched scans reuse the same incremental mode, and the filesystem watcher
enqueues it instead of quick.

Also stores rom_files.last_modified as Double (MariaDB FLOAT rounds a
current mtime to about 128 seconds), adds the CHEAT value missing from the
PostgreSQL category enum, maps `patches/` to the patch category and
excludes upload temp files from scans.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017WbesTQXohyAWWcLV5iiEN
2026-09-03 17:11:03 -04:00
Georges-Antoine Assi
ffc8dffc20 Merge upstream master into claude/rq-scan-queue-split
Master landed #4274 with the review changes that came out of it, and those
moved the code this branch was built on. Scan job bookkeeping now lives in
`handler/scan_jobs.py`, every enqueue goes through `enqueue_task`, cron
entries carry their own name and result TTL, and the watcher builds its two
rescans from one helper.

Resolved by putting this branch's changes where that code now lives:

- The scan queue, the scoped-scan check and the second scheduled registry
  moved into `handler/scan_jobs.py`, keeping master's single-round-trip
  reads (`get_job_ids` plus one `fetch_many`, and `get_jobs_to_schedule`
  for the stale sweep) across both registries.
- `enqueue_scheduled_scan` sits next to `enqueue_task` in the registry and
  is built from it, rather than hand-rolling the same enqueue in
  `tasks/tasks.py`. Its tests moved with it.
- Cron keeps master's per-entry name and result TTL, and adds the scan
  dispatch on top: `TASK_TIMEOUT` for the dispatch, the task's own timeout
  (now `SCAN_TIMEOUT`) for the scan it enqueues.
- The watcher's `schedule_rescan` helper enqueues on the scan queue with
  the abandoned-job callback.
- `PeriodicTask.func` is gone from master, so the scheduled rescan declares
  only its timeout. `tasks.registry.enqueue_scheduled_scan` joins the func
  paths an RQ worker has to be able to import.
- The job stubs shared by the discovery tests grew the scan queue and a
  scoped-scan job; the duplicated stale-sweep tests are master's.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-03 12:16:44 -04:00
Georges-Antoine Assi
32f9e338e7 Merge pull request #4274 from sdornan/claude/rq-native-scheduler
refactor(tasks): schedule with RQ instead of rq-scheduler
2026-09-03 11:50:20 -04:00
Georges-Antoine Assi
24cf0a47c3 refactor(scan): move scan job bookkeeping out of the socket endpoint
Finding a scan in flight and pruning ones left behind is RQ bookkeeping,
not socket work, and the watcher and the startup script both ask for it.
It now lives in a handler that depends on nothing heavier than the queue,
with its own tests; the socket module keeps only what it says to a client.

The func name a directly enqueued scan carries is spelled out rather than
read off the function, which lives in the module that imports this one. A
test holds the two together.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-02 21:08:38 -04:00
Georges-Antoine Assi
7036ae0e9c Merge remote-tracking branch 'origin/master' into feature/sigil-title-ids 2026-09-02 16:34:48 -04:00
Sam Dornan
83ba4d92fe fix(scan): report a scheduled scan whose worker dies, and keep its history
`on_failure=report_scan_failure` is attached where a scan is enqueued by
the socket handler and the watcher, but a scan cron enqueues carried
nothing: `CronScheduler.register()` takes no `on_failure` and `CronJob`
has no equivalent, so the one scan nobody is watching is also the one
whose worker can die without a `scan:done_ko` reaching the clients. RQ
reaps the job correctly and moves it to the failed registry, but no
callback runs, so the client keeps showing a scan that no longer exists
and `/tasks/status` cannot recover it either.

Cron now registers a dispatch job for a scan instead. It enqueues the
real scan onto the scan queue with the callback attached, mirroring what
the socket handler does. The dispatch sits on the low priority queue
rather than the scan queue so it fires on the tick instead of waiting
behind a scan that is already running, and because it only enqueues, it
takes the ordinary task timeout and hands the scan timeout to the scan
itself. That last part is a behaviour change: the cron job's own timeout
drops from `SCAN_TIMEOUT` to `TASK_TIMEOUT`.

The dispatch is left out of the task history, because it carries the
scan's own name and finishes in milliseconds, so listing it would show
one scheduled rescan as two runs. A dispatch that failed is still listed,
since then no scan ran at all.

Cron jobs also get an explicit result TTL. `register()` defaults it to
RQ's 500 seconds and writes that onto the job, so `job.get_result_ttl()`
never fell back to the worker's own 86400 and the Task History panel
emptied about eight minutes after each run. Passing `TASK_RESULT_TTL`
restores what rq-scheduler gave for free, since it passed no TTL at all.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-02 15:02:36 -05:00
Sam Dornan
dc11fcfc24 fix(scan): give the nightly rescan the scan timeout, and see the old registry
`ScanLibraryTask` never set a timeout, so it inherited `TASK_TIMEOUT` and
the nightly pass over the whole library was killed after five minutes.
That predates the scan queue, which only made it visible: the timeout is
now read straight off the task when its cron entry is registered.

Delayed scans are also looked for in the low priority queue's registry as
well as the scan queue's. A scan delayed before scans had their own queue
waits in the old one, where a worker will still release it, so the stale
sweep has to be able to see and drop it.

The queue table in the architecture doc still described the low priority
queue as the home of long-running scans.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-02 15:02:36 -05:00
Sam Dornan
4e59217275 refactor(tasks): schedule with RQ instead of rq-scheduler
rq-scheduler has one release since 2023, 109 open issues, and RomM ran a
fork of it for Redis username and SSL options that upstream never took.
Everything it was here for now ships with RQ.

Its two failure modes were the reason for the workarounds in 9e9f59c04.
It reads a job's function name before taking the job out of its registry,
so one unreadable job stalls it for good; RQ's scheduler removes every id
it looked at whether or not the job could be read. And cancelling a
delayed job needed both `Scheduler.cancel` and `Job.cancel`, because the
first left the status alone and the second left the registry entry, which
the scheduler then queued anyway; `Job.cancel` on its own now clears the
scheduled registry.

Delayed jobs, which is how the watcher defers a rescan, go onto the queue
with `Queue.enqueue_in` and are released by the worker running with
`--with-scheduler`. Periodic tasks are declared in `tasks/cron_config.py`
and loaded by an `rq cron` process, replacing `rqscheduler`. A task is
registered only when it is enabled and has a cron string, so the
schedule-then-unschedule dance around the env toggles is gone, and with
it `PeriodicTask.init/schedule/unschedule`.

Jobs are enqueued by task name through `run_task_by_name`, resolved
against a catalog in `tasks/registry.py`. Nothing pickles a task instance
into Redis any more, which is what made a payload unreadable across
upgrades in the first place. The catalog also gives the tasks endpoint
one home for what a task is, rather than a list of its own.

Scan discovery keys off the type a job carries rather than the scheduled
rescan's function name, since every task now shares one entry point. That
also drops SCAN_LIBRARY_TASK_FUNC, which only existed to name a function
across an import cycle.

The watcher's dedupe worked on `job.args[0]` while scans are enqueued with
keyword arguments, so it never matched and every filesystem change
scheduled another scan. It reads `platform_ids` from the payload now, and
deliberately ignores a scan already running: that one may have walked past
the folder that just changed.

Startup clears what the old scheduler left in Redis, once.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-02 15:02:04 -05:00
nendo
e04b6035f2 Merge upstream master into feature/sigil-title-ids
Upstream took 0113, so the sigil migration rechains onto
0113_roms_locked_fields as 0114. The sigil build stage keeps its place
ahead of the emulator stage, which upstream renamed for js-dos.
2026-08-31 11:39:53 +09:00
Sam Dornan
b2e3de4772 Merge branch 'master' into claude/steam-metadata-provider
Resolves the additive conflicts against master:

- config, handler registry and the roms endpoint imports keep both the
  Steam and the new UPC-lookup entries.
- Renumbers the Steam migration to 0113 (master took 0109) and rebases it
  onto 0112_publisher_developer_split.
- Syncs the migration's pre-Steam facet mirror list with 0112, which added
  publishers/developers to the roms_facets triggers.
- Groups SteamMetadata's publishers/developers with the shared provider
  keys, now that master has made them a shared field.
2026-08-29 16:36:58 -05:00
Georges-Antoine Assi
4142fbc018 refactor: dedupe js-dos emulation checks and player plumbing
usePlatformPlayable is the platform-level twin of useCanPlay, but only the
latter learned about js-dos, so win3x/win9x games offered Play while their
platform tile showed no playable badge and sorted into the unplayable bucket.
Teach resolveEmulator about js-dos and derive `playable`/`isPlayable` from it
instead of hand-maintained OR chains.

Collapse the duplication the new backend introduced: a shared
resolvePlatformSlug in utils, a supportedBy factory for useCanPlay's three
identical computeds, one COOP/COEP nginx pattern per map, and a single
hard-navigation branch in useGameActions that reuses the canPlay useCanPlay
already returns.

In JsDos.vue, share the teardown tail between leavePlayer and onBeforeUnmount,
collapse four derivations of the route rom id into one, start the js-dos
runtime alongside the rom request rather than behind it, and hold the rom in a
shallowRef since the view only reads scalars off it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-29 10:20:47 -04:00
Georges-Antoine Assi
e7c4cb2ab6 refactor(scan): tighten the sigil title id extraction paths
Quality pass over the title id feature, no behaviour change.

Give the Switch platform family one home by deriving it from the sigil
slug map, and drop the two inline tuples and the local frozenset that
restated it. Express the base-title-id rule once: a base id is its own
derived base. Compose the bracket regex from the 16-hex pattern instead
of repeating it.

Return the embedded name from the extraction closure rather than writing
it through nonlocal, which removes the is_rom_level flag and the repeated
sigil_platform guards, and factor the twice-duplicated rom-level file
tail into one helper.

Cut two per-ROM costs in _identify_rom: config.yml was re-read and
re-parsed three times per ROM, and the prod.keys firmware lookup ran one
DB query per Switch ROM despite depending only on the platform. Both are
now resolved once, the latter in the per-platform callers.

Also document skip_title_id_extraction and embed_switch_title_ids, drop
the always-dashed title/save id rows from the metadata tab, and render
the file row's chips from one list.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-28 18:18:47 -04:00
Sam Dornan
6a8cb34645 feat(steam): add the Steam storefront as a metadata provider
Steam covers the PC platforms RomM otherwise has thin metadata for, and
its store payload is provider-grade on its own: title, description,
portrait capsule art, screenshots, genres, developers, publishers,
release date and Metacritic score, with no API key.

Valve documents no storefront API, so this reads the two endpoints that
back the store's own search box and app pages, paced well under the ~200
requests per 5 minutes they tolerate. Every failure path degrades to "no
match" rather than aborting a scan, and the provider is opt-in behind
STEAM_API_ENABLED, matching HowLongToBeat and Flashpoint.

Matching is gated on the platform slug so the three PC platforms are the
only ones that spend a request. The storefront's search index carries
DLC, soundtracks and tools alongside games, so hits are filtered by type
and then confirmed against the app page, which is the only place a demo
or a video is distinguishable from a game. A (steam-12345) filename tag
pins a match by hand when the title is ambiguous.

SteamMetadata reuses the key names the other providers already use for
the values they share, so wiring Steam into the generated facet columns
later is a SQL change with no stored-row reshaping.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-22 13:35:42 -05:00
Spinnich
1ee6cea070 perf(roms): pick a random rom without paging to a random offset
The Home "Random Pick" widget asked the API for the library total, then
for the single row at a random offset. Paging to offset N makes the
database walk and discard the N rows before it, so the pick got slower
the bigger the library: measured on an 83,000-game instance, 1.7s at the
median offset and 6.9s deep into the list, on every home page visit.

Adds GET /api/roms/random. It offers the query a batch of random primary
keys and takes any that exist, which is one index lookup per candidate
and unbiased, since every id in the table is equally likely to be
offered. A batch only misses when the query matches too little of the id
space, and it then falls back to counting the set and taking the row at a
random position, reading index entries rather than rows because the
statement selects nothing but the id. Both paths are uniform.

On the same 83,000-game library: 2.9ms median for an unscoped pick
(0.6% of picks take the fallback, 236ms), 19-25ms scoped to a platform.
The widget now resolves a pick in one request.

The endpoint takes the platform / collection scope parameters so the
gallery "Random ROM" buttons (#4068) can move onto it too.

Fixes #4066

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-02 19:25:36 +00:00
Georges-Antoine Assi
f4984fb218 cleanup 2026-07-28 21:28:09 -04:00
Georges-Antoine Assi
48259b3a9e fix(docker): snapshot the internal valkey hourly instead of every few minutes
The keyspace holds the Switch TitleDB and LaunchBox caches, so dump.rdb runs
to hundreds of MB (424MB on a dev instance). Valkey's stock save policy
rewrites all of it every ~5 minutes once 100 keys change, which idle RQ
bookkeeping alone triggers, for gigabytes of disk writes per hour.

Fixes #3980

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-28 18:41:49 -04:00
Georges-Antoine Assi
e885792aa1 fix(tasks): skip orphaned resource cleanup when the database looks empty
`cleanup_orphaned_resources` decides what to delete purely by asking whether
a resource directory's id is absent from the database, with no sanity floor.
If `get_platforms()` ever comes back empty while artwork is still on disk
(database unavailable, mid-migration, half-restored backup), every platform
directory is treated as orphaned and removed in a single pass.

That was tolerable when the task only ran on an admin's click. Now that it
can run unattended at 5 AM via `ENABLE_SCHEDULED_CLEANUP_ORPHANED_RESOURCES`,
nobody is watching when it happens.

Bail out when the database reports zero platforms but platform directories
exist on disk, and log a warning saying so. A genuinely emptied library can
still be cleaned by running the task manually with `{"force": true}`, which
the run-task endpoint already forwards to `run()`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-27 17:06:28 -04:00
Ryan McClelland
90d1c72256 feat(tasks): allow orphaned resource cleanup to run on a schedule
Orphaned covers and screenshots left behind by deleted ROMs accumulate
indefinitely, because the only way to reclaim them is to trigger the
cleanup task by hand. On a long-lived instance the resources directory
grows without bound, which is a problem when it shares a filesystem with
the database.

Move the task to `tasks/scheduled/` and turn it into a `PeriodicTask`
with an opt-in cron schedule, defaulting to 5:00 AM so it runs after the
nightly scan and metadata tasks have settled.

`enabled` stays `True` rather than tracking the new env var, because the
run-task endpoint requires both `enabled` and `manual_run`. Gating it
would have silently removed the ability to run the cleanup by hand,
which is how it works today. The cron string is what is opt-in, and
`init()` unschedules when it is unset.

Add the new flag to the init script's scheduler condition, so enabling
only this schedule still starts `rqscheduler`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 13:53:30 -07:00
Georges-Antoine Assi
98651ecbf8 Fix ROMM_AUTH_SECRET_KEY auto-generation under nounset
The init script runs with `set -o nounset`, so testing `${ROMM_AUTH_SECRET_KEY}`
aborted with "unbound variable" before reaching the generation branch, leaving
the container in a restart loop. This only triggered when the variable was
omitted entirely; shipping it with an empty value took the working path.

Use `${ROMM_AUTH_SECRET_KEY-}` so the unset case is testable, and warn instead
of info since a generated key changes on every restart.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-27 08:07:50 -04:00
Georges-Antoine Assi
753556af7b perf(backend): materialize virtual collection membership
virtual_collections was a view that unnested five JSON arrays per rom on
every read, so both the collection list and opening a single collection
scanned the whole library. Opening a collection with a handful of roms
cost as much as one with thousands, since the name is computed inside the
view and nothing can be narrowed down early.

Membership now lives in virtual_collection_roms, one narrow row per
(type, name, rom_id) plus that rom's covers, derived from the generated_*
columns and maintained by triggers on roms (deletions ride the foreign
key cascade). The view becomes a plain aggregate over that table, so the
model, schemas and API shape are unchanged, and filtering roms by a
virtual collection is an indexed subquery instead of an IN list of every
member id.

Covers are no longer aggregated in the view, which materialized every
member's cover path on every request; the handler resolves at most five
per collection, matching the smart collection cap and what both UIs
render.

On a synthetic 50k-rom library the list goes from 1.42s to 0.128s and a
single collection from 0.111s to 0.0006s, with identical output.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 10:06:05 -04:00
nendo
8a94854b81 Add a music query API for soundtracks
RomM stores soundtracks but exposes no way to consume them as a music library: a
client has to enumerate ROMs and pull each one's tracks individually, and the
per-track metadata lives in the `rom_files.audio_meta` JSON blob, which is
unindexable on MariaDB, so any library-wide filter or sort degrades to a full
scan.

This adds a queryable, music-first API for soundtracks, backed by a typed and
indexed `track_meta` table migrated from that JSON.

It also lets users upload soundtracks, manuals, and screenshots to any ROM, not
only folder-based ones. When the target is a single-file ROM, the client warns
that the upload will migrate it to a multi-file (folder) structure, then performs
that migration in place automatically.
2026-07-02 11:16:07 +09:00
Georges-Antoine Assi
c94b92afdd self cleanup 2026-07-01 09:06:12 -04:00
Georges-Antoine Assi
2631f0e45d Merge pull request #3577 from Spinnich/feature/oidc-allow-registration
feat(auth): add OIDC_ALLOW_REGISTRATION toggle to gate OIDC auto-registration
2026-06-22 18:06:13 -04:00