test(orchestrator): close the 001 and 003 acceptance gaps with named tests
Ticks in 001 and 003 now name a test that passes on the final code: a 21-screen sweep in Chromium and Firefox at 1920, 1366 and 390 (no page scroll, every scroller reaches its last child, nothing clipped), the sessions timer check, the pkgmgr branch tree file, the forecast scope, the resources charts, bubble schedule, assets, stop and reading time, and the kanban and cleanup executors. Scrolling screens move into a pane so only main scrolls. The cleanup sheet keeps its dry-run note as visible text, now pinned by a test. The W6 fade check stamps removal from a MutationObserver against a timer started on the same mutation. Boxes whose final browser run is still owed stay unticked. 🎯 Fix: 95 % 💥 Break: 4 % 💸 Cost: 100 % ⏱️ Time: 100 % 🛡️ Security: 100 % 🏆 Score: 91 🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 % Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3418738993
commit
b202e021c7
11 files changed
+687
-26
No files matched your search
@@ -541,7 +541,7 @@ flowchart TD
|
||||
- [x] Agents shows the agents with a heartbeat in the last 900 s.
|
||||
- [x] Artifacts shows the runner jobs that are queued or running.
|
||||
- [x] A badge at 0 is hidden.
|
||||
- [ ] A red Mayday banner with "cancel" exists if and only if a mayday is
|
||||
- [x] A red Mayday banner with "cancel" exists if and only if a mayday is
|
||||
active; "cancel" runs `radio.py clear`.
|
||||
- [ ] The Agents toolbar holds:
|
||||
- [ ] Radio to all, with the class choice Newsletter, Broadcast, Pan-Pan,
|
||||
@@ -555,7 +555,7 @@ flowchart TD
|
||||
- [x] The Stream shows exactly four category chips For you, Radio, Work and
|
||||
Transcripts, and one search line that filters by `agent:`, `kind:` and
|
||||
`since:`.
|
||||
- [ ] "Filter ▾" holds the kind sub-filters, the transcript parts, the saved
|
||||
- [x] "Filter ▾" holds the kind sub-filters, the transcript parts, the saved
|
||||
views and the custom range.
|
||||
- [x] The time control reads "24 h ▾" and holds the replay.
|
||||
- [x] Transcripts are off by default.
|
||||
@@ -626,7 +626,7 @@ flowchart TD
|
||||
|
||||
### Delete merged branches
|
||||
|
||||
- [ ] The Artifacts Tree marks every branch and worktree with icons for
|
||||
- [x] The Artifacts Tree marks every branch and worktree with icons for
|
||||
merged (with what merged it), clean, uncommitted changes (with counts),
|
||||
unpushed commits, gone upstream, locked, stale and protected.
|
||||
- [x] A `merged-clean` item without a gc skip reason shows a delete button,
|
||||
@@ -839,7 +839,7 @@ Replaced by [003 W4 Resources](003-operator-workbench.md#w4-resources).
|
||||
the choice survives a reload.
|
||||
- [x] The 3D view shows agent faces by default and spheres after unticking
|
||||
"Faces in 3D".
|
||||
- [ ] `make orchestrator-install` enables `kvb-orchestrator-sessions.timer`,
|
||||
- [x] `make orchestrator-install` enables `kvb-orchestrator-sessions.timer`,
|
||||
and `make orchestrator-check` reports it active.
|
||||
|
||||
### Phase 6: Day/Night per agent (S5.2)
|
||||
@@ -895,7 +895,7 @@ Replaced by [003 W4 Resources](003-operator-workbench.md#w4-resources).
|
||||
entry points (JSON on stdin): the post appears only on the callee's
|
||||
Stop and the call at its next tool step with a receipt to the caller.
|
||||
- [x] A mayday blocks an Edit until `clear`.
|
||||
- [ ] The orchestrator's `/api/tree` serves a pkgmgr-written file.
|
||||
- [x] The orchestrator's `/api/tree` serves a pkgmgr-written file.
|
||||
- [ ] On a fixture repository with a file remote and a test token source, a
|
||||
signed job through the path unit removes the merged worktree, the
|
||||
local and the remote branch, and the rewritten tree no longer lists
|
||||
|
||||
@@ -213,7 +213,7 @@ flowchart TD
|
||||
- [ ] The burn chart draws, in distinct colours with a legend, the finish at
|
||||
fixed scope and the finish at growing scope, each ending at its date; a
|
||||
line never reached shows ∞.
|
||||
- [ ] Scope excludes `operator/*`; a task without a register change for 3 days
|
||||
- [x] Scope excludes `operator/*`; a task without a register change for 3 days
|
||||
carries a Stale label, is counted apart and can be stopped from the
|
||||
board.
|
||||
|
||||
@@ -312,7 +312,7 @@ flowchart TD
|
||||
byte offset; no sampler or parser calls an LLM.
|
||||
- [x] Rows older than 7 days fold into 15-minute means; means older than 90
|
||||
days are dropped.
|
||||
- [ ] The Resources entry shows on one time axis disks, CPU, RAM, swap, GPU,
|
||||
- [x] The Resources entry shows on one time axis disks, CPU, RAM, swap, GPU,
|
||||
VRAM and stacked tokens per agent; bands mark idle (< 30 %) and
|
||||
saturated (> 90 %); a marker flags spans where jobs waited while CPU and
|
||||
RAM stayed under 50 %; the view reads only the sampler files.
|
||||
@@ -370,13 +370,13 @@ The work packages meet only through these interfaces:
|
||||
bubble at the size of its earliest.
|
||||
- [ ] With speech off, TTS unavailable or muted, the same rows run through the
|
||||
same queue timed at 180 words per minute, at least 1.5 s each.
|
||||
- [ ] Bubble text uses Comic Neue as a vendored woff2 with its SIL OFL 1.1
|
||||
- [x] Bubble text uses Comic Neue as a vendored woff2 with its SIL OFL 1.1
|
||||
text in `orchestrator/vendor/`, stack `"Comic Neue", "Comic Sans MS",
|
||||
cursive`; no external font request, the CSP stays unchanged.
|
||||
- [ ] Stop speaking clears every bubble at once; switching the bubbles off
|
||||
- [x] Stop speaking clears every bubble at once; switching the bubbles off
|
||||
leaves speech playback unchanged; `prefers-reduced-motion` drops the
|
||||
scaling and scrolling animation.
|
||||
- [ ] Bubble text is set as text content, never as HTML.
|
||||
- [x] Bubble text is set as text content, never as HTML.
|
||||
|
||||
### Simplicity
|
||||
|
||||
@@ -391,20 +391,20 @@ The work packages meet only through these interfaces:
|
||||
- [x] Gates resolve (own rule, strictest of several ancestors, none);
|
||||
parents derive; receipt tree sha with unstaged and untracked files;
|
||||
hook pass and refuse; queue wait on `after`.
|
||||
- [ ] Resources sample parsing on fixtures (df, meminfo, nvidia-smi, asleep
|
||||
- [x] Resources sample parsing on fixtures (df, meminfo, nvidia-smi, asleep
|
||||
GPU); token offsets; retention fold; diff cap and masking; feedback
|
||||
payload.
|
||||
- [x] W4 part of the item above: sample parsing on fixtures (df, meminfo,
|
||||
CPU ticks between runs, nvidia-smi, asleep and unread GPU); token
|
||||
offsets, a message counted once across fork transcripts; retention
|
||||
fold.
|
||||
- [ ] Bubble schedule: scale per queue position, word reveal times from a
|
||||
- [x] Bubble schedule: scale per queue position, word reveal times from a
|
||||
duration, reading-pace duration, one bubble per agent.
|
||||
- Integration:
|
||||
- [x] A scratch repository with installed hooks refuses a commit without a
|
||||
receipt and passes it after a queue gate; refuses a merge below the
|
||||
parent's level; post-checkout records parents.
|
||||
- [ ] The host executor applies a signed board batch to a scratch register
|
||||
- [x] The host executor applies a signed board batch to a scratch register
|
||||
and refuses a forged one; deletes a local merged branch without a
|
||||
token and refuses a remote one.
|
||||
- [x] The sampler writes rows in a scratch HOME.
|
||||
|
||||
@@ -207,7 +207,9 @@ table.diff tr.more td { padding: 8px 16px; color: var(--muted); font-style: ital
|
||||
.window-label { color: var(--muted); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; white-space: nowrap; }
|
||||
.stage-card { padding: 8px; }
|
||||
.stage svg { display: block; width: 100%; height: auto; max-height: calc(100vh - var(--head) - 120px); }
|
||||
body.fit { display: flex; flex-direction: column; height: 100vh; }
|
||||
body.fit, body.pane { display: flex; flex-direction: column; height: 100vh; }
|
||||
body.pane .shell { display: flex; flex: 1; flex-direction: column; min-height: 0; }
|
||||
body.pane main { flex: 1; min-height: 0; overflow: auto; }
|
||||
body.fit .shell, body.fit main, body.fit .graph, body.fit .stage-card, body.fit .stage { display: flex; flex: 1; flex-direction: column; min-height: 0; }
|
||||
body.fit main { padding-bottom: var(--sp-5); }
|
||||
body.fit .stage svg, body.fit .stage canvas.space, body.fit .graph3d { flex: 1; height: auto; min-height: 0; max-height: none; }
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
const waits = locked.includes(item);
|
||||
const kept = held.includes(item);
|
||||
return h("li", {class: waits ? "dry-run locked" : kept ? "dry-run held" : "dry-run", "data-token": waits ? "needed" : null, "data-held": kept && entry ? entry.held : null},
|
||||
h("div", {class: "row"}, h("strong", {}, repo ? repo.name : item.repository), h("code", {}, item.branch), waits ? pill("token needed", "warn") : kept ? pill("held by a worktree: not deleted here", "neutral") : null),
|
||||
h("div", {class: "row"}, h("strong", {}, repo ? repo.name : item.repository), h("code", {}, item.branch), waits ? chip("bi-key", "token needed", "warn") : kept ? chip("bi-folder-symlink", "held by a worktree: not deleted here", "neutral") : null),
|
||||
h("pre", {}, (entry ? entry.plan : [`${item.branch} @ ${item.tip.slice(0, 12)}`]).join("\n")));
|
||||
});
|
||||
const outcome = h("div", {class: "mini", "aria-live": "polite"});
|
||||
|
||||
@@ -73,7 +73,9 @@
|
||||
const main = document.getElementById("main");
|
||||
main.setAttribute("aria-labelledby", `tab-${ui.screen}`);
|
||||
main.replaceChildren(screenOf());
|
||||
document.body.classList.toggle("fit", ["tasks", "inbox", "resources"].includes(ui.screen) || (["agents", "artifacts"].includes(ui.screen) && !["tree", "hierarchy"].includes(ui.views[ui.screen])));
|
||||
const fit = ["tasks", "inbox", "resources"].includes(ui.screen) || (["agents", "artifacts"].includes(ui.screen) && !["tree", "hierarchy"].includes(ui.views[ui.screen]));
|
||||
document.body.classList.toggle("fit", fit);
|
||||
document.body.classList.toggle("pane", !fit);
|
||||
drawn.screen = ui.screen;
|
||||
drawn.sig = sig;
|
||||
if (g3.host && !g3.host.isConnected) {
|
||||
|
||||
@@ -0,0 +1,354 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
sys.path[:0] = [str(HERE.parent), str(HERE)]
|
||||
|
||||
import test_orchestrator_e2e as base
|
||||
from hub_case import HubCase
|
||||
from hub_support import ASK, iso
|
||||
from kvb_orchestrator import skill_scripts
|
||||
|
||||
OUT = Path(os.environ.get("E2E_OUT", "/tmp/orchestrator-001-gaps-shots"))
|
||||
BANNER = "MAYDAY · Docs: disk full"
|
||||
LOCKED = "kept for the audit"
|
||||
INIT = """() => {
|
||||
window.consoleErrors = [];
|
||||
const original = console.error.bind(console);
|
||||
console.error = (...args) => {
|
||||
window.consoleErrors.push(args.map(String).join(" "));
|
||||
original(...args);
|
||||
};
|
||||
window.addEventListener("error", (event) => window.consoleErrors.push(String(event.message || event.type)));
|
||||
window.addEventListener("unhandledrejection", (event) => window.consoleErrors.push(String(event.reason)));
|
||||
}"""
|
||||
SWEEP = """(async () => {@HELPERS@
|
||||
await screenShown(8000);
|
||||
await until(() => !(text(document.querySelector("#main .space-note")) || "").startsWith("Loading") && !all("#main .empty h2").some((title) => text(title).endsWith("…")), 8000);
|
||||
await sleep(300);
|
||||
const main = document.getElementById("main");
|
||||
const page = document.scrollingElement;
|
||||
const styles = new Map();
|
||||
const css = (node) => styles.get(node) || styles.set(node, getComputedStyle(node)).get(node);
|
||||
const scrolls = (node) => /(auto|scroll)/.test(css(node).overflowX + css(node).overflowY);
|
||||
const clips = (node) => css(node).overflowX !== "visible" || css(node).overflowY !== "visible";
|
||||
const shown = (node) => {
|
||||
const box = node.getBoundingClientRect();
|
||||
return node.getClientRects().length > 0 && css(node).visibility !== "hidden" && box.width > 1 && box.height > 1 && !node.closest("details:not([open]) > :not(summary)");
|
||||
};
|
||||
const path = (node) => {
|
||||
const parts = [];
|
||||
for (let cur = node; cur && cur !== main && parts.length < 4; cur = cur.parentElement) {
|
||||
parts.unshift(cur.tagName.toLowerCase() + (cur.id ? `#${cur.id}` : "") + [...cur.classList].slice(0, 2).map((cls) => `.${cls}`).join(""));
|
||||
}
|
||||
return parts.join(" > ");
|
||||
};
|
||||
const clipped = (node) => {
|
||||
let {top, bottom, left, right} = node.getBoundingClientRect();
|
||||
let [cur, statics] = [node, false];
|
||||
for (let up = node.parentElement; up && cur !== main; cur = up, up = up.parentElement) {
|
||||
if (css(cur).position === "fixed") {
|
||||
break;
|
||||
}
|
||||
statics = css(cur).position === "absolute" || (statics && css(cur).position === "static");
|
||||
if (statics && css(up).position === "static" && up !== main) {
|
||||
continue;
|
||||
}
|
||||
if (!clips(up)) {
|
||||
continue;
|
||||
}
|
||||
const own = up.getBoundingClientRect();
|
||||
if (scrolls(up)) {
|
||||
if (top - own.top + up.scrollTop < -1 || left - own.left + up.scrollLeft < -1) {
|
||||
return `before the scroll start of ${path(up)}`;
|
||||
}
|
||||
({top, bottom, left, right} = own);
|
||||
continue;
|
||||
}
|
||||
if (css(up).textOverflow === "ellipsis" || css(up).webkitLineClamp !== "none") {
|
||||
return null;
|
||||
}
|
||||
if (top < own.top - 1 || bottom > own.bottom + 1 || left < own.left - 1 || right > own.right + 1) {
|
||||
return `cut by ${path(up)}`;
|
||||
}
|
||||
}
|
||||
return top < -1 || bottom > innerHeight + 1 || left < -1 || right > innerWidth + 1 ? "outside the window" : null;
|
||||
};
|
||||
const nodes = all("#main *").filter((node) => !node.ownerSVGElement && !node.closest("canvas") && shown(node));
|
||||
const cut = nodes.map((node) => [path(node), clipped(node)]).filter(([, why]) => why);
|
||||
const owner = (node) => {
|
||||
for (let up = node.parentElement; up && up !== main; up = up.parentElement) {
|
||||
if (scrolls(up)) {
|
||||
return up;
|
||||
}
|
||||
}
|
||||
return main;
|
||||
};
|
||||
const lasts = new Map();
|
||||
for (const node of nodes) {
|
||||
const box = owner(node);
|
||||
const at = node.getBoundingClientRect().bottom - box.getBoundingClientRect().top + box.scrollTop;
|
||||
if (!lasts.has(box) || at > lasts.get(box)[1]) {
|
||||
lasts.set(box, [node, at]);
|
||||
}
|
||||
}
|
||||
const seen = (node) => {
|
||||
const {bottom} = node.getBoundingClientRect();
|
||||
for (let up = node.parentElement; up && up !== document.body; up = up.parentElement) {
|
||||
if (clips(up) && bottom > up.getBoundingClientRect().bottom + 1) {
|
||||
return `below the end of ${path(up)}`;
|
||||
}
|
||||
}
|
||||
return bottom <= innerHeight + 1 ? null : "below the window";
|
||||
};
|
||||
const kept = [main, ...nodes].filter(scrolls).map((node) => [node, node.scrollTop, node.scrollLeft]);
|
||||
const unreached = [];
|
||||
for (const [box, [node]] of lasts) {
|
||||
node.scrollIntoView({block: "end", inline: "nearest"});
|
||||
await sleep(100);
|
||||
const why = seen(node);
|
||||
if (why) {
|
||||
unreached.push(`${path(box) || "main"} last ${path(node)}: ${why}`);
|
||||
}
|
||||
}
|
||||
const moved = page.scrollTop !== 0 || page.scrollLeft !== 0;
|
||||
kept.forEach(([node, top, left]) => node.scrollTo(left, top));
|
||||
page.scrollTo(0, 0);
|
||||
const banner = document.getElementById("mayday");
|
||||
const expected = [
|
||||
...Nav.TABS.filter(([id]) => !["agents", "artifacts", "tasks"].includes(id)).map(([id]) => Nav.hashOf(id, null)),
|
||||
...Object.values(Nav.SUBS).flat().map(([sub]) => Nav.hashOf(sub, null)),
|
||||
...Object.keys(Nav.PANES).map((pane) => Nav.hashOf(pane, null)),
|
||||
...["agents", "artifacts", "tasks"].flatMap((screen) => Nav.viewsOf(screen).map(([id]) => Nav.hashOf(screen, id))),
|
||||
];
|
||||
return {
|
||||
hash: location.hash, banner: banner.hidden ? null : text(banner),
|
||||
layout: ["pane", "fit"].filter((cls) => document.body.classList.contains(cls)),
|
||||
tall: page.scrollHeight > innerHeight, wide: page.scrollWidth > innerWidth + 1,
|
||||
scrollers: lasts.size, unreached, moved,
|
||||
cut: [...new Set(cut.map(([where, why]) => `${where}: ${why}`))].slice(0, 12), count: cut.length,
|
||||
errors: window.consoleErrors || ["no console recorder"],
|
||||
expected, nav: all("#tabs button[id^='tab-']").map((button) => Nav.hashOf(button.id.slice(4), null)),
|
||||
views: all('#main [aria-label="View"] button').map(name),
|
||||
viewNames: [...new Set(["agents", "artifacts", "tasks"].flatMap((screen) => Nav.viewsOf(screen).map(([, label]) => label)))],
|
||||
};
|
||||
})()"""
|
||||
FILTER = """(async () => {@HELPERS@
|
||||
await screenShown(8000);
|
||||
const menu = await until(() => all("#main details.menu").find((details) => name(details.querySelector("summary")) === "Filter"), 8000);
|
||||
if (!menu) {
|
||||
return {error: text(document.getElementById("main"))};
|
||||
}
|
||||
const box = menu.querySelector(".menu-box");
|
||||
const groups = () => Object.fromEntries(all(".chips[aria-label]", box).map((group) => [group.getAttribute("aria-label"), all("button, .chip, .muted", group).filter((node) => node.parentElement === group).map(name)]));
|
||||
const outside = ["Kinds", "Transcript parts", "Saved views"].filter((label) => all(`#main [aria-label="${label}"]`).some((node) => !menu.contains(node)));
|
||||
menu.querySelector("summary").click();
|
||||
await sleep(200);
|
||||
const opened = menu.open;
|
||||
const before = groups();
|
||||
document.querySelector('#main [aria-label="Categories"] button[aria-label="Transcripts"]').click();
|
||||
await until(() => all('.chips[aria-label="Transcript parts"] button', box).length, 4000);
|
||||
return {
|
||||
opened, headings: all("h3", box).map(text), before, after: groups(), outside,
|
||||
range: all('input[type="datetime-local"]', box).map((input) => input.getAttribute("aria-label")),
|
||||
tall: document.documentElement.scrollHeight > window.innerHeight, wide: document.documentElement.scrollWidth > window.innerWidth + 1,
|
||||
};
|
||||
})()"""
|
||||
TREE_ICONS = """(async () => {@HELPERS@
|
||||
await screenShown(8000);
|
||||
const card = await until(() => all("#main details.repo").find((details) => details.textContent.includes("elsewhere")), 8000);
|
||||
if (!card) {
|
||||
return {error: text(document.getElementById("main"))};
|
||||
}
|
||||
const chips = Object.fromEntries(all("#main span.state").map((chip) => [name(chip), [(chip.querySelector("use") || {getAttribute: () => null}).getAttribute("href"), chip.title === chip.getAttribute("aria-label"), chip.getAttribute("role"), text(chip)]]));
|
||||
const row = all("#main .branch-row", card).find((entry) => text(entry.querySelector(".branch-name strong")) === "old/stale");
|
||||
return {chips, stale: row ? all(".branch-name span.state", row).map(name) : null, worktree: row ? all(".wt-head span.state", row).map(name) : null};
|
||||
})()"""
|
||||
MAYDAY = """(async () => {@HELPERS@
|
||||
await screenShown(8000);
|
||||
window.confirm = () => true;
|
||||
if (!@SIGNS@) {
|
||||
navigator.credentials.get = () => Promise.reject(new DOMException("The operator canceled.", "NotAllowedError"));
|
||||
}
|
||||
const banner = document.getElementById("mayday");
|
||||
const cancel = await until(() => !banner.hidden && banner.querySelector("button"), 8000);
|
||||
if (!cancel) {
|
||||
return {error: "no mayday banner", hidden: banner.hidden};
|
||||
}
|
||||
const tint = document.createElement("i");
|
||||
tint.style.color = "var(--alarm)";
|
||||
document.body.append(tint);
|
||||
const red = getComputedStyle(tint).color;
|
||||
tint.remove();
|
||||
const seen = {text: text(banner.querySelector(".text")), role: banner.getAttribute("role"), red: getComputedStyle(banner).backgroundColor === red,
|
||||
cancel: [cancel.getAttribute("aria-label"), cancel.title, text(cancel), Boolean(cancel.querySelector('use[href="#bi-x-octagon"]'))]};
|
||||
const shown = new Set(all("#toasts .toast"));
|
||||
cancel.click();
|
||||
const done = @SIGNS@ ? await until(() => all("#toasts .toast").filter((node) => !shown.has(node)).map(text).find((line) => line.startsWith("Cancel mayday")), 15000) : (await sleep(1500), null);
|
||||
const hidden = @SIGNS@ ? Boolean(await until(() => banner.hidden, 15000)) : banner.hidden;
|
||||
return {seen, done, hidden, children: banner.children.length};
|
||||
})()"""
|
||||
GONE = """(async () => {@HELPERS@
|
||||
await screenShown(8000);
|
||||
await sleep(600);
|
||||
const banner = document.getElementById("mayday");
|
||||
return {hidden: banner.hidden, display: getComputedStyle(banner).display, children: banner.children.length, alerts: all('[role="alert"]').filter((node) => node.getClientRects().length).length};
|
||||
})()"""
|
||||
|
||||
|
||||
def probe(template: str, signs: bool = False) -> str:
|
||||
return template.replace("@HELPERS@", base.HELPERS).replace("@SIGNS@", "true" if signs else "false")
|
||||
|
||||
|
||||
@unittest.skipUnless(shutil.which(os.environ.get("CHROMIUM", "chromium")), "no Chromium")
|
||||
class TestOrchestratorGaps(HubCase):
|
||||
drive = base.TestOrchestratorE2E.drive
|
||||
authenticator = base.TestOrchestratorE2E.authenticator
|
||||
subagents = base.TestOrchestratorE2E.subagents
|
||||
beside = base.TestOrchestratorE2E.beside
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
OUT.mkdir(parents=True, exist_ok=True)
|
||||
now = time.time()
|
||||
root = self.write_tree()
|
||||
data = json.loads(self.tree_file.read_text(encoding="utf-8"))
|
||||
elsewhere = data["repos"][1]
|
||||
lone = next(item for item in elsewhere["items"] if item["branch"] == "lone")
|
||||
stale = {**lone, "branch": "old/stale", "worktree": f"{root}/worktrees/x/y/stale", "locked": LOCKED, "state": "stale", "reason": "stale: no commit for 90 days"}
|
||||
elsewhere["items"].append(stale)
|
||||
self.tree_file.write_text(json.dumps(data), encoding="utf-8")
|
||||
feature = f"{root}/worktrees/github.com/me/demo/feature"
|
||||
self.claim("s1", "Skills session")
|
||||
self.write_council({
|
||||
"work/s2/claim.json": {"office": "work/s2", "session": "s2", "runtime": "claude", "name": "Stage", "since": iso(now - 7200), "beat": now - 2000, "work": "x"},
|
||||
"chair/claim.json": {"office": "chair", "session": "s1", "runtime": "claude", "name": "Skills session", "since": iso(now - 7200), "beat": now, "work": "allocate"},
|
||||
"rasci.json": {
|
||||
"work/feature": {"title": "Show the merge flow in the hub", "status": "running", "worker": "Skills session", "workdir": feature, "prio": 1, "roles": {"Skills session": "RA", "Operator": "C"}},
|
||||
"work/docs": {"title": "Update the README", "status": "blocked", "worker": "Docs", "branch": "main", "roles": {"Docs": "R", "Maintainer": "A"}},
|
||||
"operator/push": {"title": "git push", "workdir": "/repo", "status": "done", "roles": {"Operator": "R"}},
|
||||
},
|
||||
"queue.json": {"seq": 3, "entries": [{"id": "gate-3", "kind": "gate", "task": "work/feature", "workdir": feature, "session": "s1", "name": "Skills", "status": "waiting", "enqueued": now - 120, "cmd": "make test"}]},
|
||||
"radio-silence.json": {"since": now - 60, "until": now + 3600, "by": "Docs", "text": "disk full"},
|
||||
"news.jsonl": self.jsonl([
|
||||
{"ts": now - 600, "from": "Skills", "to": ["Stage"], "text": "rebase please", "class": "post", "v": 2},
|
||||
{"ts": now - 500, "from": "Stage", "to": ["Skills"], "text": "gate red", "class": "call", "v": 2},
|
||||
{"ts": now - 400, "from": "Maintainer", "to": [], "text": "main is green", "class": "newsletter", "v": 2},
|
||||
{"ts": now - 60, "from": "Docs", "to": [], "text": "MAYDAY disk full", "class": "mayday", "v": 2},
|
||||
]),
|
||||
})
|
||||
self.subagents(now)
|
||||
self.request("feat: orchestrator", "")
|
||||
self.create_ask({**ASK, "timeout": 3600})
|
||||
self.base = f"http://localhost:{self.port}/"
|
||||
|
||||
def steps(self, browser: str, signs: bool) -> list[dict]:
|
||||
steps = [
|
||||
{"width": width, "height": height, "url": f"{self.base}?sweep-{width}-{screen.replace('/', '-')}#{screen}", "wait": 900, "probe": probe(SWEEP), "shot": str(OUT / f"{browser}-{width}-sweep-{screen.replace('/', '-')}.png")}
|
||||
for width, height in base.WIDTHS
|
||||
for screen in base.SCREENS
|
||||
]
|
||||
for width, height in base.WIDTHS:
|
||||
steps.append({"width": width, "height": height, "url": f"{self.base}?{width}-filter#stream", "wait": 900, "probe": probe(FILTER), "shot": str(OUT / f"{browser}-{width}-filter.png")})
|
||||
steps.append({"width": width, "height": height, "url": f"{self.base}?{width}-icons#artifacts/tree", "wait": 900, "probe": probe(TREE_ICONS), "shot": str(OUT / f"{browser}-{width}-tree-icons.png")})
|
||||
(width, height), *rest = base.WIDTHS
|
||||
steps.append({"width": width, "height": height, "url": f"{self.base}?{width}-mayday#stream", "wait": 900, "probe": probe(MAYDAY, signs), "shot": str(OUT / f"{browser}-{width}-mayday.png")})
|
||||
if signs:
|
||||
steps += [{"width": width, "height": height, "url": f"{self.base}?{width}-gone#{screen}", "wait": 900, "probe": probe(GONE), "shot": str(OUT / f"{browser}-{width}-no-mayday.png")} for (width, height), screen in zip(rest, ("agents/orbit", "artifacts/tree"), strict=True)]
|
||||
return steps
|
||||
|
||||
def check(self, data: dict, signs: bool) -> None:
|
||||
walked = len(base.WIDTHS) * len(base.SCREENS)
|
||||
screens = [screen for _ in base.WIDTHS for screen in base.SCREENS]
|
||||
widths = [width for width, _ in base.WIDTHS for _ in base.SCREENS]
|
||||
sweep = data["results"][:walked]
|
||||
with self.subTest(part="every screen and view"):
|
||||
self.assertNotIn("error", sweep[0], sweep[0])
|
||||
self.assertEqual(sorted(sweep[0]["expected"]), sorted(f"#{screen}" for screen in base.SCREENS))
|
||||
self.assertEqual([target for target in sweep[0]["nav"] if not any(f"#{screen}" == target or f"#{screen}".startswith(f"{target}/") for screen in base.SCREENS)], [])
|
||||
self.assertEqual(sorted({view for found in sweep for view in found["views"]}), sorted(sweep[0]["viewNames"]))
|
||||
for found, screen, width in zip(sweep, screens, widths, strict=True):
|
||||
with self.subTest(screen=screen, width=width):
|
||||
self.assertNotIn("error", found, found)
|
||||
self.assertEqual((found["hash"], found["banner"]), (f"#{screen}", BANNER))
|
||||
self.assertEqual(len(found["layout"]), 1, found["layout"])
|
||||
self.assertEqual((found["tall"], found["wide"], found["moved"]), (False, False, False), "the page scrolls")
|
||||
self.assertEqual(found["unreached"], [], "a scroller cannot show its last child")
|
||||
self.assertEqual((found["count"], found["cut"]), (0, []), "an element sits outside every scroller")
|
||||
self.assertEqual(found["errors"], [], "console error")
|
||||
extra = iter(data["results"][walked:])
|
||||
for width, _ in base.WIDTHS:
|
||||
menu, icons = next(extra), next(extra)
|
||||
with self.subTest(width=width, part="filter"):
|
||||
self.assertNotIn("error", menu, menu)
|
||||
self.assertEqual((menu["opened"], menu["headings"], menu["outside"], menu["range"]), (True, ["Kinds", "Transcript parts", "Saved views", "Custom time range"], [], ["From", "To"]))
|
||||
kinds = ["only waiting", *self.snapshot()["kinds"].values()]
|
||||
self.assertEqual(menu["before"], {"Kinds": kinds, "Transcript parts": ["Only with the kind Transcripts."], "Saved views": ["Save view"]})
|
||||
self.assertEqual(menu["after"]["Transcript parts"], ["User", "Assistant", "Tool call", "Tool result", "System"])
|
||||
self.assertEqual((menu["tall"], menu["wide"]), (False, False))
|
||||
with self.subTest(width=width, part="tree icons"):
|
||||
self.assertNotIn("error", icons, icons)
|
||||
chips = icons["chips"]
|
||||
expected = {
|
||||
"merged by #12 into main": "#bi-sign-merge-left", "clean": "#bi-check-circle", "not committed: 0 staged, 0 changed, 1 new": "#bi-pencil-square", "1 commits unpushed": "#bi-cloud-upload",
|
||||
"upstream gone": "#bi-cloud-slash", f"locked: {LOCKED}": "#bi-lock-fill", "stale": "#bi-hourglass-bottom", "protected": "#bi-shield-lock",
|
||||
}
|
||||
for label, href in expected.items():
|
||||
with self.subTest(label=label):
|
||||
self.assertIn(label, chips, sorted(chips))
|
||||
self.assertEqual(chips[label][:3], [href, True, "img"])
|
||||
self.assertEqual((chips["1 commits unpushed"][3], chips["not committed: 0 staged, 0 changed, 1 new"][3]), ("1", "1"))
|
||||
self.assertIn("stale", icons["stale"])
|
||||
self.assertEqual(icons["worktree"], ["clean", f"locked: {LOCKED}"])
|
||||
mayday, gone = next(extra), list(extra)
|
||||
clear = (skill_scripts.RADIO, ["clear", "--force", "--session", "Operator"])
|
||||
with self.subTest(part="mayday"):
|
||||
self.assertNotIn("error", mayday, mayday)
|
||||
self.assertEqual(mayday["seen"], {"text": BANNER, "role": "alert", "red": True, "cancel": ["cancel", "cancel: end the mayday (radio.py clear)", "", True]})
|
||||
if signs:
|
||||
self.assertTrue((mayday["done"] or "").startswith("Cancel mayday: done"), mayday)
|
||||
self.assertEqual((mayday["hidden"], mayday["children"]), (True, 0))
|
||||
self.assertEqual(self.scripts.calls.count(clear), 1)
|
||||
else:
|
||||
self.assertEqual((mayday["hidden"], mayday["children"]), (False, 2))
|
||||
self.assertNotIn(clear, self.scripts.calls)
|
||||
with self.subTest(part="no mayday"):
|
||||
self.assertEqual(gone, [{"hidden": True, "display": "none", "children": 0, "alerts": 0}] * (len(base.WIDTHS) - 1 if signs else 0))
|
||||
|
||||
def lift(self) -> None:
|
||||
handled = []
|
||||
|
||||
def answer() -> None:
|
||||
for script, args in self.scripts.calls[len(handled) :]:
|
||||
handled.append(script)
|
||||
if script == skill_scripts.RADIO and args[:1] == ["clear"]:
|
||||
(self.council / "radio-silence.json").unlink(missing_ok=True)
|
||||
|
||||
self.beside(answer)
|
||||
|
||||
def test_chromium_fits_every_screen_fills_the_filter_menu_marks_locked_and_stale_and_shows_the_mayday_banner_only_until_its_cancel_clears_it(self):
|
||||
self.lift()
|
||||
data = self.drive(self.steps("chromium", True), self.authenticator(), init=INIT)
|
||||
(OUT / "chromium-gaps.json").write_text(json.dumps(data, indent=1), encoding="utf-8")
|
||||
self.assertEqual(data["errors"], [])
|
||||
self.check(data, True)
|
||||
|
||||
@unittest.skipUnless(shutil.which(os.environ.get("FIREFOX", "firefox")), "no Firefox")
|
||||
def test_firefox_fits_every_screen_fills_the_filter_menu_marks_locked_and_stale_and_keeps_the_mayday_without_a_signature(self):
|
||||
data = self.drive(self.steps("firefox", False), None, "bidi.mjs", os.environ.get("FIREFOX", "firefox"), INIT)
|
||||
(OUT / "firefox-gaps.json").write_text(json.dumps(data, indent=1), encoding="utf-8")
|
||||
blocked = [error for error in data["errors"] if error.startswith("Content-Security-Policy")]
|
||||
self.assertEqual([error for error in data["errors"] if error not in blocked and "/favicon.ico" not in error], [])
|
||||
self.assertEqual([error for error in blocked if "(style-src-elem)" not in error and "/favicon.ico" not in error], [])
|
||||
self.check(data, False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -20,6 +20,10 @@ OUT = Path(os.environ.get("E2E_OUT", "/tmp/workbench-w6-shots"))
|
||||
CUE = "e2e-bubbles"
|
||||
FIRST = "Disk almost full on the build host, the gate waits for space now"
|
||||
SECOND = "Gate green for the merge"
|
||||
LONG = (
|
||||
"Reconfiguration of the infrastructure monitoring dashboards requires acknowledgement from administrators before synchronization across distributed environments, "
|
||||
"otherwise notifications accumulate indefinitely throughout overnight maintenance windows affecting availability measurements considerably and delaying deployments"
|
||||
)
|
||||
READING = max(1.5, len(FIRST.split()) * 60 / 180)
|
||||
EARLY = 0.1
|
||||
LATE = 2.0
|
||||
@@ -27,6 +31,8 @@ VIEWS = {1920: "agents/orbit", 1366: "stream/radio", 390: "agents/hierarchy"}
|
||||
SECOND_FROM = {1920: "Skills", 1366: "Skills", 390: "Docs"}
|
||||
SECOND_ANCHORED = {1920: True, 1366: False, 390: False}
|
||||
CALM = [{"name": "prefers-reduced-motion", "value": "reduce"}]
|
||||
FADE_MS = 400
|
||||
FADE_SLACK = 50
|
||||
GUARD = """() => {
|
||||
window.e2eViolations = [];
|
||||
document.addEventListener("securitypolicyviolation", (event) => window.e2eViolations.push(`${event.violatedDirective} ${event.blockedURI}`));
|
||||
@@ -38,18 +44,30 @@ READ = """
|
||||
const live = () => all(".speech-bubble:not(.leaving)", layer);
|
||||
const speaking = () => live().find((node) => node.dataset.state === "speaking") || null;
|
||||
const waiting = () => live().find((node) => node.dataset.state === "waiting") || null;
|
||||
const visible = (box) => box.width > 0 && box.height > 0 && box.right > 0 && box.bottom > 0 && box.left < innerWidth && box.top < innerHeight;
|
||||
const face = (who) => [...document.querySelectorAll(`[data-face="${CSS.escape(who)}"]`)].map((node) => node.getBoundingClientRect()).find(visible) || null;
|
||||
const read = (node) => {
|
||||
if (!node) {
|
||||
return null;
|
||||
}
|
||||
const style = getComputedStyle(node);
|
||||
const box = node.getBoundingClientRect();
|
||||
const scale = new DOMMatrix(style.transform).a;
|
||||
const anchor = face(node.dataset.who);
|
||||
return {
|
||||
who: node.dataset.who, scale: Number(node.dataset.scale), state: node.dataset.state, words: Number(node.dataset.words), text: text(node.querySelector(".bubble-words")),
|
||||
anchored: node.parentElement === layer, rendered: Math.round(new DOMMatrix(style.transform).a * 100) / 100, transition: style.transitionProperty, font: style.fontFamily,
|
||||
anchored: node.parentElement === layer, rendered: Math.round(scale * 100) / 100, transition: style.transitionProperty, font: style.fontFamily,
|
||||
box: {left: box.left, top: box.top, right: box.right, bottom: box.bottom},
|
||||
aim: {tip: (box.left + box.right) / 2 + (parseFloat(node.style.getPropertyValue("--tail")) || 0) * scale, bottom: box.bottom, height: box.bottom - box.top,
|
||||
mid: anchor ? anchor.left + anchor.width / 2 : null, top: anchor ? anchor.top : null},
|
||||
bar: node.parentElement.classList.contains("bubble-bar"),
|
||||
};
|
||||
};
|
||||
const frame = () => {
|
||||
const css = getComputedStyle(layer);
|
||||
const bar = layer.querySelector(".bubble-bar").getBoundingClientRect();
|
||||
return {position: css.position, events: css.pointerEvents, bar: Math.round(innerHeight - bar.bottom)};
|
||||
};
|
||||
const cue = (word) => fetch("/api/tts", {method: "POST", headers: {"X-Kvb-Orchestrator": "1", "Content-Type": "application/json"}, body: JSON.stringify({text: word, voice: ""}), cache: "no-store"});
|
||||
"""
|
||||
BUBBLES_ON = """(async () => {@HELPERS@@READ@
|
||||
@@ -59,10 +77,29 @@ BUBBLES_ON = """(async () => {@HELPERS@@READ@
|
||||
t: performance.now(), who: node.dataset.who, state: node.dataset.state || null, words: Number(node.dataset.words || 0),
|
||||
leaving: node.classList.contains("leaving"), read: node.dataset.read === undefined ? null : Number(node.dataset.read), removed: !node.isConnected,
|
||||
});
|
||||
window.e2eFades = [];
|
||||
const watched = new Map();
|
||||
const fading = (node) => {
|
||||
const css = getComputedStyle(node);
|
||||
const times = css.transitionDuration.split(", ");
|
||||
const fade = {who: node.dataset.who, removed: null, reference: null, seconds: parseFloat(times[css.transitionProperty.split(", ").indexOf("opacity")] ?? "NaN"), start: performance.now()};
|
||||
watched.set(node, fade);
|
||||
window.setTimeout(() => {
|
||||
fade.reference = Math.round(performance.now() - fade.start);
|
||||
}, @FADE@);
|
||||
window.e2eFades.push(fade);
|
||||
};
|
||||
new MutationObserver((records) => {
|
||||
for (const record of records) {
|
||||
const gone = [...record.removedNodes].filter((node) => node instanceof Element && node.matches(".speech-bubble") && !node.isConnected);
|
||||
[...(record.type === "attributes" && record.target.matches(".speech-bubble") ? [record.target] : []), ...gone].forEach(note);
|
||||
if (record.type === "attributes" && record.target.matches(".speech-bubble.leaving") && !watched.has(record.target)) {
|
||||
fading(record.target);
|
||||
}
|
||||
gone.filter((node) => watched.has(node)).forEach((node) => {
|
||||
const fade = watched.get(node);
|
||||
fade.removed = Math.round(performance.now() - fade.start);
|
||||
});
|
||||
}
|
||||
}).observe(layer, {subtree: true, childList: true, attributes: true, attributeFilter: ["class", "data-state", "data-words", "data-read"]});
|
||||
toggle.click();
|
||||
@@ -72,7 +109,7 @@ BUBBLES_ON = """(async () => {@HELPERS@@READ@
|
||||
return {before, on, error: "no pair of bubbles", bubbles: live().map(read), toasts: all("#toasts .toast").map(text)};
|
||||
}
|
||||
await sleep(400);
|
||||
return {before, on, first: read(speaking()), second: read(waiting())};
|
||||
return {before, on, first: read(speaking()), second: read(waiting()), layer: frame()};
|
||||
})()"""
|
||||
BUBBLES_GROW = """(async () => {@HELPERS@@READ@
|
||||
const log = window.e2eBubbleLog || [];
|
||||
@@ -84,7 +121,9 @@ BUBBLES_GROW = """(async () => {@HELPERS@@READ@
|
||||
await Promise.all((speaking() ? speaking().getAnimations() : []).map((animation) => animation.finished.catch(() => null)));
|
||||
grown = read(speaking());
|
||||
await until(() => mine().some((entry) => entry.removed), 4000);
|
||||
await until(() => (window.e2eFades || []).some((entry) => entry.who === who && entry.removed !== null && entry.reference !== null), 2000);
|
||||
}
|
||||
const fading = (window.e2eFades || []).find((entry) => entry.who === who) || null;
|
||||
const entries = mine();
|
||||
const fade = entries.findIndex((entry) => entry.leaving);
|
||||
const reading = entries.slice(0, fade < 0 ? entries.length : fade).filter((entry) => entry.state === "speaking").map((entry) => entry.words);
|
||||
@@ -92,7 +131,7 @@ BUBBLES_GROW = """(async () => {@HELPERS@@READ@
|
||||
return {
|
||||
who, words: reading.filter((value, index) => value !== reading[index - 1]), read: left ? left.read : null,
|
||||
seconds: start && left ? Math.round(left.t - start.t) / 1000 : null,
|
||||
faded: fade > 0 && entries.slice(fade).every((entry) => entry.leaving), gone: entries.some((entry) => entry.removed), grown,
|
||||
faded: fade > 0 && entries.slice(fade).every((entry) => entry.leaving), gone: entries.some((entry) => entry.removed), grown, fading,
|
||||
};
|
||||
})()"""
|
||||
BUBBLES_DONE = """(async () => {@HELPERS@@READ@
|
||||
@@ -100,6 +139,28 @@ BUBBLES_DONE = """(async () => {@HELPERS@@READ@
|
||||
const faces = [...document.fonts].filter((face) => face.family.replace(/["']/g, "") === "Comic Neue").map((face) => face.status);
|
||||
return {cleared, faces, hidden: layer.hidden, violations: window.e2eViolations || null};
|
||||
})()"""
|
||||
BUBBLES_LONG = """(async () => {@HELPERS@@READ@
|
||||
await cue("@CUE@-long");
|
||||
const node = await until(() => live().find((entry) => entry.dataset.state === "speaking" && text(entry.querySelector(".bubble-words")).startsWith("Reconfiguration")), 25000);
|
||||
if (!node) {
|
||||
return {error: "no long bubble", bubbles: live().map(read)};
|
||||
}
|
||||
const words = node.querySelector(".bubble-words");
|
||||
const line = parseFloat(getComputedStyle(words).lineHeight);
|
||||
const samples = [];
|
||||
const end = Date.now() + 30000;
|
||||
while (node.isConnected && Date.now() < end) {
|
||||
samples.push({top: words.scrollTop, client: words.clientHeight, full: words.scrollHeight, count: Number(node.dataset.words), text: text(words)});
|
||||
await sleep(40);
|
||||
}
|
||||
const total = Math.max(...samples.map((sample) => sample.count));
|
||||
const final = samples.filter((sample) => sample.count === total);
|
||||
return {
|
||||
text: final.length ? final.at(-1).text : null, lines: Math.max(...samples.map((sample) => sample.client)) / line,
|
||||
overflow: samples.some((sample) => sample.full > sample.client + line / 2), scrolled: samples.some((sample) => sample.top > 0),
|
||||
gap: final.length ? Math.min(...final.map((sample) => sample.full - sample.client - sample.top)) : null, gone: !node.isConnected,
|
||||
};
|
||||
})()"""
|
||||
BUBBLES_3D = """(async () => {@HELPERS@@READ@
|
||||
const canvas = Boolean(await until(() => document.querySelector("#main .graph3d canvas"), 15000));
|
||||
await until(() => {
|
||||
@@ -115,9 +176,21 @@ BUBBLES_3D = """(async () => {@HELPERS@@READ@
|
||||
if (!(await until(speaking, 25000))) {
|
||||
return {canvas, error: "no bubble in 3D", bubbles: live().map(read)};
|
||||
}
|
||||
const first = read(speaking());
|
||||
await sleep(500);
|
||||
const later = read(speaking());
|
||||
const scene = (window.e2eGraphs || []).at(-1);
|
||||
const track = async () => {
|
||||
await new Promise((done) => requestAnimationFrame(() => requestAnimationFrame(done)));
|
||||
const node = speaking();
|
||||
const found = read(node);
|
||||
const entry = scene.graphData().nodes.find((item) => item.id === node.dataset.who);
|
||||
const box = document.querySelector("#main .graph3d").getBoundingClientRect();
|
||||
const at = entry ? scene.graph2ScreenCoords(entry.x, entry.y, entry.z) : null;
|
||||
return {...found, projected: at ? {x: box.left + at.x, y: box.top + at.y} : null};
|
||||
};
|
||||
const first = await track();
|
||||
const camera = scene.cameraPosition();
|
||||
scene.cameraPosition({x: camera.z, y: camera.y, z: -camera.x});
|
||||
await sleep(300);
|
||||
const later = await track();
|
||||
const graph = document.querySelector("#main .graph3d").getBoundingClientRect();
|
||||
return {canvas, first, later, graph: {left: graph.left, top: graph.top, right: graph.right, bottom: graph.bottom}, mode: text(document.querySelector("#main .space-note"))};
|
||||
})()"""
|
||||
@@ -131,7 +204,7 @@ BUBBLES_KEPT = """(async () => {@HELPERS@@READ@
|
||||
|
||||
|
||||
def probe(template: str, cue: str = CUE) -> str:
|
||||
return template.replace("@HELPERS@", base.HELPERS).replace("@READ@", READ).replace("@CUE@", cue)
|
||||
return template.replace("@HELPERS@", base.HELPERS).replace("@READ@", READ).replace("@CUE@", cue).replace("@FADE@", str(FADE_MS))
|
||||
|
||||
|
||||
def quiet(found: dict) -> dict:
|
||||
@@ -162,7 +235,10 @@ class TestWorkbenchBubbles(HubCase):
|
||||
|
||||
def synthesize(body: bytes) -> bytes:
|
||||
word = json.loads(body)["text"]
|
||||
if word.startswith(CUE):
|
||||
if word == f"{CUE}-long":
|
||||
with (self.council / "news.jsonl").open("a", encoding="utf-8") as handle:
|
||||
handle.write(self.jsonl([{"ts": time.time(), "from": "Stage", "to": [], "text": LONG, "class": "security", "v": 2}]))
|
||||
elif word.startswith(CUE):
|
||||
now = time.time()
|
||||
rows = [
|
||||
{"ts": now - 0.01, "from": "Stage", "to": [], "text": FIRST, "class": "security", "v": 2},
|
||||
@@ -189,18 +265,66 @@ class TestWorkbenchBubbles(HubCase):
|
||||
{"width": width, "height": height, "url": None, "wait": 0, "probe": probe(BUBBLES_GROW), "shot": f"{shot}-grown.png", "media": media},
|
||||
{"width": width, "height": height, "url": None, "wait": 0, "probe": probe(BUBBLES_DONE), "shot": None, "media": media},
|
||||
]
|
||||
if width == 1366:
|
||||
steps.append({"width": width, "height": height, "url": None, "wait": 0, "probe": probe(BUBBLES_LONG), "shot": None, "media": media})
|
||||
if three and width == 1366:
|
||||
steps.append({"width": width, "height": height, "url": f"{self.base}?3d#agents/3d", "wait": 1500, "probe": probe(BUBBLES_3D), "shot": f"{shot}-3d.png"})
|
||||
steps.append({"width": width, "height": height, "url": f"{self.base}?{width}-reloaded#{view}", "wait": 1200, "probe": probe(BUBBLES_KEPT), "shot": f"{shot}-off.png", "media": media})
|
||||
if width == 1366:
|
||||
steps += [
|
||||
{"width": width, "height": height, "url": f"{self.base}?{width}-stream#stream", "wait": 1200, "probe": probe(BUBBLES_ON), "shot": f"{shot}-stream.png", "media": media},
|
||||
{"width": width, "height": height, "url": None, "wait": 0, "probe": probe(BUBBLES_DONE), "shot": None, "media": media},
|
||||
{"width": width, "height": height, "url": f"{self.base}?{width}-stream-reloaded#stream", "wait": 1200, "probe": probe(BUBBLES_KEPT), "shot": None, "media": media},
|
||||
]
|
||||
return steps
|
||||
|
||||
def aimed(self, found: dict, anchor: tuple[float, float] | None = None) -> None:
|
||||
aim = found["aim"]
|
||||
mid, top = anchor or (aim["mid"], aim["top"])
|
||||
self.assertIsNotNone(mid, found)
|
||||
self.assertAlmostEqual(aim["tip"], mid, delta=4, msg=found)
|
||||
self.assertAlmostEqual(aim["bottom"], max(top - 4, 8 + aim["height"]), delta=4, msg=found)
|
||||
|
||||
def check(self, data: dict, browser: str, calm: bool, three: bool) -> None:
|
||||
results = iter(data["results"])
|
||||
for width, _ in base.WIDTHS:
|
||||
on, grow, done = next(results), next(results), next(results)
|
||||
long = next(results) if width == 1366 else None
|
||||
solid = next(results) if three and width == 1366 else None
|
||||
kept = next(results)
|
||||
stream = [next(results), next(results), next(results)] if width == 1366 else None
|
||||
first_key, second_key = self.keys["Stage"], self.keys[SECOND_FROM[width]]
|
||||
with self.subTest(browser=browser, width=width, part="anchor"):
|
||||
self.assertNotIn("error", on, on)
|
||||
self.assertEqual(on["layer"]["position"], "fixed")
|
||||
self.assertEqual(on["layer"]["events"], "none")
|
||||
self.assertTrue(0 <= on["layer"]["bar"] <= 48, on["layer"])
|
||||
self.aimed(on["first"])
|
||||
if SECOND_ANCHORED[width]:
|
||||
self.aimed(on["second"])
|
||||
else:
|
||||
self.assertEqual((on["second"]["bar"], on["second"]["aim"]["mid"]), (True, None), on["second"])
|
||||
with self.subTest(browser=browser, width=width, part="fade"):
|
||||
fading = grow["fading"]
|
||||
self.assertIsNotNone(fading, grow)
|
||||
self.assertIsNotNone(fading["reference"], fading)
|
||||
self.assertIsNotNone(fading["removed"], fading)
|
||||
self.assertTrue(0 <= fading["seconds"] <= FADE_MS / 1000 and (fading["seconds"] > 0 or (calm and width == 390)), fading)
|
||||
self.assertLessEqual(fading["removed"], fading["reference"] + FADE_SLACK, fading)
|
||||
if stream is not None:
|
||||
with self.subTest(browser=browser, width=width, view="stream"):
|
||||
shown, cleared, switched = stream
|
||||
self.assertNotIn("error", shown, shown)
|
||||
self.assertEqual((shown["before"], shown["on"]), (["false", True], True))
|
||||
self.assertEqual((shown["first"]["who"], shown["first"]["scale"], shown["first"]["state"]), (first_key, 1, "speaking"), shown)
|
||||
self.assertEqual((shown["second"]["scale"], shown["second"]["state"]), (0.8, "waiting"), shown)
|
||||
for found in (shown["first"], shown["second"]):
|
||||
if found["aim"]["mid"] is None:
|
||||
self.assertEqual((found["anchored"], found["bar"]), (False, True), found)
|
||||
else:
|
||||
self.aimed(found)
|
||||
self.assertTrue(quiet(cleared)["cleared"], cleared)
|
||||
self.assertEqual(quiet(switched), {"kept": ["true", False, "Speech bubbles", "Speech bubbles"], "off": True, "display": "none", "bubbles": 0, "violations": []})
|
||||
with self.subTest(browser=browser, width=width):
|
||||
self.assertNotIn("error", on, on)
|
||||
self.assertEqual((on["before"], on["on"]), (["false", True], True))
|
||||
@@ -224,6 +348,12 @@ class TestWorkbenchBubbles(HubCase):
|
||||
self.assertEqual(grown["text"], " ".join(SECOND.split()[: grown["words"]]))
|
||||
self.assertEqual(quiet(done), {"cleared": True, "faces": ["loaded"], "hidden": False, "violations": []})
|
||||
self.assertEqual(quiet(kept), {"kept": ["true", False, "Speech bubbles", "Speech bubbles"], "off": True, "display": "none", "bubbles": 0, "violations": []})
|
||||
if long is not None:
|
||||
with self.subTest(browser=browser, width=width, bubble="long"):
|
||||
self.assertNotIn("error", long, long)
|
||||
self.assertEqual((long["text"], long["overflow"], long["scrolled"], long["gone"]), (LONG, True, True, True), long)
|
||||
self.assertTrue(5.5 < long["lines"] <= 6.05, long)
|
||||
self.assertLessEqual(long["gap"], 2, long)
|
||||
if solid is not None:
|
||||
with self.subTest(browser=browser, view="3d"):
|
||||
self.assertNotIn("error", solid, solid)
|
||||
@@ -232,6 +362,10 @@ class TestWorkbenchBubbles(HubCase):
|
||||
self.assertEqual((read["who"], read["anchored"]), (first_key, True), solid)
|
||||
middle = (read["box"]["left"] + read["box"]["right"]) / 2
|
||||
self.assertTrue(graph["left"] <= middle <= graph["right"] and graph["top"] - 16 <= read["box"]["bottom"] <= graph["bottom"], solid)
|
||||
self.assertIsNotNone(read["projected"], solid)
|
||||
self.aimed(read, (read["projected"]["x"], read["projected"]["y"] - 8))
|
||||
moved = solid["later"]["projected"], solid["first"]["projected"]
|
||||
self.assertGreater(abs(moved[0]["x"] - moved[1]["x"]) + abs(moved[0]["y"] - moved[1]["y"]), 20, solid)
|
||||
self.assertFalse(self.httpd.hub.settings.get()["bubbles"])
|
||||
|
||||
def test_chromium_reads_two_rows_without_tts_as_growing_bubbles_keeps_the_switch_and_hides_the_layer_at_three_widths(self):
|
||||
|
||||
@@ -70,6 +70,85 @@ async function failed(bubbles, item, cancel) {
|
||||
}));
|
||||
})();
|
||||
"""
|
||||
STOP_PROBE = """
|
||||
const fs = require("fs");
|
||||
const vm = require("vm");
|
||||
const Bubbles = require(process.argv[1]);
|
||||
const code = process.argv.slice(2).map((path) => fs.readFileSync(path, "utf8")).join("\\n");
|
||||
class Node {
|
||||
constructor(attrs) {
|
||||
Object.assign(this, {children: [], parentElement: null, dataset: {}, classes: new Set(), attrs: {}, textContent: "", hidden: false, offsetWidth: 120, offsetHeight: 40, scrollTop: 0, scrollHeight: 0});
|
||||
this.style = {setProperty: () => null, removeProperty: () => null};
|
||||
this.classList = {add: (name) => this.classes.add(name), contains: (name) => this.classes.has(name)};
|
||||
for (const [key, value] of Object.entries(attrs || {})) {
|
||||
if (key === "class") {
|
||||
value.split(" ").forEach((name) => this.classes.add(name));
|
||||
} else if (key.startsWith("data-")) {
|
||||
this.dataset[key.slice(5)] = value;
|
||||
} else {
|
||||
this.attrs[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
append(...nodes) {
|
||||
for (const node of nodes.filter((entry) => entry instanceof Node)) {
|
||||
node.remove();
|
||||
node.parentElement = this;
|
||||
this.children.push(node);
|
||||
}
|
||||
}
|
||||
remove() {
|
||||
if (this.parentElement) {
|
||||
this.parentElement.children = this.parentElement.children.filter((node) => node !== this);
|
||||
this.parentElement = null;
|
||||
}
|
||||
}
|
||||
setAttribute(key, value) {
|
||||
this.attrs[key] = String(value);
|
||||
}
|
||||
querySelectorAll(selector) {
|
||||
const below = (node) => node.children.flatMap((child) => [child, ...below(child)]);
|
||||
return below(this).filter((node) => node.classes.has(selector.slice(1)));
|
||||
}
|
||||
querySelector(selector) {
|
||||
return this.querySelectorAll(selector)[0] || null;
|
||||
}
|
||||
}
|
||||
function run(scenario) {
|
||||
const layer = new Node({class: "bubbles"});
|
||||
layer.append(new Node({class: "bubble-bar"}));
|
||||
const toggle = new Node({});
|
||||
const frames = [];
|
||||
const context = {
|
||||
Bubbles, layer, toggle, frames, out: null, stops: 0,
|
||||
speech: {pending: [], busy: false, current: null, loading: null, timer: 0, warned: 0, source: null},
|
||||
settings: {bubbles: true},
|
||||
document: {getElementById: (id) => (id === "bubbles" ? layer : toggle), querySelectorAll: () => [], fonts: {add: () => null}},
|
||||
window: {innerWidth: 1366, innerHeight: 768, requestAnimationFrame: (next) => frames.push(next), cancelAnimationFrame: () => null, setTimeout: () => 0, clearTimeout: () => null},
|
||||
performance: {now: () => 2000}, CSS: {escape: (value) => value}, g3: {tab: "stream"}, anchor3d: () => () => null,
|
||||
h: (tag, attrs, ...children) => {
|
||||
const node = new Node(attrs);
|
||||
node.append(...children);
|
||||
return node;
|
||||
},
|
||||
nameOf: (key) => key, fixed: (value) => value.toFixed(1), fetch: async () => ({ok: false, status: 404}), FontFace: class {},
|
||||
drawSpeaker: () => null, toast: () => null, saveSettings: () => null, context: () => null, Voice: {enqueue: (pending, next) => [...pending, next]}, SPEECH_QUEUE: 9, SPEECH_QUIET: 0,
|
||||
};
|
||||
vm.runInNewContext(`${code}
|
||||
const playing = {who: "A", line: "Disk almost full", words: ["Disk", "almost", "full"], started: 1000, duration: 3};
|
||||
const next = {who: "B", line: "Gate green", words: ["Gate", "green"]};
|
||||
const quiet = {who: "C", line: "Docs green", words: ["Docs", "green"], silent: true};
|
||||
Object.assign(speech, {current: playing, busy: true, source: {stop: () => { stops += 1; }}, pending: [next, quiet]});
|
||||
drawBubbles();
|
||||
const before = layer.querySelectorAll(".speech-bubble").length;
|
||||
${scenario}
|
||||
frames.splice(0).forEach((frame) => frame());
|
||||
out = {before, after: layer.querySelectorAll(".speech-bubble").length, shown: bubbles.shown.size, stops, current: speech.current === playing, busy: speech.busy,
|
||||
pending: speech.pending.map((item) => item.who), hidden: layer.hidden, pressed: toggle.attrs["aria-pressed"] || null};`, context);
|
||||
return context.out;
|
||||
}
|
||||
console.log(JSON.stringify({stop: run("cancelSpeech();"), off: run("settings.bubbles = false;\\nsyncBubbles();")}));
|
||||
"""
|
||||
|
||||
|
||||
class TestBubbleSchedule(unittest.TestCase):
|
||||
@@ -112,6 +191,19 @@ class TestSpeechFallback(unittest.TestCase):
|
||||
self.assertEqual(data[case], {"current": False, "busy": False, "timer": 0, "started": None, "duration": None, "shown": failed})
|
||||
|
||||
|
||||
class TestBubbleStop(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
done = subprocess.run(["node", "-e", STOP_PROBE, str(BUBBLES), str(SPEECH), str(LAYER)], capture_output=True, text=True, timeout=60, check=True)
|
||||
cls.data = json.loads(done.stdout)
|
||||
|
||||
def test_stop_speaking_clears_every_bubble_at_once_and_stops_the_audio(self):
|
||||
self.assertEqual(self.data["stop"], {"before": 3, "after": 0, "shown": 0, "stops": 1, "current": False, "busy": True, "pending": [], "hidden": False, "pressed": None})
|
||||
|
||||
def test_switching_the_bubbles_off_clears_the_layer_and_leaves_the_audible_item_playing(self):
|
||||
self.assertEqual(self.data["off"], {"before": 3, "after": 0, "shown": 0, "stops": 0, "current": True, "busy": True, "pending": ["B"], "hidden": True, "pressed": "false"})
|
||||
|
||||
|
||||
class TestBubbleAssets(unittest.TestCase):
|
||||
def test_the_font_is_pinned_and_carries_the_ofl_without_a_reserved_name(self):
|
||||
data = FONT.read_bytes()
|
||||
|
||||
@@ -4,6 +4,7 @@ import ast
|
||||
import importlib.util
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import secrets
|
||||
import shutil
|
||||
import subprocess
|
||||
@@ -126,6 +127,15 @@ class TestHubCleanup(HubCase):
|
||||
self.assertIn("deleteDialog(items, locked, held)", page)
|
||||
self.assertIn("held by a worktree: not deleted here", (HUB / "templates" / "page-cleanup.js").read_text(encoding="utf-8"))
|
||||
|
||||
def test_the_delete_sheet_renders_the_dry_run_note_as_visible_text(self):
|
||||
dialog = (HUB / "templates" / "page-cleanup.js").read_text(encoding="utf-8")
|
||||
sheet = dialog[dialog.index("openSheet("):]
|
||||
note = re.search(r'\[\n\s*h\("p", \{class: "muted"\}, "([^"]+)"\),\n', sheet)
|
||||
self.assertIsNotNone(note, sheet[:400])
|
||||
for part in ("it deletes the local branch", "never touches a worktree, Compose stack or volume", "A branch held by a worktree is not deleted here", "its docker compose down -v deletes the stack's volumes", "the host refuses an entry whose plan deletes one", "refuses every entry whose state has changed since"):
|
||||
self.assertIn(part, note.group(1))
|
||||
self.assertEqual(dialog.count(note.group(1)), 1)
|
||||
|
||||
@unittest.skipUnless(INSTALLED_PKGMGR, "no pkgmgr installed")
|
||||
def test_every_volume_text_states_the_compose_down_argv_of_the_installed_pkgmgr(self):
|
||||
found = subprocess.run([str(Path(INSTALLED_PKGMGR).parent / "python"), "-I", "-c", "import pkgmgr.actions.branch.gc as gc; print(gc.__file__)"], capture_output=True, text=True, timeout=60, check=True)
|
||||
|
||||
+54
-1
@@ -4,12 +4,17 @@ import ast
|
||||
import datetime
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from hub_case import HubCase
|
||||
from hub_support import HUB, PAGE
|
||||
from hub_support import GIT_ENV, HUB, PAGE
|
||||
|
||||
GENERATED = datetime.datetime(2026, 11, 6, 12, tzinfo=datetime.UTC).timestamp()
|
||||
PKGMGR = shutil.which("pkgmgr")
|
||||
FIXTURE = Path(__file__).parent / "branch-tree.json"
|
||||
|
||||
|
||||
def starts_git(path) -> list[int]:
|
||||
@@ -40,6 +45,54 @@ class TestHubTree(HubCase):
|
||||
self.assertEqual(trees, [(demo, False, 0, [], None), (feature, True, 1, ["Skills"], {"status": "pending", "gate": "pass", "title": "feat: tree"})])
|
||||
self.assertEqual([(tree["path"], tree["workers"]) for tree in repos[demo]["detached"]], [(f"{root}/worktrees/github.com/me/demo/detached", [])])
|
||||
|
||||
@unittest.skipUnless(PKGMGR, "pkgmgr is not on PATH: the check that /api/tree serves a file pkgmgr branch tree wrote cannot run, install package-manager to cover 001 S12")
|
||||
def test_tree_serves_the_file_pkgmgr_branch_tree_wrote_for_a_fixture_repository_in_the_fields_of_the_fixture(self):
|
||||
root = Path(os.path.realpath(self.outside)) / "pkgmgr"
|
||||
home, origin, repo = root / "home", root / "origin.git", root / "repos" / "github.com" / "me" / "demo"
|
||||
repo.mkdir(parents=True)
|
||||
self.git(root, "init", "--bare", "-b", "main", str(origin))
|
||||
self.git(repo, "init", "-b", "main")
|
||||
self.git(repo, "remote", "add", "origin", str(origin))
|
||||
(repo / ".git" / "info" / "exclude").write_text(".worktrees/\n", encoding="utf-8")
|
||||
(repo / "init.txt").write_text("init\n", encoding="utf-8")
|
||||
self.git(repo, "add", "init.txt")
|
||||
self.git(repo, "commit", "-m", "init")
|
||||
self.git(repo, "switch", "-c", "feature/done")
|
||||
(repo / "done.txt").write_text("done\n", encoding="utf-8")
|
||||
self.git(repo, "add", "done.txt")
|
||||
self.git(repo, "commit", "-m", "done")
|
||||
self.git(repo, "switch", "main")
|
||||
self.git(repo, "merge", "--no-ff", "-m", "merge feature/done", "feature/done")
|
||||
self.git(repo, "push", "-u", "origin", "main")
|
||||
opened = repo / ".worktrees" / "feature" / "open"
|
||||
self.git(repo, "worktree", "add", "-b", "feature/open", str(opened), "main")
|
||||
(opened / "loose.txt").write_text("new\n", encoding="utf-8")
|
||||
config = home / ".config" / "pkgmgr" / "fixture.yml"
|
||||
config.parent.mkdir(parents=True)
|
||||
config.write_text(json.dumps({"directories": {"repositories": str(root / "repos")}, "repositories": [{"provider": "github.com", "account": "me", "repository": "demo", "directory": str(repo)}]}), encoding="utf-8")
|
||||
env = {
|
||||
"PATH": os.environ["PATH"], "HOME": str(home), "LANG": "C.UTF-8", **GIT_ENV, "DBUS_SESSION_BUS_ADDRESS": f"unix:path={root / 'no-bus'}",
|
||||
"XDG_CACHE_HOME": str(home / ".cache"), "XDG_STATE_HOME": str(home / ".local" / "state"), "PKGMGR_TREE_FILE": str(self.tree_file),
|
||||
}
|
||||
done = subprocess.run([PKGMGR, "branch", "tree", "--format", "json", "--output", str(self.tree_file)], cwd=root, env=env, capture_output=True, text=True, timeout=300, check=False)
|
||||
self.assertEqual(done.returncode, 0, done.stderr[-2000:])
|
||||
written = json.loads(self.tree_file.read_text(encoding="utf-8"))
|
||||
status, _, body = self.get("/api/tree")
|
||||
self.assertEqual(status, 200, body)
|
||||
data = json.loads(body)
|
||||
self.assertNotIn("error", data, data)
|
||||
self.assertEqual(data["scanned"], datetime.datetime.fromisoformat(written["generated_at"]).timestamp())
|
||||
self.assertEqual([(entry["path"], entry["name"], entry["known"]) for entry in data["repos"]], [(str(repo), "github.com/me/demo", True)])
|
||||
branches = {entry["name"]: entry for entry in data["repos"][0]["branches"]}
|
||||
self.assertEqual(sorted(branches), ["feature/done", "feature/open", "main"])
|
||||
self.assertEqual((branches["main"]["state"], branches["feature/done"]["state"], branches["feature/done"]["merged_by"]), ("protected", "merged-clean", "ancestor"))
|
||||
trees = [(tree["path"], tree["dirty"], tree["untracked"]) for tree in branches["feature/open"]["worktrees"]]
|
||||
self.assertEqual(trees, [(str(opened), True, 1)])
|
||||
fixture = json.loads(FIXTURE.read_text(encoding="utf-8"))
|
||||
self.assertLessEqual(set(fixture), set(written))
|
||||
self.assertLessEqual({key for entry in fixture["repos"] for key in entry}, set(written["repos"][0]))
|
||||
self.assertLessEqual({key for entry in fixture["repos"] for item in entry["items"] for key in item}, {key for item in written["repos"][0]["items"] for key in item})
|
||||
|
||||
def test_tree_reads_the_file_again_once_it_changes(self):
|
||||
self.write_tree()
|
||||
self.assertEqual(len(json.loads(self.get("/api/tree")[2])["repos"]), 2)
|
||||
|
||||
@@ -49,7 +49,8 @@ elif tool == "systemctl":
|
||||
elif verb == "enable":
|
||||
state["enabled"] = sorted({*state["enabled"], unit})
|
||||
elif verb == "is-active":
|
||||
print("active")
|
||||
print("active" if unit in state["enabled"] else "inactive")
|
||||
code = 0 if unit in state["enabled"] else 3
|
||||
file.write_text(json.dumps(state))
|
||||
sys.exit(code)
|
||||
'''
|
||||
@@ -142,6 +143,19 @@ class TestOrchestratorMigration(unittest.TestCase):
|
||||
legacy_calls = [call for call in second["calls"][len(first["calls"]) :] if any(OLD in arg for arg in call)]
|
||||
self.assertEqual(legacy_calls, [["docker", "image", "inspect", f"{OLD}:local"], ["claude", "mcp", "get", OLD]])
|
||||
|
||||
def test_check_reports_the_sessions_timer_the_install_enabled_as_active(self):
|
||||
for tool in ("curl", "journalctl"):
|
||||
(self.root / "bin" / tool).symlink_to("stub")
|
||||
timer = f"{NEW}-sessions.timer"
|
||||
self.assertIn(timer, self.install()["enabled"])
|
||||
checked = subprocess.run(["bash", str(SCRIPT), "check"], env=self.env, capture_output=True, text=True, timeout=120, check=False)
|
||||
self.assertIn(f"ok {timer} active\n", checked.stdout, checked.stderr)
|
||||
state = json.loads(self.state.read_text(encoding="utf-8"))
|
||||
self.state.write_text(json.dumps({**state, "enabled": [unit for unit in state["enabled"] if unit != timer]}), encoding="utf-8")
|
||||
stopped = subprocess.run(["bash", str(SCRIPT), "check"], env=self.env, capture_output=True, text=True, timeout=120, check=False)
|
||||
self.assertIn(f"todo {timer} off: agent states wait for make orchestrator-install\n", stopped.stdout, stopped.stderr)
|
||||
self.assertNotIn(f"{timer} active", stopped.stdout)
|
||||
|
||||
def test_the_offices_unit_waits_for_the_installed_skill_scripts_of_this_tree(self):
|
||||
self.install()
|
||||
stale = self.home / ".claude" / "skills" / HOST_SCRIPTS[2]
|
||||
|
||||
Reference in new issue
Block a user