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.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
feat(view): a sent-back item says why before anything else [N26]
Corey Olson0edc4596dd7d
diff --git a/src/cockpit.js b/src/cockpit.jsindex 8fe2608d..2fda8f28 100644--- a/src/cockpit.js+++ b/src/cockpit.js@@ -142,6 +142,10 @@ input, select { border: 1px solid var(--line-strong); background: var(--surface).verdict.yes { border-left-color: var(--accent); } .verdict.no { border-left-color: var(--reject); }.verdict .by { font-size: 12px; color: var(--ink-faint); }.verdict .note { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }+.sentback { border: 1px solid color-mix(in srgb, var(--reject) 40%, var(--line)); background: color-mix(in srgb, var(--reject) 6%, var(--surface)); border-radius: 10px; padding: 10px 12px; }+.sentback h3 { color: var(--reject); }+.sentback .verdict { border-left: 0; padding: 0; margin: 0; }+.meta .why { flex-basis: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--reject); }.hist { display: grid; gap: 2px; font-size: 12.5px; }.hist div { display: grid; grid-template-columns: 4.2em minmax(0, 1fr); gap: 8px; }.hist time, .feed time { color: var(--ink-faint); font: 12px var(--mono); }@@ -259,6 +263,11 @@ const $ = (id) => document.getElementById(id);const esc = (text) => String(text ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);const ago = (iso) => { const m = Math.round((Date.now() - Date.parse(iso)) / 60000); return m < 1 ? 'now' : m < 60 ? m + 'm' : m < 2880 ? Math.round(m / 60) + 'h' : Math.round(m / 1440) + 'd'; };const clock = (iso) => new Date(iso).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hourCycle: 'h23' });+const when = (iso) => (new Date(iso).toDateString() === new Date().toDateString() ? '' : new Date(iso).toLocaleDateString([], { month: 'short', day: 'numeric' }) + ' ') + clock(iso);+const firstLine = (text) => String(text ?? '').split('\\n').map((line) => line.trim()).find(Boolean) || '';+// Sent back and not verified since: open again, being reworked, or resubmitted for a new verdict.+const rejected = (i) => i.status !== 'verified' && i.status !== 'withdrawn' && !!i.verdict && i.verdict.decision === 'REJECT';+const verdictHtml = (v) => '<div class="verdict ' + (v.decision === 'ACCEPT' ? 'yes' : 'no') + '"><b>' + esc(v.decision) + ' ' + esc(v.reason) + '</b><span class="by">' + esc(v.by) + ' · ' + when(v.at) + ' · at ' + esc(String(v.commit || '').slice(0, 12)) + '</span><div class="note">' + esc(v.note) + '</div></div>';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: ['open', ''], withdrawn: ['withdrawn', ''] };const chip = (s) => '<span class="chip ' + STATES[s][1] + '">' + STATES[s][0] + '</span>';@@ -319,8 +328,8 @@ function render() {// What needs the person, first: questions, work sent back, work waiting for a verdict, held lanes.const needs = [...p.spec.filter((r) => r.status === 'pending').map((r) => ['spec:' + r.id, r.id, r.text, 'answer in SPEC.md']),- ...by('back').map((i) => ['item:' + i.id, '#' + i.id, i.title, 'sent back']),- ...by('verify').map((i) => ['item:' + i.id, '#' + i.id, i.title, 'to verify, ' + ago(i.updatedAt)]),+ ...by('back').map((i) => ['item:' + i.id, '#' + i.id, i.title, 'sent back: ' + i.verdict.reason]),+ ...by('verify').map((i) => ['item:' + i.id, '#' + i.id, i.title, (rejected(i) ? 'resubmitted after ' + i.verdict.reason : 'to verify') + ', ' + ago(i.updatedAt)]),...p.holds.map((h) => ['tab:shouts', h.hold_lane, h.hold_reason, 'lane held']),];const drafts = p.spec.filter((r) => r.status === 'draft').length;@@ -350,7 +359,7 @@ function render() {$('chain').innerHTML = shown.length ? shown.map((i) => {const s = stateOf(i);const who = s === 'building' ? i.owner : [i.builtBy, i.verifiedBy].filter(Boolean).join(' → ');- return '<li class="row' + (view.item === i.id ? ' on' : '') + '" data-item="' + i.id + '"><span class="dot ' + s + '"></span><div><div class="t"><span>#' + i.id + '</span>' + esc(i.title) + '</div><div class="meta"><span>' + esc(i.lane) + '</span>' + (i.specs.length ? '<span>' + esc(i.specs.join(', ')) + '</span>' : '') + (who ? '<span>' + esc(who) + '</span>' : '') + (i.blockedBy.length && s === 'open' ? '<span>waits on #' + i.blockedBy.join(', #') + '</span>' : '') + '<span>' + ago(i.updatedAt) + '</span></div></div>' + chip(s) + '</li>';+ return '<li class="row' + (view.item === i.id ? ' on' : '') + '" data-item="' + i.id + '"><span class="dot ' + s + '"></span><div><div class="t"><span>#' + i.id + '</span>' + esc(i.title) + '</div><div class="meta"><span>' + esc(i.lane) + '</span>' + (i.specs.length ? '<span>' + esc(i.specs.join(', ')) + '</span>' : '') + (who ? '<span>' + esc(who) + '</span>' : '') + (i.blockedBy.length && s === 'open' ? '<span>waits on #' + i.blockedBy.join(', #') + '</span>' : '') + '<span>' + ago(i.updatedAt) + '</span>' + (rejected(i) ? '<span class="why">' + esc(i.verdict.reason + ': ' + firstLine(i.verdict.note)) + '</span>' : '') + '</div></div>' + chip(s) + '</li>';}).join('') : '<li class="empty">' + (items.length ? 'No items match.' : 'No items yet. Add the first one with New item.') + '</li>';const item = p.items.find((i) => i.id === view.item);@@ -359,12 +368,16 @@ function render() {if (item && !view.adding) {const s = stateOf(item);const cited = item.specs.map((id) => p.spec.find((r) => r.id === id) || { id, status: 'missing', text: '(not in SPEC.md)' });+ // 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 style="display:grid;gap:14px"><div><h2><span>#' + item.id + '</span>' + esc(item.title) + '</h2><div class="meta" style="margin-top:6px">' + chip(s) + '<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' : '') + '</h3>' + verdictHtml(item.verdict) + '</div>' : '')+ (item.criterion ? '<div><h3>Criterion</h3><div class="text">' + esc(item.criterion) + '</div></div>' : '')+ (cited.length ? '<div><h3>Spec rows it serves</h3>' + cited.map((r) => '<div class="rowref"><code>' + esc(r.id) + '</code><div>' + esc(r.text) + ' <span class="chip ' + tone(r.status) + '">' + esc(r.status) + '</span></div></div>').join('') + '</div>' : '')+ (item.brief ? '<div><h3>Brief</h3><div class="text muted">' + esc(item.brief) + '</div></div>' : '')+ '<div><h3>People and commits</h3><dl class="kv">' + (item.owner && s === 'building' ? '<dt>holding</dt><dd>' + esc(item.owner) + '</dd>' : '') + (item.builtBy ? '<dt>built by</dt><dd>' + esc(item.builtBy) + '</dd>' : '') + (item.verifiedBy ? '<dt>verified by</dt><dd>' + esc(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>' + item.blockedBy.map((id) => '#' + id).join(', ') + '</dd>' : '') + '</dl></div>'- + '<div><h3>Verdicts</h3>' + (item.verdicts.length ? item.verdicts.map((v) => '<div class="verdict ' + (v.decision === 'ACCEPT' ? 'yes' : 'no') + '"><b>' + esc(v.decision) + ' ' + esc(v.reason) + '</b><span class="by">' + esc(v.by) + ' · ' + clock(v.at) + ' · at ' + esc(String(v.commit || '').slice(0, 12)) + '</span><div class="note">' + esc(v.note) + '</div></div>').join('') : '<div class="muted">None yet.</div>') + '</div>'+ + (back && !earlier.length ? '' : '<div><h3>' + (back ? 'Earlier verdicts' : 'Verdicts') + '</h3>' + (earlier.length ? earlier.map(verdictHtml).join('') : '<div class="muted">None yet.</div>') + '</div>')+ '<div><h3>History</h3><div class="hist">' + item.history.map((e) => '<div><time>' + clock(e.at) + '</time><span>' + esc(e.by) + ' ' + esc(e.kind) + '</span></div>').join('') + '</div></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>';}diff --git a/test/cockpit.test.js b/test/cockpit.test.jsindex 20053f88..c2669e6f 100644--- a/test/cockpit.test.js+++ b/test/cockpit.test.js@@ -306,3 +306,83 @@ test('the sidebar lists every project and what needs the person [N26]', async ()await view.stop();}});++/**+ * The coordinator accepts an item from a checkout of its submitted commit.+ */+function accept(box, p, id) {+ box.git(p.repo, 'switch', '-q', '--detach', p.branch);+ box.run(p.repo, 'verify', String(id), 'accept', '--note', 'the page shows it', '--as', 'coordinator');+ box.git(p.repo, 'switch', '-q', 'main');+}++/**+ * One item's row in the list, or '' when the list does not show it.+ */+function itemRow(html, id) {+ return html.split('<li').find((row) => row.includes(`data-item="${id}"`)) ?? '';+}++/**+ * The board as the view serves it for one project.+ */+async function boardOf(view, root) {+ const res = await fetch(`${view.base}/api/state?root=${encodeURIComponent(root)}`, { headers: { 'x-pullboard-key': view.key } });+ return (await res.json()).project;+}++test('a sent-back item shows why first [N26]', async () => {+ const box = machine();+ const p = project(box, 'shop');+ box.run(p.repo, 'add', 'web', 'Greeting', '--specs', 'G1', '--criterion', 'greets by name', '--brief', 'Files: web/greeting.html');+ box.run(p.repo, 'add', 'web', 'Farewell', '--specs', 'G2', '--criterion', 'says goodbye', '--brief', 'Files: web/farewell.html');+ box.run(p.repo, 'add', 'web', 'Heading', '--specs', 'G1', '--criterion', 'has a heading', '--brief', 'Files: web/heading.html');+ build(box, p, 1, 'greeting.html');+ sendBack(box, p, 1, 'no <b>greeting</b> on the page\nsecond line of the note');+ build(box, p, 2, 'farewell.html');+ sendBack(box, p, 2, 'the farewell is missing');+ build(box, p, 2, 'farewell-again.html');+ build(box, p, 3, 'heading.html');+ sendBack(box, p, 3, 'no heading yet');+ build(box, p, 3, 'heading-again.html');+ accept(box, p, 3);+ const view = await startView(box);+ try {+ const page = await openPage(view);+ const needs = page.show('needs');+ assert.match(needs, /<code>#1<\/code><span>Greeting<\/span><em>sent back: BEHAVIOR_MISMATCH →<\/em>/);+ assert.match(needs, /<code>#2<\/code><span>Farewell<\/span><em>resubmitted after BEHAVIOR_MISMATCH, \w+ →<\/em>/);+ const row = itemRow(page.show('chain'), 1);+ assert.ok(row.includes('BEHAVIOR_MISMATCH: no <b>greeting</b> on the page'), row);+ assert.ok(!row.includes('second line'), 'the row shows the first line of the note only');+ assert.ok(itemRow(page.show('chain'), 2).includes('BEHAVIOR_MISMATCH: the farewell is missing'));++ await page.click({ item: '1', classes: 'row' });+ const detail = page.show('detail');+ const verdict = (await boardOf(view, p.repo)).items.find((item) => item.id === 1).verdict;+ const time = new Date(verdict.at).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hourCycle: 'h23' });+ const top = detail.slice(0, detail.indexOf('<h3>Criterion</h3>'));+ assert.ok(detail.indexOf('<h3>Criterion</h3>') > 0, 'the criterion is shown');+ assert.match(top, /<h3>Sent back<\/h3>/);+ assert.match(top, /<b>REJECT BEHAVIOR_MISMATCH<\/b>/);+ assert.match(top, new RegExp(`coordinator · (\\w+ \\d+ )?${time} · at ${verdict.commit.slice(0, 12)}`), 'who sent it back, when, and at which commit');+ assert.ok(top.includes('no <b>greeting</b> on the page\nsecond line of the note'), 'the full note, escaped, before the criterion');+ assert.ok(!detail.includes('<b>greeting</b>'), 'the note cannot inject markup');+ assert.ok(detail.indexOf('<h3>Criterion</h3>') < detail.indexOf('<h3>Spec rows it serves</h3>'));+ assert.ok(detail.indexOf('<h3>Spec rows it serves</h3>') < detail.indexOf('<h3>Brief</h3>'));+ assert.equal(detail.split('second line of the note').length, 2, 'the note is shown once');++ await page.click({ item: '2', classes: 'row' });+ assert.match(page.show('detail').slice(0, page.show('detail').indexOf('<h3>Criterion</h3>')), /<h3>Sent back, resubmitted<\/h3>[^]*the farewell is missing/);++ await page.click({ item: '3', classes: 'row' });+ const verified = page.show('detail');+ assert.doesNotMatch(verified, /Sent back/);+ assert.ok(verified.indexOf('<h3>Criterion</h3>') < verified.indexOf('<h3>Brief</h3>'));+ assert.ok(verified.indexOf('<h3>Brief</h3>') < verified.indexOf('<h3>Verdicts</h3>'), 'a verified item keeps its verdicts after the brief');+ assert.ok(verified.indexOf('<h3>Verdicts</h3>') < verified.indexOf('no heading yet'));+ assert.ok(verified.indexOf('no heading yet') < verified.indexOf('the page shows it'), 'every verdict, oldest first');+ } finally {+ await view.stop();+ }+});