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.

fix(view): a withdrawn item sent back still opens with why [N26]

Corey Olson9b1a78e29bf4
diff --git a/src/cockpit.js b/src/cockpit.js
index 2fda8f28..0f33c86e 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -265,8 +265,9 @@ const ago = (iso) => { const m = Math.round((Date.now() - Date.parse(iso)) / 600
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';
+// The latest verdict is a reject and no accept followed: open again, being reworked, resubmitted, or
+// withdrawn after it.
+const rejected = (i) => i.status !== 'verified' && !!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', ''] };
@@ -372,7 +373,7 @@ function render() {
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>' : '')
+ + (back ? '<div class="sentback"><h3>Sent back' + (s === 'building' ? ', being reworked' : s === 'verify' ? ', resubmitted' : s === 'withdrawn' ? ', then withdrawn' : '') + '</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>' : '')
diff --git a/test/cockpit.test.js b/test/cockpit.test.js
index c2669e6f..fd95eea6 100644
--- a/test/cockpit.test.js
+++ b/test/cockpit.test.js
@@ -346,9 +346,19 @@ test('a sent-back item shows why first [N26]', async () => {
sendBack(box, p, 3, 'no heading yet');
build(box, p, 3, 'heading-again.html');
accept(box, p, 3);
+ // Two more ways to be sent back and not verified: withdrawn after the reject, and being reworked.
+ box.run(p.repo, 'add', 'web', 'Banner', '--specs', 'G1', '--criterion', 'shows a banner', '--brief', 'Files: web/banner.html');
+ box.run(p.repo, 'add', 'web', 'Footer', '--specs', 'G1', '--criterion', 'shows a footer', '--brief', 'Files: web/footer.html');
+ build(box, p, 4, 'banner.html');
+ sendBack(box, p, 4, 'the banner covers the heading');
+ box.run(p.repo, 'withdraw', '4', 'the banner is dropped');
+ build(box, p, 5, 'footer.html');
+ sendBack(box, p, 5, 'the footer is empty');
+ box.run(p.web, 'claim', '5');
const view = await startView(box);
try {
const page = await openPage(view);
+ const beforeCriterion = () => page.show('detail').slice(0, Math.max(0, page.show('detail').indexOf('<h3>Criterion</h3>')));
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>/);
@@ -373,7 +383,18 @@ test('a sent-back item shows why first [N26]', async () => {
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/);
+ assert.match(beforeCriterion(), /<h3>Sent back, resubmitted<\/h3>[^]*the farewell is missing/);
+
+ assert.ok(itemRow(page.show('chain'), 5).includes('BEHAVIOR_MISMATCH: the footer is empty'), 'a row being reworked still says why');
+ await page.click({ item: '5', classes: 'row' });
+ assert.match(beforeCriterion(), /<h3>Sent back, being reworked<\/h3>[^]*<b>REJECT BEHAVIOR_MISMATCH<\/b>[^]*the footer is empty/);
+
+ // A withdrawn item has no row; the person reaches it from a spec row or the activity feed.
+ assert.equal(itemRow(page.show('chain'), 4), '');
+ await page.click({ go: 'item:4' });
+ assert.match(page.show('detail'), /<h2><span>#4<\/span>Banner<\/h2>/);
+ assert.match(beforeCriterion(), /<h3>Sent back, then withdrawn<\/h3>[^]*<b>REJECT BEHAVIOR_MISMATCH<\/b>[^]*the banner covers the heading/, 'withdrawn after a reject, it still opens with why');
+ assert.ok(page.show('detail').indexOf('<h3>Criterion</h3>') < page.show('detail').indexOf('<h3>Brief</h3>'));
await page.click({ item: '3', classes: 'row' });
const verified = page.show('detail');