diff --git a/Plugin/unraid/include/watchdog.php b/Plugin/unraid/include/watchdog.php index 2c36f99..ff43af1 100644 --- a/Plugin/unraid/include/watchdog.php +++ b/Plugin/unraid/include/watchdog.php @@ -68,6 +68,22 @@ require_once __DIR__ . '/partnership.php'; // until it doesn't and fails silently in the direction of hiding a real strike. const VV_WD_SYS_BOOKKEEPING = ['watchdog_cycle']; +// Every container that exists on this host, running or not, for deciding whether a name in a +// watchdog list still refers to anything. +// +// `docker ps -a` rather than vv_docker_containers() + vv_docker_stopped(): those two are filtered +// by status and between them still miss states like restarting, and a container this page called +// "not installed" because it happened to be mid-restart would be worse than not checking at all. +// The whole point of the badge is that it is only ever shown when it is certainly true. +// +// Returns an empty array when docker cannot be reached, and callers must treat that as "unknown" +// rather than "nothing is installed" — otherwise a docker outage marks every entry dead. +function vv_wd_installed_containers(): array { + @exec("docker ps -a --format '{{.Names}}' 2>/dev/null", $out, $rc); + if ($rc !== 0) return []; + return array_values(array_filter(array_map('trim', $out), fn($n) => $n !== '')); +} + // ── Conf array parser (bash arrays) ────────────────────────────────────────── function vv_wd_bash_array(string $raw, string $varname): array { diff --git a/Plugin/unraid/pages/watchdog.php b/Plugin/unraid/pages/watchdog.php index 036246d..bcded00 100644 --- a/Plugin/unraid/pages/watchdog.php +++ b/Plugin/unraid/pages/watchdog.php @@ -45,6 +45,9 @@ // include/ai_chat.php → the shared chat component require_once dirname(__DIR__) . '/include/confui.php'; require_once dirname(__DIR__) . '/include/ai_chat.php'; +// For vv_wd_installed_containers() only. The state on this page still arrives entirely through +// api/watchdog.php — this include buys one function, not a second collection path. +require_once dirname(__DIR__) . '/include/watchdog.php'; ?>