Feat: Live-Panel aktive Modelle + Fix llama-swap Log-Viewer

- ActiveModelsCard: zeigt geladene Modelle (aus /running via useModels) mit
  Rolle, Größe (Unified-RAM) und warm-Status; globaler "Inferenz aktiv"-Puls
  via useTokenStats-Delta. Prominent oben im Dashboard. Kein Backend-Change.
- maintenance.logs(): journalctl ohne sudo zuerst (User in Gruppe adm darf das
  System-Journal lesen), nur bei fehlenden Rechten sudo-Fallback. Behebt
  "Unbekannter Fehler" beim llama-swap-Log im MC2-UI.

tsc + Build grün; Dashboard rendert die Live-Karte (Leerzustand lokal, da Engine
offline), keine Konsolenfehler.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Hitonabi
2026-06-26 19:21:53 +02:00
parent e2547ec301
commit 93111c6eaf
8 changed files with 499 additions and 391 deletions
+12 -8
View File
@@ -167,17 +167,21 @@ def restart_service(name: str, sudo_password: str | None = None) -> dict:
def logs(service: str, lines: int = 200, sudo_password: str | None = None) -> dict:
lines = max(1, min(lines, 1000))
if service in USER_SERVICES:
r = _run(["journalctl", "--user", "-u", service, "-n", str(lines), "--no-pager"])
return {"ok": r["ok"], "text": r["out"] or r["err"]}
if service in SYSTEM_SERVICES:
# Journal-Lesen braucht i.d.R. KEIN sudo (User ist in Gruppe adm/systemd-journal).
# Erst ohne sudo versuchen; nur bei fehlenden Rechten auf sudo zurückfallen.
r = _run(["journalctl", "-u", service, "-n", str(lines), "--no-pager"])
if r["ok"]:
return {"ok": True, "text": r["out"] or "(keine Log-Einträge)"}
if err := check_sudo_needs_password(sudo_password):
return err
cmd = ["sudo", "journalctl", "-u", service, "-n", str(lines), "--no-pager"]
r = _run(cmd, sudo_password=sudo_password)
elif service in USER_SERVICES:
cmd = ["journalctl", "--user", "-u", service, "-n", str(lines), "--no-pager"]
r = _run(cmd)
else:
return {"ok": False, "text": "", "err": "Dienst nicht erlaubt."}
return {"ok": r["ok"], "text": r["out"] or r["err"]}
r = _run(["sudo", "journalctl", "-u", service, "-n", str(lines), "--no-pager"],
sudo_password=sudo_password)
return {"ok": r["ok"], "text": r["out"] or r["err"]}
return {"ok": False, "text": "", "err": "Dienst nicht erlaubt."}
def check_updates_job(sudo_password: str | None = None) -> dict:
if err := check_sudo_needs_password(sudo_password):