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 asks in the page, never window.confirm [B26,N26]
Corey Olson17f246c83dc7
diff --git a/src/cockpit.js b/src/cockpit.jsindex 994cbf91..2e84e231 100644--- a/src/cockpit.js+++ b/src/cockpit.js@@ -163,6 +163,13 @@ export function cockpitPage(key = '', { snapshot = false, readOnly = false, requ<div class="actions"><button class="go" id="spec-decline-submit" type="submit">Decline row</button><button class="ghost" id="spec-decline-cancel" type="button">Cancel</button></div></form></div>+<div class="spec-reason-backdrop" id="spec-approve-dialog" hidden>+ <form class="spec-reason-dialog" id="spec-approve-form" aria-labelledby="spec-approve-title">+ <h2 id="spec-approve-title">Approve rows</h2>+ <div class="muted" id="spec-approve-rows"></div>+ <div class="actions"><button class="go" id="spec-approve-submit" type="submit">Approve rows</button><button class="ghost" id="spec-approve-cancel" type="button">Cancel</button></div>+ </form>+</div><div class="console" id="console" title="Click to close" hidden></div><script>const snapshot = ${JSON.stringify(snapshot)};@@ -2364,6 +2371,35 @@ function askDecline(kind, id, from) {$('spec-decline-reason').focus();}+/**+ * Ask in the page before one press approves every undecided row of a Spec section (B26, N26). The browser's own confirm+ * dialog can be dismissed or never shown, and then the press recorded nothing and said nothing; this one is the page's.+ */+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 };+ $('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();+}++/**+ * 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.+ */+function closeApproveAll(approved = false) {+ const asked = view.approvingAll;+ view.approvingAll = null;+ $('spec-approve-dialog').hidden = true;+ 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;+}+/*** 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).@@ -2597,11 +2633,7 @@ document.addEventListener('click', (event) => {if (t.dataset.rowDecision === 'approve') decideRow(kind, 'spec-approve', { ids: id }, t);else askDecline(kind, id, t.closest('#' + kind + '-detail') ? 'detail' : 'list');}- else if (t.dataset.sectionApprove) {- const section = t.dataset.sectionApprove;- const ids = data.project.spec.filter((row) => row.section === section && ['pending', 'draft'].includes(row.status) && !row.decision).map((row) => row.id);- if (ids.length && window.confirm('Approve all ' + ids.length + ' undecided rows in “' + section + '”?')) decideRow('spec', 'spec-approve', { ids: ids.join(' ') }, t);- }+ else if (t.dataset.sectionApprove) askApproveAll(t.dataset.sectionApprove);else if (t.dataset.shoutId && !event.target.closest('button,a,input,textarea,select')) { go('shout:' + t.dataset.shoutId); }else if (t.dataset.row) {const [kind, id] = t.dataset.row.split(':');@@ -2681,6 +2713,14 @@ $('spec-decline-form').addEventListener('submit', (event) => {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);});+$('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('submit', (event) => {+ event.preventDefault();+ const asked = closeApproveAll(true);+ if (asked) decideRow('spec', 'spec-approve', { ids: asked.ids.join(' ') });+});$('answer-cancel').addEventListener('click', () => answer(null));$('flow-hide').addEventListener('click', () => showFlow(false));$('flow-show').addEventListener('click', () => showFlow(true));diff --git a/test/cockpit/spec.test.js b/test/cockpit/spec.test.jsindex 4f3786ff..2363fed3 100644--- a/test/cockpit/spec.test.js+++ b/test/cockpit/spec.test.js@@ -476,17 +476,23 @@ test('real Chrome records Spec row decisions from the row, detail and confirmedawait diagnosticClick(chrome, '#spec-decline-submit', width, 'decline submit');await chrome.waitFor("!!document.querySelector('#spec-detail .spec-feedback.ok,#spec-detail .spec-feedback.no')");- await chrome.stable("window.__sectionConfirm = null; window.confirm = message => { window.__sectionConfirm = message; return false; }");+ await chrome.stable("window.__confirmCalls = 0; window.confirm = () => { window.__confirmCalls += 1; return false; }");const sectionSelector = `#spec-list [data-section-approve]`;- await chrome.click(`[...document.querySelectorAll(${JSON.stringify(sectionSelector)})].find(e=>e.parentElement.querySelector('h4')?.textContent.includes('Follow-up'))`);+ const followUp = `[...document.querySelectorAll(${JSON.stringify(sectionSelector)})].find(e=>e.parentElement.querySelector('h4')?.textContent.includes('Follow-up'))`;+ await chrome.click(followUp);+ await chrome.waitFor("!document.querySelector('#spec-approve-dialog').hidden");+ assert.match(await chrome.stable("document.querySelector('#spec-approve-title').textContent"), /Approve all 2 undecided rows in/, `${width}: section approval asks for confirmation in the page`);+ assert.ok(await chrome.stable(`[...document.querySelectorAll('#spec-approve-dialog button')].every(e => e.getBoundingClientRect().height >= ${tapTarget(width)})`), `${width}: the Approve all confirmation's controls meet the 44px target`);+ await click(chrome, '#spec-approve-cancel');+ await chrome.waitFor("document.querySelector('#spec-approve-dialog').hidden");state = await boardOf(view, demo.repo);- assert.match(await chrome.stable('window.__sectionConfirm'), /Approve all 2 undecided rows in/, `${width}: section approval asks for confirmation`);- assert.equal(await chrome.stable("!!document.querySelector('#spec-list .spec-feedback')"), false, `${width}: dismissing the confirmation starts no move`);- assert.equal(state.events.filter((event) => event.event_kind === 'row_decision').length, 2, `${width}: dismissing section confirmation records no events`);- assert.equal(state.spec.find((row) => row.id === 'K1')?.decision, undefined, `${width}: dismissed section approval leaves K1 undecided`);+ assert.equal(await chrome.stable("!!document.querySelector('#spec-list .spec-feedback')"), false, `${width}: cancelling the confirmation starts no move`);+ assert.equal(state.events.filter((event) => event.event_kind === 'row_decision').length, 2, `${width}: cancelling section confirmation records no events`);+ assert.equal(state.spec.find((row) => row.id === 'K1')?.decision, undefined, `${width}: cancelled section approval leaves K1 undecided`);- await chrome.stable("window.confirm = () => true");- await chrome.click(`[...document.querySelectorAll(${JSON.stringify(sectionSelector)})].find(e=>e.parentElement.querySelector('h4')?.textContent.includes('Follow-up'))`);+ await chrome.click(followUp);+ await chrome.waitFor("!document.querySelector('#spec-approve-dialog').hidden");+ await click(chrome, '#spec-approve-submit');await chrome.waitFor("document.querySelector('#spec-list [data-row=\"spec:K1\"]').innerText.includes('approved, pending apply') && document.querySelector('#spec-list [data-row=\"spec:K2\"]').innerText.includes('approved, pending apply')");state = await boardOf(view, demo.repo);const decisions = state.events.filter((event) => event.event_kind === 'row_decision');@@ -508,6 +514,7 @@ test('real Chrome records Spec row decisions from the row, detail and confirmedawait chrome.click("document.querySelector('#spec-chips [data-rows=\"spec:decide\"]')");await chrome.waitFor("document.querySelector('#spec-list [data-row=\"spec:G3\"]') && !document.querySelector('#spec-list [data-row=\"spec:G1\"]') && !document.querySelector('#spec-list [data-row=\"spec:G2\"]') && !document.querySelector('#spec-list [data-row=\"spec:K1\"]') && !document.querySelector('#spec-list [data-row=\"spec:K2\"]')");assert.ok(await chrome.stable("document.querySelector('#spec-chips [data-rows=\"spec:decide\"]').innerText.includes('27')"), `${width}: Needs your decision excludes all four decided rows`);+ assert.equal(await chrome.stable('window.__confirmCalls'), 0, `${width}: Approve all never asks the browser's confirm dialog`);assert.deepEqual(chrome.exceptions, [], `${width}: Chrome reports no uncaught exceptions`);} finally {try { await diagnostics?.dispose(); }@@ -525,6 +532,47 @@ test('real Chrome records Spec row decisions from the row, detail and confirmedawait runWidth(1280);});+test('approve all records its rows without the browser confirm dialog [B26,N26]', { timeout: 120_000 }, async () => { // budget: hang-only ceiling for Chrome startup, one in-page confirmation and the recorded decisions.+ const executable = chromeExecutable();+ assert.ok(executable, 'the Approve all check needs real Chrome');+ const spec = '# Approve all\n\n## G · Goals\n- G1 [draft, must] First goal. | gate: web test\n- G2 [draft, must] Second goal. | gate: web test\n- G3 [draft, must] Third goal. | gate: web test\n\n## K · Follow-up\n- K1 [draft, must] Follow-up one. | gate: web test\n';+ const box = machine();+ const demo = project(box, 'spec-approve-all', spec);+ const view = await startView(box);+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-spec-approve-all-'));+ let chrome;+ try {+ chrome = await openSnapshotChrome(executable, view.link.href, profile);+ await chrome.waitFor("typeof data === 'object' && !!data?.project");+ await chrome.send('Emulation.setDeviceMetricsOverride', { width: 1280, height: 900, deviceScaleFactor: 1, mobile: false });+ await chrome.click("document.querySelector('[data-tab=spec]')");+ await chrome.waitFor("!!document.querySelector('#spec-list [data-row=\"spec:G3\"]') && !!document.querySelector('#spec-list [data-section-approve]')");+ // A dismissed or blocked browser dialog answers false; the press must not depend on it.+ await chrome.stable("window.__confirmCalls = 0; window.confirm = () => { window.__confirmCalls += 1; return false; }");+ await press(chrome, "[...document.querySelectorAll('#spec-list [data-section-approve]')].find(e => e.parentElement.querySelector('h4')?.textContent.includes('Goals'))");+ await chrome.waitFor("!document.querySelector('#spec-approve-dialog').hidden");+ assert.match(await chrome.stable("document.querySelector('#spec-approve-title').textContent"), /^Approve all 3 undecided rows in “.*Goals”\?$/u, 'the page asks about the section and its count itself');+ assert.equal(await chrome.stable("document.querySelector('#spec-approve-rows').textContent"), 'Rows: G1, G2, G3', 'the confirmation names the rows it will approve');+ assert.equal(await chrome.stable('document.activeElement?.id'), 'spec-approve-submit', 'the confirmation takes focus on its Approve button');+ await press(chrome, "document.querySelector('#spec-approve-submit')");+ await chrome.waitFor("document.querySelector('#spec-approve-dialog').hidden && !!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.+ assert.equal(await chrome.stable("document.querySelector('#spec-list .spec-feedback').textContent"), 'approved rows G1 G2 G3 (pending apply)', 'the note beside the rows says what the board recorded');+ const state = await boardOf(view, demo.repo);+ assert.deepEqual(['G1', 'G2', 'G3'].map((id) => state.spec.find((row) => row.id === id)?.stage), ['approved, pending apply', 'approved, pending apply', 'approved, pending apply'], 'each row the confirmation named is approved');+ assert.equal(state.spec.find((row) => row.id === 'K1')?.decision, undefined, 'a row in another section stays undecided');+ const decisions = state.events.filter((event) => event.event_kind === 'row_decision');+ assert.deepEqual(decisions.map((event) => [event.event_by, JSON.parse(event.event_detail).channel]), [['person', 'view'], ['person', 'view'], ['person', 'view']], 'the person recorded one decision per row through the view');+ assert.equal(await chrome.stable('window.__confirmCalls'), 0, "Approve all never asks the browser's confirm dialog");+ 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.');