feat(hub): deny reason chips, patterned Match card heads and copyable place pills
The deny sheet shows the last five distinct deny reasons as chips (recent_reasons in denying.py, served as reasons in /api/state); a click fills the reason field. Match cards get a per-card pattern (dots, stripes, waves, grid, rings) and a two-hue gradient head, the repo, branch and worktree become copyable pills, Match keeps the last comments and peeks in local storage, and Home gets a slot label. Rebased from its lane base2754568onto96d332a: the scan copy's diff against2aea6d1would have reverted the release-flash fix, so the bundle was re-exported against 2754568; the one conflict in page-match.js keeps matchView.epoch next to the new COMMENTS_KEPT and PATTERNS. node --check passes. Tests: test_deny_reason_chips_e2e plus Match review and waiting e2e and test_hub_deny, test_hub_state updates. Written, not run: the full suite runs once on master after all bundles (operator order). Security: MEDUSA over the staged tree on master: 100, no findings; index.html.j2, style-home.css and style-match.css are not covered and were read by hand (style rules only, no url or import). 🎯 Fix: 90 % 💥 Break: 5 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 86 🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 % Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
96d332a7cd
commit
f95196ca82
15 files changed
+369
-24
No files matched your search
@@ -15,6 +15,26 @@ NOTED = ("review",)
|
||||
DENY_KEYS = ("channel", "reason", "to")
|
||||
DENY_CHANNELS = {**DIRECT, **{name: words for name, words in TO_ALL.items() if name != "mayday"}}
|
||||
REASON_LIMIT = 2000
|
||||
REASONS_SHOWN = 5
|
||||
|
||||
|
||||
def recent_reasons(messages: list[dict]) -> list[str]:
|
||||
"""Args:
|
||||
messages: the stored messages; a denial's signed item holds its
|
||||
reason.
|
||||
|
||||
Returns:
|
||||
the last REASONS_SHOWN distinct non-empty denial reasons by
|
||||
created_ts, newest first.
|
||||
"""
|
||||
recent: list[str] = []
|
||||
for message in sorted(messages, key=lambda message: message["created_ts"], reverse=True):
|
||||
reason = message["denial"]["reason"] if message.get("denial") else ""
|
||||
if reason and reason not in recent:
|
||||
recent.append(reason)
|
||||
if len(recent) == REASONS_SHOWN:
|
||||
break
|
||||
return recent
|
||||
|
||||
|
||||
def denial_note(raw: dict, requester: str) -> dict:
|
||||
|
||||
@@ -15,6 +15,7 @@ from .council import (
|
||||
silence_of,
|
||||
)
|
||||
from .crons import queue_entries
|
||||
from .denying import recent_reasons
|
||||
from .engines import pitch_of, sound_of
|
||||
from .errors import ToolError
|
||||
from .events import KINDS, VIEWS
|
||||
@@ -137,6 +138,7 @@ class View:
|
||||
order = stored_order(self.council / AGENT_ORDER)
|
||||
rows = task_rows(tasks, queue, self.tree.get())
|
||||
chain = grant_order(queue_chain(queue, tasks, order, now), queue_jobs)
|
||||
stored = self.messages.listed()
|
||||
return {
|
||||
"settings": settings,
|
||||
"media": media_origins(settings),
|
||||
@@ -159,7 +161,8 @@ class View:
|
||||
"reviews": [row for row in map(review_row, self.reviews.pending()) if row["created_ts"] <= end],
|
||||
"asks": [ask_row(ask, names) for ask in self.asks.pending() if ask["expires"] > now and ask["created_ts"] <= end],
|
||||
"decisions": [decision_row(decision) for decision in self.decisions.pending() if decision["created_ts"] <= end],
|
||||
"messages": [{**message_row(message), **read_of(inlined, epoch(message.get("relay_ts")))} for message in self.messages.listed() if begin <= message["created_ts"] <= end],
|
||||
"messages": [{**message_row(message), **read_of(inlined, epoch(message.get("relay_ts")))} for message in stored if begin <= message["created_ts"] <= end],
|
||||
"reasons": recent_reasons(stored),
|
||||
"operator": operator_rows(tasks),
|
||||
"register": register_rows(tasks),
|
||||
"tasks": rows,
|
||||
|
||||
@@ -151,6 +151,7 @@ pre.notes { max-height: 260px; margin: 12px 0 0; padding: 10px 12px; overflow: a
|
||||
.chip:hover { color: var(--text); border-color: var(--line-strong); }
|
||||
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
|
||||
.chip.preset { font-weight: 650; }
|
||||
.reason-chips .chip { max-width: 100%; }
|
||||
.chip .x { padding: 0 2px; border: 0; background: none; color: inherit; cursor: pointer; }
|
||||
.split { display: grid; grid-template-columns: minmax(220px, 320px) minmax(0, 1fr); gap: 14px; align-items: start; }
|
||||
@media (max-width: 860px) { .split { grid-template-columns: minmax(0, 1fr); } }
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
const MOVE = 2000;
|
||||
const RELAYOUT = 60000;
|
||||
const SESSION_ID = /^[A-Za-z0-9_-]{1,128}$/;
|
||||
const STORE = {views: "kvb-orchestrator.views", status: "kvb-orchestrator.status"};
|
||||
const STORE = {views: "kvb-orchestrator.views", status: "kvb-orchestrator.status", comments: "kvb-orchestrator.match-comments", peeks: "kvb-orchestrator.match-peeks"};
|
||||
const PRESENCE = {
|
||||
working: ["Working", "bi-gear-fill", "info"],
|
||||
alive: ["Alive", "bi-heart-pulse-fill", "ok"],
|
||||
|
||||
@@ -6,6 +6,29 @@
|
||||
return submit([{...entryOf(item, "reject", ""), channel, reason, to: item.to}], `Denial (${CLASSES[channel]}): ${short(item.title)}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {HTMLTextAreaElement} field the field the chips fill.
|
||||
* @param {string[]} texts the earlier texts, newest first.
|
||||
* @param {string} label the accessible name of the chip group.
|
||||
* @returns {Node|null} the texts as chips: a press puts its text into the field, which stays editable; null without
|
||||
* texts.
|
||||
*/
|
||||
function presetChips(field, texts, label) {
|
||||
if (!texts.length) {
|
||||
return null;
|
||||
}
|
||||
return h("div", {class: "chips reason-chips", role: "group", "aria-label": label}, texts.map((text) => {
|
||||
const chip = h("button", {type: "button", class: "chip", title: text}, short(text));
|
||||
chip.addEventListener("click", () => {
|
||||
field.value = text;
|
||||
field.focus();
|
||||
});
|
||||
return chip;
|
||||
}));
|
||||
}
|
||||
|
||||
const reasonChips = (field) => presetChips(field, state.reasons, "Recent reasons");
|
||||
|
||||
function denySheet(item) {
|
||||
const name = `deny-${keyOf(item)}`;
|
||||
const choices = DENY_CHANNELS.map(([id, direct, hint]) => h("label", {class: "deny-channel"},
|
||||
@@ -22,6 +45,7 @@
|
||||
h("div", {class: "who"}, pill(ITEM_LABELS[item.kind], KIND_TONES[item.kind]), item.agent ? person(item.agent) : null),
|
||||
h("p", {class: "text"}, item.title),
|
||||
h("fieldset", {class: "deny-channels"}, h("legend", {}, "Channel"), choices),
|
||||
reasonChips(reason),
|
||||
h("label", {class: "deny-reason"}, "Reason (optional, the agent reads it too)", reason),
|
||||
h("p", {class: "muted"}, "The passkey signs the denial with channel, recipient and reason; then 3 s remain to undo it.",
|
||||
" Mayday stays reserved for the operator."),
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
const HOME_FETCH = 3000;
|
||||
const HOME_MESSAGE = 30000;
|
||||
const HOME_MARKS = [['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 homeView = {dom: null, pins: [], tiles: new Map(), hosts: new Map(), heads: 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);
|
||||
@@ -515,6 +515,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Element} tile the Home tile.
|
||||
* @param {Element|null} slot the controls its panel hands the tile head (homeView.heads), shown between the title and
|
||||
* the open link; null takes the previous ones out.
|
||||
*/
|
||||
function homeHeadSlot(tile, slot) {
|
||||
const old = tile.querySelector(".home-head > .home-slot");
|
||||
if (old === slot) {
|
||||
return;
|
||||
}
|
||||
if (old) {
|
||||
old.remove();
|
||||
}
|
||||
if (slot) {
|
||||
slot.classList.add("home-slot");
|
||||
tile.querySelector(".home-open").before(slot);
|
||||
}
|
||||
}
|
||||
|
||||
function homeContent(entry, pin) {
|
||||
try {
|
||||
return entry.render({w: pin.w, h: pin.h});
|
||||
@@ -535,6 +554,7 @@
|
||||
homeSpan(tile, pin);
|
||||
tile.querySelector(".home-title").textContent = name;
|
||||
homeOpenLink(tile.querySelector(".home-open"), content ? homeLink(pin) : null, name);
|
||||
homeHeadSlot(tile, content ? homeView.heads.get(pin.id) : null);
|
||||
const body = tile.querySelector(".home-body");
|
||||
const shown = content || homeGone(pin, key);
|
||||
if (body.childNodes.length !== 1 || body.firstChild !== shown) {
|
||||
|
||||
@@ -185,7 +185,7 @@
|
||||
const note = deny
|
||||
? "Every entry and every full command that gets denied; each requester gets its denial and the reason by post. After the click the passkey signs the whole selection once; then 3 s remain to undo."
|
||||
: "Every entry and every full command that gets granted. After the click the passkey signs the whole selection once; then 3 s remain to undo.";
|
||||
openSheet(label, [h("p", {class: "muted"}, note), h("ul", {class: "mini"}, rows), ...(deny ? [h("label", {class: "deny-reason"}, "Reason (optional, every requester reads it)", reason)] : []),
|
||||
openSheet(label, [h("p", {class: "muted"}, note), h("ul", {class: "mini"}, rows), ...(deny ? [reasonChips(reason), h("label", {class: "deny-reason"}, "Reason (optional, every requester reads it)", reason)] : []),
|
||||
h("div", {class: "actions"}, h("span", {class: "spacer"}), btn("Cancel", "btn ghost", closeSheet), confirm)], false);
|
||||
(reason || confirm).focus();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
const FEEDBACK_LIMIT = 2000;
|
||||
const FLY_MS = 400;
|
||||
const CONFETTI = 28;
|
||||
const COMMENTS_KEPT = 5;
|
||||
const PATTERNS = ["dots", "stripes", "waves", "grid", "rings"];
|
||||
const matchView = {cards: null, order: [], marks: new Map(), opened: new Map(), decisions: new Map(), overview: false, front: null, drag: null, dom: null, sig: "", fetched: 0, loading: false, press: null, flying: false, openBefore: 0, epoch: 0};
|
||||
|
||||
/**
|
||||
@@ -61,6 +63,20 @@
|
||||
|
||||
const cardKey = (card) => `${card.id}@${card.hash}`;
|
||||
|
||||
/**
|
||||
* @returns {string[]} this browser's last COMMENTS_KEPT distinct saved line comments, newest first.
|
||||
*/
|
||||
function savedComments() {
|
||||
const kept = stored(STORE.comments, []);
|
||||
return Array.isArray(kept) ? kept.filter((text) => typeof text === "string" && text).slice(0, COMMENTS_KEPT) : [];
|
||||
}
|
||||
|
||||
const peeksShown = () => stored(STORE.peeks, true) !== false;
|
||||
|
||||
function rememberComment(text) {
|
||||
keep(STORE.comments, [text, ...savedComments().filter((old) => old !== text)].slice(0, COMMENTS_KEPT));
|
||||
}
|
||||
|
||||
function marksOf(card) {
|
||||
const key = cardKey(card);
|
||||
if (!matchView.marks.has(key)) {
|
||||
@@ -153,11 +169,13 @@
|
||||
return;
|
||||
}
|
||||
marksOf(data).push({path: file.dataset.path, line: Number(row.dataset.line), comment: words.value.trim()});
|
||||
rememberComment(words.value.trim());
|
||||
drawMatch(true);
|
||||
}}}, icon("bi-bookmark-fill"), "Save");
|
||||
const cancel = h("button", {type: "button", class: "btn small ghost", ...named("Cancel"), on: {click: () => closeComment(article)}}, "Cancel");
|
||||
const columns = row.children.length;
|
||||
const field = h("tr", {class: "match-comment"}, h("td", {colspan: columns}, h("div", {class: "match-comment-box"}, h("code", {}, `${file.dataset.path}:${row.dataset.line}`), words, h("div", {class: "actions"}, cancel, save))));
|
||||
const field = h("tr", {class: "match-comment"}, h("td", {colspan: columns}, h("div", {class: "match-comment-box"}, h("code", {}, `${file.dataset.path}:${row.dataset.line}`),
|
||||
presetChips(words, savedComments(), "Recent comments"), words, h("div", {class: "actions"}, cancel, save))));
|
||||
row.after(field);
|
||||
words.focus();
|
||||
}
|
||||
@@ -201,6 +219,47 @@
|
||||
article.addEventListener("pointercancel", drop);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} worktree the card's worktree path.
|
||||
* @param {string} repo the card's repository path.
|
||||
* @returns {string} the worktree below the repository relative to it, the repository itself as "checkout", any
|
||||
* other path as its last three folders.
|
||||
*/
|
||||
function worktreeWords(worktree, repo) {
|
||||
if (repo && worktree === repo) {
|
||||
return "checkout";
|
||||
}
|
||||
if (repo && worktree.startsWith(`${repo}/`)) {
|
||||
return worktree.slice(repo.length + 1);
|
||||
}
|
||||
const parts = worktree.split("/").filter(Boolean);
|
||||
return parts.length > 3 ? `…/${parts.slice(-3).join("/")}` : worktree;
|
||||
}
|
||||
|
||||
function placeChip(place, iconName, label, value, words) {
|
||||
const full = revealed(value);
|
||||
const chip = h("button", {type: "button", class: "match-where", "data-place": place, title: `${label}: ${full} (click copies)`, "aria-label": `${label}: ${full}, click copies`},
|
||||
icon(iconName), h("span", {}, revealed(words)));
|
||||
chip.addEventListener("click", async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(value);
|
||||
toast(`Copied ${label.toLowerCase()}`, [full], true);
|
||||
} catch {
|
||||
toast("Not copied", ["The browser refused the clipboard."], false);
|
||||
}
|
||||
});
|
||||
return chip;
|
||||
}
|
||||
|
||||
function placeRow(card) {
|
||||
const chips = [
|
||||
card.branch ? placeChip("branch", "bi-git", "Branch", card.branch, card.branch) : null,
|
||||
card.repo ? placeChip("repo", "bi-folder2", "Repository", card.repo, card.repo.split("/").filter(Boolean).pop() || card.repo) : null,
|
||||
card.worktree ? placeChip("worktree", "bi-diagram-2", "Worktree", card.worktree, worktreeWords(card.worktree, card.repo)) : null,
|
||||
].filter(Boolean);
|
||||
return chips.length ? h("div", {class: "match-place", "aria-label": "Place"}, chips) : null;
|
||||
}
|
||||
|
||||
function matchHead(card) {
|
||||
const [kindName, kindTone, kindIcon] = MATCH_KINDS[card.kind] || [card.kind, "neutral", "bi-collection"];
|
||||
const metrics = card.metrics || [];
|
||||
@@ -210,7 +269,7 @@
|
||||
h("span", {"aria-hidden": "true"}, metric.emoji), h("span", {class: "match-metric-label"}, metric.label), h("strong", {}, revealed(metric.value))))) : null,
|
||||
h("div", {class: "states"}, h("span", {class: "pill", "data-tone": kindTone}, icon(kindIcon), kindName), card.gate ? pill(`gate ${card.gate}`, card.gate === "pass" ? "ok" : "bad") : null,
|
||||
card.score && !metrics.length ? h("span", {class: "pill", "data-tone": "neutral"}, revealed(card.score)) : null, card.stale ? h("span", {class: "pill match-stale-pill", "data-tone": "bad"}, icon("bi-hourglass-split"), "stale") : null),
|
||||
h("dl", {class: "meta match-place"}, [["Repository", card.repo], ["Branch", card.branch], ["Worktree", card.worktree]].map(([label, value]) => h("div", {}, h("dt", {}, label), h("dd", {}, h("code", {title: value ? revealed(value) : null}, revealed(dash(value))))))),
|
||||
placeRow(card),
|
||||
h("h2", {class: "match-title"}, revealed(card.title)),
|
||||
card.stale ? h("p", {class: "match-stale"}, icon("bi-exclamation-triangle"), revealed(card.stale_reason)) : null);
|
||||
}
|
||||
@@ -247,6 +306,18 @@
|
||||
card.reason && card.reason !== "-" ? h("p", {class: "match-reason"}, revealed(card.reason)) : null, preview);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {HTMLElement} article the card.
|
||||
* @param {string} id the card id; the same id always gets the same two hues and pattern, so a redraw never flickers.
|
||||
*/
|
||||
function paint(article, id) {
|
||||
const seed = Faces.hash(id);
|
||||
const hue = seed % 360;
|
||||
article.style.setProperty("--card-hue", String(hue));
|
||||
article.style.setProperty("--card-hue-2", String((hue + 40 + ((seed >>> 9) % 100)) % 360));
|
||||
article.dataset.pattern = PATTERNS[(seed >>> 17) % PATTERNS.length];
|
||||
}
|
||||
|
||||
function matchCard(card) {
|
||||
const files = card.files || [];
|
||||
const none = card.kind === "commit" ? "No diff shipped with this stage." : card.kind === "ask" ? "Its tool call changes no file." : card.merge ? (card.merge.error ? "No diff to show." : "The merge brings no change.") : "Its command names no file.";
|
||||
@@ -256,6 +327,7 @@
|
||||
const article = h("article", {class: "card match-card front", "data-card": card.id, "data-kind": card.kind, "data-stale": String(Boolean(card.stale)), "aria-label": `${card.kind} card of ${card.agent || "an agent"}`},
|
||||
matchHead(card), body);
|
||||
article.style.setProperty("--agent-hue", String(Faces.hash(card.agent) % 360));
|
||||
paint(article, card.id);
|
||||
markable(article, card);
|
||||
window.setTimeout(() => openOnScroll(body, ".match-file"), 0);
|
||||
return article;
|
||||
@@ -365,7 +437,7 @@
|
||||
decide(card, "reject", words.value.trim(), "");
|
||||
});
|
||||
const note = `${card.agent || "The agent"} gets this text by radio call at the release; nothing is sent before.`;
|
||||
openSheet(`Reject: ${card.title}`, [h("p", {class: "muted"}, note), words, h("div", {class: "actions"}, h("span", {class: "spacer"}), btn("Cancel", "btn ghost", closeSheet), confirm)], false);
|
||||
openSheet(`Reject: ${card.title}`, [h("p", {class: "muted"}, note), reasonChips(words), words, h("div", {class: "actions"}, h("span", {class: "spacer"}), btn("Cancel", "btn ghost", closeSheet), confirm)], false);
|
||||
words.focus();
|
||||
}
|
||||
|
||||
@@ -531,12 +603,16 @@
|
||||
matchView.overview = true;
|
||||
drawMatch(true);
|
||||
}}}, icon("bi-card-checklist"), tally);
|
||||
matchView.dom = {stack, count, decisions, tally};
|
||||
const peeks = h("button", {type: "button", class: "btn small soft match-peeks-toggle", "aria-pressed": String(peeksShown()), ...named("Next cards", "Next cards: show or hide the row of waiting cards below the buttons"), on: {click: () => {
|
||||
keep(STORE.peeks, !peeksShown());
|
||||
drawMatch(true);
|
||||
}}}, icon("bi-collection"));
|
||||
matchView.dom = {stack, count, decisions, tally, peeks};
|
||||
matchView.sig = "";
|
||||
if (matchView.drag) {
|
||||
matchView.drag.end();
|
||||
}
|
||||
const bar = h("div", {class: "card controls task-toolbar", role: "toolbar", "aria-label": "Match"}, h("strong", {}, icon("bi-stack"), "Match"), count, h("span", {class: "spacer"}), decisions,
|
||||
const bar = h("div", {class: "card controls task-toolbar", role: "toolbar", "aria-label": "Match"}, h("strong", {}, icon("bi-stack"), "Match"), count, h("span", {class: "spacer"}), decisions, peeks,
|
||||
iconBtn("bi-list-check", "Tasks", "btn small soft", () => go("tasks", null), "Tasks: back to the task list"), h("span", {"data-star-slot": ""}));
|
||||
fetchMatch();
|
||||
return h("div", {class: "graph tasks match", "data-panel": "tasks/match"}, bar, stack);
|
||||
@@ -544,7 +620,7 @@
|
||||
|
||||
/**
|
||||
* @returns {Element} the Match stack for a Home tile, kept while it still holds the live stack, without the
|
||||
* data-panel and star slot of the screen.
|
||||
* data-panel and toolbar of the screen: its card count and decisions button go to the tile head.
|
||||
*/
|
||||
function homeMatch() {
|
||||
const kept = homeView.hosts.get("tasks/match");
|
||||
@@ -553,7 +629,8 @@
|
||||
}
|
||||
const host = h("div", {class: "match-home"}, matchScreen());
|
||||
host.querySelectorAll("[data-panel]").forEach((node) => node.removeAttribute("data-panel"));
|
||||
host.querySelectorAll("[data-star-slot]").forEach((node) => node.removeAttribute("data-star-slot"));
|
||||
host.querySelector(".task-toolbar").remove();
|
||||
homeView.heads.set("tasks/match", h("div", {role: "toolbar", "aria-label": "Match"}, matchView.dom.count, matchView.dom.decisions, matchView.dom.peeks));
|
||||
homeView.hosts.set("tasks/match", host);
|
||||
window.setTimeout(() => drawMatch(true), 0);
|
||||
return host;
|
||||
@@ -590,6 +667,7 @@
|
||||
matchView.openBefore = open.length;
|
||||
dom.count.textContent = open.length === 1 ? "1 card waits" : `${open.length} cards wait`;
|
||||
dom.tally.textContent = String(matchView.decisions.size);
|
||||
dom.peeks.setAttribute("aria-pressed", String(peeksShown()));
|
||||
dom.decisions.hidden = !matchView.decisions.size || shownOverview;
|
||||
if (!cards.length) {
|
||||
matchView.front = null;
|
||||
@@ -613,7 +691,7 @@
|
||||
const accept = act("match-accept", "bi-check-lg", "Accept", revealed(hint), Boolean(front.stale) || (front.kind === "decision" && !front.recommended), () => acceptCard(front));
|
||||
const reject = act("match-reject", "bi-x-lg", "Reject", pickOnly(front) ? "Reject: a choice is answered with one of its options" : "Reject with feedback (left arrow, swipe left)", pickOnly(front), () => rejectCard(front));
|
||||
const later = act("match-later", "bi-arrow-up", "Later", "Later: to the back of the stack (up arrow, swipe up)", !rest.length, () => laterCard(front));
|
||||
const peeks = rest.length ? h("div", {class: "match-peeks", role: "group", "aria-label": `${rest.length} more cards`}, rest.map(peekTab)) : null;
|
||||
const peeks = rest.length && peeksShown() ? h("div", {class: "match-peeks", role: "group", "aria-label": `${rest.length} more cards`}, rest.map(peekTab)) : null;
|
||||
const behind = rest.slice(0, MATCH_PEEKS).map((card, index) => {
|
||||
const sheet = h("div", {class: "match-behind", "aria-hidden": "true"});
|
||||
sheet.style.setProperty("--depth", String(index + 1));
|
||||
@@ -624,6 +702,6 @@
|
||||
const shown = matchCard(front);
|
||||
shown.dataset.fresh = String(!before || before.dataset.card !== front.id);
|
||||
draggable(shown, front);
|
||||
dom.stack.replaceChildren(peeks || h("div", {class: "match-peeks"}), h("div", {class: "match-deck"}, behind, shown), h("div", {class: "match-actions"}, reject, later, accept));
|
||||
dom.stack.replaceChildren(h("div", {class: "match-deck"}, behind, shown), h("div", {class: "match-actions"}, reject, later, accept), peeks);
|
||||
shown.querySelector(".match-body").scrollTop = scrolled;
|
||||
}
|
||||
@@ -15,6 +15,8 @@
|
||||
.home-body .stage, .home-body .graph3d { height: 100%; min-height: 0; }
|
||||
.home-grip { cursor: grab; touch-action: none; }
|
||||
.home-open[hidden] { display: none; }
|
||||
.home-slot { display: flex; flex: none; align-items: center; gap: 6px; min-width: 0; font-size: var(--fs-sm); }
|
||||
.home-slot > .muted { white-space: nowrap; }
|
||||
.home-tile[data-w="1"] .home-head { gap: 2px; padding-inline: 2px; }
|
||||
.home-tile[data-w="1"] .home-head .icon-only { min-width: 24px; padding-inline: 4px; }
|
||||
.home-resize { position: absolute; right: 2px; bottom: 2px; z-index: 3; cursor: nwse-resize; touch-action: none; }
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
.match-home { display: grid; height: 100%; min-height: 0; }
|
||||
.match-home > .graph.match { min-height: 0; }
|
||||
.match-stack { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: var(--sp-2); min-height: 0; width: min(100%, 960px); margin: 0 auto; }
|
||||
.match-stack:has(> .match-deck) { grid-template-rows: minmax(0, 1fr) auto auto; }
|
||||
.match-peeks { display: flex; flex-wrap: wrap; gap: var(--sp-1); min-width: 0; }
|
||||
.match-peek { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0; padding: 4px 10px 4px 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: inherit; font: inherit; font-size: var(--fs-sm); cursor: pointer; }
|
||||
.match-peek[data-stale="true"] { border-color: var(--bad); }
|
||||
@@ -9,7 +10,7 @@
|
||||
.match-deck { position: relative; display: grid; grid-template-rows: minmax(0, 1fr); min-height: 0; padding-top: 14px; overflow-x: clip; }
|
||||
.match-behind { position: absolute; inset: calc(14px - var(--depth) * 7px) calc(var(--depth) * 12px) auto; height: 40px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); opacity: calc(1 - var(--depth) * 0.3); transform: rotate(calc((var(--depth) * 2 - 3) * 1deg)); }
|
||||
.match-card.front { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; padding: 0; overflow: hidden; border-radius: 22px; box-shadow: 0 14px 34px -16px rgb(0 0 0 / 0.45); }
|
||||
.match-card.front::before { content: ""; position: absolute; inset: 0 0 auto; z-index: 1; height: 6px; background: linear-gradient(90deg, hsl(var(--agent-hue, 210) 75% 58%), hsl(calc(var(--agent-hue, 210) + 70) 75% 58%)); }
|
||||
.match-card.front::before { content: ""; position: absolute; inset: 0 0 auto; z-index: 1; height: 6px; background: linear-gradient(90deg, hsl(var(--card-hue, 210) 75% 58%), hsl(var(--card-hue-2, 280) 75% 58%)); }
|
||||
.match-card[data-stale="true"]::before { background: var(--bad); }
|
||||
.match-card.front[data-fresh="true"] { animation: match-in 0.32s cubic-bezier(0.34, 1.56, 0.64, 1); }
|
||||
.match-card.front[data-fresh="true"] .match-who .avatar { animation: match-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
|
||||
@@ -25,7 +26,15 @@
|
||||
@keyframes match-fly-right { to { transform: translate(120%, -4%) rotate(18deg); opacity: 0; } }
|
||||
@keyframes match-fly-left { to { transform: translate(-120%, -4%) rotate(-18deg); opacity: 0; } }
|
||||
@keyframes match-fly-up { to { transform: translateY(-110%) scale(0.9); opacity: 0; } }
|
||||
.match-head { display: grid; justify-items: center; gap: 6px; padding: var(--sp-3); border-bottom: 1px solid var(--line); background: linear-gradient(180deg, hsl(var(--agent-hue, 210) 80% 60% / 0.16), transparent 75%); text-align: center; }
|
||||
.match-head { position: relative; isolation: isolate; display: grid; justify-items: center; gap: 6px; padding: var(--sp-3); border-bottom: 1px solid var(--line); text-align: center;
|
||||
--ink: hsl(var(--card-hue, 210) 55% 48% / 0.16);
|
||||
background: radial-gradient(120% 90% at 0% 0%, hsl(var(--card-hue, 210) 85% 62% / 0.3), transparent 60%), radial-gradient(110% 90% at 100% 10%, hsl(var(--card-hue-2, 280) 85% 62% / 0.26), transparent 62%), linear-gradient(180deg, hsl(var(--card-hue, 210) 80% 60% / 0.1), transparent 85%); }
|
||||
.match-head::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; mask-image: linear-gradient(180deg, #000 15%, transparent 95%); }
|
||||
.match-card[data-pattern="dots"] .match-head::before { background: radial-gradient(var(--ink) 1.2px, transparent 1.7px) 0 0 / 14px 14px; }
|
||||
.match-card[data-pattern="stripes"] .match-head::before { background: repeating-linear-gradient(135deg, var(--ink) 0 2px, transparent 2px 12px); }
|
||||
.match-card[data-pattern="waves"] .match-head::before { background: radial-gradient(circle at 50% 100%, transparent 7px, var(--ink) 7.5px 9px, transparent 9.5px) 0 0 / 24px 12px; }
|
||||
.match-card[data-pattern="grid"] .match-head::before { background: linear-gradient(var(--ink) 1px, transparent 1px) 0 0 / 18px 18px, linear-gradient(90deg, var(--ink) 1px, transparent 1px) 0 0 / 18px 18px; }
|
||||
.match-card[data-pattern="rings"] .match-head::before { background: repeating-radial-gradient(circle at 100% 0%, var(--ink) 0 1.5px, transparent 1.5px 14px); }
|
||||
.match-who { display: grid; justify-items: center; gap: 2px; }
|
||||
.match-who .avatar.big { width: 72px; height: 72px; }
|
||||
.match-name { font-size: var(--fs-lg); }
|
||||
@@ -33,8 +42,11 @@
|
||||
.match-metrics { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0; padding: 0; list-style: none; }
|
||||
.match-metric { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--sunken); font-size: var(--fs-sm); white-space: nowrap; }
|
||||
.match-metric-label { color: var(--muted); }
|
||||
.match-place { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); width: 100%; margin: 0; text-align: left; }
|
||||
.match-place code { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.match-place { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 100%; }
|
||||
.match-where { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; min-width: 0; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; background: color-mix(in srgb, var(--panel) 80%, transparent); color: var(--muted); font: inherit; font-size: var(--fs-sm); cursor: copy; }
|
||||
.match-where span { overflow: hidden; font-family: var(--mono); text-overflow: ellipsis; white-space: nowrap; }
|
||||
.match-where:hover { border-color: var(--line-strong); color: var(--text); }
|
||||
.match-where[data-place="branch"] { border-color: color-mix(in srgb, var(--accent) 35%, transparent); background: var(--accent-soft); color: var(--accent); font-weight: 650; }
|
||||
.match-title { margin: 0; font-size: var(--fs-md); overflow-wrap: anywhere; }
|
||||
.match-stale { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--bad); font-size: var(--fs-sm); }
|
||||
.match-body { min-height: 0; overflow: auto; padding: var(--sp-2) var(--sp-3) var(--sp-3); overscroll-behavior: contain; }
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import time
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
sys.path[:0] = [str(HERE.parent), str(HERE)]
|
||||
|
||||
import hub_e2e_kit as base
|
||||
from hub_case import HubCase
|
||||
from hub_support import ASK
|
||||
|
||||
OUT = Path(os.environ.get("E2E_OUT", "/tmp/hub-reason-chips-shots"))
|
||||
SAID = ("make the gate green first", "rebase on main", "", "rebase on main", "split the bundle")
|
||||
SHOWN = ["split the bundle", "rebase on main", "make the gate green first"]
|
||||
COMMON = """
|
||||
const row = (ref) => document.querySelector(`#main .inbox-list > li[data-ref="${ref}"]`);
|
||||
const sheet = () => document.querySelector("#sheet:not([hidden]) .sheet-box");
|
||||
const chips = () => all(".reason-chips .chip", sheet());
|
||||
const wide = () => document.documentElement.scrollWidth > innerWidth + 1;
|
||||
const key = (value) => document.body.dispatchEvent(new KeyboardEvent("keydown", {key: value, bubbles: true}));
|
||||
const pick = async (index, field) => {
|
||||
const shown = chips().map(text);
|
||||
chips()[index].click();
|
||||
const filled = field.value;
|
||||
const focused = document.activeElement === field;
|
||||
field.value += " now";
|
||||
const result = {shown, filled, focused, edited: field.value, inside: chips().every((chip) => chip.getBoundingClientRect().right <= sheet().getBoundingClientRect().right + 1), wide: wide()};
|
||||
key("Escape");
|
||||
await until(() => !sheet(), 4000);
|
||||
return result;
|
||||
};
|
||||
"""
|
||||
INBOX = """(async () => {@HELPERS@@COMMON@
|
||||
if (!(await until(() => row("@ASK@"), 8000))) {
|
||||
return {error: text(document.getElementById("main"))};
|
||||
}
|
||||
row("@ASK@").querySelector('.deny-split button[aria-haspopup="dialog"]').click();
|
||||
if (!(await until(() => sheet() && chips().length, 4000))) {
|
||||
return {error: text(document.getElementById("sheet"))};
|
||||
}
|
||||
const single = await pick(1, sheet().querySelector(".deny-reason textarea"));
|
||||
const menu = () => document.querySelector("#grant-bar details.grant-menu");
|
||||
const checkbox = row("@ASK@").querySelector('input[type="checkbox"]');
|
||||
if (checkbox && !checkbox.checked) {
|
||||
checkbox.click();
|
||||
}
|
||||
if (!(await until(() => menu(), 3000))) {
|
||||
return {single, error: "no selection menu"};
|
||||
}
|
||||
menu().querySelector("summary").click();
|
||||
await until(() => menu().open, 2000);
|
||||
const deny = all("#grant-bar .menu-item.danger").find((button) => text(button).startsWith("Deny"));
|
||||
deny.click();
|
||||
if (!(await until(() => sheet() && chips().length, 4000))) {
|
||||
return {single, error: text(document.getElementById("sheet"))};
|
||||
}
|
||||
const bulk = await pick(0, sheet().querySelector(".deny-reason textarea"));
|
||||
return {single, bulk};
|
||||
})()"""
|
||||
MATCH = """(async () => {@HELPERS@@COMMON@
|
||||
const card = () => document.querySelector("#main .match-card.front");
|
||||
if (!(await until(card, 8000))) {
|
||||
return {error: text(document.getElementById("main"))};
|
||||
}
|
||||
key("ArrowLeft");
|
||||
if (!(await until(() => sheet() && sheet().querySelector(".match-feedback") && chips().length, 4000))) {
|
||||
return {error: text(document.getElementById("sheet"))};
|
||||
}
|
||||
return {reject: await pick(2, sheet().querySelector(".match-feedback"))};
|
||||
})()"""
|
||||
|
||||
|
||||
def probe(template: str, ask: str) -> str:
|
||||
return template.replace("@HELPERS@", base.HELPERS).replace("@COMMON@", COMMON).replace("@ASK@", ask)
|
||||
|
||||
|
||||
@unittest.skipUnless(shutil.which(os.environ.get("CHROMIUM", "chromium")), "no Chromium")
|
||||
class TestReasonChips(HubCase):
|
||||
drive = base.OrchestratorE2ECase.drive
|
||||
authenticator = base.OrchestratorE2ECase.authenticator
|
||||
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
self.claim("s1", "Skills session")
|
||||
self.ask = self.create_ask({**ASK, "timeout": 3600})
|
||||
now = time.time()
|
||||
for age, reason in enumerate(SAID):
|
||||
denial = {"channel": "post", "kind": "ask", "reason": reason, "subject": {}, "to": "Skills"}
|
||||
fields = {"to": "Skills", "address": "Skills session", "text": "Denied by the operator.", "upload": None, "voice": None, "voice_sha256": "", "class": "post"}
|
||||
self.httpd.hub.messages.add({**fields, "denial": denial, "proof": None, "created_ts": now - 60 + age})
|
||||
|
||||
def steps(self) -> list[dict]:
|
||||
OUT.mkdir(parents=True, exist_ok=True)
|
||||
local = f"http://localhost:{self.port}/"
|
||||
ref = f"ask:{self.ask}"
|
||||
steps = []
|
||||
for width, height in base.WIDTHS:
|
||||
steps.append({"width": width, "height": height, "url": f"{local}?{width}#stream/inbox", "wait": 1200, "probe": probe(INBOX, ref), "shot": str(OUT / f"chromium-{width}-inbox.png")})
|
||||
steps.append({"width": width, "height": height, "url": f"{local}?{width}-match#tasks/match", "wait": 1200, "probe": probe(MATCH, ref), "shot": str(OUT / f"chromium-{width}-match.png")})
|
||||
return steps
|
||||
|
||||
def test_chromium_offers_the_last_reasons_in_every_deny_sheet_at_three_widths(self):
|
||||
data = self.drive(self.steps(), self.authenticator(), "cdp.mjs", os.environ.get("CHROMIUM", "chromium"))
|
||||
(OUT / "chromium-reason-chips.json").write_text(json.dumps(data, indent=1), encoding="utf-8")
|
||||
self.assertEqual([error for error in data["errors"] if "(style-src-elem)" not in error and "/favicon.ico" not in error], [])
|
||||
results = iter(data["results"])
|
||||
for width, _ in base.WIDTHS:
|
||||
inbox, match = next(results), next(results)
|
||||
with self.subTest(width=width):
|
||||
self.assertNotIn("error", inbox, inbox)
|
||||
self.assertNotIn("error", match, match)
|
||||
for found, index in ((inbox["single"], 1), (inbox["bulk"], 0), (match["reject"], 2)):
|
||||
self.assertEqual(found["shown"], SHOWN, found)
|
||||
self.assertEqual((found["filled"], found["focused"], found["edited"]), (SHOWN[index], True, f"{SHOWN[index]} now"), found)
|
||||
self.assertEqual((found["inside"], found["wide"]), (True, False), found)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -18,6 +18,7 @@ from hub_support import iso
|
||||
|
||||
OUT = Path(os.environ.get("E2E_OUT", "/tmp/hub-012-shots"))
|
||||
FILES = (("src/app.py", 60), ("src/view.js", 30), ("docs/notes.md", 12))
|
||||
PATTERNS = ("dots", "stripes", "waves", "grid", "rings")
|
||||
CARD = """
|
||||
const card = () => document.querySelector("#main .match-card.front");
|
||||
const body = () => card() && card().querySelector(".match-body");
|
||||
@@ -34,7 +35,8 @@ CARD = """
|
||||
name: text(card().querySelector(".match-name")), age: text(card().querySelector(".match-age")),
|
||||
metrics: all(".match-metric", card()).map((chip) => [chip.dataset.metric, text(chip.querySelector("strong"))]),
|
||||
under: Boolean(card().querySelector(".match-metrics")) && card().querySelector(".match-metrics").getBoundingClientRect().top >= card().querySelector(".match-name").getBoundingClientRect().bottom - 1,
|
||||
place: all(".match-place dt", card()).map(text).map((label, index) => [label, text(all(".match-place dd", card())[index])]),
|
||||
place: all(".match-place .match-where", card()).map((chip) => [chip.dataset.place, text(chip), chip.title]),
|
||||
paint: [card().dataset.pattern, card().style.getPropertyValue("--card-hue"), card().style.getPropertyValue("--card-hue-2"), getComputedStyle(card().querySelector(".match-head")).backgroundImage.includes("radial-gradient")],
|
||||
files: all(".match-file", card()).map((file) => file.dataset.path), accept: card().closest(".match-stack").querySelector(".match-accept").disabled,
|
||||
reason: text(card().querySelector(".match-stale")), peeks: all("#main .match-peek").map((tab) => tab.dataset.card),
|
||||
wide: document.documentElement.scrollWidth > window.innerWidth + 1,
|
||||
@@ -84,7 +86,14 @@ MARK = """(async () => {@HELPERS@@CARD@
|
||||
const pressed = await save("long press note");
|
||||
const marks = all("tr.match-mark", card()).map((mark) => [mark.dataset.line, text(mark.querySelector(".match-mark-text"))]);
|
||||
const marked = all("tr.marked", card()).map((mark) => mark.dataset.line);
|
||||
return {clicked, pressed, marks, marked, count: text(card().querySelector('.match-file[data-path="@FIRST@"] .match-marks'))};
|
||||
const third = row("@FIRST@", 9);
|
||||
third.dispatchEvent(new MouseEvent("contextmenu", {bubbles: true, cancelable: true, clientX: box.left + 40, clientY: box.top + 4, button: 2}));
|
||||
const field = await until(() => card().querySelector(".match-comment textarea"), 3000);
|
||||
const presets = all(".match-comment .reason-chips .chip", card()).map(text);
|
||||
card().querySelector(".match-comment .reason-chips .chip:last-child").click();
|
||||
const preset = [field.value, document.activeElement === field];
|
||||
card().querySelector(".match-comment .btn.ghost").click();
|
||||
return {clicked, pressed, marks, marked, presets, preset, count: text(card().querySelector('.match-file[data-path="@FIRST@"] .match-marks'))};
|
||||
})()"""
|
||||
PICK = """(async () => {@HELPERS@@CARD@
|
||||
const found = await pick("@ID@");
|
||||
@@ -171,13 +180,19 @@ class TestMatchReview(HubCase):
|
||||
def check(self, data: dict, widths: tuple[tuple[int, int], ...]) -> None:
|
||||
results = iter(data["results"])
|
||||
order = [path for path, _ in FILES]
|
||||
paints = set()
|
||||
for width, _ in widths:
|
||||
with self.subTest(width=width):
|
||||
stack = next(results)
|
||||
self.assertEqual((stack["card"], stack["kind"], stack["stale"], stack["face"]), (f"review:{self.commit}", "commit", "false", True), stack)
|
||||
self.assertEqual((stack["name"], stack["age"]), ("Skills", "3 days"), stack)
|
||||
self.assertEqual((stack["metrics"], stack["under"]), ([["fix", "95"], ["break", "3"]], True), stack)
|
||||
self.assertEqual(stack["place"], [["Repository", "/repo"], ["Branch", "feature/match"], ["Worktree", "/repo/.worktrees/feature/match"]], stack)
|
||||
place = [["branch", "feature/match", "Branch: feature/match (click copies)"], ["repo", "repo", "Repository: /repo (click copies)"],
|
||||
["worktree", ".worktrees/feature/match", "Worktree: /repo/.worktrees/feature/match (click copies)"]]
|
||||
self.assertEqual(stack["place"], place, stack)
|
||||
self.assertIn(stack["paint"][0], PATTERNS, stack)
|
||||
self.assertTrue(stack["paint"][1] and stack["paint"][2] and stack["paint"][3], stack)
|
||||
paints.add(tuple(stack["paint"]))
|
||||
self.assertEqual(stack["files"], order)
|
||||
self.assertEqual(stack["peeks"], ["operator:operator/issue", f"review:{self.stale}"], stack)
|
||||
self.assertFalse(stack["accept"], stack)
|
||||
@@ -193,6 +208,7 @@ class TestMatchReview(HubCase):
|
||||
self.assertEqual((mark["clicked"], mark["pressed"]), (True, True), mark)
|
||||
self.assertEqual(mark["marks"], [["3", "use the helper here"], ["6", "long press note"]], mark)
|
||||
self.assertEqual(mark["marked"], ["3", "6"], mark)
|
||||
self.assertEqual((mark["presets"], mark["preset"]), (["long press note", "use the helper here"], ["use the helper here", True]), mark)
|
||||
self.assertEqual(mark["count"], "2", mark)
|
||||
command = next(results)
|
||||
self.assertEqual((command["kind"], command["stale"], command["command"], command["why"]), ("command", "false", self.command, "file the release issue"), command)
|
||||
@@ -202,6 +218,7 @@ class TestMatchReview(HubCase):
|
||||
stale = next(results)
|
||||
self.assertEqual((stale["kind"], stale["stale"], stale["accept"], stale["name"], stale["age"]), ("commit", "true", True, "Stage", "9 days"), stale)
|
||||
self.assertIn("changed", stale["reason"])
|
||||
self.assertEqual(len(paints), 1, paints)
|
||||
|
||||
def test_chromium_shows_face_place_files_on_scroll_and_marks_at_three_widths(self):
|
||||
data = self.drive(self.steps("chromium", base.WIDTHS), None)
|
||||
|
||||
@@ -13,6 +13,7 @@ HERE = Path(__file__).resolve().parent
|
||||
sys.path[:0] = [str(HERE.parent), str(HERE)]
|
||||
|
||||
import hub_e2e_kit as base
|
||||
import test_home_dashboard_e2e as dash
|
||||
from hub_case import HubCase
|
||||
from hub_support import ASK, OPTIONS, iso
|
||||
from kvb_orchestrator import batches, skill_scripts
|
||||
@@ -34,6 +35,30 @@ FRONT = """(async () => {@HELPERS@
|
||||
return {front: node ? node.dataset.card : null, options: node ? all(".match-options .option", node).map((option) => [text(option.querySelector("strong")), option.classList.contains("recommended")]) : [],
|
||||
wide: document.documentElement.scrollWidth > window.innerWidth + 1};
|
||||
})()"""
|
||||
HOME = """(async () => {@HELPERS@@HOME_KIT@
|
||||
await ViewStore.update("home.pins", () => [{kind: "panel", id: "tasks/match", w: 12, h: 8}]);
|
||||
await go("#home");
|
||||
const tile = await until(() => document.querySelector('#main .home-tile[data-id="tasks/match"]'), 8000);
|
||||
if (!tile) {
|
||||
return {error: text(document.getElementById("main"))};
|
||||
}
|
||||
const slot = await until(() => tile.querySelector(".home-head > .home-slot"), 4000);
|
||||
await until(() => slot && /cards? wait/.test(text(slot)), 6000);
|
||||
const below = () => Boolean(tile.querySelector(".match-actions + .match-peeks .match-peek"));
|
||||
const toggle = slot ? slot.querySelector(".match-peeks-toggle") : null;
|
||||
const peeks = [[Boolean(await until(below, 6000)), toggle && toggle.getAttribute("aria-pressed")]];
|
||||
if (toggle) {
|
||||
toggle.click();
|
||||
await sleep(200);
|
||||
peeks.push([below() || Boolean(tile.querySelector(".match-peeks")), toggle.getAttribute("aria-pressed"), localStorage.getItem("kvb-orchestrator.match-peeks")]);
|
||||
toggle.click();
|
||||
await sleep(200);
|
||||
peeks.push([below(), toggle.getAttribute("aria-pressed"), localStorage.getItem("kvb-orchestrator.match-peeks")]);
|
||||
}
|
||||
return {peeks, slot: slot ? text(slot.querySelector(".muted")) : null, overview: Boolean(slot && slot.querySelector(".match-open-overview")),
|
||||
toolbar: Boolean(tile.querySelector(".home-body .task-toolbar")), card: Boolean(await until(() => tile.querySelector(".match-card.front"), 6000)),
|
||||
head: Math.round(tile.querySelector(".home-head").getBoundingClientRect().height), wide: document.documentElement.scrollWidth > innerWidth + 1};
|
||||
})()"""
|
||||
FLOW = """(async () => {@HELPERS@
|
||||
const posted = [];
|
||||
const send = window.fetch.bind(window);
|
||||
@@ -120,6 +145,8 @@ class TestMatchWaiting(HubCase):
|
||||
url = f"http://localhost:{self.port}/?{width}#tasks/match"
|
||||
front = FRONT.replace("@HELPERS@", base.HELPERS).replace("@PICK@", PICK)
|
||||
flow = FLOW.replace("@HELPERS@", base.HELPERS).replace("@RELEASE@", "true" if width == RELEASE_AT else "false")
|
||||
home = HOME.replace("@HELPERS@", base.HELPERS).replace("@HOME_KIT@", dash.HOME)
|
||||
steps.append({"width": width, "height": height, "url": f"http://localhost:{self.port}/?{width}-home#stream", "wait": 1500, "probe": home, "shot": str(OUT / f"chromium-{width}-home.png")})
|
||||
steps.append({"width": width, "height": height, "url": url, "wait": 1500, "probe": front, "shot": str(OUT / f"chromium-{width}-decision.png")})
|
||||
steps.append({"width": width, "height": height, "url": url, "wait": 1500, "probe": flow, "shot": str(OUT / f"chromium-{width}-overview.png")})
|
||||
return steps
|
||||
@@ -145,7 +172,12 @@ class TestMatchWaiting(HubCase):
|
||||
self.settle(lambda: self.ask_status(self.ask, "0") == "allowed")
|
||||
(OUT / "chromium-waiting.json").write_text(json.dumps(data, indent=1), encoding="utf-8")
|
||||
self.assertEqual([error for error in data["errors"] if "(style-src-elem)" not in error and "/favicon.ico" not in error], [])
|
||||
fronts, flows = data["results"][0::2], data["results"][1::2]
|
||||
homes, fronts, flows = data["results"][0::3], data["results"][1::3], data["results"][2::3]
|
||||
for home in homes:
|
||||
with self.subTest(home=home):
|
||||
self.assertEqual((home["slot"], home["overview"], home["toolbar"], home["card"], home["wide"]), ("4 cards wait", True, False, True, False), home)
|
||||
self.assertLessEqual(home["head"], 48, home)
|
||||
self.assertEqual(home["peeks"], [[True, "true"], [False, "false", "false"], [True, "true", "true"]], home)
|
||||
for front in fronts:
|
||||
with self.subTest(front=front):
|
||||
self.assertEqual((front["front"], front["options"], front["wide"]), (PICK, [["Merge now", True], ["Wait", False]], False), front)
|
||||
|
||||
+13
-2
@@ -11,7 +11,7 @@ from unittest import mock
|
||||
|
||||
from hub_case import HubCase
|
||||
from hub_support import ASK, CLIENT, PAGE, Key, key, signing, verifier
|
||||
from kvb_orchestrator import batches, skill_scripts
|
||||
from kvb_orchestrator import batches, denying, skill_scripts
|
||||
|
||||
PUSH = "git push"
|
||||
PLANTED = {"work/a0/claim.json": {"office": "work/a0", "session": "s1", "runtime": "claude", "name": "Villain session", "since": "2026-11-05T08:00:00+00:00", "beat": 0, "work": "x"}}
|
||||
@@ -106,7 +106,9 @@ class TestHubDeny(HubCase):
|
||||
self.assertEqual(sorted(sent[:3] for sent in self.radio()), [["post", "--to", "Skills session"]] * 3)
|
||||
self.assertTrue(all("Denied by the operator: " in sent[-1] for sent in self.radio()), self.radio())
|
||||
self.assertIn("Denied by the operator: commit feat: deny me", next(sent[-1] for sent in self.radio() if "Reason: rebase first" in sent[-1]))
|
||||
self.assertFalse({ask_id, review_id} & {item["id"] for item in self.snapshot()["inbox"]})
|
||||
state = self.snapshot()
|
||||
self.assertFalse({ask_id, review_id} & {item["id"] for item in state["inbox"]})
|
||||
self.assertEqual(state["reasons"], ["rebase first"])
|
||||
|
||||
def test_every_class_but_mayday_reaches_the_agent_or_all(self):
|
||||
session = "s9"
|
||||
@@ -242,5 +244,14 @@ class TestHubDeny(HubCase):
|
||||
return verifier.Trust(approvers=self.approvers, replay=self.replay / "hook.json", origin=self.origin)
|
||||
|
||||
|
||||
class TestRecentReasons(unittest.TestCase):
|
||||
def test_the_last_five_distinct_reasons_come_newest_first(self):
|
||||
said = ["a", "", "b", "a", "c", "d", "e", "f", "c"]
|
||||
denials = [{"denial": {"reason": reason}, "created_ts": float(at)} for at, reason in enumerate(said)]
|
||||
messages = [{"text": "hi", "created_ts": 99.0}, {"denial": None, "created_ts": 98.0}, *reversed(denials)]
|
||||
self.assertEqual(denying.recent_reasons(messages), ["c", "f", "e", "d", "a"])
|
||||
self.assertEqual(denying.recent_reasons([{"text": "hi", "created_ts": 1.0}]), [])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -150,7 +150,7 @@ class TestHubState(HubCase):
|
||||
self.assertEqual(
|
||||
set(state),
|
||||
{
|
||||
"now", "since", "until", "first", "alarm_since", "reviews", "asks", "decisions", "messages", "operator",
|
||||
"now", "since", "until", "first", "alarm_since", "reviews", "asks", "decisions", "messages", "reasons", "operator",
|
||||
"register", "tasks", "task_edges", "queue_line", "queue_jobs", "agent_order", "radio", "claims", "grants", "night", "night_parts", "presence", "silence", "graph",
|
||||
"inbox", "pending", "rules", "approvers", "jobs", "views", "llm", "people", "settings", "media", "speech",
|
||||
"badges", "kinds",
|
||||
|
||||
Reference in new issue
Block a user