[feat](trx-frontend-http): per-session SSE rig selection
Add SessionRigManager to track per-SSE-session rig_id so different browser tabs can independently select rigs without interfering. The /events SSE stream filters state updates by session rig (falling back to the global active rig), and /select_rig accepts an optional session_id to update the per-session mapping. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -599,6 +599,7 @@ let sdrSquelchSupported = false;
|
||||
let lastRigIds = [];
|
||||
let lastRigDisplayNames = {};
|
||||
let lastActiveRigId = null;
|
||||
let sseSessionId = null;
|
||||
const originalTitle = document.title;
|
||||
const savedTheme = loadSetting("theme", null);
|
||||
|
||||
@@ -3176,6 +3177,7 @@ async function pollFreshSnapshot() {
|
||||
function connect() {
|
||||
if (es) {
|
||||
es.close();
|
||||
sseSessionId = null;
|
||||
}
|
||||
if (esHeartbeat) {
|
||||
clearInterval(esHeartbeat);
|
||||
@@ -3210,6 +3212,10 @@ function connect() {
|
||||
lastEventAt = Date.now();
|
||||
});
|
||||
es.addEventListener("session", evt => {
|
||||
try {
|
||||
const d = JSON.parse(evt.data);
|
||||
sseSessionId = d.session_id || null;
|
||||
} catch (_) {}
|
||||
if (typeof vchanHandleSession === "function") vchanHandleSession(evt.data);
|
||||
});
|
||||
es.addEventListener("channels", evt => {
|
||||
@@ -3361,7 +3367,8 @@ async function switchRigFromSelect(selectEl) {
|
||||
// follow. Commands already carry rig_id per-tab, but SSE is still
|
||||
// global until per-session streams are implemented.
|
||||
try {
|
||||
await postPath(`/select_rig?rig_id=${encodeURIComponent(selectEl.value)}`);
|
||||
const sidParam = sseSessionId ? `&session_id=${encodeURIComponent(sseSessionId)}` : "";
|
||||
await postPath(`/select_rig?rig_id=${encodeURIComponent(selectEl.value)}${sidParam}`);
|
||||
} catch (err) {
|
||||
console.error("select_rig failed:", err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user