Merge branch 'feature/hub-radio-redesign' into unify/skills-20261114

# Conflicts:
#	orchestrator/templates/panels.js
#	tests/test_hub_home.py
This commit is contained in:
Kevin Veen-Birkenbach committed 2026-11-14 21:57:43 +00:00
commit 1c8e5845ac
19 files changed
+2119 -228

No files matched your search

+1
View File
@@ -10,6 +10,7 @@ import {join} from "node:path";
const [binary, planFile] = process.argv.slice(2);
const plan = JSON.parse(readFileSync(planFile, "utf8"));
const profile = mkdtempSync(join(tmpdir(), "bidi-"));
writeFileSync(join(profile, "user.js"), ['user_pref("media.navigator.streams.fake", true);', 'user_pref("media.navigator.permission.disabled", true);', ""].join("\n"));
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const port = await new Promise((resolve) => {
const probe = createServer().listen(0, "127.0.0.1", () => {
+10 -5
View File
@@ -437,7 +437,8 @@ OVERLAP = """
found.push(`${called(a.node)} × ${called(b.node)}`);
}
}));
const outside = boxes.filter(({box}) => box.right > root.getBoundingClientRect().right + 0.5).map(({node}) => called(node));
const framed = (node) => (getComputedStyle(node).display === "contents" ? framed(node.parentElement) : node);
const outside = boxes.filter(({box}) => box.right > framed(root).getBoundingClientRect().right + 0.5).map(({node}) => called(node));
return {found, outside};
};
"""
@@ -503,6 +504,8 @@ MEDIA = """
ADD_STATION = """(async () => {@HELPERS@
const clock = (date) => `${String(date.getHours()).padStart(2, "0")}:${String(date.getMinutes()).padStart(2, "0")}`;
location.hash = "#stream/radio";
const fold = await until(() => document.querySelector("#radio-spot details.radio-station"), 8000);
fold.open = true;
const edit = await until(() => all("#radio-spot button").find((button) => text(button) === "Edit stations" && button.getClientRects().length), 8000);
edit.click();
const form = await until(() => document.querySelector('.sheet-box form[aria-label="Stations"]'), 8000);
@@ -534,6 +537,8 @@ RADIO_STATE = """(async () => {@HELPERS@@MEDIA@
})()""".replace("@HELPERS@", HELPERS).replace("@MEDIA@", MEDIA)
RADIO_VIEW = """(async () => {@HELPERS@@MEDIA@
location.hash = "#stream/radio";
const fold = await until(() => document.querySelector("#radio-spot details.radio-station"), 8000);
fold.open = true;
const row = await until(() => all('#radio-spot [data-station="0"]').find((item) => item.getClientRects().length), 8000);
if (!row) {
const initial = JSON.parse(document.getElementById("state").textContent);
@@ -2109,7 +2114,7 @@ class TestOrchestratorE2E(HubCase):
self.assertEqual(sent["inline"], ["static", True, True])
self.assertEqual((sent["toolbar"], sent["channels"], sent["record"]), (["Priority", "Day/Night", "Status"], CHOICE_CHANNELS, ["Record"]))
self.assertEqual(sent["heads"], [["Read aloud", "Read aloud: the classes and agents the radio sounds for"], ["Cancel mayday", "Cancel mayday: lift the radio silence so the agents write again; your passkey signs it"]])
self.assertEqual((sent["tall"], sent["wide"]), (False, False))
self.assertEqual((sent["tall"], sent["wide"]), (width == 390, False))
self.assertEqual([run["cls"] for run in sent["runs"]], CHOICE_CHANNELS)
for run in sent["runs"]:
direct = run["cls"] in ("post", "call")
@@ -2121,8 +2126,8 @@ class TestOrchestratorE2E(HubCase):
self.assertEqual([entry[1:] for entry in saved["classes"] if entry[0] == "MAYDAY"], [["true", True]])
self.assertEqual((saved["kept"], saved["after"]), ([float(squelch), tone == "true", post == "true"], ["false", False]))
self.assertEqual(saved["general"], {"sections": ["Ambience", "Location", "Appearance", "Music", "Notifications", "Passkey"], "radio": 0})
self.assertEqual((saved["tall"], saved["wide"]), (False, False))
self.assertEqual(read, {"squelch": float(squelch), "tone": tone == "true", "post": post == "true", "tall": False, "wide": False})
self.assertEqual((saved["tall"], saved["wide"]), (width == 390, False))
self.assertEqual(read, {"squelch": float(squelch), "tone": tone == "true", "post": post == "true", "tall": width == 390, "wide": False})
heads = {"post": ["post", "--to", "Stage"], "call": ["send", "call", "--to", "Stage"], "newsletter": ["post"]}
radio = [args for script, args in self.scripts.calls if script == skill_scripts.RADIO]
sends = [(width, cls) for width, _ in WIDTHS for cls in CHOICE_CHANNELS]
@@ -2161,7 +2166,7 @@ class TestOrchestratorE2E(HubCase):
self.assertEqual((sent["closed"], sent["open"], sent["inline"]), ([True, "false"], [False, "true", True], ["static", True, True]))
self.assertEqual((sent["toolbar"], sent["channels"], sent["record"]), (["Priority", "Day/Night", "Status"], CHOICE_CHANNELS, ["Record"]))
self.assertEqual(sent["heads"], [["Read aloud", "Read aloud: the classes and agents the radio sounds for"], ["Cancel mayday", hint]])
self.assertEqual((sent["tall"], sent["wide"]), (False, False))
self.assertEqual((sent["tall"], sent["wide"]), (width == 390, False))
self.assertEqual([run["cls"] for run in sent["runs"]], CHOICE_CHANNELS)
for run in sent["runs"]:
direct = run["cls"] in ("post", "call")
File diff suppressed because it is too large. Load diff
+5 -4
View File
@@ -127,7 +127,7 @@ RADIO = """
await sleep(150);
};
const chips = () => Object.fromEntries(all(".chip-select", spot).map((box) => [box.dataset.chip, box.querySelector("select").value]));
const search = () => spot.querySelector('.radio-filters input[type="search"]');
const search = () => spot.querySelector('.radio-logbox input[type="search"]');
const tab = async (id) => {
spot.querySelector(`.radio-tabs [data-tab="${id}"]`).click();
await sleep(150);
@@ -187,10 +187,11 @@ LOG = """(async () => {@HELPERS@@RADIO@
all(".radio-filters button", spot).find((button) => name(button) === "Clear filters").click();
await sleep(150);
const clearedChips = [chips(), search().value, rows().length];
const summary = spot.querySelector(".radio-row summary");
summary.click();
spot.querySelector(".radio-row .radio-pick").click();
const full = await until(() => document.getElementById("popup").open && document.querySelector("#popup .radio-full"), 4000);
const opened = [document.getElementById("popup").open, text(full)];
all("#popup .popup-head button").find((button) => name(button) === "Close").click();
await sleep(150);
const opened = [summary.parentElement.open, text(summary.parentElement.querySelector(".radio-full"))];
await tab("received");
await chip("agent", "Stage");
search().value = "gate";
+9 -2
View File
@@ -79,6 +79,8 @@ const swapped = P.add(P.remove(one.pins, "panel", "agents/3d"), "panel", "tasks/
const both = [...one.pins, {kind: "panel", id: "tasks/3d", w: 6, h: 4}];
out.group = [one.refused, second.refused, second.holder, second.pins.length, swapped.refused, swapped.pins.at(-1).id, P.add(one.pins, "panel", "tasks/gantt").refused,
P.firstOfGroup(both, both[4]), P.firstOfGroup(both, both[5]), P.firstOfGroup(both, both[0])];
P.panel("radio", "Radio", () => "r", "", [12, 7]);
out.sized = [P.add(pins, "panel", "radio").pins.at(-1), P.add(pins, "panel", "tasks/gantt").pins.at(-1), P.add(pins, "task", "work/z").pins.at(-1)];
console.log(JSON.stringify(out));
"""
REGISTRY_PROBE = """
@@ -216,7 +218,8 @@ const server = hub([]);
const tab = page(server);
const {homePress, homeUnpin, homeView, Panels} = tab;
const ids = Object.fromEntries(["panel", "task", "message", "artifact", "agent", "ancestry", "metric", "nope"].map((kind) => [kind, Boolean(Panels.lookup(kind, kind === "panel" ? "stream" : "x"))]));
const panels = ["stream", "radio-log", "agents/orbit", "agents/chord", "agents/swimlane", "agents/3d", "agents/tree", "agents/hierarchy", "agents/order", "artifacts/orbit", "artifacts/chord", "artifacts/swimlane", "artifacts/tree", "artifacts/3d",
const panels = ["stream", "radio-log", "radio", "radio-device", "radio-speak", "agents/orbit", "agents/chord", "agents/swimlane", "agents/3d", "agents/tree", "agents/hierarchy", "agents/order",
"artifacts/orbit", "artifacts/chord", "artifacts/swimlane", "artifacts/tree", "artifacts/3d",
"tasks/list", "tasks/board", "tasks/rasci", "tasks/gantt", "tasks/burn", "tasks/3d", "tasks/operator"].filter((id) => !Panels.lookup("panel", id));
(async () => {
homePress("panel", "tasks/gantt", "Gantt");
@@ -613,6 +616,10 @@ class TestHomeReorder(unittest.TestCase):
holder = {"kind": "panel", "id": "agents/3d", "w": 6, "h": 4}
self.assertEqual(data["group"], ["", "group", holder, 5, "", "tasks/3d", "", True, False, True])
def test_a_panel_with_its_own_size_is_pinned_at_it_and_the_rest_at_the_default(self):
data = node(REORDER_PROBE, str(PANELS))
self.assertEqual(data["sized"], [{"kind": "panel", "id": "radio", "w": 12, "h": 7}, PIN, {"kind": "task", "id": "work/z", "w": 4, "h": 3}])
class TestHomeRegistry(unittest.TestCase):
def test_the_registry_finds_panels_and_item_kinds_and_a_missing_item_renders_none(self):
@@ -692,7 +699,7 @@ class TestHomePage(unittest.TestCase):
marked = set(re.findall(r"\['[^']+', \"([^\"]+)\"\]", home))
captured = set(re.findall(r'Panels\.capture\("([^"]+)"', home))
made = set(re.findall(r'\{kind: "(\w+)", id, view[,}]', sources))
self.assertEqual((len(literal), marked), (7, {"radio-log"}))
self.assertEqual((len(literal), marked), (11, {"radio-log"}))
literal |= marked
self.assertEqual(len(dynamic), 13)
self.assertEqual(sorted(literal | dynamic), sorted(registered))
+12 -2
View File
@@ -163,11 +163,11 @@ async function stalled() {
function pressed() {
const calls = [];
const sandbox = {RadioSet, h: (tag, attrs, ...children) => ({tag, attrs: attrs || {}, children: children.flat()}), icon: (name) => name, named: (label, hint) => ({"aria-label": label, title: hint})};
vm.runInNewContext(`${viewCode}\\nradioDom = {};`, sandbox);
vm.runInNewContext(viewCode, sandbox);
sandbox.knobs = () => [];
sandbox.context = () => calls.push("context");
sandbox.keepRadio = (change) => calls.push(change);
const modes = sandbox.faceplate().children.find((child) => child.attrs["aria-label"] === "Mode");
const modes = sandbox.faceplate({}).children.find((child) => child.attrs["aria-label"] === "Mode");
modes.children.forEach((button) => button.attrs.on.click());
return calls;
}
@@ -425,6 +425,7 @@ MESSAGES = [
{"id": "a" * 16, "to": "Stage", "text": "rebase please", "created_ts": 10, "class": "post", "voice": "v0"},
{"id": "b" * 16, "to": "*", "text": "deploy now", "created_ts": 50, "class": "broadcast", "voice": "v0"},
]
TWINS = [*LOG, {"ts": 90, "from": "Docs", "to": [], "class": "newsletter", "text": "twin one"}, {"ts": 90, "from": "Docs", "to": [], "class": "broadcast", "text": "twin two"}]
def run(calls: dict[str, list[list]]) -> dict:
@@ -460,6 +461,7 @@ class TestRadioSetModule(unittest.TestCase):
"plans": plans,
"stored": [["valid", value] for value in stored],
"logs": [["logRows", LOG, entry, HUMAN, MESSAGES] for entry in entries],
"twins": [["logRows", TWINS, entry, HUMAN, MESSAGES] for entry in (entries[0], {**entries[0], "chips": {**entries[0]["chips"], "class": "broadcast"}}, entries[1])],
"counts": [["counts", LOG, HUMAN, MESSAGES]],
"ledger": [["ledgerOf", {"text": f"deploy now [kvb-orchestrator msg {'b' * 16}]"}, MESSAGES], ["ledgerOf", {"text": f"forged [kvb-orchestrator msg {'c' * 16}]"}, MESSAGES], ["ledgerOf", LOG[-1], MESSAGES]],
"choices": [["choices", LOG]],
@@ -541,6 +543,14 @@ class TestRadioSetModule(unittest.TestCase):
self.assertEqual(self.data["choices"][0]["agent"], ["Docs", "Operator", "Skills", "Stage"])
self.assertEqual(self.data["cleared"], [{"tab": "all", "chips": {"class": "", "from": "", "to": "", "agent": ""}, "q": ""}])
def test_every_log_row_has_a_unique_key_that_a_filter_keeps_and_twins_of_one_time_and_sender_differ(self):
everything, broadcasts, sent = ({row["text"]: row["key"] for row in rows} for rows in self.data["twins"])
self.assertEqual(len(set(everything.values())), len(TWINS), everything)
self.assertEqual((everything["twin one"], everything["twin two"]), ("90 Docs 0", "90 Docs 1"), everything)
self.assertEqual(broadcasts, {text: everything[text] for text in broadcasts}, broadcasts)
self.assertIn("twin two", broadcasts)
self.assertEqual(sent, {"deploy now": f"sent {'b' * 16} 0", "rebase please": f"sent {'a' * 16} 0"}, sent)
def test_sent_comes_from_the_hub_ledger_and_a_row_only_named_operator_is_not_sent(self):
sent = self.data["logs"][1]
self.assertEqual([(row["to"], row["class"], row["sent"]) for row in sent], [([], "broadcast", True), (["Stage"], "post", True)])