diff --git a/orchestrator/client/resources.py b/orchestrator/client/resources.py index dfbed68..083cd0f 100755 --- a/orchestrator/client/resources.py +++ b/orchestrator/client/resources.py @@ -190,18 +190,21 @@ def parse_df(text: str) -> list[dict]: """Returns: One {mount, used, total} in bytes per block device in the output of df -P -k, at the first mount df lists for it; loop devices and - filesystems without a device are left out. + filesystems without a device are left out. total is used plus + available, the size normal writes can fill, so used / total is df's + Capacity; the 1K-blocks column also counts the blocks reserved for + root and would understate the fill level. """ found, seen = [], set() for line in text.splitlines()[1:]: parts = line.split(None, 5) if len(parts) < 6 or not parts[0].startswith("/dev/") or parts[0].startswith("/dev/loop") or parts[0] in seen: continue - total, used = number(parts[1]), number(parts[2]) - if total is None or used is None: + used, available = number(parts[2]), number(parts[3]) + if used is None or available is None: continue seen.add(parts[0]) - found.append({"mount": parts[5], "used": int(used) * KIB, "total": int(total) * KIB}) + found.append({"mount": parts[5], "used": int(used) * KIB, "total": int(used + available) * KIB}) return found diff --git a/orchestrator/templates/page-prune.js b/orchestrator/templates/page-prune.js index 0bdbebb..bcde0f2 100644 --- a/orchestrator/templates/page-prune.js +++ b/orchestrator/templates/page-prune.js @@ -35,7 +35,7 @@ */ function pruneControls(stale) { const pending = Prune.pending(state.jobs || [], pruneNow()); - const open = h("button", {type: "button", class: "btn small", id: "kanban-prune-open", disabled: !stale && !pending, ...named("Prune", "Prune stale tasks: one passkey signs the list and a deadline; the agents can keep a task until then")}, icon("bi-scissors"), "Prune"); + const open = h("button", {type: "button", class: "btn small icon-only", id: "kanban-prune-open", disabled: !stale && !pending, ...named("Prune", "Prune stale tasks: one passkey signs the list and a deadline; the agents can keep a task until then")}, icon("bi-scissors")); open.addEventListener("click", openPrune); if (!pending) { return [open]; diff --git a/orchestrator/templates/page-resources.js b/orchestrator/templates/page-resources.js index ba88bc5..9bad324 100644 --- a/orchestrator/templates/page-resources.js +++ b/orchestrator/templates/page-resources.js @@ -1,5 +1,6 @@ const RESOURCE = {left: 46, right: 10, wide: 50, top: 6, bottom: 6, axis: 18, poll: 5000, stale: 60, tones: 6, glyph: 6.5, shown: 100, lane: 13}; const RESOURCE_PANELS = [["hardware", "bi-cpu", "Hardware: disks, CPU, RAM, swap, GPU and VRAM"], ["tokens", "bi-coin", "Tokens per agent"], ["combined", "bi-layers", "Hardware, tokens and burnup"]]; + const HARDWARE_TONES = {shades: 3, host: {CPU: "res-cpu", RAM: "res-ram", Swap: "res-swap"}}; const RESOURCE_ZONES = {idle: "Idle: below 30 %", saturated: "Saturated: above 90 %"}; const RESOURCE_MARKS = { wait: ["#bi-hourglass-split", (mark) => `Idle waiting: ${mark.peak} jobs waited while CPU and RAM stayed under 50 %`, 0], @@ -229,14 +230,21 @@ } } + /** + * @param samples - sampler rows. + * @returns the hardware lines, each with its tone: the disks in shades of one hue, CPU, RAM and swap each in its own + * hue, every GPU in shades of a further hue and its VRAM in yet another, so that no two kinds share a colour. + */ function hardwareSeries(samples) { - const tones = new Map(); + const shades = {disk: new Map(), util: new Map(), vram: new Map()}; return Resources.hardware(samples).map((line) => { - if (!tones.has(line.name)) { - tones.set(line.name, tones.size % RESOURCE.tones); + const shade = shades[line.kind]; + if (shade && !shade.has(line.name)) { + shade.set(line.name, shade.size % HARDWARE_TONES.shades); } + const tone = shade ? `res-${line.kind}${shade.get(line.name)}` : HARDWARE_TONES.host[line.name]; const last = [...line.points].reverse().find(([, value]) => value !== null); - return {...line, id: ViewStore.id(line.kind, line.name), label: `${resourceLabel(line)} ${dash(last === undefined ? null : last[1])} %`, tone: `res-c${tones.get(line.name)} k-${line.kind}`}; + return {...line, id: ViewStore.id(line.kind, line.name), label: `${resourceLabel(line)} ${dash(last === undefined ? null : last[1])} %`, tone: `${tone} k-${line.kind}`}; }); } diff --git a/orchestrator/templates/page-running.js b/orchestrator/templates/page-running.js index e7e6696..a29b2e6 100644 --- a/orchestrator/templates/page-running.js +++ b/orchestrator/templates/page-running.js @@ -26,5 +26,5 @@ kanban.running = !kanban.running; taskView.sig = ""; drawTasks(); - }}}, icon("bi-activity"), "Running", counter(count)); + }}}, icon("bi-activity"), counter(count)); } diff --git a/orchestrator/templates/style-diff.css b/orchestrator/templates/style-diff.css index ab46ada..cf346d5 100644 --- a/orchestrator/templates/style-diff.css +++ b/orchestrator/templates/style-diff.css @@ -35,7 +35,7 @@ .feedback-float { position: fixed; z-index: 40; padding: 2px; border-radius: 10px; background: var(--glass-card); box-shadow: var(--shadow); } .code-box { display: flex; flex-direction: column; min-width: 0; margin-top: 4px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--sunken); } .code-body { display: grid; gap: var(--sp-1); min-width: 0; padding: 7px 10px; } -.code-box[data-open="false"] > .code-body { max-height: 12lh; overflow: hidden; } +.code-box[data-open="false"] > .code-body { max-height: 12lh; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; } .code-box[data-place="closed"] > .code-body { max-height: calc(1lh + 14px); } .code-box[data-place="closed"] .command > .linkish { min-width: 0; max-width: 100%; overflow: hidden; } .code-box[data-place="closed"] .command code { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } diff --git a/orchestrator/templates/style-resources.css b/orchestrator/templates/style-resources.css index b3c30a2..1b3ca71 100644 --- a/orchestrator/templates/style-resources.css +++ b/orchestrator/templates/style-resources.css @@ -69,9 +69,12 @@ svg .res-icon.hung { fill: var(--violet); pointer-events: none; } svg .res-icon.asleep, svg .res-icon.unknown { fill: var(--muted); } svg .res-bar { fill: var(--c); } svg .res-bar.faint { opacity: 0.35; } -.res-limits { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; font-size: var(--fs-xs); } +.res-panel.res-hardware { min-height: min-content; } +.res-panel.res-hardware > .res-plot { min-height: 48px; } +.res-limits { display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; min-width: 0; overflow-x: auto; scrollbar-width: none; font-size: var(--fs-xs); } +.res-limits > * { flex: none; } .res-limits .segmented button { padding: 2px 8px; font-size: var(--fs-xs); } -.limit-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.res-limits > .limit-note { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .limit-error { margin: 0; color: var(--bad); } .limits-table { border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; } .limits-table th, .limits-table td { padding: 3px 6px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; } @@ -92,5 +95,17 @@ svg .res-target text { fill: var(--muted); font-size: var(--fs-2xs); } .res-c3 { --c: var(--warn); } .res-c4 { --c: var(--violet); } .res-c5 { --c: var(--bad); } +.res-disk0 { --c: var(--ok); } +.res-disk1 { --c: color-mix(in srgb, var(--ok) 55%, var(--text)); } +.res-disk2 { --c: color-mix(in srgb, var(--ok) 55%, var(--panel)); } +.res-cpu { --c: var(--info); } +.res-ram { --c: var(--violet); } +.res-swap { --c: var(--warn); } +.res-util0 { --c: color-mix(in srgb, var(--bad) 50%, var(--violet)); } +.res-util1 { --c: color-mix(in srgb, color-mix(in srgb, var(--bad) 50%, var(--violet)) 55%, var(--text)); } +.res-util2 { --c: color-mix(in srgb, color-mix(in srgb, var(--bad) 50%, var(--violet)) 55%, var(--panel)); } +.res-vram0 { --c: var(--bad); } +.res-vram1 { --c: color-mix(in srgb, var(--bad) 55%, var(--text)); } +.res-vram2 { --c: color-mix(in srgb, var(--bad) 55%, var(--panel)); } .res-burn.k-done { --c: var(--ok); } .res-burn.k-scope { --c: var(--text); } diff --git a/orchestrator/templates/style-ui.css b/orchestrator/templates/style-ui.css index 74666ed..c6c909d 100644 --- a/orchestrator/templates/style-ui.css +++ b/orchestrator/templates/style-ui.css @@ -112,6 +112,7 @@ body.fit .spot-host { flex: none; } @container composer-foot (max-width: 480px) { .composer .cell-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } } +@media (max-width: 640px) { .composer .composer-foot :is(button, summary) { min-width: 44px; min-height: 44px; } } @media (prefers-reduced-motion: reduce) { .composer .composer-foot .bi { animation: none; } } [data-rec="busy"] > .bi { animation: presence-spin 1.2s linear infinite; } @media (prefers-reduced-motion: reduce) { [data-rec="busy"] > .bi { animation: none; } } diff --git a/tests/e2e/hub_e2e_plan.py b/tests/e2e/hub_e2e_plan.py index 53b3c85..68fd43f 100644 --- a/tests/e2e/hub_e2e_plan.py +++ b/tests/e2e/hub_e2e_plan.py @@ -115,7 +115,11 @@ BULK = """(async () => {@HELPERS@@PLAN_HELPERS@ found.toast = await fresh(shown, "Business value @VALUE@ for 2 tasks"); found.asked = asked; found.posted = posted; - found.after = [button.disabled, all("#main .task-row input.task-pick:checked").length]; + const picked = () => [document.getElementById("bulk-value").disabled, all("#main .task-row input.task-pick:checked").length]; + if (@SIGNS@) { + await until(() => JSON.stringify(picked()) === JSON.stringify([true, 0]), 8000); + } + found.after = picked(); Object.assign(found, fits()); all('#main [aria-label="Estimation"] button').find((entry) => entry.dataset.estimation === "none").click(); found.reset = Boolean(await until(() => requestShown() === false, 8000)); diff --git a/tests/e2e/test_commit_tree_diff_e2e.py b/tests/e2e/test_commit_tree_diff_e2e.py index 8ea9d05..aa63122 100644 --- a/tests/e2e/test_commit_tree_diff_e2e.py +++ b/tests/e2e/test_commit_tree_diff_e2e.py @@ -82,6 +82,9 @@ class TestCommitTreeDiff(HubCase): repo, target = merge_repo(Path(work.name)) tree = git(repo, "rev-parse", f"{target}^{{tree}}").strip() self.parent = git(repo, "rev-parse", "main").strip() + with self.assertRaises(staged_diff.DiffError) as missing: + staged_diff.git(repo, ["cat-file", "-t", MISSING], None) + self.missing = str(missing.exception) now = time.time() self.write_council({ "work/s1/claim.json": {"office": "work/s1", "session": "s1", "runtime": "claude", "name": "Skills", "since": iso(now - 86400), "beat": now, "work": "commit-tree"}, @@ -120,7 +123,8 @@ class TestCommitTreeDiff(HubCase): with self.subTest(browser=browser, width=width, step="error"): self.assertNotIn("error", broken, broken) self.assertEqual((broken["failed"], broken["files"], broken["none"], broken["wide"]), ("true", 0, "No diff to show.", False), broken) - self.assertIn(f"No commit-tree diff: git cat-file -t {MISSING} failed: fatal: Not a valid object name {MISSING}", broken["line"]) + self.assertTrue(self.missing.startswith(f"git cat-file -t {MISSING} failed: fatal: "), self.missing) + self.assertIn(f"No commit-tree diff: {self.missing}", broken["line"]) def test_chromium_shows_the_commit_tree_diff_its_eye_toggle_and_the_git_error_line(self): data = self.drive(self.steps("chromium"), None) diff --git a/tests/e2e/test_firewall_e2e.py b/tests/e2e/test_firewall_e2e.py index ed81700..f226dbe 100644 --- a/tests/e2e/test_firewall_e2e.py +++ b/tests/e2e/test_firewall_e2e.py @@ -115,7 +115,7 @@ TOOLS = """(async () => {@HELPERS@ return {error: text(document.getElementById("main"))}; } const rows = () => all("#main .tool-row").map((node) => [node.closest("[data-list]").dataset.list, node.dataset.tool, node.dataset.on, node.hasAttribute("data-staged")]); - const bar = () => document.querySelector("#main .apply-bar"); + const bar = () => document.querySelector('#main .apply-bar[aria-label="Apply changes"]'); const found = {before: rows(), hidden: bar().hidden}; await flip("blender", true); await flip("caveman@caveman", true); @@ -308,7 +308,7 @@ class TestFirewallE2E(HubCase): with self.subTest(width=width): self.assertNotIn("error", shown, shown) self.assertEqual((shown["title"], shown["subs"]), ("Controls", base.SUBS)) - self.assertEqual(shown["tabs"], {"first": [["tools", "true", False], ["rules", "false", True], ["schedules", "false", True]], "picked": [["tools", "false", True], ["rules", "true", False], ["schedules", "false", True]]}) + self.assertEqual(shown["tabs"], {"first": [["tools", "true", False], ["rules", "false", True], ["schedules", "false", True], ["queue", "false", True]], "picked": [["tools", "false", True], ["rules", "true", False], ["schedules", "false", True], ["queue", "false", True]]}) self.assertEqual(shown["collapsed"], [True] * 4) self.assertEqual(shown["sources"], [str(self.settings)]) self.assertEqual(shown["folded"], {"expanded": ["false"], "rows": 0}) diff --git a/tests/e2e/test_home_bookmarks_e2e.py b/tests/e2e/test_home_bookmarks_e2e.py index 8ff0a75..c4d974c 100644 --- a/tests/e2e/test_home_bookmarks_e2e.py +++ b/tests/e2e/test_home_bookmarks_e2e.py @@ -377,7 +377,7 @@ class TestHomeBookmarks(HubCase): loaded = next(results) self.assertTrue(loaded["drawn"], loaded) found = next(results) - self.assertEqual((found["charts"], found["stars"]), ([True] * 4, 0), found) + self.assertEqual((found["charts"], found["stars"]), ([True] * 5, 0), found) self.assertEqual(found["tree"], [True], found) self.assertTrue(found["rows"]["repo"] and all(found["rows"]["repo"]), found) self.assertTrue(found["rows"]["branch"] and all(found["rows"]["branch"]), found) diff --git a/tests/e2e/test_mic_frames_e2e.py b/tests/e2e/test_mic_frames_e2e.py index 6ad4cca..42d1345 100644 --- a/tests/e2e/test_mic_frames_e2e.py +++ b/tests/e2e/test_mic_frames_e2e.py @@ -72,8 +72,10 @@ RADIO = """(async () => {@HELPERS@@SCAN@ const mic = foot.querySelector(":scope > button.mic"); const idle = getComputedStyle(mic).backgroundColor; mic.setAttribute("aria-pressed", "true"); + await sleep(300); const recording = getComputedStyle(mic).backgroundColor; mic.setAttribute("aria-pressed", "false"); + await sleep(300); area.style.height = "260px"; await sleep(100); const after = scan().find((entry) => entry.id === area.id); diff --git a/tests/e2e/test_resources_accounts_e2e.py b/tests/e2e/test_resources_accounts_e2e.py index c011321..ead4c13 100644 --- a/tests/e2e/test_resources_accounts_e2e.py +++ b/tests/e2e/test_resources_accounts_e2e.py @@ -106,14 +106,15 @@ USAGE = """(async () => {@HELPERS@@KIT@@BAR@ pointer(document, "pointermove", rect.left + rect.width * 0.25, y); pointer(document, "pointermove", rect.left + rect.width * 0.4, y); pointer(document, "pointerup", rect.left + rect.width * 0.4, y); - const dragged = await settled(40); + const landed = await settled(40); + const dragged = landed ? read(landed) : null; const stored = (await (await fetch("/api/accounts", {cache: "no-store"})).json()).calibrations; const before = {pressed: toggle().getAttribute("aria-pressed"), marks: marks()}; toggle().click(); await until(() => toggle().getAttribute("aria-pressed") === "true" && marks().every(([, found]) => found.length === 1), 6000); const on = {pressed: toggle().getAttribute("aria-pressed"), marks: marks()}; bar().scrollIntoView({block: "center", inline: "center"}); - return {shown, right, paged, keyed: Boolean(keyed), kept, dragged: dragged ? read(dragged) : null, stored, before, on, page: wide(), violations: window.e2eViolations || null}; + return {shown, right, paged, keyed: Boolean(keyed), kept, dragged, stored, before, on, page: wide(), violations: window.e2eViolations || null}; })()""" RELOAD = """(async () => {@HELPERS@@KIT@@BAR@ if (!(await until(() => bar() && toggle() && marks().every(([, found]) => found.length === 1), 15000))) { @@ -141,7 +142,7 @@ class TestResourcesAccounts(HubCase): sample = w4.TestWorkbenchResources.sample def setUp(self): - super().setUp() + HubCase.setUp(self) OUT.mkdir(parents=True, exist_ok=True) now = int(time.time()) self.start = now - now % 60 - w4.ROWS * 60 diff --git a/tests/e2e/test_resources_usage_e2e.py b/tests/e2e/test_resources_usage_e2e.py index ca31b22..553b0b0 100644 --- a/tests/e2e/test_resources_usage_e2e.py +++ b/tests/e2e/test_resources_usage_e2e.py @@ -50,10 +50,10 @@ EXPLORE = """(async () => {@HELPERS@@READ@@KIT@ rowOf("kvb-help").click(); const drilled = Boolean(await until(() => filters().join() === "skill" && keys().join() === "kvb-help", 6000)); choose(group(), "tool"); - const switched = Boolean(await until(() => keys().join() === "Bash,Read," && split(), 6000)); + const regrouped = Boolean(await until(() => keys().join() === "Bash,Read," && split(), 6000)); const byTool = {group: group().value, keys: keys(), shares: cells("share"), split: split(), filters: filters()}; box().scrollIntoView({block: "start"}); - return {bySkill, byCost, drilled, switched, byTool, page: wide(), violations: window.e2eViolations || null}; + return {bySkill, byCost, drilled, switched: regrouped, byTool, page: wide(), violations: window.e2eViolations || null}; })()""" RESET = """(async () => {@HELPERS@@READ@@KIT@ document.querySelector('#main .res-usage [data-filter="skill"]').click(); diff --git a/tests/e2e/test_rules_page_e2e.py b/tests/e2e/test_rules_page_e2e.py index 50dda50..933fe04 100644 --- a/tests/e2e/test_rules_page_e2e.py +++ b/tests/e2e/test_rules_page_e2e.py @@ -27,7 +27,7 @@ PAGE = """(async () => {@HELPERS@ } window.e2eSameDocument = true; const fold = (id) => document.querySelector(`#main details[data-fold="${id}"]`); - const shown = (node) => Boolean(node && node.getClientRects().length); + const shown = (node) => Boolean(node && node.checkVisibility()); const visible = (id) => all("li.hub-rule", fold(id)).filter(shown).length; const rowOf = (pattern) => all("#main li.hub-rule").find((node) => text(node.querySelector(".hub-rule-pattern")) === pattern); const chipOf = (row) => row.querySelector("[data-expiry]"); diff --git a/tests/e2e/test_speak_box_e2e.py b/tests/e2e/test_speak_box_e2e.py index 2c6207b..5ae5cc3 100644 --- a/tests/e2e/test_speak_box_e2e.py +++ b/tests/e2e/test_speak_box_e2e.py @@ -54,7 +54,7 @@ HOME = """(async () => {@HELPERS@@SHAPE@ } await sleep(40); const body = tile.querySelector(".home-body").getBoundingClientRect(); - const out = [".ptt-split", ".mayday-toggle"].filter((selector) => { + const out = [".ptt-split > :first-child", ".ptt-split .ptt-more", ".mayday-toggle"].filter((selector) => { const edge = tile.querySelector(selector).getBoundingClientRect(); return !(edge.width > 0 && edge.left >= body.left - 0.5 && edge.right <= body.right + 0.5 && edge.top >= body.top - 0.5 && edge.bottom <= body.bottom + 0.5); }); diff --git a/tests/e2e/test_workbench_w4_e2e.py b/tests/e2e/test_workbench_w4_e2e.py index 28ad553..9b0e212 100644 --- a/tests/e2e/test_workbench_w4_e2e.py +++ b/tests/e2e/test_workbench_w4_e2e.py @@ -128,7 +128,7 @@ class TestWorkbenchResources(HubCase): self.assertEqual(found["unknown"], [[self.start + UNREAD[0] * 60, self.start + UNREAD[1] * 60]]) self.assertEqual((found["agents"], found["bottoms"], found["stacked"]), (["Skills", "Stage"], ["Skills"], True)) self.assertEqual(found["legend"], ["CPU 60 %", "RAM 55 %", "Swap 5 %"]) - self.assertEqual(found["labels"], {"tab": ["Resources (key 6)", "Resources"], "reload": ["Reload: read the sampler files and the accounts again", "Reload"], "titles": [[name, name] for name in PANELS.values()]}) + self.assertEqual(found["labels"], {"tab": ["Resources (key 6)", "Resources"], "reload": ["Reload: read the sampler files, the accounts and the usage again", "Reload"], "titles": [[name, name] for name in PANELS.values()]}) self.assertEqual((found["unlabelled"], found["plots"]), (0, [True] * 2)) self.assertEqual((found["tall"], found["wide"]), (False, False), "the page scrolls") self.assertEqual(quiet(found["violations"]), []) diff --git a/tests/test_resources_sample.py b/tests/test_resources_sample.py index 9a523af..8029e9f 100644 --- a/tests/test_resources_sample.py +++ b/tests/test_resources_sample.py @@ -30,9 +30,9 @@ tmpfs 8000000 1000 7999000 1% /dev/shm overlay 976762584 512000000 460000000 53% /var/lib/docker/overlay2/x/merged """ DISKS = [ - {"mount": "/", "used": 512000000 * 1024, "total": 976762584 * 1024}, - {"mount": "/boot/efi", "used": 12000 * 1024, "total": 523248 * 1024}, - {"mount": "/mnt/Backup Disk", "used": 100000000 * 1024, "total": 1953514584 * 1024}, + {"mount": "/", "used": 512000000 * 1024, "total": (512000000 + 460000000) * 1024}, + {"mount": "/boot/efi", "used": 12000 * 1024, "total": (12000 + 511248) * 1024}, + {"mount": "/mnt/Backup Disk", "used": 100000000 * 1024, "total": (100000000 + 1853514584) * 1024}, ] MEMINFO = """MemTotal: 32000000 kB MemFree: 2000000 kB