Introducing a new way to review your PRs.

Read the announcement

4gray / iptvnator

:tv: Cross-platform IPTV player application with multiple features, such as support of m3u and m3u8 playlists, favorites, TV guide, TV archive/catchup and more.

View on GitHub

26 documents · Updated Nov 23, 2026

docs / application-foundations

Application foundations

IPTVnator's application foundations give every product flow a common way to hold state, save user data, use host services, report health, and present shared interactions. They support Electron, the PWA, self-hosted storage, and shared viewing activity without making each feature manage the differences. Shared state, services, and data covers the data path in more detail. Settings and parental controls covers user choices and protection rules. Playlist management and client applications show how product flows use these foundations.

System boundaries

Shared application flow

The shared foundation turns a user action into state changes, service work, and a result that the UI can use. A feature changes shared state, a service selects the available data path, and a typed boundary carries data, progress, or failure back to the feature.

The main relationship is:

flowchart LR
    UI[Feature and shared UI] --> State[Shared state]
    State --> Services[Application services]
    Services --> Contracts[Runtime contracts]
    Contracts --> Runtime[Desktop, PWA, or server runtime]
    Runtime --> Data[Local or server data]
    Runtime --> Sources[Provider sources]
    Data --> Signals[Events and diagnostics]
    Sources --> Signals
    Signals --> UI

References: libs/…/data.service.ts• L37-79 libs/…/runtime-capabilities.service.ts• L24-42 libs/…/database-electron.service.ts• L119-137

Runtime capability model

The application treats Electron and the PWA as different runtime environments. Services check a complete capability group before they offer a feature. This lets a browser or an older desktop bridge omit a feature without leaving a half-working action in the UI.

Capability groups cover the main shared services:

  • playlist and application data
  • favorites and user activity
  • provider and XMLTV EPG
  • playback positions, downloads, and recordings
  • playlist refresh and source health checks
  • players, remote control, and desktop window actions
  • parental filtering

The groups are separate when their user value differs. For example, provider EPG can work in the PWA even when local XMLTV import is not available. Ordinary playback position storage also stays usable when atomic backup replacement is not available.

References: libs/…/runtime-capabilities.service.ts• L24-42 libs/…/runtime-capabilities.service.ts• L88-125 libs/…/runtime-capabilities.service.ts• L193-220 libs/…/runtime-capabilities.service.ts• L223-274 libs/…/runtime-capabilities.service.ts• L343-385

Workspace shell coordination

The workspace shell gives product pages one route and action context. It resolves the active playlist and section, builds navigation for the current provider, exposes shared search and collection actions, and places import or refresh progress in the right workspace surface.

Search uses the active scope. Settings search filters settings, playlist search uses the active provider, and global search is available only when the runtime and imported sources support it. Progress and cancellation also follow the capabilities of the current runtime.

References: libs/…/workspace-shell-route-state.service.ts• L45-145 libs/…/workspace-shell-search.service.ts• L41-176 libs/…/workspace-shell-xtream-import.service.ts• L35-103 libs/…/workspace-shell.facade.ts• L74-157

Shared state and persistence

Product state

Shared product state represents the current viewing context. It gives screens one view of the active source, content, filters, favorites, recent items, EPG context, and loading state. Effects and services connect those changes to persistence, navigation, source work, playback, and notices.

The state is temporary by design. Durable services keep user data across restarts, while the state layer keeps the current screen coherent during imports, refreshes, failures, and source changes.

References: libs/…/state.ts• L6-25 libs/…/actions.ts• L10-100 libs/…/effects.ts• L182-271

Viewing history

Viewing history gives each source a stable recent-items list even when provider ids repeat across content types. M3U items use their stream URL as identity, while portal items use a normalized item identity together with compatible content kind and series mode.

When a user views an item again, the service moves it to the top and keeps useful fields from the earlier row. This avoids duplicate recent entries and prevents a live channel, movie, or series with a reused provider id from replacing the wrong item.

References: libs/…/playlist-history.ts• L15-70 libs/…/playlist-history.ts• L74-141 libs/…/playlist-history.spec.ts• L27-145 libs/…/playlists.service.spec.ts• L2054-2202

Shared viewing activity

Shared viewing activity extends playback state across devices that use the same verified source server. It keeps a local projection and a durable pending queue first, then sends explicit playback starts, progress checkpoints, watched marks, resets, and imports to the server when consent and connectivity allow it.

The activity address includes the server instance, source incarnation, provider, and content identity. This prevents activity from crossing to a different server or to a replacement source that reused an id. A conflict remains visible until the user chooses the local or server state. New explicit actions supersede older launches and late player callbacks.

Activity uses provider identity rather than only display or catalog ids. Xtream episodes include their series identity. Stalker episodes include their mode and season identity. This allows different local catalog ids to refer to the same shared item without merging unrelated episodes.

References: libs/…/activity-sync-client.ts• L71-103 libs/…/activity-sync-client.ts• L148-190 libs/…/activity-sync-sessions.ts• L21-143 libs/…/activity-sync-resolution.ts• L18-211 libs/…/activity-action-fence.ts• L11-79 libs/…/activity-sync.contract.ts• L1-107

Favorite continuity

Favorites are user-owned membership data that can exist in a local playlist view and in a shared server view. The favorite service keeps a local record of the latest known server state, the current local view, and any changes that still need delivery.

The flow protects user intent across devices and runtimes:

  1. A toggle or reorder updates local state first.
  2. The change is queued with a source identity and an expected revision.
  3. Delivery sends the queued intent when consent, profile, and source identity still match.
  4. The server returns an applied result or a conflict for user resolution.
  5. A refresh accepts newer server state without discarding newer local work.

Electron stores these records through the native local boundary. The PWA uses a separate browser store. Source incarnations prevent a replacement source with the same id from receiving old favorite changes. Retiring a source removes its cached favorite context before a replacement can accept local sidecar edits, records a retirement marker, and notifies other browser contexts. When history consent is active, the same retirement also advances the source epoch and removes the old history context. A profile or consent change supersedes in-flight work rather than authorizing it under a new account.

References: libs/…/favorites-events.ts• L3-42 libs/…/favorites-sync-client.ts• L41-77 libs/…/favorites-sync-client.ts• L154-250 libs/…/favorites-sync-delivery.ts• L19-90 libs/…/favorites-context-owner.ts• L4-19 libs/…/favorites-source-contexts.ts• L46-113 libs/…/electron-favorites-local.ts• L9-59 libs/…/indexeddb-favorites-local.ts• L13-43

User settings

Settings form a shared boundary for choices that affect many flows. They include player, language, theme, startup, EPG, dashboard, downloads, recording, remote control, metadata, trailer, and parental-lock choices. The settings store loads defaults, normalizes saved data, and reports storage failures instead of showing an unconfirmed durable change.

Several settings use an explicit opt-out rule. A missing or invalid value keeps the feature on, while only the boolean value false turns it off. This keeps older saved settings aligned with current defaults and prevents malformed data from disabling a feature by accident. Dashboard rail choices are also filled from the current enabled defaults when older saved data is partial. The store saves a complete normalized snapshot, preserves unrelated choices, and keeps the TMDB key update tied to the storage commit, including changes received from another browser context.

EPG settings have two related responsibilities. The committed global XMLTV source list is saved before native source cleanup runs, while local playlist sources remain available when they are still needed by a playlist. URL values are normalized before comparison, and a failed cleanup remains retryable without replacing the settings that were saved successfully. Changes in progress are fenced so an older native acknowledgement cannot replace a newer committed EPG choice.

Settings stay separate from playlist and catalog data. A settings reset or storage problem can therefore avoid changing the source records used by product pages.

Browser settings writes read the current stored record in the same transaction as the update. This preserves unrelated changes, protects a saved TMDB key during ordinary updates, and applies a transferred key only when its expected value and current session still match. A failed write leaves the last committed settings as the durable truth, while a later successful write can clear the reported storage failure.

References: libs/…/settings-store.service.ts• L45-212 libs/…/settings-store.defaults.ts• L24-75 libs/…/settings-store.defaults.ts• L77-208 libs/…/settings-opt-out.util.ts• L5-47 libs/…/settings-storage.ts• L9-89 libs/…/epg-source-settings.service.ts• L27-46 libs/…/epg-source-settings.service.ts• L49-180 libs/…/settings.interface.ts• L133-337 libs/…/settings-store.service.spec.ts• L34-129 libs/…/settings-store.service.spec.ts• L449-579

Embedded player selection

Embedded MPV selection is checked against the current desktop host when settings load. A supported host keeps the choice and prepares the player when the runtime is idle. An unsupported or failed check returns to the default player, while an inconclusive check keeps the saved choice until a later answer is final. A newer player choice cancels the old verdict.

References: libs/…/settings-store.embedded-mpv.ts• L5-89 libs/…/settings-store.service.ts• L294-305 libs/…/settings-store.embedded-mpv.spec.ts• L83-210

Parental lock

The parental lock is a shared content gate for protected categories and groups. It keeps protection policy separate from ordinary settings and gives catalog surfaces one service to ask whether content is safe to show.

Desktop filtering sends the lock state to the local data worker. Browser filtering applies the same rule in the renderer. If the lock state or a required filter cannot be trusted, the system withholds protected content.

References: libs/…/parental-lock.service.ts• L40-59 libs/…/parental-lock.service.ts• L213-353 libs/…/runtime-capabilities.service.ts• L223-233

Persistence continuity

Persistence keeps source records and user activity available across reloads, refreshes, runtime changes, and device changes. Electron uses its local database path, browser-only use uses browser storage where needed, and self-hosted mode exposes the same playlist and activity shapes through server contracts.

Playlist refresh replaces source-owned data while preserving user-owned choices such as favorites, recent items, ordering, hidden groups, selected EPG sources, and the current auto-refresh choice. Writes for one playlist are ordered so a refresh, edit, delete, or favorite change cannot restore an older snapshot. A refresh or startup update also stops when the source row no longer exists, so a removed source is not recreated by a late result.

Shared viewing activity uses the same local-first rule. The local projection and pending operation are saved together. Delivery can pause for offline state or changed consent and can resume later without silently moving the operation to a new consent scope. Native playback checkpoints carry capture time so an older web callback cannot replace newer native progress. Reset barriers remain durable even when the visible resume value is empty.

The playlist service also keeps the old favorite projection and the new favorite synchronization record in step. This allows explicit favorite actions to update the product view and the durable sync intent as one logical change. Playlist deletion completes its row removal before related cleanup reports warnings, so cleanup failure does not bring the source back.

References: libs/…/playlist-storage-backend.ts• L5-48 libs/…/playlists.service.ts• L97-117 libs/…/playlists.service.ts• L433-483 libs/…/playlists.service.ts• L618-697 libs/…/playlists.service.ts• L699-743 libs/…/playlists.service.ts• L1074-1109 libs/…/playlist-refresh-merge.ts• L15-85 libs/…/activity-sync-client.ts• L201-222 libs/…/activity-sync-sessions.ts• L145-336 libs/…/activity-action-fence.ts• L35-79 libs/…/playlists.service.spec.ts• L2204-2297

Backup continuity

Backups move playlists together with user-owned state. Export reads authoritative collections before it writes them to the archive. Restore identifies an existing source, merges or creates the playlist, then applies the stored activity and protection state.

An unavailable or unreadable collection is not treated as an empty collection when that would erase trusted data. PWA restore writes favorites, recent items, and playback positions as separate durable steps. Receipts record the restore target so a retry skips completed lists, keeps later user edits, and waits for server confirmation before it clears the pending target. Browser and desktop restore use the storage path available in the current runtime.

On Android-style hosts, a successful replacement also records a native playback reset. The reset is written with the playback list, so a failed list write cannot make the native host discard a newer checkpoint.

Backup-level EPG sources merge into the current global source list instead of replacing it. Remote URLs use normalized URL identity, while local path references keep their path spelling and case. This lets a restore remove duplicate remote entries without treating distinct local references as the same source.

References: libs/…/playlist-backup.service.ts• L106-158 libs/…/playlist-backup.service.ts• L174-315 libs/…/playlist-backup.service.ts• L491-560 libs/…/playlist-backup.service.ts• L1115-1215 libs/…/playlist-backup-epg.ts• L1-24 libs/…/pwa-xtream-backup-storage.ts• L37-69 libs/…/pwa-xtream-backup-storage.ts• L141-249 libs/…/pwa-xtream-restore-progress.ts• L24-123 libs/…/pwa-native-playback-resets.ts• L13-54

Interfaces and services

Cross-runtime interface

The shared interface layer defines the data shapes and event meanings that cross the renderer, Electron preload, main process, and server-backed browser services. It covers portal calls, database work, playback, downloads, recordings, EPG, source probes, settings, window actions, progress, update state, and shared viewing activity.

These contracts carry normal results and expected failures in a form that each host can understand. Activity requests expose only portable content identity and safe display metadata. A feature can therefore classify cancellation, authorization refusal, player failure, unavailable storage, and activity conflict without parsing host-specific errors or sending provider credentials through the activity path.

The public interface entry point also exposes shared playback timing, autoplay, source presentation, and source-family rules. These utilities keep host and feature code on the same product behavior instead of allowing each client to choose its own timing or provider label.

References: libs/…/electron-api.interface.ts• L330-373 libs/…/electron-api.interface.ts• L722-828 libs/…/electron-api.interface.ts• L975-1015 libs/…/activity-sync.wire.ts• L13-39 libs/…/activity-sync.wire.ts• L41-139 libs/…/autoplay-streak.util.ts• L14-61 libs/…/up-next-timing.util.ts• L31-114 libs/…/source-type-icons.util.ts• L16-102 libs/…/index.ts• L14-17 libs/…/index.ts• L56-62 libs/…/portal-request-failure.util.ts• L17-35 libs/…/server-storage.contract.ts• L24-54

Application services

The services library coordinates work shared by more than one screen. It hides whether data comes from a local database, browser storage, server storage, a portal request, or an in-memory view. It also defines whether a result is safe to use as an authoritative answer.

This distinction protects user data. A best-effort read may report that a feature is unavailable, but a backup replacement must fail before it changes data when the required storage path is absent. The same rule applies to shared activity: local state may remain usable while delivery is offline, but server state is not presented as current until the server accepts it.

References: libs/…/index.ts• L1-35 libs/…/playlist-storage-backend.ts• L33-48 libs/…/database-electron.service.ts• L157-259 libs/…/activity-sync-client.ts• L224-273 libs/…/playback-position-runtime-bridge.service.ts• L180-212

Self-hosted source synchronization

Self-hosted source synchronization keeps a user's provider source list consistent between a local client and a server. The server owns source definitions and revisions. The client projects those definitions into local playlist records while keeping device-owned activity and display choices local. The same boundary also carries shared history, favorites, activity, and TMDB transfer requests when the server supports them.

The browser can remember a server address in persistent storage and keep its access token in tab storage. It verifies the server instance before it reuses that token. A known server remains the selected data source during an outage, while a new or pending server selection cannot overwrite a newer connect or disconnect action.

The synchronization flow is:

sequenceDiagram
    participant Client
    participant Guard as Instance and access guard
    participant Server
    participant Local as Local playlist store
    Client->>Guard: Verify server instance
    Guard->>Server: Request instance identity
    Server-->>Guard: Identity and access result
    Guard-->>Client: Allow or refuse source calls
    Client->>Server: Read source inventory
    Server-->>Client: Sources and revision
    Client->>Local: Project source definitions
    Client->>Server: Create, update, or delete with revision
    Server-->>Client: Accepted source and new revision
    Client->>Local: Merge source data with local activity

The client serializes refresh and mutations, uses revision checks for conflicts, and prunes local rows only when the observed revision still matches. It verifies the server instance before sending requests that may carry provider credentials. A transport failure, server failure, or instance replacement revokes the saved proof so later protected requests cannot reuse it. Connection state distinguishes local, connecting, connected, offline, locked, and conflict conditions. A completed local cache stays readable while the server is offline, but writes wait for a connected state.

References: libs/…/source-api.ts• L16-64 libs/…/source-api.ts• L67-215 libs/…/source-browser-settings.ts• L25-174 libs/…/source-connection.ts• L30-151 libs/…/source-authorization.ts• L15-71 libs/…/source-sync.service.ts• L77-155 libs/…/source-sync.service.ts• L157-365 libs/…/synced-playlist-store.ts• L29-103 libs/…/synced-playlist-store.ts• L131-289

Portal status

Portal status gives shared screens a short-lived view of provider health and account state. It normalizes connection identity, shares equivalent checks, joins concurrent passive checks, and keeps account evidence separate from transport health.

An account refusal can indicate an inactive account. A host guard failure means the source could not be checked. Explicit connection tests can replace old passive evidence, while stale passive checks cannot overwrite newer evidence.

References: libs/…/portal-status.service.ts• L16-29 libs/…/portal-status.service.ts• L65-189 libs/…/portal-status.service.ts• L229-283

Clipboard interaction

Clipboard copying gives shared actions one browser-safe result. It uses the normal clipboard path first and keeps the action working when a desktop dialog, menu, or delayed callback has briefly lost document focus. It restores the prior focus after the fallback and reports failure only when both paths fail.

References: libs/…/clipboard-copy.util.ts• L1-49 libs/…/clipboard-copy.util.spec.ts• L1-120

Data infrastructure

Local data model

The shared database is the durable local record of source content and user activity. It relates playlists to categories and content, then relates that content to favorites, recent views, playback positions, EPG data, downloads, recordings, source pins, metadata cache entries, and additive shared-activity records.

Playlist records keep the complete product document while also exposing fields needed for list views. The desktop worker and self-hosted store use the same document shape. Downloads and recordings remain local-owned records so they can outlive a source playlist when their files or history still matter. Shared activity keeps its own state and pending operations so it does not need to rewrite legacy playback rows.

References: libs/…/schema.ts• L25-65 libs/…/schema.ts• L67-195 libs/…/schema.ts• L271-315 libs/…/schema.ts• L346-429 libs/…/activity-sqlite-server.ts• L15-95 libs/…/README.md• L44-58 libs/…/app-playlist-codec.ts• L1-15 libs/…/app-playlist-codec.ts• L104-175

Catalog title search gives global content search a fast way to find title fragments across a large imported catalog. The index follows content changes and supports normalized matching so equivalent titles with diacritics remain discoverable when the SQLite runtime supports that feature.

Large catalogs keep the current search index usable while a replacement index is built in the background. Small catalogs can rebuild during startup. A failed or interrupted build does not replace the working index, and a later run can continue the pending build.

References: libs/…/content-title-fts.ts• L18-75 libs/…/content-title-fts.ts• L192-273 libs/…/content-title-fts.ts• L277-356 libs/…/connection.ts• L981-1017

Data migration continuity

Database startup treats schema change as part of opening the application. It creates missing structures, applies ordered upgrades, repairs known old data shapes, and records one-time work only after it succeeds. A failed open or half-open handle is forgotten and closed, so the next startup can retry rather than keep a broken initialization promise. This lets users skip releases without resetting their local library.

Migration order protects dependencies between old columns, indexes, triggers, and data repairs. The title search upgrade can stay deferred for a large catalog, while its worker fills and swaps a complete replacement. A startup override can force the rebuild when needed, but the normal path avoids making catalog size turn database opening into a long blocking task.

Playlist migration also keeps the storage backend transition safe. Existing browser playlists can move to the desktop store, and server-backed rows can be updated without replacing a newer copy. Shared activity uses additive tables and does not migrate or upload legacy playback rows during database initialization.

References: libs/…/README.md• L24-37 libs/…/README.md• L44-58 libs/…/README.md• L99-119 libs/…/connection.ts• L998-1017 libs/…/connection.ts• L1026-1101 libs/…/content-title-fts.ts• L192-273 libs/…/content-title-fts.ts• L284-356 libs/…/connection-init-failure.spec.ts• L54-123 libs/…/connection-retry.spec.ts• L8-113 libs/…/connection-upgrade-0-17.spec.ts• L90-118 libs/…/playlists-table.ts• L82-169 libs/…/playlists.service.ts• L140-173 libs/…/playlists.service.ts• L294-339

Safety and observability

Host health checks

The host connectivity guard protects portal flows from repeated waits on a provider that does not answer. It records host-level failures, fast-fails later requests for a short period, and permits a trial request to decide whether the host recovered.

Explicit connection tests reset old evidence before each candidate address. They use an HTTP fallback only after a certified HTTPS connection failure, explicit user permission, and no response or account evidence. Credentials stay on HTTPS by default.

References: libs/…/host-connectivity-guard.ts• L7-32 libs/…/host-connectivity-guard.ts• L155-178 libs/…/host-connectivity-guard.ts• L202-376 libs/…/xtream-connection-test.service.ts• L28-135

Source health classification

Source health turns account replies, probe results, and transport failures into one result for source and playlist views. It separates active, inactive, expired, checking, and unavailable states from reasons such as authentication, timeout, network, paused, invalid, and cancelled.

The classification keeps expiry information and does not treat a timeout as proof that an account is inactive. Probe deadlines and cancellation remain local to the request.

References: libs/…/source-health.ts• L5-24 libs/…/source-health.ts• L41-118 libs/…/source-health-evidence.service.ts• L10-41

Sensitive data protection

Shared logging keeps diagnostics useful without exposing provider credentials or private request data. It redacts secrets in keys, URLs, query values, provider paths, nested objects, errors, and free-form diagnostic text.

This boundary matters because credentials can appear in playlist records, request parameters, and error objects. Feature code can use the shared policy instead of adding a weaker local policy.

References: libs/…/redact-sensitive-data.ts• L1-64 libs/…/redact-sensitive-data.ts• L73-112 libs/…/redact-sensitive-data.ts• L130-190 libs/…/redact-sensitive-data.ts• L197-249 libs/…/connection.ts• L58-85

Performance signals

Observability reports long data operations and named performance phases without becoming a product dependency. Operation events identify start, progress, completion, cancellation, and error. Phase signals add timing, item counts, and outcomes when a measurement hook exists.

Instrumentation is fail-neutral. Missing or failing measurement code does not change the user action or turn a successful operation into an error.

References: libs/…/database-electron.service.ts• L119-137 libs/…/database-electron.service.ts• L179-259 libs/…/electron-api.interface.ts• L467-476 libs/…/performance-phase.interface.ts• L1-80

Reusable UI foundations

Shared UI components

Shared UI libraries provide common surfaces for channel and group browsing, EPG, catalog choices, seasons, content details, loading, watched state, confirmations, and desktop controls. Feature pages provide data and actions, while shared components keep interaction rules, accessibility, and layout behavior consistent.

Channel views use one interaction model for all channels, groups, favorites, and recent items. Shared controls keep selection, playback, favorite actions, details, EPG mapping, search, and protected-group behavior aligned across those views.

References: libs/…/index.ts• L1-38 libs/…/index.ts• L45-66 libs/…/channel-list-container.component.ts• L116-216 libs/…/all-channels-view.component.ts• L70-245 libs/…/favorites-view.component.ts• L50-204 libs/…/groups-view.component.ts• L101-210 libs/…/recent-view.component.ts• L52-185

Playback foundation

The playback foundation gives feature pages one host for player choice, source changes, controls, recovery, history, diagnostics, recording, and fullscreen behavior. It presents a common event model for inline engines and the embedded desktop player.

Playback history counts real forward progress. Player ownership checks prevent late events from an old engine or source from changing the current view. Bulk season actions also protect active playback progress from being overwritten by a mark-watched action.

References: libs/…/web-player-view.component.ts• L97-172 libs/…/web-player-view.component.ts• L223-310 libs/…/portal-inline-player.component.html• L1-125 libs/…/playback-diagnostic-panel.component.scss• L16-45 libs/…/season-watch-toggle.util.ts• L8-181

Playback timing rules

Shared playback rules keep episode continuation consistent across desktop, web, and TV clients. The autoplay streak counts only episodes started by autoplay, resets when the viewer chooses an episode, and can stop at a live setting limit so the host can ask whether the viewer is still watching.

The Up next timing rule chooses a closing-credit start when trusted metadata or a suitable chapter provides one. Otherwise it uses an adaptive lead based on episode length, and returns no timing for live or open-ended content.

References: libs/…/autoplay-streak.util.ts• L1-61 libs/…/up-next-timing.util.ts• L1-114 libs/…/index.ts• L14-17 libs/…/autoplay-streak.util.spec.ts• L3-71 libs/…/up-next-timing.util.spec.ts• L17-123

Source identity presentation

Shared source presentation gives each provider family one stable visual and language model. It resolves stored playlists as M3U, Xtream, or Stalker using the same precedence for icons, filters, counts, and labels, so a source does not appear under conflicting provider types in different surfaces.

The add flow can distinguish an M3U URL, local source, and pasted text. Stored playlists use the durable source information available to them, and dialog subtitles combine a safe display name with the translated source type.

References: libs/…/source-type-icons.util.ts• L4-102 libs/…/index.ts• L56-62 libs/…/source-type-icons.util.spec.ts• L9-76

Remote control interface

The remote control is a browser-facing companion surface for live playback. It reads the current channel, programme, source, and volume state from the runtime service, then sends channel and volume actions back through the remote-control interface.

The companion page chooses its language from the phone browser's preferred languages. It falls back to English when no available translation matches.

References: libs/…/remote-control.service.ts• L5-79 libs/…/remote-control.component.html• L1-189 libs/…/remote-control-language.ts• L7-86

Shared visual language

Shared styles define visual rules for portal layouts, content grids, sidebars, detail views, actions, navigation lists, and player controls. They let feature pages present dense catalog and viewing data without repeating layout rules.

Shared dialogs and progress surfaces keep headers, bodies, footers, scrolling, close results, responsive behavior, and cancellation states consistent. Desktop-only window controls appear only when the runtime supports them, while browser use keeps the same content layout without exposing desktop actions.

References: libs/…/_index.scss• L1-13 libs/…/_app-controls.scss• L1-12 libs/…/_nav-list.scss• L7-96 libs/…/dialog-shell.component.ts• L18-83 libs/…/import-progress.component.ts• L11-35 libs/…/window-controls.component.ts• L14-38 libs/…/date-format.util.ts• L1-57

Change checklist

When these files or sections are changed, remember to consider these:

  • A runtime feature must stay aligned across its capability group, typed bridge, transport contract, service fallback, and user-facing availability state.
  • A shared activity change must keep content identity, source incarnation, consent generation, local projection, pending operation, revision or session guard, and conflict resolution aligned across clients and server storage.
  • A playback checkpoint change must keep explicit-action fencing, native capture time, session ownership, sequence order, reset barriers, and delayed callbacks aligned.
  • An activity wire change must preserve the allowlisted identity and metadata boundary. Unknown provider or credential fields must not become shared state.
  • A favorite change must keep the local projection, source incarnation, profile or consent generation, durable pending intent, server revision, and conflict result aligned.
  • A recently viewed change must keep M3U URL identity, portal identity normalization, content kind, series mode, field merging, and sort order aligned.
  • A source replacement or deletion must retire its favorite context before a new source with the same id can accept local sidecar data. The retirement marker and cross-context notification must also remain aligned with history context cleanup.
  • A playlist persistence change must keep the complete document, metadata projection, write ordering, local backend, and server-backed document contract aligned.
  • A playlist refresh or delete change must preserve source-owned versus user-owned data, retain the current auto-refresh choice, and must not let a stale snapshot restore a deleted row.
  • An EPG settings change must keep normalized committed URLs, local playlist ownership, native cleanup, preference enablement, and retry behavior aligned. Persistence must complete before cleanup can change native state.
  • A settings default change must keep the default value, explicit opt-out rule, normalization, complete snapshot, dashboard rail defaults, and older saved records aligned.
  • A settings storage change must keep TMDB key preservation, transfer checks, transaction commit results, cross-tab refresh, and in-memory state aligned with the committed record.
  • A saved embedded player change must keep host support checks, inconclusive results, fallback persistence, idle preparation, and a newer user selection aligned.
  • A backup change must keep authoritative reads distinct from unavailable reads, and must keep restore identity, pending receipts, playback replacement, native reset markers, favorites, parental locks, and merged EPG sources in the same order.
  • A PWA restore change must keep list receipts, explicit user edits, server confirmation, retry scope, cache ownership, and exported pending state aligned.
  • A self-hosted source change must keep instance verification, authorization, revisions, local activity merging, cleanup, and connection state aligned.
  • A source synchronization change must not send provider credentials before the current server instance is verified.
  • A source connection change must keep persistent address state, tab token state, pending discovery, and newer connect or disconnect actions aligned.
  • A source transport change must revoke authorization after an outage or instance replacement while preserving logical revision conflicts as conflicts.
  • A database initialization change must keep table creation, migration order, failed-attempt cleanup, retry behavior, title-index readiness, and performance observation aligned.
  • A content title search change must keep the live index tokenizer, content change triggers, large-catalog build cursor, worker handoff, and atomic index swap aligned.
  • A database operation change must keep operation ids, progress events, cancellation, and failure meaning aligned across the service and host bridge.
  • A logging redaction change must cover nested values, URLs, query values, encoded keys, and new diagnostic shapes.
  • A shared playback timing change must keep autoplay claims, viewer-start resets, usable-duration checks, credit detection, lead caps, and every host's Up next behavior aligned.
  • A source presentation change must keep provider precedence, source-family counts, filters, icons, labels, and add-flow source keys aligned.
  • A shared UI change must keep public exports, runtime visibility, focus behavior, scroll ownership, and the owning feature's event contract aligned.
  • A shared clipboard change must keep the success and failure contract stable for callers and must restore focus after a fallback copy.

Important failure modes

TriggerConsequenceGuard
An activity operation outlives its consent generation or source incarnationPlayback state can be sent under a new consent scope or to a replacement sourcePending activity stores its generation and address context, and delivery checks them before sending.
A late player callback follows a newer explicit action or native checkpointOld progress can replace a reset, new launch, or newer checkpointActivity action fences compare the captured action and checkpoint time before committing.
A shared activity operation is acknowledged twice or its response is lostA restart can duplicate a begin or leave local state out of step with the serverThe server records operation receipts and the client keeps the local operation until it receives an applied result or conflict.
Activity progress conflicts with a newer server ownerAn old player can overwrite current playback or create a misleading conflictFresh checkpoints are retired, while explicit launches can rebase a bounded pending sequence or remain a visible conflict.
Activity identity uses only a provider idA movie, series episode, or Stalker episode can receive another item's activityAddresses include provider-specific content identity and source incarnation.
A favorite intent outlives its profile, consent, or source incarnationA new account or replacement source can receive an old user's changeThe favorite client marks the work superseded and checks the current generation and source context before local write or delivery.
A favorite delivery fails after local acceptanceThe user's choice disappears on restart or reconnectPending operations stay in durable local storage until the server returns an applied result or conflict.
A refresh accepts an older favorite revisionA newer server choice or local pending change is lostRefresh compares revisions and preserves pending work.
A playlist write races with refresh, edit, or deleteA stale snapshot can restore old data or resurrect a deleted playlistPlaylistsService serializes writes per playlist and merges refresh-owned data with current user state.
A late refresh completes after its source was deletedA removed source can return to the libraryRefresh reads the current row inside the write path and refuses to write when the row no longer exists.
A source replacement keeps the old favorite contextFavorites can attach to a new source that reused the same idSource cleanup retires the old context, removes its history context when applicable, and broadcasts the retirement to other browser contexts.
A recently viewed item reuses a provider id across kindsA movie, channel, or series can replace the wrong recent rowPortal history checks normalized identity with compatible kind and series mode.
A required runtime method is missingA feature can present an action that cannot completeRuntimeCapabilitiesService checks complete capability groups before services select them.
An EPG save fails after in-memory state changesThe UI can show a source or enablement choice that is not durableThe settings store reports the save failure and restores the prior committed EPG values before native reconciliation.
EPG cleanup fails after settings persistenceSaved settings can be mistaken for completed native cleanupThe saved URLs remain authoritative, and cleanup can be retried explicitly without rewriting unrelated settings.
An older EPG enable or disable acknowledgement finishes after a newer saveNative EPG state can stop matching the latest committed settingsReconciliation uses revisions and keeps the latest committed source list and enablement state.
A settings record is missing or contains malformed default-on valuesA feature can turn off when an older record did not express an opt-outDefault-on settings resolve to true unless the stored value is exactly boolean false.
Settings storage fails during load or saveDefaults or an in-memory change can look like a saved user choiceSettingsStore records the failure, rejects the save, and does not run EPG reconciliation before a successful commit.
A browser settings transaction reads stale state or commits no recordAn unrelated setting or TMDB key can be lost, or the running store can claim a change was savedThe write reads and updates the current record in one transaction, applies the in-memory key only after commit, and refreshes after a rejected transfer.
Embedded MPV support is inconclusive or the user changes player selectionA late host answer can overwrite the user's newer choiceSupport checks follow the answer only while the selection remains saved, and inconclusive answers are retried.
The server instance changes or is not verifiedProvider credentials may be sent to the wrong serverSource authorization blocks protected calls until the current instance is verified and revokes proof after a mismatch or outage.
A server revision is stale during a source mutationA newer remote source definition is overwritten or a local row becomes inconsistentThe source store uses revision conditions, exclusive mutations, and explicit conflict states.
Source synchronization deletes local data after an unobserved changeA local source or its device activity can be removed incorrectlyCleanup prunes only when the observed source revision still matches.
A source transport outage is treated as a valid responseLater requests can reuse credentials against an unverified or changed serverTransport failures and server failures invalidate verification before returning an offline result.
A backup read fails and becomes an empty collectionRestore can erase favorites, history, pins, or playback progressAuthoritative backup reads fail instead of returning an empty answer.
A backup restores EPG references by raw string onlyEquivalent remote guides can be duplicated while distinct local paths can be merged incorrectlyRestore normalizes remote URL identity and preserves local path spelling.
A PWA restore fails after one list is writtenA retry can overwrite a user's later edit or repeat completed workPer-list receipts keep the target and ownership state until all lists are written and the server confirms them.
A native playback reset is written before its replacement listA failed restore can discard a newer native checkpointThe reset marker is stamped only in the same successful storage write as the replacement list.
Database initialization fails after opening a handleAll later callers can reuse a broken promise or an open half-created connectionInitialization closes the failed handle, forgets the attempt, and lets the next call retry.
A title index rebuild uses a tokenizer that does not match title normalizationGlobal search can miss equivalent or accented titlesThe upgrade checks the live index definition, uses a compatible replacement, and keeps the old index until the replacement is complete.
A large catalog rebuild runs on the startup pathDatabase opening can block the application for a long timeLarge catalogs build beside the live index in worker batches and swap only after completion.
The title index build cursor or update triggers are lostContent added or changed during a deferred build can be absent or stale after the swapThe pending index records its cursor and uses scoped triggers until the atomic swap restores the live triggers.
A partial index is created before its migrated column existsA database from an older release can fail to openColumn migrations run before dependent indexes, and the direct 0.17 upgrade check verifies data and integrity.
A host produces repeated connection failuresLater portal actions wait through more timeoutsHostConnectivityGuard records host evidence and allows one recovery trial.
A timeout is classified as account inactivityA healthy source appears disabledSource health keeps transport failure separate from confirmed account evidence.
Lock state is unavailable while catalog data is readProtected content could become visibleParental filtering fails closed in the worker and renderer.
A database operation event belongs to another operationProgress or cancellation status appears on the wrong actionThe database service matches operation id and operation name before forwarding events.
A redaction rule misses a credential in a URL or nested valueProvider secrets enter logs or diagnosticsShared redaction handles sensitive keys, URLs, query values, nested objects, and text.
A clipboard write loses document focus and has no fallbackA copy action reports failure even though the window is still usableThe shared utility tries a focus-independent fallback and throws only when both paths fail.
A late player event arrives after an engine or source changeOld playback changes current progress or historyPlayback ownership and source or engine identity are checked before events are accepted.
Autoplay does not distinguish a pending autoplay claim from a viewer startA failed start can consume the streak or a manual choice can continue itThe shared streak releases cancelled claims and resets on starts without a pending claim.
An episode has no usable duration or has a misleading early credits chapterUp next appears for live content or appears too earlyTiming requires a finite positive duration and accepts chapter credits only in the final third, with an adaptive fallback.
A provider row has incomplete credentialsA source can disappear from filters or show a conflicting provider labelSource family resolution uses provider-defining fields with one precedence shared by icons and filters.

Key files

FileWhy to read it
libs/…/runtime-capabilities.service.ts and libs/…/data.service.tsDefine runtime environments, feature availability, and the host boundary used by shared services.
libs/…/settings-store.service.ts, settings-store.defaults.ts, and settings-storage.tsExplain shared preference loading, normalization, durable save boundaries, storage failures, default-on behavior, and cross-context TMDB key updates.
libs/…/settings-store.embedded-mpv.tsShows how a saved player choice follows current host support without overwriting a newer user choice.
libs/…/settings-store.service.spec.ts and settings-storage.spec.tsShow the guarantees for default-on settings, failed storage, partial updates, committed EPG changes, and stale asynchronous acknowledgements.
libs/…/playlists.service.ts, libs/…/playlist-refresh-merge.ts, and libs/…/playlist-storage-backend.tsExplain playlist persistence, refresh merging, write ordering, deletion boundaries, and runtime-selected storage.
libs/…/activity-sync-client.ts, activity-sync-sessions.ts, and activity-sync-resolution.tsDefine local-first viewing activity, session ownership, offline delivery, consent scope, and explicit conflict choices.
libs/…/activity-action-fence.ts, activity-projection.ts, and activity-delivery-response.tsExplain identity mapping, checkpoint ordering, reset protection, and delivery results.
libs/…/activity-sync-client.spec.ts and activity-checkpoint-order.spec.tsShow the guarantees for offline activity, source replacement, lost responses, conflicts, native checkpoints, and late callbacks.
libs/…/playlist-history.ts and libs/…/playlist-history.spec.tsDefine stable recent-item identity across M3U and portal content and the guarantees against duplicate or mismatched history rows.
libs/…/favorites-events.ts and libs/…/favorites-sync-client.tsDefine how explicit favorite actions become local state and shared server intent.
libs/…/favorites-sync-delivery.ts, favorites-source-contexts.ts, and the local store adaptersExplain queued delivery, conflict handling, source retirement, and Electron or browser durability.
libs/…/playlist-backup.service.ts, playlist-backup-epg.ts, pwa-xtream-backup-storage.ts, and pwa-xtream-restore-progress.tsShow how source records, user activity, EPG settings, list receipts, pending edits, server confirmation, and native playback resets cross a backup boundary.
libs/…/database-electron.service.tsShows the shared database service boundary, operation progress, cancellation, and authoritative reads.
libs/…/source-sync.service.ts, source-api.ts, source-connection.ts, and source-browser-settings.tsDefine self-hosted connection state, server access, instance verification, browser token scope, and source request routing.
libs/…/connection.tsDefines database opening, ordered schema upgrades, retry behavior, and the handoff for large title-index builds.
libs/…/content-title-fts.tsExplains catalog title search and how its live and deferred indexes stay safe during upgrades and content writes.
libs/…/connection-upgrade-0-17.spec.tsVerifies that a direct upgrade from an older database applies dependent migrations in the right order without losing the library.
libs/…/schema.ts, libs/…/connection.ts, and libs/…/README.mdDefine durable relationships, additive activity storage, startup retry behavior, and continuity for existing databases.
libs/…/activity-sqlite-server.tsShows server activity state, idempotency receipts, authorization, and revision-safe application.
libs/…/activity-sync.contract.ts and activity-sync.wire.tsDefine the shared activity state, operation types, identity boundary, local bridge, and input validation.
libs/…/autoplay-streak.util.ts, up-next-timing.util.ts, and source-type-icons.util.tsDefine reusable playback behavior and source presentation rules shared by product clients.
libs/…/autoplay-streak.util.spec.ts, up-next-timing.util.spec.ts, and source-type-icons.util.spec.tsShow the guarantees for autoplay limits, credit timing, usable episode data, provider precedence, and consistent source labels.
libs/…/electron-api.interface.ts and libs/…/server-storage.contract.tsDefine cross-runtime methods, events, and server-backed storage shapes.
libs/…/host-connectivity-guard.ts and libs/…/redact-sensitive-data.tsDefine portal fast-fail behavior and safe diagnostics.
libs/…/clipboard-copy.util.tsDefines the shared copy contract and its focus-safe browser fallback.
libs/…/workspace-shell.facade.ts and workspace-shell-route-state.service.tsShow how routes, active sources, provider navigation, and shared actions reach the shell.
libs/…/channel-list-container.component.ts and libs/…/web-player-view.component.tsIllustrate the shared browsing and playback foundations used by product pages.
libs/…/dialog-shell.component.ts and libs/…/_app-controls.scssDefine reusable dialog behavior and the shared visual action language.