diff --git a/CHANGELOG.md b/CHANGELOG.md
index c50b5ab..21070ae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,8 @@ The application version is maintained in `package.json` and displayed in the adm
### Changed
+- **Fewer personal best calls in Open Practice.** On fresh packs everyone beats their own best almost every lap early in the day, so the speaker never stopped. Now: no personal best call for a driver's first 10 laps of the day (since the practice started or was reset), at most one call per driver per minute, and the next call needs a best at least 0.1 s better than the last one called. The best lap is still shown on screen and in the overlay. The three values are under Settings → Audio (0 turns a rule off). Races are unaffected, and fastest lap of the session and track record calls stay as before.
+
- The practice reset button on Race Day is now called **Reset – new practice day** (it was "New practice day", which didn't say that it resets).
## 1.41.1 - 2026-10-18
diff --git a/src/app.js b/src/app.js
index afe5644..bc366d0 100644
--- a/src/app.js
+++ b/src/app.js
@@ -2130,6 +2130,10 @@ const TRANSLATIONS = {
"audio.max_delay": "Största fördröjning (sek)",
"audio.per_competitor": "Olika passing-ton per förare/bil",
"audio.race_callouts": "Utrop under race",
+ "audio.practice_pb_warmup": "Träning: tyst personbästa första varven",
+ "audio.practice_pb_cooldown": "Träning: sekunder mellan PB-utrop per förare",
+ "audio.practice_pb_min_gain": "Träning: minsta förbättring för utrop (s)",
+ "audio.practice_pb_hint": "Gäller open practice. På nyladdade ackar slår alla sin bästa tid nästan varje varv i början av dagen. Bästa varvet visas ändå på skärm och overlay. 0 stänger av regeln.",
"audio.race_callouts_passing": "Bara passeringsljud (som tidtagningssystem)",
"audio.race_callouts_full": "Speaker - namn, bästa varv, ny ledare",
"audio.test": "Testa",
@@ -3963,6 +3967,10 @@ const TRANSLATIONS = {
"audio.max_delay": "Maximum delay (seconds)",
"audio.per_competitor": "Different passing tone per driver/car",
"audio.race_callouts": "Calls during a race",
+ "audio.practice_pb_warmup": "Practice: silent personal best for first laps",
+ "audio.practice_pb_cooldown": "Practice: seconds between PB calls per driver",
+ "audio.practice_pb_min_gain": "Practice: minimum improvement to call (s)",
+ "audio.practice_pb_hint": "Open Practice. On fresh packs everyone beats their best almost every lap early in the day. The best lap is still shown on screen and in the overlay. 0 turns a rule off.",
"audio.race_callouts_passing": "Passing tone only (like timing systems)",
"audio.race_callouts_full": "Speaker - names, best laps, new leader",
"audio.test": "Test",
diff --git a/src/decoder_runtime.js b/src/decoder_runtime.js
index 8fe7f1d..a816917 100644
--- a/src/decoder_runtime.js
+++ b/src/decoder_runtime.js
@@ -2,8 +2,12 @@ import { decoderDiagnostics } from "./decoder_diagnostics.js";
import { getControlledLapStreak } from "./training_logic.js";
import { usesPersonalClock, getLatestClockStartTs } from "./prologue_logic.js";
import { isSuspectLap, getSuspectReferenceLaps } from "./suspect_laps_logic.js";
+import { shouldCallPracticePersonalBest } from "./practice_callouts_logic.js";
+import { normalizeRaceAudioSettings } from "./race_audio.js";
const PRACTICE_SESSION_TYPES = new Set(["open_practice", "free_practice", "practice"]);
+// Last personal best *called* per driver, per practice day and layout (practice_callouts_logic.js).
+const lastPracticePbCall = new Map();
function getCurrentPracticePaceLaps(result, competitorKey) {
const laps = [];
@@ -271,6 +275,11 @@ export function disconnectDecoderHelper(options = {}, deps) {
updateConnectionBadge();
}
+function getPracticePbRules(state) {
+ const audio = normalizeRaceAudioSettings(state.settings?.raceAudio);
+ return { warmupLaps: audio.practicePbWarmupLaps, cooldownSec: audio.practicePbCooldownSec, minGainMs: audio.practicePbMinGainMs };
+}
+
export function processDecoderMessageHelper(msg, deps, decoderRole = "main") {
const {
state, t, getActiveSession, ensureSessionResult, normalizeStartMode, getSessionLapWindow,
@@ -555,7 +564,13 @@ export function processDecoderMessageHelper(msg, deps, decoderRole = "main") {
}
}
if (suspect) pushOverlayEvent("suspect", `${entry.displayName || entry.driverName} • ${formatLap(lapMs)} ⚠`);
- if (!suspect && previousPersonalBest && lapMs < previousPersonalBest) triggerRaceAudio("personal_best", { variables: audioVariables, driverId: entry.driverId, competitorKey: key, logData: { raceId: session.eventId, driverId: entry.driverId, lapNumber: entry.laps, lapTime: lapMs } });
+ const isPracticeSession = PRACTICE_SESSION_TYPES.has(String(session.type || "").toLowerCase());
+ const pbCallKey = `${session.id}:${Number(session.resultsResetAt || 0)}:${layoutId}:${key}`;
+ const callPersonalBest = !suspect && (isPracticeSession
+ ? shouldCallPracticePersonalBest({ lapNumber: entry.laps, lapMs, previousBestMs: previousPersonalBest, lastCall: lastPracticePbCall.get(pbCallKey), now: Date.now(), rules: getPracticePbRules(state) })
+ : Boolean(previousPersonalBest && lapMs < previousPersonalBest));
+ if (callPersonalBest && isPracticeSession) lastPracticePbCall.set(pbCallKey, { at: Date.now(), lapMs });
+ if (callPersonalBest) triggerRaceAudio("personal_best", { variables: audioVariables, driverId: entry.driverId, competitorKey: key, logData: { raceId: session.eventId, driverId: entry.driverId, lapNumber: entry.laps, lapTime: lapMs } });
if (!suspect && previousSessionFastest && lapMs < previousSessionFastest) triggerRaceAudio("fastest_lap", { variables: audioVariables, driverId: entry.driverId, competitorKey: key, logData: { raceId: session.eventId, driverId: entry.driverId, lapNumber: entry.laps, lapTime: lapMs } });
if (!suspect && previousTrackRecord && lapMs < previousTrackRecord) triggerRaceAudio("track_record", { variables: audioVariables, driverId: entry.driverId, competitorKey: key, logData: { raceId: session.eventId, driverId: entry.driverId, lapNumber: entry.laps, lapTime: lapMs } });
if (previousPosition >= 0 && currentPosition >= 0 && currentPosition < previousPosition) triggerRaceAudio("position_gain", { driverId: entry.driverId, competitorKey: key });
diff --git a/src/practice_callouts_logic.js b/src/practice_callouts_logic.js
new file mode 100644
index 0000000..13bbbaf
--- /dev/null
+++ b/src/practice_callouts_logic.js
@@ -0,0 +1,19 @@
+// Open Practice "personal best" calls. On a fresh pack every driver beats their own best almost
+// every lap for the first laps of the day (the results start empty after a new practice or
+// "Reset – new practice day"), so with a few drivers on track the speaker never stops. The
+// rules below only decide what is *called*; the best lap itself is still shown everywhere.
+// - warm-up: nothing for a driver's first N laps of the day,
+// - cooldown: at most one call per driver per N seconds,
+// - minimum gain: after a call, the next one needs a best that beats the *called* time by this
+// much, so a run of tiny improvements is called once they add up. The first personal best
+// after the warm-up is always called.
+// Each rule is off at 0.
+export const PRACTICE_PB_DEFAULTS = Object.freeze({ warmupLaps: 10, cooldownSec: 60, minGainMs: 100 });
+
+export function shouldCallPracticePersonalBest({ lapNumber, lapMs, previousBestMs, lastCall = null, now, rules = PRACTICE_PB_DEFAULTS }) {
+ if (!previousBestMs || !(lapMs < previousBestMs)) return false;
+ if (rules.warmupLaps && lapNumber <= rules.warmupLaps) return false;
+ if (!lastCall) return true;
+ if (rules.cooldownSec && now - lastCall.at < rules.cooldownSec * 1000) return false;
+ return lastCall.lapMs - lapMs >= rules.minGainMs;
+}
diff --git a/src/race_audio.js b/src/race_audio.js
index 617e4ea..4e448f6 100644
--- a/src/race_audio.js
+++ b/src/race_audio.js
@@ -85,6 +85,10 @@ export function normalizeRaceAudioSettings(value = {}) {
maxStartDelay,
perCompetitorPassingTone: source.perCompetitorPassingTone === true,
raceCallouts: source.raceCallouts === "full" ? "full" : "passing",
+ // Open Practice personal best calls (practice_callouts_logic.js); 0 turns a rule off.
+ practicePbWarmupLaps: Math.round(clamp(source.practicePbWarmupLaps, 10, 0, 30)),
+ practicePbCooldownSec: Math.round(clamp(source.practicePbCooldownSec, 60, 0, 600)),
+ practicePbMinGainMs: Math.round(clamp(source.practicePbMinGainMs, 100, 0, 2000)),
events,
templates: source.templates && typeof source.templates === "object" ? { ...source.templates } : {},
};
diff --git a/src/settings.js b/src/settings.js
index a676c41..3b36c1b 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -251,6 +251,9 @@ export function renderSettings(deps) {
+
+
+
@@ -629,6 +632,9 @@ Erik Eriksson;654321;4WD;Associated;;
randomStartDelay: form.get("raceAudioRandomDelay") === "on", minStartDelay: Number(form.get("raceAudioMinDelay")),
maxStartDelay: Number(form.get("raceAudioMaxDelay")), perCompetitorPassingTone: form.get("raceAudioPerCompetitor") === "on",
raceCallouts: String(form.get("raceAudioRaceCallouts") || "passing"),
+ practicePbWarmupLaps: Number(form.get("raceAudioPbWarmup")),
+ practicePbCooldownSec: Number(form.get("raceAudioPbCooldown")),
+ practicePbMinGainMs: Math.round(Number(form.get("raceAudioPbMinGain")) * 1000),
events,
});
};
diff --git a/tests/browser_settings_tabs.js b/tests/browser_settings_tabs.js
index 1a52eec..f13dce5 100644
--- a/tests/browser_settings_tabs.js
+++ b/tests/browser_settings_tabs.js
@@ -57,6 +57,15 @@ export async function runSettingsTabsSmoke({ evaluate, navigate, waitFor, savedS
assert.equal(await callouts(), "passing");
console.log("PASS the legacy audio panel is gone and race calls default to passing tone only");
+ // Open Practice personal best calls: 10 warm-up laps, 60 s, 0.1 s by default, and they save.
+ const pbFields = () => evaluate(`["raceAudioPbWarmup", "raceAudioPbCooldown", "raceAudioPbMinGain"].map((name) => document.querySelector('[name="' + name + '"]').value).join("|")`);
+ assert.equal(await pbFields(), "10|60|0.1");
+ await evaluate(`(() => { document.querySelector('[name="raceAudioPbWarmup"]').value = "5"; document.querySelector('[name="raceAudioPbCooldown"]').value = "120"; document.querySelector('[name="raceAudioPbMinGain"]').value = "0.25"; document.getElementById("settingsForm").requestSubmit(); })()`);
+ await waitFor(async () => { const audio = (await savedState()).settings.raceAudio; return audio.practicePbWarmupLaps === 5 && audio.practicePbCooldownSec === 120 && audio.practicePbMinGainMs === 250; }, "practice personal best rules saved");
+ assert.equal(await pbFields(), "5|120|0.25");
+ await evaluate(`(() => { document.querySelector('[name="raceAudioPbWarmup"]').value = "10"; document.querySelector('[name="raceAudioPbCooldown"]').value = "60"; document.querySelector('[name="raceAudioPbMinGain"]').value = "0.1"; document.getElementById("settingsForm").requestSubmit(); })()`);
+ console.log("PASS the practice personal best call rules default to 10 laps / 60 s / 0.1 s and are saved");
+
// The sidebar "update available" link opens Settings on System & backup at Updates, even
// when another tab was the last one used.
await evaluate(`document.querySelector('[data-settings-tab="connection"]').click()`);
diff --git a/tests/decoder_runtime.test.js b/tests/decoder_runtime.test.js
index 11f971a..51bdd03 100644
--- a/tests/decoder_runtime.test.js
+++ b/tests/decoder_runtime.test.js
@@ -27,6 +27,7 @@ function createHarness(options = {}) {
],
cars: [],
resultsBySession: {},
+ ...(options.raceAudio ? { settings: { raceAudio: options.raceAudio } } : {}),
};
let saveCount = 0;
const overlayEvents = [];
@@ -137,7 +138,8 @@ test("flying start: a car first seen after the latest clock start gets that cloc
});
test("personal best is per session and track layout - not per stint, and an old layout's time doesn't count", () => {
- const harness = createHarness({ sessionType: "open_practice" });
+ // The practice call rules (warm-up, cooldown) are tested on their own below.
+ const harness = createHarness({ sessionType: "open_practice", raceAudio: { practicePbWarmupLaps: 0, practicePbCooldownSec: 0, practicePbMinGainMs: 0 } });
harness.session.trackLayoutId = "layout_a";
const entry = () => Object.values(harness.state.resultsBySession.session_1.competitors)[0];
const pbs = () => harness.audioEvents.filter((event) => event === "personal_best").length;
@@ -157,6 +159,21 @@ test("personal best is per session and track layout - not per stint, and an old
assert.equal(harness.state.resultsBySession.session_1.passings.at(-1).trackLayoutId, "layout_b", "each lap remembers its layout");
});
+test("practice on a fresh pack: no personal best calls for the first ten laps, then one a minute", () => {
+ const harness = createHarness({ sessionType: "open_practice" });
+ const pbs = () => harness.audioEvents.filter((event) => event === "personal_best").length;
+ let ts = 1_000;
+ // Every lap 0.3 s quicker than the one before: a personal best each lap.
+ for (let lap = 0; lap < 10; lap += 1) { ts += 25_000 - lap * 300; harness.passing(ts, "main"); }
+ assert.equal(Object.values(harness.state.resultsBySession.session_1.competitors)[0].laps, 10);
+ assert.equal(pbs(), 0, "laps 1-10 are warm-up");
+ ts += 21_000; harness.passing(ts, "main"); // lap 11
+ assert.equal(pbs(), 1, "the first best after the warm-up is called");
+ ts += 20_500; harness.passing(ts, "main");
+ assert.equal(pbs(), 1, "the next best 20 s later is inside the cooldown");
+ assert.equal(Object.values(harness.state.resultsBySession.session_1.competitors)[0].bestLapMs, 20_500, "but it is still the best lap");
+});
+
test("practice: a shortcut lap is flagged suspect - counted, but no best lap, personal best or record", () => {
const harness = createHarness({ sessionType: "open_practice" });
const entry = () => Object.values(harness.state.resultsBySession.session_1.competitors)[0];
diff --git a/tests/practice_callouts_logic.test.js b/tests/practice_callouts_logic.test.js
new file mode 100644
index 0000000..f8ba108
--- /dev/null
+++ b/tests/practice_callouts_logic.test.js
@@ -0,0 +1,52 @@
+import test from "node:test";
+import assert from "node:assert/strict";
+import { shouldCallPracticePersonalBest, PRACTICE_PB_DEFAULTS } from "../src/practice_callouts_logic.js";
+import { normalizeRaceAudioSettings } from "../src/race_audio.js";
+
+// Run a driver's laps (lapMs at 20 s intervals) through the rules and return the called laps.
+function calledLaps(laps, rules = PRACTICE_PB_DEFAULTS) {
+ let best = null;
+ let lastCall = null;
+ const called = [];
+ laps.forEach((lapMs, index) => {
+ const now = (index + 1) * 20000;
+ if (shouldCallPracticePersonalBest({ lapNumber: index + 1, lapMs, previousBestMs: best, lastCall, now, rules })) {
+ lastCall = { at: now, lapMs };
+ called.push(index + 1);
+ }
+ if (!best || lapMs < best) best = lapMs;
+ });
+ return called;
+}
+
+test("fresh pack: no personal best calls during the first ten laps of the day", () => {
+ const laps = [24000, 23000, 22500, 22000, 21600, 21300, 21000, 20800, 20600, 20500];
+ assert.deepEqual(calledLaps(laps), []);
+ assert.equal(calledLaps(laps, { warmupLaps: 0, cooldownSec: 0, minGainMs: 0 }).length, 9, "without the rules every lap is a call");
+});
+
+test("after the warm-up a real improvement is called, then at most once a minute per driver", () => {
+ const laps = [...Array(10).fill(21000), 20500, 20300, 20100, 21000];
+ // Lap 11 is called; laps 12-13 (20 and 40 s later) fall inside the cooldown.
+ assert.deepEqual(calledLaps(laps), [11]);
+ const later = [...Array(10).fill(21000), 20500, 21000, 21000, 21000, 20300];
+ assert.deepEqual(calledLaps(later), [11, 15], "a better lap after the minute is called again");
+});
+
+test("tiny improvements are called once they add up to the minimum gain", () => {
+ const rules = { warmupLaps: 0, cooldownSec: 0, minGainMs: 100 };
+ // 19.95 is the first best (called); 19.88 is only 0.07 better than that; 19.84 adds up to 0.11.
+ assert.deepEqual(calledLaps([20000, 19950, 19880, 19840, 19770], rules), [2, 4]);
+});
+
+test("a lap that is not a best is never called", () => {
+ assert.equal(shouldCallPracticePersonalBest({ lapNumber: 20, lapMs: 20000, previousBestMs: 19000, now: 0, rules: { warmupLaps: 0, cooldownSec: 0, minGainMs: 0 } }), false);
+ assert.equal(shouldCallPracticePersonalBest({ lapNumber: 20, lapMs: 20000, previousBestMs: null, now: 0 }), false, "the first timed lap is no personal best");
+});
+
+test("the settings default to 10 laps, 60 s and 0.1 s and clamp what is typed", () => {
+ const defaults = normalizeRaceAudioSettings({});
+ assert.deepEqual([defaults.practicePbWarmupLaps, defaults.practicePbCooldownSec, defaults.practicePbMinGainMs], [10, 60, 100]);
+ const typed = normalizeRaceAudioSettings({ practicePbWarmupLaps: 99, practicePbCooldownSec: -5, practicePbMinGainMs: 0 });
+ assert.deepEqual([typed.practicePbWarmupLaps, typed.practicePbCooldownSec, typed.practicePbMinGainMs], [30, 0, 0]);
+});
diff --git a/tests/run.js b/tests/run.js
index 268d436..4ee81e9 100644
--- a/tests/run.js
+++ b/tests/run.js
@@ -1,4 +1,5 @@
import "./auth.test.js";
+import "./practice_callouts_logic.test.js";
import "./local_cache.test.js";
import "./prologue_logic.test.js";
import "./suspect_laps_logic.test.js";