Frontend application architecture
RomM's frontend is a Vue single-page application for browsing, playing, listening to, and managing a game library. It connects route-level views to shared layouts, Pinia state, API services, and live server events. The web application page describes the product experience; this page describes the frontend's main responsibilities and relationships.
Application bootstrap
Startup sequence
The application starts at frontend/…/main.ts and mounts RomM.vue after it prepares shared services and initial server data. Startup loads server health, the current user, server configuration, and locale messages before the router starts normal navigation. These facts give route guards and layouts a common view of readiness, identity, feature support, and language.
The startup flow is:
- Create the Vue application.
- Register shared state, translation, UI, and event services.
- Load initial server, user, and configuration data.
- Make locale messages and accessibility labels available.
- Install the router and mount the application root.
The diagram shows how the browser reaches a mounted application with the shared state needed for its first route.
flowchart TD
A[Browser entry] --> B[Create Vue application]
B --> C[Register shared services]
C --> D{Prepare shared state}
D --> E[Server health]
D --> F[Current user]
D --> G[Server configuration]
D --> H[Locale messages]
E --> I[Install router]
F --> I
G --> I
H --> I
I --> J[Mount application root]
J --> K[Select route layout]
The bootstrap also handles stale lazy-loaded assets after a deployment. A guarded reload lets an old browser tab load the new asset set without creating a reload loop.
References: frontend/…/main.ts• L20-35 frontend/…/main.ts• L53-105 frontend/…/RomM.vue• L43-49
Application root
RomM.vue is the document-level shell. It owns global theme and language setup, the active route outlet, and global surfaces that must remain available while views change. This keeps application-wide concerns above route layouts rather than duplicating them in pages.
References: frontend/…/RomM.vue• L43-49 frontend/…/RomM.vue• L98-145 frontend/…/vuetify.ts• L8-32
Layouts and routing
Layout hierarchy
Layouts provide stable page chrome so route views can focus on a user task. Authentication uses a focused shell. The main application uses AppLayout, and settings and library tools use SettingsLayout inside that shell.
| Context | Layout | User-facing purpose |
|---|---|---|
| Authentication and setup | AuthLayout | Present login, registration, password reset, and setup flows. |
| Main application | AppLayout | Present navigation, responsive content, global overlays, background art, and playback controls. |
| Settings and library tools | SettingsLayout | Present section navigation and the active settings or library tool. |
SettingsLayout uses route metadata to choose panel, bare, or viewport-fill content. This lets ordinary settings pages share a surface while pages such as logs can own their scroll area. On small screens, the settings sidebar is removed because the main navigation provides the same section access.
References: frontend/…/AppLayout.vue• L216-237 frontend/…/AuthLayout.vue• L20-29 frontend/…/SettingsLayout.vue• L27-65 frontend/…/SettingsLayout.vue• L92-147
Route registry
The router is the shared URL map for the application. frontend/…/routes.ts maps stable route names to lazy-loaded views and layouts. A route without a registered view resolves to a visible not-found view, so incomplete route coverage is explicit instead of producing a blank outlet.
Routes group around user goals:
- Authentication and setup use public routes.
- Home, search, platforms, collections, game details, and players support library use. See the library browsing experience page.
- Music uses a route with URL-backed view state.
- Scan, upload, library management, settings, administration, statistics, and logs support operational work. See the administration workflows page.
- Pairing uses a dedicated route surface.
- Controller debugging remains an explicit development route.
Lazy loading keeps route-specific work out of the initial bundle. The route tests protect the contract between a matched URL, its stable name, and its registered view.
References: frontend/…/routes.ts• L1-75 frontend/…/routes.test.ts• L10-33 frontend/…/routeNames.ts• L1-80 frontend/…/router.ts• L648-768
Navigation state
Navigation manages document titles, scroll position, view transitions, and route-entry refresh. The shared useNavDestinations composable is the single source for the four primary content destinations, their labels, icons, targets, and active state. It derives activity from the path, so a gallery detail route can keep its parent destination selected on both desktop and mobile navigation. Library tools such as scan and upload remain available from the user menu rather than becoming primary content destinations.
Route metadata stores translation keys rather than translated text, so titles remain correct when locale messages load or the locale changes. A shared collapsing-title composable exposes the compact title shown after a page heading moves behind the navigation bar. It keeps the current page's title while an outgoing page is being disposed, then clears it when the owning page ends. Query-only changes keep the current view and scroll position because they normally change a filter, tab, or playback mode.
Gallery filters are bookmarkable session state. useGalleryFilterUrl keeps the canonical gallery filter store and the route query in sync in both directions. It applies pasted links and browser history changes to the store, writes store changes with a short debounce, and waits for platform data before resolving platform IDs. This makes a shared gallery URL reproduce the same search and filter context without adding one history entry for every toggle.
Views can own a title when it depends on fetched data. URL query helpers make gallery, tab, sort, and music state shareable without creating a browser history entry for every small change. Result refreshes can use a view transition for visible cards, while reduced-motion settings, overlays, hidden tabs, and unsupported browsers use a direct swap. Detail and gallery surfaces can also pair a shared visual element during navigation.
References: frontend/…/AppNav.vue• L1-12 frontend/…/AppNav.vue• L28-45 frontend/…/index.ts• L1-85 frontend/…/index.ts• L13-58 frontend/…/index.test.ts• L41-73 frontend/…/index.ts• L102-150 frontend/…/index.ts• L152-175 frontend/…/index.ts• L326-345 frontend/…/index.ts• L347-469 frontend/…/router.ts• L602-615 frontend/…/router.ts• L631-646 frontend/…/router.ts• L770-788 frontend/…/index.ts• L56-161 frontend/…/index.ts• L77-115 frontend/…/scrollRestoration.ts• L5-22
Route access
The global guard combines server readiness, setup state, authentication, route-level scopes, and feature settings. Public authentication routes remain open without a user. Other routes require a current user, while protected operations resolve to the not-found route when the user lacks the required scope.
Route access and in-page permissions have different jobs. The router protects entry to a page. The permission store controls individual actions after the page is open, while the backend remains the final authority.
References: frontend/…/routeNames.ts• L55-80 frontend/…/router.ts• L618-629 frontend/…/router.ts• L701-767 frontend/…/permissions.ts• L31-76 frontend/…/index.ts• L23-84
Plugins and shared behavior
Framework services
The plugin layer installs the services that form the common Vue environment. Pinia owns shared client state, vue-i18n supplies translated text, the UI system supplies shared visual behavior, and the event emitter supports loose coupling for notifications and dialog requests. Markdown rendering has a shared safety boundary so user-facing content is sanitized before it reaches the page.
References: frontend/…/index.ts• L1-10 frontend/…/pinia.ts• L1-16 frontend/…/vuetify.ts• L8-32 frontend/…/mdeditor.ts• L1-29
Shared components
Shared components express common product concepts once so pages use the same language and interaction rules. The shared library provides basic controls, data surfaces, overlays, media views, and repeated product patterns; feature components combine these primitives with domain state.
Important shared patterns include:
- Page headers, tiles, rows, platform pickers, and asset labels.
- Asset lists, strips, and action menus for save, state, download, edit, favorite, and delete flows.
- Tables and sort headers with loading, empty, responsive, and accessible states.
- Carousels, dialogs, and drawers with shared focus, Escape, scrim, and body-scroll behavior.
- Authentication cards, language controls, navigation buttons, and repeated dialogs.
Feature components can also adapt a shared game card to a related-game link. A metadata lookup sends an owned game to its local detail route and keeps an unowned game available through its external metadata page. Upload dialogs use the same shared service boundary while choosing the correct target for the ROM's file structure.
The shared library stays general. Feature composites remain near the feature that gives them meaning, which keeps business state out of basic controls.
References: frontend/…/index.ts• L1-72 frontend/…/RTable.vue• L1-35 frontend/…/RSortHeader.vue• L1-77 frontend/…/RDialog.vue• L1-18 frontend/…/RDrawer.vue• L1-19 frontend/…/RCarousel.vue• L1-24 frontend/…/RelatedGameCard.vue• L32-49 frontend/…/RelatedGameCard.vue• L180-215 frontend/…/ManualUploadTargetDialog.test.ts• L104-159
Composable behavior
Composables hold behavior that spans views or needs a lifecycle. They cover permissions, connection status, socket subscriptions, scan progress, responsive breakpoints, media controls, playback, navigation, input, URL state, user preferences, and result presentation. A page can then describe its task without owning each shared event, browser capability, or cleanup rule.
The application shell installs behavior that must live across routes. This includes permission hydration, scan and pending-asset updates, responsive document attributes, reduced motion, input modality, gamepad and spatial navigation, global hotkeys, overlay dismissal, native-launch feedback, and server recovery. Scope-based cleanup prevents a socket, timer, browser media handler, or retry pass from surviving after its owner ends.
Game actions use one shared decision point across cards, rows, and detail views. useGameActions combines play targets, stream and join actions, download and conversion work, personal status, collection actions, metadata work, sharing, and permission gates. A card can provide one action context to its child buttons, while a standalone surface can create its own context. Joining a stream uses one confirmation flow and carries the selected ROM and container into the player route.
Playback controls remain tied to the active session. Save and state tabs show all available captures while disabling states written for another core and explaining the required emulator. A device label exposes the current user's device name but uses a generic label for another user's device, so shared snapshot views do not reveal another account's device identity.
Gamepad behavior uses one input path for focus navigation and a separate path for scrolling. useGamepad maps the D-pad and left stick to the normal keyboard focus model, while action buttons activate controls, dismiss overlays, move between app sections, or open the user menu. A running player owns the controller input, except for a held Select-plus-Start exit chord and safe controls in an exit dialog. usePadRafFn starts frame polling only when a usable pad exists and checks again when browser events are missing. useRightStickScroll uses the right stick for the active view's scroll container, so focus movement and content scrolling do not compete.
Gallery composables separate structure from data. The virtual-item model turns total count, grouping, letter positions, and layout into rows that a virtual scroller can display. Visible rows resolve their ROMs separately, so a large result set can show loading and loaded content without building the full catalog in memory. Result-transition composables add optional motion around a result swap without changing the data flow.
Shared composables also keep product rules consistent. Cover animation can spin or seat physical art and can preview hover video, but it stops when the user disables motion or the system requests reduced motion. Platform icon warming avoids repeated asset reads and updates consumers when an icon becomes available. URL helpers keep filters and tabs aligned with the route, while focus and scroll helpers restore a user's place when they return to a gallery. Gallery navigation also provides a back-to-top action after the user moves beyond one viewport; it returns focus to the first gallery control only when a keyboard or gamepad user activated it.
Pending player assets form a shell-level recovery flow. When the server is unavailable, browser-held saves and states wait for a later connection. The sync pass pushes captures in time order, chains captures held on the same base, retries temporary failures, archives a save when another device owns newer slot data, and reports permanent refusal to the user. Storage is best effort, so a browser that cannot use IndexedDB does not turn a capture into a gameplay failure.
The shell also owns scan reconciliation and connection recovery. Scan socket events update one shared scan store for the indicator, scan page, and library views; batched ROM updates keep live scans usable, and a task read lets a newly loaded tab discover an existing scan. HTTP reachability events and heartbeat polling drive server recovery, while socket transport health reports when Socket.IO remains on polling instead of WebSocket. A reconnect reload waits until active play and its network cleanup finish.
Platform playability is exposed at two levels. ROM-level rules decide whether one game can run. useCanPlay combines server grants, platform support, file presence, stream access, and desktop-shell support, while its individual results let an action choose the right browser engine, stream, or native route. usePlatformPlayable applies the same server, permission, and engine rules to a platform and combines them with streaming support, while its batch sibling lets platform lists use the same answer for badges, sorting, and grouping. Native support stays separate because it describes the local desktop shell rather than a server play mode.
Cover-art rules apply across gallery, detail, home, and player surfaces. Play-capability rules combine permissions, server support, file presence, stream configuration, and desktop-shell support. The reduced-motion composable combines the operating system preference with an optional device-local user choice, so CSS and script-driven effects use the same setting. Scope-based cleanup applies to animation frames, delayed media work, input polling, and other browser resources.
References: frontend/…/index.ts• L57-163 frontend/…/index.ts• L335-417 frontend/…/index.ts• L635-695 frontend/…/index.ts• L11-55 frontend/…/index.ts• L4-11 frontend/…/index.ts• L8-62 frontend/…/index.ts• L1-85 frontend/…/index.ts• L17-58 frontend/…/index.ts• L40-161 frontend/…/index.ts• L34-123 frontend/…/AppLayout.vue• L21-46 frontend/…/AppLayout.vue• L48-200 frontend/…/GalleryShell.vue• L616-674 frontend/…/BackToTopButton.vue• L25-65 frontend/…/index.ts• L1-33 frontend/…/index.ts• L224-518 frontend/…/index.ts• L56-161 frontend/…/index.ts• L77-115 frontend/…/index.ts• L119-187 frontend/…/index.ts• L173-235 frontend/…/index.ts• L237-372 frontend/…/index.ts• L7-29 frontend/…/index.ts• L22-31 frontend/…/index.ts• L63-145 frontend/…/index.test.ts• L94-172 frontend/…/index.ts• L48-97 frontend/…/index.ts• L100-229 frontend/…/index.ts• L231-281 frontend/…/index.ts• L47-138 frontend/…/index.ts• L44-85 frontend/…/index.ts• L20-85 frontend/…/index.ts• L1-60 frontend/…/index.ts• L45-87 frontend/…/index.ts• L1-68
API and socket services
HTTP service boundary
The shared API client is the boundary between the frontend and the backend. Domain services use it for library records, identity, configuration, activity, uploads, music, saves, states, snapshot channels, synchronization, screenshots, and long-running tasks. The ROM service also supports filtered and windowed library reads, ordered ID reads for stable result windows, simple card data, related and recommended games, metadata-provider lookups, downloads, metadata changes, file progress, notes, and bulk library actions. This keeps request rules out of views and gives stores one place to reconcile server data.
The boundary also handles CSRF protection, query serialization, active-request tracking, cancellation, and reachability signals. Authentication failures send protected navigation to login. CSRF failures refresh the token without discarding the current session. Canceled requests remain neutral because gallery and search views cancel work as the user changes context. Successful responses, network failures, suspected server failures, and live 4xx responses feed the connection layer through browser events, so the UI can distinguish an unreachable backend from a reachable backend that rejected a request.
Selected library reads can use a stale-while-refresh cache. A cached response renders at once, while a shared background request updates all consumers that use the same request key. Cache reads and invalidation use the same query shape so home rows do not remain stale after a library change.
ROM uploads use a separate long-running flow. The service starts an upload, sends file parts with progress, retries temporary chunk failures, and completes or cancels the upload. The upload store then exposes the result to the UI. Upload targets can describe either a platform destination or a folder inside an existing ROM, so dialogs can add files without changing the library's target contract.
Save and state services turn player captures into server assets. Saves keep slot and conflict rules, while states use a capture-time name for the state file and its optional screenshot. Snapshot service calls extend this boundary for channel history and manifest-based pushes, so a save or state can be attached to the correct channel base and later resumed. Unload-safe requests use browser keepalive for small captures when the page is closing.
References: frontend/…/index.ts• L6-31 frontend/…/index.ts• L33-166 frontend/…/index.ts• L168-193 frontend/…/save.ts• L12-31 frontend/…/save.ts• L105-187 frontend/…/state.ts• L12-86 frontend/…/snapshot.ts• L13-69 frontend/…/snapshot.ts• L72-189 frontend/…/user.ts• L12-119 frontend/…/rom.ts• L43-173 frontend/…/rom.ts• L175-247 frontend/…/rom.ts• L447-577 frontend/…/rom.ts• L631-697 frontend/…/index.ts• L10-185 frontend/…/api.ts• L7-100
Realtime service boundary
The shared Socket.IO client carries events that must update the application without a page refresh. A typed subscription wrapper gives each listener a clear lifecycle and removes it when the owning scope ends. The application shell owns session-wide listeners so route changes do not create duplicate connections or leave old listeners active.
HTTP responses provide the baseline. Socket events then update progress, refresh permissions, reconcile notifications, report pending save or state work, and tell the scan and sync surfaces that server data changed. When an event does not contain the full changed record, the owning detail view performs a later read. Transport health stays separate from backend reachability: a connected socket that remains on polling is degraded but still usable, and a retry can rebuild the socket connection.
References: frontend/…/socket.ts• L1-7 frontend/…/index.ts• L37-59 frontend/…/AppLayout.vue• L48-63 frontend/…/index.ts• L48-97 frontend/…/index.ts• L8-20 frontend/…/index.ts• L44-85
Play and save boundary
Browser players, streaming sessions, and the desktop shell present different play targets through one user flow. Shared composables decide which targets are valid, while stores keep launch, stream, save-sync, activity, and release outcomes separate. This lets a failed save transfer remain visible without making it look like a player failure.
When a player captures a save or state while the server is unavailable, frontend/…/pending-asset.ts keeps the capture and the snapshot base it belongs to in account-scoped browser storage. A later pass pushes captures in time order, chains captures held on the same base, retries temporary failures, archives a save when another device owns newer slot data, and reports permanent refusal to the user. Storage is best effort, so a browser that cannot use IndexedDB does not turn a capture into a player error. The pass stops when the signed-in account changes.
Streaming uses backend configuration to decide which platforms can start a session and which player features are available. The store shares the whole-library list of joinable sessions for a short time, so many gallery cards do not create a request storm. A claim can restore a selected save, state, or memory card, while a joiner receives access to the room without control of the host's session.
The active session is identified by its container and claim time. Heartbeats report whether it is still held without destroying the local player on an unknown network result. Release and save-and-exit keep the session record until the backend confirms the outcome, and page-exit requests use browser keepalive so the server can finish save or release work after the document closes.
References: frontend/…/index.ts• L34-123 frontend/…/index.ts• L335-417 frontend/…/index.ts• L30-45 frontend/…/pending-asset.ts• L116-193 frontend/…/pending-asset.ts• L234-345 frontend/…/save.ts• L152-187 frontend/…/state.ts• L12-86 frontend/…/snapshot.ts• L141-189 frontend/…/streaming.ts• L96-194 frontend/…/streaming.ts• L276-345 frontend/…/streaming.ts• L122-163 frontend/…/streaming.ts• L206-305 frontend/…/streaming.ts• L318-425 frontend/…/native.ts• L156-237
Client state
Store responsibilities
Pinia stores hold state that must survive component changes or coordinate more than one view. Their boundaries follow user concerns rather than component boundaries. Stores normally call domain API services and expose reactive state to views, which keeps server access and reconciliation rules in one place.
| State group | Purpose |
|---|---|
| Identity and server state | Current user, heartbeat, server settings, feature support, and effective permissions. |
| Library state | ROMs, platforms, collections, and administrative data. |
| Browse state | Gallery filters, URL-backed view state, selection, focus, and scroll context. |
| Work state | Scans, tasks, uploads, downloads, conversions, playback, streaming, native launch, and activity. |
| Preference state | Language, theme, UI version, notification, gallery mode, and other user choices. |
Gallery state is split by responsibility. The filter store describes the query. galleryRoms owns the sparse server result and its loaded windows. gallerySelection owns selected ROM objects and bulk-action context. Focus and scroll stores preserve the user's place across route changes.
The heartbeat store is the shared view of backend health and server capabilities. Its health result distinguishes a live backend that returns a client error from a backend that is unavailable, while a separate loaded flag tells consumers whether capability defaults came from the server yet. This prevents a startup default from being mistaken for a confirmed disabled feature.
References: frontend/…/pinia.ts• L1-16 frontend/…/roms.ts• L13-24 frontend/…/galleryRoms.ts• L1-32 frontend/…/gallerySelection.ts• L1-28 frontend/…/heartbeat.ts• L96-137 frontend/…/focusRestoration.ts• L1-16 frontend/…/scrollRestoration.ts• L5-22
Gallery state
The gallery presents large filtered results without loading the full catalog into the browser. The store keeps total count, ordering, filter metadata, and only the result windows needed by the visible area. A metadata bootstrap can size the view and provide letter, filter, and ID indexes before item windows arrive. Visible positions then share bounded requests, limit concurrent work, cancel windows that leave the viewport, and retry short failures.
The store keeps the displayed result stable while a filter or sort refresh is in flight. A new first page replaces the old result as one update, and stale refreshes cannot replace a newer context. When a complete ordered ID index is available, later windows can ask for those IDs so positions remain tied to the displayed result even if records disappear between requests. A separate whole-result read supports select-all without replacing the windowed display model.
Selection is separate from the sparse result cache. This allows bulk actions to keep their selected ROM data even when the user scrolls and older result windows leave the active view. A whole-result selection can fetch the filtered set for an action without replacing the windowed display model.
The gallery's structural composable turns the store's count and letter index into virtual rows. It can represent skeletons, empty states, letter anchors, and loaded positions before every ROM is present, while the view resolves each visible ROM as its window arrives. The gallery shell also saves scroll by full route and reapplies it after the rows have enough height for a meaningful position.
References: frontend/…/galleryRoms.ts• L79-173 frontend/…/galleryRoms.ts• L315-469 frontend/…/galleryRoms.ts• L603-799 frontend/…/galleryRoms.ts• L801-945 frontend/…/GalleryShell.vue• L616-674 frontend/…/GalleryShell.vue• L809-833 frontend/…/index.ts• L224-518 frontend/…/gallerySelection.ts• L50-67 frontend/…/gallerySelection.ts• L121-151 frontend/…/index.test.ts• L62-236 frontend/…/galleryRoms.test.ts• L60-165
Library entity state
Platform and collection stores keep library groupings available to routes, filters, scan updates, and navigation. They hold server-backed lists plus small local views such as search text, counts, ownership, and filesystem platforms. Their actions replace or update records through the matching API service and keep lists unique and ordered.
Collections support regular, virtual, and smart groupings. Virtual collections are derived from library metadata, so a scan can mark the loaded list stale and cause one later refresh rather than overlapping reads. A missing or forbidden collection is removed from its cache because the user can no longer use that record. The favorite collection is selected for the current user rather than from another user's public collection.
Platforms combine stored library platforms with folders found on disk. The resulting scannable list lets management flows show both known platforms and folders that have not been scanned. Scan events add new platforms as soon as the backend reports them, while a completed scan reloads the authoritative platform counts.
References: frontend/…/collections.ts• L14-63 frontend/…/collections.ts• L87-165 frontend/…/collections.ts• L166-215 frontend/…/collections.ts• L242-324 frontend/…/platforms.ts• L9-37 frontend/…/platforms.ts• L39-108 frontend/…/index.ts• L57-97 frontend/…/index.ts• L193-213
Permission state
The permission store holds effective grants, administrator status, hydration state, and hidden platform or ROM IDs. useCan turns these grants into reactive checks for global and resource-scoped actions. The store starts closed until the backend answers, and a failed refresh must not leave old grants active.
The shell hydrates permissions after login and refreshes them when the backend sends a permission-change event. The backend remains authoritative for every write, even when the UI exposes an action.
References: frontend/…/permissions.ts• L18-75 frontend/…/index.ts• L23-84 frontend/…/AppLayout.vue• L48-56
Preference state
Preference state gives each signed-in user a consistent view across sessions. UI settings cover language, theme, home content, gallery presentation, motion, and gameplay choices. The browser provides fast local access, while the current user's server profile provides the account-level copy and receives later changes. Settings are scoped to the signed-in account so one user's choices do not appear for another user.
Language state presents the locales shipped by the application and selects a browser preference when no saved choice exists. Matching first tries the full language and region, then the language alone, and finally the default locale. This keeps locale selection predictable while allowing the language selector and translated route titles to use the same locale set.
References: frontend/…/useUISettings.ts• L9-25 frontend/…/useUISettings.ts• L132-229 frontend/…/useUserLocalStorage.ts• L10-52 frontend/…/language.ts• L4-59 frontend/…/index.ts• L27-63
Playback and activity state
Playback stores coordinate local player state with server-backed sessions and user activity. The streaming store keeps configuration, per-platform capabilities, joinable sessions, active session actions, heartbeat state, and release outcomes. The native store keeps desktop-shell support, platform probes, launch progress, cancellation, and save-sync results.
The native store treats shell capability as local state. It probes platform support before offering a native launch, keeps launch progress separate from save-sync progress, and reports cancellation separately from a real launch failure. A launch can also carry the play page's core, fullscreen, and disc choices into the desktop shell when that shell supports them.
The playing store tells the shell when a running player owns the viewport. The shell can then hide navigation chrome while keeping global feedback and session behavior available. This separation prevents a canceled native download, a failed stream release, or a failed save push from being mistaken for another outcome.
The soundtrack store keeps the global music player independent from the route that started it. It can drive a browser audio sink or another playback engine, preserve a shuffled playlist as more tracks arrive, restore position after reload, and keep volume and mute state per user. Artwork selection prefers disc art for CD systems, ignores browser-inaccessible local media, and falls back through the normal cover chain.
References: frontend/…/playing.ts• L3-18 frontend/…/streaming.ts• L39-120 frontend/…/streaming.ts• L206-305 frontend/…/streaming.ts• L318-451 frontend/…/streaming.ts• L96-194 frontend/…/streaming.ts• L276-345 frontend/…/native.ts• L50-155 frontend/…/native.ts• L160-240 frontend/…/native.ts• L268-377 frontend/…/soundtrackPlayer.ts• L9-69 frontend/…/soundtrackPlayer.ts• L88-107 frontend/…/soundtrackPlayer.ts• L109-214 frontend/…/soundtrackPlayer.ts• L245-329 frontend/…/soundtrackPlayer.test.ts• L15-97 frontend/…/soundtrackPlayer.test.ts• L99-185
Work and notification state
Format conversions, notifications, and pending assets represent work that can outlive the view that started it. Conversion records keep delayed downloads visible until the server serves the requested format. The notification inbox merges API results with live changes and applies read or dismiss actions optimistically. Pending assets persist unsent player progress until a later sync pass can settle it.
Each state model protects against a different kind of stale result. Conversion identity prevents duplicate visible work. Notification generations prevent a previous account's response from replacing the current list. Pending asset ownership prevents one signed-in account from uploading another account's browser data.
References: frontend/…/formatConversions.ts• L1-25 frontend/…/notificationInbox.ts• L24-155 frontend/…/pending-asset.ts• L116-193 frontend/…/pending-asset.ts• L317-345
Change checklist
When these files or sections are changed, remember to consider these:
- When a route changes, keep its stable name, registered view, layout, title key, access rule, and direct-link hydration aligned.
- When a layout changes, preserve the route outlet, responsive navigation, scroll owner, overlay behavior, and root-level lifecycle hooks.
- When primary navigation changes, keep destination order, path matching, labels, icons, accessibility labels, desktop navigation, mobile navigation, user-menu placement, and gamepad cycling aligned.
- When a collapsing page title changes, keep heading visibility, translated or fetched title updates, active-page ownership, and cleanup aligned.
- When gallery URL state changes, keep query names, filter types, logic operators, platform ID resolution, debounce behavior, and history semantics aligned with the filter store.
- When a shared API request changes, keep query serialization, cache keys, CSRF handling, cancellation, reachability signals, and store reconciliation aligned.
- When ROM gallery reads change, keep metadata sidecar choices, ordered ID windows, result identity, visible positions, and whole-result selection aligned.
- When ROM upload targets change, keep platform uploads, ROM-folder uploads, overwrite behavior, filename encoding, chunk progress, and completion handling aligned.
- When save, state, or snapshot flows change, keep capture names, channel bases, manifest parts, device identity, conflict handling, and unload-size limits aligned.
- When a user account request changes, keep current-user hydration, profile settings, administration actions, and account-linked refreshes aligned with the shared user service.
- When a socket event changes, update both its shell-level subscription and the store or detail-refresh path that reconciles the event.
- When scan events change, keep live batching, task-status reconciliation, scan ownership, final platform refreshes, and collection refreshes aligned.
- When effective permissions change, keep backend grants, permission-change events,
useCan, hidden items, route scopes, and visible actions consistent. - When play capability rules change, keep ROM-level browser support, platform-level badges, streaming labels, native support, file presence, engine choice, launch, save-sync, and release outcomes separate.
- When streaming claim or release behavior changes, keep container and claim identity, memory-card decisions, heartbeat status, save results, and unload recovery aligned across the API service and store.
- When streaming configuration or joinable-session behavior changes, keep config readiness, per-platform capability labels, freshness, failed-refresh behavior, and session ownership aligned with the player and gallery.
- When pending saves or states change, keep account ownership, held snapshot bases, capture order, retry rules, browser-lock behavior, and user notices aligned.
- When gallery filters, URL state, sort, or window loading changes, keep the store model, server query, visible positions, cancellation, and scroll restoration in agreement.
- When gallery virtual rows or result transitions change, keep position keys, letter anchors, visible-card identity, reduced-motion behavior, and stale-result protection aligned.
- When gallery scroll restoration changes, keep route keys, save timing, row-height readiness, and back-to-top focus handoff aligned.
- When a shared component or composable changes, keep its responsive, keyboard, focus, lifecycle, and feature-consumer contracts aligned.
- When motion or gamepad behavior changes, keep reduced-motion settings, player input ownership, overlay input, polling cadence, and browser resource cleanup aligned.
- When UI settings or locale matching changes, keep per-user storage, account sync, locale folders, display names, browser fallback, and initial locale loading aligned.
- When platform icon loading changes, keep slug normalization, shipped asset lookup, image validation, cache invalidation, and fallback rendering aligned.
- When save/state tabs change, keep displayed counts, emulator compatibility, disabled reasons, and translated labels aligned.
- When soundtrack playback changes, keep session restore, shuffle preservation, per-user volume, sink state, artwork priority, and stale time updates aligned.
- When notification or conversion state changes, keep request identity, optimistic updates, stale-response protection, and terminal cleanup consistent.
- When heartbeat or server capability handling changes, keep health status, loaded state, router readiness, offline messaging, and feature gates consistent.
- When socket transport handling changes, keep degraded transport state, upgrade detection, retry behavior, and backend reachability messaging separate.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A registered route has no view or layout entry | A valid URL shows the not-found view or an empty outlet. | Keep route names, routeComponents, and routeLayouts aligned. |
| Initial data or locale messages are not ready before navigation | Route guards or document titles use incomplete state. | Keep initial data and localesReady in the bootstrap gate. |
| A stale lazy-loaded chunk is not recovered | An old tab can become blank after deployment. | Use one guarded reload for chunk-load errors. |
| A protected route has no matching scope rule | A valid page is hidden or an unsafe page is reachable. | Align route scopes with backend access and in-page permission checks. |
| Direct navigation skips shared store hydration | Names, icons, favorite state, or play controls appear incomplete. | Hydrate collections, platforms, icons, and streaming settings at shell level. |
| Desktop and mobile navigation define different destinations or path rules | The active tab or gamepad target disagrees with the visible navigation. | Use the shared destination model for both surfaces and derive activity from the path. |
| A gallery URL uses an unknown filter value or a platform that has not loaded | A bookmark silently loses part of the user's filter. | Validate query values, wait for platform hydration, and do not apply partial platform matches. |
| An outgoing page clears a shared collapsing title after a new page owns it | The navigation bar loses the incoming page's title. | Track the active title owner and clear only from that owner. |
| A saved gallery position is restored before rows have usable height | The user lands at the wrong place or the browser's restore is lost. | Save by full route and apply the position after gallery content has loaded. |
| A socket listener outlives its owner | Old route or account state continues to change. | Scope subscriptions and reconnect the user socket after logout. |
| A user action bypasses current-user state reconciliation | The visible account or access state differs from the server after a profile or administration change. | Use the shared user service and refresh the owning store from the returned user. |
| A scan tab misses live events and does not read task status | It shows an idle scan while the backend is still working. | Reconcile eligible users with the running task and preserve terminal-event precedence. |
| A gallery context changes while a window request or frame-batched apply is active | Old or partial results can overwrite the current gallery or strand visible skeletons. | Abort old work, compare request identity, and mark a window loaded only after its current apply completes. |
| A gallery bootstrap skips sidecars but the response is applied as if they were present | Letter navigation, filter values, or whole-result selection loses its metadata. | Keep sidecar flags and metadata application rules paired. |
| A gallery refresh is replaced by a newer refresh | A late response can restore an older filter result. | Use refresh identity and commit the result only while it is current. |
| A gallery window uses a stale offset after the ordered result changes | A ROM appears in the wrong position or the wrong card remains visible. | Tie window data to the current result request and use the current ordered ID index when available. |
| A permission refresh fails but old grants remain | The UI exposes actions that may no longer be allowed. | Reset grants on failed hydration; let the backend enforce writes. |
| A platform badge uses rules different from the ROM play button | Users see a platform as playable when no game can start in the shown mode, or the reverse. | Resolve browser, stream, and native support from the shared capability sources. |
| A play target has no file on disk or lacks its required bundle or folder form | The UI offers a player that cannot boot the selected ROM. | Require file presence and apply the engine-specific checks in useCanPlay. |
| A streaming config reply from an old account lands after logout | The next account can see the wrong containers or streaming controls. | Invalidate the config generation on reset and wait for configLoaded. |
| A joinable-session refresh fails and clears the last known list | Valid Join actions disappear across the gallery during a short outage. | Keep the last list and remove a session only after a definite stale result. |
| A claim is released without its container and claim identity | A replaced or taken-over tab can end the current holder's session. | Send the claim identity on session actions and use keepalive on page exit. |
| Streaming release or reconnect interrupts active play | Save, release, or presence work can be cut off. | Keep session state until release is confirmed and defer recovery during play. |
| A heartbeat network error is treated as a definite session end | A temporary outage tears down an active player. | Treat unknown status as neutral and end play only on a definite ended result. |
| A live backend 4xx response is treated as offline | Authentication or validation errors show the wrong outage state. | Treat responses below 500 as connected and use loaded to distinguish defaults from server data. |
| A pending-asset drain runs after its shell is gone | A delayed retry can keep using stale route or account state. | Cancel or stop retry scheduling on scope disposal and check disposal before arming another pass. |
| Pending browser assets are drained under the wrong account | One user's offline progress can reach another user's account. | Stamp rows with the account ID, check it before each push, and stop when the signed-in user changes. |
| Browser storage is unavailable during a capture | The player treats a storage limitation as a gameplay failure or claims that progress was queued. | Make storage best effort and report whether the capture was kept. |
| A snapshot push is rebuilt on the wrong channel base or in the wrong order | Offline saves or states can overwrite the wrong history or leave the channel current state stale. | Store the held base with each capture and push one game's captures oldest first. |
| A save conflict is treated as an ordinary retry | Newer progress can be overwritten or the last capture can be lost. | Archive the conflicting capture and report the separate result. |
| A state retry changes its capture-time name | The same state can be stored as duplicate assets instead of settling the held capture. | Rebuild state and screenshot files from the saved capture time. |
| A keepalive capture exceeds the browser body limit | Save or snapshot work is not sent after page exit. | Reject oversized unload work and leave normal upload or pending-asset recovery to settle it. |
| A notification fetch replaces live changes that arrived during the request | A pushed, read, or dismissed notification reappears or disappears. | Replay pending changes onto the fetched result. |
| Gamepad translation remains active while the player owns input | A controller button can navigate the app or close the running game. | Suppress app actions during play and use the held exit chord for player exit. |
| Gamepad polling assumes a connection event or continues after the last pad leaves | Controller support is missing in some webviews or consumes needless frame work. | Poll only while a usable pad exists and use connection events plus periodic idle probes. |
| A result transition runs under reduced motion or while an overlay is open | The UI animates over a user-controlled surface or ignores an accessibility choice. | Fall back to a direct swap and end active result animation when an escapable overlay opens. |
| A hover video or cover animation ignores motion settings | Reduced-motion users still receive motion or media work continues after a view ends. | Gate motion by both user and system settings and release media on leave or unmount. |
| A platform icon cache accepts an HTML fallback as an image | A broken cached URL hides a valid platform icon. | Cache only image blobs and invalidate failed cached entries. |
| A state for another emulator remains enabled | The player tries to load an incompatible state. | Keep incompatible states visible for count context but disable them with a reason. |
| Settings hydrate into the active account while a save watcher is running | One user's preferences can be written to another user's profile. | Scope storage by account and suppress writes during hydration. |
| A soundtrack time update from an old track lands after a new track starts | The player seeks the new track to an old position. | Epoch time reports on play and stop and ignore queued reports from older epochs. |
| A socket upgrade failure is treated as total backend loss | The UI reports the server offline even though the socket still works over polling. | Track transport degradation separately and clear it when the engine upgrades. |
Key files
| File | Why to read it |
|---|---|
| frontend/…/main.ts | Shows application startup, initial data, locale gating, and stale asset recovery. |
| frontend/…/RomM.vue | Shows the document-level application shell. |
| frontend/…/routes.ts | Shows the route-to-view and route-to-layout registry. |
| frontend/…/router.ts | Shows guards, titles, deferred loading, and route-entry refresh. |
| frontend/…/AppLayout.vue | Shows the main shell and cross-route behavior. |
| frontend/…/AuthLayout.vue | Shows the authentication and setup shell. |
| frontend/…/SettingsLayout.vue | Shows settings navigation and route-driven panel modes. |
| frontend/…/AppNav.vue | Shows primary content navigation, utility indicators, responsive placement, and user-menu separation for library tools. |
| frontend/…/index.ts | Shows the shared primary navigation model and path-based active state. |
| frontend/…/index.ts | Shows shared collapsing page-title state and lifecycle ownership. |
| frontend/…/index.ts | Shows bookmarkable gallery filter state and the URL/store contract. |
| frontend/…/GalleryShell.vue | Shows the shared gallery structure, visible-window loading, scroll restoration, and selection behavior. |
| frontend/…/BackToTopButton.vue | Shows the gallery scroll-to-top and keyboard or gamepad focus handoff. |
| frontend/…/index.ts | Shows the shared HTTP, CSRF, cancellation, and reachability boundary. |
| frontend/…/rom.ts | Shows library reads, ordered gallery windows, metadata lookups, uploads, downloads, and ROM actions. |
| frontend/…/save.ts | Shows save naming, slot behavior, conflict inputs, and unload-safe capture. |
| frontend/…/state.ts | Shows state naming and state-plus-screenshot upload actions. |
| frontend/…/snapshot.ts | Shows channel history and manifest-based save/state pushes. |
| frontend/…/user.ts | Shows the account and current-user request boundary used by auth, profile, and administration flows. |
| frontend/…/streaming.ts | Shows streaming claims, joins, session control, generated contracts, and unload-safe requests. |
| frontend/…/socket.ts | Shows the shared realtime connection boundary. |
| frontend/…/pending-asset.ts | Shows account-scoped offline save and state handoff. |
| frontend/…/index.ts | Shows shell-level retry, account-safe drain, and user feedback for pending assets. |
| frontend/…/index.ts | Shows the shared ROM action and play-target contract. |
| frontend/…/index.ts | Shows the shared rules for browser, stream, and native play targets. |
| frontend/…/index.ts | Shows save/state counts and emulator compatibility rules. |
| frontend/…/index.ts | Shows the shared stream-join confirmation and navigation contract. |
| frontend/…/index.ts | Shows scan events, task reconciliation, batching, and library refresh. |
| frontend/…/index.ts | Shows reachability detection and safe reconnect recovery. |
| frontend/…/index.ts | Shows degraded socket transport detection and retry. |
| frontend/…/heartbeat.ts | Shows backend health, capability flags, and metadata source availability. |
| frontend/…/roms.ts | Shows detailed ROM cache and home-row state. |
| frontend/…/galleryRoms.ts | Shows metadata bootstrap, windowed gallery state, ordered result reads, refresh, and server query coordination. |
| frontend/…/gallerySelection.ts | Shows gallery selection and bulk-action state. |
| frontend/…/scrollRestoration.ts | Shows route-keyed gallery scroll positions. |
| frontend/…/collections.ts | Shows regular, virtual, and smart collection state and refresh rules. |
| frontend/…/platforms.ts | Shows library and filesystem platform state used by browsing and scans. |
| frontend/…/permissions.ts | Shows effective grants and hidden-item state. |
| frontend/…/language.ts | Shows the supported locale list and browser preference matching. |
| frontend/…/useUISettings.ts | Shows account-scoped UI preferences and server synchronization. |
| frontend/…/RelatedGameCard.vue | Shows how related metadata links resolve to owned local games or external games. |
| frontend/…/index.ts | Shows the shared platform-level browser, streaming, and native play capability model. |
| frontend/…/index.ts | Shows the gallery's structural virtual rows and letter navigation model. |
| frontend/…/index.ts | Shows safe animation around visible gallery result swaps. |
| frontend/…/index.ts | Shows shared-element navigation and graceful transition fallback. |
| frontend/…/index.ts | Shows shared cover motion and hover-media behavior. |
| frontend/…/index.ts | Shows the public shared primitive library. |
| frontend/…/index.ts | Shows the shared accessibility preference for CSS and script-driven motion. |