Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

feat(view): item links keep their addresses [N38,N26,A10]

Corey Olsonfab7aa54dea0
diff --git a/src/cockpit.js b/src/cockpit.js
index 8198798b..6c1bc004 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -179,9 +179,24 @@ const routed = ${JSON.stringify(Boolean(paths) && !snapshot)};
/** The tab the address names: the Roadmap at its own address, or null at the board's. */
function addressTab() {
if (typeof location === 'undefined') return null;
+ if (snapshot) {
+ const tab = (location.hash || '').slice(1).split('/')[0] || '';
+ return ['items', 'shouts', 'spec', 'doctrine', 'activity', 'roadmap'].includes(tab) ? tab : null;
+ }
if (location.hash === '#items/pipeline') return 'items';
+ if (/^#items\\/\\d+$/.test(location.hash)) return 'items';
return (routed ? location.pathname === '/roadmap' : location.hash === '#roadmap') ? 'roadmap' : null;
}
+/** Build an address for an item in the current app or an exported snapshot, preserving repo scope. */
+function itemAddress(id, root = view.root) {
+ if (snapshot) return location.pathname + location.search + '#items/' + encodeURIComponent(String(id));
+ const repo = data?.projects.find((entry) => entry.root === root);
+ const group = data?.groups.find((entry) => entry.key === root);
+ const name = repo?.name || group?.name;
+ const prefix = (data?.projects.filter((entry) => entry.ok).length || 0) > 1 && name ? '/' + encodeURIComponent(name) : '';
+ const path = prefix + '/items/' + encodeURIComponent(String(id));
+ return routed ? path + location.search : location.pathname + location.search + '#' + path.slice(1);
+}
/** The tab the board's own address shows: the one last picked there, or Items. */
function homeTab() {
const kept = keep('pb.tab');
@@ -490,7 +505,7 @@ function pipelineCard(items) {
const rows = items.filter((item) => pipelineStage(item) === stage).sort((a, b) => pipelineSince(a).localeCompare(pipelineSince(b)) || a.id - b.id);
const oldest = rows[0];
return '<li class="card-panel pipeline-stage" data-pipeline-stage="' + stage + '"><header><h2>' + label + '</h2><b data-stage-count="' + stage + '">' + rows.length + '</b></header>'
- + (oldest ? '<p class="pipeline-oldest">Oldest <button class="ref" type="button" data-item="' + oldest.id + '">#' + oldest.id + '</button> · ' + age(pipelineSince(oldest)) + ' in this stage</p>' : '<p class="pipeline-oldest">No items</p>')
+ + (oldest ? '<p class="pipeline-oldest">Oldest <a class="ref" href="' + esc(itemAddress(oldest.id)) + '" data-go="item:' + oldest.id + '">#' + oldest.id + '</a> · ' + age(pipelineSince(oldest)) + ' in this stage</p>' : '<p class="pipeline-oldest">No items</p>')
+ '<ul>' + rows.map((item) => '<li><button class="pipeline-item' + (view.item === item.id ? ' on' : '') + '" type="button" data-item="' + item.id + '"><span>#' + item.id + '</span><span>' + esc(item.title) + '</span></button></li>').join('') + '</ul></li>';
}).join('');
}
@@ -973,7 +988,7 @@ async function refresh() {
// Rebuild only when the board changed: a list rebuilt under the pointer can swallow a click.
if (!addressReady) {
data = next;
- const place = snapshot ? null : placeAtAddress(next);
+ const place = placeAtAddress(next);
if (place?.root && place.root !== view.root) {
view.root = place.root;
keep('pb.project', view.root);
@@ -1152,10 +1167,10 @@ function renderSide() {
* @param {boolean} allowLinks
* @returns {string}
*/
- function linked(text, titles, allowLinks = true) { return String(text ?? '').split(/(#\\d+|(?<![^\\s([{"'\`])[^\\s:@()[\\]{}"'\`]+:\\d+(?:-\\d+)?@[0-9a-f]{7,40}(?![^\\s)\\]}"'\`.,;:!?]))/).map((part, n, parts) => {
+ function linked(text, titles, allowLinks = true, root = view.root) { return String(text ?? '').split(/(#\\d+|(?<![^\\s([{"'\`])[^\\s:@()[\\]{}"'\`]+:\\d+(?:-\\d+)?@[0-9a-f]{7,40}(?![^\\s)\\]}"'\`.,;:!?]))/).map((part, n, parts) => {
if (n % 2 && part[0] !== '#') return allowLinks ? codeRef(part, parts.slice(0, n).join('').split('\\n').pop().slice(-2000)) : codeChip(part);
const id = /^#\\d+$/.test(part) ? String(Number(part.slice(1))) : '';
- return titles.has(id) && allowLinks ? '<button class="ref" data-go="item:' + id + '" title="' + esc(titles.get(id)) + '" type="button">' + esc(part) + '</button>' : esc(part);
+ return id && allowLinks ? '<a class="ref" href="' + esc(itemAddress(id, root)) + '" data-go="item:' + id + '"' + (root === view.root ? '' : ' data-board="' + esc(root) + '"') + (titles.has(id) ? ' title="' + esc(titles.get(id)) + '"' : '') + '>' + esc(part) + '</a>' : esc(part);
}).join(''); }
/** Format inline code and recognized command tokens without interpreting markup.
* @param {string} text
@@ -1163,7 +1178,7 @@ function renderSide() {
* @param {boolean} allowLinks
* @returns {string}
*/
- function inline(text, titles, allowLinks = true) { return String(text ?? '').split(/(\`[^\`]*\`|(?:[^\\s:@()[\\]{}"'\`]+)?:\\d+(?:-\\d+)?@[0-9a-f]{0,40}|${COMMAND_SOURCE}|--[\\w-]+|(?:\\/|\\.\\.?\\/|[\\w.-]+\\/)\\w[\\w./-]*\\.[A-Za-z0-9]+|\\b[0-9a-fA-F]{7,40}\\b|#\\d+)/g).map((part, n, parts) => {
+ function inline(text, titles, allowLinks = true, root = view.root) { return String(text ?? '').split(/(\`[^\`]*\`|(?:[^\\s:@()[\\]{}"'\`]+)?:\\d+(?:-\\d+)?@[0-9a-f]{0,40}|${COMMAND_SOURCE}|--[\\w-]+|(?:\\/|\\.\\.?\\/|[\\w.-]+\\/)\\w[\\w./-]*\\.[A-Za-z0-9]+|\\b[0-9a-fA-F]{7,40}\\b|#\\d+)/g).map((part, n, parts) => {
if (part.startsWith('\`') && part.endsWith('\`')) return codeChip(part.slice(1, -1));
if (part.includes('@') && part.includes(':')) {
const textBefore = parts.slice(0, n).join('');
@@ -1183,7 +1198,7 @@ function renderSide() {
if (/^(?:${COMMAND_SOURCE}|--[\\w-]+)$/.test(part)) return codeChip(part, 'cmd');
if (/^(?:\\/|\\.\\.?\\/|[\\w.-]+\\/)\\w[\\w./-]*\\.[A-Za-z0-9]+$/.test(part)) return codeChip(part, 'path');
if (/^[0-9a-fA-F]{7,40}$/.test(part)) return codeChip(part, 'sha');
- return linked(part, titles, allowLinks);
+ return linked(part, titles, allowLinks, root);
}).join(''); }
/** Render inline text and fenced or shell command blocks with escaped contents.
* @param {string} text
@@ -1205,7 +1220,8 @@ function renderSide() {
return !/[,;]\\s/.test(bare) && bare.trim().split(/\\s+/).slice(1).filter((word) => /^[A-Za-z]+$/.test(word)).length <= 2;
}
- function bullets(lines, titles, allowLinks) {
+ /** Preserve repo scope while linking references inside a prose list. */
+ function bullets(lines, titles, allowLinks, root = view.root) {
const roots = [], open = [];
for (const line of lines) {
const [, indent, text] = /^(\\s*)- (.*)$/.exec(line);
@@ -1215,14 +1231,14 @@ function renderSide() {
open.push({ indent: indent.length, node });
}
const list = (nodes) => '<ul class="text-list">' + nodes.map((node) => '<li>'
- + (wholeCommand(node.text) ? codeChip(node.text, 'cmd') : inline(node.text, titles, allowLinks))
+ + (wholeCommand(node.text) ? codeChip(node.text, 'cmd') : inline(node.text, titles, allowLinks, root))
+ (node.children.length ? list(node.children) : '') + '</li>').join('') + '</ul>';
return list(roots);
}
// A line that is nothing but one path:lines@commit reference.
const WHOLE_REF = /^\\s*[^\\s:@()[\\]{}"'\`]+:\\d+(?:-\\d+)?@[0-9a-f]{7,40}\\s*$/;
- function rich(text, titles, allowLinks = true) {
+ function rich(text, titles, allowLinks = true, root = view.root) {
const lines = String(text ?? '').split('\\n');
const output = [];
for (let i = 0; i < lines.length;) {
@@ -1241,10 +1257,10 @@ function renderSide() {
} else if (/^\\s*- /.test(lines[i])) {
const run = [];
while (i < lines.length && /^\\s*- /.test(lines[i])) run.push(lines[i++]);
- output.push({ list: bullets(run, titles, allowLinks) });
+ output.push({ list: bullets(run, titles, allowLinks, root) });
} else {
const block = [];
- while (i < lines.length && !lines[i].startsWith('\`\`\`') && !lines[i].startsWith('$ ') && !/^\\s*- /.test(lines[i]) && !(allowLinks && WHOLE_REF.test(lines[i]))) block.push(inline(lines[i++], titles, allowLinks));
+ while (i < lines.length && !lines[i].startsWith('\`\`\`') && !lines[i].startsWith('$ ') && !/^\\s*- /.test(lines[i]) && !(allowLinks && WHOLE_REF.test(lines[i]))) block.push(inline(lines[i++], titles, allowLinks, root));
output.push(block.join('<br>'));
}
}
@@ -1257,14 +1273,14 @@ function renderGroup(group) {
const needs = group.repos.flatMap((repo) => projectNeeds(repo.board).map((row) => ({ ...row, repo })));
$('group-needs').innerHTML = needs.length ? needs.map((row) => {
const titles = new Map(row.repo.board.items.map((item) => [String(item.id), item.title]));
- const text = rich(row.text, titles).replaceAll('<button class="ref" data-go=', '<button class="ref" data-root="' + esc(row.repo.root) + '" data-go=');
+ const text = rich(row.text, titles, true, row.repo.root);
return '<div class="group-need"><b>' + esc(row.repo.name) + '</b><code>' + esc(row.ref) + '</code><span>' + text + '</span><button data-root="' + esc(row.repo.root) + '" type="button"><em>' + esc(row.what) + (row.at ? ', ' + age(row.at) : '') + ' →</em></button></div>';
}).join('') : '<div class="empty">Nothing needs you across this project.</div>';
const events = group.repos.flatMap((repo) => {
const titles = new Map(repo.board.items.map((item) => [String(item.id), item.title]));
return repo.board.events.map((event) => ({ ...event, repo, titles, title: event.item_id ? titles.get(String(event.item_id)) : null }));
}).sort((a, b) => b.event_at.localeCompare(a.event_at)).slice(0, 80);
- $('group-activity').innerHTML = events.length ? byDay(events, (event) => event.event_at, (event) => '<div><time>' + clock(event.event_at) + '</time><div class="act"><b class="repo-label">' + esc(event.repo.name) + '</b> <span>' + esc(agentName(event.event_by, event.repo.board)) + ' ' + esc(event.event_kind) + (event.item_id ? ' #' + event.item_id + (event.title ? ' ' + rich(event.title, event.titles).replaceAll('<button class="ref" data-go=', '<button class="ref" data-root="' + esc(event.repo.root) + '" data-go=') : '') : '') + '</span></div></div>') : '<div class="empty">No activity yet.</div>';
+ $('group-activity').innerHTML = events.length ? byDay(events, (event) => event.event_at, (event) => '<div><time>' + clock(event.event_at) + '</time><div class="act"><b class="repo-label">' + esc(event.repo.name) + '</b> <span>' + esc(agentName(event.event_by, event.repo.board)) + ' ' + esc(event.event_kind) + (event.item_id ? ' <a class="ref" href="' + esc(itemAddress(event.item_id, event.repo.root)) + '" data-go="item:' + event.item_id + '"' + (event.repo.root === view.root ? '' : ' data-board="' + esc(event.repo.root) + '"') + '>#' + event.item_id + '</a>' + (event.title ? ' ' + rich(event.title, event.titles, true, event.repo.root) : '') : '') + '</span></div></div>') : '<div class="empty">No activity yet.</div>';
}
/**
@@ -1339,7 +1355,7 @@ function jumpToRoadmap(key) {
* title is the row's tooltip. An item that opens is a button; one that cannot says why instead.
*/
function milestoneRow(row, titles) {
- const title = row.title ? inline(String(row.title).replace(/\\s+/g, ' '), row.titles || titles).replaceAll('<button class="ref" data-go=', '<button class="ref" data-board="' + esc(row.root) + '" data-go=') : '<span class="muted">' + esc(row.why) + '</span>';
+ const title = row.title ? inline(String(row.title).replace(/\\s+/g, ' '), row.titles || titles, true, row.root) : '<span class="muted">' + esc(row.why) + '</span>';
const inner = '<span class="dot' + (row.state ? ' ' + row.state : '') + '"></span><span class="t"><span class="id">' + esc(row.label) + '</span>' + title + '</span>' + (row.state ? chip(row.state) : '<span class="chip">' + esc(row.word) + '</span>');
if (!row.open) return '<li><div class="milestone-item" title="' + esc(row.title ? row.title + ' (' + row.why + ')' : row.why) + '">' + inner + '</div></li>';
const attributes = 'class="milestone-item" data-go="item:' + row.open.id + '"' + (row.open.root === view.root ? '' : ' data-board="' + esc(row.open.root) + '"') + ' title="' + esc(row.title) + '"';
@@ -1450,7 +1466,7 @@ function inText(ref) {
// tests' stand-in document, which is not a browser, has no observer, and there nothing is marked.
if (typeof MutationObserver === 'function') new MutationObserver((changes) => {
for (const root of new Set(changes.map((change) => change.target))) {
- if (root.nodeType === 1) for (const ref of root.querySelectorAll('button.ref')) ref.classList.toggle('alone', !inText(ref));
+ if (root.nodeType === 1) for (const ref of root.querySelectorAll('button.ref, a.ref[data-go]')) ref.classList.toggle('alone', !inText(ref));
}
}).observe(document.body, { childList: true, subtree: true });
@@ -1594,7 +1610,7 @@ function render() {
const hold = s === 'open' ? heldLanes.get(i.lane) : null;
const waits = s === 'open' && i.blockedBy.length ? i.blockedBy : [];
const gated = gatedOf(i);
- const pills = (waits.length ? '<span class="gate">' + waits.map((id, index) => '<span class="wait-unit">' + (index ? '' : 'waits on ') + '<button class="ref" data-go="item:' + id + '" type="button">#' + id + '</button></span>').join(', ') + '</span>' : '') + (hold ? '<span class="gate">lane held: ' + linked(hold.hold_reason, titles) + '</span>' : '');
+ const pills = (waits.length ? '<span class="gate">' + waits.map((id, index) => '<span class="wait-unit">' + (index ? '' : 'waits on ') + '<a class="ref" href="' + esc(itemAddress(id)) + '" data-go="item:' + id + '">#' + id + '</a></span>').join(', ') + '</span>' : '') + (hold ? '<span class="gate">lane held: ' + linked(hold.hold_reason, titles) + '</span>' : '');
const tag = s === 'building' && i.owner ? '<span class="chip busy" title="building, held by ' + esc(agentName(i.owner)) + '">' + esc(agentName(i.owner)) + '</span>'
: s === 'verify' && i.reviewer ? '<span class="chip warn" title="reviewing until ' + esc(when(i.reviewUntil)) + '">' + esc(agentName(i.reviewer)) + ' reviewing</span>'
: s === 'open' ? openChip(i) : chip(s);
@@ -1645,7 +1661,7 @@ function render() {
+ referencedCode
+ (cited.length ? '<div><h3>Spec rows it serves</h3>' + cited.map((r) => '<div class="rowref"><code>' + esc(r.id) + '</code><div>' + linked(r.text, titles) + ' <span class="chip ' + tone(r.status) + '">' + esc(r.status) + '</span></div></div>').join('') + '</div>' : '')
+ (item.brief ? '<div><h3>Brief</h3><div class="text muted">' + rich(item.brief, titles) + '</div></div>' : '')
- + '<div><h3>People and commits</h3><dl class="kv">' + (item.owner && s === 'building' ? '<dt>holding</dt><dd>' + esc(agentName(item.owner)) + '</dd>' : '') + (item.builtBy ? '<dt>built by</dt><dd>' + esc(agentName(item.builtBy)) + '</dd>' : '') + (item.verifiedBy ? '<dt>verified by</dt><dd>' + esc(agentName(item.verifiedBy)) + '</dd>' : '') + (item.commit ? '<dt>commit</dt><dd><code>' + esc(item.commit.slice(0, 12)) + '</code></dd>' : '') + (item.merged ? '<dt>merged</dt><dd><code>' + esc(item.merged.slice(0, 12)) + '</code></dd>' : '') + (item.blockedBy.length ? '<dt>waits on</dt><dd class="waits-on">' + item.blockedBy.map((id) => '<span class="wait-unit"><button class="ref" data-go="item:' + id + '" type="button">#' + id + '</button></span>').join(', ') + '</dd>' : '') + '</dl></div>'
+ + '<div><h3>People and commits</h3><dl class="kv">' + (item.owner && s === 'building' ? '<dt>holding</dt><dd>' + esc(agentName(item.owner)) + '</dd>' : '') + (item.builtBy ? '<dt>built by</dt><dd>' + esc(agentName(item.builtBy)) + '</dd>' : '') + (item.verifiedBy ? '<dt>verified by</dt><dd>' + esc(agentName(item.verifiedBy)) + '</dd>' : '') + (item.commit ? '<dt>commit</dt><dd><code>' + esc(item.commit.slice(0, 12)) + '</code></dd>' : '') + (item.merged ? '<dt>merged</dt><dd><code>' + esc(item.merged.slice(0, 12)) + '</code></dd>' : '') + (item.blockedBy.length ? '<dt>waits on</dt><dd class="waits-on">' + item.blockedBy.map((id) => '<span class="wait-unit"><a class="ref" href="' + esc(itemAddress(id)) + '" data-go="item:' + id + '">#' + id + '</a></span>').join(', ') + '</dd>' : '') + '</dl></div>'
+ (back && !earlier.length ? '' : '<div><h3>' + (back ? 'Earlier verdicts' : 'Verdicts') + '</h3>' + (earlier.length ? earlier.map((v) => verdictHtml(v, titles)).join('') : '<div class="muted">None yet.</div>') + '</div>')
+ '<div><h3>History</h3>' + timeline(item) + '</div>'
+ '<div class="links"><button data-shout="' + esc(item.lane) + '" data-about="' + item.id + '" type="button">Shout the ' + esc(item.lane) + ' lane about #' + item.id + '</button><button data-new type="button">New item</button></div></div>';
@@ -1821,7 +1837,7 @@ function render() {
const line = firstLine(x.shout_text);
return '<b>' + esc(agentName(e.event_by)) + '</b> ' + verb + (x.shout_to ? ' <b>' + esc(agentName(x.shout_to)) + '</b>' : '') + (line ? '<span class="said" title="' + esc(line) + '">' + inline(line, titles) + '</span>' : '');
};
- $('activity').innerHTML = p.events.length ? byDay(p.events, (e) => e.event_at, (e) => '<div><time>' + clock(e.event_at) + '</time><div class="act">' + (e.event_kind === 'shout' || e.event_kind === 'answer' ? spoke(e) : '<b>' + esc(agentName(e.event_by)) + '</b> ' + esc(e.event_kind) + (e.item_id ? ' <button class="ref" data-go="item:' + e.item_id + '" type="button">#' + e.item_id + '</button>' + (titles.has(String(e.item_id)) ? ' <span class="what">' + rich(titles.get(String(e.item_id)), titles) + '</span>' : '') : '')) + '</div></div>') : '<div class="empty">No activity yet.</div>';
+ $('activity').innerHTML = p.events.length ? byDay(p.events, (e) => e.event_at, (e) => '<div><time>' + clock(e.event_at) + '</time><div class="act">' + (e.event_kind === 'shout' || e.event_kind === 'answer' ? spoke(e) : '<b>' + esc(agentName(e.event_by)) + '</b> ' + esc(e.event_kind) + (e.item_id ? ' <a class="ref" href="' + esc(itemAddress(e.item_id)) + '" data-go="item:' + e.item_id + '">#' + e.item_id + '</a>' + (titles.has(String(e.item_id)) ? ' <span class="what">' + rich(titles.get(String(e.item_id)), titles) + '</span>' : '') : '')) + '</div></div>') : '<div class="empty">No activity yet.</div>';
showTab();
revealPlace();
updateRoadmapPanel();
@@ -1868,8 +1884,8 @@ function placeAtAddress(page = data) {
/** Name each repo even beneath a group; one repo needs no prefix. */
function tabHref(tab) {
if (snapshot) {
- if (tab === 'items' && view.itemsView === 'pipeline') return location.pathname + location.search + '#items/pipeline';
- return location.pathname + location.search + (tab === 'roadmap' ? '#roadmap' : '');
+ const detail = tab === 'items' && view.itemsView === 'pipeline' ? 'pipeline' : view.addressDetail;
+ return location.pathname + location.search + '#' + tab + (detail === null ? '' : '/' + encodeURIComponent(String(detail)));
}
const repo = data?.projects.find((entry) => entry.root === view.root);
const group = data?.groups.find((entry) => entry.key === view.root);
@@ -1924,9 +1940,8 @@ function fromAddress(event) {
}
if (snapshot) {
const kept = event?.state || {};
- view.tab = addressTab() || kept.tab || homeTab();
- view.itemsView = location.hash === '#items/pipeline' ? 'pipeline' : 'list';
- if (typeof kept.item === 'number') view.item = kept.item;
+ const place = location.hash ? placeAtAddress() : { root: null, tab: kept.tab || homeTab(), detail: kept.detail ?? null };
+ applyPlace(place, kept);
if (kept.root && kept.root !== view.root) return switchTo(kept.root, view.item, false);
} else {
const place = placeAtAddress();
@@ -2034,7 +2049,7 @@ function answer(id) {
$('answering').hidden = !ask;
$('answering-who').textContent = ask ? agentName(ask.shout_from) : '';
const question = ask ? linked(ask.shout_text, new Map(data.project.items.map((i) => [String(i.id), i.title]))) : '';
- if (question.includes('<button class="ref"')) $('answering-q').innerHTML = question;
+ if (question.includes('<a class="ref"')) $('answering-q').innerHTML = question;
else $('answering-q').textContent = ask ? ask.shout_text : '';
if (ask) addressTo(ask.shout_from);
$('shout-to').disabled = Boolean(ask);
@@ -2473,6 +2488,10 @@ document.addEventListener('click', (event) => {
if (!t) return;
if (t.id === 'proj-switch') { fold(!$('side').classList.contains('open')); return; }
if (t.id === 'console') { t.hidden = true; return; }
+ if (t.matches('a[data-go^="item:"]')) {
+ if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
+ event.preventDefault();
+ }
if (t.dataset.statsToggle !== undefined) {
view.statsOpen = !view.statsOpen;
render();
diff --git a/src/view.css b/src/view.css
index 11be2c53..a9098f11 100644
--- a/src/view.css
+++ b/src/view.css
@@ -332,8 +332,8 @@ input:disabled { background: var(--surface-2); color: var(--ink-muted); }
.chip.gate { background: none; color: var(--ink-muted); outline: 1px dashed var(--line-strong); outline-offset: -1px; }
.meta .gate { color: var(--ink-muted); }
.meta .gate .wait-unit, .kv dd.waits-on .wait-unit { white-space: nowrap; }
-.meta .gate button.ref { min-height: 0; }
-.meta button.ref { border: 0; background: none; padding: 0; font: inherit; color: var(--accent-strong); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
+.meta .gate button.ref, .meta .gate a.ref { min-height: 0; }
+.meta button.ref, .meta a.ref { border: 0; background: none; padding: 0; font: inherit; color: var(--accent-strong); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.empty { color: var(--ink-faint); padding: 14px 10px; }
.stack { display: grid; gap: 14px; }
@@ -349,8 +349,8 @@ input:disabled { background: var(--surface-2); color: var(--ink-muted); }
.check-warning { margin: 6px 0 0; color: var(--warn); font-size: 13px; }
.kv { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 4px 10px; font-size: 13px; margin: 0; }
.kv dt { color: var(--ink-faint); } .kv dd { margin: 0; overflow-wrap: anywhere; }
-.kv dd.waits-on button.ref { border: 0; background: none; padding: 0; font: inherit; color: var(--accent-strong); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
-.kv dd.waits-on button.ref { min-height: 0; }
+.kv dd.waits-on button.ref, .kv dd.waits-on a.ref { border: 0; background: none; padding: 0; font: inherit; color: var(--accent-strong); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
+.kv dd.waits-on button.ref, .kv dd.waits-on a.ref { min-height: 0; }
.kv code, .detail code { font: 12px var(--mono); }
.verdict { display: grid; gap: 3px; margin-bottom: 10px; }
.verdict.yes b { color: var(--accent-strong); } .verdict.no b { color: var(--reject); }
@@ -465,7 +465,7 @@ form.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; paddin
.shout .receipt .outcome { color: var(--ink-muted); }
.shout .receipt-foot { color: var(--ink-faint); font-size: 12px; }
/* In a shout, a chip says what it is: an item, a path, a commit, a command. */
-.shout button.ref[data-go] { padding: 0 5px; border-radius: 5px; background: var(--violet-soft); color: var(--violet); font-weight: 600; text-decoration: none; }
+.shout button.ref[data-go], .shout a.ref[data-go] { padding: 0 5px; border-radius: 5px; background: var(--violet-soft); color: var(--violet); font-weight: 600; text-decoration: none; }
.shout code.inline.path { background: var(--blue-soft); color: var(--blue); }
.shout code.inline.sha { background: var(--warn-soft); color: var(--warn); }
.shout code.inline.cmd { background: var(--accent-soft); color: var(--accent-strong); }
@@ -475,6 +475,7 @@ form.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; paddin
.feed .day { margin: 0; padding: 12px 0 4px; font: 600 11px/1 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); }
.feed .day:first-child { padding-top: 6px; }
button.ref { width: auto; min-height: 0; border: 0; border-radius: 0; background: none; padding: 0; color: var(--accent-strong); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; display: inline; vertical-align: baseline; line-height: inherit; font: inherit; }
+a.ref[data-go] { color: var(--accent-strong); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
/* A code reference (path:lines@sha) is one long token: wider than its line, it breaks anywhere rather than push the page sideways. */
button.ref[data-code] { display: inline-flex; max-width: 100%; vertical-align: bottom; white-space: nowrap; text-align: left; }
button.ref[data-code] .ref-path { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
@@ -593,7 +594,7 @@ code.inline.long { white-space: break-spaces; overflow-wrap: anywhere; }
@media (pointer: coarse), (width < 900px) {
:root { --tap: 44px; }
button, input, select, textarea, [data-item], [data-row] { min-height: 44px; }
- button.ref.alone { display: inline-flex; align-items: center; min-height: 44px; vertical-align: middle; }
+ button.ref.alone, a.ref.alone { display: inline-flex; align-items: center; min-height: 44px; vertical-align: middle; }
.theme-btn, .flow-hide { width: 44px; height: 44px; }
}
/* A clickable row is never shorter than the target. */
diff --git a/test/cockpit/addresses.test.js b/test/cockpit/addresses.test.js
index 588c4271..f3a3379f 100644
--- a/test/cockpit/addresses.test.js
+++ b/test/cockpit/addresses.test.js
@@ -7,7 +7,7 @@ import { test } from 'node:test';
import { stableChrome } from './stable.js';
import { relayClientFixture } from '../relay-client-fixture.js';
import { startChrome, relayWorkBudgetMs } from '../relay-browser-fixture.js';
-import { SPEC, machine, project, startView, boardOf, chromeExecutable, openSnapshotChrome, closeSnapshotChrome, press, travel, settled } from './fixture.js';
+import { SPEC, machine, project, build, startView, boardOf, chromeExecutable, openSnapshotChrome, closeSnapshotChrome, press, travel, settled, serveFolder } from './fixture.js';
const SCRIPT = "typeof view === 'object' && typeof data === 'object' && !!data?.project && data.root === view.root && !document.body.classList.contains('loading')";
/** Read the actual rendered place without waiting for the expected answer. */
@@ -75,6 +75,174 @@ async function withBrowser(box, run) {
rmSync(profile, { recursive: true, force: true });
}
}
+
+/** Create accepted and open items whose real prose, dependency and activity rows cite one another. */
+function linkedItems(box, name) {
+ const alpha = project(box, name, SPEC, { practice: 'DOCTRINE.md' });
+ writeFileSync(join(alpha.repo, 'DOCTRINE.md'), `# Local rules\n\n## Team\n- PB1 [approved, must] ${name} practice rule. | gate: review\n`);
+ box.run(alpha.repo, 'add', 'web', 'Address target', '--specs', 'G1', '--criterion', 'renders');
+ box.run(alpha.repo, 'add', 'web', 'Text points to #1', '--specs', 'G1', '--criterion', 'criterion cites #1', '--brief', 'brief cites #1 and #999');
+ box.run(alpha.repo, 'add', 'web', 'Waits on #2', '--specs', 'G1', '--criterion', 'waits', '--after', '2');
+ box.run(alpha.repo, 'shout', 'all', 'Activity cites #1 and waits on #2.');
+ build(box, alpha, 1, 'target.txt');
+ box.git(alpha.repo, 'switch', '-q', '--detach', alpha.itemBranches.get(`${alpha.baseBranch}:1`));
+ box.run(alpha.repo, 'verify', '1', 'accept', '--note', 'The notes cite #2.', '--as', 'coordinator');
+ box.git(alpha.repo, 'switch', '-q', 'main');
+ return alpha;
+}
+
+/** Poll Chrome's real target list until a modified anchor click opens its href in another tab. */
+async function targetForHref(profile, href) {
+ const port = readFileSync(join(profile, 'DevToolsActivePort'), 'utf8').split('\n')[0].trim();
+ const deadline = Date.now() + 10_000; // budget: hang-only wait for Chrome to publish the native new-tab target.
+ let targets = [];
+ while (Date.now() < deadline) {
+ targets = await (await fetch(`http://127.0.0.1:${port}/json/list`)).json();
+ const match = targets.find((target) => target.type === 'page' && target.url === href);
+ if (match) return match;
+ await new Promise((resolve) => setTimeout(resolve, 50));
+ }
+ assert.fail(`Chrome did not open ${href}; page targets: ${JSON.stringify(targets.map(({ type, url }) => ({ type, url })))}`);
+}
+
+test('item text links every #N [N38,N26]', { timeout: 90_000 }, async () => { // budget: hang ceiling for the real API, Chrome navigation and linked prose checks.
+ const box = machine(), alpha = linkedItems(box, 'item-text-links');
+ await withBrowser(box, async (chrome, server) => {
+ await openAddress(chrome, server, '/items/2');
+ const refs = JSON.parse(await chrome.stable(`JSON.stringify({
+ criterion:[...([...document.querySelectorAll('#detail h3')].find(node=>node.textContent==='Criterion')?.parentElement.querySelectorAll('a.ref[data-go]')||[])].map(node=>[node.textContent,new URL(node.href).pathname]),
+ brief:[...([...document.querySelectorAll('#detail h3')].find(node=>node.textContent==='Brief')?.parentElement.querySelectorAll('a.ref[data-go]')||[])].map(node=>[node.textContent,new URL(node.href).pathname])
+ })`));
+ assert.deepEqual(refs.criterion, [['#1', '/items/1']], 'criterion references are real same-board addresses');
+ assert.deepEqual(refs.brief, [['#1', '/items/1'], ['#999', '/items/999']], 'known and unknown references are real same-board addresses');
+ await press(chrome, `document.querySelector('#detail a.ref[data-go="item:999"]')`);
+ await settled(chrome, "document.querySelector('#detail .empty')?.textContent.includes('No item #999 exists here.')");
+ assert.match(await chrome.stable("document.querySelector('#detail .empty')?.textContent"), /No item #999 exists here/,
+ 'an unknown reference opens its address and shows the missing-item detail');
+ await openAddress(chrome, server, '/items/3');
+ const waits = JSON.parse(await chrome.stable(`JSON.stringify([...document.querySelectorAll('#detail .waits-on a.ref[data-go]')].map(node=>[node.textContent,new URL(node.href).pathname]))`));
+ assert.deepEqual(waits, [['#2', '/items/2']], 'waits-on references link to the waited item');
+ await press(chrome, `document.querySelector('[data-tab="activity"]')`);
+ const activity = JSON.parse(await chrome.stable(`JSON.stringify([...document.querySelectorAll('#activity a.ref[data-go]')].map(node=>[node.textContent,new URL(node.href).pathname]))`));
+ const activityCites = JSON.parse(await chrome.stable(`JSON.stringify([...document.querySelectorAll('#activity .act')]
+ .filter(node=>node.textContent.includes('Activity cites #1 and waits on #2'))
+ .flatMap(node=>[...node.querySelectorAll('a.ref[data-go]')].map(link=>[link.textContent,new URL(link.href).pathname])))`));
+ assert.deepEqual(activityCites, [['#1', '/items/1'], ['#2', '/items/2']], 'the Activity citation and wait prose link to their exact item targets');
+ assert.ok(activity.some(([text, href]) => text === '#1' && href === '/items/1'), 'Activity item events also link to their item addresses');
+ await openAddress(chrome, server, '/items/1');
+ const verdict = JSON.parse(await chrome.stable(`JSON.stringify([...document.querySelectorAll('#detail .verdict .note a.ref[data-go]')].map(node=>[node.textContent,new URL(node.href).pathname]))`));
+ assert.deepEqual(verdict, [['#2', '/items/2']], 'verdict notes link to their cited item');
+ await press(chrome, `document.querySelector('#detail .verdict .note a.ref[data-go]')`);
+ assert.equal(await chrome.stable('location.pathname'), '/items/2', 'plain click stays in the page and opens the linked place');
+ assert.equal(await chrome.stable("document.querySelector('#detail h2 > span')?.textContent"), '#2');
+ assert.deepEqual(chrome.exceptions, [], 'the real view raises no page errors');
+ });
+});
+
+test('a modified click opens a new tab [N38,N26]', { timeout: 90_000 }, async () => { // budget: hang ceiling for Chrome startup and native modified-click targets.
+ const box = machine(), alpha = linkedItems(box, 'modified-item-link');
+ const server = await startView(box);
+ const executable = chromeExecutable();
+ assert.ok(executable, 'real Chrome is required to prove native modified-click behavior');
+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-modified-link-'));
+ let chrome;
+ try {
+ chrome = await openSnapshotChrome(executable, server.link.href, profile);
+ await settled(chrome, SCRIPT);
+ await openAddress(chrome, server, '/items/2');
+ const href = await chrome.stable(`document.querySelector('#detail a.ref[data-go="item:1"]')?.href`);
+ assert.equal(new URL(href).pathname, '/items/1', 'the anchor exposes the target before input');
+ await press(chrome, `document.querySelector('#detail a.ref[data-go="item:1"]')`, { button: 'middle' });
+ const target = await targetForHref(profile, href);
+ assert.equal(await chrome.stable('location.pathname'), '/items/2', 'the original tab remains at its current place');
+ assert.equal(target.url, href, 'Chrome opens the anchor destination in another page target');
+ await openAddress(chrome, server, '/items/3');
+ const modifierHref = await chrome.stable(`document.querySelector('#detail a.ref[data-go="item:2"]')?.href`);
+ const modifiers = process.platform === 'darwin' ? 4 : 2;
+ await press(chrome, `document.querySelector('#detail a.ref[data-go="item:2"]')`, { modifiers });
+ const modifierTarget = await targetForHref(profile, modifierHref);
+ assert.equal(await chrome.stable('location.pathname'), '/items/3', 'the platform modifier leaves the original tab at its current place');
+ assert.equal(modifierTarget.url, modifierHref, 'Chrome opens a platform-modified anchor in another page target');
+ assert.deepEqual(chrome.exceptions, []);
+ } finally {
+ if (chrome) await closeSnapshotChrome(chrome);
+ await server.stop();
+ rmSync(profile, { recursive: true, force: true });
+ }
+});
+
+test('the snapshot keeps its addresses under a sub-path [N38,A10]', { timeout: 90_000 }, async () => { // budget: hang ceiling for export, replay, click and reload.
+ const executable = chromeExecutable();
+ assert.ok(executable, 'real Chrome is required to prove exported address reloads');
+ const box = machine(), alpha = linkedItems(box, 'snapshot-item-address');
+ const folder = join(box.dir, 'snapshot');
+ box.run(alpha.repo, 'view', '--export', folder);
+ const host = await serveFolder(folder, '/demo/');
+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-snapshot-address-'));
+ let chrome;
+ try {
+ chrome = await openSnapshotChrome(executable, `${host.base}/demo/`, profile);
+ await settled(chrome, "document.body.classList.contains('snapshot') && !!data?.project");
+ await settled(chrome, 'snapshotReplay.index === snapshotReplay.events.length');
+ await press(chrome, `document.querySelector('#chain [data-item="2"]')`);
+ const reference = `document.querySelector('#detail a.ref[data-go="item:1"]')`;
+ await chrome.waitFor(`!!${reference}`);
+ const href = await chrome.stable(`${reference}.href`);
+ assert.equal(new URL(href).pathname, '/demo/', 'snapshot item links retain the export sub-path');
+ assert.equal(new URL(href).hash, '#items/1', 'snapshot item links address the item in the fragment');
+ const outsideInitialRefs = JSON.parse(await chrome.stable(`JSON.stringify([...document.querySelectorAll('#detail a.ref[data-go^="item:"]')]
+ .filter(link=>new URL(link.href).pathname !== '/demo/').map(link=>link.href))`));
+ assert.deepEqual(outsideInitialRefs, [], 'item detail references also remain under the exported sub-path');
+ await press(chrome, reference);
+ await settled(chrome, "location.pathname === '/demo/' && location.hash === '#items/1' && document.querySelector('#detail h2 > span')?.textContent === '#1'");
+ await chrome.send('Page.reload');
+ await settled(chrome, "location.pathname === '/demo/' && location.hash === '#items/1' && document.querySelector('#detail h2 > span')?.textContent === '#1'");
+
+ /** Reload an exported address and verify both its selected detail and its contained references. */
+ const checkPlace = async (hash, ready) => {
+ assert.equal(await chrome.stable('location.hash'), hash, 'the selected place is encoded in the snapshot address');
+ await chrome.send('Page.reload');
+ await settled(chrome, `location.pathname === '/demo/' && location.hash === ${JSON.stringify(hash)} && data?.project && snapshotReplay.final && snapshotReplay.index === snapshotReplay.events.length && (${ready})`);
+ assert.equal(await chrome.stable('location.pathname'), '/demo/', 'reload keeps the exported page path');
+ const outside = JSON.parse(await chrome.stable(`JSON.stringify([...document.querySelectorAll('a.ref[data-go^="item:"]')]
+ .filter(link=>new URL(link.href).pathname !== '/demo/').map(link=>link.href))`));
+ assert.deepEqual(outside, [], `${hash} keeps every item address under the exported sub-path`);
+ };
+ await press(chrome, `document.querySelector('[data-items-view="pipeline"]')`);
+ await checkPlace('#items/pipeline', "view.tab === 'items' && view.itemsView === 'pipeline' && !document.querySelector('[data-pane=items]').hidden");
+ const oldest = JSON.parse(await chrome.stable(`JSON.stringify((() => {
+ const link = document.querySelector('#pipeline .pipeline-oldest a.ref[data-go]');
+ return { href: link?.href, id: Number(link?.textContent.slice(1)) };
+ })())`));
+ assert.ok(oldest.href && oldest.id > 0, 'the exported Pipeline shows its oldest-item address');
+ await press(chrome, `document.querySelector('#pipeline .pipeline-oldest a.ref[data-go]')`);
+ await checkPlace(new URL(oldest.href).hash, `view.tab === 'items' && view.item === ${oldest.id}`);
+ await press(chrome, `document.querySelector('[data-tab="shouts"]')`);
+ await checkPlace('#shouts', "view.tab === 'shouts' && !document.querySelector('[data-pane=shouts]').hidden");
+ const shoutId = await chrome.stable(`document.querySelector('#feed [data-shout-id]')?.dataset.shoutId`);
+ await press(chrome, `document.querySelector('#feed [data-shout-id]')`);
+ await checkPlace('#shouts/' + shoutId, `view.tab === 'shouts' && view.shout === Number(${JSON.stringify(shoutId)}) && document.querySelector('#feed article.found')?.dataset.shoutId === ${JSON.stringify(shoutId)}`);
+ await press(chrome, `document.querySelector('[data-tab="spec"]')`);
+ await press(chrome, `document.querySelector('[data-rows="spec:all"]')`);
+ const specId = await chrome.stable(`document.querySelector('#spec-list [data-row]')?.dataset.row.split(':')[1]`);
+ await press(chrome, `document.querySelector('#spec-list [data-row]')`);
+ await checkPlace('#spec/' + specId, `view.tab === 'spec' && view.row.spec === ${JSON.stringify(specId)} && document.querySelector('#spec-detail h2 > span')?.textContent === ${JSON.stringify(specId)}`);
+ await press(chrome, `document.querySelector('[data-tab="doctrine"]')`);
+ const doctrineId = await chrome.stable(`document.querySelector('#doctrine-list [data-row]')?.dataset.row.split(':')[1]`);
+ await press(chrome, `document.querySelector('#doctrine-list [data-row]')`);
+ await checkPlace('#doctrine/' + doctrineId, `view.tab === 'doctrine' && view.row.doctrine === ${JSON.stringify(doctrineId)} && document.querySelector('#doctrine-detail h2 > span')?.textContent === ${JSON.stringify(doctrineId)}`);
+ await press(chrome, `document.querySelector('[data-tab="activity"]')`);
+ await checkPlace('#activity', "view.tab === 'activity' && !document.querySelector('[data-pane=activity]').hidden");
+ await press(chrome, `document.querySelector('[data-tab="roadmap"]')`);
+ await checkPlace('#roadmap', "view.tab === 'roadmap' && !document.querySelector('[data-pane=roadmap]').hidden");
+ assert.ok(host.requests.length > 0 && host.requests.every((request) => request.path.startsWith('/demo/')), 'click and reload stay under the exported sub-path');
+ assert.deepEqual(chrome.exceptions, [], 'the exported page raises no page errors');
+ } finally {
+ if (chrome) await closeSnapshotChrome(chrome);
+ await host.close();
+ rmSync(profile, { recursive: true, force: true });
+ }
+});
/** Wait only for the addressed lookup to finish, then inspect the real target and its viewport box. */
async function assertShout(chrome, id, text) {
await settled(chrome, `${SCRIPT} && !document.querySelector('#shout-address-status')?.textContent.startsWith('Loading')`);
diff --git a/test/cockpit/stable.js b/test/cockpit/stable.js
index 9709d20a..8d51453a 100644
--- a/test/cockpit/stable.js
+++ b/test/cockpit/stable.js
@@ -57,14 +57,14 @@ export async function waitForStableBoxes(chrome, find = 'document.documentElemen
}
/**
- * Press an uncovered, stable target through real Chrome input. A pointer move can change hover layout,
- * so wait again after it and refuse a changed point rather than retrying the action at another point.
+ * Press an uncovered, stable target through real Chrome input, optionally using a browser button or modifier.
+ * A pointer move can change hover layout, so wait again after it and refuse a changed point rather than retrying.
* @param {object} chrome
* @param {string} find
- * @param {{ native?: boolean, afterMouseDown?: () => Promise<void> }} [options] - Optionally run a bounded observation while the real pointer remains held.
+ * @param {{ native?: boolean, button?: string, modifiers?: number, afterMouseDown?: () => Promise<void> }} [options] - Optionally observe work while the real pointer remains held.
* @returns {Promise<void>}
*/
-export async function press(chrome, find, { native = true, afterMouseDown = null } = {}) {
+export async function press(chrome, find, { native = true, button = 'left', modifiers = 0, afterMouseDown = null } = {}) {
await waitForStableBoxes(chrome, find);
if (!native) return rawChromeEvaluation(chrome, `(${find}).click()`);
await rawChromeEvaluation(chrome, `(${find}).scrollIntoView({ block: 'center', behavior: 'instant' })`);
@@ -87,11 +87,11 @@ export async function press(chrome, find, { native = true, afterMouseDown = null
window.__pressed = { meant: name(element), at: ${Math.round(point.y)}, scrollY: Math.round(scrollY) };
document.addEventListener('mousedown', event => Object.assign(window.__pressed, { landed: name(event.target), landedAt: Math.round(event.clientY), scrolledTo: Math.round(scrollY) }), { capture: true, once: true });
})()`);
- await raw.send('Input.dispatchMouseEvent', { type: 'mousePressed', x: point.x, y: point.y, button: 'left', clickCount: 1 });
+ await raw.send('Input.dispatchMouseEvent', { type: 'mousePressed', x: point.x, y: point.y, button, clickCount: 1, modifiers });
try {
if (afterMouseDown) await afterMouseDown();
} finally {
- await raw.send('Input.dispatchMouseEvent', { type: 'mouseReleased', x: point.x, y: point.y, button: 'left', clickCount: 1 });
+ await raw.send('Input.dispatchMouseEvent', { type: 'mouseReleased', x: point.x, y: point.y, button, clickCount: 1, modifiers });
}
}