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): show sent-back reason once [N26]

Corey Olson888301ebc77a
diff --git a/src/cockpit.js b/src/cockpit.js
index 952594dc..2567e98a 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -240,6 +240,13 @@ const dayRules = (rows, at, row) => rows.map((x, i) => {
return (day === before ? '' : '<div class="day-rule" role="separator"><span>' + dayName(at(x)) + '</span></div>') + row(x);
}).join('');
const firstLine = (text) => String(text ?? '').split('\\n').map((line) => line.trim()).find(Boolean) || '';
+/** Omit a duplicated leading verdict code from rendered copy while preserving the recorded note. */
+function visibleVerdictNote(reason, note) {
+ const text = String(note ?? '');
+ const code = String(reason ?? '');
+ const remainder = text.slice(code.length);
+ return code && text.startsWith(code) && (!remainder || /^\\s/u.test(remainder)) ? remainder.trimStart() : text;
+}
// 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';
@@ -259,7 +266,7 @@ function shoutAgentName(id) {
return '<span class="agent-label' + (prefix ? ' prefix' : '') + '" title="' + esc(name) + '" role="group" aria-label="' + esc(name) + '">' + (prefix ? label + address : address + label) + '</span>';
}
/** Render a review note with escaped text and references bound to the selected board. */
-const verdictHtml = (v, titles) => '<div class="verdict ' + (v.decision === 'ACCEPT' ? 'yes' : 'no') + '"><b>' + esc(v.decision) + ' ' + esc(v.reason) + '</b><span class="by">' + esc(agentName(v.by)) + ' · ' + when(v.at) + ' · at ' + esc(String(v.commit || '').slice(0, 12)) + '</span><div class="note">' + linked(v.note, titles) + '</div></div>';
+const verdictHtml = (v, titles) => '<div class="verdict ' + (v.decision === 'ACCEPT' ? 'yes' : 'no') + '"><b>' + esc(v.decision) + ' ' + esc(v.reason) + '</b><span class="by">' + esc(agentName(v.by)) + ' · ' + when(v.at) + ' · at ' + esc(String(v.commit || '').slice(0, 12)) + '</span><div class="note">' + linked(visibleVerdictNote(v.reason, v.note), titles) + '</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: ['unclaimed', 'free'], withdrawn: ['withdrawn', ''] };
const chip = (s) => '<span class="chip ' + STATES[s][1] + '">' + STATES[s][0] + '</span>';
@@ -1354,7 +1361,7 @@ function render() {
: s === 'open' ? openChip(i) : chip(s);
return '<li class="row s-' + s + (view.item === i.id ? ' on' : '') + (gated ? ' gated' : '') + '" data-item="' + i.id + '" title="' + esc(i.title) + '"><span class="dot ' + s + '"></span><div><div class="t"><span>#' + i.id + '</span>' + rich(i.title, titles) + '</div><span class="row-age">' + age(i.updatedAt) + '</span><div class="meta">'
// A rejected row's second line is its verdict; any other row's is its lane and the spec ids it serves.
- + (rejected(i) ? '<span class="why"><b>' + esc(i.verdict.reason) + '</b> ' + linked(firstLine(i.verdict.note), titles) + '</span>'
+ + (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 + '</div></div>' + tag + '</li>';
}).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>';
diff --git a/test/cockpit/items.test.js b/test/cockpit/items.test.js
index d8b14e6f..fda646d4 100644
--- a/test/cockpit/items.test.js
+++ b/test/cockpit/items.test.js
@@ -249,6 +249,61 @@ test('a sent-back item shows why first [N26]', async () => {
}
});
+test('a sent-back reason reads once [N26]', { timeout: 90_000 }, async () => {
+ const executable = chromeExecutable();
+ assert.ok(executable, 'Chrome is required for sent-back reason rendering checks');
+
+ const box = machine();
+ const alpha = project(box, 'sent-back-reason');
+ for (const title of ['Duplicate reason', 'Plain note']) {
+ box.run(alpha.repo, 'add', 'web', title, '--specs', 'G1', '--criterion', 'the sent-back note reads clearly');
+ }
+ const notes = [
+ 'BEHAVIOR_MISMATCH a78c361: selected-lane exception is unclear',
+ 'BEHAVIOR_MISMATCHED is a separate code-like prefix: the issue remains',
+ ];
+ build(box, alpha, 1, 'duplicate.html');
+ sendBack(box, alpha, 1, notes[0]);
+ build(box, alpha, 2, 'plain.html');
+ sendBack(box, alpha, 2, notes[1]);
+
+ const view = await startView(box);
+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-sent-back-reason-chrome-'));
+ let chrome;
+ try {
+ chrome = await openSnapshotChrome(executable, view.link.href, profile);
+ await chrome.waitFor('document.querySelectorAll("#chain .row").length === 2');
+ for (const width of [375, 1280]) {
+ await chrome.send('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false });
+ await chrome.waitFor(`innerWidth === ${width} && document.querySelector('#chain .row[data-item="1"] .why')`);
+ for (const [id, title, expectedRow, expectedCard] of [
+ ['1', 'Duplicate reason', 'BEHAVIOR_MISMATCH a78c361: selected-lane exception is unclear', 'a78c361: selected-lane exception is unclear'],
+ ['2', 'Plain note', 'BEHAVIOR_MISMATCH BEHAVIOR_MISMATCHED is a separate code-like prefix: the issue remains', 'BEHAVIOR_MISMATCHED is a separate code-like prefix: the issue remains'],
+ ]) {
+ await chrome.evaluate(`document.querySelector('#chain .row[data-item="${id}"]').click()`);
+ await chrome.waitFor(`document.querySelector('#detail h2')?.textContent.includes('${title}')`);
+ const rendered = JSON.parse(await chrome.evaluate(`JSON.stringify({
+ row: document.querySelector('#chain .row[data-item="${id}"] .why')?.textContent,
+ card: document.querySelector('#detail .sentback .verdict .note')?.textContent,
+ reason: document.querySelector('#detail .sentback .verdict b')?.textContent,
+ })`));
+ assert.equal(rendered.row, expectedRow, `${width}px item #${id}: the row shows the reason code once`);
+ assert.equal(rendered.card, expectedCard, `${width}px item #${id}: the card removes only a duplicated leading code`);
+ assert.equal(rendered.reason, 'REJECT BEHAVIOR_MISMATCH', `${width}px item #${id}: the card retains its verdict heading`);
+ }
+ }
+ const storedItems = (await boardOf(view, alpha.repo)).items;
+ for (const [index, id] of [1, 2].entries()) {
+ assert.equal(storedItems.find((item) => item.id === id).verdict.note, notes[index],
+ `rendering leaves item #${id}'s stored verdict unchanged`);
+ }
+ } finally {
+ if (chrome) await closeSnapshotChrome(chrome);
+ await view.stop();
+ rmSync(profile, { recursive: true, force: true });
+ }
+});
+
test('the list shows active, verified or all [N26]', async () => {
const box = machine();
const lanes = { web: { owns: ['web/'], specs: ['G'] }, api: { owns: ['api/'], specs: ['G'] } };