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
chore(view): merge main into #368 [N26]
Corey Olsonf8e7dbe6e87b
diff --cc src/serve.jsindex dec6fb20,be784637..d88c0481--- a/src/serve.js+++ b/src/serve.js@@@ -14,10 -14,10 +14,11 @@@ import { createServer } from 'node:httpimport { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path';import * as store from './board.js';import { cockpitPage } from './cockpit.js';+ import { displayAgentName } from './agent-names.js';import { COORDINATOR, loadConfig } from './config.js';-import { loadDoctrine, standardDoctrine } from './doctrine.js';+import { doctrineHistory, loadDoctrine, standardDoctrine } from './doctrine.js';import { repoInfo, resolveCommit } from './git.js';+import { committedIds } from './history.js';import { productSummaries } from './products.js';import { listApiProjects, registryFile } from './projects.js';import { Refused } from './refused.js';diff --cc test/cockpit.test.jsindex 7ad4d695,ba7538e5..11ed1cac--- a/test/cockpit.test.js+++ b/test/cockpit.test.js@@@ -7287,202 -7305,226 +7292,426 @@@ test('needs you and the asks sit in the}});+ test('agent model display names follow the API on phone and desktop [O8,N26]', { timeout: 150_000 }, async (t) => {+ const executable = chromeExecutable();+ assert.ok(executable, 'Chrome is required for model-name viewport proof');+ const box = machine();+ const alpha = project(box, 'model-names');+ const model = 'GPT-6 with a very long model declaration for readable agent names';+ box.run(alpha.web, 'join', 'web', '--model', model);+ const board = openBoard(join(alpha.repo, '.git', 'pullboard', 'board.sqlite'));+ try { register(board, { lane: 'coordinator', path: alpha.repo, model: 'Claude' }); }+ finally { closeBoard(board); }+ for (const title of ['Known holder', 'Reviewed model', 'Unknown holder']) {+ box.run(alpha.repo, 'add', 'web', title, '--specs', 'G1', '--criterion', 'visible');+ }+ build(box, alpha, 2, 'reviewed.txt');+ accept(box, alpha, 2);+ box.run(alpha.web, 'claim', '1');+ const unknown = join(box.dir, 'unknown-web');+ box.git(alpha.repo, 'worktree', 'add', '-q', unknown, '-b', 'web/unknown');+ // An existing stored registration may have no model even though new CLI joins require one.+ const legacyBoard = openBoard(join(alpha.repo, '.git', 'pullboard', 'board.sqlite'));+ try { register(legacyBoard, { lane: 'web', path: unknown }); }+ finally { closeBoard(legacyBoard); }+ box.run(unknown, 'claim', '3');+ box.run(alpha.web, 'shout', 'web-2', 'Known sender and unknown recipient');+ box.run(unknown, 'shout', 'all', 'Unknown sender and a lane-free recipient');+ box.run(alpha.repo, 'shout', 'person', 'A model decision', '--decision');+ box.run(alpha.repo, 'hold', 'web', '--reason', 'Wait for the model decision');+ box.run(alpha.repo, 'milestone', 'add', 'Model release', '--items', '1,2,3');+ const view = await startView(box);+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-model-names-chrome-'));+ let chrome;+ /** Read rendered text from the real browser without changing its API data. */+ const text = (selector) => chrome.evaluate(`document.querySelector(${JSON.stringify(selector)})?.textContent || ''`);+ /** Press a real control and wait until its requested pane is drawn. */+ const tab = async (name) => {+ await press(chrome, `document.querySelector('[data-tab="${name}"]')`);+ await settled(chrome, `view.tab === ${JSON.stringify(name)}`);+ };+ try {+ chrome = await openSnapshotChrome(executable, view.link.href, profile);+ await settled(chrome, "data?.project?.agents?.length === 3 && !!document.querySelector('#chain [data-item=\"1\"]')");+ for (const style of ['suffix', 'prefix']) {+ if (style === 'prefix') {+ const configFile = join(alpha.repo, 'pullboard.json');+ const config = JSON.parse(readFileSync(configFile, 'utf8'));+ config.agents = { ...(config.agents || {}), names: 'prefix' };+ writeFileSync(configFile, JSON.stringify(config, null, 2));+ box.git(alpha.repo, 'add', 'pullboard.json');+ box.git(alpha.repo, 'commit', '-q', '-m', 'chore: use prefix names');+ await chrome.evaluate('refresh()');+ }+ const expected = style === 'suffix'+ ? { builder: 'web-1 (' + model + ')', reviewer: 'coordinator (Claude)', unknown: 'web-2 (unknown)' }+ : { builder: 'gpt-6-with-a-very-long-model-declaration-for-readable-agent-names-web-1', reviewer: 'claude-coordinator', unknown: 'unknown-web-2' };+ const apiNames = JSON.parse(await chrome.evaluate('JSON.stringify(Object.fromEntries(data.project.agents.map(a => [a.agent_id, a.displayName])))'));+ assert.deepEqual(apiNames, { coordinator: expected.reviewer, 'web-1': expected.builder, 'web-2': expected.unknown }, `${style}: authoritative API names`);+ for (const width of [375, 1280]) {+ await chrome.send('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false });+ await settled(chrome, `innerWidth === ${width}`);+ const at = `${style} ${width}`;+ await tab('items');+ await press(chrome, 'document.querySelector("[data-state=active]")');+ await settled(chrome, '!!document.querySelector("#chain [data-item=\\"1\\"]")');+ assert.equal(await text('#chain [data-item="1"] .chip'), expected.builder, `${at}: item row holder`);+ assert.equal(await text('#chain [data-item="3"] .chip'), expected.unknown, `${at}: unknown model row`);+ await press(chrome, 'document.querySelector("#chain [data-item=\\"1\\"]")');+ await settled(chrome, 'view.item === 1');+ assert.ok((await text('#detail')).includes(expected.builder), `${at}: held item detail`);+ assert.equal(await text('#needs .row[data-go^="decide:"] .meta'), 'NEEDS YOU a decision, asked by ' + expected.reviewer, `${at}: Needs-you decision author`);+ assert.ok((await text('#needs .row[data-go="tab:shouts"] .meta')).includes('lane held by ' + expected.reviewer), `${at}: Needs-you lane holder`);+ await press(chrome, 'document.querySelector("[data-state=verified]")');+ await settled(chrome, '!!document.querySelector("#chain [data-item=\\"2\\"]")');+ await press(chrome, 'document.querySelector("#chain [data-item=\\"2\\"]")');+ await settled(chrome, 'view.item === 2');+ const detail = await text('#detail');+ assert.ok(detail.includes(expected.builder) && detail.includes(expected.reviewer), `${at}: builder and verifier detail`);+ assert.ok((await text('#detail .verdict .by')).startsWith(expected.reviewer), `${at}: verdict identity`);+ await tab('shouts');+ for (const [id, label] of [['web-1', expected.builder], ['web-2', expected.unknown]]) {+ assert.equal(await text(`#agents [data-agent="${id}"] .agent-who b`), label, `${at}: agent panel ${id}`);+ }+ if (!await chrome.evaluate('Boolean(view.open.idle)')) await press(chrome, 'document.querySelector("[data-fold=idle]")');+ assert.equal((await text('#agents [data-agent="coordinator"]')).trim(), expected.reviewer, `${at}: idle agent model`);+ const feed = await text('#feed');+ assert.ok(feed.includes(expected.builder) && feed.includes(expected.unknown) && feed.includes(expected.reviewer), `${at}: shout sender and recipient names`);+ assert.ok(feed.includes('→ all') && feed.includes('→ person'), `${at}: person and broadcast recipients keep their names`);+ const headers = JSON.parse(await chrome.evaluate(`JSON.stringify([...document.querySelectorAll('#feed .shout header')].map(header => {+ const rect = header.getBoundingClientRect();+ return { height: rect.height, line: parseFloat(getComputedStyle(header.querySelector('.who')).lineHeight),+ labels: [...header.querySelectorAll('.agent-label')].map(label => {+ const id = label.querySelector('.agent-id'), part = label.querySelector('.agent-model'), box = id.getBoundingClientRect();+ return { name: label.textContent, title: label.title, aria: label.getAttribute('aria-label'), id: id.textContent,+ left: box.left, right: box.right, headerLeft: rect.left, headerRight: rect.right, idWidth: id.clientWidth, idScroll: id.scrollWidth,+ ellipsis: getComputedStyle(part).textOverflow, clipped: part.scrollWidth > part.clientWidth };+ }) };+ }))`));+ assert.ok(headers.length > 0, `${at}: real shout headers render`);+ const accessible = await chrome.send('Accessibility.getFullAXTree');+ const names = accessible.nodes.filter(node => node.role?.value === 'group' && !node.ignored).map(node => node.name?.value);+ assert.ok(names.includes(expected.builder) && names.includes(expected.unknown) && names.includes(expected.reviewer), `${at}: Chrome exposes complete model names to assistive readers`);++ for (const header of headers) {+ assert.ok(header.height <= header.line + 1, `${at}: shout identity stays on one line: ${JSON.stringify(header)}`);+ for (const label of header.labels) {+ assert.equal(label.title, apiNames[label.id], `${at}: full API name stays in the tooltip`);+ assert.equal(label.aria, apiNames[label.id], `${at}: full API name stays accessible`);+ assert.equal(label.idWidth, label.idScroll, `${at}: the address is never clipped`);+ assert.ok(label.left >= label.headerLeft - 1 && label.right <= label.headerRight + 1, `${at}: address stays inside its header`);+ }+ }+ if (width === 375) assert.ok(headers.flatMap(h => h.labels).some(label => label.id === 'web-1' && label.clipped && label.ellipsis === 'ellipsis'), `${at}: only the long model shortens with an ellipsis`);++ await press(chrome, 'document.querySelector("#agents [data-agent=\\"web-1\\"]")');+ await settled(chrome, 'view.agent === "web-1"');+ assert.equal(await chrome.evaluate('view.agent'), 'web-1', `${at}: filtering retains the raw API id`);+ await press(chrome, 'document.querySelector("[data-agent=\\"\\"]")');+ await tab('activity');+ const activity = await text('#activity');+ assert.ok(activity.includes(expected.builder) && activity.includes(expected.unknown) && activity.includes(expected.reviewer), `${at}: activity identities`);+ await tab('roadmap');+ assert.doesNotMatch(await text('#roadmap'), /web-[12]|coordinator/, `${at}: roadmap rows name no agents`);+ await press(chrome, 'document.querySelector("#roadmap [data-go=\\"item:1\\"]")');+ await settled(chrome, 'view.tab === "items" && view.item === 1');+ assert.ok((await text('#detail')).includes(expected.builder), `${at}: roadmap item opens with the API identity`);+ assert.ok(await chrome.evaluate('document.documentElement.scrollWidth <= innerWidth'), `${at}: no sideways overflow`);+ }+ }+ assert.deepEqual(chrome.exceptions, [], 'all model-name views run without browser exceptions');+ } finally {+ if (chrome) await closeSnapshotChrome(chrome);+ rmSync(profile, { recursive: true, force: true });+ await view.stop();+ }+ });++ test('staged and exported boards carry API model display names [O8,N26,A10]', async () => {+ const box = machine();+ const alpha = project(box, 'model-export', SPEC, { agents: { names: 'prefix' } });+ box.run(alpha.web, 'join', 'web', '--model', 'GPT-6');+ const source = openBoard(join(alpha.repo, '.git', 'pullboard', 'board.sqlite'));+ const staged = openBoard(join(box.dir, 'staged-models.sqlite'));+ try {+ const before = exportBoard(source);+ importBoard(staged, before);+ const ordinary = projectState(alpha.repo);+ const borrowed = projectState(alpha.repo, { board: staged });+ assert.equal(ordinary.agents.find(a => a.agent_id === 'web-1').displayName, 'gpt-6-web-1', 'ordinary projector respects configured API name');+ assert.equal(borrowed.agents.find(a => a.agent_id === 'web-1').displayName, 'gpt-6-web-1', 'staged projector carries the same name');+ const directory = join(box.dir, 'exported-models');+ await exportView(alpha.repo, directory);+ const boardIds = readdirSync(join(directory, 'api', 'v1', 'boards'));+ assert.equal(boardIds.length, 1, 'the export contains the real fixture board');+ const snapshot = JSON.parse(readFileSync(join(directory, 'api', 'v1', 'boards', boardIds[0], 'state.json'), 'utf8'));+ assert.equal(snapshot.state.agents.find(a => a.agent_id === 'web-1').displayName, 'gpt-6-web-1', 'snapshot API retains the configured model name');+ assert.deepEqual(exportBoard(source), before, 'presentation does not change the real source board');+ assert.equal(staged.db.prepare('SELECT 1 AS open').get().open, 1, 'the borrowed file-backed board stays open');+ } finally {+ closeBoard(staged);+ closeBoard(source);+ }+ });++ test('the project switcher\'s arrow turns with the list [N26]', { timeout: 120_000 }, async (t) => {+ const executable = chromeExecutable();+ if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for project switcher checks.');+ const box = machine();+ project(box, 'arrow-alpha');+ project(box, 'arrow-beta');+ const view = await startView(box);+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-arrow-chrome-'));+ let chrome;+ /** The switcher's arrow as it reads: shown, its size, which way it points, and whether it animates. */+ const read = async () => JSON.parse(await chrome.evaluate(`JSON.stringify((() => {+ const arrow = document.querySelector('#proj-switch small'), svg = arrow.querySelector('svg'), s = getComputedStyle(arrow), r = svg.getBoundingClientRect();+ return {+ page: { width: document.documentElement.clientWidth, scroll: document.documentElement.scrollWidth },+ shown: s.display !== 'none' && r.width > 0, size: [Math.round(r.width), Math.round(r.height)], faint: s.color === (() => { const p = document.createElement('i'); p.style.color = 'var(--ink-faint)'; document.body.append(p); const c = getComputedStyle(p).color; p.remove(); return c; })(),+ turn: s.transform, motion: [s.transitionDuration, s.animationName], open: document.querySelector('#proj-switch').getAttribute('aria-expanded'),+ };+ })())`));+ const click = (selector) => chrome.evaluate(`document.querySelector(${JSON.stringify(selector)}).click()`);+ /** One drawn frame after a click: an arrow that animated would still be part way round. */+ const frame = () => chrome.evaluate('new Promise((done) => requestAnimationFrame(() => requestAnimationFrame(done)))');+ const DOWN = 'none', UP = 'matrix(-1, 0, 0, -1, 0, 0)';+ try {+ chrome = await openSnapshotChrome(executable, view.link.href, profile);+ await chrome.waitFor("typeof data === 'object' && data?.projects?.length === 2 && !!document.querySelector('#proj-list .proj.repo')");+ for (const scheme of ['light', 'dark']) {+ for (const width of [1280, 375]) {+ 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 at = `${width}px ${scheme}`;+ if (width === 1280) {+ // Docked, the name opens no list, so there is no arrow; collapsed, the list drops from the name.+ if (await chrome.evaluate("document.documentElement.dataset.side === 'collapsed'")) await click('#side-toggle');+ await chrome.waitFor("document.documentElement.dataset.side !== 'collapsed'");+ assert.equal((await read()).shown, false, `${at}: docked, with no list to drop, there is no arrow`);+ await click('#side-toggle');+ await chrome.waitFor("document.documentElement.dataset.side === 'collapsed'");+ }+ const closed = await read();+ assert.ok(closed.page.scroll <= closed.page.width, `${at}: no sideways scroll`);+ assert.deepEqual([closed.shown, closed.size, closed.faint, closed.open, closed.turn], [true, [16, 16], true, 'false', DOWN], `${at}: a 16px chevron in the faint ink, pointing down while the list is closed: ${JSON.stringify(closed)}`);+ assert.deepEqual(closed.motion, ['0s', 'none'], `${at}: the arrow never animates: ${JSON.stringify(closed.motion)}`);+ // Open, it points up at once: one frame after the click it is all the way round. Closed again, down.+ await click('#proj-switch');+ await frame();+ const opened = await read();+ assert.deepEqual([opened.open, opened.turn], ['true', UP], `${at}: open, it points up at once: ${JSON.stringify(opened)}`);+ await click('#proj-switch');+ await frame();+ const shut = await read();+ assert.deepEqual([shut.open, shut.turn], ['false', DOWN], `${at}: closed again, it points down at once: ${JSON.stringify(shut)}`);+ }+ }+ assert.deepEqual(chrome.exceptions, [], 'the page raises no uncaught exception');+ } finally {+ if (chrome) await closeSnapshotChrome(chrome);+ rmSync(profile, { recursive: true, force: true });+ await view.stop();+ }+ });+++test('search in the top bar finds anything on the board [N26]', { timeout: 150_000 }, async (t) => {+ const executable = chromeExecutable();+ if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for search checks.');+ const box = machine();+ const spec = `${SPEC}- G3 [approved, must] The greeting names the visitor. | gate: web test\n`;+ const alpha = project(box, 'finder', spec, { practice: 'ways.md' });+ writeFileSync(join(alpha.repo, 'ways.md'), '# Local rules\n\n## Team\n- R1 [approved, must] Every greeting is read by a person. | gate: review\n');+ box.run(alpha.repo, 'add', 'web', 'Farewell page', '--specs', 'G1', '--criterion', 'renders');+ // Seven items match, so the Items group shows five of them and says how many there are.+ for (let n = 1; n <= 7; n += 1) box.run(alpha.repo, 'add', 'web', `Greeting variant ${n}`, '--specs', 'G1', '--criterion', 'renders');+ box.run(alpha.web, 'shout', 'coordinator', 'The greeting is ready for review.');+ box.run(alpha.web, 'shout', 'coordinator', 'Should the greeting wave?', '--decision');+ const view = await startView(box);+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-finder-chrome-'));+ let chrome;+ /** The top bar's search and its results as they read. */+ const read = async () => JSON.parse(await chrome.evaluate(`JSON.stringify((() => {+ const box = (e) => { if (!e) return null; const r = e.getBoundingClientRect(); return { left: r.left, right: r.right, top: r.top, bottom: r.bottom, width: r.width, height: r.height }; };+ const results = document.querySelector('#find-results');+ return {+ page: { width: document.documentElement.clientWidth, scroll: document.documentElement.scrollWidth, body: document.body.scrollWidth },+ inTop: !!document.querySelector('.top .top-find #q'), toolbar: [...document.querySelector('.toolbar').children].filter((e) => e.offsetParent !== null || e.tagName === 'SELECT').map((e) => e.id || e.className),+ field: box(document.querySelector('#q')), tabs: box(document.querySelector('#tabs')), top: box(document.querySelector('header.top')), theme: box(document.querySelector('#theme')),+ bar: [...document.querySelectorAll('.toolbar #state-chips button, .toolbar #lane-pick, .toolbar #new-item')].filter((e) => e.getClientRects().length > 0)+ .map((e) => ({ name: e.dataset.state || e.id, on: e.classList.contains('on'), middle: Math.round(e.getBoundingClientRect().top + e.getBoundingClientRect().height / 2) })),+ shoutIds: data.project.shouts.map((x) => '#' + x.shout_id), focused: document.activeElement?.id ?? null, value: document.querySelector('#q').value,+ shown: !results.hidden, groups: [...results.querySelectorAll('h4')].map((h) => [h.firstChild.textContent, h.querySelector('span').textContent]),+ hits: [...results.querySelectorAll('.find-hit')].map((hit) => ({ go: hit.dataset.find, id: hit.querySelector('code').textContent, note: hit.querySelector('small').textContent, on: hit.classList.contains('on') })),+ tab: view.tab, item: view.item, spec: view.row.spec, doctrine: view.row.doctrine,+ };+ })())`));+ const key = async (name, code, keyCode, text) => {+ for (const type of ['keyDown', 'keyUp']) await chrome.send('Input.dispatchKeyEvent', { type, key: name, code, windowsVirtualKeyCode: keyCode, ...(type === 'keyDown' && text ? { text, unmodifiedText: text } : {}) });+ };+ const tap = async (selector) => {+ const point = JSON.parse(await chrome.evaluate(`(() => { const r = document.querySelector(${JSON.stringify(selector)}).getBoundingClientRect(); return JSON.stringify({ x: r.x + r.width / 2, y: r.y + r.height / 2 }); })()`));+ for (const type of ['mousePressed', 'mouseReleased']) await chrome.send('Input.dispatchMouseEvent', { type, ...point, button: 'left', clickCount: 1 });+ };+ /** Type the words into the search as a keyboard does, from an empty field. */+ const search = async (words) => {+ await chrome.evaluate("document.querySelector('#q').focus(); document.querySelector('#q').select()");+ await chrome.send('Input.insertText', { text: words });+ await chrome.waitFor(`document.querySelector('#q').value === ${JSON.stringify(words)} && !document.querySelector('#find-results').hidden`);+ };+ try {+ chrome = await openSnapshotChrome(executable, view.link.href, profile);+ await chrome.waitFor("typeof data === 'object' && data?.project?.items?.length === 8 && data.project.shouts.length >= 2");+ for (const scheme of ['light', 'dark']) {+ for (const width of [1280, 375]) {+ 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`);+ await chrome.evaluate("document.querySelector('[data-tab=items]').click()");+ const at = `${width}px ${scheme}`;+ // The Items toolbar is one row: Active, Verified and All, the lane picker, New item at its end; on a phone Active+ // and Verified with New item, All and the lane picker dropped.+ const bar = (await read()).bar, names = bar.map((part) => part.name);+ if (width === 375) assert.deepEqual(names, ['active', 'verified', 'new-item'], `${at}: on a phone the toolbar is Active, Verified and New item`);+ else assert.deepEqual([names.slice(0, 3), names.at(-1)], [['active', 'verified', 'all'], 'new-item'], `${at}: the toolbar's states, then New item at its end`);+ assert.ok(bar.every((part) => Math.abs(part.middle - bar[0].middle) <= 2), `${at}: the toolbar is one row: ${JSON.stringify(bar)}`);+ await search('greeting');+ const r = await read();+ assert.ok(r.page.scroll <= r.page.width && r.page.body <= r.page.width, `${at}: no sideways scroll`);+ // The search is the top bar's; the Items toolbar keeps the states, the lane picker and New item.+ assert.ok(r.inTop, `${at}: the search sits in the top bar`);+ assert.deepEqual(r.toolbar, ['state-chips', 'lane-pick', 'new-item'], `${at}: the Items toolbar has no search field`);+ if (width === 375) assert.ok(r.field.top >= r.tabs.bottom - 1 && r.field.width >= r.page.width - 40, `${at}: on a phone the search is its own row under the tabs: ${JSON.stringify([r.field, r.tabs])}`);+ else assert.ok(Math.abs((r.field.top + r.field.height / 2) - (r.top.top + r.top.height / 2)) <= 2 && r.field.left >= r.tabs.right && r.field.right <= r.theme.left, `${at}: the search sits in the top bar between the tabs and the theme button: ${JSON.stringify([r.tabs, r.field, r.theme, r.top])}`);+ // Results group by kind, five a group with how many there are, the first ready for Enter.+ assert.deepEqual(r.groups, [['Items', '5 of 7'], ['Spec', '1'], ['Doctrine', '1'], ['Shouts', '2']], `${at}: grouped, newest first, five a group`);+ assert.deepEqual([r.hits.length, r.hits.findIndex((hit) => hit.on), r.hits.slice(5).map((hit) => hit.id)], [9, 0, ['G3', 'R1', ...r.shoutIds]], `${at}: every group's results, the first highlighted`);+ // A shout's result is its own id, its words and its kind, newest first.+ assert.deepEqual(r.hits.slice(7).map((hit) => hit.note), ['decision', 'shout'], `${at}: a shout's result names its kind: ${JSON.stringify(r.hits.slice(7))}`);+ await key('Escape', 'Escape', 27);+ const cleared = await read();+ assert.deepEqual([cleared.value, cleared.shown], ['', false], `${at}: Esc clears the search and closes its results`);+ }+ }++ // The arrows move the highlight and Enter opens it: here the third item, the third newest.+ await chrome.send('Emulation.setDeviceMetricsOverride', { width: 1280, height: 900, deviceScaleFactor: 1, mobile: false });+ await chrome.send('Emulation.setEmulatedMedia', { features: [{ name: 'prefers-color-scheme', value: 'light' }] });+ await chrome.waitFor('innerWidth === 1280');+ await search('greeting');+ let r = await read();+ const third = r.hits[2].go;+ await key('ArrowDown', 'ArrowDown', 40);+ await key('ArrowDown', 'ArrowDown', 40);+ assert.equal((await read()).hits.findIndex((hit) => hit.on), 2, 'down twice highlights the third');+ await key('ArrowUp', 'ArrowUp', 38);+ await key('ArrowDown', 'ArrowDown', 40);+ await key('Enter', 'Enter', 13, '\r');+ await chrome.waitFor(`view.tab === 'items' && view.item === ${Number(third.slice(5))} && document.querySelector('#find-results').hidden`);++ // On a phone, a search that opens an item shows All, since All is then the selected filter, so the person sees where+ // they are and can leave it; Active again drops All.+ for (const scheme of ['light', 'dark']) {+ await chrome.send('Emulation.setDeviceMetricsOverride', { width: 375, height: 900, deviceScaleFactor: 1, mobile: false });+ await chrome.send('Emulation.setEmulatedMedia', { features: [{ name: 'prefers-color-scheme', value: scheme }] });+ await chrome.waitFor(`innerWidth === 375 && matchMedia('(prefers-color-scheme: ${scheme})').matches`);+ await search('greeting');+ await key('Enter', 'Enter', 13, '\r');+ await chrome.waitFor("view.tab === 'items' && !!view.item && document.querySelector('#find-results').hidden");+ const opened = (await read()).bar;+ assert.deepEqual(opened.map((part) => [part.name, part.on]), [['active', false], ['verified', false], ['all', true], ['new-item', false]], `375px ${scheme}: a search that opens an item shows All, selected: ${JSON.stringify(opened)}`);+ assert.ok(opened.every((part) => Math.abs(part.middle - opened[0].middle) <= 2), `375px ${scheme}: still one row: ${JSON.stringify(opened)}`);+ await chrome.evaluate("document.querySelector('[data-state=active]').click()");+ assert.deepEqual((await read()).bar.map((part) => part.name), ['active', 'verified', 'new-item'], `375px ${scheme}: back on Active, All drops again`);+ }+ await chrome.send('Emulation.setDeviceMetricsOverride', { width: 1280, height: 900, deviceScaleFactor: 1, mobile: false });+ await chrome.send('Emulation.setEmulatedMedia', { features: [{ name: 'prefers-color-scheme', value: 'light' }] });+ await chrome.waitFor('innerWidth === 1280');++ // Spec rows and Doctrine rules read newest first by when each was added, not by where it sits in its file: R1 is+ // committed, then R2 and G4 appended, then G5 inserted above G3.+ box.git(alpha.repo, 'add', 'ways.md');+ box.git(alpha.repo, 'commit', '-q', '-m', 'docs(rules): keep the local rules [G1]');+ writeFileSync(join(alpha.repo, 'ways.md'), '# Local rules\n\n## Team\n- R1 [approved, must] Every greeting is read by a person. | gate: review\n- R2 [approved, must] A greeting never shouts. | gate: review\n');+ writeFileSync(join(alpha.repo, 'SPEC.md'), `${spec}- G4 [approved, must] The greeting waves back. | gate: web test\n`);+ box.git(alpha.repo, 'commit', '-q', '-am', 'docs(spec): the greeting waves back [G1]');+ writeFileSync(join(alpha.repo, 'SPEC.md'), spec.replace('- G3 ', '- G5 [approved, must] The greeting fits a phone. | gate: web test\n- G3 ') + '- G4 [approved, must] The greeting waves back. | gate: web test\n');+ box.git(alpha.repo, 'commit', '-q', '-am', 'docs(spec): the greeting fits a phone [G1]');+ await chrome.waitFor("data.project.spec.some((row) => row.id === 'G5') && data.project.practice.some((row) => row.id === 'R2')", 15_000);+ await search('greeting');+ const added = (await read()).hits.filter((hit) => /^(spec|doctrine):/.test(hit.go)).map((hit) => hit.id);+ assert.deepEqual(added, ['G5', 'G4', 'G3', 'R2', 'R1'], `Spec and Doctrine newest first by when each row was added: ${JSON.stringify(added)}`);+ await key('Escape', 'Escape', 27);++ // A click opens a Spec row, a Doctrine rule or a shout where it lives.+ await search('greeting');+ await tap('#find-results [data-find="spec:G3"]');+ await chrome.waitFor("view.tab === 'spec' && view.row.spec === 'G3' && document.querySelector('#spec-detail h2 span')?.textContent === 'G3'");+ await search('greeting');+ await tap('#find-results [data-find="doctrine:R1"]');+ await chrome.waitFor("view.tab === 'doctrine' && view.row.doctrine === 'R1' && document.querySelector('#doctrine-detail h2 span')?.textContent === 'R1'");+ await search('greeting');+ const shout = (await read()).hits.find((hit) => hit.go.startsWith('shout:')).go;+ await tap(`#find-results [data-find="${shout}"]`);+ await chrome.waitFor(`view.tab === 'shouts' && document.getElementById('shout-${shout.slice(6)}')?.classList.contains('found')`);++ // "/" goes to the search from the page, never from a field.+ await chrome.evaluate("document.activeElement.blur(); document.body.focus()");+ await key('/', 'Slash', 191, '/');+ r = await read();+ const selected = await chrome.evaluate("(() => { const q = document.querySelector('#q'); return q.selectionStart === 0 && q.selectionEnd === q.value.length; })()");+ assert.deepEqual([r.focused, selected], ['q', true], '"/" puts the cursor in the search, its last words selected to type over');+ await chrome.evaluate("document.querySelector('#shout-text').focus()");+ await key('/', 'Slash', 191, '/');+ assert.equal(await chrome.evaluate("document.querySelector('#shout-text').value"), '/', 'and in a field it is only a slash');++ // On a phone the lane picker shows while a lane narrows the list, so the person sees where they are and can leave+ // it; with every lane shown it drops again. A coordinator item makes a second lane to pick between.+ box.run(alpha.repo, 'add', 'coordinator', 'Plan the greeting release', '--criterion', 'planned');+ await chrome.waitFor('data.project.items.length === 9', 15_000);+ const lane = (name) => chrome.evaluate(`(() => { const pick = document.querySelector('#lane-pick'); pick.value = ${JSON.stringify(name)}; pick.dispatchEvent(new Event('change', { bubbles: true })); })()`);+ for (const scheme of ['light', 'dark']) {+ await chrome.send('Emulation.setDeviceMetricsOverride', { width: 1280, height: 900, deviceScaleFactor: 1, mobile: false });+ await chrome.send('Emulation.setEmulatedMedia', { features: [{ name: 'prefers-color-scheme', value: scheme }] });+ await chrome.waitFor(`innerWidth === 1280 && matchMedia('(prefers-color-scheme: ${scheme})').matches`);+ await chrome.evaluate("document.querySelector('[data-tab=items]').click(); document.querySelector('[data-state=active]').click()");+ await lane('web');+ await chrome.waitFor("view.lane === 'web'");+ assert.ok((await read()).bar.some((part) => part.name === 'lane-pick'), `1280px ${scheme}: the lane picker is in the toolbar`);+ await chrome.send('Emulation.setDeviceMetricsOverride', { width: 375, height: 900, deviceScaleFactor: 1, mobile: false });+ await chrome.waitFor('innerWidth === 375');+ const narrowed = await read();+ assert.deepEqual(narrowed.bar.map((part) => part.name), ['active', 'verified', 'lane-pick', 'new-item'], `375px ${scheme}: a picked lane keeps its picker: ${JSON.stringify(narrowed.bar)}`);+ assert.ok(narrowed.bar.every((part) => Math.abs(part.middle - narrowed.bar[0].middle) <= 2) && narrowed.page.scroll <= narrowed.page.width, `375px ${scheme}: still one row, no sideways scroll: ${JSON.stringify(narrowed)}`);+ // With the lane still picked, a search that opens an item makes All the selected filter too: both filters show,+ // New item is a + that is still named New item, and the row holds.+ await search('greeting');+ await key('Enter', 'Enter', 13, '\r');+ await chrome.waitFor("view.tab === 'items' && !!view.item && view.state === 'all' && view.lane === 'web' && document.querySelector('#find-results').hidden");+ const both = await read();+ assert.deepEqual(both.bar.map((part) => [part.name, part.on]), [['active', false], ['verified', false], ['all', true], ['lane-pick', false], ['new-item', false]], `375px ${scheme}: All and the picked lane both show: ${JSON.stringify(both.bar)}`);+ assert.ok(both.bar.every((part) => Math.abs(part.middle - both.bar[0].middle) <= 2) && both.page.scroll <= both.page.width && both.page.body <= both.page.width, `375px ${scheme}: both filters on one row, no sideways scroll: ${JSON.stringify(both)}`);+ assert.deepEqual(JSON.parse(await chrome.evaluate("JSON.stringify((() => { const go = document.querySelector('#new-item'); return [go.textContent, getComputedStyle(go, '::before').content, Math.round(go.getBoundingClientRect().width)]; })())")), ['New item', '"+"', 44], `375px ${scheme}: New item is a 44px + that keeps its name`);+ // A long lane name gives way rather than the row: with the coordinator lane picked, still one row.+ await lane('coordinator');+ await chrome.waitFor("view.lane === 'coordinator'");+ const long = await read();+ assert.deepEqual(long.bar.map((part) => part.name), ['active', 'verified', 'all', 'lane-pick', 'new-item'], `375px ${scheme}: a long lane keeps every control: ${JSON.stringify(long.bar)}`);+ assert.ok(long.bar.every((part) => Math.abs(part.middle - long.bar[0].middle) <= 2) && long.page.scroll <= long.page.width && long.page.body <= long.page.width, `375px ${scheme}: a long lane name gives way, not the row: ${JSON.stringify(long)}`);+ await chrome.evaluate("document.querySelector('[data-state=active]').click()");+ await lane('');+ await chrome.waitFor('view.lane === null');+ assert.deepEqual((await read()).bar.map((part) => part.name), ['active', 'verified', 'new-item'], `375px ${scheme}: every lane shown, the picker drops again`);+ assert.equal(await chrome.evaluate("getComputedStyle(document.querySelector('#new-item'), '::before').content"), 'none', `375px ${scheme}: with only Active and Verified, New item has its words`);+ }+ await chrome.send('Emulation.setDeviceMetricsOverride', { width: 1280, height: 900, deviceScaleFactor: 1, mobile: false });+ await chrome.send('Emulation.setEmulatedMedia', { features: [{ name: 'prefers-color-scheme', value: 'light' }] });+ await chrome.waitFor('innerWidth === 1280');+ assert.deepEqual(chrome.exceptions, [], 'the page raises no uncaught exception');+ } finally {+ if (chrome) await closeSnapshotChrome(chrome);+ rmSync(profile, { recursive: true, force: true });+ await view.stop();+ }+});