Show the watcher itself as a read-only row on the dashboard

The watcher writes its self-update status (running vs latest commit,
up to date / updating / held / error) to data/self.json, kept out of
state.json so the removed-stack cleanup never touches it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rainyy21
2026-11-11 16:36:54 -05:00
parent a54c625d66
commit 62a9cf28f5
4 changed files with 83 additions and 10 deletions
+9 -3
View File
@@ -25,7 +25,8 @@ from flask import (Flask, abort, flash, jsonify, redirect, render_template,
# share settings and rules with the watcher (app/watcher.py, one folder up)
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
from watcher import (CHECK_INTERVAL, CONFIG_PATH, LOCAL_DIR, # noqa: E402
REQUEST_DIR, STACKS_DIR, STATE_PATH, normalize, queue_request)
REQUEST_DIR, SELF_STATUS_PATH, STACKS_DIR, STATE_PATH, normalize,
queue_request)
# ---------- settings ----------
@@ -288,7 +289,11 @@ def index():
next_in = max(0, int(CHECK_INTERVAL - since))
stale = since > CHECK_INTERVAL * 2 + 60
return render_template("index.html", rows=rows, counts=counts, total=len(rows),
me = load_json(SELF_STATUS_PATH, None) # the watcher itself (see check_self in watcher.py)
if not isinstance(me, dict):
me = None
return render_template("index.html", rows=rows, counts=counts, total=len(rows), me=me,
next_in=next_in, stale=stale, last_round=last_round,
interval=CHECK_INTERVAL, token_envs=TOKEN_ENVS)
@@ -373,7 +378,8 @@ def version():
except OSError:
return 0
pending = pending_requests()
raw = f"{mtime(STATE_PATH)}|{mtime(Path(CONFIG_PATH))}|{sorted(pending.items())}"
raw = (f"{mtime(STATE_PATH)}|{mtime(SELF_STATUS_PATH)}|{mtime(Path(CONFIG_PATH))}|"
f"{sorted(pending.items())}")
return jsonify(version=hashlib.sha1(raw.encode()).hexdigest()[:16], busy=bool(pending))