From 842ee6f0767fc69093384a29fe9997d1fd947405 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Mar 2026 17:33:47 +0000 Subject: [PATCH] [fix](trx-frontend-http): stop fetching /bookmarks on every SSE state update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit applyRigList() was called on every SSE state update (since `remotes` is always present in the payload), and it unconditionally called bmFetch() which fires 2x GET /bookmarks (list + overlay). At the default poll rate this generated ~20 bookmark fetches/second — visible as constant GET /bookmarks traffic on each spectrum render cycle. Now track the previous rig list + active rig as a key and only re-fetch bookmarks (and re-init scheduler/background-decode) when the rig list actually changes. https://claude.ai/code/session_017g7VNMb6CChaiWrfzVBhbR Signed-off-by: Claude --- .../trx-frontend-http/assets/web/app.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 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 4c84564..5190288 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 @@ -1027,7 +1027,11 @@ function updateRigSubtitle(activeRigId) { function applyRigList(activeRigId, rigIds, displayNames) { if (!Array.isArray(rigIds)) return; - lastRigIds = rigIds.filter((id) => typeof id === "string" && id.length > 0); + const nextIds = rigIds.filter((id) => typeof id === "string" && id.length > 0); + // Detect whether the rig list or active rig actually changed so we can + // skip expensive bookmark re-fetches on every SSE state update. + const prevKey = lastRigIds.join("\0") + "|" + (lastActiveRigId || ""); + lastRigIds = nextIds; if (displayNames && typeof displayNames === "object") { lastRigDisplayNames = { ...displayNames }; } @@ -1045,13 +1049,17 @@ function applyRigList(activeRigId, rigIds, displayNames) { const aboutActive = document.getElementById("about-active-rig"); if (aboutActive) aboutActive.textContent = lastActiveRigId; } + const nextKey = lastRigIds.join("\0") + "|" + (lastActiveRigId || ""); + const rigListChanged = prevKey !== nextKey; const disableSwitch = lastRigIds.length === 0 || !authRole || authRole === "rx"; populateRigPicker(headerRigSwitchSelect, lastRigIds, lastActiveRigId, disableSwitch); updateRigSubtitle(lastActiveRigId); - if (typeof setSchedulerRig === "function") setSchedulerRig(lastActiveRigId); - if (typeof setBackgroundDecodeRig === "function") setBackgroundDecodeRig(lastActiveRigId); - if (typeof bmPopulateScopePicker === "function") bmPopulateScopePicker(); - if (typeof bmFetch === "function") bmFetch(document.getElementById("bm-category-filter")?.value || ""); + if (rigListChanged) { + if (typeof setSchedulerRig === "function") setSchedulerRig(lastActiveRigId); + if (typeof setBackgroundDecodeRig === "function") setBackgroundDecodeRig(lastActiveRigId); + if (typeof bmPopulateScopePicker === "function") bmPopulateScopePicker(); + if (typeof bmFetch === "function") bmFetch(document.getElementById("bm-category-filter")?.value || ""); + } updateMapRigFilter(); }