morse: fix stop timeout causing restart loop via checkStatus

When the stop POST timed out (5s), lifecycle was set to 'idle' on error,
allowing checkStatus to see running=true and reconnect SSE. Now:
- stop .then() stays in 'stopping' on timeout/error instead of going idle
- checkStatus skips reconnect when lifecycle is 'stopping' post-timeout
  but still transitions to idle when server confirms running=false
- LOCAL_STOP_TIMEOUT_MS raised from 5s to 12s to match server cleanup time

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Smittix
2026-02-26 22:17:26 +00:00
parent dc0775f7df
commit 818d9c9f90

View File

@@ -7,7 +7,7 @@ var MorseMode = (function () {
var SETTINGS_KEY = 'intercept.morse.settings.v3';
var STATUS_POLL_MS = 5000;
var LOCAL_STOP_TIMEOUT_MS = 5000;
var LOCAL_STOP_TIMEOUT_MS = 12000;
var START_TIMEOUT_MS = 60000;
var state = {
@@ -403,6 +403,9 @@ var MorseMode = (function () {
appendDiagLine('[stop] still alive: ' + data.alive.join(', '));
}
if (!data || data.status === 'error') {
return data; // Stay in 'stopping' — let checkStatus resolve
}
setLifecycle('idle');
setStatusText('Standby');
return data;
@@ -422,9 +425,10 @@ var MorseMode = (function () {
.then(function (data) {
if (!data || typeof data !== 'object') return;
// Guard against in-flight polls that were dispatched before stop
if (state.stopPromise || state.lifecycle === 'stopping') return;
if (state.stopPromise) return;
if (data.running) {
if (state.lifecycle === 'stopping') return; // Don't override post-timeout stopping
if (data.state === 'starting') {
setLifecycle('starting');
} else if (data.state === 'stopping') {