Release v0.34.0 — Series-4 parity, and most of Blastware's report from the event file alone #59

Merged
serversdown merged 245 commits from dev into main 2026-11-04 18:19:24 -05:00
Showing only changes of commit 3f249e2322 - Show all commits
+40 -4
View File
@@ -1664,7 +1664,8 @@ async function deviceFetch(action, params = {}, opts = {}) {
const body = await r.json().catch(() => ({}));
if (!r.ok) {
const d = body.detail;
const err = new Error(typeof d === 'string' ? d : d ? (d.message || JSON.stringify(d)) : r.statusText);
const err = new Error(body.outcome ? changeSummary(body)
: typeof d === 'string' ? d : d ? (d.message || JSON.stringify(d)) : r.statusText);
err.status = r.status; err.body = body;
throw err;
}
@@ -1908,14 +1909,17 @@ function updateMonitorPanel(s) {
// Start/stop: in serial mode only for a unit whose series its own answer
// confirmed; without a serial, as before (0x96/0x97 mean the same on both).
let lastMonitoring = null;
let changeInFlight = false; // one start/stop at a time: a double click must not send twice
function setMonitorButtons() {
const allowed = serialMode() ? controlsFor(currentUnit()).startStop : Boolean(devHost());
const allowed = !changeInFlight
&& (serialMode() ? controlsFor(currentUnit()).startStop : Boolean(devHost()));
document.getElementById('mon-start-btn').disabled = !allowed || lastMonitoring === true;
document.getElementById('mon-stop-btn').disabled = !allowed || lastMonitoring === false;
}
async function startMonitoring() {
if (!devHost()) return;
if (serialMode()) { await changeMonitoring('start'); return; }
const btn = document.getElementById('mon-start-btn');
btn.disabled = true; btn.textContent = '…';
setStatus('Starting monitoring…', 'loading');
@@ -1966,6 +1970,7 @@ async function _pollMonitorConfirm(attempt) {
async function stopMonitoring() {
if (!devHost()) return;
if (serialMode()) { await changeMonitoring('stop'); return; }
const btn = document.getElementById('mon-stop-btn');
btn.disabled = true; btn.textContent = '…';
setStatus('Stopping monitoring…', 'loading');
@@ -1980,6 +1985,37 @@ async function stopMonitoring() {
btn.textContent = '■ Stop';
}
// Serial mode: SFM's audited change -- identity and state read first, one send,
// never retried, then read back. The result body says what the unit did, on a
// 409/502 too; only the read that follows decides the panel.
async function changeMonitoring(action) {
const serial = normSerial(currentUnit().serial);
const verb = action === 'start' ? 'Start' : 'Stop';
if (!confirm(`${verb} monitoring on ${serial}?`)) return;
const btn = document.getElementById(action === 'start' ? 'mon-start-btn' : 'mon-stop-btn');
const label = btn.textContent;
changeInFlight = true; setMonitorButtons(); btn.textContent = '…';
setStatus(action === 'start' ? 'Starting — the unit runs its sensor check first (about 35 s)'
: 'Stopping…', 'loading');
try {
const r = await deviceRequest(action);
const body = await r.json().catch(() => ({}));
if (body.outcome) {
setStatus(changeSummary(body), r.ok ? 'ok' : 'error');
} else {
const d = body.detail;
setStatus(`${verb} monitoring failed: ${typeof d === 'string' ? d : d ? JSON.stringify(d) : r.statusText}`, 'error');
}
} catch (e) {
// No reply is not "nothing sent": the request may have reached the unit.
setStatus(`${verb} monitoring: no reply from SFM (${e.message}) — it may have been sent; `
+ `check the unit's state and GET /db/device_commands`, 'error');
}
changeInFlight = false; btn.textContent = label;
await refreshMonitorStatus();
setMonitorButtons();
}
// ── Device tab ─────────────────────────────────────────────────────────────────
function populateDeviceTab() {
document.getElementById('no-device-msg').style.display = 'none';
@@ -2126,8 +2162,8 @@ async function diagStopMonitoring() {
const btn = document.getElementById('diag-stop-btn');
btn.disabled = true; diagResult('diag-stop-result', 'Sending…');
try {
await deviceFetch('stop');
diagResult('diag-stop-result', 'Stop acknowledged — recording halted.', 'ok');
const r = await deviceFetch('stop');
diagResult('diag-stop-result', r.outcome ? changeSummary(r) : 'Stop acknowledged — recording halted.', 'ok');
refreshDiagnostics();
} catch (e) {
diagResult('diag-stop-result', `Failed: ${e.message}`, 'error');