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): fold the proof stats card [N26]
Corey Olson76002e581f46
diff --git a/src/cockpit.js b/src/cockpit.jsindex 3c3f0df2..f1afc9af 100644--- a/src/cockpit.js+++ b/src/cockpit.js@@ -824,7 +824,7 @@ function proofStatsCard(stats, expanded = false) {return '<button class="proof-stats-summary" id="proof-stats-summary" data-stats-toggle type="button" aria-expanded="' + expanded + '" aria-controls="proof-stats-full">'+ '<span class="proof-stats-summary-text">' + esc(summary) + '</span><span class="proof-stats-caret" aria-hidden="true">' + (expanded ? '−' : '+') + '</span></button>'+ '<div class="proof-stats-full" id="proof-stats-full"' + (expanded ? '' : ' hidden') + '>'- + '<div class="proof-stats-head"><b>Proof stats</b><span>from recorded moves</span><button id="proof-stats-close" type="button" class="proof-stats-close" data-stats-close>Close</button></div>'+ + '<div class="proof-stats-head"><b>Proof stats</b><span>from recorded moves</span></div>'+ '<div class="proof-stats-grid">'+ '<div><span>Submissions</span><b data-stat="submissions" data-value="' + esc(stats.submissions) + '">' + esc(stats.submissions) + '</b></div>'+ '<div><span>Rejections</span><b data-stat="rejections" data-value="' + esc(stats.rejections) + '">' + esc(stats.rejections) + '</b></div>'@@ -1356,7 +1356,7 @@ if (typeof MutationObserver === 'function') new MutationObserver((changes) => {/** Draw the board shown: the sidebar, then every tab's panes from the project's board. */function render() {- const statsFocus = ['proof-stats-summary', 'proof-stats-close'].includes(document.activeElement?.id) ? document.activeElement.id : null;+ const statsFocus = document.activeElement?.id === 'proof-stats-summary' ? document.activeElement.id : null;const p = data.project;const group = data.group;renderSide();@@ -2242,19 +2242,13 @@ $('shouts-pane').addEventListener('click', (event) => {// Enter shouts; Shift+Enter starts a new line.$('shout-text').addEventListener('keydown', (event) => { if (event.key === 'Enter' && !event.shiftKey && !event.isComposing) { event.preventDefault(); $('shout-form').requestSubmit(); } });document.addEventListener('click', (event) => {- const t = event.target.closest('[data-status],[data-roadmap-key],[data-roadmap-all],[data-root],[data-tab],[data-go],[data-item],[data-items-view],[data-state],[data-rows],[data-row],[data-row-decision],[data-section-approve],[data-release],[data-shout],[data-new],[data-code],[data-code-all],[data-code-less],[data-stats-toggle],[data-stats-close],#proj-switch,#console');+ const t = event.target.closest('[data-status],[data-roadmap-key],[data-roadmap-all],[data-root],[data-tab],[data-go],[data-item],[data-items-view],[data-state],[data-rows],[data-row],[data-row-decision],[data-section-approve],[data-release],[data-shout],[data-new],[data-code],[data-code-all],[data-code-less],[data-stats-toggle],#proj-switch,#console');if (!event.target.closest('.side')) fold(false);if (!t) return;if (t.id === 'proj-switch') { fold(!$('side').classList.contains('open')); return; }if (t.id === 'console') { t.hidden = true; return; }if (t.dataset.statsToggle !== undefined) {- view.statsOpen = true;- render();- $('proof-stats-close').focus({ preventScroll: true });- return;- }- if (t.dataset.statsClose !== undefined) {- view.statsOpen = false;+ view.statsOpen = !view.statsOpen;render();$('proof-stats-summary').focus({ preventScroll: true });return;diff --git a/src/view.css b/src/view.cssindex e9339e6f..1fcfd681 100644--- a/src/view.css+++ b/src/view.css@@ -712,7 +712,6 @@ code.inline.long { white-space: break-spaces; overflow-wrap: anywhere; }.proof-stats-head { display: flex; align-items: center; gap: 8px; }.proof-stats-head b { font-size: 13px; }.proof-stats-head > span, .proof-stats-grid > div > span { color: var(--ink-muted); font-size: 11px; }-.proof-stats-close { min-height: var(--tap); margin-left: auto; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); cursor: pointer; font-size: 12px; }.proof-stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px 12px; }.proof-stats-grid > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }.proof-stats-grid b { font-size: 14px; font-variant-numeric: tabular-nums; }diff --git a/test/cockpit/fixture.js b/test/cockpit/fixture.jsindex 947f9179..26be51fe 100644--- a/test/cockpit/fixture.js+++ b/test/cockpit/fixture.js@@ -7,7 +7,7 @@ import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import { after, test } from 'node:test';import vm from 'node:vm';-import { stableChrome, press } from './stable.js';+import { stableChrome, press, tapTouch } from './stable.js';import { closeBoard, openBoard } from '../../src/board.js';import { fetchFresh } from '../http-fixture.js';@@ -974,4 +974,4 @@ async function searchFor(chrome, words, timeoutMs) {}}-export { BIN, scratch, tapTarget, SPEC, machine, project, build, sendBack, fetchReason, fetchView, fetchLive, startView, styleOf, element, ageNodes, target, settle, storage, daysOn, openPage, projectRows, productEntries, timelineRows, agentEntries, drawing, textBoxes, meet, accept, needEntries, itemRow, boardId, boardOf, assertObservationAges, withoutObservationAges, assertObservationsEqual, shoutNameText, chromeExecutable, browserPause, startSnapshotChrome, openSnapshotChrome, stopOwnedChrome, closeSnapshotChrome, watchSpecDecisionWait, earlier, shoutsAt, press, pickProject, travel, pressedInto, settled, roadmapRow, showing, readRoadmap, openRoadmapParts, tabBar, serveFolder, proofShot, searchFor };+export { BIN, scratch, tapTarget, SPEC, machine, project, build, sendBack, fetchReason, fetchView, fetchLive, startView, styleOf, element, ageNodes, target, settle, storage, daysOn, openPage, projectRows, productEntries, timelineRows, agentEntries, drawing, textBoxes, meet, accept, needEntries, itemRow, boardId, boardOf, assertObservationAges, withoutObservationAges, assertObservationsEqual, shoutNameText, chromeExecutable, browserPause, startSnapshotChrome, openSnapshotChrome, stopOwnedChrome, closeSnapshotChrome, watchSpecDecisionWait, earlier, shoutsAt, press, tapTouch, pickProject, travel, pressedInto, settled, roadmapRow, showing, readRoadmap, openRoadmapParts, tabBar, serveFolder, proofShot, searchFor };diff --git a/test/cockpit/shared-wait.test.js b/test/cockpit/shared-wait.test.jsindex 0d15919c..cf3a05ff 100644--- a/test/cockpit/shared-wait.test.js+++ b/test/cockpit/shared-wait.test.js@@ -9,7 +9,7 @@ import { press, waitForStableBoxes } from './stable.js';const ROOT = fileURLToPath(new URL('../..', import.meta.url));const COCKPIT = join(ROOT, 'test', 'cockpit');-const EXEMPT_FUNCTIONS = new Set(['rawChromeEvaluation', 'waitForStableBoxes', 'press']);+const EXEMPT_FUNCTIONS = new Set(['rawChromeEvaluation', 'waitForStableBoxes', 'press', 'tapTouch']);/** Find complete top-level exception bodies without exempting the rest of stable.js. */function maskSharedChromeFunctions(source) {@@ -63,7 +63,7 @@ function rawChromeBypasses(root = COCKPIT) {}test('real Chrome tests measure and click only through the shared wait [N26,C7]', () => {- assert.deepEqual(rawChromeBypasses(), [], 'every cockpit test uses the stable API; raw CDP plumbing stays in the three named helpers');+ assert.deepEqual(rawChromeBypasses(), [], 'every cockpit test uses the stable API; raw CDP plumbing stays in the four named helpers');});test('the shared-wait guard reports a synthetic direct Chrome evaluation by file and line [N26,C7]', () => {@@ -92,11 +92,14 @@ test('raw protocol exceptions are limited to named stable helpers [N26,C7]', ()'export async function press(chrome) {',' return chrome.send(' + JSON.stringify(['Input', 'dispatchMouseEvent'].join('.')) + ', {});','}',+ 'export async function tapTouch(chrome) {',+ ' return chrome.send(' + JSON.stringify(['Input', 'dispatchTouchEvent'].join('.')) + ', {});',+ '}','export async function accidentalBypass(chrome) {',` return ${['chrome', '.', 'evaluate', '(', "'outside helper'", ')'].join('')};`,'}',].join('\n') + '\n');- assert.deepEqual(rawChromeBypasses(root), [{ file: 'stable.js', line: 11, kind: 'direct evaluate' }]);+ assert.deepEqual(rawChromeBypasses(root), [{ file: 'stable.js', line: 14, kind: 'direct evaluate' }]);} finally {rmSync(root, { recursive: true, force: true });}diff --git a/test/cockpit/stable.js b/test/cockpit/stable.jsindex b890266f..6c2a9e4d 100644--- a/test/cockpit/stable.js+++ b/test/cockpit/stable.js@@ -85,6 +85,23 @@ export async function press(chrome, find, { native = true } = {}) {await raw.send('Input.dispatchMouseEvent', { type: 'mouseReleased', x: point.x, y: point.y, button: 'left', clickCount: 1 });}+/** Tap a stable visible target with Chrome's real touch input path, so touch interactions are not simulated clicks. */+export async function tapTouch(chrome, find) {+ await waitForStableBoxes(chrome, find);+ await rawChromeEvaluation(chrome, `(${find}).scrollIntoView({ block: 'center', behavior: 'instant' })`);+ await waitForStableBoxes(chrome, find);+ const point = await rawChromeEvaluation(chrome, `(() => {+ const element = (${find}), rect = element.getBoundingClientRect(), x = rect.x + rect.width / 2, y = rect.y + rect.height / 2;+ const hit = document.elementFromPoint(x, y);+ if (!rect.width || !rect.height || !hit || (hit !== element && !element.contains(hit))) throw Error('shared touch: target is hidden or covered: ' + ${JSON.stringify(find)});+ return { x, y };+ })()`);+ const raw = clients.get(chrome);+ const touchPoint = { ...point, id: 1, radiusX: 1, radiusY: 1, force: 1 };+ await raw.send('Input.dispatchTouchEvent', { type: 'touchStart', touchPoints: [touchPoint] });+ await raw.send('Input.dispatchTouchEvent', { type: 'touchEnd', touchPoints: [] });+}+/*** Expose only waited page expressions. Every media override retains reduced motion, including the external* relay browser's pages. Polling observes readiness; it never retries a click or reruns an assertion.diff --git a/test/cockpit/stats.test.js b/test/cockpit/stats.test.jsindex de745903..4d56d03c 100644--- a/test/cockpit/stats.test.js+++ b/test/cockpit/stats.test.js@@ -5,7 +5,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';import { test } from 'node:test';import * as store from '../../src/board.js';-import { tapTarget, SPEC, machine, project, build, sendBack, startView, accept, boardOf, earlier, proofShot, chromeExecutable, openSnapshotChrome, closeSnapshotChrome, pickProject, press } from './fixture.js';+import { tapTarget, SPEC, machine, project, build, sendBack, startView, accept, boardOf, earlier, proofShot, chromeExecutable, openSnapshotChrome, closeSnapshotChrome, pickProject, press, tapTouch } from './fixture.js';/** Add a real joined worktree to the shared test board.* @param {ReturnType<typeof machine>} box@@ -29,6 +29,18 @@ function displayDuration(value) {return hours < 24 ? hours + ' h ' + rounded % 60 + ' min' : Math.floor(hours / 24) + ' d ' + hours % 24 + ' h';}+/** Read the rendered stats toggle state and its focus target without deriving application behavior. */+async function statsToggleState(chrome) {+ return JSON.parse(await chrome.stable(`JSON.stringify((() => {+ const summary = document.querySelector('#proof-stats-summary');+ const full = document.querySelector('#proof-stats-full');+ return { expanded:summary?.getAttribute('aria-expanded') ?? null, sign:summary?.querySelector('.proof-stats-caret')?.textContent ?? null,+ hidden:full?.hidden ?? true, closeCount:document.querySelectorAll('#proof-stats-close, [data-stats-close]').length,+ focus:document.activeElement?.id ?? null, height:summary?.getBoundingClientRect().height ?? 0,+ tap:getComputedStyle(document.documentElement).getPropertyValue('--tap').trim() };+ })())`));+}+test('[V2,N26] real Chrome shows matching proof stats at phone width and clears on a group [V2,N26]', { timeout: 90_000 }, async (t) => {const executable = chromeExecutable();@@ -146,6 +158,109 @@ test('[V2,N26] stats counts agree in number', { timeout: 90_000 }, async () => {}});+/** Save an optional visual receipt for one collapsed or expanded stats-card layout. */+async function saveStatsToggleShot(chrome, width, scheme, state) {+ const directory = process.env.PULLBOARD_STATS_TOGGLE_PROOF;+ if (!directory) return;+ mkdirSync(directory, { recursive: true });+ const shot = await chrome.send('Page.captureScreenshot', { format: 'png' });+ writeFileSync(join(directory, `stats-toggle-${width}-${scheme}-${state}.png`), Buffer.from(shot.data, 'base64'));+}++/** Exercise every real input path that opens and folds the proof card, then check its responsive targets. */+test('the stats card folds from its summary line [N26]', {+ timeout: 30_000, // budget: stop a hung local Chrome flow, not a rendering-speed assertion.+}, async () => {+ const executable = chromeExecutable();+ assert.ok(executable, 'Chrome is required for the stats summary toggle criterion.');++ const box = machine();+ const alpha = project(box, 'stats-summary-toggle');+ const view = await startView(box);+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-stats-summary-toggle-'));+ let chrome;+ try {+ chrome = await openSnapshotChrome(executable, view.link.href, profile);+ await chrome.waitFor("!!data?.project?.proofStats && document.querySelector('#proof-stats-summary')");+ await chrome.stable(`(() => {+ window.__statsTouchTargets = [];+ document.addEventListener('pointerdown', event => {+ if (event.pointerType === 'touch') window.__statsTouchTargets.push(event.target.closest('#proof-stats-summary') !== null);+ }, true);+ return true;+ })()`);++ for (const scheme of ['light', 'dark']) for (const width of [375, 1280]) {+ await chrome.send('Emulation.setTouchEmulationEnabled', { enabled: false });+ await chrome.send('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false });+ await chrome.send('Emulation.setEmulatedMedia', { features: [{ name: 'prefers-color-scheme', value: scheme }] });+ await chrome.waitFor(`innerWidth === ${width} && matchMedia('(prefers-color-scheme: ${scheme})').matches`);+ const start = await statsToggleState(chrome);+ assert.equal(start.expanded, 'false', `${width}px ${scheme}: summary starts collapsed`);+ assert.equal(start.sign, '+', `${width}px ${scheme}: plus signals that the card will open`);+ assert.equal(start.hidden, true, `${width}px ${scheme}: full card starts hidden`);+ assert.equal(start.closeCount, 0, `${width}px ${scheme}: no Close button is rendered`);+ assert.ok(start.height >= tapTarget(width), `${width}px ${scheme}: the summary meets the #371 target: ${JSON.stringify(start)}`);+ await saveStatsToggleShot(chrome, width, scheme, 'collapsed');++ await press(chrome, "document.querySelector('#proof-stats-summary')");+ let state = await statsToggleState(chrome);+ assert.equal(state.expanded, 'true', `${width}px ${scheme}: mouse click anywhere on the summary opens the card`);+ assert.equal(state.sign, '−', `${width}px ${scheme}: minus signals that the card will fold`);+ assert.equal(state.hidden, false, `${width}px ${scheme}: full card opens from the summary`);+ assert.equal(state.focus, 'proof-stats-summary', `${width}px ${scheme}: opening keeps focus on the toggle`);+ assert.equal(state.closeCount, 0, `${width}px ${scheme}: opening adds no Close button`);+ await saveStatsToggleShot(chrome, width, scheme, 'expanded');++ await press(chrome, "document.querySelector('#proof-stats-summary .proof-stats-caret')");+ state = await statsToggleState(chrome);+ assert.equal(state.expanded, 'false', `${width}px ${scheme}: clicking the minus folds the card`);+ assert.equal(state.sign, '+', `${width}px ${scheme}: folded card shows plus`);+ assert.equal(state.hidden, true, `${width}px ${scheme}: minus click hides the full card`);++ await chrome.send('Emulation.setTouchEmulationEnabled', { enabled: true, maxTouchPoints: 5 });+ await chrome.waitFor("matchMedia('(pointer: coarse)').matches");+ state = await statsToggleState(chrome);+ assert.ok(state.height >= 44, `${width}px ${scheme}: touch mode keeps a 44px summary target: ${JSON.stringify(state)}`);+ await tapTouch(chrome, "document.querySelector('#proof-stats-summary')");+ state = await statsToggleState(chrome);+ assert.equal(state.expanded, 'true', `${width}px ${scheme}: a real touch opens the card`);+ assert.equal(state.focus, 'proof-stats-summary', `${width}px ${scheme}: touch keeps focus on the summary`);+ await tapTouch(chrome, "document.querySelector('#proof-stats-summary')");+ state = await statsToggleState(chrome);+ assert.equal(state.expanded, 'false', `${width}px ${scheme}: a second real touch folds the card`);+ const touchTargets = JSON.parse(await chrome.stable('JSON.stringify(window.__statsTouchTargets)'));+ assert.ok(touchTargets.length >= 2 && touchTargets.slice(-2).every(Boolean), `${width}px ${scheme}: real touch pointer events land on the summary: ${JSON.stringify(touchTargets)}`);++ await chrome.send('Emulation.setTouchEmulationEnabled', { enabled: false });+ await chrome.stable("document.querySelector('#proof-stats-summary').focus()");+ for (const type of ['keyDown', 'keyUp']) await chrome.send('Input.dispatchKeyEvent', { type, key: 'Enter', code: 'Enter', windowsVirtualKeyCode: 13, nativeVirtualKeyCode: 13, ...(type === 'keyDown' ? { text: '\r', unmodifiedText: '\r' } : {}) });+ await chrome.waitFor("document.querySelector('#proof-stats-summary')?.getAttribute('aria-expanded') === 'true'");+ state = await statsToggleState(chrome);+ assert.equal(state.hidden, false, `${width}px ${scheme}: Enter opens the focused summary`);+ assert.equal(state.focus, 'proof-stats-summary', `${width}px ${scheme}: Enter retains focus on the summary`);+ for (const type of ['keyDown', 'keyUp']) await chrome.send('Input.dispatchKeyEvent', { type, key: ' ', code: 'Space', windowsVirtualKeyCode: 32, nativeVirtualKeyCode: 32, ...(type === 'keyDown' ? { text: ' ', unmodifiedText: ' ' } : {}) });+ await chrome.waitFor("document.querySelector('#proof-stats-summary')?.getAttribute('aria-expanded') === 'false'");+ state = await statsToggleState(chrome);+ assert.equal(state.hidden, true, `${width}px ${scheme}: Space folds the focused summary`);+ assert.equal(state.focus, 'proof-stats-summary', `${width}px ${scheme}: Space retains focus on the summary`);+ for (const type of ['keyDown', 'keyUp']) await chrome.send('Input.dispatchKeyEvent', { type, key: 'Enter', code: 'Enter', windowsVirtualKeyCode: 13, nativeVirtualKeyCode: 13, ...(type === 'keyDown' ? { text: '\r', unmodifiedText: '\r' } : {}) });+ await chrome.waitFor("document.querySelector('#proof-stats-summary')?.getAttribute('aria-expanded') === 'true'");+ for (const type of ['keyDown', 'keyUp']) await chrome.send('Input.dispatchKeyEvent', { type, key: 'Escape', code: 'Escape', windowsVirtualKeyCode: 27, nativeVirtualKeyCode: 27 });+ await chrome.waitFor("document.querySelector('#proof-stats-full').hidden");+ state = await statsToggleState(chrome);+ assert.equal(state.expanded, 'false', `${width}px ${scheme}: Escape folds the card`);+ assert.equal(state.sign, '+', `${width}px ${scheme}: Escape returns the plus sign`);+ assert.equal(state.focus, 'proof-stats-summary', `${width}px ${scheme}: Escape returns focus to the summary`);+ assert.equal(state.closeCount, 0, `${width}px ${scheme}: the full card still has no Close button`);+ }+ } finally {+ if (chrome) await closeSnapshotChrome(chrome);+ await view.stop();+ rmSync(profile, { recursive: true, force: true });+ }+});+/** Exercise the glance layout with 300 real registrations and measured native lifecycle moves. */// budget: 300 registrations plus four Chrome layouts; derived from the existing 90s browser ceiling with fixture headroom.test('stats read at a glance on a board with hundreds of agents [N26,V2]', { timeout: 300_000 }, async (t) => {@@ -239,11 +354,11 @@ test('stats read at a glance on a board with hundreds of agents [N26,V2]', { tim}if (width === 375 && scheme === 'light') {- await press(chrome, "document.querySelector('#proof-stats-close')");+ await press(chrome, "document.querySelector('#proof-stats-summary')");} else {for (const type of ['keyDown', 'keyUp']) await chrome.send('Input.dispatchKeyEvent', { type, key: 'Escape', code: 'Escape', windowsVirtualKeyCode: 27 });}- assert.equal(await chrome.stable("document.querySelector('#proof-stats-full').hidden"), true, `${width}px ${scheme}: Close or Escape folds the expanded card`);+ assert.equal(await chrome.stable("document.querySelector('#proof-stats-full').hidden"), true, `${width}px ${scheme}: the summary or Escape folds the expanded card`);assert.equal(await chrome.stable('document.activeElement?.id'), 'proof-stats-summary', `${width}px ${scheme}: closing returns focus to the list summary`);await chrome.stable('refresh().then(() => true)');assert.equal(await chrome.stable('document.activeElement?.id'), 'proof-stats-summary', `${width}px ${scheme}: a real API refresh preserves the returned keyboard focus`);