diff --git a/CHANGELOG.md b/CHANGELOG.md index 4277bf8..1fb7490 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ The application version is maintained in `package.json` and displayed in the adm No changes recorded yet. +## 1.39.2 - 2026-10-17 + +### Fixed + +- Settings → Connection: **Connect now** connected to the previously *saved* decoder URL, even when the field showed a newly typed one, e.g. port 9443 typed but 9000 still saved. Typed decoder URLs are now saved first and then used. + ## 1.39.1 - 2026-10-13 ### Changed diff --git a/ROADMAP.md b/ROADMAP.md index 664abaa..8429fb1 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -924,6 +924,19 @@ Verified 2026-10-11: - Open Practice shows "23L 0:15.833 -" with the best lap once. - 73 browser scenarios pass. +## Decoder URL on its own port (2026-10-17) + +Reported by the user: AMMC runs as their own systemd service on port 9443, but RaceCore showed "Decoder offline" and the UI log still said 9000. + +Checked: +- The "AMMC WebSocket port 9000" and its log belong to Managed AMMC only (started 17:02, stopped 17:09). The decoder URL had been set to `:9000` by "Use server WS URL". +- No code path changes the URL by itself. +- A new browser test (`tests/browser_decoder_url.js`) types a new URL, saves and connects, and comes online on that port, so the app flow works. What remains on the user's side is reachability of port 9443 from the browser (firewall/UFW only opened 9000-9003 in the README). + +- [x] Found while checking: "Connect now" used the saved URL even when the field showed a typed one. It now saves typed decoder URLs first. Covered by the same browser test (connects to the typed port without pressing Save). + +Verified: 265 unit and 75 browser scenarios pass. + ## Documentation maintenance - [x] Update the architecture's module/dependency inventory as modules change. diff --git a/package-lock.json b/package-lock.json index 281b2c0..e61ca72 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.39.1", + "version": "1.39.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.39.1", + "version": "1.39.2", "hasInstallScript": true, "dependencies": { "better-sqlite3": "^12.11.1", diff --git a/package.json b/package.json index c36cfce..c3adb9e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.39.1", + "version": "1.39.2", "private": true, "description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence", "engines": { diff --git a/src/settings.js b/src/settings.js index 048ebcb..a676c41 100644 --- a/src/settings.js +++ b/src/settings.js @@ -701,7 +701,16 @@ Erik Eriksson;654321;4WD;Associated;; renderView(); }); - document.getElementById("settingsConnect")?.addEventListener("click", connectDecoder); + // Connect uses what the fields show: unsaved decoder URLs are saved first (connecting to the + // previously saved port while the field said another one was confusing). + document.getElementById("settingsConnect")?.addEventListener("click", () => { + const formNode = document.getElementById("settingsForm"); + const typed = formNode ? new FormData(formNode) : null; + const changed = typed && ["wsUrl", "splitWsUrl", "pitEntryWsUrl", "pitExitWsUrl"] + .some((name) => typed.has(name) && String(typed.get(name) || "").trim() !== String(state.settings[name] || "")); + if (changed) formNode.requestSubmit(); + connectDecoder(); + }); document.getElementById("settingsUseCurrentOrigin")?.addEventListener("click", () => { state.settings.backendUrl = pageOrigin; saveState(); diff --git a/tests/browser_decoder_url.js b/tests/browser_decoder_url.js new file mode 100644 index 0000000..afb5db0 --- /dev/null +++ b/tests/browser_decoder_url.js @@ -0,0 +1,42 @@ +import assert from "node:assert/strict"; +import { startFakeDecoder } from "./browser_fake_decoder.js"; + +// A user running AMMC themselves on another port: type the new WebSocket URL in Settings -> +// Connection, press Save, then Connect now - the decoder must come online on that port. +export async function runDecoderUrlSmoke({ evaluate, navigate, savedState, waitFor, base }) { + const decoder = await startFakeDecoder(); + const before = await savedState(); + try { + await navigate("settings", "settingsForm"); + await evaluate(`document.querySelector('[data-settings-tab="connection"]').click()`); + const url = `ws://127.0.0.1:${decoder.port}`; + await evaluate(`(() => { + const input = document.querySelector('#settingsForm [name="wsUrl"]'); + input.value = ${JSON.stringify(url)}; + input.dispatchEvent(new Event("input", { bubbles: true })); + input.dispatchEvent(new Event("change", { bubbles: true })); + document.querySelector('#settingsForm button[type="submit"]').click(); + })()`); + await waitFor(async () => (await savedState()).settings.wsUrl === url, "the new WebSocket URL is saved"); + await evaluate(`document.getElementById("settingsConnect").click()`); + await waitFor(async () => evaluate('document.getElementById("connectionBadge")?.classList.contains("badge-online")'), "decoder online on the new port"); + assert.equal(await evaluate(`document.querySelector('#settingsForm [name="wsUrl"]').value`), url, "the field still shows the new URL after the re-render"); + console.log("PASS typing a new decoder WebSocket URL, Save and Connect now connects on that port"); + + // Typing a URL and pressing Connect now without Save: the typed URL is saved and used. + const second = await startFakeDecoder(); + try { + const secondUrl = `ws://127.0.0.1:${second.port}`; + await evaluate(`(() => { const input = document.querySelector('#settingsForm [name="wsUrl"]'); input.value = ${JSON.stringify(secondUrl)}; document.getElementById("settingsConnect").click(); })()`); + await waitFor(async () => (await savedState()).settings.wsUrl === secondUrl, "the typed URL is saved by Connect now"); + await waitFor(async () => second.totalConnections() > 0, "connected to the typed port"); + console.log("PASS Connect now uses the URL in the field even without pressing Save"); + } finally { + await second.close(); + } + } finally { + const current = await savedState(); + await fetch(base + "/api/state", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ ...current, settings: { ...current.settings, wsUrl: before.settings.wsUrl, autoReconnect: false } }) }); + await decoder.close(); + } +} diff --git a/tests/browser_smoke.js b/tests/browser_smoke.js index e9828a8..edce185 100644 --- a/tests/browser_smoke.js +++ b/tests/browser_smoke.js @@ -17,6 +17,7 @@ import { runCorrectionsScopeSmoke } from "./browser_corrections_scope.js"; import { runDriversPageSmoke } from "./browser_drivers_page.js"; import { runSeriesSmoke } from "./browser_series.js"; import { runTrainingSourceSmoke } from "./browser_training_source.js"; +import { runDecoderUrlSmoke } from "./browser_decoder_url.js"; import { runObsPopupSmoke } from "./browser_obs_popup.js"; import { runDecoderReconnectSmoke } from "./browser_decoder_reconnect.js"; import assert from "node:assert/strict"; @@ -164,6 +165,7 @@ try { await runDriversPageSmoke({ evaluate, navigate, savedState, waitFor, base }); await runSeriesSmoke({ evaluate, navigate, savedState, waitFor, base, dialogs }); await runTrainingSourceSmoke({ evaluate, navigate, savedState, waitFor, base }); + await runDecoderUrlSmoke({ evaluate, navigate, savedState, waitFor, base }); await runRaceDaySmoke({ evaluate, navigate, fill, savedState, waitFor, pause, base, dialogs }); await runRaceDayStartSequencesSmoke({ evaluate, navigate, waitFor, pause, base, dialogs }); await runObsPopupSmoke({ evaluate, navigate, fill, savedState, waitFor, pause, base, debugPort, dialogs, realClick });