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 decline stays on the board it was opened on [B26,N26]

Corey Olson492373b17a6e
diff --git a/src/cockpit.js b/src/cockpit.js
index 7d1564a0..cb52cbbd 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -2228,8 +2228,8 @@ function applyPlace(place, kept = null) {
/** Restore the address on Back and Forward, with a scoped refresh when the repo changes. */
function fromAddress(event) {
if (!data) return;
- // Back and Forward close the Approve all confirmation without recording, wherever they lead.
- if (view.approvingAll) closeApproveAll(false, true);
+ // Back and Forward close Approve all's confirmation and the decline dialog without recording, wherever they lead.
+ leaveDialogs();
// The configured relay transport owns pairing fragments and removes their secrets itself.
if (transportModule) {
const pairing = new URLSearchParams((location.hash || '').slice(1));
@@ -2595,10 +2595,23 @@ function askDecline(kind, id, from) {
view.declining = id;
view.declineKind = kind;
view.declineFrom = from;
+ // The dialog belongs to the board it was opened on, as Approve all's confirmation does (#612).
+ view.declineRoot = view.root;
$('spec-decline-title').textContent = 'Decline ' + id;
$('spec-decline-reason').value = '';
- $('spec-decline-dialog').hidden = false;
- $('spec-decline-reason').focus();
+ openModal($('spec-decline-dialog'), $('spec-decline-reason'));
+}
+
+/**
+ * Close the decline dialog and return what it asked about. Closed by the person, focus returns to the list it was asked
+ * from; closed because the page left its board, focus stays where the person put it.
+ */
+function closeDecline(left = false) {
+ const asked = view.declining ? { id: view.declining, kind: view.declineKind, root: view.declineRoot, from: view.declineFrom } : null;
+ view.declining = null;
+ closeModal($('spec-decline-dialog'));
+ if (!left && asked?.from === 'list') $(asked.kind + '-list').focus({ preventScroll: true });
+ return asked;
}
/**
@@ -2632,9 +2645,16 @@ function closeApproveAll(approved = false, left = false) {
return asked;
}
-/** Close, recording nothing, a confirmation opened on another board than the one the page now shows. */
+/** Close, recording nothing, a confirmation or decline opened on another board than the one the page now shows. */
function closeIfLeft() {
if (view.approvingAll && view.approvingAll.root !== view.root) closeApproveAll(false, true);
+ if (view.declining && view.declineRoot !== view.root) closeDecline(true);
+}
+
+/** Close every dialog bound to a board, recording nothing: the page is leaving the board it was asked on. */
+function leaveDialogs() {
+ if (view.approvingAll) closeApproveAll(false, true);
+ if (view.declining) closeDecline(true);
}
/**
@@ -2793,8 +2813,8 @@ function fold(open) {
/** Show another project and its item; history restores keep the tab their entry named. */
function switchTo(root, target = null, record = true) {
- // Switching board or project closes the Approve all confirmation; it records nothing on either board.
- if (view.approvingAll) closeApproveAll(false, true);
+ // Switching board or project closes Approve all's confirmation and the decline dialog; neither records on either board.
+ leaveDialogs();
const generation = ++switchGeneration;
answer(null);
view.root = root;
@@ -2967,17 +2987,17 @@ $('upgrade-note').addEventListener('click', (event) => {
renderReleaseNotes(data.project);
});
$('add-cancel').addEventListener('click', () => { view.adding = false; render(); });
-$('spec-decline-cancel').addEventListener('click', () => { view.declining = null; $('spec-decline-dialog').hidden = true; if (view.declineFrom === 'list') $(view.declineKind + '-list').focus({ preventScroll: true }); });
+$('spec-decline-cancel').addEventListener('click', () => { closeDecline(); });
+$('spec-decline-form').addEventListener('keydown', trapFocus);
+// The row the dialog named is declined, with its reason, on the board it was opened on and only there.
$('spec-decline-form').addEventListener('submit', (event) => {
event.preventDefault();
- const id = view.declining, kind = view.declineKind;
const reason = $('spec-decline-reason').value.trim();
- if (!id || !reason) return;
- view.declining = null;
- $('spec-decline-dialog').hidden = true;
- if (view.declineFrom === 'list') $(kind + '-list').focus({ preventScroll: true });
- const anchor = view.declineFrom === 'detail' ? $(kind + '-detail') : [...$(kind + '-list').querySelectorAll('[data-row]')].find((row) => row.dataset.row === kind + ':' + id);
- decideRow(kind, 'spec-decline', { ids: id, reason }, anchor);
+ if (!view.declining || !reason) return;
+ const asked = closeDecline();
+ if (asked.root !== view.root) return;
+ const anchor = asked.from === 'detail' ? $(asked.kind + '-detail') : [...$(asked.kind + '-list').querySelectorAll('[data-row]')].find((row) => row.dataset.row === asked.kind + ':' + asked.id);
+ decideRow(asked.kind, 'spec-decline', { ids: asked.id, reason }, anchor);
});
$('spec-approve-cancel').addEventListener('click', () => { closeApproveAll(); });
$('spec-approve-form').addEventListener('keydown', (event) => { if (event.key === 'Escape') { event.preventDefault(); closeApproveAll(); } else trapFocus(event); });
diff --git a/test/cockpit/spec.test.js b/test/cockpit/spec.test.js
index 46a33d0d..461aa5a7 100644
--- a/test/cockpit/spec.test.js
+++ b/test/cockpit/spec.test.js
@@ -660,6 +660,98 @@ test('approve all stays on the board it was opened on [B26,N26]', { timeout: 150
}
});
+// #616: the decline-with-reason dialog has the same reach as Approve all's confirmation (#612). Opened on one board, it
+// must never record the person's decline on another: the page behind it is inert, Tab stays inside it, and leaving the
+// board closes it.
+test('a decline stays on the board it was opened on [B26,N26]', { timeout: 150_000 }, async () => { // budget: hang-only ceiling for Chrome startup, two boards and their recorded decisions.
+ const executable = chromeExecutable();
+ assert.ok(executable, 'the decline board check needs real Chrome');
+ const spec = '# Same rows\n\n## G · Goals\n- G1 [draft, must] First goal. | gate: web test\n- G2 [draft, must] Second goal. | gate: web test\n';
+ const box = machine();
+ const alpha = project(box, 'decline-alpha', spec);
+ const beta = project(box, 'decline-beta', spec);
+ const view = await startView(box);
+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-spec-decline-board-'));
+ let chrome;
+ /** Each board's G rows as the API reports them: status, stage and any decision. */
+ const decided = async (board) => JSON.stringify((await boardOf(view, board.repo)).spec.filter((row) => row.id.startsWith('G')).map((row) => [row.id, row.status, row.stage ?? null, row.decision ?? null]));
+ /** One real key press, as Chrome's own keyboard delivers it; Enter carries its text, so it activates a button. */
+ const key = async (name, code, keyCode, modifiers = 0) => {
+ await chrome.send('Input.dispatchKeyEvent', { type: 'keyDown', key: name, code, windowsVirtualKeyCode: keyCode, modifiers, ...(name === 'Enter' ? { text: '\r' } : {}) });
+ await chrome.send('Input.dispatchKeyEvent', { type: 'keyUp', key: name, code, windowsVirtualKeyCode: keyCode, modifiers });
+ };
+ const open = "!document.querySelector('#spec-decline-dialog').hidden";
+ /** Open the decline dialog for G1 on the board shown, with a reason typed as the person types it. */
+ const askG1 = async () => {
+ await press(chrome, "document.querySelector('#spec-list [data-row=\"spec:G1\"]')");
+ await chrome.waitFor("!!document.querySelector('#spec-detail [data-row-decision=\"decline\"]')");
+ await press(chrome, "document.querySelector('#spec-detail [data-row-decision=\"decline\"]')");
+ await chrome.waitFor(`${open} && document.activeElement?.id === 'spec-decline-reason'`);
+ await chrome.send('Input.insertText', { text: 'needs a clearer outcome' });
+ };
+ try {
+ chrome = await openSnapshotChrome(executable, view.link.href, profile);
+ await chrome.send('Emulation.setDeviceMetricsOverride', { width: 1280, height: 900, deviceScaleFactor: 1, mobile: false });
+ await chrome.waitFor(`typeof data === 'object' && data?.project?.root === ${JSON.stringify(alpha.repo)} && !!document.querySelector('#proj-list [data-root=${JSON.stringify(beta.repo)}]')`);
+ await chrome.click("document.querySelector('[data-tab=spec]')");
+ await chrome.waitFor("!!document.querySelector('#spec-list [data-row=\"spec:G1\"]')");
+ const untouched = { alpha: await decided(alpha), beta: await decided(beta) };
+ assert.ok(!untouched.beta.includes('declined'), `board B starts with no decline: ${untouched.beta}`);
+ await askG1();
+
+ // Tab and Shift+Tab try to leave the dialog for the project list, and to switch to board B with Enter.
+ const stops = [];
+ for (let step = 0; step < 40; step++) {
+ await key('Tab', 'Tab', 9, step % 5 === 4 ? 8 : 0);
+ const at = JSON.parse(await chrome.stable("JSON.stringify({ inside: !!document.activeElement?.closest('#spec-decline-dialog'), root: document.activeElement?.dataset?.root ?? null })"));
+ stops.push(at);
+ if (at.root === beta.repo) {
+ await key('Enter', 'Enter', 13);
+ await chrome.waitFor(`view.root === ${JSON.stringify(beta.repo)} && data?.project?.root === ${JSON.stringify(beta.repo)}`);
+ break;
+ }
+ }
+ const left = JSON.parse(await chrome.stable(`JSON.stringify({ root: view.root, open: ${open}, inertBehind: !!document.querySelector('.shell')?.inert })`));
+ // Whatever the keys reached, a dialog still open on board B is submitted, as a person would submit it.
+ if (left.open && left.root === beta.repo) {
+ await press(chrome, "document.querySelector('#spec-decline-submit')");
+ await chrome.waitFor("!!document.querySelector('#spec-detail .spec-feedback,#spec-list .spec-feedback')", 15_000); // budget: hang ceiling for a recorded decision's note; no throughput claim.
+ }
+ assert.equal(await decided(beta), untouched.beta, `no row on board B is ever declined: ${JSON.stringify({ left, stops })}`);
+ assert.ok(stops.every((stop) => stop.inside), `Tab and Shift+Tab stay inside the dialog: ${JSON.stringify(stops)}`);
+ assert.deepEqual([left.root, left.open, left.inertBehind], [alpha.repo, true, true], 'board B is unreachable while the dialog is open, and the page behind it is inert');
+
+ // A switch the dialog does not see, such as a link, closes it and records nothing on either board.
+ await chrome.stable(`switchTo(${JSON.stringify(beta.repo)})`);
+ await chrome.waitFor(`!(${open}) && !view.declining && data?.project?.root === ${JSON.stringify(beta.repo)} && !document.querySelector('.shell').inert`);
+ await chrome.stable("document.querySelector('#spec-decline-reason').value = 'still typed'; document.querySelector('#spec-decline-form').requestSubmit()");
+ // Back to board A, then Back in history while the dialog is open: it closes again.
+ await chrome.stable(`switchTo(${JSON.stringify(alpha.repo)})`);
+ await chrome.waitFor(`data?.project?.root === ${JSON.stringify(alpha.repo)} && !!document.querySelector('#spec-list [data-row="spec:G1"]')`);
+ await askG1();
+ await chrome.stable('history.back()');
+ await chrome.waitFor(`!(${open}) && !view.declining`);
+ assert.deepEqual([await decided(alpha), await decided(beta)], [untouched.alpha, untouched.beta], 'leaving the board records nothing on either board');
+
+ // Opened and submitted on board A, it declines G1 on board A only, with its reason.
+ await chrome.stable(`switchTo(${JSON.stringify(alpha.repo)})`);
+ await chrome.waitFor(`data?.project?.root === ${JSON.stringify(alpha.repo)} && !!document.querySelector('#spec-list [data-row="spec:G1"]')`);
+ await askG1();
+ await press(chrome, "document.querySelector('#spec-decline-submit')");
+ await chrome.waitFor("!!document.querySelector('#spec-detail .spec-feedback.ok,#spec-detail .spec-feedback.no,#spec-list .spec-feedback.ok,#spec-list .spec-feedback.no')", 15_000); // budget: hang ceiling for the recorded decision and its note; no throughput claim.
+ const g1 = (await boardOf(view, alpha.repo)).spec.find((row) => row.id === 'G1');
+ assert.deepEqual([g1?.decision?.decision, g1?.decision?.reason], ['decline', 'needs a clearer outcome'], 'board A records the decline and its reason');
+ assert.equal(await decided(beta), untouched.beta, 'and board B still has none');
+ assert.deepEqual(chrome.exceptions, [], 'Chrome reports no uncaught exceptions');
+ } finally {
+ try { if (chrome) await closeSnapshotChrome(chrome); }
+ finally {
+ try { await view.stop(); }
+ finally { rmSync(profile, { recursive: true, force: true }); }
+ }
+ }
+});
+
test('the spec decision wait names its state on timeout [N26]', { timeout: 60_000 }, async (t) => {
const executable = chromeExecutable();
if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for Spec wait diagnostics.');