From 0e195bd3c670e022fd39a449c4891f689a7d57aa Mon Sep 17 00:00:00 2001 From: Stan Grams Date: Sun, 22 Mar 2026 00:20:34 +0100 Subject: [PATCH] [fix](trx-frontend-http): remove global state mutation from select_rig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Stan Grams --- .../trx-frontend/trx-frontend-http/assets/web/app.js | 4 ++-- src/trx-client/trx-frontend/trx-frontend-http/src/api.rs | 9 ++------- 2 files changed, 4 insertions(+), 9 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 66872b6..d538244 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 @@ -3116,8 +3116,8 @@ function render(update) { if (typeof update.clients === "number") { document.getElementById("about-clients").textContent = update.clients; } - if (typeof update.active_rig_id === "string" && update.active_rig_id.length > 0) { - document.getElementById("about-active-rig").textContent = update.active_rig_id; + if (lastActiveRigId) { + document.getElementById("about-active-rig").textContent = lastActiveRigId; } if (Array.isArray(update.rig_ids)) { applyRigList(update.active_rig_id, update.rig_ids); diff --git a/src/trx-client/trx-frontend/trx-frontend-http/src/api.rs b/src/trx-client/trx-frontend/trx-frontend-http/src/api.rs index 1e408e4..71214b9 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/src/api.rs +++ b/src/trx-client/trx-frontend/trx-frontend-http/src/api.rs @@ -1633,13 +1633,8 @@ pub async fn select_rig( ))); } - // Always update the global active rig — the remote client uses it to - // route commands to the correct rig on the server. - 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. + // Only update per-session rig selection — never mutate the global + // active rig so that other tabs/sessions are unaffected. if let Some(ref sid) = query.session_id { if let Ok(uuid) = Uuid::parse_str(sid) { session_rig_mgr.set_rig(uuid, rig_id.to_string());