From c9d204ad1c36ce64f89f01867ceaa766a3c9cf02 Mon Sep 17 00:00:00 2001 From: Stan Grams Date: Tue, 10 Mar 2026 23:22:49 +0100 Subject: [PATCH] [fix](trx-frontend-http): populate scheduler rig list after SSE delivers rig data initScheduler() runs before the first SSE event, so lastRigIds is empty. Now applyRigList() calls reloadSchedulerRigSelect() whenever the rig list updates, and renderSchedulerRigSelect() loads the config for the first rig if currentRigId was previously unset. Co-Authored-By: Claude Sonnet 4.6 Signed-off-by: Stan Grams --- .../trx-frontend-http/assets/web/app.js | 1 + .../assets/web/plugins/scheduler.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js index 6bceed6..c824683 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/app.js @@ -745,6 +745,7 @@ function applyRigList(activeRigId, rigIds, displayNames) { const disableSwitch = lastRigIds.length === 0 || !authRole || authRole === "rx"; populateRigPicker(headerRigSwitchSelect, lastRigIds, activeRigId, disableSwitch); updateRigSubtitle(activeRigId); + if (typeof reloadSchedulerRigSelect === "function") reloadSchedulerRigSelect(); } async function refreshRigList() { diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/scheduler.js b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/scheduler.js index 2a8df39..e0a660d 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/scheduler.js +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/scheduler.js @@ -42,13 +42,8 @@ if (!sel) return; // Populate from global rig list exposed by app.js const rigs = (typeof getAvailableRigIds === "function") ? getAvailableRigIds() : []; + if (!rigs.length) return; // wait until rig list arrives sel.innerHTML = ""; - if (!rigs.length) { - const opt = document.createElement("option"); - opt.textContent = "No rigs available"; - sel.appendChild(opt); - return; - } rigs.forEach(function (id) { const opt = document.createElement("option"); opt.value = id; @@ -56,6 +51,13 @@ if (id === currentRigId) opt.selected = true; sel.appendChild(opt); }); + // If currentRigId was unset, pick the first available rig and load its config. + if (!currentRigId || !rigs.includes(currentRigId)) { + currentRigId = rigs[0]; + sel.value = currentRigId; + loadScheduler(); + pollStatus(); + } } // -------------------------------------------------------------------------