feat(orchestrator): overlay the queue order on the Tasks board

queue_order.py parses queue.py list --json into positions and reasons; the Tasks board overlays each card with its queue position, wait and reason, and falls back to Order only when the queue cannot be read. Tests run once on unify/skills-20261114 after the merge (operator order 2026-11-14).

🎯 Fix: 80 %
💥 Break: 10 %
💸 Tokens: 20 %
⏱️ Velocity: 20 %
🛡️ Security: 100 %
🏆 Score: 100
🚦 Gate: ⛔ fix 80 % < 90, break 10 % > 5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-14 21:32:48 +00:00
1 parent 48f26b678a
commit e1de1ee0e6
15 files changed
+975 -20

No files matched your search

+3
View File
@@ -31,6 +31,7 @@ from .messaging import Messaging
from .names import Names
from .offices import Offices
from .presence import SNAPSHOT
from .queue_order import QUEUE_SCRIPT, QueueOrder
from .receipts import (
NAMES,
READS,
@@ -127,6 +128,7 @@ class Hub(Mcp, Reviewing, Asking, Messaging, Choosing, Approving, Denying, Reque
voice_notes: VoiceNotes
replay: Path
history: History
queue_order: QueueOrder
view_store: ViewStore
def hosts(self) -> tuple[str, str]:
@@ -193,6 +195,7 @@ def open_hub(council: Path, pages: Path, public_port: int, state: Path, host_sta
kept=places.kept,
council=council,
history=History(council / queue_live.HISTORY),
queue_order=QueueOrder(script=scripts.skills / QUEUE_SCRIPT, council=council, home=state),
pages=pages,
public_port=public_port,
reviews=reviews,
@@ -0,0 +1,193 @@
from __future__ import annotations
import json
import math
import subprocess
import sys
import threading
from dataclasses import dataclass, field
from pathlib import Path
from .crons import outcome_of
from .records import shown
from .skill_scripts import script_env
from .tasks import QUEUE_SHOWN, TEXT_SHOWN, prio_of
QUEUE_SCRIPT = "kvb-org-queue/scripts/queue.py"
ORDER_ARGS = ("list", "--json")
ORDER_SECONDS = 20
ORDER_TIMEOUT = 10
ORDER_LIMIT = 1 << 20
TRACE_SHOWN = 20
POSITION_SHOWN = 32
CLASSES = ("hotfix", "fix", "feature", "main")
def amount(value: object) -> float | None:
if isinstance(value, bool) or not isinstance(value, int | float) or not math.isfinite(value) or value < 0:
return None
return float(value)
def text(value: object) -> str:
return value[:TEXT_SHOWN] if isinstance(value, str) else ""
def position_of(value: object) -> int | str | None:
if isinstance(value, int) and not isinstance(value, bool) and value >= 0:
return value
return value[:POSITION_SHOWN] if isinstance(value, str) and value else None
def steps_of(value: object) -> list[str]:
return [step[:TEXT_SHOWN] for step in value[:TRACE_SHOWN] if isinstance(step, str)] if isinstance(value, list) else []
def bounded(value: object) -> str | None:
return value if isinstance(value, str) and len(value) <= TEXT_SHOWN else None
def score_of(value: object) -> float | None:
return amount(value.get("score") if isinstance(value, dict) else value)
def queue_job(raw: object) -> dict | None:
"""Args:
raw: one row of `queue.py list --json`.
Returns:
The row as the board shows it, each field of one type and bounded:
position an int or a word such as run, class one of CLASSES, prio an
int, wsjf (a number or {"score"}), waited_s and eta_s non-negative
numbers, each else None; trace at most TRACE_SHOWN strings; agent
falls back to name. None for a row without a string id.
"""
if not isinstance(raw, dict) or not isinstance(raw.get("id"), str) or not raw["id"]:
return None
klass = bounded(raw.get("class"))
return {
"position": position_of(raw.get("position")),
"id": raw["id"][:TEXT_SHOWN],
"kind": text(raw.get("kind")),
"task": bounded(raw.get("task")),
"session": text(raw.get("session")),
"agent": text(raw.get("agent", raw.get("name"))),
"class": klass if klass in CLASSES else None,
"prio": prio_of(raw),
"wsjf": score_of(raw.get("wsjf")),
"waited_s": amount(raw.get("waited_s")),
"eta_s": amount(raw.get("eta_s")),
"reason": text(raw.get("reason")),
"trace": steps_of(raw.get("trace")),
}
def lines_of(stdout: str) -> list | None:
try:
return [json.loads(line) for line in stdout.splitlines() if line.strip()] or None
except (ValueError, RecursionError):
return None
def parsed(stdout: str) -> object:
try:
return json.loads(stdout)
except (ValueError, RecursionError):
return lines_of(stdout)
def rows_of(stdout: str) -> list | None:
data = parsed(stdout)
if isinstance(data, dict):
data = data.get("entries") if "entries" in data else [data] if "id" in data else None
return data if isinstance(data, list) else None
def queue_jobs(stdout: str) -> list[dict] | None:
"""Args:
stdout: what `queue.py list --json` printed: a JSON list of rows,
an object holding them under entries, or one row object per
line.
Returns:
queue_job() of each row in grant order, each id once, at most
QUEUE_SHOWN; None when the output holds no such rows.
"""
rows = rows_of(stdout)
if rows is None:
return None
found: dict[str, dict] = {}
for job in map(queue_job, rows):
if job is not None and job["id"] not in found:
found[job["id"]] = job
return list(found.values())[:QUEUE_SHOWN]
def live_ids(queue: list[tuple[dict, float]]) -> frozenset[str]:
return frozenset(shown(entry.get("id")) for entry, _ in queue if outcome_of(entry) is None)
def grant_order(chain: list[tuple[str, bool]], jobs: list[dict] | None) -> list[tuple[str, bool]]:
"""Args:
chain: queue_chain(), the hub's own grant order.
jobs: queue_jobs() of the installed queue.py, None without them.
Returns:
The chain in queue.py's order: the ids jobs lists in its order, the
others after them in the chain's; the chain itself without jobs.
"""
if jobs is None:
return chain
place = {job["id"]: index for index, job in enumerate(jobs)}
return sorted(chain, key=lambda pair: place.get(pair[0], len(place)))
@dataclass
class QueueOrder:
script: Path
council: Path
home: Path
lock: threading.Lock = field(default_factory=threading.Lock)
cached: list[dict] | None = None
live: frozenset[str] | None = None
at: float = 0.0
def run(self) -> list[dict] | None:
try:
done = subprocess.run(
[sys.executable, str(self.script), *ORDER_ARGS],
capture_output=True,
timeout=ORDER_TIMEOUT,
env=script_env(self.home, self.council),
stdin=subprocess.DEVNULL,
check=False,
)
except (OSError, subprocess.TimeoutExpired):
return None
if done.returncode != 0 or len(done.stdout) > ORDER_LIMIT:
return None
return queue_jobs(done.stdout.decode("utf-8", errors="replace"))
def get(self, live: frozenset[str], now: float) -> list[dict] | None:
"""Args:
live: live_ids() of the queue entries the hub reads.
now: epoch seconds.
Returns:
[] while no entry is live, without a run. Else queue_jobs() of a
`queue.py list --json` run, run again once ORDER_SECONDS passed
or the live ids changed; while another request runs it, the rows
read before. None while the installed queue.py lists no JSON,
fails or overruns ORDER_TIMEOUT, so the board keeps the hub's own
order and the page says why.
"""
if not live:
return []
if not self.lock.acquire(blocking=False):
return self.cached
try:
if live != self.live or now - self.at >= ORDER_SECONDS:
self.cached, self.live, self.at = self.run(), live, now
return self.cached
finally:
self.lock.release()
@@ -34,6 +34,10 @@ def bounded(stdout: str) -> str:
return "\n".join([first if len(first) <= FIRST_LINE_LIMIT else "", ELIDED, rest[-OUTPUT_LIMIT:]])
def script_env(home: Path, council: Path) -> dict[str, str]:
return {"PATH": SAFE_PATH, "HOME": str(home), "AGENTS_COUNCIL_ROOT": str(council), "PYTHONDONTWRITEBYTECODE": "1"}
def script_module(script: Path) -> ModuleType | None:
"""Returns:
The installed script as a module, loaded again after an install
@@ -73,7 +77,7 @@ class Scripts:
def run(self, script: str, args: list[str]) -> dict:
command = " ".join([Path(script).name, *args])
env = {"PATH": SAFE_PATH, "HOME": str(self.home), "AGENTS_COUNCIL_ROOT": str(self.council), "PYTHONDONTWRITEBYTECODE": "1"}
env = script_env(self.home, self.council)
try:
done = subprocess.run(
[sys.executable, str(self.skills / script), *args],
+4 -1
View File
@@ -24,6 +24,7 @@ from .messaging import message_row
from .orbits import TRACK_STEPS, track
from .phrasing import joined, phrase_parts
from .presence import presence, read_snapshot
from .queue_order import grant_order, live_ids
from .receipts import inline, read_of
from .records import epoch, iso_epoch, read_jsonl
from .register import (
@@ -120,9 +121,10 @@ class View:
settings = self.settings.get()
inbox = self.inbox(now, tasks, directory)
queue = queue_entries(self.council, self.history.rows)
jobs = self.queue_order.get(live_ids(queue), now)
order = stored_order(self.council / AGENT_ORDER)
rows = task_rows(tasks, queue, self.tree.get())
chain = queue_chain(queue, tasks, order, now)
chain = grant_order(queue_chain(queue, tasks, order, now), jobs)
return {
"settings": settings,
"media": media_origins(settings),
@@ -151,6 +153,7 @@ class View:
"tasks": rows,
"task_edges": task_edges(rows, chain),
"queue_line": queue_line(chain, queue),
"queue_jobs": jobs,
"agent_order": agent_order(tasks, claims, order),
"radio": radio,
"claims": claims,
+20 -5
View File
@@ -17,6 +17,7 @@ VIEW = {
"resources": {"hidden": [], "tokens": "interval", "combined": False, "combinedHidden": []},
"burn": {"overlays": []},
"home": {"pins": []},
"kanban": {"hidden": []},
}
VIEW_PATH = re.compile(r"[A-Za-z]{1,32}(?:\.[A-Za-z]{1,32})?")
SERIES_ID = re.compile(r"[A-Za-z0-9:_./-]{1,200}")
@@ -24,6 +25,7 @@ PIN_KIND = re.compile(r"[A-Za-z0-9:_./-]{1,32}")
IDS_LIMIT = 500
TOKEN_MODES = ("interval", "accumulated")
OVERLAYS = ("fix", "break", "tokens", "velocity", "security", "score")
KANBAN_LAYERS = ("line", "jobs")
PINS_LIMIT = 64
SPAN = (1, 12)
METRIC = "metric"
@@ -41,6 +43,12 @@ def series_ids(value: object, name: str) -> list[str]:
return list(value)
def members(value: object, name: str, what: str, allowed: tuple[str, ...]) -> list[str]:
if not isinstance(value, list) or not all(isinstance(item, str) and item in allowed for item in value) or len(set(value)) != len(value):
raise ToolError(f"{name} must list distinct {what} of {', '.join(allowed)}")
return list(value)
def span(value: object, name: str) -> int:
low, high = SPAN
if isinstance(value, bool) or not isinstance(value, int) or not low <= value <= high:
@@ -140,11 +148,9 @@ def valid_view(raw: object) -> dict:
resources = section(data["resources"], "resources", tuple(VIEW["resources"]))
burn = section(data["burn"], "burn", tuple(VIEW["burn"]))
home = section(data["home"], "home", tuple(VIEW["home"]))
kanban = section(data["kanban"], "kanban", tuple(VIEW["kanban"]))
if not isinstance(resources["tokens"], str) or resources["tokens"] not in TOKEN_MODES:
raise ToolError(f"resources.tokens must be one of {', '.join(TOKEN_MODES)}")
overlays = burn["overlays"]
if not isinstance(overlays, list) or not all(isinstance(item, str) and item in OVERLAYS for item in overlays) or len(set(overlays)) != len(overlays):
raise ToolError(f"burn.overlays must list distinct metrics of {', '.join(OVERLAYS)}")
return {
"resources": {
"hidden": series_ids(resources["hidden"], "resources.hidden"),
@@ -152,11 +158,20 @@ def valid_view(raw: object) -> dict:
"combined": flag(resources["combined"], "resources.combined"),
"combinedHidden": series_ids(resources["combinedHidden"], "resources.combinedHidden"),
},
"burn": {"overlays": list(overlays)},
"burn": {"overlays": members(burn["overlays"], "burn.overlays", "metrics", OVERLAYS)},
"home": {"pins": pins(home["pins"])},
"kanban": {"hidden": members(kanban["hidden"], "kanban.hidden", "layers", KANBAN_LAYERS)},
}
def upgraded(raw: object) -> object:
"""Returns:
A stored document of an older hub with each VIEW section it lacks
at its default; anything else as it is.
"""
return {**copy.deepcopy(VIEW), **raw} if isinstance(raw, dict) else raw
def slot(view: dict, path: object) -> tuple[dict, str]:
"""Args:
view: a document of the shape of VIEW.
@@ -188,7 +203,7 @@ class ViewStore:
self.file = file
self.lock = threading.Lock()
try:
self.current = valid_view(read_json(file))
self.current = valid_view(upgraded(read_json(file)))
except ToolError:
self.current = copy.deepcopy(VIEW)
+2 -1
View File
@@ -18,7 +18,8 @@
--host-state: the state directory's path on the host, named in the radio
rows that carry an upload or a voice recording.
--skills: installed skills directory holding the kvb-org-radio,
kvb-org-rasci and kvb-org-suspend scripts.
kvb-org-rasci and kvb-org-suspend scripts, and the kvb-org-queue
queue.py.
--transcripts: directory the Claude Code transcripts (*.jsonl) lie under.
--templates: directory holding index.html.j2 and the *.js modules it
includes.
+102 -1
View File
@@ -6,7 +6,13 @@ const Kanban = (() => {
const FREE_FROM = 4;
const OFF = ["command"];
const DAY = 86400;
const HOUR = 3600;
const MINUTE = 60;
const REFUSED = ["failed", "refused"];
const QUEUE = "queue/";
const RUNNING = "run";
const QUEUE_LAYERS = [["line", "Queue line", "k-queue-line"], ["jobs", "Queue jobs", "k-queue-jobs"]];
const CLASS_TONES = {hotfix: "bad", fix: "warn", feature: "info", main: "violet"};
const onBoard = (row) => !OFF.includes(row.kind);
const laneOf = (prio) => (prio === null ? "unpinned" : prio >= FREE_FROM ? "p4" : `p${Math.max(prio, 1)}`);
@@ -164,7 +170,102 @@ const Kanban = (() => {
return failed.length ? {failed, applied: batch.filter((job) => job.status === "done").length, total: batch.length} : null;
}
return {COLUMNS, LANES, FREE_FROM, onBoard, columnOf, laneOf, labelOf, board, freePin, move, stage, pending, lines, why};
/**
* @param seconds - a span in seconds.
* @returns the span in words, cut to its two largest units: "45 s", "12 min", "2 h 5 min", "3 d 4 h".
*/
function span(seconds) {
const whole = Math.max(0, Math.floor(seconds));
if (whole < MINUTE) {
return `${whole} s`;
}
if (whole < HOUR) {
return `${Math.floor(whole / MINUTE)} min`;
}
const [big, unit, small, rest] = whole < DAY ? [HOUR, "h", MINUTE, "min"] : [DAY, "d", HOUR, "h"];
const part = Math.floor((whole % big) / small);
return part ? `${Math.floor(whole / big)} ${unit} ${part} ${rest}` : `${Math.floor(whole / big)} ${unit}`;
}
/**
* @param rows - the shown cards' rows.
* @param line - the hub's queue_line: tasks holding a live queue entry, in grant order.
* @param jobs - the hub's queue_jobs: the rows of `queue.py list --json` in grant order, null where the installed
* queue.py lists no JSON.
* @returns {task: {place, of, jobs}} for each shown card the queue concerns: place its 1-based stop on the queue
* line (null for a card off the line), of the line's length, and jobs its queue jobs in grant order, a queue card's
* own job and a task card's jobs by task; jobs stays empty without queue_jobs.
*/
function queued(rows, line, jobs) {
const found = {};
for (const row of rows) {
const place = line.indexOf(row.task);
const own = (jobs || []).filter((job) => (row.kind === "queue" ? `${QUEUE}${job.id}` === row.task : job.task === row.task));
if (place >= 0 || own.length) {
found[row.task] = {place: place >= 0 ? place + 1 : null, of: line.length, jobs: own};
}
}
return found;
}
const placeOf = (job) => (typeof job.position === "number" ? `#${job.position}` : job.position === RUNNING ? "running" : job.position || "?");
/**
* @param job - one queue_jobs row.
* @returns the chips of its card overlay in display order, each {key, text, hint, tone}: its grant position, class,
* pin, WSJF, the gate it runs (its kind), how long it waits and its ETA; a class, pin, WSJF or wait the row lacks
* leaves its chip out, an unknown ETA reads "ETA ?".
*/
function jobChips(job) {
const running = job.position === RUNNING;
const chips = [{key: "position", text: placeOf(job), hint: `${job.id}: ${running ? "granted, running now" : `grant position ${placeOf(job)}`}`, tone: "neutral"}];
if (job.class) {
chips.push({key: "class", text: job.class, hint: `${job.id}: class ${job.class}`, tone: CLASS_TONES[job.class]});
}
if (job.prio !== null) {
chips.push({key: "prio", text: `P${job.prio}`, hint: `${job.id}: its task is pinned P${job.prio}`, tone: "neutral"});
}
if (job.wsjf !== null) {
chips.push({key: "wsjf", text: `WSJF ${Number(job.wsjf.toFixed(2))}`, hint: `${job.id}: WSJF ${job.wsjf} of its task`, tone: "neutral"});
}
chips.push({key: "gate", text: job.kind || "?", hint: `${job.id}: runs the gate ${job.kind || "of an unknown kind"}`, tone: "teal"});
if (job.waited_s !== null) {
chips.push({key: "waited", text: `${running ? "waited" : "waits"} ${span(job.waited_s)}`, hint: `${job.id}: ${running ? "waited" : "waits"} ${span(job.waited_s)} in the queue`, tone: "neutral"});
}
const eta = job.eta_s === null ? "no ETA learned yet" : `${running ? "ends" : "starts"} in about ${span(job.eta_s)}`;
chips.push({key: "eta", text: job.eta_s === null ? "ETA ?" : `ETA ${span(job.eta_s)}`, hint: `${job.id}: ${eta}`, tone: "neutral"});
return chips;
}
/**
* @param job - one queue_jobs row.
* @returns {label, place, steps}: the popover's name, where the job stands (#n, running or the word queue.py gave)
* and the rule trace that put it there, in the order queue.py applied it; a row without a trace shows its reason
* as the only step, one without either says so.
*/
function whyHere(job) {
const steps = job.trace.length ? job.trace : [job.reason || "queue.py gave no trace and no reason for this job"];
return {label: `Why here: ${job.id} at ${placeOf(job)}`, place: placeOf(job), steps};
}
/**
* @param hidden - the kanban.hidden view-store list: the queue layers switched off.
* @returns {line, jobs}: whether the numbered queue line and the job overlay of the cards show.
*/
function layers(hidden) {
return Object.fromEntries(QUEUE_LAYERS.map(([id]) => [id, !hidden.includes(id)]));
}
/**
* @param jobs - the hub's queue_jobs.
* @returns them with waited_s and eta_s in whole minutes.
*/
function queueSig(jobs) {
const minutes = (value) => (value === null ? null : Math.floor(value / MINUTE));
return jobs === null ? null : jobs.map((job) => ({...job, waited_s: minutes(job.waited_s), eta_s: minutes(job.eta_s)}));
}
return {COLUMNS, LANES, FREE_FROM, QUEUE_LAYERS, onBoard, columnOf, laneOf, labelOf, board, freePin, move, stage, pending, lines, why, span, queued, jobChips, whyHere, layers, queueSig};
})();
if (typeof module === "object" && module.exports) {
module.exports = Kanban;
+93 -7
View File
@@ -1,7 +1,9 @@
const KANBAN_LABELS = {blocked: ["Blocked", "bad"], stopped: ["Stopped", "neutral"]};
const KANBAN_COLUMN_ICONS = {queued: "bi-hourglass", running: "bi-play-circle", done: "bi-check2-circle"};
const KANBAN_DRAG = "application/x-kvb-task";
const kanban = {staged: [], collapsed: new Set(), old: false, dragging: null};
const KANBAN_LAYERS = "kanban.hidden";
const KANBAN_JOBS_SHOWN = 3;
const kanban = {staged: [], collapsed: new Set(), old: false, dragging: null, queue: {marks: {}, line: true, jobs: true}, bound: false};
function restage(next) {
kanban.staged = next;
@@ -81,6 +83,65 @@
const cardOf = (task) => () => [...document.querySelectorAll("#main .kanban-card")].find((node) => node.dataset.task === task) || null;
function whyButton(task, id) {
const card = cardOf(task)();
return card ? [...card.querySelectorAll(".queue-why")].find((node) => node.dataset.job === id) || null : null;
}
function openWhy(task, job) {
const found = Kanban.whyHere(job);
const anchor = () => whyButton(task, job.id);
const body = h("div", {class: "popup-body"}, h("ol", {class: "queue-trace", "aria-label": `Rule trace of ${job.id}`}, found.steps.map((step) => h("li", {}, step))),
job.reason && job.trace.length ? h("p", {class: "queue-reason"}, `Now: ${job.reason}`) : null);
openPopup(found.label, [popupHead(icon("bi-signpost-split"), found.label, h("code", {class: "task-id"}, job.task || task)), body], anchor, () => {
const button = anchor();
if (button) {
button.focus();
}
});
const close = popupBox().querySelector(".popup-head button");
if (close) {
close.focus();
}
}
function queuePlace(row) {
const mark = kanban.queue.marks[row.task];
if (!kanban.queue.line || !mark || mark.place === null) {
return null;
}
return h("span", {class: "queue-place", "data-place": mark.place, role: "img", ...named(`Queue stop ${mark.place} of ${mark.of}`, `${row.task}: stop ${mark.place} of ${mark.of} on the queue line, in grant order`)}, String(mark.place));
}
function chipHint(job, chip) {
if (chip.key === "waited") {
return `${chip.hint}, since ${absolute.format(stampOf(state.now - job.waited_s))}`;
}
return chip.key === "eta" && job.eta_s !== null ? `${chip.hint}, about ${absolute.format(stampOf(state.now + job.eta_s))}` : chip.hint;
}
function queueJob(row, job) {
const chips = Kanban.jobChips(job).map((chip) => h("span", {class: "pill queue-chip", "data-chip": chip.key, "data-tone": chip.tone, title: chipHint(job, chip)}, chip.text));
const open = (event) => {
event.stopPropagation();
openWhy(row.task, job);
};
const hint = `Why ${job.id} stands at ${Kanban.whyHere(job).place}: the rules queue.py applied, in order`;
const why = h("button", {type: "button", class: "btn small ghost queue-why", "data-job": job.id, ...named(`Why here: ${job.id}`, hint), on: {click: open}}, icon("bi-question-circle"), h("span", {class: "queue-why-text"}, "Why here?"));
return h("li", {class: "queue-job", "data-job": job.id, "data-class": job.class || "", "data-kind": job.kind},
h("div", {class: "queue-chips"}, chips, why), job.reason ? h("p", {class: "queue-reason", title: job.reason}, job.reason) : null);
}
function queueJobs(row) {
const mark = kanban.queue.marks[row.task];
if (!kanban.queue.jobs || !mark || !mark.jobs.length) {
return null;
}
const more = mark.jobs.length - KANBAN_JOBS_SHOWN;
return h("ul", {class: "queue-jobs", "aria-label": `Queue jobs of ${row.task}`}, mark.jobs.slice(0, KANBAN_JOBS_SHOWN).map((job) => queueJob(row, job)),
more > 0 ? h("li", {class: "queue-more muted"}, `+${more} more queue jobs`) : null);
}
function kanbanCard(row, lane, column, cards) {
const open = () => taskSelect(row.task, cardOf(row.task));
const own = (event) => !event.target.closest("button, summary, details, select, .kanban-handle");
@@ -112,7 +173,7 @@
},
},
},
h("div", {class: "head-row", "data-star-slot": ""}, h("code", {class: "task-id"}, row.task), cardLabels(row), h("span", {class: "spacer"}),
h("div", {class: "head-row", "data-star-slot": ""}, queuePlace(row), h("code", {class: "task-id"}, row.task), cardLabels(row), h("span", {class: "spacer"}),
row.pending ? h("span", {class: "kanban-pending", role: "img", ...named("Staged", row.pending.map(shownArgv).join("\n"))}, icon("bi-pencil")) : null,
openJobs(row.task).length ? h("span", {class: "kanban-wait", role: "img", ...named("At the runner", `${row.task}: a signed change waits for the runner`)}, icon("bi-hourglass-split")) : null,
row.editable ? h("span", {class: "kanban-handle", role: "img", draggable: "true", ...named("Follows", `Drag onto the card that waits for ${row.task}`), on: {dragstart: dragFrom(row.task, "after"), dragend: () => {
@@ -121,6 +182,7 @@
row.movable ? kanbanMenu(row, cards) : null),
h("span", {class: "kanban-title"}, titleOf(row)),
row.worker !== "-" ? h("span", {class: "muted"}, row.worker) : null,
queueJobs(row),
cardWhy(row.task));
}
@@ -168,17 +230,39 @@
const stalled = h("span", {class: "pill", id: "kanban-stale", "data-tone": "warn", role: "img", ...named(`Stale: ${stale}`, `Stale: ${stale} tasks without a register change for ${Plan.STALE_DAYS} days, counted apart`)}, icon("bi-hourglass-bottom"), String(stale));
const listed = count ? h("ol", {class: "kanban-staged", id: "kanban-staged", "aria-label": `${words}: the passkey signs exactly these`},
kanban.staged.map(({task, argv}) => h("li", {"data-task": task}, h("code", {}, shownArgv(argv))))) : null;
return [h("div", {class: "kanban-bar", role: "toolbar", "aria-label": "Board"}, apply, discard, older, stalled), listed];
return [h("div", {class: "kanban-bar", role: "toolbar", "aria-label": "Board"}, apply, discard, older, stalled, queueLegend()), listed];
}
function queueLegend() {
const layers = LegendChips.render(Kanban.QUEUE_LAYERS.map(([id, label, tone]) => ({id, label, tone})), KANBAN_LAYERS, "hidden");
const words = "The installed queue.py lists no JSON (queue.py list --json): the board numbers the grant order but shows no class, gate, ETA or rule trace";
const only = state.queue_jobs === null && state.queue_line.length ? h("span", {class: "pill", id: "kanban-queue-order", "data-tone": "warn", role: "img", ...named("Queue order only", words)}, icon("bi-info-circle"), "Order only") : null;
return [layers, only];
}
function bindLayers() {
if (!kanban.bound) {
kanban.bound = true;
ViewStore.on(KANBAN_LAYERS, () => {
taskView.sig = "";
drawTasks();
});
}
}
function kanbanLines(box, rows) {
const svg = box.querySelector("svg.kanban-lines");
const base = box.getBoundingClientRect();
const rectOf = (task) => {
const node = [...box.querySelectorAll(".kanban-card")].find((card) => card.dataset.task === task);
const rectIn = (node) => {
const found = node && node.getClientRects().length ? node.getBoundingClientRect() : null;
return found && {x: found.left - base.left, y: found.top - base.top, w: found.width, h: found.height};
};
const cardNode = (task) => [...box.querySelectorAll(".kanban-card")].find((card) => card.dataset.task === task) || null;
const rectOf = (task) => rectIn(cardNode(task));
const stopOf = (task) => {
const card = cardNode(task);
return rectIn(card && card.querySelector(".queue-place")) || rectIn(card);
};
const centre = (r) => ({x: r.x + r.w / 2, y: r.y + r.h / 2});
const rim = (r, toward) => {
const c = centre(r);
@@ -187,7 +271,7 @@
return {x: c.x + dx * scale, y: c.y + dy * scale};
};
const hub = new Map(state.tasks.map((row) => [row.task, row]));
const {arrows, queue} = Kanban.lines(rows, state.queue_line);
const {arrows, queue} = Kanban.lines(rows, kanban.queue.line ? state.queue_line : []);
const marks = [];
for (const {from, to} of arrows) {
const [a, b] = [rectOf(from), rectOf(to)];
@@ -199,7 +283,7 @@
s("title", {}, `${to} follows ${from}: click to remove`), s("path", {class: "kanban-hit", d}), s("path", {class: "kanban-link", d, "marker-end": "url(#kanban-tip)"})));
}
}
const stops = queue.map(rectOf).filter(Boolean).map(centre);
const stops = queue.map(stopOf).filter(Boolean).map(centre);
if (stops.length > 1) {
marks.push(s("polyline", {class: "kanban-queue", "data-tasks": queue.filter((task) => rectOf(task)).join(" "), points: stops.map((at) => `${fixed(at.x)},${fixed(at.y)}`).join(" ")}, s("title", {}, "Queue order")));
}
@@ -215,6 +299,8 @@
}
const ids = new Set(shown.map((row) => row.task));
const rows = Kanban.pending(state.tasks, kanban.staged).filter((row) => ids.has(row.task) && Kanban.onBoard(row));
bindLayers();
kanban.queue = {marks: Kanban.queued(rows, state.queue_line, state.queue_jobs), ...Kanban.layers(ViewStore.get(KANBAN_LAYERS))};
const {lanes} = Kanban.board(rows, {now: state.now, old: kanban.old});
const cards = lanes.flatMap((lane) => Object.values(lane.cells).flat());
const head = h("div", {class: "kanban-head"}, TASK_COLUMNS.map(([id, label]) => h("h3", {class: "task-column group-title", "data-column": id}, icon(KANBAN_COLUMN_ICONS[id]), label,
+1 -1
View File
@@ -191,7 +191,7 @@
stage3d("tasks", dom.stage);
}
const q = taskView.q.trim().toLowerCase();
const sig = JSON.stringify([state.tasks, state.jobs, state.task_edges, settings.estimation, settings.trend, taskView.filter, taskView.sort, taskView.descending, taskView.forecast, taskView.scope, q, waitingCount(), Math.floor(nowSeconds() / 60)]);
const sig = JSON.stringify([state.tasks, state.jobs, state.task_edges, state.queue_line, Kanban.queueSig(state.queue_jobs), settings.estimation, settings.trend, taskView.filter, taskView.sort, taskView.descending, taskView.forecast, taskView.scope, q, waitingCount(), Math.floor(nowSeconds() / 60)]);
if (sig === taskView.sig) {
return;
}
+14
View File
@@ -32,6 +32,20 @@ svg .kanban-hit { fill: none; stroke: transparent; stroke-width: 12; pointer-eve
svg .kanban-arrow.pending .kanban-link { opacity: .55; }
svg .kanban-tip { fill: var(--violet); }
svg .kanban-queue { fill: none; stroke: var(--warn); stroke-width: 1.6; stroke-dasharray: 6 4; }
.kanban-card .queue-place + .task-id { flex-basis: calc(100% - 2.4em); }
.queue-place { display: inline-grid; flex: none; place-items: center; min-width: 1.7em; height: 1.7em; padding: 0 4px; border: 2px solid var(--warn); border-radius: 999px; background: var(--warn-soft); color: var(--warn); font-size: var(--fs-2xs); font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1; }
.queue-jobs { display: grid; gap: 4px; min-width: 0; margin: 0; padding: 0; list-style: none; }
.queue-job { display: grid; gap: 2px; min-width: 0; padding-top: 4px; border-top: 1px dashed var(--line); }
.queue-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; min-width: 0; }
.queue-chips .pill { max-width: 100%; padding: 0 6px; line-height: 18px; white-space: normal; overflow-wrap: anywhere; }
.queue-chips .queue-why { min-width: 0; padding: 0 6px; font-size: var(--fs-xs); }
.queue-reason, .queue-more { margin: 0; color: var(--muted); font-size: var(--fs-2xs); overflow-wrap: anywhere; }
.queue-trace { display: grid; gap: 4px; margin: 0; padding-left: 1.4em; overflow-wrap: anywhere; }
.legend-chip.k-queue-line { --c: var(--warn); }
.legend-chip.k-queue-jobs { --c: var(--teal); }
@media (max-width: 640px) {
.queue-why-text { display: none; }
}
svg .burn-finish-line { fill: none; stroke: var(--c); stroke-width: 2; stroke-dasharray: 8 3; }
svg .burn-finish-end { fill: var(--c); }
svg.burn .k-fixed, .burn-key.k-fixed { --c: var(--violet); }