Hub: send in the field (032), coherent speak box (033), stream head band (034), Match at full width with its pile (035, 036), Home without the outer box (037), badge to Match (038), rejects that survive a changed or withdrawn card (039), the release card (040), code marks in the review diff (041), why Deny is off (042), the undo window clock (043), widgets without inner boxes (044), the Artifacts head on one line (045), accepting a red gate's risk (046), one code box (047), done rows greyed and folded (048), one control height (049), menus that stay open (050), radio settings in the Device card (051), bubbles beside the modes (052), agent settings on every face and name (053), pin only by menu (054), WASD in Match (055), the flowing card edge (056), Schedules in Controls (057) and the hub poll cost (059). Skills: the coach leaves for its own repository kevinveenbirkenbach/coach (058; test_install pins its four skills in skills-lock.json and stays red until that repository is published and pinned), hooks and timers start fewer processes (060), council files on hot paths stay bounded and mirror by marker instead of mtime (061), scripts and hooks hand agents less output (062), and block.py builds the commit table and message block in one run (063). Requirement documents 032 to 063 with their implementation amendments. MEDUSA false positives accepted after kvb-think-criticize (36 lines): MM-SCAN-058 (pla inside replace or plan), JB-SCAN-616/641 (the local clip helper), CODEGEN-SCAN-001 (drop-in paths), CGS-SCAN-029 (systemctl argv from constants), CGS-SCAN-040 (runner poll loop), FLA-SCAN-055 (feedback), WM-SCAN-354, AI-BACKDOOR-006, GENAI-SCAN-1270, B604 (runner shell path for passkey-verified commands), TC004, EXA002, EXA006, EXA010 and WEB-SSRF. 🎯 Fix: 92 % 💥 Break: 8 % 💸 Tokens: 89 % ⏱️ Velocity: – 🛡️ Security: ~100 % 🏆 Score: 95 🚦 Gate: ⛔ break 8 % > 5 Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
145 lines
7.5 KiB
Python
145 lines
7.5 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import os
|
|
import re
|
|
import shutil
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
HERE = Path(__file__).resolve().parent
|
|
sys.path[:0] = [str(HERE.parent), str(HERE)]
|
|
|
|
import hub_e2e_kit as base
|
|
import hub_support
|
|
from hub_case import HubCase
|
|
|
|
OUT = Path(os.environ.get("E2E_OUT", "/tmp/hub-031-shots"))
|
|
TEMPLATES = hub_support.HUB / "templates"
|
|
SCAN = """
|
|
const shown = (node) => Boolean(node && node.getClientRects().length);
|
|
const scan = () => all("button.mic").filter(shown).map((button) => {
|
|
const field = document.getElementById(button.getAttribute("aria-controls"));
|
|
const frame = button.closest(".mic-frame");
|
|
if (!field || !frame || field.parentElement !== frame) {
|
|
return {id: button.getAttribute("aria-controls"), framed: false};
|
|
}
|
|
const line = frame.classList.contains("mic-line");
|
|
const [outer, mic, text] = [frame.getBoundingClientRect(), button.getBoundingClientRect(), field.getBoundingClientRect()];
|
|
const foot = line ? null : frame.querySelector(":scope > .mic-foot");
|
|
const tail = line ? [...frame.children].slice([...frame.children].indexOf(button) + 1) : [];
|
|
const end = line ? frame.lastElementChild.getBoundingClientRect() : null;
|
|
const spans = (box) => Math.abs(box.top - outer.top - 1) <= 1 && Math.abs(outer.bottom - 1 - box.bottom) <= 1;
|
|
return {
|
|
id: field.id, label: field.getAttribute("aria-label") || "", framed: true, line,
|
|
last: line ? field.nextElementSibling === button && tail.every((node) => node.matches("button[type=submit]")) : Boolean(foot) && button.parentElement === foot && field.nextElementSibling === foot && [...foot.children].slice([...foot.children].indexOf(button) + 1).every((node) => node.matches(".ptt-split, .mayday-toggle")),
|
|
fits: line ? spans(mic) && Math.abs(outer.right - 1 - end.right) <= 1 : mic.bottom <= outer.bottom && mic.top >= text.bottom - 1,
|
|
divider: line ? getComputedStyle(button).borderLeftWidth : getComputedStyle(foot).borderTopWidth,
|
|
clear: line ? text.right <= mic.left + 0.5 : true,
|
|
send: tail.map((node) => ({fits: spans(node.getBoundingClientRect()), divider: getComputedStyle(node).borderLeftWidth, own: getComputedStyle(node).borderTopWidth})),
|
|
};
|
|
});
|
|
const ring = (field) => {
|
|
field.focus();
|
|
const frame = field.closest(".mic-frame");
|
|
return [getComputedStyle(frame).outlineStyle, getComputedStyle(field).outlineStyle];
|
|
};
|
|
const wide = () => document.documentElement.scrollWidth > innerWidth + 1;
|
|
"""
|
|
STREAM = """(async () => {@HELPERS@@SCAN@
|
|
const field = await until(() => document.querySelector('#main input[type="search"]'), 15000);
|
|
await until(() => field.closest(".mic-frame"), 4000);
|
|
const other = await until(() => document.querySelector("#main .option.other .mic-frame"), 8000);
|
|
const extra = document.body.appendChild(document.createElement("textarea"));
|
|
await sleep(100);
|
|
extra.remove();
|
|
await sleep(100);
|
|
const sends = other.closest("form").querySelectorAll("button[type=submit]").length;
|
|
return {mics: scan(), sends, ring: ring(field), wide: wide()};
|
|
})()"""
|
|
RULES = """(async () => {@HELPERS@@SCAN@
|
|
(await until(() => document.getElementById("controls-tab-rules"), 15000)).click();
|
|
await until(() => document.querySelector("#main .rule-form .mic-frame"), 4000);
|
|
return {mics: scan(), wide: wide()};
|
|
})()"""
|
|
RADIO = """(async () => {@HELPERS@@SCAN@
|
|
const area = await until(() => document.querySelector("#radio-spot form.composer textarea"), 15000);
|
|
await until(() => area.closest(".mic-frame"), 4000);
|
|
const foot = area.closest(".mic-frame").querySelector(".mic-foot");
|
|
const first = foot.firstElementChild;
|
|
const mic = foot.querySelector(":scope > button.mic");
|
|
const idle = getComputedStyle(mic).backgroundColor;
|
|
mic.setAttribute("aria-pressed", "true");
|
|
const recording = getComputedStyle(mic).backgroundColor;
|
|
mic.setAttribute("aria-pressed", "false");
|
|
area.style.height = "260px";
|
|
await sleep(100);
|
|
const after = scan().find((entry) => entry.id === area.id);
|
|
return {mics: scan(), record: first.textContent.trim() || first.getAttribute("aria-label"), looks: idle !== recording, resized: after, ring: ring(area), wide: wide()};
|
|
})()"""
|
|
|
|
|
|
def probe(template: str) -> str:
|
|
return template.replace("@HELPERS@", base.HELPERS).replace("@SCAN@", SCAN)
|
|
|
|
|
|
class TestMicSource(unittest.TestCase):
|
|
def test_no_page_module_but_the_mic_helper_inserts_a_mic_button(self):
|
|
callers = [path.name for path in TEMPLATES.glob("*.js") if path.name != "page-mic.js" and re.search(r"micButton\(", path.read_text(encoding="utf-8"))]
|
|
self.assertEqual(callers, [])
|
|
|
|
|
|
@unittest.skipUnless(shutil.which(os.environ.get("CHROMIUM", "chromium")), "no Chromium")
|
|
class TestMicFrames(HubCase):
|
|
drive = base.OrchestratorE2ECase.drive
|
|
|
|
def setUp(self):
|
|
super().setUp()
|
|
OUT.mkdir(parents=True, exist_ok=True)
|
|
self.claim("s1", "Skills")
|
|
decided = self.tool("decision_request", {"question": "Merge the mic frames?", "options": hub_support.OPTIONS, "agent": "Skills", "recommended": ""})
|
|
self.assertFalse(decided["isError"], decided)
|
|
self.snapshot()
|
|
self.page_url = f"http://localhost:{self.port}/"
|
|
|
|
def check_mics(self, mics: list[dict]) -> None:
|
|
self.assertTrue(mics)
|
|
for entry in mics:
|
|
with self.subTest(field=entry["id"]):
|
|
self.assertTrue(entry["framed"], entry)
|
|
self.assertEqual((entry["last"], entry["fits"], entry["divider"], entry["clear"]), (True, True, "1px", True), entry)
|
|
|
|
def test_chromium_joins_every_mic_into_its_field_frame_at_three_widths(self):
|
|
steps = []
|
|
for width, height in base.WIDTHS:
|
|
shot = OUT / f"chromium-{width}"
|
|
steps += [
|
|
{"width": width, "height": height, "url": f"{self.page_url}?{width}#stream", "wait": 1200, "probe": probe(STREAM), "shot": f"{shot}-stream.png"},
|
|
{"width": width, "height": height, "url": f"{self.page_url}?{width}-rules#stream/rules", "wait": 1200, "probe": probe(RULES), "shot": f"{shot}-rules.png"},
|
|
{"width": width, "height": height, "url": f"{self.page_url}?{width}-radio#stream/radio", "wait": 1200, "probe": probe(RADIO), "shot": f"{shot}-radio.png"},
|
|
]
|
|
data = self.drive(steps, None)
|
|
(OUT / "chromium-mic-frames.json").write_text(json.dumps(data, indent=1), encoding="utf-8")
|
|
self.assertEqual(data["errors"], [])
|
|
results = iter(data["results"])
|
|
for width, _ in base.WIDTHS:
|
|
stream, rules, radio = next(results), next(results), next(results)
|
|
with self.subTest(width=width):
|
|
for found in (stream, rules, radio):
|
|
self.assertNotIn("error", found, found)
|
|
self.check_mics(found["mics"])
|
|
self.assertFalse(found["wide"])
|
|
other = [entry for entry in stream["mics"] if entry["label"].startswith("Other answer to ")]
|
|
self.assertEqual([entry["send"] for entry in other], [[{"fits": True, "divider": "1px", "own": "0px"}]], other)
|
|
self.assertEqual(stream["sends"], 1)
|
|
self.assertEqual(stream["ring"], ["solid", "none"])
|
|
self.assertEqual(radio["ring"], ["solid", "none"])
|
|
self.assertEqual(radio["record"], "Record")
|
|
self.assertTrue(radio["looks"])
|
|
self.assertEqual((radio["resized"]["last"], radio["resized"]["fits"]), (True, True), radio["resized"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|