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
fix(view): approve all stays on the board it was opened on [B26,N26]
Corey Olson2b5fe99b9eb9
diff --git a/src/cockpit.js b/src/cockpit.jsindex 38c94c68..7d1564a0 100644--- a/src/cockpit.js+++ b/src/cockpit.js@@ -1763,6 +1763,8 @@ function renderReleaseNotes(project) {/** Draw the board shown: the sidebar, then every tab's panes from the project's board. */function render() {+ // A refresh that moved the page to another board closes a confirmation opened on the last one.+ closeIfLeft();if (heldClickPointer !== null) { deferredClickRender = true; return; }deferredClickRender = false;const statsFocus = document.activeElement?.id === 'proof-stats-summary' ? document.activeElement.id : null;@@ -2226,6 +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);// The configured relay transport owns pairing fragments and removes their secrets itself.if (transportModule) {const pairing = new URLSearchParams((location.hash || '').slice(1));@@ -2605,27 +2609,61 @@ function askApproveAll(section) {const ids = data.project.spec.filter((row) => row.section === section && ['pending', 'draft'].includes(row.status) && !row.decision).map((row) => row.id);// Every row was decided after the last redraw; this one drops the stale control.if (!ids.length) { render(); return; }- view.approvingAll = { section, ids };+ // The confirmation belongs to the board it was opened on: its rows are that board's, and only that board records them.+ view.approvingAll = { root: view.root, section, ids };$('spec-approve-title').textContent = 'Approve all ' + ids.length + (ids.length === 1 ? ' undecided row in “' : ' undecided rows in “') + section + '”?';$('spec-approve-rows').textContent = 'Rows: ' + ids.join(', ');$('spec-approve-submit').textContent = 'Approve ' + ids.length + (ids.length === 1 ? ' row' : ' rows');- $('spec-approve-dialog').hidden = false;- $('spec-approve-submit').focus();+ openModal($('spec-approve-dialog'), $('spec-approve-submit'));}/*** Close the Approve all confirmation. Cancelled, focus returns to the section control that opened it; approved, to the- * list, since the section's control leaves once its rows are decided.+ * list, since the section's control leaves once its rows are decided. Closed because the page left its board, focus+ * stays where the person put it.*/-function closeApproveAll(approved = false) {+function closeApproveAll(approved = false, left = false) {const asked = view.approvingAll;view.approvingAll = null;- $('spec-approve-dialog').hidden = true;+ closeModal($('spec-approve-dialog'));+ if (left) return asked;const control = !approved && asked && [...$('spec-list').querySelectorAll('[data-section-approve]')].find((button) => button.dataset.sectionApprove === asked.section);(control || $('spec-list')).focus({ preventScroll: true });return asked;}+/** Close, recording nothing, a confirmation opened on another board than the one the page now shows. */+function closeIfLeft() {+ if (view.approvingAll && view.approvingAll.root !== view.root) closeApproveAll(false, true);+}++/**+ * Show a page dialog over an inert page: nothing behind it takes a click or focus while it is open, so the person+ * cannot act on the page, or switch the board, under a question the page is asking.+ */+function openModal(dialog, focus) {+ dialog.hidden = false;+ for (const element of document.body.children || []) if (element !== dialog && element.tagName !== 'SCRIPT') element.inert = true;+ focus.focus();+}++/** Hide a page dialog and give the page back its clicks and focus. */+function closeModal(dialog) {+ dialog.hidden = true;+ for (const element of document.body.children || []) element.inert = false;+}++/** Keep Tab and Shift+Tab cycling through an open page dialog's own controls. */+function trapFocus(event) {+ if (event.key !== 'Tab') return;+ const controls = [...event.currentTarget.querySelectorAll('button, input, select, textarea, a[href]')].filter((control) => !control.disabled && control.offsetParent !== null);+ if (!controls.length) return;+ event.preventDefault();+ const at = controls.indexOf(document.activeElement);+ const next = at < 0 ? (event.shiftKey ? controls.length - 1 : 0) : (at + (event.shiftKey ? controls.length - 1 : 1)) % controls.length;+ controls[next].focus();+}+/*** Record a Spec or Doctrine decision beside its row and retain the list's reading position (B26, N26). A Doctrine rule* goes to the board by its qualified id, doctrine:D1, as the command line names it (pullboard spec approve doctrine:D1).@@ -2755,6 +2793,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);const generation = ++switchGeneration;answer(null);view.root = root;@@ -2940,12 +2980,13 @@ $('spec-decline-form').addEventListener('submit', (event) => {decideRow(kind, 'spec-decline', { ids: id, reason }, anchor);});$('spec-approve-cancel').addEventListener('click', () => { closeApproveAll(); });-$('spec-approve-form').addEventListener('keydown', (event) => { if (event.key === 'Escape') { event.preventDefault(); closeApproveAll(); } });-// The rows the confirmation named are the rows approved; the decision's note beside them says what the board did.+$('spec-approve-form').addEventListener('keydown', (event) => { if (event.key === 'Escape') { event.preventDefault(); closeApproveAll(); } else trapFocus(event); });+// The rows the confirmation named are the rows approved, on the board it was opened on and only there; the decision's+// note beside them says what the board did.$('spec-approve-form').addEventListener('submit', (event) => {event.preventDefault();const asked = closeApproveAll(true);- if (asked) decideRow('spec', 'spec-approve', { ids: asked.ids.join(' ') });+ if (asked && asked.root === view.root) decideRow('spec', 'spec-approve', { ids: asked.ids.join(' ') });});$('answer-cancel').addEventListener('click', () => answer(null));$('flow-hide').addEventListener('click', () => showFlow(false));diff --git a/test/cockpit/spec.test.js b/test/cockpit/spec.test.jsindex 2363fed3..46a33d0d 100644--- a/test/cockpit/spec.test.js+++ b/test/cockpit/spec.test.js@@ -573,6 +573,93 @@ test('approve all records its rows without the browser confirm dialog [B26,N26]'}});+// #612: the in-page confirmation (#581) replaced window.confirm, which blocked the page. Opened on one board, it must+// never record on another: the page behind it is inert, Tab stays inside it, and leaving the board closes it.+test('approve all 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 Approve all 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, 'approve-alpha', spec);+ const beta = project(box, 'approve-beta', spec);+ const view = await startView(box);+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-spec-approve-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-approve-dialog').hidden";+ const goals = "[...document.querySelectorAll('#spec-list [data-section-approve]')].find(e => e.parentElement.querySelector('h4')?.textContent.includes('Goals'))";+ 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(`!!(${goals})`);+ const untouched = { alpha: await decided(alpha), beta: await decided(beta) };+ assert.ok(!untouched.beta.includes('approved'), `board B starts with no approval: ${untouched.beta}`);+ await press(chrome, goals);+ await chrome.waitFor(open);++ // Tab and Shift+Tab try to leave the confirmation 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-approve-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 confirmation still open on board B is pressed, as a person would press it.+ if (left.open && left.root === beta.repo) {+ await press(chrome, "document.querySelector('#spec-approve-submit')");+ await chrome.waitFor("!!document.querySelector('#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 approved: ${JSON.stringify({ left, stops })}`);+ assert.ok(stops.every((stop) => stop.inside), `Tab and Shift+Tab stay inside the confirmation: ${JSON.stringify(stops)}`);+ assert.deepEqual([left.root, left.open, left.inertBehind], [alpha.repo, true, true], 'board B is unreachable while the confirmation is open, and the page behind it is inert');++ // A switch the confirmation 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.approvingAll === null && data?.project?.root === ${JSON.stringify(beta.repo)} && !document.querySelector('.shell').inert`);+ await chrome.stable("document.querySelector('#spec-approve-form').requestSubmit()");+ // Back to board A, then Back in history while the confirmation is open: it closes again.+ await chrome.stable(`switchTo(${JSON.stringify(alpha.repo)})`);+ await chrome.waitFor(`data?.project?.root === ${JSON.stringify(alpha.repo)} && !!(${goals})`);+ await press(chrome, goals);+ await chrome.waitFor(open);+ await chrome.stable('history.back()');+ await chrome.waitFor(`!(${open}) && view.approvingAll === null`);+ assert.deepEqual([await decided(alpha), await decided(beta)], [untouched.alpha, untouched.beta], 'leaving the board records nothing on either board');++ // Opened and approved on board A, it records on board A only.+ await chrome.stable(`switchTo(${JSON.stringify(alpha.repo)})`);+ await chrome.waitFor(`data?.project?.root === ${JSON.stringify(alpha.repo)} && !!(${goals})`);+ await press(chrome, goals);+ await chrome.waitFor(open);+ await press(chrome, "document.querySelector('#spec-approve-submit')");+ await chrome.waitFor("!!document.querySelector('#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 state = await boardOf(view, alpha.repo);+ assert.deepEqual(['G1', 'G2'].map((id) => state.spec.find((row) => row.id === id)?.stage), ['approved, pending apply', 'approved, pending apply'], 'board A records the rows its confirmation named');+ 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.');