Step 1: the settings page, read-only, live on NA Ingest at port 8020

Overview (problems in the room with the hold action, the live deck, one line per computer),
Keys (both pages, what each key will say and what holding does), Computers (map with the keys
that turn red, cards with a light per thing that runs there from the watchdog's snapshot and a
read-only probe, Gear, Setup), Logs, History (the installer's copies for now), Help (four cards,
the generated key guide, cheat sheet and Where things are, glossary, Companion facts), Site setup
and Fixes read-only. The editing code is checked (with a lockout) but nothing can change yet.

Also: faults are attributed to the computers their check is about; the installer refuses while a
HyperDeck is recording (--now overrides); the Lighting PC's MIDI session is listed; the probes read
sudo's answer correctly and expand $HOME outside the quotes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
2026-10-14 12:18:36 -04:00
co-authored by Claude Fable 5.1
parent 2343a27529
commit 01c18ba5ef
9 changed files with 348 additions and 45 deletions
+70 -24
View File
@@ -163,11 +163,27 @@ class Site:
if f["level"] not in ("err", "warn"):
continue
text = f["msg"] if f["msg"] and f["msg"] != tile["label"] else tile["label"]
hold = keyguide.hold_words(tile, cfg)
hold = keyguide.plain(keyguide.hold_words(tile, cfg))
problems.append({"key": tid, "label": tile["label"], "text": "%s: %s" % (tile["label"], f["msg"]),
"level": f["level"], "acked": f.get("acked"), "since": f.get("since"),
"action": "hold the %s key (%s)" % (tile["label"], hold) if hold and not hold.startswith("nothing")
else "no automatic fix: check the device"})
fresh = snap.get("time") and now - snap["time"] < 30
if not problems and deck and not fresh:
# The watchdog has not written a snapshot (older code, or just started): read the deck itself.
for tid, s in deck.items():
tile = tiles.get(tid)
if not tile or tile.get("members") or tile.get("kind") == "master":
continue # groups and ALL repeat their members
if s.get("b") not in (0xFF0000, 0x8B0000, 0xFFA000, 0x3A0000):
continue
lines = (s.get("x") or "").split("\n")
text = " ".join(lines[1:]) if len(lines) > 1 else lines[0]
hold = keyguide.plain(keyguide.hold_words(tile, cfg))
problems.append({"key": tid, "label": tile["label"], "text": "%s: %s" % (tile["label"], text),
"level": "warn" if s.get("b") == 0xFFA000 else "err", "acked": s.get("b") == 0x8B0000, "since": None,
"action": "hold the %s key (%s)" % (tile["label"], hold) if hold and not hold.startswith("nothing")
else "no automatic fix: check the device"})
if started and started.get("config_sha") and started["config_sha"] != self.cfg_sha:
needs.append("The watchdog is running an older settings file than the one on disk (restart it to pick up the change).")
pages = self.pages_state()
@@ -176,7 +192,8 @@ class Site:
return {
"time": now, "site": cfg.get("site", {}), "deck": deck, "heartbeat_age": (now - hb) if hb else None,
"companion_ok": companion_ok, "watchdog": self.watchdog_state(started, hb, now),
"live": live, "running": running, "service_on": snap.get("service_on"), "alarms_override": snap.get("alarms_override"),
"live": live, "running": running, "service_on": snap.get("service_on") if fresh else None,
"alarms_override": snap.get("alarms_override") if fresh else None,
"auto_fix": {"phrase": schema.phrases(cfg)["auto_fix"], "state": snap.get("auto_fix")},
"problems": sorted(problems, key=lambda p: (p["level"] != "err", p["since"] or 0)), "needs": needs,
"computers": self.computer_lines(snap), "pages": pages, "snapshot_age": (now - snap["time"]) if snap.get("time") else None,
@@ -196,34 +213,63 @@ class Site:
state["heartbeat_fresh"] = bool(hb and now - hb < cfg_stale(self.cfg))
return state
def check_hosts(self, cfg):
"""{(key id, check identity): {computer aliases}}: which computers a check is about - the Mac a
MIDI session or remote command runs on, the peer's computer when a computer is named like it,
the computer a check's fix runs on, this Mac for local things."""
hosts = cfg.get("hosts", {})
me = next((a for a, h in hosts.items() if h.get("self")), None)
by_session = {}
for alias, h in hosts.items():
for run in h.get("runs", []):
if run.get("kind") == "midi_session" and run.get("name"):
by_session[run["name"]] = alias
if h.get("name"):
by_session.setdefault(h["name"], alias)
out = {}
for t in cfg["tiles"]:
for c in t.get("checks", []):
who = set()
if c["type"] in ("remote", "midi_peer") and c.get("host"):
who.add(c["host"])
elif c["type"] == "midi_peer" and me:
who.add(me)
if c["type"] == "midi_peer" and c.get("peer") in by_session:
who.add(by_session[c["peer"]])
if c["type"] in ("launchd", "process", "disk", "pref", "spotify", "atem", "midi_rx") and me:
who.add(me)
fx = c.get("fix")
for f in (fx.values() if isinstance(fx, dict) else [fx]):
fix = cfg.get("fixes", {}).get(f) if f else None
if fix and fix.get("host"):
who.add(fix["host"])
elif fix and fix.get("kind") in ("local", "spotify") and me:
who.add(me)
if t.get("hold_always"):
fix = cfg["fixes"].get(t["hold_always"], {})
if fix.get("host"):
who.add(fix["host"])
out[(t["id"], sp.check_identity(c))] = who
return out
def computer_lines(self, snap):
"""One line per computer: a status word and the reason, from what the watchdog sees."""
cfg = self.cfg
live = self.read_json("machines-live.json", {}) or {}
tiles_by_host = {}
for t in cfg["tiles"]:
for c in t.get("checks", []):
h = c.get("host") if c["type"] in ("remote", "midi_peer") else None
if h:
tiles_by_host.setdefault(h, set()).add(t["id"])
for fid, fix in cfg.get("fixes", {}).items():
if fix.get("host"):
for t in cfg["tiles"]:
own = set()
for c in t.get("checks", []):
fx = c.get("fix")
own |= set(fx.values()) if isinstance(fx, dict) else ({fx} if fx else set())
if fid in own or t.get("hold_always") == fid:
tiles_by_host.setdefault(fix["host"], set()).add(t["id"])
owners = self.check_hosts(cfg)
tiles_by_host, labels = {}, {t["id"]: t["label"] for t in cfg["tiles"]}
for (tid, _), who in owners.items():
for alias in who:
tiles_by_host.setdefault(alias, set()).add(tid)
lines = []
for alias, h in cfg.get("hosts", {}).items():
probe = live.get(alias) or {}
word, reason = "OK", ""
faults = []
for tid in sorted(tiles_by_host.get(alias, [])):
for f in (snap.get("faults") or {}).get(tid, []):
if f["level"] == "err" and (f["type"] in ("remote", "midi_peer") or True):
faults.append("%s %s" % (tiles_by_host and next(t["label"] for t in cfg["tiles"] if t["id"] == tid), f["msg"]))
for tid, fs in (snap.get("faults") or {}).items():
for f in fs:
if f["level"] == "err" and alias in owners.get((tid, f.get("check")), set()):
faults.append("%s %s" % (labels.get(tid, tid), f["msg"]))
if probe and not probe.get("reachable") and not h.get("self"):
word, reason = "Problem", "cannot be reached (%s)" % probe.get("error", "no answer")
elif faults:
@@ -453,14 +499,14 @@ class Site:
if c.get("tag"):
ws = ["%s %s" % (c["tag"], w) for w in ws]
words += ws
tiles.append(dict(t, says=sorted(set(words)), holding=re.sub(r"<[^>]+>", "", keyguide.hold_words(t, cfg)),
checks=[dict(c, sentence=re.sub(r"<[^>]+>", "", keyguide.check_sentence(c, cfg)),
tiles.append(dict(t, says=sorted(set(words)), holding=keyguide.plain(keyguide.hold_words(t, cfg)),
checks=[dict(c, sentence=keyguide.plain(keyguide.check_sentence(c, cfg)),
identity=sp.check_identity(c)) for c in t.get("checks", [])]))
rp = cfg.get("restart_page")
keys = []
if rp:
for k in rp["keys"]:
keys.append(dict(k, holding=re.sub(r"<[^>]+>", "", keyguide.fix_words(k["fix"], cfg))))
keys.append(dict(k, holding=keyguide.plain(keyguide.fix_words(k["fix"], cfg))))
return {"page": cfg["page"], "page_name": cfg["page_name"], "tiles": tiles, "restart_page": dict(rp, keys=keys) if rp else None,
"hold": schema.phrases(cfg)["hold"], "grid": cfg.get("page_grid", schema.F["page_grid"]["default"])}