Commit Graph

20 Commits

Author SHA1 Message Date
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
ea8c734b65 test(frontend): run shared component stories in the Storybook harness
PlatformIcon's story moved out of src/v2/lib, which the harness only globbed, so CI stopped rendering it and running its axe checks. Covering components/shared restores that and adds the four other shared stories.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 21:52:40 -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
Sam Dornan
ff3cbce1e9 test(frontend): cover the dev server's CSS prefixing
Nothing exercised the dev CSS path: CI's e2e run serves a production build,
and vitest.config.ts never loads vite.config.js, so dropping `css.transformer`
would leave every check green while Safari below 18.4 lost its blur again.

Drives the real config through Vite's programmatic server and asserts both the
standard and prefixed properties. Removing the transformer fails it.

Also trims the comment above the setting to the two lines the repo allows.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BEtFQ17BQDS52wXosTjcUU
2026-09-18 01:03:27 +00:00
Georges-Antoine Assi
ec11448bba fix(frontend): check each nginx isolation map on its own
Address the Greptile review: compare the restated patterns against the
$coep_header and $coop_header maps separately, since a merged set hides a
pattern dropped from one of them, and skip the check where the whole repo
is not mounted, so the drift test can still run in the dev container.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 09:24:00 -04: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
3eadc4c33c fix(v2): apply the code review fixes to the launch path
Replace the player entry when leaving by SPA navigation, keep a failed
js-dos runtime load from stacking a second stylesheet, and answer the
player URLs from `vite preview` as well as the dev server.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 08:18:20 -04:00
zurdi
6bf6ed25d2 refactor(v2): fold the cleanup pass findings into the launch path
- The stream player restated the stop pair `useActivityPresence.stop()` now
  owns, so it calls it.
- The dev server's isolation list and the nginx map it mirrors are checked
  against each other by a test, rather than by a comment asking whoever edits
  one to remember the other.
- One case covers the js-dos runtime being injected once, whichever side of the
  first load a second view mounts on.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R1VFUvsR5wYK3axxR1gebc
2026-09-17 05:44:52 +02: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
Sam Dornan
1f231c84f4 test(precompress): close the gaps the review found in the gzip_static guards
The nginx guard only read the http-level default.conf and the three raw
location bodies, so two ways of reintroducing the ROM-corruption bug went
undetected. Both were confirmed against the suite before this change, each
leaving all seven tests green:

- gzip_static added at server scope in the template, with the locations left
  intact: /library/ and /cache/ inherit it, and a request for Game.nes returns
  Game.nes.gz's bytes.
- gzip_static removed from the fingerprinted-assets regex location, which the
  parametrised list never covered, silently dropping precompressed bundles.

Parse the template's location blocks instead, honouring braces inside the
quoted regex matcher, and assert against server scope, each build-output
location including the regex one, and any location that gains the directive.
A prefix match would have let /assets/romm/resources/ pass as expected, so
matchers resolve exactly and only the regex is keyed by its opening.

Also tie MIN_BYTES to nginx's gzip_min_length with a test rather than a
comment, cover the "gzip made it bigger" branch that the extension filter
kept unreachable, drop an em dash, and correct a comment that claimed every
file without a .gz sibling is gzipped on the fly, which is untrue for types
outside gzip_types.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HDXxq3vAxJVGhm1pQuK8V7
2026-09-12 04:49:06 +00:00
Sam Dornan
64740468ec fix(frontend): address the review findings on the precompress plugin
The summary divided by zero and printed "NaN% smaller" when nothing
cleared the extension and size filters.

The comment on the extension list said it tracks gzip_types, which was
wrong twice over: .svg, .wasm, .webmanifest and .map are absent from that
directive, and gzip_static serves a .gz sibling without consulting it at
all. Someone editing either list on the strength of that comment would
have changed behaviour silently.

Storybook builds ran the plugin too, gzipping storybook-static that nginx
never serves. It is stripped alongside vite-plugin-pwa, which .storybook
already does for the same reason.

The Python test could only grep vite.config.js for the call, so a gutted
closeBundle or apply: "serve" left it green. A vitest suite now runs the
hooks against a temporary directory and checks the archive round-trips,
that small and already-compressed files are skipped, and that a rerun does
not compress its own output.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HDXxq3vAxJVGhm1pQuK8V7
2026-09-12 02:09:24 +00:00
Georges-Antoine Assi
fba242150a docs(v2): trim and compact a11y comments
Remove redundant explanation and shorten the remaining comments added by
the accessibility work to the "why" only.

Generated-By: PostHog Code
Task-Id: b44aba2c-90c9-407d-8c80-5bbe77ecd6c1
2026-07-05 22:40:51 -04:00
Georges-Antoine Assi
1eb4d1c8ed test(v2): add axe accessibility gate + keyboard nav tests to Storybook
Wire axe-core into the vitest Storybook runner so every v2 lib story is
scanned for accessibility violations, gated per story by the
@storybook/addon-a11y `a11y.test` parameter (error / todo / off) with a
global default of "error".

Fix the unlabeled-control violations this surfaces (icon-only buttons,
decorative images) and mark the remaining component-level gaps as `todo`
so CI stays green while the backlog stays visible. Add keyboard-operability
play() tests to RSwitch, RTabNav, and RRating.

Refs #1848

Generated-By: PostHog Code
Task-Id: b44aba2c-90c9-407d-8c80-5bbe77ecd6c1
2026-07-05 22:10:52 -04:00
Georges-Antoine Assi
f9941385f1 run fmt 2026-07-04 14:22:27 -04:00
suriel123
e1a9c0b7aa fix: stop mapping public domain to Poland 2026-07-05 00:35:35 +08:00
zurdi
df8f6178ef chore(frontend): set up vitest + storybook play() tests and align CI
Add Vitest 4 with happy-dom, @vue/test-utils, and a single
test/storybook.test.ts that auto-discovers every story under
src/v2/lib and runs its play() via composeStories — no Playwright,
just composition-based interaction tests. 89 stories now smoke-pass
in CI.

Scripts: lint:fix (auto-fix), lint (now scoped to ./src/v2; v1 is
frozen), lint:all (legacy sweep), test, test:watch, test:ui,
storybook:test.

eslint.config.js gets argsIgnorePattern: "^_" so unused-by-design
parameters can use the underscore convention.

CI: new frontend.yml runs lint, test, build in parallel on
frontend/** changes; typecheck.yml bumped to Node 22 with cached
npm ci. Existing typecheck job preserved for branch protection.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-28 11:52:44 +00:00