Merge branch 'feature/hub-bookmarks-everywhere' into unify/skills-20261114

# Conflicts:
#	orchestrator/templates/page-inbox.js
This commit is contained in:
Kevin Veen-Birkenbach committed 2026-11-14 21:56:35 +00:00
commit ccde693567
16 files changed
+1382 -104

No files matched your search

+68 -2
View File
@@ -26,6 +26,11 @@ TOKEN_MODES = ("interval", "accumulated")
OVERLAYS = ("fix", "break", "tokens", "velocity", "security", "score")
PINS_LIMIT = 64
SPAN = (1, 12)
METRIC = "metric"
CHARTS = ("hardware", "tokens", "combined")
SHOWN_LIMIT = 100
FNV_PRIME = 0x01000193
FNV_SEEDS = (0x811C9DC5, 0x01000193)
def series_ids(value: object, name: str) -> list[str]:
@@ -43,14 +48,75 @@ def span(value: object, name: str) -> int:
return value
def fnv(text: str, seed: int) -> str:
value = seed
for char in text:
value = ((value ^ ord(char)) * FNV_PRIME) & 0xFFFFFFFF
return f"{value:08x}"
def digest(text: str) -> str:
"""Args:
text: any text, such as the series ids of a metric pin joined by
newlines.
Returns:
The 16 hex characters Panels.digest gives for the same text: FNV-1a
over its code points from FNV_SEEDS, one hash per seed.
"""
return "".join(fnv(text, seed) for seed in FNV_SEEDS)
def metric_id(view: dict) -> str:
"""Args:
view: a metric pin's view as metric_view returns it.
Returns:
The only id resourcePin gives a pin of that view: the chart, the
token mode unless the chart is hardware, and all or the digest of the
series switched on.
"""
shown = "all" if view["shown"] is None else digest("\n".join(view["shown"]))
return "/".join([view["chart"], shown] if view["chart"] == "hardware" else [view["chart"], view["tokens"], shown])
def metric_view(raw: object, name: str) -> dict:
"""Args:
raw: the view a metric pin stores: the chart, its token mode and the
series switched on when it was starred, null for all of them.
name: where the view sits, for the error message.
Returns:
The view; a chart outside CHARTS, a hardware chart with a token mode
other than interval, or a series list that is not a sorted list of
at most SHOWN_LIMIT distinct series ids raises ToolError.
"""
view = section(raw, name, ("chart", "tokens", "shown"))
if not isinstance(view["chart"], str) or view["chart"] not in CHARTS:
raise ToolError(f"{name}.chart must be one of {', '.join(CHARTS)}")
if not isinstance(view["tokens"], str) or view["tokens"] not in TOKEN_MODES or (view["chart"] == "hardware" and view["tokens"] != "interval"):
raise ToolError(f"{name}.tokens must be one of {', '.join(TOKEN_MODES)}, interval for the hardware chart")
shown = view["shown"]
if shown is not None and (len(series_ids(shown, f"{name}.shown")) > SHOWN_LIMIT or shown != sorted(shown)):
raise ToolError(f"{name}.shown must be null or a sorted list of at most {SHOWN_LIMIT} series ids")
return {"chart": view["chart"], "tokens": view["tokens"], "shown": None if shown is None else list(shown)}
def pin_entry(raw: object, index: int) -> dict:
name = f"home.pins[{index}]"
entry = section(raw, name, ("kind", "id", "w", "h"))
metric = isinstance(raw, dict) and raw.get("kind") == METRIC
entry = section(raw, name, ("kind", "id", "w", "h", "view") if metric else ("kind", "id", "w", "h"))
if not isinstance(entry["kind"], str) or not PIN_KIND.fullmatch(entry["kind"]):
raise ToolError(f"{name}.kind must be 1 to 32 characters from A-Z, a-z, 0-9 and :_./-")
if not isinstance(entry["id"], str) or not SERIES_ID.fullmatch(entry["id"]):
raise ToolError(f"{name}.id must be 1 to 200 characters from A-Z, a-z, 0-9 and :_./-")
return {"kind": entry["kind"], "id": entry["id"], "w": span(entry["w"], f"{name}.w"), "h": span(entry["h"], f"{name}.h")}
pin = {"kind": entry["kind"], "id": entry["id"], "w": span(entry["w"], f"{name}.w"), "h": span(entry["h"], f"{name}.h")}
if not metric:
return pin
view = metric_view(entry["view"], f"{name}.view")
if entry["id"] != metric_id(view):
raise ToolError(f"{name}.id must be {metric_id(view)}, the chart, token mode and series of its view")
return {**pin, "view": view}
def pins(value: object) -> list[dict]:
+4 -4
View File
@@ -1,4 +1,4 @@
const orderDom = {box: null, dragged: null, focus: null};
const orderDom = {box: null, slot: null, dragged: null, focus: null};
function openAgentOrder() {
go("agents", "hierarchy");
@@ -84,15 +84,15 @@
const key = orderDom.focus || focusKey(box);
orderDom.focus = null;
const changed = JSON.stringify(ui.order) !== JSON.stringify(state.agent_order);
box.replaceChildren(
h("div", {class: "inbox-head"}, h("h2", {class: "group-title", id: "agent-order-title", tabindex: "-1", "data-focus": "order:title"}, "Agent priority", counter(ui.order.length))),
Panels.keepFocus(orderDom.slot, () => box.replaceChildren(
h("div", {class: "inbox-head"}, h("h2", {class: "group-title", id: "agent-order-title", tabindex: "-1", "data-focus": "order:title"}, "Agent priority", counter(ui.order.length)), h("span", {class: "spacer"}), orderDom.slot),
h("p", {class: "muted"}, "Orders the chair's grants and decides only between equal task priorities; the tasks' --prio pins stay unchanged."),
ui.order.length ? h("ol", {class: "order-list", "aria-label": "Agent order"}, ui.order.map(orderItem)) : h("p", {class: "muted"}, "No agent with an office or an open task."),
h("div", {class: "actions"},
h("span", {class: "muted"}, "Drag or use the arrows to reorder"),
h("span", {class: "spacer"}),
h("button", {type: "button", class: "btn ghost", "data-focus": "order:reset", disabled: !changed, on: {click: () => placeAgent([...state.agent_order], "order:reset")}}, "Reset"),
h("button", {type: "button", class: "btn primary", "data-focus": "order:save", disabled: !changed, on: {click: saveAgentOrder}}, "Save order")));
h("button", {type: "button", class: "btn primary", "data-focus": "order:save", disabled: !changed, on: {click: saveAgentOrder}}, "Save order"))));
const target = key && [...box.querySelectorAll("[data-focus]")].find((element) => element.dataset.focus === key);
if (target && target.disabled) {
refocus(box, key.startsWith("up:") ? `down:${key.slice(3)}` : key.startsWith("down:") ? `up:${key.slice(5)}` : "order:title");
+20 -5
View File
@@ -60,7 +60,17 @@
}
}
const ids = new Set(nodes.map((node) => node.id));
return {nodes, links: links.filter((link) => ids.has(link.source) && ids.has(link.target)), byId: new Map(nodes.map((node) => [node.id, node]))};
return {nodes, links: links.filter((link) => ids.has(link.source) && ids.has(link.target)), byId: new Map(nodes.map((node) => [node.id, node])), byRef: new Map(nodes.map((node) => [artifactRef(node.id), node]))};
}
/**
* @param id - an artifacts model node id, such as wt:<path> or artefact:wt:<path>\u0000<task>\u0000<ref>.
* @returns the id its star pins after the artifact: kind: the node id while Panels.token keeps it within 200
* characters, else <node kind>#<Panels.digest of the node id>, which no node id equals and which Home resolves
* against the live tree through byRef.
*/
function artifactRef(id) {
return Panels.token(id) === null ? `${id.slice(0, id.indexOf(":"))}#${Panels.digest(id)}` : id;
}
function chosenRepo() {
@@ -216,7 +226,12 @@
return h("div", {class: "legend"}, marks, h("span", {class: "muted"}, words[view]));
}
function artPopup(node) {
/**
* @param node - an artifacts model node.
* @param glance - true for the read-only copy a Home tile shows, without the delete button.
* @returns the popup head and body of the node.
*/
function artPopup(node, glance) {
const [kindName, kindIcon] = ART_KINDS[node.kind];
const data = node.data;
const body = [];
@@ -226,7 +241,7 @@
} else if (node.kind === "branch") {
body.push(h("div", {class: "states"}, branchStates(data), gateIcons(node.repo, data.name)), meta([["Upstream", data.upstream], ["Head", data.head.slice(0, 12), data.head], ["Merged into", data.merged_into], ["Reason", data.reason]]),
data.worktrees.map((wt) => flowDetails(wt.flow, data.name)),
h("h3", {}, "Dry run"), h("pre", {class: "notes"}, data.plan.join("\n")), h("div", {class: "actions"}, deleteButton(data)));
h("h3", {}, "Dry run"), h("pre", {class: "notes"}, data.plan.join("\n")), glance ? null : h("div", {class: "actions"}, deleteButton(data)));
} else if (node.kind === "worktree") {
body.push(h("div", {class: "states"}, worktreeStates(data)), workChips(data.open_work), meta([["Path", data.path], ["Branch", data.branch], ["HEAD", data.head.slice(0, 12), data.head]]),
flowDetails(data.flow, data.branch),
@@ -237,7 +252,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", "data-item": `artifact:${node.id}`}, body)];
return [popupHead(icon(kindIcon), node.label, h("span", {class: "muted"}, kindName)), h("div", {class: "popup-body", "data-item": `artifact:${artifactRef(node.id)}`}, body)];
}
function artifactsScreen() {
@@ -264,7 +279,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", "data-panel": `artifacts/${view}`}, stageBox, legendBox);
const body = view === "tree" ? h("div", {class: "tree-panel", "data-panel": "artifacts/tree"}, list) : h("div", {class: "card stage-card", "data-panel": `artifacts/${view}`}, stageBox, legendBox);
return h("div", {class: "graph"}, controls, body);
}
+2 -1
View File
@@ -4,7 +4,8 @@
function hierarchyScreen() {
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"});
orderDom.box = h("section", {class: "card agent-order", id: "agent-order", "aria-labelledby": "agent-order-title", "data-panel": "agents/order"});
orderDom.slot = h("span", {"data-star-slot": ""});
hier.sig = "";
return h("div", {class: "hierarchy-body"}, hier.chart, orderDom.box);
}
+74 -10
View File
@@ -67,8 +67,10 @@
}
function homeTree(draw) {
if (!tree.data) {
if (!tree.data || Date.now() - (homeView.fetched.tree || 0) > HOME_TREE) {
homeFetch("tree", fetchTree);
}
if (!tree.data) {
return homeWait("Reading repositories …");
}
return tree.data.error ? emptyState("No tree", tree.data.error) : draw();
@@ -81,10 +83,13 @@
});
}
function homeArtifact(id) {
const artifactNode = (ref) => (tree.model ? tree.model.byRef.get(ref) || null : null);
const artifactTitle = (ref) => `Artifact ${(artifactNode(ref) ? artifactNode(ref).id : ref).replace(/\u0000/g, " ")}`;
function homeArtifact(ref) {
return homeTree(() => {
const node = tree.model.byId.get(id);
return node ? h("div", {class: "home-popup"}, artPopup(node)) : null;
const node = artifactNode(ref);
return node ? h("div", {class: "home-popup"}, artPopup(node, true)) : null;
});
}
@@ -161,9 +166,68 @@
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("artifact", artifactTitle, (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));
Panels.panel("artifacts/tree", "Artifacts: tree", () => homeTree(() => h("div", {class: "repos"}, treeCards("", true).nodes)));
Panels.panel("agents/order", "Agents: priority", homeOrder);
Panels.panel("tasks/operator", "Tasks: Waits on Operator", homeInbox);
Panels.item("metric", (id, view) => metricTitle(view), (size, id, view) => homeMetric(id, view));
Panels.capture("resources-hardware", () => resourcePin("hardware"));
Panels.capture("resources-tokens", () => resourcePin("tokens"));
Panels.capture("resources-combined", () => resourcePin("combined"));
const HOME_TREE = 30000;
const HOME_METRICS = {hardware: "Hardware", tokens: "Tokens", combined: "Combined"};
const homeMetricView = (view) => Boolean(view) && Object.hasOwn(HOME_METRICS, view.chart) && (view.shown === null || Array.isArray(view.shown));
const seriesName = (id) => Panels.raw(id).slice(Panels.raw(id).indexOf(":") + 1);
function homeOrder() {
const order = state.agent_order;
return order.length ? h("ol", {class: "order-list home-order"}, order.map((name, index) => h("li", {"data-name": name}, h("span", {class: "rank"}, `${index + 1}.`), face(name, false), person(name))))
: h("p", {class: "muted"}, "No agent with an office or an open task.");
}
function homeInbox() {
const items = visibleInbox();
return items.length ? h("ol", {class: "home-inbox"}, items.map((item) => h("li", {class: `k-${item.kind}`, "data-wait": keyOf(item)},
h("div", {class: "msg-meta"}, when(item.ts), pill(ITEM_LABELS[item.kind], KIND_TONES[item.kind]), item.agent ? [face(item.agent, false), person(item.agent)] : null),
inboxHeadline(item),
h("div", {class: "item-actions line-actions"}, actionsFor(item))))) : emptyState("All done", "Nothing is waiting for you right now.");
}
function metricTitle(view) {
if (!homeMetricView(view)) {
return "Metric";
}
const mode = view.chart !== "hardware" && view.tokens === "accumulated" ? " (accumulated)" : "";
const names = view.shown === null ? "all series" : view.shown.length > 3 ? `${view.shown.length} series` : view.shown.map(seriesName).join(", ") || "no series";
return `${HOME_METRICS[view.chart]}${mode}: ${names}`;
}
function homeMetric(id, view) {
if (!homeMetricView(view)) {
return null;
}
homeFetch("resources", () => (resourceView.data === null || resourcesStale() ? fetchResources() : null));
const key = `metric:${id}`;
const host = homeView.hosts.get(key) || h("div", {class: "home-metric", "data-chart": view.chart}, h("div", {class: "legend-chips"}), h("div", {class: "res-plot"}));
homeView.hosts.set(key, host);
window.setTimeout(() => host.isConnected && drawMetric(host, view), 0);
return host;
}
function drawMetric(host, view) {
const [legend, plot] = host.children;
if (resourceView.data === null) {
plot.replaceChildren(homeWait("Loading …"));
return;
}
const box = plot.getBoundingClientRect();
const drawn = metricChart(view, {width: Math.round(box.width), height: Math.round(box.height)});
plot.replaceChildren(...(drawn.svg ? [drawn.svg] : []));
legend.replaceChildren(...drawn.series.map((line) => h("span", {class: `legend-chip ${line.tone}`, "data-series": line.id}, line.label)));
}
function homeRefused(why) {
homeView.pins = homeStore.read();
@@ -197,21 +261,21 @@
}
}
function homePress(kind, id, title) {
function homePress(kind, id, title, view) {
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);
const {refused, holder} = Panels.add(homePins(), kind, id, view);
if (refused) {
homeRefusal(refused, holder, title);
return;
}
homeSave((pins) => Panels.add(pins, kind, id).pins).then((stored) => {
homeSave((pins) => Panels.add(pins, kind, id, view).pins).then((stored) => {
const now = homeStore.read();
if (stored && !Panels.has(now, kind, id)) {
const late = Panels.add(now, kind, id);
const late = Panels.add(now, kind, id, view);
homeRefusal(late.refused, late.holder, title);
}
});
@@ -328,7 +392,7 @@
function homeFill(tile, pin, index, count) {
const key = Panels.keyOf(pin);
const entry = Panels.lookup(pin.kind, pin.id);
const entry = Panels.lookup(pin.kind, pin.id, pin.view);
const content = entry ? homeContent(entry, pin) : null;
const name = entry ? entry.title : `${pin.kind} ${pin.id}`;
tile.classList.toggle("gone", !content);
+11 -5
View File
@@ -1,3 +1,4 @@
let inboxSlot = null;
const GONE_NOTICE = "already done or removed elsewhere";
function closeGone(result, keys, label) {
@@ -187,6 +188,10 @@
return buttons;
}
function inboxHeadline(item) {
return h("button", {type: "button", class: "linkish headline", title: "Open", on: {click: () => openItem(item)}}, revealed(item.kind === "operator" ? item.id : item.kind === "ask" ? item.title.split(": ")[0] : item.title));
}
function inboxItem(item, index) {
const red = item.kind === "review" && item.gate !== "pass";
const commanded = item.kind === "ask" || item.kind === "operator";
@@ -203,7 +208,7 @@
item.until ? pill(`until ${absolute.format(stampOf(item.until))}`, "neutral") : null),
h("div", {class: "entry-body"},
h("div", {class: "route"},
h("button", {type: "button", class: "linkish headline", title: "Open", on: {click: () => openItem(item)}}, revealed(item.kind === "operator" ? item.id : item.kind === "ask" ? item.title.split(": ")[0] : item.title)),
inboxHeadline(item),
item.agent ? [face(item.agent, false), person(item.agent)] : null),
item.kind === "review" ? h("div", {class: "muted"}, revealed(item.detail), item.score ? revealed(` · ${item.score}`) : "") : null,
commanded ? h("div", {class: "command", "data-path": item.directory || "-"}, h("code", {}, revealed(item.command)), copyButton(item.command)) : null,
@@ -226,7 +231,8 @@
}
function inboxScreen() {
inboxDom = h("div", {class: "inbox"});
inboxDom = h("div", {class: "inbox", "data-panel": "tasks/operator"});
inboxSlot = h("span", {"data-star-slot": ""});
return inboxDom;
}
@@ -260,12 +266,12 @@
const choose = h("button", {type: "button", class: "btn small soft", ...named(`Grant selection (${grantable.length})`), disabled: !grantable.length || ui.busy, on: {click: () => bulk(chosen, "Grant selection", false)}}, icon("bi-check2-square"), String(grantable.length));
const deny = h("button", {type: "button", class: "btn small danger", ...named(`Deny selection (${deniable.length})`, `Deny selection (${deniable.length}): each requester gets its denial by post, one passkey signature, 3 s to undo`), disabled: !deniable.length || ui.busy, on: {click: () => bulk(chosen, "Deny selection", true)}}, icon("bi-x-square"), String(deniable.length));
const all = h("button", {type: "button", class: "btn small primary", ...named(`Grant all green (${green.length})`), disabled: !green.length || ui.busy, on: {click: () => bulk(green, "Grant all green", false)}}, icon("bi-check2-all"), String(green.length));
inboxDom.replaceChildren(
Panels.keepFocus(inboxSlot, () => inboxDom.replaceChildren(
h("div", {class: "inbox-head"}, h("h2", {class: "group-title"}, "Waits on Operator", counter(waitingCount())), h("span", {class: "spacer"}),
hidden ? h("label", {class: "check"}, snoozed, `${hidden} snoozed`) : null),
hidden ? h("label", {class: "check"}, snoozed, `${hidden} snoozed`) : null, inboxSlot),
h("div", {class: "inbox-actions"}, choose, deny, all),
onLocalhost() ? "" : h("p", {class: "muted"}, "The passkey signs grants only under ", localLink()),
items.length ? h("ol", {class: "inbox-list"}, items.map(inboxItem)) : emptyState("All done", "Nothing is waiting for you right now."));
items.length ? h("ol", {class: "inbox-list"}, items.map(inboxItem)) : emptyState("All done", "Nothing is waiting for you right now.")));
settleConsoles(items);
const current = inboxDom.querySelector(`.item[data-index="${ui.cursor}"]`);
if (current && document.activeElement === document.body) {
+65 -14
View File
@@ -1,4 +1,4 @@
const RESOURCE = {left: 46, right: 10, wide: 50, top: 6, bottom: 6, axis: 18, poll: 5000, stale: 60, tones: 6, narrow: 600};
const RESOURCE = {left: 46, right: 10, wide: 50, top: 6, bottom: 6, axis: 18, poll: 5000, stale: 60, tones: 6, glyph: 6.5, shown: 100};
const RESOURCE_PANELS = [["hardware", "bi-cpu", "Hardware: disks, CPU, RAM, swap, GPU and VRAM"], ["tokens", "bi-coin", "Tokens per agent"], ["combined", "bi-layers", "Hardware, tokens and burnup"]];
const RESOURCE_ZONES = {idle: "Idle: below 30 %", saturated: "Saturated: above 90 %"};
const RESOURCE_MARKS = {
@@ -7,8 +7,9 @@
unknown: ["#bi-question-circle", (mark) => `${mark.name} unknown: no reading`],
};
const RESOURCE_BURN = {done: "Done", scope: "Scope"};
const resourceView = {data: null, dom: null, busy: false, key: "", at: 0, timer: 0};
const resourceView = {data: null, dom: null, busy: false, key: "", at: 0, timer: 0, series: {}};
const resourceKey = () => JSON.stringify([ui.preset, ui.from, ui.to, ui.asOf]);
const resourcesStale = () => resourceKey() !== resourceView.key || nowSeconds() - resourceView.at >= RESOURCE.stale;
const compactCount = (value) => (value >= 1e6 ? `${fixed(value / 1e6)}M` : value >= 1e3 ? `${fixed(value / 1e3)}k` : String(Math.round(value)));
const resourceLabel = (line) => (line.kind === "vram" ? `${line.name} VRAM` : line.name);
const percentOf = (value) => `${value} %`;
@@ -28,7 +29,7 @@
const legend = h("div", {class: "res-legend"});
const plot = h("div", {class: "res-plot"});
const panel = h("section", {class: `card res-panel res-${kind}`, "data-panel": `resources-${kind}`, "aria-label": label, hidden: kind === "combined"},
h("div", {class: "res-head"}, h("span", {class: "res-title", title: label, "aria-label": label}, icon(name)), legend), plot);
h("div", {class: "res-head", "data-star-slot": ""}, h("span", {class: "res-title", title: label, "aria-label": label}, icon(name)), legend), plot);
return {kind, label, legend, plot, panel};
});
resourceView.dom = {count, switches, panels};
@@ -52,7 +53,7 @@
if (!dom || !dom.count.isConnected || document.hidden || resourceView.busy) {
return;
}
if (resourceKey() !== resourceView.key || nowSeconds() - resourceView.at >= RESOURCE.stale) {
if (resourcesStale()) {
fetchResources();
}
}
@@ -82,17 +83,31 @@
const bottom = size.height - (axis ? RESOURCE.axis : RESOURCE.bottom);
const x = (t) => RESOURCE.left + ((Math.min(Math.max(t, span.from), span.to) - span.from) / (span.to - span.from)) * (right - RESOURCE.left);
const svg = s("svg", {class: `chart res-chart res-${entry.kind}`, "data-chart": entry.kind, "data-from": span.from, "data-to": span.to, viewBox: `0 0 ${size.width} ${size.height}`, role: "img", "aria-label": entry.label});
const ticks = size.width < RESOURCE.narrow ? 2 : 4;
for (let index = 0; index <= ticks; index += 1) {
const t = span.from + ((span.to - span.from) * index) / ticks;
const ticks = resourceTicks(span, right - RESOURCE.left);
for (let index = 0; index <= ticks.count; index += 1) {
const t = span.from + ((span.to - span.from) * index) / ticks.count;
svg.append(s("line", {class: "grid", x1: fixed(x(t)), x2: fixed(x(t)), y1: RESOURCE.top, y2: fixed(bottom)}));
if (axis) {
svg.append(s("text", {class: "axis", x: fixed(x(t)), y: size.height - 4, "text-anchor": index === 0 ? "start" : index === ticks ? "end" : "middle"}, (span.to - span.from > DAY ? absolute : clock).format(stampOf(t))));
if (axis && (ticks.all || index === ticks.count)) {
svg.append(s("text", {class: "axis", "data-axis": "time", x: fixed(x(t)), y: size.height - 4, "text-anchor": index === 0 ? "start" : index === ticks.count ? "end" : "middle"}, ticks.format.format(stampOf(t))));
}
}
return {svg, x, top: RESOURCE.top, bottom, right};
}
/**
* @param span - {from, to} of the chart in epoch seconds.
* @param room - the plot width in px.
* @returns {count, all, format}: up to 4 intervals between time labels, as many as fit apart at RESOURCE.glyph px
* per character, all false when not even the first and the last label fit, so that only the last is drawn.
*/
function resourceTicks(span, room) {
const format = span.to - span.from > DAY ? absolute : clock;
const wide = Math.max(...[span.from, span.to].map((t) => format.format(stampOf(t)).length)) * RESOURCE.glyph + RESOURCE.glyph;
const fits = (count) => room / count >= wide * (count === 1 ? 2 : 1.5);
const count = [4, 3, 2, 1].find(fits);
return {count: count || 1, all: Boolean(count), format};
}
function resourceScale(frame, values, label, side) {
const y = (value) => frame.top + (1 - value / values[values.length - 1]) * (frame.bottom - frame.top);
const left = side === "left";
@@ -203,7 +218,7 @@
const y = resourceScale(frame, [0, 50, 100], percentOf, "left");
resourceBackdrop(frame, y, parts.marks, span);
resourceLines(frame, y, parts.hardware.filter((line) => !parts.hidden.has(line.id)));
return {svg: frame.svg, series: parts.hardware, path: "resources.hidden"};
return {svg: frame.svg, series: RESOURCE_SERIES.hardware(parts), path: "resources.hidden"};
}
function tokensChart(entry, parts, span, size) {
@@ -211,7 +226,7 @@
const plot = tokenPlot(shownRows(parts.tokens, parts.agents, parts.hidden), parts.mode);
const y = resourceScale(frame, [0, plot.top], compactCount, "left");
tokenMarks(frame, y, plot, parts.agents.tones, span, false);
return {svg: frame.svg, series: parts.agents.list, path: "resources.hidden"};
return {svg: frame.svg, series: RESOURCE_SERIES.tokens(parts), path: "resources.hidden"};
}
function combinedChart(entry, parts, span, size) {
@@ -224,10 +239,45 @@
for (const line of parts.burn.filter((item) => !parts.combinedHidden.has(item.id) && item.points.length)) {
frame.svg.append(s("path", {class: line.tone, "data-id": line.id, "data-series": line.name, "data-last": line.points[line.points.length - 1][1], "data-top": line.top, d: resourceSteps(frame, y, line.points)}, s("title", {}, `${line.label} of the largest scope in the window (${line.top})`)));
}
return {svg: frame.svg, series: [...parts.hardware, ...parts.agents.list, ...parts.burn], path: "resources.combinedHidden"};
return {svg: frame.svg, series: RESOURCE_SERIES.combined(parts), path: "resources.combinedHidden"};
}
const RESOURCE_CHARTS = {hardware: hardwareChart, tokens: tokensChart, combined: combinedChart};
const RESOURCE_SERIES = {hardware: (parts) => parts.hardware, tokens: (parts) => parts.agents.list, combined: (parts) => [...parts.hardware, ...parts.agents.list, ...parts.burn]};
const resourceSmall = (size) => size.width < RESOURCE.left + RESOURCE.wide + 10 || size.height < RESOURCE.axis + 10;
/**
* @param kind - hardware, tokens or combined.
* @returns the metric pin the chart's star makes now: {kind: "metric", id, view}, view being the chart, its token
* mode and the sorted ids of the series switched on, null while all are on; the id names the chart, the mode and
* all or a digest of the series, so another selection is another pin. With more than RESOURCE.shown series on but
* not all, the pin also carries refused, as the view store keeps at most that many.
*/
function resourcePin(kind) {
const drawn = resourceView.series[kind] || {ids: [], shown: [], tokens: ViewStore.get("resources").tokens};
const shown = [...drawn.shown].sort();
const view = {chart: kind, tokens: kind === "hardware" ? "interval" : drawn.tokens, shown: shown.length === drawn.ids.length ? null : shown};
const id = [kind, kind === "hardware" ? "" : view.tokens, view.shown === null ? "all" : Panels.digest(shown.join("\n"))].filter(Boolean).join("/");
const over = view.shown !== null && view.shown.length > RESOURCE.shown;
return over ? {kind: "metric", id, view, refused: `more than ${RESOURCE.shown} series are switched on: switch some off, or all of them on`} : {kind: "metric", id, view};
}
/**
* @param view - a metric pin's view: {chart, tokens, shown}.
* @param size - {width, height} of the plot in px.
* @returns {svg, series}: the chart drawn from the loaded samples with only the view's series, svg null when the
* plot is too small, and those series for a legend.
*/
function metricChart(view, size) {
const data = resourceView.data;
const span = {from: data.since, to: Math.max(data.until, data.since + 60)};
const parts = resourceParts(data, {tokens: view.tokens, hidden: [], combinedHidden: [], combined: view.chart === "combined"}, span);
const series = RESOURCE_SERIES[view.chart](parts);
const hidden = new Set(view.shown === null ? [] : series.map((line) => line.id).filter((id) => !view.shown.includes(id)));
const [, , label] = RESOURCE_PANELS.find(([kind]) => kind === view.chart);
const drawn = RESOURCE_CHARTS[view.chart]({kind: view.chart, label}, {...parts, hidden, combinedHidden: hidden}, span, size);
return {svg: resourceSmall(size) ? null : drawn.svg, series: series.filter((line) => !hidden.has(line.id))};
}
function resourceParts(data, view, span) {
return {
@@ -274,8 +324,9 @@
const box = entry.plot.getBoundingClientRect();
const size = {width: Math.round(box.width), height: Math.round(box.height)};
const drawn = RESOURCE_CHARTS[entry.kind](entry, parts, span, size);
const small = size.width < RESOURCE.left + RESOURCE.wide + 10 || size.height < RESOURCE.axis + 10;
entry.plot.replaceChildren(...(small ? [] : [drawn.svg]));
const hidden = drawn.path === "resources.hidden" ? parts.hidden : parts.combinedHidden;
resourceView.series[entry.kind] = {ids: drawn.series.map((line) => line.id), shown: drawn.series.map((line) => line.id).filter((id) => !hidden.has(id)), tokens: view.tokens};
entry.plot.replaceChildren(...(resourceSmall(size) ? [] : [drawn.svg]));
entry.legend.replaceChildren(LegendChips.render(drawn.series, drawn.path, "hidden"));
const chip = focused === null ? null : [...entry.legend.querySelectorAll("[data-chip]")].find((node) => node.getAttribute("data-chip") === focused);
if (chip) {
+29 -18
View File
@@ -70,8 +70,9 @@
tree.data.delete_ready !== true ? iconBtn("bi-key-fill", "Store token", "btn small soft", storeToken, "Store token: add the operator row that stores the GitHub token in the Secret Service") : null);
}
function leafRow(found) {
return h("li", {class: "leaf"}, h("span", {class: "state", "data-tone": found.ended ? "warn" : "neutral", role: "img", ...named(found.kind)}, icon(ARTEFACT_ICONS[found.kind] || "bi-paperclip")),
function leafRow(holder, found) {
return h("li", {class: "leaf", "data-item": `artifact:${artifactRef(`artefact:${holder}\u0000${found.task}\u0000${found.ref}`)}`},
h("span", {class: "state", "data-tone": found.ended ? "warn" : "neutral", role: "img", ...named(found.kind)}, icon(ARTEFACT_ICONS[found.kind] || "bi-paperclip")),
h("code", {}, found.ref), h("span", {class: "muted"}, found.task), found.ended ? pill("task ended", "warn") : null);
}
@@ -81,8 +82,8 @@
function worktreeRow(wt) {
const review = wt.review;
return h("div", {class: wt.open_work.length ? "wt open-work" : "wt", "data-open-work": wt.open_work.join(" ") || null},
h("div", {class: "wt-head"},
return h("div", {class: wt.open_work.length ? "wt open-work" : "wt", "data-open-work": wt.open_work.join(" ") || null, "data-item": `artifact:${artifactRef(`wt:${wt.path}`)}`},
h("div", {class: "wt-head", "data-star-slot": ""},
h("span", {class: "states"}, worktreeStates(wt), openWork(wt)),
h("code", {}, wt.path),
h("span", {class: "muted", title: wt.head}, wt.head.slice(0, 10)),
@@ -90,7 +91,7 @@
review ? [status(review.status), review.gate ? pill(review.gate === "pass" ? "Gate green" : "Gate red", review.gate === "pass" ? "ok" : "bad") : null] : null,
copyButton(wt.path)),
flowLine(wt.flow, wt.branch),
wt.artefacts && wt.artefacts.length ? h("ul", {class: "leaves", "aria-label": "Artifacts"}, wt.artefacts.map(leafRow)) : null);
wt.artefacts && wt.artefacts.length ? h("ul", {class: "leaves", "aria-label": "Artifacts"}, wt.artefacts.map((found) => leafRow(`wt:${wt.path}`, found))) : null);
}
function resultOf(repo, entry) {
@@ -105,11 +106,11 @@
return chip(name, `${label}${result.reason ? `: ${result.reason}` : ""}`, tone);
}
function branchRow(repo, entry) {
function branchRow(repo, entry, glance) {
const result = resultOf(repo, entry);
return h("div", {class: "branch-row"},
h("div", {class: "branch-name"}, h("strong", {}, entry.name), h("span", {class: "states"}, branchStates(entry)), entry.upstream ? h("span", {class: "muted"}, `↔ ${entry.upstream}`) : null,
h("span", {class: "muted", title: entry.head}, entry.head.slice(0, 10)), result ? resultChip(result) : null, h("span", {class: "spacer"}), gateIcons(repo.path, entry.name), deleteButton(entry)),
return h("div", {class: "branch-row", "data-item": `artifact:${artifactRef(`branch:${repo.path}\u0000${entry.name}`)}`},
h("div", {class: "branch-name", "data-star-slot": ""}, h("strong", {}, entry.name), h("span", {class: "states"}, branchStates(entry)), entry.upstream ? h("span", {class: "muted"}, `↔ ${entry.upstream}`) : null,
h("span", {class: "muted", title: entry.head}, entry.head.slice(0, 10)), result ? resultChip(result) : null, h("span", {class: "spacer"}), gateIcons(repo.path, entry.name), glance ? null : deleteButton(entry)),
entry.worktrees.map(worktreeRow));
}
@@ -124,7 +125,19 @@
return;
}
tree.dom.removeAll.replaceChildren(deleteAll(), gateApply() || "");
const q = tree.q.trim().toLowerCase();
const shown = treeCards(tree.q.trim().toLowerCase());
tree.dom.count.textContent = `${shown.count} repositories · as of ${clock.format(stampOf(tree.data.scanned))}${tree.data.delete_ready ? "" : ` · Delete blocked: ${tree.data.delete_reason}`}`;
tree.dom.list.replaceChildren(...shown.nodes);
}
/**
* @param q - the lower-case filter text, "" for all.
* @param glance - true for the read-only copy a Home tile shows, without the delete buttons.
* @returns {count, nodes}: how many repositories match and the cards of the tree view for them, the tasks without a
* worktree and the recently deleted branches, or an empty state when nothing matches or, without a filter, when
* pkgmgr names nothing.
*/
function treeCards(q, glance) {
const hit = (...texts) => !q || texts.some((text) => String(text).toLowerCase().includes(q));
const repos = [];
for (const repo of tree.data.repos) {
@@ -137,22 +150,20 @@
const tasks = (tree.data.tasks || []).filter((task) => hit(task.task, task.title, ...task.artefacts.map((found) => found.ref)));
const listed = new Set(tree.data.repos.flatMap((repo) => repo.branches.map((entry) => `${repo.path}\u0000${entry.name}`)));
const gone = (tree.data.cleanups || []).flatMap((result) => result.items).filter((item) => !listed.has(`${item.repository}\u0000${item.branch}`) && hit(item.repository, item.branch));
tree.dom.count.textContent = `${repos.length} repositories · as of ${clock.format(stampOf(tree.data.scanned))}${tree.data.delete_ready ? "" : ` · Delete blocked: ${tree.data.delete_reason}`}`;
if (!repos.length && !tasks.length && !gone.length) {
tree.dom.list.replaceChildren(emptyState("Nothing found", "No repository matches the filter."));
return;
return {count: 0, nodes: [q ? emptyState("Nothing found", "No repository matches the filter.") : emptyState("No repository", "pkgmgr names no repository.")]};
}
const cards = repos.map(({repo, branches, detached}) => {
const trees = repo.branches.flatMap((entry) => entry.worktrees).concat(repo.detached);
const dirty = trees.filter((wt) => wt.dirty).length;
const merged = repo.branches.filter((entry) => entry.cleanup).length;
const busy = trees.filter((wt) => wt.open_work.length).length;
const details = h("details", {class: "card repo", open: Boolean(q) || tree.open.has(repo.path)},
h("summary", {}, icon("bi-git"), h("span", {}, repo.name), counter(`${repo.branches.length} branches`), counter(`${trees.length} worktrees`),
const details = h("details", {class: "card repo", open: Boolean(q) || tree.open.has(repo.path), "data-item": `artifact:${artifactRef(`repo:${repo.path}`)}`},
h("summary", {"data-star-slot": ""}, icon("bi-git"), h("span", {}, repo.name), counter(`${repo.branches.length} branches`), counter(`${trees.length} worktrees`),
dirty ? chip("bi-pencil-square", `${dirty} worktrees with changes`, "warn", dirty) : null, merged ? chip("bi-sign-merge-left", `${merged} merged, deletable`, "ok", merged) : null,
busy ? chip("bi-lightning-charge", `${busy} worktrees with open work`, "warn", busy) : null),
repo.branches.length ? branchAncestry(repo) : null,
branches.map((entry) => branchRow(repo, entry)),
branches.map((entry) => branchRow(repo, entry, glance)),
detached.length ? h("div", {class: "branch-row"}, h("div", {class: "branch-name"}, h("strong", {}, "detached HEAD")), detached.map(worktreeRow)) : null);
details.addEventListener("toggle", () => {
if (details.open) {
@@ -165,8 +176,8 @@
});
const loose = tasks.length ? h("details", {class: "card repo", open: true}, h("summary", {}, icon("bi-card-checklist"), h("span", {}, "Tasks without a worktree"), counter(tasks.length)),
tasks.map((task) => h("div", {class: "branch-row"}, h("div", {class: "branch-name"}, h("strong", {}, task.task), h("span", {class: "muted"}, task.title), status(task.status)),
h("ul", {class: "leaves", "aria-label": "Artifacts"}, task.artefacts.map(leafRow))))) : null;
h("ul", {class: "leaves", "aria-label": "Artifacts"}, task.artefacts.map((found) => leafRow(`task:${task.task}`, found)))))) : null;
const past = gone.length ? h("details", {class: "card repo", open: true}, h("summary", {}, icon("bi-trash3"), h("span", {}, "Recently deleted"), counter(gone.length)),
gone.map((item) => h("div", {class: "branch-row", "data-result": item.status}, h("div", {class: "branch-name"}, h("strong", {}, item.branch), h("code", {}, item.repository), resultChip(item))))) : null;
tree.dom.list.replaceChildren(...cards, loose || "", past || "");
return {count: repos.length, nodes: [...cards, loose || "", past || ""]};
}
+85 -31
View File
@@ -10,15 +10,19 @@ const Panels = (() => {
const PANEL = "panel";
const SIZES = {panel: [6, 4], item: [4, 3]};
const HOSTS = "[data-panel], [data-item]";
const TOO_LONG = "the id runs past 200 characters";
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 captures = 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);
const plain = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
const keysOf = (pin) => Object.keys(pin).sort().join(",");
/**
* @param raw - an item's own id, any text.
@@ -32,8 +36,22 @@ const Panels = (() => {
const raw = (id) => id.replace(ESCAPED, (_, hex) => String.fromCodePoint(parseInt(hex, 16)));
function fnv(text, seed) {
let value = seed;
for (const char of text) {
value = Math.imul(value ^ char.codePointAt(0), 0x01000193) >>> 0;
}
return value.toString(16).padStart(8, "0");
}
/**
* @param text - any text, such as the canonical form of a pin's view.
* @returns 16 hex characters, two FNV-1a hashes of the text with different offsets.
*/
const digest = (text) => `${fnv(text, 0x811c9dc5)}${fnv(text, 0x01000193)}`;
function valid(pin) {
return Boolean(pin) && typeof pin === "object" && !Array.isArray(pin) && Object.keys(pin).sort().join(",") === "h,id,kind,w"
return plain(pin) && ["h,id,kind,w", "h,id,kind,view,w"].includes(keysOf(pin)) && (!Object.hasOwn(pin, "view") || plain(pin.view))
&& typeof pin.kind === "string" && KIND.test(pin.kind) && typeof pin.id === "string" && ID.test(pin.id) && span(pin.w) && span(pin.h);
}
@@ -46,7 +64,8 @@ const Panels = (() => {
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}));
return pins.filter((pin) => valid(pin) && !seen.has(keyOf(pin)) && Boolean(seen.add(keyOf(pin)))).slice(0, MAX)
.map(({kind, id, w, h, view}) => (view ? {kind, id, w, h, view} : {kind, id, w, h}));
}
/**
@@ -61,39 +80,61 @@ const Panels = (() => {
/**
* @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.
* @param title - the tile title, or (id, view) => title.
* @param render - (size, id, view) => Node, or null once the item no longer exists; view is the pin's stored view,
* undefined for a pin without one.
*/
function item(kind, title, render) {
items.set(kind, {title, render, group: ""});
}
function lookup(kind, id) {
/**
* @param id - the data-panel of a source element whose star pins a bookmark of what it shows instead of itself.
* @param take - (element) => {kind, id, view, refused}: the item pin the star makes now, such as a chart with the
* series switched on at this moment; the star shows that pin's pressed state, or stays disabled with refused as its
* reason while refused is a non-empty text.
*/
function capture(id, take) {
captures.set(id, take);
}
function lookup(kind, id, view) {
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)};
const name = kind === PANEL ? id : raw(id);
return {kind, id, group: entry.group, title: typeof entry.title === "function" ? entry.title(name, view) : entry.title, render: (size) => entry.render(size, name, view)};
}
/**
* @param element - a source element with data-panel or data-item.
* @returns {kind, id, view, refused} of the pin its star makes now, or null for a data-item without a kind; refused
* names why no pin is possible, such as an id past 200 characters, and id is null then unless a capture gave one.
*/
function targetOf(element) {
if (element.hasAttribute("data-panel")) {
return {kind: PANEL, id: element.getAttribute("data-panel")};
const id = element.getAttribute("data-panel");
return captures.has(id) ? captures.get(id)(element) : {kind: PANEL, id};
}
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;
if (cut < 1) {
return null;
}
const id = token(value.slice(cut + 1));
return id ? {kind: value.slice(0, cut), id} : {kind: value.slice(0, cut), id: null, refused: TOO_LONG};
}
const has = (pins, kind, id) => pins.some((pin) => pin.kind === kind && pin.id === id);
const groupOf = (pin) => (lookup(pin.kind, pin.id) || {group: ""}).group;
/**
* @param view - optional plain object the new pin stores, such as the chart selection of a metric bookmark.
* @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) {
function add(pins, kind, id, view) {
if (has(pins, kind, id)) {
return {pins, refused: "", holder: null};
}
@@ -106,7 +147,7 @@ const Panels = (() => {
return {pins, refused: "group", holder};
}
const [w, h] = kind === PANEL ? SIZES.panel : SIZES.item;
return {pins: [...pins, {kind, id, w, h}], refused: "", holder: null};
return {pins: [...pins, plain(view) ? {kind, id, w, h, view} : {kind, id, w, h}], refused: "", holder: null};
}
const firstOfGroup = (pins, pin) => !groupOf(pin) || pins.find((other) => groupOf(other) === groupOf(pin)) === pin;
@@ -214,7 +255,7 @@ const Panels = (() => {
return svg;
}
function paint(button, on, title) {
function paint(button, on, title, refused) {
const label = on ? "Unpin from Home" : "Pin to Home";
if (button.getAttribute("aria-pressed") !== String(on)) {
button.setAttribute("aria-pressed", String(on));
@@ -223,10 +264,17 @@ const Panels = (() => {
if (button.getAttribute("aria-label") !== label) {
button.setAttribute("aria-label", label);
}
const hint = `${label}: ${title}`;
const hint = refused ? `${label}: not possible, ${refused}` : `${label}: ${title}`;
if (button.getAttribute("title") !== hint) {
button.setAttribute("title", hint);
}
if (button.hasAttribute("disabled") !== Boolean(refused)) {
if (refused) {
button.setAttribute("disabled", "");
} else {
button.removeAttribute("disabled");
}
}
}
function slotOf(element) {
@@ -244,25 +292,18 @@ const Panels = (() => {
return row;
}
function button(element, options, enabled) {
function button(element, options) {
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;
const entry = now && now.id && !now.refused ? lookup(now.kind, now.id, now.view) : null;
if (entry) {
options.press(now.kind, now.id, entry.title);
options.press(now.kind, now.id, entry.title, now.view);
}
});
return made;
@@ -273,26 +314,39 @@ const Panels = (() => {
return;
}
const target = targetOf(element);
const entry = target && target.id ? lookup(target.kind, target.id) : null;
const entry = target && target.id ? lookup(target.kind, target.id, target.view) : null;
if (!target || (target.id && !entry)) {
return;
}
let made = placed.get(element);
if (!made || !element.contains(made)) {
made = button(element, options, Boolean(entry));
made = button(element, options);
placed.set(element, made);
slotOf(element).append(made);
}
if (entry) {
paint(made, options.pinned(target.kind, target.id), entry.title);
const refused = target.refused || "";
paint(made, !refused && options.pinned(target.kind, target.id), entry ? entry.title : "", refused);
}
/**
* @param slot - a data-star-slot element that draw moves into freshly drawn content.
* @param draw - () => void, the redraw.
* @returns nothing; the star in the slot gets back the focus it had before draw moved it.
*/
function keepFocus(slot, draw) {
const held = slot && slot.contains(document.activeElement) ? document.activeElement : null;
draw();
if (held && held.isConnected && document.activeElement !== held) {
held.focus();
}
}
/**
* @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.
* @param options - {pinned(kind, id) => boolean, press(kind, id, title, view), marks: [[selector, panel id], ...]},
* marks naming source elements whose page carries no data-panel of its own; view is undefined unless a capture
* gave one.
* @returns mark(): tags the marks, stars what lacks one and repaints the pressed state of all.
*/
function decorate(root, options) {
@@ -307,8 +361,8 @@ const Panels = (() => {
}
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,
MAX, SPAN, PANEL, ID, HOSTS, keyOf, token, raw, digest, valid, validLayout, clean, panel, item, capture, lookup, targetOf, has, add, remove, firstOfGroup,
place, move, resize, placeKey, moveKey, resizeKey, resizeBy, stretch, memory, store, decorate, keepFocus,
};
})();
if (typeof module === "object" && module.exports) {
+8
View File
@@ -18,6 +18,14 @@
.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); }
.home-metric { display: flex; flex-direction: column; gap: var(--sp-1); height: 100%; min-height: 0; }
.home-metric .res-plot { flex: 1; min-height: 60px; }
.home-metric .res-plot > svg { height: 100%; max-height: none; }
.home-metric .legend-chip, .home-order li { cursor: default; }
.home-inbox { display: grid; gap: var(--sp-2); margin: 0; padding: 0; list-style: none; }
.home-inbox > li { display: grid; gap: var(--sp-1); padding: var(--sp-2); border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--sunken); }
.home-inbox .msg-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.leaf > .star-row { order: 1; margin-inline-start: auto; }
@media (max-width: 640px) {
.home-tile { grid-column: 1 / -1; }
.legend[data-star-slot] > .star { order: 1; }