From 54989d8597db05dc977c1f72b7f42495e406f694 Mon Sep 17 00:00:00 2001 From: larssand Date: Sat, 7 Nov 2026 17:14:39 +0100 Subject: [PATCH] fix(overlay): overlay windows are read-only, no decoder connection or saves (1.76.1) --- CHANGELOG.md | 5 +++++ README.md | 1 + README.sv.md | 1 + package-lock.json | 4 ++-- package.json | 2 +- src/app.js | 12 +++++++----- tests/browser_obs_popup.js | 4 ++++ 7 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71632eb..269a2f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ The application version is maintained in `package.json` and displayed in the adm No changes recorded yet. +## 1.76.1 + +### Fixed +- An overlay opened on another computer (or the OBS window) could undo what Race Day did, such as a start, a pause or laps: it connected to the decoder itself and saved its own copy of the state. Overlay windows are now read-only. They follow the server and never connect to the decoder or save. + ## 1.76.0 ### Added diff --git a/README.md b/README.md index 68fec3f..d9fb897 100644 --- a/README.md +++ b/README.md @@ -279,6 +279,7 @@ The **Overlay** menu has leaderboard, speaker, results, TV and team modes, plus - **TV graphics:** a title plate top left (event and heat) and a timing tower top right with the clock on top and real columns: place / **start position** (e.g. "2 / 3"), driver, laps, time, best and gap, in large bold type with podium colours for the top three. No backdrop of its own, so the camera image shows through. The start position can be turned off and is not shown in practice. - **Click a driver** in RaceCore's own overlay to open that driver's training stats (the stand-alone overlay window opens them in a new tab). The public overlay has no such links. - **Copy OBS URL** gives a browser-source link; the chosen columns are part of the link. +- **Overlay windows are read-only:** they do not connect to the decoder and never save, so an overlay on another computer (or in OBS) cannot disturb the race run from Race Day. No admin PIN is needed for that. Run Race Day in one browser at a time. - Public overlays live at `/public-overlay/` and can require a token: set `PUBLIC_OVERLAY_TOKEN` and add `?token=...`. Publish only `/public-overlay/*` through your reverse proxy. - Club branding (name, logo, PDF theme) is applied to the sidebar, overlays, mobile profiles and PDFs; branding can also be set per event. diff --git a/README.sv.md b/README.sv.md index 5bce7b6..225253e 100644 --- a/README.sv.md +++ b/README.sv.md @@ -292,6 +292,7 @@ Menyn **Overlay** har lägena leaderboard, speaker, resultat, TV och lag, plus e - **TV-grafik:** rubrikskylt uppe till vänster (event och heat) och en topplista uppe till höger med klockan överst och raka kolumner: placering / **startplats** (t.ex. "2 / 3"), förare, varv, tid, bästa och gap, i stor fet text och medaljfärger för topp 3. Ingen egen bakgrund, så kamerabilden syns igenom. Startplatsen kan stängas av och visas inte i träning. - **Klicka på en förare** i RaceCores egen overlay för att öppna förarens träningsstatistik (det fristående overlay-fönstret öppnar den i en ny flik). Den publika overlayn har inga sådana länkar. - **Kopiera OBS-URL** ger en länk för browser source; valda kolumner ingår i länken. +- **Overlay-fönster är skrivskyddade:** de kopplar inte upp sig mot decodern och sparar aldrig, så en overlay på en annan dator (eller i OBS) kan inte störa racet som körs från Race Day. Ingen admin-PIN behövs för det. Kör bara Race Day i en webbläsare åt gången. - Publika overlays finns på `/public-overlay/` och kan kräva en nyckel: sätt `PUBLIC_OVERLAY_TOKEN` och lägg till `?token=...`. Publicera bara `/public-overlay/*` via din reverse proxy. - Klubbprofilen (namn, logga, PDF-tema) används i menyn, overlays, mobilprofiler och PDF; den kan även sättas per tävling. diff --git a/package-lock.json b/package-lock.json index 7e37e65..45a8b71 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.76.0", + "version": "1.76.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.76.0", + "version": "1.76.1", "hasInstallScript": true, "dependencies": { "better-sqlite3": "^12.11.1", diff --git a/package.json b/package.json index be8cea3..4d8ec66 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.76.0", + "version": "1.76.1", "private": true, "description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence", "engines": { diff --git a/src/app.js b/src/app.js index 4113d08..a8fccee 100644 --- a/src/app.js +++ b/src/app.js @@ -5797,7 +5797,8 @@ async function init() { updateHeaderState(); updateConnectionBadge(); // The decoder simulator (Settings) is connected on load even with auto-reconnect off. - if (state.settings.wsUrl && (state.settings.autoReconnect || state.settings.simPreviousWsUrl) && !state.decoder.connected) { + // An overlay window only shows: the race controller's browser owns the decoder. + if (!overlayMode && state.settings.wsUrl && (state.settings.autoReconnect || state.settings.simPreviousWsUrl) && !state.decoder.connected) { connectDecoder(); } }); @@ -5812,9 +5813,6 @@ async function init() { startOverlayRotation(); startOverlayLiveRefresh(); - if (overlayMode && state.settings.wsUrl && !state.decoder.connected) { - connectDecoder(); - } } function updateSyncStatus() { @@ -6113,6 +6111,9 @@ function loadState() { } function saveState(options = {}) { + // Overlay windows (also on another computer) are read-only: they follow the server every + // 0.8 s and never push their copy, which could undo a start or laps from Race Day. + if (overlayMode) return; const persistable = buildPersistableState(); const cached = writeLocalCache(localStorage, STORAGE_KEY, persistable); if (!cached.ok && !localCacheFull) console.warn("Browser storage is full; the local cache is dropped and the server's state is used.", cached.error); @@ -8084,7 +8085,7 @@ function findDuplicateSessionTransponders(session) { } async function persistSessionResultToBackend(sessionId) { - if (!sessionId || !state.resultsBySession[sessionId]) return; + if (overlayMode || !sessionId || !state.resultsBySession[sessionId]) return; try { const res = await fetch(`${getBackendUrl()}/api/session-results`, { method: "POST", @@ -8098,6 +8099,7 @@ async function persistSessionResultToBackend(sessionId) { } async function persistPassingToBackend(sessionId, passing) { + if (overlayMode) return; backend.pendingWrites = (backend.pendingWrites || 0) + 1; try { const res = await fetch(`${getBackendUrl()}/api/passings`, { diff --git a/tests/browser_obs_popup.js b/tests/browser_obs_popup.js index 7f0af38..6861d30 100644 --- a/tests/browser_obs_popup.js +++ b/tests/browser_obs_popup.js @@ -91,6 +91,7 @@ export async function runObsPopupSmoke({ evaluate, navigate, fill, savedState, w await evaluate(`[...document.querySelectorAll(".nav-item")].find(el => el.textContent === "Overlay")?.click()`); await waitFor(async () => await evaluate('Boolean(document.getElementById("overlayLaunchObs"))'), "admin overlay page shows the launch buttons"); const before = await listPageTargets(); + const decoderConnectsBefore = decoder.totalConnections(); // A synthetic .click() is not a trusted gesture, so Chrome's popup blocker would // silently swallow the window.open() this button triggers; dispatch a real click. await realClick("#overlayLaunchObs"); @@ -118,6 +119,9 @@ export async function runObsPopupSmoke({ evaluate, navigate, fill, savedState, w await pause(2500); const secondClock = await clockAt(); assert.notEqual(secondClock, firstClock, "popup clock advances live without a manual reload"); + // Read-only: the popup (like an overlay on another computer) opens no decoder connection + // of its own and never saves, so it cannot undo a start or laps from Race Day. + assert.equal(decoder.totalConnections(), decoderConnectsBefore, "the overlay window does not connect to the decoder"); // Back on the admin side, the Race Day view was replaced by the Overlay nav view // above, so raceDayPause no longer exists in the DOM until we return to it.