From 28036ab589be404525a72aeb1c6ec85ccd622628 Mon Sep 17 00:00:00 2001 From: Stan Grams Date: Wed, 11 Mar 2026 07:37:52 +0100 Subject: [PATCH] [feat](trx-frontend-http): sync mode picker to active virtual channel - Add vchanSyncModeDisplay() in vchan.js; called from vchanSyncAccentUI() and vchanSubscribe() so the mode picker always reflects the active virtual channel's mode on switch and on channel-list refresh - Guard the rig-state mode picker update in render() so it is skipped when vchanIsOnVirtual() is true, preventing primary-channel mode from overwriting the virtual channel selection Note: per-channel audio and decoder output require server-side protocol changes (separate Opus streams per virtual channel) and are not yet implemented. Co-Authored-By: Claude Sonnet 4.6 Signed-off-by: Stan Grams --- .../trx-frontend-http/assets/web/app.js | 7 ++++++- .../trx-frontend-http/assets/web/plugins/vchan.js | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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 6d19dc4..9ec0880 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 @@ -2445,7 +2445,12 @@ function render(update) { if (update.status && update.status.mode) { const mode = normalizeMode(update.status.mode); const modeUpper = mode ? mode.toUpperCase() : ""; - modeEl.value = modeUpper; + // When subscribed to a virtual channel the mode picker must reflect + // that channel's mode, not the primary rig mode. Skip the update here; + // vchan.js will apply the correct mode via vchanSyncModeDisplay(). + if (typeof vchanIsOnVirtual !== "function" || !vchanIsOnVirtual()) { + modeEl.value = modeUpper; + } if (modeUpper === "WFM" && lastModeName !== "WFM") { setJogDivisor(10); resetRdsDisplay(); diff --git a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/vchan.js b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/vchan.js index a584d87..3786c8a 100644 --- a/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/vchan.js +++ b/src/trx-client/trx-frontend/trx-frontend-http/assets/web/plugins/vchan.js @@ -158,6 +158,7 @@ async function vchanSubscribe(channelId) { } vchanActiveId = channelId; vchanRender(); + vchanSyncModeDisplay(); } catch (e) { console.error("vchan: subscribe error", e); } @@ -198,6 +199,18 @@ function vchanUpdateFreqDisplay() { } } +// Sync the mode picker to the active virtual channel's mode. +// Called whenever the active channel changes or the channel list is refreshed. +function vchanSyncModeDisplay() { + const modeEl = document.getElementById("mode"); + if (!modeEl) return; + if (vchanIsOnVirtual()) { + const ch = vchanActiveChannel(); + if (ch && ch.mode) modeEl.value = ch.mode.toUpperCase(); + } + // When on primary channel, app.js rig-state updates handle the picker. +} + // Add / remove the vchan accent class from the freq and BW inputs. function vchanSyncAccentUI() { const onVirtual = vchanIsOnVirtual(); @@ -207,6 +220,7 @@ function vchanSyncAccentUI() { if (bwEl) bwEl.classList.toggle("vchan-ch-active", onVirtual); if (onVirtual) { vchanUpdateFreqDisplay(); + vchanSyncModeDisplay(); } else if (typeof _origRefreshFreqDisplay === "function") { _origRefreshFreqDisplay(); }