30 Commits

Author SHA1 Message Date
Stu Anderson
8e1ea1155d fix(frontend): catch mdi icon names the build would drop (#5562)
* perf(frontend): subset the mdi icon font to the icons the app uses

#5118 trimmed the icon CSS, but the font file still held every glyph
(403 KB) and the build still copied the eot, ttf and woff formats.
The build plugin now also cuts the woff2 down to the code points of the
rules it keeps, and the stylesheet's only font source is that file.

Build only: dev keeps the full font, so a newly used icon renders
without a restart. Font in the build: 403,216 B -> 25,504 B, and the
three unused formats are no longer emitted.

Adds subset-font and @types/subset-font as dev dependencies.

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

* chore(frontend): lint against building mdi icon names at runtime

The build keeps only the icon glyphs whose names appear in full in
src/, so `mdi-${name}` or "mdi-" + name would render an empty square
in production. romm/no-dynamic-mdi-name reports both forms in scripts
and Vue templates.

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

* chore(frontend): drop the mdi font subsetting, keep the lint rule

The browser caches the full icon font after the first load, so
subsetting it only saves about 360 KB on a cold cache. That doesn't
justify two new dev dependencies and a build step that writes into
node_modules. The rule that rejects runtime-built icon names still
protects the existing CSS trim.

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

* fix(frontend): flag mdi icon names split across string literals

Addresses Greptile's review: "mdi-" + "home" passed the rule, but the
build only finds icon names written in full, so that icon lost its CSS.

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

* fix(frontend): type isStringLiteral as a type guard

vue-tsc rejected reading .value off the narrowed BinaryExpression side.

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

* fix(frontend): catch mdi names split across + chains and templates

pr-ready step 2 (code-review xhigh). The rule now reads the static text
at each end of a join, so `base + " mdi-" + name` and `mdi-` + name are
reported, while "mdi-home" + " " + tone stays valid. The word boundary
no longer treats `_` as a separator, and the test reuses a shared
sfcTemplate helper.

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

* refactor(frontend): share the SFC test wrapper, inline isStringLiteral

pr-ready step 3 (simplify). sfc and sfcTemplate now build their case
through one vueCase helper, isStringLiteral is inlined into its only
caller, and the rule points at the build's ICON_NAME so the two
character classes stay in step.

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

* feat(frontend): fail the build on mdi names @mdi/font does not define

The icon trim keeps only names written in full in src/, so a name built
at runtime, or one @mdi/font never had, renders blank in production.
The build now lists each mdi-* token outside tests that names no class
in the stylesheet, with its file and line, and stops. That covers what
the lint rule cannot see: names joined through a variable, .concat, or
+=, and plain typos.

The check found mdi-playstation in the RSelect story, which @mdi/font 7
does not have; it is now mdi-sony-playstation.

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

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com>
2026-11-17 08:13:26 -05:00
Sam Dornan
70f125d184 chore(frontend): remove Tailwind CSS and Vuetify (#5315) 2026-10-25 05:03:45 -05:00
Sam Dornan
7eae2b8ffb chore(frontend): remove the v1 UI and console mode (#5309) 2026-10-23 19:37:45 -05:00
Stu Anderson
4e8fec6845 perf(frontend): serve only the mdi icons the app uses (#5118)
* perf(frontend): serve only the mdi icons the app uses

@mdi/font ships a CSS rule and four font formats for every icon. Generate
a trimmed stylesheet from the icons named in the source and alias the
package import to it.

- scripts/build-icons.ts writes src/plugins/materialdesignicons-trimmed.css
  (woff2 only, LF line endings, no source map pointer). predev and prebuild
  run it through build:icons, and CI checks the committed file is current.
- scripts/trim-mdi-fonts.ts builds the allow list from src/, Vuetify's own
  icon set and the icons the backend names. Only a plain
  .mdi-name::before rule can be dropped; anything unsure is kept.
- Custom notification icons the app does not draw fall back to the level
  icon instead of rendering blank.
- An "All icons (mdi)" story under Primitives/RIcon shows every shipped
  icon with search, plus the icons that are available but not shipped.
- Vitest keeps ?raw CSS imports instead of emptying them.
- build:tokens leaves tokens.css alone when only formatting differs.

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

* perf(frontend): trim the mdi icon css in a Vite plugin

Replace the generated, committed icon CSS with a transform plugin that
trims @mdi/font in memory, in dev, Storybook and build. A watcher
reloads dev when the source names a new icon. Drops build-icons.ts, the
alias, the CI staleness check and the checked-in CSS.

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

* PR feedback

* style(frontend): sort imports in notifications test

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

* perf(frontend): reduce the mdi icon trim to a build-only plugin

Drop the icon browser story, the notification glyph probe, the
build:tokens compare and the woff2-only font rewrite. The plugin now
only removes unused icon rules in production builds, so dev serves the
full set and needs no file watcher.

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

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com>
2026-10-08 07:25:40 -04:00
Sam Dornan
208bfa7889 test(frontend): run Storybook stories and a11y checks in Chromium via addon-vitest (#5153) 2026-10-06 12:59:12 -04:00
Sam Dornan
55498ec427 fix(v2): name dialogs and select listboxes; axe-check story overlays (#5151) 2026-10-05 15:39:16 -04:00
Zach Clendenen
a0ede752f4 perf(frontend): smaller first load and faster vitest setup (#5072)
* perf(frontend): keep the inactive UI and the markdown renderer out of the first load

vue-router fetches every named view of a route before entering it, so a v2 visit also downloaded the v1 view tree. The inactive UI's views are now deferred until rendered. The changelog dialog, mounted on every v2 page, loads md-editor-v3 on first open.

* perf(frontend): set up Storybook annotations only for the story test

Every vitest file paid for the Storybook preview (full Vuetify and the Storybook runtime) though only storybook.test.ts renders stories.

* fix(frontend): address pr-ready code review

* style(frontend): pr-ready polish

* docs(frontend): pr-ready humanizer pass

* fix(frontend): address Greptile review

- router.test.ts: cover an in-place UI switch, so a deferred view that renders blank fails the suite.
- storybook.test.ts: narrow the preview setup comment to the invariant it guards.

* refactor(frontend): drop the view-loader check from the deferred-view guard

Every route view is a lazy import loader, so a typeof check finds the
inactive UI's views without copying vue-router's own heuristic.

* chore(frontend): restrict direct md-editor-v3 imports

md-editor-v3 now loads lazily on v2 pages outside the game details route,
so an eager import anywhere else would quietly pull it back into a shared
chunk. ESLint now flags it and points at the MarkdownPreview wrapper. Type
imports stay allowed, the frozen v1 trees are skipped, and the list is
shared with the v2/lib block so primitives keep their own restrictions.

* fix(frontend): pr-ready code review

Prefetch every deferred view of the current route on a UI switch, lint
static imports of the md-editor wrappers, make the hand-back test
self-contained, and drop redundant mock resets.

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

* refactor(frontend): pr-ready simplify

Render MarkdownViewer through the shared MarkdownPreview wrapper, inline
the route-entering check, and set the test UI version once in beforeEach.

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

* perf(frontend): load md-editor config with its consumers and skip echarts

The md-editor config module now applies itself on import, and each
md-editor consumer (v1 details, NotesTab, MarkdownPreview) imports it,
so md-editor's config, json5 and the XSS filter leave the entry chunk.
Lint flags eager imports of the config module.

Echarts fences render as code and a stub instance stops md-editor from
fetching echarts from unpkg whenever a preview mounts.

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

---------

Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com>
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-03 12:55:05 -04:00
Georges-Antoine Assi
48976e8115 Run every v2 story in the Storybook runner and move AssetActions to shared
AssetActions renders the per-item buttons that the shared AssetList and
AssetStrip stories compose, so it belongs in components/shared rather
than a feature folder. The runner now globs every v2 story, which also
picks up the Player, Home, Platforms, GameCard and AppShell stories that
had no play() or a11y coverage.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 14:00:53 -04:00
Georges-Antoine Assi
b640661a87 Keep Storybook harness stories inside CI's time budget
The SaveDataTab stories timed out at Vitest's 5s default on the CI runner,
almost all of it in the axe scan, and the still-running scan then failed
the next file's stories with "Axe is already running". Shrink the mixed
save/state fixtures and give harness stories a 20s timeout.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 13:23:20 -04:00
Georges-Antoine Assi
bd60b4d821 Align save/state stories with master and reuse shared fixtures
- Rewrite AssetActions stories for the edit/favorite actions that replaced
  the public toggle, and render the favoriting save as type="save".
- Build save/state/user/ROM fixtures on the existing *.fixtures.ts helpers
  instead of a hand-rolled DetailedRomSchema, and rename them to
  saveStates.fixtures.ts / saveStates.plays.ts.
- Mount SaveDataTab after the auth user and ?subtab= are set, so stories
  render the requested subtab from the first frame.
- Add components/GameDetails stories to the Storybook harness glob.
- Restore the per-story comments, drop the unused helper and the
  duplicated prefix constant, and use Array.from for NodeLists so
  typecheck passes.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 10:31:17 -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
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