Watching the eligible user's id instead of the whole user object lets
Vue dedupe the reconcile, so the manual once-per-login flag goes away.
Move the remaining in-flight guard next to the code that reads it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Collection.vue and Platform.vue each carried an identical manual
`unmounted` flag to keep a late random pick from navigating a component
that had already gone away. Replace both with a shared composable built
on `onScopeDispose`, so the guard also works outside a component.
VueUse's `useMounted` is not a substitute: it only flips to `true` on
mount and never back to `false` on teardown.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The sort key and the launchbox inverted-title matcher each carried their
own copy of the same 16 articles. Build both patterns from a single
ARTICLES tuple, and point the frontend's hand-synced copy at it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Addresses review feedback on #4142.
`authStore.user` is null at install in the real flow, since AppLayout
mounts while /users/me is still in flight, and the watch is what catches
the arrival. That path had no coverage, and couldn't have: the auth mock
was a plain object, so the watch never fired on change. Making it
reactive exposed a second problem, that the host component was never
unmounted, leaving earlier tests' watchers alive to reconcile again on
the shared state. Unmount in afterEach.
Also swap the double-nextTick settle for an explicit flushPromises, and
optional-chain `running.meta` since the task status is a JSON boundary
where a missing snapshot should mean "no counters yet", not a throw.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Scan state was built up purely from socket events, so a tab that loaded
while a scan was running started at `scanning: false`: /scan rendered its
empty state with an armed Start button and the navbar pill stayed hidden.
Two changes:
`scan:update_stats` now flips `scanning` on. It is the only event a scan
emits continuously, since `scanning_platform` fires once per platform and
`scanning_rom` only for ROMs the scan actually adds, so an update scan
over a settled library emits nothing else for long stretches.
`reconcileWithRunningScan` asks /api/tasks/status on install and seeds
`scanning` plus `scanStats` from the running job's meta, so a refresh or
a second tab is correct immediately rather than eventually. Gated on the
`tasks.run` scope, the same one the scan socket handler requires. Guards
cover a terminal event landing mid-request and live stats being fresher
than the job snapshot.
The per-platform live log is unchanged: it only ever exists in the
originating tab's memory, so it fills in from the next platform onward.
Fixes#4141
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ScreenScraper's box-2D was the only media type that never got a local
file: it fed url_cover and nothing else. When any other provider won the
cover (the default, since SCAN_ARTWORK_PRIORITY puts ss fourth), the box
front was recorded as a URL and never downloaded, leaving it unreachable
from the UI. Enabling box2d_back/box2d_side could only be made to look
right by forcing ss to the top of scan.priority.cover.
box-2D now records a box2d_path when box2d is listed in scan.media, like
every sibling media type. The Artwork subtab lists the box front, and
the interactive 3D box takes its front face from that scan (falling back
to the rom cover), so all three faces come from the same source and the
3D box no longer depends on cover priority.
Fixes#4127
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The staleness check added in #4113 asks whether a different gallery is
loaded, not whether the user is still in the gallery they clicked from.
Leaving for a non-gallery route never runs `resetGallery()` and never
clears `Collection.vue`'s local `currentCollection` ref, so the captured
scope id still matches: the pick navigates away from wherever the user
went, and a failed pick toasts on that unrelated page.
Treat the view being torn down as stale and OR that into the existing
`stale()` closure, so both symptoms go through the same gate. This also
covers hopping between collection kinds, which are separate route
records whose local ref the id check could never see go stale.
Fixes#4114
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The platforms index only matched the display name, so a platform you
know by its folder on disk, its slug, or its family stayed unreachable
unless you guessed the name RomM shows.
Match the term against the display name, slug, fs_slug, category and
family name. Category contributes both the raw stored value and the
prettified label, since the label is what the list column and the group
heading show while the raw value is what the app stores.
The placeholder now names the searchable fields, in the same style the
ROM search uses.
Non-hero GameCards render at a fixed height with a natural width, which
`.r-gc__art` took from GameCover's `aspect-ratio` via `width: auto`. That
makes the width depend on the aspect-ratio transferred size, and inside a
shrink-to-fit ancestor (the Match ROM dialog's grid cell) the resolution is
circular. WebKit collapses it to a few pixels, so covers render as thin
slivers of the image.
Multiply the height by the cover ratio instead. Both are already CSS
variables on the element, so the width lands on the same number with
nothing left for the engine to resolve.
44ef5cf5 addressed the same report by making the cell a flex container.
That changed where the width was resolved but left the transfer in place,
so the covers still collapsed on 5.1.0.
Fixes#3761
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The MobyGames API returns moby_score on a 0-10 scale and the backend
stores it verbatim (handler/metadata/moby_handler.py), so a score of 5.5
was rendering as "5.5%" instead of "55%". v1 applies the same multiplier
in Details/Title.vue, as does the mock library generator.
This reverses 781e4ff0f, whose premise that the backend already returns
0-100 scores is not borne out by the recorded API responses in the
MobyGames cassettes.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Ratings had their own section in the metadata tab, duplicating the
provider list rendered right below it. Each score now sits on its
provider card, right aligned next to the external ID, and the standalone
section is gone.
Scale normalization and percent formatting move into providerRating(),
next to providerId(), so the provider registry stays the single source
of truth. Formatting itself is now Number.toLocaleString with
style: "percent" rather than toFixed plus manual trailing-zero
stripping, which also drops the NaN chips that missing metadata used to
render.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Repo style forbids em-dashes in comments and text. Also trims the
provider-categorisation comment, whose parentheticals just enumerated the
two lists below it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`getAllMetadataOptions()` stopped labelling IGDB as "IGDB + Playmatch" in
aed926ac9, when Playmatch became its own metadata source. The rename that
stripped the suffix stayed behind, and the test fixture asserted the old
label, so the fixture only passed because the rename normalised it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The provider selects represent "All" as an empty model, so the Playmatch
gate read no IGDB and forced the switch off. It also meant an All-mode
group sent an empty `apis` list, which the backend reads as "no sources".
Both scan dialogs now expand All-mode groups before gating Playmatch and
building the payload, matching what the Scan view already did.
The three surfaces had drifted apart because they each carried their own
copy of this logic, so it moves to a shared `useScanProviders` composable.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The collection gallery carried the same unconditional error handler, so a
request that rejected after the user switched collections raised a snackbar
for the one they left.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A request that rejects after the user switched platforms reached the
unconditional error handler, so an abandoned platform could still raise a
snackbar. Gate it on the same staleness check the success path uses.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The platform gallery's Random ROM button never re-checked which platform
was on screen when its request came back, so a pick started before
switching platforms still navigated, landing the user in a game from the
gallery they had left. Capture the platform id at click time and abandon
the pick once it no longer matches, the same guard the collection gallery
already carries.
Fixes#4104
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The "Recently added" and "Recently played" rows each ask for 15 games and
render 15 covers, but both requests still made the server count every game
in the library and then discarded the number. On a large library that count
is the expensive part of the request, so opening the home page paid for two
whole-library counts nobody sees.
Both rows now send with_total=false, the option added for the gallery in
#4062.
The flag has to reach the request and the cache-clear pattern together: the
pattern is matched against the cache key by substring, so adding it to only
one side would leave the row permanently stale. The cached service now
builds both from a single parameter map per row so they cannot drift, and
the tests assert the clear pattern still matches the key the request writes.
Fixes#4099
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The platform and collection "Random ROM" buttons asked the API for the
scope total, then for the single row at a random offset, and neither call
opted out of the char index, the filter values or the rom id index. All
three cover the whole result set, so picking one game did about as much
work as loading the entire gallery. Scoped requests are never cached
either, so the full cost came back on every click: on an 83,000-game
instance, 7.19s and 878KB against 0.27s and 16.9KB for the same request
with the sidecars off.
Both buttons now call GET /api/roms/random, which samples on the primary
key and returns one row. The scope parameters it already accepts cover
the platform id and all three collection kinds, so the collection view
keeps its kind split unchanged and null stands in for an empty scope.
The v1 RandomBtn / ContextualRandomBtn share the old shape and are left
alone, since v1 is frozen.
Fixes#4068
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The files list and the firmware list both read SHA-1, CHD SHA-1, MD5, CRC,
RA. The metadata tab led with CRC instead, so the same hashes appeared in a
different order depending on which tab the user was on.
Covers the ordering with a unit test, including the CHD SHA-1 position: the
mock library holds no CHD, so that branch cannot be reached in a browser.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
MetadataTab was the only place labelling the row SHA1, while FileRow,
FilesSummary and the firmware list all use SHA-1. It was also inconsistent
within its own list, sitting directly beside a CHD SHA-1 row.
The label is hardcoded rather than translated, so no locale changes.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The Clipboard API only exists in a secure context, so over plain HTTP the
copy button on a hash chip always failed. Because the displayed value is
abbreviated in JavaScript, the rest of the hash was never in the DOM
either, leaving the full value unreachable on any HTTP install.
Clicking a chip now reveals the full value as selectable text whenever a
copy cannot land, so Ctrl+C works as a fallback. On HTTP the click no
longer attempts the doomed copy, so the misleading error toast is gone.
Behaviour over HTTPS is unchanged apart from revealing when a copy throws.
The firmware tab only ever showed the MD5, as an unselectable chip with no
copy affordance, while the stored CRC and SHA-1 were never displayed. All
three now render as copyable chips, matching the ROM files tab.
Fixes#4082
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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>
The v2 home page requested GET /api/setup/library on every visit, which
walks every platform directory under the library path to count files.
That hint only exists for brand-new instances, but it fired for everyone:
17s per home page load on an 83k-game library, 38s on slower storage, and
the result was thrown away because the library wasn't empty.
The frontend watcher was wired to `isEmpty` with `immediate: true`, so it
ran during setup, before any of the page's data requests had started. All
the `fetching*` flags were still false and the stores were still empty, so
the library looked empty and the walk kicked off.
Frontend: onMounted now awaits the initial fetches and flips an
`initialLoadDone` flag. The watcher and the empty-state `v-if` both gate on
`initialLoadDone && isEmpty`, so the request and the render can no longer
disagree about whether the library is empty.
Backend: get_setup_library_info() returns early with an empty
`existing_platforms` once the database holds ROMs, since the on-disk hint is
meaningless then. Gated on ROMs alone, not platforms: platform rows with
zero ROMs are exactly the case the hint exists for, so those still walk.
Fixes#4063
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Server Stats rendered "1 games" for a single-game platform, and the row
meta line leaned on the faint foreground tier: the middot separator, the
size percentage and the region expand toggle all sat at the edge of
readability.
- Pass the count as vue-i18n's plural choice and give every locale the
plural forms its `collection.games-count` sibling already uses.
- Draw the separator as a 4px dot in the muted tier instead of a thin
middot glyph, and move the size percentage off the faint tier.
- Outline the region expand/collapse control so it reads as a button,
and label it for screen readers.
- Spell out the coverage tooltip as "IGDB matches: 159 / 227".
Fixes#4057
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Opting out of the rom id index made the endpoint fall back to a COUNT
over the whole filtered set, so every scroll batch re-derived a total
the page already had from its bootstrap.
Add a with_total flag that skips that count, and have the v2 gallery's
window fetch pass it alongside the sidecar opt-outs it already sends.
total comes back null there, which the store's existing guard leaves
alone rather than applying over the size it knows.
Fixes#4053
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The match flags on `hasheous_metadata` are keyed off Hasheous'
`SignatureSourceType` names, and two never lined up with what its API
actually returns:
* `MAMERedump`, the source holding Redump's disc images in CHD form, was
mapped to nothing at all. A CHD identified by its disc-data SHA1 matched,
got its metadata, and still read as unverified because no flag was set.
* `puredos_match` looked for `PureDOS`; the source is named `PureDOSDAT`, so
the flag was pinned to False for every ROM.
CHD matches now set `mame_redump_match`, which the verified filter counts and
which the Metadata tab folds into the existing Redump chip (same database,
different distribution format). Existing rows pick the flag up on their next
rescan.
Hasheous also exposes Pleasuredome, TotalDOSCollection, eXo, ScreenScraper and
Generic sources that RomM still maps to nothing; those are left alone since
folding them in widens what "verified" means.
Fixes#4030
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>