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
feat(view): decide spec rows without losing position [B26,N26]
Corey Olson8577041ac0d6
diff --git a/src/cockpit.js b/src/cockpit.jsindex 1aa48261..92319672 100644--- a/src/cockpit.js+++ b/src/cockpit.js@@ -135,13 +135,20 @@ export function cockpitPage(key = '', { snapshot = false, apiBase = '', apiHeade</main></div></div>+<div class="spec-reason-backdrop" id="spec-decline-dialog" hidden>+ <form class="spec-reason-dialog" id="spec-decline-form" aria-labelledby="spec-decline-title">+ <h2 id="spec-decline-title">Decline spec row</h2>+ <label>Reason<input id="spec-decline-reason" required maxlength="240" placeholder="Why this row needs changes"></label>+ <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="console" id="console" title="Click to close" hidden></div><script>const snapshot = ${JSON.stringify(snapshot)};const connection = ${connection};const snapshotReplay = { final: null, events: [], index: 0, playing: false, timer: null };const keep = (name, value) => { name = snapshot ? 'snapshot.' + name : name; try { if (value === undefined) return localStorage.getItem(name); localStorage.setItem(name, value); } catch { return null; } return value; };-const view = { root: keep('pb.project'), tab: keep('pb.tab') || 'items', seen: {}, code: {}, item: null, adding: false, state: 'active', rows: { spec: 'decide', doctrine: 'all' }, row: { spec: null, doctrine: null } };+const view = { root: keep('pb.project'), tab: keep('pb.tab') || 'items', seen: {}, code: {}, item: null, adding: false, declining: null, state: 'active', rows: { spec: 'decide', doctrine: 'all' }, row: { spec: null, doctrine: null } };if (snapshot) view.state = 'all';let data = null;let seen = '';@@ -203,9 +210,9 @@ const doing = (x) => [x.decisions && count(x.decisions, 'decision', 'decisions')function projectNeeds(p) {return [...p.decisions.map((d) => ({ ref: d.shout_from, text: d.shout_text, what: 'decision', at: d.shout_at })),- ...p.spec.filter((row) => row.status === 'pending').map((row) => ({ ref: row.id, text: row.text, what: 'answer in SPEC.md' })),+ ...p.spec.filter((row) => row.status === 'pending' && !row.decision).map((row) => ({ ref: row.id, text: row.text, what: 'answer in SPEC.md' })),...p.holds.map((hold) => ({ ref: hold.hold_lane, text: hold.hold_reason, what: 'lane held by ' + hold.hold_by })),- ...(p.spec.some((row) => row.status === 'draft') ? [{ ref: String(p.spec.filter((row) => row.status === 'draft').length), text: 'draft spec rows to approve or drop', what: 'review in SPEC.md', target: 'tab:spec' }] : []),+ ...(p.spec.some((row) => row.status === 'draft' && !row.decision) ? [{ ref: String(p.spec.filter((row) => row.status === 'draft' && !row.decision).length), text: 'draft spec rows to approve or drop', what: 'review in SPEC.md', target: 'tab:spec' }] : []),];}// The item lifecycle as pullboard declares it in src/machine.js, embedded when the page is served.@@ -449,8 +456,8 @@ function boardSummary(board, state) {sentBack: count((item) => item.status === 'open' && item.verdict && item.verdict.decision === 'REJECT'),open: count((item) => item.status === 'open'),verified: count((item) => item.status === 'verified'),- pending: state.spec.filter((row) => row.status === 'pending').length,- drafts: state.spec.filter((row) => row.status === 'draft').length,+ pending: state.spec.filter((row) => row.status === 'pending' && !row.decision).length,+ drafts: state.spec.filter((row) => row.status === 'draft' && !row.decision).length,holds: state.holds.length,decisions: state.decisions.length,};@@ -768,7 +775,7 @@ function render() {const items = p.items.filter((i) => i.status !== 'withdrawn');const active = items.filter((i) => stateOf(i) !== 'verified');$('count-items').textContent = active.length || '';- $('count-spec').textContent = p.spec.filter((r) => ['pending', 'draft'].includes(r.status)).length || '';+ $('count-spec').textContent = p.spec.filter((r) => ['pending', 'draft'].includes(r.status) && !r.decision).length || '';$('count-doctrine').textContent = p.practice.filter((r) => ['pending', 'draft'].includes(r.status)).length || '';const titles = new Map(p.items.map((i) => [String(i.id), i.title]));@@ -777,10 +784,10 @@ function render() {// on the board with who holds it; it is the agents' to move.const needs = [...p.decisions.map((d) => ['decide:' + d.shout_id, d.shout_from, d.shout_text, 'decide', d.shout_at]),- ...p.spec.filter((r) => r.status === 'pending').map((r) => ['spec:' + r.id, r.id, r.text, 'answer in SPEC.md']),+ ...p.spec.filter((r) => r.status === 'pending' && !r.decision).map((r) => ['spec:' + r.id, r.id, r.text, 'answer in SPEC.md']),...p.holds.map((h) => ['tab:shouts', h.hold_lane, h.hold_reason, 'lane held by ' + h.hold_by]),];- const drafts = p.spec.filter((r) => r.status === 'draft').length;+ const drafts = p.spec.filter((r) => r.status === 'draft' && !r.decision).length;$('needs').hidden = !needs.length && !drafts;$('needs').innerHTML = '<div class="head"><i></i>Needs you</div>' + needs.slice(0, 6).map(([target, ref, text, what, at]) => '<button class="ny" data-go="' + esc(target) + '" type="button"><code>' + esc(ref) + '</code><span>' + rich(text, titles, false) + '</span><em>' + esc(what) + (at ? ', ' + age(at) : '') + ' →</em></button>').join('') + (needs.length > 6 ? '<div class="muted more">and ' + (needs.length - 6) + ' more</div>' : '') + (drafts ? '<button class="ny" data-go="tab:spec" type="button"><code>' + drafts + '</code><span>draft spec rows to approve or drop</span><em>review →</em></button>' : '');@@ -879,19 +886,30 @@ function render() {const rows = kind === 'spec' ? p.spec : p.practice;const filter = view.rows[kind];const labels = { decide: 'Needs your decision', all: 'All rows', approved: 'Approved' };- const n = { decide: rows.filter((r) => ['pending', 'draft'].includes(r.status)).length, all: rows.length, approved: rows.filter((r) => r.status === 'approved').length };+ /** A source row stays in Needs your decision until its person decision is recorded. */+ const undecided = (r) => ['pending', 'draft'].includes(r.status) && !r.decision;+ const n = { decide: rows.filter(undecided).length, all: rows.length, approved: rows.filter((r) => r.status === 'approved').length };$(kind + '-chips').innerHTML = Object.keys(labels).map((f) => '<button data-rows="' + kind + ':' + f + '" class="' + (filter === f ? 'on' : '') + '" type="button">' + labels[f] + '<b>' + n[f] + '</b></button>').join('');- const shownRows = rows.filter((r) => filter === 'all' || (filter === 'decide' ? ['pending', 'draft'].includes(r.status) : r.status === 'approved'));+ const shownRows = rows.filter((r) => filter === 'all' || (filter === 'decide' ? undecided(r) : r.status === 'approved'));+ const feedback = kind === 'spec' && view.specFeedback?.root === view.root && view.specFeedback.from === 'list' ? view.specFeedback : null;+ const feedbackId = feedback && (shownRows.some((r) => r.id === feedback.id) ? feedback.id : shownRows.some((r) => r.id === feedback.next) ? feedback.next : shownRows[0]?.id);let section = null;$(kind + '-list').innerHTML = shownRows.length ? shownRows.map((r) => {- const head = r.section !== section ? '<h4>' + esc(r.section) + '</h4>' : '';+ const sectionRows = kind === 'spec' && r.section !== section ? rows.filter((entry) => entry.section === r.section && undecided(entry)) : [];+ const head = r.section !== section ? '<div class="spec-section-head"><h4>' + esc(r.section) + '</h4>' + (sectionRows.length ? '<button class="spec-section-approve" data-section-approve="' + esc(r.section) + '" type="button">Approve all ' + sectionRows.length + ' in this section</button>' : '') + '</div>' : '';section = r.section;const declined = kind === 'doctrine' && r.status === 'wont';const text = declined ? '<s>' + esc(r.standardText || r.text) + '</s>' : esc(r.text);const reason = declined && r.reason ? '<small class="rule-reason">Reason: ' + esc(r.reason) + '</small>' : '';const source = kind === 'doctrine' ? '<small class="rule-source">' + esc(ruleSource(r)) + '</small>' : '';- return head + '<div class="srow' + (view.row[kind] === r.id ? ' on' : '') + '" data-row="' + kind + ':' + esc(r.id) + '"><code>' + esc(r.id) + '</code><span><span class="chip ' + tone(r.status) + '">' + esc(r.status) + '</span>' + source + '</span><span>' + text + reason + '</span></div>';+ const status = r.stage || r.status;+ /** Render person-only row decisions in both the list and its detail pane. */+ const decisionActions = (kind === 'spec' && undecided(r))+ ? '<div class="spec-decision-actions"><button class="approve-row" data-row-decision="approve" data-row-id="' + esc(r.id) + '" type="button">Approve</button><button class="decline-row" data-row-decision="decline" data-row-id="' + esc(r.id) + '" type="button">Decline</button></div>'+ : '';+ return head + (feedback && feedbackId === r.id ? specFeedback(feedback) : '') + '<div class="srow' + (view.row[kind] === r.id ? ' on' : '') + '" data-row="' + kind + ':' + esc(r.id) + '"><code>' + esc(r.id) + '</code><span><span class="chip ' + tone(r.status) + '">' + esc(status) + '</span>' + source + '</span><span>' + text + reason + decisionActions + '</span></div>';}).join('') : '<div class="empty">' + (rows.length ? 'No rows match.' : kind === 'spec' ? 'No spec rows yet. Each requirement is one row in SPEC.md, such as G1 [draft, must] and a line; write them, or ask an agent to, and they show up here.' : 'No practice rows yet: they live in PRACTICE.md.') + '</div>';+ if (feedback && !shownRows.length) $(kind + '-list').innerHTML += specFeedback(feedback);const row = rows.find((r) => r.id === view.row[kind]);const citing = row ? p.items.filter((i) => i.specs.includes(row.id)) : [];const declined = kind === 'doctrine' && row && row.status === 'wont';@@ -899,7 +917,11 @@ function render() {const source = kind === 'doctrine' && row ? '<span class="chip">' + esc(ruleSource(row)) + '</span>' : '';const reason = declined && row.reason ? '<dt>reason</dt><dd>' + esc(row.reason) + '</dd>' : '';const home = kind === 'doctrine' && row && row.origin === 'standard' ? 'Standard rules come with Pullboard; override or decline one in PRACTICE.md.' : 'Rows change in ' + (kind === 'spec' ? 'SPEC.md' : 'PRACTICE.md') + ', and only you approve them.';- $(kind + '-detail').innerHTML = row ? '<div class="stack tight"><h2><span>' + esc(row.id) + '</span>' + text + '</h2><div class="meta"><span class="chip ' + tone(row.status) + '">' + esc(row.status) + '</span>' + (row.tier ? '<span class="chip">' + esc(row.tier) + '</span>' : '') + source + '</div><dl class="kv"><dt>section</dt><dd>' + esc(row.section) + '</dd>' + reason + (row.gate ? '<dt>gate</dt><dd>' + esc(row.gate) + '</dd>' : '') + (row.serves && row.serves.length ? '<dt>serves</dt><dd>' + esc(row.serves.join(', ')) + '</dd>' : '') + '</dl><div><h3>Items that cite it</h3>' + (citing.length ? '<div class="links">' + citing.map((i) => '<button data-go="item:' + i.id + '" type="button">#' + i.id + ' ' + rich(i.title, titles, false) + '</button>').join('') + '</div>' : '<div class="muted">None yet.</div>') + '</div><div class="muted">' + home + '</div></div>' : '<div class="empty">Pick a row to see it, and the items that cite it.</div>';+ const rowStatus = row?.stage || row?.status;+ const rowDecisionActions = row && kind === 'spec' && undecided(row)+ ? '<div class="spec-decision-actions detail-decision-actions"><button class="approve-row" data-row-decision="approve" data-row-id="' + esc(row.id) + '" type="button">Approve</button><button class="decline-row" data-row-decision="decline" data-row-id="' + esc(row.id) + '" type="button">Decline</button></div>'+ : '';+ $(kind + '-detail').innerHTML = row ? '<div class="stack tight"><h2><span>' + esc(row.id) + '</span>' + text + '</h2><div class="meta"><span class="chip ' + tone(row.status) + '">' + esc(rowStatus) + '</span>' + (row.tier ? '<span class="chip">' + esc(row.tier) + '</span>' : '') + source + '</div>' + rowDecisionActions + (kind === 'spec' && view.specFeedback?.root === view.root && view.specFeedback.from === 'detail' && view.specFeedback.id === row.id ? specFeedback(view.specFeedback) : '') + '<dl class="kv"><dt>section</dt><dd>' + esc(row.section) + '</dd>' + reason + (row.gate ? '<dt>gate</dt><dd>' + esc(row.gate) + '</dd>' : '') + (row.serves && row.serves.length ? '<dt>serves</dt><dd>' + esc(row.serves.join(', ')) + '</dd>' : '') + '</dl><div><h3>Items that cite it</h3>' + (citing.length ? '<div class="links">' + citing.map((i) => '<button data-go="item:' + i.id + '" type="button">#' + i.id + ' ' + rich(i.title, titles, false) + '</button>').join('') + '</div>' : '<div class="muted">None yet.</div>') + '</div><div class="muted">' + home + '</div></div>' : '<div class="empty">Pick a row to see it, and the items that cite it.</div>';}if (keep('pb.flow') !== 'hidden') $('flow').innerHTML = flowSvg(p);@@ -1033,6 +1055,16 @@ function pageMove(command, args = {}) {if (command === 'answer') return { body: { verb: 'answer', item: Number(args.id), args: { text: text(args.text), as: 'person' } }, label: ['answer', text(args.id), text(args.text), '--as', 'person'].join(' ') };if (command === 'hold') return { body: { verb: 'hold', args: { lane: text(args.lane), reason: text(args.reason) } }, label: ['hold', text(args.lane), '--reason', text(args.reason)].join(' ') };if (command === 'release') return { body: { verb: 'hold', args: { lane: text(args.lane), off: true } }, label: ['hold', text(args.lane), '--off'].join(' ') };+ if (command === 'spec-approve') {+ const ids = text(args.ids);+ if (!ids) throw new Error('Choose at least one spec row to approve.');+ return { body: { verb: 'spec-approve', args: { ids } }, label: 'spec approve ' + ids };+ }+ if (command === 'spec-decline') {+ const ids = text(args.ids), reason = text(args.reason);+ if (!ids || !reason) throw new Error('Choose a spec row and enter a reason to decline it.');+ return { body: { verb: 'spec-decline', args: { ids, reason } }, label: 'spec decline ' + ids + ' --reason ' + reason };+ }throw new Error('No view action ' + String(command) + '; choose add, shout, answer, hold or release.');}@@ -1041,9 +1073,46 @@ function moveMessage(move, result) {if (move.verb === 'add') return 'added #' + result.item.item_id;if (move.verb === 'shout') return 'shouted to ' + move.args.to;if (move.verb === 'answer') return 'answered #' + move.item;+ if (move.verb === 'spec-approve') return 'approved rows ' + move.args.ids + ' (pending apply)';+ if (move.verb === 'spec-decline') return 'declined rows ' + move.args.ids + ' (pending apply)';return move.args.off ? 'released the ' + move.args.lane + ' lane' : 'holding the ' + move.args.lane + ' lane: ' + move.args.reason;}+/** Render escaped decision feedback beside the affected Spec row (B26, N26). */+function specFeedback(feedback) {+ return '<div class="spec-feedback ' + feedback.tone + '" role="status">' + esc(feedback.text) + '</div>';+}++/** Record a Spec decision beside its row and retain the list's reading position (B26, N26). */+async function decideSpec(command, args, anchor) {+ if (snapshot) return false;+ const root = view.root, scroll = window.scrollY;+ const ids = String(args.ids).split(/\s+/);+ const rows = [...$('spec-list').querySelectorAll('[data-row]')];+ const index = rows.findIndex((row) => row.dataset.row === 'spec:' + ids[0]);+ const next = rows.slice(index + 1).find((row) => !ids.includes(row.dataset.row.slice(5)))?.dataset.row.slice(5);+ const feedback = { root, id: ids[0], next, from: anchor?.closest('#spec-detail') ? 'detail' : 'list', tone: '', text: 'Recording decision…' };+ view.specFeedback = feedback;+ render();+ window.scrollTo({ top: scroll, behavior: 'instant' });+ try {+ const move = pageMove(command, args);+ const result = await api(boardPath(root) + '/moves', move.body);+ feedback.tone = 'ok';+ feedback.text = moveMessage(move.body, result.result);+ await refresh();+ } catch (error) {+ feedback.tone = 'no';+ feedback.text = String(error.message || error);+ }+ if (root === view.root && view.specFeedback === feedback) {+ render();+ window.scrollTo({ top: scroll, behavior: 'instant' });+ setTimeout(() => { if (view.specFeedback === feedback) { view.specFeedback = null; render(); } }, 6000);+ }+ return feedback.tone === 'ok';+}+/** Run a public API move beside its action and let only the latest one own the console and timer. */async function act(command, args, anchor) {const out = $('console');@@ -1115,7 +1184,7 @@ function switchTo(root) {}document.addEventListener('click', (event) => {- const t = event.target.closest('[data-root],[data-tab],[data-go],[data-item],[data-state],[data-rows],[data-row],[data-release],[data-shout],[data-new],[data-code],#proj-switch,#console');+ const t = event.target.closest('[data-root],[data-tab],[data-go],[data-item],[data-state],[data-rows],[data-row],[data-row-decision],[data-section-approve],[data-release],[data-shout],[data-new],[data-code],#proj-switch,#console');if (!event.target.closest('.side')) fold(false);if (!t) return;if (t.id === 'proj-switch') { fold(!$('side').classList.contains('open')); return; }@@ -1126,6 +1195,23 @@ document.addEventListener('click', (event) => {else if (t.dataset.item) pick(Number(t.dataset.item));else if (t.dataset.state) { view.state = t.dataset.state; render(); }else if (t.dataset.rows) { const [kind, f] = t.dataset.rows.split(':'); view.rows[kind] = f; render(); }+ else if (t.dataset.rowDecision) {+ const id = t.dataset.rowId;+ if (t.dataset.rowDecision === 'approve') decideSpec('spec-approve', { ids: id }, t);+ else {+ view.declining = id;+ view.declineFrom = t.closest('#spec-detail') ? 'detail' : 'list';+ $('spec-decline-title').textContent = 'Decline ' + id;+ $('spec-decline-reason').value = '';+ $('spec-decline-dialog').hidden = false;+ $('spec-decline-reason').focus();+ }+ }+ 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 + '”?')) decideSpec('spec-approve', { ids: ids.join(' ') }, t);+ }else if (t.dataset.row) { const [kind, id] = t.dataset.row.split(':'); view.row[kind] = id; render(); }else if (t.dataset.code) code(t.dataset.code, t.dataset.before || '');else if (t.dataset.release) act('release', { lane: t.dataset.release }, t);@@ -1135,6 +1221,17 @@ document.addEventListener('click', (event) => {// The form covers the picked item rather than dropping it, so Cancel brings it back.$('new-item').addEventListener('click', () => { view.adding = true; render(); $('add-title').focus(); });$('add-cancel').addEventListener('click', () => { view.adding = false; render(); });+$('spec-decline-cancel').addEventListener('click', () => { view.declining = null; $('spec-decline-dialog').hidden = true; });+$('spec-decline-form').addEventListener('submit', (event) => {+ event.preventDefault();+ const id = view.declining;+ const reason = $('spec-decline-reason').value.trim();+ if (!id || !reason) return;+ view.declining = null;+ $('spec-decline-dialog').hidden = true;+ const anchor = view.declineFrom === 'detail' ? $('spec-detail') : [...$('spec-list').querySelectorAll('[data-row]')].find((row) => row.dataset.row === 'spec:' + id);+ decideSpec('spec-decline', { ids: id, reason }, anchor);+});$('answer-cancel').addEventListener('click', () => answer(null));$('flow-hide').addEventListener('click', () => showFlow(false));$('flow-show').addEventListener('click', () => showFlow(true));diff --git a/src/view.css b/src/view.cssindex 74364087..3dabddeb 100644--- a/src/view.css+++ b/src/view.css@@ -253,8 +253,22 @@ code.inline { padding: 0 3px; border-radius: 3px; background: color-mix(in srgb,.lane { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; }.lane:first-child { border-top: 0; }.rows { padding: 4px 10px 10px; }-.rows h4 { margin: 12px 0 4px; font-size: 12.5px; color: var(--ink-muted); }-.srow { display: grid; grid-template-columns: 4.4em 6.2em minmax(0, 1fr); gap: 8px; padding: 6px 4px; border-top: 1px solid var(--line); align-items: baseline; cursor: pointer; border-radius: 6px; }+.spec-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 0 4px; }+.rows h4 { margin: 0; font-size: 12.5px; color: var(--ink-muted); }+.spec-section-approve, .approve-row, .decline-row { min-height: 44px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); cursor: pointer; }+.spec-section-approve { color: var(--accent-strong); }+.approve-row { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }+.decline-row { border-color: var(--reject); color: var(--reject); }+.spec-decision-actions { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-top: 8px; cursor: default; }+.detail-decision-actions { margin: 0 0 12px; }+.spec-reason-backdrop { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 16px; background: rgb(15 23 42 / 45%); }+.spec-reason-dialog { width: min(100%, 420px); display: grid; gap: 12px; padding: 18px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); box-shadow: 0 18px 60px rgb(0 0 0 / 24%); }+.spec-reason-dialog h2 { margin: 0; font-size: 17px; }+.spec-reason-dialog label { display: grid; gap: 5px; color: var(--ink-muted); font-size: 12px; }+.spec-reason-dialog input { width: 100%; min-height: 44px; padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 13px; }+.spec-reason-dialog .actions { display: flex; flex-wrap: wrap; gap: 8px; }+.spec-reason-dialog .actions button { min-height: 44px; }+.srow { display: grid; grid-template-columns: 4.4em minmax(6.2em, max-content) minmax(0, 1fr); gap: 8px; padding: 6px 4px; border-top: 1px solid var(--line); align-items: baseline; cursor: pointer; border-radius: 6px; }.srow:hover { background: var(--surface-2); }.srow.on { background: var(--accent-soft); }.srow code { font: 600 12px var(--mono); }@@ -296,3 +310,7 @@ button, input, select, textarea, [data-item], [data-row] { min-height: 44px; }@media (width < 480px) {.toolbar .seg { flex: 1 1 100%; }}++.spec-feedback { margin: 8px 0; padding: 8px; border: 1px solid var(--line-strong); border-radius: 8px; overflow-wrap: anywhere; font-size: 13px; }+.spec-feedback.ok { color: var(--accent-strong); }+.spec-feedback.no { color: var(--reject); }diff --git a/test/cockpit.test.js b/test/cockpit.test.jsindex 05f22261..8220aa39 100644--- a/test/cockpit.test.js+++ b/test/cockpit.test.js@@ -2855,6 +2855,138 @@ test('real Chrome keeps the demo board usable at phone and desktop widths [H5,N2}});+test('real Chrome records Spec row decisions from the row, detail and confirmed section controls [B26,N26]', { timeout: 120_000 }, async (t) => {+ const executable = chromeExecutable();+ if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for Spec decision checks.');++ /** Click a visible control through Chrome's input path without scrolling the result away. */+ const click = async (chrome, selector) => {+ const point = JSON.parse(await chrome.evaluate(`(() => {+ const e = document.querySelector(${JSON.stringify(selector)});+ if (!e) throw Error('missing ' + ${JSON.stringify(selector)});+ e.scrollIntoView({block:'center'});+ const r = e.getBoundingClientRect();+ if (r.width <= 0 || r.height <= 0 || r.top < 0 || r.bottom > innerHeight) throw Error('control is not visible: ' + ${JSON.stringify(selector)});+ return JSON.stringify({x:r.x+r.width/2,y:r.y+r.height/2});+ })()`));+ await chrome.send('Input.dispatchMouseEvent', { type: 'mouseMoved', ...point });+ await chrome.send('Input.dispatchMouseEvent', { type: 'mousePressed', ...point, button: 'left', clickCount: 1 });+ await chrome.send('Input.dispatchMouseEvent', { type: 'mouseReleased', ...point, button: 'left', clickCount: 1 });+ };++ /** Run the full decision story in a fresh real board and browser at one viewport width. */+ const runWidth = async (width) => {+ const rows = Array.from({ length: 29 }, (_, index) => `- G${index + 1} [draft, must] Goal ${index + 1}. | gate: web test`);+ const spec = `# Decisions\n\n## G · Goals\n${rows.join('\n')}\n\n## K · Follow-up\n- K1 [draft, must] Follow-up one. | gate: web test\n- K2 [draft, must] Follow-up two. | gate: web test\n`;+ const box = machine();+ const demo = project(box, `spec-decisions-${width}`, spec);+ const view = await startView(box);+ const profile = mkdtempSync(join(tmpdir(), `pullboard-spec-decisions-${width}-`));+ let chrome;+ try {+ chrome = await openSnapshotChrome(executable, view.link.href, profile);+ await chrome.waitFor("typeof data === 'object' && !!data && !!data.project");+ await chrome.send('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false });+ await chrome.evaluate("document.querySelector('[data-tab=spec]').click()");+ await chrome.waitFor(`innerWidth === ${width} && !!document.querySelector('#spec-list [data-row="spec:G1"]')`);+ await chrome.evaluate("document.querySelector('#spec-chips [data-rows=\"spec:all\"]').click()");+ await chrome.waitFor("document.querySelector('#spec-list [data-row=\"spec:G2\"]') && document.querySelector('#count-spec').textContent === '31'");++ const geometry = JSON.parse(await chrome.evaluate(`JSON.stringify({+ overflow: document.documentElement.scrollWidth > document.documentElement.clientWidth,+ controls: [...document.querySelectorAll('#spec-list button[data-row-decision],#spec-list button[data-section-approve]')].map(e=>({height:e.getBoundingClientRect().height})),+ rows: [...document.querySelectorAll('#spec-list .srow')].map(row=>{+ const chip=row.querySelector(':scope > span:nth-child(2) .chip');+ const text=row.querySelector(':scope > span:nth-child(3)');+ if (!chip || !text) return {id:row.dataset.row, missing:true};+ const a=chip.getBoundingClientRect(), b=text.getBoundingClientRect();+ return {id:row.dataset.row, intersects:a.right>b.left && a.left<b.right && a.bottom>b.top && a.top<b.bottom};+ })+ })`));+ assert.equal(geometry.overflow, false, `${width}: Spec has no horizontal overflow`);+ assert.deepEqual(geometry.controls.filter((control) => control.height < 44), [], `${width}: row and section controls meet the 44px target`);+ assert.deepEqual(geometry.rows.filter((row) => row.missing), [], `${width}: row status and text are present for every fixture row`);+ if (width === 1280) assert.deepEqual(geometry.rows.filter((row) => row.intersects), [], '1280: stage chips never cover row text');++ await chrome.evaluate("document.querySelector('#spec-list [data-row=\"spec:G2\"]').click()");+ await chrome.waitFor("document.querySelector('#spec-detail h2 span')?.textContent === 'G2'");+ assert.ok(await chrome.evaluate("document.querySelector('#spec-detail [data-row-decision=approve]') && document.querySelector('#spec-detail [data-row-decision=decline]')"), `${width}: selected G2 has both detail decisions`);+ await click(chrome, '#spec-list [data-row="spec:G1"] [data-row-decision="approve"]');+ await chrome.waitFor("!!document.querySelector('.spec-feedback.ok,.spec-feedback.no')");+ let state = await boardOf(view, demo.repo);+ assert.equal(state.spec.find((row) => row.id === 'G1')?.stage, 'approved, pending apply', `${width}: clicked G1 is approved`);+ assert.equal(state.spec.find((row) => row.id === 'G2')?.decision, undefined, `${width}: selecting G2 does not redirect the clicked G1 decision`);+ assert.ok(await chrome.evaluate(`(() => { const e=document.querySelector('#spec-list [data-row="spec:G2"]'); const r=e.getBoundingClientRect(); return r.top >= 0 && r.bottom <= innerHeight; })()`), `${width}: next undecided G2 stays in the viewport after G1 approval`);+ assert.equal(await chrome.evaluate("document.querySelector('#count-spec').textContent"), '30', `${width}: Spec badge excludes the decided row`);+ if (width === 1280) assert.ok(await chrome.evaluate(`(() => {+ const row=document.querySelector('#spec-list [data-row="spec:G1"]');+ const chip=row.querySelector(':scope > span:nth-child(2) .chip').getBoundingClientRect();+ const text=row.querySelector(':scope > span:nth-child(3)').getBoundingClientRect();+ return chip.right <= text.left || chip.bottom <= text.top || chip.top >= text.bottom;+ })()`), '1280: the approved pending stage does not cover row text');++ await chrome.evaluate("document.querySelector('#spec-chips [data-rows=\"spec:decide\"]').click()");+ assert.equal(await chrome.evaluate("!!document.querySelector('#spec-list [data-row=\"spec:G1\"]')"), false, `${width}: approval immediately leaves Needs your decision`);+ await chrome.evaluate("document.querySelector('#spec-chips [data-rows=\"spec:all\"]').click()");++ await click(chrome, '#spec-detail [data-row-decision="decline"]');+ assert.ok(await chrome.evaluate("!document.querySelector('#spec-decline-dialog').hidden && document.querySelector('#spec-decline-title').textContent === 'Decline G2'"), `${width}: G2 decline opens the reason form`);+ assert.ok(await chrome.evaluate("[...document.querySelectorAll('#spec-decline-dialog input,#spec-decline-dialog button')].every(e => e.getBoundingClientRect().height >= 44)"), `${width}: decline reason and controls meet the 44px target`);+ await click(chrome, '#spec-decline-cancel');+ state = await boardOf(view, demo.repo);+ assert.equal(state.events.filter((event) => event.event_kind === 'row_decision').length, 1, `${width}: cancelling decline records no event`);+ assert.equal(state.spec.find((row) => row.id === 'G2')?.decision, undefined, `${width}: cancelling leaves G2 undecided`);++ await click(chrome, '#spec-detail [data-row-decision="decline"]');+ await chrome.evaluate("document.querySelector('#spec-decline-reason').value = 'Needs a clearer outcome'");+ box.run(demo.repo, 'shout', 'person', `refresh probe ${width}`);+ await chrome.waitFor(`data.project.shouts.some(shout => shout.shout_text === 'refresh probe ${width}')`);+ assert.equal(await chrome.evaluate("document.querySelector('#spec-decline-reason').value"), 'Needs a clearer outcome', `${width}: typed reason survives a live refresh`);+ await click(chrome, '#spec-decline-submit');+ await chrome.waitFor("!!document.querySelector('#spec-detail .spec-feedback.ok,#spec-detail .spec-feedback.no')");++ await chrome.evaluate("window.__sectionConfirm = null; window.confirm = message => { window.__sectionConfirm = message; return false; }");+ const sectionSelector = `#spec-list [data-section-approve]`;+ await chrome.evaluate(`(() => { const button=[...document.querySelectorAll(${JSON.stringify(sectionSelector)})].find(e=>e.parentElement.querySelector('h4')?.textContent.includes('Follow-up')); if(!button) throw Error('missing K section approval'); button.click(); })()`);+ state = await boardOf(view, demo.repo);+ assert.match(await chrome.evaluate('window.__sectionConfirm'), /Approve all 2 undecided rows in/, `${width}: section approval asks for confirmation`);+ assert.equal(await chrome.evaluate("!!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`);++ await chrome.evaluate("window.confirm = () => true");+ await chrome.evaluate(`(() => { const button=[...document.querySelectorAll(${JSON.stringify(sectionSelector)})].find(e=>e.parentElement.querySelector('h4')?.textContent.includes('Follow-up')); if(!button) throw Error('missing K section approval'); button.click(); })()`);+ 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');+ assert.equal(decisions.length, 4, `${width}: approve, decline and two section rows produce four events`);+ assert.deepEqual(decisions.map((event) => event.event_by), ['person', 'person', 'person', 'person'], `${width}: every decision is recorded by the person`);+ assert.deepEqual(decisions.map((event) => JSON.parse(event.event_detail).channel), ['view', 'view', 'view', 'view'], `${width}: every decision uses the view channel`);+ assert.equal(state.spec.find((row) => row.id === 'G2')?.stage, 'declined, pending apply', `${width}: G2 shows its pending decline stage`);+ assert.equal(state.spec.find((row) => row.id === 'G2')?.decision?.reason, 'Needs a clearer outcome', `${width}: decline reason is in board state`);+ assert.equal(state.spec.find((row) => row.id === 'K1')?.stage, 'approved, pending apply', `${width}: K1 was approved`);+ assert.equal(state.spec.find((row) => row.id === 'K2')?.stage, 'approved, pending apply', `${width}: K2 was approved`);+ assert.equal(state.spec.find((row) => row.id === 'G3')?.decision, undefined, `${width}: other section rows remain undecided`);+ if (width === 1280) assert.ok(await chrome.evaluate(`['G1','G2','K1','K2'].every(id => {+ const row=document.querySelector('#spec-list [data-row="spec:'+id+'"]');+ const chip=row.querySelector(':scope > span:nth-child(2) .chip').getBoundingClientRect();+ const text=row.querySelector(':scope > span:nth-child(3)').getBoundingClientRect();+ return chip.right <= text.left || chip.bottom <= text.top || chip.top >= text.bottom;+ })`), '1280: every pending decision stage has room beside its row text');+ await chrome.evaluate("document.querySelector('#spec-chips [data-rows=\"spec:decide\"]').click()");+ 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.evaluate("document.querySelector('#spec-chips [data-rows=\"spec:decide\"]').innerText.includes('27')"), `${width}: Needs your decision excludes all four decided rows`);+ assert.deepEqual(chrome.exceptions, [], `${width}: Chrome reports no uncaught exceptions`);+ } finally {+ if (chrome) await closeSnapshotChrome(chrome);+ await view.stop();+ rmSync(profile, { recursive: true, force: true });+ }+ };++ await runWidth(375);+ await runWidth(1280);+});test('static export redacts structured checkout paths but preserves paths people wrote [A10]', async () => {const box = machine();const alpha = project(box, 'private-project');