From ee8e0db10efab494187a92e0b332bea740a3fe53 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Fri, 13 Nov 2026 05:35:07 +0800 Subject: [PATCH 01/72] refactor: the folder-file code moves from lib.php to lib.folders.php Move only: 13 functions, byte for byte, in their old order. lib.php requires the new file next to themes.php and lib.foreign_import.php. --- .../folder.view3/server/lib.folders.php | 262 ++++++++++++++++++ .../plugins/folder.view3/server/lib.php | 261 +---------------- 2 files changed, 263 insertions(+), 260 deletions(-) create mode 100644 src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.folders.php diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.folders.php b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.folders.php new file mode 100644 index 00000000..0a455c73 --- /dev/null +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.folders.php @@ -0,0 +1,262 @@ + "$type.json is unreadable"]); + } + // Unparseable stays byte-identical so the client's cached-copy fallback still fires + $decoded = json_decode($raw, true); + if (json_last_error() !== JSON_ERROR_NONE) { return $raw; } + // Valid JSON that isn't a folder map fails like an unreadable file + if (!is_array($decoded)) { + fv3_error_log('readFolder', "$type.json does not contain a folder map"); + http_response_code(500); + return json_encode(['error' => "$type.json does not contain a folder map"]); + } + $clean = json_encode((object)fv3_normalize_folders($decoded)); + return $clean !== false ? $clean : $raw; + } + + // Fills the fields every reader dereferences so a hand-edited folder can't break a render + // or the autostart sync; object fields stay JSON objects. Never writes the file. + function fv3_normalize_folders(array $folders): array { + $out = []; + foreach ($folders as $id => $f) { + if (!is_array($f)) { continue; } + $f['name'] = is_scalar($f['name'] ?? null) ? (string)$f['name'] : (string)$id; + $f['icon'] = is_string($f['icon'] ?? null) ? $f['icon'] : ''; + $f['regex'] = is_string($f['regex'] ?? null) ? $f['regex'] : ''; + $f['containers'] = is_array($f['containers'] ?? null) ? array_values($f['containers']) : []; + $f['hidden_preview'] = is_array($f['hidden_preview'] ?? null) ? array_values($f['hidden_preview']) : []; + $f['actions'] = is_array($f['actions'] ?? null) ? array_values(array_filter($f['actions'], 'is_array')) : []; + $f['settings'] = (object)(is_array($f['settings'] ?? null) ? $f['settings'] : []); + foreach (['containerImages', 'containerIds'] as $k) { + if (array_key_exists($k, $f)) { $f[$k] = (object)(is_array($f[$k]) ? $f[$k] : []); } + } + $out[$id] = $f; + } + return $out; + } + + // A container may be explicit in at most one folder (issue #62). $winnerId's list survives + // intact (the folder just saved wins); elsewhere ties resolve first-wins in key order. + function fv3_dedupe_explicit_members(array $folders, ?string $winnerId = null): array { + $claimed = []; + // PHP stores an all-digit id as an int key, so compare canonical strings below — on === + // the winner would fail to match its own id and be stripped of the members claimed here + $winnerKey = $winnerId === null ? null : (string)$winnerId; + $winnerMembers = $winnerId !== null ? ($folders[$winnerId]['containers'] ?? null) : null; + if (is_array($winnerMembers)) { + foreach ($winnerMembers as $ct) { + if (is_string($ct)) { $claimed[$ct] = true; } + } + } + foreach ($folders as $fid => $folder) { + if (($winnerKey !== null && (string)$fid === $winnerKey) || !is_array($folder['containers'] ?? null)) { continue; } + $kept = []; + foreach ($folder['containers'] as $ct) { + if (is_string($ct)) { + if (isset($claimed[$ct])) { continue; } + $claimed[$ct] = true; + } + $kept[] = $ct; + } + $folders[$fid]['containers'] = $kept; + } + return $folders; + } + + function updateFolder(string $type, string $content, ?string $id = null) : void { + $decoded = json_decode($content, true); + // A folder must be an object/array — reject scalars so a full-backup bundle can't pollute $type.json + if (json_last_error() !== JSON_ERROR_NONE || !is_array($decoded)) { + http_response_code(400); + exit; + } + // 'root' is reserved by Unraid's Docker organizer — a same-named folder can never mirror + if (isset($decoded['name']) && is_string($decoded['name']) && strtolower(trim($decoded['name'])) === 'root') { + http_response_code(400); + header('Content-Type: application/json'); + echo json_encode(['error' => "The folder name 'root' is reserved by Unraid's Docker organizer"]); + exit; + } + // Only create.php omits the id; importAll() re-keys its own bad ids, so a malformed one here is a bad + // request, never a new folder + if ($id === null) { + $id = generateId(); + } elseif (!fv3_is_folder_id($id)) { + http_response_code(400); + header('Content-Type: application/json'); + echo json_encode(['error' => 'Folder id may only contain letters, digits, _ and -']); + exit; + } + fv3_write_folders($type, 'updateFolder', function (array $fileData) use ($decoded, $id): array { + $fileData[$id] = $decoded; + return fv3_dedupe_explicit_members($fileData, $id); + }); + } + + // The locked read-modify-write of docker.json / vm.json (imports and createFile() take the same lock themselves): $apply + // gets the folders as they are on disk, [] with no file, and returns them changed or null for no write. A failure is a 500 + function fv3_write_folders(string $type, string $caller, callable $apply, string $refusal = 'refusing to save so existing folders are not wiped'): void { + global $configDir; + $lock = fv3_config_lock("$type.json"); + $abort = function (string $logged, string $error) use ($caller, $lock): void { + if ($lock) fv3_config_unlock($lock); + fv3_error_log($caller, $logged); + http_response_code(500); + header('Content-Type: application/json'); + echo json_encode(['error' => $error]); + exit; + }; + // Corrupt config must fail closed: merging onto empty would wipe every other folder + $fileData = fv3_read_json_strict("$configDir/$type.json"); + if ($fileData === null) $abort("$type.json is unreadable, $refusal", "$type.json is unreadable — $refusal"); + $changed = $apply($fileData); + // Nothing is written without the lock; a request that changes nothing never fails for want of it + if ($changed !== null && !$lock) $abort("could not lock $type.json", "Could not lock $type.json — nothing was saved"); + if ($changed !== null && !fv3_atomic_write("$configDir/$type.json", json_encode($changed))) { + $abort("could not write $type.json", "Could not write $type.json — nothing was saved"); + } + if ($lock) fv3_config_unlock($lock); + } + + // True for a value the settings page can send as the default of folder setting $key. Colours, the text width and the + // graph time are saved there under looser rules than the editor's (fv3_sanitize_setting), so they are judged by those + function fv3_default_value_ok(string $key, $value): bool { + $rule = fv3_foreign_setting_rules()[$key] ?? null; + if ($rule === null) return false; + // unset: the page sends '' for an empty field, and null where the form held no number + if ($value === null || $value === '') return true; + if ($rule[0] === 'color' || $rule[0] === 'width') return is_string($value) && strlen($value) <= 50 && !preg_match('/[<>"\'\\\\]/', $value); + if ($key === 'context_graph_time') return is_int($value) && $value >= 0; + [$clean, $ok] = fv3_foreign_setting_value($rule, $value); + return $ok && $clean === $value; + } + + // Apply defaults: $settings merged into the settings of every folder as it is on disk, so nothing a page loaded + // earlier is written back. A folder that locks its colours keeps them + function applyFolderDefaults(string $type, string $settings) : void { + $patch = json_decode($settings, true); + // One bad request must not stamp an unknown key or value on every folder + if (!is_array($patch) || array_filter($patch, fn($value, $key) => !fv3_default_value_ok((string)$key, $value), ARRAY_FILTER_USE_BOTH)) { + http_response_code(400); + header('Content-Type: application/json'); + echo json_encode(['error' => 'The defaults must be folder settings with values the settings page can send']); + exit; + } + if (!$patch) { return; } + $unlocked = array_diff_key($patch, array_flip(['preview_vertical_bars_color', 'preview_border_color', 'preview_row_separator_color'])); + fv3_write_folders($type, 'applyFolderDefaults', function (array $fileData) use ($patch, $unlocked): ?array { + $changed = false; + foreach ($fileData as $folderId => $folder) { + if (!is_array($folder)) continue; + $old = is_array($folder['settings'] ?? null) ? $folder['settings'] : []; + // what the pages call locked: any value JavaScript reads as true + $locked = !in_array($old['lock_colors'] ?? false, [false, null, 0, 0.0, ''], true); + $new = array_replace($old, $locked ? $unlocked : $patch); + if ($new === $old) continue; + $fileData[$folderId]['settings'] = $new; + $changed = true; + } + return $changed ? $fileData : null; + }); + } + + // What a Docker, VMs or Dashboard page found at load, per folder: `renames` (old name => new) and `identity` (name => the + // image or UUID to know it by), applied to the folder as it is on disk. Whole lists from a page's copy are not taken + function updateFolderIds(string $type, string $data) : void { + $updates = json_decode($data, true); + // A JSON list is not a report: its positions would be read as folder ids. Told by the text: a map keyed "0" decodes the same + if (json_last_error() !== JSON_ERROR_NONE || !is_array($updates) || ($updates && ltrim($data)[0] === '[')) { http_response_code(400); exit; } + if (!$updates) { return; } + $identity = $type === 'vm' ? 'containerIds' : 'containerImages'; + fv3_write_folders($type, 'updateFolderIds', function (array $fileData) use ($updates, $identity): ?array { + // Every name that is a member of some folder by now: a rename never takes one from where it was put + $claimed = []; + foreach ($fileData as $folder) { + foreach (is_array($folder) && is_array($folder['containers'] ?? null) ? $folder['containers'] : [] as $member) { + if (is_scalar($member)) $claimed[(string)$member] = true; + } + } + $changed = false; + foreach ($updates as $folderId => $patch) { + if (!fv3_is_folder_id($folderId)) continue; + if (!is_array($fileData[$folderId] ?? null) || !is_array($patch)) continue; + $folder = fv3_apply_member_changes($fileData[$folderId], $patch, $identity, $claimed); + if ($folder === $fileData[$folderId]) continue; + $fileData[$folderId] = $folder; + $changed = true; + } + // As before this took renames: one container still listed in two folders stays in the first (issue #62) + return $changed ? fv3_dedupe_explicit_members($fileData) : null; + }); + } + + // $folder with a page's renames and identity entries applied to its members as they are now. Mirrors what + // fv3ResolveRenamedContainers (customEvents.js) does to the page's own copy, its skip of a $claimed name included + function fv3_apply_member_changes(array $folder, array $patch, string $identity, array &$claimed): array { + $members = is_array($folder['containers'] ?? null) ? $folder['containers'] : []; + $find = function ($name) use (&$members) { + foreach ($members as $at => $member) { if (is_scalar($member) && (string)$member === (string)$name) return $at; } + return null; + }; + foreach (is_array($patch['renames'] ?? null) ? $patch['renames'] : [] as $old => $new) { + $at = is_string($new) && $new !== '' ? $find($old) : null; + // a new name that a save since the page loaded made a member somewhere is left there: the next load decides again + if ($at === null || isset($claimed[$new])) continue; + $claimed[$new] = true; + $members[$at] = $new; + $folder['containers'] = $members; + if (is_array($folder[$identity] ?? null) && array_key_exists($old, $folder[$identity])) { + $folder[$identity][$new] = $folder[$identity][$old]; + unset($folder[$identity][$old]); + } + $hidden = is_array($folder['hidden_preview'] ?? null) ? array_search((string)$old, $folder['hidden_preview'], true) : false; + if ($hidden !== false) $folder['hidden_preview'][$hidden] = $new; + } + foreach (is_array($patch['identity'] ?? null) ? $patch['identity'] : [] as $name => $value) { + if (!is_string($value) || $value === '' || $find($name) === null) continue; + if (is_array($folder[$identity] ?? null) && array_key_exists($name, $folder[$identity])) continue; + if (!is_array($folder[$identity] ?? null)) $folder[$identity] = []; + $folder[$identity][$name] = $value; + } + return $folder; + } + + function deleteFolder(string $type, string $id) : void { + fv3_write_folders($type, 'deleteFolder', function (array $fileData) use ($id): ?array { + // Already gone: delete stays idempotent, and there is nothing to rewrite + if (!array_key_exists($id, $fileData)) { return null; } + unset($fileData[$id]); + return $fileData; + }, 'refusing to delete so the folder config is not wiped'); + } + + function generateId(int $length = 20) : string { + return substr(str_replace(['+', '/', '='], '', base64_encode(random_bytes((int)ceil($length * 3 / 4)))), 0, $length); + } + + // Ids safe to write and to render into class/selector/onclick markup; int = all-digit JSON key + function fv3_is_folder_id($id) : bool { + return (is_string($id) || is_int($id)) && preg_match('/^[A-Za-z0-9_-]+$/D', (string)$id) === 1; + } + + function createFile(string $type): void { + global $configDir; + if (!is_dir($configDir)) { @mkdir($configDir, 0770, true); } + $path = "$configDir/$type.json"; + // Under the file's lock, and only if it is still missing: a save or an import since the caller's check is never replaced + $lock = fv3_config_lock("$type.json"); + if (!$lock) return; + clearstatcache(true, $path); + if (!file_exists($path)) { fv3_atomic_write($path, '{}'); } + fv3_config_unlock($lock); + } diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php index 3a22610d..98681328 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php @@ -317,50 +317,6 @@ function fv3_get_tailscale_fqdn_from_container(string $containerName): ?string { return null; } - function readFolder(string $type) : string { - global $configDir; - if(!file_exists("$configDir/$type.json")) { createFile($type); } - $raw = @file_get_contents("$configDir/$type.json"); - if ($raw === false) { - // Fail the request: a 200 '{}' would be cached client-side over the last good copy - fv3_error_log('readFolder', "$type.json is unreadable"); - http_response_code(500); - return json_encode(['error' => "$type.json is unreadable"]); - } - // Unparseable stays byte-identical so the client's cached-copy fallback still fires - $decoded = json_decode($raw, true); - if (json_last_error() !== JSON_ERROR_NONE) { return $raw; } - // Valid JSON that isn't a folder map fails like an unreadable file - if (!is_array($decoded)) { - fv3_error_log('readFolder', "$type.json does not contain a folder map"); - http_response_code(500); - return json_encode(['error' => "$type.json does not contain a folder map"]); - } - $clean = json_encode((object)fv3_normalize_folders($decoded)); - return $clean !== false ? $clean : $raw; - } - - // Fills the fields every reader dereferences so a hand-edited folder can't break a render - // or the autostart sync; object fields stay JSON objects. Never writes the file. - function fv3_normalize_folders(array $folders): array { - $out = []; - foreach ($folders as $id => $f) { - if (!is_array($f)) { continue; } - $f['name'] = is_scalar($f['name'] ?? null) ? (string)$f['name'] : (string)$id; - $f['icon'] = is_string($f['icon'] ?? null) ? $f['icon'] : ''; - $f['regex'] = is_string($f['regex'] ?? null) ? $f['regex'] : ''; - $f['containers'] = is_array($f['containers'] ?? null) ? array_values($f['containers']) : []; - $f['hidden_preview'] = is_array($f['hidden_preview'] ?? null) ? array_values($f['hidden_preview']) : []; - $f['actions'] = is_array($f['actions'] ?? null) ? array_values(array_filter($f['actions'], 'is_array')) : []; - $f['settings'] = (object)(is_array($f['settings'] ?? null) ? $f['settings'] : []); - foreach (['containerImages', 'containerIds'] as $k) { - if (array_key_exists($k, $f)) { $f[$k] = (object)(is_array($f[$k]) ? $f[$k] : []); } - } - $out[$id] = $f; - } - return $out; - } - function readUserPrefs(string $type) : string { $userPrefsDir = "/boot/config/plugins"; $prefsFilePath = ''; @@ -901,201 +857,6 @@ function syncContainerOrder(string $type): ?string { return null; } - // A container may be explicit in at most one folder (issue #62). $winnerId's list survives - // intact (the folder just saved wins); elsewhere ties resolve first-wins in key order. - function fv3_dedupe_explicit_members(array $folders, ?string $winnerId = null): array { - $claimed = []; - // PHP stores an all-digit id as an int key, so compare canonical strings below — on === - // the winner would fail to match its own id and be stripped of the members claimed here - $winnerKey = $winnerId === null ? null : (string)$winnerId; - $winnerMembers = $winnerId !== null ? ($folders[$winnerId]['containers'] ?? null) : null; - if (is_array($winnerMembers)) { - foreach ($winnerMembers as $ct) { - if (is_string($ct)) { $claimed[$ct] = true; } - } - } - foreach ($folders as $fid => $folder) { - if (($winnerKey !== null && (string)$fid === $winnerKey) || !is_array($folder['containers'] ?? null)) { continue; } - $kept = []; - foreach ($folder['containers'] as $ct) { - if (is_string($ct)) { - if (isset($claimed[$ct])) { continue; } - $claimed[$ct] = true; - } - $kept[] = $ct; - } - $folders[$fid]['containers'] = $kept; - } - return $folders; - } - - function updateFolder(string $type, string $content, ?string $id = null) : void { - $decoded = json_decode($content, true); - // A folder must be an object/array — reject scalars so a full-backup bundle can't pollute $type.json - if (json_last_error() !== JSON_ERROR_NONE || !is_array($decoded)) { - http_response_code(400); - exit; - } - // 'root' is reserved by Unraid's Docker organizer — a same-named folder can never mirror - if (isset($decoded['name']) && is_string($decoded['name']) && strtolower(trim($decoded['name'])) === 'root') { - http_response_code(400); - header('Content-Type: application/json'); - echo json_encode(['error' => "The folder name 'root' is reserved by Unraid's Docker organizer"]); - exit; - } - // Only create.php omits the id; importAll() re-keys its own bad ids, so a malformed one here is a bad - // request, never a new folder - if ($id === null) { - $id = generateId(); - } elseif (!fv3_is_folder_id($id)) { - http_response_code(400); - header('Content-Type: application/json'); - echo json_encode(['error' => 'Folder id may only contain letters, digits, _ and -']); - exit; - } - fv3_write_folders($type, 'updateFolder', function (array $fileData) use ($decoded, $id): array { - $fileData[$id] = $decoded; - return fv3_dedupe_explicit_members($fileData, $id); - }); - } - - // The locked read-modify-write of docker.json / vm.json (imports and createFile() take the same lock themselves): $apply - // gets the folders as they are on disk, [] with no file, and returns them changed or null for no write. A failure is a 500 - function fv3_write_folders(string $type, string $caller, callable $apply, string $refusal = 'refusing to save so existing folders are not wiped'): void { - global $configDir; - $lock = fv3_config_lock("$type.json"); - $abort = function (string $logged, string $error) use ($caller, $lock): void { - if ($lock) fv3_config_unlock($lock); - fv3_error_log($caller, $logged); - http_response_code(500); - header('Content-Type: application/json'); - echo json_encode(['error' => $error]); - exit; - }; - // Corrupt config must fail closed: merging onto empty would wipe every other folder - $fileData = fv3_read_json_strict("$configDir/$type.json"); - if ($fileData === null) $abort("$type.json is unreadable, $refusal", "$type.json is unreadable — $refusal"); - $changed = $apply($fileData); - // Nothing is written without the lock; a request that changes nothing never fails for want of it - if ($changed !== null && !$lock) $abort("could not lock $type.json", "Could not lock $type.json — nothing was saved"); - if ($changed !== null && !fv3_atomic_write("$configDir/$type.json", json_encode($changed))) { - $abort("could not write $type.json", "Could not write $type.json — nothing was saved"); - } - if ($lock) fv3_config_unlock($lock); - } - - // True for a value the settings page can send as the default of folder setting $key. Colours, the text width and the - // graph time are saved there under looser rules than the editor's (fv3_sanitize_setting), so they are judged by those - function fv3_default_value_ok(string $key, $value): bool { - $rule = fv3_foreign_setting_rules()[$key] ?? null; - if ($rule === null) return false; - // unset: the page sends '' for an empty field, and null where the form held no number - if ($value === null || $value === '') return true; - if ($rule[0] === 'color' || $rule[0] === 'width') return is_string($value) && strlen($value) <= 50 && !preg_match('/[<>"\'\\\\]/', $value); - if ($key === 'context_graph_time') return is_int($value) && $value >= 0; - [$clean, $ok] = fv3_foreign_setting_value($rule, $value); - return $ok && $clean === $value; - } - - // Apply defaults: $settings merged into the settings of every folder as it is on disk, so nothing a page loaded - // earlier is written back. A folder that locks its colours keeps them - function applyFolderDefaults(string $type, string $settings) : void { - $patch = json_decode($settings, true); - // One bad request must not stamp an unknown key or value on every folder - if (!is_array($patch) || array_filter($patch, fn($value, $key) => !fv3_default_value_ok((string)$key, $value), ARRAY_FILTER_USE_BOTH)) { - http_response_code(400); - header('Content-Type: application/json'); - echo json_encode(['error' => 'The defaults must be folder settings with values the settings page can send']); - exit; - } - if (!$patch) { return; } - $unlocked = array_diff_key($patch, array_flip(['preview_vertical_bars_color', 'preview_border_color', 'preview_row_separator_color'])); - fv3_write_folders($type, 'applyFolderDefaults', function (array $fileData) use ($patch, $unlocked): ?array { - $changed = false; - foreach ($fileData as $folderId => $folder) { - if (!is_array($folder)) continue; - $old = is_array($folder['settings'] ?? null) ? $folder['settings'] : []; - // what the pages call locked: any value JavaScript reads as true - $locked = !in_array($old['lock_colors'] ?? false, [false, null, 0, 0.0, ''], true); - $new = array_replace($old, $locked ? $unlocked : $patch); - if ($new === $old) continue; - $fileData[$folderId]['settings'] = $new; - $changed = true; - } - return $changed ? $fileData : null; - }); - } - - // What a Docker, VMs or Dashboard page found at load, per folder: `renames` (old name => new) and `identity` (name => the - // image or UUID to know it by), applied to the folder as it is on disk. Whole lists from a page's copy are not taken - function updateFolderIds(string $type, string $data) : void { - $updates = json_decode($data, true); - // A JSON list is not a report: its positions would be read as folder ids. Told by the text: a map keyed "0" decodes the same - if (json_last_error() !== JSON_ERROR_NONE || !is_array($updates) || ($updates && ltrim($data)[0] === '[')) { http_response_code(400); exit; } - if (!$updates) { return; } - $identity = $type === 'vm' ? 'containerIds' : 'containerImages'; - fv3_write_folders($type, 'updateFolderIds', function (array $fileData) use ($updates, $identity): ?array { - // Every name that is a member of some folder by now: a rename never takes one from where it was put - $claimed = []; - foreach ($fileData as $folder) { - foreach (is_array($folder) && is_array($folder['containers'] ?? null) ? $folder['containers'] : [] as $member) { - if (is_scalar($member)) $claimed[(string)$member] = true; - } - } - $changed = false; - foreach ($updates as $folderId => $patch) { - if (!fv3_is_folder_id($folderId)) continue; - if (!is_array($fileData[$folderId] ?? null) || !is_array($patch)) continue; - $folder = fv3_apply_member_changes($fileData[$folderId], $patch, $identity, $claimed); - if ($folder === $fileData[$folderId]) continue; - $fileData[$folderId] = $folder; - $changed = true; - } - // As before this took renames: one container still listed in two folders stays in the first (issue #62) - return $changed ? fv3_dedupe_explicit_members($fileData) : null; - }); - } - - // $folder with a page's renames and identity entries applied to its members as they are now. Mirrors what - // fv3ResolveRenamedContainers (customEvents.js) does to the page's own copy, its skip of a $claimed name included - function fv3_apply_member_changes(array $folder, array $patch, string $identity, array &$claimed): array { - $members = is_array($folder['containers'] ?? null) ? $folder['containers'] : []; - $find = function ($name) use (&$members) { - foreach ($members as $at => $member) { if (is_scalar($member) && (string)$member === (string)$name) return $at; } - return null; - }; - foreach (is_array($patch['renames'] ?? null) ? $patch['renames'] : [] as $old => $new) { - $at = is_string($new) && $new !== '' ? $find($old) : null; - // a new name that a save since the page loaded made a member somewhere is left there: the next load decides again - if ($at === null || isset($claimed[$new])) continue; - $claimed[$new] = true; - $members[$at] = $new; - $folder['containers'] = $members; - if (is_array($folder[$identity] ?? null) && array_key_exists($old, $folder[$identity])) { - $folder[$identity][$new] = $folder[$identity][$old]; - unset($folder[$identity][$old]); - } - $hidden = is_array($folder['hidden_preview'] ?? null) ? array_search((string)$old, $folder['hidden_preview'], true) : false; - if ($hidden !== false) $folder['hidden_preview'][$hidden] = $new; - } - foreach (is_array($patch['identity'] ?? null) ? $patch['identity'] : [] as $name => $value) { - if (!is_string($value) || $value === '' || $find($name) === null) continue; - if (is_array($folder[$identity] ?? null) && array_key_exists($name, $folder[$identity])) continue; - if (!is_array($folder[$identity] ?? null)) $folder[$identity] = []; - $folder[$identity][$name] = $value; - } - return $folder; - } - - function deleteFolder(string $type, string $id) : void { - fv3_write_folders($type, 'deleteFolder', function (array $fileData) use ($id): ?array { - // Already gone: delete stays idempotent, and there is nothing to rewrite - if (!array_key_exists($id, $fileData)) { return null; } - unset($fileData[$id]); - return $fileData; - }, 'refusing to delete so the folder config is not wiped'); - } - function readSettings() : string { global $configDir; $raw = @file_get_contents("$configDir/settings.json"); @@ -1271,6 +1032,7 @@ function updateSettingsBatch(array $settings) : void { // Theme listing, import, toggle and delete, and the styles/ confinement helpers they share require_once(__DIR__ . '/themes.php'); require_once(__DIR__ . '/lib.foreign_import.php'); + require_once(__DIR__ . '/lib.folders.php'); function exportAll() : array { global $configDir; @@ -1673,27 +1435,6 @@ function fv3_render_css_files(array $config) : array { return $out; } - function generateId(int $length = 20) : string { - return substr(str_replace(['+', '/', '='], '', base64_encode(random_bytes((int)ceil($length * 3 / 4)))), 0, $length); - } - - // Ids safe to write and to render into class/selector/onclick markup; int = all-digit JSON key - function fv3_is_folder_id($id) : bool { - return (is_string($id) || is_int($id)) && preg_match('/^[A-Za-z0-9_-]+$/D', (string)$id) === 1; - } - - function createFile(string $type): void { - global $configDir; - if (!is_dir($configDir)) { @mkdir($configDir, 0770, true); } - $path = "$configDir/$type.json"; - // Under the file's lock, and only if it is still missing: a save or an import since the caller's check is never replaced - $lock = fv3_config_lock("$type.json"); - if (!$lock) return; - clearstatcache(true, $path); - if (!file_exists($path)) { fv3_atomic_write($path, '{}'); } - fv3_config_unlock($lock); - } - // Mirrors DockerContainers.php:82 — ':???' net-ref wins, then Unraid's per-container cache. // Only 'updated' comes from that cache; WebUi/Shell stay live here (the cache holds unresolved [IP]/[PORT:n]). function fv3_container_update_status(array $ct, string $name, array $cache, DockerUpdate $DockerUpdate): ?bool { From 72fea886cc89d86917e28b8c4ae01fb2b25e951d Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 07:57:00 +0800 Subject: [PATCH 02/72] docs: the v2026.11.14 notes list the Unraid 7.4 advanced preview fix [skip ci] --- CHANGELOG.md | 3 ++- folder.view3.plg | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 201d69df..81dbcb40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,8 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache - Imports keep the file's folder order; settings lists folders in page order - FolderView Plus migration fixes: hidden members, branch exports, script arguments, icons - Docker page shows an update when a container's tag moves to another image -- Display fixes: incognito Tailscale tooltip, advanced preview menu, theme import log +- Advanced preview menu keeps its spacing on Unraid 7.4 +- Display fixes: incognito Tailscale tooltip, theme import log ## 2026.11.13.3 (beta) diff --git a/folder.view3.plg b/folder.view3.plg index b92f74c5..9229f27d 100644 --- a/folder.view3.plg +++ b/folder.view3.plg @@ -35,7 +35,8 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache - Imports keep the file's folder order; settings lists folders in page order - FolderView Plus migration fixes: hidden members, branch exports, script arguments, icons - Docker page shows an update when a container's tag moves to another image -- Display fixes: incognito Tailscale tooltip, advanced preview menu, theme import log +- Advanced preview menu keeps its spacing on Unraid 7.4 +- Display fixes: incognito Tailscale tooltip, theme import log ###2026.11.13.3 - VMs page folders stay in their saved place, also when two folders sit next to each other, and keep their VMs inside From 8c55fcbbd3a53e049c5fecbc2c471aabd610cc04 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 07:57:53 +0800 Subject: [PATCH 03/72] docs: the folder-file header says imports and restores replace the files outside it --- .../local/emhttp/plugins/folder.view3/server/lib.folders.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.folders.php b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.folders.php index a2247080..f94fc5fb 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.folders.php +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.folders.php @@ -1,5 +1,6 @@ Date: Sat, 14 Nov 2026 09:18:59 +0800 Subject: [PATCH 04/72] fix: a folder action Unraid refuses shows Unraid's reason, not its JSON answer --- .github/scripts/action_refusal_test.js | 79 +++++++++++++++++++ .github/scripts/preview_pages_harness.js | 25 +++++- .github/scripts/settings_order_test.js | 19 +---- .github/workflows/ci.yml | 1 + .../plugins/folder.view3/scripts/shared.js | 14 +++- 5 files changed, 119 insertions(+), 19 deletions(-) create mode 100644 .github/scripts/action_refusal_test.js diff --git a/.github/scripts/action_refusal_test.js b/.github/scripts/action_refusal_test.js new file mode 100644 index 00000000..f4261775 --- /dev/null +++ b/.github/scripts/action_refusal_test.js @@ -0,0 +1,79 @@ +// node .github/scripts/action_refusal_test.js — a folder action Unraid refuses shows Unraid's own reason: the real docker.js and vm.js +// folder actions and shared.js, answered as Unraid's Events.php ({success: true|reason}) and VMajax.php ({success: true}|{error: reason}) answer +'use strict'; +const { drawDocker, drawVms, check, done } = require('./preview_pages_harness.js'); + +const folder = (name, containers = [], regex = '') => ({ name, containers, regex }); + +// Each action post answered by `answer(data)` (or failed when it returns an Error); the dialogs as the user reads them +const stub = (p, answer) => { + const posts = []; + const dialogs = []; + p.$.post = (url, data) => { + posts.push({ url, data }); + const a = answer(data); + return a instanceof Error ? p.$.Deferred().reject({ status: 500, statusText: a.message }) : p.$.Deferred().resolve(a); + }; + p.w.swal = (o) => { + const box = p.w.document.createElement('div'); + box.innerHTML = String(o.text); + dialogs.push({ title: o.title, lines: box.innerHTML.split('
').map((part) => { box.innerHTML = part; return box.textContent; }) }); + }; + p.w.swal.close = () => {}; + return { posts, dialogs }; +}; + +// Runs a folder action to the end on the page's manual clock +const act = async (p, call) => { + let finished = false; + p.g(call).then(() => { finished = true; }, (e) => { p.errors.push(`${call}: ${e && e.stack || e}`); finished = true; }); + for (let i = 0; i < 50 && !finished; i++) await p.tick(100); + return finished; +}; + +(async () => { + const REFUSED = 'Error response from daemon: cannot stop container: web: permission denied'; + { + const page = await drawDocker({ folders: { f: folder('Apps', ['web', 'db']) }, containers: ['web', 'db'], prefs: ['folder-f', 'web', 'db'] }); + await page.draw(); + const { posts, dialogs } = stub(page.p, (data) => (data.container === page.p.g("globalFolders['f'].containers['web'].id") ? { success: REFUSED } : { success: true })); + const finished = await act(page.p, "actionFolder('f', 'stop')"); + check("a container Unraid refuses to stop: the dialog shows Unraid's reason, not its JSON answer", + finished && posts.length === 2 && dialogs.length === 1 && dialogs[0].title === 'exec-error' && JSON.stringify(dialogs[0].lines) === JSON.stringify([REFUSED]), + { finished, posts: posts.length, dialogs, errors: page.p.errors }); + } + { + const page = await drawDocker({ folders: { f: folder('Apps', ['web', 'db']) }, containers: ['web', 'db'], prefs: ['folder-f', 'web', 'db'] }); + await page.draw(); + const { posts, dialogs } = stub(page.p, () => ({ success: true })); + const finished = await act(page.p, "actionFolder('f', 'stop')"); + check('every container accepted: no dialog', finished && posts.length === 2 && dialogs.length === 0, { finished, posts: posts.length, dialogs }); + } + { + const page = await drawDocker({ folders: { f: folder('Apps', ['web']) }, containers: ['web'], prefs: ['folder-f', 'web'] }); + await page.draw(); + const { dialogs } = stub(page.p, () => new Error('Internal Server Error')); + const finished = await act(page.p, "actionFolder('f', 'stop')"); + check('a request that fails outright is still in the dialog, named by its failure', + finished && dialogs.length === 1 && JSON.stringify(dialogs[0].lines) === JSON.stringify(['Internal Server Error']), { finished, dialogs }); + } + { + const NO_NETWORK = "Requested operation is not valid: network 'br0' is not active"; + const p = await drawVms({ folders: { v: folder('VMs', ['vm-a', 'vm-b']) }, names: ['vm-a', 'vm-b'], prefs: ['folder-v', 'vm-a', 'vm-b'] }); + const { posts, dialogs } = stub(p, (data) => (data.uuid === 'u0' ? { error: NO_NETWORK } : { success: true, state: 'running' })); + const finished = await act(p, "actionFolder('v', 'domain-start')"); + check("a VM Unraid refuses to start: the dialog shows libvirt's reason, not the JSON answer", + finished && posts.length === 2 && dialogs.length === 1 && JSON.stringify(dialogs[0].lines) === JSON.stringify([NO_NETWORK]), + { finished, posts: posts.length, dialogs, errors: p.errors }); + } + { + // An answer with no reason in it is still a failure, shown as Unraid sent it + const page = await drawDocker({ folders: { f: folder('Apps', ['web']) }, containers: ['web'], prefs: ['folder-f', 'web'] }); + await page.draw(); + const { dialogs } = stub(page.p, () => ({ success: '' })); + const finished = await act(page.p, "actionFolder('f', 'stop')"); + check('an Events.php answer with an empty reason is a failure, not a success', + finished && dialogs.length === 1 && JSON.stringify(dialogs[0].lines) === JSON.stringify(['{"success":""}']), { finished, dialogs }); + } + done(); +})().catch((e) => { console.error(e); process.exit(1); }); diff --git a/.github/scripts/preview_pages_harness.js b/.github/scripts/preview_pages_harness.js index 0ad69e6f..cda7e621 100644 --- a/.github/scripts/preview_pages_harness.js +++ b/.github/scripts/preview_pages_harness.js @@ -305,6 +305,29 @@ const drawDocker = async ({ folders, containers, prefs, listed }) => { return { p, posts, failing, dropped, render, draw, rows, members, drawn }; }; +// Unraid's row for one VM (VMMachines.php), stopped, with its hidden detail row +const vmRow = (name, i) => `` + + `${name}
stopped
` + + ``; + +// The VMs page drawn by the real vm.js from vm.json's folders (settings a folder leaves out are drawDocker's), the VMs (all shut +// off, uuid u0, u1, …) and userprefs.cfg's values +const drawVms = async ({ folders, names, prefs }) => { + const info = Object.fromEntries(names.map((n, i) => [n, { uuid: `u${i}`, state: 'shutoff', autostart: false }])); + const defs = Object.fromEntries(Object.entries(folders).map(([id, f]) => [id, { icon: '', hidden_preview: [], actions: [], ...f, settings: { ...FOLDER_SETTINGS, ...(f.settings || {}) } }])); + const p = await makePage({ page: 'vm', api: false, answers: { + 'read.php': () => JSON.stringify(defs), 'read_order.php': () => JSON.stringify(prefs), + 'read_unraid_order.php': () => JSON.stringify(names), 'read_info.php': () => JSON.stringify(info), + } }); + fakeXhr(p.w, () => ({ status: 200, body: '' })); + p.w.loadlist_original = () => p.$('#kvm_list').html(names.map(vmRow).join('')); + p.g('loadlist()'); + p.g('fv3DrawList()'); + for (let i = 0; i < 50 && !(p.w.fv3DrawLog || []).some((d) => d.outcome === 'drawn') && !p.errors.length; i++) await p.tick(100); + if (p.errors.length || !(p.w.fv3DrawLog || []).some((d) => d.outcome === 'drawn')) throw new Error(`VMs page not drawn: ${p.errors.join('; ')}`); + return p; +}; + let failed = 0; const check = (label, ok, detail) => { if (ok) { console.log(`ok ${label}`); return; } @@ -347,4 +370,4 @@ const phpServer = (label, { containers = [] } = {}) => { return { config, server, cleanup: () => fs.rmSync(tmp, { recursive: true, force: true }) }; }; -module.exports = { makePage, drawDocker, fakeXhr, scriptHelpers, check, done, flush, read, phpServer }; +module.exports = { makePage, drawDocker, drawVms, fakeXhr, scriptHelpers, check, done, flush, read, phpServer }; diff --git a/.github/scripts/settings_order_test.js b/.github/scripts/settings_order_test.js index 597f64da..91231ae8 100644 --- a/.github/scripts/settings_order_test.js +++ b/.github/scripts/settings_order_test.js @@ -4,7 +4,7 @@ const fs = require('fs'); const vm = require('vm'); const { JSDOM, VirtualConsole } = require('jsdom'); -const { makePage, drawDocker, fakeXhr, scriptHelpers, check, done, read, phpServer } = require('./preview_pages_harness.js'); +const { drawDocker, drawVms, scriptHelpers, check, done, read, phpServer } = require('./preview_pages_harness.js'); // The settings page's backup panel (the two folder tables) with the shipped code that fills them const part = (rel, from, to) => { @@ -50,22 +50,9 @@ const dockerPage = async ({ folders, names, prefs }) => { await page.draw(); return page.rows().filter((r) => r.startsWith('folder-')).map((r) => folders[r.slice(7)].name.trim()); }; -// The VMs page's folder order, by name as shown (trimmed), top-down: Unraid's rows (VMMachines.php) for the names as VMs -const vmRow = (name, i) => `` + - `${name}
stopped
` + - ``; +// The VMs page's folder order, by name as shown (trimmed), top-down const vmPage = async ({ folders, names, prefs }) => { - const info = Object.fromEntries(names.map((n, i) => [n, { uuid: `u${i}`, state: 'shutoff', autostart: false }])); - const p = await makePage({ page: 'vm', api: false, answers: { - 'read.php': () => JSON.stringify(folders), 'read_order.php': () => JSON.stringify(prefs), - 'read_unraid_order.php': () => JSON.stringify(names), 'read_info.php': () => JSON.stringify(info), - } }); - fakeXhr(p.w, () => ({ status: 200, body: '' })); - p.w.loadlist_original = () => p.$('#kvm_list').html(names.map(vmRow).join('')); - p.g('loadlist()'); - p.g('fv3DrawList()'); - for (let i = 0; i < 50 && !(p.w.fv3DrawLog || []).some((d) => d.outcome === 'drawn') && !p.errors.length; i++) await p.tick(100); - if (p.errors.length || !(p.w.fv3DrawLog || []).some((d) => d.outcome === 'drawn')) throw new Error(`VMs page not drawn: ${p.errors.join('; ')}`); + const p = await drawVms({ folders, names, prefs }); return p.$('#kvm_list > tr.folder').toArray().map((tr) => folders[tr.className.match(/folder-id-(\S+)/)[1]].name.trim()); }; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c03e6f0a..0d682578 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,6 +98,7 @@ jobs: node settings_order_test.js node import_order_test.js node name_order_test.js + node action_refusal_test.js node rename_update_test.js - name: Validate plugin manifest (XML) diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/shared.js b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/shared.js index 812d4988..3b7fe0df 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/shared.js +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/shared.js @@ -1391,10 +1391,19 @@ window.fv3ContainerAction = async (type, id, action) => { return null; }; +// Unraid's answer to a container or VM action in the shape the folder actions read: a refusal's reason is in `success` (Events.php) +// or `error` (VMajax.php), the same on 7.0 to 7.4 +window.fv3ActionAnswer = (answer) => { + if (!answer || typeof answer !== 'object') return answer; + var reason = typeof answer.success === 'string' && answer.success ? answer.success : answer.error; + return typeof reason === 'string' && reason ? { success: false, text: reason } : answer; +}; + window.fv3DockerAction = (action, containerId, fullId) => { var gqlAction = fv3DockerActionMap[action]; var phpFallback = () => $.post(window.eventURL || '/update.htm', { action: action, container: containerId }, null, 'json').promise() - .fail(() => fv3ShowBanner(fv3I18nOr('container-action-failed', 'The container action "$1" failed. Check your server connection.', action))); + .fail(() => fv3ShowBanner(fv3I18nOr('container-action-failed', 'The container action "$1" failed. Check your server connection.', action))) + .then(fv3ActionAnswer); if (fv3ApiAvailable && gqlAction && fullId) { return fv3GraphQL('mutation($id: PrefixedID!) { docker { ' + gqlAction + '(id: $id) { id } } }', { id: fullId }) .then(() => { fv3Debug('API', 'Docker', gqlAction, containerId, 'OK'); return { success: true }; }) @@ -1409,7 +1418,8 @@ window.fv3DockerAction = (action, containerId, fullId) => { window.fv3VmAction = (action, uuid) => { var gqlAction = fv3VmActionMap[action]; var phpFallback = () => $.post('/plugins/dynamix.vm.manager/include/VMajax.php', { action: action, uuid: uuid }, null, 'json').promise() - .fail(() => fv3ShowBanner(fv3I18nOr('vm-action-failed', 'The VM action "$1" failed. Check your server connection.', action.replace('domain-', '')))); + .fail(() => fv3ShowBanner(fv3I18nOr('vm-action-failed', 'The VM action "$1" failed. Check your server connection.', action.replace('domain-', '')))) + .then(fv3ActionAnswer); if (fv3ApiAvailable && gqlAction) { return fv3GraphQL('mutation($id: PrefixedID!) { vm { ' + gqlAction + '(id: $id) } }', { id: uuid }) .then(() => { fv3Debug('API', 'VM', gqlAction, uuid, 'OK'); return { success: true }; }) From 57ac0bad44a9dd08c2fcc5fc1ab6e46a3f1d6857 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 09:23:55 +0800 Subject: [PATCH 05/72] fix: a success with an error field stays a success, a null answer is a failure; the API-first path and raw VM fixtures are tested --- .github/scripts/action_refusal_test.js | 39 ++++++++++++++++++- .github/scripts/preview_pages_harness.js | 12 +++--- .../plugins/folder.view3/scripts/shared.js | 5 ++- 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/.github/scripts/action_refusal_test.js b/.github/scripts/action_refusal_test.js index f4261775..6f546c51 100644 --- a/.github/scripts/action_refusal_test.js +++ b/.github/scripts/action_refusal_test.js @@ -1,9 +1,11 @@ // node .github/scripts/action_refusal_test.js — a folder action Unraid refuses shows Unraid's own reason: the real docker.js and vm.js // folder actions and shared.js, answered as Unraid's Events.php ({success: true|reason}) and VMajax.php ({success: true}|{error: reason}) answer 'use strict'; -const { drawDocker, drawVms, check, done } = require('./preview_pages_harness.js'); +const { drawDocker, drawVms, check, done, FOLDER_SETTINGS } = require('./preview_pages_harness.js'); const folder = (name, containers = [], regex = '') => ({ name, containers, regex }); +// A VM folder as vm.json holds one +const vmFolder = (name, vms) => ({ name, icon: '', regex: '', containers: vms, settings: { ...FOLDER_SETTINGS }, hidden_preview: [], actions: [] }); // Each action post answered by `answer(data)` (or failed when it returns an Error); the dialogs as the user reads them const stub = (p, answer) => { @@ -59,13 +61,46 @@ const act = async (p, call) => { } { const NO_NETWORK = "Requested operation is not valid: network 'br0' is not active"; - const p = await drawVms({ folders: { v: folder('VMs', ['vm-a', 'vm-b']) }, names: ['vm-a', 'vm-b'], prefs: ['folder-v', 'vm-a', 'vm-b'] }); + const p = await drawVms({ folders: { v: vmFolder('VMs', ['vm-a', 'vm-b']) }, names: ['vm-a', 'vm-b'], prefs: ['folder-v', 'vm-a', 'vm-b'] }); const { posts, dialogs } = stub(p, (data) => (data.uuid === 'u0' ? { error: NO_NETWORK } : { success: true, state: 'running' })); const finished = await act(p, "actionFolder('v', 'domain-start')"); check("a VM Unraid refuses to start: the dialog shows libvirt's reason, not the JSON answer", finished && posts.length === 2 && dialogs.length === 1 && JSON.stringify(dialogs[0].lines) === JSON.stringify([NO_NETWORK]), { finished, posts: posts.length, dialogs, errors: p.errors }); } + { + // A success that also carries an `error` field (a warning) is still a success + const p = await drawVms({ folders: { v: vmFolder('VMs', ['vm-a']) }, names: ['vm-a'], prefs: ['folder-v', 'vm-a'] }); + const { dialogs } = stub(p, () => ({ success: true, state: 'running', error: 'Waiting for the guest agent' })); + const finished = await act(p, "actionFolder('v', 'domain-start')"); + check('an answer that says success and also carries an error field is a success: no dialog', finished && dialogs.length === 0, { finished, dialogs }); + } + { + // json_encode of nothing: the action still ends with a dialog instead of throwing with the spinner up + const page = await drawDocker({ folders: { f: folder('Apps', ['web']) }, containers: ['web'], prefs: ['folder-f', 'web'] }); + await page.draw(); + const { dialogs } = stub(page.p, () => null); + const finished = await act(page.p, "actionFolder('f', 'stop')"); + check('a null answer ends the action with a dialog that says the request failed', + finished && !page.p.errors.length && dialogs.length === 1 && JSON.stringify(dialogs[0].lines) === JSON.stringify(['Request failed']), { finished, dialogs, errors: page.p.errors }); + } + { + // With the Unraid API (7.2 and later) the action goes to GraphQL first; when that errors, the PHP endpoint's refusal is shown + const page = await drawDocker({ folders: { f: folder('Apps', ['web']) }, containers: ['web'], prefs: ['folder-f', 'web'], api: true }); + await page.draw(); + const realFetch = page.p.w.fetch; + let mutations = 0; + page.p.w.fetch = async (url, init) => { + if (!String(url).includes('/graphql') || !/mutation/.test(String(init && init.body))) return realFetch(url, init); + mutations++; + return { ok: true, json: async () => ({ errors: [{ message: 'container web: permission denied' }] }) }; + }; + const { posts, dialogs } = stub(page.p, () => ({ success: REFUSED })); + const finished = await act(page.p, "actionFolder('f', 'stop')"); + check("with the API, an action GraphQL refuses goes to Unraid's PHP endpoint once, and its reason is shown", + finished && mutations === 1 && posts.length === 1 && dialogs.length === 1 && JSON.stringify(dialogs[0].lines) === JSON.stringify([REFUSED]), + { finished, mutations, posts: posts.length, dialogs, errors: page.p.errors }); + } { // An answer with no reason in it is still a failure, shown as Unraid sent it const page = await drawDocker({ folders: { f: folder('Apps', ['web']) }, containers: ['web'], prefs: ['folder-f', 'web'] }); diff --git a/.github/scripts/preview_pages_harness.js b/.github/scripts/preview_pages_harness.js index cda7e621..88847ea4 100644 --- a/.github/scripts/preview_pages_harness.js +++ b/.github/scripts/preview_pages_harness.js @@ -252,7 +252,7 @@ const dockerRow = (name, sid) => ``; // The Docker page drawn by the real createFolders() from docker.json's folders, Docker's container names and userprefs.cfg's values -const drawDocker = async ({ folders, containers, prefs, listed }) => { +const drawDocker = async ({ folders, containers, prefs, listed, api = false }) => { const sid = (i) => String(i).padStart(12, 'a'); const defs = Object.fromEntries(Object.entries(folders).map(([id, f]) => [id, { ...f, icon: '', settings: { ...FOLDER_SETTINGS }, hidden_preview: [], actions: [] }])); const saved = prefs.filter((n) => containers.includes(n)); @@ -261,7 +261,7 @@ const drawDocker = async ({ folders, containers, prefs, listed }) => { // false = 0); how it orders several missing ones among themselves is its own tie-break, so they stay as given const shown = missing.concat(saved); const info = {}; - const p = await makePage({ page: 'docker', api: false, answers: { + const p = await makePage({ page: 'docker', api, answers: { 'read.php': () => JSON.stringify(defs), 'read_order.php': () => JSON.stringify(prefs), 'read_info.php': () => JSON.stringify(info), @@ -310,13 +310,11 @@ const vmRow = (name, i) => `${name}
stopped` + ``; -// The VMs page drawn by the real vm.js from vm.json's folders (settings a folder leaves out are drawDocker's), the VMs (all shut -// off, uuid u0, u1, …) and userprefs.cfg's values +// The VMs page drawn by the real vm.js from vm.json's folders as given, the VMs (all shut off, uuid u0, u1, …) and userprefs.cfg's values const drawVms = async ({ folders, names, prefs }) => { const info = Object.fromEntries(names.map((n, i) => [n, { uuid: `u${i}`, state: 'shutoff', autostart: false }])); - const defs = Object.fromEntries(Object.entries(folders).map(([id, f]) => [id, { icon: '', hidden_preview: [], actions: [], ...f, settings: { ...FOLDER_SETTINGS, ...(f.settings || {}) } }])); const p = await makePage({ page: 'vm', api: false, answers: { - 'read.php': () => JSON.stringify(defs), 'read_order.php': () => JSON.stringify(prefs), + 'read.php': () => JSON.stringify(folders), 'read_order.php': () => JSON.stringify(prefs), 'read_unraid_order.php': () => JSON.stringify(names), 'read_info.php': () => JSON.stringify(info), } }); fakeXhr(p.w, () => ({ status: 200, body: '' })); @@ -370,4 +368,4 @@ const phpServer = (label, { containers = [] } = {}) => { return { config, server, cleanup: () => fs.rmSync(tmp, { recursive: true, force: true }) }; }; -module.exports = { makePage, drawDocker, drawVms, fakeXhr, scriptHelpers, check, done, flush, read, phpServer }; +module.exports = { makePage, drawDocker, drawVms, fakeXhr, scriptHelpers, check, done, flush, read, phpServer, FOLDER_SETTINGS }; diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/shared.js b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/shared.js index 3b7fe0df..19411a79 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/shared.js +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/shared.js @@ -1392,9 +1392,10 @@ window.fv3ContainerAction = async (type, id, action) => { }; // Unraid's answer to a container or VM action in the shape the folder actions read: a refusal's reason is in `success` (Events.php) -// or `error` (VMajax.php), the same on 7.0 to 7.4 +// or `error` (VMajax.php); an answer that is no object at all is a failure too window.fv3ActionAnswer = (answer) => { - if (!answer || typeof answer !== 'object') return answer; + if (!answer || typeof answer !== 'object') return { success: false, text: answer ? String(answer) : fv3I18nOr('request-failed', 'Request failed') }; + if (answer.success === true) return answer; var reason = typeof answer.success === 'string' && answer.success ? answer.success : answer.error; return typeof reason === 'string' && reason ? { success: false, text: reason } : answer; }; From 071f96c1b899bf0e62b834db34c69646e97728fe Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 02:05:49 +0000 Subject: [PATCH 06/72] chore(beta): release changelog Release-Synced: 43c85d1a8c8e651a70167992a1838043f6b047e9 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81dbcb40..23e5095e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache if the page doesn't display correctly — before submitting a debug .json. +## Unreleased + +- refactor: the folder-file code moves from lib.php to lib.folders.php +- fix: a success with an error field stays a success, a null answer is a failure; the API-first path and raw VM fixtures are tested +- fix: a folder action Unraid refuses shows Unraid's reason, not its JSON answer + ## 2026.11.14.1 (beta) - Folder saves from two tabs, or made at once, no longer overwrite each other From 90f2c02b4ea3c99d48a9ba571b508bbf19e650cf Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 10:44:04 +0800 Subject: [PATCH 07/72] ci: the Unraid watch checks what FolderView3 relies on in every supported Unraid release: contracts, Unraid CSS by release and theme, CSS variable fallbacks --- .github/unraid-watch/README.md | 22 ++++-- .github/unraid-watch/css.py | 97 +++++++++++++++++++++++++++ .github/unraid-watch/github.py | 16 +++++ .github/unraid-watch/releases.py | 6 ++ .github/unraid-watch/report.py | 47 +++++++++++++ .github/unraid-watch/scan.py | 15 +++++ .github/unraid-watch/status.py | 11 ++- .github/unraid-watch/test_commands.py | 49 +++++++++++++- .github/unraid-watch/test_css.py | 71 ++++++++++++++++++++ .github/unraid-watch/test_github.py | 10 +++ .github/unraid-watch/test_releases.py | 3 + .github/unraid-watch/test_report.py | 6 ++ .github/unraid-watch/test_status.py | 40 ++++++++--- .github/unraid-watch/upstream.py | 41 +++++++++++ .github/unraid-watch/watch.json | 32 ++++++++- .github/unraid-watch/watch.py | 29 +++++++- .github/unraid-watch/world.py | 32 ++++++++- 17 files changed, 503 insertions(+), 24 deletions(-) create mode 100644 .github/unraid-watch/css.py create mode 100644 .github/unraid-watch/test_css.py diff --git a/.github/unraid-watch/README.md b/.github/unraid-watch/README.md index 7d20aef2..a67b4521 100644 --- a/.github/unraid-watch/README.md +++ b/.github/unraid-watch/README.md @@ -7,11 +7,14 @@ plugin stands. Both go to issue #52. - **check** (every CI run, offline). Reads each GraphQL document out of `scripts/*.js` and `*.page`, and each webgui PHP file the plugin references. Fails when a document is not a plain string, because nothing - downstream could see it. + downstream could see it. Also fails on a `var(--x)` in the plugin's stylesheets with no fallback when only + Unraid defines `--x`, so an Unraid release without it cannot drop the style; a variable the plugin's own + stylesheets declare, or its scripts or server code name (the CSS tool's presets), is the plugin's. - **contract** (pull requests that touch `src/`, this directory or the workflow file, every push to `main` or `beta`, and daily for both). Validates every operation against the `unraid/api` schema on `main` and at the - latest release, and confirms every watched path still exists upstream. Red means the plugin sends something - that is no longer valid, or a file it depends on is gone. The daily run checks each branch with that branch's + latest release, confirms every watched path still exists upstream, and checks every contract on each stable + OS release from the plugin's declared minimum and on the development branch. Red means the plugin sends + something that is no longer valid, a file it depends on is gone, or a release it supports breaks a contract. The daily run checks each branch with that branch's copy of the tool; a manual run checks the branch it is started on. - **watch** (daily, on every push to `beta`, and by hand). It always reads the plugin on `beta`, whichever branch starts it, and does two things: @@ -39,8 +42,13 @@ Once it is on `main` the daily run starts by itself, and still reads `beta`. - **Coming with X.Y**: what the newest OS pre-release has that the newest stable does not. - **Operations by OS release**: how many of the plugin's operations are valid on the API each OS release bundles, and which fields are missing. +- **Contracts by OS release**: whether each contract holds on every supported release and the development branch. +- **Unraid CSS by OS release**: per theme, the layout properties Unraid's stylesheets set on an element the + plugin's own CSS styles, that differ between releases, and that the plugin does not set itself: what can + look different on an older or newer Unraid. A rule no longer set on the development branch is listed apart, + as it has often only moved to a stylesheet not read here. - **API not used yet**: Docker and VM operations the plugin never calls, and how much of each type it reads. -- **Still on legacy**: the webgui files the plugin still depends on. +- **Still on legacy**: the webgui files the plugin still depends on, stylesheets aside. OS versions and the API each one bundles are read from the release notes. They state it in prose, in several styles; a release whose notes do not say is listed as not stated rather than guessed. Files are compared by @@ -63,6 +71,12 @@ with `' + name + '` when `watch.json` has an `expand` rule naming the JS map tha operation from an unread field. - `releases`: directory holding the OS release notes. `since` is the oldest OS release to list, and `tags` is the repository whose tags carry those OS versions. +- `manifest`: the plugin's `.plg`. Its `min` attribute is the oldest OS release the contracts and stylesheets + are checked on; the webgui's stable tags from there up are the releases. +- `contracts`: what the plugin relies on in a webgui file, as a `path`, a regular expression it must `match`, + and `why`. Optional `since`: the oldest release held to it. Add one with each change that relies on Unraid. +- `styles`: the `themes`, and the stylesheet `files` that make up each one in load order (`{theme}` is + replaced). A file a release does not have is skipped, so files from older and newer layouts can both be listed. ## Running it by hand diff --git a/.github/unraid-watch/css.py b/.github/unraid-watch/css.py new file mode 100644 index 00000000..c7ca166a --- /dev/null +++ b/.github/unraid-watch/css.py @@ -0,0 +1,97 @@ +"""Stylesheets, FolderView3's and Unraid's: rules as text, the elements FolderView3 styles, and what Unraid sets on them per release.""" +import re + +TOKEN = re.compile(r'[#.][A-Za-z_][\w-]*') +COMMENT = re.compile(r'/\*.*?\*/', re.S) +# A semicolon inside url(...) or a data URI does not end a declaration +DECLARATION = re.compile(r';(?![^(]*\))') +VAR = re.compile(r'var\(\s*(--[\w-]+)\s*([,)])') +DEFINED = re.compile(r'(?:^|[;{\s])(--[\w-]+)\s*:') +# What moves or wraps an element. Colours and fonts change with each theme by design, so they are left out +LAYOUT = frozenset({ + 'display', 'position', 'white-space', 'overflow', 'overflow-x', 'overflow-y', 'float', 'clear', 'box-sizing', 'flex', 'flex-direction', + 'flex-wrap', 'flex-grow', 'flex-shrink', 'flex-basis', 'align-items', 'justify-content', 'gap', 'grid-template-columns', 'width', + 'min-width', 'max-width', 'height', 'min-height', 'max-height', 'margin', 'margin-top', 'margin-bottom', 'margin-left', 'margin-right', + 'padding', 'padding-top', 'padding-bottom', 'padding-left', 'padding-right', 'line-height', 'font-size', 'vertical-align', 'text-align', + 'text-overflow', 'word-break', 'overflow-wrap', 'table-layout', 'border-collapse', 'border-spacing', 'top', 'left', 'right', 'bottom', + 'transform', 'z-index', 'visibility', 'content'}) + + +def uncommented(text): + """The text with each comment blanked out, line breaks kept so positions still give line numbers.""" + return COMMENT.sub(lambda m: '\n' * m.group(0).count('\n'), text) + + +def rules(text): + """[(at-rule conditions, selector, {property: value})], one entry per selector of a rule.""" + text = uncommented(text) + out, heads, start = [], [], 0 + for i, c in enumerate(text): + if c == '{': + heads.append(' '.join(text[start:i].split())) + start = i + 1 + elif c == '}' and heads: + head, body = heads.pop(), text[start:i] + if not head.startswith('@') and '{' not in body: + decls = {} + for part in DECLARATION.split(body): + name, colon, value = part.partition(':') + if colon and name.strip(): + # `4px!important` and `4px !important` are the same value + decls[name.strip().lower()] = ' '.join(re.sub(r'\s*!\s*important\b', ' !important', value).split()) + context = ' '.join(h for h in heads if h.startswith('@')) + out += [(context, ' '.join(s.split()), decls) for s in head.split(',') if s.strip()] + start = i + 1 + return out + + +def subject(selector): + """The ids and classes of the element a selector styles: its last compound, without what :not(...) and the like name.""" + last = re.split(r'[\s>+~]+', re.sub(r'\([^()]*\)', '', selector).strip())[-1] + return TOKEN.findall(last) + + +def styled(texts): + """{id or class: properties FolderView3 sets on elements that carry it} from FolderView3's own stylesheets.""" + out = {} + for text in texts: + for _, selector, decls in rules(text): + for token in subject(selector): + out.setdefault(token, set()).update(decls) + return out + + +def merged(texts): + """{(at-rule conditions, selector, property): value} for stylesheets in load order: a later one wins.""" + out = {} + for text in texts: + for context, selector, decls in rules(text): + for name, value in decls.items(): + out[(context, selector, name)] = value + return out + + +def changes(by_ref, refs, ours): + """[(at-rule conditions, selector, property, [(ref, value or None)])] for layout properties Unraid sets on an element + FolderView3 styles, that differ between refs, and that FolderView3 does not set there itself.""" + out = [] + for context, selector, name in sorted(set().union(*(by_ref[r] for r in refs))): + tokens = [t for t in subject(selector) if t in ours] + if name not in LAYOUT or not tokens or any(name in ours[t] for t in tokens): + continue + values = [(ref, by_ref[ref].get((context, selector, name))) for ref in refs] + if len({v for _, v in values}) > 1: + out.append((context, selector, name, values)) + return out + + +def fallbacks(stylesheets, code): + """Problems: var(--x) with no fallback where --x is Unraid's: no FolderView3 stylesheet declares it and its scripts and + server code (the CSS tool's presets, the generated theme CSS) never name it.""" + texts = {f: uncommented(f.read_text(encoding='utf-8')) for f in stylesheets} + ours = {name for text in texts.values() for name in DEFINED.findall(text)} + named = '\n'.join(f.read_text(encoding='utf-8') for f in code) + return [f'{f.name}:{text.count(chr(10), 0, m.start()) + 1}: var({m.group(1)}) has no fallback and only Unraid defines ' + f'{m.group(1)}; an Unraid release without it would drop the style' + for f, text in texts.items() for m in VAR.finditer(text) + if m.group(2) == ')' and m.group(1) not in ours and not re.search(r"['\"](?:--)?" + re.escape(m.group(1)[2:]) + r"['\"]", named)] diff --git a/.github/unraid-watch/github.py b/.github/unraid-watch/github.py index 64911d7f..4e49da31 100644 --- a/.github/unraid-watch/github.py +++ b/.github/unraid-watch/github.py @@ -112,6 +112,22 @@ def read(): return self._call('GET', f'/repos/{repo}/contents/{urllib.parse.quote(path)}', {'ref': ref}, raw=True) return self._once(('file', repo, ref, path), read) + def blob(self, repo, sha): + """A file's text by its blob sha: one read per version of a file, however many releases share it.""" + return self._once(('blob', repo, sha), lambda: self._call('GET', f'/repos/{repo}/git/blobs/{sha}', raw=True)) + + def tags(self, repo): + """Every tag name of a repository.""" + def read(): + names = [] + for page in range(1, 51): + batch = self._call('GET', f'/repos/{repo}/tags', {'page': page, 'per_page': 100}) + names += [t['name'] for t in batch] + if len(batch) < 100: + return names + raise GitHubError(f'{repo}: more than 5000 tags') + return self._once(('tags', repo), read) + def exists(self, repo, ref, path): return bool(self._call('HEAD', f'/repos/{repo}/contents/{urllib.parse.quote(path.rstrip("/"))}', {'ref': ref}, missing=(404,))) diff --git a/.github/unraid-watch/releases.py b/.github/unraid-watch/releases.py index f8a09aa0..05ac29f2 100644 --- a/.github/unraid-watch/releases.py +++ b/.github/unraid-watch/releases.py @@ -16,6 +16,12 @@ def stable(version): return '-' not in version +def os_tag(name): + """A stable Unraid OS release tag such as 7.4.0; the webgui's oldest tags are dates such as 2014.11.10.""" + found = VERSION.fullmatch(name) + return bool(found) and stable(name) and int(found.group(1)) < 1000 + + def heading(text): """First markdown heading of a release-notes file; '' when it has none.""" for line in text.splitlines(): diff --git a/.github/unraid-watch/report.py b/.github/unraid-watch/report.py index 41366faa..ef3f375c 100644 --- a/.github/unraid-watch/report.py +++ b/.github/unraid-watch/report.py @@ -91,6 +91,52 @@ def _changed(commits): return f'{len(commits)} commit{"" if len(commits) == 1 else "s"}, newest {code(f"{date} {subject}")}' +def _runs(values): + """`a` in `7.0.0`–`7.3.5`, not set in `7.4.0`–`master`: consecutive refs with the same value as one span.""" + runs = [] + for ref, value in values: + if runs and runs[-1][0] == value: + runs[-1][2] = ref + else: + runs.append([value, ref, ref]) + return ', '.join(f'{"not set" if value is None else code(value)} in {code(a)}' + ('' if a == b else f'–{code(b)}') + for value, a, b in runs) + + +def _contracts(view): + *tags, branch = view['refs'] + span = ((f'{code(tags[0])} to {code(tags[-1])}' if len(tags) > 1 else code(tags[0])) + ' and ' if tags else '') + code(branch) + out = ['', '**Contracts by OS release**', '', f'What FolderView3 relies on in the webgui, checked on {span}.', ''] + for entry, found in view['contracts']: + held = [ref for ref, ok in found.items() if ok is not None] + failed = [ref for ref, ok in found.items() if ok is False] + state = 'fails on ' + ', '.join(code(r) for r in failed) if failed else f'holds on all {len(held)}' + since = f' (from {code(entry["since"])})' if 'since' in entry else '' + out.append(f'- {code(entry["path"].rsplit("/", 1)[-1])} {entry["why"]}: {state}{since}') + return out + + +def _styles(view): + themes, changed, gone = list(view['styles']), {}, {} + for theme, rows in view['styles'].items(): + for context, selector, name, values in rows: + # Not set on the development branch any more: often a rule that moved to a stylesheet this does not read + (gone if values[-1][1] is None else changed).setdefault((context, selector, name, tuple(values)), []).append(theme) + + def row(key, who): + context, selector, name, values = key + where = '' if len(who) == len(themes) else f' ({", ".join(who)})' + return f'- {code((context + " " if context else "") + selector, 200)} {code(name)}: {_runs(values)}{where}' + out = ['', '**Unraid CSS by OS release**', '', + 'Layout properties Unraid sets on elements FolderView3 styles, that differ between releases, and that FolderView3 ' + 'does not set itself.', ''] + out += capped([row(k, w) for k, w in changed.items()], 60) or ['- none'] + if gone: + out += ['', f'
No longer set in the stylesheets read here ({len(gone)}; may have moved elsewhere)', ''] + out += capped([row(k, w) for k, w in gone.items()], 60) + ['', '
'] + return out + + def render_status(view): newest, stable, latest = view['releases'] facts = [f'Newest OS release {code(newest[0])} (API {code(newest[1] or "not stated")})'] if newest else [] @@ -117,6 +163,7 @@ def render_status(view): + ': ' + '; '.join(members)) if view['unstated']: out.append('- API version not stated in the notes: ' + ', '.join(code(v) for v in view['unstated'])) + out += _contracts(view) + _styles(view) out += ['', f'
API not used yet ({len(view["idle"])} operations)', ''] out += [f'- {code(signature, 300)}' for signature in view['idle']] if view['types']: diff --git a/.github/unraid-watch/scan.py b/.github/unraid-watch/scan.py index 15ac1f9b..b00a8247 100644 --- a/.github/unraid-watch/scan.py +++ b/.github/unraid-watch/scan.py @@ -65,6 +65,21 @@ def operations(plugin, rules): return ops, problems +def stylesheets(plugin): + return _files(plugin, ('styles/*.css',)) + + +def code(plugin): + """The scripts and server code, which name the plugin's own CSS variables (the CSS tool, the generated theme CSS).""" + return _files(plugin, ('scripts/*.js', 'server/*.php')) + + +def minimum(manifest): + """The oldest Unraid release the plugin declares it runs on: the PLUGIN tag's min attribute; None when it has none.""" + found = re.search(r']*\bmin="(\d+\.\d+\.\d+)"', manifest.read_text(encoding='utf-8')) if manifest.is_file() else None + return found and found.group(1) + + def endpoints(plugin, prefixes): """{upstream path: file:line} for every webgui PHP file the plugin references by URL or include.""" found = {} diff --git a/.github/unraid-watch/status.py b/.github/unraid-watch/status.py index d6414760..0482ff43 100644 --- a/.github/unraid-watch/status.py +++ b/.github/unraid-watch/status.py @@ -20,8 +20,8 @@ def stage(gh, cfg, ops, watched, spans): return out -def gather(gh, cfg, ops, watched, heads): - """Everything the status comment shows, as plain data.""" +def gather(gh, cfg, ops, watched, heads, local): + """Everything the status comment shows, as plain data; local is watch.local(): the plugin's floor and styled elements.""" api, docs = upstream.source(cfg, 'schema'), upstream.source(cfg, 'releases') core, tagged = api['repo'], docs['tags'] branch = next(s['branch'] for s in cfg['sources'] if s['repo'] == tagged) @@ -59,5 +59,10 @@ def bundled(release): current = schema.load(gh.file(core, heads[core], api['schema'])) idle, types = schema.coverage(current, api['surface'], schema.check(current, ops)[2], api['namespaces']) + held = upstream.source(cfg, 'contracts') + refs = upstream.release_refs(gh, held, local['floor']) return {'releases': (newest, stable, latest), 'stages': stages, 'matrix': matrix, 'unstated': unstated, - 'idle': idle, 'types': types, 'legacy': sorted(watched[tagged].items())} + 'idle': idle, 'types': types, 'refs': refs, 'contracts': upstream.contracts(gh, held, refs), + 'styles': upstream.stylesheets(gh, held, refs, local['styled']), + # Stylesheets are not pages to move off: they are what the plugin's own CSS sits on + 'legacy': [(path, why) for path, why in sorted(watched[tagged].items()) if not path.endswith('.css')]} diff --git a/.github/unraid-watch/test_commands.py b/.github/unraid-watch/test_commands.py index afc99793..20ff35a6 100644 --- a/.github/unraid-watch/test_commands.py +++ b/.github/unraid-watch/test_commands.py @@ -5,7 +5,7 @@ import watch from github import GitHubError -from world import API, CFG, DOCS, ME, NEW, RELEASE, SCRIPT, SDL, USERPREFS, WEB, WITHOUT_STOP, Case, World, sha, url +from world import API, CFG, DOCS, EVENTS, ME, NEW, RELEASE, SCRIPT, SDL, STYLES, USERPREFS, WEB, WITHOUT_STOP, Case, World, sha, url class ContractTest(Case): @@ -77,10 +77,43 @@ def test_scan_problem_fails_the_contract(self): self.assertEqual(code, 1) self.assertIn('::error::a.js:6:', out) + def test_contracts_are_checked_on_master_and_listed(self): + code, out = self.contract() + self.assertEqual(code, 0) + self.assertIn(f'- contract {EVENTS}: holds on 1 of 1 refs', out) + + def test_a_contract_a_supported_release_breaks_fails_and_names_the_release(self): + self.w.release_line() + self.w.tree(WEB, '9.0.3', {EVENTS: 'ev0'}) + self.w.blob(WEB, 'ev0', "$arrResponse = ['ok' => $DockerClient->startContainer($container)];\n") + code, out = self.contract() + self.assertEqual(code, 1) + self.assertIn(f"::error::unraid/webgui: {EVENTS} does not match \"'success' => \" on 9.0.3: answers in `success`", out) + self.assertIn(f'- contract {EVENTS}: holds on 1 of 2 refs', out) + + def test_a_release_before_a_contracts_since_is_not_held_to_it(self): + self.w.release_line() + self.w.tree(WEB, '9.0.3', {}) + cfg = {**CFG, 'sources': [{**s, 'contracts': [{**s['contracts'][0], 'since': '9.1.0'}]} if 'contracts' in s else s + for s in CFG['sources']]} + code, out = self.captured(watch.cmd_contract, cfg, self.w.client(), self.w.root, None) + self.assertEqual(code, 0) + self.assertIn(f'- contract {EVENTS}: holds on 1 of 1 refs', out) + + def test_only_stable_releases_from_the_plugins_minimum_are_read(self): + self.w.release_line() + self.contract() + read = {c[1].split('/git/trees/')[1].split('?')[0] for c in self.w.fake.calls if f'/repos/{WEB}/git/trees/' in c[1]} + self.assertEqual(read, {'9.0.3', 'master'}) + + def test_a_manifest_without_a_minimum_stops_the_contract(self): + with self.assertRaisesRegex(watch.Problem, 'no min="x.y.z"'): + self.contract(world=World(self, manifest='\n')) + class CheckTest(Case): - def check(self, script): - world = World(self, script) + def check(self, script, **world): + world = World(self, script, **world) code, out = self.captured(watch.cmd_check, CFG, world.root) self.assertEqual(world.fake.calls, []) return code, out @@ -107,6 +140,16 @@ def test_plugin_that_references_no_endpoint_fails(self): self.assertEqual(code, 1) self.assertIn('::error::unraid/webgui: the plugin references none of its endpoints', out) + def test_an_unraid_css_variable_without_a_fallback_fails(self): + code, out = self.check(SCRIPT, styles=STYLES + '.tip { margin: var(--gap); }\n') + self.assertEqual(code, 1) + self.assertIn('::error::a.css:3: var(--gap) has no fallback and only Unraid defines --gap', out) + + def test_a_manifest_without_a_minimum_fails(self): + code, out = self.check(SCRIPT, manifest='\n') + self.assertEqual(code, 1) + self.assertIn('::error::plugin.plg: no min="x.y.z" on its PLUGIN tag', out) + class MainTest(Case): def main(self, *argv): diff --git a/.github/unraid-watch/test_css.py b/.github/unraid-watch/test_css.py new file mode 100644 index 00000000..7e1109cf --- /dev/null +++ b/.github/unraid-watch/test_css.py @@ -0,0 +1,71 @@ +import tempfile +import unittest +from pathlib import Path + +import css + + +class RulesTest(unittest.TestCase): + def test_each_selector_gets_the_declarations_and_its_at_rule(self): + text = '/* a\ncomment */ @media (max-width: 9px) { .a, #b > .c { white-space: pre-line; margin-top:4px!important } }\n.d{display:none}' + self.assertEqual(css.rules(text), [ + ('@media (max-width: 9px)', '.a', {'white-space': 'pre-line', 'margin-top': '4px !important'}), + ('@media (max-width: 9px)', '#b > .c', {'white-space': 'pre-line', 'margin-top': '4px !important'}), + ('', '.d', {'display': 'none'})]) + + def test_a_semicolon_inside_a_url_does_not_end_the_declaration(self): + self.assertEqual(css.rules('.a { background: url(data:image/png;base64,xy); top: 0 }'), + [('', '.a', {'background': 'url(data:image/png;base64,xy)', 'top': '0'})]) + + def test_the_styled_element_is_the_last_compound_without_what_not_names(self): + self.assertEqual(css.subject('#docker_containers > tr.sortable:not(.folder)'), ['.sortable']) + self.assertEqual(css.subject('div.title:first-of-type'), ['.title']) + self.assertEqual(css.subject('label + .content'), ['.content']) + + +class ChangesTest(unittest.TestCase): + OURS = {'.tip': {'color'}, '.row': {'white-space'}} + + def by_ref(self, old, new): + return {'7.0.0': css.merged([old]), 'master': css.merged([new])} + + def test_a_layout_property_unraid_changed_on_an_element_the_plugin_styles_is_listed(self): + rows = css.changes(self.by_ref('.tip { display: block }', '.tip { white-space: pre-line }'), ['7.0.0', 'master'], self.OURS) + self.assertEqual(rows, [('', '.tip', 'display', [('7.0.0', 'block'), ('master', None)]), + ('', '.tip', 'white-space', [('7.0.0', None), ('master', 'pre-line')])]) + + def test_what_the_plugin_sets_itself_colours_and_elements_it_does_not_style_are_left_out(self): + # .row's colour: an element the plugin styles, a property it does not set, but a colour, not layout + old = '.row { white-space: nowrap; color: red } .tip { color: red } .other { display: block }' + new = '.row { white-space: normal; color: blue } .tip { color: blue } .other { display: flex }' + self.assertEqual(css.changes(self.by_ref(old, new), ['7.0.0', 'master'], self.OURS), []) + + def test_a_later_stylesheet_wins_as_the_page_loads_them(self): + self.assertEqual(css.merged(['.tip { top: 1px }', '.tip { top: 2px }']), {('', '.tip', 'top'): '2px'}) + + +class FallbacksTest(unittest.TestCase): + def check(self, sheet, code=''): + tmp = tempfile.TemporaryDirectory() + self.addCleanup(tmp.cleanup) + a, js = Path(tmp.name, 'a.css'), Path(tmp.name, 'a.js') + a.write_text(sheet, encoding='utf-8') + js.write_text(code, encoding='utf-8') + return css.fallbacks([a], [js]) + + def test_an_unraid_variable_without_a_fallback_is_named_with_its_line(self): + (problem,) = self.check('/* two\nlines */\n.a { color: var(--text); }\n') + self.assertTrue(problem.startswith('a.css:3: var(--text) has no fallback and only Unraid defines --text'), problem) + + def test_a_fallback_or_a_variable_the_plugin_owns_passes(self): + self.assertEqual(self.check('.a { color: var(--text, #fff); }'), []) + self.assertEqual(self.check(':root { --gap: 5px; } .a { gap: var(--gap); }'), []) + self.assertEqual(self.check('.a { color: var(--fv3-name-color); }', "const vars = { 'fv3-name-color': '#fff' };"), []) + + def test_a_variable_nested_in_a_fallback_needs_its_own(self): + (problem,) = self.check('.a { color: var(--fv3-x, var(--text)); }', "'fv3-x'") + self.assertIn('var(--text) has no fallback', problem) + + +if __name__ == '__main__': + unittest.main() diff --git a/.github/unraid-watch/test_github.py b/.github/unraid-watch/test_github.py index dbe3043c..bdcf981c 100644 --- a/.github/unraid-watch/test_github.py +++ b/.github/unraid-watch/test_github.py @@ -15,6 +15,16 @@ def compare(self, page, status, total, numbers): self.fake.routes['GET', url(f'/repos/o/r/compare/{sha(1)}...{sha(2)}', page=page, per_page=100)] = { 'status': status, 'total_commits': total, 'commits': [commit(n) for n in numbers]} + def test_tags_follow_every_page(self): + self.fake.routes['GET', url('/repos/o/r/tags', page=1, per_page=100)] = [{'name': f't{n}'} for n in range(100)] + self.fake.routes['GET', url('/repos/o/r/tags', page=2, per_page=100)] = [{'name': 't100'}] + self.assertEqual(self.gh.tags('o/r'), [f't{n}' for n in range(101)]) + + def test_a_blob_is_read_once_however_many_releases_share_it(self): + self.fake.routes['GET', '/repos/o/r/git/blobs/abc'] = '.tip { top: 0 }' + self.assertEqual([self.gh.blob('o/r', 'abc') for _ in range(3)], ['.tip { top: 0 }'] * 3) + self.assertEqual(len(self.fake.sent('GET')), 1) + def test_between_follows_every_page(self): self.compare(1, 'ahead', 105, range(100, 200)) self.compare(2, 'ahead', 105, range(200, 205)) diff --git a/.github/unraid-watch/test_releases.py b/.github/unraid-watch/test_releases.py index d24901b5..2e512aa2 100644 --- a/.github/unraid-watch/test_releases.py +++ b/.github/unraid-watch/test_releases.py @@ -10,6 +10,9 @@ def test_versions_sort_beta_before_rc_before_final(self): ['9.0.9', '9.0.10', '9.1.0-beta.2', '9.1.0-beta.2.1', '9.1.0-beta.10', '9.1.0-rc.1', '9.1.0', '10.0.0-beta.1']) + def test_an_os_release_tag_is_a_stable_version_not_a_date(self): + self.assertEqual([t for t in ('7.4.0', '7.4.0-rc.1', '2014.11.10', 'v7.4.0', '7.4') if releases.os_tag(t)], ['7.4.0']) + def test_stable_means_no_prerelease_suffix(self): self.assertTrue(releases.stable('9.1.0')) self.assertFalse(releases.stable('9.1.0-rc.1')) diff --git a/.github/unraid-watch/test_report.py b/.github/unraid-watch/test_report.py index 4b01e673..cd8a4363 100644 --- a/.github/unraid-watch/test_report.py +++ b/.github/unraid-watch/test_report.py @@ -181,5 +181,11 @@ def test_unexpected_comment_link_is_refused(self): report.announce(data, link) +class RunsTest(unittest.TestCase): + def test_releases_with_the_same_value_read_as_one_span(self): + values = [('7.0.0', None), ('7.1.0', None), ('7.2.0', '4px'), ('7.3.0', None), ('master', None)] + self.assertEqual(report._runs(values), 'not set in `7.0.0`–`7.1.0`, `4px` in `7.2.0`, not set in `7.3.0`–`master`') + + if __name__ == '__main__': unittest.main() diff --git a/.github/unraid-watch/test_status.py b/.github/unraid-watch/test_status.py index 8c97d6e3..8c197449 100644 --- a/.github/unraid-watch/test_status.py +++ b/.github/unraid-watch/test_status.py @@ -42,7 +42,7 @@ def view(self): self.w.release_line() return status.gather(self.w.client(), CFG, OPS, {API: {'api/switch.ts': 'page switch'}, WEB: {'emhttp/page/': 'markup', USERPREFS: 'called from a.js:5'}, - DOCS: {}}, NEW) + DOCS: {}}, NEW, self.local()) def test_stages_cover_merged_released_and_the_prerelease(self): titles = [title for title, _ in self.view()['stages']] @@ -81,9 +81,28 @@ def test_status_reads_as_expected(self): '- 3 of 3: `main` (not released); `v4.2.0` (latest API release); `v4.1.0` (Unraid 9.1.0-beta.2)', '- 2 of 3, missing `DockerMutations.stop`: `v4.0.0` (Unraid 9.0.3)', '- API version not stated in the notes: `9.0.2`, `9.0.1`', + '', + '**Contracts by OS release**', + '', + 'What FolderView3 relies on in the webgui, checked on `9.0.3` and `master`.', + '', + '- `Events.php` answers in `success`: holds on all 2', + '', + '**Unraid CSS by OS release**', + '', + 'Layout properties Unraid sets on elements FolderView3 styles, that differ between releases, and that FolderView3 ' + 'does not set itself.', + '', + '- `.tip` `white-space`: not set in `9.0.3`, `pre-line` in `master`', ])) self.assertEqual(body.split('\n\n
', 1)[1], '\n'.join([ - 'API not used yet (1 operations)', + 'No longer set in the stylesheets read here (1; may have moved elsewhere)', + '', + '- `.tip` `display`: `block` in `9.0.3`, not set in `master` (azure)', + '', + '
', + '', + '
API not used yet (1 operations)', '', '- `DockerMutations.restart(id: ID!): Boolean!`', '', @@ -108,7 +127,7 @@ def test_each_schema_is_fetched_once_however_many_stages_use_it(self): url(f'/repos/{API}/contents/api/schema.graphql', ref=ref) for ref in (RELEASE, BETA_API, LATEST_API, NEW[API]))) def test_with_no_release_notes_the_stages_that_need_them_say_so(self): - body = report.render_status(status.gather(self.w.client(), CFG, OPS, {API: {}, WEB: {}, DOCS: {}}, NEW)) + body = report.render_status(status.gather(self.w.client(), CFG, OPS, {API: {}, WEB: {}, DOCS: {}}, NEW, self.local())) self.assertIn('Latest API release `v4.0.0`.', body) self.assertIn('**Coming: merged, in no release**\n\n- unraid/api `v4.0.0`...`main`: nothing\n' '- unraid/webgui `not stated`...`master`: not available\n', body) @@ -121,7 +140,7 @@ def test_with_no_release_notes_the_stages_that_need_them_say_so(self): def test_release_whose_notes_do_not_state_the_api_says_so(self): self.w.release_line() self.w.notes(NEW[DOCS], {'9.1.0.md': '# Version 9.1.0-beta.2 2030-01-02\n\nNothing about the API.\n'}) - body = report.render_status(status.gather(self.w.client(), CFG, OPS, {API: {}, WEB: {}, DOCS: {}}, NEW)) + body = report.render_status(status.gather(self.w.client(), CFG, OPS, {API: {}, WEB: {}, DOCS: {}}, NEW, self.local())) self.assertIn('Newest OS release `9.1.0-beta.2` (API `not stated`), latest API release `v4.2.0`.', body) self.assertIn('**Coming: released API, not in an OS build**\n\n- unraid/api `not stated`...`v4.2.0`: not available\n', body) self.assertIn('- API version not stated in the notes: `9.1.0-beta.2`', body) @@ -129,11 +148,16 @@ def test_release_whose_notes_do_not_state_the_api_says_so(self): def test_release_documented_before_its_tag_exists_is_shown_as_not_available(self): self.w.release_line() del self.w.fake.routes['GET', f'/repos/{WEB}/commits/9.1.0-beta.2'] - body = report.render_status(status.gather(self.w.client(), CFG, OPS, {API: {}, WEB: {}, DOCS: {}}, NEW)) + body = report.render_status(status.gather(self.w.client(), CFG, OPS, {API: {}, WEB: {}, DOCS: {}}, NEW, self.local())) self.assertIn('- unraid/webgui `9.1.0-beta.2`...`master`: not available\n', body) self.assertIn('- unraid/webgui `9.0.3`...`9.1.0-beta.2`: not available\n', body) self.assertIn('- unraid/api `v4.0.0`...`v4.1.0`:\n - removed', body) + def test_watched_stylesheets_are_not_listed_as_legacy_pages(self): + view = status.gather(self.w.client(), CFG, OPS, {API: {}, WEB: {'css/azure.css': 'theme', USERPREFS: 'prefs'}, DOCS: {}}, + NEW, self.local()) + self.assertEqual(view['legacy'], [(USERPREFS, 'prefs')]) + def test_file_that_differs_with_no_commit_to_show_just_says_differs(self): view = self.view() view['stages'] = [('Coming: merged, in no release', [(API, 'v4.2.0', 'main', [], [('api/switch.ts', 'w', [])])])] @@ -143,7 +167,7 @@ def test_when_the_newest_release_is_stable_there_is_no_prerelease_stage(self): self.w.release_line() self.w.notes(NEW[DOCS], {'9.0.3.md': '# Version 9.0.3 2030-01-01\n\n* The Unraid API version remains 4.0.0.\n'}) self.w.tree(WEB, STABLE_WEB, {'emhttp/page': 't1', USERPREFS: 'u0'}) - body = report.render_status(status.gather(self.w.client(), CFG, OPS, {API: {}, WEB: {}, DOCS: {}}, NEW)) + body = report.render_status(status.gather(self.w.client(), CFG, OPS, {API: {}, WEB: {}, DOCS: {}}, NEW, self.local())) self.assertIn('Newest OS release `9.0.3` (API `4.0.0`), latest API release `v4.2.0`.', body) self.assertNotIn('Coming with', body) self.assertIn('- unraid/webgui `9.0.3`...`master`: nothing', body) @@ -152,7 +176,7 @@ def test_when_the_newest_release_is_stable_there_is_no_prerelease_stage(self): def test_latest_release_that_an_os_build_already_ships_is_one_row(self): self.w.release_line() self.w.fake.routes['GET', f'/repos/{API}/releases/latest'] = {'tag_name': 'v4.1.0'} - body = report.render_status(status.gather(self.w.client(), CFG, OPS, {API: {}, WEB: {}, DOCS: {}}, NEW)) + body = report.render_status(status.gather(self.w.client(), CFG, OPS, {API: {}, WEB: {}, DOCS: {}}, NEW, self.local())) self.assertIn('`v4.1.0` (latest API release, Unraid 9.1.0-beta.2)', body) self.assertIn('- unraid/api `v4.1.0`...`v4.1.0`: nothing', body) @@ -161,7 +185,7 @@ def test_upstream_text_in_the_status_stays_inert(self): self.w.between(API, [50, 51], span=(LATEST_API, NEW[API])) self.w.fake.routes['GET', url(f'/repos/{API}/commits', page=1, path='api/switch.ts', per_page=100, sha=NEW[API])] = [ commit(51, 'x `y` @someone '), commit(50, 'older')] - body = report.render_status(status.gather(self.w.client(), CFG, OPS, {API: {'api/switch.ts': 'w'}, WEB: {}, DOCS: {}}, NEW)) + body = report.render_status(status.gather(self.w.client(), CFG, OPS, {API: {'api/switch.ts': 'w'}, WEB: {}, DOCS: {}}, NEW, self.local())) self.assertIn("`api/switch.ts`: 2 commits, newest `2026-10-01 x 'y' @someone `", body) self.assertTrue(body.endswith('\n\n' + report.STATUS)) diff --git a/.github/unraid-watch/upstream.py b/.github/unraid-watch/upstream.py index f482815f..4deaa655 100644 --- a/.github/unraid-watch/upstream.py +++ b/.github/unraid-watch/upstream.py @@ -1,6 +1,7 @@ """What upstream looks like, read through the GitHub client: schema changes, release notes, file differences.""" import re +import css import releases import schema @@ -67,6 +68,46 @@ def validity(gh, src, ops, refs): return out +def release_refs(gh, src, floor): + """Stable release tags at or after floor (the plugin's declared minimum), oldest first, then the development branch.""" + tags = [t for t in gh.tags(src['repo']) if releases.os_tag(t)] + return sorted((t for t in tags if releases.order(t) >= releases.order(floor)), key=releases.order) + [src['branch']] + + +def text_at(gh, repo, ref, path): + """A file's text at a ref; None when the file is not there.""" + blob = gh.tree(repo, ref).get(path) + return None if blob is None else gh.blob(repo, blob) + + +def applies(entry, ref): + """A contract with `since` holds only from that release on; the development branch is always held to it.""" + return 'since' not in entry or not releases.VERSION.fullmatch(ref) or releases.order(ref) >= releases.order(entry['since']) + + +def contracts(gh, src, refs): + """[(contract, {ref: True if it holds, False if not, None where it does not apply})].""" + out = [] + for entry in src.get('contracts', []): + found = {ref: bool(re.search(entry['match'], text_at(gh, src['repo'], ref, entry['path']) or '')) + if applies(entry, ref) else None for ref in refs} + out.append((entry, found)) + return out + + +def stylesheets(gh, src, refs, ours): + """{theme: css.changes} for Unraid's stylesheets per release; a file a release does not have is skipped.""" + styles = src['styles'] + out = {} + for theme in styles['themes']: + by_ref = {} + for ref in refs: + texts = (text_at(gh, src['repo'], ref, pattern.format(theme=theme)) for pattern in styles['files']) + by_ref[ref] = css.merged(t for t in texts if t is not None) + out[theme] = css.changes(by_ref, refs, ours) + return out + + def differences(gh, repo, paths, start, head): """[(path, why, commits)] for watched paths that differ between two commits; commits is None when start is no ancestor.""" a, b = gh.tree(repo, start), gh.tree(repo, head) diff --git a/.github/unraid-watch/watch.json b/.github/unraid-watch/watch.json index 6c15eb26..0f863386 100644 --- a/.github/unraid-watch/watch.json +++ b/.github/unraid-watch/watch.json @@ -1,6 +1,7 @@ { "issue": 52, "plugin": "src/folder.view3/usr/local/emhttp/plugins/folder.view3", + "manifest": "folder.view3.plg", "expand": [ {"match": "docker { ${gqlAction}", "map": "fv3DockerActionMap"}, {"match": "vm { ${gqlAction}", "map": "fv3VmActionMap"} @@ -48,7 +49,36 @@ "emhttp/plugins/dynamix/include/DefaultPageLayout/BodyInlineJS.php": "task tray openDocker runs through from 7.4", "emhttp/plugins/dynamix/include/TaskCommand.php": "task tray endpoint behind openDocker from 7.4", "emhttp/plugins/dynamix/styles/default-dynamix.css": "tooltipster rules the advanced preview popup is drawn inside (7.4 added white-space: pre-line)", - "emhttp/plugins/dynamix/styles/default-base.css": "sweet-alert, table and menu rules the plugin's dialogs and rows sit in" + "emhttp/plugins/dynamix/styles/default-base.css": "sweet-alert, table and menu rules the plugin's dialogs and rows sit in", + "emhttp/plugins/dynamix/styles/default-color-palette.css": "colour variables the plugin's own colours fall back from", + "emhttp/plugins/dynamix/styles/themes/azure.css": "azure theme rules under the folder rows and dialogs", + "emhttp/plugins/dynamix/styles/themes/black.css": "black theme rules under the folder rows and dialogs", + "emhttp/plugins/dynamix/styles/themes/gray.css": "gray theme rules under the folder rows and dialogs", + "emhttp/plugins/dynamix/styles/themes/white.css": "white theme rules under the folder rows and dialogs", + "emhttp/plugins/dynamix.docker.manager/sheets/DockerContainers.css": "Docker tab rows the folders sit among", + "emhttp/plugins/dynamix.vm.manager/sheets/VMMachines.css": "VMs tab rows the folders sit among", + "emhttp/plugins/dynamix.vm.manager/styles/dynamix.vm.manager.css": "VM list rules the VM folders inherit", + "emhttp/plugins/dynamix/sheets/DashStats.css": "Dashboard tiles the folder tiles are drawn in", + "emhttp/plugins/dynamix.docker.manager/include/Events.php": "answers a container action: true, or the reason Unraid refused it (shared.js fv3ActionAnswer)" + }, + "contracts": [ + {"path": "emhttp/plugins/dynamix.docker.manager/include/Events.php", "match": "'success' => \\$DockerClient->startContainer\\(", + "why": "answers a container start in `success`: true, or the reason it was refused (shared.js fv3ActionAnswer)"}, + {"path": "emhttp/plugins/dynamix.vm.manager/include/VMajax.php", "match": "\\['error' => ", + "why": "answers a refused VM action in `error` (shared.js fv3ActionAnswer)"}, + {"path": "emhttp/plugins/dynamix.docker.manager/include/UserPrefs.php", "match": "\\$save\\[\\] = \\$index\\[\\$i\\+\\+\\]\\.\"=\\\\\"\"\\.\\$name\\.\"\\\\\"\"", + "why": "saves the Docker order as N=\"name\" lines, the format the plugin reads and inserts into (lib.php fv3_parse_user_prefs)"} + ], + "styles": { + "themes": ["azure", "black", "gray", "white"], + "files": [ + "emhttp/plugins/dynamix/styles/default-{theme}.css", "emhttp/plugins/dynamix/styles/dynamix-{theme}.css", + "emhttp/plugins/dynamix/styles/default-color-palette.css", "emhttp/plugins/dynamix/styles/default-base.css", + "emhttp/plugins/dynamix/styles/themes/{theme}.css", "emhttp/plugins/dynamix/styles/default-dynamix.css", + "emhttp/plugins/dynamix/styles/jquery.sweetalert.css", "emhttp/plugins/dynamix/styles/default-popup.css", + "emhttp/plugins/dynamix.docker.manager/sheets/DockerContainers.css", "emhttp/plugins/dynamix.vm.manager/styles/dynamix.vm.manager.css", + "emhttp/plugins/dynamix.vm.manager/sheets/VMMachines.css", "emhttp/plugins/dynamix/sheets/DashStats.css" + ] } }, { diff --git a/.github/unraid-watch/watch.py b/.github/unraid-watch/watch.py index 4598e11c..75e4c042 100644 --- a/.github/unraid-watch/watch.py +++ b/.github/unraid-watch/watch.py @@ -6,12 +6,13 @@ import sys from pathlib import Path +import css import scan import schema import status from github import GitHub, GitHubError from report import announce, code, read_state, render, render_status, restamp, status_comment -from upstream import api_changes, release_notes, source, validity +from upstream import api_changes, contracts, release_notes, release_refs, source, validity HERE = Path(__file__).resolve().parent @@ -41,6 +42,15 @@ def derive(cfg, root): return ops, watched, problems +def local(cfg, root): + """What the checks per release need from the plugin: the oldest Unraid it supports, and what its stylesheets style.""" + floor = scan.minimum(Path(root, cfg['manifest'])) + if not floor: + raise Problem(f'{cfg["manifest"]}: no min="x.y.z" on its PLUGIN tag, so the oldest Unraid it supports is unknown') + sheets = scan.stylesheets(Path(root, cfg['plugin'])) + return {'floor': floor, 'styled': css.styled(f.read_text(encoding='utf-8') for f in sheets)} + + def readable(cfg, root): """(operations, watched paths), or a Problem when the plugin source cannot be read reliably.""" ops, watched, problems = derive(cfg, root) @@ -71,6 +81,12 @@ def show(text): def cmd_check(cfg, root): ops, watched, problems = derive(cfg, root) + plugin = Path(root, cfg['plugin']) + problems += css.fallbacks(scan.stylesheets(plugin), scan.code(plugin)) + try: + local(cfg, root) + except Problem as e: + problems.append(str(e)) for query, where in ops: print(f'{where[0]:22s} {query}') for repo, paths in watched.items(): @@ -97,6 +113,13 @@ def cmd_contract(cfg, gh, root, refs): gone = [p for p in paths if not gh.exists(repo, head, p)] errors += [f'{repo}: {p} no longer exists on {src["branch"]}; fix the call or watch.json' for p in gone] lines.append(f'- {len(paths) - len(gone)} of {len(paths)} watched paths present in {repo}') + held = source(cfg, 'contracts') + for entry, found in contracts(gh, held, release_refs(gh, held, local(cfg, root)['floor'])): + failed = [ref for ref, ok in found.items() if ok is False] + if failed: + errors.append(f'{held["repo"]}: {entry["path"]} does not match {entry["match"]!r} on {", ".join(failed)}: {entry["why"]}') + lines.append(f'- contract {entry["path"]}: holds on {sum(ok is True for ok in found.values())} of ' + f'{sum(ok is not None for ok in found.values())} refs') for error in errors: annotate('error', error) print('\n'.join(lines)) @@ -107,7 +130,7 @@ def cmd_contract(cfg, gh, root, refs): def cmd_status(cfg, gh, root): ops, watched = readable(cfg, root) heads = {src['repo']: gh.sha(src['repo'], src['branch']) for src in cfg['sources']} - show(render_status(status.gather(gh, cfg, ops, watched, heads))) + show(render_status(status.gather(gh, cfg, ops, watched, heads, local(cfg, root)))) return 0 @@ -151,7 +174,7 @@ def cmd_watch(cfg, gh, root, me, base, dry_run): for ref, bad, _ in validity(gh, api, ops, [api['branch'], gh.latest_release(api['repo'])])) + '.' body = render(report, heads) show(body) - view = render_status(status.gather(gh, cfg, ops, watched, heads)) + view = render_status(status.gather(gh, cfg, ops, watched, heads, local(cfg, root))) show(view) if dry_run: return 0 diff --git a/.github/unraid-watch/world.py b/.github/unraid-watch/world.py index 535c113c..11c94c77 100644 --- a/.github/unraid-watch/world.py +++ b/.github/unraid-watch/world.py @@ -19,6 +19,9 @@ BOT = {'login': 'github-actions[bot]'} API, WEB, DOCS = 'unraid/api', 'unraid/webgui', 'unraid/docs' USERPREFS = 'emhttp/plugins/dynamix.docker.manager/include/UserPrefs.php' +EVENTS = 'emhttp/plugins/dynamix.docker.manager/include/Events.php' +# The plugin colours .tip and sets .row's white-space itself +STYLES = '.tip { color: var(--c, red); }\n.row { white-space: nowrap; }\n' SDL = ''' type Query { docker: Docker! } type Mutation { docker: DockerMutations! } @@ -36,12 +39,15 @@ CFG = { 'issue': 52, 'plugin': 'plugin', + 'manifest': 'plugin.plg', 'expand': [{'match': 'docker { ${act}', 'map': 'dockerMap'}], 'sources': [ {'repo': API, 'branch': 'main', 'schema': 'api/schema.graphql', 'surface': '(?i)docker', 'namespaces': ['Docker', 'DockerMutations'], 'paths': {'api/switch.ts': 'page switch'}}, {'repo': WEB, 'branch': 'master', 'paths': {'emhttp/page/': 'markup'}, - 'endpoints': {'/plugins/dynamix.docker.manager/': 'emhttp/plugins/dynamix.docker.manager/'}}, + 'endpoints': {'/plugins/dynamix.docker.manager/': 'emhttp/plugins/dynamix.docker.manager/'}, + 'contracts': [{'path': EVENTS, 'match': "'success' => ", 'why': 'answers in `success`'}], + 'styles': {'themes': ['azure', 'black'], 'files': ['css/old-{theme}.css', 'css/{theme}.css']}}, {'repo': DOCS, 'branch': 'main', 'releases': 'notes/', 'since': '9.0.0', 'tags': WEB}, ], } @@ -94,13 +100,16 @@ def sent(self, method): class World: """A plugin, its issue, and three upstream repos that moved from OLD to NEW without touching anything watched.""" - def __init__(self, case, script=SCRIPT): + def __init__(self, case, script=SCRIPT, styles=STYLES, manifest='\n'): tmp = tempfile.TemporaryDirectory() case.addCleanup(tmp.cleanup) self.root = tmp.name scripts = Path(tmp.name, 'plugin/scripts') scripts.mkdir(parents=True) (scripts / 'a.js').write_text(script, encoding='utf-8') + Path(tmp.name, 'plugin/styles').mkdir() + Path(tmp.name, 'plugin/styles/a.css').write_text(styles, encoding='utf-8') + Path(tmp.name, 'plugin.plg').write_text(manifest, encoding='utf-8') self.fake, self.comments = Fake(), [] routes = self.fake.routes routes['GET', url(f'/repos/{ME}/issues/52/comments', page=1, per_page=100)] = self.comments @@ -120,6 +129,17 @@ def __init__(self, case, script=SCRIPT): self.tree(API, ref, {'api/schema.graphql': 's1', 'api/switch.ts': 'w1'}) self.notes(OLD[DOCS], {}) self.notes(NEW[DOCS], {}) + # The webgui with no release tag yet: contracts and stylesheets are read on master alone + self.tags(WEB, []) + self.tree(WEB, 'master', {EVENTS: 'ev1', 'css/azure.css': 'st1', 'css/black.css': 'st1'}) + self.blob(WEB, 'ev1', "$arrResponse = ['success' => $DockerClient->startContainer($container)];\n") + self.blob(WEB, 'st1', '.tip { white-space: pre-line; color: red; }\n.row { white-space: normal; }\n') + + def tags(self, repo, names): + self.fake.routes['GET', url(f'/repos/{repo}/tags', page=1, per_page=100)] = [{'name': n} for n in names] + + def blob(self, repo, sha, text): + self.fake.routes['GET', f'/repos/{repo}/git/blobs/{sha}'] = text def between(self, repo, numbers, status='ahead', span=None): start, head = span or (OLD[repo], NEW[repo]) @@ -162,6 +182,11 @@ def release_line(self): self.tree(WEB, NEW[WEB], {'emhttp/page': 't1', USERPREFS: 'u0'}) self.between(API, [50], span=(LATEST_API, NEW[API])) self.between(WEB, [60, 61], status='diverged', span=(STABLE_WEB, BETA_WEB)) + # Only 9.0.3 is a stable OS release at or after the plugin's floor (9.0.0); 9.0.3's azure theme sets .tip's display, + # master's does not but sets its white-space + self.tags(WEB, ['9.1.0-beta.2', '9.0.3', '8.9.0', '2014.11.10']) + self.tree(WEB, '9.0.3', {EVENTS: 'ev1', 'css/old-azure.css': 'old1'}) + self.blob(WEB, 'old1', '.tip { display: block; color: blue; }\n') self.fake.routes['GET', url(f'/repos/{API}/commits', page=1, path='api/switch.ts', per_page=100, sha=NEW[API])] = [commit(50, 'feat: enable the new page', '2030-01-03T00:00:00Z')] @@ -228,6 +253,9 @@ def setUp(self): def saved(self, body): return report.read_state([bot(body)])[0] + def local(self): + return watch.local(CFG, self.w.root) + def outputs(self): """Point the job outputs at a file and return its path.""" path = Path(self.w.root, 'out') From 11686276d52195cc065b24c14d1e47c7796da4b5 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 11:01:31 +0800 Subject: [PATCH 08/72] fix: the Unraid watch reads nested CSS, fails closed on empty input, reads master at its pinned sha, and a failed release read no longer stops the news --- .github/unraid-watch/README.md | 7 +- .github/unraid-watch/css.py | 140 +++++++++++++++++++------- .github/unraid-watch/report.py | 24 +++-- .github/unraid-watch/scan.py | 2 +- .github/unraid-watch/status.py | 13 ++- .github/unraid-watch/test_commands.py | 40 +++++++- .github/unraid-watch/test_css.py | 48 +++++++-- .github/unraid-watch/test_releases.py | 2 +- .github/unraid-watch/test_report.py | 4 +- .github/unraid-watch/test_status.py | 60 +++++++---- .github/unraid-watch/upstream.py | 35 ++++--- .github/unraid-watch/watch.py | 27 ++++- .github/unraid-watch/world.py | 11 +- .github/workflows/unraid-watch.yml | 2 + 14 files changed, 310 insertions(+), 105 deletions(-) diff --git a/.github/unraid-watch/README.md b/.github/unraid-watch/README.md index a67b4521..5b2eab3f 100644 --- a/.github/unraid-watch/README.md +++ b/.github/unraid-watch/README.md @@ -13,7 +13,7 @@ plugin stands. Both go to issue #52. - **contract** (pull requests that touch `src/`, this directory or the workflow file, every push to `main` or `beta`, and daily for both). Validates every operation against the `unraid/api` schema on `main` and at the latest release, confirms every watched path still exists upstream, and checks every contract on each stable - OS release from the plugin's declared minimum and on the development branch. Red means the plugin sends + webgui release tag from the plugin's declared minimum and on the development branch. Red means the plugin sends something that is no longer valid, a file it depends on is gone, or a release it supports breaks a contract. The daily run checks each branch with that branch's copy of the tool; a manual run checks the branch it is started on. - **watch** (daily, on every push to `beta`, and by hand). It always reads the plugin on `beta`, whichever branch @@ -42,7 +42,8 @@ Once it is on `main` the daily run starts by itself, and still reads `beta`. - **Coming with X.Y**: what the newest OS pre-release has that the newest stable does not. - **Operations by OS release**: how many of the plugin's operations are valid on the API each OS release bundles, and which fields are missing. -- **Contracts by OS release**: whether each contract holds on every supported release and the development branch. +- **Contracts by OS release**: whether each contract holds on every webgui release tag from the plugin's minimum + and on the development branch. An OS release the webgui has no tag for (some patch releases) is not read. - **Unraid CSS by OS release**: per theme, the layout properties Unraid's stylesheets set on an element the plugin's own CSS styles, that differ between releases, and that the plugin does not set itself: what can look different on an older or newer Unraid. A rule no longer set on the development branch is listed apart, @@ -72,7 +73,7 @@ with `' + name + '` when `watch.json` has an `expand` rule naming the JS map tha - `releases`: directory holding the OS release notes. `since` is the oldest OS release to list, and `tags` is the repository whose tags carry those OS versions. - `manifest`: the plugin's `.plg`. Its `min` attribute is the oldest OS release the contracts and stylesheets - are checked on; the webgui's stable tags from there up are the releases. + are checked on; the webgui's stable tags from there up are the releases, and finding none is an error. - `contracts`: what the plugin relies on in a webgui file, as a `path`, a regular expression it must `match`, and `why`. Optional `since`: the oldest release held to it. Add one with each change that relies on Unraid. - `styles`: the `themes`, and the stylesheet `files` that make up each one in load order (`{theme}` is diff --git a/.github/unraid-watch/css.py b/.github/unraid-watch/css.py index c7ca166a..4f4c689f 100644 --- a/.github/unraid-watch/css.py +++ b/.github/unraid-watch/css.py @@ -3,10 +3,10 @@ TOKEN = re.compile(r'[#.][A-Za-z_][\w-]*') COMMENT = re.compile(r'/\*.*?\*/', re.S) -# A semicolon inside url(...) or a data URI does not end a declaration -DECLARATION = re.compile(r';(?![^(]*\))') VAR = re.compile(r'var\(\s*(--[\w-]+)\s*([,)])') DEFINED = re.compile(r'(?:^|[;{\s])(--[\w-]+)\s*:') +# At-rules whose block holds rules for elements; @keyframes, @font-face and @page hold none +GROUPS = ('@media', '@supports', '@container', '@layer', '@scope') # What moves or wraps an element. Colours and fonts change with each theme by design, so they are left out LAYOUT = frozenset({ 'display', 'position', 'white-space', 'overflow', 'overflow-x', 'overflow-y', 'float', 'clear', 'box-sizing', 'flex', 'flex-direction', @@ -22,33 +22,100 @@ def uncommented(text): return COMMENT.sub(lambda m: '\n' * m.group(0).count('\n'), text) -def rules(text): - """[(at-rule conditions, selector, {property: value})], one entry per selector of a rule.""" - text = uncommented(text) - out, heads, start = [], [], 0 +def _plain(text): + """[(index, char)] for characters outside quoted strings, so a "}" or ";" in a content value is just text.""" + out, quote = [], None for i, c in enumerate(text): - if c == '{': - heads.append(' '.join(text[start:i].split())) - start = i + 1 - elif c == '}' and heads: - head, body = heads.pop(), text[start:i] - if not head.startswith('@') and '{' not in body: - decls = {} - for part in DECLARATION.split(body): - name, colon, value = part.partition(':') - if colon and name.strip(): - # `4px!important` and `4px !important` are the same value - decls[name.strip().lower()] = ' '.join(re.sub(r'\s*!\s*important\b', ' !important', value).split()) - context = ' '.join(h for h in heads if h.startswith('@')) - out += [(context, ' '.join(s.split()), decls) for s in head.split(',') if s.strip()] + if quote: + quote = None if c == quote and text[i - 1] != '\\' else quote + elif c in '"\'': + quote = c + else: + out.append((i, c)) + return out + + +def _split(text, at): + """text cut at each `at` character outside parentheses and strings (a url() or :not() list keeps its ; and ,).""" + parts, depth, start = [], 0, 0 + for i, c in _plain(text): + depth += (c == '(') - (c == ')') + if c == at and depth <= 0: + parts.append(text[start:i]) start = i + 1 + return parts + [text[start:]] + + +def _selector(text): + """One spelling per selector: spacing around combinators and quotes around attribute values do not make a rule new.""" + text = re.sub(r'\s*([>+~])\s*', r' \1 ', text) + text = re.sub(r'\[\s*([\w-]+)\s*([~|^$*]?=)\s*["\']?([^"\'\]]*?)["\']?\s*\]', r'[\1\2\3]', text) + return ' '.join(text.split()) + + +def _condition(text): + """One spelling per at-rule condition, `@media (max-width: 767px)`, however the stylesheet spaced it.""" + text = re.sub(r'\s*([():,])\s*', r'\1', text) + text = re.sub(r'(?<=[\w)])\(', ' (', text).replace(':', ': ').replace(',', ', ') + return ' '.join(text.split()) + + +def _parts(body): + """(declarations, [(head, block)]) of a body: its own declarations, and the rules and at-rules nested in it.""" + own, nested, depth, paren, start, item = [], [], 0, 0, 0, 0 + for i, c in _plain(body): + paren += (c == '(') - (c == ')') if depth == 0 else 0 + if c == '{': + if depth == 0: + own.append(body[start:item]) + head, opened = ' '.join(body[item:i].split()), i + 1 + depth += 1 + elif c == '}' and depth: + depth -= 1 + if depth == 0: + nested.append((head, body[opened:i])) + start = item = i + 1 + elif c == ';' and depth == 0 and paren <= 0: + item = i + 1 + return ''.join(own) + body[start:], nested + + +def _declarations(text): + decls = {} + for part in _split(text, ';'): + name, colon, value = part.partition(':') + if colon and name.strip() and not name.strip().startswith('@'): + # `4px!important` and `4px !important` are the same value + decls[name.strip().lower()] = ' '.join(re.sub(r'\s*!\s*important\b', ' !important', value).split()) + return decls + + +def _walk(body, conditions, parents, out): + own, nested = _parts(body) + decls = _declarations(own) if parents else {} + out += [(conditions, parent, decls) for parent in parents if decls] + for head, block in nested: + if head.startswith('@'): + if head.split(None, 1)[0].lower() in GROUPS: + _walk(block, ' '.join(filter(None, (conditions, _condition(head)))), parents, out) + continue + selectors = [_selector(s) for s in _split(head, ',') if s.strip()] + # Nesting: & is the parent rule; a nested selector without one is a descendant of it + resolved = [s.replace('&', p) if '&' in s else f'{p} {s}' for p in parents for s in selectors] if parents else selectors + _walk(block, conditions, resolved, out) + + +def rules(text): + """[(at-rule conditions, selector, {property: value})] in document order, nested rules resolved.""" + out = [] + _walk(uncommented(text), '', [], out) return out def subject(selector): - """The ids and classes of the element a selector styles: its last compound, without what :not(...) and the like name.""" - last = re.split(r'[\s>+~]+', re.sub(r'\([^()]*\)', '', selector).strip())[-1] - return TOKEN.findall(last) + """The ids and classes of the element a selector styles; none for a ::before box, nothing an attribute value or :not() names.""" + last = re.split(r'[\s>+~]+', re.sub(r'\([^()]*\)|\[[^\]]*\]', '', selector).strip())[-1] + return [] if '::' in last else TOKEN.findall(last) def styled(texts): @@ -65,33 +132,36 @@ def merged(texts): """{(at-rule conditions, selector, property): value} for stylesheets in load order: a later one wins.""" out = {} for text in texts: - for context, selector, decls in rules(text): + for conditions, selector, decls in rules(text): for name, value in decls.items(): - out[(context, selector, name)] = value + out[(conditions, selector, name)] = value return out def changes(by_ref, refs, ours): - """[(at-rule conditions, selector, property, [(ref, value or None)])] for layout properties Unraid sets on an element - FolderView3 styles, that differ between refs, and that FolderView3 does not set there itself.""" + """[(conditions, selector, property, [(ref, value)])]: layout Unraid changed on elements FolderView3 styles but does not set.""" out = [] - for context, selector, name in sorted(set().union(*(by_ref[r] for r in refs))): + for conditions, selector, name in sorted(set().union(*(by_ref[r] for r in refs))): tokens = [t for t in subject(selector) if t in ours] if name not in LAYOUT or not tokens or any(name in ours[t] for t in tokens): continue - values = [(ref, by_ref[ref].get((context, selector, name))) for ref in refs] + values = [(ref, by_ref[ref].get((conditions, selector, name))) for ref in refs] if len({v for _, v in values}) > 1: - out.append((context, selector, name, values)) + out.append((conditions, selector, name, values)) return out def fallbacks(stylesheets, code): - """Problems: var(--x) with no fallback where --x is Unraid's: no FolderView3 stylesheet declares it and its scripts and - server code (the CSS tool's presets, the generated theme CSS) never name it.""" + """Problems: var(--x) with no fallback where --x is Unraid's, not declared or keyed by FolderView3's own CSS or code.""" texts = {f: uncommented(f.read_text(encoding='utf-8')) for f in stylesheets} ours = {name for text in texts.values() for name in DEFINED.findall(text)} named = '\n'.join(f.read_text(encoding='utf-8') for f in code) - return [f'{f.name}:{text.count(chr(10), 0, m.start()) + 1}: var({m.group(1)}) has no fallback and only Unraid defines ' - f'{m.group(1)}; an Unraid release without it would drop the style' + + def keyed(name): + # The CSS tool's presets ('fv3-x': '#fff') and the generated theme CSS ('x' => '#fff') key the plugin's own variables + bare = re.escape(name[2:]) + return re.search(r"['\"]--" + bare + r"['\"]|['\"]" + bare + r"['\"]\s*(?::|=>)", named) + return [f'{f.name}:{text.count(chr(10), 0, m.start()) + 1}: var({m.group(1)}) has no fallback and FolderView3 does not ' + f'define {m.group(1)}, so the style needs every Unraid release to; give it a fallback' for f, text in texts.items() for m in VAR.finditer(text) - if m.group(2) == ')' and m.group(1) not in ours and not re.search(r"['\"](?:--)?" + re.escape(m.group(1)[2:]) + r"['\"]", named)] + if m.group(2) == ')' and m.group(1) not in ours and not keyed(m.group(1))] diff --git a/.github/unraid-watch/report.py b/.github/unraid-watch/report.py index ef3f375c..f6af135a 100644 --- a/.github/unraid-watch/report.py +++ b/.github/unraid-watch/report.py @@ -104,19 +104,24 @@ def _runs(values): def _contracts(view): + if 'unread' in view: + return ['', f'**Contracts and Unraid CSS by OS release**: could not be read ({code(view["unread"], 300)}).'] *tags, branch = view['refs'] - span = ((f'{code(tags[0])} to {code(tags[-1])}' if len(tags) > 1 else code(tags[0])) + ' and ' if tags else '') + code(branch) - out = ['', '**Contracts by OS release**', '', f'What FolderView3 relies on in the webgui, checked on {span}.', ''] + span = f'{code(tags[0])} to {code(tags[-1])}' if len(tags) > 1 else code(tags[0]) + out = ['', '**Contracts by OS release**', '', + f'What FolderView3 relies on in the webgui, checked on its release tags {span} and on {code(branch)}.', ''] for entry, found in view['contracts']: held = [ref for ref, ok in found.items() if ok is not None] - failed = [ref for ref, ok in found.items() if ok is False] - state = 'fails on ' + ', '.join(code(r) for r in failed) if failed else f'holds on all {len(held)}' + broken = [f'{"missing" if ok == "missing" else "fails"} on {code(ref)}' for ref, ok in found.items() if ok not in (True, None)] since = f' (from {code(entry["since"])})' if 'since' in entry else '' - out.append(f'- {code(entry["path"].rsplit("/", 1)[-1])} {entry["why"]}: {state}{since}') + out.append(f'- {code(entry["path"].rsplit("/", 1)[-1])} {entry["why"]}: ' + + (', '.join(broken) if broken else f'holds on all {len(held)}') + since) return out def _styles(view): + if 'unread' in view: + return [] themes, changed, gone = list(view['styles']), {}, {} for theme, rows in view['styles'].items(): for context, selector, name, values in rows: @@ -130,10 +135,12 @@ def row(key, who): out = ['', '**Unraid CSS by OS release**', '', 'Layout properties Unraid sets on elements FolderView3 styles, that differ between releases, and that FolderView3 ' 'does not set itself.', ''] - out += capped([row(k, w) for k, w in changed.items()], 60) or ['- none'] + out += capped([row(k, w) for k, w in changed.items()], 40) or ['- none'] + if view['unmatched']: + out += ['', 'Listed in watch.json but on no release: ' + ', '.join(code(p, 200) for p in view['unmatched']) + '.'] if gone: out += ['', f'
No longer set in the stylesheets read here ({len(gone)}; may have moved elsewhere)', ''] - out += capped([row(k, w) for k, w in gone.items()], 60) + ['', '
'] + out += capped([row(k, w) for k, w in gone.items()], 40) + ['', '
'] return out @@ -163,7 +170,6 @@ def render_status(view): + ': ' + '; '.join(members)) if view['unstated']: out.append('- API version not stated in the notes: ' + ', '.join(code(v) for v in view['unstated'])) - out += _contracts(view) + _styles(view) out += ['', f'
API not used yet ({len(view["idle"])} operations)', ''] out += [f'- {code(signature, 300)}' for signature in view['idle']] if view['types']: @@ -171,6 +177,8 @@ def render_status(view): + ', '.join(f'{code(name)} {read}/{total}' for name, read, total in view['types']) + '.'] out += ['', '
', '', f'
Still on legacy ({len(view["legacy"])} webgui files)', ''] out += [f'- {code(path, 200)}: {why}' for path, why in view['legacy']] + ['', '
'] + # Last: the longest sections, so a body cut for length loses these before anything above + out += _contracts(view) + _styles(view) return fit('\n'.join(out)) + '\n\n' + STATUS diff --git a/.github/unraid-watch/scan.py b/.github/unraid-watch/scan.py index b00a8247..0abd44a0 100644 --- a/.github/unraid-watch/scan.py +++ b/.github/unraid-watch/scan.py @@ -76,7 +76,7 @@ def code(plugin): def minimum(manifest): """The oldest Unraid release the plugin declares it runs on: the PLUGIN tag's min attribute; None when it has none.""" - found = re.search(r']*\bmin="(\d+\.\d+\.\d+)"', manifest.read_text(encoding='utf-8')) if manifest.is_file() else None + found = re.search(r']*\bmin="(\d+\.\d+\.\d+)"', manifest.read_text(encoding='utf-8')) return found and found.group(1) diff --git a/.github/unraid-watch/status.py b/.github/unraid-watch/status.py index 0482ff43..d40d6e90 100644 --- a/.github/unraid-watch/status.py +++ b/.github/unraid-watch/status.py @@ -2,6 +2,7 @@ import releases import schema import upstream +from github import GitHubError def stage(gh, cfg, ops, watched, spans): @@ -60,9 +61,15 @@ def bundled(release): current = schema.load(gh.file(core, heads[core], api['schema'])) idle, types = schema.coverage(current, api['surface'], schema.check(current, ops)[2], api['namespaces']) held = upstream.source(cfg, 'contracts') - refs = upstream.release_refs(gh, held, local['floor']) + pinned = {held['branch']: heads[held['repo']]} + try: + refs = upstream.release_refs(gh, held, local['floor']) + styles, unmatched = upstream.stylesheets(gh, held, refs, local['styled'], pinned) + compat = {'refs': refs, 'contracts': upstream.contracts(gh, held, refs, pinned), 'styles': styles, 'unmatched': unmatched} + except GitHubError as e: + # These sections only report: a failed read leaves them out and says so, and the news still goes out + compat = {'refs': [], 'contracts': [], 'styles': {}, 'unread': str(e)} return {'releases': (newest, stable, latest), 'stages': stages, 'matrix': matrix, 'unstated': unstated, - 'idle': idle, 'types': types, 'refs': refs, 'contracts': upstream.contracts(gh, held, refs), - 'styles': upstream.stylesheets(gh, held, refs, local['styled']), + 'idle': idle, 'types': types, **compat, # Stylesheets are not pages to move off: they are what the plugin's own CSS sits on 'legacy': [(path, why) for path, why in sorted(watched[tagged].items()) if not path.endswith('.css')]} diff --git a/.github/unraid-watch/test_commands.py b/.github/unraid-watch/test_commands.py index 20ff35a6..47221664 100644 --- a/.github/unraid-watch/test_commands.py +++ b/.github/unraid-watch/test_commands.py @@ -80,7 +80,7 @@ def test_scan_problem_fails_the_contract(self): def test_contracts_are_checked_on_master_and_listed(self): code, out = self.contract() self.assertEqual(code, 0) - self.assertIn(f'- contract {EVENTS}: holds on 1 of 1 refs', out) + self.assertIn(f'- contract {EVENTS}: holds on 2 of 2 refs', out) def test_a_contract_a_supported_release_breaks_fails_and_names_the_release(self): self.w.release_line() @@ -91,6 +91,14 @@ def test_a_contract_a_supported_release_breaks_fails_and_names_the_release(self) self.assertIn(f"::error::unraid/webgui: {EVENTS} does not match \"'success' => \" on 9.0.3: answers in `success`", out) self.assertIn(f'- contract {EVENTS}: holds on 1 of 2 refs', out) + def test_a_contract_file_a_release_does_not_have_is_named_missing_not_mismatched(self): + self.w.release_line() + self.w.tree(WEB, '9.0.3', {}) + code, out = self.contract() + self.assertEqual(code, 1) + self.assertIn(f'::error::unraid/webgui: {EVENTS} is missing on 9.0.3: answers in `success`', out) + self.assertNotIn('does not match', out) + def test_a_release_before_a_contracts_since_is_not_held_to_it(self): self.w.release_line() self.w.tree(WEB, '9.0.3', {}) @@ -104,11 +112,19 @@ def test_only_stable_releases_from_the_plugins_minimum_are_read(self): self.w.release_line() self.contract() read = {c[1].split('/git/trees/')[1].split('?')[0] for c in self.w.fake.calls if f'/repos/{WEB}/git/trees/' in c[1]} - self.assertEqual(read, {'9.0.3', 'master'}) + # master is read at the sha the run pinned it to, not by its moving name + self.assertEqual(read, {'9.0.3', NEW[WEB]}) - def test_a_manifest_without_a_minimum_stops_the_contract(self): + def test_a_manifest_without_a_minimum_stops_the_contract_before_any_request(self): + world = World(self, manifest='\n') with self.assertRaisesRegex(watch.Problem, 'no min="x.y.z"'): - self.contract(world=World(self, manifest='\n')) + self.contract(world=world) + self.assertEqual(world.fake.calls, []) + + def test_no_supported_release_tag_is_an_error_not_a_pass_on_master_alone(self): + self.w.tags(WEB, ['8.9.0', '9.1.0-beta.2', '2030.11.10']) + with self.assertRaisesRegex(GitHubError, 'no stable release tag at or after 9.0.0'): + self.contract() class CheckTest(Case): @@ -143,13 +159,27 @@ def test_plugin_that_references_no_endpoint_fails(self): def test_an_unraid_css_variable_without_a_fallback_fails(self): code, out = self.check(SCRIPT, styles=STYLES + '.tip { margin: var(--gap); }\n') self.assertEqual(code, 1) - self.assertIn('::error::a.css:3: var(--gap) has no fallback and only Unraid defines --gap', out) + self.assertIn('::error::a.css:3: var(--gap) has no fallback and FolderView3 does not define --gap', out) def test_a_manifest_without_a_minimum_fails(self): code, out = self.check(SCRIPT, manifest='\n') self.assertEqual(code, 1) self.assertIn('::error::plugin.plg: no min="x.y.z" on its PLUGIN tag', out) + def test_a_missing_manifest_says_it_is_missing(self): + world = World(self) + Path(world.root, 'plugin.plg').unlink() + code, out = self.captured(watch.cmd_check, CFG, world.root) + self.assertEqual(code, 1) + self.assertIn('::error::plugin.plg is missing', out) + + def test_a_plugin_with_no_stylesheets_fails_instead_of_reading_as_nothing_styled(self): + world = World(self) + Path(world.root, 'plugin/styles/a.css').unlink() + code, out = self.captured(watch.cmd_check, CFG, world.root) + self.assertEqual(code, 1) + self.assertIn('::error::plugin/styles has no stylesheets', out) + class MainTest(Case): def main(self, *argv): diff --git a/.github/unraid-watch/test_css.py b/.github/unraid-watch/test_css.py index 7e1109cf..5a52565c 100644 --- a/.github/unraid-watch/test_css.py +++ b/.github/unraid-watch/test_css.py @@ -13,6 +13,37 @@ def test_each_selector_gets_the_declarations_and_its_at_rule(self): ('@media (max-width: 9px)', '#b > .c', {'white-space': 'pre-line', 'margin-top': '4px !important'}), ('', '.d', {'display': 'none'})]) + def test_nested_rules_resolve_against_their_parent_and_keep_its_own_declarations(self): + text = '.title { display: flex; &:first-of-type { margin-top: 0 } .x, &.y { top: 1px } @media (min-width: 1px) { clear: both } }' + self.assertEqual(css.rules(text), [ + ('', '.title', {'display': 'flex'}), + ('', '.title:first-of-type', {'margin-top': '0'}), + ('', '.title .x', {'top': '1px'}), + ('', '.title.y', {'top': '1px'}), + ('@media (min-width: 1px)', '.title', {'clear': 'both'})]) + + def test_a_statement_at_rule_does_not_swallow_the_next_rule_and_keyframes_are_no_elements(self): + text = '@charset "UTF-8";\n@import url(a.css);\n.tip { display: block }\n@keyframes k { from { top: 0 } }' + self.assertEqual(css.rules(text), [('', '.tip', {'display': 'block'})]) + + def test_a_brace_inside_a_string_is_just_text(self): + self.assertEqual(css.rules('.q::after { content: "}"; } .row { top: 0 }'), + [('', '.q::after', {'content': '"}"'}), ('', '.row', {'top': '0'})]) + + def test_spacing_and_attribute_quotes_do_not_make_a_rule_new(self): + a = css.merged(['label+.content{top:0} [type="radio"]~.x{top:0} @media (max-width:9px){.y{top:0}}']) + b = css.merged(['label + .content { top: 0 } [type=radio] ~ .x { top: 0 } @media ( max-width: 9px ) { .y { top: 0 } }']) + self.assertEqual(a, b) + self.assertIn(('@media (max-width: 9px)', '.y', 'top'), a) + + def test_a_generated_box_or_an_attribute_value_is_not_the_element(self): + self.assertEqual(css.subject('.tip::before'), []) + self.assertEqual(css.subject('a[href$=".png"]'), []) + + def test_a_comma_inside_not_stays_in_its_selector(self): + self.assertEqual(css.rules('.x:not(.p, .q), .z { display: none }'), + [('', '.x:not(.p, .q)', {'display': 'none'}), ('', '.z', {'display': 'none'})]) + def test_a_semicolon_inside_a_url_does_not_end_the_declaration(self): self.assertEqual(css.rules('.a { background: url(data:image/png;base64,xy); top: 0 }'), [('', '.a', {'background': 'url(data:image/png;base64,xy)', 'top': '0'})]) @@ -27,18 +58,18 @@ class ChangesTest(unittest.TestCase): OURS = {'.tip': {'color'}, '.row': {'white-space'}} def by_ref(self, old, new): - return {'7.0.0': css.merged([old]), 'master': css.merged([new])} + return {'9.0.0': css.merged([old]), 'master': css.merged([new])} def test_a_layout_property_unraid_changed_on_an_element_the_plugin_styles_is_listed(self): - rows = css.changes(self.by_ref('.tip { display: block }', '.tip { white-space: pre-line }'), ['7.0.0', 'master'], self.OURS) - self.assertEqual(rows, [('', '.tip', 'display', [('7.0.0', 'block'), ('master', None)]), - ('', '.tip', 'white-space', [('7.0.0', None), ('master', 'pre-line')])]) + rows = css.changes(self.by_ref('.tip { display: block }', '.tip { white-space: pre-line }'), ['9.0.0', 'master'], self.OURS) + self.assertEqual(rows, [('', '.tip', 'display', [('9.0.0', 'block'), ('master', None)]), + ('', '.tip', 'white-space', [('9.0.0', None), ('master', 'pre-line')])]) def test_what_the_plugin_sets_itself_colours_and_elements_it_does_not_style_are_left_out(self): # .row's colour: an element the plugin styles, a property it does not set, but a colour, not layout old = '.row { white-space: nowrap; color: red } .tip { color: red } .other { display: block }' new = '.row { white-space: normal; color: blue } .tip { color: blue } .other { display: flex }' - self.assertEqual(css.changes(self.by_ref(old, new), ['7.0.0', 'master'], self.OURS), []) + self.assertEqual(css.changes(self.by_ref(old, new), ['9.0.0', 'master'], self.OURS), []) def test_a_later_stylesheet_wins_as_the_page_loads_them(self): self.assertEqual(css.merged(['.tip { top: 1px }', '.tip { top: 2px }']), {('', '.tip', 'top'): '2px'}) @@ -55,12 +86,17 @@ def check(self, sheet, code=''): def test_an_unraid_variable_without_a_fallback_is_named_with_its_line(self): (problem,) = self.check('/* two\nlines */\n.a { color: var(--text); }\n') - self.assertTrue(problem.startswith('a.css:3: var(--text) has no fallback and only Unraid defines --text'), problem) + self.assertTrue(problem.startswith('a.css:3: var(--text) has no fallback and FolderView3 does not define --text'), problem) def test_a_fallback_or_a_variable_the_plugin_owns_passes(self): self.assertEqual(self.check('.a { color: var(--text, #fff); }'), []) self.assertEqual(self.check(':root { --gap: 5px; } .a { gap: var(--gap); }'), []) self.assertEqual(self.check('.a { color: var(--fv3-name-color); }', "const vars = { 'fv3-name-color': '#fff' };"), []) + self.assertEqual(self.check('.a { color: var(--graph-cpu); }', "$vars = ['graph-cpu' => '#2b8da3'];"), []) + + def test_a_word_the_code_merely_uses_does_not_make_an_unraid_variable_the_plugins(self): + (problem,) = self.check('.a { color: var(--text); }', "fields.push({ type: 'text', label: 'Name' });") + self.assertIn('var(--text) has no fallback', problem) def test_a_variable_nested_in_a_fallback_needs_its_own(self): (problem,) = self.check('.a { color: var(--fv3-x, var(--text)); }', "'fv3-x'") diff --git a/.github/unraid-watch/test_releases.py b/.github/unraid-watch/test_releases.py index 2e512aa2..8146c8b4 100644 --- a/.github/unraid-watch/test_releases.py +++ b/.github/unraid-watch/test_releases.py @@ -11,7 +11,7 @@ def test_versions_sort_beta_before_rc_before_final(self): '10.0.0-beta.1']) def test_an_os_release_tag_is_a_stable_version_not_a_date(self): - self.assertEqual([t for t in ('7.4.0', '7.4.0-rc.1', '2014.11.10', 'v7.4.0', '7.4') if releases.os_tag(t)], ['7.4.0']) + self.assertEqual([t for t in ('9.4.0', '9.4.0-rc.1', '2030.11.10', 'v9.4.0', '9.4') if releases.os_tag(t)], ['9.4.0']) def test_stable_means_no_prerelease_suffix(self): self.assertTrue(releases.stable('9.1.0')) diff --git a/.github/unraid-watch/test_report.py b/.github/unraid-watch/test_report.py index cd8a4363..a3c627de 100644 --- a/.github/unraid-watch/test_report.py +++ b/.github/unraid-watch/test_report.py @@ -183,8 +183,8 @@ def test_unexpected_comment_link_is_refused(self): class RunsTest(unittest.TestCase): def test_releases_with_the_same_value_read_as_one_span(self): - values = [('7.0.0', None), ('7.1.0', None), ('7.2.0', '4px'), ('7.3.0', None), ('master', None)] - self.assertEqual(report._runs(values), 'not set in `7.0.0`–`7.1.0`, `4px` in `7.2.0`, not set in `7.3.0`–`master`') + values = [('9.0.0', None), ('9.1.0', None), ('9.2.0', '4px'), ('9.3.0', None), ('master', None)] + self.assertEqual(report._runs(values), 'not set in `9.0.0`–`9.1.0`, `4px` in `9.2.0`, not set in `9.3.0`–`master`') if __name__ == '__main__': diff --git a/.github/unraid-watch/test_status.py b/.github/unraid-watch/test_status.py index 8c197449..8fbe0cbf 100644 --- a/.github/unraid-watch/test_status.py +++ b/.github/unraid-watch/test_status.py @@ -81,39 +81,39 @@ def test_status_reads_as_expected(self): '- 3 of 3: `main` (not released); `v4.2.0` (latest API release); `v4.1.0` (Unraid 9.1.0-beta.2)', '- 2 of 3, missing `DockerMutations.stop`: `v4.0.0` (Unraid 9.0.3)', '- API version not stated in the notes: `9.0.2`, `9.0.1`', + ])) + self.assertEqual(body.split('\n\n
', 1)[1], '\n'.join([ + 'API not used yet (1 operations)', '', - '**Contracts by OS release**', + '- `DockerMutations.restart(id: ID!): Boolean!`', '', - 'What FolderView3 relies on in the webgui, checked on `9.0.3` and `master`.', + 'Fields read of those available: `Item` 1/2.', '', - '- `Events.php` answers in `success`: holds on all 2', + '
', '', - '**Unraid CSS by OS release**', + '
Still on legacy (2 webgui files)', '', - 'Layout properties Unraid sets on elements FolderView3 styles, that differ between releases, and that FolderView3 ' - 'does not set itself.', + '- `emhttp/page/`: markup', + f'- `{USERPREFS}`: called from a.js:5', '', - '- `.tip` `white-space`: not set in `9.0.3`, `pre-line` in `master`', - ])) - self.assertEqual(body.split('\n\n
', 1)[1], '\n'.join([ - 'No longer set in the stylesheets read here (1; may have moved elsewhere)', + '
', '', - '- `.tip` `display`: `block` in `9.0.3`, not set in `master` (azure)', + '**Contracts by OS release**', '', - '
', + 'What FolderView3 relies on in the webgui, checked on its release tags `9.0.3` and on `master`.', '', - '
API not used yet (1 operations)', + '- `Events.php` answers in `success`: holds on all 2', '', - '- `DockerMutations.restart(id: ID!): Boolean!`', + '**Unraid CSS by OS release**', '', - 'Fields read of those available: `Item` 1/2.', + 'Layout properties Unraid sets on elements FolderView3 styles, that differ between releases, and that FolderView3 ' + 'does not set itself.', '', - '
', + '- `.tip` `white-space`: not set in `9.0.3`, `pre-line` in `master`', '', - '
Still on legacy (2 webgui files)', + '
No longer set in the stylesheets read here (1; may have moved elsewhere)', '', - '- `emhttp/page/`: markup', - f'- `{USERPREFS}`: called from a.js:5', + '- `.tip` `display`: `block` in `9.0.3`, not set in `master` (azure)', '', '
', '', @@ -153,6 +153,20 @@ def test_release_documented_before_its_tag_exists_is_shown_as_not_available(self self.assertIn('- unraid/webgui `9.0.3`...`9.1.0-beta.2`: not available\n', body) self.assertIn('- unraid/api `v4.0.0`...`v4.1.0`:\n - removed', body) + def test_a_failed_read_leaves_the_release_checks_out_and_says_so(self): + self.w.fake.routes['GET', url(f'/repos/{WEB}/tags', page=1, per_page=100)] = (500, 'boom') + body = report.render_status(status.gather(self.w.client(), CFG, OPS, {API: {}, WEB: {}, DOCS: {}}, NEW, self.local())) + self.assertIn('**Operations by OS release**', body) + self.assertIn('**Contracts and Unraid CSS by OS release**: could not be read (`GET /repos/unraid/webgui/tags: HTTP 500', body) + self.assertNotIn('**Unraid CSS by OS release**', body) + + def test_a_listed_stylesheet_no_release_has_is_named(self): + cfg = {**CFG, 'sources': [{**s, 'styles': {**s['styles'], 'files': s['styles']['files'] + ['css/typo-{theme}.css']}} + if 'styles' in s else s for s in CFG['sources']]} + self.w.release_line() + body = report.render_status(status.gather(self.w.client(), cfg, OPS, {API: {}, WEB: {}, DOCS: {}}, NEW, self.local())) + self.assertIn('Listed in watch.json but on no release: `css/typo-{theme}.css`.', body) + def test_watched_stylesheets_are_not_listed_as_legacy_pages(self): view = status.gather(self.w.client(), CFG, OPS, {API: {}, WEB: {'css/azure.css': 'theme', USERPREFS: 'prefs'}, DOCS: {}}, NEW, self.local()) @@ -237,6 +251,14 @@ def test_refreshed_even_when_news_was_posted(self): self.w.run() self.assertEqual((len(self.w.posted), len(self.w.status)), (1, 1)) + def test_news_still_goes_out_when_the_release_checks_cannot_be_read(self): + self.w.state() + self.w.hit() + self.w.fake.routes['GET', f'/repos/{WEB}/git/blobs/ev1'] = (500, 'boom') + code, _ = self.w.run() + self.assertEqual((code, len(self.w.posted), len(self.w.status)), (0, 1, 1)) + self.assertIn('could not be read', self.w.status[0][1]) + def test_status_command_prints_and_writes_nothing(self): code, out = self.captured(watch.cmd_status, CFG, self.w.client(), self.w.root) self.assertEqual(code, 0) diff --git a/.github/unraid-watch/upstream.py b/.github/unraid-watch/upstream.py index 4deaa655..259904dc 100644 --- a/.github/unraid-watch/upstream.py +++ b/.github/unraid-watch/upstream.py @@ -4,6 +4,7 @@ import css import releases import schema +from github import GitHubError NOTES = re.compile(r'[\w.-]+\.md\Z') @@ -70,8 +71,11 @@ def validity(gh, src, ops, refs): def release_refs(gh, src, floor): """Stable release tags at or after floor (the plugin's declared minimum), oldest first, then the development branch.""" - tags = [t for t in gh.tags(src['repo']) if releases.os_tag(t)] - return sorted((t for t in tags if releases.order(t) >= releases.order(floor)), key=releases.order) + [src['branch']] + tags = [t for t in gh.tags(src['repo']) if releases.os_tag(t) and releases.order(t) >= releases.order(floor)] + # None would leave only the development branch checked, read as every release passing + if not tags: + raise GitHubError(f'{src["repo"]}: no stable release tag at or after {floor}') + return sorted(tags, key=releases.order) + [src['branch']] def text_at(gh, repo, ref, path): @@ -85,27 +89,34 @@ def applies(entry, ref): return 'since' not in entry or not releases.VERSION.fullmatch(ref) or releases.order(ref) >= releases.order(entry['since']) -def contracts(gh, src, refs): - """[(contract, {ref: True if it holds, False if not, None where it does not apply})].""" +def contracts(gh, src, refs, pinned): + """[(contract, {ref: True, False, 'missing' (no such file), or None where it does not apply})]; pinned maps a branch to its sha.""" out = [] for entry in src.get('contracts', []): - found = {ref: bool(re.search(entry['match'], text_at(gh, src['repo'], ref, entry['path']) or '')) - if applies(entry, ref) else None for ref in refs} + found = {} + for ref in refs: + text = text_at(gh, src['repo'], pinned.get(ref, ref), entry['path']) if applies(entry, ref) else None + found[ref] = None if not applies(entry, ref) else 'missing' if text is None else bool(re.search(entry['match'], text)) out.append((entry, found)) return out -def stylesheets(gh, src, refs, ours): - """{theme: css.changes} for Unraid's stylesheets per release; a file a release does not have is skipped.""" +def stylesheets(gh, src, refs, ours, pinned): + """({theme: css.changes}, [listed file no release has]) for Unraid's stylesheets; a file one release lacks is skipped.""" styles = src['styles'] - out = {} + out, seen = {}, set() for theme in styles['themes']: by_ref = {} for ref in refs: - texts = (text_at(gh, src['repo'], ref, pattern.format(theme=theme)) for pattern in styles['files']) - by_ref[ref] = css.merged(t for t in texts if t is not None) + texts = [] + for pattern in styles['files']: + text = text_at(gh, src['repo'], pinned.get(ref, ref), pattern.format(theme=theme)) + if text is not None: + texts.append(text) + seen.add(pattern) + by_ref[ref] = css.merged(texts) out[theme] = css.changes(by_ref, refs, ours) - return out + return out, [p for p in styles['files'] if p not in seen] def differences(gh, repo, paths, start, head): diff --git a/.github/unraid-watch/watch.py b/.github/unraid-watch/watch.py index 75e4c042..59023aff 100644 --- a/.github/unraid-watch/watch.py +++ b/.github/unraid-watch/watch.py @@ -42,13 +42,24 @@ def derive(cfg, root): return ops, watched, problems +def floor(cfg, root): + """The oldest Unraid release the plugin supports, from its manifest; a Problem when it states none.""" + manifest = Path(root, cfg['manifest']) + if not manifest.is_file(): + raise Problem(f'{cfg["manifest"]} is missing, so the oldest Unraid the plugin supports is unknown') + found = scan.minimum(manifest) + if not found: + raise Problem(f'{cfg["manifest"]}: no min="x.y.z" on its PLUGIN tag, so the oldest Unraid it supports is unknown') + return found + + def local(cfg, root): """What the checks per release need from the plugin: the oldest Unraid it supports, and what its stylesheets style.""" - floor = scan.minimum(Path(root, cfg['manifest'])) - if not floor: - raise Problem(f'{cfg["manifest"]}: no min="x.y.z" on its PLUGIN tag, so the oldest Unraid it supports is unknown') sheets = scan.stylesheets(Path(root, cfg['plugin'])) - return {'floor': floor, 'styled': css.styled(f.read_text(encoding='utf-8') for f in sheets)} + # No stylesheets would read as "Unraid changed nothing the plugin styles" + if not sheets: + raise Problem(f'{cfg["plugin"]}/styles has no stylesheets, so what the plugin styles is unknown') + return {'floor': floor(cfg, root), 'styled': css.styled(f.read_text(encoding='utf-8') for f in sheets)} def readable(cfg, root): @@ -100,6 +111,8 @@ def cmd_check(cfg, root): def cmd_contract(cfg, gh, root, refs): ops, watched, errors = derive(cfg, root) + # Read before the first request: a manifest that states no minimum stops the run before anything is fetched + oldest = floor(cfg, root) api = source(cfg, 'schema') lines = [] for ref, bad, deprecated in validity(gh, api, ops, refs or [api['branch'], gh.latest_release(api['repo'])]): @@ -114,8 +127,12 @@ def cmd_contract(cfg, gh, root, refs): errors += [f'{repo}: {p} no longer exists on {src["branch"]}; fix the call or watch.json' for p in gone] lines.append(f'- {len(paths) - len(gone)} of {len(paths)} watched paths present in {repo}') held = source(cfg, 'contracts') - for entry, found in contracts(gh, held, release_refs(gh, held, local(cfg, root)['floor'])): + pinned = {held['branch']: gh.sha(held['repo'], held['branch'])} + for entry, found in contracts(gh, held, release_refs(gh, held, oldest), pinned): + missing = [ref for ref, ok in found.items() if ok == 'missing'] failed = [ref for ref, ok in found.items() if ok is False] + if missing: + errors.append(f'{held["repo"]}: {entry["path"]} is missing on {", ".join(missing)}: {entry["why"]}') if failed: errors.append(f'{held["repo"]}: {entry["path"]} does not match {entry["match"]!r} on {", ".join(failed)}: {entry["why"]}') lines.append(f'- contract {entry["path"]}: holds on {sum(ok is True for ok in found.values())} of ' diff --git a/.github/unraid-watch/world.py b/.github/unraid-watch/world.py index 11c94c77..efe56d4d 100644 --- a/.github/unraid-watch/world.py +++ b/.github/unraid-watch/world.py @@ -129,9 +129,10 @@ def __init__(self, case, script=SCRIPT, styles=STYLES, manifest=' $DockerClient->startContainer($container)];\n") self.blob(WEB, 'st1', '.tip { white-space: pre-line; color: red; }\n.row { white-space: normal; }\n') @@ -179,12 +180,12 @@ def release_line(self): self.tree(API, NEW[API], {'api/schema.graphql': 's2', 'api/switch.ts': 'w1'}) self.tree(WEB, STABLE_WEB, {'emhttp/page': 't0', USERPREFS: 'u0'}) self.tree(WEB, BETA_WEB, {'emhttp/page': 't1', USERPREFS: 'u0'}) - self.tree(WEB, NEW[WEB], {'emhttp/page': 't1', USERPREFS: 'u0'}) + self.tree(WEB, NEW[WEB], {'emhttp/page': 't1', USERPREFS: 'u0', EVENTS: 'ev1', 'css/azure.css': 'st1', 'css/black.css': 'st1'}) self.between(API, [50], span=(LATEST_API, NEW[API])) self.between(WEB, [60, 61], status='diverged', span=(STABLE_WEB, BETA_WEB)) # Only 9.0.3 is a stable OS release at or after the plugin's floor (9.0.0); 9.0.3's azure theme sets .tip's display, # master's does not but sets its white-space - self.tags(WEB, ['9.1.0-beta.2', '9.0.3', '8.9.0', '2014.11.10']) + self.tags(WEB, ['9.1.0-beta.2', '9.0.3', '8.9.0', '2030.11.10']) self.tree(WEB, '9.0.3', {EVENTS: 'ev1', 'css/old-azure.css': 'old1'}) self.blob(WEB, 'old1', '.tip { display: block; color: blue; }\n') self.fake.routes['GET', url(f'/repos/{API}/commits', page=1, path='api/switch.ts', per_page=100, diff --git a/.github/workflows/unraid-watch.yml b/.github/workflows/unraid-watch.yml index 090167d6..a69cea42 100644 --- a/.github/workflows/unraid-watch.yml +++ b/.github/workflows/unraid-watch.yml @@ -19,6 +19,8 @@ on: pull_request: paths: - 'src/**' + # its min attribute is the oldest Unraid release the contracts are checked on + - 'folder.view3.plg' - '.github/unraid-watch/**' - '.github/workflows/unraid-watch.yml' push: From d5102adda07eb3631e40cbf2fc9e9f9946a0db16 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 11:02:41 +0800 Subject: [PATCH 09/72] docs: the palette's watched reason says the plugin reads its variables with fallbacks --- .github/unraid-watch/watch.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/unraid-watch/watch.json b/.github/unraid-watch/watch.json index 0f863386..fb35d8c5 100644 --- a/.github/unraid-watch/watch.json +++ b/.github/unraid-watch/watch.json @@ -50,7 +50,7 @@ "emhttp/plugins/dynamix/include/TaskCommand.php": "task tray endpoint behind openDocker from 7.4", "emhttp/plugins/dynamix/styles/default-dynamix.css": "tooltipster rules the advanced preview popup is drawn inside (7.4 added white-space: pre-line)", "emhttp/plugins/dynamix/styles/default-base.css": "sweet-alert, table and menu rules the plugin's dialogs and rows sit in", - "emhttp/plugins/dynamix/styles/default-color-palette.css": "colour variables the plugin's own colours fall back from", + "emhttp/plugins/dynamix/styles/default-color-palette.css": "colour variables the plugin's CSS reads, each with its own fallback", "emhttp/plugins/dynamix/styles/themes/azure.css": "azure theme rules under the folder rows and dialogs", "emhttp/plugins/dynamix/styles/themes/black.css": "black theme rules under the folder rows and dialogs", "emhttp/plugins/dynamix/styles/themes/gray.css": "gray theme rules under the folder rows and dialogs", From 8e04e04b572fa83491b867604f834a8f3c203f0e Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 11:17:45 +0800 Subject: [PATCH 10/72] fix: a declaration after a nested rule keeps its place, each theme's stylesheet counts as its own input, and stylesheets that style nothing are refused --- .github/unraid-watch/css.py | 20 +++++++++++--------- .github/unraid-watch/test_commands.py | 7 ++++++- .github/unraid-watch/test_css.py | 3 +++ .github/unraid-watch/test_status.py | 10 ++++++++-- .github/unraid-watch/upstream.py | 10 ++++++---- .github/unraid-watch/watch.py | 9 +++++---- .github/unraid-watch/world.py | 3 ++- 7 files changed, 41 insertions(+), 21 deletions(-) diff --git a/.github/unraid-watch/css.py b/.github/unraid-watch/css.py index 4f4c689f..e2de36bb 100644 --- a/.github/unraid-watch/css.py +++ b/.github/unraid-watch/css.py @@ -61,23 +61,23 @@ def _condition(text): def _parts(body): - """(declarations, [(head, block)]) of a body: its own declarations, and the rules and at-rules nested in it.""" - own, nested, depth, paren, start, item = [], [], 0, 0, 0, 0 + """[(None, declarations) or (head, block)] of a body in source order: its own declarations and the rules nested in it.""" + items, depth, paren, start, item = [], 0, 0, 0, 0 for i, c in _plain(body): paren += (c == '(') - (c == ')') if depth == 0 else 0 if c == '{': if depth == 0: - own.append(body[start:item]) + items.append((None, body[start:item])) head, opened = ' '.join(body[item:i].split()), i + 1 depth += 1 elif c == '}' and depth: depth -= 1 if depth == 0: - nested.append((head, body[opened:i])) + items.append((head, body[opened:i])) start = item = i + 1 elif c == ';' and depth == 0 and paren <= 0: item = i + 1 - return ''.join(own) + body[start:], nested + return items + [(None, body[start:])] def _declarations(text): @@ -91,10 +91,12 @@ def _declarations(text): def _walk(body, conditions, parents, out): - own, nested = _parts(body) - decls = _declarations(own) if parents else {} - out += [(conditions, parent, decls) for parent in parents if decls] - for head, block in nested: + # In source order: a declaration after a nested rule comes after it, as the browser applies them + for head, block in _parts(body): + if head is None: + decls = _declarations(block) if parents else {} + out += [(conditions, parent, decls) for parent in parents if decls] + continue if head.startswith('@'): if head.split(None, 1)[0].lower() in GROUPS: _walk(block, ' '.join(filter(None, (conditions, _condition(head)))), parents, out) diff --git a/.github/unraid-watch/test_commands.py b/.github/unraid-watch/test_commands.py index 47221664..71d4aee7 100644 --- a/.github/unraid-watch/test_commands.py +++ b/.github/unraid-watch/test_commands.py @@ -178,7 +178,12 @@ def test_a_plugin_with_no_stylesheets_fails_instead_of_reading_as_nothing_styled Path(world.root, 'plugin/styles/a.css').unlink() code, out = self.captured(watch.cmd_check, CFG, world.root) self.assertEqual(code, 1) - self.assertIn('::error::plugin/styles has no stylesheets', out) + self.assertIn('::error::plugin/styles has no stylesheets that style an element', out) + + def test_an_empty_stylesheet_fails_the_same_way(self): + code, out = self.check(SCRIPT, styles='') + self.assertEqual(code, 1) + self.assertIn('::error::plugin/styles has no stylesheets that style an element', out) class MainTest(Case): diff --git a/.github/unraid-watch/test_css.py b/.github/unraid-watch/test_css.py index 5a52565c..3f2742b2 100644 --- a/.github/unraid-watch/test_css.py +++ b/.github/unraid-watch/test_css.py @@ -22,6 +22,9 @@ def test_nested_rules_resolve_against_their_parent_and_keep_its_own_declarations ('', '.title.y', {'top': '1px'}), ('@media (min-width: 1px)', '.title', {'clear': 'both'})]) + def test_a_declaration_after_a_nested_rule_wins_as_it_does_in_the_browser(self): + self.assertEqual(css.merged(['.tip { & { top: 1px; } top: 2px; }']), {('', '.tip', 'top'): '2px'}) + def test_a_statement_at_rule_does_not_swallow_the_next_rule_and_keyframes_are_no_elements(self): text = '@charset "UTF-8";\n@import url(a.css);\n.tip { display: block }\n@keyframes k { from { top: 0 } }' self.assertEqual(css.rules(text), [('', '.tip', {'display': 'block'})]) diff --git a/.github/unraid-watch/test_status.py b/.github/unraid-watch/test_status.py index 8fbe0cbf..ffc6a86e 100644 --- a/.github/unraid-watch/test_status.py +++ b/.github/unraid-watch/test_status.py @@ -4,7 +4,7 @@ import status import upstream import watch -from world import (API, BETA_API, BETA_WEB, CFG, DOCS, LATEST_API, ME, NEW, RELEASE, SCRIPT, STABLE_WEB, USERPREFS, WEB, +from world import (API, BETA_API, BETA_WEB, CFG, DOCS, EVENTS, LATEST_API, ME, NEW, RELEASE, SCRIPT, STABLE_WEB, USERPREFS, WEB, Case, World, commit, sha, url) OPS = [('{ docker { statuses { name } } }', ['a.js:3']), @@ -165,7 +165,13 @@ def test_a_listed_stylesheet_no_release_has_is_named(self): if 'styles' in s else s for s in CFG['sources']]} self.w.release_line() body = report.render_status(status.gather(self.w.client(), cfg, OPS, {API: {}, WEB: {}, DOCS: {}}, NEW, self.local())) - self.assertIn('Listed in watch.json but on no release: `css/typo-{theme}.css`.', body) + self.assertIn('Listed in watch.json but on no release: `css/typo-azure.css`, `css/typo-black.css`.', body) + + def test_one_themes_file_missing_on_every_release_is_named_though_another_theme_has_it(self): + self.w.release_line() + self.w.tree(WEB, '9.0.3', {EVENTS: 'ev1', 'css/old-azure.css': 'old1'}) + body = report.render_status(status.gather(self.w.client(), CFG, OPS, {API: {}, WEB: {}, DOCS: {}}, NEW, self.local())) + self.assertIn('Listed in watch.json but on no release: `css/old-black.css`.', body) def test_watched_stylesheets_are_not_listed_as_legacy_pages(self): view = status.gather(self.w.client(), CFG, OPS, {API: {}, WEB: {'css/azure.css': 'theme', USERPREFS: 'prefs'}, DOCS: {}}, diff --git a/.github/unraid-watch/upstream.py b/.github/unraid-watch/upstream.py index 259904dc..660b62ac 100644 --- a/.github/unraid-watch/upstream.py +++ b/.github/unraid-watch/upstream.py @@ -105,18 +105,20 @@ def stylesheets(gh, src, refs, ours, pinned): """({theme: css.changes}, [listed file no release has]) for Unraid's stylesheets; a file one release lacks is skipped.""" styles = src['styles'] out, seen = {}, set() + # Each theme's own file is its own input: one theme's themes/{theme}.css does not stand in for another's + listed = list(dict.fromkeys(p.format(theme=t) for t in styles['themes'] for p in styles['files'])) for theme in styles['themes']: by_ref = {} for ref in refs: texts = [] - for pattern in styles['files']: - text = text_at(gh, src['repo'], pinned.get(ref, ref), pattern.format(theme=theme)) + for path in (p.format(theme=theme) for p in styles['files']): + text = text_at(gh, src['repo'], pinned.get(ref, ref), path) if text is not None: texts.append(text) - seen.add(pattern) + seen.add(path) by_ref[ref] = css.merged(texts) out[theme] = css.changes(by_ref, refs, ours) - return out, [p for p in styles['files'] if p not in seen] + return out, [p for p in listed if p not in seen] def differences(gh, repo, paths, start, head): diff --git a/.github/unraid-watch/watch.py b/.github/unraid-watch/watch.py index 59023aff..3755fa3e 100644 --- a/.github/unraid-watch/watch.py +++ b/.github/unraid-watch/watch.py @@ -56,10 +56,11 @@ def floor(cfg, root): def local(cfg, root): """What the checks per release need from the plugin: the oldest Unraid it supports, and what its stylesheets style.""" sheets = scan.stylesheets(Path(root, cfg['plugin'])) - # No stylesheets would read as "Unraid changed nothing the plugin styles" - if not sheets: - raise Problem(f'{cfg["plugin"]}/styles has no stylesheets, so what the plugin styles is unknown') - return {'floor': floor(cfg, root), 'styled': css.styled(f.read_text(encoding='utf-8') for f in sheets)} + styled = css.styled(f.read_text(encoding='utf-8') for f in sheets) + # No stylesheets, or none that styles an element by id or class, would read as "Unraid changed nothing the plugin styles" + if not styled: + raise Problem(f'{cfg["plugin"]}/styles has no stylesheets that style an element by id or class, so what the plugin styles is unknown') + return {'floor': floor(cfg, root), 'styled': styled} def readable(cfg, root): diff --git a/.github/unraid-watch/world.py b/.github/unraid-watch/world.py index efe56d4d..9a56d979 100644 --- a/.github/unraid-watch/world.py +++ b/.github/unraid-watch/world.py @@ -186,8 +186,9 @@ def release_line(self): # Only 9.0.3 is a stable OS release at or after the plugin's floor (9.0.0); 9.0.3's azure theme sets .tip's display, # master's does not but sets its white-space self.tags(WEB, ['9.1.0-beta.2', '9.0.3', '8.9.0', '2030.11.10']) - self.tree(WEB, '9.0.3', {EVENTS: 'ev1', 'css/old-azure.css': 'old1'}) + self.tree(WEB, '9.0.3', {EVENTS: 'ev1', 'css/old-azure.css': 'old1', 'css/old-black.css': 'old0'}) self.blob(WEB, 'old1', '.tip { display: block; color: blue; }\n') + self.blob(WEB, 'old0', '') self.fake.routes['GET', url(f'/repos/{API}/commits', page=1, path='api/switch.ts', per_page=100, sha=NEW[API])] = [commit(50, 'feat: enable the new page', '2030-01-03T00:00:00Z')] From ebb7db4adabe9ccdea5d0748530f9eb0723410bd Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 11:19:19 +0800 Subject: [PATCH 11/72] fix: a watch.json with no contracts, themes or files, or a contract without a path, match or valid regex, fails check instead of reading as every release passing --- .github/unraid-watch/test_commands.py | 10 ++++++++++ .github/unraid-watch/watch.py | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/.github/unraid-watch/test_commands.py b/.github/unraid-watch/test_commands.py index 71d4aee7..fab44c34 100644 --- a/.github/unraid-watch/test_commands.py +++ b/.github/unraid-watch/test_commands.py @@ -180,6 +180,16 @@ def test_a_plugin_with_no_stylesheets_fails_instead_of_reading_as_nothing_styled self.assertEqual(code, 1) self.assertIn('::error::plugin/styles has no stylesheets that style an element', out) + def test_release_checks_with_nothing_to_check_fail_instead_of_passing(self): + web = next(s for s in CFG['sources'] if 'contracts' in s) + for broken in ({**web, 'contracts': []}, {**web, 'styles': {**web['styles'], 'themes': []}}, + {**web, 'contracts': [{'path': EVENTS, 'match': '(', 'why': 'w'}]}, {**web, 'contracts': [{'path': EVENTS}]}): + with self.subTest(broken=broken.get('contracts')): + cfg = {**CFG, 'sources': [broken if s is web else s for s in CFG['sources']]} + code, out = self.captured(watch.cmd_check, cfg, World(self).root) + self.assertEqual(code, 1) + self.assertIn('::error::watch.json: ', out) + def test_an_empty_stylesheet_fails_the_same_way(self): code, out = self.check(SCRIPT, styles='') self.assertEqual(code, 1) diff --git a/.github/unraid-watch/watch.py b/.github/unraid-watch/watch.py index 3755fa3e..728944cc 100644 --- a/.github/unraid-watch/watch.py +++ b/.github/unraid-watch/watch.py @@ -3,6 +3,7 @@ import argparse import json import os +import re import sys from pathlib import Path @@ -39,9 +40,27 @@ def derive(cfg, root): for path, where in found.items(): paths.setdefault(path, f'called from {where}') watched[src['repo']] = paths + problems += release_checks_config(cfg) return ops, watched, problems +def release_checks_config(cfg): + """Problems with the contracts and styles in watch.json: an empty list would read as every release passing.""" + held = next((s for s in cfg['sources'] if 'contracts' in s), {}) + styles = held.get('styles', {}) + problems = [] if held.get('contracts') and styles.get('themes') and styles.get('files') else \ + ['watch.json: the webgui source needs contracts and styles with themes and files, or the release checks read as passing'] + for entry in held.get('contracts', []): + if not all(isinstance(entry.get(key), str) and entry[key] for key in ('path', 'match', 'why')): + problems.append(f'watch.json: a contract needs a path, a match and a why: {entry}') + continue + try: + re.compile(entry['match']) + except re.error as e: + problems.append(f'watch.json: the contract on {entry["path"]} has a match that is not a regular expression ({e})') + return problems + + def floor(cfg, root): """The oldest Unraid release the plugin supports, from its manifest; a Problem when it states none.""" manifest = Path(root, cfg['manifest']) From 14faa0582798f0d15a61fe90f5f39d70a40572bf Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 12:21:48 +0800 Subject: [PATCH 12/72] fix: the CSS comparison keeps !important over a later plain declaration, scopes the plugin's own rules to their media condition, and treats an empty stylesheet as missing --- .github/unraid-watch/css.py | 25 ++++++++++++++++++------- .github/unraid-watch/test_css.py | 15 ++++++++++++++- .github/unraid-watch/test_status.py | 6 ++++++ .github/unraid-watch/upstream.py | 3 ++- .github/unraid-watch/world.py | 2 +- 5 files changed, 41 insertions(+), 10 deletions(-) diff --git a/.github/unraid-watch/css.py b/.github/unraid-watch/css.py index e2de36bb..b97ef283 100644 --- a/.github/unraid-watch/css.py +++ b/.github/unraid-watch/css.py @@ -80,13 +80,19 @@ def _parts(body): return items + [(None, body[start:])] +def _set(decls, name, value): + """A later declaration wins, except over an !important one that it is not itself.""" + if not (decls.get(name, '').endswith('!important') and not value.endswith('!important')): + decls[name] = value + + def _declarations(text): decls = {} for part in _split(text, ';'): name, colon, value = part.partition(':') if colon and name.strip() and not name.strip().startswith('@'): # `4px!important` and `4px !important` are the same value - decls[name.strip().lower()] = ' '.join(re.sub(r'\s*!\s*important\b', ' !important', value).split()) + _set(decls, name.strip().lower(), ' '.join(re.sub(r'\s*!\s*important\b', ' !important', value).split())) return decls @@ -121,31 +127,36 @@ def subject(selector): def styled(texts): - """{id or class: properties FolderView3 sets on elements that carry it} from FolderView3's own stylesheets.""" + """{id or class: {(at-rule conditions, property)} FolderView3 sets on elements that carry it} from its own stylesheets.""" out = {} for text in texts: - for _, selector, decls in rules(text): + for conditions, selector, decls in rules(text): for token in subject(selector): - out.setdefault(token, set()).update(decls) + out.setdefault(token, set()).update((conditions, name) for name in decls) return out def merged(texts): - """{(at-rule conditions, selector, property): value} for stylesheets in load order: a later one wins.""" + """{(at-rule conditions, selector, property): value} for stylesheets in load order: a later one wins, !important aside.""" out = {} for text in texts: for conditions, selector, decls in rules(text): for name, value in decls.items(): - out[(conditions, selector, name)] = value + _set(out, (conditions, selector, name), value) return out +def _covers(ours, token, conditions, name): + # The plugin's own rule for this property covers Unraid's when it holds everywhere, or under the same condition + return ('', name) in ours[token] or (conditions, name) in ours[token] + + def changes(by_ref, refs, ours): """[(conditions, selector, property, [(ref, value)])]: layout Unraid changed on elements FolderView3 styles but does not set.""" out = [] for conditions, selector, name in sorted(set().union(*(by_ref[r] for r in refs))): tokens = [t for t in subject(selector) if t in ours] - if name not in LAYOUT or not tokens or any(name in ours[t] for t in tokens): + if name not in LAYOUT or not tokens or any(_covers(ours, t, conditions, name) for t in tokens): continue values = [(ref, by_ref[ref].get((conditions, selector, name))) for ref in refs] if len({v for _, v in values}) > 1: diff --git a/.github/unraid-watch/test_css.py b/.github/unraid-watch/test_css.py index 3f2742b2..4cc17d0e 100644 --- a/.github/unraid-watch/test_css.py +++ b/.github/unraid-watch/test_css.py @@ -58,7 +58,7 @@ def test_the_styled_element_is_the_last_compound_without_what_not_names(self): class ChangesTest(unittest.TestCase): - OURS = {'.tip': {'color'}, '.row': {'white-space'}} + OURS = {'.tip': {('', 'color')}, '.row': {('', 'white-space')}} def by_ref(self, old, new): return {'9.0.0': css.merged([old]), 'master': css.merged([new])} @@ -77,6 +77,19 @@ def test_what_the_plugin_sets_itself_colours_and_elements_it_does_not_style_are_ def test_a_later_stylesheet_wins_as_the_page_loads_them(self): self.assertEqual(css.merged(['.tip { top: 1px }', '.tip { top: 2px }']), {('', '.tip', 'top'): '2px'}) + def test_an_important_declaration_is_not_overwritten_by_a_plain_one(self): + self.assertEqual(css.merged(['.tip { top: 1px !important }', '.tip { top: 2px }']), {('', '.tip', 'top'): '1px !important'}) + self.assertEqual(css.rules('.tip { top: 1px !important; top: 2px }'), [('', '.tip', {'top': '1px !important'})]) + self.assertEqual(css.merged(['.tip { top: 1px !important }', '.tip { top: 3px !important }']), {('', '.tip', 'top'): '3px !important'}) + + def test_the_plugin_setting_a_property_under_a_condition_covers_only_that_condition(self): + ours = css.styled(['@media (max-width: 600px) { .tip { white-space: normal } }']) + by_ref = {'9.0.0': css.merged(['.tip { white-space: nowrap }']), 'master': css.merged(['.tip { white-space: pre-line }'])} + self.assertEqual([r[2] for r in css.changes(by_ref, ['9.0.0', 'master'], ours)], ['white-space']) + same = {'9.0.0': css.merged(['@media (max-width: 600px) { .tip { white-space: nowrap } }']), + 'master': css.merged(['@media (max-width: 600px) { .tip { white-space: pre-line } }'])} + self.assertEqual(css.changes(same, ['9.0.0', 'master'], ours), []) + class FallbacksTest(unittest.TestCase): def check(self, sheet, code=''): diff --git a/.github/unraid-watch/test_status.py b/.github/unraid-watch/test_status.py index ffc6a86e..d4ef3ff2 100644 --- a/.github/unraid-watch/test_status.py +++ b/.github/unraid-watch/test_status.py @@ -167,6 +167,12 @@ def test_a_listed_stylesheet_no_release_has_is_named(self): body = report.render_status(status.gather(self.w.client(), cfg, OPS, {API: {}, WEB: {}, DOCS: {}}, NEW, self.local())) self.assertIn('Listed in watch.json but on no release: `css/typo-azure.css`, `css/typo-black.css`.', body) + def test_an_empty_stylesheet_counts_as_missing_not_as_no_change(self): + self.w.release_line() + self.w.blob(WEB, 'old0', ' \n') + body = report.render_status(status.gather(self.w.client(), CFG, OPS, {API: {}, WEB: {}, DOCS: {}}, NEW, self.local())) + self.assertIn('Listed in watch.json but on no release: `css/old-black.css`.', body) + def test_one_themes_file_missing_on_every_release_is_named_though_another_theme_has_it(self): self.w.release_line() self.w.tree(WEB, '9.0.3', {EVENTS: 'ev1', 'css/old-azure.css': 'old1'}) diff --git a/.github/unraid-watch/upstream.py b/.github/unraid-watch/upstream.py index 660b62ac..bca34aa6 100644 --- a/.github/unraid-watch/upstream.py +++ b/.github/unraid-watch/upstream.py @@ -113,7 +113,8 @@ def stylesheets(gh, src, refs, ours, pinned): texts = [] for path in (p.format(theme=theme) for p in styles['files']): text = text_at(gh, src['repo'], pinned.get(ref, ref), path) - if text is not None: + # An empty file is no input either: a theme of empty files must not read as "no change" + if text and text.strip(): texts.append(text) seen.add(path) by_ref[ref] = css.merged(texts) diff --git a/.github/unraid-watch/world.py b/.github/unraid-watch/world.py index 9a56d979..35ba1b1e 100644 --- a/.github/unraid-watch/world.py +++ b/.github/unraid-watch/world.py @@ -188,7 +188,7 @@ def release_line(self): self.tags(WEB, ['9.1.0-beta.2', '9.0.3', '8.9.0', '2030.11.10']) self.tree(WEB, '9.0.3', {EVENTS: 'ev1', 'css/old-azure.css': 'old1', 'css/old-black.css': 'old0'}) self.blob(WEB, 'old1', '.tip { display: block; color: blue; }\n') - self.blob(WEB, 'old0', '') + self.blob(WEB, 'old0', '.other { top: 0; }\n') self.fake.routes['GET', url(f'/repos/{API}/commits', page=1, path='api/switch.ts', per_page=100, sha=NEW[API])] = [commit(50, 'feat: enable the new page', '2030-01-03T00:00:00Z')] From ae7ff678e4161d491be83a67c0ce862abe7fcc6f Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 12:33:11 +0800 Subject: [PATCH 13/72] fix: the element a selector styles is found past guards nested in :where(:not(...)), as Unraid 7.4 writes them --- .github/unraid-watch/css.py | 6 +++++- .github/unraid-watch/test_css.py | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/unraid-watch/css.py b/.github/unraid-watch/css.py index b97ef283..6a78a3eb 100644 --- a/.github/unraid-watch/css.py +++ b/.github/unraid-watch/css.py @@ -122,7 +122,11 @@ def rules(text): def subject(selector): """The ids and classes of the element a selector styles; none for a ::before box, nothing an attribute value or :not() names.""" - last = re.split(r'[\s>+~]+', re.sub(r'\([^()]*\)|\[[^\]]*\]', '', selector).strip())[-1] + # Innermost first, until none is left: 7.4 wraps its guards as :where(:not(.unapi *)) + bare, previous = re.sub(r'\[[^\]]*\]', '', selector), None + while bare != previous: + bare, previous = re.sub(r'\([^()]*\)', '', bare), bare + last = re.split(r'[\s>+~]+', bare.strip())[-1] return [] if '::' in last else TOKEN.findall(last) diff --git a/.github/unraid-watch/test_css.py b/.github/unraid-watch/test_css.py index 4cc17d0e..bf8574a8 100644 --- a/.github/unraid-watch/test_css.py +++ b/.github/unraid-watch/test_css.py @@ -39,6 +39,10 @@ def test_spacing_and_attribute_quotes_do_not_make_a_rule_new(self): self.assertEqual(a, b) self.assertIn(('@media (max-width: 9px)', '.y', 'top'), a) + def test_a_guard_nested_in_where_and_not_leaves_the_element_it_styles(self): + self.assertEqual(css.subject('a.button:where(:not(.ext *))'), ['.button']) + self.assertEqual(css.subject('.box:where(:not(:is(.a .b) .c))'), ['.box']) + def test_a_generated_box_or_an_attribute_value_is_not_the_element(self): self.assertEqual(css.subject('.tip::before'), []) self.assertEqual(css.subject('a[href$=".png"]'), []) From 69ca571d523455b54b73f3a967fe75cf3a597e4d Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 13:23:19 +0800 Subject: [PATCH 14/72] fix: a group rule written @media(...) with no space is read, and code that only reads a CSS variable no longer counts as defining it --- .github/unraid-watch/css.py | 9 +++++---- .github/unraid-watch/test_css.py | 8 ++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/unraid-watch/css.py b/.github/unraid-watch/css.py index 6a78a3eb..a0e08f48 100644 --- a/.github/unraid-watch/css.py +++ b/.github/unraid-watch/css.py @@ -104,7 +104,8 @@ def _walk(body, conditions, parents, out): out += [(conditions, parent, decls) for parent in parents if decls] continue if head.startswith('@'): - if head.split(None, 1)[0].lower() in GROUPS: + # `@media(max-width:600px)` needs no space after the keyword + if re.match(r'@[\w-]+', head).group(0).lower() in GROUPS: _walk(block, ' '.join(filter(None, (conditions, _condition(head)))), parents, out) continue selectors = [_selector(s) for s in _split(head, ',') if s.strip()] @@ -175,9 +176,9 @@ def fallbacks(stylesheets, code): named = '\n'.join(f.read_text(encoding='utf-8') for f in code) def keyed(name): - # The CSS tool's presets ('fv3-x': '#fff') and the generated theme CSS ('x' => '#fff') key the plugin's own variables - bare = re.escape(name[2:]) - return re.search(r"['\"]--" + bare + r"['\"]|['\"]" + bare + r"['\"]\s*(?::|=>)", named) + # The CSS tool's presets ('fv3-x': '#fff') and the generated theme CSS ('x' => '#fff') key the plugin's own variables; + # a name that is only read (getPropertyValue('--x')) is not defined by that + return re.search(r"['\"](?:--)?" + re.escape(name[2:]) + r"['\"]\s*(?::|=>)", named) return [f'{f.name}:{text.count(chr(10), 0, m.start()) + 1}: var({m.group(1)}) has no fallback and FolderView3 does not ' f'define {m.group(1)}, so the style needs every Unraid release to; give it a fallback' for f, text in texts.items() for m in VAR.finditer(text) diff --git a/.github/unraid-watch/test_css.py b/.github/unraid-watch/test_css.py index bf8574a8..b1455670 100644 --- a/.github/unraid-watch/test_css.py +++ b/.github/unraid-watch/test_css.py @@ -47,6 +47,10 @@ def test_a_generated_box_or_an_attribute_value_is_not_the_element(self): self.assertEqual(css.subject('.tip::before'), []) self.assertEqual(css.subject('a[href$=".png"]'), []) + def test_a_group_rule_with_no_space_after_its_keyword_is_still_read(self): + self.assertEqual(css.rules('@media(max-width:600px){.tip{white-space:pre-line}} @supports(display:grid){.row{top:0}}'), + [('@media (max-width: 600px)', '.tip', {'white-space': 'pre-line'}), ('@supports (display: grid)', '.row', {'top': '0'})]) + def test_a_comma_inside_not_stays_in_its_selector(self): self.assertEqual(css.rules('.x:not(.p, .q), .z { display: none }'), [('', '.x:not(.p, .q)', {'display': 'none'}), ('', '.z', {'display': 'none'})]) @@ -118,6 +122,10 @@ def test_a_word_the_code_merely_uses_does_not_make_an_unraid_variable_the_plugin (problem,) = self.check('.a { color: var(--text); }', "fields.push({ type: 'text', label: 'Name' });") self.assertIn('var(--text) has no fallback', problem) + def test_code_that_only_reads_a_variable_does_not_define_it(self): + (problem,) = self.check('.a { color: var(--text); }', "getComputedStyle(document.body).getPropertyValue('--text');") + self.assertIn('var(--text) has no fallback', problem) + def test_a_variable_nested_in_a_fallback_needs_its_own(self): (problem,) = self.check('.a { color: var(--fv3-x, var(--text)); }', "'fv3-x'") self.assertIn('var(--text) has no fallback', problem) From d12e46202cdd0a84675f887615b93a3e8ad8623c Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 14:35:20 +0800 Subject: [PATCH 15/72] docs: beta release notes Release-Synced: 43c85d1a8c8e651a70167992a1838043f6b047e9 --- CHANGELOG.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23e5095e..39d8a323 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,7 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache ## Unreleased -- refactor: the folder-file code moves from lib.php to lib.folders.php -- fix: a success with an error field stays a success, a null answer is a failure; the API-first path and raw VM fixtures are tested -- fix: a folder action Unraid refuses shows Unraid's reason, not its JSON answer +- Folder actions that Unraid refuses now show its reason instead of raw JSON ## 2026.11.14.1 (beta) From eb1784887edda88c0cca6f4f2cedb18af780619b Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 14:38:39 +0800 Subject: [PATCH 16/72] chore(release): v2026.11.14.2 [skip ci] --- CHANGELOG.md | 2 +- folder.view3.plg | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39d8a323..986a6f98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache if the page doesn't display correctly — before submitting a debug .json. -## Unreleased +## 2026.11.14.2 (beta) - Folder actions that Unraid refuses now show its reason instead of raw JSON diff --git a/folder.view3.plg b/folder.view3.plg index 9229f27d..572bfdcf 100644 --- a/folder.view3.plg +++ b/folder.view3.plg @@ -6,8 +6,8 @@ - - + + ]> @@ -16,6 +16,9 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache if the page doesn't display correctly — before submitting a debug .json. +###2026.11.14.2 +- Folder actions that Unraid refuses now show its reason instead of raw JSON + ###2026.11.14.1 - Folder saves from two tabs, or made at once, no longer overwrite each other - Apply Defaults accepts only valid values for each setting From 16806a0b9c69c374677efdc8b2632d8f829a9a6d Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 16:27:48 +0800 Subject: [PATCH 17/72] fix: a failed update no longer deletes the package archive the installed version boots from --- folder.view3.plg | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/folder.view3.plg b/folder.view3.plg index 572bfdcf..b907aafb 100644 --- a/folder.view3.plg +++ b/folder.view3.plg @@ -857,12 +857,6 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache - Initial Release - - - rm -f $(ls /boot/config/plugins/&name;/&name;*.txz 2>/dev/null | grep -v '&pkgname;') - - - https://github.com/&github;/releases/download/v&version;/&pkgname;.txz @@ -872,6 +866,8 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache + # Only once the new package is in: a failed download or upgradepkg keeps the archive the next boot installs from + rm -f $(ls /boot/config/plugins/&name;/&name;*.txz 2>/dev/null | grep -v '&pkgname;') for p in /var/log/packages/&name;-*; do [ -e "$p" ] || continue case "$(basename "$p")" in &pkgname;) continue;; esac From ce2b14939f33dc5ecf17a680989eca338465df68 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 16:27:48 +0800 Subject: [PATCH 18/72] ci: FolderView3 goes through each supported Unraid's own plugin installer, its PHP tests run on PHP 8.3 to 8.5, and every !important needs its reason --- .coderabbit.yaml | 14 ++ .github/scripts/important_check.py | 81 +++++++++++ .github/scripts/important_check_test.py | 60 ++++++++ .github/unraid-compat/Dockerfile | 4 + .github/unraid-compat/install_test.sh | 130 ++++++++++++++++++ .github/unraid-compat/php_tests.sh | 27 ++++ .github/workflows/ci.yml | 125 +++++++++++++---- renovate.json | 31 +++++ .../plugins/folder.view3/scripts/shared.js | 1 + 9 files changed, 448 insertions(+), 25 deletions(-) create mode 100644 .github/scripts/important_check.py create mode 100644 .github/scripts/important_check_test.py create mode 100644 .github/unraid-compat/Dockerfile create mode 100755 .github/unraid-compat/install_test.sh create mode 100755 .github/unraid-compat/php_tests.sh diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 24006ece..63c9df1f 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -206,6 +206,20 @@ reviews: GraphQL checks in schema.py; flag a second copy of either. - TESTS use synthetic versions, shas and handles only; a value captured from a live system in a fixture is a finding. + - path: ".github/unraid-compat/**" + instructions: | + The Unraid compatibility matrix; CI only, nothing here ships. + - install_test.sh puts the .plg through each Unraid version's own + plugin installer in a throwaway container with no network. Only + Slackware's upgradepkg and removepkg are stubbed: flag any other + stand-in for Unraid's code. It must refuse to run on a real server. + - Each step asserts what the user is left with (live files, the + registered manifest, saved folders, Unraid's orders) right after it, + against values written by hand. A failed step fails the job. + - php_tests.sh is the one list of PHP checks for Lint + build and the + PHP matrix: php -l on every .php and .page file, then every + .github/scripts/*_test.php; a deprecation fails like an error. + - Fixtures hold synthetic names and ids only. - path: ".github/scripts/**" instructions: | CI tests and helpers; nothing here ships in the plugin. diff --git a/.github/scripts/important_check.py b/.github/scripts/important_check.py new file mode 100644 index 00000000..0b1ca939 --- /dev/null +++ b/.github/scripts/important_check.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 +"""Each !important in the plugin's own CSS, JS, PHP and .page files needs a `!important: ` comment: on its line, +on the line above it, or (CSS) directly above its rule. Bundled libraries listed in vendor.json are skipped.""" +import json +import pathlib +import re +import sys + +REASON = re.compile(r'!important:\s*\w') +KINDS = {'.css': 'css', '.js': 'script', '.php': 'script', '.page': 'script'} + + +def scan(text, kind): + """(code, comments): the text with comments and strings blanked, and [(start, end, comment text)].""" + code, comments, i, n = list(text), [], 0, len(text) + while i < n: + c, two = text[i], text[i:i + 2] + if two == '/*' or (two == '//' and kind == 'script'): + end = text.find('*/', i + 2) + 2 if two == '/*' else text.find('\n', i) + end = n if end < 2 or end == -1 else end + comments.append((i, end, text[i:end])) + code[i:end] = [ch if ch == '\n' else ' ' for ch in text[i:end]] + i = end + elif c in '"\'' or (c == '`' and kind == 'script'): + j = i + 1 + while j < n and text[j] != c and text[j] != '\n': + j += 2 if text[j] == '\\' else 1 + # A script's string is where inline styles live: keep it as code; a CSS string (content: "...") is text + if kind == 'css': + code[i:j + 1] = [ch if ch == '\n' else ' ' for ch in text[i:j + 1]] + i = j + 1 + else: + i += 1 + return ''.join(code), comments + + +def _line(text, at): + return text.count('\n', 0, at) + + +def _reason_ends_on(comments, text, line): + return any(REASON.search(body) and _line(text, end - 1) == line for start, end, body in comments) + + +def _rule_start(code, at): + """Where the selector of the rule holding the declaration at `at` begins.""" + opened = code.rfind('{', 0, at) + before = max(code.rfind(ch, 0, opened) for ch in '{};') + return before + 1 + (len(code[before + 1:opened]) - len(code[before + 1:opened].lstrip())) + + +def problems_in(path, text, kind): + code, comments = scan(text, kind) + out = [] + for m in re.finditer(r'!\s*important\b', code): + line = _line(text, m.start()) + ok = _reason_ends_on(comments, text, line) or _reason_ends_on(comments, text, line - 1) + if not ok and kind == 'css': + start = _rule_start(code, m.start()) + ok = _reason_ends_on(comments, text, _line(text, start) - 1) or _reason_ends_on(comments, text, _line(text, start)) + if not ok: + out.append(f'{path}:{line + 1}: !important without a "!important: " comment on its line, the line above, or above its rule') + return out + + +def problems(repo): + manifest = json.loads((repo / 'vendor.json').read_text(encoding='utf-8')) + root = repo / manifest['root'] + bundled = {(root / dest).resolve() for lib in manifest['libraries'] for dest in lib['files'].values()} + out = [] + for path in sorted(root.rglob('*')): + kind = KINDS.get(path.suffix) + if kind and path.is_file() and path.resolve() not in bundled: + out += problems_in(path.relative_to(repo), path.read_text(encoding='utf-8'), kind) + return out + + +if __name__ == '__main__': + found = problems(pathlib.Path(__file__).resolve().parents[2]) + print('\n'.join(found) or 'Every !important has its reason') + sys.exit(1 if found else 0) diff --git a/.github/scripts/important_check_test.py b/.github/scripts/important_check_test.py new file mode 100644 index 00000000..9f9b195f --- /dev/null +++ b/.github/scripts/important_check_test.py @@ -0,0 +1,60 @@ +import json +import pathlib +import tempfile +import unittest + +import important_check + +ROOT = 'src/plugin' + + +class ImportantCheckTest(unittest.TestCase): + def check(self, files, bundled=()): + tmp = tempfile.TemporaryDirectory() + self.addCleanup(tmp.cleanup) + repo = pathlib.Path(tmp.name) + (repo / 'vendor.json').write_text(json.dumps({'root': ROOT, 'libraries': [{'files': {f'x/{b}': b for b in bundled}}]}), encoding='utf-8') + for name, text in files.items(): + (repo / ROOT / name).parent.mkdir(parents=True, exist_ok=True) + (repo / ROOT / name).write_text(text, encoding='utf-8') + return important_check.problems(repo) + + def test_a_reason_above_the_rule_or_on_the_line_passes(self): + sheet = ('.a { top: 0 }\n\n/* !important: Unraid inlines this padding */\n#t .x,\n#t .y {\n padding-left: 20px !important;\n}\n' + '.b { margin: 0 !important; /* !important: a theme sets it inline */ }\n') + self.assertEqual(self.check({'styles/a.css': sheet}), []) + + def test_an_important_without_its_reason_is_named_with_its_line(self): + sheet = '/* spacing */\n.a {\n top: 0;\n left: 1px!important;\n}\n' + self.assertEqual(self.check({'styles/a.css': sheet}), + [f'{ROOT}/styles/a.css:4: !important without a "!important: " comment on its line, the line above, or above its rule']) + + def test_a_reason_belongs_to_the_rule_under_it_only(self): + sheet = '/* !important: first */\n.a { top: 0 !important }\n.b { top: 0 !important }\n' + (problem,) = self.check({'styles/a.css': sheet}) + self.assertIn('a.css:3:', problem) + + def test_a_reason_comment_must_give_a_reason(self): + self.assertEqual(len(self.check({'styles/a.css': '/* !important: */\n.a { top: 0 !important }\n'})), 1) + + def test_a_comment_or_a_content_string_that_mentions_it_is_not_a_use(self): + sheet = '/* never use !important here */\n.a::after { content: "!important"; }\n' + self.assertEqual(self.check({'styles/a.css': sheet}), []) + + def test_a_script_needs_the_reason_on_its_line_or_the_line_above(self): + good = "// beats swal's !important rules\n// !important: no stylesheet may show a row while it is measured\nrow.style.cssText += ';visibility:hidden !important;';\n" + bad = "// hide the row\nrow.style.cssText += ';visibility:hidden !important;';\n" + self.assertEqual(self.check({'scripts/a.js': good}), []) + (problem,) = self.check({'scripts/b.js': bad}) + self.assertIn('scripts/b.js:2:', problem) + + def test_page_and_php_files_are_checked_too(self): + found = self.check({'Folder.page': 'Menu="x"\n---\n\n', 'server/a.php': " +set -u +# This replaces plugin files and system tools, so it must never touch a real server. +if [ -e /etc/unraid-version ] || [ -d /boot/config ]; then echo 'Refusing to run on an Unraid system' >&2; exit 2; fi +web=$(cd "$1" && pwd); version=$2; stable=$(cd "$3" && pwd); repo=$(pwd) +fail() { echo "FAILED [Unraid $version]: $*"; exit 1; } +awk --version 2>/dev/null | grep -q 'GNU Awk' || fail 'awk is not gawk, as it is on Unraid: the remove script needs RT' + +name=folder.view3 +docroot=/usr/local/emhttp +flash=/boot/config/plugins/$name +live=$docroot/plugins/$name +manifest=/boot/config/plugins/$name.plg +mkdir -p "$docroot/plugins" /boot/config/plugins-error /var/log/plugins /var/log/packages /var/local/emhttp +cp -R "$web/emhttp/plugins/dynamix" "$web/emhttp/plugins/dynamix.plugin.manager" "$docroot/plugins/" +ln -sfn "$docroot/plugins/dynamix" "$docroot/webGui" +printf 'csrf_token="compat-test-token"\n' > /var/local/emhttp/var.ini +# The hooks check every installed plugin through Unraid's php at /usr/bin/php; this container has only this one +rm -rf "$docroot/plugins/dynamix.plugin.manager/pre-hooks" "$docroot/plugins/dynamix.plugin.manager/post-hooks" +ln -sf "$(command -v php)" /usr/bin/php +plugin() { php "$docroot/plugins/dynamix.plugin.manager/scripts/plugin" "$@"; } + +# Slackware's package tools; everything else is Unraid's own code +cat > /sbin/upgradepkg <<'STUB' +#!/bin/bash +for pkg; do :; done +tar -xJf "$pkg" -C / || exit 1 +touch "/var/log/packages/$(basename "$pkg" .txz)" +STUB +cat > /sbin/removepkg <<'STUB' +#!/bin/bash +rm -rf /usr/local/emhttp/plugins/folder.view3 +rm -f "/var/log/packages/$1" +STUB +chmod +x /sbin/upgradepkg /sbin/removepkg + +work=$(mktemp -d) +build() { # build : the .plg and package as the release workflow makes them + local dir="$work/$2"; mkdir -p "$dir"; cp -R "$1/src" "$1/$name.plg" "$1/pkg_build.sh" "$dir/" + (cd "$dir" && bash pkg_build.sh --version "$2" --branch "$3" --out "$dir/dist" >/dev/null) || fail "package build of $2" +} +old=2026.01.01; new=2099.01.01 +build "$stable" $old main; build "$repo" $new beta +min=$(grep -o ']*min="[^"]*"' "$work/$new/$name.plg" | sed 's/.*min="//; s/"$//') +[ -n "$min" ] || fail 'the .plg names no min version' + +set_version() { printf 'version="%s"\n' "$1" > /etc/unraid-version; } +reset() { + rm -rf "$flash" "$live" "$manifest" /var/log/plugins/$name.plg /var/log/packages/$name-* /boot/config/plugins/dockerMan /boot/config/plugins/dynamix.vm.manager + mkdir -p "$flash" +} +install() { # install : the .plg with its package already on the flash, as a boot or a cached download has it + cp "$work/$1/dist/$name-$1-x86_64-1.txz" "$flash/" + plugin install "$work/$1/$name.plg" > "$work/$2.log" 2>&1 || { cat "$work/$2.log"; fail "$2: install of $1 refused"; } +} +installed() { # installed : its files are live, its package is recorded and its manifest registered + local pkg=$name-$1-x86_64-1 x=$work/unpacked + rm -rf "$x" && mkdir "$x" && tar -xJf "$work/$1/dist/$pkg.txz" -C "$x" || fail "$2: unpack $1" + local differ; differ=$(cd "$x" && find . -type f | while read -r f; do cmp -s "$f" "/$f" || echo "${f#.}"; done) + [ -z "$differ" ] || fail "$2: files not as $1 ships them: $(echo $differ | head -c 300)" + [ -e "/var/log/packages/$pkg" ] || fail "$2: no package record for $1" + [ -L /var/log/plugins/$name.plg ] && grep -q "ENTITY version \"$1\"" "$manifest" || fail "$2: $1 is not the registered manifest" +} +saved_config() { # what a user has saved: folders, settings, a theme, and Unraid's own orders holding folder entries + mkdir -p "$flash/styles" "$flash/scripts" /boot/config/plugins/dockerMan /boot/config/plugins/dynamix.vm.manager + printf '{"AbCdEfGhIjKlMnOpQrSt":{"name":"Media","icon":"","regex":"","containers":["alpha"],"settings":{"preview":1},"actions":[]}}' > "$flash/docker.json" + printf '{"ZyXwVuTsRqPoNmLkJiHg":{"name":"Lab","icon":"","regex":"","containers":["Debian 12"],"settings":{"preview":1},"actions":[]}}' > "$flash/vm.json" + printf '{"docker":{"preview":1}}' > "$flash/settings.json" + printf '.folder-appname { color: #abc; }\n' > "$flash/styles/custom.css" + # folder-sync and folder-nightlybackups are containers: too short, or no capital as a folder id has + printf '0="folder-AbCdEfGhIjKlMnOpQrSt"\n1="alpha"\n2="folder-sync"\n3="folder-nightlybackups"\n4="beta"\n' > /boot/config/plugins/dockerMan/userprefs.cfg + printf '0="folder-ZyXwVuTsRqPoNmLkJiHg"\r\n1="Debian 12"\r\n2="Windows"' > /boot/config/plugins/dynamix.vm.manager/userprefs.cfg +} +config_sums() { (cd /boot/config/plugins && find $name dockerMan dynamix.vm.manager -type f ! -name "$name-*.txz" ! -path "$name/version" -print0 | sort -z | xargs -0 md5sum); } +set_version "$version" + +# A fresh install +reset; install $new fresh; installed $new fresh +[ "$(cat "$flash/version")" = $new ] || fail 'fresh: version file not written' +[ -d "$flash/styles" ] && [ -d "$flash/scripts" ] || fail 'fresh: styles and scripts folders not made' + +# An upgrade over the last stable keeps what the user saved, byte for byte, and drops the previous package +reset; install $old stable; installed $old stable; saved_config; before=$(config_sums) +install $new upgrade; installed $new upgrade +[ "$(config_sums)" = "$before" ] || fail 'upgrade: saved folders, settings, theme or Unraid orders changed' +[ ! -e "$flash/$name-$old-x86_64-1.txz" ] || fail 'upgrade: previous archive left on the flash' +[ ! -e "/var/log/packages/$name-$old-x86_64-1" ] || fail 'upgrade: previous package record left' + +# What a reboot does: the registered manifest installs again from the archive on the flash +rm -f /var/log/plugins/$name.plg +plugin install "$manifest" > "$work/boot.log" 2>&1 || { cat "$work/boot.log"; fail 'boot: reinstall refused'; } +installed $new boot + +# Removal leaves nothing, and takes only FolderView3's own entries out of Unraid's orders, line endings kept +plugin remove $name.plg > "$work/remove.log" 2>&1 || { cat "$work/remove.log"; fail 'remove: refused'; } +[ ! -e "$live" ] && [ ! -e "$flash" ] && [ ! -e /var/log/plugins/$name.plg ] && [ ! -e "$manifest" ] || fail 'remove: files left behind' +ls /var/log/packages/$name-* >/dev/null 2>&1 && fail 'remove: package record left' +cmp -s /boot/config/plugins/dockerMan/userprefs.cfg <(printf '0="alpha"\n1="folder-sync"\n2="folder-nightlybackups"\n3="beta"\n') \ + || fail "remove: Docker order not as expected: $(od -c /boot/config/plugins/dockerMan/userprefs.cfg | head -5)" +cmp -s /boot/config/plugins/dynamix.vm.manager/userprefs.cfg <(printf '0="Debian 12"\r\n1="Windows"') \ + || fail "remove: VM order not as expected: $(od -c /boot/config/plugins/dynamix.vm.manager/userprefs.cfg | head -5)" + +# A download that fails (no network here) leaves the running install and what the user saved +reset; install $old stable2; saved_config; before=$(config_sums) +plugin install "$work/$new/$name.plg" > "$work/download.log" 2>&1 && fail 'download: install reported success without its package' +installed $old download +[ -f "$flash/$name-$old-x86_64-1.txz" ] || fail 'download: deleted the archive the next boot installs from' +[ "$(config_sums)" = "$before" ] || fail 'download: saved files changed' + +# A failed upgradepkg does the same +reset; install $old stable3; saved_config; before=$(config_sums) +cp "$work/$new/dist/$name-$new-x86_64-1.txz" "$flash/" +mv /sbin/upgradepkg "$work/upgradepkg"; printf '#!/bin/bash\nexit 1\n' > /sbin/upgradepkg; chmod +x /sbin/upgradepkg +plugin install "$work/$new/$name.plg" > "$work/upgradepkg.log" 2>&1; status=$? +mv "$work/upgradepkg" /sbin/upgradepkg +[ $status -ne 0 ] || fail 'upgradepkg: install reported success though upgradepkg failed' +installed $old upgradepkg +[ -f "$flash/$name-$old-x86_64-1.txz" ] || fail 'upgradepkg: deleted the archive the next boot installs from' +[ "$(config_sums)" = "$before" ] || fail 'upgradepkg: saved files changed' + +# The installer itself refuses an Unraid below the .plg's min, and says why +reset; set_version 6.12.15; cp "$work/$new/dist/$name-$new-x86_64-1.txz" "$flash/" +plugin install "$work/$new/$name.plg" > "$work/min.log" 2>&1 && fail "min: installed on 6.12.15 though min is $min" +grep -q "installed Unraid version is too low, require at least version $min" "$work/min.log" || { cat "$work/min.log"; fail 'min: no reason given'; } +[ ! -e "$live" ] || fail 'min: files installed below min' +set_version "$version" + +echo "Unraid $version: install, upgrade, boot, remove, failed download, failed upgradepkg and min passed" diff --git a/.github/unraid-compat/php_tests.sh b/.github/unraid-compat/php_tests.sh new file mode 100755 index 00000000..5ea8f42a --- /dev/null +++ b/.github/unraid-compat/php_tests.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# php -l over every plugin .php and .page file, then every .github/scripts/*_test.php, with every error level on. +# A deprecation fails like an error, so a PHP that Unraid has not shipped yet shows what FolderView3 must change. +set -u +cd "$(dirname "$0")/../.." || exit 2 +status=0 +errors=$(mktemp) +trap 'rm -f "$errors"' EXIT +php -v | head -1 + +while IFS= read -r -d '' f; do + if ! out=$(php -d error_reporting=-1 -l "$f" 2>&1) || grep -q 'Deprecated:' <<<"$out"; then + echo "$out" + status=1 + fi +done < <(find src \( -name '*.php' -o -name '*.page' \) -print0) + +for t in .github/scripts/*_test.php; do + echo "== $t" + php -d error_reporting=-1 -d display_errors=stderr -d log_errors=0 "$t" 2>"$errors" || status=1 + cat "$errors" >&2 + if grep -q 'Deprecated:' "$errors"; then + echo "FAILED: $t ran into a deprecation" + status=1 + fi +done +exit $status diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d682578..7688915c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,33 +31,18 @@ jobs: - name: Install tools run: sudo apt-get update && sudo apt-get install -y --no-install-recommends libxml2-utils - - name: PHP syntax check - run: | - status=0 - while IFS= read -r f; do - php -l "$f" || status=1 - done < <(find src -name '*.php') - exit $status - - - name: Update status test - run: php .github/scripts/update_status_test.php - - - name: FolderView Plus import tests - run: php .github/scripts/foreign_import_test.php + # php -l on every .php and .page file, then every .github/scripts/*_test.php; a deprecation fails too + - name: PHP syntax check and PHP tests + run: bash .github/unraid-compat/php_tests.sh - - name: Autostart order tests - run: php .github/scripts/page_order_test.php - - - name: POST endpoint answer tests - run: php .github/scripts/post_answers_test.php - - - name: Folder file lock tests - run: php .github/scripts/folder_lock_test.php + - name: Every !important has its reason + working-directory: .github/scripts + run: | + python3 -B -m unittest important_check_test + python3 -B important_check.py - name: Variables tab tests - run: | - php .github/scripts/variables_tab_test.php - node .github/scripts/variables_tab_test.js + run: node .github/scripts/variables_tab_test.js - name: Autostart tab tests run: node .github/scripts/autostart_api_test.js @@ -146,6 +131,96 @@ jobs: python -m unittest discover -s .github/unraid-watch -p 'test_*.py' python .github/unraid-watch/watch.py check + php: + name: PHP ${{ matrix.php }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + # Unraid ships 8.3 up to 7.2.7 and in 7.3.0, 8.4 from 7.2.8, 7.3.1 and 7.4; 8.5 is ahead of every release + php: ['8.3', '8.4', '8.5'] + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + persist-credentials: false + + - name: PHP syntax check and PHP tests + env: + PHP_VERSION: ${{ matrix.php }} + run: docker run --rm -v "$PWD:/repo" -w /repo "php:${PHP_VERSION}-cli" bash .github/unraid-compat/php_tests.sh + + unraid: + name: Unraid ${{ matrix.unraid }}${{ matrix.row && format(' ({0})', matrix.row) || '' }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + # The newest release of each minor from the .plg's min, on the PHP that release ships + include: + - {unraid: '7.0.1', php: '8.3'} + - {unraid: '7.1.4', php: '8.3'} + - {unraid: '7.2.7', php: '8.3'} + - {unraid: '7.3.5', php: '8.4'} + # renovate: newest Unraid + - {unraid: '7.4.0', php: '8.4'} + # renovate: newest Unraid tag, betas included; a beta on a newer PHP needs its php raised by hand + - {unraid: '7.4.0', php: '8.4', row: 'newest tag'} + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + persist-credentials: false + + - name: Checkout the last stable release + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + persist-credentials: false + ref: main + path: .stable + + - name: Checkout the Unraid webGUI at this version + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + persist-credentials: false + repository: unraid/webgui + ref: ${{ matrix.unraid }} + path: .webgui + sparse-checkout: | + emhttp/plugins/dynamix + emhttp/plugins/dynamix.plugin.manager + + - name: Install, upgrade, remove and failures through Unraid's own plugin installer + env: + PHP_VERSION: ${{ matrix.php }} + UNRAID_VERSION: ${{ matrix.unraid }} + run: | + docker build -q -t fv3-unraid --build-arg PHP="$PHP_VERSION" .github/unraid-compat + docker run --rm --network none -v "$PWD:/repo" -w /repo fv3-unraid bash .github/unraid-compat/install_test.sh .webgui "$UNRAID_VERSION" .stable + + # One check per matrix for beta's branch protection: the version rows rename themselves as Renovate moves them + php-compat: + name: PHP compatibility + needs: php + if: always() + runs-on: ubuntu-latest + steps: + - name: Every PHP version passed + env: + RESULT: ${{ needs.php.result }} + run: '[ "$RESULT" = success ]' + + unraid-compat: + name: Unraid compatibility + needs: unraid + if: always() + runs-on: ubuntu-latest + steps: + - name: Every Unraid version passed + env: + RESULT: ${{ needs.unraid.result }} + run: '[ "$RESULT" = success ]' + # A dispatched run's checks never reach the PR, so vendor-sync's run reports Lint + build there as a commit status. report: needs: validate @@ -168,7 +243,7 @@ jobs: gh api "repos/$REPO/statuses/$SHA" -f state="$state" -f context='Lint + build' -f target_url="$RUN_URL" -f description="CI dispatched for this PR: $RESULT" >/dev/null notify-failure: - needs: validate + needs: [validate, php, unraid] if: failure() && github.event_name != 'pull_request' && !inputs.base permissions: {} uses: chodeus/chodeus-ops/.github/workflows/notify-discord.yml@65484add1113c1bbc00827af7237ebe7a1837bbb # main diff --git a/renovate.json b/renovate.json index 42aeef79..c365eefe 100644 --- a/renovate.json +++ b/renovate.json @@ -4,6 +4,26 @@ "forkProcessing": "enabled", "baseBranchPatterns": ["beta"], "customManagers": [ + { + "customType": "regex", + "description": "The newest stable Unraid the CI matrix installs FolderView3 on, so a new release is tested before users reach it.", + "managerFilePatterns": ["/^\\.github/workflows/ci\\.yml$/"], + "matchStrings": ["# renovate: newest Unraid\\s+- \\{unraid: '(?[^']+)'"], + "datasourceTemplate": "github-tags", + "depNameTemplate": "unraid/webgui", + "depTypeTemplate": "unraid-stable", + "versioningTemplate": "semver" + }, + { + "customType": "regex", + "description": "The newest Unraid tag of any kind, betas and release candidates included, for the matrix's 'newest tag' row.", + "managerFilePatterns": ["/^\\.github/workflows/ci\\.yml$/"], + "matchStrings": ["# renovate: newest Unraid tag[^\\n]*\\s+- \\{unraid: '(?[^']+)'"], + "datasourceTemplate": "github-tags", + "depNameTemplate": "unraid/webgui", + "depTypeTemplate": "unraid-newest-tag", + "versioningTemplate": "semver" + }, { "customType": "regex", "description": "actionlint's release tag and tarball SHA-256 in validate-workflows.yml; Renovate takes the same asset's hash from the new release.", @@ -37,6 +57,17 @@ } ], "packageRules": [ + { + "description": "Unraid releases only: webgui also carries 2014.x date tags, which sort above every 7.x.", + "matchDepTypes": ["unraid-stable"], + "allowedVersions": "/^\\d{1,2}\\.\\d+\\.\\d+$/" + }, + { + "description": "Unraid releases and their betas and release candidates, still without the date tags.", + "matchDepTypes": ["unraid-newest-tag"], + "allowedVersions": "/^\\d{1,2}\\.\\d+\\.\\d+(-[0-9A-Za-z.]+)?$/", + "ignoreUnstable": false + }, { "description": "Bundled libraries ship to users, so their updates are fix(deps).", "matchDepTypes": ["bundled"], diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/shared.js b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/shared.js index 19411a79..241972b6 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/shared.js +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/shared.js @@ -1912,6 +1912,7 @@ window.fv3InstallDockerTableWidthFix = () => { if (!storage || !storage.children.length) return; const children = Array.from(storage.children); const origStyles = children.map(c => c.getAttribute('style') || ''); + // !important: an inline !important outranks every stylesheet, so no theme or custom CSS shows a row while it is measured children.forEach(c => c.style.cssText += ';visibility:hidden !important;'); children.forEach(c => folder.parentNode.insertBefore(c, folder.nextSibling)); void tbl.offsetHeight; From 4903b3f08798c4291e45862d54d0166b070ce374 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 16:30:27 +0800 Subject: [PATCH 19/72] ci: a dispatched run posts the PHP and Unraid checks on the PR too, and the PHP runner sits with the tests it runs --- .coderabbit.yaml | 6 ++--- .../{unraid-compat => scripts}/php_tests.sh | 0 .github/workflows/ci.yml | 25 ++++++++++++------- 3 files changed, 19 insertions(+), 12 deletions(-) rename .github/{unraid-compat => scripts}/php_tests.sh (100%) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 63c9df1f..0739a0d5 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -216,9 +216,6 @@ reviews: - Each step asserts what the user is left with (live files, the registered manifest, saved folders, Unraid's orders) right after it, against values written by hand. A failed step fails the job. - - php_tests.sh is the one list of PHP checks for Lint + build and the - PHP matrix: php -l on every .php and .page file, then every - .github/scripts/*_test.php; a deprecation fails like an error. - Fixtures hold synthetic names and ids only. - path: ".github/scripts/**" instructions: | @@ -238,6 +235,9 @@ reviews: failed read or download as "nothing to report". - package.json here is test-only (jquery, jsdom), pinned to exact versions. + - php_tests.sh is the one list of PHP checks for Lint + build and the + PHP matrix: php -l on every .php and .page file, then every + *_test.php here; a deprecation fails like an error. - path: "**" instructions: |- Applies to every file, whatever the language: diff --git a/.github/unraid-compat/php_tests.sh b/.github/scripts/php_tests.sh similarity index 100% rename from .github/unraid-compat/php_tests.sh rename to .github/scripts/php_tests.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7688915c..955dd96a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: # php -l on every .php and .page file, then every .github/scripts/*_test.php; a deprecation fails too - name: PHP syntax check and PHP tests - run: bash .github/unraid-compat/php_tests.sh + run: bash .github/scripts/php_tests.sh - name: Every !important has its reason working-directory: .github/scripts @@ -148,7 +148,7 @@ jobs: - name: PHP syntax check and PHP tests env: PHP_VERSION: ${{ matrix.php }} - run: docker run --rm -v "$PWD:/repo" -w /repo "php:${PHP_VERSION}-cli" bash .github/unraid-compat/php_tests.sh + run: docker run --rm -v "$PWD:/repo" -w /repo "php:${PHP_VERSION}-cli" bash .github/scripts/php_tests.sh unraid: name: Unraid ${{ matrix.unraid }}${{ matrix.row && format(' ({0})', matrix.row) || '' }} @@ -221,26 +221,33 @@ jobs: RESULT: ${{ needs.unraid.result }} run: '[ "$RESULT" = success ]' - # A dispatched run's checks never reach the PR, so vendor-sync's run reports Lint + build there as a commit status. + # A dispatched run's checks never reach the PR, so vendor-sync's run reports each gate there as a commit status. report: - needs: validate + needs: [validate, php-compat, unraid-compat] if: always() && github.event_name == 'workflow_dispatch' && inputs.base != '' runs-on: ubuntu-latest permissions: statuses: write steps: - - name: Post the result on the PR's commit + - name: Post the results on the PR's commit env: - RESULT: ${{ needs.validate.result }} + LINT: ${{ needs.validate.result }} + PHP: ${{ needs.php-compat.result }} + UNRAID: ${{ needs.unraid-compat.result }} GH_TOKEN: ${{ github.token }} REPO: ${{ github.repository }} SHA: ${{ github.sha }} RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} run: | set -euo pipefail - state=failure - [ "$RESULT" = success ] && state=success - gh api "repos/$REPO/statuses/$SHA" -f state="$state" -f context='Lint + build' -f target_url="$RUN_URL" -f description="CI dispatched for this PR: $RESULT" >/dev/null + post() { + local state=failure + [ "$2" = success ] && state=success + gh api "repos/$REPO/statuses/$SHA" -f state="$state" -f context="$1" -f target_url="$RUN_URL" -f description="CI dispatched for this PR: $2" >/dev/null + } + post 'Lint + build' "$LINT" + post 'PHP compatibility' "$PHP" + post 'Unraid compatibility' "$UNRAID" notify-failure: needs: [validate, php, unraid] From 7d54ebb537ccee4cec58c3cfcb04896375d30c20 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 08:31:11 +0000 Subject: [PATCH 20/72] chore(deps): update dependency jsdom to v31.0.1 (#187) Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/scripts/package-lock.json | 8 ++++---- .github/scripts/package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/scripts/package-lock.json b/.github/scripts/package-lock.json index dc7d31db..92812c63 100644 --- a/.github/scripts/package-lock.json +++ b/.github/scripts/package-lock.json @@ -7,7 +7,7 @@ "name": "folder-view3-ci-tests", "devDependencies": { "jquery": "3.7.1", - "jsdom": "31.0.0" + "jsdom": "31.0.1" } }, "node_modules/@exodus/bytes": { @@ -154,9 +154,9 @@ "license": "MIT" }, "node_modules/jsdom": { - "version": "31.0.0", - "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-31.0.0.tgz", - "integrity": "sha512-xAkhD9z1eyFC5+QUi9K24CaZJgdCQ2GOGLW1GdVDoQvkp/AxEH9TQ0pAplPOlIiV92hfcgnFOADZypbjgbBT6Q==", + "version": "31.0.1", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-31.0.1.tgz", + "integrity": "sha512-CbhJL8ZQg3eKswxSZth4QO9tW0jPIhmR0vtSXQSbKSfWbwIT6hoRc17wdHIVTQ43KI0mdV5iTJr3281IDgVZ5g==", "dev": true, "license": "MIT", "dependencies": { diff --git a/.github/scripts/package.json b/.github/scripts/package.json index cab4cf12..3548b360 100644 --- a/.github/scripts/package.json +++ b/.github/scripts/package.json @@ -4,6 +4,6 @@ "description": "Test-only dependencies for the scripts in this folder; nothing here ships in the plugin", "devDependencies": { "jquery": "3.7.1", - "jsdom": "31.0.0" + "jsdom": "31.0.1" } } From 41a4ca4797346cd2efbd86a718074f6471774884 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 17:19:30 +0800 Subject: [PATCH 21/72] ci: deprecations in endpoint child processes fail, a boot starts from an empty RAM root, each failure step proves its cause, one Unraid row per minor kept by Renovate and matrix_check, and the !important check reads case, URLs, nesting and regexes --- .coderabbit.yaml | 9 +- .github/scripts/important_check.py | 107 +++++++++++++++------ .github/scripts/important_check_test.py | 29 +++++- .github/scripts/php_tests.sh | 38 +++++--- .github/scripts/vendor.py | 21 +++- .github/unraid-compat/Dockerfile | 5 +- .github/unraid-compat/install_test.sh | 49 ++++++---- .github/unraid-compat/matrix_check.py | 48 +++++++++ .github/unraid-compat/matrix_check_test.py | 35 +++++++ .github/workflows/ci.yml | 26 ++++- renovate.json | 26 +++-- 11 files changed, 308 insertions(+), 85 deletions(-) create mode 100644 .github/unraid-compat/matrix_check.py create mode 100644 .github/unraid-compat/matrix_check_test.py diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 0739a0d5..65ac2287 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -210,9 +210,12 @@ reviews: instructions: | The Unraid compatibility matrix; CI only, nothing here ships. - install_test.sh puts the .plg through each Unraid version's own - plugin installer in a throwaway container with no network. Only - Slackware's upgradepkg and removepkg are stubbed: flag any other - stand-in for Unraid's code. It must refuse to run on a real server. + plugin installer, hooks included, in a fresh Docker container with + no network; it must refuse to run anywhere else. Only Slackware's + upgradepkg and removepkg are stubbed, keeping their file-list + records: flag any other stand-in for Unraid's code. + - matrix_check.py keeps ci.yml's Unraid rows at one per minor from the + .plg's min to the newest release; Renovate only moves rows. - Each step asserts what the user is left with (live files, the registered manifest, saved folders, Unraid's orders) right after it, against values written by hand. A failed step fails the job. diff --git a/.github/scripts/important_check.py b/.github/scripts/important_check.py index 0b1ca939..12e4e01d 100644 --- a/.github/scripts/important_check.py +++ b/.github/scripts/important_check.py @@ -1,33 +1,65 @@ #!/usr/bin/env python3 -"""Each !important in the plugin's own CSS, JS, PHP and .page files needs a `!important: ` comment: on its line, -on the line above it, or (CSS) directly above its rule. Bundled libraries listed in vendor.json are skipped.""" -import json +"""Each !important in the plugin's own CSS, JS, PHP and .page files needs a `!important: ` comment.""" import pathlib import re import sys -REASON = re.compile(r'!important:\s*\w') -KINDS = {'.css': 'css', '.js': 'script', '.php': 'script', '.page': 'script'} +import vendor + +REASON = re.compile(r'!important:\s*\w', re.I) +KINDS = {'.css': 'css', '.js': 'js', '.php': 'php', '.page': 'page'} +# A `/` after one of these, or first on its line, opens a JS regex literal rather than dividing; not `<`, as `

` has it +REGEX_AFTER = set('(,=:[!&|?{};+-*%>~^') + + +def _blank(code, text, i, j): + code[i:j] = [ch if ch == '\n' else ' ' for ch in text[i:j]] + + +def _regex_end(text, i): + """End of the JS regex literal opening at `i`, or None when the `/` divides.""" + before = text[:i].rstrip(' \t') + if before and not before.endswith('\n') and before[-1] not in REGEX_AFTER and not re.search(r'\b(return|typeof)$', before): + return None + j, in_class = i + 1, False + while j < len(text) and text[j] != '\n': + if text[j] == '\\': + j += 1 + elif text[j] == '[': + in_class = True + elif text[j] == ']': + in_class = False + elif text[j] == '/' and not in_class: + return j + 1 + j += 1 + return None def scan(text, kind): - """(code, comments): the text with comments and strings blanked, and [(start, end, comment text)].""" + """(code, comments): the text with comments, CSS strings and JS regexes blanked, and [(start, end, comment text)].""" code, comments, i, n = list(text), [], 0, len(text) + script = kind != 'css' while i < n: c, two = text[i], text[i:i + 2] - if two == '/*' or (two == '//' and kind == 'script'): - end = text.find('*/', i + 2) + 2 if two == '/*' else text.find('\n', i) - end = n if end < 2 or end == -1 else end + html = kind == 'page' and text.startswith('' if html else '\n' + found = text.find(close, i + 2) + end = n if found == -1 else found + (0 if close == '\n' else len(close)) comments.append((i, end, text[i:end])) - code[i:end] = [ch if ch == '\n' else ' ' for ch in text[i:end]] + _blank(code, text, i, end) i = end - elif c in '"\'' or (c == '`' and kind == 'script'): + elif c == '/' and kind in ('js', 'page') and (end := _regex_end(text, i)): + _blank(code, text, i, end) + i = end + elif c in '"\'' or (c == '`' and script): j = i + 1 while j < n and text[j] != c and text[j] != '\n': j += 2 if text[j] == '\\' else 1 # A script's string is where inline styles live: keep it as code; a CSS string (content: "...") is text if kind == 'css': - code[i:j + 1] = [ch if ch == '\n' else ' ' for ch in text[i:j + 1]] + _blank(code, text, i, j + 1) i = j + 1 else: i += 1 @@ -38,41 +70,52 @@ def _line(text, at): return text.count('\n', 0, at) -def _reason_ends_on(comments, text, line): - return any(REASON.search(body) and _line(text, end - 1) == line for start, end, body in comments) +def _own_line(text, start): + return text[text.rfind('\n', 0, start) + 1:start].strip() == '' + + +def _reason(comments, text, line, alone): + """A reason comment ending on `line`; with `alone`, only one with no code before it on its line.""" + return any(REASON.search(body) and _line(text, end - 1) == line and (not alone or _own_line(text, start)) + for start, end, body in comments) def _rule_start(code, at): - """Where the selector of the rule holding the declaration at `at` begins.""" - opened = code.rfind('{', 0, at) - before = max(code.rfind(ch, 0, opened) for ch in '{};') - return before + 1 + (len(code[before + 1:opened]) - len(code[before + 1:opened].lstrip())) + """Where the selector of the rule holding the declaration at `at` begins, past any nested rules; None outside a rule.""" + depth, opened = 0, at - 1 + while opened >= 0 and not (code[opened] == '{' and depth == 0): + depth += (code[opened] == '}') - (code[opened] == '{') + opened -= 1 + if opened < 0: + return None + start = max(code.rfind(ch, 0, opened) for ch in '{};') + 1 + while start < opened and code[start].isspace(): + start += 1 + return start def problems_in(path, text, kind): code, comments = scan(text, kind) out = [] - for m in re.finditer(r'!\s*important\b', code): + for m in re.finditer(r'!\s*important\b', code, re.I): line = _line(text, m.start()) - ok = _reason_ends_on(comments, text, line) or _reason_ends_on(comments, text, line - 1) - if not ok and kind == 'css': - start = _rule_start(code, m.start()) - ok = _reason_ends_on(comments, text, _line(text, start) - 1) or _reason_ends_on(comments, text, _line(text, start)) + ok = _reason(comments, text, line, alone=False) or _reason(comments, text, line - 1, alone=True) + start = _rule_start(code, m.start()) if kind == 'css' else None + if not ok and start is not None: + ok = _reason(comments, text, _line(text, start) - 1, alone=True) or _reason(comments, text, _line(text, start), alone=True) if not ok: out.append(f'{path}:{line + 1}: !important without a "!important: " comment on its line, the line above, or above its rule') return out def problems(repo): - manifest = json.loads((repo / 'vendor.json').read_text(encoding='utf-8')) - root = repo / manifest['root'] - bundled = {(root / dest).resolve() for lib in manifest['libraries'] for dest in lib['files'].values()} - out = [] - for path in sorted(root.rglob('*')): - kind = KINDS.get(path.suffix) - if kind and path.is_file() and path.resolve() not in bundled: - out += problems_in(path.relative_to(repo), path.read_text(encoding='utf-8'), kind) - return out + repo = repo.resolve() + manifest, root = vendor.plugin_root(repo) + bundled = {vendor.destination(manifest, root, dest) for lib in manifest['libraries'] for dest in lib['files'].values()} + files = [p for p in sorted(root.rglob('*')) if p.suffix in KINDS and p.is_file() and p.resolve() not in bundled] + if not files: + return [f'{manifest["root"]}: no CSS, JS, PHP or .page files to check'] + return [problem for p in files for problem in problems_in(p.relative_to(repo), p.read_text(encoding='utf-8'), KINDS[p.suffix])] if __name__ == '__main__': diff --git a/.github/scripts/important_check_test.py b/.github/scripts/important_check_test.py index 9f9b195f..5bbcc125 100644 --- a/.github/scripts/important_check_test.py +++ b/.github/scripts/important_check_test.py @@ -34,6 +34,32 @@ def test_a_reason_belongs_to_the_rule_under_it_only(self): (problem,) = self.check({'styles/a.css': sheet}) self.assertIn('a.css:3:', problem) + def test_a_reason_at_the_end_of_a_line_covers_that_line_only(self): + rules = '.a { top: 0 !important } /* !important: r */\n.b { top: 0 !important }\n' + decls = '.c {\n top: 0 !important; /* !important: r */\n left: 0 !important;\n}\n' + self.assertEqual([p.split(': !')[0] for p in self.check({'styles/a.css': rules, 'styles/b.css': decls})], + [f'{ROOT}/styles/a.css:2', f'{ROOT}/styles/b.css:3']) + + def test_a_nested_rule_does_not_move_a_declaration_to_its_selector(self): + outer = '/* !important: r */\n.a {\n .b { color: red }\n top: 0 !important;\n}\n' + inner = '.a {\n /* !important: r */\n .b { color: red }\n top: 0 !important;\n}\n' + self.assertEqual(self.check({'styles/a.css': outer}), []) + (problem,) = self.check({'styles/b.css': inner}) + self.assertIn('b.css:4:', problem) + + def test_a_quote_in_a_regex_literal_or_a_php_hash_comment_is_read_as_code_does(self): + js = "s = s.replace(/'/g, ''); el.style.cssText = 'x:1 !important'; // !important: r\n" + php = "See https://example.test

\n\n\n'}) + self.assertEqual([p.split(': !')[0] for p in found], [f'{ROOT}/Folder.page:1', f'{ROOT}/styles/a.css:1']) + + def test_no_files_to_check_fails_closed(self): + self.assertEqual(self.check({'README.md': 'x'}), [f'{ROOT}: no CSS, JS, PHP or .page files to check']) + def test_a_reason_comment_must_give_a_reason(self): self.assertEqual(len(self.check({'styles/a.css': '/* !important: */\n.a { top: 0 !important }\n'})), 1) @@ -53,7 +79,8 @@ def test_page_and_php_files_are_checked_too(self): self.assertEqual([p.split(':')[0] for p in found], [f'{ROOT}/Folder.page', f'{ROOT}/server/a.php']) def test_a_bundled_library_is_skipped(self): - self.assertEqual(self.check({'styles/include/lib.css': '.a { top: 0 !important }\n'}, bundled=['styles/include/lib.css']), []) + self.assertEqual(self.check({'styles/include/lib.css': '.a { top: 0 !important }\n', 'styles/own.css': '.b { top: 0 }\n'}, + bundled=['styles/include/lib.css']), []) if __name__ == '__main__': diff --git a/.github/scripts/php_tests.sh b/.github/scripts/php_tests.sh index 5ea8f42a..53457d56 100755 --- a/.github/scripts/php_tests.sh +++ b/.github/scripts/php_tests.sh @@ -1,27 +1,37 @@ #!/bin/bash # php -l over every plugin .php and .page file, then every .github/scripts/*_test.php, with every error level on. -# A deprecation fails like an error, so a PHP that Unraid has not shipped yet shows what FolderView3 must change. +# Every PHP process logs to one file, the endpoints the tests start included; a deprecation there fails like an error. set -u cd "$(dirname "$0")/../.." || exit 2 status=0 -errors=$(mktemp) -trap 'rm -f "$errors"' EXIT +ini=$(mktemp -d) +trap 'rm -rf "$ini"' EXIT +log=$ini/errors.log +: > "$log" +printf 'error_reporting=-1\nlog_errors=1\nerror_log=%s\n' "$log" > "$ini/zz-fv3-tests.ini" +# An empty entry keeps PHP's own scan folder; this file loads after it, in every child process too +export PHP_INI_SCAN_DIR="${PHP_INI_SCAN_DIR:-}:$ini" php -v | head -1 +php -r 'exit((error_reporting() & E_ALL) === E_ALL && ini_get("log_errors") ? 0 : 1);' || { echo 'FAILED: the error-log settings did not load'; exit 1; } + +deprecated() { # deprecated : fails the run when logged a deprecation + local seen; seen=$(grep -c 'Deprecated:' "$log") + if [ "$seen" -gt "${logged:-0}" ]; then + echo "FAILED: $1 ran into a deprecation:" + grep 'Deprecated:' "$log" | tail -n "$((seen - ${logged:-0}))" + status=1 + fi + logged=$seen +} while IFS= read -r -d '' f; do - if ! out=$(php -d error_reporting=-1 -l "$f" 2>&1) || grep -q 'Deprecated:' <<<"$out"; then - echo "$out" - status=1 - fi + php -l "$f" >/dev/null 2>&1 || { php -l "$f"; status=1; } done < <(find src \( -name '*.php' -o -name '*.page' \) -print0) +deprecated 'php -l' for t in .github/scripts/*_test.php; do - echo "== $t" - php -d error_reporting=-1 -d display_errors=stderr -d log_errors=0 "$t" 2>"$errors" || status=1 - cat "$errors" >&2 - if grep -q 'Deprecated:' "$errors"; then - echo "FAILED: $t ran into a deprecation" - status=1 - fi + echo "== $t" + php -d display_errors=stderr "$t" || status=1 + deprecated "$t" done exit $status diff --git a/.github/scripts/vendor.py b/.github/scripts/vendor.py index ef2e1f91..0437defb 100755 --- a/.github/scripts/vendor.py +++ b/.github/scripts/vendor.py @@ -95,12 +95,25 @@ def lf(data): return data if b'\0' in data[:8000] else data.replace(b'\r\n', b'\n') +def plugin_root(repo=ROOT): + """(vendor.json, the plugin folder its root names).""" + manifest = json.loads((repo / 'vendor.json').read_text()) + return manifest, (repo / manifest['root']).resolve() + + +def destination(manifest, root, rel): + """Where a bundled file lands; vendor.json may not point outside the plugin folder.""" + dest = (root / rel).resolve() + if not dest.is_relative_to(root): + raise SystemExit(f'vendor.json: {rel} is outside {manifest["root"]}') + return dest + + def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('mode', choices=('check', 'sync')) mode = parser.parse_args().mode - manifest = json.loads((ROOT / 'vendor.json').read_text()) - root = (ROOT / manifest['root']).resolve() + manifest, root = plugin_root() stale = [] for lib in manifest['libraries']: if 'npm' in lib: @@ -110,9 +123,7 @@ def main(): else: raise SystemExit(f'vendor.json: a library needs an npm or github source: {lib}') for src, data in files.items(): - dest = (root / lib['files'][src]).resolve() - if not dest.is_relative_to(root): - raise SystemExit(f'vendor.json: {lib["files"][src]} is outside {manifest["root"]}') + dest = destination(manifest, root, lib['files'][src]) data = lf(data) if dest.is_file() and dest.read_bytes() == data: continue diff --git a/.github/unraid-compat/Dockerfile b/.github/unraid-compat/Dockerfile index 232bc533..2f8f421f 100644 --- a/.github/unraid-compat/Dockerfile +++ b/.github/unraid-compat/Dockerfile @@ -1,4 +1,5 @@ -# The PHP an Unraid version ships, plus what Unraid has and this image lacks: gawk (the .plg's remove script uses RT) and xz. +# The PHP an Unraid version ships, plus what Unraid has and this image lacks: gawk (the .plg's remove script uses RT), xz +# (the package format) and wget (the installer's downloader, so a download fails on the network, not a missing tool). ARG PHP FROM php:${PHP}-cli -RUN apt-get update && apt-get install -y --no-install-recommends gawk xz-utils && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y --no-install-recommends gawk wget xz-utils && rm -rf /var/lib/apt/lists/* diff --git a/.github/unraid-compat/install_test.sh b/.github/unraid-compat/install_test.sh index 7ec80ef5..103a2c3a 100755 --- a/.github/unraid-compat/install_test.sh +++ b/.github/unraid-compat/install_test.sh @@ -2,10 +2,12 @@ # FolderView3 through a real Unraid webGUI's plugin installer: install, upgrade over the last stable, remove, failures, min. # Disposable container only, as root, with no network. Usage: install_test.sh set -u -# This replaces plugin files and system tools, so it must never touch a real server. -if [ -e /etc/unraid-version ] || [ -d /boot/config ]; then echo 'Refusing to run on an Unraid system' >&2; exit 2; fi -web=$(cd "$1" && pwd); version=$2; stable=$(cd "$3" && pwd); repo=$(pwd) +# This replaces /usr/bin/php, package tools and plugin files, so it runs only in a fresh Docker container, never on a host. +if [ ! -f /.dockerenv ] || [ -e /etc/unraid-version ] || [ -d /boot/config ]; then echo 'Refusing to run outside a fresh Docker container' >&2; exit 2; fi +version=$2; repo=$(pwd) fail() { echo "FAILED [Unraid $version]: $*"; exit 1; } +web=$(cd "$1" 2>/dev/null && pwd) && [ -f "$web/emhttp/plugins/dynamix.plugin.manager/scripts/plugin" ] || fail "no Unraid plugin installer under $1" +stable=$(cd "$3" 2>/dev/null && pwd) && [ -f "$stable/pkg_build.sh" ] || fail "no last-stable checkout with pkg_build.sh at $3" awk --version 2>/dev/null | grep -q 'GNU Awk' || fail 'awk is not gawk, as it is on Unraid: the remove script needs RT' name=folder.view3 @@ -17,22 +19,26 @@ mkdir -p "$docroot/plugins" /boot/config/plugins-error /var/log/plugins /var/log cp -R "$web/emhttp/plugins/dynamix" "$web/emhttp/plugins/dynamix.plugin.manager" "$docroot/plugins/" ln -sfn "$docroot/plugins/dynamix" "$docroot/webGui" printf 'csrf_token="compat-test-token"\n' > /var/local/emhttp/var.ini -# The hooks check every installed plugin through Unraid's php at /usr/bin/php; this container has only this one -rm -rf "$docroot/plugins/dynamix.plugin.manager/pre-hooks" "$docroot/plugins/dynamix.plugin.manager/post-hooks" +# Unraid's pre- and post-install hooks run as #!/usr/bin/php and keep their state under /tmp/plugins +mkdir -p /tmp/plugins ln -sf "$(command -v php)" /usr/bin/php plugin() { php "$docroot/plugins/dynamix.plugin.manager/scripts/plugin" "$@"; } -# Slackware's package tools; everything else is Unraid's own code +# Slackware's package tools, as they work: the record lists the package's files, and removepkg takes those and the folders +# they leave empty. Everything else is Unraid's own code. cat > /sbin/upgradepkg <<'STUB' #!/bin/bash for pkg; do :; done tar -xJf "$pkg" -C / || exit 1 -touch "/var/log/packages/$(basename "$pkg" .txz)" +tar -tJf "$pkg" > "/var/log/packages/$(basename "$pkg" .txz)" STUB cat > /sbin/removepkg <<'STUB' #!/bin/bash -rm -rf /usr/local/emhttp/plugins/folder.view3 -rm -f "/var/log/packages/$1" +record=/var/log/packages/$1 +[ -f "$record" ] || exit 1 +grep -v '/$' "$record" | while IFS= read -r f; do rm -f "/$f"; done +grep '/$' "$record" | sort -r | while IFS= read -r d; do rmdir "/$d" 2>/dev/null; done +rm -f "$record" STUB chmod +x /sbin/upgradepkg /sbin/removepkg @@ -74,6 +80,10 @@ saved_config() { # what a user has saved: folders, settings, a theme, and Unraid printf '0="folder-ZyXwVuTsRqPoNmLkJiHg"\r\n1="Debian 12"\r\n2="Windows"' > /boot/config/plugins/dynamix.vm.manager/userprefs.cfg } config_sums() { (cd /boot/config/plugins && find $name dockerMan dynamix.vm.manager -type f ! -name "$name-*.txz" ! -path "$name/version" -print0 | sort -z | xargs -0 md5sum); } +boot() { # boot : what a reboot does: RAM starts empty, and the registered manifest installs again from the flash alone + rm -rf "$live" /var/log/packages/$name-* /var/log/plugins/$name.plg + plugin install "$manifest" > "$work/$1.log" 2>&1 || { cat "$work/$1.log"; fail "$1: reinstall at boot refused"; } +} set_version "$version" # A fresh install @@ -88,12 +98,13 @@ install $new upgrade; installed $new upgrade [ ! -e "$flash/$name-$old-x86_64-1.txz" ] || fail 'upgrade: previous archive left on the flash' [ ! -e "/var/log/packages/$name-$old-x86_64-1" ] || fail 'upgrade: previous package record left' -# What a reboot does: the registered manifest installs again from the archive on the flash -rm -f /var/log/plugins/$name.plg -plugin install "$manifest" > "$work/boot.log" 2>&1 || { cat "$work/boot.log"; fail 'boot: reinstall refused'; } -installed $new boot +# A reboot after the upgrade brings back the new version from its archive +boot boot; installed $new boot +[ "$(config_sums)" = "$before" ] || fail 'boot: saved files changed' -# Removal leaves nothing, and takes only FolderView3's own entries out of Unraid's orders, line endings kept +# Removal leaves nothing, a file the package did not ship included, and takes only FolderView3's entries out of Unraid's +# orders, line endings kept +printf 'x' > "$live/not-from-the-package" plugin remove $name.plg > "$work/remove.log" 2>&1 || { cat "$work/remove.log"; fail 'remove: refused'; } [ ! -e "$live" ] && [ ! -e "$flash" ] && [ ! -e /var/log/plugins/$name.plg ] && [ ! -e "$manifest" ] || fail 'remove: files left behind' ls /var/log/packages/$name-* >/dev/null 2>&1 && fail 'remove: package record left' @@ -102,12 +113,14 @@ cmp -s /boot/config/plugins/dockerMan/userprefs.cfg <(printf '0="alpha"\n1="fold cmp -s /boot/config/plugins/dynamix.vm.manager/userprefs.cfg <(printf '0="Debian 12"\r\n1="Windows"') \ || fail "remove: VM order not as expected: $(od -c /boot/config/plugins/dynamix.vm.manager/userprefs.cfg | head -5)" -# A download that fails (no network here) leaves the running install and what the user saved +# A download that fails (no network here) leaves the running install, what the user saved, and a next boot that brings it back reset; install $old stable2; saved_config; before=$(config_sums) plugin install "$work/$new/$name.plg" > "$work/download.log" 2>&1 && fail 'download: install reported success without its package' +grep -q 'download failure' "$work/download.log" || { cat "$work/download.log"; fail 'download: refused for a reason other than the download'; } installed $old download -[ -f "$flash/$name-$old-x86_64-1.txz" ] || fail 'download: deleted the archive the next boot installs from' [ "$(config_sums)" = "$before" ] || fail 'download: saved files changed' +[ -f "$flash/$name-$old-x86_64-1.txz" ] || fail 'download: deleted the archive the next boot installs from' +boot download-boot; installed $old download-boot # A failed upgradepkg does the same reset; install $old stable3; saved_config; before=$(config_sums) @@ -116,9 +129,11 @@ mv /sbin/upgradepkg "$work/upgradepkg"; printf '#!/bin/bash\nexit 1\n' > /sbin/u plugin install "$work/$new/$name.plg" > "$work/upgradepkg.log" 2>&1; status=$? mv "$work/upgradepkg" /sbin/upgradepkg [ $status -ne 0 ] || fail 'upgradepkg: install reported success though upgradepkg failed' +grep -q "run failed: 'upgradepkg" "$work/upgradepkg.log" || { cat "$work/upgradepkg.log"; fail 'upgradepkg: refused before upgradepkg ran'; } installed $old upgradepkg -[ -f "$flash/$name-$old-x86_64-1.txz" ] || fail 'upgradepkg: deleted the archive the next boot installs from' [ "$(config_sums)" = "$before" ] || fail 'upgradepkg: saved files changed' +[ -f "$flash/$name-$old-x86_64-1.txz" ] || fail 'upgradepkg: deleted the archive the next boot installs from' +boot upgradepkg-boot; installed $old upgradepkg-boot # The installer itself refuses an Unraid below the .plg's min, and says why reset; set_version 6.12.15; cp "$work/$new/dist/$name-$new-x86_64-1.txz" "$flash/" diff --git a/.github/unraid-compat/matrix_check.py b/.github/unraid-compat/matrix_check.py new file mode 100644 index 00000000..c67c5604 --- /dev/null +++ b/.github/unraid-compat/matrix_check.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +"""ci.yml's Unraid matrix has one release row per minor from the .plg's min to the newest, and one for any newer release.""" +import pathlib +import re +import sys + +ROW = re.compile(r"- \{unraid: '([^']+)', php: '([^']+)'(?:, row: '([^']+)')?\}") +RELEASE = re.compile(r'(\d+)\.(\d+)\.\d+') + + +def problems(ci, plg): + floor = re.search(r']*\bmin="(\d+)\.(\d+)\.\d+"', plg) + if not floor: + return ['folder.view3.plg names no min="x.y.z"'] + floor = (int(floor[1]), int(floor[2])) + rows = ROW.findall(ci) + releases = [version for version, _, row in rows if not row] + tags = [version for version, _, row in rows if row == 'newest tag'] + out = [] if len(tags) == 1 else [f"ci.yml needs exactly one 'newest tag' row, not {len(tags)}"] + minors = {} + for version in releases: + m = RELEASE.fullmatch(version) + if not m: + out.append(f'release row {version} is not a release version x.y.z') + else: + minors.setdefault((int(m[1]), int(m[2])), []).append(version) + if not minors: + return out + ['ci.yml has no Unraid release rows'] + for (major, minor), versions in sorted(minors.items()): + if len(versions) > 1: + out.append(f'Unraid {major}.{minor} has {len(versions)} release rows: {", ".join(versions)}') + if (major, minor) < floor: + out.append(f'release row {versions[0]} is below the .plg\'s min {floor[0]}.{floor[1]}') + for major in sorted({major for major, _ in minors if major >= floor[0]}): + first = floor[1] if major == floor[0] else 0 + missing = [f'{major}.{n}' for n in range(first, max(n for m, n in minors if m == major)) if (major, n) not in minors] + out += [f'no release row for Unraid {v}, between the .plg\'s min and the newest row' for v in missing] + # The 'newest tag' row runs only betas; a release it reaches needs a row of its own and the PHP that release ships + out += [f'Unraid {tag} is out: give it a release row with the PHP its release notes name' for tag in tags + if RELEASE.fullmatch(tag) and tag not in releases] + return out + + +if __name__ == '__main__': + repo = pathlib.Path(__file__).resolve().parents[2] + found = problems((repo / '.github/workflows/ci.yml').read_text(encoding='utf-8'), (repo / 'folder.view3.plg').read_text(encoding='utf-8')) + print('\n'.join(found) or 'The Unraid matrix covers every minor from min to the newest release') + sys.exit(1 if found else 0) diff --git a/.github/unraid-compat/matrix_check_test.py b/.github/unraid-compat/matrix_check_test.py new file mode 100644 index 00000000..cdd6f6b1 --- /dev/null +++ b/.github/unraid-compat/matrix_check_test.py @@ -0,0 +1,35 @@ +import unittest + +import matrix_check + +PLG = '' + + +def ci(*rows, tag="'7.4.0', php: '8.4'"): + lines = [f" - {{unraid: '{v}', php: '8.4'}}" for v in rows] + return '\n'.join(lines + [f" - {{unraid: {tag}, row: 'newest tag'}}"]) + + +class MatrixCheckTest(unittest.TestCase): + def test_one_row_per_minor_up_to_the_newest_passes_with_a_beta_or_that_release_as_newest_tag(self): + self.assertEqual(matrix_check.problems(ci('7.0.1', '7.1.4', '7.2.7', '7.3.5', '7.4.0'), PLG), []) + self.assertEqual(matrix_check.problems(ci('7.0.1', '7.1.4', '7.2.7', '7.3.5', '7.4.0', tag="'7.5.0-beta.1', php: '8.4'"), PLG), []) + + def test_a_release_the_newest_tag_reached_needs_its_own_row(self): + self.assertEqual(matrix_check.problems(ci('7.0.1', '7.1.4', '7.2.7', '7.3.5', '7.4.0', tag="'7.5.0', php: '8.4'"), PLG), + ['Unraid 7.5.0 is out: give it a release row with the PHP its release notes name']) + + def test_a_skipped_minor_a_second_row_for_one_and_a_row_below_min_are_named(self): + self.assertEqual(matrix_check.problems(ci('6.12.15', '7.0.1', '7.0.0', '7.2.7', '7.3.5', '7.4.0'), PLG), [ + 'release row 6.12.15 is below the .plg\'s min 7.0', + 'Unraid 7.0 has 2 release rows: 7.0.1, 7.0.0', + 'no release row for Unraid 7.1, between the .plg\'s min and the newest row']) + + def test_a_missing_min_newest_tag_or_release_row_fails_closed(self): + self.assertEqual(matrix_check.problems(ci('7.0.1'), ''), ['folder.view3.plg names no min="x.y.z"']) + self.assertEqual(matrix_check.problems("- {unraid: '7.0.1', php: '8.3'}", PLG), ["ci.yml needs exactly one 'newest tag' row, not 0"]) + self.assertEqual(matrix_check.problems(ci(), PLG), ['ci.yml has no Unraid release rows']) + + +if __name__ == '__main__': + unittest.main() diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 955dd96a..1199e8eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,12 @@ jobs: python3 -B -m unittest important_check_test python3 -B important_check.py + - name: The Unraid matrix has a row for every minor up to the newest release + working-directory: .github/unraid-compat + run: | + python3 -B -m unittest matrix_check_test + python3 -B matrix_check.py + - name: Variables tab tests run: node .github/scripts/variables_tab_test.js @@ -156,23 +162,33 @@ jobs: strategy: fail-fast: false matrix: - # The newest release of each minor from the .plg's min, on the PHP that release ships + # One release row per minor from the .plg's min, on the PHP its release notes name; Renovate moves each to its newest + # patch, and the 'newest tag' row to any newer tag. matrix_check.py fails when a release has no row of its own. include: - {unraid: '7.0.1', php: '8.3'} - {unraid: '7.1.4', php: '8.3'} - - {unraid: '7.2.7', php: '8.3'} + - {unraid: '7.2.9', php: '8.4'} - {unraid: '7.3.5', php: '8.4'} - # renovate: newest Unraid - {unraid: '7.4.0', php: '8.4'} - # renovate: newest Unraid tag, betas included; a beta on a newer PHP needs its php raised by hand + # Runs only while it names a beta or release candidate; one on a newer PHP needs its php raised by hand - {unraid: '7.4.0', php: '8.4', row: 'newest tag'} + env: + RUNS: ${{ !matrix.row || contains(matrix.unraid, '-') }} steps: + - name: Nothing newer than the release rows + if: env.RUNS != 'true' + env: + UNRAID_VERSION: ${{ matrix.unraid }} + run: echo "::notice::Unraid $UNRAID_VERSION is a release, so its own release row tests it" + - name: Checkout + if: env.RUNS == 'true' uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: persist-credentials: false - name: Checkout the last stable release + if: env.RUNS == 'true' uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: persist-credentials: false @@ -180,6 +196,7 @@ jobs: path: .stable - name: Checkout the Unraid webGUI at this version + if: env.RUNS == 'true' uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 with: persist-credentials: false @@ -191,6 +208,7 @@ jobs: emhttp/plugins/dynamix.plugin.manager - name: Install, upgrade, remove and failures through Unraid's own plugin installer + if: env.RUNS == 'true' env: PHP_VERSION: ${{ matrix.php }} UNRAID_VERSION: ${{ matrix.unraid }} diff --git a/renovate.json b/renovate.json index c365eefe..ab655f85 100644 --- a/renovate.json +++ b/renovate.json @@ -6,19 +6,19 @@ "customManagers": [ { "customType": "regex", - "description": "The newest stable Unraid the CI matrix installs FolderView3 on, so a new release is tested before users reach it.", + "description": "Each release row of the CI matrix's Unraid list, moved to the newest patch of its minor.", "managerFilePatterns": ["/^\\.github/workflows/ci\\.yml$/"], - "matchStrings": ["# renovate: newest Unraid\\s+- \\{unraid: '(?[^']+)'"], + "matchStrings": ["- \\{unraid: '(?[^']+)', php: '[^']+'\\}"], "datasourceTemplate": "github-tags", "depNameTemplate": "unraid/webgui", - "depTypeTemplate": "unraid-stable", + "depTypeTemplate": "unraid-release", "versioningTemplate": "semver" }, { "customType": "regex", - "description": "The newest Unraid tag of any kind, betas and release candidates included, for the matrix's 'newest tag' row.", + "description": "The matrix's 'newest tag' row: the newest Unraid tag of any kind, betas and release candidates included.", "managerFilePatterns": ["/^\\.github/workflows/ci\\.yml$/"], - "matchStrings": ["# renovate: newest Unraid tag[^\\n]*\\s+- \\{unraid: '(?[^']+)'"], + "matchStrings": ["- \\{unraid: '(?[^']+)', php: '[^']+', row: 'newest tag'\\}"], "datasourceTemplate": "github-tags", "depNameTemplate": "unraid/webgui", "depTypeTemplate": "unraid-newest-tag", @@ -58,16 +58,28 @@ ], "packageRules": [ { - "description": "Unraid releases only: webgui also carries 2014.x date tags, which sort above every 7.x.", - "matchDepTypes": ["unraid-stable"], + "description": "Release rows take Unraid releases only (webgui also carries 2014.x date tags, which sort above every 7.x), within their minor.", + "matchDepTypes": ["unraid-release"], "allowedVersions": "/^\\d{1,2}\\.\\d+\\.\\d+$/" }, + { + "description": "A new minor gets a row of its own by hand, so a release row never leaves its minor.", + "matchDepTypes": ["unraid-release"], + "matchUpdateTypes": ["major", "minor"], + "enabled": false + }, { "description": "Unraid releases and their betas and release candidates, still without the date tags.", "matchDepTypes": ["unraid-newest-tag"], "allowedVersions": "/^\\d{1,2}\\.\\d+\\.\\d+(-[0-9A-Za-z.]+)?$/", "ignoreUnstable": false }, + { + "description": "One Unraid PR, merged by hand: a patch can change the PHP a release ships (7.2.8 did), so each row's php is checked against the release notes.", + "matchDepNames": ["unraid/webgui"], + "groupName": "Unraid versions", + "automerge": false + }, { "description": "Bundled libraries ship to users, so their updates are fix(deps).", "matchDepTypes": ["bundled"], From 967b87f9f5f9c928ab9684635249a911b353beb8 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 17:31:55 +0800 Subject: [PATCH 22/72] ci: a .page's CSS is no JS regex, recovery boots check saved files, and the matrix check skips commented-out rows and needs the min's own major --- .github/scripts/important_check.py | 8 +++++++- .github/scripts/important_check_test.py | 6 ++++++ .github/unraid-compat/install_test.sh | 2 ++ .github/unraid-compat/matrix_check.py | 9 ++++++--- .github/unraid-compat/matrix_check_test.py | 8 ++++++++ 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/.github/scripts/important_check.py b/.github/scripts/important_check.py index 12e4e01d..b5bcb9f9 100644 --- a/.github/scripts/important_check.py +++ b/.github/scripts/important_check.py @@ -35,10 +35,16 @@ def _regex_end(text, i): return None +def _in_script(spans, i): + return any(start <= i < end for start, end in spans) + + def scan(text, kind): """(code, comments): the text with comments, CSS strings and JS regexes blanked, and [(start, end, comment text)].""" code, comments, i, n = list(text), [], 0, len(text) script = kind != 'css' + # A .page holds CSS and HTML too: only its ', text, re.I | re.S)] if kind == 'page' else [] while i < n: c, two = text[i], text[i:i + 2] html = kind == 'page' and text.startswith('\n\n'}) self.assertEqual([p.split(': !')[0] for p in found], [f'{ROOT}/Folder.page:1', f'{ROOT}/styles/a.css:1']) + def test_a_url_in_page_css_is_no_regex_but_one_in_its_script_is(self): + page = ('\n' + "\n") + (problem,) = self.check({'Folder.page': page}) + self.assertIn('Folder.page:1:', problem) + def test_no_files_to_check_fails_closed(self): self.assertEqual(self.check({'README.md': 'x'}), [f'{ROOT}: no CSS, JS, PHP or .page files to check']) diff --git a/.github/unraid-compat/install_test.sh b/.github/unraid-compat/install_test.sh index 103a2c3a..2612bb54 100755 --- a/.github/unraid-compat/install_test.sh +++ b/.github/unraid-compat/install_test.sh @@ -121,6 +121,7 @@ installed $old download [ "$(config_sums)" = "$before" ] || fail 'download: saved files changed' [ -f "$flash/$name-$old-x86_64-1.txz" ] || fail 'download: deleted the archive the next boot installs from' boot download-boot; installed $old download-boot +[ "$(config_sums)" = "$before" ] || fail 'download-boot: saved files changed' # A failed upgradepkg does the same reset; install $old stable3; saved_config; before=$(config_sums) @@ -134,6 +135,7 @@ installed $old upgradepkg [ "$(config_sums)" = "$before" ] || fail 'upgradepkg: saved files changed' [ -f "$flash/$name-$old-x86_64-1.txz" ] || fail 'upgradepkg: deleted the archive the next boot installs from' boot upgradepkg-boot; installed $old upgradepkg-boot +[ "$(config_sums)" = "$before" ] || fail 'upgradepkg-boot: saved files changed' # The installer itself refuses an Unraid below the .plg's min, and says why reset; set_version 6.12.15; cp "$work/$new/dist/$name-$new-x86_64-1.txz" "$flash/" diff --git a/.github/unraid-compat/matrix_check.py b/.github/unraid-compat/matrix_check.py index c67c5604..23c1b1e0 100644 --- a/.github/unraid-compat/matrix_check.py +++ b/.github/unraid-compat/matrix_check.py @@ -4,7 +4,8 @@ import re import sys -ROW = re.compile(r"- \{unraid: '([^']+)', php: '([^']+)'(?:, row: '([^']+)')?\}") +# Only a row that YAML reads: first on its line, so a commented-out row is not counted as tested +ROW = re.compile(r"^[ \t]*- \{unraid: '([^']+)', php: '([^']+)'(?:, row: '([^']+)')?\}", re.M) RELEASE = re.compile(r'(\d+)\.(\d+)\.\d+') @@ -31,9 +32,11 @@ def problems(ci, plg): out.append(f'Unraid {major}.{minor} has {len(versions)} release rows: {", ".join(versions)}') if (major, minor) < floor: out.append(f'release row {versions[0]} is below the .plg\'s min {floor[0]}.{floor[1]}') - for major in sorted({major for major, _ in minors if major >= floor[0]}): + # From the min's own minor: a major with no rows at all still needs its first minor + for major in range(floor[0], max(minors)[0] + 1): first = floor[1] if major == floor[0] else 0 - missing = [f'{major}.{n}' for n in range(first, max(n for m, n in minors if m == major)) if (major, n) not in minors] + present = [n for m, n in minors if m == major] + missing = [f'{major}.{n}' for n in range(first, max(present, default=first + 1)) if n not in present] out += [f'no release row for Unraid {v}, between the .plg\'s min and the newest row' for v in missing] # The 'newest tag' row runs only betas; a release it reaches needs a row of its own and the PHP that release ships out += [f'Unraid {tag} is out: give it a release row with the PHP its release notes name' for tag in tags diff --git a/.github/unraid-compat/matrix_check_test.py b/.github/unraid-compat/matrix_check_test.py index cdd6f6b1..5f63c9f6 100644 --- a/.github/unraid-compat/matrix_check_test.py +++ b/.github/unraid-compat/matrix_check_test.py @@ -25,6 +25,14 @@ def test_a_skipped_minor_a_second_row_for_one_and_a_row_below_min_are_named(self 'Unraid 7.0 has 2 release rows: 7.0.1, 7.0.0', 'no release row for Unraid 7.1, between the .plg\'s min and the newest row']) + def test_a_commented_out_row_is_not_tested_so_not_counted(self): + text = ci('7.0.1', '7.1.4', '7.3.5', '7.4.0').replace(" - {unraid: '7.3.5'", " # - {unraid: '7.2.9', php: '8.4'}\n - {unraid: '7.3.5'") + self.assertEqual(matrix_check.problems(text, PLG), ["no release row for Unraid 7.2, between the .plg's min and the newest row"]) + + def test_the_mins_own_major_needs_rows_when_only_a_later_major_has_them(self): + self.assertEqual(matrix_check.problems(ci('8.0.0', tag="'8.0.0', php: '8.4'"), PLG), + ["no release row for Unraid 7.0, between the .plg's min and the newest row"]) + def test_a_missing_min_newest_tag_or_release_row_fails_closed(self): self.assertEqual(matrix_check.problems(ci('7.0.1'), ''), ['folder.view3.plg names no min="x.y.z"']) self.assertEqual(matrix_check.problems("- {unraid: '7.0.1', php: '8.3'}", PLG), ["ci.yml needs exactly one 'newest tag' row, not 0"]) From 2522f0a3a4766c794514061c95fbd3f9be8b05e0 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 17:33:04 +0800 Subject: [PATCH 23/72] ci: in a .page, // starts a comment only in its script and PHP blocks, so url(//cdn) in CSS hides nothing --- .github/scripts/important_check.py | 6 ++++-- .github/scripts/important_check_test.py | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/scripts/important_check.py b/.github/scripts/important_check.py index b5bcb9f9..489c0fd1 100644 --- a/.github/scripts/important_check.py +++ b/.github/scripts/important_check.py @@ -43,13 +43,15 @@ def scan(text, kind): """(code, comments): the text with comments, CSS strings and JS regexes blanked, and [(start, end, comment text)].""" code, comments, i, n = list(text), [], 0, len(text) script = kind != 'css' - # A .page holds CSS and HTML too: only its ', text, re.I | re.S)] if kind == 'page' else [] + slashes = [(0, n)] if kind in ('js', 'php') else js + [m.span(1) for m in re.finditer(r'<\?(.*?)(?:\?>|\Z)', text, re.S)] if kind == 'page' else [] while i < n: c, two = text[i], text[i:i + 2] html = kind == 'page' and text.startswith('' if html else '\n' found = text.find(close, i + 2) end = n if found == -1 else found + (0 if close == '\n' else len(close)) diff --git a/.github/scripts/important_check_test.py b/.github/scripts/important_check_test.py index 7c876c17..ad451f49 100644 --- a/.github/scripts/important_check_test.py +++ b/.github/scripts/important_check_test.py @@ -63,6 +63,11 @@ def test_a_url_in_page_css_is_no_regex_but_one_in_its_script_is(self): (problem,) = self.check({'Folder.page': page}) self.assertIn('Folder.page:1:', problem) + def test_a_protocol_relative_url_in_page_css_is_no_comment_but_one_in_its_php_is(self): + page = '\n"; ?>\n' + (problem,) = self.check({'Folder.page': page}) + self.assertIn('Folder.page:1:', problem) + def test_no_files_to_check_fails_closed(self): self.assertEqual(self.check({'README.md': 'x'}), [f'{ROOT}: no CSS, JS, PHP or .page files to check']) From b16d60a2dc0628852c2028a6462fb7506ba43cd4 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 10:48:59 +0000 Subject: [PATCH 24/72] chore(beta): release changelog Release-Synced: 4a8472bd0b08a831c1d086b3caf5879885f40807 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 986a6f98..4f64ad3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache if the page doesn't display correctly — before submitting a debug .json. +## Unreleased + +- fix: a failed update no longer deletes the package archive the installed version boots from + ## 2026.11.14.2 (beta) - Folder actions that Unraid refuses now show its reason instead of raw JSON From eaf0fad0825d785d5e2ff738837503d4713fec8e Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 18:50:52 +0800 Subject: [PATCH 25/72] docs: beta release notes Release-Synced: 4a8472bd0b08a831c1d086b3caf5879885f40807 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f64ad3a..208b8260 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache ## Unreleased -- fix: a failed update no longer deletes the package archive the installed version boots from +- A failed update no longer deletes the package the installed version reinstalls from at boot ## 2026.11.14.2 (beta) From 6129a29cf91183c08bf2597d144581c70d7fc11f Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 18:54:26 +0800 Subject: [PATCH 26/72] chore(release): v2026.11.14.3 [skip ci] --- CHANGELOG.md | 2 +- folder.view3.plg | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 208b8260..e02dacbb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache if the page doesn't display correctly — before submitting a debug .json. -## Unreleased +## 2026.11.14.3 (beta) - A failed update no longer deletes the package the installed version reinstalls from at boot diff --git a/folder.view3.plg b/folder.view3.plg index b907aafb..9e9dddcb 100644 --- a/folder.view3.plg +++ b/folder.view3.plg @@ -6,8 +6,8 @@ - - + + ]> @@ -16,6 +16,9 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache if the page doesn't display correctly — before submitting a debug .json. +###2026.11.14.3 +- A failed update no longer deletes the package the installed version reinstalls from at boot + ###2026.11.14.2 - Folder actions that Unraid refuses now show its reason instead of raw JSON From 57eb7f39da0617c0daee17f74f40e6081ca859da Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 19:39:03 +0800 Subject: [PATCH 27/72] ci: FV3's endpoints and pages through each Unraid version's real webGUI fake_unraid.sh serves one webGUI tag with php -S, Docker and libvirt faked at the system boundary from fixtures; pages_test.php checks Unraid's lists, FV3's reads and writes behind Unraid's CSRF check, and FV3's pages in 4 themes with every file they link. lib.sh holds what install_test.sh and fake_unraid.sh share. --- .coderabbit.yaml | 13 +- .github/unraid-compat/Dockerfile | 6 +- .github/unraid-compat/fake/docker.php | 92 ++++++++++ .github/unraid-compat/fake/libvirt.php | 128 ++++++++++++++ .github/unraid-compat/fake/prepend.php | 5 + .github/unraid-compat/fake/router.php | 19 +++ .github/unraid-compat/fake_unraid.sh | 81 +++++++++ .github/unraid-compat/fixtures/docker.json | 25 +++ .github/unraid-compat/fixtures/vms.json | 28 +++ .github/unraid-compat/install_test.sh | 22 +-- .github/unraid-compat/lib.sh | 22 +++ .github/unraid-compat/pages_test.php | 187 +++++++++++++++++++++ .github/unraid-compat/pages_test.sh | 6 + .github/workflows/ci.yml | 10 +- 14 files changed, 619 insertions(+), 25 deletions(-) create mode 100644 .github/unraid-compat/fake/docker.php create mode 100644 .github/unraid-compat/fake/libvirt.php create mode 100644 .github/unraid-compat/fake/prepend.php create mode 100644 .github/unraid-compat/fake/router.php create mode 100644 .github/unraid-compat/fake_unraid.sh create mode 100644 .github/unraid-compat/fixtures/docker.json create mode 100644 .github/unraid-compat/fixtures/vms.json create mode 100644 .github/unraid-compat/lib.sh create mode 100644 .github/unraid-compat/pages_test.php create mode 100644 .github/unraid-compat/pages_test.sh diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 65ac2287..aedcd2e8 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -211,9 +211,16 @@ reviews: The Unraid compatibility matrix; CI only, nothing here ships. - install_test.sh puts the .plg through each Unraid version's own plugin installer, hooks included, in a fresh Docker container with - no network; it must refuse to run anywhere else. Only Slackware's - upgradepkg and removepkg are stubbed, keeping their file-list - records: flag any other stand-in for Unraid's code. + no network; it must refuse to run anywhere else (lib.sh's guard). + Only Slackware's upgradepkg and removepkg are stubbed, keeping their + file-list records: flag any other stand-in for Unraid's code. + - fake_unraid.sh serves one Unraid version's real webGUI with php -S + and pages_test.php drives FV3 through it. Stand-ins are the system + boundary only: fake/docker.php (dockerd's socket and the docker CLI), + fake/libvirt.php (the php-libvirt extension) and the Connect plugin's + ServerState, which the webGUI repo lacks. A call they do not answer + is logged as UNKNOWN and fails the run: flag an answer that hides + one, and any other stand-in for Unraid's code. - matrix_check.py keeps ci.yml's Unraid rows at one per minor from the .plg's min to the newest release; Renovate only moves rows. - Each step asserts what the user is left with (live files, the diff --git a/.github/unraid-compat/Dockerfile b/.github/unraid-compat/Dockerfile index 2f8f421f..935ad012 100644 --- a/.github/unraid-compat/Dockerfile +++ b/.github/unraid-compat/Dockerfile @@ -1,5 +1,7 @@ # The PHP an Unraid version ships, plus what Unraid has and this image lacks: gawk (the .plg's remove script uses RT), xz -# (the package format) and wget (the installer's downloader, so a download fails on the network, not a missing tool). +# (the package format), procps (Unraid's pages test for running services with pgrep) and wget (the installer's downloader, +# so a download fails on the network, not a missing tool). Unraid's /bin/sh is bash: its exec() strings use &>. ARG PHP FROM php:${PHP}-cli -RUN apt-get update && apt-get install -y --no-install-recommends gawk wget xz-utils && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y --no-install-recommends gawk procps wget xz-utils && rm -rf /var/lib/apt/lists/* \ + && ln -sf bash /bin/sh diff --git a/.github/unraid-compat/fake/docker.php b/.github/unraid-compat/fake/docker.php new file mode 100644 index 00000000..6804d30a --- /dev/null +++ b/.github/unraid-compat/fake/docker.php @@ -0,0 +1,92 @@ +` stands in for the docker +// CLI. Both read fixtures/docker.json (Docker Engine API answers captured from throwaway containers); a request this file +// does not know is logged as UNKNOWN and refused, so a new call by Unraid or FV3 shows up in the log. +$d = json_decode((string)@file_get_contents(__DIR__ . '/../fixtures/docker.json'), true); +if (!is_array($d)) { fwrite(STDERR, "fixtures/docker.json is unreadable\n"); exit(2); } + +function fv3d_log(string $line): void { file_put_contents('/var/log/fv3-fakes.log', "docker $line\n", FILE_APPEND | LOCK_EX); } + +function fv3d_container(array $d, string $ref): ?array { + foreach ($d['inspect'] as $ct) { + if (ltrim($ct['Name'], '/') === ltrim($ref, '/') || (strlen($ref) >= 12 && str_starts_with($ct['Id'], $ref))) return $ct; + } + return null; +} + +function fv3d_running(array $d): array { return array_values(array_filter($d['containers'], fn($c) => $c['State'] === 'running')); } + +function fv3d_answer(array $d, string $method, string $target): array { + $path = (string)parse_url($target, PHP_URL_PATH); + parse_str((string)parse_url($target, PHP_URL_QUERY), $query); + if ($method !== 'GET') return [null, null]; + if ($path === '/containers/json') return [200, ($query['all'] ?? '0') !== '0' ? $d['containers'] : fv3d_running($d)]; + if (preg_match('#^/containers/([^/]+)/json$#', $path, $m)) { + $ct = fv3d_container($d, $m[1]); + return $ct ? [200, $ct] : [404, ['message' => "No such container: {$m[1]}"]]; + } + if ($path === '/images/json') return [200, $d['images']]; + if (preg_match('#^/images/(.+)/json$#', $path, $m)) { + foreach ($d['image_inspect'] as $id => $img) { + if ($m[1] === $id || in_array($m[1], $img['RepoTags'] ?? [], true)) return [200, $img]; + } + return [404, ['message' => "No such image: {$m[1]}"]]; + } + return [null, null]; +} + +// The docker CLI lines Unraid and FV3 run, answered in the CLI's own output format +function fv3d_cli(array $d, array $args): ?array { + $format = null; + foreach ($args as $i => $a) if (str_starts_with($a, '--format=')) { $format = substr($a, 9); unset($args[$i]); } + $line = implode(' ', $args); + if ($line === 'network ls' && $format === '{{.Name}}={{.Driver}}') return array_map(fn($n) => "{$n['Name']}={$n['Driver']}", $d['networks']); + if ($line === 'ps -q --no-trunc') return array_column(fv3d_running($d), 'Id'); + if (preg_match('/^ps --filter label=(\S+) --format \{\{\.Names\}\}$/', $line, $m)) { + return array_map(fn($c) => ltrim($c['Names'][0], '/'), array_values(array_filter(fv3d_running($d), fn($c) => isset($c['Labels'][$m[1]])))); + } + if (str_starts_with($line, 'stats --no-stream') && $format === '{{.ID}};{{.CPUPerc}};{{.MemUsage}}') { + return array_map(fn($c) => substr($c['Id'], 0, 12) . ';0.50%;12.5MiB / 7.7GiB', fv3d_running($d)); + } + if (preg_match('/^inspect (\S+)$/', $line, $m) && ($ct = fv3d_container($d, $m[1]))) { + if ($format === '{{.Name}}') return [$ct['Name']]; + if (preg_match('/^\{\{range \.NetworkSettings\.Networks\}\}\{\{\.(IPAddress|GlobalIPv6Address)\}\} \{\{end\}\}$/', (string)$format, $f)) { + return [implode('', array_map(fn($n) => ($n[$f[1]] ?? '') . ' ', $ct['NetworkSettings']['Networks']))]; + } + } + return null; +} + +if (($argv[1] ?? '') === 'cli') { + $args = array_slice($argv, 2); + $out = fv3d_cli($d, $args); + fv3d_log(($out === null ? 'UNKNOWN ' : '') . 'cli ' . implode(' ', $args)); + if ($out === null) exit(1); + echo $out ? implode("\n", $out) . "\n" : ''; + exit(0); +} + +if (($argv[1] ?? '') === 'serve') { + $sock = '/var/run/docker.sock'; + @unlink($sock); + $server = stream_socket_server("unix://$sock", $errno, $errstr); + if (!$server) { fwrite(STDERR, "docker.sock: $errstr\n"); exit(2); } + chmod($sock, 0666); + file_put_contents('/var/run/dockerd.pid', getmypid()); + while (true) { + $conn = @stream_socket_accept($server, -1); + if (!$conn) continue; + $request = (string)fgets($conn); + while (($line = fgets($conn)) !== false && rtrim($line) !== ''); + [$method, $target] = array_pad(explode(' ', trim($request)), 2, ''); + [$status, $body] = fv3d_answer($d, $method, $target); + fv3d_log(($status === null ? 'UNKNOWN ' : '') . "socket $method $target"); + if ($status === null) [$status, $body] = [404, ['message' => 'page not found']]; + // One line of JSON with a length, as dockerd answers: DockerClient decodes the body line by line + $json = json_encode($body, JSON_UNESCAPED_SLASHES) . "\n"; + fwrite($conn, "HTTP/1.1 $status " . ($status === 200 ? 'OK' : 'Not Found') . "\r\nContent-Type: application/json\r\nContent-Length: " . strlen($json) . "\r\nConnection: close\r\n\r\n$json"); + fclose($conn); + } +} +fwrite(STDERR, "usage: docker.php serve | cli \n"); +exit(2); diff --git a/.github/unraid-compat/fake/libvirt.php b/.github/unraid-compat/fake/libvirt.php new file mode 100644 index 00000000..a4b3fde5 --- /dev/null +++ b/.github/unraid-compat/fake/libvirt.php @@ -0,0 +1,128 @@ + $d) if (is_resource($dom) && fv3l_handle('domain', $name) === $dom) return $d; + $GLOBALS['fv3l_error'] = 'invalid domain handle'; + return null; +} + +function fv3l_lookup(string $field, $value) { + foreach (fv3l_domains() as $name => $d) if ($d[$field] === $value) return fv3l_handle('domain', $name); + $GLOBALS['fv3l_error'] = "Domain not found: no domain with matching $field '$value'"; + return false; +} + +function libvirt_connect($uri = null, $readonly = true, $credentials = []) { return fv3l_handle('connection', 'qemu:///system'); } +function libvirt_get_last_error() { return $GLOBALS['fv3l_error'] ?? null; } +function libvirt_logfile_set($filename, $maxsize = 0) { return true; } +function libvirt_connect_get_uri($conn) { return 'qemu:///system'; } +function libvirt_connect_get_hostname($conn) { return 'Tower'; } +function libvirt_list_domains($conn) { return array_keys(fv3l_domains()); } +function libvirt_list_active_domain_ids($conn) { return array_values(array_map(fn($d) => $d['id'], array_filter(fv3l_domains(), fn($d) => $d['id'] > 0))); } +function libvirt_domain_lookup_by_name($conn, $name) { return fv3l_lookup('name', (string)$name); } +function libvirt_domain_lookup_by_uuid_string($conn, $uuid) { return fv3l_lookup('uuid', (string)$uuid); } +function libvirt_domain_get_name($dom) { return fv3l_domain($dom)['name'] ?? false; } +function libvirt_domain_get_uuid_string($dom) { return fv3l_domain($dom)['uuid'] ?? false; } +function libvirt_domain_get_id($dom) { $d = fv3l_domain($dom); return $d ? $d['id'] : false; } +function libvirt_domain_is_active($dom) { $d = fv3l_domain($dom); return $d ? $d['id'] > 0 : false; } +function libvirt_domain_get_autostart($dom) { $d = fv3l_domain($dom); return $d ? (int)$d['autostart'] : false; } +function libvirt_domain_get_xml_desc($dom, $xpath = null, $flags = 0) { return fv3l_domain($dom)['xml'] ?? false; } +function libvirt_list_domain_snapshots($dom) { return fv3l_domain($dom) ? [] : false; } + +function libvirt_domain_get_info($dom) { + $d = fv3l_domain($dom); + if (!$d) return false; + $xml = simplexml_load_string($d['xml']); + return ['maxMem' => (int)$xml->memory, 'memory' => (int)$xml->currentMemory, 'state' => $d['state'], 'nrVirtCpu' => (int)$xml->vcpu, 'cpuUsed' => $d['id'] > 0 ? 12.5 : 0]; +} + +function libvirt_node_get_info($conn) { + return ['model' => 'x86_64', 'memory' => 16777216, 'cpus' => 8, 'nodes' => 1, 'sockets' => 1, 'cores' => 4, 'threads' => 2, 'mhz' => 3600]; +} + +// Each disk is a 20 GiB image at the path its XML names +function libvirt_domain_get_block_info($dom, $dev) { + $d = fv3l_domain($dom); + if (!$d) return false; + foreach (simplexml_load_string($d['xml'])->devices->disk as $disk) { + if ((string)$disk->target['dev'] !== (string)$dev) continue; + $size = 21474836480; + return ['device' => (string)$dev, 'file' => (string)$disk->source['file'], 'type' => (string)$disk->driver['type'], 'capacity' => $size, 'allocation' => $size, 'physical' => $size]; + } + $GLOBALS['fv3l_error'] = "invalid argument: no disk with target $dev"; + return false; +} + +function libvirt_domain_get_counts($conn) { + $active = count(array_filter(fv3l_domains(), fn($d) => $d['id'] > 0)); + return ['total' => count(fv3l_domains()), 'active' => $active, 'inactive' => count(fv3l_domains()) - $active]; +} + +// php-libvirt's answer: the matches' text in order, with their count under 'num' +function libvirt_domain_xml_xpath($dom, $xpath, $flags = 0) { + $d = fv3l_domain($dom); + if (!$d) return false; + $doc = new DOMDocument(); + $doc->loadXML($d['xml']); + $nodes = @(new DOMXPath($doc))->query($xpath); + if ($nodes === false) { $GLOBALS['fv3l_error'] = "invalid xpath $xpath"; return false; } + $out = ['xpath' => $xpath, 'num' => $nodes->length]; + foreach ($nodes as $i => $node) $out[$i] = $node->nodeValue; + return $out; +} + +// Every other name in Unraid's libvirt.php, libvirt_helpers.php and VMMachines.php: none has an answer here yet +foreach (['libvirt_connect_get_information', 'libvirt_connect_get_capabilities', 'libvirt_connect_get_machine_types', + 'libvirt_connect_get_domain_capabilities', 'libvirt_connect_get_all_domain_stats', 'libvirt_has_feature', + 'libvirt_list_nodedevs', 'libvirt_nodedev_get', 'libvirt_nodedev_get_xml_desc', 'libvirt_nodedev_get_information', + 'libvirt_nodedev_capabilities', 'libvirt_list_networks', 'libvirt_network_get', 'libvirt_network_get_xml_desc', 'libvirt_get_net_res', + 'libvirt_get_net_list', 'libvirt_get_net_xml', 'libvirt_domain_interface_addresses', + 'libvirt_domain_interface_stats', 'libvirt_domain_get_interface_devices', 'libvirt_domain_memory_stats', + 'libvirt_domain_get_screen_dimensions', 'libvirt_domain_qemu_agent_command', 'libvirt_domain_define_xml', 'libvirt_domain_create_xml', + 'libvirt_domain_undefine', 'libvirt_domain_update_device', 'libvirt_domain_create', 'libvirt_domain_destroy', 'libvirt_domain_shutdown', + 'libvirt_domain_reboot', 'libvirt_domain_suspend', 'libvirt_domain_resume', 'libvirt_domain_managedsave', 'libvirt_domain_set_autostart', + 'libvirt_domain_change_boot_devices', 'libvirt_domain_disk_remove', 'libvirt_domain_send_keys', 'libvirt_domain_send_pointer_event', + 'libvirt_domain_snapshot_create', 'libvirt_domain_snapshot_delete', 'libvirt_domain_snapshot_get_xml', 'libvirt_domain_snapshot_lookup_by_name', + 'libvirt_domain_snapshot_revert', 'libvirt_storagevolume_create_xml'] as $fv3lName) { + eval("function $fv3lName(...\$args) { fv3l_log('UNKNOWN $fv3lName'); \$GLOBALS['fv3l_error'] = 'not in the fake'; return false; }"); +} +unset($fv3lName); diff --git a/.github/unraid-compat/fake/prepend.php b/.github/unraid-compat/fake/prepend.php new file mode 100644 index 00000000..b45b0259 --- /dev/null +++ b/.github/unraid-compat/fake/prepend.php @@ -0,0 +1,5 @@ + +set -u +version=$2; repo=$(pwd); here=$repo/.github/unraid-compat +. "$here/lib.sh" +fail() { echo "FAILED [Unraid $version]: $*"; exit 1; } +fv3_docroot "$1" || fail "no Unraid webGUI under $1" + +# FV3 as upgradepkg leaves it, and the config folder its .plg makes +fv3_build "$repo" 2099.01.01 beta || fail 'package build' +tar -xJf "$work/2099.01.01/dist/$name-2099.01.01-x86_64-1.txz" -C / || fail 'package unpack' +mkdir -p "$flash/styles" "$flash/scripts" && printf '2099.01.01' > "$flash/version" + +# Unraid's own state, as emhttp writes it with the array started +printf 'version="%s"\n' "$version" > /etc/unraid-version +cat >> /var/local/emhttp/var.ini < /var/local/emhttp/network.ini +printf 'DOCKER_ENABLED="yes"\n' > /boot/config/docker.cfg +# DEBUG keeps PHP warnings on: without it Unraid's libvirt_helpers.php, which FV3 loads, turns error reporting off +printf 'SERVICE="enable"\nDEBUG="yes"\n' > /boot/config/domain.cfg +# The OS image adds the Connect plugin, which the webGUI repo lacks from 7.2 on; 7.4's header requires its state class +if [ ! -f $docroot/plugins/dynamix.my.servers/include/state.php ]; then + mkdir -p $docroot/plugins/dynamix.my.servers/include + printf ' $docroot/plugins/dynamix.my.servers/include/state.php + : > $docroot/plugins/dynamix.my.servers/include/myservers1.php +fi +ln -sf $docroot/plugins/dynamix.plugin.manager/scripts/plugin /usr/local/sbin/plugin + +# A saved setup: Media holds app-a by hand and app-b by its label, Tools takes tool-c by regex, app-d is loose; Lab holds a VM +mkdir -p /boot/config/plugins/dockerMan/templates-user /boot/config/plugins/dynamix.vm.manager /var/lib/docker +cat > "$flash/docker.json" <<'EOF' +{"MediaAbCdEfGhIjKlMnO":{"name":"Media","icon":"","regex":"","containers":["app-a"],"settings":{"preview":1},"actions":[]},"ToolsPqRsTuVwXyZaBcD":{"name":"Tools","icon":"","regex":"^tool-","containers":[],"settings":{"preview":1},"actions":[]}} +EOF +cat > "$flash/vm.json" <<'EOF' +{"LabFoldAbCdEfGhIjKlM":{"name":"Lab","icon":"","regex":"","containers":["Debian 12"],"settings":{"preview":1},"actions":[]}} +EOF +printf '0="folder-MediaAbCdEfGhIjKlMnO"\n1="app-a"\n2="app-b"\n3="folder-ToolsPqRsTuVwXyZaBcD"\n4="tool-c"\n5="app-d"\n' > /boot/config/plugins/dockerMan/userprefs.cfg +printf '0="folder-LabFoldAbCdEfGhIjKlM"\n1="Debian 12"\n2="Home Assistant"\n3="Windows 11"\n' > /boot/config/plugins/dynamix.vm.manager/userprefs.cfg +printf 'app-a\napp-d 10\n' > /var/lib/docker/unraid-autostart +cat > /boot/config/plugins/dockerMan/templates-user/my-app-a.xml <<'EOF' + + + app-a + alpine:3.20 + bridge + sh + http://[IP]:[PORT:8080]/ + 18080 + +EOF + +# Every PHP process starts as Unraid's php.ini has it: short tags, the prepend, errors to a log and never into a page +cat > "$PHP_INI_DIR/conf.d/zz-fake-unraid.ini" < /var/log/phplog; : > /var/log/fv3-fakes.log + +# Docker and libvirtd under their own names, so Unraid's pgrep() and /proc/ checks find them running +printf '#!/bin/sh\nexec php %s/fake/docker.php cli "$@"\n' "$here" > /usr/local/bin/docker && chmod +x /usr/local/bin/docker +ln -sf "$(command -v php)" /usr/local/sbin/dockerd; ln -sf "$(command -v sleep)" /usr/local/sbin/libvirtd +dockerd "$here/fake/docker.php" serve > /var/log/dockerd.log 2>&1 & +mkdir -p /var/run/libvirt; libvirtd infinity & echo $! > /var/run/libvirt/libvirtd.pid +php -S 127.0.0.1:80 -t $docroot "$here/fake/router.php" > /var/log/php-server.log 2>&1 & +for _ in $(seq 300); do + [ -S /var/run/docker.sock ] && curl -sf -o /dev/null http://127.0.0.1/robots.txt && exit 0 + sleep 0.1 +done +fail "the fake Unraid did not start: $(cat /var/log/dockerd.log /var/log/php-server.log)" diff --git a/.github/unraid-compat/fixtures/docker.json b/.github/unraid-compat/fixtures/docker.json new file mode 100644 index 00000000..dc4bbea0 --- /dev/null +++ b/.github/unraid-compat/fixtures/docker.json @@ -0,0 +1,25 @@ +{ + "containers": [ + {"Id":"600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd","Names":["/app-d"],"Image":"alpine:3.20","ImageID":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:aarch64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"arm64","os":"linux","variant":"v8"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"net.unraid.docker.managed":"dockerman"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"host"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"host":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"1d8356c7e2572093121c6ecc3f3aa90f115043fc120bce24df492e9046968e53","EndpointID":"94d7de5784b83c465530aac4d83eb3748b59d47c8aaf458474145d73eb8c3a61","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, + {"Id":"32b7dac6e0272111835c5192f61054626ff79f117ba024985e9e48cd089e6629","Names":["/tool-c"],"Image":"alpine:3.20","ImageID":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:aarch64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"arm64","os":"linux","variant":"v8"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"net.unraid.docker.managed":"dockerman"},"State":"created","Status":"Created","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"","EndpointID":"","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, + {"Id":"37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1","Names":["/app-b"],"Image":"alpine:3.20","ImageID":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:aarch64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"arm64","os":"linux","variant":"v8"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"folder.view3":"Media","net.unraid.docker.managed":"dockerman"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"47de28aa8e317df6a908d72b266290cc7dbc3a18a554e5269630623cd4f7fb71","EndpointID":"bd56c9e7b10762831e36c7f251099a298217e0e343ed1133bf195296107e552a","Gateway":"172.17.0.1","IPAddress":"172.17.0.3","MacAddress":"3e:b4:33:03:78:7e","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, + {"Id":"7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380","Names":["/app-a"],"Image":"alpine:3.20","ImageID":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:aarch64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"arm64","os":"linux","variant":"v8"}},"Command":"sleep 3600","Created":1794654653,"Ports":[{"IP":"0.0.0.0","PrivatePort":8080,"PublicPort":18080,"Type":"tcp"},{"IP":"::","PrivatePort":8080,"PublicPort":18080,"Type":"tcp"}],"Labels":{"net.unraid.docker.icon":"/plugins/dynamix.docker.manager/images/question.png","net.unraid.docker.managed":"dockerman","net.unraid.docker.webui":"http://[IP]:[PORT:8080]/"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"47de28aa8e317df6a908d72b266290cc7dbc3a18a554e5269630623cd4f7fb71","EndpointID":"b3f964c8ef346a2bef5b11a0f3f05fc5f9783db10a0fff31db735e8056c72e86","Gateway":"172.17.0.1","IPAddress":"172.17.0.2","MacAddress":"0e:f7:ce:c2:79:80","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]} + ], + "inspect": { + "app-a": {"Id":"7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380","Created":"2026-11-14T11:10:53.865989285Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":3201330,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:53.881644066Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ResolvConfPath":"/var/lib/docker/containers/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380/resolv.conf","HostnamePath":"/var/lib/docker/containers/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380/hostname","HostsPath":"/var/lib/docker/containers/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380/hosts","LogPath":"/var/lib/docker/containers/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380-json.log","Name":"/app-a","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{"8080/tcp":[{"HostIp":"","HostPort":"18080"}]},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"7d18800f0983","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"ExposedPorts":{"8080/tcp":{}},"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.icon":"/plugins/dynamix.docker.manager/images/question.png","net.unraid.docker.managed":"dockerman","net.unraid.docker.webui":"http://[IP]:[PORT:8080]/"}},"NetworkSettings":{"SandboxID":"e3c238cede0e60f74780079e1c2b1301e97d101a00097cff872b2704404d2884","SandboxKey":"/var/run/docker/netns/e3c238cede0e","Ports":{"8080/tcp":[{"HostIp":"0.0.0.0","HostPort":"18080"},{"HostIp":"::","HostPort":"18080"}]},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"47de28aa8e317df6a908d72b266290cc7dbc3a18a554e5269630623cd4f7fb71","EndpointID":"b3f964c8ef346a2bef5b11a0f3f05fc5f9783db10a0fff31db735e8056c72e86","Gateway":"172.17.0.1","IPAddress":"172.17.0.2","MacAddress":"0e:f7:ce:c2:79:80","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:aarch64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"arm64","os":"linux","variant":"v8"}}}, + "app-b": {"Id":"37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1","Created":"2026-11-14T11:10:54.013835226Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":3201412,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:54.04418883Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ResolvConfPath":"/var/lib/docker/containers/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1/resolv.conf","HostnamePath":"/var/lib/docker/containers/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1/hostname","HostsPath":"/var/lib/docker/containers/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1/hosts","LogPath":"/var/lib/docker/containers/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1-json.log","Name":"/app-b","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"37a78efc3169","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"folder.view3":"Media","net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"b1ca3d1f194461b8d618bc13f55509aefdd2c0a86430e9cae3c169a5c1b9229f","SandboxKey":"/var/run/docker/netns/b1ca3d1f1944","Ports":{},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"47de28aa8e317df6a908d72b266290cc7dbc3a18a554e5269630623cd4f7fb71","EndpointID":"bd56c9e7b10762831e36c7f251099a298217e0e343ed1133bf195296107e552a","Gateway":"172.17.0.1","IPAddress":"172.17.0.3","MacAddress":"3e:b4:33:03:78:7e","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:aarch64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"arm64","os":"linux","variant":"v8"}}}, + "tool-c": {"Id":"32b7dac6e0272111835c5192f61054626ff79f117ba024985e9e48cd089e6629","Created":"2026-11-14T11:10:54.108306911Z","Path":"sleep","Args":["3600"],"State":{"Status":"created","Running":false,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":0,"ExitCode":0,"Error":"","StartedAt":"0001-01-01T00:00:00Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ResolvConfPath":"","HostnamePath":"","HostsPath":"","LogPath":"","Name":"/tool-c","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":false,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"32b7dac6e027","Domainname":"","User":"","AttachStdin":false,"AttachStdout":true,"AttachStderr":true,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"","SandboxKey":"","Ports":{},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"","EndpointID":"","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:aarch64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"arm64","os":"linux","variant":"v8"}}}, + "app-d": {"Id":"600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd","Created":"2026-11-14T11:10:54.137826016Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":3201459,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:54.155919462Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ResolvConfPath":"/var/lib/docker/containers/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd/resolv.conf","HostnamePath":"/var/lib/docker/containers/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd/hostname","HostsPath":"/var/lib/docker/containers/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd/hosts","LogPath":"/var/lib/docker/containers/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd-json.log","Name":"/app-d","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"host","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"colima","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"1146429705f7841f920992f51e91d518d4e11d95924a7b0173bda4e684c7c0df","SandboxKey":"/var/run/docker/netns/default","Ports":{},"Networks":{"host":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"1d8356c7e2572093121c6ecc3f3aa90f115043fc120bce24df492e9046968e53","EndpointID":"94d7de5784b83c465530aac4d83eb3748b59d47c8aaf458474145d73eb8c3a61","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:aarch64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"arm64","os":"linux","variant":"v8"}}} + }, + "images": [ + {"Containers":4,"Created":1776383604,"Id":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","Labels":{},"ParentId":"","Descriptor":{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","size":9226},"RepoDigests":["alpine@sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc"],"RepoTags":["alpine:3.20"],"SharedSize":-1,"Size":13660215} + ], + "image_inspect": { + "sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc": {"Id":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","RepoTags":["alpine:3.20"],"RepoDigests":["alpine@sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc"],"Comment":"buildkit.dockerfile.v0","Created":"2026-04-16T23:53:24.896953537Z","Config":{"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh"],"WorkingDir":"/"},"Architecture":"arm64","Variant":"v8","Os":"linux","Size":4103199,"RootFS":{"Type":"layers","Layers":["sha256:88b4fba61c4c714a2fc173ddf7e9324a257304696830bf41ad28ecc58c11c95f"]},"Metadata":{"LastTagTime":"2026-10-30T23:32:14.282085809Z"},"Descriptor":{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","size":9226},"Identity":{"Pull":[{"Repository":"docker.io/library/alpine"}]}} + }, + "networks": [ + {"Name":"host","Driver":"host"}, + {"Name":"none","Driver":"null"}, + {"Name":"bridge","Driver":"bridge"} + ] +} diff --git a/.github/unraid-compat/fixtures/vms.json b/.github/unraid-compat/fixtures/vms.json new file mode 100644 index 00000000..a2be0356 --- /dev/null +++ b/.github/unraid-compat/fixtures/vms.json @@ -0,0 +1,28 @@ +{ + "domains": [ + { + "name": "Debian 12", + "uuid": "803bd917-84b0-490f-ba3c-5e21b4cd6f07", + "state": 1, + "id": 1, + "autostart": true, + "xml": "\n Debian 12\n 803bd917-84b0-490f-ba3c-5e21b4cd6f07\n Debian 12 lab server\n \n \n \n 2097152\n 2097152\n \n \n \n 2\n \n hvm\n \n \n \n /usr/local/sbin/qemu\n \n \n \n \n \n \n \n \n \n \n \n \n \n\n" + }, + { + "name": "Windows 11", + "uuid": "9fd1c657-7f2b-41b4-9ff3-5b42706315d5", + "state": 5, + "id": -1, + "autostart": false, + "xml": "\n Windows 11\n 9fd1c657-7f2b-41b4-9ff3-5b42706315d5\n \n \n \n \n 8388608\n 8388608\n \n \n \n 4\n \n hvm\n \n \n \n /usr/local/sbin/qemu\n \n \n \n \n \n \n \n \n \n \n \n \n \n\n" + }, + { + "name": "Home Assistant", + "uuid": "39ec878e-ce44-4414-8dd1-b8fb3e57f9b2", + "state": 3, + "id": 2, + "autostart": true, + "xml": "\n Home Assistant\n 39ec878e-ce44-4414-8dd1-b8fb3e57f9b2\n \n \n \n \n 4194304\n 4194304\n \n \n \n 3\n \n hvm\n \n \n \n /usr/local/sbin/qemu\n \n \n \n \n \n \n \n \n \n \n \n \n \n\n" + } + ] +} diff --git a/.github/unraid-compat/install_test.sh b/.github/unraid-compat/install_test.sh index 2612bb54..380b3b6e 100755 --- a/.github/unraid-compat/install_test.sh +++ b/.github/unraid-compat/install_test.sh @@ -2,26 +2,18 @@ # FolderView3 through a real Unraid webGUI's plugin installer: install, upgrade over the last stable, remove, failures, min. # Disposable container only, as root, with no network. Usage: install_test.sh set -u -# This replaces /usr/bin/php, package tools and plugin files, so it runs only in a fresh Docker container, never on a host. -if [ ! -f /.dockerenv ] || [ -e /etc/unraid-version ] || [ -d /boot/config ]; then echo 'Refusing to run outside a fresh Docker container' >&2; exit 2; fi version=$2; repo=$(pwd) +. "$repo/.github/unraid-compat/lib.sh" fail() { echo "FAILED [Unraid $version]: $*"; exit 1; } -web=$(cd "$1" 2>/dev/null && pwd) && [ -f "$web/emhttp/plugins/dynamix.plugin.manager/scripts/plugin" ] || fail "no Unraid plugin installer under $1" stable=$(cd "$3" 2>/dev/null && pwd) && [ -f "$stable/pkg_build.sh" ] || fail "no last-stable checkout with pkg_build.sh at $3" awk --version 2>/dev/null | grep -q 'GNU Awk' || fail 'awk is not gawk, as it is on Unraid: the remove script needs RT' +fv3_docroot "$1" || fail "no Unraid plugin installer under $1" -name=folder.view3 -docroot=/usr/local/emhttp -flash=/boot/config/plugins/$name live=$docroot/plugins/$name manifest=/boot/config/plugins/$name.plg -mkdir -p "$docroot/plugins" /boot/config/plugins-error /var/log/plugins /var/log/packages /var/local/emhttp -cp -R "$web/emhttp/plugins/dynamix" "$web/emhttp/plugins/dynamix.plugin.manager" "$docroot/plugins/" -ln -sfn "$docroot/plugins/dynamix" "$docroot/webGui" -printf 'csrf_token="compat-test-token"\n' > /var/local/emhttp/var.ini -# Unraid's pre- and post-install hooks run as #!/usr/bin/php and keep their state under /tmp/plugins +mkdir -p /boot/config/plugins-error /var/log/plugins /var/log/packages +# Unraid's pre- and post-install hooks keep their state under /tmp/plugins mkdir -p /tmp/plugins -ln -sf "$(command -v php)" /usr/bin/php plugin() { php "$docroot/plugins/dynamix.plugin.manager/scripts/plugin" "$@"; } # Slackware's package tools, as they work: the record lists the package's files, and removepkg takes those and the folders @@ -42,11 +34,7 @@ rm -f "$record" STUB chmod +x /sbin/upgradepkg /sbin/removepkg -work=$(mktemp -d) -build() { # build : the .plg and package as the release workflow makes them - local dir="$work/$2"; mkdir -p "$dir"; cp -R "$1/src" "$1/$name.plg" "$1/pkg_build.sh" "$dir/" - (cd "$dir" && bash pkg_build.sh --version "$2" --branch "$3" --out "$dir/dist" >/dev/null) || fail "package build of $2" -} +build() { fv3_build "$@" || fail "package build of $2"; } old=2026.01.01; new=2099.01.01 build "$stable" $old main; build "$repo" $new beta min=$(grep -o ']*min="[^"]*"' "$work/$new/$name.plg" | sed 's/.*min="//; s/"$//') diff --git a/.github/unraid-compat/lib.sh b/.github/unraid-compat/lib.sh new file mode 100644 index 00000000..f6ac976b --- /dev/null +++ b/.github/unraid-compat/lib.sh @@ -0,0 +1,22 @@ +#!/bin/bash +# Shared by install_test.sh and fake_unraid.sh. Source it from the repo root; it sets name, docroot, flash and work. +# These scripts replace system files, so they run only in a fresh Docker container, never on a host. +if [ ! -f /.dockerenv ] || [ -e /etc/unraid-version ] || [ -d /boot/config ]; then echo 'Refusing to run outside a fresh Docker container' >&2; exit 2; fi +name=folder.view3 +docroot=/usr/local/emhttp +flash=/boot/config/plugins/$name +work=$(mktemp -d) + +fv3_docroot() { # fv3_docroot : Unraid's /usr/local/emhttp from that webGUI checkout, its symlinks included + [ -f "$1/emhttp/plugins/dynamix.plugin.manager/scripts/plugin" ] || return 1 + mkdir -p $docroot /var/local/emhttp /boot/config/plugins + cp -a "$1/emhttp/." $docroot/ + printf 'csrf_token="compat-test-token"\n' > /var/local/emhttp/var.ini + # Unraid's hooks and scripts run as #!/usr/bin/php + ln -sf "$(command -v php)" /usr/bin/php +} + +fv3_build() { # fv3_build : the .plg and package as the release workflow makes them, in $work/ + local dir="$work/$2"; mkdir -p "$dir"; cp -R "$1/src" "$1/$name.plg" "$1/pkg_build.sh" "$dir/" + (cd "$dir" && bash pkg_build.sh --version "$2" --branch "$3" --out "$dir/dist" >/dev/null) +} diff --git a/.github/unraid-compat/pages_test.php b/.github/unraid-compat/pages_test.php new file mode 100644 index 00000000..f7177e3a --- /dev/null +++ b/.github/unraid-compat/pages_test.php @@ -0,0 +1,187 @@ + +$version = $argv[1] ?? '?'; +$failures = []; +$checks = 0; +function check(bool $ok, string $what): void { global $failures, $checks; $checks++; if (!$ok) $failures[] = $what; } + +// One request to the fake Unraid: [status, body, lower-cased response headers]; a POST carries Unraid's token unless told not to +function req(string $method, string $path, array $fields = [], ?string $token = 'compat-test-token'): array { + $headers = []; + $ch = curl_init("http://127.0.0.1$path"); + curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 60, CURLOPT_CUSTOMREQUEST => $method, + CURLOPT_HEADERFUNCTION => function ($ch, $line) use (&$headers) { + if (str_contains($line, ':')) { [$k, $v] = explode(':', $line, 2); $headers[strtolower(trim($k))] = trim($v); } + return strlen($line); + }]); + if ($method === 'POST') curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields + ($token === null ? [] : ['csrf_token' => $token]))); + $body = curl_exec($ch); + $status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE); + curl_close($ch); + return [$status, (string)$body, $headers]; +} + +// What one .page file put on the page: Unraid opens each file's part, in the head and again in the body, with a comment naming it +function fv3t_page_part(string $html, string $file): string { + preg_match_all('//', $html, $marks, PREG_OFFSET_CAPTURE); + $part = ''; + foreach ($marks[0] as $i => [$mark, $at]) { + if ($marks[1][$i][0] !== $file) continue; + $from = $at + strlen($mark); + $part .= substr($html, $from, ($marks[0][$i + 1][1] ?? strlen($html)) - $from); + } + return $part; +} + +function get_json(string $path, ?int &$status = null) { + [$status, $body] = req('GET', "/plugins/folder.view3/server/$path"); + return json_decode($body, true); +} + +$flash = '/boot/config/plugins/folder.view3'; +$media = 'MediaAbCdEfGhIjKlMnO'; +$tools = 'ToolsPqRsTuVwXyZaBcD'; +$lab = 'LabFoldAbCdEfGhIjKlM'; +$containers = ['app-a', 'app-b', 'app-d', 'tool-c']; +$vms = ['Debian 12', 'Home Assistant', 'Windows 11']; +$fixture = json_decode(file_get_contents(__DIR__ . '/fixtures/docker.json'), true); +$shortId = fn(string $name) => substr($fixture['inspect'][$name]['Id'], 0, 12); +$sorted = function (array $a): array { sort($a); return $a; }; + +// Unraid's own lists, which FV3's pages fold into folders +[$status, $body] = req('GET', '/plugins/dynamix.docker.manager/include/DockerContainers.php'); +check($status === 200 && substr_count($body, "") === 4, "Docker list: status $status, " . substr_count($body, "") . ' container rows, not 4'); +foreach ($containers as $ct) check(str_contains($body, $ct), "Docker list has no row for $ct"); +[$status, $body] = req('GET', '/plugins/dynamix.vm.manager/include/VMMachines.php'); +check($status === 200 && preg_match_all("//", $body) === 3, "VM list: status $status, not 3 VM rows"); +foreach ($vms as $vm) check(str_contains($body, $vm), "VM list has no row for $vm"); +[$status, $body] = req('POST', '/webGui/include/DashboardApps.php', ['docker' => 1, 'vms' => 1, 'vmusage' => 'N']); +foreach (array_merge($containers, $vms) as $name) check($status === 200 && str_contains($body, $name), "Dashboard tiles: status $status, no tile for $name"); + +// FV3's reads, each answered from what Unraid's own code got from Docker and libvirt +$info = get_json('read_info.php?type=docker', $status); +check($status === 200 && is_array($info) && $sorted(array_keys($info)) === $containers, "read_info docker: status $status, containers " . json_encode(is_array($info) ? array_keys($info) : $info)); +if (is_array($info) && $sorted(array_keys($info)) === $containers) { + check($info['app-a']['info']['State']['Autostart'] === true && $info['app-d']['info']['State']['Autostart'] === true && $info['app-b']['info']['State']['Autostart'] === false, + 'read_info docker: autostart not app-a and app-d only'); + check(str_ends_with($info['app-a']['info']['State']['WebUi'], ':18080/'), "read_info docker: app-a WebUI {$info['app-a']['info']['State']['WebUi']} does not reach host port 18080"); + check(($info['app-a']['info']['template']['path'] ?? '') === '/boot/config/plugins/dockerMan/templates-user/my-app-a.xml', 'read_info docker: app-a lost its template'); + check($info['tool-c']['info']['State']['Running'] === false && $info['app-b']['info']['State']['Running'] === true, 'read_info docker: running states wrong'); + check($info['app-d']['shortId'] === $shortId('app-d'), 'read_info docker: app-d short id wrong'); +} +$info = get_json('read_info.php?type=vm', $status); +check($status === 200 && is_array($info) && $sorted(array_keys($info)) === $vms, "read_info vm: status $status, VMs " . json_encode(is_array($info) ? array_keys($info) : $info)); +if (is_array($info) && $sorted(array_keys($info)) === $vms) { + $seen = array_map(fn($v) => [$v['state'], $v['autostart'], $v['icon'], $v['vnc_port']], $info); + check($seen === [ + 'Debian 12' => ['running', 1, '/plugins/dynamix.vm.manager/templates/images/debian.png', '5700'], + 'Windows 11' => ['shutoff', false, '/plugins/dynamix.vm.manager/templates/images/windows11.png', ''], + 'Home Assistant' => ['paused', 1, '/plugins/dynamix.vm.manager/templates/images/linux.png', '5701'], + ], 'read_info vm: state, autostart, icon or VNC port wrong: ' . json_encode($seen)); + check($info['Debian 12']['description'] === 'Debian 12 lab server', 'read_info vm: description lost'); +} +check(get_json('read_unraid_order.php?type=docker', $status) === ['app-a', 'app-b', 'tool-c', 'app-d'] && $status === 200, 'read_unraid_order docker: not the saved order'); +check(get_json('read_unraid_order.php?type=vm', $status) === ['Debian 12', 'Home Assistant', 'Windows 11'] && $status === 200, 'read_unraid_order vm: not the saved order'); +$membership = get_json('read_membership.php?type=docker', $status); +check($status === 200 && ($membership['membership'] ?? null) === ['app-a' => 'Media', 'app-b' => 'Media', 'tool-c' => 'Tools'], + "read_membership: status $status, " . json_encode($membership)); +[$status, $body] = req('GET', '/plugins/folder.view3/server/docker_load.php'); +$load = explode("\n", trim($body)); +sort($load); +$want = array_map(fn($n) => $shortId($n) . ';0.50%;12.5MiB / 7.7GiB', ['app-a', 'app-b', 'app-d']); +sort($want); +check($status === 200 && $load === $want, "docker_load: status $status, " . json_encode($load)); +$image = array_key_first($fixture['image_inspect']); +$env = get_json('read_image_env.php?image=' . urlencode($image), $status); +check($status === 200 && $env === ['env' => ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin']], "read_image_env: status $status, " . json_encode($env)); +$folders = get_json('read.php?type=docker', $status); +check($status === 200 && array_keys((array)$folders) === [$media, $tools], 'read docker: ' . json_encode($folders)); +$folders = get_json('read.php?type=vm', $status); +check($status === 200 && ($folders[$lab]['containers'] ?? null) === ['Debian 12'], 'read vm: ' . json_encode($folders)); +$autostart = get_json('read_autostart.php', $status); +check($status === 200 && ($autostart['autostart'] ?? null) === [['name' => 'app-a', 'wait' => 0], ['name' => 'app-d', 'wait' => 10]], 'read_autostart: ' . json_encode($autostart)); +foreach (['read_order.php?type=docker', 'read_order.php?type=vm', 'read_settings.php', 'list_themes.php', 'read_css_config.php', 'read_css_defaults.php', + 'read_error_log.php', 'read_organizer_registry.php', 'export_all.php'] as $path) { + [$status, $body] = req('GET', "/plugins/folder.view3/server/$path"); + check($status === 200 && json_decode($body) !== null, "$path: status $status, not JSON: " . substr($body, 0, 200)); +} +[$status, $body] = req('GET', '/plugins/folder.view3/server/version.php'); +check($status === 200 && $body === '2099.01.01', "version: status $status, $body"); +[$status, $body] = req('GET', '/plugins/folder.view3/server/cpu.php'); +check($status === 200 && (int)$body > 0, "cpu: status $status, $body"); + +// FV3's pages in every theme: rendered whole, FV3's own section present, and every file it links served by this Unraid +$pages = [ + 'Docker' => ['folder.view3.Docker.page', ['/plugins/folder.view3/scripts/docker.js', '/plugins/folder.view3/styles/docker.css']], + 'VMs' => ['folder.view3.VMs.page', ['/plugins/folder.view3/scripts/vm.js', '/plugins/folder.view3/styles/vm.css']], + 'Dashboard' => ['folder.view3.Dashboard.page', ['/plugins/folder.view3/scripts/dashboard.js', '/plugins/folder.view3/styles/dashboard.css']], + 'Settings/FolderView3' => ['FolderView3.page', ['/plugins/folder.view3/scripts/folderview3.js', '/plugins/folder.view3/styles/folderview3.css']], + "Folder?type=docker&id=$media" => ['Folder.page', ['/plugins/folder.view3/scripts/folder.js', '/plugins/folder.view3/styles/folder.css']], +]; +$served = []; +@mkdir('/boot/config/plugins/dynamix', 0777, true); +foreach (['black', 'white', 'azure', 'gray'] as $theme) { + file_put_contents('/boot/config/plugins/dynamix/dynamix.cfg', "[display]\ntheme=\"$theme\"\n"); + foreach ($pages as $page => [$file, $needs]) { + [$status, $html] = req('GET', "/$page"); + $where = "$page ($theme)"; + check($status === 200 && str_contains($html, ''), "$where: status $status, page cut short"); + check(!preg_match('#Error evaluating content in plugins\\\\?/folder\.view3#', $html), "$where: Unraid caught an error in FV3's page"); + $part = fv3t_page_part($html, "plugins/folder.view3/$file"); + if ($part === '') { + check(false, "$where: no part from $file"); + continue; + } + check(!str_contains($part, '{"error":"Internal error"}'), "$where: FV3's error answer inside the page"); + check(preg_match("#/webGui/styles/(?:themes/|default-)$theme\.css#", $html) === 1, "$where: Unraid's $theme stylesheet missing, so the theme was not applied"); + preg_match_all('#(?:src|href)="(/[^"?]+\.(?:js|css))(?:\?[^"]*)?"#', $part, $links); + foreach ($needs as $need) check(in_array($need, $links[1], true), "$where: does not load $need"); + foreach (array_unique($links[1]) as $link) { + $served[$link] ??= req('GET', $link)[0]; + check($served[$link] === 200, "$where: links $link, which this Unraid answers {$served[$link]}"); + } + } +} +@unlink('/boot/config/plugins/dynamix/dynamix.cfg'); + +// Writes go through Unraid's CSRF check: without the token nothing is saved and FV3 never answers +$folder = fn(string $name, array $members) => json_encode(['name' => $name, 'icon' => '', 'regex' => '', 'containers' => $members, 'settings' => ['preview' => 1], 'actions' => []]); +$before = md5_file("$flash/docker.json"); +foreach (['missing' => null, 'wrong' => 'not-the-token'] as $case => $token) { + [$status, $body, $headers] = req('POST', '/plugins/folder.view3/server/create.php', ['type' => 'docker', 'content' => $folder('New', ['app-d'])], $token); + check(md5_file("$flash/docker.json") === $before && !isset($headers['x-fv3-answer']), "create with the token $case: saved or answered by FV3 (status $status)"); +} +$saved = fn(string $type) => json_decode(file_get_contents("$flash/$type.json"), true); +[$status, , $headers] = req('POST', '/plugins/folder.view3/server/create.php', ['type' => 'docker', 'content' => $folder('New', ['app-d'])]); +$new = array_values(array_diff(array_keys($saved('docker')), [$media, $tools])); +check($status === 200 && isset($headers['x-fv3-answer']) && count($new) === 1 && $saved('docker')[$new[0]]['containers'] === ['app-d'], "create: status $status, " . json_encode($saved('docker'))); +[$status] = req('POST', '/plugins/folder.view3/server/update.php', ['type' => 'docker', 'id' => $media, 'content' => $folder('Media 2', ['app-a'])]); +check($status === 200 && $saved('docker')[$media]['name'] === 'Media 2', "update: status $status, " . json_encode($saved('docker')[$media] ?? null)); +[$status] = req('POST', '/plugins/folder.view3/server/update.php', ['type' => 'vm', 'id' => $lab, 'content' => $folder('Lab 2', ['Debian 12'])]); +check($status === 200 && $saved('vm')[$lab]['name'] === 'Lab 2', "update vm: status $status, " . json_encode($saved('vm')[$lab] ?? null)); +if ($new) { + [$status] = req('POST', '/plugins/folder.view3/server/delete.php', ['type' => 'docker', 'id' => $new[0]]); + check($status === 200 && array_keys($saved('docker')) === [$media, $tools], "delete: status $status, " . json_encode(array_keys($saved('docker')))); +} +[$status] = req('POST', '/plugins/folder.view3/server/update_settings.php', ['key' => 'dashboard_docker_layout', 'value' => 'classic']); +check($status === 200 && (json_decode((string)@file_get_contents("$flash/settings.json"), true)['dashboard_docker_layout'] ?? null) === 'classic', "update_settings: status $status"); +[$status, $body] = req('POST', '/plugins/folder.view3/server/sync_order.php', ['type' => 'docker']); +check($status === 200 && json_decode($body) !== null, "sync_order: status $status, $body"); + +// What the runs left in the logs: FV3's files must log nothing, and neither fake was asked anything it does not know +$fv3Lines = preg_grep('#/plugins/folder\.view3/#', file('/var/log/phplog', FILE_IGNORE_NEW_LINES)); +check(!$fv3Lines, "PHP logged from FV3's files:\n " . implode("\n ", array_slice($fv3Lines, 0, 20))); +// php-error lines copy every warning of the request, Unraid's too, and name only the file's basename: the PHP log judges those +$errorLog = is_file("$flash/error.log") ? file("$flash/error.log", FILE_IGNORE_NEW_LINES) : []; +$reported = $errorLog === false ? ['error.log could not be read'] : preg_grep('/^\[[^]]+\] (?!php-error: )/', $errorLog); +check(!$reported, "FV3's error.log:\n " . implode("\n ", $reported)); +$unknown = preg_grep('/UNKNOWN/', file('/var/log/fv3-fakes.log', FILE_IGNORE_NEW_LINES)); +check(!$unknown, "the fakes were asked what they do not answer:\n " . implode("\n ", array_unique($unknown))); + +if ($failures) { + echo "FAILED [Unraid $version]: " . count($failures) . " of $checks checks\n- " . implode("\n- ", $failures) . "\n"; + exit(1); +} +echo "Unraid $version: Unraid's lists, FV3's reads and writes, and its pages in 4 themes passed ($checks checks)\n"; diff --git a/.github/unraid-compat/pages_test.sh b/.github/unraid-compat/pages_test.sh new file mode 100644 index 00000000..8028ad84 --- /dev/null +++ b/.github/unraid-compat/pages_test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# FV3's endpoints and pages through a real Unraid webGUI. Disposable container only, as root, with no network; run from the +# repo root. Usage: pages_test.sh +set -u +bash .github/unraid-compat/fake_unraid.sh "$1" "$2" || exit 1 +php -d auto_prepend_file= .github/unraid-compat/pages_test.php "$2" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1199e8eb..98769d14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -203,9 +203,7 @@ jobs: repository: unraid/webgui ref: ${{ matrix.unraid }} path: .webgui - sparse-checkout: | - emhttp/plugins/dynamix - emhttp/plugins/dynamix.plugin.manager + sparse-checkout: emhttp - name: Install, upgrade, remove and failures through Unraid's own plugin installer if: env.RUNS == 'true' @@ -216,6 +214,12 @@ jobs: docker build -q -t fv3-unraid --build-arg PHP="$PHP_VERSION" .github/unraid-compat docker run --rm --network none -v "$PWD:/repo" -w /repo fv3-unraid bash .github/unraid-compat/install_test.sh .webgui "$UNRAID_VERSION" .stable + - name: FV3's endpoints and pages through this Unraid's webGUI, Docker and libvirt faked + if: env.RUNS == 'true' + env: + UNRAID_VERSION: ${{ matrix.unraid }} + run: docker run --rm --network none -v "$PWD:/repo" -w /repo fv3-unraid bash .github/unraid-compat/pages_test.sh .webgui "$UNRAID_VERSION" + # One check per matrix for beta's branch protection: the version rows rename themselves as Renovate moves them php-compat: name: PHP compatibility From 44aae4a6e3ea8d67cb3e4a7af6b980c4de2b3681 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 19:52:12 +0800 Subject: [PATCH 28/72] ci: page checks see .page warnings, stay inside FV3's part and need the fake Unraid Review fixes: the PHP-log filter also matches Unraid's page-relative names, a part ends at or the footer, pages_test.php refuses to run outside the fake and shows its own errors, readiness waits for dockerd.pid, the pages step runs after a failed install test, fv3_docroot reports a failed copy, the fixture drops the dev host's name and arm64 data, fail() and the Connect stand-in have one home. --- .coderabbit.yaml | 10 +++++----- .github/unraid-compat/Dockerfile | 6 +++--- .github/unraid-compat/fake/connect_state.php | 3 +++ .github/unraid-compat/fake/docker.php | 5 ++--- .github/unraid-compat/fake/libvirt.php | 9 +++++---- .github/unraid-compat/fake_unraid.sh | 13 +++++++------ .github/unraid-compat/fixtures/docker.json | 18 +++++++++--------- .github/unraid-compat/install_test.sh | 1 - .github/unraid-compat/lib.sh | 10 +++++----- .github/unraid-compat/pages_test.php | 18 ++++++++++++------ .github/unraid-compat/pages_test.sh | 2 +- .github/workflows/ci.yml | 3 ++- 12 files changed, 54 insertions(+), 44 deletions(-) create mode 100644 .github/unraid-compat/fake/connect_state.php diff --git a/.coderabbit.yaml b/.coderabbit.yaml index aedcd2e8..92e81f12 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -215,11 +215,11 @@ reviews: Only Slackware's upgradepkg and removepkg are stubbed, keeping their file-list records: flag any other stand-in for Unraid's code. - fake_unraid.sh serves one Unraid version's real webGUI with php -S - and pages_test.php drives FV3 through it. Stand-ins are the system - boundary only: fake/docker.php (dockerd's socket and the docker CLI), - fake/libvirt.php (the php-libvirt extension) and the Connect plugin's - ServerState, which the webGUI repo lacks. A call they do not answer - is logged as UNKNOWN and fails the run: flag an answer that hides + and pages_test.php drives FV3 through it. Stand-ins live in fake/ and + are the system boundary only: docker.php (dockerd's socket and the + docker CLI), libvirt.php (the php-libvirt extension) and + connect_state.php (the Connect plugin, which the webGUI repo lacks). + A call they do not answer fails the run: flag an answer that hides one, and any other stand-in for Unraid's code. - matrix_check.py keeps ci.yml's Unraid rows at one per minor from the .plg's min to the newest release; Renovate only moves rows. diff --git a/.github/unraid-compat/Dockerfile b/.github/unraid-compat/Dockerfile index 935ad012..1fae0965 100644 --- a/.github/unraid-compat/Dockerfile +++ b/.github/unraid-compat/Dockerfile @@ -1,7 +1,7 @@ -# The PHP an Unraid version ships, plus what Unraid has and this image lacks: gawk (the .plg's remove script uses RT), xz -# (the package format), procps (Unraid's pages test for running services with pgrep) and wget (the installer's downloader, -# so a download fails on the network, not a missing tool). Unraid's /bin/sh is bash: its exec() strings use &>. +# The PHP an Unraid version ships, plus Unraid's gawk (the remove script uses RT), xz (packages), procps (pages call pgrep) +# and wget (the installer's downloader, so a download fails on the network, not a missing tool) ARG PHP FROM php:${PHP}-cli +# Unraid's /bin/sh is bash: its exec() strings use &> RUN apt-get update && apt-get install -y --no-install-recommends gawk procps wget xz-utils && rm -rf /var/lib/apt/lists/* \ && ln -sf bash /bin/sh diff --git a/.github/unraid-compat/fake/connect_state.php b/.github/unraid-compat/fake/connect_state.php new file mode 100644 index 00000000..6ed92c36 --- /dev/null +++ b/.github/unraid-compat/fake/connect_state.php @@ -0,0 +1,3 @@ +` stands in for the docker -// CLI. Both read fixtures/docker.json (Docker Engine API answers captured from throwaway containers); a request this file -// does not know is logged as UNKNOWN and refused, so a new call by Unraid or FV3 shows up in the log. +// Fake Docker from fixtures/docker.json (Engine API answers of throwaway containers): `serve` answers /var/run/docker.sock, +// `cli ` is the docker CLI. A request it does not know is logged as UNKNOWN and refused. $d = json_decode((string)@file_get_contents(__DIR__ . '/../fixtures/docker.json'), true); if (!is_array($d)) { fwrite(STDERR, "fixtures/docker.json is unreadable\n"); exit(2); } diff --git a/.github/unraid-compat/fake/libvirt.php b/.github/unraid-compat/fake/libvirt.php index a4b3fde5..14a2a8b9 100644 --- a/.github/unraid-compat/fake/libvirt.php +++ b/.github/unraid-compat/fake/libvirt.php @@ -1,6 +1,7 @@ +# One Unraid version running in this container, FV3 installed and Docker and libvirt faked, served on 127.0.0.1:80. +# Run from the repo root. Usage: fake_unraid.sh set -u version=$2; repo=$(pwd); here=$repo/.github/unraid-compat . "$here/lib.sh" -fail() { echo "FAILED [Unraid $version]: $*"; exit 1; } fv3_docroot "$1" || fail "no Unraid webGUI under $1" # FV3 as upgradepkg leaves it, and the config folder its .plg makes @@ -29,7 +27,7 @@ printf 'SERVICE="enable"\nDEBUG="yes"\n' > /boot/config/domain.cfg # The OS image adds the Connect plugin, which the webGUI repo lacks from 7.2 on; 7.4's header requires its state class if [ ! -f $docroot/plugins/dynamix.my.servers/include/state.php ]; then mkdir -p $docroot/plugins/dynamix.my.servers/include - printf ' $docroot/plugins/dynamix.my.servers/include/state.php + cp "$here/fake/connect_state.php" $docroot/plugins/dynamix.my.servers/include/state.php : > $docroot/plugins/dynamix.my.servers/include/myservers1.php fi ln -sf $docroot/plugins/dynamix.plugin.manager/scripts/plugin /usr/local/sbin/plugin @@ -75,7 +73,10 @@ dockerd "$here/fake/docker.php" serve > /var/log/dockerd.log 2>&1 & mkdir -p /var/run/libvirt; libvirtd infinity & echo $! > /var/run/libvirt/libvirtd.pid php -S 127.0.0.1:80 -t $docroot "$here/fake/router.php" > /var/log/php-server.log 2>&1 & for _ in $(seq 300); do - [ -S /var/run/docker.sock ] && curl -sf -o /dev/null http://127.0.0.1/robots.txt && exit 0 + if [ -S /var/run/docker.sock ] && [ -s /var/run/dockerd.pid ] && curl -sf -o /dev/null http://127.0.0.1/robots.txt; then + # pages_test.php refuses to run without it + touch /var/run/fv3-fake-unraid && exit 0 + fi sleep 0.1 done fail "the fake Unraid did not start: $(cat /var/log/dockerd.log /var/log/php-server.log)" diff --git a/.github/unraid-compat/fixtures/docker.json b/.github/unraid-compat/fixtures/docker.json index dc4bbea0..922495ff 100644 --- a/.github/unraid-compat/fixtures/docker.json +++ b/.github/unraid-compat/fixtures/docker.json @@ -1,21 +1,21 @@ { "containers": [ - {"Id":"600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd","Names":["/app-d"],"Image":"alpine:3.20","ImageID":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:aarch64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"arm64","os":"linux","variant":"v8"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"net.unraid.docker.managed":"dockerman"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"host"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"host":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"1d8356c7e2572093121c6ecc3f3aa90f115043fc120bce24df492e9046968e53","EndpointID":"94d7de5784b83c465530aac4d83eb3748b59d47c8aaf458474145d73eb8c3a61","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, - {"Id":"32b7dac6e0272111835c5192f61054626ff79f117ba024985e9e48cd089e6629","Names":["/tool-c"],"Image":"alpine:3.20","ImageID":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:aarch64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"arm64","os":"linux","variant":"v8"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"net.unraid.docker.managed":"dockerman"},"State":"created","Status":"Created","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"","EndpointID":"","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, - {"Id":"37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1","Names":["/app-b"],"Image":"alpine:3.20","ImageID":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:aarch64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"arm64","os":"linux","variant":"v8"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"folder.view3":"Media","net.unraid.docker.managed":"dockerman"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"47de28aa8e317df6a908d72b266290cc7dbc3a18a554e5269630623cd4f7fb71","EndpointID":"bd56c9e7b10762831e36c7f251099a298217e0e343ed1133bf195296107e552a","Gateway":"172.17.0.1","IPAddress":"172.17.0.3","MacAddress":"3e:b4:33:03:78:7e","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, - {"Id":"7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380","Names":["/app-a"],"Image":"alpine:3.20","ImageID":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:aarch64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"arm64","os":"linux","variant":"v8"}},"Command":"sleep 3600","Created":1794654653,"Ports":[{"IP":"0.0.0.0","PrivatePort":8080,"PublicPort":18080,"Type":"tcp"},{"IP":"::","PrivatePort":8080,"PublicPort":18080,"Type":"tcp"}],"Labels":{"net.unraid.docker.icon":"/plugins/dynamix.docker.manager/images/question.png","net.unraid.docker.managed":"dockerman","net.unraid.docker.webui":"http://[IP]:[PORT:8080]/"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"47de28aa8e317df6a908d72b266290cc7dbc3a18a554e5269630623cd4f7fb71","EndpointID":"b3f964c8ef346a2bef5b11a0f3f05fc5f9783db10a0fff31db735e8056c72e86","Gateway":"172.17.0.1","IPAddress":"172.17.0.2","MacAddress":"0e:f7:ce:c2:79:80","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]} + {"Id":"600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd","Names":["/app-d"],"Image":"alpine:3.20","ImageID":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"net.unraid.docker.managed":"dockerman"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"host"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"host":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"1d8356c7e2572093121c6ecc3f3aa90f115043fc120bce24df492e9046968e53","EndpointID":"94d7de5784b83c465530aac4d83eb3748b59d47c8aaf458474145d73eb8c3a61","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, + {"Id":"32b7dac6e0272111835c5192f61054626ff79f117ba024985e9e48cd089e6629","Names":["/tool-c"],"Image":"alpine:3.20","ImageID":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"net.unraid.docker.managed":"dockerman"},"State":"created","Status":"Created","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"","EndpointID":"","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, + {"Id":"37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1","Names":["/app-b"],"Image":"alpine:3.20","ImageID":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"folder.view3":"Media","net.unraid.docker.managed":"dockerman"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"47de28aa8e317df6a908d72b266290cc7dbc3a18a554e5269630623cd4f7fb71","EndpointID":"bd56c9e7b10762831e36c7f251099a298217e0e343ed1133bf195296107e552a","Gateway":"172.17.0.1","IPAddress":"172.17.0.3","MacAddress":"3e:b4:33:03:78:7e","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, + {"Id":"7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380","Names":["/app-a"],"Image":"alpine:3.20","ImageID":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}},"Command":"sleep 3600","Created":1794654653,"Ports":[{"IP":"0.0.0.0","PrivatePort":8080,"PublicPort":18080,"Type":"tcp"},{"IP":"::","PrivatePort":8080,"PublicPort":18080,"Type":"tcp"}],"Labels":{"net.unraid.docker.icon":"/plugins/dynamix.docker.manager/images/question.png","net.unraid.docker.managed":"dockerman","net.unraid.docker.webui":"http://[IP]:[PORT:8080]/"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"47de28aa8e317df6a908d72b266290cc7dbc3a18a554e5269630623cd4f7fb71","EndpointID":"b3f964c8ef346a2bef5b11a0f3f05fc5f9783db10a0fff31db735e8056c72e86","Gateway":"172.17.0.1","IPAddress":"172.17.0.2","MacAddress":"0e:f7:ce:c2:79:80","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]} ], "inspect": { - "app-a": {"Id":"7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380","Created":"2026-11-14T11:10:53.865989285Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":3201330,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:53.881644066Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ResolvConfPath":"/var/lib/docker/containers/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380/resolv.conf","HostnamePath":"/var/lib/docker/containers/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380/hostname","HostsPath":"/var/lib/docker/containers/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380/hosts","LogPath":"/var/lib/docker/containers/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380-json.log","Name":"/app-a","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{"8080/tcp":[{"HostIp":"","HostPort":"18080"}]},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"7d18800f0983","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"ExposedPorts":{"8080/tcp":{}},"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.icon":"/plugins/dynamix.docker.manager/images/question.png","net.unraid.docker.managed":"dockerman","net.unraid.docker.webui":"http://[IP]:[PORT:8080]/"}},"NetworkSettings":{"SandboxID":"e3c238cede0e60f74780079e1c2b1301e97d101a00097cff872b2704404d2884","SandboxKey":"/var/run/docker/netns/e3c238cede0e","Ports":{"8080/tcp":[{"HostIp":"0.0.0.0","HostPort":"18080"},{"HostIp":"::","HostPort":"18080"}]},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"47de28aa8e317df6a908d72b266290cc7dbc3a18a554e5269630623cd4f7fb71","EndpointID":"b3f964c8ef346a2bef5b11a0f3f05fc5f9783db10a0fff31db735e8056c72e86","Gateway":"172.17.0.1","IPAddress":"172.17.0.2","MacAddress":"0e:f7:ce:c2:79:80","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:aarch64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"arm64","os":"linux","variant":"v8"}}}, - "app-b": {"Id":"37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1","Created":"2026-11-14T11:10:54.013835226Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":3201412,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:54.04418883Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ResolvConfPath":"/var/lib/docker/containers/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1/resolv.conf","HostnamePath":"/var/lib/docker/containers/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1/hostname","HostsPath":"/var/lib/docker/containers/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1/hosts","LogPath":"/var/lib/docker/containers/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1-json.log","Name":"/app-b","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"37a78efc3169","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"folder.view3":"Media","net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"b1ca3d1f194461b8d618bc13f55509aefdd2c0a86430e9cae3c169a5c1b9229f","SandboxKey":"/var/run/docker/netns/b1ca3d1f1944","Ports":{},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"47de28aa8e317df6a908d72b266290cc7dbc3a18a554e5269630623cd4f7fb71","EndpointID":"bd56c9e7b10762831e36c7f251099a298217e0e343ed1133bf195296107e552a","Gateway":"172.17.0.1","IPAddress":"172.17.0.3","MacAddress":"3e:b4:33:03:78:7e","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:aarch64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"arm64","os":"linux","variant":"v8"}}}, - "tool-c": {"Id":"32b7dac6e0272111835c5192f61054626ff79f117ba024985e9e48cd089e6629","Created":"2026-11-14T11:10:54.108306911Z","Path":"sleep","Args":["3600"],"State":{"Status":"created","Running":false,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":0,"ExitCode":0,"Error":"","StartedAt":"0001-01-01T00:00:00Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ResolvConfPath":"","HostnamePath":"","HostsPath":"","LogPath":"","Name":"/tool-c","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":false,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"32b7dac6e027","Domainname":"","User":"","AttachStdin":false,"AttachStdout":true,"AttachStderr":true,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"","SandboxKey":"","Ports":{},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"","EndpointID":"","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:aarch64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"arm64","os":"linux","variant":"v8"}}}, - "app-d": {"Id":"600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd","Created":"2026-11-14T11:10:54.137826016Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":3201459,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:54.155919462Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ResolvConfPath":"/var/lib/docker/containers/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd/resolv.conf","HostnamePath":"/var/lib/docker/containers/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd/hostname","HostsPath":"/var/lib/docker/containers/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd/hosts","LogPath":"/var/lib/docker/containers/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd-json.log","Name":"/app-d","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"host","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"colima","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"1146429705f7841f920992f51e91d518d4e11d95924a7b0173bda4e684c7c0df","SandboxKey":"/var/run/docker/netns/default","Ports":{},"Networks":{"host":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"1d8356c7e2572093121c6ecc3f3aa90f115043fc120bce24df492e9046968e53","EndpointID":"94d7de5784b83c465530aac4d83eb3748b59d47c8aaf458474145d73eb8c3a61","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"arm64v8","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:aarch64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"arm64","os":"linux","variant":"v8"}}} + "app-a": {"Id":"7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380","Created":"2026-11-14T11:10:53.865989285Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":3201330,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:53.881644066Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ResolvConfPath":"/var/lib/docker/containers/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380/resolv.conf","HostnamePath":"/var/lib/docker/containers/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380/hostname","HostsPath":"/var/lib/docker/containers/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380/hosts","LogPath":"/var/lib/docker/containers/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380-json.log","Name":"/app-a","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{"8080/tcp":[{"HostIp":"","HostPort":"18080"}]},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"7d18800f0983","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"ExposedPorts":{"8080/tcp":{}},"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.icon":"/plugins/dynamix.docker.manager/images/question.png","net.unraid.docker.managed":"dockerman","net.unraid.docker.webui":"http://[IP]:[PORT:8080]/"}},"NetworkSettings":{"SandboxID":"e3c238cede0e60f74780079e1c2b1301e97d101a00097cff872b2704404d2884","SandboxKey":"/var/run/docker/netns/e3c238cede0e","Ports":{"8080/tcp":[{"HostIp":"0.0.0.0","HostPort":"18080"},{"HostIp":"::","HostPort":"18080"}]},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"47de28aa8e317df6a908d72b266290cc7dbc3a18a554e5269630623cd4f7fb71","EndpointID":"b3f964c8ef346a2bef5b11a0f3f05fc5f9783db10a0fff31db735e8056c72e86","Gateway":"172.17.0.1","IPAddress":"172.17.0.2","MacAddress":"0e:f7:ce:c2:79:80","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}}}, + "app-b": {"Id":"37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1","Created":"2026-11-14T11:10:54.013835226Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":3201412,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:54.04418883Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ResolvConfPath":"/var/lib/docker/containers/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1/resolv.conf","HostnamePath":"/var/lib/docker/containers/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1/hostname","HostsPath":"/var/lib/docker/containers/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1/hosts","LogPath":"/var/lib/docker/containers/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1-json.log","Name":"/app-b","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"37a78efc3169","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"folder.view3":"Media","net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"b1ca3d1f194461b8d618bc13f55509aefdd2c0a86430e9cae3c169a5c1b9229f","SandboxKey":"/var/run/docker/netns/b1ca3d1f1944","Ports":{},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"47de28aa8e317df6a908d72b266290cc7dbc3a18a554e5269630623cd4f7fb71","EndpointID":"bd56c9e7b10762831e36c7f251099a298217e0e343ed1133bf195296107e552a","Gateway":"172.17.0.1","IPAddress":"172.17.0.3","MacAddress":"3e:b4:33:03:78:7e","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}}}, + "tool-c": {"Id":"32b7dac6e0272111835c5192f61054626ff79f117ba024985e9e48cd089e6629","Created":"2026-11-14T11:10:54.108306911Z","Path":"sleep","Args":["3600"],"State":{"Status":"created","Running":false,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":0,"ExitCode":0,"Error":"","StartedAt":"0001-01-01T00:00:00Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ResolvConfPath":"","HostnamePath":"","HostsPath":"","LogPath":"","Name":"/tool-c","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":false,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"32b7dac6e027","Domainname":"","User":"","AttachStdin":false,"AttachStdout":true,"AttachStderr":true,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"","SandboxKey":"","Ports":{},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"","EndpointID":"","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}}}, + "app-d": {"Id":"600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd","Created":"2026-11-14T11:10:54.137826016Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":3201459,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:54.155919462Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ResolvConfPath":"/var/lib/docker/containers/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd/resolv.conf","HostnamePath":"/var/lib/docker/containers/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd/hostname","HostsPath":"/var/lib/docker/containers/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd/hosts","LogPath":"/var/lib/docker/containers/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd-json.log","Name":"/app-d","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"host","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"Tower","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"1146429705f7841f920992f51e91d518d4e11d95924a7b0173bda4e684c7c0df","SandboxKey":"/var/run/docker/netns/default","Ports":{},"Networks":{"host":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"1d8356c7e2572093121c6ecc3f3aa90f115043fc120bce24df492e9046968e53","EndpointID":"94d7de5784b83c465530aac4d83eb3748b59d47c8aaf458474145d73eb8c3a61","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}}} }, "images": [ {"Containers":4,"Created":1776383604,"Id":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","Labels":{},"ParentId":"","Descriptor":{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","size":9226},"RepoDigests":["alpine@sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc"],"RepoTags":["alpine:3.20"],"SharedSize":-1,"Size":13660215} ], "image_inspect": { - "sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc": {"Id":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","RepoTags":["alpine:3.20"],"RepoDigests":["alpine@sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc"],"Comment":"buildkit.dockerfile.v0","Created":"2026-04-16T23:53:24.896953537Z","Config":{"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh"],"WorkingDir":"/"},"Architecture":"arm64","Variant":"v8","Os":"linux","Size":4103199,"RootFS":{"Type":"layers","Layers":["sha256:88b4fba61c4c714a2fc173ddf7e9324a257304696830bf41ad28ecc58c11c95f"]},"Metadata":{"LastTagTime":"2026-10-30T23:32:14.282085809Z"},"Descriptor":{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","size":9226},"Identity":{"Pull":[{"Repository":"docker.io/library/alpine"}]}} + "sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc": {"Id":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","RepoTags":["alpine:3.20"],"RepoDigests":["alpine@sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc"],"Comment":"buildkit.dockerfile.v0","Created":"2026-04-16T23:53:24.896953537Z","Config":{"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh"],"WorkingDir":"/"},"Architecture":"amd64","Os":"linux","Size":4103199,"RootFS":{"Type":"layers","Layers":["sha256:88b4fba61c4c714a2fc173ddf7e9324a257304696830bf41ad28ecc58c11c95f"]},"Metadata":{"LastTagTime":"2026-10-30T23:32:14.282085809Z"},"Descriptor":{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","size":9226},"Identity":{"Pull":[{"Repository":"docker.io/library/alpine"}]}} }, "networks": [ {"Name":"host","Driver":"host"}, diff --git a/.github/unraid-compat/install_test.sh b/.github/unraid-compat/install_test.sh index 380b3b6e..64281244 100755 --- a/.github/unraid-compat/install_test.sh +++ b/.github/unraid-compat/install_test.sh @@ -4,7 +4,6 @@ set -u version=$2; repo=$(pwd) . "$repo/.github/unraid-compat/lib.sh" -fail() { echo "FAILED [Unraid $version]: $*"; exit 1; } stable=$(cd "$3" 2>/dev/null && pwd) && [ -f "$stable/pkg_build.sh" ] || fail "no last-stable checkout with pkg_build.sh at $3" awk --version 2>/dev/null | grep -q 'GNU Awk' || fail 'awk is not gawk, as it is on Unraid: the remove script needs RT' fv3_docroot "$1" || fail "no Unraid plugin installer under $1" diff --git a/.github/unraid-compat/lib.sh b/.github/unraid-compat/lib.sh index f6ac976b..b9d96bee 100644 --- a/.github/unraid-compat/lib.sh +++ b/.github/unraid-compat/lib.sh @@ -1,17 +1,17 @@ #!/bin/bash -# Shared by install_test.sh and fake_unraid.sh. Source it from the repo root; it sets name, docroot, flash and work. -# These scripts replace system files, so they run only in a fresh Docker container, never on a host. +# Shared by install_test.sh and fake_unraid.sh: source it from the repo root with $version set. These replace system files, +# so they run only in a fresh Docker container, never on a host. if [ ! -f /.dockerenv ] || [ -e /etc/unraid-version ] || [ -d /boot/config ]; then echo 'Refusing to run outside a fresh Docker container' >&2; exit 2; fi name=folder.view3 docroot=/usr/local/emhttp flash=/boot/config/plugins/$name work=$(mktemp -d) +fail() { echo "FAILED [Unraid $version]: $*"; exit 1; } fv3_docroot() { # fv3_docroot : Unraid's /usr/local/emhttp from that webGUI checkout, its symlinks included [ -f "$1/emhttp/plugins/dynamix.plugin.manager/scripts/plugin" ] || return 1 - mkdir -p $docroot /var/local/emhttp /boot/config/plugins - cp -a "$1/emhttp/." $docroot/ - printf 'csrf_token="compat-test-token"\n' > /var/local/emhttp/var.ini + mkdir -p $docroot /var/local/emhttp /boot/config/plugins && cp -a "$1/emhttp/." $docroot/ || return 1 + printf 'csrf_token="compat-test-token"\n' > /var/local/emhttp/var.ini || return 1 # Unraid's hooks and scripts run as #!/usr/bin/php ln -sf "$(command -v php)" /usr/bin/php } diff --git a/.github/unraid-compat/pages_test.php b/.github/unraid-compat/pages_test.php index f7177e3a..07b9ce16 100644 --- a/.github/unraid-compat/pages_test.php +++ b/.github/unraid-compat/pages_test.php @@ -1,7 +1,7 @@ +// FV3 through the Unraid webGUI fake_unraid.sh serves: Unraid's lists, FV3's reads and CSRF-checked writes, its pages in 4 themes +// and the files they link. A warning from FV3's files fails; 7.0 and 7.1 log a .page's inline PHP without the page's name. +if (!is_file('/.dockerenv') || !is_file('/var/run/fv3-fake-unraid')) { fwrite(STDERR, "Run pages_test.sh: this needs the container fake_unraid.sh set up\n"); exit(2); } $version = $argv[1] ?? '?'; $failures = []; $checks = 0; @@ -23,14 +23,19 @@ function req(string $method, string $path, array $fields = [], ?string $token = return [$status, (string)$body, $headers]; } -// What one .page file put on the page: Unraid opens each file's part, in the head and again in the body, with a comment naming it +// What one .page file put on the page: Unraid opens each file's part, in the head and again in the body, with a comment naming +// it; a part ends at the next one, at or at the footer function fv3t_page_part(string $html, string $file): string { preg_match_all('//', $html, $marks, PREG_OFFSET_CAPTURE); + preg_match_all('#|id="footer"#', $html, $ends, PREG_OFFSET_CAPTURE); + $bounds = array_merge(array_column($marks[0], 1), array_column($ends[0], 1), [strlen($html)]); + sort($bounds); $part = ''; foreach ($marks[0] as $i => [$mark, $at]) { if ($marks[1][$i][0] !== $file) continue; $from = $at + strlen($mark); - $part .= substr($html, $from, ($marks[0][$i + 1][1] ?? strlen($html)) - $from); + $to = current(array_filter($bounds, fn($b) => $b >= $from)); + $part .= substr($html, $from, $to - $from); } return $part; } @@ -171,7 +176,8 @@ function get_json(string $path, ?int &$status = null) { check($status === 200 && json_decode($body) !== null, "sync_order: status $status, $body"); // What the runs left in the logs: FV3's files must log nothing, and neither fake was asked anything it does not know -$fv3Lines = preg_grep('#/plugins/folder\.view3/#', file('/var/log/phplog', FILE_IGNORE_NEW_LINES)); +// From 7.2 Unraid logs a .page's inline PHP as "in plugins/folder.view3/.page", with no leading slash +$fv3Lines = preg_grep('#plugins/folder\.view3/#', file('/var/log/phplog', FILE_IGNORE_NEW_LINES)); check(!$fv3Lines, "PHP logged from FV3's files:\n " . implode("\n ", array_slice($fv3Lines, 0, 20))); // php-error lines copy every warning of the request, Unraid's too, and name only the file's basename: the PHP log judges those $errorLog = is_file("$flash/error.log") ? file("$flash/error.log", FILE_IGNORE_NEW_LINES) : []; diff --git a/.github/unraid-compat/pages_test.sh b/.github/unraid-compat/pages_test.sh index 8028ad84..3306f716 100644 --- a/.github/unraid-compat/pages_test.sh +++ b/.github/unraid-compat/pages_test.sh @@ -3,4 +3,4 @@ # repo root. Usage: pages_test.sh set -u bash .github/unraid-compat/fake_unraid.sh "$1" "$2" || exit 1 -php -d auto_prepend_file= .github/unraid-compat/pages_test.php "$2" +php -d auto_prepend_file= -d display_errors=stderr .github/unraid-compat/pages_test.php "$2" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 98769d14..5c045d78 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -214,8 +214,9 @@ jobs: docker build -q -t fv3-unraid --build-arg PHP="$PHP_VERSION" .github/unraid-compat docker run --rm --network none -v "$PWD:/repo" -w /repo fv3-unraid bash .github/unraid-compat/install_test.sh .webgui "$UNRAID_VERSION" .stable + # Runs after a failed install test too: the two report on different things - name: FV3's endpoints and pages through this Unraid's webGUI, Docker and libvirt faked - if: env.RUNS == 'true' + if: ${{ !cancelled() && env.RUNS == 'true' }} env: UNRAID_VERSION: ${{ matrix.unraid }} run: docker run --rm --network none -v "$PWD:/repo" -w /repo fv3-unraid bash .github/unraid-compat/pages_test.sh .webgui "$UNRAID_VERSION" From 7a4ef82f10736d0157782ed3c5ade2ff0a78df8c Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 19:59:23 +0800 Subject: [PATCH 29/72] ci: the fake Unraid runs Docker and VMs as the Dashboard sees them, with synthetic fixtures Audit fixes: rc.docker and rc.libvirt answer status, so the Dashboard draws the tiles FV3 folds; Unraid's VM usage poll is answered; each page asserts the lists FV3's scripts fold; the sync check seeds an out-of-order autostart file; the xpath stand-in answers false on no match as php-libvirt does; the Docker socket fake refuses to run outside the fake; fixture ids, MACs and PIDs are synthetic. --- .coderabbit.yaml | 16 +++++++----- .github/unraid-compat/fake/docker.php | 4 ++- .github/unraid-compat/fake/libvirt.php | 17 +++++++++++-- .github/unraid-compat/fake/rc_service.sh | 5 ++++ .github/unraid-compat/fake_unraid.sh | 10 ++++---- .github/unraid-compat/fixtures/docker.json | 20 +++++++-------- .github/unraid-compat/pages_test.php | 29 ++++++++++++++-------- 7 files changed, 67 insertions(+), 34 deletions(-) create mode 100644 .github/unraid-compat/fake/rc_service.sh diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 92e81f12..4bf0bbf0 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -215,12 +215,16 @@ reviews: Only Slackware's upgradepkg and removepkg are stubbed, keeping their file-list records: flag any other stand-in for Unraid's code. - fake_unraid.sh serves one Unraid version's real webGUI with php -S - and pages_test.php drives FV3 through it. Stand-ins live in fake/ and - are the system boundary only: docker.php (dockerd's socket and the - docker CLI), libvirt.php (the php-libvirt extension) and - connect_state.php (the Connect plugin, which the webGUI repo lacks). - A call they do not answer fails the run: flag an answer that hides - one, and any other stand-in for Unraid's code. + and pages_test.php drives FV3 through it. Stand-ins are what the OS + image adds around the webGUI, nothing of the webGUI itself: + router.php (nginx's locations), prepend.php (php.ini's prepend), + docker.php (dockerd's socket and the docker CLI), libvirt.php (the + php-libvirt extension), rc_service.sh (rc.docker and rc.libvirt), + connect_state.php (the Connect plugin), the dockerd and libvirtd + processes, and emhttp's state files (var.ini, network.ini, the + docker and domain cfg). A call a stand-in does not answer fails + the run: flag an answer that hides one, and any stand-in for code + the webGUI repo has. - matrix_check.py keeps ci.yml's Unraid rows at one per minor from the .plg's min to the newest release; Renovate only moves rows. - Each step asserts what the user is left with (live files, the diff --git a/.github/unraid-compat/fake/docker.php b/.github/unraid-compat/fake/docker.php index c6820083..225872ee 100644 --- a/.github/unraid-compat/fake/docker.php +++ b/.github/unraid-compat/fake/docker.php @@ -66,6 +66,8 @@ function fv3d_cli(array $d, array $args): ?array { } if (($argv[1] ?? '') === 'serve') { + // It replaces the host's Docker socket: only inside fake_unraid.sh's container + if (!is_file('/.dockerenv') || !is_file('/var/run/fv3-fake-unraid')) { fwrite(STDERR, "docker.php serve runs only under fake_unraid.sh\n"); exit(2); } $sock = '/var/run/docker.sock'; @unlink($sock); $server = stream_socket_server("unix://$sock", $errno, $errstr); @@ -81,7 +83,7 @@ function fv3d_cli(array $d, array $args): ?array { [$status, $body] = fv3d_answer($d, $method, $target); fv3d_log(($status === null ? 'UNKNOWN ' : '') . "socket $method $target"); if ($status === null) [$status, $body] = [404, ['message' => 'page not found']]; - // One line of JSON with a length, as dockerd answers: DockerClient decodes the body line by line + // One line of JSON with a length: DockerClient decodes the body line by line $json = json_encode($body, JSON_UNESCAPED_SLASHES) . "\n"; fwrite($conn, "HTTP/1.1 $status " . ($status === 200 ? 'OK' : 'Not Found') . "\r\nContent-Type: application/json\r\nContent-Length: " . strlen($json) . "\r\nConnection: close\r\n\r\n$json"); fclose($conn); diff --git a/.github/unraid-compat/fake/libvirt.php b/.github/unraid-compat/fake/libvirt.php index 14a2a8b9..2440d5a2 100644 --- a/.github/unraid-compat/fake/libvirt.php +++ b/.github/unraid-compat/fake/libvirt.php @@ -93,12 +93,24 @@ function libvirt_domain_get_block_info($dom, $dev) { return false; } +// Unraid's VM usage poller reads these keys per domain name; a running domain has used some CPU time +function libvirt_connect_get_all_domain_stats($conn, $stats = 0, $flags = 0) { + $all = []; + foreach (fv3l_domains() as $name => $d) { + $info = libvirt_domain_get_info(fv3l_handle('domain', $name)); + $all[$name] = ['state.state' => $d['state'], 'state.reason' => 1, 'cpu.time' => $d['id'] > 0 ? 125000000000 : 0, + 'vcpu.current' => $info['nrVirtCpu'], 'vcpu.maximum' => $info['nrVirtCpu'], 'balloon.current' => $info['memory'], + 'balloon.maximum' => $info['maxMem'], 'net.count' => 0, 'block.count' => 0]; + } + return $all; +} + function libvirt_domain_get_counts($conn) { $active = count(array_filter(fv3l_domains(), fn($d) => $d['id'] > 0)); return ['total' => count(fv3l_domains()), 'active' => $active, 'inactive' => count(fv3l_domains()) - $active]; } -// php-libvirt's answer: the matches' text in order, with their count under 'num' +// php-libvirt's answer: the matches' text in order, their count under 'num', and false when nothing matches function libvirt_domain_xml_xpath($dom, $xpath, $flags = 0) { $d = fv3l_domain($dom); if (!$d) return false; @@ -106,6 +118,7 @@ function libvirt_domain_xml_xpath($dom, $xpath, $flags = 0) { $doc->loadXML($d['xml']); $nodes = @(new DOMXPath($doc))->query($xpath); if ($nodes === false) { $GLOBALS['fv3l_error'] = "invalid xpath $xpath"; return false; } + if ($nodes->length === 0) return false; $out = ['xpath' => $xpath, 'num' => $nodes->length]; foreach ($nodes as $i => $node) $out[$i] = $node->nodeValue; return $out; @@ -113,7 +126,7 @@ function libvirt_domain_xml_xpath($dom, $xpath, $flags = 0) { // Every other libvirt_* function in the webGUI's code at 7.0.1-7.4.0: none has an answer here yet foreach (['libvirt_connect_get_information', 'libvirt_connect_get_capabilities', 'libvirt_connect_get_machine_types', - 'libvirt_connect_get_domain_capabilities', 'libvirt_connect_get_all_domain_stats', 'libvirt_has_feature', + 'libvirt_connect_get_domain_capabilities', 'libvirt_has_feature', 'libvirt_list_nodedevs', 'libvirt_nodedev_get', 'libvirt_nodedev_get_xml_desc', 'libvirt_nodedev_get_information', 'libvirt_nodedev_capabilities', 'libvirt_list_networks', 'libvirt_network_get', 'libvirt_network_get_xml_desc', 'libvirt_get_net_res', 'libvirt_get_net_list', 'libvirt_get_net_xml', 'libvirt_domain_interface_addresses', diff --git a/.github/unraid-compat/fake/rc_service.sh b/.github/unraid-compat/fake/rc_service.sh new file mode 100644 index 00000000..1f5fa134 --- /dev/null +++ b/.github/unraid-compat/fake/rc_service.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Stand-in for the OS image's /etc/rc.d/rc.docker and rc.libvirt: `status` says running (the Dashboard draws its tiles from it) +[ "$1" = status ] && exit 0 +echo "rc UNKNOWN $0 $*" >> /var/log/fv3-fakes.log +exit 1 diff --git a/.github/unraid-compat/fake_unraid.sh b/.github/unraid-compat/fake_unraid.sh index 32e8b339..a062417f 100644 --- a/.github/unraid-compat/fake_unraid.sh +++ b/.github/unraid-compat/fake_unraid.sh @@ -4,6 +4,8 @@ set -u version=$2; repo=$(pwd); here=$repo/.github/unraid-compat . "$here/lib.sh" +# Past lib.sh's guard: fake/docker.php and pages_test.php refuse to run without this +mkdir -p /var/run && touch /var/run/fv3-fake-unraid || fail 'no marker' fv3_docroot "$1" || fail "no Unraid webGUI under $1" # FV3 as upgradepkg leaves it, and the config folder its .plg makes @@ -66,17 +68,15 @@ error_reporting=E_ALL EOF : > /var/log/phplog; : > /var/log/fv3-fakes.log -# Docker and libvirtd under their own names, so Unraid's pgrep() and /proc/ checks find them running +# Docker and libvirtd under their own names and rc scripts, so Unraid's pgrep(), /proc/ and status checks find them running +mkdir -p /etc/rc.d && for rc in rc.docker rc.libvirt; do cp "$here/fake/rc_service.sh" /etc/rc.d/$rc && chmod +x /etc/rc.d/$rc; done printf '#!/bin/sh\nexec php %s/fake/docker.php cli "$@"\n' "$here" > /usr/local/bin/docker && chmod +x /usr/local/bin/docker ln -sf "$(command -v php)" /usr/local/sbin/dockerd; ln -sf "$(command -v sleep)" /usr/local/sbin/libvirtd dockerd "$here/fake/docker.php" serve > /var/log/dockerd.log 2>&1 & mkdir -p /var/run/libvirt; libvirtd infinity & echo $! > /var/run/libvirt/libvirtd.pid php -S 127.0.0.1:80 -t $docroot "$here/fake/router.php" > /var/log/php-server.log 2>&1 & for _ in $(seq 300); do - if [ -S /var/run/docker.sock ] && [ -s /var/run/dockerd.pid ] && curl -sf -o /dev/null http://127.0.0.1/robots.txt; then - # pages_test.php refuses to run without it - touch /var/run/fv3-fake-unraid && exit 0 - fi + [ -S /var/run/docker.sock ] && [ -s /var/run/dockerd.pid ] && curl -sf -o /dev/null http://127.0.0.1/robots.txt && exit 0 sleep 0.1 done fail "the fake Unraid did not start: $(cat /var/log/dockerd.log /var/log/php-server.log)" diff --git a/.github/unraid-compat/fixtures/docker.json b/.github/unraid-compat/fixtures/docker.json index 922495ff..b10c3b1b 100644 --- a/.github/unraid-compat/fixtures/docker.json +++ b/.github/unraid-compat/fixtures/docker.json @@ -1,21 +1,21 @@ { "containers": [ - {"Id":"600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd","Names":["/app-d"],"Image":"alpine:3.20","ImageID":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"net.unraid.docker.managed":"dockerman"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"host"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"host":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"1d8356c7e2572093121c6ecc3f3aa90f115043fc120bce24df492e9046968e53","EndpointID":"94d7de5784b83c465530aac4d83eb3748b59d47c8aaf458474145d73eb8c3a61","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, - {"Id":"32b7dac6e0272111835c5192f61054626ff79f117ba024985e9e48cd089e6629","Names":["/tool-c"],"Image":"alpine:3.20","ImageID":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"net.unraid.docker.managed":"dockerman"},"State":"created","Status":"Created","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"","EndpointID":"","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, - {"Id":"37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1","Names":["/app-b"],"Image":"alpine:3.20","ImageID":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"folder.view3":"Media","net.unraid.docker.managed":"dockerman"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"47de28aa8e317df6a908d72b266290cc7dbc3a18a554e5269630623cd4f7fb71","EndpointID":"bd56c9e7b10762831e36c7f251099a298217e0e343ed1133bf195296107e552a","Gateway":"172.17.0.1","IPAddress":"172.17.0.3","MacAddress":"3e:b4:33:03:78:7e","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, - {"Id":"7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380","Names":["/app-a"],"Image":"alpine:3.20","ImageID":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}},"Command":"sleep 3600","Created":1794654653,"Ports":[{"IP":"0.0.0.0","PrivatePort":8080,"PublicPort":18080,"Type":"tcp"},{"IP":"::","PrivatePort":8080,"PublicPort":18080,"Type":"tcp"}],"Labels":{"net.unraid.docker.icon":"/plugins/dynamix.docker.manager/images/question.png","net.unraid.docker.managed":"dockerman","net.unraid.docker.webui":"http://[IP]:[PORT:8080]/"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"47de28aa8e317df6a908d72b266290cc7dbc3a18a554e5269630623cd4f7fb71","EndpointID":"b3f964c8ef346a2bef5b11a0f3f05fc5f9783db10a0fff31db735e8056c72e86","Gateway":"172.17.0.1","IPAddress":"172.17.0.2","MacAddress":"0e:f7:ce:c2:79:80","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]} + {"Id":"c02cabde5b2bae8bbe0ed4a53597fc7f6a95317322f9df9f415d49837824bb6f","Names":["/app-d"],"Image":"alpine:3.20","ImageID":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:704f8823e322c9ae8c92aa3a330e9df3a626ca80158f016ed3d12903a28d9e39","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"net.unraid.docker.managed":"dockerman"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"host"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"host":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"d76277a5b0783027956af1e58f401a4a9018b9e63f2c0bde7babe8c8bdc23378","EndpointID":"51578f75b98400841232ddda91450f8b4bd6fc805fea58ba6f0b864e27b3d39a","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, + {"Id":"6f0a162e593d88facb5c669bb52959572ca3571de86575e7fcc2a69f1eddd4d8","Names":["/tool-c"],"Image":"alpine:3.20","ImageID":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:704f8823e322c9ae8c92aa3a330e9df3a626ca80158f016ed3d12903a28d9e39","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"net.unraid.docker.managed":"dockerman"},"State":"created","Status":"Created","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"","EndpointID":"","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, + {"Id":"74f3b261653ad172efc0f1f7cc23c596605e85fafe84cbcb9f39a17480935df7","Names":["/app-b"],"Image":"alpine:3.20","ImageID":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:704f8823e322c9ae8c92aa3a330e9df3a626ca80158f016ed3d12903a28d9e39","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}},"Command":"sleep 3600","Created":1794654654,"Ports":[],"Labels":{"folder.view3":"Media","net.unraid.docker.managed":"dockerman"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"9a33407be38f647fe4c00b47444159cf8cb2484ea0e716778a059c23c62cfcf4","EndpointID":"997b20e28c8074ea75a32f93fe786be4221aa760c27900338354945b216b6794","Gateway":"172.17.0.1","IPAddress":"172.17.0.3","MacAddress":"02:42:ac:11:00:02","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]}, + {"Id":"7da32cf55ebd070122ced08ab094712770b1d5e3f0a2ba68e84809e6a0e67104","Names":["/app-a"],"Image":"alpine:3.20","ImageID":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:704f8823e322c9ae8c92aa3a330e9df3a626ca80158f016ed3d12903a28d9e39","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}},"Command":"sleep 3600","Created":1794654653,"Ports":[{"IP":"0.0.0.0","PrivatePort":8080,"PublicPort":18080,"Type":"tcp"},{"IP":"::","PrivatePort":8080,"PublicPort":18080,"Type":"tcp"}],"Labels":{"net.unraid.docker.icon":"/plugins/dynamix.docker.manager/images/question.png","net.unraid.docker.managed":"dockerman","net.unraid.docker.webui":"http://[IP]:[PORT:8080]/"},"State":"running","Status":"Up Less than a second","HostConfig":{"NetworkMode":"bridge"},"Health":{"Status":"none","FailingStreak":0},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"9a33407be38f647fe4c00b47444159cf8cb2484ea0e716778a059c23c62cfcf4","EndpointID":"b659ee595f07b05268a63cb7b00a429891b16b62726c04320af96a0ad14c2fab","Gateway":"172.17.0.1","IPAddress":"172.17.0.2","MacAddress":"02:42:ac:11:00:03","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"Mounts":[]} ], "inspect": { - "app-a": {"Id":"7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380","Created":"2026-11-14T11:10:53.865989285Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":3201330,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:53.881644066Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ResolvConfPath":"/var/lib/docker/containers/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380/resolv.conf","HostnamePath":"/var/lib/docker/containers/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380/hostname","HostsPath":"/var/lib/docker/containers/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380/hosts","LogPath":"/var/lib/docker/containers/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380/7d18800f0983d6ecb26b0723a8ca52934964675a8c4dbd20c0b85ca0d3b83380-json.log","Name":"/app-a","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{"8080/tcp":[{"HostIp":"","HostPort":"18080"}]},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"7d18800f0983","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"ExposedPorts":{"8080/tcp":{}},"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.icon":"/plugins/dynamix.docker.manager/images/question.png","net.unraid.docker.managed":"dockerman","net.unraid.docker.webui":"http://[IP]:[PORT:8080]/"}},"NetworkSettings":{"SandboxID":"e3c238cede0e60f74780079e1c2b1301e97d101a00097cff872b2704404d2884","SandboxKey":"/var/run/docker/netns/e3c238cede0e","Ports":{"8080/tcp":[{"HostIp":"0.0.0.0","HostPort":"18080"},{"HostIp":"::","HostPort":"18080"}]},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"47de28aa8e317df6a908d72b266290cc7dbc3a18a554e5269630623cd4f7fb71","EndpointID":"b3f964c8ef346a2bef5b11a0f3f05fc5f9783db10a0fff31db735e8056c72e86","Gateway":"172.17.0.1","IPAddress":"172.17.0.2","MacAddress":"0e:f7:ce:c2:79:80","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}}}, - "app-b": {"Id":"37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1","Created":"2026-11-14T11:10:54.013835226Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":3201412,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:54.04418883Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ResolvConfPath":"/var/lib/docker/containers/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1/resolv.conf","HostnamePath":"/var/lib/docker/containers/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1/hostname","HostsPath":"/var/lib/docker/containers/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1/hosts","LogPath":"/var/lib/docker/containers/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1/37a78efc3169096f5792940da290445b77e858951026d2d56a186e826fb793d1-json.log","Name":"/app-b","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"37a78efc3169","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"folder.view3":"Media","net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"b1ca3d1f194461b8d618bc13f55509aefdd2c0a86430e9cae3c169a5c1b9229f","SandboxKey":"/var/run/docker/netns/b1ca3d1f1944","Ports":{},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"47de28aa8e317df6a908d72b266290cc7dbc3a18a554e5269630623cd4f7fb71","EndpointID":"bd56c9e7b10762831e36c7f251099a298217e0e343ed1133bf195296107e552a","Gateway":"172.17.0.1","IPAddress":"172.17.0.3","MacAddress":"3e:b4:33:03:78:7e","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}}}, - "tool-c": {"Id":"32b7dac6e0272111835c5192f61054626ff79f117ba024985e9e48cd089e6629","Created":"2026-11-14T11:10:54.108306911Z","Path":"sleep","Args":["3600"],"State":{"Status":"created","Running":false,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":0,"ExitCode":0,"Error":"","StartedAt":"0001-01-01T00:00:00Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ResolvConfPath":"","HostnamePath":"","HostsPath":"","LogPath":"","Name":"/tool-c","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":false,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"32b7dac6e027","Domainname":"","User":"","AttachStdin":false,"AttachStdout":true,"AttachStderr":true,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"","SandboxKey":"","Ports":{},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"","EndpointID":"","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}}}, - "app-d": {"Id":"600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd","Created":"2026-11-14T11:10:54.137826016Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":3201459,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:54.155919462Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","ResolvConfPath":"/var/lib/docker/containers/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd/resolv.conf","HostnamePath":"/var/lib/docker/containers/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd/hostname","HostsPath":"/var/lib/docker/containers/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd/hosts","LogPath":"/var/lib/docker/containers/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd/600ab5c857f84d2318abb88f789cabd98504a5bcbcf8d54b8e15924838a7a2cd-json.log","Name":"/app-d","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"host","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"Tower","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"1146429705f7841f920992f51e91d518d4e11d95924a7b0173bda4e684c7c0df","SandboxKey":"/var/run/docker/netns/default","Ports":{},"Networks":{"host":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"1d8356c7e2572093121c6ecc3f3aa90f115043fc120bce24df492e9046968e53","EndpointID":"94d7de5784b83c465530aac4d83eb3748b59d47c8aaf458474145d73eb8c3a61","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:45e09956dc667c5eff3583c9d94830261fb1ca0be10a0a7db36266edf5de9e1d","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}}} + "app-a": {"Id":"7da32cf55ebd070122ced08ab094712770b1d5e3f0a2ba68e84809e6a0e67104","Created":"2026-11-14T11:10:53.865989285Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":1001,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:53.881644066Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","ResolvConfPath":"/var/lib/docker/containers/7da32cf55ebd070122ced08ab094712770b1d5e3f0a2ba68e84809e6a0e67104/resolv.conf","HostnamePath":"/var/lib/docker/containers/7da32cf55ebd070122ced08ab094712770b1d5e3f0a2ba68e84809e6a0e67104/hostname","HostsPath":"/var/lib/docker/containers/7da32cf55ebd070122ced08ab094712770b1d5e3f0a2ba68e84809e6a0e67104/hosts","LogPath":"/var/lib/docker/containers/7da32cf55ebd070122ced08ab094712770b1d5e3f0a2ba68e84809e6a0e67104/7da32cf55ebd070122ced08ab094712770b1d5e3f0a2ba68e84809e6a0e67104-json.log","Name":"/app-a","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{"8080/tcp":[{"HostIp":"","HostPort":"18080"}]},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"7da32cf55ebd","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"ExposedPorts":{"8080/tcp":{}},"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.icon":"/plugins/dynamix.docker.manager/images/question.png","net.unraid.docker.managed":"dockerman","net.unraid.docker.webui":"http://[IP]:[PORT:8080]/"}},"NetworkSettings":{"SandboxID":"427490050ddf210917ec5cf9bdb658d51e340d522578968f45f2c54f637961c7","SandboxKey":"/var/run/docker/netns/0123456789ab","Ports":{"8080/tcp":[{"HostIp":"0.0.0.0","HostPort":"18080"},{"HostIp":"::","HostPort":"18080"}]},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"9a33407be38f647fe4c00b47444159cf8cb2484ea0e716778a059c23c62cfcf4","EndpointID":"b659ee595f07b05268a63cb7b00a429891b16b62726c04320af96a0ad14c2fab","Gateway":"172.17.0.1","IPAddress":"172.17.0.2","MacAddress":"02:42:ac:11:00:03","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:704f8823e322c9ae8c92aa3a330e9df3a626ca80158f016ed3d12903a28d9e39","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}}}, + "app-b": {"Id":"74f3b261653ad172efc0f1f7cc23c596605e85fafe84cbcb9f39a17480935df7","Created":"2026-11-14T11:10:54.013835226Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":1002,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:54.04418883Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","ResolvConfPath":"/var/lib/docker/containers/74f3b261653ad172efc0f1f7cc23c596605e85fafe84cbcb9f39a17480935df7/resolv.conf","HostnamePath":"/var/lib/docker/containers/74f3b261653ad172efc0f1f7cc23c596605e85fafe84cbcb9f39a17480935df7/hostname","HostsPath":"/var/lib/docker/containers/74f3b261653ad172efc0f1f7cc23c596605e85fafe84cbcb9f39a17480935df7/hosts","LogPath":"/var/lib/docker/containers/74f3b261653ad172efc0f1f7cc23c596605e85fafe84cbcb9f39a17480935df7/74f3b261653ad172efc0f1f7cc23c596605e85fafe84cbcb9f39a17480935df7-json.log","Name":"/app-b","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"74f3b261653a","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"folder.view3":"Media","net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"32bdb90ab4c38d97d285fc4330f4d1c810e095b1f6a0e77c1e2fe8e654ead58c","SandboxKey":"/var/run/docker/netns/0123456789ab","Ports":{},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"9a33407be38f647fe4c00b47444159cf8cb2484ea0e716778a059c23c62cfcf4","EndpointID":"997b20e28c8074ea75a32f93fe786be4221aa760c27900338354945b216b6794","Gateway":"172.17.0.1","IPAddress":"172.17.0.3","MacAddress":"02:42:ac:11:00:02","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:704f8823e322c9ae8c92aa3a330e9df3a626ca80158f016ed3d12903a28d9e39","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}}}, + "tool-c": {"Id":"6f0a162e593d88facb5c669bb52959572ca3571de86575e7fcc2a69f1eddd4d8","Created":"2026-11-14T11:10:54.108306911Z","Path":"sleep","Args":["3600"],"State":{"Status":"created","Running":false,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":0,"ExitCode":0,"Error":"","StartedAt":"0001-01-01T00:00:00Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","ResolvConfPath":"","HostnamePath":"","HostsPath":"","LogPath":"","Name":"/tool-c","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"bridge","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":false,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"6f0a162e593d","Domainname":"","User":"","AttachStdin":false,"AttachStdout":true,"AttachStderr":true,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"","SandboxKey":"","Ports":{},"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"","EndpointID":"","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:704f8823e322c9ae8c92aa3a330e9df3a626ca80158f016ed3d12903a28d9e39","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}}}, + "app-d": {"Id":"c02cabde5b2bae8bbe0ed4a53597fc7f6a95317322f9df9f415d49837824bb6f","Created":"2026-11-14T11:10:54.137826016Z","Path":"sleep","Args":["3600"],"State":{"Status":"running","Running":true,"Paused":false,"Restarting":false,"OOMKilled":false,"Dead":false,"Pid":1003,"ExitCode":0,"Error":"","StartedAt":"2026-11-14T11:10:54.155919462Z","FinishedAt":"0001-01-01T00:00:00Z"},"Image":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","ResolvConfPath":"/var/lib/docker/containers/c02cabde5b2bae8bbe0ed4a53597fc7f6a95317322f9df9f415d49837824bb6f/resolv.conf","HostnamePath":"/var/lib/docker/containers/c02cabde5b2bae8bbe0ed4a53597fc7f6a95317322f9df9f415d49837824bb6f/hostname","HostsPath":"/var/lib/docker/containers/c02cabde5b2bae8bbe0ed4a53597fc7f6a95317322f9df9f415d49837824bb6f/hosts","LogPath":"/var/lib/docker/containers/c02cabde5b2bae8bbe0ed4a53597fc7f6a95317322f9df9f415d49837824bb6f/c02cabde5b2bae8bbe0ed4a53597fc7f6a95317322f9df9f415d49837824bb6f-json.log","Name":"/app-d","RestartCount":0,"Driver":"overlayfs","Platform":"linux","MountLabel":"","ProcessLabel":"","AppArmorProfile":"docker-default","ExecIDs":null,"HostConfig":{"Binds":null,"ContainerIDFile":"","LogConfig":{"Type":"json-file","Config":{}},"NetworkMode":"host","PortBindings":{},"RestartPolicy":{"Name":"no","MaximumRetryCount":0},"AutoRemove":false,"VolumeDriver":"","VolumesFrom":null,"ConsoleSize":[0,0],"CapAdd":null,"CapDrop":null,"CgroupnsMode":"private","Dns":null,"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"private","Cgroup":"","Links":null,"OomScoreAdj":0,"PidMode":"","Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"SecurityOpt":null,"UTSMode":"","UsernsMode":"","ShmSize":67108864,"Runtime":"runc","Isolation":"","CpuShares":0,"Memory":0,"NanoCpus":0,"CgroupParent":"","BlkioWeight":0,"BlkioWeightDevice":[],"BlkioDeviceReadBps":[],"BlkioDeviceWriteBps":[],"BlkioDeviceReadIOps":[],"BlkioDeviceWriteIOps":[],"CpuPeriod":0,"CpuQuota":0,"CpuRealtimePeriod":0,"CpuRealtimeRuntime":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"DeviceCgroupRules":null,"DeviceRequests":null,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":null,"OomKillDisable":null,"PidsLimit":null,"Ulimits":null,"CpuCount":0,"CpuPercent":0,"IOMaximumIOps":0,"IOMaximumBandwidth":0,"MaskedPaths":["/proc/acpi","/proc/asound","/proc/interrupts","/proc/kcore","/proc/keys","/proc/latency_stats","/proc/sched_debug","/proc/scsi","/proc/timer_list","/proc/timer_stats","/sys/devices/virtual/powercap","/sys/firmware"],"ReadonlyPaths":["/proc/bus","/proc/fs","/proc/irq","/proc/sys","/proc/sysrq-trigger"]},"Storage":{"RootFS":{"Snapshot":{"Name":"overlayfs"}}},"Mounts":[],"Config":{"Hostname":"Tower","Domainname":"","User":"","AttachStdin":false,"AttachStdout":false,"AttachStderr":false,"Tty":false,"OpenStdin":false,"StdinOnce":false,"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["sleep","3600"],"Image":"alpine:3.20","Volumes":null,"WorkingDir":"/","Entrypoint":null,"Labels":{"net.unraid.docker.managed":"dockerman"}},"NetworkSettings":{"SandboxID":"7352ddb38c6519326c97324ee5da104c419573030e2111f1a3422e0f5b45eae8","SandboxKey":"/var/run/docker/netns/default","Ports":{},"Networks":{"host":{"IPAMConfig":null,"Links":null,"Aliases":null,"DriverOpts":null,"GwPriority":0,"NetworkID":"d76277a5b0783027956af1e58f401a4a9018b9e63f2c0bde7babe8c8bdc23378","EndpointID":"51578f75b98400841232ddda91450f8b4bd6fc805fea58ba6f0b864e27b3d39a","Gateway":"","IPAddress":"","MacAddress":"","IPPrefixLen":0,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"DNSNames":null}}},"ImageManifestDescriptor":{"mediaType":"application/vnd.oci.image.manifest.v1+json","digest":"sha256:704f8823e322c9ae8c92aa3a330e9df3a626ca80158f016ed3d12903a28d9e39","size":1026,"annotations":{"com.docker.official-images.bashbrew.arch":"amd64","org.opencontainers.image.base.name":"scratch","org.opencontainers.image.created":"2026-04-16T23:53:21Z","org.opencontainers.image.revision":"0db70ae354ee747109ce0b9a0cfbcd3c907bc822","org.opencontainers.image.source":"https://github.com/alpinelinux/docker-alpine.git#0db70ae354ee747109ce0b9a0cfbcd3c907bc822:x86_64","org.opencontainers.image.url":"https://hub.docker.com/_/alpine","org.opencontainers.image.version":"3.20.10"},"platform":{"architecture":"amd64","os":"linux"}}} }, "images": [ - {"Containers":4,"Created":1776383604,"Id":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","Labels":{},"ParentId":"","Descriptor":{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","size":9226},"RepoDigests":["alpine@sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc"],"RepoTags":["alpine:3.20"],"SharedSize":-1,"Size":13660215} + {"Containers":4,"Created":1776383604,"Id":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","Labels":{},"ParentId":"","Descriptor":{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","size":9226},"RepoDigests":["alpine@sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615"],"RepoTags":["alpine:3.20"],"SharedSize":-1,"Size":13660215} ], "image_inspect": { - "sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc": {"Id":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","RepoTags":["alpine:3.20"],"RepoDigests":["alpine@sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc"],"Comment":"buildkit.dockerfile.v0","Created":"2026-04-16T23:53:24.896953537Z","Config":{"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh"],"WorkingDir":"/"},"Architecture":"amd64","Os":"linux","Size":4103199,"RootFS":{"Type":"layers","Layers":["sha256:88b4fba61c4c714a2fc173ddf7e9324a257304696830bf41ad28ecc58c11c95f"]},"Metadata":{"LastTagTime":"2026-10-30T23:32:14.282085809Z"},"Descriptor":{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:d9e853e87e55526f6b2917df91a2115c36dd7c696a35be12163d44e6e2a4b6bc","size":9226},"Identity":{"Pull":[{"Repository":"docker.io/library/alpine"}]}} + "sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615": {"Id":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","RepoTags":["alpine:3.20"],"RepoDigests":["alpine@sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615"],"Comment":"buildkit.dockerfile.v0","Created":"2026-04-16T23:53:24.896953537Z","Config":{"Env":["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],"Cmd":["/bin/sh"],"WorkingDir":"/"},"Architecture":"amd64","Os":"linux","Size":4103199,"RootFS":{"Type":"layers","Layers":["sha256:17fde15de9bf75f013a6219775fcb946f09ebb3c5f19ef7305ad8599b1cee239"]},"Metadata":{"LastTagTime":"2026-10-30T23:32:14.282085809Z"},"Descriptor":{"mediaType":"application/vnd.oci.image.index.v1+json","digest":"sha256:1ff3b73d4cc7e7dcaff2ff9071a710eabe41b5da61ebd2dabc9febe5d974b615","size":9226},"Identity":{"Pull":[{"Repository":"docker.io/library/alpine"}]}} }, "networks": [ {"Name":"host","Driver":"host"}, diff --git a/.github/unraid-compat/pages_test.php b/.github/unraid-compat/pages_test.php index 07b9ce16..78506f39 100644 --- a/.github/unraid-compat/pages_test.php +++ b/.github/unraid-compat/pages_test.php @@ -1,6 +1,6 @@ 0, "cpu: status $status, $body"); -// FV3's pages in every theme: rendered whole, FV3's own section present, and every file it links served by this Unraid +// FV3's pages in every theme: rendered whole, Unraid's lists that FV3's scripts fold present, FV3's own part present, and every +// file that part links served by this Unraid $pages = [ - 'Docker' => ['folder.view3.Docker.page', ['/plugins/folder.view3/scripts/docker.js', '/plugins/folder.view3/styles/docker.css']], - 'VMs' => ['folder.view3.VMs.page', ['/plugins/folder.view3/scripts/vm.js', '/plugins/folder.view3/styles/vm.css']], - 'Dashboard' => ['folder.view3.Dashboard.page', ['/plugins/folder.view3/scripts/dashboard.js', '/plugins/folder.view3/styles/dashboard.css']], - 'Settings/FolderView3' => ['FolderView3.page', ['/plugins/folder.view3/scripts/folderview3.js', '/plugins/folder.view3/styles/folderview3.css']], - "Folder?type=docker&id=$media" => ['Folder.page', ['/plugins/folder.view3/scripts/folder.js', '/plugins/folder.view3/styles/folder.css']], + 'Docker' => ['folder.view3.Docker.page', ['/plugins/folder.view3/scripts/docker.js', '/plugins/folder.view3/styles/docker.css'], ['docker_list', 'loadlist()']], + 'VMs' => ['folder.view3.VMs.page', ['/plugins/folder.view3/scripts/vm.js', '/plugins/folder.view3/styles/vm.css'], ['kvm_table', 'kvm_list', 'loadlist()']], + 'Dashboard' => ['folder.view3.Dashboard.page', ['/plugins/folder.view3/scripts/dashboard.js', '/plugins/folder.view3/styles/dashboard.css'], ['docker_view', 'vm_view', 'loadlist()']], + 'Settings/FolderView3' => ['FolderView3.page', ['/plugins/folder.view3/scripts/folderview3.js', '/plugins/folder.view3/styles/folderview3.css'], []], + "Folder?type=docker&id=$media" => ['Folder.page', ['/plugins/folder.view3/scripts/folder.js', '/plugins/folder.view3/styles/folder.css'], []], ]; $served = []; @mkdir('/boot/config/plugins/dynamix', 0777, true); foreach (['black', 'white', 'azure', 'gray'] as $theme) { file_put_contents('/boot/config/plugins/dynamix/dynamix.cfg', "[display]\ntheme=\"$theme\"\n"); - foreach ($pages as $page => [$file, $needs]) { + foreach ($pages as $page => [$file, $needs, $unraid]) { [$status, $html] = req('GET', "/$page"); $where = "$page ($theme)"; check($status === 200 && str_contains($html, ''), "$where: status $status, page cut short"); + // An element id, or a function FV3's script wraps when written as name() + foreach ($unraid as $hook) { + $found = str_ends_with($hook, '()') ? preg_match('/function\s+' . substr($hook, 0, -2) . '\s*\(/', $html) : preg_match("/id=[\"']{$hook}[\"']/", $html); + check($found === 1, "$where: Unraid's page has no $hook for FV3's script"); + } check(!preg_match('#Error evaluating content in plugins\\\\?/folder\.view3#', $html), "$where: Unraid caught an error in FV3's page"); $part = fv3t_page_part($html, "plugins/folder.view3/$file"); if ($part === '') { @@ -172,8 +178,11 @@ function get_json(string $path, ?int &$status = null) { } [$status] = req('POST', '/plugins/folder.view3/server/update_settings.php', ['key' => 'dashboard_docker_layout', 'value' => 'classic']); check($status === 200 && (json_decode((string)@file_get_contents("$flash/settings.json"), true)['dashboard_docker_layout'] ?? null) === 'classic', "update_settings: status $status"); +// Autostart out of the saved order: the sync puts it back in folder order, app-d's wait kept +file_put_contents('/var/lib/docker/unraid-autostart', "app-d 10\napp-a\n"); [$status, $body] = req('POST', '/plugins/folder.view3/server/sync_order.php', ['type' => 'docker']); -check($status === 200 && json_decode($body) !== null, "sync_order: status $status, $body"); +$autostart = (string)@file_get_contents('/var/lib/docker/unraid-autostart'); +check($status === 200 && json_decode($body) !== null && $autostart === "app-a\napp-d 10\n", "sync_order: status $status, $body, autostart " . json_encode($autostart)); // What the runs left in the logs: FV3's files must log nothing, and neither fake was asked anything it does not know // From 7.2 Unraid logs a .page's inline PHP as "in plugins/folder.view3/.page", with no leading slash From 21f4dfee0aac63522fb0acf1ce64df16cf3d9c71 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 20:00:11 +0800 Subject: [PATCH 30/72] ci: comments in the fake Unraid claim only what holds --- .github/unraid-compat/fake/prepend.php | 2 +- .github/unraid-compat/fake_unraid.sh | 2 +- .github/unraid-compat/pages_test.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/unraid-compat/fake/prepend.php b/.github/unraid-compat/fake/prepend.php index b45b0259..785ca16f 100644 --- a/.github/unraid-compat/fake/prepend.php +++ b/.github/unraid-compat/fake/prepend.php @@ -1,5 +1,5 @@ /boot/config/plugins/dockerMan/templates-user/my-app-a.xml <<'EOF' EOF -# Every PHP process starts as Unraid's php.ini has it: short tags, the prepend, errors to a log and never into a page +# PHP as Unraid's php.ini sets it: short tags, the prepend, errors to a log and never into a page cat > "$PHP_INI_DIR/conf.d/zz-fake-unraid.ini" < 1, 'vms' => 1, 'vmusage' => 'N']); foreach (array_merge($containers, $vms) as $name) check($status === 200 && str_contains($body, $name), "Dashboard tiles: status $status, no tile for $name"); -// FV3's reads, each answered from what Unraid's own code got from Docker and libvirt +// FV3's reads; the Docker and VM ones answer from what Unraid's own code got from the fakes $info = get_json('read_info.php?type=docker', $status); check($status === 200 && is_array($info) && $sorted(array_keys($info)) === $containers, "read_info docker: status $status, containers " . json_encode(is_array($info) ? array_keys($info) : $info)); if (is_array($info) && $sorted(array_keys($info)) === $containers) { @@ -157,7 +157,7 @@ function get_json(string $path, ?int &$status = null) { } @unlink('/boot/config/plugins/dynamix/dynamix.cfg'); -// Writes go through Unraid's CSRF check: without the token nothing is saved and FV3 never answers +// Writes go through Unraid's CSRF check: a create without the right token saves nothing and FV3 never answers $folder = fn(string $name, array $members) => json_encode(['name' => $name, 'icon' => '', 'regex' => '', 'containers' => $members, 'settings' => ['preview' => 1], 'actions' => []]); $before = md5_file("$flash/docker.json"); foreach (['missing' => null, 'wrong' => 'not-the-token'] as $case => $token) { From a5b60e9803c1bc78cf6cb0f7f32518879a5043f0 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 20:15:51 +0800 Subject: [PATCH 31/72] ci: the fakes refuse forms they do not answer, and each step checks everything it leaves CodeRabbit round 1: a container-list filter or a stats selector is UNKNOWN, not answered as if absent; the libvirt XML calls likewise. create, update, delete and the settings save are checked against the whole saved file, the sync against Unraid's own order too, and read.php against the complete folders it returns. --- .github/unraid-compat/fake/docker.php | 6 ++-- .github/unraid-compat/fake/libvirt.php | 7 +++- .github/unraid-compat/pages_test.php | 47 +++++++++++++++----------- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/.github/unraid-compat/fake/docker.php b/.github/unraid-compat/fake/docker.php index 225872ee..ed36b7ee 100644 --- a/.github/unraid-compat/fake/docker.php +++ b/.github/unraid-compat/fake/docker.php @@ -18,7 +18,9 @@ function fv3d_running(array $d): array { return array_values(array_filter($d['co function fv3d_answer(array $d, string $method, string $target): array { $path = (string)parse_url($target, PHP_URL_PATH); parse_str((string)parse_url($target, PHP_URL_QUERY), $query); - if ($method !== 'GET') return [null, null]; + // Only `all` on the two lists is answered; a filter or any other parameter is a request this fake does not know + $lists = in_array($path, ['/containers/json', '/images/json'], true); + if ($method !== 'GET' || array_diff(array_keys($query), $lists ? ['all'] : [])) return [null, null]; if ($path === '/containers/json') return [200, ($query['all'] ?? '0') !== '0' ? $d['containers'] : fv3d_running($d)]; if (preg_match('#^/containers/([^/]+)/json$#', $path, $m)) { $ct = fv3d_container($d, $m[1]); @@ -44,7 +46,7 @@ function fv3d_cli(array $d, array $args): ?array { if (preg_match('/^ps --filter label=(\S+) --format \{\{\.Names\}\}$/', $line, $m)) { return array_map(fn($c) => ltrim($c['Names'][0], '/'), array_values(array_filter(fv3d_running($d), fn($c) => isset($c['Labels'][$m[1]])))); } - if (str_starts_with($line, 'stats --no-stream') && $format === '{{.ID}};{{.CPUPerc}};{{.MemUsage}}') { + if ($line === 'stats --no-stream' && $format === '{{.ID}};{{.CPUPerc}};{{.MemUsage}}') { return array_map(fn($c) => substr($c['Id'], 0, 12) . ';0.50%;12.5MiB / 7.7GiB', fv3d_running($d)); } if (preg_match('/^inspect (\S+)$/', $line, $m) && ($ct = fv3d_container($d, $m[1]))) { diff --git a/.github/unraid-compat/fake/libvirt.php b/.github/unraid-compat/fake/libvirt.php index 2440d5a2..71c37f1e 100644 --- a/.github/unraid-compat/fake/libvirt.php +++ b/.github/unraid-compat/fake/libvirt.php @@ -66,7 +66,11 @@ function libvirt_domain_get_uuid_string($dom) { return fv3l_domain($dom)['uuid'] function libvirt_domain_get_id($dom) { $d = fv3l_domain($dom); return $d ? $d['id'] : false; } function libvirt_domain_is_active($dom) { $d = fv3l_domain($dom); return $d ? $d['id'] > 0 : false; } function libvirt_domain_get_autostart($dom) { $d = fv3l_domain($dom); return $d ? (int)$d['autostart'] : false; } -function libvirt_domain_get_xml_desc($dom, $xpath = null, $flags = 0) { return fv3l_domain($dom)['xml'] ?? false; } +// The live XML only, as Unraid asks for it ($dom, 0): an xpath or flags would be a form this fake does not answer +function libvirt_domain_get_xml_desc($dom, $xpath = null, $flags = 0) { + if (!in_array($xpath, [null, 0, '0', ''], true) || $flags !== 0) { fv3l_log('UNKNOWN libvirt_domain_get_xml_desc with an xpath or flags'); return false; } + return fv3l_domain($dom)['xml'] ?? false; +} function libvirt_list_domain_snapshots($dom) { return fv3l_domain($dom) ? [] : false; } function libvirt_domain_get_info($dom) { @@ -112,6 +116,7 @@ function libvirt_domain_get_counts($conn) { // php-libvirt's answer: the matches' text in order, their count under 'num', and false when nothing matches function libvirt_domain_xml_xpath($dom, $xpath, $flags = 0) { + if ($flags !== 0) { fv3l_log('UNKNOWN libvirt_domain_xml_xpath on the inactive XML'); return false; } $d = fv3l_domain($dom); if (!$d) return false; $doc = new DOMDocument(); diff --git a/.github/unraid-compat/pages_test.php b/.github/unraid-compat/pages_test.php index c4482c02..f0e76165 100644 --- a/.github/unraid-compat/pages_test.php +++ b/.github/unraid-compat/pages_test.php @@ -54,6 +54,13 @@ function get_json(string $path, ?int &$status = null) { $fixture = json_decode(file_get_contents(__DIR__ . '/fixtures/docker.json'), true); $shortId = fn(string $name) => substr($fixture['inspect'][$name]['Id'], 0, 12); $sorted = function (array $a): array { sort($a); return $a; }; +// The saved setup fake_unraid.sh writes, as FV3 stores a folder +$folder = fn(string $name, array $members, string $regex = '') => ['name' => $name, 'icon' => '', 'regex' => $regex, 'containers' => $members, 'settings' => ['preview' => 1], 'actions' => []]; +$mediaFolder = $folder('Media', ['app-a']); +$toolsFolder = $folder('Tools', [], '^tool-'); +$labFolder = $folder('Lab', ['Debian 12']); +// read.php adds the fields every reader dereferences (fv3_normalize_folders), without writing them +$read = fn(array $f) => $f + ['hidden_preview' => []]; // Unraid's own lists, which FV3's pages fold into folders [$status, $body] = req('GET', '/plugins/dynamix.docker.manager/include/DockerContainers.php'); @@ -102,9 +109,9 @@ function get_json(string $path, ?int &$status = null) { $env = get_json('read_image_env.php?image=' . urlencode($image), $status); check($status === 200 && $env === ['env' => ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin']], "read_image_env: status $status, " . json_encode($env)); $folders = get_json('read.php?type=docker', $status); -check($status === 200 && array_keys((array)$folders) === [$media, $tools], 'read docker: ' . json_encode($folders)); +check($status === 200 && $folders === [$media => $read($mediaFolder), $tools => $read($toolsFolder)], 'read docker: ' . json_encode($folders)); $folders = get_json('read.php?type=vm', $status); -check($status === 200 && ($folders[$lab]['containers'] ?? null) === ['Debian 12'], 'read vm: ' . json_encode($folders)); +check($status === 200 && $folders === [$lab => $read($labFolder)], 'read vm: ' . json_encode($folders)); $autostart = get_json('read_autostart.php', $status); check($status === 200 && ($autostart['autostart'] ?? null) === [['name' => 'app-a', 'wait' => 0], ['name' => 'app-d', 'wait' => 10]], 'read_autostart: ' . json_encode($autostart)); foreach (['read_order.php?type=docker', 'read_order.php?type=vm', 'read_settings.php', 'list_themes.php', 'read_css_config.php', 'read_css_defaults.php', @@ -157,32 +164,34 @@ function get_json(string $path, ?int &$status = null) { } @unlink('/boot/config/plugins/dynamix/dynamix.cfg'); -// Writes go through Unraid's CSRF check: a create without the right token saves nothing and FV3 never answers -$folder = fn(string $name, array $members) => json_encode(['name' => $name, 'icon' => '', 'regex' => '', 'containers' => $members, 'settings' => ['preview' => 1], 'actions' => []]); +// Writes go through Unraid's CSRF check: a create without the right token saves nothing and FV3 never answers. +// Each write leaves every saved folder, setting and order exactly as written here. +$prefs = "0=\"folder-$media\"\n1=\"app-a\"\n2=\"app-b\"\n3=\"folder-$tools\"\n4=\"tool-c\"\n5=\"app-d\"\n"; +$saved = fn(string $type) => json_decode((string)@file_get_contents("$flash/$type.json"), true); $before = md5_file("$flash/docker.json"); foreach (['missing' => null, 'wrong' => 'not-the-token'] as $case => $token) { - [$status, $body, $headers] = req('POST', '/plugins/folder.view3/server/create.php', ['type' => 'docker', 'content' => $folder('New', ['app-d'])], $token); + [$status, $body, $headers] = req('POST', '/plugins/folder.view3/server/create.php', ['type' => 'docker', 'content' => json_encode($folder('New', ['app-d']))], $token); check(md5_file("$flash/docker.json") === $before && !isset($headers['x-fv3-answer']), "create with the token $case: saved or answered by FV3 (status $status)"); } -$saved = fn(string $type) => json_decode(file_get_contents("$flash/$type.json"), true); -[$status, , $headers] = req('POST', '/plugins/folder.view3/server/create.php', ['type' => 'docker', 'content' => $folder('New', ['app-d'])]); -$new = array_values(array_diff(array_keys($saved('docker')), [$media, $tools])); -check($status === 200 && isset($headers['x-fv3-answer']) && count($new) === 1 && $saved('docker')[$new[0]]['containers'] === ['app-d'], "create: status $status, " . json_encode($saved('docker'))); -[$status] = req('POST', '/plugins/folder.view3/server/update.php', ['type' => 'docker', 'id' => $media, 'content' => $folder('Media 2', ['app-a'])]); -check($status === 200 && $saved('docker')[$media]['name'] === 'Media 2', "update: status $status, " . json_encode($saved('docker')[$media] ?? null)); -[$status] = req('POST', '/plugins/folder.view3/server/update.php', ['type' => 'vm', 'id' => $lab, 'content' => $folder('Lab 2', ['Debian 12'])]); -check($status === 200 && $saved('vm')[$lab]['name'] === 'Lab 2', "update vm: status $status, " . json_encode($saved('vm')[$lab] ?? null)); -if ($new) { - [$status] = req('POST', '/plugins/folder.view3/server/delete.php', ['type' => 'docker', 'id' => $new[0]]); - check($status === 200 && array_keys($saved('docker')) === [$media, $tools], "delete: status $status, " . json_encode(array_keys($saved('docker')))); -} +[$status, $body, $headers] = req('POST', '/plugins/folder.view3/server/create.php', ['type' => 'docker', 'content' => json_encode($folder('New', ['app-d']))]); +$new = (string)(json_decode($body, true)['id'] ?? ''); +check($status === 200 && isset($headers['x-fv3-answer']) && $saved('docker') === [$media => $mediaFolder, $tools => $toolsFolder, $new => $folder('New', ['app-d'])], + "create: status $status, $body, saved " . json_encode($saved('docker'))); +[$status] = req('POST', '/plugins/folder.view3/server/update.php', ['type' => 'docker', 'id' => $media, 'content' => json_encode($folder('Media 2', ['app-a']))]); +$mediaFolder = $folder('Media 2', ['app-a']); +check($status === 200 && $saved('docker') === [$media => $mediaFolder, $tools => $toolsFolder, $new => $folder('New', ['app-d'])], "update: status $status, saved " . json_encode($saved('docker'))); +[$status] = req('POST', '/plugins/folder.view3/server/update.php', ['type' => 'vm', 'id' => $lab, 'content' => json_encode($folder('Lab 2', ['Debian 12']))]); +check($status === 200 && $saved('vm') === [$lab => $folder('Lab 2', ['Debian 12'])], "update vm: status $status, saved " . json_encode($saved('vm'))); +[$status] = req('POST', '/plugins/folder.view3/server/delete.php', ['type' => 'docker', 'id' => $new]); +check($status === 200 && $saved('docker') === [$media => $mediaFolder, $tools => $toolsFolder], "delete: status $status, saved " . json_encode($saved('docker'))); [$status] = req('POST', '/plugins/folder.view3/server/update_settings.php', ['key' => 'dashboard_docker_layout', 'value' => 'classic']); -check($status === 200 && (json_decode((string)@file_get_contents("$flash/settings.json"), true)['dashboard_docker_layout'] ?? null) === 'classic', "update_settings: status $status"); -// Autostart out of the saved order: the sync puts it back in folder order, app-d's wait kept +check($status === 200 && $saved('settings') === ['dashboard_docker_layout' => 'classic'], "update_settings: status $status, saved " . json_encode($saved('settings'))); +// Autostart out of the saved order: the sync puts it back in folder order, app-d's wait kept, Unraid's own order untouched file_put_contents('/var/lib/docker/unraid-autostart', "app-d 10\napp-a\n"); [$status, $body] = req('POST', '/plugins/folder.view3/server/sync_order.php', ['type' => 'docker']); $autostart = (string)@file_get_contents('/var/lib/docker/unraid-autostart'); check($status === 200 && json_decode($body) !== null && $autostart === "app-a\napp-d 10\n", "sync_order: status $status, $body, autostart " . json_encode($autostart)); +check((string)@file_get_contents('/boot/config/plugins/dockerMan/userprefs.cfg') === $prefs, "Unraid's Docker order changed by FV3's writes"); // What the runs left in the logs: FV3's files must log nothing, and neither fake was asked anything it does not know // From 7.2 Unraid logs a .page's inline PHP as "in plugins/folder.view3/.page", with no leading slash From 3d248118b04e0e10b9ea34c6cd017871eb4e90eb Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 21:25:07 +0800 Subject: [PATCH 32/72] ci: the fakes refuse every form Unraid does not send, and each step checks all saved state right after it - docker.php reads `all` as Docker does (false for empty, 0, no, false, none) and refuses all[] - libvirt.php refuses a stats or flags selection, another URI and a read-only connection - pages_test.php checks FV3's folders and settings and Unraid's Docker, VM and autostart orders against hand-written values after the reads, the pages and each write --- .github/unraid-compat/fake/docker.php | 9 ++-- .github/unraid-compat/fake/libvirt.php | 10 ++++- .github/unraid-compat/pages_test.php | 59 +++++++++++++++++--------- 3 files changed, 53 insertions(+), 25 deletions(-) diff --git a/.github/unraid-compat/fake/docker.php b/.github/unraid-compat/fake/docker.php index ed36b7ee..2f2bdd75 100644 --- a/.github/unraid-compat/fake/docker.php +++ b/.github/unraid-compat/fake/docker.php @@ -18,10 +18,13 @@ function fv3d_running(array $d): array { return array_values(array_filter($d['co function fv3d_answer(array $d, string $method, string $target): array { $path = (string)parse_url($target, PHP_URL_PATH); parse_str((string)parse_url($target, PHP_URL_QUERY), $query); - // Only `all` on the two lists is answered; a filter or any other parameter is a request this fake does not know + // Only `all` on the two lists is answered; a filter, any other parameter or all[] (Docker's key `all[]`, not `all`) is a + // request this fake does not know $lists = in_array($path, ['/containers/json', '/images/json'], true); - if ($method !== 'GET' || array_diff(array_keys($query), $lists ? ['all'] : [])) return [null, null]; - if ($path === '/containers/json') return [200, ($query['all'] ?? '0') !== '0' ? $d['containers'] : fv3d_running($d)]; + if ($method !== 'GET' || array_diff(array_keys($query), $lists ? ['all'] : []) || array_filter($query, 'is_array')) return [null, null]; + // Docker's httputils.BoolValue: empty, 0, no, false and none are false, any other value true + $all = !in_array(strtolower(trim($query['all'] ?? '')), ['', '0', 'no', 'false', 'none'], true); + if ($path === '/containers/json') return [200, $all ? $d['containers'] : fv3d_running($d)]; if (preg_match('#^/containers/([^/]+)/json$#', $path, $m)) { $ct = fv3d_container($d, $m[1]); return $ct ? [200, $ct] : [404, ['message' => "No such container: {$m[1]}"]]; diff --git a/.github/unraid-compat/fake/libvirt.php b/.github/unraid-compat/fake/libvirt.php index 71c37f1e..ac656a6d 100644 --- a/.github/unraid-compat/fake/libvirt.php +++ b/.github/unraid-compat/fake/libvirt.php @@ -52,7 +52,11 @@ function fv3l_lookup(string $field, $value) { return false; } -function libvirt_connect($uri = null, $readonly = true, $credentials = []) { return fv3l_handle('connection', 'qemu:///system'); } +// Unraid's Libvirt class connects read-write to qemu:///system; another URI or a read-only connection is not this fake +function libvirt_connect($uri = null, $readonly = true, $credentials = []) { + if ($uri !== 'qemu:///system' || $readonly !== false) { fv3l_log('UNKNOWN libvirt_connect to ' . var_export($uri, true) . ($readonly === false ? '' : ' read-only')); return false; } + return fv3l_handle('connection', 'qemu:///system'); +} function libvirt_get_last_error() { return $GLOBALS['fv3l_error'] ?? null; } function libvirt_logfile_set($filename, $maxsize = 0) { return true; } function libvirt_connect_get_uri($conn) { return 'qemu:///system'; } @@ -97,8 +101,10 @@ function libvirt_domain_get_block_info($dom, $dev) { return false; } -// Unraid's VM usage poller reads these keys per domain name; a running domain has used some CPU time +// Unraid's VM usage poller asks for every stat of every domain ($conn alone) and reads these keys; a stats or flags selection is +// a form this fake does not answer. A running domain has used some CPU time function libvirt_connect_get_all_domain_stats($conn, $stats = 0, $flags = 0) { + if ($stats !== 0 || $flags !== 0) { fv3l_log('UNKNOWN libvirt_connect_get_all_domain_stats with a stats or flags selection'); return false; } $all = []; foreach (fv3l_domains() as $name => $d) { $info = libvirt_domain_get_info(fv3l_handle('domain', $name)); diff --git a/.github/unraid-compat/pages_test.php b/.github/unraid-compat/pages_test.php index f0e76165..e3ba3af4 100644 --- a/.github/unraid-compat/pages_test.php +++ b/.github/unraid-compat/pages_test.php @@ -62,6 +62,23 @@ function get_json(string $path, ?int &$status = null) { // read.php adds the fields every reader dereferences (fv3_normalize_folders), without writing them $read = fn(array $f) => $f + ['hidden_preview' => []]; +// FV3's saved folders and settings and Unraid's orders, as fake_unraid.sh wrote them: FV3's reads, its pages and each write below +// leave them exactly so, bar what the write is meant to change; $leaves checks all six after the reads, the pages and each write +$dockerPrefs = '/boot/config/plugins/dockerMan/userprefs.cfg'; +$vmPrefs = '/boot/config/plugins/dynamix.vm.manager/userprefs.cfg'; +$autostartFile = '/var/lib/docker/unraid-autostart'; +$saved = fn(string $type) => is_file("$flash/$type.json") ? json_decode(file_get_contents("$flash/$type.json"), true) ?? 'not JSON' : 'absent'; +$state = fn() => ['docker' => $saved('docker'), 'vm' => $saved('vm'), 'settings' => $saved('settings'), 'Docker order' => (string)@file_get_contents($dockerPrefs), + 'VM order' => (string)@file_get_contents($vmPrefs), 'autostart' => (string)@file_get_contents($autostartFile)]; +$seeded = ['docker' => [$media => $mediaFolder, $tools => $toolsFolder], 'vm' => [$lab => $labFolder], 'settings' => 'absent', + 'Docker order' => "0=\"folder-$media\"\n1=\"app-a\"\n2=\"app-b\"\n3=\"folder-$tools\"\n4=\"tool-c\"\n5=\"app-d\"\n", + 'VM order' => "0=\"folder-$lab\"\n1=\"Debian 12\"\n2=\"Home Assistant\"\n3=\"Windows 11\"\n", 'autostart' => "app-a\napp-d 10\n"]; +$leaves = function (string $step, array $changed = []) use ($seeded, $state): void { + static $want = null; + $want = array_replace($want ?? $seeded, $changed); + foreach ($state() as $what => $now) check($now === $want[$what], "$step left $what as " . json_encode($now)); +}; + // Unraid's own lists, which FV3's pages fold into folders [$status, $body] = req('GET', '/plugins/dynamix.docker.manager/include/DockerContainers.php'); check($status === 200 && substr_count($body, "") === 4, "Docker list: status $status, " . substr_count($body, "") . ' container rows, not 4'); @@ -123,6 +140,7 @@ function get_json(string $path, ?int &$status = null) { check($status === 200 && $body === '2099.01.01', "version: status $status, $body"); [$status, $body] = req('GET', '/plugins/folder.view3/server/cpu.php'); check($status === 200 && (int)$body > 0, "cpu: status $status, $body"); +$leaves("FV3's reads"); // FV3's pages in every theme: rendered whole, Unraid's lists that FV3's scripts fold present, FV3's own part present, and every // file that part links served by this Unraid @@ -163,35 +181,36 @@ function get_json(string $path, ?int &$status = null) { } } @unlink('/boot/config/plugins/dynamix/dynamix.cfg'); +$leaves("FV3's pages"); -// Writes go through Unraid's CSRF check: a create without the right token saves nothing and FV3 never answers. -// Each write leaves every saved folder, setting and order exactly as written here. -$prefs = "0=\"folder-$media\"\n1=\"app-a\"\n2=\"app-b\"\n3=\"folder-$tools\"\n4=\"tool-c\"\n5=\"app-d\"\n"; -$saved = fn(string $type) => json_decode((string)@file_get_contents("$flash/$type.json"), true); -$before = md5_file("$flash/docker.json"); +// Writes go through Unraid's CSRF check: a create without the right token saves nothing and FV3 never answers +$create = ['type' => 'docker', 'content' => json_encode($folder('New', ['app-d']))]; foreach (['missing' => null, 'wrong' => 'not-the-token'] as $case => $token) { - [$status, $body, $headers] = req('POST', '/plugins/folder.view3/server/create.php', ['type' => 'docker', 'content' => json_encode($folder('New', ['app-d']))], $token); - check(md5_file("$flash/docker.json") === $before && !isset($headers['x-fv3-answer']), "create with the token $case: saved or answered by FV3 (status $status)"); + [$status, $body, $headers] = req('POST', '/plugins/folder.view3/server/create.php', $create, $token); + check(!isset($headers['x-fv3-answer']), "create with the token $case: answered by FV3 (status $status)"); + $leaves("create with the token $case"); } -[$status, $body, $headers] = req('POST', '/plugins/folder.view3/server/create.php', ['type' => 'docker', 'content' => json_encode($folder('New', ['app-d']))]); +[$status, $body, $headers] = req('POST', '/plugins/folder.view3/server/create.php', $create); $new = (string)(json_decode($body, true)['id'] ?? ''); -check($status === 200 && isset($headers['x-fv3-answer']) && $saved('docker') === [$media => $mediaFolder, $tools => $toolsFolder, $new => $folder('New', ['app-d'])], - "create: status $status, $body, saved " . json_encode($saved('docker'))); +check($status === 200 && isset($headers['x-fv3-answer']) && $new !== '', "create: status $status, $body"); +$leaves('create', ['docker' => [$media => $mediaFolder, $tools => $toolsFolder, $new => $folder('New', ['app-d'])]]); [$status] = req('POST', '/plugins/folder.view3/server/update.php', ['type' => 'docker', 'id' => $media, 'content' => json_encode($folder('Media 2', ['app-a']))]); -$mediaFolder = $folder('Media 2', ['app-a']); -check($status === 200 && $saved('docker') === [$media => $mediaFolder, $tools => $toolsFolder, $new => $folder('New', ['app-d'])], "update: status $status, saved " . json_encode($saved('docker'))); +check($status === 200, "update: status $status"); +$leaves('update', ['docker' => [$media => $folder('Media 2', ['app-a']), $tools => $toolsFolder, $new => $folder('New', ['app-d'])]]); [$status] = req('POST', '/plugins/folder.view3/server/update.php', ['type' => 'vm', 'id' => $lab, 'content' => json_encode($folder('Lab 2', ['Debian 12']))]); -check($status === 200 && $saved('vm') === [$lab => $folder('Lab 2', ['Debian 12'])], "update vm: status $status, saved " . json_encode($saved('vm'))); +check($status === 200, "update vm: status $status"); +$leaves('update vm', ['vm' => [$lab => $folder('Lab 2', ['Debian 12'])]]); [$status] = req('POST', '/plugins/folder.view3/server/delete.php', ['type' => 'docker', 'id' => $new]); -check($status === 200 && $saved('docker') === [$media => $mediaFolder, $tools => $toolsFolder], "delete: status $status, saved " . json_encode($saved('docker'))); +check($status === 200, "delete: status $status"); +$leaves('delete', ['docker' => [$media => $folder('Media 2', ['app-a']), $tools => $toolsFolder]]); [$status] = req('POST', '/plugins/folder.view3/server/update_settings.php', ['key' => 'dashboard_docker_layout', 'value' => 'classic']); -check($status === 200 && $saved('settings') === ['dashboard_docker_layout' => 'classic'], "update_settings: status $status, saved " . json_encode($saved('settings'))); -// Autostart out of the saved order: the sync puts it back in folder order, app-d's wait kept, Unraid's own order untouched -file_put_contents('/var/lib/docker/unraid-autostart', "app-d 10\napp-a\n"); +check($status === 200, "update_settings: status $status"); +$leaves('update_settings', ['settings' => ['dashboard_docker_layout' => 'classic']]); +// Autostart out of the saved order: the sync puts it back in folder order with app-d's wait kept, and changes nothing else +file_put_contents($autostartFile, "app-d 10\napp-a\n"); [$status, $body] = req('POST', '/plugins/folder.view3/server/sync_order.php', ['type' => 'docker']); -$autostart = (string)@file_get_contents('/var/lib/docker/unraid-autostart'); -check($status === 200 && json_decode($body) !== null && $autostart === "app-a\napp-d 10\n", "sync_order: status $status, $body, autostart " . json_encode($autostart)); -check((string)@file_get_contents('/boot/config/plugins/dockerMan/userprefs.cfg') === $prefs, "Unraid's Docker order changed by FV3's writes"); +check($status === 200 && json_decode($body) !== null, "sync_order: status $status, $body"); +$leaves('sync_order', ['autostart' => "app-a\napp-d 10\n"]); // What the runs left in the logs: FV3's files must log nothing, and neither fake was asked anything it does not know // From 7.2 Unraid logs a .page's inline PHP as "in plugins/folder.view3/.page", with no leading slash From ada51de04553f39785da57be40a954e2d085bc0f Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 22:31:48 +0800 Subject: [PATCH 33/72] ci: stand-ins for dmidecode and ip, a missing command fails the run, and the guard needs no network - dmidecode.sh and ip.sh answer the forms Unraid's Dashboard and ipaddr() run (ip from network.ini), anything else UNKNOWN - pages_test.php fails on a command this image lacks, and checks every container's autostart, running state, WebUI, template and short id - docker.php refuses a label=key=value filter; lib.sh refuses a container with a network - the pages step runs on success() || failure() instead of !cancelled() --- .coderabbit.yaml | 3 ++- .github/unraid-compat/fake/dmidecode.sh | 10 ++++++++++ .github/unraid-compat/fake/docker.php | 3 ++- .github/unraid-compat/fake/ip.sh | 8 ++++++++ .github/unraid-compat/fake_unraid.sh | 2 ++ .github/unraid-compat/lib.sh | 8 +++++--- .github/unraid-compat/pages_test.php | 21 ++++++++++++++------- .github/workflows/ci.yml | 2 +- 8 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 .github/unraid-compat/fake/dmidecode.sh create mode 100644 .github/unraid-compat/fake/ip.sh diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 4bf0bbf0..73a03c99 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -220,7 +220,8 @@ reviews: router.php (nginx's locations), prepend.php (php.ini's prepend), docker.php (dockerd's socket and the docker CLI), libvirt.php (the php-libvirt extension), rc_service.sh (rc.docker and rc.libvirt), - connect_state.php (the Connect plugin), the dockerd and libvirtd + dmidecode.sh and ip.sh (those commands), connect_state.php (the + Connect plugin), the dockerd and libvirtd processes, and emhttp's state files (var.ini, network.ini, the docker and domain cfg). A call a stand-in does not answer fails the run: flag an answer that hides one, and any stand-in for code diff --git a/.github/unraid-compat/fake/dmidecode.sh b/.github/unraid-compat/fake/dmidecode.sh new file mode 100644 index 00000000..2010982f --- /dev/null +++ b/.github/unraid-compat/fake/dmidecode.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# Stand-in for the OS image's dmidecode: the SMBIOS types Unraid's Dashboard and VM pages read, for a synthetic board with 16 GiB +case "$*" in +-qt0) printf 'BIOS Information\n\tVendor: Example BIOS\n\tVersion: 1.00\n\tRelease Date: 01/01/2025\n\n' ;; +-qt2) printf 'Base Board Information\n\tManufacturer: Example Boards\n\tProduct Name: FV3-TEST\n\tVersion: 1.0\n\tSerial Number: FV3-0001\n\n' ;; +-qt4 | '-q -t 4') printf 'Processor Information\n\tSocket Designation: CPU0\n\tManufacturer: Example CPUs\n\tVersion: Example CPU 8-Core\n\tCurrent Speed: 3600 MHz\n\n' ;; +-qt16) printf 'Physical Memory Array\n\tLocation: System Board Or Motherboard\n\tUse: System Memory\n\tError Correction Type: None\n\tMaximum Capacity: 64 GB\n\tNumber Of Devices: 2\n\n' ;; +-qt17) for slot in A1 B1; do printf 'Memory Device\n\tSize: 8 GB\n\tLocator: DIMM_%s\n\tType: DDR4\n\tSpeed: 3200 MT/s\n\n' $slot; done ;; +*) echo "dmidecode UNKNOWN $*" >> /var/log/fv3-fakes.log; exit 1 ;; +esac diff --git a/.github/unraid-compat/fake/docker.php b/.github/unraid-compat/fake/docker.php index 2f2bdd75..23a8e62f 100644 --- a/.github/unraid-compat/fake/docker.php +++ b/.github/unraid-compat/fake/docker.php @@ -46,7 +46,8 @@ function fv3d_cli(array $d, array $args): ?array { $line = implode(' ', $args); if ($line === 'network ls' && $format === '{{.Name}}={{.Driver}}') return array_map(fn($n) => "{$n['Name']}={$n['Driver']}", $d['networks']); if ($line === 'ps -q --no-trunc') return array_column(fv3d_running($d), 'Id'); - if (preg_match('/^ps --filter label=(\S+) --format \{\{\.Names\}\}$/', $line, $m)) { + // A label's presence only, as Unraid filters: label=key=value is a form this fake does not answer + if (preg_match('/^ps --filter label=([^\s=]+) --format \{\{\.Names\}\}$/', $line, $m)) { return array_map(fn($c) => ltrim($c['Names'][0], '/'), array_values(array_filter(fv3d_running($d), fn($c) => isset($c['Labels'][$m[1]])))); } if ($line === 'stats --no-stream' && $format === '{{.ID}};{{.CPUPerc}};{{.MemUsage}}') { diff --git a/.github/unraid-compat/fake/ip.sh b/.github/unraid-compat/fake/ip.sh new file mode 100644 index 00000000..4f725a77 --- /dev/null +++ b/.github/unraid-compat/fake/ip.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# Stand-in for the OS image's ip: eth0's IPv4 address from network.ini, the one form Unraid's ipaddr() asks from 7.1 +addr=$(sed -n 's/^IPADDR:0="\(.*\)"$/\1/p' /var/local/emhttp/network.ini 2>/dev/null) +case "$*" in +'-4 -br addr show eth0 scope global') [ -n "$addr" ] && echo "eth0 UP $addr/24 " && exit 0 ;; +esac +echo "ip UNKNOWN $* (network.ini address: ${addr:-none})" >> /var/log/fv3-fakes.log +exit 1 diff --git a/.github/unraid-compat/fake_unraid.sh b/.github/unraid-compat/fake_unraid.sh index debcf16b..c117f683 100644 --- a/.github/unraid-compat/fake_unraid.sh +++ b/.github/unraid-compat/fake_unraid.sh @@ -70,6 +70,8 @@ EOF # Docker and libvirtd under their own names and rc scripts, so Unraid's pgrep(), /proc/ and status checks find them running mkdir -p /etc/rc.d && for rc in rc.docker rc.libvirt; do cp "$here/fake/rc_service.sh" /etc/rc.d/$rc && chmod +x /etc/rc.d/$rc; done +# The OS image's dmidecode and ip: the forms Unraid's Dashboard and ipaddr() run, anything else UNKNOWN +for cmd in dmidecode ip; do cp "$here/fake/$cmd.sh" /usr/sbin/$cmd && chmod +x /usr/sbin/$cmd; done printf '#!/bin/sh\nexec php %s/fake/docker.php cli "$@"\n' "$here" > /usr/local/bin/docker && chmod +x /usr/local/bin/docker ln -sf "$(command -v php)" /usr/local/sbin/dockerd; ln -sf "$(command -v sleep)" /usr/local/sbin/libvirtd dockerd "$here/fake/docker.php" serve > /var/log/dockerd.log 2>&1 & diff --git a/.github/unraid-compat/lib.sh b/.github/unraid-compat/lib.sh index b9d96bee..ad48d599 100644 --- a/.github/unraid-compat/lib.sh +++ b/.github/unraid-compat/lib.sh @@ -1,7 +1,9 @@ #!/bin/bash -# Shared by install_test.sh and fake_unraid.sh: source it from the repo root with $version set. These replace system files, -# so they run only in a fresh Docker container, never on a host. -if [ ! -f /.dockerenv ] || [ -e /etc/unraid-version ] || [ -d /boot/config ]; then echo 'Refusing to run outside a fresh Docker container' >&2; exit 2; fi +# Shared by install_test.sh and fake_unraid.sh: source it from the repo root with $version set. These replace system files and +# a download must fail, so they run only in a fresh Docker container with no network (loopback alone), never on a host. +if [ ! -f /.dockerenv ] || [ -e /etc/unraid-version ] || [ -d /boot/config ] || [ "$(ls /sys/class/net 2>/dev/null)" != lo ]; then + echo 'Refusing to run outside a fresh Docker container with no network' >&2; exit 2 +fi name=folder.view3 docroot=/usr/local/emhttp flash=/boot/config/plugins/$name diff --git a/.github/unraid-compat/pages_test.php b/.github/unraid-compat/pages_test.php index e3ba3af4..80214a59 100644 --- a/.github/unraid-compat/pages_test.php +++ b/.github/unraid-compat/pages_test.php @@ -93,12 +93,16 @@ function get_json(string $path, ?int &$status = null) { $info = get_json('read_info.php?type=docker', $status); check($status === 200 && is_array($info) && $sorted(array_keys($info)) === $containers, "read_info docker: status $status, containers " . json_encode(is_array($info) ? array_keys($info) : $info)); if (is_array($info) && $sorted(array_keys($info)) === $containers) { - check($info['app-a']['info']['State']['Autostart'] === true && $info['app-d']['info']['State']['Autostart'] === true && $info['app-b']['info']['State']['Autostart'] === false, - 'read_info docker: autostart not app-a and app-d only'); - check(str_ends_with($info['app-a']['info']['State']['WebUi'], ':18080/'), "read_info docker: app-a WebUI {$info['app-a']['info']['State']['WebUi']} does not reach host port 18080"); - check(($info['app-a']['info']['template']['path'] ?? '') === '/boot/config/plugins/dockerMan/templates-user/my-app-a.xml', 'read_info docker: app-a lost its template'); - check($info['tool-c']['info']['State']['Running'] === false && $info['app-b']['info']['State']['Running'] === true, 'read_info docker: running states wrong'); - check($info['app-d']['shortId'] === $shortId('app-d'), 'read_info docker: app-d short id wrong'); + $seen = array_map(fn($c) => [$c['info']['State']['Autostart'], $c['info']['State']['Running'], $c['info']['State']['WebUi'], $c['info']['template']['path'] ?? null, $c['shortId']], $info); + ksort($seen); + // [IP] is ipaddr() on 7.0 (network.ini's address); from 7.1 DockerUtil::host() needs a LAN port, which a container with no network lacks + $webui = version_compare($version, '7.1', '<') ? 'http://192.0.2.10:18080/' : 'http://:18080/'; + check($seen === [ + 'app-a' => [true, true, $webui, '/boot/config/plugins/dockerMan/templates-user/my-app-a.xml', $shortId('app-a')], + 'app-b' => [false, true, '', null, $shortId('app-b')], + 'app-d' => [true, true, '', null, $shortId('app-d')], + 'tool-c' => [false, false, '', null, $shortId('tool-c')], + ], 'read_info docker: autostart, running, WebUI, template or short id wrong: ' . json_encode($seen)); } $info = get_json('read_info.php?type=vm', $status); check($status === 200 && is_array($info) && $sorted(array_keys($info)) === $vms, "read_info vm: status $status, VMs " . json_encode(is_array($info) ? array_keys($info) : $info)); @@ -212,7 +216,8 @@ function get_json(string $path, ?int &$status = null) { check($status === 200 && json_decode($body) !== null, "sync_order: status $status, $body"); $leaves('sync_order', ['autostart' => "app-a\napp-d 10\n"]); -// What the runs left in the logs: FV3's files must log nothing, and neither fake was asked anything it does not know +// What the runs left in the logs: FV3's files must log nothing, no stand-in was asked anything it does not answer, and no +// command the webGUI ran was missing where the shell's error reached php -S's log (one run with 2>/dev/null fails unseen) // From 7.2 Unraid logs a .page's inline PHP as "in plugins/folder.view3/.page", with no leading slash $fv3Lines = preg_grep('#plugins/folder\.view3/#', file('/var/log/phplog', FILE_IGNORE_NEW_LINES)); check(!$fv3Lines, "PHP logged from FV3's files:\n " . implode("\n ", array_slice($fv3Lines, 0, 20))); @@ -222,6 +227,8 @@ function get_json(string $path, ?int &$status = null) { check(!$reported, "FV3's error.log:\n " . implode("\n ", $reported)); $unknown = preg_grep('/UNKNOWN/', file('/var/log/fv3-fakes.log', FILE_IGNORE_NEW_LINES)); check(!$unknown, "the fakes were asked what they do not answer:\n " . implode("\n ", array_unique($unknown))); +$missing = preg_grep('/command not found/', file('/var/log/php-server.log', FILE_IGNORE_NEW_LINES)); +check(!$missing, "the webGUI ran commands this image lacks:\n " . implode("\n ", array_unique($missing))); if ($failures) { echo "FAILED [Unraid $version]: " . count($failures) . " of $checks checks\n- " . implode("\n- ", $failures) . "\n"; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c045d78..2c5905cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -216,7 +216,7 @@ jobs: # Runs after a failed install test too: the two report on different things - name: FV3's endpoints and pages through this Unraid's webGUI, Docker and libvirt faked - if: ${{ !cancelled() && env.RUNS == 'true' }} + if: ${{ (success() || failure()) && env.RUNS == 'true' }} env: UNRAID_VERSION: ${{ matrix.unraid }} run: docker run --rm --network none -v "$PWD:/repo" -w /repo fv3-unraid bash .github/unraid-compat/pages_test.sh .webgui "$UNRAID_VERSION" From c8f491854af278debbc1bc7e3a87312c9087152e Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sat, 14 Nov 2026 23:43:48 +0800 Subject: [PATCH 34/72] ci: the fakes answer each command whole, each read is checked against what was seeded, and the fake's state is as Unraid keeps it --- .github/unraid-compat/fake/docker.php | 17 ++++------ .github/unraid-compat/fake/libvirt.php | 5 +-- .github/unraid-compat/fake/rc_service.sh | 2 +- .github/unraid-compat/fake_unraid.sh | 25 ++++++++++++-- .github/unraid-compat/fixtures/vms.json | 6 ++-- .github/unraid-compat/pages_test.php | 43 ++++++++++++++++++++---- 6 files changed, 73 insertions(+), 25 deletions(-) diff --git a/.github/unraid-compat/fake/docker.php b/.github/unraid-compat/fake/docker.php index 23a8e62f..e6b24307 100644 --- a/.github/unraid-compat/fake/docker.php +++ b/.github/unraid-compat/fake/docker.php @@ -39,25 +39,22 @@ function fv3d_answer(array $d, string $method, string $target): array { return [null, null]; } -// The docker CLI lines Unraid and FV3 run, answered in the CLI's own output format +// The docker CLI lines Unraid and FV3 run, each matched whole (its --format too) and answered in the CLI's own output format function fv3d_cli(array $d, array $args): ?array { - $format = null; - foreach ($args as $i => $a) if (str_starts_with($a, '--format=')) { $format = substr($a, 9); unset($args[$i]); } $line = implode(' ', $args); - if ($line === 'network ls' && $format === '{{.Name}}={{.Driver}}') return array_map(fn($n) => "{$n['Name']}={$n['Driver']}", $d['networks']); + if ($line === 'network ls --format={{.Name}}={{.Driver}}') return array_map(fn($n) => "{$n['Name']}={$n['Driver']}", $d['networks']); if ($line === 'ps -q --no-trunc') return array_column(fv3d_running($d), 'Id'); // A label's presence only, as Unraid filters: label=key=value is a form this fake does not answer if (preg_match('/^ps --filter label=([^\s=]+) --format \{\{\.Names\}\}$/', $line, $m)) { return array_map(fn($c) => ltrim($c['Names'][0], '/'), array_values(array_filter(fv3d_running($d), fn($c) => isset($c['Labels'][$m[1]])))); } - if ($line === 'stats --no-stream' && $format === '{{.ID}};{{.CPUPerc}};{{.MemUsage}}') { + if ($line === 'stats --no-stream --format={{.ID}};{{.CPUPerc}};{{.MemUsage}}') { return array_map(fn($c) => substr($c['Id'], 0, 12) . ';0.50%;12.5MiB / 7.7GiB', fv3d_running($d)); } - if (preg_match('/^inspect (\S+)$/', $line, $m) && ($ct = fv3d_container($d, $m[1]))) { - if ($format === '{{.Name}}') return [$ct['Name']]; - if (preg_match('/^\{\{range \.NetworkSettings\.Networks\}\}\{\{\.(IPAddress|GlobalIPv6Address)\}\} \{\{end\}\}$/', (string)$format, $f)) { - return [implode('', array_map(fn($n) => ($n[$f[1]] ?? '') . ' ', $ct['NetworkSettings']['Networks']))]; - } + // DockerUtil::myIP() + if (preg_match('/^inspect --format=\{\{range \.NetworkSettings\.Networks\}\}\{\{\.(IPAddress|GlobalIPv6Address)\}\} \{\{end\}\} (\S+)$/', $line, $m) + && ($ct = fv3d_container($d, $m[2]))) { + return [implode('', array_map(fn($n) => ($n[$m[1]] ?? '') . ' ', $ct['NetworkSettings']['Networks']))]; } return null; } diff --git a/.github/unraid-compat/fake/libvirt.php b/.github/unraid-compat/fake/libvirt.php index ac656a6d..41f15ba5 100644 --- a/.github/unraid-compat/fake/libvirt.php +++ b/.github/unraid-compat/fake/libvirt.php @@ -102,7 +102,8 @@ function libvirt_domain_get_block_info($dom, $dev) { } // Unraid's VM usage poller asks for every stat of every domain ($conn alone) and reads these keys; a stats or flags selection is -// a form this fake does not answer. A running domain has used some CPU time +// a form this fake does not answer. An active domain (running or paused) has used some CPU time and holds all its memory +// (balloon.rss, which libvirt reports only for an active domain) function libvirt_connect_get_all_domain_stats($conn, $stats = 0, $flags = 0) { if ($stats !== 0 || $flags !== 0) { fv3l_log('UNKNOWN libvirt_connect_get_all_domain_stats with a stats or flags selection'); return false; } $all = []; @@ -110,7 +111,7 @@ function libvirt_connect_get_all_domain_stats($conn, $stats = 0, $flags = 0) { $info = libvirt_domain_get_info(fv3l_handle('domain', $name)); $all[$name] = ['state.state' => $d['state'], 'state.reason' => 1, 'cpu.time' => $d['id'] > 0 ? 125000000000 : 0, 'vcpu.current' => $info['nrVirtCpu'], 'vcpu.maximum' => $info['nrVirtCpu'], 'balloon.current' => $info['memory'], - 'balloon.maximum' => $info['maxMem'], 'net.count' => 0, 'block.count' => 0]; + 'balloon.maximum' => $info['maxMem'], 'net.count' => 0, 'block.count' => 0] + ($d['id'] > 0 ? ['balloon.rss' => $info['memory']] : []); } return $all; } diff --git a/.github/unraid-compat/fake/rc_service.sh b/.github/unraid-compat/fake/rc_service.sh index 1f5fa134..f34303f3 100644 --- a/.github/unraid-compat/fake/rc_service.sh +++ b/.github/unraid-compat/fake/rc_service.sh @@ -1,5 +1,5 @@ #!/bin/bash # Stand-in for the OS image's /etc/rc.d/rc.docker and rc.libvirt: `status` says running (the Dashboard draws its tiles from it) -[ "$1" = status ] && exit 0 +[ "$*" = status ] && exit 0 echo "rc UNKNOWN $0 $*" >> /var/log/fv3-fakes.log exit 1 diff --git a/.github/unraid-compat/fake_unraid.sh b/.github/unraid-compat/fake_unraid.sh index c117f683..6daf410f 100644 --- a/.github/unraid-compat/fake_unraid.sh +++ b/.github/unraid-compat/fake_unraid.sh @@ -13,24 +13,45 @@ fv3_build "$repo" 2099.01.01 beta || fail 'package build' tar -xJf "$work/2099.01.01/dist/$name-2099.01.01-x86_64-1.txz" -C / || fail 'package unpack' mkdir -p "$flash/styles" "$flash/scripts" && printf '2099.01.01' > "$flash/version" -# Unraid's own state, as emhttp writes it with the array started +# Unraid's own state in emhttp's files, the array started: a synthetic licence and flash, root alone, and no devices, disks +# or user shares printf 'version="%s"\n' "$version" > /etc/unraid-version cat >> /var/local/emhttp/var.ini < /var/local/emhttp/$ini.ini; done +printf '["root"]\nidx="0"\nname="root"\ndesc="Console and webGui login account"\npasswd="yes"\n' > /var/local/emhttp/users.ini printf '[eth0]\nBONDING="no"\nBRIDGING="no"\nIPADDR:0="192.0.2.10"\nNETMASK:0="255.255.255.0"\nUSE_DHCP:0="no"\n' > /var/local/emhttp/network.ini printf 'DOCKER_ENABLED="yes"\n' > /boot/config/docker.cfg # DEBUG keeps PHP warnings on: without it Unraid's libvirt_helpers.php, which FV3 loads, turns error reporting off printf 'SERVICE="enable"\nDEBUG="yes"\n' > /boot/config/domain.cfg -# The OS image adds the Connect plugin, which the webGUI repo lacks from 7.2 on; 7.4's header requires its state class +# Unraid's own writers add every other key with its default +for cfg in dynamix.docker.manager/scripts/dockerconfig dynamix.vm.manager/scripts/libvirtconfig; do + php -d short_open_tag=On $docroot/plugins/$cfg || fail "$cfg" +done +# The OS image adds the Connect plugin, which the webGUI repo lacks from 7.2 on: the header includes its myservers files, and +# from 7.4 requires its state class if [ ! -f $docroot/plugins/dynamix.my.servers/include/state.php ]; then mkdir -p $docroot/plugins/dynamix.my.servers/include cp "$here/fake/connect_state.php" $docroot/plugins/dynamix.my.servers/include/state.php : > $docroot/plugins/dynamix.my.servers/include/myservers1.php + : > $docroot/plugins/dynamix.my.servers/include/myservers2.php fi ln -sf $docroot/plugins/dynamix.plugin.manager/scripts/plugin /usr/local/sbin/plugin diff --git a/.github/unraid-compat/fixtures/vms.json b/.github/unraid-compat/fixtures/vms.json index a2be0356..f6be4c74 100644 --- a/.github/unraid-compat/fixtures/vms.json +++ b/.github/unraid-compat/fixtures/vms.json @@ -6,7 +6,7 @@ "state": 1, "id": 1, "autostart": true, - "xml": "\n Debian 12\n 803bd917-84b0-490f-ba3c-5e21b4cd6f07\n Debian 12 lab server\n \n \n \n 2097152\n 2097152\n \n \n \n 2\n \n hvm\n \n \n \n /usr/local/sbin/qemu\n \n \n \n \n \n \n \n \n \n \n \n \n \n\n" + "xml": "\n Debian 12\n 803bd917-84b0-490f-ba3c-5e21b4cd6f07\n Debian 12 lab server\n \n \n \n 2097152\n 2097152\n \n \n \n 2\n \n hvm\n \n \n \n \n \n \n \n /usr/local/sbin/qemu\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n" }, { "name": "Windows 11", @@ -14,7 +14,7 @@ "state": 5, "id": -1, "autostart": false, - "xml": "\n Windows 11\n 9fd1c657-7f2b-41b4-9ff3-5b42706315d5\n \n \n \n \n 8388608\n 8388608\n \n \n \n 4\n \n hvm\n \n \n \n /usr/local/sbin/qemu\n \n \n \n \n \n \n \n \n \n \n \n \n \n\n" + "xml": "\n Windows 11\n 9fd1c657-7f2b-41b4-9ff3-5b42706315d5\n \n \n \n \n 8388608\n 8388608\n \n \n \n 4\n \n hvm\n \n \n \n \n \n \n /usr/local/sbin/qemu\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n" }, { "name": "Home Assistant", @@ -22,7 +22,7 @@ "state": 3, "id": 2, "autostart": true, - "xml": "\n Home Assistant\n 39ec878e-ce44-4414-8dd1-b8fb3e57f9b2\n \n \n \n \n 4194304\n 4194304\n \n \n \n 3\n \n hvm\n \n \n \n /usr/local/sbin/qemu\n \n \n \n \n \n \n \n \n \n \n \n \n \n\n" + "xml": "\n Home Assistant\n 39ec878e-ce44-4414-8dd1-b8fb3e57f9b2\n \n \n \n \n 4194304\n 4194304\n \n \n \n 3\n \n hvm\n \n \n \n \n \n \n \n /usr/local/sbin/qemu\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\n" } ] } diff --git a/.github/unraid-compat/pages_test.php b/.github/unraid-compat/pages_test.php index 80214a59..d350dc1a 100644 --- a/.github/unraid-compat/pages_test.php +++ b/.github/unraid-compat/pages_test.php @@ -135,15 +135,38 @@ function get_json(string $path, ?int &$status = null) { check($status === 200 && $folders === [$lab => $read($labFolder)], 'read vm: ' . json_encode($folders)); $autostart = get_json('read_autostart.php', $status); check($status === 200 && ($autostart['autostart'] ?? null) === [['name' => 'app-a', 'wait' => 0], ['name' => 'app-d', 'wait' => 10]], 'read_autostart: ' . json_encode($autostart)); -foreach (['read_order.php?type=docker', 'read_order.php?type=vm', 'read_settings.php', 'list_themes.php', 'read_css_config.php', 'read_css_defaults.php', - 'read_error_log.php', 'read_organizer_registry.php', 'export_all.php'] as $path) { +// Unraid's saved orders, and no FV3 settings, themes, styles or organizer folders yet; re-encoded, so {} and [] stay apart +$exact = [ + 'read_order.php?type=docker' => json_encode(["folder-$media", 'app-a', 'app-b', "folder-$tools", 'tool-c', 'app-d']), + 'read_order.php?type=vm' => json_encode(["folder-$lab", 'Debian 12', 'Home Assistant', 'Windows 11']), + 'read_settings.php' => '{}', 'list_themes.php' => '[]', 'read_css_config.php' => '{}', 'read_organizer_registry.php' => '{"folders":[]}', +]; +foreach ($exact as $path => $want) { [$status, $body] = req('GET', "/plugins/folder.view3/server/$path"); - check($status === 200 && json_decode($body) !== null, "$path: status $status, not JSON: " . substr($body, 0, 200)); + check($status === 200 && json_encode(json_decode($body)) === $want, "$path: status $status, " . substr($body, 0, 200)); } +// All 49 of the CSS tool's defaults, two of them by value +$defaults = get_json('read_css_defaults.php', $status); +check($status === 200 && is_array($defaults) && count($defaults) === 49 && ($defaults['folder-view3-graph-cpu'] ?? null) === '#2b8da3' + && ($defaults['fv3-folder-name-min-width'] ?? null) === '220px', "read_css_defaults: status $status, " . substr(json_encode($defaults), 0, 200)); +// The backup: the seeded folders and nothing else of FV3's yet, stamped with this Unraid, this FV3 and the time +$export = get_json('export_all.php', $status); +$stamp = strtotime((string)($export['exported'] ?? '')); +unset($export['exported']); +check($status === 200 && $export === ['fv3_export_version' => 1, 'plugin_version' => '2099.01.01', 'unraid_version' => $version, + 'docker' => [$media => $mediaFolder, $tools => $toolsFolder], 'vm' => [$lab => $labFolder], 'settings' => [], 'autostart' => [], + 'css_config' => [], 'custom_styles' => [], 'order_docker' => [], 'order_vm' => []], "export_all: status $status, " . json_encode($export)); +check($stamp !== false && abs($stamp - time()) < 300, 'export_all: not stamped with the time'); +// FV3's debug panel shows the error log's last 200 lines; what those lines may hold is checked with the logs below +$raw = trim((string)@file_get_contents("$flash/error.log")); +$log = get_json('read_error_log.php', $status); +check($status === 200 && $log === ['log' => implode("\n", array_slice($raw === '' ? [] : explode("\n", $raw), -200))], "read_error_log: status $status, not the log's tail"); [$status, $body] = req('GET', '/plugins/folder.view3/server/version.php'); check($status === 200 && $body === '2099.01.01', "version: status $status, $body"); +// Logical CPUs, as this container's /proc/cpuinfo lists them +$cpus = count(preg_grep('/^processor\s*:/', file('/proc/cpuinfo'))); [$status, $body] = req('GET', '/plugins/folder.view3/server/cpu.php'); -check($status === 200 && (int)$body > 0, "cpu: status $status, $body"); +check($status === 200 && trim($body) === (string)$cpus, "cpu: status $status, $body, not $cpus"); $leaves("FV3's reads"); // FV3's pages in every theme: rendered whole, Unraid's lists that FV3's scripts fold present, FV3's own part present, and every @@ -219,11 +242,17 @@ function get_json(string $path, ?int &$status = null) { // What the runs left in the logs: FV3's files must log nothing, no stand-in was asked anything it does not answer, and no // command the webGUI ran was missing where the shell's error reached php -S's log (one run with 2>/dev/null fails unseen) // From 7.2 Unraid logs a .page's inline PHP as "in plugins/folder.view3/.page", with no leading slash -$fv3Lines = preg_grep('#plugins/folder\.view3/#', file('/var/log/phplog', FILE_IGNORE_NEW_LINES)); +$phplog = file('/var/log/phplog', FILE_IGNORE_NEW_LINES); +$fv3Lines = preg_grep('#plugins/folder\.view3/#', $phplog); check(!$fv3Lines, "PHP logged from FV3's files:\n " . implode("\n ", array_slice($fv3Lines, 0, 20))); -// php-error lines copy every warning of the request, Unraid's too, and name only the file's basename: the PHP log judges those +// No script died or failed an include: in Unraid's own code, a sign of state the fakes lack +$broken = preg_grep('/PHP Fatal error|Failed opening .* for inclusion/', $phplog); +check(!$broken, "PHP died or missed a file:\n " . implode("\n ", array_slice(array_unique($broken), 0, 20))); +// FV3's error log copies every warning raised in its requests, Unraid's too, by basename. With VM debug on, a real Unraid's +// libvirt.php adds one when it keys an array by a domain handle; any other line fails $errorLog = is_file("$flash/error.log") ? file("$flash/error.log", FILE_IGNORE_NEW_LINES) : []; -$reported = $errorLog === false ? ['error.log could not be read'] : preg_grep('/^\[[^]]+\] (?!php-error: )/', $errorLog); +$handleWarning = '/^\[[^]]+\] php-error: Resource ID#\d+ used as offset, casting to integer \(\d+\) at libvirt\.php:\d+$/'; +$reported = $errorLog === false ? ['error.log could not be read'] : preg_grep($handleWarning, $errorLog, PREG_GREP_INVERT); check(!$reported, "FV3's error.log:\n " . implode("\n ", $reported)); $unknown = preg_grep('/UNKNOWN/', file('/var/log/fv3-fakes.log', FILE_IGNORE_NEW_LINES)); check(!$unknown, "the fakes were asked what they do not answer:\n " . implode("\n ", array_unique($unknown))); From e8a8011c801ab844946f0428cec6492c0887a4be Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 00:35:50 +0800 Subject: [PATCH 35/72] ci: the fakes match arguments as the shell split them, and drop forms no run sends --- .github/unraid-compat/fake/dmidecode.sh | 6 +++--- .github/unraid-compat/fake/docker.php | 19 +++++++------------ .github/unraid-compat/fake/ip.sh | 7 ++++--- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/.github/unraid-compat/fake/dmidecode.sh b/.github/unraid-compat/fake/dmidecode.sh index 2010982f..bf718867 100644 --- a/.github/unraid-compat/fake/dmidecode.sh +++ b/.github/unraid-compat/fake/dmidecode.sh @@ -1,10 +1,10 @@ #!/bin/bash -# Stand-in for the OS image's dmidecode: the SMBIOS types Unraid's Dashboard and VM pages read, for a synthetic board with 16 GiB +# Stand-in for the OS image's dmidecode: the SMBIOS types Unraid's Dashboard reads, for a synthetic board with 16 GiB case "$*" in -qt0) printf 'BIOS Information\n\tVendor: Example BIOS\n\tVersion: 1.00\n\tRelease Date: 01/01/2025\n\n' ;; -qt2) printf 'Base Board Information\n\tManufacturer: Example Boards\n\tProduct Name: FV3-TEST\n\tVersion: 1.0\n\tSerial Number: FV3-0001\n\n' ;; --qt4 | '-q -t 4') printf 'Processor Information\n\tSocket Designation: CPU0\n\tManufacturer: Example CPUs\n\tVersion: Example CPU 8-Core\n\tCurrent Speed: 3600 MHz\n\n' ;; +-qt4) printf 'Processor Information\n\tSocket Designation: CPU0\n\tManufacturer: Example CPUs\n\tVersion: Example CPU 8-Core\n\tCurrent Speed: 3600 MHz\n\n' ;; -qt16) printf 'Physical Memory Array\n\tLocation: System Board Or Motherboard\n\tUse: System Memory\n\tError Correction Type: None\n\tMaximum Capacity: 64 GB\n\tNumber Of Devices: 2\n\n' ;; -qt17) for slot in A1 B1; do printf 'Memory Device\n\tSize: 8 GB\n\tLocator: DIMM_%s\n\tType: DDR4\n\tSpeed: 3200 MT/s\n\n' $slot; done ;; -*) echo "dmidecode UNKNOWN $*" >> /var/log/fv3-fakes.log; exit 1 ;; +*) echo "dmidecode UNKNOWN $* ($# arguments)" >> /var/log/fv3-fakes.log; exit 1 ;; esac diff --git a/.github/unraid-compat/fake/docker.php b/.github/unraid-compat/fake/docker.php index e6b24307..108a1514 100644 --- a/.github/unraid-compat/fake/docker.php +++ b/.github/unraid-compat/fake/docker.php @@ -39,30 +39,25 @@ function fv3d_answer(array $d, string $method, string $target): array { return [null, null]; } -// The docker CLI lines Unraid and FV3 run, each matched whole (its --format too) and answered in the CLI's own output format +// The docker CLI lines Unraid and FV3 run, matched argument by argument as the shell split them (--format too), and answered +// in the CLI's own output format function fv3d_cli(array $d, array $args): ?array { - $line = implode(' ', $args); - if ($line === 'network ls --format={{.Name}}={{.Driver}}') return array_map(fn($n) => "{$n['Name']}={$n['Driver']}", $d['networks']); - if ($line === 'ps -q --no-trunc') return array_column(fv3d_running($d), 'Id'); + if ($args === ['network', 'ls', '--format={{.Name}}={{.Driver}}']) return array_map(fn($n) => "{$n['Name']}={$n['Driver']}", $d['networks']); + if ($args === ['ps', '-q', '--no-trunc']) return array_column(fv3d_running($d), 'Id'); // A label's presence only, as Unraid filters: label=key=value is a form this fake does not answer - if (preg_match('/^ps --filter label=([^\s=]+) --format \{\{\.Names\}\}$/', $line, $m)) { + if (count($args) === 5 && [$args[0], $args[1], $args[3], $args[4]] === ['ps', '--filter', '--format', '{{.Names}}'] && preg_match('/^label=([^\s=]+)$/', $args[2], $m)) { return array_map(fn($c) => ltrim($c['Names'][0], '/'), array_values(array_filter(fv3d_running($d), fn($c) => isset($c['Labels'][$m[1]])))); } - if ($line === 'stats --no-stream --format={{.ID}};{{.CPUPerc}};{{.MemUsage}}') { + if ($args === ['stats', '--no-stream', '--format={{.ID}};{{.CPUPerc}};{{.MemUsage}}']) { return array_map(fn($c) => substr($c['Id'], 0, 12) . ';0.50%;12.5MiB / 7.7GiB', fv3d_running($d)); } - // DockerUtil::myIP() - if (preg_match('/^inspect --format=\{\{range \.NetworkSettings\.Networks\}\}\{\{\.(IPAddress|GlobalIPv6Address)\}\} \{\{end\}\} (\S+)$/', $line, $m) - && ($ct = fv3d_container($d, $m[2]))) { - return [implode('', array_map(fn($n) => ($n[$m[1]] ?? '') . ' ', $ct['NetworkSettings']['Networks']))]; - } return null; } if (($argv[1] ?? '') === 'cli') { $args = array_slice($argv, 2); $out = fv3d_cli($d, $args); - fv3d_log(($out === null ? 'UNKNOWN ' : '') . 'cli ' . implode(' ', $args)); + fv3d_log(($out === null ? 'UNKNOWN ' : '') . 'cli ' . implode(' ', $args) . ($out === null ? ' (' . count($args) . ' arguments)' : '')); if ($out === null) exit(1); echo $out ? implode("\n", $out) . "\n" : ''; exit(0); diff --git a/.github/unraid-compat/fake/ip.sh b/.github/unraid-compat/fake/ip.sh index 4f725a77..38682d6c 100644 --- a/.github/unraid-compat/fake/ip.sh +++ b/.github/unraid-compat/fake/ip.sh @@ -1,8 +1,9 @@ #!/bin/bash # Stand-in for the OS image's ip: eth0's IPv4 address from network.ini, the one form Unraid's ipaddr() asks from 7.1 addr=$(sed -n 's/^IPADDR:0="\(.*\)"$/\1/p' /var/local/emhttp/network.ini 2>/dev/null) -case "$*" in -'-4 -br addr show eth0 scope global') [ -n "$addr" ] && echo "eth0 UP $addr/24 " && exit 0 ;; +# Matched on the argument count as well as the words, so the same words split another way are not answered +case "$#:$*" in +'7:-4 -br addr show eth0 scope global') [ -n "$addr" ] && echo "eth0 UP $addr/24 " && exit 0 ;; esac -echo "ip UNKNOWN $* (network.ini address: ${addr:-none})" >> /var/log/fv3-fakes.log +echo "ip UNKNOWN $* ($# arguments; network.ini address: ${addr:-none})" >> /var/log/fv3-fakes.log exit 1 From a10601444838025c2180480f07ee2be7b58e0eac Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 06:40:06 +0800 Subject: [PATCH 36/72] ci: FV3's pages in Chromium and Firefox on every Unraid row, every theme and width, the advanced preview's layout included browser_test.sh runs the fake Unraid with no network and the Playwright image in a container that joins it. browser_test.js checks the drawn folders, an opened folder and the advanced preview against values written by hand, and fails on any FV3 error; screenshots are kept as an artifact. The fake's log checks move to fake_logs.php for both tests. --- .coderabbit.yaml | 9 + .github/unraid-compat/browser_test.js | 229 ++++++++++++++++++++++++ .github/unraid-compat/browser_test.sh | 32 ++++ .github/unraid-compat/fake_logs.php | 42 +++++ .github/unraid-compat/package-lock.json | 26 +++ .github/unraid-compat/package.json | 8 + .github/unraid-compat/pages_test.php | 22 +-- .github/workflows/ci.yml | 24 +++ renovate.json | 14 ++ 9 files changed, 387 insertions(+), 19 deletions(-) create mode 100644 .github/unraid-compat/browser_test.js create mode 100644 .github/unraid-compat/browser_test.sh create mode 100644 .github/unraid-compat/fake_logs.php create mode 100644 .github/unraid-compat/package-lock.json create mode 100644 .github/unraid-compat/package.json diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 73a03c99..f10fccdd 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -226,6 +226,15 @@ reviews: docker and domain cfg). A call a stand-in does not answer fails the run: flag an answer that hides one, and any stand-in for code the webGUI repo has. + - browser_test.sh starts fake_unraid.sh in a container with no network + and runs the Playwright image in a second container that joins its + network. browser_test.js drives FV3's Docker, VMs and Dashboard + pages in Chromium and Firefox and checks what the user sees (rows, + tiles, an opened folder, the advanced preview's layout) against + values written by hand. A failed request or console error passes + only for a service the fake does not run (ABSENT) or for Unraid's + own unload handler. fake_logs.php holds the log checks both tests + run. package.json pins playwright-core to the image's version. - matrix_check.py keeps ci.yml's Unraid rows at one per minor from the .plg's min to the newest release; Renovate only moves rows. - Each step asserts what the user is left with (live files, the diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js new file mode 100644 index 00000000..be0cc7e4 --- /dev/null +++ b/.github/unraid-compat/browser_test.js @@ -0,0 +1,229 @@ +// FV3's pages in Chromium and Firefox on the fake Unraid browser_test.sh started, every theme and width; a screenshot per view. +// Usage: node browser_test.js +'use strict'; +const fs = require('fs'); +const { chromium, firefox } = require('playwright-core'); + +const [version, shots, fakeToken] = process.argv.slice(2); +const base = 'http://127.0.0.1'; +const failures = []; +let checks = 0; +const check = (ok, what) => { checks++; if (!ok) failures.push(what); return ok; }; +const same = (got, want) => JSON.stringify(got) === JSON.stringify(want); + +const MEDIA = 'MediaAbCdEfGhIjKlMnO'; +const LAB = 'LabFoldAbCdEfGhIjKlM'; +const THEMES = ['black', 'white', 'azure', 'gray']; +const SIZES = [[1440, 900], [768, 1024], [400, 860]]; + +// Unraid's services the fake does not run. A failed request, or a console error naming one, passes only on its path here. +const ABSENT = [ + [/^\/sub\//, "Unraid's nchan push channels: the fake runs no nchan, so the page's live updates never connect"], + [/^\/graphql$/, "the Unraid API: the fake has none, so FV3's fv3DetectApi takes the PHP path"], +]; +const absent = (url) => { try { const path = new URL(url).pathname; return ABSENT.some(([re]) => re.test(path)); } catch { return false; } }; +// Chromium refuses every unload handler: Unraid's dynamix.js adds some, and on 7.0 the Docker and Dashboard pages' inline +// scripts too. From those sources the refusal is Unraid's, while FV3's shipped files add none +const plugin = `${__dirname}/../../src/folder.view3/usr/local/emhttp/plugins/folder.view3`; +const fv3Unload = fs.readdirSync(plugin, { recursive: true }).filter((f) => /\.(js|page|php)$/.test(f)) + .filter((f) => /(? { + if (fv3Unload.length || m.text() !== 'Permissions policy violation: unload is not allowed in this document.') return false; + try { return ['/webGui/javascript/dynamix.js', `/${page}`].includes(new URL(m.location()?.url).pathname); } catch { return false; } +}; + +// Each page's own rows, tiles and folders as the user sees them, read in the page: a folder as "name [members it shows]", a +// container or VM by its name +const READ = { + Docker: () => window.fv3Test.tableRows('docker_list', 'ct-name'), + VMs: () => { + // Each VM's detail row stays right after its VM, wherever FV3 moved the pair + const details = [...document.querySelectorAll('#kvm_list tr[child-id]')]; + const paired = details.filter((d) => d.previousElementSibling?.getAttribute('parent-id') === d.getAttribute('child-id')).length; + return { rows: window.fv3Test.tableRows('kvm_list', 'vm-name'), details: `${paired} of ${details.length} detail rows after their VM` }; + }, + Dashboard: () => { + const { seen, name } = window.fv3Test; + const tiles = (view) => [...document.querySelectorAll(`tbody#${view} > tr.updated > td > *`)].filter(seen).map((tile) => { + if (!tile.classList.contains('folder-showcase-outer')) return name(tile); + const members = [...tile.querySelectorAll('.folder-storage > span.outer, .folder-showcase > span.outer')]; + return `${tile.querySelector('.fv3-folder-appname').innerText.trim()} [${members.map(name).join(', ')}] shows [${members.filter(seen).map(name).join(', ')}]`; + }); + return { docker: tiles('docker_view'), vms: tiles('vm_view') }; + }, +}; + +// What fake_unraid.sh saved: Media holds app-a by hand and app-b by its label, Tools takes tool-c by regex, app-d is loose, Lab +// holds Debian 12; each list in Unraid's saved order +const WANT = { + Docker: { shut: ['Media [app-a, app-b]', 'Tools [tool-c]', 'app-d'], open: ['Media [app-a, app-b]', 'app-a', 'app-b', 'Tools [tool-c]', 'app-d'] }, + VMs: { + shut: { rows: ['Lab [Debian 12]', 'Home Assistant', 'Windows 11'], details: '3 of 3 detail rows after their VM' }, + open: { rows: ['Lab [Debian 12]', 'Debian 12', 'Home Assistant', 'Windows 11'], details: '3 of 3 detail rows after their VM' }, + }, + Dashboard: { + shut: { docker: ['Media [app-a, app-b] shows []', 'Tools [tool-c] shows []', 'app-d'], vms: ['Lab [Debian 12] shows []', 'Home Assistant', 'Windows 11'] }, + open: { docker: ['Media [app-a, app-b] shows [app-a, app-b]', 'Tools [tool-c] shows []', 'app-d'], vms: ['Lab [Debian 12] shows []', 'Home Assistant', 'Windows 11'] }, + }, +}; +// FV3's events for a finished draw; the folder each page opens, its event when open, and how a user opens it +const DRAWN = { Docker: ['docker-post-folders-creation'], VMs: ['vm-post-folders-creation'], Dashboard: ['docker-post-folders-creation', 'vm-post-folders-creation'] }; +const OPEN = { + Docker: ['Media', 'docker-post-folder-expansion', (p) => p.click(`button.dropDown-${MEDIA}`)], + VMs: ['Lab', 'vm-post-folder-expansion', (p) => p.click(`button.dropDown-${LAB}`)], + // The Dashboard opens a folder from its tile's menu; this is the call that menu entry makes (dashboard.js, its Expand item) + Dashboard: ['Media', 'docker-post-folder-expansion', (p) => p.evaluate((id) => expandFolderDocker(id), MEDIA)], +}; +// The first member of Media, and where a click opens its advanced preview once Media is open +const PREVIEWED = 'app-a'; +const PREVIEW = { Docker: `tr.folder-id-${MEDIA} .folder-preview span.hand[id^="folder-preview-"]`, Dashboard: `.folder-showcase-${MEDIA} > span.outer > span.hand` }; + +// Before the page's scripts: records FV3's draw and expansion events as they fire, and the readers' helpers. A display: contents +// element (FV3's Dashboard folders) is seen when a child is; a name is .inner's text before its first line break, drawn or not +function testHelpers() { + const events = []; + const dispatch = EventTarget.prototype.dispatchEvent; + EventTarget.prototype.dispatchEvent = function (event) { + if (/-post-folders?-(creation|expansion)$/.test(event.type)) events.push(event.type); + return dispatch.call(this, event); + }; + const seen = (el) => getComputedStyle(el).visibility !== 'hidden' + && (el.getClientRects().length > 0 || (getComputedStyle(el).display === 'contents' && [...el.children].some(seen))); + const name = (outer) => { + const before = []; + for (const node of outer.querySelector('.inner').childNodes) { if (node.nodeName === 'BR') break; before.push(node.textContent); } + return before.join('').trim(); + }; + const tableRows = (list, nameCell) => [...document.querySelectorAll(`#${list} > tr`)].filter(seen).map((row) => row.classList.contains('folder') + ? `${row.querySelector('.folder-appname').innerText.trim()} [${[...row.querySelectorAll('.folder-preview span.outer')].filter(seen).map(name).join(', ')}]` + : name(row.querySelector(`td.${nameCell} span.outer`))); + window.fv3Test = { events, seen, name, tableRows }; +} + +// The page's reading once two in a row agree: FV3 animates an opening and Unraid may reload a list after the first draw +async function settled(page, read, arg) { + let last = null; + for (let i = 0; i < 40; i++) { + const now = await page.evaluate(read, arg); + if (last !== null && same(now, last)) return now; + last = now; + await page.waitForTimeout(250); + } + throw new Error(`still changing after 10 s: ${JSON.stringify(last)}`); +} + +const waitEvents = (page, names) => page.waitForFunction((names) => names.every((n) => window.fv3Test.events.includes(n)), names, { timeout: 20000 }); + +// The popup's markup is indented HTML: with each blank text node set to one space nothing may move, as it does where Unraid's +// tooltip box keeps line breaks (7.4's .tooltipster-content white-space: pre-line) and FV3 does not reset it +function popupState(name) { + const base = [...document.querySelectorAll('.tooltipster-base')].find((b) => b.getClientRects().length && b.querySelector('.preview-outbox')); + if (!base) return { error: 'no advanced preview open' }; + const box = base.querySelector('.preview-outbox'); + const elements = [box, ...box.querySelectorAll('*')]; + const boxes = () => elements.map((e) => { const r = e.getBoundingClientRect(); return [r.top, r.left, r.width, r.height].map(Math.round).join(','); }); + const before = boxes(); + const blanks = []; + const walker = document.createTreeWalker(box, NodeFilter.SHOW_TEXT); + for (let node; (node = walker.nextNode());) if (node.data.trim() === '' && node.data !== ' ') blanks.push([node, node.data]); + blanks.forEach(([node]) => { node.data = ' '; }); + const after = boxes(); + blanks.forEach(([node, data]) => { node.data = data; }); + const moved = elements.filter((e, i) => before[i] !== after[i]); + const r = base.getBoundingClientRect(); + return { + named: box.innerText.includes(name), + blanks: blanks.length, + moved: moved.length ? `${moved.length} elements, first ${moved.slice(0, 3).map((e) => `${e.tagName.toLowerCase()}.${[...e.classList].join('.')}`).join(', ')}` : '', + inside: r.left >= 0 && r.right <= window.innerWidth + 1 ? '' : `left ${Math.round(r.left)}, right ${Math.round(r.right)} of ${window.innerWidth}`, + }; +} + +async function view(browser, kind, theme, [width, height], page) { + const where = `${kind} ${theme} ${width}px ${page}`; + const context = await browser.newContext({ viewport: { width, height } }); + await context.addInitScript(testHelpers); + const tab = await context.newPage(); + const errors = []; + tab.on('pageerror', (e) => errors.push(`page error: ${e.message}`)); + tab.on('console', (m) => { + if (m.type() !== 'error') return; + const urls = [m.location()?.url, ...(m.text().match(/\b(?:https?|wss?):\/\/[^\s'"]+/g) || [])].filter(Boolean); + if (!urls.some(absent) && !unraidUnload(m, page)) errors.push(`console error: ${m.text()} (${m.location()?.url || 'no source'})`); + }); + tab.on('response', (r) => { if (r.status() >= 400 && !absent(r.url())) errors.push(`${r.status()} for ${r.url()}`); }); + tab.on('requestfailed', (r) => { if (!absent(r.url())) errors.push(`request failed: ${r.url()} ${r.failure()?.errorText}`); }); + const file = `${shots}/${kind}/${theme}-${width}-${page}`; + try { + await tab.goto(`${base}/${page}`); + check(await tab.evaluate((t) => [...document.querySelectorAll('link[rel=stylesheet]')] + .some((l) => new RegExp(`/webGui/styles/(?:themes/|default-)${t}\\.css`).test(l.getAttribute('href'))), theme), `${where}: the ${theme} theme's stylesheet is not on the page`); + await waitEvents(tab, DRAWN[page]).catch(() => { throw new Error(`FV3 did not finish drawing within 20 s (${DRAWN[page].join(', ')})`); }); + let got = await settled(tab, READ[page]); + check(same(got, WANT[page].shut), `${where}: drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].shut)}`); + const [folder, opened, open] = OPEN[page]; + await open(tab); + await waitEvents(tab, [opened]).catch(() => { throw new Error(`${folder} did not open within 20 s (${opened})`); }); + got = await settled(tab, READ[page]); + check(same(got, WANT[page].open), `${where}: with ${folder} open, drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].open)}`); + await tab.screenshot({ path: `${file}.png`, fullPage: true }); + if (PREVIEW[page]) { + await tab.locator(PREVIEW[page]).first().click(); + await tab.waitForSelector('.tooltipster-base .preview-outbox', { state: 'visible', timeout: 10000 }) + .catch(() => { throw new Error('the advanced preview did not open within 10 s'); }); + // The popup fades in and draws its graph after it opens + const popup = await settled(tab, popupState, PREVIEWED); + if (popup.error) throw new Error(popup.error); + check(popup.named, `${where}: the advanced preview is not ${PREVIEWED}'s`); + check(!popup.moved, `${where}: the advanced preview draws its markup's line breaks: ${popup.moved} moved when ${popup.blanks} blank text nodes became one space`); + check(!popup.inside, `${where}: the advanced preview leaves the window: ${popup.inside}`); + await tab.screenshot({ path: `${file}-preview.png` }); + } + check(!(await tab.locator('.fv3-banner').count()), `${where}: FV3 shows a banner: ${await tab.locator('.fv3-banner').allInnerTexts()}`); + } catch (e) { + check(false, `${where}: ${e.message.split('\n')[0]}`); + await tab.screenshot({ path: `${file}-failed.png`, fullPage: true }).catch(() => {}); + } + check(!errors.length, `${where}:\n ${[...new Set(errors)].join('\n ')}`); + await context.close(); +} + +// A save as the page posts it; anything but a 200, or an FV3 answer without FV3's header, stops the run +async function post(request, path, form, what) { + const r = await request.post(`${base}${path}`, { form }); + if (r.status() !== 200 || (path.includes('folder.view3') && !r.headers()['x-fv3-answer'])) throw new Error(`${what}: status ${r.status()}, ${(await r.text()).slice(0, 200)}`); +} + +(async () => { + if (!fs.existsSync('/.dockerenv') || !fakeToken) { console.error('Run browser_test.sh: this needs the fake Unraid it starts'); process.exit(2); } + check(!fv3Unload.length, `FV3 adds an unload handler, which Chromium never runs: ${fv3Unload.join(', ')}`); + const browsers = { chromium: await chromium.launch(), firefox: await firefox.launch() }; + const setup = await browsers.chromium.newContext(); + const tab = await setup.newPage(); + await tab.goto(`${base}/Docker`); + // The token of the fake browser_test.sh started, so these writes never reach any other server on this loopback + const token = await tab.evaluate(() => typeof csrf_token === 'string' ? csrf_token : ''); + if (token !== fakeToken) { console.error(`127.0.0.1 is not the fake Unraid browser_test.sh started (token "${token}")`); process.exit(2); } + // Media as fake_unraid.sh saved it, with the advanced preview on + const saved = await setup.request.get(`${base}/plugins/folder.view3/server/read.php?type=docker`); + const media = saved.ok() ? (await saved.json())[MEDIA] : undefined; + if (!media) throw new Error(`no Media folder to turn the advanced preview on: status ${saved.status()}`); + await post(setup.request, '/plugins/folder.view3/server/update.php', { type: 'docker', id: MEDIA, csrf_token: token, + content: JSON.stringify({ ...media, settings: { ...media.settings, context: 2 } }) }, "Media's advanced preview"); + await post(setup.request, '/plugins/folder.view3/server/update_settings.php', { key: 'dashboard_context', value: '2', csrf_token: token }, "the Dashboard's advanced preview"); + for (const theme of THEMES) { + // As Unraid's Display Settings saves it + await post(setup.request, '/update.php', { '#file': 'dynamix/dynamix.cfg', '#section': 'display', theme, csrf_token: token }, `the ${theme} theme`); + for (const [kind, browser] of Object.entries(browsers)) { + fs.mkdirSync(`${shots}/${kind}`, { recursive: true }); + for (const size of SIZES) for (const page of ['Docker', 'VMs', 'Dashboard']) await view(browser, kind, theme, size, page); + } + } + await setup.close(); + for (const browser of Object.values(browsers)) await browser.close(); + if (failures.length) { + console.log(`FAILED [Unraid ${version}]: ${failures.length} of ${checks} browser checks\n- ${failures.join('\n- ')}`); + process.exit(1); + } + console.log(`Unraid ${version}: FV3's pages in Chromium and Firefox, ${THEMES.length} themes at ${SIZES.length} widths, passed (${checks} checks)`); +})().catch((e) => { console.log(`FAILED [Unraid ${version}]: ${e.message}`); process.exit(1); }); diff --git a/.github/unraid-compat/browser_test.sh b/.github/unraid-compat/browser_test.sh new file mode 100644 index 00000000..f29233dc --- /dev/null +++ b/.github/unraid-compat/browser_test.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# FV3's pages in Chromium and Firefox: the fake Unraid in a container with no network, the browsers in one that joins its network. +# From the repo root, after npm ci here: browser_test.sh +set -u +image=$1; tree=$2; version=$3; shots=$4 +# Renovate moves this with playwright-core in package.json: the driver only runs the browsers built for its own version +browsers=mcr.microsoft.com/playwright:v1.65.1-noble@sha256:1507cbfc550a63a6b7396791ca4f00df17beb56342d2447b3f106c306f525579 +fake=fv3-browser-test-$$ +fail() { echo "FAILED [Unraid $version]: $*"; exit 1; } +trap 'docker rm -f $fake >/dev/null 2>&1' EXIT + +[ -d .github/unraid-compat/node_modules/playwright-core ] || fail "no playwright-core: run npm ci in .github/unraid-compat first" +docker run -d --name $fake --network none -v "$PWD:/repo" -w /repo "$image" \ + bash -c 'bash .github/unraid-compat/fake_unraid.sh "$0" "$1" && touch /run/fv3-fake-up && exec sleep infinity' "$tree" "$version" \ + >/dev/null || fail 'the fake Unraid container did not start' +end=$((SECONDS + 120)) +until docker exec $fake test -f /run/fv3-fake-up 2>/dev/null; do + [ "$(docker inspect -f '{{.State.Running}}' $fake 2>/dev/null)" = true ] || fail "the fake Unraid stopped: $(docker logs $fake 2>&1 | tail -20)" + [ $SECONDS -lt $end ] || fail 'the fake Unraid was not up within 2 minutes' + sleep 0.5 +done +# browser_test.js writes only once the page it reaches carries this token +token=$(docker exec $fake php -d auto_prepend_file= -r 'echo parse_ini_file("/var/local/emhttp/var.ini")["csrf_token"] ?? "";') +[ -n "$token" ] || fail "no csrf_token in the fake's var.ini" + +mkdir -p "$shots" || fail "cannot make $shots" +docker run --rm --network container:$fake --shm-size=1g -v "$PWD:/repo:ro" -v "$(cd "$shots" && pwd):/shots" \ + -w /repo/.github/unraid-compat "$browsers" node browser_test.js "$version" /shots "$token" +status=$? +# The logs hold what the pages asked of Unraid's PHP and the fakes, for every run above +docker exec $fake php -d auto_prepend_file= -d display_errors=stderr .github/unraid-compat/fake_logs.php "$version" || status=1 +exit $status diff --git a/.github/unraid-compat/fake_logs.php b/.github/unraid-compat/fake_logs.php new file mode 100644 index 00000000..d9efa473 --- /dev/null +++ b/.github/unraid-compat/fake_logs.php @@ -0,0 +1,42 @@ +/dev/null that is missing goes unseen: only errors that reach php -S's log are caught +function fv3_fake_log_checks(): array { + $checks = []; + // fake_unraid.sh makes each log, FV3 its error.log on its first line: one that cannot be read fails, never "nothing logged" + $read = function (string $file, bool $mayBeAbsent = false) use (&$checks): array { + if ($mayBeAbsent && !file_exists($file)) return []; + $lines = @file($file, FILE_IGNORE_NEW_LINES); + $checks[] = [$lines !== false, "$file could not be read"]; + return $lines ?: []; + }; + // From 7.2 Unraid logs a .page's inline PHP as "in plugins/folder.view3/.page", with no leading slash + $phplog = $read('/var/log/phplog'); + $fv3Lines = preg_grep('#plugins/folder\.view3/#', $phplog); + $checks[] = [!$fv3Lines, "PHP logged from FV3's files:\n " . implode("\n ", array_slice($fv3Lines, 0, 20))]; + // No script died or failed an include: in Unraid's own code, a sign of state the fakes lack + $broken = preg_grep('/PHP Fatal error|Failed opening .* for inclusion/', $phplog); + $checks[] = [!$broken, "PHP died or missed a file:\n " . implode("\n ", array_slice(array_unique($broken), 0, 20))]; + // FV3's error log copies every warning raised in its requests, Unraid's too, by basename. With VM debug on, a real Unraid's + // libvirt.php adds one when it keys an array by a domain handle; any other line fails + $handleWarning = '/^\[[^]]+\] php-error: Resource ID#\d+ used as offset, casting to integer \(\d+\) at libvirt\.php:\d+$/'; + $reported = preg_grep($handleWarning, $read('/boot/config/plugins/folder.view3/error.log', true), PREG_GREP_INVERT); + $checks[] = [!$reported, "FV3's error.log:\n " . implode("\n ", $reported)]; + $unknown = preg_grep('/UNKNOWN/', $read('/var/log/fv3-fakes.log')); + $checks[] = [!$unknown, "the fakes were asked what they do not answer:\n " . implode("\n ", array_unique($unknown))]; + $missing = preg_grep('/command not found/', $read('/var/log/php-server.log')); + $checks[] = [!$missing, "the webGUI ran commands this image lacks:\n " . implode("\n ", array_unique($missing))]; + return $checks; +} + +// Run on its own (browser_test.sh): print what failed, exit 1 on any +if (PHP_SAPI === 'cli' && realpath($argv[0] ?? '') === __FILE__) { + if (!is_file('/.dockerenv') || !is_file('/var/run/fv3-fake-unraid')) { fwrite(STDERR, "Run in the container fake_unraid.sh set up\n"); exit(2); } + $version = $argv[1] ?? '?'; + $failed = array_column(array_filter(fv3_fake_log_checks(), fn($c) => !$c[0]), 1); + if ($failed) { + echo "FAILED [Unraid $version]: the fake Unraid's logs\n- " . implode("\n- ", $failed) . "\n"; + exit(1); + } + echo "Unraid $version: the fake Unraid's logs are clean\n"; +} diff --git a/.github/unraid-compat/package-lock.json b/.github/unraid-compat/package-lock.json new file mode 100644 index 00000000..702bb3fa --- /dev/null +++ b/.github/unraid-compat/package-lock.json @@ -0,0 +1,26 @@ +{ + "name": "folder-view3-unraid-browser-test", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "folder-view3-unraid-browser-test", + "devDependencies": { + "playwright-core": "1.65.1" + } + }, + "node_modules/playwright-core": { + "version": "1.65.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.65.1.tgz", + "integrity": "sha512-hqPpz7blSMPxWVdoeE1yiBSzXsKiVOd2k+kjCvmUywD2GPO2Dd9HfcWnq9NN0GHbNZDFgZ9JfBFr+X5/BLo0qw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=20" + } + } + } +} diff --git a/.github/unraid-compat/package.json b/.github/unraid-compat/package.json new file mode 100644 index 00000000..2a7b95a1 --- /dev/null +++ b/.github/unraid-compat/package.json @@ -0,0 +1,8 @@ +{ + "name": "folder-view3-unraid-browser-test", + "private": true, + "description": "browser_test.js's driver; nothing here ships in the plugin. Its version must equal the Playwright image's in browser_test.sh", + "devDependencies": { + "playwright-core": "1.65.1" + } +} diff --git a/.github/unraid-compat/pages_test.php b/.github/unraid-compat/pages_test.php index d350dc1a..186ec117 100644 --- a/.github/unraid-compat/pages_test.php +++ b/.github/unraid-compat/pages_test.php @@ -239,25 +239,9 @@ function get_json(string $path, ?int &$status = null) { check($status === 200 && json_decode($body) !== null, "sync_order: status $status, $body"); $leaves('sync_order', ['autostart' => "app-a\napp-d 10\n"]); -// What the runs left in the logs: FV3's files must log nothing, no stand-in was asked anything it does not answer, and no -// command the webGUI ran was missing where the shell's error reached php -S's log (one run with 2>/dev/null fails unseen) -// From 7.2 Unraid logs a .page's inline PHP as "in plugins/folder.view3/.page", with no leading slash -$phplog = file('/var/log/phplog', FILE_IGNORE_NEW_LINES); -$fv3Lines = preg_grep('#plugins/folder\.view3/#', $phplog); -check(!$fv3Lines, "PHP logged from FV3's files:\n " . implode("\n ", array_slice($fv3Lines, 0, 20))); -// No script died or failed an include: in Unraid's own code, a sign of state the fakes lack -$broken = preg_grep('/PHP Fatal error|Failed opening .* for inclusion/', $phplog); -check(!$broken, "PHP died or missed a file:\n " . implode("\n ", array_slice(array_unique($broken), 0, 20))); -// FV3's error log copies every warning raised in its requests, Unraid's too, by basename. With VM debug on, a real Unraid's -// libvirt.php adds one when it keys an array by a domain handle; any other line fails -$errorLog = is_file("$flash/error.log") ? file("$flash/error.log", FILE_IGNORE_NEW_LINES) : []; -$handleWarning = '/^\[[^]]+\] php-error: Resource ID#\d+ used as offset, casting to integer \(\d+\) at libvirt\.php:\d+$/'; -$reported = $errorLog === false ? ['error.log could not be read'] : preg_grep($handleWarning, $errorLog, PREG_GREP_INVERT); -check(!$reported, "FV3's error.log:\n " . implode("\n ", $reported)); -$unknown = preg_grep('/UNKNOWN/', file('/var/log/fv3-fakes.log', FILE_IGNORE_NEW_LINES)); -check(!$unknown, "the fakes were asked what they do not answer:\n " . implode("\n ", array_unique($unknown))); -$missing = preg_grep('/command not found/', file('/var/log/php-server.log', FILE_IGNORE_NEW_LINES)); -check(!$missing, "the webGUI ran commands this image lacks:\n " . implode("\n ", array_unique($missing))); +// What the runs left in the logs +require __DIR__ . '/fake_logs.php'; +foreach (fv3_fake_log_checks() as [$ok, $what]) check($ok, $what); if ($failures) { echo "FAILED [Unraid $version]: " . count($failures) . " of $checks checks\n- " . implode("\n- ", $failures) . "\n"; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c5905cb..ff1c6217 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -221,6 +221,30 @@ jobs: UNRAID_VERSION: ${{ matrix.unraid }} run: docker run --rm --network none -v "$PWD:/repo" -w /repo fv3-unraid bash .github/unraid-compat/pages_test.sh .webgui "$UNRAID_VERSION" + - name: Set up Node + if: ${{ (success() || failure()) && env.RUNS == 'true' }} + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: 26 + + # Runs after a failed step above too: this one checks what the pages draw + - name: FV3's pages in Chromium and Firefox, every theme at desktop, tablet and phone widths + if: ${{ (success() || failure()) && env.RUNS == 'true' }} + timeout-minutes: 20 + env: + UNRAID_VERSION: ${{ matrix.unraid }} + run: | + (cd .github/unraid-compat && npm ci --ignore-scripts --no-audit --no-fund) + bash .github/unraid-compat/browser_test.sh fv3-unraid .webgui "$UNRAID_VERSION" "$RUNNER_TEMP/screenshots" + + - name: Keep the browsers' screenshots + if: ${{ always() && env.RUNS == 'true' }} + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: screenshots-unraid-${{ matrix.unraid }} + path: ${{ runner.temp }}/screenshots + retention-days: 14 + # One check per matrix for beta's branch protection: the version rows rename themselves as Renovate moves them php-compat: name: PHP compatibility diff --git a/renovate.json b/renovate.json index ab655f85..084ed7a3 100644 --- a/renovate.json +++ b/renovate.json @@ -54,6 +54,15 @@ "datasourceTemplate": "git-refs", "packageNameTemplate": "https://github.com/{{{depName}}}", "depTypeTemplate": "bundled" + }, + { + "customType": "regex", + "description": "The Playwright image browser_test.sh runs the browsers in, by tag and digest.", + "managerFilePatterns": ["/^\\.github/unraid-compat/browser_test\\.sh$/"], + "matchStrings": [ + "browsers=(?mcr\\.microsoft\\.com/playwright):(?v[0-9.]+-noble)@(?sha256:[a-f0-9]{64})" + ], + "datasourceTemplate": "docker" } ], "packageRules": [ @@ -102,6 +111,11 @@ "matchFileNames": [".github/scripts/package.json"], "matchPackageNames": ["jquery"], "allowedVersions": "<4" + }, + { + "description": "playwright-core drives only the browsers of its own release, so it moves with the Playwright image in one PR.", + "matchPackageNames": ["playwright-core", "mcr.microsoft.com/playwright"], + "groupName": "Playwright" } ] } From 0c5f72113b6b7dfaa60cd1585586e6d48e64aecf Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 08:58:43 +0800 Subject: [PATCH 37/72] ci: browser checks open folders as a user does, count only members a user can see, and stop a stuck run - Folders open by their chevron or the Dashboard tile's menu; a click is dispatched only where Unraid's layout covers it - A member must be visible, not transparent or clipped away; every banner shown is recorded - Failures print as they happen, a view has 90 s, and 3 undrawn views in a row stop the run - An empty folder whose name must be escaped; the driver's version is checked against the image's - The fake's flash folder must exist before its error.log is read; node_modules stays out of the image --- .coderabbit.yaml | 7 +- .github/unraid-compat/.dockerignore | 1 + .github/unraid-compat/browser_test.js | 160 +++++++++++++++++++------- .github/unraid-compat/browser_test.sh | 26 +++-- .github/unraid-compat/fake_logs.php | 8 +- .github/unraid-compat/pages_test.php | 4 +- .github/workflows/ci.yml | 8 +- 7 files changed, 147 insertions(+), 67 deletions(-) create mode 100644 .github/unraid-compat/.dockerignore diff --git a/.coderabbit.yaml b/.coderabbit.yaml index f10fccdd..d50cecb2 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -233,8 +233,11 @@ reviews: tiles, an opened folder, the advanced preview's layout) against values written by hand. A failed request or console error passes only for a service the fake does not run (ABSENT) or for Unraid's - own unload handler. fake_logs.php holds the log checks both tests - run. package.json pins playwright-core to the image's version. + own unload handler. Clicks are a user's; only where Unraid's own + layout covers the target is the click dispatched instead. + fake_logs.php holds the log checks both tests run. package.json + pins playwright-core to the image's version, which + browser_test.sh checks. - matrix_check.py keeps ci.yml's Unraid rows at one per minor from the .plg's min to the newest release; Renovate only moves rows. - Each step asserts what the user is left with (live files, the diff --git a/.github/unraid-compat/.dockerignore b/.github/unraid-compat/.dockerignore new file mode 100644 index 00000000..3c3629e6 --- /dev/null +++ b/.github/unraid-compat/.dockerignore @@ -0,0 +1 @@ +node_modules diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index be0cc7e4..75ea84a1 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -1,4 +1,4 @@ -// FV3's pages in Chromium and Firefox on the fake Unraid browser_test.sh started, every theme and width; a screenshot per view. +// FV3's pages in Chromium and Firefox on the fake Unraid browser_test.sh started, 4 themes at 3 widths, screenshots kept. // Usage: node browser_test.js 'use strict'; const fs = require('fs'); @@ -8,11 +8,13 @@ const [version, shots, fakeToken] = process.argv.slice(2); const base = 'http://127.0.0.1'; const failures = []; let checks = 0; -const check = (ok, what) => { checks++; if (!ok) failures.push(what); return ok; }; +// Each failure prints as it happens, so a run the step's time limit kills still shows what failed +const check = (ok, what) => { checks++; if (!ok) { failures.push(what); console.log(`- ${what}`); } return ok; }; const same = (got, want) => JSON.stringify(got) === JSON.stringify(want); const MEDIA = 'MediaAbCdEfGhIjKlMnO'; const LAB = 'LabFoldAbCdEfGhIjKlM'; +const SPARE = 'Spare & '; const THEMES = ['black', 'white', 'azure', 'gray']; const SIZES = [[1440, 900], [768, 1024], [400, 860]]; @@ -21,15 +23,23 @@ const ABSENT = [ [/^\/sub\//, "Unraid's nchan push channels: the fake runs no nchan, so the page's live updates never connect"], [/^\/graphql$/, "the Unraid API: the fake has none, so FV3's fv3DetectApi takes the PHP path"], ]; -const absent = (url) => { try { const path = new URL(url).pathname; return ABSENT.some(([re]) => re.test(path)); } catch { return false; } }; -// Chromium refuses every unload handler: Unraid's dynamix.js adds some, and on 7.0 the Docker and Dashboard pages' inline -// scripts too. From those sources the refusal is Unraid's, while FV3's shipped files add none +const pathOf = (url) => { try { return new URL(url).pathname; } catch { return ''; } }; +const absent = (url) => ABSENT.some(([re]) => re.test(pathOf(url))); +// Chromium refuses every unload handler: Unraid's dynamix.js adds some, and 7.0's inline page scripts. From dynamix.js or the +// page itself the refusal is Unraid's while FV3's shipped files add none, which fv3Unload checks const plugin = `${__dirname}/../../src/folder.view3/usr/local/emhttp/plugins/folder.view3`; const fv3Unload = fs.readdirSync(plugin, { recursive: true }).filter((f) => /\.(js|page|php)$/.test(f)) .filter((f) => /(? { if (fv3Unload.length || m.text() !== 'Permissions policy violation: unload is not allowed in this document.') return false; - try { return ['/webGui/javascript/dynamix.js', `/${page}`].includes(new URL(m.location()?.url).pathname); } catch { return false; } + return ['/webGui/javascript/dynamix.js', `/${page}`].includes(pathOf(m.location()?.url)); +}; +// A console error from FV3's files is never excused; elsewhere, by its source or a URL in its text (trailing punctuation dropped) +const excused = (m, page) => { + const from = m.location()?.url || ''; + if (pathOf(from).startsWith('/plugins/folder.view3/')) return false; + const urls = [from, ...(m.text().match(/\b(?:https?|wss?):\/\/[^\s'"]+/g) || []).map((u) => u.replace(/[.,;:)]+$/, ''))]; + return urls.some(absent) || unraidUnload(m, page); }; // Each page's own rows, tiles and folders as the user sees them, read in the page: a folder as "name [members it shows]", a @@ -53,26 +63,32 @@ const READ = { }, }; -// What fake_unraid.sh saved: Media holds app-a by hand and app-b by its label, Tools takes tool-c by regex, app-d is loose, Lab -// holds Debian 12; each list in Unraid's saved order +// fake_unraid.sh's setup in Unraid's saved order: Media holds app-a by hand and app-b by its label, Tools takes tool-c by regex, +// app-d is loose, Lab holds Debian 12. The empty folder made below is in no saved order, so FV3 draws it first const WANT = { - Docker: { shut: ['Media [app-a, app-b]', 'Tools [tool-c]', 'app-d'], open: ['Media [app-a, app-b]', 'app-a', 'app-b', 'Tools [tool-c]', 'app-d'] }, + Docker: { + shut: [`${SPARE} []`, 'Media [app-a, app-b]', 'Tools [tool-c]', 'app-d'], + open: [`${SPARE} []`, 'Media [app-a, app-b]', 'app-a', 'app-b', 'Tools [tool-c]', 'app-d'], + }, VMs: { shut: { rows: ['Lab [Debian 12]', 'Home Assistant', 'Windows 11'], details: '3 of 3 detail rows after their VM' }, open: { rows: ['Lab [Debian 12]', 'Debian 12', 'Home Assistant', 'Windows 11'], details: '3 of 3 detail rows after their VM' }, }, Dashboard: { - shut: { docker: ['Media [app-a, app-b] shows []', 'Tools [tool-c] shows []', 'app-d'], vms: ['Lab [Debian 12] shows []', 'Home Assistant', 'Windows 11'] }, - open: { docker: ['Media [app-a, app-b] shows [app-a, app-b]', 'Tools [tool-c] shows []', 'app-d'], vms: ['Lab [Debian 12] shows []', 'Home Assistant', 'Windows 11'] }, + shut: { docker: [`${SPARE} [] shows []`, 'Media [app-a, app-b] shows []', 'Tools [tool-c] shows []', 'app-d'], vms: ['Lab [Debian 12] shows []', 'Home Assistant', 'Windows 11'] }, + open: { docker: [`${SPARE} [] shows []`, 'Media [app-a, app-b] shows [app-a, app-b]', 'Tools [tool-c] shows []', 'app-d'], vms: ['Lab [Debian 12] shows []', 'Home Assistant', 'Windows 11'] }, }, }; // FV3's events for a finished draw; the folder each page opens, its event when open, and how a user opens it const DRAWN = { Docker: ['docker-post-folders-creation'], VMs: ['vm-post-folders-creation'], Dashboard: ['docker-post-folders-creation', 'vm-post-folders-creation'] }; const OPEN = { - Docker: ['Media', 'docker-post-folder-expansion', (p) => p.click(`button.dropDown-${MEDIA}`)], - VMs: ['Lab', 'vm-post-folder-expansion', (p) => p.click(`button.dropDown-${LAB}`)], - // The Dashboard opens a folder from its tile's menu; this is the call that menu entry makes (dashboard.js, its Expand item) - Dashboard: ['Media', 'docker-post-folder-expansion', (p) => p.evaluate((id) => expandFolderDocker(id), MEDIA)], + Docker: ['Media', 'docker-post-folder-expansion', (p) => press(p.locator(`button.dropDown-${MEDIA}`), "Media's chevron")], + VMs: ['Lab', 'vm-post-folder-expansion', (p) => press(p.locator(`button.dropDown-${LAB}`), "Lab's chevron")], + // The tile's menu, the item FV3's lang pack labels 'expand' + Dashboard: ['Media', 'docker-post-folder-expansion', async (p) => { + await press(p.locator(`#folder-id-${MEDIA}`), "Media's tile"); + await press(p.locator('ul.dropdown-context:visible li > a', { hasText: await p.evaluate(() => $.i18n('expand')) }), "its menu's Expand"); + }], }; // The first member of Media, and where a click opens its advanced preview once Media is open const PREVIEWED = 'app-a'; @@ -87,8 +103,23 @@ function testHelpers() { if (/-post-folders?-(creation|expansion)$/.test(event.type)) events.push(event.type); return dispatch.call(this, event); }; - const seen = (el) => getComputedStyle(el).visibility !== 'hidden' - && (el.getClientRects().length > 0 || (getComputedStyle(el).display === 'contents' && [...el.children].some(seen))); + // Seen: drawn, not transparent or hidden, and not clipped away by an overflow: hidden/clip ancestor (scrolling ones are reachable) + const seen = (el) => { + if (getComputedStyle(el).display === 'contents') return [...el.children].some(seen); + if (!el.checkVisibility({ opacityProperty: true, visibilityProperty: true })) return false; + let { left, right, top, bottom } = el.getBoundingClientRect(); + for (let a = el.parentElement; a && right > left && bottom > top; a = a.parentElement) { + const style = getComputedStyle(a), box = a.getBoundingClientRect(); + if (/hidden|clip/.test(style.overflowX)) { left = Math.max(left, box.left); right = Math.min(right, box.right); } + if (/hidden|clip/.test(style.overflowY)) { top = Math.max(top, box.top); bottom = Math.min(bottom, box.bottom); } + } + return right > left && bottom > top; + }; + // Every FV3 banner shown, kept after the page removes it + const banners = []; + new MutationObserver((changes) => changes.forEach((c) => c.addedNodes.forEach((n) => { + if (n.nodeType === 1 && n.matches('.fv3-banner, :has(.fv3-banner)')) banners.push(n.textContent.trim()); + }))).observe(document, { childList: true, subtree: true }); const name = (outer) => { const before = []; for (const node of outer.querySelector('.inner').childNodes) { if (node.nodeName === 'BR') break; before.push(node.textContent); } @@ -97,7 +128,7 @@ function testHelpers() { const tableRows = (list, nameCell) => [...document.querySelectorAll(`#${list} > tr`)].filter(seen).map((row) => row.classList.contains('folder') ? `${row.querySelector('.folder-appname').innerText.trim()} [${[...row.querySelectorAll('.folder-preview span.outer')].filter(seen).map(name).join(', ')}]` : name(row.querySelector(`td.${nameCell} span.outer`))); - window.fv3Test = { events, seen, name, tableRows }; + window.fv3Test = { events, seen, name, tableRows, banners }; } // The page's reading once two in a row agree: FV3 animates an opening and Unraid may reload a list after the first draw @@ -112,6 +143,27 @@ async function settled(page, read, arg) { throw new Error(`still changing after 10 s: ${JSON.stringify(last)}`); } +// A user's click, the target scrolled to the middle first. When something lies over it, FV3's own element fails the view; Unraid's +// (7.0's fixed sidebar themes cover the left of the page below desktop width) gets the click dispatched to the target instead +async function press(locator, what) { + await locator.evaluate((el) => el.scrollIntoView({ block: 'center', inline: 'center' })); + try { + await locator.click({ timeout: 5000 }); + } catch (e) { + const cover = await locator.evaluate((el) => { + if (!window.fv3Test.seen(el)) return null; + const r = el.getBoundingClientRect(); + const top = document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2); + if (!top || el.contains(top)) return null; + for (let n = top; n && n !== document.body; n = n.parentElement) if ([...n.classList].some((c) => /^(fv3|folder-)/.test(c))) return `FV3's ${n.tagName.toLowerCase()}.${[...n.classList].join('.')}`; + return ''; + }); + if (cover === null) throw new Error(`${what} could not be clicked: ${e.message.split('\n')[0]}`); + if (cover) throw new Error(`${what} is covered by ${cover}`); + await locator.dispatchEvent('click'); + } +} + const waitEvents = (page, names) => page.waitForFunction((names) => names.every((n) => window.fv3Test.events.includes(n)), names, { timeout: 20000 }); // The popup's markup is indented HTML: with each blank text node set to one space nothing may move, as it does where Unraid's @@ -139,26 +191,41 @@ function popupState(name) { }; } +// A page whose script never yields stalls page.evaluate, which has no timeout: past this the view fails, not the step's time limit +const VIEW_LIMIT = 90000; + +// One page in one browser, theme and width; false when it ended before FV3 drew async function view(browser, kind, theme, [width, height], page) { const where = `${kind} ${theme} ${width}px ${page}`; - const context = await browser.newContext({ viewport: { width, height } }); - await context.addInitScript(testHelpers); - const tab = await context.newPage(); - const errors = []; - tab.on('pageerror', (e) => errors.push(`page error: ${e.message}`)); - tab.on('console', (m) => { - if (m.type() !== 'error') return; - const urls = [m.location()?.url, ...(m.text().match(/\b(?:https?|wss?):\/\/[^\s'"]+/g) || [])].filter(Boolean); - if (!urls.some(absent) && !unraidUnload(m, page)) errors.push(`console error: ${m.text()} (${m.location()?.url || 'no source'})`); - }); - tab.on('response', (r) => { if (r.status() >= 400 && !absent(r.url())) errors.push(`${r.status()} for ${r.url()}`); }); - tab.on('requestfailed', (r) => { if (!absent(r.url())) errors.push(`request failed: ${r.url()} ${r.failure()?.errorText}`); }); const file = `${shots}/${kind}/${theme}-${width}-${page}`; + const errors = []; + let context, tab, timer, drew = false; try { - await tab.goto(`${base}/${page}`); + context = await browser.newContext({ viewport: { width, height } }); + await context.addInitScript(testHelpers); + tab = await context.newPage(); + tab.on('pageerror', (e) => errors.push(`page error: ${e.message}`)); + tab.on('console', (m) => { if (m.type() === 'error' && !excused(m, page)) errors.push(`console error: ${m.text()} (${m.location()?.url || 'no source'})`); }); + tab.on('response', (r) => { if (r.status() >= 400 && !absent(r.url())) errors.push(`${r.status()} for ${r.url()}`); }); + tab.on('requestfailed', (r) => { if (!absent(r.url())) errors.push(`request failed: ${r.url()} ${r.failure()?.errorText}`); }); + await Promise.race([steps(), new Promise((_, reject) => { timer = setTimeout(() => reject(new Error(`the view took over ${VIEW_LIMIT / 1000} s`)), VIEW_LIMIT); })]); + } catch (e) { + check(false, `${where}: ${e.message.split('\n')[0]}`); + await tab?.screenshot({ path: `${file}-failed.png`, fullPage: true, timeout: 10000 }).catch(() => {}); + } finally { + clearTimeout(timer); + } + check(!errors.length, `${where}:\n ${[...new Set(errors)].join('\n ')}`); + await context?.close().catch(() => {}); + return drew; + + async function steps() { + const loaded = await tab.goto(`${base}/${page}`); + if (loaded?.status() !== 200) throw new Error(`/${page} answered ${loaded?.status()}`); check(await tab.evaluate((t) => [...document.querySelectorAll('link[rel=stylesheet]')] .some((l) => new RegExp(`/webGui/styles/(?:themes/|default-)${t}\\.css`).test(l.getAttribute('href'))), theme), `${where}: the ${theme} theme's stylesheet is not on the page`); await waitEvents(tab, DRAWN[page]).catch(() => { throw new Error(`FV3 did not finish drawing within 20 s (${DRAWN[page].join(', ')})`); }); + drew = true; let got = await settled(tab, READ[page]); check(same(got, WANT[page].shut), `${where}: drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].shut)}`); const [folder, opened, open] = OPEN[page]; @@ -168,7 +235,7 @@ async function view(browser, kind, theme, [width, height], page) { check(same(got, WANT[page].open), `${where}: with ${folder} open, drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].open)}`); await tab.screenshot({ path: `${file}.png`, fullPage: true }); if (PREVIEW[page]) { - await tab.locator(PREVIEW[page]).first().click(); + await press(tab.locator(PREVIEW[page]).first(), `${PREVIEWED}'s preview icon`); await tab.waitForSelector('.tooltipster-base .preview-outbox', { state: 'visible', timeout: 10000 }) .catch(() => { throw new Error('the advanced preview did not open within 10 s'); }); // The popup fades in and draws its graph after it opens @@ -179,13 +246,9 @@ async function view(browser, kind, theme, [width, height], page) { check(!popup.inside, `${where}: the advanced preview leaves the window: ${popup.inside}`); await tab.screenshot({ path: `${file}-preview.png` }); } - check(!(await tab.locator('.fv3-banner').count()), `${where}: FV3 shows a banner: ${await tab.locator('.fv3-banner').allInnerTexts()}`); - } catch (e) { - check(false, `${where}: ${e.message.split('\n')[0]}`); - await tab.screenshot({ path: `${file}-failed.png`, fullPage: true }).catch(() => {}); + const banners = await tab.evaluate(() => window.fv3Test.banners); + check(!banners.length, `${where}: FV3 showed a banner: ${banners.join(' | ')}`); } - check(!errors.length, `${where}:\n ${[...new Set(errors)].join('\n ')}`); - await context.close(); } // A save as the page posts it; anything but a 200, or an FV3 answer without FV3's header, stops the run @@ -200,8 +263,9 @@ async function post(request, path, form, what) { const browsers = { chromium: await chromium.launch(), firefox: await firefox.launch() }; const setup = await browsers.chromium.newContext(); const tab = await setup.newPage(); - await tab.goto(`${base}/Docker`); - // The token of the fake browser_test.sh started, so these writes never reach any other server on this loopback + const loaded = await tab.goto(`${base}/Docker`); + if (loaded?.status() !== 200) throw new Error(`/Docker answered ${loaded?.status()}, so the setup could not read Unraid's token`); + // lib.sh gives every fake this token and a real Unraid never has it, so no real server on this loopback is written to const token = await tab.evaluate(() => typeof csrf_token === 'string' ? csrf_token : ''); if (token !== fakeToken) { console.error(`127.0.0.1 is not the fake Unraid browser_test.sh started (token "${token}")`); process.exit(2); } // Media as fake_unraid.sh saved it, with the advanced preview on @@ -211,19 +275,29 @@ async function post(request, path, form, what) { await post(setup.request, '/plugins/folder.view3/server/update.php', { type: 'docker', id: MEDIA, csrf_token: token, content: JSON.stringify({ ...media, settings: { ...media.settings, context: 2 } }) }, "Media's advanced preview"); await post(setup.request, '/plugins/folder.view3/server/update_settings.php', { key: 'dashboard_context', value: '2', csrf_token: token }, "the Dashboard's advanced preview"); + // A folder with no members, named in characters a page must escape + await post(setup.request, '/plugins/folder.view3/server/create.php', { type: 'docker', csrf_token: token, + content: JSON.stringify({ name: SPARE, icon: '', regex: '', containers: [], settings: { preview: 1 }, actions: [] }) }, 'the empty folder'); + let undrawn = 0; for (const theme of THEMES) { // As Unraid's Display Settings saves it await post(setup.request, '/update.php', { '#file': 'dynamix/dynamix.cfg', '#section': 'display', theme, csrf_token: token }, `the ${theme} theme`); for (const [kind, browser] of Object.entries(browsers)) { fs.mkdirSync(`${shots}/${kind}`, { recursive: true }); - for (const size of SIZES) for (const page of ['Docker', 'VMs', 'Dashboard']) await view(browser, kind, theme, size, page); + for (const size of SIZES) for (const page of ['Docker', 'VMs', 'Dashboard']) { + undrawn = (await view(browser, kind, theme, size, page)) ? 0 : undrawn + 1; + if (undrawn === 3) throw new Error('3 views in a row ended before FV3 drew, so the rest were not run'); + } } } await setup.close(); for (const browser of Object.values(browsers)) await browser.close(); if (failures.length) { - console.log(`FAILED [Unraid ${version}]: ${failures.length} of ${checks} browser checks\n- ${failures.join('\n- ')}`); + console.log(`FAILED [Unraid ${version}]: ${failures.length} of ${checks} browser checks, each listed above`); process.exit(1); } console.log(`Unraid ${version}: FV3's pages in Chromium and Firefox, ${THEMES.length} themes at ${SIZES.length} widths, passed (${checks} checks)`); -})().catch((e) => { console.log(`FAILED [Unraid ${version}]: ${e.message}`); process.exit(1); }); +})().catch((e) => { + console.log(`FAILED [Unraid ${version}]: ${e.message.split('\n')[0]}${failures.length ? ` (after ${failures.length} failed checks, listed above)` : ''}`); + process.exit(1); +}); diff --git a/.github/unraid-compat/browser_test.sh b/.github/unraid-compat/browser_test.sh index f29233dc..7b41b87b 100644 --- a/.github/unraid-compat/browser_test.sh +++ b/.github/unraid-compat/browser_test.sh @@ -5,28 +5,30 @@ set -u image=$1; tree=$2; version=$3; shots=$4 # Renovate moves this with playwright-core in package.json: the driver only runs the browsers built for its own version browsers=mcr.microsoft.com/playwright:v1.65.1-noble@sha256:1507cbfc550a63a6b7396791ca4f00df17beb56342d2447b3f106c306f525579 -fake=fv3-browser-test-$$ fail() { echo "FAILED [Unraid $version]: $*"; exit 1; } -trap 'docker rm -f $fake >/dev/null 2>&1' EXIT +# Removes only the container this run made; one a killed run leaves stops within the hour (its sleep 3600) +fake= +trap '[ -z "$fake" ] || docker rm -f "$fake" >/dev/null 2>&1' EXIT -[ -d .github/unraid-compat/node_modules/playwright-core ] || fail "no playwright-core: run npm ci in .github/unraid-compat first" -docker run -d --name $fake --network none -v "$PWD:/repo" -w /repo "$image" \ - bash -c 'bash .github/unraid-compat/fake_unraid.sh "$0" "$1" && touch /run/fv3-fake-up && exec sleep infinity' "$tree" "$version" \ - >/dev/null || fail 'the fake Unraid container did not start' +driver=$(node -p "require('./.github/unraid-compat/node_modules/playwright-core/package.json').version" 2>/dev/null) +[[ $browsers == *":v$driver-"* ]] || fail "playwright-core ${driver:-is not installed (npm ci in .github/unraid-compat)}, but the browsers are ${browsers%@*}" +fake=$(docker run -d --network none -v "$PWD:/repo" -w /repo "$image" \ + bash -c 'bash .github/unraid-compat/fake_unraid.sh "$0" "$1" && touch /run/fv3-fake-up && exec sleep 3600' "$tree" "$version") \ + || fail 'the fake Unraid container did not start' end=$((SECONDS + 120)) -until docker exec $fake test -f /run/fv3-fake-up 2>/dev/null; do - [ "$(docker inspect -f '{{.State.Running}}' $fake 2>/dev/null)" = true ] || fail "the fake Unraid stopped: $(docker logs $fake 2>&1 | tail -20)" +until docker exec "$fake" test -f /run/fv3-fake-up 2>/dev/null; do + [ "$(docker inspect -f '{{.State.Running}}' "$fake" 2>/dev/null)" = true ] || fail "the fake Unraid stopped: $(docker logs "$fake" 2>&1 | tail -20)" [ $SECONDS -lt $end ] || fail 'the fake Unraid was not up within 2 minutes' sleep 0.5 done # browser_test.js writes only once the page it reaches carries this token -token=$(docker exec $fake php -d auto_prepend_file= -r 'echo parse_ini_file("/var/local/emhttp/var.ini")["csrf_token"] ?? "";') +token=$(docker exec "$fake" php -d auto_prepend_file= -r 'echo parse_ini_file("/var/local/emhttp/var.ini")["csrf_token"] ?? "";') [ -n "$token" ] || fail "no csrf_token in the fake's var.ini" mkdir -p "$shots" || fail "cannot make $shots" -docker run --rm --network container:$fake --shm-size=1g -v "$PWD:/repo:ro" -v "$(cd "$shots" && pwd):/shots" \ - -w /repo/.github/unraid-compat "$browsers" node browser_test.js "$version" /shots "$token" +docker run --rm --network container:"$fake" --shm-size=1g --user "$(id -u):$(id -g)" -e HOME=/tmp \ + -v "$PWD:/repo:ro" -v "$(cd "$shots" && pwd):/shots" -w /repo/.github/unraid-compat "$browsers" node browser_test.js "$version" /shots "$token" status=$? # The logs hold what the pages asked of Unraid's PHP and the fakes, for every run above -docker exec $fake php -d auto_prepend_file= -d display_errors=stderr .github/unraid-compat/fake_logs.php "$version" || status=1 +docker exec "$fake" php -d auto_prepend_file= -d display_errors=stderr .github/unraid-compat/fake_logs.php "$version" || status=1 exit $status diff --git a/.github/unraid-compat/fake_logs.php b/.github/unraid-compat/fake_logs.php index d9efa473..916309c3 100644 --- a/.github/unraid-compat/fake_logs.php +++ b/.github/unraid-compat/fake_logs.php @@ -1,6 +1,10 @@ /dev/null that is missing goes unseen: only errors that reach php -S's log are caught + +// FV3's flash folder in the fake, as lib.sh's $flash names it +const FV3T_FLASH = '/boot/config/plugins/folder.view3'; + function fv3_fake_log_checks(): array { $checks = []; // fake_unraid.sh makes each log, FV3 its error.log on its first line: one that cannot be read fails, never "nothing logged" @@ -20,7 +24,9 @@ function fv3_fake_log_checks(): array { // FV3's error log copies every warning raised in its requests, Unraid's too, by basename. With VM debug on, a real Unraid's // libvirt.php adds one when it keys an array by a domain handle; any other line fails $handleWarning = '/^\[[^]]+\] php-error: Resource ID#\d+ used as offset, casting to integer \(\d+\) at libvirt\.php:\d+$/'; - $reported = preg_grep($handleWarning, $read('/boot/config/plugins/folder.view3/error.log', true), PREG_GREP_INVERT); + // No error.log means nothing logged only while its folder is there + $checks[] = [is_dir(FV3T_FLASH), FV3T_FLASH . ' is missing, so its error.log was never read']; + $reported = preg_grep($handleWarning, $read(FV3T_FLASH . '/error.log', true), PREG_GREP_INVERT); $checks[] = [!$reported, "FV3's error.log:\n " . implode("\n ", $reported)]; $unknown = preg_grep('/UNKNOWN/', $read('/var/log/fv3-fakes.log')); $checks[] = [!$unknown, "the fakes were asked what they do not answer:\n " . implode("\n ", array_unique($unknown))]; diff --git a/.github/unraid-compat/pages_test.php b/.github/unraid-compat/pages_test.php index 186ec117..93c7c332 100644 --- a/.github/unraid-compat/pages_test.php +++ b/.github/unraid-compat/pages_test.php @@ -45,7 +45,8 @@ function get_json(string $path, ?int &$status = null) { return json_decode($body, true); } -$flash = '/boot/config/plugins/folder.view3'; +require __DIR__ . '/fake_logs.php'; +$flash = FV3T_FLASH; $media = 'MediaAbCdEfGhIjKlMnO'; $tools = 'ToolsPqRsTuVwXyZaBcD'; $lab = 'LabFoldAbCdEfGhIjKlM'; @@ -240,7 +241,6 @@ function get_json(string $path, ?int &$status = null) { $leaves('sync_order', ['autostart' => "app-a\napp-d 10\n"]); // What the runs left in the logs -require __DIR__ . '/fake_logs.php'; foreach (fv3_fake_log_checks() as [$ok, $what]) check($ok, $what); if ($failures) { diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff1c6217..6d5fbd4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -221,13 +221,7 @@ jobs: UNRAID_VERSION: ${{ matrix.unraid }} run: docker run --rm --network none -v "$PWD:/repo" -w /repo fv3-unraid bash .github/unraid-compat/pages_test.sh .webgui "$UNRAID_VERSION" - - name: Set up Node - if: ${{ (success() || failure()) && env.RUNS == 'true' }} - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 - with: - node-version: 26 - - # Runs after a failed step above too: this one checks what the pages draw + # Runs after a failed step above too: this one checks what the pages draw. The runner's own npm installs the driver - name: FV3's pages in Chromium and Firefox, every theme at desktop, tablet and phone widths if: ${{ (success() || failure()) && env.RUNS == 'true' }} timeout-minutes: 20 From 532fdc97ab4f939c2de9d5073c704d7b1fd959bc Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 09:37:46 +0800 Subject: [PATCH 38/72] ci: a click is dispatched only where Unraid's 7.0 sidebar covers it; any other cover fails by name --- .coderabbit.yaml | 5 +++-- .github/unraid-compat/browser_test.js | 17 +++++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index d50cecb2..4d3ef96d 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -233,8 +233,9 @@ reviews: tiles, an opened folder, the advanced preview's layout) against values written by hand. A failed request or console error passes only for a service the fake does not run (ABSENT) or for Unraid's - own unload handler. Clicks are a user's; only where Unraid's own - layout covers the target is the click dispatched instead. + own unload handler. Clicks are a user's; only where an element of + Unraid's page frame named in FRAME covers the target is the click + dispatched instead. fake_logs.php holds the log checks both tests run. package.json pins playwright-core to the image's version, which browser_test.sh checks. diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index 75ea84a1..2f97d827 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -143,21 +143,26 @@ async function settled(page, read, arg) { throw new Error(`still changing after 10 s: ${JSON.stringify(last)}`); } -// A user's click, the target scrolled to the middle first. When something lies over it, FV3's own element fails the view; Unraid's -// (7.0's fixed sidebar themes cover the left of the page below desktop width) gets the click dispatched to the target instead +// Unraid's own page frame. A click it covers is dispatched to the target; any other cover fails the view +const FRAME = [ + ['#menu', "7.0's azure and gray sidebar: fixed at the left edge, it lies over the page below desktop width"], +]; + +// A user's click, the target scrolled to the middle first async function press(locator, what) { await locator.evaluate((el) => el.scrollIntoView({ block: 'center', inline: 'center' })); try { await locator.click({ timeout: 5000 }); } catch (e) { - const cover = await locator.evaluate((el) => { + const cover = await locator.evaluate((el, frame) => { if (!window.fv3Test.seen(el)) return null; const r = el.getBoundingClientRect(); const top = document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2); if (!top || el.contains(top)) return null; - for (let n = top; n && n !== document.body; n = n.parentElement) if ([...n.classList].some((c) => /^(fv3|folder-)/.test(c))) return `FV3's ${n.tagName.toLowerCase()}.${[...n.classList].join('.')}`; - return ''; - }); + if (frame.some((selector) => top.closest(selector))) return ''; + const n = top.closest('[id], [class]') || top; + return `${n.tagName.toLowerCase()}${n.id ? `#${n.id}` : ''}${[...n.classList].map((c) => `.${c}`).join('')}`; + }, FRAME.map(([selector]) => selector)); if (cover === null) throw new Error(`${what} could not be clicked: ${e.message.split('\n')[0]}`); if (cover) throw new Error(`${what} is covered by ${cover}`); await locator.dispatchEvent('click'); From f3436d986e7eac6c0fb27037eaedc0470234b528 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 10:58:20 +0800 Subject: [PATCH 39/72] ci: the advanced preview must be visible, fit the window's width and lie where the page can scroll to --- .github/unraid-compat/browser_test.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index 2f97d827..42c4ec52 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -187,12 +187,15 @@ function popupState(name) { const after = boxes(); blanks.forEach(([node, data]) => { node.data = data; }); const moved = elements.filter((e, i) => before[i] !== after[i]); - const r = base.getBoundingClientRect(); + // Within the window's width, and nowhere the page cannot scroll to: a clicked popup stays open and in place while the page scrolls + const r = base.getBoundingClientRect(), top = r.top + scrollY, bottom = r.bottom + scrollY, page = document.documentElement.scrollHeight; + const fits = r.left >= 0 && r.right <= innerWidth + 1 && top >= 0 && bottom <= page + 1; return { + seen: window.fv3Test.seen(box), named: box.innerText.includes(name), blanks: blanks.length, moved: moved.length ? `${moved.length} elements, first ${moved.slice(0, 3).map((e) => `${e.tagName.toLowerCase()}.${[...e.classList].join('.')}`).join(', ')}` : '', - inside: r.left >= 0 && r.right <= window.innerWidth + 1 ? '' : `left ${Math.round(r.left)}, right ${Math.round(r.right)} of ${window.innerWidth}`, + inside: fits ? '' : `left ${Math.round(r.left)}, right ${Math.round(r.right)} of the window's ${innerWidth}; top ${Math.round(top)}, bottom ${Math.round(bottom)} of the page's ${page}`, }; } @@ -246,9 +249,11 @@ async function view(browser, kind, theme, [width, height], page) { // The popup fades in and draws its graph after it opens const popup = await settled(tab, popupState, PREVIEWED); if (popup.error) throw new Error(popup.error); + // Playwright's visible ignores opacity: a popup tooltipster leaves transparent opens to nothing + if (!popup.seen) throw new Error('the advanced preview opened but cannot be seen'); check(popup.named, `${where}: the advanced preview is not ${PREVIEWED}'s`); check(!popup.moved, `${where}: the advanced preview draws its markup's line breaks: ${popup.moved} moved when ${popup.blanks} blank text nodes became one space`); - check(!popup.inside, `${where}: the advanced preview leaves the window: ${popup.inside}`); + check(!popup.inside, `${where}: the advanced preview is out of reach: ${popup.inside}`); await tab.screenshot({ path: `${file}-preview.png` }); } const banners = await tab.evaluate(() => window.fv3Test.banners); From 515cbd64daf051db01a17b8f470b0a25484e4ca8 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 12:43:22 +0800 Subject: [PATCH 40/72] ci: an Unraid-alone pass checks every Unraid hook FV3 relies on, and FV3's pages keep Unraid's layout in every Dashboard layout --- .coderabbit.yaml | 8 + .github/unraid-compat/browser_test.js | 211 ++++++++++++++++++-------- .github/unraid-compat/browser_test.sh | 15 +- .github/unraid-compat/hooks.js | 94 ++++++++++++ .github/unraid-compat/layout.js | 58 +++++++ 5 files changed, 315 insertions(+), 71 deletions(-) create mode 100644 .github/unraid-compat/hooks.js create mode 100644 .github/unraid-compat/layout.js diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 4d3ef96d..42e6488d 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -239,6 +239,14 @@ reviews: fake_logs.php holds the log checks both tests run. package.json pins playwright-core to the image's version, which browser_test.sh checks. + - browser_test.sh runs an Unraid-alone pass first, FV3's three + page hooks moved out of its plugin folder. It checks hooks.js, a + hand-written list of Unraid's DOM hooks, functions and endpoints + FV3 relies on, each naming the FV3 file that still mentions it and + what the user loses; any/since only where FV3 itself branches. + layout.js holds the layout rules FV3's pass checks against that + pass and a loose container on the same page, each from a fix FV3 + has shipped. - matrix_check.py keeps ci.yml's Unraid rows at one per minor from the .plg's min to the newest release; Renovate only moves rows. - Each step asserts what the user is left with (live files, the diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index 42c4ec52..ce2ada0d 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -1,10 +1,16 @@ // FV3's pages in Chromium and Firefox on the fake Unraid browser_test.sh started, 4 themes at 3 widths, screenshots kept. -// Usage: node browser_test.js +// Usage: node browser_test.js [unraid-alone] 'use strict'; const fs = require('fs'); +const path = require('path'); const { chromium, firefox } = require('playwright-core'); +const { HOOKS, names, describe, applies, missingHooks } = require('./hooks'); +const { widths, layoutState } = require('./layout'); -const [version, shots, fakeToken] = process.argv.slice(2); +const [version, shots, fakeToken, tree, mode = 'fv3'] = process.argv.slice(2); +// The Unraid-alone pass runs with FV3's page hooks moved away: it checks Unraid's hooks and measures what FV3's pass compares with +const ALONE = mode === 'unraid-alone'; +const MEASURED = `${shots}/unraid-alone.json`; const base = 'http://127.0.0.1'; const failures = []; let checks = 0; @@ -53,11 +59,11 @@ const READ = { return { rows: window.fv3Test.tableRows('kvm_list', 'vm-name'), details: `${paired} of ${details.length} detail rows after their VM` }; }, Dashboard: () => { - const { seen, name } = window.fv3Test; - const tiles = (view) => [...document.querySelectorAll(`tbody#${view} > tr.updated > td > *`)].filter(seen).map((tile) => { + const { seen, name, members } = window.fv3Test; + const tiles = (view) => [...document.querySelectorAll(`tbody#${view} > tr.updated > td > :not(.fv3-fullwidth-panel)`)].filter(seen).map((tile) => { if (!tile.classList.contains('folder-showcase-outer')) return name(tile); - const members = [...tile.querySelectorAll('.folder-storage > span.outer, .folder-showcase > span.outer')]; - return `${tile.querySelector('.fv3-folder-appname').innerText.trim()} [${members.map(name).join(', ')}] shows [${members.filter(seen).map(name).join(', ')}]`; + const mine = members(tile); + return `${tile.querySelector('.fv3-folder-appname').innerText.trim()} [${mine.map(name).join(', ')}] shows [${mine.filter(seen).map(name).join(', ')}]`; }); return { docker: tiles('docker_view'), vms: tiles('vm_view') }; }, @@ -90,9 +96,13 @@ const OPEN = { await press(p.locator('ul.dropdown-context:visible li > a', { hasText: await p.evaluate(() => $.i18n('expand')) }), "its menu's Expand"); }], }; -// The first member of Media, and where a click opens its advanced preview once Media is open +// FV3's Dashboard layouts for the Docker and VM cards in each theme, so every layout is drawn at every width +const LAYOUTS = [['classic', 'embossed'], ['fullwidth', 'classic'], ['accordion', 'fullwidth'], ['inset', 'accordion']]; +// Unraid's own list on each page once its rows load: a loading placeholder row is not one +const LISTED = { Docker: '#docker_list > tr.sortable', VMs: '#kvm_list > tr.sortable', Dashboard: 'tbody#docker_view > tr.updated' }; +// The first member of Media, and where a click opens its advanced preview once Media is open (fullwidth: in the panel after its row) const PREVIEWED = 'app-a'; -const PREVIEW = { Docker: `tr.folder-id-${MEDIA} .folder-preview span.hand[id^="folder-preview-"]`, Dashboard: `.folder-showcase-${MEDIA} > span.outer > span.hand` }; +const PREVIEW = { Docker: `tr.folder-id-${MEDIA} .folder-preview span.hand[id^="folder-preview-"]`, Dashboard: `.folder-showcase-${MEDIA} > span.outer > span.hand, .fv3-fullwidth-panel[data-folder-name="Media"] > span.outer > span.hand` }; // Before the page's scripts: records FV3's draw and expansion events as they fire, and the readers' helpers. A display: contents // element (FV3's Dashboard folders) is seen when a child is; a name is .inner's text before its first line break, drawn or not @@ -125,10 +135,16 @@ function testHelpers() { for (const node of outer.querySelector('.inner').childNodes) { if (node.nodeName === 'BR') break; before.push(node.textContent); } return before.join('').trim(); }; + // A Dashboard folder's member tiles wherever its layout puts them: in the folder, or the fullwidth layout's panel in its row + const members = (folder) => { + const named = folder.querySelector('.folder-showcase')?.dataset.folderName; + const panel = [...folder.parentElement.querySelectorAll(':scope > .fv3-fullwidth-panel')].find((p) => p.dataset.folderName === named); + return [...folder.querySelectorAll('.folder-storage > span.outer, .folder-showcase > span.outer'), ...(panel?.querySelectorAll(':scope > span.outer') || [])]; + }; const tableRows = (list, nameCell) => [...document.querySelectorAll(`#${list} > tr`)].filter(seen).map((row) => row.classList.contains('folder') ? `${row.querySelector('.folder-appname').innerText.trim()} [${[...row.querySelectorAll('.folder-preview span.outer')].filter(seen).map(name).join(', ')}]` : name(row.querySelector(`td.${nameCell} span.outer`))); - window.fv3Test = { events, seen, name, tableRows, banners }; + window.fv3Test = { events, seen, name, members, tableRows, banners }; } // The page's reading once two in a row agree: FV3 animates an opening and Unraid may reload a list after the first draw @@ -202,12 +218,12 @@ function popupState(name) { // A page whose script never yields stalls page.evaluate, which has no timeout: past this the view fails, not the step's time limit const VIEW_LIMIT = 90000; -// One page in one browser, theme and width; false when it ended before FV3 drew -async function view(browser, kind, theme, [width, height], page) { - const where = `${kind} ${theme} ${width}px ${page}`; - const file = `${shots}/${kind}/${theme}-${width}-${page}`; +// One page in one browser, theme and width, through one pass's steps; false when it ended before the page drew +async function view(browser, kind, theme, [width, height], page, steps) { + const v = { where: `${kind} ${theme} ${width}px ${page}`, file: `${shots}/${kind}/${theme}-${width}-${page}`, theme, width, page, drew: false }; + const { where, file } = v; const errors = []; - let context, tab, timer, drew = false; + let context, tab, timer; try { context = await browser.newContext({ viewport: { width, height } }); await context.addInitScript(testHelpers); @@ -216,59 +232,117 @@ async function view(browser, kind, theme, [width, height], page) { tab.on('console', (m) => { if (m.type() === 'error' && !excused(m, page)) errors.push(`console error: ${m.text()} (${m.location()?.url || 'no source'})`); }); tab.on('response', (r) => { if (r.status() >= 400 && !absent(r.url())) errors.push(`${r.status()} for ${r.url()}`); }); tab.on('requestfailed', (r) => { if (!absent(r.url())) errors.push(`request failed: ${r.url()} ${r.failure()?.errorText}`); }); - await Promise.race([steps(), new Promise((_, reject) => { timer = setTimeout(() => reject(new Error(`the view took over ${VIEW_LIMIT / 1000} s`)), VIEW_LIMIT); })]); + await Promise.race([steps(tab, v), new Promise((_, reject) => { timer = setTimeout(() => reject(new Error(`the view took over ${VIEW_LIMIT / 1000} s`)), VIEW_LIMIT); })]); } catch (e) { check(false, `${where}: ${e.message.split('\n')[0]}`); await tab?.screenshot({ path: `${file}-failed.png`, fullPage: true, timeout: 10000 }).catch(() => {}); } finally { clearTimeout(timer); } - check(!errors.length, `${where}:\n ${[...new Set(errors)].join('\n ')}`); + // Unraid alone's own errors are not FV3's + if (!ALONE) check(!errors.length, `${where}:\n ${[...new Set(errors)].join('\n ')}`); await context?.close().catch(() => {}); - return drew; + return v.drew; +} - async function steps() { - const loaded = await tab.goto(`${base}/${page}`); - if (loaded?.status() !== 200) throw new Error(`/${page} answered ${loaded?.status()}`); - check(await tab.evaluate((t) => [...document.querySelectorAll('link[rel=stylesheet]')] - .some((l) => new RegExp(`/webGui/styles/(?:themes/|default-)${t}\\.css`).test(l.getAttribute('href'))), theme), `${where}: the ${theme} theme's stylesheet is not on the page`); - await waitEvents(tab, DRAWN[page]).catch(() => { throw new Error(`FV3 did not finish drawing within 20 s (${DRAWN[page].join(', ')})`); }); - drew = true; - let got = await settled(tab, READ[page]); - check(same(got, WANT[page].shut), `${where}: drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].shut)}`); - const [folder, opened, open] = OPEN[page]; - await open(tab); - await waitEvents(tab, [opened]).catch(() => { throw new Error(`${folder} did not open within 20 s (${opened})`); }); - got = await settled(tab, READ[page]); - check(same(got, WANT[page].open), `${where}: with ${folder} open, drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].open)}`); - await tab.screenshot({ path: `${file}.png`, fullPage: true }); - if (PREVIEW[page]) { - await press(tab.locator(PREVIEW[page]).first(), `${PREVIEWED}'s preview icon`); - await tab.waitForSelector('.tooltipster-base .preview-outbox', { state: 'visible', timeout: 10000 }) - .catch(() => { throw new Error('the advanced preview did not open within 10 s'); }); - // The popup fades in and draws its graph after it opens - const popup = await settled(tab, popupState, PREVIEWED); - if (popup.error) throw new Error(popup.error); - // Playwright's visible ignores opacity: a popup tooltipster leaves transparent opens to nothing - if (!popup.seen) throw new Error('the advanced preview opened but cannot be seen'); - check(popup.named, `${where}: the advanced preview is not ${PREVIEWED}'s`); - check(!popup.moved, `${where}: the advanced preview draws its markup's line breaks: ${popup.moved} moved when ${popup.blanks} blank text nodes became one space`); - check(!popup.inside, `${where}: the advanced preview is out of reach: ${popup.inside}`); - await tab.screenshot({ path: `${file}-preview.png` }); - } - const banners = await tab.evaluate(() => window.fv3Test.banners); - check(!banners.length, `${where}: FV3 showed a banner: ${banners.join(' | ')}`); +// The page as the theme's stylesheet draws it, or the view fails +async function load(tab, { where, page, theme }) { + const loaded = await tab.goto(`${base}/${page}`); + if (loaded?.status() !== 200) throw new Error(`/${page} answered ${loaded?.status()}`); + check(await tab.evaluate((t) => [...document.querySelectorAll('link[rel=stylesheet]')] + .some((l) => new RegExp(`/webGui/styles/(?:themes/|default-)${t}\\.css`).test(l.getAttribute('href'))), theme), `${where}: the ${theme} theme's stylesheet is not on the page`); +} + +// Unraid alone: its list drawn, the widths FV3's pass compares with, and which of FV3's hooks it lacks +const measured = {}, lacking = new Map(); +async function aloneSteps(tab, v) { + await load(tab, v); + v.drew = await tab.waitForSelector(LISTED[v.page], { timeout: 20000 }).then(() => true, () => false); + check(v.drew, `${v.where}: Unraid alone drew no ${LISTED[v.page]} within 20 s`); + measured[v.where] = await settled(tab, widths); + const hooks = HOOKS.filter((h) => !h.url && [v.page, 'any page'].includes(h.page) && applies(h, version)); + for (const i of await settled(tab, missingHooks, hooks)) lacking.set(hooks[i], [...(lacking.get(hooks[i]) || []), v.where]); +} + +// FV3's pass: drawn in the saved order, a folder opened as a user opens it, the layout rules, the advanced preview, no banners +async function fv3Steps(tab, v) { + const { where, file, page, width } = v; + await load(tab, v); + await waitEvents(tab, DRAWN[page]).catch(() => { throw new Error(`FV3 did not finish drawing within 20 s (${DRAWN[page].join(', ')})`); }); + v.drew = true; + if (page === 'Dashboard') { + const want = LAYOUTS[THEMES.indexOf(v.theme)]; + const drawn = await tab.evaluate(() => ['docker_view', 'vm_view'].map((t) => [...(document.querySelector(`tbody#${t} > tr.updated > td`)?.classList || [])] + .find((c) => c.startsWith('fv3-layout-'))?.slice('fv3-layout-'.length) || 'no layout')); + check(same(drawn, want), `${where}: the Docker and VM cards are drawn in ${drawn.join(' and ')}, not ${want.join(' and ')}`); + } + let got = await settled(tab, READ[page]); + check(same(got, WANT[page].shut), `${where}: drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].shut)}`); + const [folder, opened, open] = OPEN[page]; + await open(tab); + await waitEvents(tab, [opened]).catch(() => { throw new Error(`${folder} did not open within 20 s (${opened})`); }); + got = await settled(tab, READ[page]); + check(same(got, WANT[page].open), `${where}: with ${folder} open, drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].open)}`); + const layout = await settled(tab, layoutState, { page, desktop: width === SIZES[0][0] }); + if (layout.error) throw new Error(layout.error); + for (const problem of Object.values(layout.rules)) check(!problem, `${where}: ${problem}`); + // Where Unraid alone already scrolls sideways (both tables at tablet and phone widths), FV3 may be wider + const now = await tab.evaluate(widths), was = measured[where]; + check(was && (!was.page || now.page) && (was.table !== true || now.table), + `${where}: FV3 adds sideways scrolling Unraid alone does not have: ${now.sizes} (Unraid alone ${was?.sizes ?? 'not measured'})`); + await tab.screenshot({ path: `${file}.png`, fullPage: true }); + if (PREVIEW[page]) { + await press(tab.locator(PREVIEW[page]).first(), `${PREVIEWED}'s preview icon`); + await tab.waitForSelector('.tooltipster-base .preview-outbox', { state: 'visible', timeout: 10000 }) + .catch(() => { throw new Error('the advanced preview did not open within 10 s'); }); + // The popup fades in and draws its graph after it opens + const popup = await settled(tab, popupState, PREVIEWED); + if (popup.error) throw new Error(popup.error); + // Playwright's visible ignores opacity: a popup tooltipster leaves transparent opens to nothing + if (!popup.seen) throw new Error('the advanced preview opened but cannot be seen'); + check(popup.named, `${where}: the advanced preview is not ${PREVIEWED}'s`); + check(!popup.moved, `${where}: the advanced preview draws its markup's line breaks: ${popup.moved} moved when ${popup.blanks} blank text nodes became one space`); + check(!popup.inside, `${where}: the advanced preview is out of reach: ${popup.inside}`); + await tab.screenshot({ path: `${file}-preview.png` }); } + const banners = await tab.evaluate(() => window.fv3Test.banners); + check(!banners.length, `${where}: FV3 showed a banner: ${banners.join(' | ')}`); } // A save as the page posts it; anything but a 200, or an FV3 answer without FV3's header, stops the run -async function post(request, path, form, what) { - const r = await request.post(`${base}${path}`, { form }); - if (r.status() !== 200 || (path.includes('folder.view3') && !r.headers()['x-fv3-answer'])) throw new Error(`${what}: status ${r.status()}, ${(await r.text()).slice(0, 200)}`); +async function post(request, route, form, what) { + const r = await request.post(`${base}${route}`, { form }); + if (r.status() !== 200 || (route.includes('folder.view3') && !r.headers()['x-fv3-answer'])) throw new Error(`${what}: status ${r.status()}, ${(await r.text()).slice(0, 200)}`); +} + +// FV3's pass starts from: Media and the Dashboard with the advanced preview on, and an empty folder +async function fv3Setup(request, token) { + // Media as fake_unraid.sh saved it + const saved = await request.get(`${base}/plugins/folder.view3/server/read.php?type=docker`); + const media = saved.ok() ? (await saved.json())[MEDIA] : undefined; + if (!media) throw new Error(`no Media folder to turn the advanced preview on: status ${saved.status()}`); + await post(request, '/plugins/folder.view3/server/update.php', { type: 'docker', id: MEDIA, csrf_token: token, + content: JSON.stringify({ ...media, settings: { ...media.settings, context: 2 } }) }, "Media's advanced preview"); + await post(request, '/plugins/folder.view3/server/update_settings.php', { key: 'dashboard_context', value: '2', csrf_token: token }, "the Dashboard's advanced preview"); + // Named in characters a page must escape + await post(request, '/plugins/folder.view3/server/create.php', { type: 'docker', csrf_token: token, + content: JSON.stringify({ name: SPARE, icon: '', regex: '', containers: [], settings: { preview: 1 }, actions: [] }) }, 'the empty folder'); +} + +// Each hook's FV3 file still mentions it; each missing hook once, with the views it was missing from. An endpoint is a webGUI file +function hookChecks(webgui) { + for (const h of HOOKS) { + const text = fs.existsSync(`${plugin}/${h.file}`) ? fs.readFileSync(`${plugin}/${h.file}`, 'utf8') : null; + const gone = text === null ? [h.file] : names(h).filter((n) => !text.includes(n)); + check(!gone.length, `hooks.js names ${h.file} for ${describe(h)}, but FV3 no longer has ${gone.join(', ')} there`); + } + for (const [h, where] of lacking) check(false, `Unraid ${version} lacks ${describe(h)} on ${h.page} (${where.length} views, first ${where[0]}), which ${h.file} needs: ${h.loses}`); + for (const h of HOOKS.filter((x) => x.url)) check(fs.existsSync(path.join(webgui, 'emhttp', h.url)), `Unraid ${version} lacks ${h.url}, which ${h.file} needs: ${h.loses}`); } (async () => { - if (!fs.existsSync('/.dockerenv') || !fakeToken) { console.error('Run browser_test.sh: this needs the fake Unraid it starts'); process.exit(2); } + const webgui = path.resolve(__dirname, '../..', tree || ''); + if (!fs.existsSync('/.dockerenv') || !fakeToken || !fs.existsSync(`${webgui}/emhttp`)) { console.error('Run browser_test.sh: this needs the fake Unraid it starts and its webGUI tree'); process.exit(2); } check(!fv3Unload.length, `FV3 adds an unload handler, which Chromium never runs: ${fv3Unload.join(', ')}`); const browsers = { chromium: await chromium.launch(), firefox: await firefox.launch() }; const setup = await browsers.chromium.newContext(); @@ -278,35 +352,38 @@ async function post(request, path, form, what) { // lib.sh gives every fake this token and a real Unraid never has it, so no real server on this loopback is written to const token = await tab.evaluate(() => typeof csrf_token === 'string' ? csrf_token : ''); if (token !== fakeToken) { console.error(`127.0.0.1 is not the fake Unraid browser_test.sh started (token "${token}")`); process.exit(2); } - // Media as fake_unraid.sh saved it, with the advanced preview on - const saved = await setup.request.get(`${base}/plugins/folder.view3/server/read.php?type=docker`); - const media = saved.ok() ? (await saved.json())[MEDIA] : undefined; - if (!media) throw new Error(`no Media folder to turn the advanced preview on: status ${saved.status()}`); - await post(setup.request, '/plugins/folder.view3/server/update.php', { type: 'docker', id: MEDIA, csrf_token: token, - content: JSON.stringify({ ...media, settings: { ...media.settings, context: 2 } }) }, "Media's advanced preview"); - await post(setup.request, '/plugins/folder.view3/server/update_settings.php', { key: 'dashboard_context', value: '2', csrf_token: token }, "the Dashboard's advanced preview"); - // A folder with no members, named in characters a page must escape - await post(setup.request, '/plugins/folder.view3/server/create.php', { type: 'docker', csrf_token: token, - content: JSON.stringify({ name: SPARE, icon: '', regex: '', containers: [], settings: { preview: 1 }, actions: [] }) }, 'the empty folder'); + if (!ALONE) { + try { Object.assign(measured, JSON.parse(fs.readFileSync(MEASURED, 'utf8'))); } catch (e) { throw new Error(`the Unraid-alone pass left no measurements: ${e.message}`); } + await fv3Setup(setup.request, token); + } let undrawn = 0; - for (const theme of THEMES) { + for (const [i, theme] of THEMES.entries()) { // As Unraid's Display Settings saves it await post(setup.request, '/update.php', { '#file': 'dynamix/dynamix.cfg', '#section': 'display', theme, csrf_token: token }, `the ${theme} theme`); + if (!ALONE) for (const [card, layout] of [['docker', LAYOUTS[i][0]], ['vm', LAYOUTS[i][1]]]) { + await post(setup.request, '/plugins/folder.view3/server/update_settings.php', { key: `dashboard_${card}_layout`, value: layout, csrf_token: token }, `the Dashboard's ${layout} ${card} card`); + } for (const [kind, browser] of Object.entries(browsers)) { fs.mkdirSync(`${shots}/${kind}`, { recursive: true }); for (const size of SIZES) for (const page of ['Docker', 'VMs', 'Dashboard']) { - undrawn = (await view(browser, kind, theme, size, page)) ? 0 : undrawn + 1; - if (undrawn === 3) throw new Error('3 views in a row ended before FV3 drew, so the rest were not run'); + undrawn = (await view(browser, kind, theme, size, page, ALONE ? aloneSteps : fv3Steps)) ? 0 : undrawn + 1; + if (undrawn === 3) throw new Error(`3 views in a row ended before ${ALONE ? 'Unraid' : 'FV3'} drew, so the rest were not run`); } } } await setup.close(); for (const browser of Object.values(browsers)) await browser.close(); + if (ALONE) { + hookChecks(webgui); + fs.writeFileSync(MEASURED, JSON.stringify(measured)); + } + const what = ALONE ? `Unraid alone has the ${HOOKS.length} hooks FV3 relies on, ${THEMES.length} themes at ${SIZES.length} widths in Chromium and Firefox` + : `FV3's pages in Chromium and Firefox, ${THEMES.length} themes at ${SIZES.length} widths`; if (failures.length) { - console.log(`FAILED [Unraid ${version}]: ${failures.length} of ${checks} browser checks, each listed above`); + console.log(`FAILED [Unraid ${version}]: ${failures.length} of ${checks} checks (${ALONE ? 'Unraid alone' : "FV3's pages"}), each listed above`); process.exit(1); } - console.log(`Unraid ${version}: FV3's pages in Chromium and Firefox, ${THEMES.length} themes at ${SIZES.length} widths, passed (${checks} checks)`); + console.log(`Unraid ${version}: ${what}, passed (${checks} checks)`); })().catch((e) => { console.log(`FAILED [Unraid ${version}]: ${e.message.split('\n')[0]}${failures.length ? ` (after ${failures.length} failed checks, listed above)` : ''}`); process.exit(1); diff --git a/.github/unraid-compat/browser_test.sh b/.github/unraid-compat/browser_test.sh index 7b41b87b..27783073 100644 --- a/.github/unraid-compat/browser_test.sh +++ b/.github/unraid-compat/browser_test.sh @@ -1,6 +1,6 @@ #!/bin/bash # FV3's pages in Chromium and Firefox: the fake Unraid in a container with no network, the browsers in one that joins its network. -# From the repo root, after npm ci here: browser_test.sh +# From the repo root, after npm ci here: browser_test.sh set -u image=$1; tree=$2; version=$3; shots=$4 # Renovate moves this with playwright-core in package.json: the driver only runs the browsers built for its own version @@ -26,9 +26,16 @@ token=$(docker exec "$fake" php -d auto_prepend_file= -r 'echo parse_ini_file("/ [ -n "$token" ] || fail "no csrf_token in the fake's var.ini" mkdir -p "$shots" || fail "cannot make $shots" -docker run --rm --network container:"$fake" --shm-size=1g --user "$(id -u):$(id -g)" -e HOME=/tmp \ - -v "$PWD:/repo:ro" -v "$(cd "$shots" && pwd):/shots" -w /repo/.github/unraid-compat "$browsers" node browser_test.js "$version" /shots "$token" -status=$? +browse() { docker run --rm --network container:"$fake" --shm-size=1g --user "$(id -u):$(id -g)" -e HOME=/tmp -v "$PWD:/repo:ro" \ + -v "$(cd "$shots" && pwd):/shots" -w /repo/.github/unraid-compat "$browsers" node browser_test.js "$version" /shots "$token" "$tree" "$@"; } +# Unraid alone first, with FV3's page hooks out of its plugin folder; FV3's pass then compares with what it measured +pages='folder.view3.Docker.page folder.view3.VMs.page folder.view3.Dashboard.page' +docker exec "$fake" bash -c "mkdir -p /run/fv3-off && cd /usr/local/emhttp/plugins/folder.view3 && mv $pages /run/fv3-off/" || fail "FV3's pages could not be moved aside" +# FV3's pass must never compare with an earlier run's measurements +rm -f "$shots/unraid-alone.json" +browse unraid-alone; status=$? +docker exec "$fake" bash -c 'mv /run/fv3-off/* /usr/local/emhttp/plugins/folder.view3/' || fail "FV3's pages could not be put back" +browse || status=1 # The logs hold what the pages asked of Unraid's PHP and the fakes, for every run above docker exec "$fake" php -d auto_prepend_file= -d display_errors=stderr .github/unraid-compat/fake_logs.php "$version" || status=1 exit $status diff --git a/.github/unraid-compat/hooks.js b/.github/unraid-compat/hooks.js new file mode 100644 index 00000000..b6445d80 --- /dev/null +++ b/.github/unraid-compat/hooks.js @@ -0,0 +1,94 @@ +// Unraid's own parts FV3 relies on: each names the FV3 file that uses it and what the user loses without it. browser_test.js +// checks each on Unraid alone, and that the file still mentions it. any: FV3 takes whichever exists; since: FV3 needs it only from there +'use strict'; +const D = 'Docker', V = 'VMs', B = 'Dashboard', ALL = 'any page'; +const HOOKS = [ + // Docker's list and its rows + { page: D, dom: '#docker_list > tr.sortable', file: 'scripts/docker.js', loses: 'folders never draw' }, + { page: D, dom: '#docker_containers > thead > tr > th', file: 'scripts/docker.js', loses: 'folder rows lose their column spans and widths' }, + { page: D, dom: '#docker_list td.ct-name > span.outer > span.hand > img.img', file: 'scripts/docker.js', loses: "folder previews show no containers' icons" }, + { page: D, dom: '#docker_list td.ct-name span.inner > span.appname > a.exec', file: 'scripts/docker.js', loses: 'containers are not read into their folders' }, + { page: D, dom: '#docker_list td.ct-name span.outer i[id^="load-"]', file: 'scripts/docker.js', loses: "folder icons stop showing their containers' state" }, + { page: D, dom: '#docker_list td.updatecolumn', file: 'scripts/shared.js', loses: 'incognito leaves version text showing' }, + { page: D, dom: '#docker_list td.advanced', file: 'scripts/docker.js', loses: "the folder autostart switch cannot find its containers' switches" }, + { page: D, dom: '#docker_list input.autostart', file: 'scripts/docker.js', loses: 'the folder autostart switch does nothing' }, + { page: D, dom: '.switch-button-background', file: 'scripts/docker.js', loses: 'the folder autostart switch is unstyled' }, + { page: D, dom: '#docker_containers th.nine', file: 'scripts/shared.js', loses: 'the autostart column is sized wrong' }, + { page: D, dom: '.advancedview', file: 'scripts/docker.js', loses: 'folders are not redrawn on the basic/advanced toggle' }, + { page: D, any: ['.js-actions', 'input[value="Add Container"]'], file: 'folder.view3.Docker.page', loses: 'no Add Folder button' }, + { page: D, dom: 'div.spinner.fixed', file: 'scripts/docker.js', loses: 'no spinner during folder actions' }, + // VMs' list and its rows + { page: V, dom: '#kvm_list > tr.sortable', file: 'scripts/vm.js', loses: 'folders never draw' }, + { page: V, dom: '#kvm_table > thead > tr', file: 'scripts/vm.js', loses: 'folder rows lose their column spans' }, + { page: V, dom: '#kvm_list td.vm-name span.outer span.inner a', file: 'scripts/vm.js', loses: 'VMs are not read into their folders' }, + { page: V, dom: '#kvm_list td.vm-name span.hand > img.img', file: 'scripts/vm.js', loses: "folder previews show no VMs' icons" }, + { page: V, dom: '#kvm_list tr[id^="name-"]', file: 'scripts/vm.js', loses: 'VM detail rows escape their folders' }, + { page: V, dom: '#kvm_list a[onclick*="toggle_id"]', file: 'scripts/vm.js', loses: 'VM detail rows escape their folders' }, + { page: V, dom: '#kvm_table th.th1', file: 'scripts/vm.js', loses: 'the name column is not sized' }, + { page: V, dom: '#kvm_list input.autostart', file: 'scripts/vm.js', loses: 'the folder autostart switch throws' }, + { page: V, any: ['.js-actions', 'input[value="Add VM"]'], file: 'folder.view3.VMs.page', loses: 'no Add Folder button' }, + // The Dashboard's tiles + { page: B, dom: 'tbody#docker_view > tr.updated > td', file: 'scripts/dashboard.js', loses: 'Docker folders never draw' }, + { page: B, dom: 'tbody#vm_view > tr.updated > td', file: 'scripts/dashboard.js', loses: 'VM folders never draw' }, + { page: B, dom: 'tbody#docker_view span.outer.solid.apps > span.hand', file: 'scripts/dashboard.js', loses: 'containers are not moved into folder tiles' }, + { page: B, dom: 'tbody#docker_view span.outer.apps > span.inner', file: 'scripts/dashboard.js', loses: "containers' names are not read" }, + { page: B, dom: 'tbody#vm_view span.outer.vms > span.hand', file: 'scripts/dashboard.js', loses: 'VMs are not moved into folder tiles' }, + { page: B, dom: 'input#apps', file: 'scripts/dashboard.js', loses: "hide-stopped ignores Docker folders" }, + { page: B, dom: 'input#vms', file: 'scripts/dashboard.js', loses: 'hide-stopped ignores VM folders' }, + { page: B, dom: 'table.dashboard', file: 'styles/dashboard.css', loses: 'folder tiles lose their padding' }, + // Every page + { page: ALL, dom: 'link[href*="default-base"]', since: '7.1', file: 'scripts/include/customEvents.js', loses: "FV3 styles the page as 7.0's layout" }, + // Classes FV3 puts on its own markup for Unraid's stylesheet to colour + { page: ALL, css: 'green-text', file: 'scripts/docker.js', loses: 'a started folder loses its green state' }, + { page: ALL, css: 'red-text', file: 'scripts/docker.js', loses: 'a stopped folder loses its red state' }, + { page: ALL, css: 'orange-text', file: 'scripts/docker.js', loses: "a folder's drag handle and update mark lose their colour" }, + // Unraid's functions and jQuery plugins + { page: D, js: 'loadlist', file: 'scripts/docker.js', loses: 'folders never draw' }, + { page: D, js: 'listview', file: 'scripts/docker.js', loses: 'folders are not redrawn after a view toggle' }, + { page: D, js: 'openDocker', file: 'scripts/docker.js', loses: "a folder's Update does nothing" }, + { page: D, js: 'openTerminal', file: 'scripts/docker.js', loses: 'the console and log buttons do nothing' }, + { page: D, js: 'dockerload', file: 'scripts/docker.js', loses: 'no CPU and memory stats without the Unraid API' }, + { page: V, js: 'loadlist', file: 'scripts/vm.js', loses: 'folders never draw' }, + { page: ALL, js: 'context.attach', file: 'scripts/docker.js', loses: 'folders have no menus' }, + { page: ALL, js: 'swal', file: 'scripts/shared.js', loses: 'no confirm or error dialogs' }, + { page: ALL, js: 'csrf_token', file: 'scripts/include/customEvents.js', loses: "every FV3 save is refused" }, + { page: ALL, js: '$.fn.tooltipster', file: 'scripts/advanced-preview.js', loses: 'no advanced preview' }, + { page: D, js: '$.fn.switchButton', file: 'scripts/docker.js', loses: 'the folder autostart switch never draws' }, + { page: D, js: '$.fn.sortable', file: 'scripts/docker.js', loses: 'folders cannot be dragged' }, + { page: D, js: '$.cookie', file: 'scripts/docker.js', loses: 'the advanced view is not detected' }, + { page: D, js: '$.fn.readmore', file: 'scripts/shared.js', loses: "an opened folder's long descriptions are not folded" }, + { page: ALL, js: 'openBox', file: 'scripts/shared.js', loses: "a folder's user script actions do nothing" }, + // Unraid's endpoints FV3 intercepts or calls, as files in the webGUI + { url: '/plugins/dynamix.docker.manager/include/UserPrefs.php', file: 'scripts/docker.js', loses: "Unraid saves an order without FV3's folders" }, + { url: '/plugins/dynamix.vm.manager/include/UserPrefs.php', file: 'scripts/vm.js', loses: "Unraid saves an order without FV3's folders" }, + { url: '/plugins/dynamix.vm.manager/include/VMMachines.php', file: 'scripts/vm.js', loses: 'folders are not redrawn when the VM list reloads' }, + { url: '/webGui/include/DashboardApps.php', file: 'scripts/dashboard.js', loses: 'Dashboard folders are not redrawn when the tiles reload' }, + { url: '/plugins/dynamix.docker.manager/include/UpdateConfig.php', file: 'scripts/docker.js', loses: 'folder autostart falls out of step' }, + { url: '/plugins/dynamix.docker.manager/include/DockerUpdate.php', file: 'scripts/docker.js', loses: 'folders are not redrawn after an update' }, + { url: '/plugins/dynamix.vm.manager/include/VMajax.php', file: 'scripts/shared.js', loses: 'VM folder actions fail' }, + { url: '/plugins/dynamix.vm.manager/vnc.html', file: 'scripts/vm.js', loses: "a folder member's VNC button does nothing" }, + { url: '/plugins/dynamix.docker.manager/images/question.png', file: 'scripts/docker.js', loses: 'folders without an icon show a broken image' }, +]; + +// What a hook's FV3 file must still mention: a selector's ids, classes and quoted values, a function's own name, a URL's file +const names = (h) => (h.js ? [h.js.replace(/^\$\.(fn\.)?/, '')] : h.url ? [h.url.split('/').pop()] : h.css ? [h.css] + : (h.any || [h.dom]).flatMap((s) => [...s.matchAll(/[#.]([\w-]+)|"([^"]+)"/g)].map((m) => m[1] || m[2]))); +const describe = (h) => h.dom || (h.any && `any of ${h.any.join(', ')}`) || (h.css && `a stylesheet rule for .${h.css}`) || h.url || `the global ${h.js}`; +const older = (a, b) => { const [x, y] = [a, b].map((v) => v.split('.').map(Number)); const i = x.findIndex((n, k) => n !== y[k]); return i >= 0 && x[i] < y[i]; }; +const applies = (h, version) => !h.since || !older(version, h.since); + +// In the page: the indexes of the hooks it lacks. Rules nested in @media count; a sheet that cannot be read counts as none +function missingHooks(hooks) { + const flat = (rules) => rules.flatMap((r) => (r.cssRules ? [r, ...flat([...r.cssRules])] : [r])); + const selectors = flat([...document.styleSheets].flatMap((s) => { try { return [...s.cssRules]; } catch { return []; } })) + .map((r) => r.selectorText || '').join('\n'); + const present = (h) => { + if (h.dom) return !!document.querySelector(h.dom); + if (h.any) return h.any.some((s) => document.querySelector(s)); + if (h.css) return new RegExp(`\\.${h.css}(?![\\w-])`).test(selectors); + try { return (0, eval)(`typeof ${h.js}`) !== 'undefined'; } catch { return false; } + }; + return hooks.map((h, i) => (present(h) ? -1 : i)).filter((i) => i >= 0); +} + +module.exports = { HOOKS, names, describe, applies, missingHooks }; diff --git a/.github/unraid-compat/layout.js b/.github/unraid-compat/layout.js new file mode 100644 index 00000000..a7d011a2 --- /dev/null +++ b/.github/unraid-compat/layout.js @@ -0,0 +1,58 @@ +// The layout rules browser_test.js checks once FV3 has opened a folder, each from a fix FV3 has shipped, read in the page +'use strict'; + +// Whether the page, and the table wrapper where only the table scrolls (7.2's .TableContainer), fit without scrolling sideways +function widths() { + const page = document.documentElement, table = document.querySelector('.TableContainer'); + const fits = (el) => el.scrollWidth <= el.clientWidth + 1; + const size = (el) => `${el.scrollWidth} of ${el.clientWidth} px`; + return { page: fits(page), table: table ? fits(table) : null, sizes: `page ${size(page)}${table ? `, table ${size(table)}` : ''}` }; +} + +// Each rule's failure, '' when it holds. A folder against a loose container on its page (Unraid's name element, a link only +// with a template): name no taller, row no taller than 1.5x; at desktop width, its preview on one line inside its cell +function layoutState({ page, desktop }) { + const { seen, name, members } = window.fv3Test; + const box = (el) => el.getBoundingClientRect(); + const tall = (node) => { const r = document.createRange(); r.selectNodeContents(node); return Math.round(r.getBoundingClientRect().height); }; + const shown = (label, nameEl, icon, other, loose) => [ + !nameEl || !seen(nameEl) ? `${label}'s name cannot be seen` : tall(nameEl) > 1.5 * tall(other) ? `${label}'s name is ${tall(nameEl)} px tall, ${loose}'s ${tall(other)} px` : '', + !icon || !seen(icon) ? `${label}'s icon cannot be seen` : !icon.complete || !icon.naturalWidth ? `${label}'s icon did not load` : '', + ].filter(Boolean); + const rules = { name: [] }; + + if (page === 'Dashboard') { + const tile = [...document.querySelectorAll('tbody#docker_view span.outer')].find((o) => !o.closest('.folder-showcase-outer') && seen(o) && name(o) === 'app-d'); + const otherName = tile?.querySelector('.inner > *'); + if (!otherName) return { error: "no app-d tile to compare folders' tiles with" }; + rules.card = []; + for (const folder of document.querySelectorAll('.folder-showcase-outer')) { + const label = folder.querySelector('.fv3-folder-appname')?.innerText.trim() || 'a folder'; + rules.name.push(...shown(label, folder.querySelector('.fv3-folder-appname'), folder.querySelector('img.fv3-folder-icon'), otherName, 'app-d')); + const card = box(folder.closest('tbody')); + const out = [folder.querySelector(':scope > span.outer'), ...members(folder)].filter((o) => o && seen(o)).filter((o) => box(o).left < card.left - 1 || box(o).right > card.right + 1); + if (out.length) rules.card.push(`${label}'s ${out.map((o) => name(o) || 'tile').join(', ')} leave the card (${Math.round(card.left)}-${Math.round(card.right)})`); + } + } else { + const [list, cell, loose] = page === 'Docker' ? ['docker_list', 'ct-name', 'app-d'] : ['kvm_list', 'vm-name', 'Home Assistant']; + const rows = [...document.querySelectorAll(`#${list} > tr`)].filter(seen); + const other = rows.find((r) => !r.classList.contains('folder') && r.querySelector(`td.${cell} span.outer`) && name(r.querySelector(`td.${cell} span.outer`)) === loose); + const otherName = other?.querySelector(`td.${cell} span.inner > *`); + if (!otherName) return { error: `no ${loose} row to compare folders with` }; + rules.height = []; + if (desktop) rules.preview = []; + for (const row of rows.filter((r) => r.classList.contains('folder'))) { + const label = row.querySelector('a.folder-appname')?.innerText.trim() || 'a folder'; + rules.name.push(...shown(label, row.querySelector('a.folder-appname'), row.querySelector('img.folder-img'), otherName, loose)); + if (box(row).height > 1.5 * box(other).height) rules.height.push(`${label}'s row is ${Math.round(box(row).height)} px tall, ${loose}'s ${Math.round(box(other).height)} px`); + const items = [...row.querySelectorAll('.folder-preview span.outer')].filter(seen); + if (!desktop || !items.length) continue; + const c = box(row.querySelector('.folder-preview').closest('td')), top = box(items[0]).top; + const off = items.filter((i) => Math.abs(box(i).top - top) > 2 || box(i).left < c.left - 1 || box(i).right > c.right + 1); + if (off.length) rules.preview.push(`${label}'s preview wraps or leaves its cell at ${off.map(name).join(', ')}`); + } + } + return { rules: Object.fromEntries(Object.entries(rules).map(([rule, problems]) => [rule, problems.join('; ')])) }; +} + +module.exports = { widths, layoutState }; From 7c633914224779dde1f8f159fbfdd9cc04a9cf4a Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 12:49:39 +0800 Subject: [PATCH 41/72] ci: the Unraid-alone pass reads nothing from a page that never drew, hooks must be named as whole tokens, and a missing measurement fails only the width check --- .github/unraid-compat/browser_test.js | 17 +++++++++-------- .github/unraid-compat/hooks.js | 21 +++++++++++++-------- .github/unraid-compat/layout.js | 2 +- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index ce2ada0d..e44f071b 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -4,7 +4,7 @@ const fs = require('fs'); const path = require('path'); const { chromium, firefox } = require('playwright-core'); -const { HOOKS, names, describe, applies, missingHooks } = require('./hooks'); +const { HOOKS, tokens, mentions, describe, applies, missingHooks } = require('./hooks'); const { widths, layoutState } = require('./layout'); const [version, shots, fakeToken, tree, mode = 'fv3'] = process.argv.slice(2); @@ -220,7 +220,7 @@ const VIEW_LIMIT = 90000; // One page in one browser, theme and width, through one pass's steps; false when it ended before the page drew async function view(browser, kind, theme, [width, height], page, steps) { - const v = { where: `${kind} ${theme} ${width}px ${page}`, file: `${shots}/${kind}/${theme}-${width}-${page}`, theme, width, page, drew: false }; + const v = { where: `${kind} ${theme} ${width}px ${page}`, file: `${shots}/${kind}/${theme}-${width}-${page}${ALONE ? '-unraid-alone' : ''}`, theme, width, page, drew: false }; const { where, file } = v; const errors = []; let context, tab, timer; @@ -258,7 +258,7 @@ const measured = {}, lacking = new Map(); async function aloneSteps(tab, v) { await load(tab, v); v.drew = await tab.waitForSelector(LISTED[v.page], { timeout: 20000 }).then(() => true, () => false); - check(v.drew, `${v.where}: Unraid alone drew no ${LISTED[v.page]} within 20 s`); + if (!check(v.drew, `${v.where}: Unraid alone drew no ${LISTED[v.page]} within 20 s, so its hooks and widths were not read`)) return; measured[v.where] = await settled(tab, widths); const hooks = HOOKS.filter((h) => !h.url && [v.page, 'any page'].includes(h.page) && applies(h, version)); for (const i of await settled(tab, missingHooks, hooks)) lacking.set(hooks[i], [...(lacking.get(hooks[i]) || []), v.where]); @@ -288,8 +288,8 @@ async function fv3Steps(tab, v) { for (const problem of Object.values(layout.rules)) check(!problem, `${where}: ${problem}`); // Where Unraid alone already scrolls sideways (both tables at tablet and phone widths), FV3 may be wider const now = await tab.evaluate(widths), was = measured[where]; - check(was && (!was.page || now.page) && (was.table !== true || now.table), - `${where}: FV3 adds sideways scrolling Unraid alone does not have: ${now.sizes} (Unraid alone ${was?.sizes ?? 'not measured'})`); + if (was) check((!was.page || now.page) && (was.table !== true || now.table), `${where}: FV3 adds sideways scrolling Unraid alone does not have: ${now.sizes} (Unraid alone ${was.sizes})`); + else if (Object.keys(measured).length) check(false, `${where}: widths not compared, the Unraid-alone pass did not measure this view`); await tab.screenshot({ path: `${file}.png`, fullPage: true }); if (PREVIEW[page]) { await press(tab.locator(PREVIEW[page]).first(), `${PREVIEWED}'s preview icon`); @@ -333,7 +333,7 @@ async function fv3Setup(request, token) { function hookChecks(webgui) { for (const h of HOOKS) { const text = fs.existsSync(`${plugin}/${h.file}`) ? fs.readFileSync(`${plugin}/${h.file}`, 'utf8') : null; - const gone = text === null ? [h.file] : names(h).filter((n) => !text.includes(n)); + const gone = text === null ? [h.file] : tokens(h).filter((t) => !mentions(text, t)); check(!gone.length, `hooks.js names ${h.file} for ${describe(h)}, but FV3 no longer has ${gone.join(', ')} there`); } for (const [h, where] of lacking) check(false, `Unraid ${version} lacks ${describe(h)} on ${h.page} (${where.length} views, first ${where[0]}), which ${h.file} needs: ${h.loses}`); @@ -343,7 +343,7 @@ function hookChecks(webgui) { (async () => { const webgui = path.resolve(__dirname, '../..', tree || ''); if (!fs.existsSync('/.dockerenv') || !fakeToken || !fs.existsSync(`${webgui}/emhttp`)) { console.error('Run browser_test.sh: this needs the fake Unraid it starts and its webGUI tree'); process.exit(2); } - check(!fv3Unload.length, `FV3 adds an unload handler, which Chromium never runs: ${fv3Unload.join(', ')}`); + if (!ALONE) check(!fv3Unload.length, `FV3 adds an unload handler, which Chromium never runs: ${fv3Unload.join(', ')}`); const browsers = { chromium: await chromium.launch(), firefox: await firefox.launch() }; const setup = await browsers.chromium.newContext(); const tab = await setup.newPage(); @@ -353,7 +353,8 @@ function hookChecks(webgui) { const token = await tab.evaluate(() => typeof csrf_token === 'string' ? csrf_token : ''); if (token !== fakeToken) { console.error(`127.0.0.1 is not the fake Unraid browser_test.sh started (token "${token}")`); process.exit(2); } if (!ALONE) { - try { Object.assign(measured, JSON.parse(fs.readFileSync(MEASURED, 'utf8'))); } catch (e) { throw new Error(`the Unraid-alone pass left no measurements: ${e.message}`); } + // Without them only the width comparison is lost; FV3's pass still runs + try { Object.assign(measured, JSON.parse(fs.readFileSync(MEASURED, 'utf8'))); } catch (e) { check(false, `the Unraid-alone pass left no measurements, so no widths are compared: ${e.message}`); } await fv3Setup(setup.request, token); } let undrawn = 0; diff --git a/.github/unraid-compat/hooks.js b/.github/unraid-compat/hooks.js index b6445d80..c67a801e 100644 --- a/.github/unraid-compat/hooks.js +++ b/.github/unraid-compat/hooks.js @@ -9,7 +9,7 @@ const HOOKS = [ { page: D, dom: '#docker_list td.ct-name > span.outer > span.hand > img.img', file: 'scripts/docker.js', loses: "folder previews show no containers' icons" }, { page: D, dom: '#docker_list td.ct-name span.inner > span.appname > a.exec', file: 'scripts/docker.js', loses: 'containers are not read into their folders' }, { page: D, dom: '#docker_list td.ct-name span.outer i[id^="load-"]', file: 'scripts/docker.js', loses: "folder icons stop showing their containers' state" }, - { page: D, dom: '#docker_list td.updatecolumn', file: 'scripts/shared.js', loses: 'incognito leaves version text showing' }, + { page: D, dom: 'td.updatecolumn', file: 'scripts/shared.js', loses: 'incognito leaves version text showing' }, { page: D, dom: '#docker_list td.advanced', file: 'scripts/docker.js', loses: "the folder autostart switch cannot find its containers' switches" }, { page: D, dom: '#docker_list input.autostart', file: 'scripts/docker.js', loses: 'the folder autostart switch does nothing' }, { page: D, dom: '.switch-button-background', file: 'scripts/docker.js', loses: 'the folder autostart switch is unstyled' }, @@ -70,17 +70,22 @@ const HOOKS = [ { url: '/plugins/dynamix.docker.manager/images/question.png', file: 'scripts/docker.js', loses: 'folders without an icon show a broken image' }, ]; -// What a hook's FV3 file must still mention: a selector's ids, classes and quoted values, a function's own name, a URL's file -const names = (h) => (h.js ? [h.js.replace(/^\$\.(fn\.)?/, '')] : h.url ? [h.url.split('/').pop()] : h.css ? [h.css] - : (h.any || [h.dom]).flatMap((s) => [...s.matchAll(/[#.]([\w-]+)|"([^"]+)"/g)].map((m) => m[1] || m[2]))); +// What a hook's FV3 file must still mention: a selector's #ids, .classes and quoted values, a function's name, a URL's file +const tokens = (h) => (h.js ? [h.js.startsWith('$.fn.') ? h.js.slice(4) : h.js] : h.url ? [h.url.split('/').pop()] : h.css ? [h.css] + : (h.any || [h.dom]).flatMap((s) => [...s.matchAll(/([#.][\w-]+)|"([^"]+)"/g)].map((m) => m[1] || m[2]))); +const esc = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +// As a whole token (a #id or .class starts at its mark); a class may also be named in a class attribute or as a quoted string +const mentions = (text, t) => new RegExp(`${/^[#.]/.test(t) ? '' : '(? h.dom || (h.any && `any of ${h.any.join(', ')}`) || (h.css && `a stylesheet rule for .${h.css}`) || h.url || `the global ${h.js}`; const older = (a, b) => { const [x, y] = [a, b].map((v) => v.split('.').map(Number)); const i = x.findIndex((n, k) => n !== y[k]); return i >= 0 && x[i] < y[i]; }; const applies = (h, version) => !h.since || !older(version, h.since); -// In the page: the indexes of the hooks it lacks. Rules nested in @media count; a sheet that cannot be read counts as none +// In the page: the indexes of the hooks it lacks. Rules in @media and @import count; a sheet that cannot be read counts as none function missingHooks(hooks) { - const flat = (rules) => rules.flatMap((r) => (r.cssRules ? [r, ...flat([...r.cssRules])] : [r])); - const selectors = flat([...document.styleSheets].flatMap((s) => { try { return [...s.cssRules]; } catch { return []; } })) + const own = (sheet) => { try { return [...sheet.cssRules]; } catch { return []; } }; + const flat = (rules) => rules.flatMap((r) => (r.styleSheet ? flat(own(r.styleSheet)) : r.cssRules ? [r, ...flat([...r.cssRules])] : [r])); + const selectors = flat([...document.styleSheets].flatMap(own)) .map((r) => r.selectorText || '').join('\n'); const present = (h) => { if (h.dom) return !!document.querySelector(h.dom); @@ -91,4 +96,4 @@ function missingHooks(hooks) { return hooks.map((h, i) => (present(h) ? -1 : i)).filter((i) => i >= 0); } -module.exports = { HOOKS, names, describe, applies, missingHooks }; +module.exports = { HOOKS, tokens, mentions, describe, applies, missingHooks }; diff --git a/.github/unraid-compat/layout.js b/.github/unraid-compat/layout.js index a7d011a2..9dc27db5 100644 --- a/.github/unraid-compat/layout.js +++ b/.github/unraid-compat/layout.js @@ -10,7 +10,7 @@ function widths() { } // Each rule's failure, '' when it holds. A folder against a loose container on its page (Unraid's name element, a link only -// with a template): name no taller, row no taller than 1.5x; at desktop width, its preview on one line inside its cell +// with a template): name and row no taller than 1.5x theirs; at desktop width, its preview on one line inside its cell function layoutState({ page, desktop }) { const { seen, name, members } = window.fv3Test; const box = (el) => el.getBoundingClientRect(); From c4d56e1449d611f3a5e0bc8d55eedb8d2e7f145b Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 13:11:47 +0800 Subject: [PATCH 42/72] ci: the Dashboard opens Lab too, Unraid alone must be without FV3, and an endpoint FV3 intercepts must still be called by Unraid's pages --- .coderabbit.yaml | 7 ++- .github/unraid-compat/browser_test.js | 84 ++++++++++++++++----------- .github/unraid-compat/browser_test.sh | 5 +- .github/unraid-compat/hooks.js | 26 +++++---- 4 files changed, 70 insertions(+), 52 deletions(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 42e6488d..ad04c22e 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -241,9 +241,10 @@ reviews: browser_test.sh checks. - browser_test.sh runs an Unraid-alone pass first, FV3's three page hooks moved out of its plugin folder. It checks hooks.js, a - hand-written list of Unraid's DOM hooks, functions and endpoints - FV3 relies on, each naming the FV3 file that still mentions it and - what the user loses; any/since only where FV3 itself branches. + hand-written list of Unraid's DOM hooks, functions, stylesheet + classes and endpoints FV3 relies on, each naming the FV3 file that + still mentions it and what the user loses; any/since only where + FV3 itself branches. layout.js holds the layout rules FV3's pass checks against that pass and a loose container on the same page, each from a fix FV3 has shipped. diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index e44f071b..51546085 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -4,7 +4,7 @@ const fs = require('fs'); const path = require('path'); const { chromium, firefox } = require('playwright-core'); -const { HOOKS, tokens, mentions, describe, applies, missingHooks } = require('./hooks'); +const { HOOKS, tokens, mentions, describe, applies, forView, missingHooks } = require('./hooks'); const { widths, layoutState } = require('./layout'); const [version, shots, fakeToken, tree, mode = 'fv3'] = process.argv.slice(2); @@ -14,7 +14,8 @@ const MEASURED = `${shots}/unraid-alone.json`; const base = 'http://127.0.0.1'; const failures = []; let checks = 0; -// Each failure prints as it happens, so a run the step's time limit kills still shows what failed +// Each failure prints as it happens, so a run the step's time limit kills still shows what failed; a missing hook prints once the +// views end, as one line for all its views const check = (ok, what) => { checks++; if (!ok) { failures.push(what); console.log(`- ${what}`); } return ok; }; const same = (got, want) => JSON.stringify(got) === JSON.stringify(want); @@ -82,18 +83,21 @@ const WANT = { }, Dashboard: { shut: { docker: [`${SPARE} [] shows []`, 'Media [app-a, app-b] shows []', 'Tools [tool-c] shows []', 'app-d'], vms: ['Lab [Debian 12] shows []', 'Home Assistant', 'Windows 11'] }, - open: { docker: [`${SPARE} [] shows []`, 'Media [app-a, app-b] shows [app-a, app-b]', 'Tools [tool-c] shows []', 'app-d'], vms: ['Lab [Debian 12] shows []', 'Home Assistant', 'Windows 11'] }, + open: { docker: [`${SPARE} [] shows []`, 'Media [app-a, app-b] shows [app-a, app-b]', 'Tools [tool-c] shows []', 'app-d'], vms: ['Lab [Debian 12] shows [Debian 12]', 'Home Assistant', 'Windows 11'] }, }, }; -// FV3's events for a finished draw; the folder each page opens, its event when open, and how a user opens it +// FV3's events for a finished draw; the folders each page opens, their events once open, and how a user opens them const DRAWN = { Docker: ['docker-post-folders-creation'], VMs: ['vm-post-folders-creation'], Dashboard: ['docker-post-folders-creation', 'vm-post-folders-creation'] }; const OPEN = { - Docker: ['Media', 'docker-post-folder-expansion', (p) => press(p.locator(`button.dropDown-${MEDIA}`), "Media's chevron")], - VMs: ['Lab', 'vm-post-folder-expansion', (p) => press(p.locator(`button.dropDown-${LAB}`), "Lab's chevron")], - // The tile's menu, the item FV3's lang pack labels 'expand' - Dashboard: ['Media', 'docker-post-folder-expansion', async (p) => { - await press(p.locator(`#folder-id-${MEDIA}`), "Media's tile"); - await press(p.locator('ul.dropdown-context:visible li > a', { hasText: await p.evaluate(() => $.i18n('expand')) }), "its menu's Expand"); + Docker: ['Media', ['docker-post-folder-expansion'], (p) => press(p.locator(`button.dropDown-${MEDIA}`), "Media's chevron")], + VMs: ['Lab', ['vm-post-folder-expansion'], (p) => press(p.locator(`button.dropDown-${LAB}`), "Lab's chevron")], + // Each by its tile's menu, the item FV3's lang pack labels 'expand': Media on the Docker card, Lab on the VM card + Dashboard: ['Media and Lab', ['docker-post-folder-expansion', 'vm-post-folder-expansion'], async (p) => { + const expand = await p.evaluate(() => $.i18n('expand')); + for (const [id, folder] of [[MEDIA, 'Media'], [LAB, 'Lab']]) { + await press(p.locator(`#folder-id-${id}`), `${folder}'s tile`); + await press(p.locator('ul.dropdown-context:visible li > a', { hasText: expand }), `${folder}'s menu's Expand`); + } }], }; // FV3's Dashboard layouts for the Docker and VM cards in each theme, so every layout is drawn at every width @@ -257,14 +261,17 @@ async function load(tab, { where, page, theme }) { const measured = {}, lacking = new Map(); async function aloneSteps(tab, v) { await load(tab, v); + // An FV3 page hook left in place would compare FV3 with itself + const fv3 = await tab.$('script[src*="/plugins/folder.view3/"], link[href*="/plugins/folder.view3/"]'); + if (!check(!fv3, `${v.where}: FV3 is on the page, so this is not Unraid alone and nothing was read`)) return; v.drew = await tab.waitForSelector(LISTED[v.page], { timeout: 20000 }).then(() => true, () => false); if (!check(v.drew, `${v.where}: Unraid alone drew no ${LISTED[v.page]} within 20 s, so its hooks and widths were not read`)) return; measured[v.where] = await settled(tab, widths); - const hooks = HOOKS.filter((h) => !h.url && [v.page, 'any page'].includes(h.page) && applies(h, version)); + const hooks = forView(v.page, version); for (const i of await settled(tab, missingHooks, hooks)) lacking.set(hooks[i], [...(lacking.get(hooks[i]) || []), v.where]); } -// FV3's pass: drawn in the saved order, a folder opened as a user opens it, the layout rules, the advanced preview, no banners +// FV3's pass: drawn in the saved order, folders opened as a user opens them, the layout rules, the advanced preview, no banners async function fv3Steps(tab, v) { const { where, file, page, width } = v; await load(tab, v); @@ -280,13 +287,13 @@ async function fv3Steps(tab, v) { check(same(got, WANT[page].shut), `${where}: drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].shut)}`); const [folder, opened, open] = OPEN[page]; await open(tab); - await waitEvents(tab, [opened]).catch(() => { throw new Error(`${folder} did not open within 20 s (${opened})`); }); + await waitEvents(tab, opened).catch(() => { throw new Error(`${folder} did not open within 20 s (${opened.join(', ')})`); }); got = await settled(tab, READ[page]); check(same(got, WANT[page].open), `${where}: with ${folder} open, drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].open)}`); const layout = await settled(tab, layoutState, { page, desktop: width === SIZES[0][0] }); if (layout.error) throw new Error(layout.error); for (const problem of Object.values(layout.rules)) check(!problem, `${where}: ${problem}`); - // Where Unraid alone already scrolls sideways (both tables at tablet and phone widths), FV3 may be wider + // Only where Unraid alone fits: where it already scrolls sideways, FV3 may be wider const now = await tab.evaluate(widths), was = measured[where]; if (was) check((!was.page || now.page) && (was.table !== true || now.table), `${where}: FV3 adds sideways scrolling Unraid alone does not have: ${now.sizes} (Unraid alone ${was.sizes})`); else if (Object.keys(measured).length) check(false, `${where}: widths not compared, the Unraid-alone pass did not measure this view`); @@ -329,15 +336,21 @@ async function fv3Setup(request, token) { content: JSON.stringify({ name: SPARE, icon: '', regex: '', containers: [], settings: { preview: 1 }, actions: [] }) }, 'the empty folder'); } -// Each hook's FV3 file still mentions it; each missing hook once, with the views it was missing from. An endpoint is a webGUI file -function hookChecks(webgui) { +// Before the views: each hook's FV3 file still mentions it, and each endpoint is a webGUI file, called from Unraid's pages +// where FV3 intercepts it +function hookFiles(webgui) { for (const h of HOOKS) { const text = fs.existsSync(`${plugin}/${h.file}`) ? fs.readFileSync(`${plugin}/${h.file}`, 'utf8') : null; const gone = text === null ? [h.file] : tokens(h).filter((t) => !mentions(text, t)); check(!gone.length, `hooks.js names ${h.file} for ${describe(h)}, but FV3 no longer has ${gone.join(', ')} there`); } - for (const [h, where] of lacking) check(false, `Unraid ${version} lacks ${describe(h)} on ${h.page} (${where.length} views, first ${where[0]}), which ${h.file} needs: ${h.loses}`); - for (const h of HOOKS.filter((x) => x.url)) check(fs.existsSync(path.join(webgui, 'emhttp', h.url)), `Unraid ${version} lacks ${h.url}, which ${h.file} needs: ${h.loses}`); + const plugins = `${webgui}/emhttp/plugins`; + const pages = fs.readdirSync(plugins, { recursive: true }).filter((f) => /\.(page|php|js)$/.test(f)).map((f) => [`/plugins/${f}`, fs.readFileSync(`${plugins}/${f}`, 'utf8')]); + for (const h of HOOKS.filter((x) => x.url)) { + const file = h.url.replace(/^\/webGui\//, '/plugins/dynamix/'); + if (!check(fs.existsSync(`${webgui}/emhttp${file}`), `Unraid ${version} lacks ${h.url}, which ${h.file} needs: ${h.loses}`) || !h.intercepts) continue; + check(pages.some(([f, text]) => f !== file && text.includes(h.url)), `Unraid ${version}'s pages no longer call ${h.url}, which ${h.file} intercepts: ${h.loses}`); + } } (async () => { @@ -357,28 +370,31 @@ function hookChecks(webgui) { try { Object.assign(measured, JSON.parse(fs.readFileSync(MEASURED, 'utf8'))); } catch (e) { check(false, `the Unraid-alone pass left no measurements, so no widths are compared: ${e.message}`); } await fv3Setup(setup.request, token); } + if (ALONE) hookFiles(webgui); let undrawn = 0; - for (const [i, theme] of THEMES.entries()) { - // As Unraid's Display Settings saves it - await post(setup.request, '/update.php', { '#file': 'dynamix/dynamix.cfg', '#section': 'display', theme, csrf_token: token }, `the ${theme} theme`); - if (!ALONE) for (const [card, layout] of [['docker', LAYOUTS[i][0]], ['vm', LAYOUTS[i][1]]]) { - await post(setup.request, '/plugins/folder.view3/server/update_settings.php', { key: `dashboard_${card}_layout`, value: layout, csrf_token: token }, `the Dashboard's ${layout} ${card} card`); - } - for (const [kind, browser] of Object.entries(browsers)) { - fs.mkdirSync(`${shots}/${kind}`, { recursive: true }); - for (const size of SIZES) for (const page of ['Docker', 'VMs', 'Dashboard']) { - undrawn = (await view(browser, kind, theme, size, page, ALONE ? aloneSteps : fv3Steps)) ? 0 : undrawn + 1; - if (undrawn === 3) throw new Error(`3 views in a row ended before ${ALONE ? 'Unraid' : 'FV3'} drew, so the rest were not run`); + try { + for (const [i, theme] of THEMES.entries()) { + // As Unraid's Display Settings saves it + await post(setup.request, '/update.php', { '#file': 'dynamix/dynamix.cfg', '#section': 'display', theme, csrf_token: token }, `the ${theme} theme`); + if (!ALONE) for (const [card, layout] of [['docker', LAYOUTS[i][0]], ['vm', LAYOUTS[i][1]]]) { + await post(setup.request, '/plugins/folder.view3/server/update_settings.php', { key: `dashboard_${card}_layout`, value: layout, csrf_token: token }, `the Dashboard's ${layout} ${card} card`); + } + for (const [kind, browser] of Object.entries(browsers)) { + fs.mkdirSync(`${shots}/${kind}`, { recursive: true }); + for (const size of SIZES) for (const page of ['Docker', 'VMs', 'Dashboard']) { + undrawn = (await view(browser, kind, theme, size, page, ALONE ? aloneSteps : fv3Steps)) ? 0 : undrawn + 1; + if (undrawn === 3) throw new Error(`3 views in a row ended before ${ALONE ? 'Unraid' : 'FV3'} drew, so the rest were not run`); + } } } + } finally { + // Each missing hook once, with the views it was missing from, also when the run stops early + for (const [h, where] of lacking) check(false, `Unraid ${version} lacks ${describe(h)} on ${h.page} (${where.length} views, first ${where[0]}), which ${h.file} needs: ${h.loses}`); } await setup.close(); for (const browser of Object.values(browsers)) await browser.close(); - if (ALONE) { - hookChecks(webgui); - fs.writeFileSync(MEASURED, JSON.stringify(measured)); - } - const what = ALONE ? `Unraid alone has the ${HOOKS.length} hooks FV3 relies on, ${THEMES.length} themes at ${SIZES.length} widths in Chromium and Firefox` + if (ALONE) fs.writeFileSync(MEASURED, JSON.stringify(measured)); + const what = ALONE ? `Unraid alone has the ${HOOKS.filter((h) => applies(h, version)).length} hooks FV3 relies on, ${THEMES.length} themes at ${SIZES.length} widths in Chromium and Firefox` : `FV3's pages in Chromium and Firefox, ${THEMES.length} themes at ${SIZES.length} widths`; if (failures.length) { console.log(`FAILED [Unraid ${version}]: ${failures.length} of ${checks} checks (${ALONE ? 'Unraid alone' : "FV3's pages"}), each listed above`); diff --git a/.github/unraid-compat/browser_test.sh b/.github/unraid-compat/browser_test.sh index 27783073..fa44c2ee 100644 --- a/.github/unraid-compat/browser_test.sh +++ b/.github/unraid-compat/browser_test.sh @@ -28,9 +28,8 @@ token=$(docker exec "$fake" php -d auto_prepend_file= -r 'echo parse_ini_file("/ mkdir -p "$shots" || fail "cannot make $shots" browse() { docker run --rm --network container:"$fake" --shm-size=1g --user "$(id -u):$(id -g)" -e HOME=/tmp -v "$PWD:/repo:ro" \ -v "$(cd "$shots" && pwd):/shots" -w /repo/.github/unraid-compat "$browsers" node browser_test.js "$version" /shots "$token" "$tree" "$@"; } -# Unraid alone first, with FV3's page hooks out of its plugin folder; FV3's pass then compares with what it measured -pages='folder.view3.Docker.page folder.view3.VMs.page folder.view3.Dashboard.page' -docker exec "$fake" bash -c "mkdir -p /run/fv3-off && cd /usr/local/emhttp/plugins/folder.view3 && mv $pages /run/fv3-off/" || fail "FV3's pages could not be moved aside" +# Unraid alone first, with FV3's page hooks (folder.view3..page) out of its plugin folder; FV3's pass then compares with it +docker exec "$fake" bash -c 'mkdir -p /run/fv3-off && mv /usr/local/emhttp/plugins/folder.view3/folder.view3.*.page /run/fv3-off/' || fail "FV3's pages could not be moved aside" # FV3's pass must never compare with an earlier run's measurements rm -f "$shots/unraid-alone.json" browse unraid-alone; status=$? diff --git a/.github/unraid-compat/hooks.js b/.github/unraid-compat/hooks.js index c67a801e..9fc787de 100644 --- a/.github/unraid-compat/hooks.js +++ b/.github/unraid-compat/hooks.js @@ -1,5 +1,5 @@ -// Unraid's own parts FV3 relies on: each names the FV3 file that uses it and what the user loses without it. browser_test.js -// checks each on Unraid alone, and that the file still mentions it. any: FV3 takes whichever exists; since: FV3 needs it only from there +// Unraid's own parts FV3 relies on, each with the FV3 file that uses it and what the user loses without it. browser_test.js checks +// them on Unraid alone (endpoints as webGUI files), each file still naming its hook; any/since only where FV3 itself branches 'use strict'; const D = 'Docker', V = 'VMs', B = 'Dashboard', ALL = 'any page'; const HOOKS = [ @@ -12,7 +12,7 @@ const HOOKS = [ { page: D, dom: 'td.updatecolumn', file: 'scripts/shared.js', loses: 'incognito leaves version text showing' }, { page: D, dom: '#docker_list td.advanced', file: 'scripts/docker.js', loses: "the folder autostart switch cannot find its containers' switches" }, { page: D, dom: '#docker_list input.autostart', file: 'scripts/docker.js', loses: 'the folder autostart switch does nothing' }, - { page: D, dom: '.switch-button-background', file: 'scripts/docker.js', loses: 'the folder autostart switch is unstyled' }, + { page: D, dom: '.switch-button-background', file: 'scripts/docker.js', loses: "the folder autostart switch leaves its members' switches unchanged" }, { page: D, dom: '#docker_containers th.nine', file: 'scripts/shared.js', loses: 'the autostart column is sized wrong' }, { page: D, dom: '.advancedview', file: 'scripts/docker.js', loses: 'folders are not redrawn on the basic/advanced toggle' }, { page: D, any: ['.js-actions', 'input[value="Add Container"]'], file: 'folder.view3.Docker.page', loses: 'no Add Folder button' }, @@ -55,16 +55,16 @@ const HOOKS = [ { page: ALL, js: '$.fn.tooltipster', file: 'scripts/advanced-preview.js', loses: 'no advanced preview' }, { page: D, js: '$.fn.switchButton', file: 'scripts/docker.js', loses: 'the folder autostart switch never draws' }, { page: D, js: '$.fn.sortable', file: 'scripts/docker.js', loses: 'folders cannot be dragged' }, - { page: D, js: '$.cookie', file: 'scripts/docker.js', loses: 'the advanced view is not detected' }, + { page: D, js: '$.cookie', file: 'scripts/docker.js', loses: 'docker.js stops at load, so folders never draw' }, { page: D, js: '$.fn.readmore', file: 'scripts/shared.js', loses: "an opened folder's long descriptions are not folded" }, { page: ALL, js: 'openBox', file: 'scripts/shared.js', loses: "a folder's user script actions do nothing" }, - // Unraid's endpoints FV3 intercepts or calls, as files in the webGUI - { url: '/plugins/dynamix.docker.manager/include/UserPrefs.php', file: 'scripts/docker.js', loses: "Unraid saves an order without FV3's folders" }, - { url: '/plugins/dynamix.vm.manager/include/UserPrefs.php', file: 'scripts/vm.js', loses: "Unraid saves an order without FV3's folders" }, - { url: '/plugins/dynamix.vm.manager/include/VMMachines.php', file: 'scripts/vm.js', loses: 'folders are not redrawn when the VM list reloads' }, - { url: '/webGui/include/DashboardApps.php', file: 'scripts/dashboard.js', loses: 'Dashboard folders are not redrawn when the tiles reload' }, - { url: '/plugins/dynamix.docker.manager/include/UpdateConfig.php', file: 'scripts/docker.js', loses: 'folder autostart falls out of step' }, - { url: '/plugins/dynamix.docker.manager/include/DockerUpdate.php', file: 'scripts/docker.js', loses: 'folders are not redrawn after an update' }, + // Unraid's endpoints FV3 calls, as files in the webGUI; one it intercepts must also still be called from Unraid's pages + { url: '/plugins/dynamix.docker.manager/include/UserPrefs.php', intercepts: true, file: 'scripts/docker.js', loses: "Unraid saves an order without FV3's folders" }, + { url: '/plugins/dynamix.vm.manager/include/UserPrefs.php', intercepts: true, file: 'scripts/vm.js', loses: "Unraid saves an order without FV3's folders" }, + { url: '/plugins/dynamix.vm.manager/include/VMMachines.php', intercepts: true, file: 'scripts/vm.js', loses: 'folders are not redrawn when the VM list reloads' }, + { url: '/webGui/include/DashboardApps.php', intercepts: true, file: 'scripts/dashboard.js', loses: 'Dashboard folders are not redrawn when the tiles reload' }, + { url: '/plugins/dynamix.docker.manager/include/UpdateConfig.php', intercepts: true, file: 'scripts/docker.js', loses: 'folder autostart falls out of step' }, + { url: '/plugins/dynamix.docker.manager/include/DockerUpdate.php', intercepts: true, file: 'scripts/docker.js', loses: 'folders are not redrawn after an update' }, { url: '/plugins/dynamix.vm.manager/include/VMajax.php', file: 'scripts/shared.js', loses: 'VM folder actions fail' }, { url: '/plugins/dynamix.vm.manager/vnc.html', file: 'scripts/vm.js', loses: "a folder member's VNC button does nothing" }, { url: '/plugins/dynamix.docker.manager/images/question.png', file: 'scripts/docker.js', loses: 'folders without an icon show a broken image' }, @@ -80,6 +80,8 @@ const mentions = (text, t) => new RegExp(`${/^[#.]/.test(t) ? '' : '(? h.dom || (h.any && `any of ${h.any.join(', ')}`) || (h.css && `a stylesheet rule for .${h.css}`) || h.url || `the global ${h.js}`; const older = (a, b) => { const [x, y] = [a, b].map((v) => v.split('.').map(Number)); const i = x.findIndex((n, k) => n !== y[k]); return i >= 0 && x[i] < y[i]; }; const applies = (h, version) => !h.since || !older(version, h.since); +// The hooks one view checks: its page's and every page's that apply to this version (endpoints are checked as files) +const forView = (page, version) => HOOKS.filter((h) => !h.url && [page, ALL].includes(h.page) && applies(h, version)); // In the page: the indexes of the hooks it lacks. Rules in @media and @import count; a sheet that cannot be read counts as none function missingHooks(hooks) { @@ -96,4 +98,4 @@ function missingHooks(hooks) { return hooks.map((h, i) => (present(h) ? -1 : i)).filter((i) => i >= 0); } -module.exports = { HOOKS, tokens, mentions, describe, applies, missingHooks }; +module.exports = { HOOKS, tokens, mentions, describe, applies, forView, missingHooks }; From 0bfe2b763582250307f83cb5c9302df6ce193e1c Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 14:43:03 +0800 Subject: [PATCH 43/72] ci: a Dashboard folder's menu waits for the last one to close, and a press that finds nothing names its target --- .github/unraid-compat/browser_test.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index 51546085..85e592f8 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -91,12 +91,15 @@ const DRAWN = { Docker: ['docker-post-folders-creation'], VMs: ['vm-post-folders const OPEN = { Docker: ['Media', ['docker-post-folder-expansion'], (p) => press(p.locator(`button.dropDown-${MEDIA}`), "Media's chevron")], VMs: ['Lab', ['vm-post-folder-expansion'], (p) => press(p.locator(`button.dropDown-${LAB}`), "Lab's chevron")], - // Each by its tile's menu, the item FV3's lang pack labels 'expand': Media on the Docker card, Lab on the VM card + // Each by its tile's menu, the item FV3's lang pack labels 'expand'. Unraid fades a used menu out and then hides every menu, + // so a user's next menu waits for that: one opened during the fade closes at once Dashboard: ['Media and Lab', ['docker-post-folder-expansion', 'vm-post-folder-expansion'], async (p) => { const expand = await p.evaluate(() => $.i18n('expand')); for (const [id, folder] of [[MEDIA, 'Media'], [LAB, 'Lab']]) { await press(p.locator(`#folder-id-${id}`), `${folder}'s tile`); await press(p.locator('ul.dropdown-context:visible li > a', { hasText: expand }), `${folder}'s menu's Expand`); + await p.waitForFunction(() => [...document.querySelectorAll('ul.dropdown-context')].every((u) => !u.offsetParent), null, { timeout: 5000 }) + .catch(() => { throw new Error(`${folder}'s menu did not close within 5 s`); }); } }], }; @@ -170,7 +173,8 @@ const FRAME = [ // A user's click, the target scrolled to the middle first async function press(locator, what) { - await locator.evaluate((el) => el.scrollIntoView({ block: 'center', inline: 'center' })); + await locator.evaluate((el) => el.scrollIntoView({ block: 'center', inline: 'center' }), null, { timeout: 10000 }) + .catch(() => { throw new Error(`${what} is not on the page within 10 s`); }); try { await locator.click({ timeout: 5000 }); } catch (e) { @@ -182,7 +186,8 @@ async function press(locator, what) { if (frame.some((selector) => top.closest(selector))) return ''; const n = top.closest('[id], [class]') || top; return `${n.tagName.toLowerCase()}${n.id ? `#${n.id}` : ''}${[...n.classList].map((c) => `.${c}`).join('')}`; - }, FRAME.map(([selector]) => selector)); + }, FRAME.map(([selector]) => selector), { timeout: 5000 }).catch(() => undefined); + if (cover === undefined) throw new Error(`${what} could not be clicked, then left the page: ${e.message.split('\n')[0]}`); if (cover === null) throw new Error(`${what} could not be clicked: ${e.message.split('\n')[0]}`); if (cover) throw new Error(`${what} is covered by ${cover}`); await locator.dispatchEvent('click'); From 14e667250291889fc7a9d9670ef56026514b91d8 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 15:23:36 +0800 Subject: [PATCH 44/72] ci: a Dashboard folder's menu waits for the last menu's fade to end --- .github/unraid-compat/browser_test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index 85e592f8..5fdb48e2 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -91,14 +91,14 @@ const DRAWN = { Docker: ['docker-post-folders-creation'], VMs: ['vm-post-folders const OPEN = { Docker: ['Media', ['docker-post-folder-expansion'], (p) => press(p.locator(`button.dropDown-${MEDIA}`), "Media's chevron")], VMs: ['Lab', ['vm-post-folder-expansion'], (p) => press(p.locator(`button.dropDown-${LAB}`), "Lab's chevron")], - // Each by its tile's menu, the item FV3's lang pack labels 'expand'. Unraid fades a used menu out and then hides every menu, - // so a user's next menu waits for that: one opened during the fade closes at once + // Each by its tile's menu, the item FV3's lang pack labels 'expand'. Unraid fades a used menu out and hides every menu as each + // fade ends, so a user's next menu waits for the fade (jQuery's :animated): one opened during it closes at once Dashboard: ['Media and Lab', ['docker-post-folder-expansion', 'vm-post-folder-expansion'], async (p) => { const expand = await p.evaluate(() => $.i18n('expand')); for (const [id, folder] of [[MEDIA, 'Media'], [LAB, 'Lab']]) { await press(p.locator(`#folder-id-${id}`), `${folder}'s tile`); await press(p.locator('ul.dropdown-context:visible li > a', { hasText: expand }), `${folder}'s menu's Expand`); - await p.waitForFunction(() => [...document.querySelectorAll('ul.dropdown-context')].every((u) => !u.offsetParent), null, { timeout: 5000 }) + await p.waitForFunction(() => !$('ul.dropdown-context:animated').length && [...document.querySelectorAll('ul.dropdown-context')].every((u) => !u.offsetParent), null, { timeout: 5000 }) .catch(() => { throw new Error(`${folder}'s menu did not close within 5 s`); }); } }], From 2fc37a9974fbfa580c99f27b1cb55aa9e7b58840 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 15:23:47 +0800 Subject: [PATCH 45/72] ci: a layout failure names the folder even when its name is hidden --- .github/unraid-compat/layout.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/unraid-compat/layout.js b/.github/unraid-compat/layout.js index 9dc27db5..87b5a572 100644 --- a/.github/unraid-compat/layout.js +++ b/.github/unraid-compat/layout.js @@ -19,6 +19,8 @@ function layoutState({ page, desktop }) { !nameEl || !seen(nameEl) ? `${label}'s name cannot be seen` : tall(nameEl) > 1.5 * tall(other) ? `${label}'s name is ${tall(nameEl)} px tall, ${loose}'s ${tall(other)} px` : '', !icon || !seen(icon) ? `${label}'s icon cannot be seen` : !icon.complete || !icon.naturalWidth ? `${label}'s icon did not load` : '', ].filter(Boolean); + // A folder by its name's text, even where that text cannot be seen + const nameOf = (el) => el?.textContent.trim() || 'a folder'; const rules = { name: [] }; if (page === 'Dashboard') { @@ -27,7 +29,7 @@ function layoutState({ page, desktop }) { if (!otherName) return { error: "no app-d tile to compare folders' tiles with" }; rules.card = []; for (const folder of document.querySelectorAll('.folder-showcase-outer')) { - const label = folder.querySelector('.fv3-folder-appname')?.innerText.trim() || 'a folder'; + const label = nameOf(folder.querySelector('.fv3-folder-appname')); rules.name.push(...shown(label, folder.querySelector('.fv3-folder-appname'), folder.querySelector('img.fv3-folder-icon'), otherName, 'app-d')); const card = box(folder.closest('tbody')); const out = [folder.querySelector(':scope > span.outer'), ...members(folder)].filter((o) => o && seen(o)).filter((o) => box(o).left < card.left - 1 || box(o).right > card.right + 1); @@ -42,7 +44,7 @@ function layoutState({ page, desktop }) { rules.height = []; if (desktop) rules.preview = []; for (const row of rows.filter((r) => r.classList.contains('folder'))) { - const label = row.querySelector('a.folder-appname')?.innerText.trim() || 'a folder'; + const label = nameOf(row.querySelector('a.folder-appname')); rules.name.push(...shown(label, row.querySelector('a.folder-appname'), row.querySelector('img.folder-img'), otherName, loose)); if (box(row).height > 1.5 * box(other).height) rules.height.push(`${label}'s row is ${Math.round(box(row).height)} px tall, ${loose}'s ${Math.round(box(other).height)} px`); const items = [...row.querySelectorAll('.folder-preview span.outer')].filter(seen); From 181e40eb7367e293747f865bb7aba5c93c8418df Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:30:01 +0800 Subject: [PATCH 46/72] ci: a click waits for its target to stop moving, and a failed click names what Playwright says covered it --- .github/unraid-compat/browser_test.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index 5fdb48e2..b5d46f2b 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -171,13 +171,23 @@ const FRAME = [ ['#menu', "7.0's azure and gray sidebar: fixed at the left edge, it lies over the page below desktop width"], ]; -// A user's click, the target scrolled to the middle first +// A user's click, the target scrolled to the middle until it stays there: a folder opening above it grows for a moment async function press(locator, what) { - await locator.evaluate((el) => el.scrollIntoView({ block: 'center', inline: 'center' }), null, { timeout: 10000 }) - .catch(() => { throw new Error(`${what} is not on the page within 10 s`); }); + const middle = () => locator.evaluate((el) => { + el.scrollIntoView({ block: 'center', inline: 'center' }); + const r = el.getBoundingClientRect(); + return `${Math.round(r.top)},${Math.round(r.left)}`; + }, null, { timeout: 10000 }).catch(() => { throw new Error(`${what} is not on the page within 10 s`); }); + for (let at = await middle(), i = 0; i < 20; i++) { + await locator.page().waitForTimeout(100); + if (at === (at = await middle())) break; + } try { await locator.click({ timeout: 5000 }); } catch (e) { + // Playwright's own retries scroll the target elsewhere: what covers it is read back in the middle, beside Playwright's reason + const why = e.message.split('\n').find((l) => l.includes('intercepts pointer events'))?.trim().replace(/^- /, '') || e.message.split('\n')[0]; + await middle().catch(() => {}); const cover = await locator.evaluate((el, frame) => { if (!window.fv3Test.seen(el)) return null; const r = el.getBoundingClientRect(); @@ -187,9 +197,9 @@ async function press(locator, what) { const n = top.closest('[id], [class]') || top; return `${n.tagName.toLowerCase()}${n.id ? `#${n.id}` : ''}${[...n.classList].map((c) => `.${c}`).join('')}`; }, FRAME.map(([selector]) => selector), { timeout: 5000 }).catch(() => undefined); - if (cover === undefined) throw new Error(`${what} could not be clicked, then left the page: ${e.message.split('\n')[0]}`); - if (cover === null) throw new Error(`${what} could not be clicked: ${e.message.split('\n')[0]}`); - if (cover) throw new Error(`${what} is covered by ${cover}`); + if (cover === undefined) throw new Error(`${what} could not be clicked, then left the page: ${why}`); + if (cover === null) throw new Error(`${what} could not be clicked: ${why}`); + if (cover) throw new Error(`${what} is covered by ${cover} (${why})`); await locator.dispatchEvent('click'); } } From 3a11551784784816fa5bbe1763b04309e2067408 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:30:15 +0800 Subject: [PATCH 47/72] ci: a tile outside its card is named once --- .github/unraid-compat/browser_test.js | 2 +- .github/unraid-compat/layout.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index b5d46f2b..cb892e12 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -171,7 +171,7 @@ const FRAME = [ ['#menu', "7.0's azure and gray sidebar: fixed at the left edge, it lies over the page below desktop width"], ]; -// A user's click, the target scrolled to the middle until it stays there: a folder opening above it grows for a moment +// A user's click, the target scrolled to the middle until it stays there: a folder opening above it can still move it async function press(locator, what) { const middle = () => locator.evaluate((el) => { el.scrollIntoView({ block: 'center', inline: 'center' }); diff --git a/.github/unraid-compat/layout.js b/.github/unraid-compat/layout.js index 87b5a572..f9f8269d 100644 --- a/.github/unraid-compat/layout.js +++ b/.github/unraid-compat/layout.js @@ -32,8 +32,9 @@ function layoutState({ page, desktop }) { const label = nameOf(folder.querySelector('.fv3-folder-appname')); rules.name.push(...shown(label, folder.querySelector('.fv3-folder-appname'), folder.querySelector('img.fv3-folder-icon'), otherName, 'app-d')); const card = box(folder.closest('tbody')); - const out = [folder.querySelector(':scope > span.outer'), ...members(folder)].filter((o) => o && seen(o)).filter((o) => box(o).left < card.left - 1 || box(o).right > card.right + 1); - if (out.length) rules.card.push(`${label}'s ${out.map((o) => name(o) || 'tile').join(', ')} leave the card (${Math.round(card.left)}-${Math.round(card.right)})`); + const own = folder.querySelector(':scope > span.outer'); + const out = [own, ...members(folder)].filter((o) => o && seen(o)).filter((o) => box(o).left < card.left - 1 || box(o).right > card.right + 1); + if (out.length) rules.card.push(`${label}'s ${out.map((o) => (o === own ? 'tile' : name(o))).join(', ')} outside the card (${Math.round(card.left)} to ${Math.round(card.right)} px)`); } } else { const [list, cell, loose] = page === 'Docker' ? ['docker_list', 'ct-name', 'app-d'] : ['kvm_list', 'vm-name', 'Home Assistant']; From 63d6fdf24a63d03092dc56480528728f40fcbb44 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 17:50:51 +0800 Subject: [PATCH 48/72] ci: drop the preview line rule: FV3's preview clips an item that does not fit, which the readout already fails --- .github/unraid-compat/browser_test.js | 4 ++-- .github/unraid-compat/layout.js | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index cb892e12..d50bec9e 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -288,7 +288,7 @@ async function aloneSteps(tab, v) { // FV3's pass: drawn in the saved order, folders opened as a user opens them, the layout rules, the advanced preview, no banners async function fv3Steps(tab, v) { - const { where, file, page, width } = v; + const { where, file, page } = v; await load(tab, v); await waitEvents(tab, DRAWN[page]).catch(() => { throw new Error(`FV3 did not finish drawing within 20 s (${DRAWN[page].join(', ')})`); }); v.drew = true; @@ -305,7 +305,7 @@ async function fv3Steps(tab, v) { await waitEvents(tab, opened).catch(() => { throw new Error(`${folder} did not open within 20 s (${opened.join(', ')})`); }); got = await settled(tab, READ[page]); check(same(got, WANT[page].open), `${where}: with ${folder} open, drawn as ${JSON.stringify(got)}, not ${JSON.stringify(WANT[page].open)}`); - const layout = await settled(tab, layoutState, { page, desktop: width === SIZES[0][0] }); + const layout = await settled(tab, layoutState, page); if (layout.error) throw new Error(layout.error); for (const problem of Object.values(layout.rules)) check(!problem, `${where}: ${problem}`); // Only where Unraid alone fits: where it already scrolls sideways, FV3 may be wider diff --git a/.github/unraid-compat/layout.js b/.github/unraid-compat/layout.js index f9f8269d..b6aa0c7b 100644 --- a/.github/unraid-compat/layout.js +++ b/.github/unraid-compat/layout.js @@ -10,8 +10,8 @@ function widths() { } // Each rule's failure, '' when it holds. A folder against a loose container on its page (Unraid's name element, a link only -// with a template): name and row no taller than 1.5x theirs; at desktop width, its preview on one line inside its cell -function layoutState({ page, desktop }) { +// with a template): name and row no taller than 1.5x theirs. A preview item that does not fit is clipped, which the readout fails +function layoutState(page) { const { seen, name, members } = window.fv3Test; const box = (el) => el.getBoundingClientRect(); const tall = (node) => { const r = document.createRange(); r.selectNodeContents(node); return Math.round(r.getBoundingClientRect().height); }; @@ -43,16 +43,10 @@ function layoutState({ page, desktop }) { const otherName = other?.querySelector(`td.${cell} span.inner > *`); if (!otherName) return { error: `no ${loose} row to compare folders with` }; rules.height = []; - if (desktop) rules.preview = []; for (const row of rows.filter((r) => r.classList.contains('folder'))) { const label = nameOf(row.querySelector('a.folder-appname')); rules.name.push(...shown(label, row.querySelector('a.folder-appname'), row.querySelector('img.folder-img'), otherName, loose)); if (box(row).height > 1.5 * box(other).height) rules.height.push(`${label}'s row is ${Math.round(box(row).height)} px tall, ${loose}'s ${Math.round(box(other).height)} px`); - const items = [...row.querySelectorAll('.folder-preview span.outer')].filter(seen); - if (!desktop || !items.length) continue; - const c = box(row.querySelector('.folder-preview').closest('td')), top = box(items[0]).top; - const off = items.filter((i) => Math.abs(box(i).top - top) > 2 || box(i).left < c.left - 1 || box(i).right > c.right + 1); - if (off.length) rules.preview.push(`${label}'s preview wraps or leaves its cell at ${off.map(name).join(', ')}`); } } return { rules: Object.fromEntries(Object.entries(rules).map(([rule, problems]) => [rule, problems.join('; ')])) }; From d77299e66207de068cc8f11f4b28e945f953a51b Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 18:11:55 +0800 Subject: [PATCH 49/72] ci: Unraid alone's own browser errors fail its pass too --- .github/unraid-compat/browser_test.js | 4 ++-- .github/unraid-compat/layout.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/unraid-compat/browser_test.js b/.github/unraid-compat/browser_test.js index d50bec9e..113bc3b3 100644 --- a/.github/unraid-compat/browser_test.js +++ b/.github/unraid-compat/browser_test.js @@ -258,8 +258,8 @@ async function view(browser, kind, theme, [width, height], page, steps) { } finally { clearTimeout(timer); } - // Unraid alone's own errors are not FV3's - if (!ALONE) check(!errors.length, `${where}:\n ${[...new Set(errors)].join('\n ')}`); + // Unraid alone must run clean too: an error there is Unraid's or the fake's, and its readings would not hold + check(!errors.length, `${where}:\n ${[...new Set(errors)].join('\n ')}`); await context?.close().catch(() => {}); return v.drew; } diff --git a/.github/unraid-compat/layout.js b/.github/unraid-compat/layout.js index b6aa0c7b..39310694 100644 --- a/.github/unraid-compat/layout.js +++ b/.github/unraid-compat/layout.js @@ -10,7 +10,7 @@ function widths() { } // Each rule's failure, '' when it holds. A folder against a loose container on its page (Unraid's name element, a link only -// with a template): name and row no taller than 1.5x theirs. A preview item that does not fit is clipped, which the readout fails +// with a template): name and row no taller than 1.5x theirs. A preview item clipped wholly out of sight drops out of the readout function layoutState(page) { const { seen, name, members } = window.fv3Test; const box = (el) => el.getBoundingClientRect(); From b060ca8e6acddc49a2516e0a3c1efd783509fa3b Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 19:08:41 +0800 Subject: [PATCH 50/72] ci: stop when the last run's measurements cannot be removed --- .github/unraid-compat/browser_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/unraid-compat/browser_test.sh b/.github/unraid-compat/browser_test.sh index fa44c2ee..5624e2c0 100644 --- a/.github/unraid-compat/browser_test.sh +++ b/.github/unraid-compat/browser_test.sh @@ -31,7 +31,7 @@ browse() { docker run --rm --network container:"$fake" --shm-size=1g --user "$(i # Unraid alone first, with FV3's page hooks (folder.view3..page) out of its plugin folder; FV3's pass then compares with it docker exec "$fake" bash -c 'mkdir -p /run/fv3-off && mv /usr/local/emhttp/plugins/folder.view3/folder.view3.*.page /run/fv3-off/' || fail "FV3's pages could not be moved aside" # FV3's pass must never compare with an earlier run's measurements -rm -f "$shots/unraid-alone.json" +rm -f "$shots/unraid-alone.json" || fail "the last run's measurements could not be removed from $shots" browse unraid-alone; status=$? docker exec "$fake" bash -c 'mv /run/fv3-off/* /usr/local/emhttp/plugins/folder.view3/' || fail "FV3's pages could not be put back" browse || status=1 From 5ba4a64acde244bfc42536e0641a53f6d8142866 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 19:43:39 +0800 Subject: [PATCH 51/72] fix(error log): log only warnings raised in FV3's own files Unraid's own warnings (libvirt.php with VM Manager debug on) stay in its phplog and no longer show in FV3's debug panel as FV3 errors. The fake Unraid's log check drops its libvirt exception: any line in FV3's error.log fails. --- .github/scripts/error_handler_test.php | 52 +++++++++++++++++++ .github/unraid-compat/fake_logs.php | 6 +-- .../plugins/folder.view3/server/lib.php | 4 +- 3 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 .github/scripts/error_handler_test.php diff --git a/.github/scripts/error_handler_test.php b/.github/scripts/error_handler_test.php new file mode 100644 index 00000000..753d6d31 --- /dev/null +++ b/.github/scripts/error_handler_test.php @@ -0,0 +1,52 @@ +&1', $out, $rc); +check('the plugin was copied', $rc === 0 && is_file("$docroot/plugins/folder.view3/server/lib.php"), $out); +// Each warns on its line 2: an FV3 file, Unraid's VM code, and a folder whose name only starts like FV3's +$warns = [ + 'fv3-own' => "$docroot/plugins/folder.view3/server/fv3t_warn.php", + 'unraid-own' => "$docroot/plugins/dynamix.vm.manager/include/fv3t_warn.php", + 'name-prefix' => "$docroot/plugins/folder.view3-copy/fv3t_warn.php", +]; +// lib.php requires these two Unraid host files at load time +$files = ['webGui/include/Helpers.php' => ' ' $path) $files[substr($path, strlen("$docroot/"))] = " $src) { + @mkdir(dirname("$docroot/$rel"), 0777, true); + file_put_contents("$docroot/$rel", $src); +} + +// One request: load lib.php, then run each file +$request = '$_SERVER["DOCUMENT_ROOT"] = ' . var_export($docroot, true) . '; require ' . var_export("$docroot/plugins/folder.view3/server/lib.php", true) . ';' + . ' $configDir = ' . var_export("$fv3tTmp/config", true) . '; foreach (' . var_export(array_values($warns), true) . ' as $f) include $f;'; +$out = []; +exec(escapeshellarg(PHP_BINARY) . ' -d error_reporting=-1 -d display_errors=0 -d log_errors=1 -d error_log=' . escapeshellarg("$fv3tTmp/php.log") + . ' -r ' . escapeshellarg($request) . ' 2>&1', $out, $rc); +check('the request ran with no output', $rc === 0 && $out === [], ['rc' => $rc, 'out' => $out]); + +$logged = @file("$fv3tTmp/config/error.log", FILE_IGNORE_NEW_LINES) ?: []; +check("error.log holds the FV3 file's warning and nothing else", + count($logged) === 1 && preg_match('/^\[\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\] php-error: Undefined array key "fv3-own" at fv3t_warn\.php:2$/', $logged[0]), $logged); +$phplog = (string)@file_get_contents("$fv3tTmp/php.log"); +foreach ($warns as $key => $path) { + check("PHP's own log still has the $key warning", str_contains($phplog, "PHP Warning: Undefined array key \"$key\" in $path on line 2"), $phplog); +} + +exec('rm -rf ' . escapeshellarg($fv3tTmp)); +echo $fv3tFailed ? "\n$fv3tFailed FAILED\n" : "\nall passed\n"; +exit($fv3tFailed ? 1 : 0); diff --git a/.github/unraid-compat/fake_logs.php b/.github/unraid-compat/fake_logs.php index 916309c3..0e3528c4 100644 --- a/.github/unraid-compat/fake_logs.php +++ b/.github/unraid-compat/fake_logs.php @@ -21,12 +21,10 @@ function fv3_fake_log_checks(): array { // No script died or failed an include: in Unraid's own code, a sign of state the fakes lack $broken = preg_grep('/PHP Fatal error|Failed opening .* for inclusion/', $phplog); $checks[] = [!$broken, "PHP died or missed a file:\n " . implode("\n ", array_slice(array_unique($broken), 0, 20))]; - // FV3's error log copies every warning raised in its requests, Unraid's too, by basename. With VM debug on, a real Unraid's - // libvirt.php adds one when it keys an array by a domain handle; any other line fails - $handleWarning = '/^\[[^]]+\] php-error: Resource ID#\d+ used as offset, casting to integer \(\d+\) at libvirt\.php:\d+$/'; + // Any line in FV3's error log fails: a clean run logs nothing there, and Unraid's own warnings stay in its phplog // No error.log means nothing logged only while its folder is there $checks[] = [is_dir(FV3T_FLASH), FV3T_FLASH . ' is missing, so its error.log was never read']; - $reported = preg_grep($handleWarning, $read(FV3T_FLASH . '/error.log', true), PREG_GREP_INVERT); + $reported = $read(FV3T_FLASH . '/error.log', true); $checks[] = [!$reported, "FV3's error.log:\n " . implode("\n ", $reported)]; $unknown = preg_grep('/UNKNOWN/', $read('/var/log/fv3-fakes.log')); $checks[] = [!$unknown, "the fakes were asked what they do not answer:\n " . implode("\n ", array_unique($unknown))]; diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php index 0118c9a1..b281120b 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php @@ -164,9 +164,11 @@ function fv3_read_error_log_tail(): ?string { if (!headers_sent()) { http_response_code(500); header('Content-Type: application/json'); } echo json_encode(['error' => 'Internal error']); }); - // Non-fatal PHP errors don't end the request, so only log them; deprecations are noise, not failures + // Non-fatal PHP errors don't end the request, so only log them; deprecations are noise, not failures. + // Only FV3's own files: a warning raised in Unraid's code (libvirt.php...) stays in Unraid's phplog alone set_error_handler(function(int $severity, string $message, string $file, int $line): bool { if (!(error_reporting() & $severity) || ($severity & (E_DEPRECATED | E_USER_DEPRECATED))) return false; + if (!str_starts_with($file, dirname(__DIR__) . '/')) return false; fv3_error_log('php-error', "$message at " . basename($file) . ":$line"); return false; }); From 12093958cb2ddc796bc03b9316a137df6ca9725d Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 19:48:18 +0800 Subject: [PATCH 52/72] fix(error log): comments say what the check tests: files under FV3's folder --- .github/scripts/error_handler_test.php | 6 +++--- .../usr/local/emhttp/plugins/folder.view3/server/lib.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/scripts/error_handler_test.php b/.github/scripts/error_handler_test.php index 753d6d31..a7ed48e5 100644 --- a/.github/scripts/error_handler_test.php +++ b/.github/scripts/error_handler_test.php @@ -1,6 +1,6 @@ 'Internal error']); }); // Non-fatal PHP errors don't end the request, so only log them; deprecations are noise, not failures. - // Only FV3's own files: a warning raised in Unraid's code (libvirt.php...) stays in Unraid's phplog alone + // Only files under FV3's folder: a warning raised in Unraid's code (libvirt.php...) stays in Unraid's phplog alone set_error_handler(function(int $severity, string $message, string $file, int $line): bool { if (!(error_reporting() & $severity) || ($severity & (E_DEPRECATED | E_USER_DEPRECATED))) return false; if (!str_starts_with($file, dirname(__DIR__) . '/')) return false; From 6d8a25a61a5afc93db714df06a4f2067dbdb8024 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:36:07 +0800 Subject: [PATCH 53/72] ci: a function hook must be callable and csrf_token a non-empty string; dockerload's hook is the addEventListener FV3 calls --- .github/unraid-compat/hooks.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/unraid-compat/hooks.js b/.github/unraid-compat/hooks.js index 9fc787de..d2fb6d1d 100644 --- a/.github/unraid-compat/hooks.js +++ b/.github/unraid-compat/hooks.js @@ -42,16 +42,16 @@ const HOOKS = [ { page: ALL, css: 'green-text', file: 'scripts/docker.js', loses: 'a started folder loses its green state' }, { page: ALL, css: 'red-text', file: 'scripts/docker.js', loses: 'a stopped folder loses its red state' }, { page: ALL, css: 'orange-text', file: 'scripts/docker.js', loses: "a folder's drag handle and update mark lose their colour" }, - // Unraid's functions and jQuery plugins + // Unraid's functions and jQuery plugins, each callable, and its CSRF token, a non-empty string { page: D, js: 'loadlist', file: 'scripts/docker.js', loses: 'folders never draw' }, { page: D, js: 'listview', file: 'scripts/docker.js', loses: 'folders are not redrawn after a view toggle' }, { page: D, js: 'openDocker', file: 'scripts/docker.js', loses: "a folder's Update does nothing" }, { page: D, js: 'openTerminal', file: 'scripts/docker.js', loses: 'the console and log buttons do nothing' }, - { page: D, js: 'dockerload', file: 'scripts/docker.js', loses: 'no CPU and memory stats without the Unraid API' }, + { page: D, js: 'dockerload.addEventListener', file: 'scripts/docker.js', loses: 'no CPU and memory stats without the Unraid API' }, { page: V, js: 'loadlist', file: 'scripts/vm.js', loses: 'folders never draw' }, { page: ALL, js: 'context.attach', file: 'scripts/docker.js', loses: 'folders have no menus' }, { page: ALL, js: 'swal', file: 'scripts/shared.js', loses: 'no confirm or error dialogs' }, - { page: ALL, js: 'csrf_token', file: 'scripts/include/customEvents.js', loses: "every FV3 save is refused" }, + { page: ALL, js: 'csrf_token', string: true, file: 'scripts/include/customEvents.js', loses: "every FV3 save is refused" }, { page: ALL, js: '$.fn.tooltipster', file: 'scripts/advanced-preview.js', loses: 'no advanced preview' }, { page: D, js: '$.fn.switchButton', file: 'scripts/docker.js', loses: 'the folder autostart switch never draws' }, { page: D, js: '$.fn.sortable', file: 'scripts/docker.js', loses: 'folders cannot be dragged' }, @@ -93,7 +93,10 @@ function missingHooks(hooks) { if (h.dom) return !!document.querySelector(h.dom); if (h.any) return h.any.some((s) => document.querySelector(s)); if (h.css) return new RegExp(`\\.${h.css}(?![\\w-])`).test(selectors); - try { return (0, eval)(`typeof ${h.js}`) !== 'undefined'; } catch { return false; } + try { + const value = (0, eval)(h.js); + return h.string ? typeof value === 'string' && value !== '' : typeof value === 'function'; + } catch { return false; } }; return hooks.map((h, i) => (present(h) ? -1 : i)).filter((i) => i >= 0); } From 030d65bed7e248d42aa15b217ab870bf2985d622 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:47:10 +0800 Subject: [PATCH 54/72] ci: a hook's expected type lives in HOOKS; a failed js hook names the function or non-empty string it lacked --- .github/unraid-compat/hooks.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/unraid-compat/hooks.js b/.github/unraid-compat/hooks.js index d2fb6d1d..ee7e7470 100644 --- a/.github/unraid-compat/hooks.js +++ b/.github/unraid-compat/hooks.js @@ -51,7 +51,7 @@ const HOOKS = [ { page: V, js: 'loadlist', file: 'scripts/vm.js', loses: 'folders never draw' }, { page: ALL, js: 'context.attach', file: 'scripts/docker.js', loses: 'folders have no menus' }, { page: ALL, js: 'swal', file: 'scripts/shared.js', loses: 'no confirm or error dialogs' }, - { page: ALL, js: 'csrf_token', string: true, file: 'scripts/include/customEvents.js', loses: "every FV3 save is refused" }, + { page: ALL, js: 'csrf_token', type: 'string', file: 'scripts/include/customEvents.js', loses: "every FV3 save is refused" }, { page: ALL, js: '$.fn.tooltipster', file: 'scripts/advanced-preview.js', loses: 'no advanced preview' }, { page: D, js: '$.fn.switchButton', file: 'scripts/docker.js', loses: 'the folder autostart switch never draws' }, { page: D, js: '$.fn.sortable', file: 'scripts/docker.js', loses: 'folders cannot be dragged' }, @@ -77,7 +77,8 @@ const esc = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // As a whole token (a #id or .class starts at its mark); a class may also be named in a class attribute or as a quoted string const mentions = (text, t) => new RegExp(`${/^[#.]/.test(t) ? '' : '(? h.dom || (h.any && `any of ${h.any.join(', ')}`) || (h.css && `a stylesheet rule for .${h.css}`) || h.url || `the global ${h.js}`; +const describe = (h) => h.dom || (h.any && `any of ${h.any.join(', ')}`) || (h.css && `a stylesheet rule for .${h.css}`) || h.url + || (h.type === 'string' ? `${h.js} as a non-empty string` : `the function ${h.js}`); const older = (a, b) => { const [x, y] = [a, b].map((v) => v.split('.').map(Number)); const i = x.findIndex((n, k) => n !== y[k]); return i >= 0 && x[i] < y[i]; }; const applies = (h, version) => !h.since || !older(version, h.since); // The hooks one view checks: its page's and every page's that apply to this version (endpoints are checked as files) @@ -95,7 +96,7 @@ function missingHooks(hooks) { if (h.css) return new RegExp(`\\.${h.css}(?![\\w-])`).test(selectors); try { const value = (0, eval)(h.js); - return h.string ? typeof value === 'string' && value !== '' : typeof value === 'function'; + return typeof value === (h.type || 'function') && value !== ''; } catch { return false; } }; return hooks.map((h, i) => (present(h) ? -1 : i)).filter((i) => i >= 0); From db3a3c50d3d5ea5f563be40fdb8ff362242acf1d Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Sun, 15 Nov 2026 15:39:11 +0000 Subject: [PATCH 55/72] chore(beta): release changelog Release-Synced: 6c42d026e904b611e6978ec4b877673e3fe1724e --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e02dacbb..63d1b00a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache if the page doesn't display correctly — before submitting a debug .json. +## Unreleased + +- fix(error log): comments say what the check tests: files under FV3's folder +- fix(error log): log only warnings raised in FV3's own files + ## 2026.11.14.3 (beta) - A failed update no longer deletes the package the installed version reinstalls from at boot From 6c9ad1396021bb7f5a94349549b4b4eb417cfd5c Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Mon, 16 Nov 2026 04:24:59 +0800 Subject: [PATCH 56/72] docs: beta release notes Release-Synced: 6c42d026e904b611e6978ec4b877673e3fe1724e --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63d1b00a..d795950a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,7 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache ## Unreleased -- fix(error log): comments say what the check tests: files under FV3's folder -- fix(error log): log only warnings raised in FV3's own files +- The error log no longer lists Unraid's own PHP warnings as FolderView3 errors ## 2026.11.14.3 (beta) From 8f7ca7fa3051ce5fd7f7108ba54089a4bdf96643 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Mon, 16 Nov 2026 04:35:54 +0800 Subject: [PATCH 57/72] chore(release): v2026.11.16.1 [skip ci] --- CHANGELOG.md | 2 +- folder.view3.plg | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d795950a..98e8ed12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache if the page doesn't display correctly — before submitting a debug .json. -## Unreleased +## 2026.11.16.1 (beta) - The error log no longer lists Unraid's own PHP warnings as FolderView3 errors diff --git a/folder.view3.plg b/folder.view3.plg index 9e9dddcb..05a97934 100644 --- a/folder.view3.plg +++ b/folder.view3.plg @@ -6,8 +6,8 @@ - - + + ]> @@ -16,6 +16,9 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache if the page doesn't display correctly — before submitting a debug .json. +###2026.11.16.1 +- The error log no longer lists Unraid's own PHP warnings as FolderView3 errors + ###2026.11.14.3 - A failed update no longer deletes the package the installed version reinstalls from at boot From e84e6d5e9687d7c95c284af54b23d3249dc5ba7e Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Mon, 16 Nov 2026 12:34:48 +0800 Subject: [PATCH 58/72] fix: keep a saved userprefs.cfg's containers with their folders In folder mode the autostart file followed the page, but userprefs.cfg kept the order of the last drag: a container added to a folder since then was missing from it, and Unraid (and other plugins that read it, such as an appdata backup's start order) put it first. The order sync now places each folder's members together, in the folder's order, next to the folder's entry, on the side they were saved on. - Only a saved order is changed: no userprefs.cfg is created (#112). - A folder with no entry, or none of its members saved yet, stays as it is. - Written only when it changes; a failed write is reported, and the autostart file is still put in order. --- .github/scripts/page_order_test.php | 44 +++++++++++++++ .../plugins/folder.view3/server/lib.php | 54 ++++++++++++++++--- 2 files changed, 92 insertions(+), 6 deletions(-) diff --git a/.github/scripts/page_order_test.php b/.github/scripts/page_order_test.php index 58b8ce4b..cf3665fc 100644 --- a/.github/scripts/page_order_test.php +++ b/.github/scripts/page_order_test.php @@ -90,6 +90,12 @@ class DockerUpdate {} $GLOBALS['fv3tDown'] = false; } }; +// $sync's run, answering with userprefs.cfg as the run left it (null = no file) in place of the autostart file +$syncPrefs = function (?array $folders, array $names, ?string $cfg, ?callable $break = null) use ($sync, $fv3DockerManDir): array { + [$answer] = $sync($folders, $names, $cfg, null, $break); + $file = "$fv3DockerManDir/userprefs.cfg"; + return [$answer, file_exists($file) ? file_get_contents($file) : null]; +}; // updateAutostartConfig() as the Autostart tab calls it, with the folder config as given $autostartSave = function (string $mode, string $foldersJson, array $waits = [], bool $readOnly = false) use ($setPrefs, $configDir, $fv3tAutostart): array { $GLOBALS['fv3tNames'] = ['a', 'b']; @@ -248,6 +254,44 @@ class DockerUpdate {} $sync([], ['b', 'a', 'c'], $cutOff, ['c', 'ghost', 'b 5', 'a']), ["Unraid's saved Docker order (userprefs.cfg) could not be read", ['c', 'ghost', 'b 5', 'a']]], ['an empty userprefs.cfg writes A-Z, as no userprefs.cfg does', $sync([], ['b', 'a', 'c'], '', ['c', 'b 5', 'a']), [null, ['a', 'b 5', 'c']]], + ['userprefs.cfg: a folder member it lacks is saved right after its folder, in the folder\'s order', + $syncPrefs(['f' => $folder('F', ['x', 'y'])], ['a', 'b', 'x', 'y'], $userprefs(['a', 'folder-f', 'x', 'b'])), [null, $userprefs(['a', 'folder-f', 'x', 'y', 'b'])]], + ['userprefs.cfg: a member saved away from its folder moves to it', + $syncPrefs(['f' => $folder('F', ['x', 'y'])], ['a', 'b', 'x', 'y'], $userprefs(['y', 'a', 'folder-f', 'x', 'b'])), [null, $userprefs(['a', 'folder-f', 'x', 'y', 'b'])]], + ['userprefs.cfg: a member moved to another folder follows it', + $syncPrefs(['f' => $folder('F', ['x']), 'g' => $folder('G', ['w', 'y'])], ['w', 'x', 'y'], $userprefs(['folder-f', 'x', 'y', 'folder-g', 'w'])), [null, $userprefs(['folder-f', 'x', 'folder-g', 'w', 'y'])]], + ['userprefs.cfg: members saved before their folder, as FV3\'s own writers save them, stay before it', + $syncPrefs(['f' => $folder('F', ['x', 'y'])], ['a', 'x', 'y'], $userprefs(['x', 'folder-f', 'a'])), [null, $userprefs(['x', 'y', 'folder-f', 'a'])]], + ['userprefs.cfg: a regex folder\'s members keep the saved order, on their side of its entry', + $syncPrefs(['r' => $folder('Rx', [], '^web')], ['web1', 'web2', 'db'], $userprefs(['web2', 'folder-r', 'db', 'web1'])), [null, $userprefs(['web2', 'web1', 'folder-r', 'db'])]], + ['userprefs.cfg: a folder with none of its members saved yet, as after an import, is left as it is', + $syncPrefs(['f' => $folder('F', ['x'])], ['a', 'x'], $userprefs(['folder-f', 'a'])), [null, $userprefs(['folder-f', 'a'])]], + ['userprefs.cfg: a folder it has no entry for leaves its members where they are', + $syncPrefs(['f' => $folder('F', ['x', 'y'])], ['a', 'x', 'y'], $userprefs(['x', 'a', 'y'])), [null, $userprefs(['x', 'a', 'y'])]], + ['userprefs.cfg: an entry Docker does not have keeps its place', + $syncPrefs(['f' => $folder('F', ['x'])], ['a', 'x'], $userprefs(['ghost', 'folder-f', 'a', 'x'])), [null, $userprefs(['ghost', 'folder-f', 'x', 'a'])]], + ['userprefs.cfg: none is not created, so Unraid keeps its A-Z order', + $syncPrefs(['f' => $folder('F', ['x'])], ['a', 'x'], null), [null, null]], + ['userprefs.cfg: an empty one stays empty', + $syncPrefs(['f' => $folder('F', ['x'])], ['a', 'x'], ''), [null, '']], + ['userprefs.cfg: one already in place is not written again, its numbering kept', + $syncPrefs(['f' => $folder('F', ['x', 'y'])], ['x', 'y'], "0=\"folder-f\"\n2=\"x\"\n5=\"y\"\n"), [null, "0=\"folder-f\"\n2=\"x\"\n5=\"y\"\n"]], + ['userprefs.cfg: the fixture\'s saved order is already in place', + $syncPrefs($fixture['folders'], $fixture['containers'], $userprefs($fixture['prefs'])), [null, $userprefs($fixture['prefs'])]], + ['userprefs.cfg: custom and off modes leave it as it is', + array_map(fn($mode) => $syncPrefs(['f' => $folder('F', ['x'])], ['a', 'x'], $userprefs(['x', 'folder-f', 'a']), + fn() => file_put_contents("$configDir/autostart.json", json_encode(['mode' => $mode, 'sequence' => ['a', 'x']]))), ['custom', 'off']), + array_fill(0, 2, [null, $userprefs(['x', 'folder-f', 'a'])])], + ['userprefs.cfg: a cut-off one is left as it is, and reported', + $syncPrefs(['f' => $folder('F', ['x'])], ['a', 'x'], $cutOff), ["Unraid's saved Docker order (userprefs.cfg) could not be read", $cutOff]], + ['userprefs.cfg: a failed write is reported, and the autostart file is still put in order', + (function () use ($sync, $folder, $userprefs, $fv3DockerManDir) { + try { return $sync(['f' => $folder('F', ['x'])], ['a', 'b', 'x'], $userprefs(['b', 'folder-f', 'a', 'x']), ['a', 'x', 'b'], fn() => chmod($fv3DockerManDir, 0555)); } + finally { chmod($fv3DockerManDir, 0755); } + })(), ["Unraid's saved Docker order (userprefs.cfg) could not be updated", ['b', 'x', 'a']]], + ['userprefs.cfg: the page order is the same before and after the update', + $order(['f' => $folder('F', ['x', 'y'])], ['a', 'b', 'x', 'y'], fv3_parse_user_prefs($syncPrefs(['f' => $folder('F', ['x', 'y'])], ['a', 'b', 'x', 'y'], $userprefs(['y', 'a', 'folder-f', 'b']))[1])), + $order(['f' => $folder('F', ['x', 'y'])], ['a', 'b', 'x', 'y'], ['y', 'a', 'folder-f', 'b'])], ['no containers, or Docker not running (Unraid\'s client answers an empty list): nothing is written, nothing is reported', $sync([], [], null, ['b', 'a']), [null, ['b', 'a']]], ['a container list with an unnamed entry: nothing is written, and it is reported', diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php index a34941c2..9a056353 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php @@ -856,6 +856,45 @@ function fv3_page_order(array $membership, array $allContainerNames, array $pref return array_merge($new, $loose, $placed); } + // $prefs with each folder's members together in its order, on the side of its entry a neighbour shows (a drag: after, FV3's writers: + // before; after by default). A folder with no entry or no saved member (a new import), and every other entry, stay as they are + function fv3_prefs_with_folder_members(array $prefs, array $membership): array { + $blocks = []; + foreach ($membership['containers'] as $placeholder => $members) { + $at = array_search($placeholder, $prefs, true); + if ($at === false || !array_intersect($prefs, $members)) continue; + $after = isset($prefs[$at + 1]) && in_array($prefs[$at + 1], $members, true); + $before = !$after && $at > 0 && in_array($prefs[$at - 1], $members, true); + $blocks[$placeholder] = ['members' => $members, 'before' => $before]; + } + if (!$blocks) return $prefs; + $moved = array_merge(...array_column($blocks, 'members')); + $out = []; + foreach ($prefs as $entry) { + if (in_array($entry, $moved, true)) continue; + if (!isset($blocks[$entry])) { $out[] = $entry; continue; } + ['members' => $members, 'before' => $before] = $blocks[$entry]; + unset($blocks[$entry]); // a repeated entry for the same folder keeps its place, its members come once + array_push($out, ...($before ? [...$members, $entry] : [$entry, ...$members])); + } + return $out; + } + + // Keeps userprefs.cfg's containers with their folders, so what reads it (Unraid's Start all and autostart sort, other plugins) + // follows the page. Only a saved order is changed: creating one switches Unraid off its A-Z order (#112). Returns why it failed + function fv3_sync_user_prefs(array $prefs, array $membership): ?string { + global $fv3DockerManDir; + if (!$prefs) return null; + $updated = fv3_prefs_with_folder_members($prefs, $membership); + if ($updated === $prefs) return null; + if (!fv3_write_user_prefs("$fv3DockerManDir/userprefs.cfg", $updated)) { + fv3_debug_log("fv3_sync_user_prefs: userprefs.cfg could not be written"); + return "Unraid's saved Docker order (userprefs.cfg) could not be updated"; + } + fv3_debug_log("fv3_sync_user_prefs: wrote userprefs.cfg with " . count($updated) . " entries"); + return null; + } + // Autostart lines ("name" or "name delay") in $order's sequence, each once; lines $order does not name follow, in file order function fv3_reorder_autostart(array $lines, array $order): array { $byName = []; @@ -867,10 +906,10 @@ function fv3_reorder_autostart(array $lines, array $order): array { return array_merge($ordered, array_values($byName)); } - // Returns why the autostart file could not be put in order (a file or a Docker read it needs failed), else null. + // Returns why the autostart file or userprefs.cfg could not be put in order (a file or a Docker read it needs failed), else null. // Folder mode only logs an empty container list: a server with no containers, or with Docker off, has nothing to report function syncContainerOrder(string $type): ?string { - // Rewrites the autostart file to match what FV3 renders on screen — top-to-bottom, + // Rewrites the autostart file (and, in folder mode, a saved userprefs.cfg) to match what FV3 renders on screen — top-to-bottom, // folder members left-to-right in their editor-chosen order. Render order comes from // userprefs.cfg when it exists (saved by a drag-reorder or an import), A-Z otherwise. global $configDir; @@ -915,21 +954,24 @@ function syncContainerOrder(string $type): ?string { $prefs = fv3_docker_prefs(); // The page's order cannot be worked out then, so the file stays as it is if ($prefs === null) { return $stop("Unraid's saved Docker order (userprefs.cfg) could not be read"); } - $newOrder = fv3_page_order(fv3_compute_folder_membership($folders, $allContainerNames, $ctLabels, $prefs), $allContainerNames, $prefs); + $membership = fv3_compute_folder_membership($folders, $allContainerNames, $ctLabels, $prefs); + // A failed userprefs.cfg write is reported, but the autostart file below is still put in order + $prefsFailed = fv3_sync_user_prefs($prefs, $membership); + $newOrder = fv3_page_order($membership, $allContainerNames, $prefs); fv3_debug_log("syncContainerOrder: computed newOrder with " . count($newOrder) . " entries (" . ($prefs ? 'userprefs.cfg' : 'A-Z, no userprefs.cfg') . ")"); - // Rewrite autostart file in $newOrder sequence; userprefs.cfg is not touched here + // Rewrite autostart file in $newOrder sequence $autoStartFile = fv3_autostart_file(); if (file_exists($autoStartFile)) { $rawLines = fv3_read_autostart_lines($autoStartFile); if ($rawLines === null) { return $stop('the autostart file could not be read'); } $autoStartLines = fv3_prune_stale_autostart($rawLines, $allContainerNames, $ctListComplete); $newAutoStart = fv3_reorder_autostart($autoStartLines, $newOrder); - if ($newAutoStart === $rawLines) { fv3_debug_log("syncContainerOrder: autostart file already in order"); return null; } + if ($newAutoStart === $rawLines) { fv3_debug_log("syncContainerOrder: autostart file already in order"); return $prefsFailed; } if (@file_put_contents($autoStartFile, implode("\n", $newAutoStart) . "\n", LOCK_EX) === false) { return $stop('the autostart file could not be written'); } fv3_debug_log("syncContainerOrder: wrote autostart file with " . count($newAutoStart) . " entries"); } - return null; + return $prefsFailed; } // Creates Unraid's saved Docker order on a server with none, after an import or a restore: $first's entries (placeholders, names) From a2333cdea15ddf3fb7a8de4fdf1956d30e90f5a8 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:54:35 +0800 Subject: [PATCH 59/72] fix: regroup userprefs.cfg in every autostart mode and on page load - Off and custom modes regroup userprefs.cfg too; the Off label and tooltip now say FV3 never writes the autostart file - The Docker page asks for one sync per load, so a container a regex or label put in a folder is saved with it - The regroup re-reads the file before writing, refuses a name it cannot write back, and refreshes the order snapshot - A failed userprefs.cfg write and a failed autostart write are both reported --- .github/scripts/docker_saved_places_test.js | 49 +++++++++- .github/scripts/page_order_test.php | 46 +++++++--- .../plugins/folder.view3/FolderView3.page | 4 +- .../emhttp/plugins/folder.view3/langs/de.json | 4 +- .../emhttp/plugins/folder.view3/langs/en.json | 4 +- .../emhttp/plugins/folder.view3/langs/es.json | 4 +- .../emhttp/plugins/folder.view3/langs/fr.json | 4 +- .../emhttp/plugins/folder.view3/langs/it.json | 4 +- .../emhttp/plugins/folder.view3/langs/pl.json | 4 +- .../emhttp/plugins/folder.view3/langs/zh.json | 4 +- .../plugins/folder.view3/scripts/docker.js | 19 +++- .../plugins/folder.view3/server/lib.php | 90 ++++++++++--------- 12 files changed, 156 insertions(+), 80 deletions(-) diff --git a/.github/scripts/docker_saved_places_test.js b/.github/scripts/docker_saved_places_test.js index 1a28436a..02dc263f 100644 --- a/.github/scripts/docker_saved_places_test.js +++ b/.github/scripts/docker_saved_places_test.js @@ -1,7 +1,9 @@ -// node .github/scripts/docker_saved_places_test.js — a deleted folder or removed container still named in userprefs.cfg no longer -// moves a saved folder on the Docker page (npm ci in this folder first) +// node .github/scripts/docker_saved_places_test.js — where the Docker page puts saved folders: stale userprefs.cfg entries do not move +// them, and the page draws the same after sync_order.php regroups the file, which it asks for once per load (npm ci in this folder first) 'use strict'; -const { drawDocker, check, done } = require('./preview_pages_harness.js'); +const fs = require('fs'); +const path = require('path'); +const { drawDocker, phpServer, check, done } = require('./preview_pages_harness.js'); const same = (a, b) => JSON.stringify(a) === JSON.stringify(b); const folder = (name, containers = [], regex = '') => ({ name, containers, regex }); @@ -65,5 +67,46 @@ const folder = (name, containers = [], regex = '') => ({ name, containers, regex check('the generated orders do place folders, with and without unsaved rows above them', shapes.folders > 50 && shapes.unsaved > 50 && shapes.both > 20, shapes); check('200 generated orders with nothing stale place every folder where they did before', differ.length === 0, differ.slice(0, 2)); } + // The real sync_order.php regroups userprefs.cfg; the page drawn from the file before and after is the same + const drawnFrom = async (folders, containers, prefs) => { const page = await drawDocker({ folders, containers, prefs }); await page.draw(); return page.drawn(); }; + for (const [what, folders, containers, prefs] of [ + ['a folder member it lacks', { f: folder('F', ['x', 'y']) }, ['a', 'b', 'x', 'y'], ['a', 'folder-f', 'x', 'b']], + ['a member saved away from its folder', { f: folder('F', ['x', 'y']) }, ['a', 'b', 'x', 'y'], ['y', 'a', 'folder-f', 'x', 'b']], + ['a member moved to another folder', { f: folder('F', ['x']), g: folder('G', ['w', 'y']) }, ['w', 'x', 'y'], ['folder-f', 'x', 'y', 'folder-g', 'w']], + ['members saved before their folder', { f: folder('F', ['x', 'y']) }, ['a', 'x', 'y'], ['x', 'folder-f', 'a']], + ['a regex folder', { r: folder('Rx', [], '^web') }, ['web1', 'web2', 'db'], ['web2', 'folder-r', 'db', 'web1']], + ]) { + const php = phpServer('userprefs-sync', { containers }); + try { + const dockerMan = path.join(path.dirname(php.config), 'dockerMan'); + fs.writeFileSync(path.join(php.config, 'docker.json'), JSON.stringify(folders)); + fs.writeFileSync(path.join(dockerMan, 'dockerMan.cfg'), `autostart-file="${path.join(dockerMan, 'unraid-autostart')}"\n`); + fs.writeFileSync(path.join(dockerMan, 'userprefs.cfg'), prefs.map((n, i) => `${i}="${n}"\n`).join('')); + const answer = php.server('sync_order.php', 'POST', { type: 'docker' }); + const after = fs.readFileSync(path.join(dockerMan, 'userprefs.cfg'), 'utf8').split('\n').filter(Boolean).map((l) => l.replace(/^\d+="(.*)"$/, '$1')); + const [was, now] = [await drawnFrom(folders, containers, prefs), await drawnFrom(folders, containers, after)]; + check(`${what}: the sync regroups userprefs.cfg, and the page draws the same from it`, answer === '{"success":true}' && !same(after, prefs) && same(was, now), { answer, after, was, now }); + } finally { php.cleanup(); } + } + { + const syncs = (page) => page.posts.filter((r) => r.url.endsWith('/sync_order.php')).map((r) => r.data); + const saved = { folders: { f: folder('F', ['m']) }, containers: ['a', 'm'], prefs: ['folder-f', 'a'] }; + const page = await drawDocker(saved); + await page.draw(); + await page.draw(); + check('a page with folders and a saved order asks for one sync, not one per list rebuild', same(syncs(page), [{ type: 'docker' }]), page.posts); + for (const [what, setup] of [['nothing saved', { ...saved, prefs: [] }], ['no folders', { ...saved, folders: {} }], + ['no folder holds a container', { ...saved, containers: ['a'] }]]) { + const quiet = await drawDocker(setup); + await quiet.draw(); + check(`${what}: no sync is asked for`, syncs(quiet).length === 0, quiet.posts); + } + const refused = await drawDocker(saved); + const banners = []; + refused.p.w.fv3ShowBanner = (text) => { banners.push(text); }; + refused.failing.add('sync_order.php'); + await refused.draw(); + check('a refused sync shows the start-order banner with the reason', same(banners, ['The Docker start order could not be updated: refused by the test']), banners); + } done(); })(); diff --git a/.github/scripts/page_order_test.php b/.github/scripts/page_order_test.php index cf3665fc..89c0a634 100644 --- a/.github/scripts/page_order_test.php +++ b/.github/scripts/page_order_test.php @@ -75,6 +75,7 @@ class DockerUpdate {} $GLOBALS['fv3tDown'] = $names === null; $setPrefs($cfg); @unlink("$configDir/docker.json"); + @unlink("$configDir/order-docker.json"); @unlink($fv3tAutostart); if ($folders !== null) file_put_contents("$configDir/docker.json", json_encode((object)$folders)); if ($autostart !== null) file_put_contents($fv3tAutostart, is_array($autostart) ? implode("\n", $autostart) . "\n" : $autostart); @@ -278,18 +279,25 @@ class DockerUpdate {} $syncPrefs(['f' => $folder('F', ['x', 'y'])], ['x', 'y'], "0=\"folder-f\"\n2=\"x\"\n5=\"y\"\n"), [null, "0=\"folder-f\"\n2=\"x\"\n5=\"y\"\n"]], ['userprefs.cfg: the fixture\'s saved order is already in place', $syncPrefs($fixture['folders'], $fixture['containers'], $userprefs($fixture['prefs'])), [null, $userprefs($fixture['prefs'])]], - ['userprefs.cfg: custom and off modes leave it as it is', - array_map(fn($mode) => $syncPrefs(['f' => $folder('F', ['x'])], ['a', 'x'], $userprefs(['x', 'folder-f', 'a']), - fn() => file_put_contents("$configDir/autostart.json", json_encode(['mode' => $mode, 'sequence' => ['a', 'x']]))), ['custom', 'off']), - array_fill(0, 2, [null, $userprefs(['x', 'folder-f', 'a'])])], + ['userprefs.cfg: custom and off modes regroup it too, and leave the autostart file to their own rule', + array_map(fn($mode) => [...$sync(['f' => $folder('F', ['x'])], ['a', 'x'], $userprefs(['x', 'a', 'folder-f']), ['x', 'a'], + fn() => file_put_contents("$configDir/autostart.json", json_encode(['mode' => $mode, 'sequence' => ['a', 'x']]))), file_get_contents("$fv3DockerManDir/userprefs.cfg")], ['custom', 'off']), + [[null, ['a', 'x'], $userprefs(['a', 'folder-f', 'x'])], [null, ['x', 'a'], $userprefs(['a', 'folder-f', 'x'])]]], + ['userprefs.cfg: a name that cannot be written back (a quote another tool saved) leaves it as it is, and is reported', + $syncPrefs(['f' => $folder('F', ['x'])], ['x'], "0=\"x\"\n1=\"a\\\"b\"\n2=\"folder-f\"\n"), + ["Unraid's saved Docker order (userprefs.cfg) holds a name that cannot be written back", "0=\"x\"\n1=\"a\\\"b\"\n2=\"folder-f\"\n"]], + ['userprefs.cfg: an order saved while the sync worked it out is kept as it is', + (function () use ($setPrefs, $userprefs, $folder, $fv3DockerManDir) { + $read = ['x', 'b', 'folder-f']; + $setPrefs($userprefs(['folder-f', 'x', 'b'])); + return [fv3_sync_user_prefs($read, fv3_compute_folder_membership(['f' => $folder('F', ['x'])], ['b', 'x'], [], $read)), file_get_contents("$fv3DockerManDir/userprefs.cfg")]; + })(), [null, $userprefs(['folder-f', 'x', 'b'])]], + ['userprefs.cfg: FV3\'s order snapshot, which the heal restores from after a reinstall, is saved with it', + [$syncPrefs(['f' => $folder('F', ['x'])], ['a', 'x'], $userprefs(['x', 'a', 'folder-f']))[1], fv3_export_order_snapshot('docker')['entries'] ?? null], + [$userprefs(['a', 'folder-f', 'x']), ['a', 'folder-f', 'x']]], ['userprefs.cfg: a cut-off one is left as it is, and reported', $syncPrefs(['f' => $folder('F', ['x'])], ['a', 'x'], $cutOff), ["Unraid's saved Docker order (userprefs.cfg) could not be read", $cutOff]], - ['userprefs.cfg: a failed write is reported, and the autostart file is still put in order', - (function () use ($sync, $folder, $userprefs, $fv3DockerManDir) { - try { return $sync(['f' => $folder('F', ['x'])], ['a', 'b', 'x'], $userprefs(['b', 'folder-f', 'a', 'x']), ['a', 'x', 'b'], fn() => chmod($fv3DockerManDir, 0555)); } - finally { chmod($fv3DockerManDir, 0755); } - })(), ["Unraid's saved Docker order (userprefs.cfg) could not be updated", ['b', 'x', 'a']]], - ['userprefs.cfg: the page order is the same before and after the update', + ['userprefs.cfg: the start order worked out from it is the same before and after the update (the page: docker_saved_places_test.js)', $order(['f' => $folder('F', ['x', 'y'])], ['a', 'b', 'x', 'y'], fv3_parse_user_prefs($syncPrefs(['f' => $folder('F', ['x', 'y'])], ['a', 'b', 'x', 'y'], $userprefs(['y', 'a', 'folder-f', 'b']))[1])), $order(['f' => $folder('F', ['x', 'y'])], ['a', 'b', 'x', 'y'], ['y', 'a', 'folder-f', 'b'])], ['no containers, or Docker not running (Unraid\'s client answers an empty list): nothing is written, nothing is reported', @@ -298,17 +306,17 @@ class DockerUpdate {} $sync([], ['a', ''], null, ['b', 'a']), ["Docker's container list could not be read", ['b', 'a']]], ['a failed label read: nothing is written, and it is reported', $sync([], ['a', 'b'], null, ['b', 'a'], function () { $GLOBALS['fv3tLabelsDown'] = true; }), ['the container labels could not be read', ['b', 'a']]], - ['custom mode does not read the folder config, so a damaged one does not stop it', + ['custom mode still writes its sequence when a damaged folder config stops the userprefs.cfg update, and says so', $sync([], ['a', 'b'], null, ['b', 'a'], function () use ($configDir) { file_put_contents("$configDir/docker.json", '{'); file_put_contents("$configDir/autostart.json", '{"mode":"custom","sequence":["a","b"]}'); - }), [null, ['a', 'b']]], + }), ['the folder config could not be read', ['a', 'b']]], ['a missing plugin config folder (deleted by hand under an open tab) is "no folders", not a failure: the sync runs and reports nothing', [$syncWithoutConfigDir(['b', 'a']), $syncWithoutConfigDir([]), is_dir($configDir)], [[null, ['a', 'b']], [null, ['b', 'a']], true]], ['a damaged folder config is reported', $sync([], ['a', 'b'], null, ['b', 'a'], fn() => file_put_contents("$configDir/docker.json", '{')), ['the folder config could not be read', ['b', 'a']]], - ['autostart mode off reads nothing and reports nothing', - $sync([], ['a', 'b'], $cutOff, ['b', 'a'], fn() => file_put_contents("$configDir/autostart.json", '{"mode":"off"}')), [null, ['b', 'a']]], + ['autostart mode off leaves the autostart file as it is, and reports a userprefs.cfg it cannot read', + $sync([], ['a', 'b'], $cutOff, ['b', 'a'], fn() => file_put_contents("$configDir/autostart.json", '{"mode":"off"}')), ["Unraid's saved Docker order (userprefs.cfg) could not be read", ['b', 'a']]], ['custom mode writes its saved sequence, the rest after it in file order', $sync([], ['a', 'b', 'c'], null, ['b 5', 'a', 'ghost', 'c'], fn() => file_put_contents("$configDir/autostart.json", '{"mode":"custom","sequence":["c","a"]}')), [null, ['c', 'a', 'b 5']]], ['custom mode: a file already in its sequence is not written again', @@ -363,6 +371,16 @@ class DockerUpdate {} [['success' => true, 'mode' => 'off', 'sequence' => [], 'warning' => 'the wait edits could not be written to the autostart file'], ['success' => true, 'mode' => 'folder', 'sequence' => [], 'warning' => 'the wait edits could not be written to the autostart file; the autostart file could not be written'], ['success' => true, 'mode' => 'off', 'sequence' => []], ['b', 'a 30']]]; + $cases[] = ['userprefs.cfg: a failed write is reported, and the autostart file is still put in order', + (function () use ($sync, $folder, $userprefs, $fv3DockerManDir) { + try { return $sync(['f' => $folder('F', ['x'])], ['a', 'b', 'x'], $userprefs(['b', 'folder-f', 'a', 'x']), ['a', 'x', 'b'], fn() => chmod($fv3DockerManDir, 0555)); } + finally { chmod($fv3DockerManDir, 0755); } + })(), ["Unraid's saved Docker order (userprefs.cfg) could not be updated", ['b', 'x', 'a']]]; + $cases[] = ['userprefs.cfg and the autostart file both not written: both are reported', + (function () use ($sync, $folder, $userprefs, $fv3DockerManDir, $fv3tAutostart) { + try { return $sync(['f' => $folder('F', ['x'])], ['a', 'b', 'x'], $userprefs(['b', 'folder-f', 'a', 'x']), ['a', 'x', 'b'], function () use ($fv3DockerManDir, $fv3tAutostart) { chmod($fv3DockerManDir, 0555); chmod($fv3tAutostart, 0444); }); } + finally { chmod($fv3DockerManDir, 0755); } + })(), ["Unraid's saved Docker order (userprefs.cfg) could not be updated; the autostart file could not be written", ['a', 'x', 'b']]]; $cases[] = ['custom mode reports it too', $sync([], ['a', 'b'], null, ['b', 'a'], function () use ($configDir, $fv3tAutostart) { file_put_contents("$configDir/autostart.json", '{"mode":"custom","sequence":["a","b"]}'); chmod($fv3tAutostart, 0444); }), ['the autostart file could not be written', ['b', 'a']]]; } diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/FolderView3.page b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/FolderView3.page index 20a6ec3f..2225c10d 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/FolderView3.page +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/FolderView3.page @@ -599,7 +599,7 @@ require_once('/usr/local/emhttp/plugins/folder.view3/langs/script.php'); @@ -608,7 +608,7 @@ require_once('/usr/local/emhttp/plugins/folder.view3/langs/script.php');
-

Folder-based keeps today's behaviour: the container start order follows your folder layout on the Docker page. Custom sequence uses the order below instead — it cuts across folders and overrides the Docker page order, and survives reboots. Off hands the start order fully back to Unraid; FolderView3 stops writing it entirely.

+

Folder-based keeps today's behaviour: the container start order follows your folder layout on the Docker page. Custom sequence uses the order below instead — it cuts across folders and overrides the Docker page order, and survives reboots. Off hands the start order back to Unraid, which follows the Docker page's saved order; FolderView3 stops writing the autostart file.

diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/de.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/de.json index dbad2037..4e93dc08 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/de.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/de.json @@ -331,7 +331,7 @@ "autostart-mode": "Startreihenfolge-Modus:", "autostart-mode-folder": "Ordnerbasiert (Standard)", "autostart-mode-custom": "Eigene Reihenfolge", - "autostart-mode-off": "Aus (FolderView3 schreibt die Startreihenfolge nie)", + "autostart-mode-off": "Aus (FolderView3 schreibt die Autostart-Datei nie)", "autostart-sequence": "Startreihenfolge", "autostart-not-started": "Kein Autostart", "autostart-col-container": "Container", @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Aktiviert eine sanfte Gleitanimation beim Auf- und Zuklappen von Ordnern im Dashboard.", "default-preview-tooltip": "Standard-Vorschaustil für neue Ordner. Einzelne Ordner können dies in ihren Einstellungen überschreiben.", "default-update-column-tooltip": "Blendet die Aktualisierungsspalte \"Version\" für alle Ordnerzeilen aus und schafft so horizontalen Platz.", - "autostart-mode-tooltip": "Ordnerbasiert behält das bisherige Verhalten bei: Die Startreihenfolge der Container folgt deiner Ordneranordnung auf der Docker-Seite. Eigene Reihenfolge verwendet stattdessen die Reihenfolge unten — sie gilt ordnerübergreifend, überschreibt die Reihenfolge der Docker-Seite und bleibt nach einem Neustart erhalten. Aus überlässt die Startreihenfolge vollständig Unraid; FolderView3 schreibt sie dann überhaupt nicht mehr.", + "autostart-mode-tooltip": "Ordnerbasiert behält das bisherige Verhalten bei: Die Startreihenfolge der Container folgt deiner Ordneranordnung auf der Docker-Seite. Eigene Reihenfolge verwendet stattdessen die Reihenfolge unten — sie gilt ordnerübergreifend, überschreibt die Reihenfolge der Docker-Seite und bleibt nach einem Neustart erhalten. Aus überlässt die Startreihenfolge Unraid, das der gespeicherten Reihenfolge der Docker-Seite folgt; FolderView3 schreibt die Autostart-Datei dann nicht mehr.", "docker-only": "Nur Docker", "preview-text-width-placeholder": "z. B. 80px, 6rem (leer = keine Begrenzung)", "autostart-sequence-hint": "Ziehe Zeilen oder gib eine Positionsnummer ein, um die globale Startreihenfolge festzulegen (oben startet zuerst). Warten ist die Pause in Sekunden, nachdem dieser Container gestartet ist. Nur bearbeitbar, solange der Startreihenfolge-Modus auf Eigene Reihenfolge steht; Änderungen gelten nach Anwenden.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/en.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/en.json index 9556ea3a..2e3af1cd 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/en.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/en.json @@ -331,7 +331,7 @@ "autostart-mode": "Start order mode:", "autostart-mode-folder": "Folder-based (default)", "autostart-mode-custom": "Custom sequence", - "autostart-mode-off": "Off (FolderView3 never writes the start order)", + "autostart-mode-off": "Off (FolderView3 never writes the autostart file)", "autostart-sequence": "Startup sequence", "autostart-not-started": "Not autostarted", "autostart-col-container": "Container", @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Enables a smooth slide animation when expanding or collapsing folders on the Dashboard.", "default-preview-tooltip": "Default preview style for new folders. Individual folders can override this in their settings.", "default-update-column-tooltip": "Hides the \"Version\" update column for all folder rows, freeing up horizontal space.", - "autostart-mode-tooltip": "Folder-based keeps today's behaviour: the container start order follows your folder layout on the Docker page. Custom sequence uses the order below instead — it cuts across folders and overrides the Docker page order, and survives reboots. Off hands the start order fully back to Unraid; FolderView3 stops writing it entirely.", + "autostart-mode-tooltip": "Folder-based keeps today's behaviour: the container start order follows your folder layout on the Docker page. Custom sequence uses the order below instead — it cuts across folders and overrides the Docker page order, and survives reboots. Off hands the start order back to Unraid, which follows the Docker page's saved order; FolderView3 stops writing the autostart file.", "docker-only": "Docker only", "preview-text-width-placeholder": "e.g. 80px, 6rem (blank = no limit)", "autostart-sequence-hint": "Drag rows or type a position number to set the global start order (top starts first). Wait is the pause in seconds after that container starts. Editable only while Start order mode is set to Custom sequence; changes apply on Apply.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/es.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/es.json index 6953d964..6365c01a 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/es.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/es.json @@ -331,7 +331,7 @@ "autostart-mode": "Modo de orden de arranque:", "autostart-mode-folder": "Según carpetas (predeterminado)", "autostart-mode-custom": "Secuencia personalizada", - "autostart-mode-off": "Desactivado (FolderView3 nunca escribe el orden de arranque)", + "autostart-mode-off": "Desactivado (FolderView3 nunca escribe el archivo de autoarranque)", "autostart-sequence": "Secuencia de arranque", "autostart-not-started": "Sin autoarranque", "autostart-col-container": "Contenedor", @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Activa una animación de deslizamiento suave al expandir o contraer carpetas en el panel de control.", "default-preview-tooltip": "Estilo de vista previa predeterminado para las carpetas nuevas. Cada carpeta puede cambiarlo en su configuración.", "default-update-column-tooltip": "Oculta la columna de actualización \"Versión\" en todas las filas de carpeta y libera espacio horizontal.", - "autostart-mode-tooltip": "Según carpetas mantiene el comportamiento actual: el orden de arranque de los contenedores sigue la disposición de tus carpetas en la página de Docker. Secuencia personalizada usa en su lugar el orden de abajo: abarca todas las carpetas, prevalece sobre el orden de la página de Docker y se conserva tras reiniciar. Desactivado devuelve el orden de arranque por completo a Unraid; FolderView3 deja de escribirlo.", + "autostart-mode-tooltip": "Según carpetas mantiene el comportamiento actual: el orden de arranque de los contenedores sigue la disposición de tus carpetas en la página de Docker. Secuencia personalizada usa en su lugar el orden de abajo: abarca todas las carpetas, prevalece sobre el orden de la página de Docker y se conserva tras reiniciar. Desactivado devuelve el orden de arranque a Unraid, que sigue el orden guardado de la página de Docker; FolderView3 deja de escribir el archivo de autoarranque.", "docker-only": "Solo Docker", "preview-text-width-placeholder": "p. ej. 80px, 6rem (vacío = sin límite)", "autostart-sequence-hint": "Arrastra las filas o escribe un número de posición para fijar el orden de arranque global (la de arriba arranca primero). Espera es la pausa en segundos tras arrancar ese contenedor. Solo se puede editar mientras el modo de orden de arranque sea Secuencia personalizada; los cambios se aplican con Aplicar.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/fr.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/fr.json index 1c2a74cd..84f26c4e 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/fr.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/fr.json @@ -331,7 +331,7 @@ "autostart-mode": "Mode d'ordre de démarrage :", "autostart-mode-folder": "Basé sur les dossiers (par défaut)", "autostart-mode-custom": "Séquence personnalisée", - "autostart-mode-off": "Désactivé (FolderView3 n'écrit jamais l'ordre de démarrage)", + "autostart-mode-off": "Désactivé (FolderView3 n'écrit jamais le fichier de démarrage automatique)", "autostart-sequence": "Séquence de démarrage", "autostart-not-started": "Sans démarrage auto", "autostart-col-container": "Conteneur", @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Active une animation de glissement fluide lors du déploiement ou de la réduction des dossiers sur le tableau de bord.", "default-preview-tooltip": "Style d'aperçu par défaut des nouveaux dossiers. Chaque dossier peut le remplacer dans ses paramètres.", "default-update-column-tooltip": "Masque la colonne de mise à jour \"Version\" pour toutes les lignes de dossier, ce qui libère de l'espace horizontal.", - "autostart-mode-tooltip": "Basé sur les dossiers conserve le comportement actuel : l'ordre de démarrage des conteneurs suit la disposition de vos dossiers sur la page Docker. Séquence personnalisée utilise plutôt l'ordre ci-dessous — il s'applique à travers les dossiers, remplace l'ordre de la page Docker et survit aux redémarrages. Désactivé rend entièrement l'ordre de démarrage à Unraid ; FolderView3 cesse complètement de l'écrire.", + "autostart-mode-tooltip": "Basé sur les dossiers conserve le comportement actuel : l'ordre de démarrage des conteneurs suit la disposition de vos dossiers sur la page Docker. Séquence personnalisée utilise plutôt l'ordre ci-dessous — il s'applique à travers les dossiers, remplace l'ordre de la page Docker et survit aux redémarrages. Désactivé rend l'ordre de démarrage à Unraid, qui suit l'ordre enregistré de la page Docker ; FolderView3 cesse d'écrire le fichier de démarrage automatique.", "docker-only": "Docker seulement", "preview-text-width-placeholder": "ex. 80px, 6rem (vide = aucune limite)", "autostart-sequence-hint": "Faites glisser les lignes ou saisissez un numéro de position pour définir l'ordre de démarrage global (le haut démarre en premier). Attente est la pause en secondes après le démarrage de ce conteneur. Modifiable uniquement lorsque le mode d'ordre de démarrage est Séquence personnalisée ; les changements s'appliquent avec Appliquer.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/it.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/it.json index 6c621946..101aa8d9 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/it.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/it.json @@ -331,7 +331,7 @@ "autostart-mode": "Modalità ordine di avvio:", "autostart-mode-folder": "In base alle cartelle (predefinito)", "autostart-mode-custom": "Sequenza personalizzata", - "autostart-mode-off": "Disattivato (FolderView3 non scrive mai l'ordine di avvio)", + "autostart-mode-off": "Disattivato (FolderView3 non scrive mai il file di avvio automatico)", "autostart-sequence": "Sequenza di avvio", "autostart-not-started": "Senza avvio automatico", "autostart-col-container": "Container", @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Attiva un'animazione di scorrimento fluida quando si espandono o comprimono le cartelle nella dashboard.", "default-preview-tooltip": "Stile di anteprima predefinito per le nuove cartelle. Ogni cartella può sovrascriverlo nelle proprie impostazioni.", "default-update-column-tooltip": "Nasconde la colonna di aggiornamento \"Versione\" per tutte le righe delle cartelle, liberando spazio orizzontale.", - "autostart-mode-tooltip": "In base alle cartelle mantiene il comportamento attuale: l'ordine di avvio dei container segue la disposizione delle cartelle nella pagina Docker. Sequenza personalizzata usa invece l'ordine qui sotto — vale per tutte le cartelle, sovrascrive l'ordine della pagina Docker e resta valido dopo un riavvio. Disattivato restituisce completamente l'ordine di avvio a Unraid; FolderView3 smette del tutto di scriverlo.", + "autostart-mode-tooltip": "In base alle cartelle mantiene il comportamento attuale: l'ordine di avvio dei container segue la disposizione delle cartelle nella pagina Docker. Sequenza personalizzata usa invece l'ordine qui sotto — vale per tutte le cartelle, sovrascrive l'ordine della pagina Docker e resta valido dopo un riavvio. Disattivato restituisce l'ordine di avvio a Unraid, che segue l'ordine salvato della pagina Docker; FolderView3 smette di scrivere il file di avvio automatico.", "docker-only": "Solo Docker", "preview-text-width-placeholder": "es. 80px, 6rem (vuoto = nessun limite)", "autostart-sequence-hint": "Trascina le righe o digita un numero di posizione per impostare l'ordine di avvio globale (in alto parte per primo). Attesa è la pausa in secondi dopo l'avvio di quel container. Modificabile solo quando la modalità ordine di avvio è Sequenza personalizzata; le modifiche si applicano con Applica.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/pl.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/pl.json index c0dc44f9..54b49a39 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/pl.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/pl.json @@ -331,7 +331,7 @@ "autostart-mode": "Tryb kolejności startu:", "autostart-mode-folder": "Wg folderów (domyślnie)", "autostart-mode-custom": "Własna kolejność", - "autostart-mode-off": "Wyłączone (FolderView3 nigdy nie zapisuje kolejności startu)", + "autostart-mode-off": "Wyłączone (FolderView3 nigdy nie zapisuje pliku autostartu)", "autostart-sequence": "Kolejność startu", "autostart-not-started": "Bez autostartu", "autostart-col-container": "Kontener", @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Włącza płynną animację przesuwania przy rozwijaniu i zwijaniu folderów na Dashboardzie.", "default-preview-tooltip": "Domyślny styl podglądu dla nowych folderów. Poszczególne foldery mogą to zmienić w swoich ustawieniach.", "default-update-column-tooltip": "Ukrywa kolumnę aktualizacji \"Wersja\" we wszystkich wierszach folderów, zwalniając miejsce w poziomie.", - "autostart-mode-tooltip": "Wg folderów zachowuje dotychczasowe działanie: kolejność uruchamiania kontenerów wynika z układu folderów na stronie Docker. Własna kolejność używa zamiast tego kolejności poniżej — obejmuje wszystkie foldery, zastępuje kolejność ze strony Docker i przetrwa ponowne uruchomienie. Wyłączone oddaje kolejność uruchamiania w całości Unraid; FolderView3 całkowicie przestaje ją zapisywać.", + "autostart-mode-tooltip": "Wg folderów zachowuje dotychczasowe działanie: kolejność uruchamiania kontenerów wynika z układu folderów na stronie Docker. Własna kolejność używa zamiast tego kolejności poniżej — obejmuje wszystkie foldery, zastępuje kolejność ze strony Docker i przetrwa ponowne uruchomienie. Wyłączone oddaje kolejność uruchamiania Unraid, który stosuje zapisaną kolejność ze strony Docker; FolderView3 przestaje zapisywać plik autostartu.", "docker-only": "Tylko Docker", "preview-text-width-placeholder": "np. 80px, 6rem (puste = bez limitu)", "autostart-sequence-hint": "Przeciągnij wiersze lub wpisz numer pozycji, aby ustawić globalną kolejność uruchamiania (górny startuje pierwszy). Oczekiwanie to przerwa w sekundach po uruchomieniu danego kontenera. Edycja jest możliwa tylko, gdy tryb kolejności startu to Własna kolejność; zmiany obowiązują po kliknięciu Zastosuj.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/zh.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/zh.json index 6d40bb79..ee28c5d5 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/zh.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/zh.json @@ -331,7 +331,7 @@ "autostart-mode": "启动顺序模式:", "autostart-mode-folder": "按文件夹(默认)", "autostart-mode-custom": "自定义顺序", - "autostart-mode-off": "关闭(FolderView3 不再写入启动顺序)", + "autostart-mode-off": "关闭(FolderView3 从不写入自动启动文件)", "autostart-sequence": "启动顺序", "autostart-not-started": "未自动启动", "autostart-col-container": "容器", @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "在仪表板上展开或折叠文件夹时启用平滑的滑动动画。", "default-preview-tooltip": "新文件夹的默认预览样式。各个文件夹可以在其设置中覆盖此项。", "default-update-column-tooltip": "隐藏所有文件夹行的“版本”更新栏,腾出水平空间。", - "autostart-mode-tooltip": "按文件夹保持现有行为:容器的启动顺序跟随 Docker 页面上的文件夹布局。自定义顺序改用下方的顺序——它跨越文件夹,覆盖 Docker 页面的顺序,并在重启后保留。关闭则将启动顺序完全交还给 Unraid;FolderView3 将完全停止写入它。", + "autostart-mode-tooltip": "按文件夹保持现有行为:容器的启动顺序跟随 Docker 页面上的文件夹布局。自定义顺序改用下方的顺序——它跨越文件夹,覆盖 Docker 页面的顺序,并在重启后保留。关闭则将启动顺序交还给 Unraid,Unraid 按 Docker 页面保存的顺序启动;FolderView3 将停止写入自动启动文件。", "docker-only": "仅 Docker", "preview-text-width-placeholder": "例如 80px、6rem(留空 = 不限制)", "autostart-sequence-hint": "拖动行或输入位置编号来设置全局启动顺序(最上面的最先启动)。等待是该容器启动后暂停的秒数。仅当启动顺序模式设为自定义顺序时才可编辑;点击应用后生效。", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/docker.js b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/docker.js index c48fb954..01e2ed31 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/docker.js +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/docker.js @@ -13,6 +13,7 @@ let folderobserverConfig = { let folderReq = []; const fv3Folders = fv3FolderData(); let fv3RemeasureWidths = false; +let fv3OrderSyncAsked = false; // Folder rendering — orchestrate (createFolders) and per-folder build (createFolder) const createFolders = async () => { @@ -219,6 +220,13 @@ const createFolders = async () => { globalFolders = foldersDone; fv3Debug('createFolders', 'Assigned foldersDone to globalFolders:', {...globalFolders}); + // A container that joined a folder by regex or label stays missing from userprefs.cfg until a sync: one per page load, when a + // folder holds a container. With nothing saved there is nothing to regroup: the sync never creates userprefs.cfg + if (!fv3OrderSyncAsked && unraidOrder.length && Object.values(globalFolders).some((f) => Object.keys(f.containers ?? {}).length)) { + fv3OrderSyncAsked = true; + fv3SyncDockerOrder(); + } + requestAnimationFrame(() => fv3SyncPreviewHeights('docker_listview_mode')); fv3SyncOrganizer(globalFolders); @@ -1336,12 +1344,17 @@ $(document).ajaxComplete((event, jqXHR, settings) => { && data.indexOf('names=') !== -1; if (isAutostartToggle || isOrderSave) { fv3Debug('autostartSync', 'Rebuilding autostart after Unraid event', {url, sample: data.slice(0, 80)}); - // a refused sync leaves the start order stale: fv3ShowBanner shows the same message once until it is closed - $.post('/plugins/folder.view3/server/sync_order.php', {type: 'docker'}) - .fail((err) => fv3ShowBanner(fv3I18nOr('autostart-sync-failed', 'The Docker start order could not be updated: $1', fv3FailReason(err)))); + fv3SyncDockerOrder(); } }); +// Runs syncContainerOrder() (sync_order.php). A refused sync leaves the start order stale: fv3ShowBanner shows the same message +// once until it is closed +function fv3SyncDockerOrder() { + return $.post('/plugins/folder.view3/server/sync_order.php', {type: 'docker'}) + .fail((err) => fv3ShowBanner(fv3I18nOr('autostart-sync-failed', 'The Docker start order could not be updated: $1', fv3FailReason(err)))); +} + // checkAll shows "checking..." in every version cell until its loadlist's reply, and a measure before then caps the // labels at that text — so the rebuild from that reply drops the cache (not here, while the cells still read it). $(document).ajaxComplete((event, jqXHR, settings) => { diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php index 9a056353..096e8afc 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php @@ -887,10 +887,18 @@ function fv3_sync_user_prefs(array $prefs, array $membership): ?string { if (!$prefs) return null; $updated = fv3_prefs_with_folder_members($prefs, $membership); if ($updated === $prefs) return null; + $updated = fv3_sanitize_order_entries($updated); + if ($updated === null) return "Unraid's saved Docker order (userprefs.cfg) holds a name that cannot be written back"; + // Stock UserPrefs writes take no lock: an order saved since the read above is kept as it is + $now = fv3_docker_prefs(); + if ($now === null) return "Unraid's saved Docker order (userprefs.cfg) could not be read"; + if ($now !== $prefs) { fv3_debug_log("fv3_sync_user_prefs: userprefs.cfg changed meanwhile, left as it is"); return null; } if (!fv3_write_user_prefs("$fv3DockerManDir/userprefs.cfg", $updated)) { fv3_debug_log("fv3_sync_user_prefs: userprefs.cfg could not be written"); return "Unraid's saved Docker order (userprefs.cfg) could not be updated"; } + // FV3's own copy, which the heal restores from after a reinstall + if (!saveOrderSnapshot('docker', $updated)) fv3_error_log('fv3_sync_user_prefs', 'the order snapshot could not be written'); fv3_debug_log("fv3_sync_user_prefs: wrote userprefs.cfg with " . count($updated) . " entries"); return null; } @@ -906,72 +914,66 @@ function fv3_reorder_autostart(array $lines, array $order): array { return array_merge($ordered, array_values($byName)); } - // Returns why the autostart file or userprefs.cfg could not be put in order (a file or a Docker read it needs failed), else null. - // Folder mode only logs an empty container list: a server with no containers, or with Docker off, has nothing to report + // Returns why userprefs.cfg or the autostart file could not be put in order (a file or a Docker read it needs failed), else null. + // An empty container list is only logged: a server with no containers, or with Docker off, has nothing to report function syncContainerOrder(string $type): ?string { - // Rewrites the autostart file (and, in folder mode, a saved userprefs.cfg) to match what FV3 renders on screen — top-to-bottom, - // folder members left-to-right in their editor-chosen order. Render order comes from - // userprefs.cfg when it exists (saved by a drag-reorder or an import), A-Z otherwise. - global $configDir; fv3_debug_log("syncContainerOrder called for type: $type"); - $stop = function (string $why): string { fv3_debug_log("syncContainerOrder: $why, aborting before write"); return $why; }; - if ($type !== 'docker') { return null; } $autostartMode = readAutostartConfig()['mode']; - // 'off' = FV3 never writes the autostart file — pure stock Unraid behaviour - if ($autostartMode === 'off') { fv3_debug_log("syncContainerOrder: autostart mode off, skipping"); return null; } - $dockerClient = new DockerClient(); $ctNames = fv3_read_container_names($dockerClient); - $allContainerNames = $ctNames['names']; - // Prune below only on a complete, fully-named container list — a degraded Docker read must not wipe autostart entries (#214) - $ctListComplete = $ctNames['complete']; - - // 'custom' = the Autostart tab's saved sequence overrides folder-derived order entirely - if ($autostartMode === 'custom') { - return fv3_apply_custom_autostart($allContainerNames, $ctListComplete); - } - + // 'custom' = the Autostart tab's saved sequence orders the autostart file; 'off' = FV3 never writes it + $failed = array_filter([ + $autostartMode === 'custom' ? fv3_apply_custom_autostart($ctNames['names'], $ctNames['complete']) : null, + ...fv3_sync_page_order($dockerClient, $ctNames, $autostartMode === 'folder'), + ]); + return $failed ? implode('; ', $failed) : null; + } - // Folder-derived order needs the WHOLE list: containers missing from a partial read are - // skipped by the order walk and land appended at the end, silently reordering the file. - // Custom mode above is exempt — its order comes from the saved sequence, not this list. - if (!$ctListComplete) { - if ($ctNames['empty']) { fv3_debug_log("syncContainerOrder: no containers, nothing to sync"); return null; } + // Puts a saved userprefs.cfg's containers with their folders and, with $autostart, the autostart file in the order FV3 renders: + // top to bottom, folder members in their editor order. Returns why each part could not be done, [] when all went through + function fv3_sync_page_order(DockerClient $dockerClient, array $ctNames, bool $autostart): array { + global $configDir; + $stop = function (string $why): array { fv3_debug_log("syncContainerOrder: $why, aborting before write"); return [$why]; }; + $allContainerNames = $ctNames['names']; + // The page's order needs the WHOLE list: a container missing from a partial read would be put out of place in either file + if (!$ctNames['complete']) { + if ($ctNames['empty']) { fv3_debug_log("syncContainerOrder: no containers, nothing to sync"); return []; } return $stop("Docker's container list could not be read"); } // No docker.json, or no config folder at all (deleted by hand under an open tab), is "no folders": never a stop $folders = fv3_read_json_strict("$configDir/docker.json"); - // Corrupt folder config must not rewrite the autostart file as if no folders exist + // Corrupt folder config must not be read as no folders if ($folders === null) { return $stop('the folder config could not be read'); } $ctLabels = fv3_read_container_labels($dockerClient, $allContainerNames); - // Fail closed: without label claims the order below would write label-assigned - // containers back out as unassigned — the same hazard $ctListComplete guards above. + // Fail closed: without label claims, label-assigned containers would be written back out as unassigned if ($ctLabels === null) { return $stop('the container labels could not be read'); } $prefs = fv3_docker_prefs(); - // The page's order cannot be worked out then, so the file stays as it is + // The page's order cannot be worked out then, so both files stay as they are if ($prefs === null) { return $stop("Unraid's saved Docker order (userprefs.cfg) could not be read"); } $membership = fv3_compute_folder_membership($folders, $allContainerNames, $ctLabels, $prefs); - // A failed userprefs.cfg write is reported, but the autostart file below is still put in order - $prefsFailed = fv3_sync_user_prefs($prefs, $membership); - $newOrder = fv3_page_order($membership, $allContainerNames, $prefs); - fv3_debug_log("syncContainerOrder: computed newOrder with " . count($newOrder) . " entries (" . ($prefs ? 'userprefs.cfg' : 'A-Z, no userprefs.cfg') . ")"); + // Each file is put in order on its own: one that fails does not hold the other back + return array_values(array_filter([ + fv3_sync_user_prefs($prefs, $membership), + $autostart ? fv3_sync_autostart_order(fv3_page_order($membership, $allContainerNames, $prefs), $allContainerNames) : null, + ])); + } - // Rewrite autostart file in $newOrder sequence + // The autostart file's lines in $order's sequence, entries for removed containers dropped ($names must be Docker's whole list, + // #214). Returns why it could not be put in order, else null + function fv3_sync_autostart_order(array $order, array $names): ?string { $autoStartFile = fv3_autostart_file(); - if (file_exists($autoStartFile)) { - $rawLines = fv3_read_autostart_lines($autoStartFile); - if ($rawLines === null) { return $stop('the autostart file could not be read'); } - $autoStartLines = fv3_prune_stale_autostart($rawLines, $allContainerNames, $ctListComplete); - $newAutoStart = fv3_reorder_autostart($autoStartLines, $newOrder); - if ($newAutoStart === $rawLines) { fv3_debug_log("syncContainerOrder: autostart file already in order"); return $prefsFailed; } - if (@file_put_contents($autoStartFile, implode("\n", $newAutoStart) . "\n", LOCK_EX) === false) { return $stop('the autostart file could not be written'); } - fv3_debug_log("syncContainerOrder: wrote autostart file with " . count($newAutoStart) . " entries"); - } - return $prefsFailed; + if (!file_exists($autoStartFile)) return null; + $rawLines = fv3_read_autostart_lines($autoStartFile); + if ($rawLines === null) return 'the autostart file could not be read'; + $newAutoStart = fv3_reorder_autostart(fv3_prune_stale_autostart($rawLines, $names, true), $order); + if ($newAutoStart === $rawLines) { fv3_debug_log("syncContainerOrder: autostart file already in order"); return null; } + if (@file_put_contents($autoStartFile, implode("\n", $newAutoStart) . "\n", LOCK_EX) === false) return 'the autostart file could not be written'; + fv3_debug_log("syncContainerOrder: wrote autostart file with " . count($newAutoStart) . " entries"); + return null; } // Creates Unraid's saved Docker order on a server with none, after an import or a restore: $first's entries (placeholders, names) From f148f898dc4d2bf4357da52f3326cb5bf403c355 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Mon, 16 Nov 2026 15:28:26 +0800 Subject: [PATCH 60/72] fix: save a folder's members when none were saved yet; Off never reorders - A folder with an entry in userprefs.cfg but none of its members saved (a container installed since, a regex match) now gets them after its entry, so the page draws its rows in the file's order - Off reads "never reorders the autostart file": a wait edit applied in Off mode still writes it - The page-load sync gate moves out of createFolders into fv3SyncOrderOnce - Generated orders through the real sync_order.php and page: after a sync the rows follow the file, and a second sync changes nothing --- .github/scripts/docker_saved_places_test.js | 71 +++++++++++++++---- .github/scripts/page_order_test.php | 12 ++-- .../plugins/folder.view3/FolderView3.page | 4 +- .../emhttp/plugins/folder.view3/langs/de.json | 4 +- .../emhttp/plugins/folder.view3/langs/en.json | 4 +- .../emhttp/plugins/folder.view3/langs/es.json | 4 +- .../emhttp/plugins/folder.view3/langs/fr.json | 4 +- .../emhttp/plugins/folder.view3/langs/it.json | 4 +- .../emhttp/plugins/folder.view3/langs/pl.json | 4 +- .../emhttp/plugins/folder.view3/langs/zh.json | 4 +- .../plugins/folder.view3/scripts/docker.js | 15 ++-- .../plugins/folder.view3/server/lib.php | 6 +- 12 files changed, 91 insertions(+), 45 deletions(-) diff --git a/.github/scripts/docker_saved_places_test.js b/.github/scripts/docker_saved_places_test.js index 02dc263f..edc138c5 100644 --- a/.github/scripts/docker_saved_places_test.js +++ b/.github/scripts/docker_saved_places_test.js @@ -1,5 +1,5 @@ // node .github/scripts/docker_saved_places_test.js — where the Docker page puts saved folders: stale userprefs.cfg entries do not move -// them, and the page draws the same after sync_order.php regroups the file, which it asks for once per load (npm ci in this folder first) +// them, and after sync_order.php (asked for once per load) regroups the file, the page draws its rows in its order (npm ci here first) 'use strict'; const fs = require('fs'); const path = require('path'); @@ -67,8 +67,22 @@ const folder = (name, containers = [], regex = '') => ({ name, containers, regex check('the generated orders do place folders, with and without unsaved rows above them', shapes.folders > 50 && shapes.unsaved > 50 && shapes.both > 20, shapes); check('200 generated orders with nothing stale place every folder where they did before', differ.length === 0, differ.slice(0, 2)); } - // The real sync_order.php regroups userprefs.cfg; the page drawn from the file before and after is the same - const drawnFrom = async (folders, containers, prefs) => { const page = await drawDocker({ folders, containers, prefs }); await page.draw(); return page.drawn(); }; + // The real sync_order.php on a saved userprefs.cfg: its answers, the file after one sync, and after a second + const synced = (folders, containers, prefs) => { + const php = phpServer('userprefs-sync', { containers }); + try { + const dockerMan = path.join(path.dirname(php.config), 'dockerMan'); + const file = path.join(dockerMan, 'userprefs.cfg'); + fs.writeFileSync(path.join(php.config, 'docker.json'), JSON.stringify(folders)); + fs.writeFileSync(path.join(dockerMan, 'dockerMan.cfg'), `autostart-file="${path.join(dockerMan, 'unraid-autostart')}"\n`); + fs.writeFileSync(file, prefs.map((n, i) => `${i}="${n}"\n`).join('')); + const read = () => fs.readFileSync(file, 'utf8').split('\n').filter(Boolean).map((l) => l.replace(/^\d+="(.*)"$/, '$1')); + const first = php.server('sync_order.php', 'POST', { type: 'docker' }); + const after = read(); + return { answers: [first, php.server('sync_order.php', 'POST', { type: 'docker' })], after, again: read() }; + } finally { php.cleanup(); } + }; + const drawnFrom = async (folders, containers, prefs) => { const page = await drawDocker({ folders, containers, prefs }); await page.draw(); return page; }; for (const [what, folders, containers, prefs] of [ ['a folder member it lacks', { f: folder('F', ['x', 'y']) }, ['a', 'b', 'x', 'y'], ['a', 'folder-f', 'x', 'b']], ['a member saved away from its folder', { f: folder('F', ['x', 'y']) }, ['a', 'b', 'x', 'y'], ['y', 'a', 'folder-f', 'x', 'b']], @@ -76,17 +90,46 @@ const folder = (name, containers = [], regex = '') => ({ name, containers, regex ['members saved before their folder', { f: folder('F', ['x', 'y']) }, ['a', 'x', 'y'], ['x', 'folder-f', 'a']], ['a regex folder', { r: folder('Rx', [], '^web') }, ['web1', 'web2', 'db'], ['web2', 'folder-r', 'db', 'web1']], ]) { - const php = phpServer('userprefs-sync', { containers }); - try { - const dockerMan = path.join(path.dirname(php.config), 'dockerMan'); - fs.writeFileSync(path.join(php.config, 'docker.json'), JSON.stringify(folders)); - fs.writeFileSync(path.join(dockerMan, 'dockerMan.cfg'), `autostart-file="${path.join(dockerMan, 'unraid-autostart')}"\n`); - fs.writeFileSync(path.join(dockerMan, 'userprefs.cfg'), prefs.map((n, i) => `${i}="${n}"\n`).join('')); - const answer = php.server('sync_order.php', 'POST', { type: 'docker' }); - const after = fs.readFileSync(path.join(dockerMan, 'userprefs.cfg'), 'utf8').split('\n').filter(Boolean).map((l) => l.replace(/^\d+="(.*)"$/, '$1')); - const [was, now] = [await drawnFrom(folders, containers, prefs), await drawnFrom(folders, containers, after)]; - check(`${what}: the sync regroups userprefs.cfg, and the page draws the same from it`, answer === '{"success":true}' && !same(after, prefs) && same(was, now), { answer, after, was, now }); - } finally { php.cleanup(); } + const r = synced(folders, containers, prefs); + const [was, now] = [(await drawnFrom(folders, containers, prefs)).drawn(), (await drawnFrom(folders, containers, r.after)).drawn()]; + check(`${what}: the sync regroups userprefs.cfg, and the page draws the same from it`, r.answers[0] === '{"success":true}' && !same(r.after, prefs) && same(was, now), { answers: r.answers, after: r.after, was, now }); + } + { + // A regex folder saved while empty; web1, installed since, joins it by regex + const r = synced({ f: folder('F', [], '^web') }, ['a', 'web1', 'b'], ['a', 'folder-f', 'b']); + check('a folder with none of its members saved yet gets them after its entry', same(r.after, ['a', 'folder-f', 'web1', 'b']), r); + } + { + // Generated folders (a container listed in one folder at most) and saved orders, with stale and unsaved entries + let seed = 20261116; + const rnd = (n) => { seed = (Math.imul(seed, 1103515245) + 12345) & 0x7fffffff; return (seed >>> 8) % n; }; + const shuffle = (a) => { for (let i = a.length - 1; i > 0; i--) { const j = rnd(i + 1); [a[i], a[j]] = [a[j], a[i]]; } return a; }; + const off = [], unstable = [], refused = []; + let changed = 0; + for (let n = 0; n < 120; n++) { + const containers = shuffle(['a', 'b', 'c', 'web1', 'web2', 'x', 'y']).slice(0, 3 + rnd(5)); + const nf = 1 + rnd(3); + const folders = Object.fromEntries(Array.from({ length: nf }, (_, i) => [`f${i}`, folder(`F${i}`, [], rnd(3) === 0 ? '^web' : '')])); + for (const c of containers) { const i = rnd(nf * 2); if (i < nf) folders[`f${i}`].containers.push(c); } + const entries = containers.concat(Object.keys(folders).map((k) => `folder-${k}`)); + if (rnd(4) === 0) entries.push('ghost'); + const prefs = shuffle(entries).filter(() => rnd(5) > 0); + if (!prefs.length) continue; + const r = synced(folders, containers, prefs); + if (r.answers.some((a) => a !== '{"success":true}')) { refused.push({ folders, prefs, r }); continue; } + changed += !same(r.after, prefs); + if (!same(r.after, r.again)) unstable.push({ folders, containers, prefs, r }); + const page = await drawnFrom(folders, containers, r.after); + const inFolder = new Set(Object.keys(folders).flatMap((id) => page.members(id))); + const shown = (e) => (e.startsWith('folder-') && folders[e.slice(7)]) || (containers.includes(e) && !inFolder.has(e)); + // Unraid puts a name the file lacks first; docker.js puts each folder it lacks on top, the last in docker.json first + const want = Object.keys(folders).map((id) => `folder-${id}`).filter((e) => !r.after.includes(e)).reverse() + .concat(containers.filter((c) => !r.after.includes(c) && !inFolder.has(c)), r.after.filter(shown)); + if (!same(page.rows(), want)) off.push({ folders, containers, after: r.after, rows: page.rows(), want }); + } + check('the generated orders are regrouped by the sync, and every sync answers success', changed > 30 && refused.length === 0, { changed, refused: refused.slice(0, 2) }); + check('a second sync leaves userprefs.cfg as the first wrote it', unstable.length === 0, unstable.slice(0, 2)); + check('after the sync the page draws its rows in the order userprefs.cfg names them', off.length === 0, { count: off.length, first: off.slice(0, 2) }); } { const syncs = (page) => page.posts.filter((r) => r.url.endsWith('/sync_order.php')).map((r) => r.data); diff --git a/.github/scripts/page_order_test.php b/.github/scripts/page_order_test.php index 89c0a634..3b1b7fc1 100644 --- a/.github/scripts/page_order_test.php +++ b/.github/scripts/page_order_test.php @@ -265,8 +265,8 @@ class DockerUpdate {} $syncPrefs(['f' => $folder('F', ['x', 'y'])], ['a', 'x', 'y'], $userprefs(['x', 'folder-f', 'a'])), [null, $userprefs(['x', 'y', 'folder-f', 'a'])]], ['userprefs.cfg: a regex folder\'s members keep the saved order, on their side of its entry', $syncPrefs(['r' => $folder('Rx', [], '^web')], ['web1', 'web2', 'db'], $userprefs(['web2', 'folder-r', 'db', 'web1'])), [null, $userprefs(['web2', 'web1', 'folder-r', 'db'])]], - ['userprefs.cfg: a folder with none of its members saved yet, as after an import, is left as it is', - $syncPrefs(['f' => $folder('F', ['x'])], ['a', 'x'], $userprefs(['folder-f', 'a'])), [null, $userprefs(['folder-f', 'a'])]], + ['userprefs.cfg: a folder with none of its members saved yet, as after an install, gets them after its entry', + $syncPrefs(['f' => $folder('F', ['x'])], ['a', 'x'], $userprefs(['folder-f', 'a'])), [null, $userprefs(['folder-f', 'x', 'a'])]], ['userprefs.cfg: a folder it has no entry for leaves its members where they are', $syncPrefs(['f' => $folder('F', ['x', 'y'])], ['a', 'x', 'y'], $userprefs(['x', 'a', 'y'])), [null, $userprefs(['x', 'a', 'y'])]], ['userprefs.cfg: an entry Docker does not have keeps its place', @@ -460,10 +460,10 @@ class DockerUpdate {} }; $cases[] = ['folder import, no saved order: the new folders first in the file\'s order, each after its members, then the rest A-Z', $importOrder(null, ['n2', 'n1'], ['a', 'b', 'c']), ['200', true, null, null, $userprefs(['folder-n2', 'b', 'folder-n1', 'c', 'a', 'folder-old'])]]; -$cases[] = ['folder import, a saved order: the new folders go on top in the file\'s order, the saved entries after them as they were', - $importOrder($keep, ['n2', 'n1'], ['a', 'b', 'c']), ['200', true, null, null, $userprefs(['folder-n2', 'folder-n1', 'alpha', 'zed'])]]; -$cases[] = ['folder import, a saved order that already places one of them: that one keeps its place, an id with no folder is not written', - $importOrder($userprefs(['alpha', 'folder-n1', 'zed']), ['n2', 'n1', 'ghost'], ['a', 'b', 'c']), ['200', true, null, null, $userprefs(['folder-n2', 'alpha', 'folder-n1', 'zed'])]]; +$cases[] = ['folder import, a saved order: the new folders go on top in the file\'s order with their members, the saved entries after them as they were', + $importOrder($keep, ['n2', 'n1'], ['a', 'b', 'c']), ['200', true, null, null, $userprefs(['folder-n2', 'folder-n1', 'b', 'alpha', 'zed'])]]; +$cases[] = ['folder import, a saved order that already places one of them: that one keeps its place with its member, an id with no folder is not written', + $importOrder($userprefs(['alpha', 'folder-n1', 'zed']), ['n2', 'n1', 'ghost'], ['a', 'b', 'c']), ['200', true, null, null, $userprefs(['folder-n2', 'alpha', 'folder-n1', 'b', 'zed'])]]; $cases[] = ['folder import, a saved order holding a list line: said, and left as it was', $importOrder("0=\"a\"\n1[]=\"b\"\n", ['n1'], ['a', 'b']), ['200', true, "Unraid's saved Docker order (userprefs.cfg) could not be read", "Unraid's saved Docker order (userprefs.cfg) could not be read", "0=\"a\"\n1[]=\"b\"\n"]]; $cases[] = ['folder import, a saved order and a folder config that will not parse: said, and the order left as it was', diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/FolderView3.page b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/FolderView3.page index 2225c10d..b153b523 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/FolderView3.page +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/FolderView3.page @@ -599,7 +599,7 @@ require_once('/usr/local/emhttp/plugins/folder.view3/langs/script.php'); @@ -608,7 +608,7 @@ require_once('/usr/local/emhttp/plugins/folder.view3/langs/script.php');
-

Folder-based keeps today's behaviour: the container start order follows your folder layout on the Docker page. Custom sequence uses the order below instead — it cuts across folders and overrides the Docker page order, and survives reboots. Off hands the start order back to Unraid, which follows the Docker page's saved order; FolderView3 stops writing the autostart file.

+

Folder-based keeps today's behaviour: the container start order follows your folder layout on the Docker page. Custom sequence uses the order below instead — it cuts across folders and overrides the Docker page order, and survives reboots. Off hands the start order back to Unraid, which follows the Docker page's saved order; FolderView3 stops reordering the autostart file.

diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/de.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/de.json index 4e93dc08..469c3421 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/de.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/de.json @@ -331,7 +331,7 @@ "autostart-mode": "Startreihenfolge-Modus:", "autostart-mode-folder": "Ordnerbasiert (Standard)", "autostart-mode-custom": "Eigene Reihenfolge", - "autostart-mode-off": "Aus (FolderView3 schreibt die Autostart-Datei nie)", + "autostart-mode-off": "Aus (FolderView3 ordnet die Autostart-Datei nie um)", "autostart-sequence": "Startreihenfolge", "autostart-not-started": "Kein Autostart", "autostart-col-container": "Container", @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Aktiviert eine sanfte Gleitanimation beim Auf- und Zuklappen von Ordnern im Dashboard.", "default-preview-tooltip": "Standard-Vorschaustil für neue Ordner. Einzelne Ordner können dies in ihren Einstellungen überschreiben.", "default-update-column-tooltip": "Blendet die Aktualisierungsspalte \"Version\" für alle Ordnerzeilen aus und schafft so horizontalen Platz.", - "autostart-mode-tooltip": "Ordnerbasiert behält das bisherige Verhalten bei: Die Startreihenfolge der Container folgt deiner Ordneranordnung auf der Docker-Seite. Eigene Reihenfolge verwendet stattdessen die Reihenfolge unten — sie gilt ordnerübergreifend, überschreibt die Reihenfolge der Docker-Seite und bleibt nach einem Neustart erhalten. Aus überlässt die Startreihenfolge Unraid, das der gespeicherten Reihenfolge der Docker-Seite folgt; FolderView3 schreibt die Autostart-Datei dann nicht mehr.", + "autostart-mode-tooltip": "Ordnerbasiert behält das bisherige Verhalten bei: Die Startreihenfolge der Container folgt deiner Ordneranordnung auf der Docker-Seite. Eigene Reihenfolge verwendet stattdessen die Reihenfolge unten — sie gilt ordnerübergreifend, überschreibt die Reihenfolge der Docker-Seite und bleibt nach einem Neustart erhalten. Aus überlässt die Startreihenfolge Unraid, das der gespeicherten Reihenfolge der Docker-Seite folgt; FolderView3 ordnet die Autostart-Datei dann nicht mehr um.", "docker-only": "Nur Docker", "preview-text-width-placeholder": "z. B. 80px, 6rem (leer = keine Begrenzung)", "autostart-sequence-hint": "Ziehe Zeilen oder gib eine Positionsnummer ein, um die globale Startreihenfolge festzulegen (oben startet zuerst). Warten ist die Pause in Sekunden, nachdem dieser Container gestartet ist. Nur bearbeitbar, solange der Startreihenfolge-Modus auf Eigene Reihenfolge steht; Änderungen gelten nach Anwenden.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/en.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/en.json index 2e3af1cd..c054bea6 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/en.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/en.json @@ -331,7 +331,7 @@ "autostart-mode": "Start order mode:", "autostart-mode-folder": "Folder-based (default)", "autostart-mode-custom": "Custom sequence", - "autostart-mode-off": "Off (FolderView3 never writes the autostart file)", + "autostart-mode-off": "Off (FolderView3 never reorders the autostart file)", "autostart-sequence": "Startup sequence", "autostart-not-started": "Not autostarted", "autostart-col-container": "Container", @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Enables a smooth slide animation when expanding or collapsing folders on the Dashboard.", "default-preview-tooltip": "Default preview style for new folders. Individual folders can override this in their settings.", "default-update-column-tooltip": "Hides the \"Version\" update column for all folder rows, freeing up horizontal space.", - "autostart-mode-tooltip": "Folder-based keeps today's behaviour: the container start order follows your folder layout on the Docker page. Custom sequence uses the order below instead — it cuts across folders and overrides the Docker page order, and survives reboots. Off hands the start order back to Unraid, which follows the Docker page's saved order; FolderView3 stops writing the autostart file.", + "autostart-mode-tooltip": "Folder-based keeps today's behaviour: the container start order follows your folder layout on the Docker page. Custom sequence uses the order below instead — it cuts across folders and overrides the Docker page order, and survives reboots. Off hands the start order back to Unraid, which follows the Docker page's saved order; FolderView3 stops reordering the autostart file.", "docker-only": "Docker only", "preview-text-width-placeholder": "e.g. 80px, 6rem (blank = no limit)", "autostart-sequence-hint": "Drag rows or type a position number to set the global start order (top starts first). Wait is the pause in seconds after that container starts. Editable only while Start order mode is set to Custom sequence; changes apply on Apply.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/es.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/es.json index 6365c01a..0828c7b2 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/es.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/es.json @@ -331,7 +331,7 @@ "autostart-mode": "Modo de orden de arranque:", "autostart-mode-folder": "Según carpetas (predeterminado)", "autostart-mode-custom": "Secuencia personalizada", - "autostart-mode-off": "Desactivado (FolderView3 nunca escribe el archivo de autoarranque)", + "autostart-mode-off": "Desactivado (FolderView3 nunca reordena el archivo de autoarranque)", "autostart-sequence": "Secuencia de arranque", "autostart-not-started": "Sin autoarranque", "autostart-col-container": "Contenedor", @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Activa una animación de deslizamiento suave al expandir o contraer carpetas en el panel de control.", "default-preview-tooltip": "Estilo de vista previa predeterminado para las carpetas nuevas. Cada carpeta puede cambiarlo en su configuración.", "default-update-column-tooltip": "Oculta la columna de actualización \"Versión\" en todas las filas de carpeta y libera espacio horizontal.", - "autostart-mode-tooltip": "Según carpetas mantiene el comportamiento actual: el orden de arranque de los contenedores sigue la disposición de tus carpetas en la página de Docker. Secuencia personalizada usa en su lugar el orden de abajo: abarca todas las carpetas, prevalece sobre el orden de la página de Docker y se conserva tras reiniciar. Desactivado devuelve el orden de arranque a Unraid, que sigue el orden guardado de la página de Docker; FolderView3 deja de escribir el archivo de autoarranque.", + "autostart-mode-tooltip": "Según carpetas mantiene el comportamiento actual: el orden de arranque de los contenedores sigue la disposición de tus carpetas en la página de Docker. Secuencia personalizada usa en su lugar el orden de abajo: abarca todas las carpetas, prevalece sobre el orden de la página de Docker y se conserva tras reiniciar. Desactivado devuelve el orden de arranque a Unraid, que sigue el orden guardado de la página de Docker; FolderView3 deja de reordenar el archivo de autoarranque.", "docker-only": "Solo Docker", "preview-text-width-placeholder": "p. ej. 80px, 6rem (vacío = sin límite)", "autostart-sequence-hint": "Arrastra las filas o escribe un número de posición para fijar el orden de arranque global (la de arriba arranca primero). Espera es la pausa en segundos tras arrancar ese contenedor. Solo se puede editar mientras el modo de orden de arranque sea Secuencia personalizada; los cambios se aplican con Aplicar.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/fr.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/fr.json index 84f26c4e..622bd5e9 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/fr.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/fr.json @@ -331,7 +331,7 @@ "autostart-mode": "Mode d'ordre de démarrage :", "autostart-mode-folder": "Basé sur les dossiers (par défaut)", "autostart-mode-custom": "Séquence personnalisée", - "autostart-mode-off": "Désactivé (FolderView3 n'écrit jamais le fichier de démarrage automatique)", + "autostart-mode-off": "Désactivé (FolderView3 ne réordonne jamais le fichier de démarrage automatique)", "autostart-sequence": "Séquence de démarrage", "autostart-not-started": "Sans démarrage auto", "autostart-col-container": "Conteneur", @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Active une animation de glissement fluide lors du déploiement ou de la réduction des dossiers sur le tableau de bord.", "default-preview-tooltip": "Style d'aperçu par défaut des nouveaux dossiers. Chaque dossier peut le remplacer dans ses paramètres.", "default-update-column-tooltip": "Masque la colonne de mise à jour \"Version\" pour toutes les lignes de dossier, ce qui libère de l'espace horizontal.", - "autostart-mode-tooltip": "Basé sur les dossiers conserve le comportement actuel : l'ordre de démarrage des conteneurs suit la disposition de vos dossiers sur la page Docker. Séquence personnalisée utilise plutôt l'ordre ci-dessous — il s'applique à travers les dossiers, remplace l'ordre de la page Docker et survit aux redémarrages. Désactivé rend l'ordre de démarrage à Unraid, qui suit l'ordre enregistré de la page Docker ; FolderView3 cesse d'écrire le fichier de démarrage automatique.", + "autostart-mode-tooltip": "Basé sur les dossiers conserve le comportement actuel : l'ordre de démarrage des conteneurs suit la disposition de vos dossiers sur la page Docker. Séquence personnalisée utilise plutôt l'ordre ci-dessous — il s'applique à travers les dossiers, remplace l'ordre de la page Docker et survit aux redémarrages. Désactivé rend l'ordre de démarrage à Unraid, qui suit l'ordre enregistré de la page Docker ; FolderView3 cesse de réordonner le fichier de démarrage automatique.", "docker-only": "Docker seulement", "preview-text-width-placeholder": "ex. 80px, 6rem (vide = aucune limite)", "autostart-sequence-hint": "Faites glisser les lignes ou saisissez un numéro de position pour définir l'ordre de démarrage global (le haut démarre en premier). Attente est la pause en secondes après le démarrage de ce conteneur. Modifiable uniquement lorsque le mode d'ordre de démarrage est Séquence personnalisée ; les changements s'appliquent avec Appliquer.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/it.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/it.json index 101aa8d9..6bb2c9d8 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/it.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/it.json @@ -331,7 +331,7 @@ "autostart-mode": "Modalità ordine di avvio:", "autostart-mode-folder": "In base alle cartelle (predefinito)", "autostart-mode-custom": "Sequenza personalizzata", - "autostart-mode-off": "Disattivato (FolderView3 non scrive mai il file di avvio automatico)", + "autostart-mode-off": "Disattivato (FolderView3 non riordina mai il file di avvio automatico)", "autostart-sequence": "Sequenza di avvio", "autostart-not-started": "Senza avvio automatico", "autostart-col-container": "Container", @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Attiva un'animazione di scorrimento fluida quando si espandono o comprimono le cartelle nella dashboard.", "default-preview-tooltip": "Stile di anteprima predefinito per le nuove cartelle. Ogni cartella può sovrascriverlo nelle proprie impostazioni.", "default-update-column-tooltip": "Nasconde la colonna di aggiornamento \"Versione\" per tutte le righe delle cartelle, liberando spazio orizzontale.", - "autostart-mode-tooltip": "In base alle cartelle mantiene il comportamento attuale: l'ordine di avvio dei container segue la disposizione delle cartelle nella pagina Docker. Sequenza personalizzata usa invece l'ordine qui sotto — vale per tutte le cartelle, sovrascrive l'ordine della pagina Docker e resta valido dopo un riavvio. Disattivato restituisce l'ordine di avvio a Unraid, che segue l'ordine salvato della pagina Docker; FolderView3 smette di scrivere il file di avvio automatico.", + "autostart-mode-tooltip": "In base alle cartelle mantiene il comportamento attuale: l'ordine di avvio dei container segue la disposizione delle cartelle nella pagina Docker. Sequenza personalizzata usa invece l'ordine qui sotto — vale per tutte le cartelle, sovrascrive l'ordine della pagina Docker e resta valido dopo un riavvio. Disattivato restituisce l'ordine di avvio a Unraid, che segue l'ordine salvato della pagina Docker; FolderView3 smette di riordinare il file di avvio automatico.", "docker-only": "Solo Docker", "preview-text-width-placeholder": "es. 80px, 6rem (vuoto = nessun limite)", "autostart-sequence-hint": "Trascina le righe o digita un numero di posizione per impostare l'ordine di avvio globale (in alto parte per primo). Attesa è la pausa in secondi dopo l'avvio di quel container. Modificabile solo quando la modalità ordine di avvio è Sequenza personalizzata; le modifiche si applicano con Applica.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/pl.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/pl.json index 54b49a39..abba53c1 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/pl.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/pl.json @@ -331,7 +331,7 @@ "autostart-mode": "Tryb kolejności startu:", "autostart-mode-folder": "Wg folderów (domyślnie)", "autostart-mode-custom": "Własna kolejność", - "autostart-mode-off": "Wyłączone (FolderView3 nigdy nie zapisuje pliku autostartu)", + "autostart-mode-off": "Wyłączone (FolderView3 nigdy nie zmienia kolejności w pliku autostartu)", "autostart-sequence": "Kolejność startu", "autostart-not-started": "Bez autostartu", "autostart-col-container": "Kontener", @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Włącza płynną animację przesuwania przy rozwijaniu i zwijaniu folderów na Dashboardzie.", "default-preview-tooltip": "Domyślny styl podglądu dla nowych folderów. Poszczególne foldery mogą to zmienić w swoich ustawieniach.", "default-update-column-tooltip": "Ukrywa kolumnę aktualizacji \"Wersja\" we wszystkich wierszach folderów, zwalniając miejsce w poziomie.", - "autostart-mode-tooltip": "Wg folderów zachowuje dotychczasowe działanie: kolejność uruchamiania kontenerów wynika z układu folderów na stronie Docker. Własna kolejność używa zamiast tego kolejności poniżej — obejmuje wszystkie foldery, zastępuje kolejność ze strony Docker i przetrwa ponowne uruchomienie. Wyłączone oddaje kolejność uruchamiania Unraid, który stosuje zapisaną kolejność ze strony Docker; FolderView3 przestaje zapisywać plik autostartu.", + "autostart-mode-tooltip": "Wg folderów zachowuje dotychczasowe działanie: kolejność uruchamiania kontenerów wynika z układu folderów na stronie Docker. Własna kolejność używa zamiast tego kolejności poniżej — obejmuje wszystkie foldery, zastępuje kolejność ze strony Docker i przetrwa ponowne uruchomienie. Wyłączone oddaje kolejność uruchamiania Unraid, który stosuje zapisaną kolejność ze strony Docker; FolderView3 przestaje zmieniać kolejność w pliku autostartu.", "docker-only": "Tylko Docker", "preview-text-width-placeholder": "np. 80px, 6rem (puste = bez limitu)", "autostart-sequence-hint": "Przeciągnij wiersze lub wpisz numer pozycji, aby ustawić globalną kolejność uruchamiania (górny startuje pierwszy). Oczekiwanie to przerwa w sekundach po uruchomieniu danego kontenera. Edycja jest możliwa tylko, gdy tryb kolejności startu to Własna kolejność; zmiany obowiązują po kliknięciu Zastosuj.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/zh.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/zh.json index ee28c5d5..470990bb 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/zh.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/zh.json @@ -331,7 +331,7 @@ "autostart-mode": "启动顺序模式:", "autostart-mode-folder": "按文件夹(默认)", "autostart-mode-custom": "自定义顺序", - "autostart-mode-off": "关闭(FolderView3 从不写入自动启动文件)", + "autostart-mode-off": "关闭(FolderView3 从不重新排列自动启动文件)", "autostart-sequence": "启动顺序", "autostart-not-started": "未自动启动", "autostart-col-container": "容器", @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "在仪表板上展开或折叠文件夹时启用平滑的滑动动画。", "default-preview-tooltip": "新文件夹的默认预览样式。各个文件夹可以在其设置中覆盖此项。", "default-update-column-tooltip": "隐藏所有文件夹行的“版本”更新栏,腾出水平空间。", - "autostart-mode-tooltip": "按文件夹保持现有行为:容器的启动顺序跟随 Docker 页面上的文件夹布局。自定义顺序改用下方的顺序——它跨越文件夹,覆盖 Docker 页面的顺序,并在重启后保留。关闭则将启动顺序交还给 Unraid,Unraid 按 Docker 页面保存的顺序启动;FolderView3 将停止写入自动启动文件。", + "autostart-mode-tooltip": "按文件夹保持现有行为:容器的启动顺序跟随 Docker 页面上的文件夹布局。自定义顺序改用下方的顺序——它跨越文件夹,覆盖 Docker 页面的顺序,并在重启后保留。关闭则将启动顺序交还给 Unraid,Unraid 按 Docker 页面保存的顺序启动;FolderView3 将停止重新排列自动启动文件。", "docker-only": "仅 Docker", "preview-text-width-placeholder": "例如 80px、6rem(留空 = 不限制)", "autostart-sequence-hint": "拖动行或输入位置编号来设置全局启动顺序(最上面的最先启动)。等待是该容器启动后暂停的秒数。仅当启动顺序模式设为自定义顺序时才可编辑;点击应用后生效。", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/docker.js b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/docker.js index 01e2ed31..7ad2597c 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/docker.js +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/scripts/docker.js @@ -220,12 +220,7 @@ const createFolders = async () => { globalFolders = foldersDone; fv3Debug('createFolders', 'Assigned foldersDone to globalFolders:', {...globalFolders}); - // A container that joined a folder by regex or label stays missing from userprefs.cfg until a sync: one per page load, when a - // folder holds a container. With nothing saved there is nothing to regroup: the sync never creates userprefs.cfg - if (!fv3OrderSyncAsked && unraidOrder.length && Object.values(globalFolders).some((f) => Object.keys(f.containers ?? {}).length)) { - fv3OrderSyncAsked = true; - fv3SyncDockerOrder(); - } + fv3SyncOrderOnce(unraidOrder, globalFolders); requestAnimationFrame(() => fv3SyncPreviewHeights('docker_listview_mode')); @@ -1355,6 +1350,14 @@ function fv3SyncDockerOrder() { .fail((err) => fv3ShowBanner(fv3I18nOr('autostart-sync-failed', 'The Docker start order could not be updated: $1', fv3FailReason(err)))); } +// A container that joined a folder by regex or label stays missing from userprefs.cfg until a sync: one per page load, when a +// folder holds a container. With nothing saved there is nothing to regroup: the sync never creates userprefs.cfg +function fv3SyncOrderOnce(saved, folders) { + if (fv3OrderSyncAsked || !saved.length || !Object.values(folders).some((f) => Object.keys(f.containers ?? {}).length)) return; + fv3OrderSyncAsked = true; + fv3SyncDockerOrder(); +} + // checkAll shows "checking..." in every version cell until its loadlist's reply, and a measure before then caps the // labels at that text — so the rebuild from that reply drops the cache (not here, while the cells still read it). $(document).ajaxComplete((event, jqXHR, settings) => { diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php index 096e8afc..897ebb0f 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php @@ -857,12 +857,12 @@ function fv3_page_order(array $membership, array $allContainerNames, array $pref } // $prefs with each folder's members together in its order, on the side of its entry a neighbour shows (a drag: after, FV3's writers: - // before; after by default). A folder with no entry or no saved member (a new import), and every other entry, stay as they are + // before; after by default). A folder with no entry, and every other entry, stay as they are function fv3_prefs_with_folder_members(array $prefs, array $membership): array { $blocks = []; foreach ($membership['containers'] as $placeholder => $members) { $at = array_search($placeholder, $prefs, true); - if ($at === false || !array_intersect($prefs, $members)) continue; + if ($at === false || !$members) continue; $after = isset($prefs[$at + 1]) && in_array($prefs[$at + 1], $members, true); $before = !$after && $at > 0 && in_array($prefs[$at - 1], $members, true); $blocks[$placeholder] = ['members' => $members, 'before' => $before]; @@ -923,7 +923,7 @@ function syncContainerOrder(string $type): ?string { $autostartMode = readAutostartConfig()['mode']; $dockerClient = new DockerClient(); $ctNames = fv3_read_container_names($dockerClient); - // 'custom' = the Autostart tab's saved sequence orders the autostart file; 'off' = FV3 never writes it + // 'custom' = the Autostart tab's saved sequence orders the autostart file; 'off' = FV3 never reorders it $failed = array_filter([ $autostartMode === 'custom' ? fv3_apply_custom_autostart($ctNames['names'], $ctNames['complete']) : null, ...fv3_sync_page_order($dockerClient, $ctNames, $autostartMode === 'folder'), From cbd71b5c7c58f90df30b218ea1a12f42241030a4 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Mon, 16 Nov 2026 15:30:58 +0800 Subject: [PATCH 61/72] test: say what the generated-order check counts --- .github/scripts/docker_saved_places_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/docker_saved_places_test.js b/.github/scripts/docker_saved_places_test.js index edc138c5..b33e7eab 100644 --- a/.github/scripts/docker_saved_places_test.js +++ b/.github/scripts/docker_saved_places_test.js @@ -127,7 +127,7 @@ const folder = (name, containers = [], regex = '') => ({ name, containers, regex .concat(containers.filter((c) => !r.after.includes(c) && !inFolder.has(c)), r.after.filter(shown)); if (!same(page.rows(), want)) off.push({ folders, containers, after: r.after, rows: page.rows(), want }); } - check('the generated orders are regrouped by the sync, and every sync answers success', changed > 30 && refused.length === 0, { changed, refused: refused.slice(0, 2) }); + check('the sync regroups over a quarter of the generated orders, and every sync answers success', changed > 30 && refused.length === 0, { changed, refused: refused.slice(0, 2) }); check('a second sync leaves userprefs.cfg as the first wrote it', unstable.length === 0, unstable.slice(0, 2)); check('after the sync the page draws its rows in the order userprefs.cfg names them', off.length === 0, { count: off.length, first: off.slice(0, 2) }); } From dc87ff42c092e14793d58168d4761f5866a5cfa0 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Mon, 16 Nov 2026 15:51:53 +0800 Subject: [PATCH 62/72] fix: Off tooltip says Unraid starts in the autostart file's order - Unraid starts containers in the autostart file's order and re-sorts it by the Docker page only on a reorder or an autostart toggle there; the tooltip no longer says it always follows the page --- .../usr/local/emhttp/plugins/folder.view3/FolderView3.page | 2 +- .../usr/local/emhttp/plugins/folder.view3/langs/de.json | 2 +- .../usr/local/emhttp/plugins/folder.view3/langs/en.json | 2 +- .../usr/local/emhttp/plugins/folder.view3/langs/es.json | 2 +- .../usr/local/emhttp/plugins/folder.view3/langs/fr.json | 2 +- .../usr/local/emhttp/plugins/folder.view3/langs/it.json | 2 +- .../usr/local/emhttp/plugins/folder.view3/langs/pl.json | 2 +- .../usr/local/emhttp/plugins/folder.view3/langs/zh.json | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/FolderView3.page b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/FolderView3.page index b153b523..fa3ecf0b 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/FolderView3.page +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/FolderView3.page @@ -608,7 +608,7 @@ require_once('/usr/local/emhttp/plugins/folder.view3/langs/script.php');
-

Folder-based keeps today's behaviour: the container start order follows your folder layout on the Docker page. Custom sequence uses the order below instead — it cuts across folders and overrides the Docker page order, and survives reboots. Off hands the start order back to Unraid, which follows the Docker page's saved order; FolderView3 stops reordering the autostart file.

+

Folder-based keeps today's behaviour: the container start order follows your folder layout on the Docker page. Custom sequence uses the order below instead — it cuts across folders and overrides the Docker page order, and survives reboots. Off hands the start order back to Unraid: containers start in the autostart file's order, which Unraid re-sorts to the Docker page's order when you reorder containers or switch one's autostart there; FolderView3 stops reordering that file.

diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/de.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/de.json index 469c3421..ef254cc8 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/de.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/de.json @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Aktiviert eine sanfte Gleitanimation beim Auf- und Zuklappen von Ordnern im Dashboard.", "default-preview-tooltip": "Standard-Vorschaustil für neue Ordner. Einzelne Ordner können dies in ihren Einstellungen überschreiben.", "default-update-column-tooltip": "Blendet die Aktualisierungsspalte \"Version\" für alle Ordnerzeilen aus und schafft so horizontalen Platz.", - "autostart-mode-tooltip": "Ordnerbasiert behält das bisherige Verhalten bei: Die Startreihenfolge der Container folgt deiner Ordneranordnung auf der Docker-Seite. Eigene Reihenfolge verwendet stattdessen die Reihenfolge unten — sie gilt ordnerübergreifend, überschreibt die Reihenfolge der Docker-Seite und bleibt nach einem Neustart erhalten. Aus überlässt die Startreihenfolge Unraid, das der gespeicherten Reihenfolge der Docker-Seite folgt; FolderView3 ordnet die Autostart-Datei dann nicht mehr um.", + "autostart-mode-tooltip": "Ordnerbasiert behält das bisherige Verhalten bei: Die Startreihenfolge der Container folgt deiner Ordneranordnung auf der Docker-Seite. Eigene Reihenfolge verwendet stattdessen die Reihenfolge unten — sie gilt ordnerübergreifend, überschreibt die Reihenfolge der Docker-Seite und bleibt nach einem Neustart erhalten. Aus überlässt die Startreihenfolge Unraid: Container starten in der Reihenfolge der Autostart-Datei, die Unraid nach der Reihenfolge der Docker-Seite neu sortiert, wenn du dort Container umordnest oder ihren Autostart umschaltest; FolderView3 ordnet diese Datei dann nicht mehr um.", "docker-only": "Nur Docker", "preview-text-width-placeholder": "z. B. 80px, 6rem (leer = keine Begrenzung)", "autostart-sequence-hint": "Ziehe Zeilen oder gib eine Positionsnummer ein, um die globale Startreihenfolge festzulegen (oben startet zuerst). Warten ist die Pause in Sekunden, nachdem dieser Container gestartet ist. Nur bearbeitbar, solange der Startreihenfolge-Modus auf Eigene Reihenfolge steht; Änderungen gelten nach Anwenden.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/en.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/en.json index c054bea6..52625d16 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/en.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/en.json @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Enables a smooth slide animation when expanding or collapsing folders on the Dashboard.", "default-preview-tooltip": "Default preview style for new folders. Individual folders can override this in their settings.", "default-update-column-tooltip": "Hides the \"Version\" update column for all folder rows, freeing up horizontal space.", - "autostart-mode-tooltip": "Folder-based keeps today's behaviour: the container start order follows your folder layout on the Docker page. Custom sequence uses the order below instead — it cuts across folders and overrides the Docker page order, and survives reboots. Off hands the start order back to Unraid, which follows the Docker page's saved order; FolderView3 stops reordering the autostart file.", + "autostart-mode-tooltip": "Folder-based keeps today's behaviour: the container start order follows your folder layout on the Docker page. Custom sequence uses the order below instead — it cuts across folders and overrides the Docker page order, and survives reboots. Off hands the start order back to Unraid: containers start in the autostart file's order, which Unraid re-sorts to the Docker page's order when you reorder containers or switch one's autostart there; FolderView3 stops reordering that file.", "docker-only": "Docker only", "preview-text-width-placeholder": "e.g. 80px, 6rem (blank = no limit)", "autostart-sequence-hint": "Drag rows or type a position number to set the global start order (top starts first). Wait is the pause in seconds after that container starts. Editable only while Start order mode is set to Custom sequence; changes apply on Apply.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/es.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/es.json index 0828c7b2..f45a36b3 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/es.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/es.json @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Activa una animación de deslizamiento suave al expandir o contraer carpetas en el panel de control.", "default-preview-tooltip": "Estilo de vista previa predeterminado para las carpetas nuevas. Cada carpeta puede cambiarlo en su configuración.", "default-update-column-tooltip": "Oculta la columna de actualización \"Versión\" en todas las filas de carpeta y libera espacio horizontal.", - "autostart-mode-tooltip": "Según carpetas mantiene el comportamiento actual: el orden de arranque de los contenedores sigue la disposición de tus carpetas en la página de Docker. Secuencia personalizada usa en su lugar el orden de abajo: abarca todas las carpetas, prevalece sobre el orden de la página de Docker y se conserva tras reiniciar. Desactivado devuelve el orden de arranque a Unraid, que sigue el orden guardado de la página de Docker; FolderView3 deja de reordenar el archivo de autoarranque.", + "autostart-mode-tooltip": "Según carpetas mantiene el comportamiento actual: el orden de arranque de los contenedores sigue la disposición de tus carpetas en la página de Docker. Secuencia personalizada usa en su lugar el orden de abajo: abarca todas las carpetas, prevalece sobre el orden de la página de Docker y se conserva tras reiniciar. Desactivado devuelve el orden de arranque a Unraid: los contenedores arrancan en el orden del archivo de autoarranque, que Unraid reordena según la página de Docker cuando reordenas allí los contenedores o cambias su autoarranque; FolderView3 deja de reordenar ese archivo.", "docker-only": "Solo Docker", "preview-text-width-placeholder": "p. ej. 80px, 6rem (vacío = sin límite)", "autostart-sequence-hint": "Arrastra las filas o escribe un número de posición para fijar el orden de arranque global (la de arriba arranca primero). Espera es la pausa en segundos tras arrancar ese contenedor. Solo se puede editar mientras el modo de orden de arranque sea Secuencia personalizada; los cambios se aplican con Aplicar.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/fr.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/fr.json index 622bd5e9..1a2ca10e 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/fr.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/fr.json @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Active une animation de glissement fluide lors du déploiement ou de la réduction des dossiers sur le tableau de bord.", "default-preview-tooltip": "Style d'aperçu par défaut des nouveaux dossiers. Chaque dossier peut le remplacer dans ses paramètres.", "default-update-column-tooltip": "Masque la colonne de mise à jour \"Version\" pour toutes les lignes de dossier, ce qui libère de l'espace horizontal.", - "autostart-mode-tooltip": "Basé sur les dossiers conserve le comportement actuel : l'ordre de démarrage des conteneurs suit la disposition de vos dossiers sur la page Docker. Séquence personnalisée utilise plutôt l'ordre ci-dessous — il s'applique à travers les dossiers, remplace l'ordre de la page Docker et survit aux redémarrages. Désactivé rend l'ordre de démarrage à Unraid, qui suit l'ordre enregistré de la page Docker ; FolderView3 cesse de réordonner le fichier de démarrage automatique.", + "autostart-mode-tooltip": "Basé sur les dossiers conserve le comportement actuel : l'ordre de démarrage des conteneurs suit la disposition de vos dossiers sur la page Docker. Séquence personnalisée utilise plutôt l'ordre ci-dessous — il s'applique à travers les dossiers, remplace l'ordre de la page Docker et survit aux redémarrages. Désactivé rend l'ordre de démarrage à Unraid : les conteneurs démarrent dans l'ordre du fichier de démarrage automatique, qu'Unraid retrie selon l'ordre de la page Docker quand vous y réordonnez des conteneurs ou changez leur démarrage automatique ; FolderView3 cesse de réordonner ce fichier.", "docker-only": "Docker seulement", "preview-text-width-placeholder": "ex. 80px, 6rem (vide = aucune limite)", "autostart-sequence-hint": "Faites glisser les lignes ou saisissez un numéro de position pour définir l'ordre de démarrage global (le haut démarre en premier). Attente est la pause en secondes après le démarrage de ce conteneur. Modifiable uniquement lorsque le mode d'ordre de démarrage est Séquence personnalisée ; les changements s'appliquent avec Appliquer.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/it.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/it.json index 6bb2c9d8..d99cd3e6 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/it.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/it.json @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Attiva un'animazione di scorrimento fluida quando si espandono o comprimono le cartelle nella dashboard.", "default-preview-tooltip": "Stile di anteprima predefinito per le nuove cartelle. Ogni cartella può sovrascriverlo nelle proprie impostazioni.", "default-update-column-tooltip": "Nasconde la colonna di aggiornamento \"Versione\" per tutte le righe delle cartelle, liberando spazio orizzontale.", - "autostart-mode-tooltip": "In base alle cartelle mantiene il comportamento attuale: l'ordine di avvio dei container segue la disposizione delle cartelle nella pagina Docker. Sequenza personalizzata usa invece l'ordine qui sotto — vale per tutte le cartelle, sovrascrive l'ordine della pagina Docker e resta valido dopo un riavvio. Disattivato restituisce l'ordine di avvio a Unraid, che segue l'ordine salvato della pagina Docker; FolderView3 smette di riordinare il file di avvio automatico.", + "autostart-mode-tooltip": "In base alle cartelle mantiene il comportamento attuale: l'ordine di avvio dei container segue la disposizione delle cartelle nella pagina Docker. Sequenza personalizzata usa invece l'ordine qui sotto — vale per tutte le cartelle, sovrascrive l'ordine della pagina Docker e resta valido dopo un riavvio. Disattivato restituisce l'ordine di avvio a Unraid: i container si avviano nell'ordine del file di avvio automatico, che Unraid riordina secondo la pagina Docker quando vi riordini i container o cambi il loro avvio automatico; FolderView3 smette di riordinare quel file.", "docker-only": "Solo Docker", "preview-text-width-placeholder": "es. 80px, 6rem (vuoto = nessun limite)", "autostart-sequence-hint": "Trascina le righe o digita un numero di posizione per impostare l'ordine di avvio globale (in alto parte per primo). Attesa è la pausa in secondi dopo l'avvio di quel container. Modificabile solo quando la modalità ordine di avvio è Sequenza personalizzata; le modifiche si applicano con Applica.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/pl.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/pl.json index abba53c1..dd932298 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/pl.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/pl.json @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "Włącza płynną animację przesuwania przy rozwijaniu i zwijaniu folderów na Dashboardzie.", "default-preview-tooltip": "Domyślny styl podglądu dla nowych folderów. Poszczególne foldery mogą to zmienić w swoich ustawieniach.", "default-update-column-tooltip": "Ukrywa kolumnę aktualizacji \"Wersja\" we wszystkich wierszach folderów, zwalniając miejsce w poziomie.", - "autostart-mode-tooltip": "Wg folderów zachowuje dotychczasowe działanie: kolejność uruchamiania kontenerów wynika z układu folderów na stronie Docker. Własna kolejność używa zamiast tego kolejności poniżej — obejmuje wszystkie foldery, zastępuje kolejność ze strony Docker i przetrwa ponowne uruchomienie. Wyłączone oddaje kolejność uruchamiania Unraid, który stosuje zapisaną kolejność ze strony Docker; FolderView3 przestaje zmieniać kolejność w pliku autostartu.", + "autostart-mode-tooltip": "Wg folderów zachowuje dotychczasowe działanie: kolejność uruchamiania kontenerów wynika z układu folderów na stronie Docker. Własna kolejność używa zamiast tego kolejności poniżej — obejmuje wszystkie foldery, zastępuje kolejność ze strony Docker i przetrwa ponowne uruchomienie. Wyłączone oddaje kolejność uruchamiania Unraid: kontenery startują w kolejności pliku autostartu, który Unraid sortuje według strony Docker, gdy zmienisz tam kolejność kontenerów lub przełączysz ich autostart; FolderView3 przestaje zmieniać kolejność w tym pliku.", "docker-only": "Tylko Docker", "preview-text-width-placeholder": "np. 80px, 6rem (puste = bez limitu)", "autostart-sequence-hint": "Przeciągnij wiersze lub wpisz numer pozycji, aby ustawić globalną kolejność uruchamiania (górny startuje pierwszy). Oczekiwanie to przerwa w sekundach po uruchomieniu danego kontenera. Edycja jest możliwa tylko, gdy tryb kolejności startu to Własna kolejność; zmiany obowiązują po kliknięciu Zastosuj.", diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/zh.json b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/zh.json index 470990bb..744e7467 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/zh.json +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/langs/zh.json @@ -355,7 +355,7 @@ "dashboard-animation-tooltip": "在仪表板上展开或折叠文件夹时启用平滑的滑动动画。", "default-preview-tooltip": "新文件夹的默认预览样式。各个文件夹可以在其设置中覆盖此项。", "default-update-column-tooltip": "隐藏所有文件夹行的“版本”更新栏,腾出水平空间。", - "autostart-mode-tooltip": "按文件夹保持现有行为:容器的启动顺序跟随 Docker 页面上的文件夹布局。自定义顺序改用下方的顺序——它跨越文件夹,覆盖 Docker 页面的顺序,并在重启后保留。关闭则将启动顺序交还给 Unraid,Unraid 按 Docker 页面保存的顺序启动;FolderView3 将停止重新排列自动启动文件。", + "autostart-mode-tooltip": "按文件夹保持现有行为:容器的启动顺序跟随 Docker 页面上的文件夹布局。自定义顺序改用下方的顺序——它跨越文件夹,覆盖 Docker 页面的顺序,并在重启后保留。关闭则将启动顺序交还给 Unraid:容器按自动启动文件的顺序启动;当你在 Docker 页面调整容器顺序或切换其自动启动时,Unraid 会按该页面的顺序重新排列此文件;FolderView3 将停止重新排列该文件。", "docker-only": "仅 Docker", "preview-text-width-placeholder": "例如 80px、6rem(留空 = 不限制)", "autostart-sequence-hint": "拖动行或输入位置编号来设置全局启动顺序(最上面的最先启动)。等待是该容器启动后暂停的秒数。仅当启动顺序模式设为自定义顺序时才可编辑;点击应用后生效。", From e365b373cebfd0c92ee88643ecc37136924b6578 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Mon, 16 Nov 2026 17:05:48 +0800 Subject: [PATCH 63/72] fix: a container two folders' regexes match goes to the folder the page draws first PHP walked folders in docker.json order, the page in its drawing order, so the sync could save such a container beside the wrong folder. read_membership.php now reads the saved order the way the page does. --- .github/scripts/docker_saved_places_test.js | 36 +++++++++++++++++-- .github/scripts/page_order_test.php | 15 +++++--- .../plugins/folder.view3/server/lib.php | 22 ++++++++++-- .../folder.view3/server/read_membership.php | 4 +-- 4 files changed, 67 insertions(+), 10 deletions(-) diff --git a/.github/scripts/docker_saved_places_test.js b/.github/scripts/docker_saved_places_test.js index b33e7eab..96ec7187 100644 --- a/.github/scripts/docker_saved_places_test.js +++ b/.github/scripts/docker_saved_places_test.js @@ -99,13 +99,38 @@ const folder = (name, containers = [], regex = '') => ({ name, containers, regex const r = synced({ f: folder('F', [], '^web') }, ['a', 'web1', 'b'], ['a', 'folder-f', 'b']); check('a folder with none of its members saved yet gets them after its entry', same(r.after, ['a', 'folder-f', 'web1', 'b']), r); } + // The real read_membership.php: container => folder name. `json` is docker.json as written, its key order kept + const membershipOf = (folders, containers, prefs, json = JSON.stringify(folders)) => { + const php = phpServer('membership', { containers }); + try { + fs.writeFileSync(path.join(php.config, 'docker.json'), json); + if (prefs.length) fs.writeFileSync(path.join(path.dirname(php.config), 'dockerMan', 'userprefs.cfg'), prefs.map((n, i) => `${i}="${n}"\n`).join('')); + return JSON.parse(php.server('read_membership.php', 'GET', { type: 'docker' })).membership; + } finally { php.cleanup(); } + }; + { + const web = (name) => folder(name, [], '^web'); + for (const [what, folders, containers, prefs, owner, json] of [ + ['the folder userprefs.cfg names first', { a: web('A'), b: web('B') }, ['web1', 'loose'], ['folder-b', 'loose', 'folder-a'], 'b'], + ['of folders it does not name, an index-like id first', { x: web('X'), 7: web('Seven') }, ['web1', 'loose'], ['loose'], '7', + `{"x":${JSON.stringify(web('X'))},"7":${JSON.stringify(web('Seven'))}}`], + ['with nothing saved, the folder first A-Z', { z: web('Zulu'), a: web('Alpha') }, ['web1'], [], 'a'], + ]) { + const page = await drawnFrom(folders, containers, prefs); + const map = membershipOf(folders, containers, prefs, json); + check(`two folders' regexes match a container: ${what} gets it, on the page and in read_membership.php`, + same(page.members(owner), ['web1']) && map?.web1 === folders[owner].name, { members: Object.keys(folders).map((id) => [id, page.members(id)]), map }); + } + const r = synced({ a: web('A'), b: web('B') }, ['web1', 'loose'], ['folder-b', 'loose', 'folder-a', 'web1']); + check('and the sync moves it beside the folder the page draws it in', same(r.after, ['folder-b', 'web1', 'loose', 'folder-a']), r); + } { // Generated folders (a container listed in one folder at most) and saved orders, with stale and unsaved entries let seed = 20261116; const rnd = (n) => { seed = (Math.imul(seed, 1103515245) + 12345) & 0x7fffffff; return (seed >>> 8) % n; }; const shuffle = (a) => { for (let i = a.length - 1; i > 0; i--) { const j = rnd(i + 1); [a[i], a[j]] = [a[j], a[i]]; } return a; }; - const off = [], unstable = [], refused = []; - let changed = 0; + const off = [], apart = [], unstable = [], refused = []; + let changed = 0, overlaps = 0; for (let n = 0; n < 120; n++) { const containers = shuffle(['a', 'b', 'c', 'web1', 'web2', 'x', 'y']).slice(0, 3 + rnd(5)); const nf = 1 + rnd(3); @@ -115,6 +140,7 @@ const folder = (name, containers = [], regex = '') => ({ name, containers, regex if (rnd(4) === 0) entries.push('ghost'); const prefs = shuffle(entries).filter(() => rnd(5) > 0); if (!prefs.length) continue; + overlaps += Object.values(folders).filter((f) => f.regex).length > 1 && containers.some((c) => c.startsWith('web')); const r = synced(folders, containers, prefs); if (r.answers.some((a) => a !== '{"success":true}')) { refused.push({ folders, prefs, r }); continue; } changed += !same(r.after, prefs); @@ -126,10 +152,16 @@ const folder = (name, containers = [], regex = '') => ({ name, containers, regex const want = Object.keys(folders).map((id) => `folder-${id}`).filter((e) => !r.after.includes(e)).reverse() .concat(containers.filter((c) => !r.after.includes(c) && !inFolder.has(c)), r.after.filter(shown)); if (!same(page.rows(), want)) off.push({ folders, containers, after: r.after, rows: page.rows(), want }); + // Members of a folder the file has no entry for stay where they were saved + const unsaved = new Set(Object.keys(folders).filter((id) => !r.after.includes(`folder-${id}`)).flatMap((id) => page.members(id))); + const named = r.after.filter((e) => containers.includes(e) && !unsaved.has(e)); + if (!same(named, page.drawn().filter((e) => named.includes(e)))) apart.push({ folders, containers, after: r.after, drawn: page.drawn() }); } check('the sync regroups over a quarter of the generated orders, and every sync answers success', changed > 30 && refused.length === 0, { changed, refused: refused.slice(0, 2) }); check('a second sync leaves userprefs.cfg as the first wrote it', unstable.length === 0, unstable.slice(0, 2)); check('after the sync the page draws its rows in the order userprefs.cfg names them', off.length === 0, { count: off.length, first: off.slice(0, 2) }); + check('and userprefs.cfg names its containers in the order the page draws them, folders whose regexes match one container among them', + apart.length === 0 && overlaps > 10, { overlaps, count: apart.length, first: apart.slice(0, 2) }); } { const syncs = (page) => page.posts.filter((r) => r.url.endsWith('/sync_order.php')).map((r) => r.data); diff --git a/.github/scripts/page_order_test.php b/.github/scripts/page_order_test.php index 3b1b7fc1..edab0144 100644 --- a/.github/scripts/page_order_test.php +++ b/.github/scripts/page_order_test.php @@ -211,11 +211,18 @@ class DockerUpdate {} ['folder-a', 'folder-b', 'folder-m', 'plex', 'folder-z']], ['no userprefs.cfg: a look-alike of a folder member keeps its own A-Z place', $order(['f' => $folder('F', ['10'])], ['10', '1e1', '0first'], []), ['0first', '1e1', '10', 'folder-f']], - ['read_membership.php: an explicit entry beats a label (s1), a label places a loose container (mid), the first folder whose regex matches wins (r1, y1)', - $membership(null), [1, '200', ['alpha' => 'Dup', 'mid' => 'Zulu', 'n1' => 'Numbers', 'o1' => 'Old', 'r1' => 'Rex', 'r2' => 'Rex', 's1' => 'Seven', 'y1' => 'Yankee', 'y2' => 'Yankee', 'z1' => 'Zulu', 'z2' => 'Zulu']]], - ['and its answer does not depend on userprefs.cfg: the saved order, a reversed one, a file cut off mid-save', + ['two folders\' regexes match a container: the folder userprefs.cfg names first takes it, as the page draws it', + $order(['a' => $folder('A', [], '^web'), 'b' => $folder('B', [], '^web')], ['web1', 'loose'], ['folder-b', 'loose', 'folder-a']), + ['web1', 'folder-b', 'loose', 'folder-a']], + ['folders userprefs.cfg does not name take theirs in JS key order, an index-like id first', + $order(['x' => $folder('X', [], '^web'), '7' => $folder('Seven', [], '^web')], ['web1', 'loose'], ['loose']), ['folder-x', 'web1', 'folder-7', 'loose']], + ['no userprefs.cfg: the folder first A-Z takes a container two regexes match', + $order(['z' => $folder('Zulu', [], '^web'), 'a' => $folder('Alpha', [], '^web')], ['web1'], []), ['web1', 'folder-a', 'folder-z']], + ['read_membership.php: an explicit entry beats a label (s1), a label places a loose container (mid); with nothing saved the folder first A-Z whose regex matches wins (Dup: r1, y1)', + $membership(null), [1, '200', ['alpha' => 'Dup', 'mid' => 'Zulu', 'n1' => 'Numbers', 'o1' => 'Old', 'r1' => 'Dup', 'r2' => 'Dup', 's1' => 'Seven', 'y1' => 'Dup', 'y2' => 'Dup', 'z1' => 'Zulu', 'z2' => 'Zulu']]], + ['with a saved order, the folders it names win first, then the rest (Rex, Yankee before Dup); a file cut off mid-save reads as nothing saved, as on the page', [$membership($userprefs($fixture['prefs'])), $membership($userprefs(array_reverse($fixture['containers']))), $membership($cutOff)], - array_fill(0, 3, $membership(null))], + [...array_fill(0, 2, [1, '200', ['alpha' => 'Dup', 'mid' => 'Zulu', 'n1' => 'Numbers', 'o1' => 'Old', 'r1' => 'Rex', 'r2' => 'Rex', 's1' => 'Seven', 'y1' => 'Yankee', 'y2' => 'Yankee', 'z1' => 'Zulu', 'z2' => 'Zulu']]), $membership(null)]], ['autostart lines follow the order and keep their wait value', fv3_reorder_autostart(['a 5', 'b', 'c 10'], ['c', 'folder-f', 'a', 'a']), ['c 10', 'a 5', 'b']], ['a line the order does not name stays after the others, in file order', diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php index 897ebb0f..7cb65a14 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php @@ -715,9 +715,26 @@ function fv3_live_order(array $names, array $prefs): array { return array_merge($saved, array_values(array_filter($names, function($n) use ($saved) { return !in_array($n, $saved, true); }))); } + // The order docker.js createFolders() draws folders in: the folders userprefs.cfg names, in its order, then the rest in JS key + // order; with nothing saved, A-Z by name + function fv3_folder_walk_order(array $folders, array $prefs): array { + $ids = fv3_js_key_order(array_keys($folders)); + if (!$prefs) { + $name = fn($id) => $folders[$id]['name'] !== '' ? $folders[$id]['name'] : "folder-$id"; + usort($ids, fn($a, $b) => fv3_name_cmp($name($a), $name($b))); + return $ids; + } + $saved = []; + foreach ($prefs as $entry) { + if (str_starts_with($entry, 'folder-') && array_key_exists(substr($entry, 7), $folders)) $saved[] = substr($entry, 7); + } + return array_values(array_unique(array_merge($saved, $ids))); + } + // Effective membership — explicit > label > regex (issues #46/#55). Single source of // truth shared by syncContainerOrder and read_membership.php (issue #61). - // $prefs orders each folder's regex and label members as the Docker page lists them (fv3_live_order) + // $prefs orders each folder's regex and label members as the Docker page lists them (fv3_live_order), and the folders as the + // page draws them, so a container two folders' regexes match goes to the one the page shows it in function fv3_compute_folder_membership(array $folders, array $allContainerNames, array $ctLabels, array $prefs = []): array { $live = fv3_live_order($allContainerNames, $prefs); // One malformed entry is dropped or filled in, not allowed to abort every folder's sync @@ -737,7 +754,8 @@ function fv3_compute_folder_membership(array $folders, array $allContainerNames, foreach ($ctLabels as $ctName => $ctLabel) { if (isset($folderNameSet[$ctLabel])) { $explicitAssigned[] = (string)$ctName; } } - foreach ($folders as $folderId => $folder) { + foreach (fv3_folder_walk_order($folders, $prefs) as $folderId) { + $folder = $folders[$folderId]; $members = $folder['containers'] ?? []; // is_string + trim, not empty(): empty("0") is true in PHP, so a regex of "0" was // silently dropped while docker.js applied it. The type check mirrors docker.js and diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/read_membership.php b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/read_membership.php index ab7fa68d..1e3cc838 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/read_membership.php +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/read_membership.php @@ -41,8 +41,8 @@ echo json_encode(['error' => 'container label read unavailable']); exit; } - // The map does not depend on the saved order (page_order_test.php), so userprefs.cfg is not read here - $m = fv3_compute_folder_membership($folders, $allContainerNames, $ctLabels); + // The saved order as the page reads it (readUserPrefs: unreadable = nothing saved) decides who gets a container two folders' regexes match + $m = fv3_compute_folder_membership($folders, $allContainerNames, $ctLabels, fv3_docker_prefs() ?? []); $out = []; foreach ($m['containers'] as $placeholder => $members) { foreach ($members as $ct) { $out[$ct] = $m['names'][$placeholder]; } From 531efd18ff6aa0d092a148fc3084499740d4de1b Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Mon, 16 Nov 2026 18:08:02 +0800 Subject: [PATCH 64/72] refactor: move the container order code from lib.php into lib.order.php A pure move: 32 functions, each byte-identical, and lib.php requires the new file. lib.php goes from 2,131 to 1,471 lines. --- .github/scripts/name_order_test.js | 4 +- .../server/lib.foreign_import.php | 2 +- .../plugins/folder.view3/server/lib.order.php | 665 ++++++++++++++++++ .../plugins/folder.view3/server/lib.php | 662 +---------------- 4 files changed, 669 insertions(+), 664 deletions(-) create mode 100644 src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.order.php diff --git a/.github/scripts/name_order_test.js b/.github/scripts/name_order_test.js index 69461bd3..43184cc8 100644 --- a/.github/scripts/name_order_test.js +++ b/.github/scripts/name_order_test.js @@ -4,8 +4,8 @@ const { execFileSync } = require('child_process'); const { check, done, read } = require('./preview_pages_harness.js'); -// The shipped function, taken from lib.php as written -const fn = read('server/lib.php').match(/^ {4}function fv3_name_cmp\([\s\S]*?\n {4}}\n/m)[0]; +// The shipped function, taken from lib.order.php as written +const fn = read('server/lib.order.php').match(/^ {4}function fv3_name_cmp\([\s\S]*?\n {4}}\n/m)[0]; const phpSort = (names) => JSON.parse(execFileSync('php', ['-r', `${fn} $l = json_decode(stream_get_contents(STDIN), true); usort($l, 'fv3_name_cmp'); echo json_encode($l);`], { input: JSON.stringify(names), encoding: 'utf8' })); const browserSort = (names) => names.slice().sort((a, b) => a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' })); diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.foreign_import.php b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.foreign_import.php index 0b76d37e..f4755d1b 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.foreign_import.php +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.foreign_import.php @@ -398,7 +398,7 @@ function fv3_convert_foreign_bundle(array $raw, ?string $onlyType, array $existi $regex = is_string($src['regex'] ?? null) && strlen($src['regex']) <= 1024 ? $src['regex'] : ''; // A regex present but refused on type or length is left out as much as one that will not compile if ($regex === '' && $suppliedRegex !== null && $suppliedRegex !== '') $r['dropped_regex']++; - // Same pattern build as syncContainerOrder in lib.php; a regex it can't compile would match nothing + // Same pattern build as fv3_compute_folder_membership in lib.order.php; a regex it can't compile would match nothing if ($regex !== '' && @preg_match('/' . str_replace('/', '\/', $regex) . '/', '') === false) { $regex = ''; $r['dropped_regex']++; } // The renderers hand the stored pattern to JS new RegExp(), so one PHP alone accepts // would place members the page then cannot show — see fv3_foreign_regex_js_safe() diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.order.php b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.order.php new file mode 100644 index 00000000..3216d3b7 --- /dev/null +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.order.php @@ -0,0 +1,665 @@ + !is_string($v))) return null; + uksort($parsed, fn($a, $b) => (int)$a <=> (int)$b); + return array_values($parsed); + } + + // userprefs.cfg in the format Unraid writes it, one N="name" line per entry + function fv3_write_user_prefs(string $file, array $entries): bool { + $lines = []; + foreach (array_values($entries) as $i => $name) { $lines[] = $i . '="' . $name . '"'; } + return fv3_atomic_write($file, implode("\n", $lines) . "\n"); + } + + function fv3_order_snapshot_file(string $type): string { + global $configDir; + return "$configDir/order-$type.json"; + } + + // Returns the cleaned list, or null when any non-empty entry breaks the snapshot + // rules. Empty entries are delimiter artifacts (every stock names string ends ';') + // and are dropped, not treated as invalid. The rules exist because a violating + // entry could corrupt an ini line when healed back into userprefs.cfg. + function fv3_sanitize_order_entries(array $entries): ?array { + $clean = []; + foreach ($entries as $e) { + if (!is_string($e)) return null; + $e = trim($e); + if ($e === '') continue; + if (strlen($e) > 256 || strpos($e, '"') !== false || preg_match('/[\x00-\x1f\x7f]/', $e)) return null; + $clean[] = $e; + } + if (count($clean) > 4096) return null; + return $clean; + } + + function saveOrderSnapshot(string $type, array $entries): bool { + $clean = fv3_sanitize_order_entries($entries); + if ($clean === null || empty($clean)) return false; + return fv3_atomic_write(fv3_order_snapshot_file($type), json_encode(['fv3_order_version' => 1, 'entries' => $clean], JSON_PRETTY_PRINT)); + } + + // Snapshot state for export, keeping the tri-state importAll() relies on: + // absent file -> [] (present-empty: source authoritatively has no snapshot, import + // clears the destination); unreadable/malformed -> null (omit the bundle key, import + // leaves the destination untouched); valid -> the wrapped snapshot. + // A snapshot wrapper saveOrderSnapshot could actually have written: version 1 and a + // non-empty entries list that passes sanitization unchanged. Returns the entries or + // null. Shared by export (file contents) and import (bundle contents) so both sides + // apply identical validation — anything else is corrupt/tampered and must be ignored, + // never treated as empty (that would clear a valid destination snapshot on import). + function fv3_validate_order_snapshot(array $data): ?array { + if (($data['fv3_order_version'] ?? null) !== 1 + || !isset($data['entries']) || !is_array($data['entries'])) return null; + $clean = fv3_sanitize_order_entries($data['entries']); + if ($clean === null || empty($clean) || $clean !== array_values($data['entries'])) return null; + return $clean; + } + + function fv3_export_order_snapshot(string $type): ?array { + $path = fv3_order_snapshot_file($type); + if (!file_exists($path)) return []; + $raw = @file_get_contents($path); + $data = ($raw !== false) ? json_decode($raw, true) : null; + if (!is_array($data) || fv3_validate_order_snapshot($data) === null) return null; + return $data; + } + + // Re-insert folder rows into the stock sort prefs from FV3's own order snapshot. + // Fires when prefs has entries but at least one live folder is unpositioned — + // the post-reinstall state, or a folder whose entry went missing. Insert-only — + // existing prefs entries are never reordered or removed, so container order is + // preserved, and already-positioned folders are kept in place and used as anchors. + function fv3_heal_user_prefs(string $type, string $prefsFilePath): void { + global $configDir; + $raw = @file_get_contents($prefsFilePath); + if (!is_string($raw) || $raw === '') return; + $current = fv3_parse_user_prefs($raw); + if (!$current) return; + + $config = fv3_read_json("$configDir/$type.json"); + if (empty($config)) return; + // Prefs and the snapshot store folder rows as 'folder-' placeholders + // (the hidden appname the stock reorder serializes); config keys are raw ids. + $placeholders = []; + foreach (array_keys($config) as $fid) { $placeholders['folder-' . $fid] = true; } + if (empty(array_diff(array_keys($placeholders), $current))) return; + + $snap = fv3_read_json(fv3_order_snapshot_file($type)); + $saved = $snap['entries'] ?? null; + if (!is_array($saved)) return; + + $currentSet = array_flip($current); + // Each unpositioned live folder placeholder maps to the first later snapshot entry still present in prefs (null = append) + $insertBefore = []; + $pending = []; + foreach ($saved as $entry) { + if (!is_string($entry)) continue; + if (isset($placeholders[$entry]) && !isset($currentSet[$entry])) { $pending[] = $entry; continue; } + if (isset($currentSet[$entry])) { + foreach ($pending as $fid) { $insertBefore[$fid] = $entry; } + $pending = []; + } + } + foreach ($pending as $fid) { $insertBefore[$fid] = null; } + if (empty($insertBefore)) return; + + $out = []; + foreach ($current as $name) { + foreach ($insertBefore as $fid => $succ) { + if ($succ === $name) { $out[] = $fid; unset($insertBefore[$fid]); } + } + $out[] = $name; + } + foreach (array_keys($insertBefore) as $fid) { $out[] = $fid; } + + // Stock UserPrefs writes are lockless, so re-check the source right before + // replacing — a concurrent reorder mid-compute aborts the heal (next load retries). + if (@file_get_contents($prefsFilePath) !== $raw) return; + if (fv3_write_user_prefs($prefsFilePath, $out)) { + fv3_debug_log("fv3_heal_user_prefs($type): re-inserted " . (count($out) - count($current)) . " folder position(s)"); + } + } + + function fv3_autostart_file(): string { + global $fv3DockerManDir; + $dockerManPaths = @parse_ini_file("$fv3DockerManDir/dockerMan.cfg") ?: []; + return $dockerManPaths['autostart-file'] ?? "/var/lib/docker/unraid-autostart"; + } + + // null when the file cannot be read: a caller that rebuilds the file from these lines must stop, not write [] + function fv3_read_autostart_lines(string $file): ?array { + $lines = @file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); + return $lines === false ? null : $lines; + } + + function readAutostartConfig(): array { + global $configDir; + $cfg = fv3_read_json_strict("$configDir/autostart.json"); + // Corrupt config fails closed to 'off' (pure stock behaviour, no autostart writes) + // rather than silently flipping a custom/off user to folder mode. + if ($cfg === null) return ['mode' => 'off', 'sequence' => []]; + $mode = $cfg['mode'] ?? 'folder'; + if (!in_array($mode, ['folder', 'custom', 'off'], true)) $mode = 'folder'; + $sequence = []; + foreach ((array)($cfg['sequence'] ?? []) as $name) { + // docker name charset — a crafted config entry must not smuggle markup or newlines into the autostart file + if (is_string($name) && preg_match('/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/', $name)) $sequence[] = $name; + } + return ['mode' => $mode, 'sequence' => array_values(array_unique($sequence))]; + } + + function updateAutostartConfig(string $mode, array $sequence, array $waits): array { + global $configDir; + if (!in_array($mode, ['folder', 'custom', 'off'], true)) return ['error' => 'Invalid mode']; + $cleanSeq = []; + foreach ($sequence as $name) { + if (is_string($name) && preg_match('/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/', $name)) $cleanSeq[] = $name; + if (count($cleanSeq) >= 500) break; + } + $cleanSeq = array_values(array_unique($cleanSeq)); + // Read before the write: an unreadable autostart file aborts the save rather than reporting + // success with the wait edits silently dropped + $autoStartFile = fv3_autostart_file(); + $lines = null; + if (!empty($waits)) { + if (file_exists($autoStartFile)) { + // Zeros still have to reach the loop below: that is how a wait is cleared + $lines = fv3_read_autostart_lines($autoStartFile); + if ($lines === null) return ['error' => 'Could not read the autostart file — nothing was saved']; + } elseif (array_filter($waits, static fn($w) => (int)$w > 0)) { + // No file to apply them to; an all-zero map is the empty state and saves normally + return ['error' => 'Could not read the autostart file — nothing was saved']; + } + } + + $ok = fv3_atomic_write("$configDir/autostart.json", json_encode(['mode' => $mode, 'sequence' => $cleanSeq], JSON_PRETTY_PRINT)); + if (!$ok) return ['error' => 'Failed to write autostart config']; + + // Fold wait edits into the live file — a name only matches a line that already has autostart enabled + $waitFailed = null; + if ($lines !== null) { + $changed = false; + foreach ($lines as $i => $line) { + $name = explode(' ', $line, 2)[0]; + if (array_key_exists($name, $waits)) { + $wait = max(0, min(3600, (int)$waits[$name])); + $newLine = rtrim($name . ' ' . ($wait > 0 ? $wait : '')); + if ($newLine !== $line) { $lines[$i] = $newLine; $changed = true; } + } + } + if ($changed && @file_put_contents($autoStartFile, implode("\n", $lines) . "\n", LOCK_EX) === false) { + $waitFailed = 'the wait edits could not be written to the autostart file'; + } + } + + // Re-assert order under the saved mode — saving folder mode instantly restores folder-derived order. + // The mode and sequence are saved either way: wait edits that were not written and a sync that stopped come back as `warning` + $warnings = array_filter([$waitFailed, $mode !== 'off' ? syncContainerOrder('docker') : null]); + return ['success' => true, 'mode' => $mode, 'sequence' => $cleanSeq] + ($warnings ? ['warning' => implode('; ', $warnings)] : []); + } + + // Reorders the existing autostart lines to the saved custom sequence. Waits ride along + // verbatim; enabled-but-unsequenced containers keep their current relative order at the end. + // Returns why the autostart file could not be put in the saved sequence, or null + function fv3_apply_custom_autostart(array $allContainerNames, bool $ctListComplete): ?string { + $autoStartFile = fv3_autostart_file(); + if (!file_exists($autoStartFile)) return null; + $sequence = readAutostartConfig()['sequence']; + $rawLines = fv3_read_autostart_lines($autoStartFile); + if ($rawLines === null) { fv3_debug_log("fv3_apply_custom_autostart: $autoStartFile unreadable, not rewriting"); return 'the autostart file could not be read'; } + $newAutoStart = fv3_reorder_autostart(fv3_prune_stale_autostart($rawLines, $allContainerNames, $ctListComplete), $sequence); + if ($newAutoStart === $rawLines) { return null; } + if (@file_put_contents($autoStartFile, implode("\n", $newAutoStart) . "\n", LOCK_EX) === false) { return 'the autostart file could not be written'; } + fv3_debug_log("fv3_apply_custom_autostart: wrote " . count($newAutoStart) . " entries (" . count($sequence) . " sequenced)"); + return null; + } + + // The one definition of "drop autostart entries whose container is gone". A degraded Docker + // read must never prune (#214/#231) — a transient blip would otherwise curtail the file. + function fv3_prune_stale_autostart(array $autoStartLines, array $allContainerNames, bool $ctListComplete): array { + if (!$ctListComplete) return $autoStartLines; + $kept = []; + foreach ($autoStartLines as $line) { + $name = explode(' ', $line, 2)[0]; + if (in_array($name, $allContainerNames, true)) { $kept[] = $line; continue; } + fv3_debug_log("autostart: dropped stale entry '$name' (container no longer exists)"); + } + return $kept; + } + + // The values of Unraid's saved Docker order (userprefs.cfg): [] when there is none, null when the file will not be read + function fv3_docker_prefs(): ?array { + global $fv3DockerManDir; + $file = "$fv3DockerManDir/userprefs.cfg"; + if (!is_file($file)) { return []; } + $raw = @file_get_contents($file); + return $raw === false ? null : fv3_parse_user_prefs($raw); + } + + // Container names in the order read_unraid_order.php hands the page (readUnraidOrder): saved names in userprefs.cfg + // order, unsaved ones after them as Docker lists them; A-Z when nothing is saved + function fv3_live_order(array $names, array $prefs): array { + if (!$prefs) { usort($names, 'strnatcasecmp'); return $names; } + $saved = array_values(array_unique(array_filter($prefs, function($p) use ($names) { return in_array($p, $names, true); }))); + return array_merge($saved, array_values(array_filter($names, function($n) use ($saved) { return !in_array($n, $saved, true); }))); + } + + // The order docker.js createFolders() draws folders in: the folders userprefs.cfg names, in its order, then the rest in JS key + // order; with nothing saved, A-Z by name + function fv3_folder_walk_order(array $folders, array $prefs): array { + $ids = fv3_js_key_order(array_keys($folders)); + if (!$prefs) { + $name = fn($id) => $folders[$id]['name'] !== '' ? $folders[$id]['name'] : "folder-$id"; + usort($ids, fn($a, $b) => fv3_name_cmp($name($a), $name($b))); + return $ids; + } + $saved = []; + foreach ($prefs as $entry) { + if (str_starts_with($entry, 'folder-') && array_key_exists(substr($entry, 7), $folders)) $saved[] = substr($entry, 7); + } + return array_values(array_unique(array_merge($saved, $ids))); + } + + // Effective membership — explicit > label > regex (issues #46/#55). Single source of + // truth shared by syncContainerOrder and read_membership.php (issue #61). + // $prefs orders each folder's regex and label members as the Docker page lists them (fv3_live_order), and the folders as the + // page draws them, so a container two folders' regexes match goes to the one the page shows it in + function fv3_compute_folder_membership(array $folders, array $allContainerNames, array $ctLabels, array $prefs = []): array { + $live = fv3_live_order($allContainerNames, $prefs); + // One malformed entry is dropped or filled in, not allowed to abort every folder's sync + $folders = fv3_normalize_folders($folders); + $folderNameSet = []; + foreach ($folders as $folder) { + if (isset($folder['name'])) { $folderNameSet[$folder['name']] = true; } + } + $folderContainers = []; + $folderNames = []; + $assignedContainers = []; + $explicitMembers = []; + foreach ($folders as $folder) { + $explicitMembers = array_merge($explicitMembers, $folder['containers'] ?? []); + } + $explicitAssigned = $explicitMembers; + foreach ($ctLabels as $ctName => $ctLabel) { + if (isset($folderNameSet[$ctLabel])) { $explicitAssigned[] = (string)$ctName; } + } + foreach (fv3_folder_walk_order($folders, $prefs) as $folderId) { + $folder = $folders[$folderId]; + $members = $folder['containers'] ?? []; + // is_string + trim, not empty(): empty("0") is true in PHP, so a regex of "0" was + // silently dropped while docker.js applied it. The type check mirrors docker.js and + // keeps a non-string regex from fataling trim() (TypeError on PHP 8). + if (is_string($folder['regex'] ?? null) && trim($folder['regex']) !== '') { + $regex = '/' . str_replace('/', '\/', $folder['regex']) . '/'; + foreach ($live as $name) { + if (@preg_match($regex, $name) && !in_array($name, $members, true) && !in_array($name, $explicitAssigned, true)) { + $members[] = $name; + } + } + } + // Explicit containers[] entries anywhere win over a label claim (issue #55) + foreach ($live as $ctName) { + if (($ctLabels[$ctName] ?? null) === $folder['name'] && !in_array($ctName, $members, true) && !in_array($ctName, $explicitMembers, true)) { + $members[] = $ctName; + } + } + $members = array_values(array_filter($members, function($m) use ($allContainerNames, $assignedContainers) { + return in_array($m, $allContainerNames, true) && !in_array($m, $assignedContainers, true); + })); + $folderContainers["folder-$folderId"] = $members; + $folderNames["folder-$folderId"] = $folder['name'] ?? "folder-$folderId"; + $assignedContainers = array_merge($assignedContainers, $members); + } + return ['containers' => $folderContainers, 'names' => $folderNames, 'assigned' => $assignedContainers]; + } + + // The order JS walks an object's keys in: index-like keys ("7", not "07") first and ascending, then the rest as written + function fv3_js_key_order(array $keys): array { + $keys = array_map('strval', $keys); + $index = array_values(array_filter($keys, function($k) { return preg_match('/^(0|[1-9]\d{0,9})$/D', $k) === 1 && (int)$k < 4294967295; })); + sort($index, SORT_NUMERIC); + return array_merge($index, array_values(array_diff($keys, $index))); + } + + // A name as the Docker page sorts it with nothing saved: trimmed of what JavaScript's trim() removes + function fv3_js_trim(string $s): string { + return preg_replace('/^[\x{9}-\x{D}\x{20}\x{A0}\x{1680}\x{2000}-\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}\x{FEFF}]+|' + . '[\x{9}-\x{D}\x{20}\x{A0}\x{1680}\x{2000}-\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}\x{FEFF}]+$/u', '', $s) ?? trim($s); + } + + // The browser's name order (localeCompare(b, undefined, {numeric: true, sensitivity: 'base'})) for ASCII: space and punctuation in + // ICU's order, numbers by value, letters in any case. Other characters follow z by code point, so accents can differ + function fv3_name_cmp(string $a, string $b): int { + static $punct = null; + $punct ??= array_flip(str_split(" _-,;:!?.'\"()[]{}@*/\\&#%`^+<=>|~$")); + $tokens = static function (string $s) use ($punct): ?array { + if (preg_match_all('/[0-9]+|./su', $s, $m) === false) return null; + return array_map(static function (string $t) use ($punct): array { + if (ctype_digit($t)) return [100, ltrim($t, '0')]; + $c = strtolower($t); + if (isset($punct[$c])) return [$punct[$c], '']; + return strlen($c) === 1 && $c >= 'a' && $c <= 'z' ? [200 + ord($c), ''] : [1000, $t]; + }, $m[0]); + }; + $ta = $tokens($a); + $tb = $tokens($b); + if ($ta === null || $tb === null) return strnatcasecmp($a, $b); + foreach ($ta as $i => [$ga, $ka]) { + if (!isset($tb[$i])) return 1; + [$gb, $kb] = $tb[$i]; + if ($ga !== $gb) return $ga <=> $gb; + $c = $ga === 100 ? (strlen($ka) <=> strlen($kb) ?: strcmp($ka, $kb)) : strcmp($ka, $kb); + if ($c !== 0) return $c <=> 0; + } + return count($ta) < count($tb) ? -1 : 0; + } + + // The Docker page's order, top-down, as container names and folder placeholders, members before their folder. + // $prefs is userprefs.cfg's values; with none it is A-Z by name as createFolders() sorts it (fv3_name_cmp: accents can differ) + function fv3_page_order(array $membership, array $allContainerNames, array $prefs): array { + $folderContainers = $membership['containers']; + $assigned = $membership['assigned']; + if (!$prefs) { + $entries = []; + foreach ($folderContainers as $placeholder => $_members) { + // The page's last pass sorts the rows by the trimmed name it shows (docker.js createFolders) + $entries[] = ['key' => $placeholder, 'name' => fv3_js_trim($membership['names'][$placeholder])]; + } + foreach ($allContainerNames as $name) { + if (!in_array($name, $assigned, true)) { $entries[] = ['key' => $name, 'name' => $name]; } + } + usort($entries, function($a, $b) { return fv3_name_cmp($a['name'], $b['name']); }); + $prefs = array_column($entries, 'key'); + } + $placed = []; + $seen = []; + foreach ($prefs as $item) { + if (isset($folderContainers[$item])) { + foreach ($folderContainers[$item] as $ct) { + if (!in_array($ct, $seen, true)) { $placed[] = $ct; $seen[] = $ct; } + } + $placed[] = $item; + $seen[] = $item; + } elseif (in_array($item, $assigned, true)) { + continue; + } elseif (in_array($item, $allContainerNames, true) && !in_array($item, $seen, true)) { + $placed[] = $item; + $seen[] = $item; + } + } + // Not in userprefs.cfg yet: docker.js unshifts each such folder (the last one it meets ends on top); new containers sit below them + $new = []; + $ids = array_map(function($placeholder) { return substr($placeholder, 7); }, array_keys($folderContainers)); + foreach (array_reverse(fv3_js_key_order($ids)) as $id) { + $placeholder = "folder-$id"; + if (in_array($placeholder, $seen, true)) { continue; } + foreach ($folderContainers[$placeholder] as $ct) { $new[] = $ct; } + $new[] = $placeholder; + } + $loose = array_values(array_filter($allContainerNames, function($name) use ($seen, $assigned) { + return !in_array($name, $seen, true) && !in_array($name, $assigned, true); + })); + usort($loose, 'strnatcasecmp'); + return array_merge($new, $loose, $placed); + } + + // $prefs with each folder's members together in its order, on the side of its entry a neighbour shows (a drag: after, FV3's writers: + // before; after by default). A folder with no entry, and every other entry, stay as they are + function fv3_prefs_with_folder_members(array $prefs, array $membership): array { + $blocks = []; + foreach ($membership['containers'] as $placeholder => $members) { + $at = array_search($placeholder, $prefs, true); + if ($at === false || !$members) continue; + $after = isset($prefs[$at + 1]) && in_array($prefs[$at + 1], $members, true); + $before = !$after && $at > 0 && in_array($prefs[$at - 1], $members, true); + $blocks[$placeholder] = ['members' => $members, 'before' => $before]; + } + if (!$blocks) return $prefs; + $moved = array_merge(...array_column($blocks, 'members')); + $out = []; + foreach ($prefs as $entry) { + if (in_array($entry, $moved, true)) continue; + if (!isset($blocks[$entry])) { $out[] = $entry; continue; } + ['members' => $members, 'before' => $before] = $blocks[$entry]; + unset($blocks[$entry]); // a repeated entry for the same folder keeps its place, its members come once + array_push($out, ...($before ? [...$members, $entry] : [$entry, ...$members])); + } + return $out; + } + + // Keeps userprefs.cfg's containers with their folders, so what reads it (Unraid's Start all and autostart sort, other plugins) + // follows the page. Only a saved order is changed: creating one switches Unraid off its A-Z order (#112). Returns why it failed + function fv3_sync_user_prefs(array $prefs, array $membership): ?string { + global $fv3DockerManDir; + if (!$prefs) return null; + $updated = fv3_prefs_with_folder_members($prefs, $membership); + if ($updated === $prefs) return null; + $updated = fv3_sanitize_order_entries($updated); + if ($updated === null) return "Unraid's saved Docker order (userprefs.cfg) holds a name that cannot be written back"; + // Stock UserPrefs writes take no lock: an order saved since the read above is kept as it is + $now = fv3_docker_prefs(); + if ($now === null) return "Unraid's saved Docker order (userprefs.cfg) could not be read"; + if ($now !== $prefs) { fv3_debug_log("fv3_sync_user_prefs: userprefs.cfg changed meanwhile, left as it is"); return null; } + if (!fv3_write_user_prefs("$fv3DockerManDir/userprefs.cfg", $updated)) { + fv3_debug_log("fv3_sync_user_prefs: userprefs.cfg could not be written"); + return "Unraid's saved Docker order (userprefs.cfg) could not be updated"; + } + // FV3's own copy, which the heal restores from after a reinstall + if (!saveOrderSnapshot('docker', $updated)) fv3_error_log('fv3_sync_user_prefs', 'the order snapshot could not be written'); + fv3_debug_log("fv3_sync_user_prefs: wrote userprefs.cfg with " . count($updated) . " entries"); + return null; + } + + // Autostart lines ("name" or "name delay") in $order's sequence, each once; lines $order does not name follow, in file order + function fv3_reorder_autostart(array $lines, array $order): array { + $byName = []; + foreach ($lines as $line) { $byName[explode(' ', $line, 2)[0]] = $line; } + $ordered = []; + foreach ($order as $name) { + if (isset($byName[$name])) { $ordered[] = $byName[$name]; unset($byName[$name]); } + } + return array_merge($ordered, array_values($byName)); + } + + // Returns why userprefs.cfg or the autostart file could not be put in order (a file or a Docker read it needs failed), else null. + // An empty container list is only logged: a server with no containers, or with Docker off, has nothing to report + function syncContainerOrder(string $type): ?string { + fv3_debug_log("syncContainerOrder called for type: $type"); + if ($type !== 'docker') { return null; } + + $autostartMode = readAutostartConfig()['mode']; + $dockerClient = new DockerClient(); + $ctNames = fv3_read_container_names($dockerClient); + // 'custom' = the Autostart tab's saved sequence orders the autostart file; 'off' = FV3 never reorders it + $failed = array_filter([ + $autostartMode === 'custom' ? fv3_apply_custom_autostart($ctNames['names'], $ctNames['complete']) : null, + ...fv3_sync_page_order($dockerClient, $ctNames, $autostartMode === 'folder'), + ]); + return $failed ? implode('; ', $failed) : null; + } + + // Puts a saved userprefs.cfg's containers with their folders and, with $autostart, the autostart file in the order FV3 renders: + // top to bottom, folder members in their editor order. Returns why each part could not be done, [] when all went through + function fv3_sync_page_order(DockerClient $dockerClient, array $ctNames, bool $autostart): array { + global $configDir; + $stop = function (string $why): array { fv3_debug_log("syncContainerOrder: $why, aborting before write"); return [$why]; }; + $allContainerNames = $ctNames['names']; + // The page's order needs the WHOLE list: a container missing from a partial read would be put out of place in either file + if (!$ctNames['complete']) { + if ($ctNames['empty']) { fv3_debug_log("syncContainerOrder: no containers, nothing to sync"); return []; } + return $stop("Docker's container list could not be read"); + } + + // No docker.json, or no config folder at all (deleted by hand under an open tab), is "no folders": never a stop + $folders = fv3_read_json_strict("$configDir/docker.json"); + // Corrupt folder config must not be read as no folders + if ($folders === null) { return $stop('the folder config could not be read'); } + + $ctLabels = fv3_read_container_labels($dockerClient, $allContainerNames); + // Fail closed: without label claims, label-assigned containers would be written back out as unassigned + if ($ctLabels === null) { return $stop('the container labels could not be read'); } + $prefs = fv3_docker_prefs(); + // The page's order cannot be worked out then, so both files stay as they are + if ($prefs === null) { return $stop("Unraid's saved Docker order (userprefs.cfg) could not be read"); } + $membership = fv3_compute_folder_membership($folders, $allContainerNames, $ctLabels, $prefs); + // Each file is put in order on its own: one that fails does not hold the other back + return array_values(array_filter([ + fv3_sync_user_prefs($prefs, $membership), + $autostart ? fv3_sync_autostart_order(fv3_page_order($membership, $allContainerNames, $prefs), $allContainerNames) : null, + ])); + } + + // The autostart file's lines in $order's sequence, entries for removed containers dropped ($names must be Docker's whole list, + // #214). Returns why it could not be put in order, else null + function fv3_sync_autostart_order(array $order, array $names): ?string { + $autoStartFile = fv3_autostart_file(); + if (!file_exists($autoStartFile)) return null; + $rawLines = fv3_read_autostart_lines($autoStartFile); + if ($rawLines === null) return 'the autostart file could not be read'; + $newAutoStart = fv3_reorder_autostart(fv3_prune_stale_autostart($rawLines, $names, true), $order); + if ($newAutoStart === $rawLines) { fv3_debug_log("syncContainerOrder: autostart file already in order"); return null; } + if (@file_put_contents($autoStartFile, implode("\n", $newAutoStart) . "\n", LOCK_EX) === false) return 'the autostart file could not be written'; + fv3_debug_log("syncContainerOrder: wrote autostart file with " . count($newAutoStart) . " entries"); + return null; + } + + // Creates Unraid's saved Docker order on a server with none, after an import or a restore: $first's entries (placeholders, names) + // first. Its other writers: the heal and fv3_place_imported_docker_folders. Returns why it stopped, or null: also when one is saved + function fv3_create_docker_order(array $first): ?string { + global $configDir, $fv3DockerManDir; + if (!$first) return null; + $prefs = fv3_docker_prefs(); + if ($prefs === null) return "Unraid's saved Docker order (userprefs.cfg) could not be read"; + if ($prefs) return null; + $dockerClient = new DockerClient(); + $ctNames = fv3_read_container_names($dockerClient); + // Docker stopped and no containers both answer []. An order of folders alone would put every container above them once Docker lists them + if ($ctNames['empty']) return 'Docker is not running or lists no containers'; + if (!$ctNames['complete']) return "Docker's container list could not be read"; + $names = $ctNames['names']; + $folders = fv3_read_json_strict("$configDir/docker.json"); + if ($folders === null) return 'the folder config could not be read'; + $labels = fv3_read_container_labels($dockerClient, $names); + if ($labels === null) return 'the container labels could not be read'; + // A restore's order copy names containers too: regex and label members keep its order, the rest Docker's list order (A-Z with none) + $membership = fv3_compute_folder_membership($folders, $names, $labels, array_values(array_filter($first, fn($e) => is_string($e) && in_array($e, $names, true)))); + // Each folder after its members, as the page lists them; the rest as the page draws it with nothing saved (A-Z) + $out = []; + foreach ($first as $entry) { + if (!is_string($entry)) continue; + if (isset($membership['containers'][$entry])) { + array_push($out, ...$membership['containers'][$entry]); + $out[] = $entry; + } elseif (in_array($entry, $names, true) && !in_array($entry, $membership['assigned'], true)) { + $out[] = $entry; + } + } + $out = fv3_sanitize_order_entries(array_values(array_unique(array_merge($out, fv3_page_order($membership, $names, []))))); + if ($out === null) return 'a name cannot be written to userprefs.cfg'; + // Stock UserPrefs writes take no lock: an order Unraid saved meanwhile wins; one that cannot be read now is said + $now = fv3_docker_prefs(); + if ($now === null) return "Unraid's saved Docker order (userprefs.cfg) could not be read"; + if ($now) return null; + if (!is_dir($fv3DockerManDir) || !fv3_write_user_prefs("$fv3DockerManDir/userprefs.cfg", $out)) { + return "Unraid's saved Docker order (userprefs.cfg) could not be written"; + } + // FV3's own copy, which the heal restores from after a reinstall + if (!saveOrderSnapshot('docker', $out)) fv3_error_log('fv3_create_docker_order', 'the order snapshot could not be written'); + return null; + } + + // After an import: the new Docker folders ($first, placeholders in the file's order) go on top of Unraid's saved order, insert-only, + // so the page draws them and lets them claim containers top-first; with no saved order one is created. Returns why it stopped, or null + function fv3_place_imported_docker_folders(array $first): ?string { + global $configDir, $fv3DockerManDir; + $file = "$fv3DockerManDir/userprefs.cfg"; + $read = fn() => is_file($file) ? @file_get_contents($file) : ''; + for ($try = 0; $try < 3; $try++) { + $raw = $read(); + $current = $raw === false ? null : fv3_parse_user_prefs($raw); + if ($current === null) return "Unraid's saved Docker order (userprefs.cfg) could not be read"; + if (!$current) return fv3_create_docker_order($first); + $folders = fv3_read_json_strict("$configDir/docker.json"); + if ($folders === null) return 'the folder config could not be read'; + $new = array_values(array_unique(array_filter($first, fn($e) => is_string($e) && str_starts_with($e, 'folder-') + && array_key_exists(substr($e, 7), $folders) && !in_array($e, $current, true)))); + if (!$new) return null; + $out = array_merge($new, $current); + // Stock UserPrefs writes take no lock: an order Unraid saved meanwhile is read again + if ($read() !== $raw) continue; + if (!fv3_write_user_prefs($file, $out)) return "Unraid's saved Docker order (userprefs.cfg) could not be written"; + if (!saveOrderSnapshot('docker', $out)) fv3_error_log('fv3_place_imported_docker_folders', 'the order snapshot could not be written'); + return null; + } + return "Unraid's saved Docker order (userprefs.cfg) kept changing during the import"; + } + + function readUnraidOrder(string $type): array { + fv3_debug_log("readUnraidOrder called for type: $type"); + $user_prefs_path = "/boot/config/plugins"; + $order = []; + if ($type == "docker") { + $dockerClient = new DockerClient(); + // A userprefs.cfg that will not parse lists A-Z, as one that is absent does + $order = fv3_live_order(array_column($dockerClient->getDockerContainers() ?: [], 'Name'), fv3_docker_prefs() ?? []); + + } elseif ($type == "vm") { + if (!fv3_require_libvirt_helpers()) { fv3_debug_log("VM Order: libvirt_helpers.php not available."); return []; } + global $lv; + if (!isset($lv)) { $lv = new Libvirt(); if (!$lv->connect()) { fv3_debug_log("VM Order: Libvirt connection failed."); return []; } } + + $prefs_file = "$user_prefs_path/dynamix.vm.manager/userprefs.cfg"; + $vms = $lv->get_domains(); + + if (!empty($vms)) { + if (file_exists($prefs_file)) { + $prefs_ini = @parse_ini_file($prefs_file); + if ($prefs_ini) { + $prefs_array = array_values($prefs_ini); + $sort = []; + $count_vms = count($vms); + foreach ($vms as $vm_name) { + $search = array_search($vm_name, $prefs_array); + $sort[] = ($search === false) ? ($count_vms + count($sort) + 1) : $search; + } + if (!empty($sort)) { + @array_multisort($sort, SORT_NUMERIC, $vms); + } else { + natcasesort($vms); + } + } else { + natcasesort($vms); + } + } else { + natcasesort($vms); + } + $order = array_values($vms); + } + } + fv3_debug_log("readUnraidOrder for type: $type completed. Order: " . json_encode($order)); + return $order; + } diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php index 7cb65a14..e6b91506 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.php @@ -348,176 +348,6 @@ function fv3_without_dead_plus_icons(array $folders): array { return $folders; } - function readUserPrefs(string $type) : string { - global $fv3DockerManDir; - $prefsFilePath = ''; - if($type == 'docker') { $prefsFilePath = "$fv3DockerManDir/userprefs.cfg"; } - elseif($type == 'vm') { $prefsFilePath = "/boot/config/plugins/dynamix.vm.manager/userprefs.cfg"; } - else { return '[]'; } - if(!file_exists($prefsFilePath)) { return '[]'; } - // Deliberate GET side-effect (self-heal on the page-load read, mirroring the - // organizer mirror + rename-backfill pattern): content derives only from - // server-side state, is idempotent, and inserts rather than removes — a - // cross-site-triggered GET can only cause the same heal the next page load would. - fv3_heal_user_prefs($type, $prefsFilePath); - $raw = @file_get_contents($prefsFilePath); - return json_encode(($raw === false ? null : fv3_parse_user_prefs($raw)) ?? []); - } - - // userprefs.cfg's values in Unraid's order (by the number before each =, as its Docker page sorts them); null when the text - // will not parse or holds a value that is not a string (a `n[]=` line) - function fv3_parse_user_prefs(string $raw): ?array { - $parsed = @parse_ini_string($raw); - if (!is_array($parsed) || array_filter($parsed, fn($v) => !is_string($v))) return null; - uksort($parsed, fn($a, $b) => (int)$a <=> (int)$b); - return array_values($parsed); - } - - // userprefs.cfg in the format Unraid writes it, one N="name" line per entry - function fv3_write_user_prefs(string $file, array $entries): bool { - $lines = []; - foreach (array_values($entries) as $i => $name) { $lines[] = $i . '="' . $name . '"'; } - return fv3_atomic_write($file, implode("\n", $lines) . "\n"); - } - - function fv3_order_snapshot_file(string $type): string { - global $configDir; - return "$configDir/order-$type.json"; - } - - // Returns the cleaned list, or null when any non-empty entry breaks the snapshot - // rules. Empty entries are delimiter artifacts (every stock names string ends ';') - // and are dropped, not treated as invalid. The rules exist because a violating - // entry could corrupt an ini line when healed back into userprefs.cfg. - function fv3_sanitize_order_entries(array $entries): ?array { - $clean = []; - foreach ($entries as $e) { - if (!is_string($e)) return null; - $e = trim($e); - if ($e === '') continue; - if (strlen($e) > 256 || strpos($e, '"') !== false || preg_match('/[\x00-\x1f\x7f]/', $e)) return null; - $clean[] = $e; - } - if (count($clean) > 4096) return null; - return $clean; - } - - function saveOrderSnapshot(string $type, array $entries): bool { - $clean = fv3_sanitize_order_entries($entries); - if ($clean === null || empty($clean)) return false; - return fv3_atomic_write(fv3_order_snapshot_file($type), json_encode(['fv3_order_version' => 1, 'entries' => $clean], JSON_PRETTY_PRINT)); - } - - // Snapshot state for export, keeping the tri-state importAll() relies on: - // absent file -> [] (present-empty: source authoritatively has no snapshot, import - // clears the destination); unreadable/malformed -> null (omit the bundle key, import - // leaves the destination untouched); valid -> the wrapped snapshot. - // A snapshot wrapper saveOrderSnapshot could actually have written: version 1 and a - // non-empty entries list that passes sanitization unchanged. Returns the entries or - // null. Shared by export (file contents) and import (bundle contents) so both sides - // apply identical validation — anything else is corrupt/tampered and must be ignored, - // never treated as empty (that would clear a valid destination snapshot on import). - function fv3_validate_order_snapshot(array $data): ?array { - if (($data['fv3_order_version'] ?? null) !== 1 - || !isset($data['entries']) || !is_array($data['entries'])) return null; - $clean = fv3_sanitize_order_entries($data['entries']); - if ($clean === null || empty($clean) || $clean !== array_values($data['entries'])) return null; - return $clean; - } - - function fv3_export_order_snapshot(string $type): ?array { - $path = fv3_order_snapshot_file($type); - if (!file_exists($path)) return []; - $raw = @file_get_contents($path); - $data = ($raw !== false) ? json_decode($raw, true) : null; - if (!is_array($data) || fv3_validate_order_snapshot($data) === null) return null; - return $data; - } - - // Re-insert folder rows into the stock sort prefs from FV3's own order snapshot. - // Fires when prefs has entries but at least one live folder is unpositioned — - // the post-reinstall state, or a folder whose entry went missing. Insert-only — - // existing prefs entries are never reordered or removed, so container order is - // preserved, and already-positioned folders are kept in place and used as anchors. - function fv3_heal_user_prefs(string $type, string $prefsFilePath): void { - global $configDir; - $raw = @file_get_contents($prefsFilePath); - if (!is_string($raw) || $raw === '') return; - $current = fv3_parse_user_prefs($raw); - if (!$current) return; - - $config = fv3_read_json("$configDir/$type.json"); - if (empty($config)) return; - // Prefs and the snapshot store folder rows as 'folder-' placeholders - // (the hidden appname the stock reorder serializes); config keys are raw ids. - $placeholders = []; - foreach (array_keys($config) as $fid) { $placeholders['folder-' . $fid] = true; } - if (empty(array_diff(array_keys($placeholders), $current))) return; - - $snap = fv3_read_json(fv3_order_snapshot_file($type)); - $saved = $snap['entries'] ?? null; - if (!is_array($saved)) return; - - $currentSet = array_flip($current); - // Each unpositioned live folder placeholder maps to the first later snapshot entry still present in prefs (null = append) - $insertBefore = []; - $pending = []; - foreach ($saved as $entry) { - if (!is_string($entry)) continue; - if (isset($placeholders[$entry]) && !isset($currentSet[$entry])) { $pending[] = $entry; continue; } - if (isset($currentSet[$entry])) { - foreach ($pending as $fid) { $insertBefore[$fid] = $entry; } - $pending = []; - } - } - foreach ($pending as $fid) { $insertBefore[$fid] = null; } - if (empty($insertBefore)) return; - - $out = []; - foreach ($current as $name) { - foreach ($insertBefore as $fid => $succ) { - if ($succ === $name) { $out[] = $fid; unset($insertBefore[$fid]); } - } - $out[] = $name; - } - foreach (array_keys($insertBefore) as $fid) { $out[] = $fid; } - - // Stock UserPrefs writes are lockless, so re-check the source right before - // replacing — a concurrent reorder mid-compute aborts the heal (next load retries). - if (@file_get_contents($prefsFilePath) !== $raw) return; - if (fv3_write_user_prefs($prefsFilePath, $out)) { - fv3_debug_log("fv3_heal_user_prefs($type): re-inserted " . (count($out) - count($current)) . " folder position(s)"); - } - } - - function fv3_autostart_file(): string { - global $fv3DockerManDir; - $dockerManPaths = @parse_ini_file("$fv3DockerManDir/dockerMan.cfg") ?: []; - return $dockerManPaths['autostart-file'] ?? "/var/lib/docker/unraid-autostart"; - } - - // null when the file cannot be read: a caller that rebuilds the file from these lines must stop, not write [] - function fv3_read_autostart_lines(string $file): ?array { - $lines = @file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); - return $lines === false ? null : $lines; - } - - function readAutostartConfig(): array { - global $configDir; - $cfg = fv3_read_json_strict("$configDir/autostart.json"); - // Corrupt config fails closed to 'off' (pure stock behaviour, no autostart writes) - // rather than silently flipping a custom/off user to folder mode. - if ($cfg === null) return ['mode' => 'off', 'sequence' => []]; - $mode = $cfg['mode'] ?? 'folder'; - if (!in_array($mode, ['folder', 'custom', 'off'], true)) $mode = 'folder'; - $sequence = []; - foreach ((array)($cfg['sequence'] ?? []) as $name) { - // docker name charset — a crafted config entry must not smuggle markup or newlines into the autostart file - if (is_string($name) && preg_match('/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/', $name)) $sequence[] = $name; - } - return ['mode' => $mode, 'sequence' => array_values(array_unique($sequence))]; - } - // Names of organizer folders FV3 created/manages — user-made native folders are never listed here function readOrganizerRegistry(): array { global $configDir; @@ -543,72 +373,6 @@ function updateOrganizerRegistry(array $names): bool { return fv3_atomic_write("$configDir/organizer-registry.json", json_encode(['folders' => $clean], JSON_PRETTY_PRINT)); } - function updateAutostartConfig(string $mode, array $sequence, array $waits): array { - global $configDir; - if (!in_array($mode, ['folder', 'custom', 'off'], true)) return ['error' => 'Invalid mode']; - $cleanSeq = []; - foreach ($sequence as $name) { - if (is_string($name) && preg_match('/^[a-zA-Z0-9][a-zA-Z0-9_.-]*$/', $name)) $cleanSeq[] = $name; - if (count($cleanSeq) >= 500) break; - } - $cleanSeq = array_values(array_unique($cleanSeq)); - // Read before the write: an unreadable autostart file aborts the save rather than reporting - // success with the wait edits silently dropped - $autoStartFile = fv3_autostart_file(); - $lines = null; - if (!empty($waits)) { - if (file_exists($autoStartFile)) { - // Zeros still have to reach the loop below: that is how a wait is cleared - $lines = fv3_read_autostart_lines($autoStartFile); - if ($lines === null) return ['error' => 'Could not read the autostart file — nothing was saved']; - } elseif (array_filter($waits, static fn($w) => (int)$w > 0)) { - // No file to apply them to; an all-zero map is the empty state and saves normally - return ['error' => 'Could not read the autostart file — nothing was saved']; - } - } - - $ok = fv3_atomic_write("$configDir/autostart.json", json_encode(['mode' => $mode, 'sequence' => $cleanSeq], JSON_PRETTY_PRINT)); - if (!$ok) return ['error' => 'Failed to write autostart config']; - - // Fold wait edits into the live file — a name only matches a line that already has autostart enabled - $waitFailed = null; - if ($lines !== null) { - $changed = false; - foreach ($lines as $i => $line) { - $name = explode(' ', $line, 2)[0]; - if (array_key_exists($name, $waits)) { - $wait = max(0, min(3600, (int)$waits[$name])); - $newLine = rtrim($name . ' ' . ($wait > 0 ? $wait : '')); - if ($newLine !== $line) { $lines[$i] = $newLine; $changed = true; } - } - } - if ($changed && @file_put_contents($autoStartFile, implode("\n", $lines) . "\n", LOCK_EX) === false) { - $waitFailed = 'the wait edits could not be written to the autostart file'; - } - } - - // Re-assert order under the saved mode — saving folder mode instantly restores folder-derived order. - // The mode and sequence are saved either way: wait edits that were not written and a sync that stopped come back as `warning` - $warnings = array_filter([$waitFailed, $mode !== 'off' ? syncContainerOrder('docker') : null]); - return ['success' => true, 'mode' => $mode, 'sequence' => $cleanSeq] + ($warnings ? ['warning' => implode('; ', $warnings)] : []); - } - - // Reorders the existing autostart lines to the saved custom sequence. Waits ride along - // verbatim; enabled-but-unsequenced containers keep their current relative order at the end. - // Returns why the autostart file could not be put in the saved sequence, or null - function fv3_apply_custom_autostart(array $allContainerNames, bool $ctListComplete): ?string { - $autoStartFile = fv3_autostart_file(); - if (!file_exists($autoStartFile)) return null; - $sequence = readAutostartConfig()['sequence']; - $rawLines = fv3_read_autostart_lines($autoStartFile); - if ($rawLines === null) { fv3_debug_log("fv3_apply_custom_autostart: $autoStartFile unreadable, not rewriting"); return 'the autostart file could not be read'; } - $newAutoStart = fv3_reorder_autostart(fv3_prune_stale_autostart($rawLines, $allContainerNames, $ctListComplete), $sequence); - if ($newAutoStart === $rawLines) { return null; } - if (@file_put_contents($autoStartFile, implode("\n", $newAutoStart) . "\n", LOCK_EX) === false) { return 'the autostart file could not be written'; } - fv3_debug_log("fv3_apply_custom_autostart: wrote " . count($newAutoStart) . " entries (" . count($sequence) . " sequenced)"); - return null; - } - // Container names from getDockerContainers(). 'complete' is false when the read is empty // or any entry is unnamed — a degraded list must not drive autostart pruning (#214). // DockerClient echoes its socket error when Docker is not running; buffer it out of the JSON response @@ -638,19 +402,6 @@ function fv3_read_container_names(DockerClient $dockerClient): array { return ['names' => $names, 'complete' => $complete, 'empty' => $empty]; } - // The one definition of "drop autostart entries whose container is gone". A degraded Docker - // read must never prune (#214/#231) — a transient blip would otherwise curtail the file. - function fv3_prune_stale_autostart(array $autoStartLines, array $allContainerNames, bool $ctListComplete): array { - if (!$ctListComplete) return $autoStartLines; - $kept = []; - foreach ($autoStartLines as $line) { - $name = explode(' ', $line, 2)[0]; - if (in_array($name, $allContainerNames, true)) { $kept[] = $line; continue; } - fv3_debug_log("autostart: dropped stale entry '$name' (container no longer exists)"); - } - return $kept; - } - // `folder.view3: ` label claims keyed by container name — getDockerContainers() // carries no Labels, so read the same raw endpoint readInfo() uses. Returns null on a // failed/partial/unnamed read so callers fail closed rather than treat label-assigned @@ -698,373 +449,6 @@ function fv3_read_image_env(string $imageId): ?array { return is_array($env) ? array_values(array_filter($env, 'is_string')) : null; } - // The values of Unraid's saved Docker order (userprefs.cfg): [] when there is none, null when the file will not be read - function fv3_docker_prefs(): ?array { - global $fv3DockerManDir; - $file = "$fv3DockerManDir/userprefs.cfg"; - if (!is_file($file)) { return []; } - $raw = @file_get_contents($file); - return $raw === false ? null : fv3_parse_user_prefs($raw); - } - - // Container names in the order read_unraid_order.php hands the page (readUnraidOrder): saved names in userprefs.cfg - // order, unsaved ones after them as Docker lists them; A-Z when nothing is saved - function fv3_live_order(array $names, array $prefs): array { - if (!$prefs) { usort($names, 'strnatcasecmp'); return $names; } - $saved = array_values(array_unique(array_filter($prefs, function($p) use ($names) { return in_array($p, $names, true); }))); - return array_merge($saved, array_values(array_filter($names, function($n) use ($saved) { return !in_array($n, $saved, true); }))); - } - - // The order docker.js createFolders() draws folders in: the folders userprefs.cfg names, in its order, then the rest in JS key - // order; with nothing saved, A-Z by name - function fv3_folder_walk_order(array $folders, array $prefs): array { - $ids = fv3_js_key_order(array_keys($folders)); - if (!$prefs) { - $name = fn($id) => $folders[$id]['name'] !== '' ? $folders[$id]['name'] : "folder-$id"; - usort($ids, fn($a, $b) => fv3_name_cmp($name($a), $name($b))); - return $ids; - } - $saved = []; - foreach ($prefs as $entry) { - if (str_starts_with($entry, 'folder-') && array_key_exists(substr($entry, 7), $folders)) $saved[] = substr($entry, 7); - } - return array_values(array_unique(array_merge($saved, $ids))); - } - - // Effective membership — explicit > label > regex (issues #46/#55). Single source of - // truth shared by syncContainerOrder and read_membership.php (issue #61). - // $prefs orders each folder's regex and label members as the Docker page lists them (fv3_live_order), and the folders as the - // page draws them, so a container two folders' regexes match goes to the one the page shows it in - function fv3_compute_folder_membership(array $folders, array $allContainerNames, array $ctLabels, array $prefs = []): array { - $live = fv3_live_order($allContainerNames, $prefs); - // One malformed entry is dropped or filled in, not allowed to abort every folder's sync - $folders = fv3_normalize_folders($folders); - $folderNameSet = []; - foreach ($folders as $folder) { - if (isset($folder['name'])) { $folderNameSet[$folder['name']] = true; } - } - $folderContainers = []; - $folderNames = []; - $assignedContainers = []; - $explicitMembers = []; - foreach ($folders as $folder) { - $explicitMembers = array_merge($explicitMembers, $folder['containers'] ?? []); - } - $explicitAssigned = $explicitMembers; - foreach ($ctLabels as $ctName => $ctLabel) { - if (isset($folderNameSet[$ctLabel])) { $explicitAssigned[] = (string)$ctName; } - } - foreach (fv3_folder_walk_order($folders, $prefs) as $folderId) { - $folder = $folders[$folderId]; - $members = $folder['containers'] ?? []; - // is_string + trim, not empty(): empty("0") is true in PHP, so a regex of "0" was - // silently dropped while docker.js applied it. The type check mirrors docker.js and - // keeps a non-string regex from fataling trim() (TypeError on PHP 8). - if (is_string($folder['regex'] ?? null) && trim($folder['regex']) !== '') { - $regex = '/' . str_replace('/', '\/', $folder['regex']) . '/'; - foreach ($live as $name) { - if (@preg_match($regex, $name) && !in_array($name, $members, true) && !in_array($name, $explicitAssigned, true)) { - $members[] = $name; - } - } - } - // Explicit containers[] entries anywhere win over a label claim (issue #55) - foreach ($live as $ctName) { - if (($ctLabels[$ctName] ?? null) === $folder['name'] && !in_array($ctName, $members, true) && !in_array($ctName, $explicitMembers, true)) { - $members[] = $ctName; - } - } - $members = array_values(array_filter($members, function($m) use ($allContainerNames, $assignedContainers) { - return in_array($m, $allContainerNames, true) && !in_array($m, $assignedContainers, true); - })); - $folderContainers["folder-$folderId"] = $members; - $folderNames["folder-$folderId"] = $folder['name'] ?? "folder-$folderId"; - $assignedContainers = array_merge($assignedContainers, $members); - } - return ['containers' => $folderContainers, 'names' => $folderNames, 'assigned' => $assignedContainers]; - } - - // The order JS walks an object's keys in: index-like keys ("7", not "07") first and ascending, then the rest as written - function fv3_js_key_order(array $keys): array { - $keys = array_map('strval', $keys); - $index = array_values(array_filter($keys, function($k) { return preg_match('/^(0|[1-9]\d{0,9})$/D', $k) === 1 && (int)$k < 4294967295; })); - sort($index, SORT_NUMERIC); - return array_merge($index, array_values(array_diff($keys, $index))); - } - - // A name as the Docker page sorts it with nothing saved: trimmed of what JavaScript's trim() removes - function fv3_js_trim(string $s): string { - return preg_replace('/^[\x{9}-\x{D}\x{20}\x{A0}\x{1680}\x{2000}-\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}\x{FEFF}]+|' - . '[\x{9}-\x{D}\x{20}\x{A0}\x{1680}\x{2000}-\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}\x{FEFF}]+$/u', '', $s) ?? trim($s); - } - - // The browser's name order (localeCompare(b, undefined, {numeric: true, sensitivity: 'base'})) for ASCII: space and punctuation in - // ICU's order, numbers by value, letters in any case. Other characters follow z by code point, so accents can differ - function fv3_name_cmp(string $a, string $b): int { - static $punct = null; - $punct ??= array_flip(str_split(" _-,;:!?.'\"()[]{}@*/\\&#%`^+<=>|~$")); - $tokens = static function (string $s) use ($punct): ?array { - if (preg_match_all('/[0-9]+|./su', $s, $m) === false) return null; - return array_map(static function (string $t) use ($punct): array { - if (ctype_digit($t)) return [100, ltrim($t, '0')]; - $c = strtolower($t); - if (isset($punct[$c])) return [$punct[$c], '']; - return strlen($c) === 1 && $c >= 'a' && $c <= 'z' ? [200 + ord($c), ''] : [1000, $t]; - }, $m[0]); - }; - $ta = $tokens($a); - $tb = $tokens($b); - if ($ta === null || $tb === null) return strnatcasecmp($a, $b); - foreach ($ta as $i => [$ga, $ka]) { - if (!isset($tb[$i])) return 1; - [$gb, $kb] = $tb[$i]; - if ($ga !== $gb) return $ga <=> $gb; - $c = $ga === 100 ? (strlen($ka) <=> strlen($kb) ?: strcmp($ka, $kb)) : strcmp($ka, $kb); - if ($c !== 0) return $c <=> 0; - } - return count($ta) < count($tb) ? -1 : 0; - } - - // The Docker page's order, top-down, as container names and folder placeholders, members before their folder. - // $prefs is userprefs.cfg's values; with none it is A-Z by name as createFolders() sorts it (fv3_name_cmp: accents can differ) - function fv3_page_order(array $membership, array $allContainerNames, array $prefs): array { - $folderContainers = $membership['containers']; - $assigned = $membership['assigned']; - if (!$prefs) { - $entries = []; - foreach ($folderContainers as $placeholder => $_members) { - // The page's last pass sorts the rows by the trimmed name it shows (docker.js createFolders) - $entries[] = ['key' => $placeholder, 'name' => fv3_js_trim($membership['names'][$placeholder])]; - } - foreach ($allContainerNames as $name) { - if (!in_array($name, $assigned, true)) { $entries[] = ['key' => $name, 'name' => $name]; } - } - usort($entries, function($a, $b) { return fv3_name_cmp($a['name'], $b['name']); }); - $prefs = array_column($entries, 'key'); - } - $placed = []; - $seen = []; - foreach ($prefs as $item) { - if (isset($folderContainers[$item])) { - foreach ($folderContainers[$item] as $ct) { - if (!in_array($ct, $seen, true)) { $placed[] = $ct; $seen[] = $ct; } - } - $placed[] = $item; - $seen[] = $item; - } elseif (in_array($item, $assigned, true)) { - continue; - } elseif (in_array($item, $allContainerNames, true) && !in_array($item, $seen, true)) { - $placed[] = $item; - $seen[] = $item; - } - } - // Not in userprefs.cfg yet: docker.js unshifts each such folder (the last one it meets ends on top); new containers sit below them - $new = []; - $ids = array_map(function($placeholder) { return substr($placeholder, 7); }, array_keys($folderContainers)); - foreach (array_reverse(fv3_js_key_order($ids)) as $id) { - $placeholder = "folder-$id"; - if (in_array($placeholder, $seen, true)) { continue; } - foreach ($folderContainers[$placeholder] as $ct) { $new[] = $ct; } - $new[] = $placeholder; - } - $loose = array_values(array_filter($allContainerNames, function($name) use ($seen, $assigned) { - return !in_array($name, $seen, true) && !in_array($name, $assigned, true); - })); - usort($loose, 'strnatcasecmp'); - return array_merge($new, $loose, $placed); - } - - // $prefs with each folder's members together in its order, on the side of its entry a neighbour shows (a drag: after, FV3's writers: - // before; after by default). A folder with no entry, and every other entry, stay as they are - function fv3_prefs_with_folder_members(array $prefs, array $membership): array { - $blocks = []; - foreach ($membership['containers'] as $placeholder => $members) { - $at = array_search($placeholder, $prefs, true); - if ($at === false || !$members) continue; - $after = isset($prefs[$at + 1]) && in_array($prefs[$at + 1], $members, true); - $before = !$after && $at > 0 && in_array($prefs[$at - 1], $members, true); - $blocks[$placeholder] = ['members' => $members, 'before' => $before]; - } - if (!$blocks) return $prefs; - $moved = array_merge(...array_column($blocks, 'members')); - $out = []; - foreach ($prefs as $entry) { - if (in_array($entry, $moved, true)) continue; - if (!isset($blocks[$entry])) { $out[] = $entry; continue; } - ['members' => $members, 'before' => $before] = $blocks[$entry]; - unset($blocks[$entry]); // a repeated entry for the same folder keeps its place, its members come once - array_push($out, ...($before ? [...$members, $entry] : [$entry, ...$members])); - } - return $out; - } - - // Keeps userprefs.cfg's containers with their folders, so what reads it (Unraid's Start all and autostart sort, other plugins) - // follows the page. Only a saved order is changed: creating one switches Unraid off its A-Z order (#112). Returns why it failed - function fv3_sync_user_prefs(array $prefs, array $membership): ?string { - global $fv3DockerManDir; - if (!$prefs) return null; - $updated = fv3_prefs_with_folder_members($prefs, $membership); - if ($updated === $prefs) return null; - $updated = fv3_sanitize_order_entries($updated); - if ($updated === null) return "Unraid's saved Docker order (userprefs.cfg) holds a name that cannot be written back"; - // Stock UserPrefs writes take no lock: an order saved since the read above is kept as it is - $now = fv3_docker_prefs(); - if ($now === null) return "Unraid's saved Docker order (userprefs.cfg) could not be read"; - if ($now !== $prefs) { fv3_debug_log("fv3_sync_user_prefs: userprefs.cfg changed meanwhile, left as it is"); return null; } - if (!fv3_write_user_prefs("$fv3DockerManDir/userprefs.cfg", $updated)) { - fv3_debug_log("fv3_sync_user_prefs: userprefs.cfg could not be written"); - return "Unraid's saved Docker order (userprefs.cfg) could not be updated"; - } - // FV3's own copy, which the heal restores from after a reinstall - if (!saveOrderSnapshot('docker', $updated)) fv3_error_log('fv3_sync_user_prefs', 'the order snapshot could not be written'); - fv3_debug_log("fv3_sync_user_prefs: wrote userprefs.cfg with " . count($updated) . " entries"); - return null; - } - - // Autostart lines ("name" or "name delay") in $order's sequence, each once; lines $order does not name follow, in file order - function fv3_reorder_autostart(array $lines, array $order): array { - $byName = []; - foreach ($lines as $line) { $byName[explode(' ', $line, 2)[0]] = $line; } - $ordered = []; - foreach ($order as $name) { - if (isset($byName[$name])) { $ordered[] = $byName[$name]; unset($byName[$name]); } - } - return array_merge($ordered, array_values($byName)); - } - - // Returns why userprefs.cfg or the autostart file could not be put in order (a file or a Docker read it needs failed), else null. - // An empty container list is only logged: a server with no containers, or with Docker off, has nothing to report - function syncContainerOrder(string $type): ?string { - fv3_debug_log("syncContainerOrder called for type: $type"); - if ($type !== 'docker') { return null; } - - $autostartMode = readAutostartConfig()['mode']; - $dockerClient = new DockerClient(); - $ctNames = fv3_read_container_names($dockerClient); - // 'custom' = the Autostart tab's saved sequence orders the autostart file; 'off' = FV3 never reorders it - $failed = array_filter([ - $autostartMode === 'custom' ? fv3_apply_custom_autostart($ctNames['names'], $ctNames['complete']) : null, - ...fv3_sync_page_order($dockerClient, $ctNames, $autostartMode === 'folder'), - ]); - return $failed ? implode('; ', $failed) : null; - } - - // Puts a saved userprefs.cfg's containers with their folders and, with $autostart, the autostart file in the order FV3 renders: - // top to bottom, folder members in their editor order. Returns why each part could not be done, [] when all went through - function fv3_sync_page_order(DockerClient $dockerClient, array $ctNames, bool $autostart): array { - global $configDir; - $stop = function (string $why): array { fv3_debug_log("syncContainerOrder: $why, aborting before write"); return [$why]; }; - $allContainerNames = $ctNames['names']; - // The page's order needs the WHOLE list: a container missing from a partial read would be put out of place in either file - if (!$ctNames['complete']) { - if ($ctNames['empty']) { fv3_debug_log("syncContainerOrder: no containers, nothing to sync"); return []; } - return $stop("Docker's container list could not be read"); - } - - // No docker.json, or no config folder at all (deleted by hand under an open tab), is "no folders": never a stop - $folders = fv3_read_json_strict("$configDir/docker.json"); - // Corrupt folder config must not be read as no folders - if ($folders === null) { return $stop('the folder config could not be read'); } - - $ctLabels = fv3_read_container_labels($dockerClient, $allContainerNames); - // Fail closed: without label claims, label-assigned containers would be written back out as unassigned - if ($ctLabels === null) { return $stop('the container labels could not be read'); } - $prefs = fv3_docker_prefs(); - // The page's order cannot be worked out then, so both files stay as they are - if ($prefs === null) { return $stop("Unraid's saved Docker order (userprefs.cfg) could not be read"); } - $membership = fv3_compute_folder_membership($folders, $allContainerNames, $ctLabels, $prefs); - // Each file is put in order on its own: one that fails does not hold the other back - return array_values(array_filter([ - fv3_sync_user_prefs($prefs, $membership), - $autostart ? fv3_sync_autostart_order(fv3_page_order($membership, $allContainerNames, $prefs), $allContainerNames) : null, - ])); - } - - // The autostart file's lines in $order's sequence, entries for removed containers dropped ($names must be Docker's whole list, - // #214). Returns why it could not be put in order, else null - function fv3_sync_autostart_order(array $order, array $names): ?string { - $autoStartFile = fv3_autostart_file(); - if (!file_exists($autoStartFile)) return null; - $rawLines = fv3_read_autostart_lines($autoStartFile); - if ($rawLines === null) return 'the autostart file could not be read'; - $newAutoStart = fv3_reorder_autostart(fv3_prune_stale_autostart($rawLines, $names, true), $order); - if ($newAutoStart === $rawLines) { fv3_debug_log("syncContainerOrder: autostart file already in order"); return null; } - if (@file_put_contents($autoStartFile, implode("\n", $newAutoStart) . "\n", LOCK_EX) === false) return 'the autostart file could not be written'; - fv3_debug_log("syncContainerOrder: wrote autostart file with " . count($newAutoStart) . " entries"); - return null; - } - - // Creates Unraid's saved Docker order on a server with none, after an import or a restore: $first's entries (placeholders, names) - // first. Its other writers: the heal and fv3_place_imported_docker_folders. Returns why it stopped, or null: also when one is saved - function fv3_create_docker_order(array $first): ?string { - global $configDir, $fv3DockerManDir; - if (!$first) return null; - $prefs = fv3_docker_prefs(); - if ($prefs === null) return "Unraid's saved Docker order (userprefs.cfg) could not be read"; - if ($prefs) return null; - $dockerClient = new DockerClient(); - $ctNames = fv3_read_container_names($dockerClient); - // Docker stopped and no containers both answer []. An order of folders alone would put every container above them once Docker lists them - if ($ctNames['empty']) return 'Docker is not running or lists no containers'; - if (!$ctNames['complete']) return "Docker's container list could not be read"; - $names = $ctNames['names']; - $folders = fv3_read_json_strict("$configDir/docker.json"); - if ($folders === null) return 'the folder config could not be read'; - $labels = fv3_read_container_labels($dockerClient, $names); - if ($labels === null) return 'the container labels could not be read'; - // A restore's order copy names containers too: regex and label members keep its order, the rest Docker's list order (A-Z with none) - $membership = fv3_compute_folder_membership($folders, $names, $labels, array_values(array_filter($first, fn($e) => is_string($e) && in_array($e, $names, true)))); - // Each folder after its members, as the page lists them; the rest as the page draws it with nothing saved (A-Z) - $out = []; - foreach ($first as $entry) { - if (!is_string($entry)) continue; - if (isset($membership['containers'][$entry])) { - array_push($out, ...$membership['containers'][$entry]); - $out[] = $entry; - } elseif (in_array($entry, $names, true) && !in_array($entry, $membership['assigned'], true)) { - $out[] = $entry; - } - } - $out = fv3_sanitize_order_entries(array_values(array_unique(array_merge($out, fv3_page_order($membership, $names, []))))); - if ($out === null) return 'a name cannot be written to userprefs.cfg'; - // Stock UserPrefs writes take no lock: an order Unraid saved meanwhile wins; one that cannot be read now is said - $now = fv3_docker_prefs(); - if ($now === null) return "Unraid's saved Docker order (userprefs.cfg) could not be read"; - if ($now) return null; - if (!is_dir($fv3DockerManDir) || !fv3_write_user_prefs("$fv3DockerManDir/userprefs.cfg", $out)) { - return "Unraid's saved Docker order (userprefs.cfg) could not be written"; - } - // FV3's own copy, which the heal restores from after a reinstall - if (!saveOrderSnapshot('docker', $out)) fv3_error_log('fv3_create_docker_order', 'the order snapshot could not be written'); - return null; - } - - // After an import: the new Docker folders ($first, placeholders in the file's order) go on top of Unraid's saved order, insert-only, - // so the page draws them and lets them claim containers top-first; with no saved order one is created. Returns why it stopped, or null - function fv3_place_imported_docker_folders(array $first): ?string { - global $configDir, $fv3DockerManDir; - $file = "$fv3DockerManDir/userprefs.cfg"; - $read = fn() => is_file($file) ? @file_get_contents($file) : ''; - for ($try = 0; $try < 3; $try++) { - $raw = $read(); - $current = $raw === false ? null : fv3_parse_user_prefs($raw); - if ($current === null) return "Unraid's saved Docker order (userprefs.cfg) could not be read"; - if (!$current) return fv3_create_docker_order($first); - $folders = fv3_read_json_strict("$configDir/docker.json"); - if ($folders === null) return 'the folder config could not be read'; - $new = array_values(array_unique(array_filter($first, fn($e) => is_string($e) && str_starts_with($e, 'folder-') - && array_key_exists(substr($e, 7), $folders) && !in_array($e, $current, true)))); - if (!$new) return null; - $out = array_merge($new, $current); - // Stock UserPrefs writes take no lock: an order Unraid saved meanwhile is read again - if ($read() !== $raw) continue; - if (!fv3_write_user_prefs($file, $out)) return "Unraid's saved Docker order (userprefs.cfg) could not be written"; - if (!saveOrderSnapshot('docker', $out)) fv3_error_log('fv3_place_imported_docker_folders', 'the order snapshot could not be written'); - return null; - } - return "Unraid's saved Docker order (userprefs.cfg) kept changing during the import"; - } - function readSettings() : string { global $configDir; $raw = @file_get_contents("$configDir/settings.json"); @@ -1241,6 +625,7 @@ function updateSettingsBatch(array $settings) : void { require_once(__DIR__ . '/themes.php'); require_once(__DIR__ . '/lib.foreign_import.php'); require_once(__DIR__ . '/lib.folders.php'); + require_once(__DIR__ . '/lib.order.php'); function exportAll() : array { global $configDir; @@ -2054,51 +1439,6 @@ function readInfo(string $type): array { return $info; } - function readUnraidOrder(string $type): array { - fv3_debug_log("readUnraidOrder called for type: $type"); - $user_prefs_path = "/boot/config/plugins"; - $order = []; - if ($type == "docker") { - $dockerClient = new DockerClient(); - // A userprefs.cfg that will not parse lists A-Z, as one that is absent does - $order = fv3_live_order(array_column($dockerClient->getDockerContainers() ?: [], 'Name'), fv3_docker_prefs() ?? []); - - } elseif ($type == "vm") { - if (!fv3_require_libvirt_helpers()) { fv3_debug_log("VM Order: libvirt_helpers.php not available."); return []; } - global $lv; - if (!isset($lv)) { $lv = new Libvirt(); if (!$lv->connect()) { fv3_debug_log("VM Order: Libvirt connection failed."); return []; } } - - $prefs_file = "$user_prefs_path/dynamix.vm.manager/userprefs.cfg"; - $vms = $lv->get_domains(); - - if (!empty($vms)) { - if (file_exists($prefs_file)) { - $prefs_ini = @parse_ini_file($prefs_file); - if ($prefs_ini) { - $prefs_array = array_values($prefs_ini); - $sort = []; - $count_vms = count($vms); - foreach ($vms as $vm_name) { - $search = array_search($vm_name, $prefs_array); - $sort[] = ($search === false) ? ($count_vms + count($sort) + 1) : $search; - } - if (!empty($sort)) { - @array_multisort($sort, SORT_NUMERIC, $vms); - } else { - natcasesort($vms); - } - } else { - natcasesort($vms); - } - } else { - natcasesort($vms); - } - $order = array_values($vms); - } - } - fv3_debug_log("readUnraidOrder for type: $type completed. Order: " . json_encode($order)); - return $order; - } function pathToMultiDimArray($dir) { $final = []; try { From 9cd4d47ba479974318c860f9fb56c0e1acc6f9e5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 16 Nov 2026 10:08:42 +0000 Subject: [PATCH 65/72] chore(deps): lock file maintenance (#197) Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/scripts/package-lock.json | 40 +++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/scripts/package-lock.json b/.github/scripts/package-lock.json index 92812c63..5338d543 100644 --- a/.github/scripts/package-lock.json +++ b/.github/scripts/package-lock.json @@ -202,9 +202,9 @@ } }, "node_modules/parse5": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.1.0.tgz", - "integrity": "sha512-sq3qBFpee5jeocbFbO48VHlGr8sT7mbXS0vxlKN6sottBtJzrOG3998sr0llSZcQAGgfpdmEYAIZE0P9z0dE8w==", + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.1.1.tgz", + "integrity": "sha512-EcR/6WDcU7b2N3vQSxKALCk9lXGtUMQxXio008OEMBE0kavu/7JLfBEeFPzi43nMqVDSbEn3QCK+BMCc9zO//w==", "dev": true, "license": "MIT", "dependencies": { @@ -215,13 +215,13 @@ } }, "node_modules/parse5-parser-stream": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-8.1.0.tgz", - "integrity": "sha512-58MPfNTA+DsIzro41rU94xghnu/h2N4yEPdPdGPlZVHM/QvA5jlVGYVo7IzlHbFLHYx3cZUnr9s9HBrA0tEYyw==", + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/parse5-parser-stream/-/parse5-parser-stream-8.1.1.tgz", + "integrity": "sha512-hMcVbbUJcQmP8rURWUdYrT1flRiBiBVjq/RYGguJpDUgIXSqdYKlE0CxthmdMWoSlBAuL5bUBa73g0pttSy7Hw==", "dev": true, "license": "MIT", "dependencies": { - "parse5": "^8.0.0" + "parse5": "^8.1.1" }, "funding": { "url": "https://github.com/inikulin/parse5?sponsor=1" @@ -251,29 +251,29 @@ } }, "node_modules/tldts": { - "version": "7.4.19", - "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.4.19.tgz", - "integrity": "sha512-48dH6aSpQnpbzDUc4vIQZ1VjB8tkK+e8c1yx05/SZK+rkssgjEOlxDd/yU8/a4vGYQ9vRgJr9dwMq9TJ0b3X2Q==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.5.4.tgz", + "integrity": "sha512-Rn2ABgjHZrA+jzqom5zhxA0hLohzYrIgfCPyhpTUxqsUrcsBYuab49LseR9waB9Jr8/MxdodvMHA91oRiGLO3Q==", "dev": true, "license": "MIT", "dependencies": { - "tldts-core": "^7.4.19" + "tldts-core": "^7.5.4" }, "bin": { "tldts": "bin/cli.js" } }, "node_modules/tldts-core": { - "version": "7.4.20", - "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.4.20.tgz", - "integrity": "sha512-C630TWXZCZmLq0F2bW4QqwnaaxCQ/svpAqvJwnC4JvgEM5ohhBnGsEzTLSOXcN+xjz+kEaHS5uoWIw2klnqd0A==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.5.4.tgz", + "integrity": "sha512-9+4zWtKEDZ3V3FoZ1B97rv+5z5oqp7yeXGVze3CxgQ+CJro9do9DCPD00wxstYZDXDMXsurkBerFfiB6GYtPbA==", "dev": true, "license": "MIT" }, "node_modules/tough-cookie": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.2.tgz", - "integrity": "sha512-exgYmnmL/sJpR3upZfXG5PoatXQii55xAiXGXzY+sROLZ/Y+SLcp9PgJNI9Vz37HpQ74WvDcLT8eqm+kV3FzrA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.1.0.tgz", + "integrity": "sha512-FTxc8u8Kl2tz0Lat1u8ksvcy8bwHRyEMawwTWybo51JqaC6O7SvfuhAKg+Ld6VqyIe2QRJBzY9HA7y2WyFRT2w==", "dev": true, "license": "BSD-3-Clause", "dependencies": { @@ -297,9 +297,9 @@ } }, "node_modules/undici": { - "version": "8.12.3", - "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.3.tgz", - "integrity": "sha512-+fdndUTwBP86cVjihTp21hZHo7d6oj1c/47XPA3lL8mM0XHs+C4EkcjmgRsFnFk2f/UONGDy9ItBItmXsLOQHw==", + "version": "8.12.4", + "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.4.tgz", + "integrity": "sha512-8Mx+uNKKER2bA4AdtedkqRbwUCIJFr2nJckXRe5yrDqzePqwLP7VNcctN8/XdmDSbF7mS+jJKIszlL+vbam1VA==", "dev": true, "license": "MIT", "engines": { From e4e25d153829db4849831e47ae136f460b5efc6b Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Mon, 16 Nov 2026 18:23:59 +0800 Subject: [PATCH 66/72] test: name_order_test.js requires the real lib.order.php; pointers follow the move The watcher's UserPrefs.php contract and lib.php's require block now point at lib.order.php, whose header names the VM order too. --- .github/scripts/name_order_test.js | 9 +++++---- .github/scripts/preview_pages_harness.js | 2 +- .github/unraid-watch/watch.json | 2 +- .../emhttp/plugins/folder.view3/server/lib.order.php | 4 ++-- .../usr/local/emhttp/plugins/folder.view3/server/lib.php | 1 + 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/scripts/name_order_test.js b/.github/scripts/name_order_test.js index 43184cc8..26061e62 100644 --- a/.github/scripts/name_order_test.js +++ b/.github/scripts/name_order_test.js @@ -1,12 +1,13 @@ // node .github/scripts/name_order_test.js — the server's fv3_name_cmp() sorts names as the pages do in the browser // (localeCompare(b, undefined, {numeric: true, sensitivity: 'base'})): the shipped PHP function against node's ICU on the same names (needs php) 'use strict'; +const path = require('path'); const { execFileSync } = require('child_process'); -const { check, done, read } = require('./preview_pages_harness.js'); +const { check, done, plugin } = require('./preview_pages_harness.js'); -// The shipped function, taken from lib.order.php as written -const fn = read('server/lib.order.php').match(/^ {4}function fv3_name_cmp\([\s\S]*?\n {4}}\n/m)[0]; -const phpSort = (names) => JSON.parse(execFileSync('php', ['-r', `${fn} $l = json_decode(stream_get_contents(STDIN), true); usort($l, 'fv3_name_cmp'); echo json_encode($l);`], +// The shipped lib.order.php, required whole: it defines functions only +const phpSort = (names) => JSON.parse(execFileSync('php', ['-r', `require $argv[1]; $l = json_decode(stream_get_contents(STDIN), true); usort($l, 'fv3_name_cmp'); echo json_encode($l);`, + path.join(plugin, 'server/lib.order.php')], { input: JSON.stringify(names), encoding: 'utf8' })); const browserSort = (names) => names.slice().sort((a, b) => a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' })); diff --git a/.github/scripts/preview_pages_harness.js b/.github/scripts/preview_pages_harness.js index 88847ea4..0f094b0e 100644 --- a/.github/scripts/preview_pages_harness.js +++ b/.github/scripts/preview_pages_harness.js @@ -368,4 +368,4 @@ const phpServer = (label, { containers = [] } = {}) => { return { config, server, cleanup: () => fs.rmSync(tmp, { recursive: true, force: true }) }; }; -module.exports = { makePage, drawDocker, drawVms, fakeXhr, scriptHelpers, check, done, flush, read, phpServer, FOLDER_SETTINGS }; +module.exports = { makePage, drawDocker, drawVms, fakeXhr, scriptHelpers, check, done, flush, read, phpServer, plugin, FOLDER_SETTINGS }; diff --git a/.github/unraid-watch/watch.json b/.github/unraid-watch/watch.json index fb35d8c5..ab9b5fb4 100644 --- a/.github/unraid-watch/watch.json +++ b/.github/unraid-watch/watch.json @@ -67,7 +67,7 @@ {"path": "emhttp/plugins/dynamix.vm.manager/include/VMajax.php", "match": "\\['error' => ", "why": "answers a refused VM action in `error` (shared.js fv3ActionAnswer)"}, {"path": "emhttp/plugins/dynamix.docker.manager/include/UserPrefs.php", "match": "\\$save\\[\\] = \\$index\\[\\$i\\+\\+\\]\\.\"=\\\\\"\"\\.\\$name\\.\"\\\\\"\"", - "why": "saves the Docker order as N=\"name\" lines, the format the plugin reads and inserts into (lib.php fv3_parse_user_prefs)"} + "why": "saves the Docker order as N=\"name\" lines, the format the plugin reads and inserts into (lib.order.php fv3_parse_user_prefs)"} ], "styles": { "themes": ["azure", "black", "gray", "white"], diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.order.php b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.order.php index 3216d3b7..9d94d466 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.order.php +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.order.php @@ -1,6 +1,6 @@ Date: Mon, 16 Nov 2026 18:27:56 +0800 Subject: [PATCH 67/72] style: trim lib.order.php's moved comment blocks to two lines Seven blocks ran three to nine lines. Each keeps its warning or pointer; the tri-state note moves above fv3_export_order_snapshot, the function it describes. No code line changes. --- .../plugins/folder.view3/server/lib.order.php | 48 +++++++------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.order.php b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.order.php index 9d94d466..33d031ac 100644 --- a/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.order.php +++ b/src/folder.view3/usr/local/emhttp/plugins/folder.view3/server/lib.order.php @@ -9,10 +9,8 @@ function readUserPrefs(string $type) : string { elseif($type == 'vm') { $prefsFilePath = "/boot/config/plugins/dynamix.vm.manager/userprefs.cfg"; } else { return '[]'; } if(!file_exists($prefsFilePath)) { return '[]'; } - // Deliberate GET side-effect (self-heal on the page-load read, mirroring the - // organizer mirror + rename-backfill pattern): content derives only from - // server-side state, is idempotent, and inserts rather than removes — a - // cross-site-triggered GET can only cause the same heal the next page load would. + // A deliberate GET side effect: the heal derives only from server-side state and only inserts, so a cross-site GET does no + // more than the next page load would fv3_heal_user_prefs($type, $prefsFilePath); $raw = @file_get_contents($prefsFilePath); return json_encode(($raw === false ? null : fv3_parse_user_prefs($raw)) ?? []); @@ -39,10 +37,8 @@ function fv3_order_snapshot_file(string $type): string { return "$configDir/order-$type.json"; } - // Returns the cleaned list, or null when any non-empty entry breaks the snapshot - // rules. Empty entries are delimiter artifacts (every stock names string ends ';') - // and are dropped, not treated as invalid. The rules exist because a violating - // entry could corrupt an ini line when healed back into userprefs.cfg. + // The cleaned list, or null when an entry breaks the rules that keep healed userprefs.cfg lines sound (a string, at most 256 + // bytes, no quote or control character; at most 4096 entries). Empty ones (every stock names string ends ';') are dropped function fv3_sanitize_order_entries(array $entries): ?array { $clean = []; foreach ($entries as $e) { @@ -62,15 +58,8 @@ function saveOrderSnapshot(string $type, array $entries): bool { return fv3_atomic_write(fv3_order_snapshot_file($type), json_encode(['fv3_order_version' => 1, 'entries' => $clean], JSON_PRETTY_PRINT)); } - // Snapshot state for export, keeping the tri-state importAll() relies on: - // absent file -> [] (present-empty: source authoritatively has no snapshot, import - // clears the destination); unreadable/malformed -> null (omit the bundle key, import - // leaves the destination untouched); valid -> the wrapped snapshot. - // A snapshot wrapper saveOrderSnapshot could actually have written: version 1 and a - // non-empty entries list that passes sanitization unchanged. Returns the entries or - // null. Shared by export (file contents) and import (bundle contents) so both sides - // apply identical validation — anything else is corrupt/tampered and must be ignored, - // never treated as empty (that would clear a valid destination snapshot on import). + // The entries of a wrapper saveOrderSnapshot could have written (version 1, non-empty entries that sanitize unchanged), else null: export + // and import share it, and anything else must be ignored, never read as empty (import would clear a valid snapshot) function fv3_validate_order_snapshot(array $data): ?array { if (($data['fv3_order_version'] ?? null) !== 1 || !isset($data['entries']) || !is_array($data['entries'])) return null; @@ -79,6 +68,8 @@ function fv3_validate_order_snapshot(array $data): ?array { return $clean; } + // The tri-state importAll() relies on: no file -> [] (import clears the destination), unreadable or malformed -> null (import + // leaves it alone), valid -> the wrapped snapshot function fv3_export_order_snapshot(string $type): ?array { $path = fv3_order_snapshot_file($type); if (!file_exists($path)) return []; @@ -88,11 +79,8 @@ function fv3_export_order_snapshot(string $type): ?array { return $data; } - // Re-insert folder rows into the stock sort prefs from FV3's own order snapshot. - // Fires when prefs has entries but at least one live folder is unpositioned — - // the post-reinstall state, or a folder whose entry went missing. Insert-only — - // existing prefs entries are never reordered or removed, so container order is - // preserved, and already-positioned folders are kept in place and used as anchors. + // Puts live folders the saved order lacks (after a reinstall, or a lost entry) back where FV3's snapshot had them. Insert-only: + // existing entries keep their place and order function fv3_heal_user_prefs(string $type, string $prefsFilePath): void { global $configDir; $raw = @file_get_contents($prefsFilePath); @@ -222,9 +210,8 @@ function updateAutostartConfig(string $mode, array $sequence, array $waits): arr return ['success' => true, 'mode' => $mode, 'sequence' => $cleanSeq] + ($warnings ? ['warning' => implode('; ', $warnings)] : []); } - // Reorders the existing autostart lines to the saved custom sequence. Waits ride along - // verbatim; enabled-but-unsequenced containers keep their current relative order at the end. - // Returns why the autostart file could not be put in the saved sequence, or null + // The autostart lines in the saved custom sequence, waits kept; enabled containers it does not name keep their order at the end. + // Returns why the autostart file could not be put in that sequence, or null function fv3_apply_custom_autostart(array $allContainerNames, bool $ctListComplete): ?string { $autoStartFile = fv3_autostart_file(); if (!file_exists($autoStartFile)) return null; @@ -284,10 +271,8 @@ function fv3_folder_walk_order(array $folders, array $prefs): array { return array_values(array_unique(array_merge($saved, $ids))); } - // Effective membership — explicit > label > regex (issues #46/#55). Single source of - // truth shared by syncContainerOrder and read_membership.php (issue #61). - // $prefs orders each folder's regex and label members as the Docker page lists them (fv3_live_order), and the folders as the - // page draws them, so a container two folders' regexes match goes to the one the page shows it in + // Membership, explicit > label > regex (#46/#55), for syncContainerOrder and read_membership.php alike (#61). $prefs orders regex + // and label members as the page lists them (fv3_live_order), and folders as it draws them: of two regex matches, the first drawn wins function fv3_compute_folder_membership(array $folders, array $allContainerNames, array $ctLabels, array $prefs = []): array { $live = fv3_live_order($allContainerNames, $prefs); // One malformed entry is dropped or filled in, not allowed to abort every folder's sync @@ -310,9 +295,8 @@ function fv3_compute_folder_membership(array $folders, array $allContainerNames, foreach (fv3_folder_walk_order($folders, $prefs) as $folderId) { $folder = $folders[$folderId]; $members = $folder['containers'] ?? []; - // is_string + trim, not empty(): empty("0") is true in PHP, so a regex of "0" was - // silently dropped while docker.js applied it. The type check mirrors docker.js and - // keeps a non-string regex from fataling trim() (TypeError on PHP 8). + // is_string + trim, not empty(): empty("0") is true, so a regex of "0" was dropped while docker.js applied it; the type + // check mirrors docker.js and keeps a non-string regex from fataling trim() if (is_string($folder['regex'] ?? null) && trim($folder['regex']) !== '') { $regex = '/' . str_replace('/', '\/', $folder['regex']) . '/'; foreach ($live as $name) { From f699597e23b3bbf21c6407cd1acdf521ff7fe999 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Mon, 16 Nov 2026 11:25:49 +0000 Subject: [PATCH 68/72] chore(beta): release changelog Release-Synced: a13f213e13ef63127ade7ec1724a03d80619ca1b --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98e8ed12..59174fb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache if the page doesn't display correctly — before submitting a debug .json. +## Unreleased + +- fix: a container two folders' regexes match goes to the folder the page draws first +- fix: Off tooltip says Unraid starts in the autostart file's order +- fix: save a folder's members when none were saved yet; Off never reorders +- fix: regroup userprefs.cfg in every autostart mode and on page load +- fix: keep a saved userprefs.cfg's containers with their folders +- refactor: move the container order code from lib.php into lib.order.php + ## 2026.11.16.1 (beta) - The error log no longer lists Unraid's own PHP warnings as FolderView3 errors From 7bb12641f47a7f74ed2cdad9f58d5b14e6174893 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Mon, 16 Nov 2026 19:26:50 +0800 Subject: [PATCH 69/72] docs: beta release notes Release-Synced: a13f213e13ef63127ade7ec1724a03d80619ca1b --- CHANGELOG.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59174fb0..f828d97d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,9 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache ## Unreleased -- fix: a container two folders' regexes match goes to the folder the page draws first -- fix: Off tooltip says Unraid starts in the autostart file's order -- fix: save a folder's members when none were saved yet; Off never reorders -- fix: regroup userprefs.cfg in every autostart mode and on page load -- fix: keep a saved userprefs.cfg's containers with their folders -- refactor: move the container order code from lib.php into lib.order.php +- Unraid's saved Docker order keeps each folder's containers with it, so new members no longer come first +- A container two folders' regexes match is saved with the folder the Docker page shows it in +- Autostart mode Off now says FolderView3 never reorders the autostart file ## 2026.11.16.1 (beta) From 3d247d7c0d02d18b57ce969eac5b9b9147ea55b9 Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Mon, 16 Nov 2026 19:38:42 +0800 Subject: [PATCH 70/72] chore(release): v2026.11.16.2 [skip ci] --- CHANGELOG.md | 2 +- folder.view3.plg | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f828d97d..0276f139 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache if the page doesn't display correctly — before submitting a debug .json. -## Unreleased +## 2026.11.16.2 (beta) - Unraid's saved Docker order keeps each folder's containers with it, so new members no longer come first - A container two folders' regexes match is saved with the folder the Docker page shows it in diff --git a/folder.view3.plg b/folder.view3.plg index 05a97934..6279cad1 100644 --- a/folder.view3.plg +++ b/folder.view3.plg @@ -6,8 +6,8 @@ - - + + ]> @@ -16,6 +16,11 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache if the page doesn't display correctly — before submitting a debug .json. +###2026.11.16.2 +- Unraid's saved Docker order keeps each folder's containers with it, so new members no longer come first +- A container two folders' regexes match is saved with the folder the Docker page shows it in +- Autostart mode Off now says FolderView3 never reorders the autostart file + ###2026.11.16.1 - The error log no longer lists Unraid's own PHP warnings as FolderView3 errors From 697710dcf79ac237e56c04fe34dce34c4a561a1c Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Mon, 16 Nov 2026 11:38:52 +0000 Subject: [PATCH 71/72] chore(main): release changelog Release-Synced: a38e354c50446db05b23b806d9abfd218f55b9c8 Release-Synced-Beta: 2026.11.16.2 --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ce172bb..5d2993c3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache if the page doesn't display correctly — before submitting a debug .json. +## Unreleased + +- Folder actions that Unraid refuses now show its reason instead of raw JSON +- A failed update no longer deletes the package the installed version reinstalls from at boot +- The error log no longer lists Unraid's own PHP warnings as FolderView3 errors +- Unraid's saved Docker order keeps each folder's containers with it, so new members no longer come first +- A container two folders' regexes match is saved with the folder the Docker page shows it in +- Autostart mode Off now says FolderView3 never reorders the autostart file + ## 2026.11.16.2 (beta) - Unraid's saved Docker order keeps each folder's containers with it, so new members no longer come first From 302b64f80ee2084b144b0fbd307abbe079410ade Mon Sep 17 00:00:00 2001 From: chodeus <190988615+chodeus@users.noreply.github.com> Date: Tue, 17 Nov 2026 11:31:20 +0800 Subject: [PATCH 72/72] docs: stable release notes --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d2993c3..90cb8a04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ After updating, hard-refresh your browser (Ctrl/Cmd+Shift+R) and clear its cache - Folder actions that Unraid refuses now show its reason instead of raw JSON - A failed update no longer deletes the package the installed version reinstalls from at boot - The error log no longer lists Unraid's own PHP warnings as FolderView3 errors -- Unraid's saved Docker order keeps each folder's containers with it, so new members no longer come first +- Unraid's saved Docker order keeps folder members together in every start order mode, Off included - A container two folders' regexes match is saved with the folder the Docker page shows it in - Autostart mode Off now says FolderView3 never reorders the autostart file