Fix agent/local mode state sync and process cleanup

Agent fixes:
- Fix stop not killing secondary processes (pager_rtl, aprs_rtl, rtlamr_tcp)
- Modes using piped processes now properly terminate all child processes

UI state sync fixes:
- Add syncLocalModeStates() to check local status when switching to local
- Fix switchMode() to re-sync with agent/local when changing mode tabs
- Only stop local modes when actually in local mode
- UI now correctly reflects running state when switching agents or modes
This commit is contained in:
cemaxecuter
2026-01-27 09:31:14 -05:00
parent afccb6fe0a
commit a5f574062d
3 changed files with 97 additions and 7 deletions
+19 -7
View File
@@ -2092,16 +2092,28 @@
// Mode switching
function switchMode(mode) {
// Stop any running scans when switching modes
if (isRunning) stopDecoding();
if (isSensorRunning) stopSensorDecoding();
if (isWifiRunning) stopWifiScan();
if (isBtRunning) stopBtScan();
if (isAprsRunning) stopAprs();
if (isTscmRunning) stopTscmSweep();
// Only stop local scans if in local mode (not agent mode)
const isAgentMode = typeof currentAgent !== 'undefined' && currentAgent !== 'local';
if (!isAgentMode) {
if (isRunning) stopDecoding();
if (isSensorRunning) stopSensorDecoding();
if (isWifiRunning) stopWifiScan();
if (isBtRunning) stopBtScan();
if (isAprsRunning) stopAprs();
if (isTscmRunning) stopTscmSweep();
}
currentMode = mode;
// Sync mode state with current agent/local after switching
if (isAgentMode && typeof syncAgentModeStates === 'function') {
// Re-sync with agent to update this mode's UI state
syncAgentModeStates(currentAgent);
} else if (!isAgentMode && typeof syncLocalModeStates === 'function') {
// Sync with local status
syncLocalModeStates();
}
// Close dropdowns and update active state
closeAllDropdowns();
updateDropdownActiveState();