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): a stale verdict shows a stale chip [N26,V4]

Corey Olson54569bb1fb1d
diff --git a/src/cockpit.js b/src/cockpit.js
index 7304bf49..1241690e 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -5,6 +5,7 @@ import {
} from './machine.js';
import { commandPhrases } from './help.js';
import { personNeeds } from './needs.js';
+import { staleChip } from './view/stale.js';
/** The CLI's default phrases, ordered by depth for the existing prose inventory guard. */
export const PULLBOARD_COMMANDS = Object.freeze(commandPhrases().sort((left, right) => right.split(' ').length - left.split(' ').length));
@@ -493,6 +494,8 @@ const verdictHtml = (v, titles) => '<div class="verdict ' + (v.decision === 'ACC
const stateOf = (i) => i.status === 'claimed' ? 'building' : i.status === 'submitted' ? 'verify' : i.status === 'verified' ? 'verified' : i.status === 'withdrawn' ? 'withdrawn' : i.verdict && i.verdict.decision === 'REJECT' ? 'back' : 'open';
const STATES = { building: ['building', 'busy'], verify: ['to verify', 'warn'], back: ['sent back', 'no'], verified: ['verified', 'ok'], open: ['unclaimed', 'free'], withdrawn: ['withdrawn', ''] };
const chip = (s) => '<span class="chip ' + STATES[s][1] + '">' + STATES[s][0] + '</span>';
+// A verified item's stale mark from src/view/stale.js (#726): Core publishes verdictState and the page only draws it.
+const staleChip = (${staleChip.toString()});
/** Parse the bounded reference syntax before requesting additional committed line windows. */
function codeReferenceParts(ref) {
const match = /^(.+):(\\d+)(?:-(\\d+))?@([0-9a-f]{7,40})$/.exec(String(ref));
@@ -1923,6 +1926,7 @@ function milestoneItem(entry, p) {
root,
titles: new Map((root === view.root ? p.items : root ? named[0].items : []).map((i) => [String(i.id), i.title])),
state: read ? stateOf(read) : null,
+ stale: item ? staleChip(item) : '',
stage: item ? pipelineStage(item) : entry.status,
word: entry.status,
open: item ? { root, id } : null,
@@ -1975,7 +1979,7 @@ function jumpToRoadmap(key) {
*/
function milestoneRow(row, titles) {
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>');
+ const inner = '<span class="dot' + (row.state ? ' ' + row.state : '') + '"></span><span class="t"><span class="id">' + esc(row.label) + '</span>' + title + '</span>' + (row.stale || '') + (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) + '"';
// A title with its own links needs a separate containing control, never a nested button.
@@ -2287,7 +2291,7 @@ function render() {
primary: '<span>#' + i.id + '</span>' + rich(i.title, titles), rightTop: age(i.updatedAt), rightBottom: tag,
// A rejected row's second line is its verdict; any other row's is its lane and the spec ids it serves.
secondary: (rejected(i) ? '<span class="why"><b>' + esc(i.verdict.reason) + '</b> ' + linked(firstLine(visibleVerdictNote(i.verdict.reason, i.verdict.note)), titles) + '</span>'
- : '<span>' + esc(i.lane) + '</span>' + (i.specs.length ? '<span class="specs" title="' + esc(i.specs.join(', ')) + '">' + esc(i.specs.slice(0, 3).join(', ') + (i.specs.length > 3 ? ' +' + (i.specs.length - 3) : '')) + '</span>' : '')) + pills });
+ : '<span>' + esc(i.lane) + '</span>' + (i.specs.length ? '<span class="specs" title="' + esc(i.specs.join(', ')) + '">' + esc(i.specs.slice(0, 3).join(', ') + (i.specs.length > 3 ? ' +' + (i.specs.length - 3) : '')) + '</span>' : '')) + pills + staleChip(i) });
}).join('') : '<li class="empty">' + (items.length ? 'No items match.' : snapshot ? 'No items at this event.' : 'No items yet. Add the first one with New item.') + '</li>';
const selected = p.items.find((i) => i.id === view.item);
@@ -2326,7 +2330,7 @@ function render() {
// Why it came back is the first thing the person reads; the verdicts before it stay below.
const back = rejected(item);
const earlier = back ? item.verdicts.slice(0, -1) : item.verdicts;
- $('detail').innerHTML = '<div class="stack"><div><h2><span>#' + item.id + '</span>' + rich(item.title, titles) + '</h2><div class="meta spaced">' + (s === 'open' ? openChip(item) : chip(s)) + '<span class="chip">' + esc(item.lane) + '</span><span class="chip">' + esc(item.route) + '</span></div></div>'
+ $('detail').innerHTML = '<div class="stack"><div><h2><span>#' + item.id + '</span>' + rich(item.title, titles) + '</h2><div class="meta spaced">' + (s === 'open' ? openChip(item) : chip(s)) + staleChip(item) + '<span class="chip">' + esc(item.lane) + '</span><span class="chip">' + esc(item.route) + '</span></div></div>'
+ (back ? '<div class="sentback"><h3>Sent back' + (s === 'building' ? ', being reworked' : s === 'verify' ? ', resubmitted' : s === 'withdrawn' ? ', then withdrawn' : '') + '</h3>' + verdictHtml(item.verdict, titles) + '</div>' : '')
+ (item.criterion ? '<div><h3>Criterion</h3><div class="text">' + rich(item.criterion, titles) + '</div></div>' : '')
+ (item.check ? '<div><h3>Check</h3><dl class="kv"><dt>command</dt><dd><code>' + esc(item.check) + '</code></dd><dt>baseline</dt><dd><span class="chip ' + baselineClass + '">' + esc(baseline?.result ?? 'not recorded') + '</span></dd></dl>'
@@ -2402,11 +2406,11 @@ function render() {
// Asks waiting on someone else are not the person's to answer: they show only once the composer's toggle opens them.
+ (p.asked.length && view.open.waiting ? p.asked.map((d) => card(d, '', false)).join('') : '');
foldShouts();
- // Each agent with what it holds: its claim, then its work sent back, then its work waiting for a
- // verdict. The worktree path is there on hover; what the person reads is who is doing what.
+ // Each agent with what it holds: its claim, then its work sent back or with a stale verdict to redo, then its work waiting
+ // for a verdict. The worktree path is there on hover; what the person reads is who is doing what.
// A review an agent holds (V15) comes right after its claim.
- const rank = (a, i) => i.status === 'claimed' ? 0 : reviewerOf(i) === a.agent_id ? 1 : stateOf(i) === 'back' ? 2 : 3;
- const holding = (a) => items.filter((i) => i.status === 'claimed' ? holderOf(i) === a.agent_id : reviewerOf(i) === a.agent_id || (i.builtBy === a.agent_id && ['back', 'verify'].includes(stateOf(i)))).sort((x, y) => rank(a, x) - rank(a, y));
+ const rank = (a, i) => i.status === 'claimed' ? 0 : reviewerOf(i) === a.agent_id ? 1 : stateOf(i) === 'back' || staleChip(i) ? 2 : 3;
+ const holding = (a) => items.filter((i) => i.status === 'claimed' ? holderOf(i) === a.agent_id : reviewerOf(i) === a.agent_id || (i.builtBy === a.agent_id && (['back', 'verify'].includes(stateOf(i)) || staleChip(i)))).sort((x, y) => rank(a, x) - rank(a, y));
// The agents at work: holding a claim or a review now, or moved in the last hour. Every agent is one click away;
// work an idle agent left sent back or waiting stays on the Items tab.
const recent = (a) => p.items.some((i) => (i.status === 'claimed' && holderOf(i) === a.agent_id) || (i.status === 'submitted' && reviewerOf(i) === a.agent_id))
@@ -2418,12 +2422,13 @@ function render() {
const busy = listed.filter((a) => holding(a).length), idle = listed.filter((a) => !holding(a).length);
const face = (a) => lead(a.agent_id) ? '<span class="avatar">' + LEAD + '</span>' : '<span class="avatar' + (initials(a.agent_id).length > 3 ? ' wide' : '') + '" aria-hidden="true">' + esc(initials(a.agent_id)) + '</span>';
const tip = (a) => 'Shouts with ' + agentName(a.agent_id) + ' · ' + a.agent_lane + ' · ' + a.agent_route + ' (' + a.agent_path + ')';
- const state = (a, i) => reviewerOf(i) === a.agent_id ? '<span class="chip warn">reviewing</span>' : chip(stateOf(i));
+ // Beside the name there is room for one word, so a stale verdict says stale there; the opened rows say verified and stale.
+ const state = (a, i, brief = false) => reviewerOf(i) === a.agent_id ? '<span class="chip warn">reviewing</span>' : (brief && staleChip(i)) || chip(stateOf(i)) + staleChip(i);
const marks = (a) => ' h' + hue(a.agent_id) + (lead(a.agent_id) ? ' lead' : '') + (view.agent === a.agent_id ? ' on' : '');
const row = (a) => {
const mine = holding(a), first = mine[0];
return '<div class="agent-card' + marks(a) + '"><button class="agent-row" data-agent="' + esc(a.agent_id) + '" title="' + esc(tip(a)) + '" type="button">' + face(a)
- + '<span class="agent-who"><b>' + esc(agentName(a.agent_id)) + '</b>' + state(a, first) + (mine.length > 1 ? '<span class="agent-more">+' + (mine.length - 1) + '</span>' : '') + (a.lastMoveAt ? '<time data-ago="' + esc(a.lastMoveAt) + '">' + ago(a.lastMoveAt) + '</time>' : '') + '</span>'
+ + '<span class="agent-who"><b>' + esc(agentName(a.agent_id)) + '</b>' + state(a, first, true) + (mine.length > 1 ? '<span class="agent-more">+' + (mine.length - 1) + '</span>' : '') + (a.lastMoveAt ? '<time data-ago="' + esc(a.lastMoveAt) + '">' + ago(a.lastMoveAt) + '</time>' : '') + '</span>'
+ '<span class="agent-doing"><span class="agent-what"><i>#' + first.id + '</i> ' + esc(first.title) + '</span></span></button>'
+ (view.agent === a.agent_id ? mine.map((i) => '<div class="agent-work" data-item="' + i.id + '" data-go="item:' + i.id + '"><span>#' + i.id + ' ' + rich(i.title, titles) + '</span>' + state(a, i) + '</div>').join('') : '') + '</div>';
};
diff --git a/src/view.css b/src/view.css
index 70967c54..6805ce53 100644
--- a/src/view.css
+++ b/src/view.css
@@ -338,6 +338,12 @@ input:disabled { background: var(--surface-2); color: var(--ink-muted); }
.chip.busy { background: var(--blue-soft); color: var(--blue); }
.chip.free { background: var(--violet-soft); color: var(--violet); }
.chip.gate { background: none; color: var(--ink-muted); outline: 1px dashed var(--line-strong); outline-offset: -1px; }
+/* A stale verdict (#726) is a quiet word with a small dot beside the verified chip; its title says what main moved. */
+.chip.stale { background: none; color: var(--ink-muted); padding-inline: 0; }
+.chip.stale::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 4px; border-radius: 50%; background: var(--warn); vertical-align: 1px; }
+.row .meta > .stale { margin-left: auto; }
+.milestone-item:has(> .stale) { grid-template-columns: 12px minmax(0, 1fr) auto auto; }
+.agent-work:has(> .stale) { grid-template-columns: minmax(0, 1fr) auto auto; }
.meta .gate { color: var(--ink-muted); }
.meta .gate .wait-unit, .kv dd.waits-on .wait-unit { white-space: nowrap; }
.meta .gate button.ref, .meta .gate a.ref { min-height: 0; }
diff --git a/src/view/stale.js b/src/view/stale.js
new file mode 100644
index 00000000..179372ad
--- /dev/null
+++ b/src/view/stale.js
@@ -0,0 +1,31 @@
+/**
+ * The view's stale mark on a verdict (N26, #726). Core (#409) decides staleness and publishes it as an
+ * item's verdictState, {code: "STALE_VERDICT", file, commit, main, reason?, legacy?}; the view only
+ * draws what it is given, so it never re-derives which files main moved.
+ */
+
+/**
+ * A quiet "stale" chip for a verified item whose verdict main has moved under, or '' for any other
+ * item. The status stays verified and the ACCEPT stays in the history: this is a mark beside them.
+ * The title and the accessible name say why in full, the file and the commit, since the short word
+ * alone cannot tell the person what moved.
+ *
+ * The page embeds this function's source, so it reads nothing outside itself, its own escaping
+ * included.
+ *
+ * @param {{status?: string, merged?: string|null, stage?: string, verdictState?: {code?: string, file?: string|null, commit?: string|null, reason?: string, legacy?: boolean}|null}|null} item
+ * @returns {string} The chip's markup, or ''.
+ */
+export function staleChip(item) {
+ const state = item && item.verdictState;
+ // A merged item's verdict is final whatever main does next; only a verified item waiting to land can go stale.
+ // A summary row names a merge by its stage, an item's detail by its merged commit.
+ if (!state || state.code !== 'STALE_VERDICT' || item.status !== 'verified' || item.merged || item.stage === 'merged') return '';
+ const escape = (text) => String(text).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
+ const why = state.file && state.commit
+ ? 'main changed ' + state.file + ' in ' + state.commit + ' after this verdict checked it'
+ : state.reason || 'main changed files this verdict checked';
+ // A legacy receipt sealed no reviewed trunk, so Core judged it from the claim's base instead.
+ const title = 'Stale verdict: ' + why + (state.legacy ? ' (an older receipt, judged from where the claim began)' : '') + '. Re-review it before it lands.';
+ return '<span class="chip stale" role="img" title="' + escape(title) + '" aria-label="' + escape(title) + '">stale</span>';
+}
diff --git a/test/cockpit/items.test.js b/test/cockpit/items.test.js
index 08bc105c..873c4029 100644
--- a/test/cockpit/items.test.js
+++ b/test/cockpit/items.test.js
@@ -69,6 +69,41 @@ test('a review in progress names its reviewer [N26]', async () => {
await view.stop();
}
});
+test('a stale verdict shows a stale chip [N26,V4]', async () => {
+ const box = machine(), alpha = project(box, 'alpha');
+ for (const title of ['Stale', 'Fresh', 'Landed', 'Legacy', 'Open']) box.run(alpha.repo, 'add', 'web', title, '--specs', 'G1', '--criterion', 'renders');
+ for (const id of [1, 2, 3, 4]) { build(box, alpha, id, `page-${id}.html`); accept(box, alpha, id); }
+ box.git(alpha.repo, 'merge', '-q', '--ff-only', alpha.itemBranches.get(`${alpha.baseBranch}:3`));
+ box.run(alpha.repo, 'merged', '3', box.git(alpha.repo, 'rev-parse', 'HEAD'));
+ box.run(alpha.repo, 'milestone', 'add', 'Next', '--items', '1,2,3,4,5');
+ const view = await startView(box);
+ try {
+ const page = await openPage(view);
+ await page.click({ state: 'all' });
+ // Core (#409) publishes verdictState; here the fixture hands it in, a file name with markup included.
+ const [one, two, file] = ['a'.repeat(40), 'b'.repeat(40), `web/<b>x</b>&"y'.html`];
+ const states = { 1: { code: 'STALE_VERDICT', file, commit: one, main: two }, 3: { code: 'STALE_VERDICT', file, commit: one, main: two }, 4: { code: 'STALE_VERDICT', file: 'web/page-4.html', commit: two, main: one, legacy: true } };
+ page.run(`for (const [id, s] of Object.entries(${JSON.stringify(states)})) data.project.items.find((i) => i.id === Number(id)).verdictState = s; render();`);
+ const said = (why) => { const t = 'Stale verdict: ' + why + '. Re-review it before it lands.'; return `<span class="chip stale" role="img" title="${t}" aria-label="${t}">stale</span>`; };
+ const stale = said(`main changed web/&lt;b&gt;x&lt;/b&gt;&amp;&quot;y&#39;.html in ${one} after this verdict checked it`);
+ const legacy = said(`main changed web/page-4.html in ${two} after this verdict checked it (an older receipt, judged from where the claim began)`);
+ const marks = (html) => (html.match(/<span class="chip stale"[^>]*>stale<\/span>/g) ?? []).join('');
+ const rows = (html, at) => [1, 2, 3, 4].map((id) => marks(html.split('<li').find((row) => row.includes(at(id))) ?? ''));
+ assert.deepEqual(rows(page.show('chain'), (id) => `data-item="${id}"`), [stale, '', '', legacy], 'the list marks the stale and legacy verdicts, never the fresh or merged one');
+ assert.match(itemRow(page.show('chain'), 1), /<span class="chip ok">verified<\/span><\/li>$/, 'the status stays verified');
+ await page.click({ state: 'verified' });
+ assert.deepEqual(rows(page.show('chain'), (id) => `data-item="${id}"`), [stale, '', '', legacy], 'the verified filter still lists them');
+ await page.click({ go: 'item:1' });
+ assert.equal(marks(page.show('detail')), stale, 'the detail marks it beside the verified chip');
+ assert.match(page.show('detail'), /<div class="verdict yes"><b>ACCEPT /, 'the ACCEPT stays in the history');
+ await page.click({ go: 'item:3' });
+ assert.equal(marks(page.show('detail')), '', 'a merged item carries no mark');
+ page.run('view.tab = "roadmap"; render();');
+ assert.deepEqual(rows(page.show('roadmap'), (id) => `data-go="item:${id}"`), [stale, '', '', legacy], 'the Roadmap marks the same rows');
+ page.run('view.agent = "web-1"; render();');
+ assert.deepEqual(rows(page.show('agents').replaceAll('<div class="agent-work"', '<li'), (id) => `data-item="${id}"`), [stale, '', '', legacy], 'the builder holds its stale verdicts in the agent rows');
+ } finally { await view.stop(); }
+});
test('each row says what it waits on [N26]', async () => {
const box = machine();
const lanes = { web: { owns: ['web/'], specs: ['G'] }, api: { owns: ['api/'], specs: ['G'] } };