feat(orchestrator): Home tab with pinned panels on a 12-column grid (008)

A Home tab left of Stream shows every panel and item the operator starred: a star on every panel and item pins it, tiles sit on a 12-column grid, resize in width and height, reorder by drag, render live, and a pinned item that no longer exists shows a gone tile with an unpin button. Home becomes the start tab once something is pinned. The layout lives in 007's view store, changed only through update() so two tabs never overwrite each other's pins. Committed below the 90/5 bar on the operator's word so the unify e2e proves it before master moves.

🎯 Fix: 88 %
💥 Break: 6 %
💸 Cost: 100 %
⏱️ Time: 100 %
🛡️ Security: 100 %
🏆 Score: 83
🚦 Gate: ⛔ fix 88 % < 90, break 6 % > 5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-13 12:51:20 +00:00
1 parent 3418738993
commit 4451eecc0b
21 files changed
+1703 -27

No files matched your search

+6
View File
@@ -421,6 +421,8 @@ pre.notes { margin: 0; padding: 8px 10px; background: var(--sunken); border-radi
{% include "style-diff.css" %}
{% include "style-ancestry.css" %}
{% include "style-home.css" %}
</style>
</head>
<body>
@@ -469,6 +471,8 @@ pre.notes { margin: 0; padding: 8px 10px; background: var(--sunken); border-radi
{% include "nav.js" %}
{% include "panels.js" %}
{% include "ancestry.js" %}
{% include "popup.js" %}
@@ -584,6 +588,8 @@ pre.notes { margin: 0; padding: 8px 10px; background: var(--sunken); border-radi
{% include "page-resources.js" %}
{% include "page-home.js" %}
{% include "page-rules.js" %}
{% include "page-keyboard.js" %}
+10 -3
View File
@@ -1,13 +1,13 @@
const Nav = (() => {
"use strict";
const TABS = [["stream", "Stream"], ["agents", "Agents"], ["artifacts", "Artifacts"], ["tasks", "Tasks"], ["resources", "Resources"]];
const TABS = [["home", "Home"], ["stream", "Stream"], ["agents", "Agents"], ["artifacts", "Artifacts"], ["tasks", "Tasks"], ["resources", "Resources"]];
const SUBS = {stream: [["rules", "Firewall"]]};
const PANES = {inbox: ["tasks", "operator"]};
const VIEWS = [["orbit", "Orbit"], ["chord", "Chord"], ["swimlane", "Swimlane"], ["tree", "Tree"], ["3d", "3D"]];
const TASK_VIEWS = [["list", "List"], ["board", "Board"], ["rasci", "RASCI"], ["gantt", "Gantt"], ["burn", "Burndown and burnup"], ["3d", "3D"]];
const OWN = {agents: [["hierarchy", "Hierarchy"]]};
const ICONS = {
stream: "bi-activity", inbox: "bi-inbox", rules: "bi-card-checklist", agents: "bi-people", artifacts: "bi-git", tasks: "bi-list-check",
home: "bi-house-door", stream: "bi-activity", inbox: "bi-inbox", rules: "bi-card-checklist", agents: "bi-people", artifacts: "bi-git", tasks: "bi-list-check",
orbit: "bi-globe2", chord: "bi-bezier2", swimlane: "bi-bar-chart-steps", tree: "bi-diagram-3", "3d": "bi-badge-3d", hierarchy: "bi-diagram-2",
list: "bi-list-task", board: "bi-kanban", rasci: "bi-grid-3x3", gantt: "bi-calendar-range", burn: "bi-graph-down-arrow",
resources: "bi-speedometer2",
@@ -27,8 +27,15 @@ const Nav = (() => {
return tabOf(screen) === screen ? (view ? `#${screen}/${view}` : `#${screen}`) : `#${tabOf(screen)}/${screen}`;
}
function route(hash) {
/**
* @param hash - the location hash.
* @param pinned - how many pins Home holds; an empty hash opens Home once it holds one, else Stream.
*/
function route(hash, pinned) {
const [head, sub] = decodeURIComponent(String(hash).replace(/^#/, "")).split("/");
if (!head && pinned > 0) {
return {screen: "home", view: null, redirect: "#home"};
}
if (head === "stream" && sub === "radio") {
return {screen: "stream", view: null, redirect: "#stream", spot: true};
}
+1 -1
View File
@@ -118,7 +118,7 @@
const former = (people()[key] || {names: []}).names.filter((entry) => entry !== name);
openPopup(name, [
popupHead(face(name, true), name, h("span", {class: "muted"}, former.length ? `Agent · formerly ${former.join(", ")}` : "Agent"), " ", life),
h("div", {class: "popup-body"}, nightRow, info, h("h3", {}, "Subagents"), subs, h("h3", {}, "History"), log),
h("div", {class: "popup-body", "data-item": `agent:${key}`}, nightRow, info, h("h3", {}, "Subagents"), subs, h("h3", {}, "History"), log),
form,
], anchor, () => {
agentDom = null;
+2 -1
View File
@@ -81,7 +81,7 @@
const svg = s("svg", {viewBox: `0 0 ${width} ${plan.height}`, width, height: plan.height, class: "chart ancestry", role: "group", "aria-label": label});
const curve = (link) => `M${fixed(link.x1)},${fixed(link.y1)} C${fixed(link.x1)},${fixed((link.y1 + link.y2) / 2)} ${fixed(link.x2)},${fixed((link.y1 + link.y2) / 2)} ${fixed(link.x2)},${fixed(link.y2)}`;
svg.append(s("g", {}, plan.links.map((link) => mark.edge(link, curve(link)))), s("g", {}, plan.nodes.map((node) => mark.node(node))));
return h("div", {class: "ancestry-frame"}, svg);
return h("div", {class: "ancestry-frame", "data-item": mark.item || null}, svg);
}
function branchAncestry(repo) {
@@ -103,6 +103,7 @@
const plan = Ancestry.layout(repo.branches.map((entry) => ({id: entry.name, label: entry.name})), edges);
const dropping = (link) => staged.some((item) => item.drop && item.branch === link.child && item.parent === link.parent);
return ancestryChart(plan, `Ancestry of ${repo.name}`, {
item: `ancestry:${repo.path}`,
edge: (link, d) => s("path", {
class: ["ancestry-edge", link.derived ? "derived" : "", link.source === "staged" ? "pending" : "", dropping(link) ? "dropping" : ""].filter(Boolean).join(" "),
d, "data-child": link.child, "data-parent": link.parent, "data-source": link.source,
+2 -2
View File
@@ -237,7 +237,7 @@
} else {
body.push(meta([["Title", data.title], ["Status", data.status]]));
}
return [popupHead(icon(kindIcon), node.label, h("span", {class: "muted"}, kindName)), h("div", {class: "popup-body"}, body)];
return [popupHead(icon(kindIcon), node.label, h("span", {class: "muted"}, kindName)), h("div", {class: "popup-body", "data-item": `artifact:${node.id}`}, body)];
}
function artifactsScreen() {
@@ -264,7 +264,7 @@
}, 0);
const controls = h("div", {class: "card controls"}, viewSwitch("artifacts"), view === "3d" ? layoutTools("artifacts") : view === "tree" ? null : picker,
h("div", {class: "toolbar", role: "toolbar", "aria-label": "Artifacts"}, search, reload, removeAll, apply), count);
const body = view === "tree" ? list : h("div", {class: "card stage-card"}, stageBox, legendBox);
const body = view === "tree" ? list : h("div", {class: "card stage-card", "data-panel": `artifacts/${view}`}, stageBox, legendBox);
return h("div", {class: "graph"}, controls, body);
}
+1
View File
@@ -48,6 +48,7 @@
notifyLabel();
announce();
measure();
homeBoot();
apply();
drawTime();
motion.asOf = ui.asOf;
+1 -1
View File
@@ -185,6 +185,6 @@
const stageBox = h("div", {class: "stage"});
const toolbar = agentsToolbar();
graphDom = {stage: stageBox, pulses: null, toolbar};
const body = view === "tree" ? spawnScreen() : view === "hierarchy" ? hierarchyScreen() : h("div", {class: "card stage-card"}, stageBox, view === "3d" ? null : legend());
const body = view === "tree" ? spawnScreen() : view === "hierarchy" ? hierarchyScreen() : h("div", {class: "card stage-card", "data-panel": `agents/${view}`}, stageBox, view === "3d" ? null : legend());
return h("div", {class: "graph"}, toolbar.bar, h("div", {class: "card controls"}, viewSwitch("agents"), view === "3d" ? layoutTools("agents") : null), body);
}
+2 -2
View File
@@ -3,7 +3,7 @@
const OFFICE_GROUPS = [["cluster", "Organizers", "Organizer"], ["work", "Presidents", "President"], ["other", "Other offices", "Office"]];
function hierarchyScreen() {
hier.chart = h("section", {class: "card org-chart", "aria-labelledby": "org-title"});
hier.chart = h("section", {class: "card org-chart", "data-panel": "agents/hierarchy", "aria-labelledby": "org-title"});
orderDom.box = h("section", {class: "card agent-order", id: "agent-order", "aria-labelledby": "agent-order-title"});
hier.sig = "";
return h("div", {class: "hierarchy-body"}, hier.chart, orderDom.box);
@@ -120,7 +120,7 @@
hier.ids = 0;
const count = state.claims.length;
hier.chart.replaceChildren(
h("div", {class: "inbox-head"}, h("h2", {class: "group-title", id: "org-title"}, "Hierarchy", counter(count)),
h("div", {class: "inbox-head", "data-star-slot": ""}, h("h2", {class: "group-title", id: "org-title"}, "Hierarchy", counter(count)),
h("span", {class: "muted"}, "Formal offices from the council: Operator → Chair → dimensions → lines, plus organizers and presidents"),
h("span", {class: "spacer"}),
h("button", {type: "button", class: "btn small soft", "data-focus": "appoint:new", ...named("New office", "New office: give a free office to a session, with a passkey signature"), on: {click: () => officeSheet("appoint", null)}}, icon("bi-person-plus"), "New office")),
+403
View File
@@ -0,0 +1,403 @@
const HOME_PATH = "home.pins";
const HOME_FETCH = 3000;
const HOME_MESSAGE = 30000;
const HOME_RADIO = 12;
const HOME_MARKS = [['section[aria-label="Radio log"]', "radio-log"], ['section[aria-label="Recently sent"]', "radio-log"]];
const homeView = {dom: null, pins: [], tiles: new Map(), hosts: new Map(), messages: new Map(), drag: null, mark: () => null, touched: false, fetched: {}};
const homeStore = Panels.store(typeof ViewStore === "object" && ViewStore ? ViewStore : Panels.memory(), HOME_PATH);
const homePins = () => homeView.pins;
const homeIndex = (key) => homePins().findIndex((pin) => Panels.keyOf(pin) === key);
const homeWait = (title) => emptyState(title, "The tile fills in on the next poll.");
function homeFetch(name, work) {
if (Date.now() - (homeView.fetched[name] || 0) > HOME_FETCH) {
homeView.fetched[name] = Date.now();
Promise.resolve(work()).then(() => drawHome());
}
}
function homeStream(size) {
homeFetch("events", fetchEvents);
const rows = [...stream.events, ...stream.entries].sort((a, b) => b.ts - a.ts).slice(0, Math.max(3, size.h * 2));
return rows.length ? h("ol", {class: "feed"}, rows.map(eventRow)) : homeWait(stream.key ? "No entries" : "Loading …");
}
async function homeLoadMessage(key, ts, id) {
const known = homeView.messages.get(key) || {entry: undefined};
homeView.messages.set(key, {...known, busy: true, at: Date.now()});
let entry = known.entry;
try {
const response = await fetch(`/api/events?from=${Math.floor(ts) - 1}&to=${Math.ceil(ts) + 1}&after=0`, {cache: "no-store"});
if (response.ok) {
const data = await response.json();
entry = [...data.events, ...data.entries].find((row) => String(row.id) === id) || null;
}
} catch {
ui.offline = true;
}
homeView.messages.set(key, {entry, busy: false, at: Date.now()});
drawHome();
}
function homeMessage(key) {
const cut = key.indexOf("/");
const ts = Number(key.slice(0, cut));
const id = key.slice(cut + 1);
if (cut < 1 || !Number.isFinite(ts)) {
return null;
}
const shown = [...stream.events, ...stream.entries].find((row) => String(row.id) === id);
const known = homeView.messages.get(key);
if (!shown && (!known || (!known.busy && Date.now() - known.at > HOME_MESSAGE))) {
homeLoadMessage(key, ts, id);
}
const entry = shown || (known ? known.entry : undefined);
if (entry === undefined) {
return homeWait("Loading …");
}
return entry ? h("ol", {class: "feed"}, eventRow(entry)) : null;
}
function homeRadio() {
const rows = state.radio.slice(-HOME_RADIO).reverse();
return rows.length ? h("ul", {class: "mini"}, rows.map((row) => h("li", {},
h("div", {class: "row"}, klass(row.class), when(row.ts)),
h("span", {class: "muted"}, `${dash(row.from)} → ${targetsOf(row)}`),
h("span", {}, short(row.text))))) : h("p", {class: "muted"}, "No radio in the chosen time range yet.");
}
function homeTree(draw) {
if (!tree.data) {
homeFetch("tree", fetchTree);
return homeWait("Reading repositories …");
}
return tree.data.error ? emptyState("No tree", tree.data.error) : draw();
}
function homeArt(view) {
return homeTree(() => {
const repo = chosenRepo();
return repo ? {orbit: artOrbit, chord: artChord, swimlane: artSwimlane}[view](repo, tree.model) : emptyState("No repository", "pkgmgr names no repository.");
});
}
function homeArtifact(id) {
return homeTree(() => {
const node = tree.model.byId.get(id);
return node ? h("div", {class: "home-popup"}, artPopup(node)) : null;
});
}
function homeAncestry(path) {
return homeTree(() => {
const repo = tree.data.repos.find((entry) => entry.path === path);
return repo ? branchAncestry(repo) : null;
});
}
function homeOrbit() {
const kept = [graphDom, positions];
graphDom = {pulses: null};
try {
return orbit();
} finally {
[graphDom, positions] = kept;
}
}
function home3d(tab) {
const id = `${tab}/3d`;
const pin = homePins().find((entry) => entry.kind === Panels.PANEL && entry.id === id);
if (pin && !Panels.firstOfGroup(homePins(), pin)) {
return emptyState("One 3D tile at a time", "Another 3D tile already runs live on Home; unpin it to bring this one to life.");
}
const host = homeView.hosts.get(id) || h("div", {class: "stage home-stage"});
homeView.hosts.set(id, host);
window.setTimeout(() => host.isConnected && stage3d(tab, host), 0);
return host;
}
function agentTile(key) {
const node = state.graph.nodes.find((entry) => entry.id === key);
if (!node && !Object.hasOwn(people(), key)) {
return null;
}
const tasks = node ? node.tasks : [];
const claims = node ? node.claims : [];
return h("div", {class: "home-agent"},
h("div", {class: "who"}, face(key, true), person(nameOf(key)), presenceMark(key, true)),
h("p", {class: "muted"}, claims.length ? `Offices: ${claims.map((claim) => claim.office).join(", ")}` : "No office"),
tasks.length ? h("ul", {class: "mini"}, tasks.map((task) => h("li", {}, h("div", {class: "row"}, h("code", {}, task.task), status(task.status)), h("span", {}, dash(task.title)))))
: h("p", {class: "muted"}, "No open tasks."));
}
function homeTask(id) {
const row = state.tasks.find((entry) => entry.task === id);
return row ? h("ol", {class: "task-list"}, taskItem(row, etaOf().get(row.task))) : null;
}
function homeTaskList() {
const etas = etaOf();
return h("ol", {class: "task-list"}, Plan.sortRows(shownTasks(), taskView.sort, taskView.descending).map((row) => taskItem(row, etas.get(row.task))));
}
Panels.panel("stream", "Stream", homeStream);
Panels.panel("radio-log", "Radio log", homeRadio);
Panels.panel("agents/orbit", "Agents: Orbit", homeOrbit);
Panels.panel("agents/chord", "Agents: Chord", () => chord());
Panels.panel("agents/swimlane", "Agents: Swimlane", () => swimlane());
Panels.panel("agents/3d", "Agents: 3D", () => home3d("agents"), "3d");
Panels.panel("agents/tree", "Agents: spawn tree", () => h("ul", {class: "spawn-tree root"}, spawnItem(spawnTree())));
Panels.panel("agents/hierarchy", "Agents: hierarchy", () => chartTree());
Panels.panel("artifacts/orbit", "Artifacts: Orbit", () => homeArt("orbit"));
Panels.panel("artifacts/chord", "Artifacts: Chord", () => homeArt("chord"));
Panels.panel("artifacts/swimlane", "Artifacts: Swimlane", () => homeArt("swimlane"));
Panels.panel("artifacts/3d", "Artifacts: 3D", () => homeTree(() => home3d("artifacts")), "3d");
Panels.panel("tasks/list", "Tasks: list", homeTaskList);
Panels.panel("tasks/board", "Tasks: kanban", () => kanbanBoard(shownTasks()));
Panels.panel("tasks/rasci", "Tasks: RASCI", () => taskMatrix(shownTasks()));
Panels.panel("tasks/gantt", "Tasks: Gantt", () => ganttChart(shownTasks()));
Panels.panel("tasks/burn", "Tasks: burndown and burnup", () => burnChart(state.tasks, shownTasks()));
Panels.panel("tasks/3d", "Tasks: 3D", () => home3d("tasks"), "3d");
Panels.item("task", (id) => `Task ${id}`, (size, id) => homeTask(id));
Panels.item("message", "Message", (size, id) => homeMessage(id));
Panels.item("artifact", (id) => `Artifact ${id.replace(/\u0000/g, " ")}`, (size, id) => homeArtifact(id));
Panels.item("agent", (id) => `Agent ${labelOf(id)}`, (size, id) => agentTile(id));
Panels.item("ancestry", (id) => `Ancestry ${id}`, (size, id) => homeAncestry(id));
function homeRefused(why) {
homeView.pins = homeStore.read();
drawHome();
homeView.mark();
toast("Home not saved", [why], false);
}
function homeSave(change) {
const done = homeStore.change(change);
homeView.pins = homeStore.read();
drawHome();
homeView.mark();
return done.then((stored) => {
if (stored === false) {
homeRefused(homeStore.error() || "The view store refused the layout.");
}
return stored !== false;
}, (error) => {
homeRefused(String(error.message || error));
return false;
});
}
function homeRefusal(refused, holder, title) {
if (refused === "full") {
toast("Home is full", [`At most ${Panels.MAX} pins: unpin one before you pin ${title}.`], false);
} else if (refused === "group") {
const other = Panels.lookup(holder.kind, holder.id);
toast("One 3D tile at a time", [`Home already holds ${other ? other.title : holder.id}: unpin it before you pin ${title}.`], false);
}
}
function homePress(kind, id, title) {
homeView.touched = true;
if (Panels.has(homePins(), kind, id)) {
homeSave((pins) => Panels.remove(pins, kind, id));
return;
}
const {refused, holder} = Panels.add(homePins(), kind, id);
if (refused) {
homeRefusal(refused, holder, title);
return;
}
homeSave((pins) => Panels.add(pins, kind, id).pins).then((stored) => {
const now = homeStore.read();
if (stored && !Panels.has(now, kind, id)) {
const late = Panels.add(now, kind, id);
homeRefusal(late.refused, late.holder, title);
}
});
}
function homeUnpin(key) {
homeView.touched = true;
homeSave((pins) => pins.filter((pin) => Panels.keyOf(pin) !== key));
}
function homeSpan(tile, size) {
tile.style.setProperty("--w", String(size.w));
tile.style.setProperty("--h", String(size.h));
tile.dataset.w = String(size.w);
tile.dataset.h = String(size.h);
}
function homeGrab(event, key, mode) {
if (event.button !== 0 || homeIndex(key) < 0) {
return;
}
event.preventDefault();
const pin = homePins()[homeIndex(key)];
const grid = homeView.dom.grid;
const look = getComputedStyle(grid);
const gap = parseFloat(look.columnGap) || 0;
const column = (grid.clientWidth - gap * (Panels.SPAN - 1)) / Panels.SPAN + gap;
const row = (parseFloat(look.gridAutoRows) || 1) + (parseFloat(look.rowGap) || 0);
homeView.drag = {mode, key, x: event.clientX, y: event.clientY, start: {w: pin.w, h: pin.h}, next: {w: pin.w, h: pin.h}, column, row, over: null};
homeView.tiles.get(key).classList.add("dragging");
}
function homeDragMove(event) {
const drag = homeView.drag;
if (!drag) {
return;
}
const tile = homeView.tiles.get(drag.key);
if (drag.mode === "size") {
drag.next = Panels.stretch(drag.start, event.clientX - drag.x, event.clientY - drag.y, drag.column, drag.row);
homeSpan(tile, drag.next);
return;
}
const under = document.elementFromPoint(event.clientX, event.clientY);
const into = under ? under.closest(".home-tile") : null;
drag.over = into && into !== tile ? into.dataset.pin : null;
homeView.tiles.forEach((other) => other.classList.toggle("drop", other.dataset.pin === drag.over));
}
function homeDragEnd() {
const drag = homeView.drag;
if (!drag) {
return;
}
homeView.drag = null;
homeView.tiles.forEach((tile) => tile.classList.remove("drop", "dragging"));
const {key, next, over} = drag;
if (drag.mode === "size" && (next.w !== drag.start.w || next.h !== drag.start.h)) {
homeSave((pins) => Panels.resizeKey(pins, key, next.w, next.h));
} else if (drag.mode === "move" && over) {
homeSave((pins) => Panels.placeKey(pins, key, over));
} else {
drawHome();
}
}
function homeKeys(event, key) {
const steps = {ArrowLeft: -1, ArrowUp: -1, ArrowRight: 1, ArrowDown: 1};
if (event.target !== event.currentTarget || !Object.hasOwn(steps, event.key) || event.altKey || event.ctrlKey || event.metaKey) {
return;
}
event.preventDefault();
homeSave((pins) => Panels.moveKey(pins, key, steps[event.key]));
}
function homeSizeKeys(event, key) {
const steps = {ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1]};
if (!Object.hasOwn(steps, event.key)) {
return;
}
event.preventDefault();
event.stopPropagation();
const [dw, dh] = steps[event.key];
homeSave((pins) => Panels.resizeBy(pins, key, dw, dh));
}
function homeGone(pin, key) {
return h("div", {class: "home-gone"}, h("strong", {class: "home-gone-word"}, "gone"),
h("p", {class: "muted"}, `This ${pin.kind} no longer exists: ${Panels.raw(pin.id).replace(/\u0000/g, " ")}`),
btn("Unpin", "btn small danger home-gone-unpin", () => homeUnpin(key)));
}
function homeTile(key) {
const title = h("h3", {class: "home-title"});
const body = h("div", {class: "home-body"});
const grip = iconBtn("bi-grip-vertical", "Move", "btn small ghost home-grip", null, "Move: drag to another tile, or focus the tile and press the arrow keys");
const handle = iconBtn("bi-arrow-down-right", "Resize", "btn small ghost home-resize", null, "Resize: drag, or the arrow keys, 1 to 12 columns wide and rows high");
const tile = h("article", {class: "home-tile", tabindex: 0, role: "listitem", "data-pin": key, on: {keydown: (event) => homeKeys(event, key)}},
h("header", {class: "home-head"}, grip, title, iconBtn("bi-x-lg", "Unpin", "btn small ghost home-unpin", () => homeUnpin(key), "Unpin: remove the tile from Home")), body, handle);
grip.addEventListener("pointerdown", (event) => homeGrab(event, key, "move"));
handle.addEventListener("pointerdown", (event) => homeGrab(event, key, "size"));
handle.addEventListener("keydown", (event) => homeSizeKeys(event, key));
homeView.tiles.set(key, tile);
return tile;
}
function homeContent(entry, pin) {
try {
return entry.render({w: pin.w, h: pin.h});
} catch (error) {
return h("p", {class: "muted home-error"}, `Not drawable: ${error.message || error}`);
}
}
function homeFill(tile, pin, index, count) {
const key = Panels.keyOf(pin);
const entry = Panels.lookup(pin.kind, pin.id);
const content = entry ? homeContent(entry, pin) : null;
const name = entry ? entry.title : `${pin.kind} ${pin.id}`;
tile.classList.toggle("gone", !content);
tile.dataset.kind = pin.kind;
tile.dataset.id = pin.id;
tile.setAttribute("aria-label", `${name}, ${pin.w} by ${pin.h}, tile ${index + 1} of ${count}`);
homeSpan(tile, pin);
tile.querySelector(".home-title").textContent = name;
const body = tile.querySelector(".home-body");
const shown = content || homeGone(pin, key);
if (body.childNodes.length !== 1 || body.firstChild !== shown) {
body.replaceChildren(shown);
}
}
function drawHome() {
const dom = homeView.dom;
if (!dom || !dom.grid.isConnected) {
homeView.dom = null;
return;
}
if (homeView.drag) {
return;
}
const pins = homePins();
const keys = new Set(pins.map(Panels.keyOf));
for (const [key, tile] of homeView.tiles) {
if (!keys.has(key)) {
tile.remove();
homeView.tiles.delete(key);
}
}
const focused = document.activeElement;
pins.forEach((pin, index) => {
const key = Panels.keyOf(pin);
const tile = homeView.tiles.get(key) || homeTile(key);
homeFill(tile, pin, index, pins.length);
if (dom.grid.children[index] !== tile) {
dom.grid.insertBefore(tile, dom.grid.children[index] || null);
}
});
if (focused instanceof HTMLElement && focused.isConnected && document.activeElement !== focused) {
focused.focus();
}
dom.empty.hidden = pins.length > 0;
}
function homeScreen() {
const grid = h("div", {class: "home-grid", role: "list", "aria-label": "Pinned panels and items"});
const empty = emptyState("Nothing pinned yet", "Press the star on any panel or item to pin it here; pins, sizes and order are kept for every browser.");
homeView.dom = {grid, empty};
homeView.tiles = new Map();
return h("div", {class: "home"}, empty, grid);
}
function homeBoot() {
homeView.pins = homeStore.read();
const opened = homePins().length;
homeStore.watch((pins) => {
homeView.pins = pins;
if (!homeView.touched && !opened && pins.length && ui.screen === "stream" && !window.location.hash.replace(/^#/, "")) {
apply();
return;
}
drawHome();
homeView.mark();
});
homeView.mark = Panels.decorate(document.body, {pinned: (kind, id) => Panels.has(homePins(), kind, id), press: homePress, marks: HOME_MARKS});
window.addEventListener("pointermove", homeDragMove);
window.addEventListener("pointerup", homeDragEnd);
window.addEventListener("pointercancel", homeDragEnd);
}
+2 -2
View File
@@ -86,7 +86,7 @@
const own = (event) => !event.target.closest("button, summary, details, select, .kanban-handle");
const after = () => kanban.dragging && kanban.dragging.mode === "after" && kanban.dragging.task !== row.task;
return h("li", {
class: ["task-card", "kanban-card", row.pending ? "pending" : ""].filter(Boolean).join(" "), "data-task": row.task, "data-lane": lane, "data-column": column, tabindex: 0,
class: ["task-card", "kanban-card", row.pending ? "pending" : ""].filter(Boolean).join(" "), "data-task": row.task, "data-item": `task:${row.task}`, "data-lane": lane, "data-column": column, tabindex: 0,
"data-pending": row.pending ? row.pending.map((argv) => argv.join(" ")).join("\n") : null, draggable: row.movable ? "true" : null,
on: {
click: (event) => own(event) && open(),
@@ -112,7 +112,7 @@
},
},
},
h("div", {class: "head-row"}, h("code", {class: "task-id"}, row.task), cardLabels(row), h("span", {class: "spacer"}),
h("div", {class: "head-row", "data-star-slot": ""}, h("code", {class: "task-id"}, row.task), cardLabels(row), h("span", {class: "spacer"}),
row.pending ? h("span", {class: "kanban-pending", role: "img", ...named("Staged", row.pending.map(shownArgv).join("\n"))}, icon("bi-pencil")) : null,
openJobs(row.task).length ? h("span", {class: "kanban-wait", role: "img", ...named("At the runner", `${row.task}: a signed change waits for the runner`)}, icon("bi-hourglass-split")) : null,
row.editable ? h("span", {class: "kanban-handle", role: "img", draggable: "true", ...named("Follows", `Drag onto the card that waits for ${row.task}`), on: {dragstart: dragFrom(row.task, "after"), dragend: () => {
+3 -2
View File
@@ -25,7 +25,7 @@
}
function apply() {
const route = Nav.route(window.location.hash);
const route = Nav.route(window.location.hash, homePins().length);
if (route.redirect) {
window.history.replaceState(null, "", route.redirect);
}
@@ -55,7 +55,7 @@
}
function screenOf() {
return {stream: streamScreen, inbox: tasksScreen, rules: rulesScreen, agents: agentsScreen, artifacts: artifactsScreen, tasks: tasksScreen, resources: resourcesScreen}[ui.screen]();
return {home: homeScreen, stream: streamScreen, inbox: tasksScreen, rules: rulesScreen, agents: agentsScreen, artifacts: artifactsScreen, tasks: tasksScreen, resources: resourcesScreen}[ui.screen]();
}
function render(force) {
@@ -82,6 +82,7 @@
}
stage();
drawSpawn();
drawHome();
drawHierarchy(force);
drawToolbar();
drawInbox();
+2 -2
View File
@@ -98,7 +98,7 @@
}
function spawnScreen() {
const list = h("div", {class: "card spawn"});
const list = h("div", {class: "card spawn", "data-panel": "agents/tree"});
spawn.dom = {list};
window.setTimeout(() => {
drawSpawn();
@@ -116,7 +116,7 @@
const all = spawnFlat(root).map(({entry}) => entry).filter((entry) => entry.running !== null);
const running = all.filter((entry) => entry.running).length;
spawn.dom.list.replaceChildren(
h("div", {class: "inbox-head"}, h("h2", {class: "group-title"}, "Spawn tree", counter(all.length)), h("span", {class: "muted"}, `${running} running · ${all.length - running} finished · Operator → Chair → Sessions → Subagents`)),
h("div", {class: "inbox-head", "data-star-slot": ""}, h("h2", {class: "group-title"}, "Spawn tree", counter(all.length)), h("span", {class: "muted"}, `${running} running · ${all.length - running} finished · Operator → Chair → Sessions → Subagents`)),
agentAncestry(root),
h("ul", {class: "spawn-tree root"}, spawnItem(root)));
}
+3 -3
View File
@@ -134,10 +134,10 @@
const renamed = entry.now && entry.now !== entry.agent ? h("span", {title: `now: ${entry.now}`}, person(entry.agent)) : person(entry.agent);
const who = entry.agent ? [face(entry.agent, false), renamed] : entry.session ? h("strong", {title: entry.session}, entry.session.slice(0, 8)) : null;
const headline = entry.kind === "transcript" || entry.kind === "ask" || entry.kind === "operator" ? null : h("span", {class: "headline"}, entry.title);
return h("li", {class: `entry k-${entry.kind}${entry.waiting ? " waiting" : ""}${alarm ? " alarm" : ""}`, "data-ref": item ? keyOf(item) : null, "data-to": item && item.to ? item.to : null},
return h("li", {class: `entry k-${entry.kind}${entry.waiting ? " waiting" : ""}${alarm ? " alarm" : ""}`, "data-ref": item ? keyOf(item) : null, "data-item": `message:${entry.ts}/${entry.id}`, "data-to": item && item.to ? item.to : null},
h("div", {class: "msg-meta"}, when(entry.ts), kindPill(entry), extras(entry)),
h("div", {},
h("div", {class: "route"}, who, entry.sub ? h("button", {type: "button", class: "linkish muted", on: {click: () => focusSub(entry.session, entry.sub)}}, `› Subagent ${entry.sub.slice(0, 12)}`) : null, entry.kind === "ask" ? h("strong", {}, entry.title) : null, headline),
h("div", {class: "route", "data-star-slot": ""}, who, entry.sub ? h("button", {type: "button", class: "linkish muted", on: {click: () => focusSub(entry.session, entry.sub)}}, `› Subagent ${entry.sub.slice(0, 12)}`) : null, entry.kind === "ask" ? h("strong", {}, entry.title) : null, headline),
body(entry),
item ? diffBlocks(item) : null,
item ? feedbackList(keyOf(item)) : null,
@@ -175,7 +175,7 @@
const parts = h("div", {class: "chips", role: "group", "aria-label": "Transcript parts"});
const saved = h("div", {class: "chips", role: "group", "aria-label": "Saved views"});
const focus = h("div", {class: "chips"});
const list = h("div", {});
const list = h("div", {"data-panel": "stream"});
const more = h("details", {class: "menu"}, h("summary", named("Filter", "Filter: kinds, transcript parts, saved views, custom time range"), icon("bi-funnel"), caret()), h("div", {class: "menu-box end"},
h("h3", {}, "Kinds"), kinds, h("h3", {}, "Transcript parts"), parts, h("h3", {}, "Saved views"), saved, h("h3", {}, "Custom time range"), customRange()));
stream.dom = {search, count, categories, kinds, parts, saved, focus, list};
+3 -3
View File
@@ -69,8 +69,8 @@
function taskItem(row, eta) {
const classes = ["task-row", row.open_work.length ? "open-work" : "", row.ended ? "ended" : ""].filter(Boolean).join(" ");
const pick = row.editable ? h("input", {type: "checkbox", class: "task-pick", "aria-label": `Select ${row.task}`, title: `Select ${row.task} for a bulk business value`, checked: taskView.picked.has(row.task), on: {change: (event) => pickTask(row.task, event.target.checked)}}) : null;
return h("li", {class: classes, "data-task": row.task, "data-kind": row.kind, "data-status": row.status},
h("div", {class: "head-row"}, pick, h("code", {class: "task-id"}, row.task), taskBadges(row, true), h("span", {class: "spacer"}), etaMark(eta),
return h("li", {class: classes, "data-task": row.task, "data-item": `task:${row.task}`, "data-kind": row.kind, "data-status": row.status},
h("div", {class: "head-row", "data-star-slot": ""}, pick, h("code", {class: "task-id"}, row.task), taskBadges(row, true), h("span", {class: "spacer"}), etaMark(eta),
row.editable ? iconBtn("bi-sort-numeric-down", "Priority", "btn small soft", () => taskSheet(row.task), `Priority and WSJF of ${row.task}: pin or estimate, signed with the passkey`) : null),
opener(row),
row.objective !== "-" ? h("div", {class: "muted"}, `Objective: ${row.objective}`) : null,
@@ -165,7 +165,7 @@
drawTasks();
}}});
const stage = !inbox && view === "3d" ? h("div", {class: "stage"}) : null;
const body = inbox ? inboxScreen() : stage ? h("div", {class: "card stage-card tasks-body"}, layoutTools("tasks"), stage) : h("div", {class: "tasks-body"});
const body = inbox ? inboxScreen() : stage ? h("div", {class: "card stage-card tasks-body", "data-panel": "tasks/3d"}, layoutTools("tasks"), stage) : h("div", {class: "tasks-body", "data-panel": `tasks/${view}`});
taskView.dom = {chips, count, body, inbox, view, stage};
taskView.sig = "";
taskView.plan = null;
+316
View File
@@ -0,0 +1,316 @@
const Panels = (() => {
"use strict";
const MAX = 64;
const SPAN = 12;
const ID_MAX = 200;
const ID = /^[A-Za-z0-9:_./-]{1,200}$/;
const KIND = /^[A-Za-z0-9:_./-]{1,32}$/;
const ESCAPE = /[^A-Za-z0-9./-]/gu;
const ESCAPED = /_([0-9a-f]+)_/g;
const PANEL = "panel";
const SIZES = {panel: [6, 4], item: [4, 3]};
const HOSTS = "[data-panel], [data-item]";
const XHTML = "http://www.w3.org/1999/xhtml";
const SVG = "http://www.w3.org/2000/svg";
const panels = new Map();
const items = new Map();
const placed = new WeakMap();
const keyOf = (pin) => `${pin.kind}:${pin.id}`;
const span = (value) => Number.isInteger(value) && value >= 1 && value <= SPAN;
const clamp = (value) => Math.min(Math.max(Math.round(value), 1), SPAN);
/**
* @param raw - an item's own id, any text.
* @returns the pin id in the view store grammar of ViewStore.id: each character outside A-Z, a-z, 0-9 and ./- as
* _<hex>_; null when that runs past 200 characters, as such an id would lose its way back to the item.
*/
function token(raw) {
const text = String(raw).replace(ESCAPE, (char) => `_${char.codePointAt(0).toString(16)}_`);
return text.length <= ID_MAX ? text : null;
}
const raw = (id) => id.replace(ESCAPED, (_, hex) => String.fromCodePoint(parseInt(hex, 16)));
function valid(pin) {
return Boolean(pin) && typeof pin === "object" && !Array.isArray(pin) && Object.keys(pin).sort().join(",") === "h,id,kind,w"
&& typeof pin.kind === "string" && KIND.test(pin.kind) && typeof pin.id === "string" && ID.test(pin.id) && span(pin.w) && span(pin.h);
}
function validLayout(pins) {
return Array.isArray(pins) && pins.length <= MAX && pins.every(valid) && new Set(pins.map(keyOf)).size === pins.length;
}
function clean(pins) {
if (!Array.isArray(pins)) {
return [];
}
const seen = new Set();
return pins.filter((pin) => valid(pin) && !seen.has(keyOf(pin)) && Boolean(seen.add(keyOf(pin)))).slice(0, MAX).map(({kind, id, w, h}) => ({kind, id, w, h}));
}
/**
* @param id - the panel id, the value of the source element's data-panel.
* @param title - the tile title.
* @param render - (size) => Node, size being {w, h} in grid cells.
* @param group - optional name of a group of which Home holds one pin at most, such as the 3D views.
*/
function panel(id, title, render, group) {
panels.set(id, {title, render, group: group || ""});
}
/**
* @param kind - the item kind, the part of data-item before the first colon.
* @param title - the tile title, or (id) => title.
* @param render - (size, id) => Node, or null once the item no longer exists.
*/
function item(kind, title, render) {
items.set(kind, {title, render, group: ""});
}
function lookup(kind, id) {
const entry = kind === PANEL ? panels.get(id) : items.get(kind);
if (!entry) {
return null;
}
const plain = kind === PANEL ? id : raw(id);
return {kind, id, group: entry.group, title: typeof entry.title === "function" ? entry.title(plain) : entry.title, render: (size) => entry.render(size, plain)};
}
function targetOf(element) {
if (element.hasAttribute("data-panel")) {
return {kind: PANEL, id: element.getAttribute("data-panel")};
}
const value = element.getAttribute("data-item") || "";
const cut = value.indexOf(":");
return cut > 0 ? {kind: value.slice(0, cut), id: token(value.slice(cut + 1))} : null;
}
const has = (pins, kind, id) => pins.some((pin) => pin.kind === kind && pin.id === id);
const groupOf = (pin) => (lookup(pin.kind, pin.id) || {group: ""}).group;
/**
* @returns {pins, refused, holder}: pins unchanged when the pin is already there or refused; refused is "" when the
* pin is there, "full" at 64 pins and "group" when holder, a pin of the same single-instance group, is on Home.
*/
function add(pins, kind, id) {
if (has(pins, kind, id)) {
return {pins, refused: "", holder: null};
}
if (pins.length >= MAX) {
return {pins, refused: "full", holder: null};
}
const group = groupOf({kind, id});
const holder = group ? pins.find((pin) => groupOf(pin) === group) || null : null;
if (holder) {
return {pins, refused: "group", holder};
}
const [w, h] = kind === PANEL ? SIZES.panel : SIZES.item;
return {pins: [...pins, {kind, id, w, h}], refused: "", holder: null};
}
const firstOfGroup = (pins, pin) => !groupOf(pin) || pins.find((other) => groupOf(other) === groupOf(pin)) === pin;
const remove = (pins, kind, id) => pins.filter((pin) => !(pin.kind === kind && pin.id === id));
const indexOf = (pins, key) => pins.findIndex((pin) => keyOf(pin) === key);
function place(pins, from, to) {
if (!Number.isInteger(from) || !Number.isInteger(to) || from < 0 || from >= pins.length || to < 0 || to >= pins.length || from === to) {
return pins;
}
const next = [...pins];
const [moved] = next.splice(from, 1);
next.splice(to, 0, moved);
return next;
}
const move = (pins, index, step) => (index < 0 ? pins : place(pins, index, Math.min(Math.max(index + step, 0), pins.length - 1)));
const resize = (pins, index, w, h) => pins.map((pin, at) => (at === index ? {...pin, w: clamp(w), h: clamp(h)} : pin));
const placeKey = (pins, from, to) => place(pins, indexOf(pins, from), indexOf(pins, to));
const moveKey = (pins, key, step) => move(pins, indexOf(pins, key), step);
const resizeKey = (pins, key, w, h) => resize(pins, indexOf(pins, key), w, h);
function resizeBy(pins, key, dw, dh) {
const pin = pins[indexOf(pins, key)];
return pin ? resize(pins, indexOf(pins, key), pin.w + dw, pin.h + dh) : pins;
}
/**
* @param start - the tile's {w, h} when the gesture began.
* @param dx - the pointer's horizontal travel in px.
* @param dy - the pointer's vertical travel in px.
* @param column - one column plus its gap in px.
* @param row - one row plus its gap in px.
* @returns the new {w, h}, each rounded to whole cells and held in 1 to 12.
*/
function stretch(start, dx, dy, column, row) {
return {w: clamp(start.w + dx / column), h: clamp(start.h + dy / row)};
}
function memory() {
const values = new Map();
const listeners = new Map();
return {
get: (path) => values.get(path),
update: (path, change) => {
const value = change(values.get(path));
values.set(path, value);
(listeners.get(path) || []).forEach((listen) => listen(value));
return Promise.resolve(true);
},
on: (path, listen) => listeners.set(path, [...(listeners.get(path) || []), listen]),
};
}
/**
* @param backend - an object with get(path), update(path, change) and on(path, cb), as ViewStore offers; get and
* on may throw for a path the store does not know, update re-runs change on the stored list after a conflict.
* @param path - the view store path of the pins.
* @returns {read, change, watch, error}: read() gives the cleaned pins, change(fn) hands fn, a pure function from
* the stored pins to the new ones, to backend.update and gives a promise of its true or false, refused before the
* store when fn makes an invalid layout of the shown pins; watch(cb) calls cb with the cleaned pins on every change
* and error() gives the store's reason for its last refusal.
*/
function store(backend, path) {
const read = () => {
try {
return clean(backend.get(path));
} catch {
return [];
}
};
return {
read,
change: (fn) => {
if (!validLayout(fn(read()))) {
return Promise.reject(new Error("invalid layout"));
}
return new Promise((resolve) => resolve(backend.update(path, (stored) => {
const before = clean(stored);
const after = fn(before);
return validLayout(after) ? after : before;
})));
},
watch: (listen) => {
try {
backend.on(path, (value) => listen(clean(value)));
return true;
} catch {
return false;
}
},
error: () => (typeof backend.error === "function" ? backend.error() : ""),
};
}
function glyph(name) {
const svg = document.createElementNS(SVG, "svg");
svg.setAttribute("class", "bi");
svg.setAttribute("aria-hidden", "true");
svg.setAttribute("focusable", "false");
const use = document.createElementNS(SVG, "use");
use.setAttribute("href", `#${name}`);
svg.append(use);
return svg;
}
function paint(button, on, title) {
const label = on ? "Unpin from Home" : "Pin to Home";
if (button.getAttribute("aria-pressed") !== String(on)) {
button.setAttribute("aria-pressed", String(on));
button.replaceChildren(glyph(on ? "bi-star-fill" : "bi-star"));
}
if (button.getAttribute("aria-label") !== label) {
button.setAttribute("aria-label", label);
}
const hint = `${label}: ${title}`;
if (button.getAttribute("title") !== hint) {
button.setAttribute("title", hint);
}
}
function slotOf(element) {
const own = [...element.querySelectorAll("[data-star-slot]")].find((slot) => slot.closest(HOSTS) === element);
if (own) {
return own;
}
const found = [...element.children].find((child) => child.classList.contains("star-row"));
if (found) {
return found;
}
const row = document.createElement("div");
row.setAttribute("class", "star-row");
element.prepend(row);
return row;
}
function button(element, options, enabled) {
const made = document.createElement("button");
made.setAttribute("type", "button");
made.setAttribute("class", "star btn small ghost icon-only");
if (!enabled) {
made.setAttribute("disabled", "");
made.setAttribute("aria-label", "Pin to Home");
made.setAttribute("title", "Pin to Home: not possible, the id runs past 200 characters");
made.append(glyph("bi-star"));
return made;
}
made.addEventListener("pointerdown", (event) => event.stopPropagation());
made.addEventListener("click", (event) => {
event.preventDefault();
event.stopPropagation();
const now = targetOf(element);
const entry = now && now.id ? lookup(now.kind, now.id) : null;
if (entry) {
options.press(now.kind, now.id, entry.title);
}
});
return made;
}
function star(element, options) {
if (element.namespaceURI !== XHTML) {
return;
}
const target = targetOf(element);
const entry = target && target.id ? lookup(target.kind, target.id) : null;
if (!target || (target.id && !entry)) {
return;
}
let made = placed.get(element);
if (!made || !element.contains(made)) {
made = button(element, options, Boolean(entry));
placed.set(element, made);
slotOf(element).append(made);
}
if (entry) {
paint(made, options.pinned(target.kind, target.id), entry.title);
}
}
/**
* @param root - the element whose subtree gets a star on every element with data-panel or data-item; the star goes
* into the element's own data-star-slot descendant, else into a star row the element gets as its first child.
* @param options - {pinned(kind, id) => boolean, press(kind, id, title), marks: [[selector, panel id], ...]}, marks
* naming source elements whose page carries no data-panel of its own.
* @returns mark(): tags the marks, stars what lacks one and repaints the pressed state of all.
*/
function decorate(root, options) {
const marks = options.marks || [];
const mark = () => {
marks.forEach(([selector, id]) => root.querySelectorAll(selector).forEach((element) => element.hasAttribute("data-panel") || element.setAttribute("data-panel", id)));
root.querySelectorAll(HOSTS).forEach((element) => star(element, options));
};
mark();
new MutationObserver(mark).observe(root, {childList: true, subtree: true});
return mark;
}
return {
MAX, SPAN, PANEL, ID, HOSTS, keyOf, token, raw, valid, validLayout, clean, panel, item, lookup, targetOf, has, add, remove, firstOfGroup,
place, move, resize, placeKey, moveKey, resizeKey, resizeBy, stretch, memory, store, decorate,
};
})();
if (typeof module === "object" && module.exports) {
module.exports = Panels;
}
+23
View File
@@ -0,0 +1,23 @@
.star-row { display: flex; flex: none; grid-column: 1 / -1; justify-content: flex-end; min-width: 0; }
.star { flex: none; margin-inline-start: auto; color: var(--muted); }
.star[aria-pressed="true"] { color: var(--warn); }
.home { display: grid; gap: var(--sp-4); }
.home .empty[hidden] { display: none; }
.home-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: 72px; gap: var(--sp-3); }
.home-tile { position: relative; display: flex; flex-direction: column; grid-column: span var(--w, 6); grid-row: span var(--h, 4); min-width: 0; min-height: 0; overflow: hidden; background: var(--glass-card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.home-tile.gone { border-style: dashed; }
.home-tile.dragging { opacity: .6; }
.home-tile.drop { outline: 2px dashed var(--accent); outline-offset: 2px; }
.home-head { display: flex; flex: none; align-items: center; gap: 6px; padding: 4px 6px 4px 4px; border-bottom: 1px solid var(--line); }
.home-title { flex: 1; min-width: 0; margin: 0; overflow: hidden; font-size: var(--fs-sm); text-overflow: ellipsis; white-space: nowrap; }
.home-body { flex: 1; min-height: 0; padding: var(--sp-2); overflow: auto; }
.home-body svg.chart { display: block; width: 100%; height: auto; max-height: 100%; }
.home-body .stage, .home-body .graph3d { height: 100%; min-height: 0; }
.home-grip { cursor: grab; touch-action: none; }
.home-resize { position: absolute; right: 2px; bottom: 2px; z-index: 3; cursor: nwse-resize; touch-action: none; }
.home-gone { display: grid; place-content: center; justify-items: center; gap: var(--sp-2); height: 100%; text-align: center; }
.home-gone-word { color: var(--bad); font-size: var(--fs-lg); text-transform: uppercase; letter-spacing: .06em; }
.home-agent { display: grid; gap: var(--sp-2); }
@media (max-width: 640px) {
.home-tile { grid-column: 1 / -1; }
}