fix(sfm): page polish from the 1c bench -- #6, #10, #12, #16 (Batch 2)

- #6 Config tab by serial: the empty legacy edit form stays hidden (settings
  are read-only until phase 5); the settings box shows from the start, 'Not read
  yet', and a different unit's settings are never left on screen.
- #10 A start/stop that went out but was not confirmed is no longer called
  'failed'.  The route now adds 'sent' (acknowledged / unknown) and 'audit_id'
  to a ChangeUnconfirmed -- same status, same message -- and the page says
  'Start monitoring not confirmed: <what happened, audit record>'.
- #12 Device tab by serial: the empty legacy Compliance/Project tables are
  hidden behind a pointer to the Config tab; a Micromate's Firmware card reads
  'Thor line (version not read)' (its version string is in 0x01, undecoded).
- #16 A 504 with nothing sent adds: the connection opened, so the modem is
  reachable -- another program (THOR or Blastware) may be holding the line, or
  the unit is busy.  Measured 2026-10-29: THOR polling leaves SFM a 0-byte 504.

New logic lives in sfm/static/device_routing.js (firmwareLabel,
deviceErrorText, changeErrorText, serialPanes) under Node tests; the page glue
in sfm_webapp.js only applies them.  Checked in jsdom against the real page
(served at a fake origin, /static from disk): all four, legacy mode unchanged,
no script errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SyJ2ip3Krb6dtdv2cXua44
This commit is contained in:
serversdownandClaude Opus 5.5 committed 2026-11-02 16:22:22 -05:00
1 parent 2b886c4f39
commit 8123d75d72
7 files changed
+163 -22

No files matched your search

+14 -3
View File
@@ -86,7 +86,7 @@ from sfm import db_snapshot
from sfm.event_ingest import backfill_series3_event, persist_download
import dataclasses
from sfm.device_access import DeviceAccess, DeviceError, UnitAddress
from sfm.device_access.errors import BadRequest
from sfm.device_access.errors import BadRequest, ChangeUnconfirmed
from sfm.device_access.series import normalise_serial, series_for_serial
from sfm.audit import DbAudit
@@ -400,9 +400,20 @@ def _via_device_access(fn) -> dict:
def _change_response(fn) -> JSONResponse:
"""Run a start/stop; the ChangeResult is the body, its outcome picks the status.
DeviceError mapping is _via_device_access's -- not repeated here.
DeviceError mapping is _via_device_access's -- not repeated here. A change
that went out, or may have (ChangeUnconfirmed), keeps that status and message
and adds `sent` ("acknowledged" / "unknown") and `audit_id`, so a client can
tell it from a failure that sent nothing without matching the wording
(bench finding #10, 2026-11-02).
"""
body = _via_device_access(fn)
try:
body = _via_device_access(fn)
except HTTPException as exc:
cause = exc.__cause__
if not isinstance(cause, ChangeUnconfirmed):
raise
return JSONResponse(status_code=exc.status_code,
content={"detail": exc.detail, "sent": cause.sent, "audit_id": cause.audit_id})
# An allow-list: only a dry run, a skip, or a change read back as made is a 200.
ok = (body["outcome"] in ("dry_run", "skipped")
or (body["outcome"] == "sent" and body["verified"] == "ok"))