fix(control): pause, resume, false start and reset are master-only too (1.77.1)

This commit is contained in:
larssand committed 2026-11-07 17:48:25 +01:00
1 parent cf3a4c5fdb
commit 0589fe5f65
8 files changed
+35 -9

No files matched your search

+5
View File
@@ -8,6 +8,11 @@ The application version is maintained in `package.json` and displayed in the adm
No changes recorded yet.
## 1.77.1
### Fixed
- Race Controller Master: pause, resume and false start on the speaker panel, resetting a heat or practice, and pausing or resuming the day are now also limited to the master. On other computers the banner flashes instead. Only the master's browser ends a heat when its time runs out. Judging corrections and the other speaker calls still work from any computer.
## 1.77.0
### Added
+1 -1
View File
@@ -321,7 +321,7 @@ Erik Eriksson;654321;4WD;Associated;;
RaceCore is meant for a trusted race network:
- **Admin PIN** (Settings → System & backup, off by default) protects every change through the API. The login lasts 30 days and is throttled against guessing.
- **Race Controller Master:** one computer at a time runs the race (the decoder, start, pause, stop and the autopilot). The first admin browser opened becomes master; other computers show "You are following the race …" and can prepare drivers and races. Whoever works as race controller presses **Take over as master**, and the previous master lets go of the decoder within seconds. With the admin PIN on, taking over needs a login. Name the computer under Settings → System, e.g. "Speaker booth". Overlays and OBS are always view-only.
- **Race Controller Master:** one computer at a time runs the race (the decoder, start, pause, resume, stop, false start, resetting a heat and the autopilot, also from the speaker panel). Judging corrections and the other calls work from any computer. The first admin browser opened becomes master; other computers show "You are following the race …" and can prepare drivers and races. Whoever works as race controller presses **Take over as master**, and the previous master lets go of the decoder within seconds. With the admin PIN on, taking over needs a login. Name the computer under Settings → System, e.g. "Speaker booth". Overlays and OBS are always view-only.
- **`RC_ADMIN_ALLOWED_CIDRS`** restricts admin changes to certain addresses or networks, e.g. `192.168.1.0/24`.
- **`RC_ALLOWED_ORIGINS`** is for a UI deliberately served from another address.
- **Don't expose port 8081 to the internet.** Reads are not PIN protected. Publish only the public overlay and mobile profile paths through a reverse proxy or VPN.
+1 -1
View File
@@ -334,7 +334,7 @@ Erik Eriksson;654321;4WD;Associated;;
RaceCore är tänkt för ett betrott racenätverk:
- **Admin-PIN** (Inställningar → System & backup, av som standard) skyddar alla ändringar via API:t. Inloggningen gäller i 30 dagar och är skyddad mot gissning.
- **Race Controller Master:** bara en dator åt gången kör racet (decodern, start, paus, stopp och autopiloten). Den första admin-webbläsaren som öppnas blir master; andra datorer visar "Du följer racet …" och kan förbereda förare och race. Den som jobbar som race controller trycker **Ta över som master**, och den förra mastern släpper decodern inom några sekunder. Med admin-PIN krävs inloggning för att ta över. Ge datorn ett namn under Inställningar → System, t.ex. "Speakerbåset". Overlays och OBS är alltid bara visning.
- **Race Controller Master:** bara en dator åt gången kör racet (decodern, start, paus, fortsätt, stopp, tjuvstart, nollställ heat och autopiloten, även från speakerpanelen). Domarvyns korrigeringar och övriga utrop fungerar från alla datorer. Den första admin-webbläsaren som öppnas blir master; andra datorer visar "Du följer racet …" och kan förbereda förare och race. Den som jobbar som race controller trycker **Ta över som master**, och den förra mastern släpper decodern inom några sekunder. Med admin-PIN krävs inloggning för att ta över. Ge datorn ett namn under Inställningar → System, t.ex. "Speakerbåset". Overlays och OBS är alltid bara visning.
- **`RC_ADMIN_ALLOWED_CIDRS`** begränsar adminändringar till vissa adresser eller nät, till exempel `192.168.1.0/24`.
- **`RC_ALLOWED_ORIGINS`** används för ett gränssnitt som medvetet körs från en annan adress.
- **Exponera inte port 8081 mot internet.** Läsningar skyddas inte av PIN. Publicera bara sökvägarna för publik overlay och mobilprofil via reverse proxy eller VPN.
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "rc-racecore",
"version": "1.77.0",
"version": "1.77.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "rc-racecore",
"version": "1.77.0",
"version": "1.77.1",
"hasInstallScript": true,
"dependencies": {
"better-sqlite3": "^12.11.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "rc-racecore",
"version": "1.77.0",
"version": "1.77.1",
"private": true,
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
"engines": {
+5 -2
View File
@@ -256,7 +256,7 @@ const announceRaceFinished = (finished = null) => {
const announceRaceClockEvent = (eventKey, session) => triggerRaceAudio(eventKey, { logData: { raceId: session.eventId, sessionId: session.id } });
const handleSessionTimerTick = () => handleSessionTimerTickHelper({ getActiveSession: getLiveSession, isUntimedSession, getSessionTiming, saveState, getLastFinishAnnouncementSessionId: () => lastFinishAnnouncementSessionId, setLastFinishAnnouncementSessionId: (value) => { lastFinishAnnouncementSessionId = value; }, announceRaceFinished, announceRaceClockEvent,
// The race browser: the one on the decoder, or with no decoder anywhere, the one that started the heat.
isClockOwner: (session) => !overlayMode && (Boolean(state.decoder?.connected) || readClockOwner() === session.id),
isClockOwner: (session) => !overlayMode && isRaceMaster() && (Boolean(state.decoder?.connected) || readClockOwner() === session.id),
getFinishWait: (session) => getFinishWaitLogic(session, state.resultsBySession[session.id]?.competitors, { maxLapMs: getSessionLapWindow(session).maxLapMs }) });
const CLOCK_OWNER_KEY = "rc_clock_owner";
const readClockOwner = () => { try { return sessionStorage.getItem(CLOCK_OWNER_KEY) || ""; } catch { return ""; } };
@@ -540,6 +540,7 @@ const bindDayCall = (root) => bindDayCallBanner(root, {
});
// Pausing the day stops the autopilot and pauses whatever is on track (or holds the count-down).
function pauseRaceDay(date) {
if (!isRaceMaster()) { notifyNotMaster(); return; }
saveDayPlan({ ...getDayPlan(date), pausedAt: Date.now() });
const live = state.sessions.find((session) => session.status === "running");
if (live) pauseOperationalSession(live);
@@ -547,6 +548,7 @@ function pauseRaceDay(date) {
renderView();
}
function resumeRaceDay(date) {
if (!isRaceMaster()) { notifyNotMaster(); return; }
saveDayPlan({ ...getDayPlan(date), pausedAt: null });
const paused = state.sessions.find((session) => session.status === "paused" && session.mode === "race" && !isPracticeSessionType(session.type));
if (paused) resumeOperationalSession(paused);
@@ -601,6 +603,7 @@ function currentSession(session) {
function resetSessionData(session) {
session = currentSession(session);
if (!session) return false;
if (!isRaceMaster()) { notifyNotMaster(); return false; }
syncTrainingLedger();
session.resultsResetAt = Date.now();
delete state.resultsBySession[session.id];
@@ -813,7 +816,7 @@ const renderTiming = () => renderTimingView({ renderSuspectLapsPanel: (session)
// Speaker panel (race-control calls, quick sound switches) on Race Day and Judging.
const speakerPanelDeps = {
renderSpeakerPanel: () => renderSpeakerPanel({ state, t, escapeHtml }),
bindSpeakerPanel: (root) => bindSpeakerPanel(root, { state, getActiveSession, cancelRaceStart, triggerRaceAudio, saveState, updateHeaderState, renderView }),
bindSpeakerPanel: (root) => bindSpeakerPanel(root, { state, getActiveSession, cancelRaceStart, triggerRaceAudio, saveState, updateHeaderState, renderView, canRunRace: isRaceMaster, notifyNotMaster }),
};
const renderJudging = () => renderJudgingView({ ...speakerPanelDeps,
getJudgingSession, setJudgingSessionId: (value) => { judgingSessionId = value; }, getJudgingSessionChoices,
+6 -1
View File
@@ -46,12 +46,17 @@ export function renderSpeakerPanel({ state, t, escapeHtml }) {
</section>`;
}
export function bindSpeakerPanel(root, { state, getActiveSession, cancelRaceStart, triggerRaceAudio, saveState, updateHeaderState, renderView }) {
export function bindSpeakerPanel(root, { state, getActiveSession, cancelRaceStart, triggerRaceAudio, saveState, updateHeaderState, renderView, canRunRace = () => true, notifyNotMaster = () => {} }) {
if (!root) return;
root.querySelectorAll("#speakerPanel [data-race-audio-cue]").forEach((node) => {
node.addEventListener("click", () => {
const cue = node.dataset.raceAudioCue;
const session = getActiveSession();
// Pause, resume and false start change the heat: only the Race Controller Master may.
if (["false_start", "race_paused", "race_resumed"].includes(cue) && !canRunRace()) {
notifyNotMaster();
return;
}
if (cue === "false_start") {
cancelRaceStart();
} else if (cue === "race_paused" && session?.status === "running") {
+14 -1
View File
@@ -31,13 +31,26 @@ export async function runRaceControllerSmoke({ evaluate, navigate, savedState, w
assert.equal(decoder.totalConnections(), connectsBefore, "the second browser does not connect to the decoder");
assert.match(await second.evaluate('document.getElementById("controllerBanner").textContent'), /Race Controller Master/);
// The follower cannot pause, resume or reset the heat (speaker panel or Race Day).
const before = await savedState();
const heat = { id: "rc_ctrl_heat", eventId: before.events[0]?.id || "", name: "RC Ctrl Heat", type: "final", mode: "race", status: "paused", startMode: "position", durationMin: 5, startedAt: Date.now() - 60000, pausedAt: Date.now() - 30000, totalPausedMs: 0, driverIds: [] };
await patchState({ sessions: [...before.sessions, heat], activeSessionId: heat.id });
await second.evaluate(`location.href = ${JSON.stringify(base + "/?view=race_day")}; true`);
await second.waitFor(async () => Boolean(await second.evaluate('document.querySelector(\'#speakerPanel [data-race-audio-cue="race_resumed"]\')')) && (await second.evaluate('document.getElementById("controllerBanner").hidden')) === false, "follower on Race Day");
await second.evaluate('document.querySelector(\'#speakerPanel [data-race-audio-cue="race_resumed"]\').click(); true');
await pause(1500);
assert.equal((await savedState()).sessions.find((session) => session.id === heat.id).status, "paused", "the follower's Resume does nothing");
assert.equal(await second.evaluate('document.getElementById("controllerBanner").classList.contains("is-flash")'), true, "the banner points at Take over");
const cleaned = await savedState();
await patchState({ sessions: cleaned.sessions.filter((session) => session.id !== heat.id), activeSessionId: before.activeSessionId || null });
await second.evaluate('window.confirm = () => true; document.getElementById("controllerTakeOver").click(); true');
const secondId = await second.evaluate('sessionStorage.getItem("rc_controller_client_id")');
await waitFor(async () => (await controller())?.clientId === secondId, "take over moves the master");
await waitFor(async () => decoder.totalConnections() > connectsBefore, "the new master connects to the decoder");
await waitFor(async () => (await evaluate('document.getElementById("controllerBanner").hidden')) === false, "the old master sees the banner", 12000);
assert.equal(await evaluate("document.getElementById('connectionBadge').classList.contains('badge-online')"), false, "the old master lets go of the decoder");
console.log("PASS Race Controller Master: a second browser follows without the decoder, takes over, and the first one lets go");
console.log("PASS Race Controller Master: a second browser follows without the decoder or pause/resume, takes over, and the first one lets go");
// Back to the first browser for the rest of the suite.
await evaluate('window.confirm = () => true; document.getElementById("controllerTakeOver").click(); true');