fix(race-day): run again resets the current heat, not a stale copy; show the set time before the start (1.54.2)

This commit is contained in:
larssand committed 2026-11-03 08:46:51 +01:00
1 parent 8b625c3d64
commit a8996c4195
7 files changed
+32 -4

No files matched your search

+7
View File
@@ -8,6 +8,13 @@ The application version is maintained in `package.json` and displayed in the adm
No changes recorded yet.
## 1.54.2 - 2026-11-03
### Fixed
- ↻ Run again on a stopped heat could leave the clock at the time it was stopped (e.g. 4:32) and keep the laps. The page refreshes its data from the server every 15 s, and the button then still held an old copy of the heat; Run again, Start, Pause, Resume and Finish now always work on the heat as it is now.
- Before the start, a staggered heat's clock shows the time set for it (5:00) instead of 5 minutes plus the time it takes to release every car.
## 1.54.1 - 2026-11-02
### Fixed
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "rc-racecore",
"version": "1.54.1",
"version": "1.54.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "rc-racecore",
"version": "1.54.1",
"version": "1.54.2",
"hasInstallScript": true,
"dependencies": {
"better-sqlite3": "^12.11.1",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "rc-racecore",
"version": "1.54.1",
"version": "1.54.2",
"private": true,
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
"engines": {
+11
View File
@@ -530,7 +530,14 @@ const renderBoard = () => {
// --- Race Day as the place where things are run --------------------------------------
// "New practice day": clears the session's laps on Timing for a new day; every lap so far
// is first put in the training stats, where resultsResetAt keeps it (see syncTrainingLedger).
// The session as it is in state now. A background refresh from the server replaces every
// session object without redrawing the page, so a button may still hold an old copy; changing
// that copy would change nothing (e.g. Run again left the clock at 4:32).
function currentSession(session) {
return (session && state.sessions.find((item) => item.id === session.id)) || session;
}
function resetSessionData(session) {
session = currentSession(session);
if (!session) return false;
syncTrainingLedger();
session.resultsResetAt = Date.now();
@@ -5627,6 +5634,7 @@ function saveState(options = {}) {
}
async function startOperationalSession(session, callbacks = {}) {
session = currentSession(session);
if (!session) return { ok: false, message: t("race_day.start_failed") };
const { requirePreflight = false, onTone, ...sequenceCallbacks } = callbacks;
if (session.mode === "track") {
@@ -5709,6 +5717,7 @@ function saveOperationalLapWindow(session, minLapSec, maxLapSec) {
}
function finishOperationalSession(session) {
session = currentSession(session);
if (!session) return false;
cancelRaceStart();
state.activeSessionId = session.id;
@@ -5722,6 +5731,7 @@ function finishOperationalSession(session) {
}
function pauseOperationalSession(session) {
session = currentSession(session);
if (!pauseSessionControl(session)) return false;
triggerRaceAudio("race_paused", { interrupt: true, force: true, logData: { raceId: session.eventId, sessionId: session.id } });
saveState();
@@ -5730,6 +5740,7 @@ function pauseOperationalSession(session) {
}
function resumeOperationalSession(session) {
session = currentSession(session);
if (!resumeSessionControl(session)) return false;
triggerRaceAudio("race_resumed", { interrupt: true, force: true, logData: { raceId: session.eventId, sessionId: session.id } });
saveState();
+2 -1
View File
@@ -129,7 +129,8 @@ export function getSessionTiming(session, nowTs = Date.now(), { getSessionTarget
return {
targetMs,
elapsedMs,
remainingMs: targetMs === null ? null : Math.max(0, targetMs - elapsedMs),
// Before the start the clock shows the time set for the heat (5:00), not the release extension.
remainingMs: targetMs === null ? null : !startedAt ? baseTargetMs : Math.max(0, targetMs - elapsedMs),
untimed: targetMs === null,
followUpActive,
followUpRemainingMs,
+4
View File
@@ -58,12 +58,16 @@ export async function runRaceDayQuickSmoke({ evaluate, navigate, savedState, wai
await evaluate(`(() => { const select = document.getElementById("raceDaySessionSelect"); select.value = "rq_done"; select.dispatchEvent(new Event("change")); })()`);
await waitFor(async () => Boolean(await evaluate(`document.getElementById("raceDayResetSession")`)), "Run again for the finished heat");
assert.equal(await evaluate(`document.getElementById("raceDayResetSession").textContent.trim()`), "↻ Run again");
// The page refreshes its data from the server every 15 s without redrawing; Run again must
// still reset the heat itself, not an old copy of it (the clock used to stay at 4:32).
await new Promise((resolve) => setTimeout(resolve, 16000));
await evaluate(`document.getElementById("raceDayResetSession").click()`);
await waitFor(async () => (await savedState()).sessions.find((session) => session.id === "rq_done")?.status === "ready", "the heat is ready to run again");
const reset = (await savedState()).sessions.find((session) => session.id === "rq_done");
assert.deepEqual([reset.startedAt || null, reset.endedAt || null, reset.finishedByTimer], [null, null, false], "the clock is back at zero");
assert.equal((await savedState()).resultsBySession.rq_done?.passings?.length || 0, 0, "its laps are cleared");
await waitFor(async () => Boolean(await evaluate(`document.getElementById("raceDayStart")`)), "Start is offered again");
assert.equal(await evaluate(`document.querySelector("[data-race-day-clock]").textContent.trim()`), "05:00", "the clock shows the full time again");
console.log("PASS a finished heat can be picked and reset: clock to zero, laps cleared, Start again");
// The race controller follows the heat on Race Day: order, laps, last/best lap, estimate.
+5
View File
@@ -620,6 +620,11 @@ test("session timing handles untimed practice, countdown, and follow-up", () =>
assert.equal(untimed.untimed, true);
assert.equal(untimed.remainingMs, null);
assert.equal(untimed.elapsedMs, 60000);
// A staggered heat not (yet / again) started shows the time set for it, not the release extension.
const staggered = { type: "qualification", durationMin: 5, startMode: "staggered", staggerGapSec: 3, manualGridIds: ["a", "b", "c", "d", "e", "f"] };
assert.equal(getSessionTiming(staggered, 5000, { getSessionTargetMs: getTarget }).remainingMs, 300000);
assert.equal(getSessionTiming({ ...staggered, startedAt: 1000 }, 1000, { getSessionTargetMs: getTarget }).remainingMs, 315000, "the running clock keeps the extension");
});
// Regression coverage for the user's report: a staggered-start qualifying heat with 4