Let a non-blocking checklist item be dismissed with a recorded decision, and run discovery on the mirror once there is something to discover

This commit is contained in:
Gmer4Lfe
2026-08-16 21:56:00 -04:00
parent 39dba3f8ab
commit cce1e25c2b
5 changed files with 146 additions and 6 deletions
+37 -1
View File
@@ -232,6 +232,42 @@ if (!empty($host2)) {
];
}
$allOk = !in_array(false, array_column($items, 'ok'), true);
// ── Blocking vs deferrable ────────────────────────────────────────────────────
// Setup used to be complete only when every item was green, which made a media-server API key a
// gate on finishing onboarding. A mirror that runs no Emby, or runs one the operator has not got
// round to configuring, could never reach "complete" — and the checklist is what tells them
// whether they are done.
//
// Blocking items are the ones the mesh genuinely cannot work without: who this host is, its conf,
// its SSH key, the owner's master.conf, and the partnership itself. Everything else improves the
// install without being load-bearing, and can be dismissed with a recorded decision.
//
// Deferring is per item and reversible, stored in the setup state so it survives a reload. The
// item still shows — amber, "deferred" — rather than disappearing, because a dismissed item is a
// decision to revisit, not a thing that stopped being true.
$deferrable = ['api_key' => true, 'populated' => true, 'emby_key' => true, 'jellyfin_key' => true];
$state = vv_setup_state_read();
foreach ($items as &$item) {
$canDefer = !empty($deferrable[$item['id']]);
$item['blocking'] = !$canDefer;
$item['deferred'] = $canDefer && !$item['ok']
&& !empty($state['DEFER_' . strtoupper($item['id'])]);
if ($item['deferred']) {
$item['detail'] = ($item['detail'] ?? '') . ' — deferred';
$item['action'] = 'undefer';
} elseif ($canDefer && !$item['ok']) {
// Keep the item's real action as the primary; the UI offers defer alongside it.
$item['can_defer'] = true;
}
}
unset($item);
// Complete when every blocking item is green and every deferrable one is green or dismissed.
$allOk = true;
foreach ($items as $i) {
if ($i['ok']) continue;
if ($i['blocking'] || empty($i['deferred'])) { $allOk = false; break; }
}
echo json_encode(['ok' => true, 'complete' => $allOk, 'host_id' => $hostId, 'items' => $items]);