[fix](trx-frontend-http): remove global state mutation from select_rig

select_rig no longer mutates remote_active_rig_id — only the per-session
mapping is updated. This eliminates cross-tab leaking entirely: each tab
carries its own rig_id via the session manager, /events?rig_id, and
/status?rig_id query params.

The global remote_active_rig_id now only serves as the startup default
for brand-new sessions that have no rig_id yet.

Also fix the About section to show the per-tab lastActiveRigId instead
of the server's global active_rig_id.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
2026-03-22 00:20:34 +01:00
parent f3d8d349b1
commit 0e195bd3c6
2 changed files with 4 additions and 9 deletions
@@ -3116,8 +3116,8 @@ function render(update) {
if (typeof update.clients === "number") { if (typeof update.clients === "number") {
document.getElementById("about-clients").textContent = update.clients; document.getElementById("about-clients").textContent = update.clients;
} }
if (typeof update.active_rig_id === "string" && update.active_rig_id.length > 0) { if (lastActiveRigId) {
document.getElementById("about-active-rig").textContent = update.active_rig_id; document.getElementById("about-active-rig").textContent = lastActiveRigId;
} }
if (Array.isArray(update.rig_ids)) { if (Array.isArray(update.rig_ids)) {
applyRigList(update.active_rig_id, update.rig_ids); applyRigList(update.active_rig_id, update.rig_ids);
@@ -1633,13 +1633,8 @@ pub async fn select_rig(
))); )));
} }
// Always update the global active rig — the remote client uses it to // Only update per-session rig selection — never mutate the global
// route commands to the correct rig on the server. // active rig so that other tabs/sessions are unaffected.
if let Ok(mut active) = context.remote_active_rig_id.lock() {
*active = Some(rig_id.to_string());
}
// Update per-session rig selection if session_id is provided.
if let Some(ref sid) = query.session_id { if let Some(ref sid) = query.session_id {
if let Ok(uuid) = Uuid::parse_str(sid) { if let Ok(uuid) = Uuid::parse_str(sid) {
session_rig_mgr.set_rig(uuid, rig_id.to_string()); session_rig_mgr.set_rig(uuid, rig_id.to_string());