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): expanding a row paints from its summary at once [N26]
Corey Olson9509dd2e4981
diff --git a/src/cockpit.js b/src/cockpit.jsindex b4d8b880..fb42b4e3 100644--- a/src/cockpit.js+++ b/src/cockpit.js@@ -802,6 +802,7 @@ function milestoneItem(entry, p) {const label = local ? '#' + entry.id : String(entry.id);const expanded = view.tab === 'roadmap' && view.roadmapOpen.get(JSON.stringify([view.root, 'i:' + label])) === true;const detail = item && expanded ? detailOf(source, item, true, root) : null;+ if (item && !expanded) roadmapAhead.set('i:' + label, () => detailOf(source, item, 'ahead', root));// A status the lifecycle declares; the roadmap says unavailable or missing for an item it could not read.const read = item || (FLOW.states.some((state) => state.id === entry.status) ? { status: entry.status, verdict: null } : null);return {@@ -815,8 +816,10 @@ function milestoneItem(entry, p) {holds: root === view.root ? source.holds : source.laneHolds, items: source.items, agents: source.agents, state: stateOf,address: (id) => itemAddress(id, root), board: root === view.root ? null : root,releases: (p.milestones || []).filter((milestone) => milestone.items.some((ref) => ref.id === entry.id)).map((milestone) => milestone.name),- loading: detail?.loading, error: detail?.error,+ error: detail?.error,}) : null,+ // Until its omitted fields arrive, an expanded row paints what its summary holds and fills the rest in place (#1039).+ pending: Boolean(detail?.loading),stage: entry.state === 'landed' ? 'merged' : entry.state === 'accepted' ? 'accepted' : item ? pipelineStage(item) : entry.status,word: entry.status,open: item ? { root, id } : null,@@ -830,6 +833,7 @@ function milestoneItem(entry, p) {function updateRoadmapPanel() {const panel = $('roadmap-panel');if (!panel || view.tab !== 'roadmap') return;+ aheadRoadmapRows();const entries = [...panel.querySelectorAll('[data-roadmap-jump]')].map((button) => ({key: button.dataset.roadmapJump,target: $('roadmap-list').querySelector('[data-key="' + CSS.escape(button.dataset.roadmapJump) + '"]'),@@ -884,7 +888,7 @@ function milestoneRow(row, titles) {const detail = row.block ? row.block.detail : '<p>' + esc(row.why || row.word) + '</p>';// Every row stays on the Roadmap; only its explicit Open in Items link navigates (#605).return '<li><div ' + toggle + ' role="button" tabindex="0">' + inner + '</div>'- + '<div class="milestone-why"' + (open ? '' : ' hidden') + '>' + detail + '</div></li>';+ + '<div class="milestone-why"' + (open ? '' : ' hidden') + (row.pending ? ' aria-busy="true"' : '') + '>' + detail + '</div></li>';}/** Read supplied landed counts and explicit shipments; keep old exports readable and omit withdrawn rows. */@@ -1098,6 +1102,7 @@ function render() {// Every refresh redraws the Roadmap. Left alone, that would send the phone's release chips back to their start// and the panel back to its top under a person mid-scroll, so both keep where they were.const chipsAt = $('roadmap-releases')?.scrollLeft ?? 0, panelAt = $('roadmap-panel')?.scrollTop ?? 0;+ roadmapAhead.clear();$('roadmap').innerHTML = roadmapCards(p, titles);// The mark sets its chip in bold, which widens it, and the fresh row has no mark yet. Restored first, the scroll// would clamp to a row narrower by that bold and leave the chips short of where they were (#452).@@ -1230,8 +1235,11 @@ function render() {$('detail').hidden = adding;if (!selected) $('detail').innerHTML = '<div class="empty">' + (view.tab === 'items' && view.addressDetail !== null && view.addressDetail !== 'pipeline' ? 'No item #' + esc(view.addressDetail) + ' exists here.' : 'Pick an item to see its criterion, verdicts and history.') + '</div>';const opened = selected && !view.adding ? detailOf(p, selected, view.tab === 'items' && data.root === view.root) : null;- if (opened && !opened.item) $('detail').innerHTML = '<div class="stack"><p class="detail-wait muted" role="status">'- + (opened.error ? 'Could not load #' + selected.id + ': ' + esc(opened.error) : 'Loading #' + selected.id + '…') + '</p></div>';+ /** An item's heading: its id, title, state, lane and route, all of which its summary holds. */+ const head = (item, s = stateOf(item)) => '<div><h2><span>#' + item.id + '</span>' + rich(item.title, titles) + '</h2><div class="meta spaced">' + (s === 'open' ? openChip(item) : chip(s)) + staleChip(item) + '<span class="chip">' + esc(item.lane) + '</span><span class="chip">' + esc(item.route) + '</span></div></div>';+ if (opened?.error) $('detail').innerHTML = '<div class="stack"><p class="detail-wait muted" role="status">Could not load #' + selected.id + ': ' + esc(opened.error) + '</p></div>';+ // Until its omitted fields arrive, an opened item paints its heading from its summary and fills the rest in place (#1039).+ else if (opened?.loading) $('detail').innerHTML = '<div class="stack" aria-busy="true">' + head(selected) + '</div>';const item = opened?.item;if (item) {const s = stateOf(item);@@ -1258,7 +1266,7 @@ function render() {// Why it came back is the first thing the person reads; the verdicts before it stay below.const back = rejected(item);const earlier = back ? item.verdicts.slice(0, -1) : item.verdicts;- $('detail').innerHTML = '<div class="stack"><div><h2><span>#' + item.id + '</span>' + rich(item.title, titles) + '</h2><div class="meta spaced">' + (s === 'open' ? openChip(item) : chip(s)) + staleChip(item) + '<span class="chip">' + esc(item.lane) + '</span><span class="chip">' + esc(item.route) + '</span></div></div>'+ $('detail').innerHTML = '<div class="stack">' + head(item, s)+ (back ? '<div class="sentback"><h3>Sent back' + (s === 'building' ? ', being reworked' : s === 'verify' ? ', resubmitted' : s === 'withdrawn' ? ', then withdrawn' : '') + '</h3>' + verdictHtml(item.verdict, titles) + '</div>' : '')+ (item.criterion ? '<div><h3>Criterion</h3><div class="text">' + rich(item.criterion, titles) + '</div></div>' : '')+ (item.check ? '<div><h3>Check</h3><dl class="kv"><dt>command</dt><dd><code>' + esc(item.check) + '</code></dd><dt>baseline</dt><dd><span class="chip ' + baselineClass + '">' + esc(baseline?.result ?? 'not recorded') + '</span></dd></dl>'diff --git a/src/view/page-script-3.js b/src/view/page-script-3.jsindex b78f53ee..937e199f 100644--- a/src/view/page-script-3.js+++ b/src/view/page-script-3.js@@ -263,37 +263,84 @@ const fullItems = (project) => project.items.every((item) => Array.isArray(item./** Text available locally for an item before the API searches criteria omitted from summaries. */const searchedText = (item) => ('#' + item.id + ' ' + item.title + ' ' + item.lane + ' ' + item.specs.join(' ') + ' ' + (item.criterion || '')).toLowerCase();-/** Whether the board has a gap in its retained events or an item event newer than a detail read. */+/** Whether the board's retained events hold an event of this item newer than a detail read. */function movedSince(project, id, cursor) {- const events = project.events || [];- if (!events.length || events[0].event_id <= cursor) return false;- if (events.at(-1).event_id > cursor + 1) return true;- return events.some((event) => event.event_id > cursor && event.item_id === id);+ return (project.events || []).some((event) => event.event_id > cursor && event.item_id === id);}-/** Load one opened item's omitted fields, retaining them only while its summary and event cursor stay current. */+/**+ * What says an item has moved: its last update, status and counts. A whole summary can differ between two polls of an+ * item that has not moved, and an event gap says nothing about this item, so neither drops a detail it read (#1039).+ */+const movedKey = (item) => JSON.stringify([item.id, item.updatedAt, item.status, item.counts]);++// Reads ahead of an expand, two at a time, so they never crowd out one the person asked for (#1039).+const aheadQueue = [];+let aheadBusy = 0;++/** Start the next queued reads ahead while fewer than two are on their way. */+function aheadNext() {+ while (aheadBusy < 2 && aheadQueue.length) {+ const entry = aheadQueue.shift();+ if (!entry.start) continue;+ aheadBusy++;+ entry.start().finally(() => { aheadBusy--; aheadNext(); });+ }+}++/**+ * Load one item's omitted fields, retaining them while the item has not moved. ask is true for an item on show and+ * 'ahead' for a Roadmap row on screen, read in the background so its expand fills at once (#1039).+ */function detailOf(project, item, ask, root = view.root) {if (Array.isArray(item.history)) return { item };- const drawnRoot = view.root, key = root + '\\n' + item.id, summary = JSON.stringify(item);+ const drawnRoot = view.root, key = root + '\\n' + item.id, moved = movedKey(item), shows = ask && ask !== 'ahead';const kept = itemDetails.get(key);/** Keep the prior detail visible during a refresh, or return the short initial loading state. */const waiting = (entry) => (entry?.shown ? { item: { ...item, ...entry.shown } } : { loading: true });- if (kept?.loading) return waiting(kept);- if (kept && kept.summary === summary && !movedSince(project, item.id, kept.cursor) && !(ask && kept.error && Date.now() - kept.failedAt >= 2_500)) {+ if (kept?.loading) {+ // Asked for while it waits in the queue ahead, it starts now and draws when it lands.+ if (shows && !kept.wanted) { kept.wanted = true; if (kept.start) detailRead = kept.start(); }+ return waiting(kept);+ }+ if (kept && kept.moved === moved && !movedSince(project, item.id, kept.cursor) && !(shows && kept.error && Date.now() - kept.failedAt >= 2_500)) {return kept.error ? { error: kept.error } : { item: { ...item, ...kept.detail } };}if (!ask) return waiting(kept && { shown: kept.detail });- const entry = { loading: true, summary, cursor: project.events?.[0]?.event_id ?? 0, detail: null, error: null, shown: kept?.detail ?? null };+ const entry = { loading: true, wanted: shows, moved, cursor: project.events?.[0]?.event_id ?? 0, detail: null, error: null, shown: kept?.detail ?? null };itemDetails.set(key, entry);- detailRead = api(boardPath(root) + '/items/' + encodeURIComponent(String(item.id))).then((reply) => { entry.detail = reply.item; },- // A failed read is not the answer: while this item stays open it reads again in 3 s, so a dropped request recovers (#908).- (error) => { entry.error = String(error.message || error); entry.failedAt = Date.now(); setTimeout(() => { if (view.root === drawnRoot && view.item === item.id) render(); }, 3_000); }).finally(() => {- entry.loading = false;- if (view.root === drawnRoot && ((root === view.root && view.item === item.id) || view.tab === 'roadmap')) render();- });+ entry.start = () => {+ entry.start = null;+ return api(boardPath(root) + '/items/' + encodeURIComponent(String(item.id))).then((reply) => { entry.detail = reply.item; }, (error) => {+ // A read ahead that fails is forgotten, so the expand reads again; one on show reads again in 3 s while this item stays open (#908).+ if (!entry.wanted) { if (itemDetails.get(key) === entry) itemDetails.delete(key); return; }+ entry.error = String(error.message || error); entry.failedAt = Date.now(); setTimeout(() => { if (view.root === drawnRoot && view.item === item.id) render(); }, 3_000);+ }).finally(() => {+ entry.loading = false;+ if (entry.wanted && view.root === drawnRoot && ((root === view.root && view.item === item.id) || view.tab === 'roadmap')) render();+ });+ };+ if (shows) detailRead = entry.start();+ else { aheadQueue.push(entry); aheadNext(); }return waiting(entry);}+// The rows the last Roadmap draw can read ahead, by row key (#1039).+const roadmapAhead = new Map();+let aheadFrame = 0;++/** Read ahead the detail of each folded Roadmap row on screen, once per frame, so its first expand fills at once (#1039). */+function aheadRoadmapRows() {+ if (aheadFrame || view.tab !== 'roadmap') return;+ aheadFrame = requestAnimationFrame(() => {+ aheadFrame = 0;+ for (const row of document.querySelectorAll('#roadmap .milestone-item[aria-expanded=false]')) {+ const box = row.getBoundingClientRect();+ if (box.height && box.bottom > 0 && box.top < innerHeight) roadmapAhead.get(row.dataset.roadmapKey)?.();+ }+ });+}+/** Search full snapshots locally and summary states through the API, once per query and board. */function searchIds(project, words) {const query = words.trim().toLowerCase();diff --git a/test/cockpit/detail.test.js b/test/cockpit/detail.test.jsindex c196fb63..a5b3c643 100644--- a/test/cockpit/detail.test.js+++ b/test/cockpit/detail.test.js@@ -33,6 +33,7 @@ const DETAIL = `(() => {return {title: detail.querySelector('h2')?.innerText ?? null,waiting: detail.querySelector('.detail-wait')?.textContent ?? null,+ busy: !!detail.querySelector('[aria-busy]'),criterion: part('Criterion')?.querySelector('.text').innerText ?? null,check: part('Check') ? [part('Check').querySelector('code').textContent, part('Check').querySelector('.chip').textContent] : null,brief: part('Brief')?.querySelector('.text').innerText ?? null,@@ -88,12 +89,13 @@ test('opening an item loads its detail on demand [N26,A2]', { timeout: 150_000 }await chrome.waitFor("!!document.querySelector('#find-results [data-find=\"item:2\"]')");assert.deepEqual(itemReads(await chrome.stable('window.__pbReads')), ['items?q=zeppelin'], 'the search sends its words to the API once');await press(chrome, "document.querySelector('#find-results [data-find=\"item:2\"]')");- await chrome.waitFor("view.tab === 'items' && view.item === 2 && !!document.querySelector('#detail .detail-wait')");+ await chrome.waitFor("view.tab === 'items' && view.item === 2 && !!document.querySelector('#detail [aria-busy] h2')");const waiting = await chrome.stable(DETAIL);- assert.equal(waiting.waiting, 'Loading #2…', 'a short loading line shows while the detail is on its way');- assert.deepEqual([waiting.title, waiting.criterion], [null, null], 'and no part of the item until it arrives');+ assert.equal(waiting.waiting, null, 'no loading line shows while the detail is on its way');+ assert.match(waiting.title, /#2\s*Farewell page/u, 'the item paints its heading from its summary at once');+ assert.equal(waiting.criterion, null, 'the omitted fields wait for the detail');await chrome.stable('window.__pbRelease()');- await chrome.waitFor("view.item === 2 && !document.querySelector('#detail .detail-wait') && !!document.querySelector('#detail .tl')");+ await chrome.waitFor("view.item === 2 && !document.querySelector('#detail [aria-busy]') && !!document.querySelector('#detail .tl')");const farewell = await chrome.stable(DETAIL);assert.equal(farewell.criterion, 'The farewell mentions the zeppelin.');assert.deepEqual(farewell.moves, ['add', 'claim', 'submit']);@@ -103,10 +105,10 @@ test('opening an item loads its detail on demand [N26,A2]', { timeout: 150_000 }await chrome.stable("(() => { const q = document.querySelector('#q'); q.value = ''; q.dispatchEvent(new Event('input', { bubbles: true })); q.blur(); })()");await chooseFilter(chrome, 'state:all');await press(chrome, "document.querySelector('#chain .row[data-item=\"1\"]')");- await chrome.waitFor("view.item === 1 && !document.querySelector('#detail .detail-wait') && !!document.querySelector('#detail .tl')");+ await chrome.waitFor("view.item === 1 && !document.querySelector('#detail [aria-busy]') && !!document.querySelector('#detail .tl')");const greeting = await chrome.stable(DETAIL);assert.equal(greeting.waiting, null, 'the detail has arrived');- delete greeting.waiting;+ delete greeting.waiting; delete greeting.busy;assert.deepEqual(greeting, {title: '#1Offline greeting',criterion: 'The greeting renders from the snapshot alone.',diff --git a/test/cockpit/roadmap.test.js b/test/cockpit/roadmap.test.jsindex 664352ac..b9280149 100644--- a/test/cockpit/roadmap.test.js+++ b/test/cockpit/roadmap.test.js@@ -1,10 +1,12 @@/** Cockpit roadmap checks, using the shared real-board fixtures [N26]. */import assert from 'node:assert/strict';+import { spawn, spawnSync } from 'node:child_process';import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { test } from 'node:test';-import { tapTarget, SPEC, machine, project, build, sendBack, fetchLive, startView, target, accept, chromeExecutable, openSnapshotChrome, closeSnapshotChrome, press, travel, pressedInto, settled, roadmapRow, showing, readRoadmap, openRoadmapParts, tabBar, proofShot, pickProject, chooseFilter } from './fixture.js';+import { generateStressBoard, removeStressBoard } from './perf/generate.mjs';+import { BIN, tapTarget, SPEC, machine, project, build, sendBack, fetchLive, startView, target, accept, chromeExecutable, openSnapshotChrome, closeSnapshotChrome, press, travel, pressedInto, settled, roadmapRow, showing, readRoadmap, openRoadmapParts, tabBar, proofShot, pickProject, chooseFilter } from './fixture.js';/** The roadmap state a failed wait saw: its tab, rows, row ids and expansion, dots and open detail (#938). */@@ -1056,7 +1058,7 @@ test('a blocked roadmap item shows its dot and expands to say why [N26]', { time/** Read the visible detail only, after its optional first detail request settles. */async function opened(id) {await press(chrome, row(id));- await chrome.waitFor(`${row(id)}?.getAttribute('aria-expanded')==='true' && !${row(id)}.parentElement.querySelector('.roadmap-loading')`);+ await chrome.waitFor(`${row(id)}?.getAttribute('aria-expanded')==='true' && !${row(id)}.parentElement.querySelector('.milestone-why[aria-busy]')`);return await chrome.stable(`${row(id)}.parentElement.querySelector('.milestone-why').textContent`);}/** Count item reads, excluding ordinary board polling. */@@ -1077,7 +1079,7 @@ test('a blocked roadmap item shows its dot and expands to say why [N26]', { timeassert.equal(await chrome.stable(`${row('#2')}.parentElement.querySelectorAll('.roadmap-criterion em').length`),0,'criterion markup stays escaped');assert.match(blocked, /Waits on#1 building.*web-2.*since/u, 'dependency includes state, holder and local time');assert.match(blocked, /History.*added/u); assert.match(blocked, /Release.*Next.*G1/u);- assert.equal((await reads()).length, 1, 'the first opened summary reads its detail once');+ assert.ok((await reads()).filter(url => /\/items\/2$/.test(url)).length <= 1, 'the first opened row reads its detail once, ahead or on expand');for (const id of ['#2', '#6', '#5']) {if (id !== '#2') await opened(id);const text = await chrome.stable(`${row(id)}.parentElement.querySelector('.milestone-why').textContent`);@@ -1161,7 +1163,7 @@ test('the expanded row keeps send-backs short and names agents plainly [N26]', {/** Expand a row, if it is not open yet, and read its detail once it has loaded. */async function opened(id) {if (await chrome.stable(`${row(id)}?.getAttribute('aria-expanded')`) !== 'true') await press(chrome, row(id));- await chrome.waitFor(`${row(id)}?.getAttribute('aria-expanded')==='true' && !${row(id)}.parentElement.querySelector('.roadmap-loading')`);+ await chrome.waitFor(`${row(id)}?.getAttribute('aria-expanded')==='true' && !${row(id)}.parentElement.querySelector('.milestone-why[aria-busy]')`);return await chrome.stable(`${row(id)}.parentElement.querySelector('.milestone-why').textContent`);}try {@@ -1316,3 +1318,117 @@ test('a roadmap case that times out names the page state and its waiting step [NrmSync(profile, { recursive: true, force: true });}});++/** Every item-detail read the page makes answers 500 ms late; the page logs each path asked and each answered. */+const SLOW_DETAIL = `(() => {+ const fetched = window.fetch.bind(window);+ window.__asked = []; window.__answered = [];+ window.fetch = (url, options) => {+ const path = new URL(String(url), location.href).pathname;+ if (!/\\/items\\/\\d+$/u.test(path)) return fetched(url, options);+ window.__asked.push(path);+ return fetched(url, options).then((reply) => new Promise((done) => setTimeout(() => { window.__answered.push(path); done(reply); }, 500)));+ };+ /** Time one roadmap row's click to the frame it is drawn in, and read what that frame shows. */+ window.__armExpand = (key) => {+ window.__painted = new Promise((resolve) => addEventListener('click', () => {+ const started = performance.now();+ requestAnimationFrame(() => {+ const row = [...document.querySelectorAll('#roadmap .milestone-item')].find((each) => each.dataset.roadmapKey === key), why = row.parentElement.querySelector('.milestone-why');+ resolve({ ms: performance.now() - started, expanded: row.getAttribute('aria-expanded'), shown: !why.hidden, block: !!why.querySelector('.roadmap-detail'),+ title: row.querySelector('.t').textContent, state: row.querySelector('.dot').className, loading: !!why.querySelector('.roadmap-loading'),+ fields: [...why.querySelectorAll('dt')].map((dt) => dt.textContent) });+ });+ }, { capture: true, once: true }));+ return true;+ };+ window.__sawLoading = false;+ new MutationObserver(() => { if (document.querySelector('#roadmap .roadmap-loading')) window.__sawLoading = true; }).observe(document, { childList: true, subtree: true });+})()`;++/** Start a foreground view on a generated stress board and read its local link. */+async function startStressView(board) {+ const child = spawn(process.execPath, [BIN, 'view', '--no-open', '--port', '0'], { cwd: board.root, env: { ...board.env, PULLBOARD_VIEW_FOREGROUND: '1' }, stdio: ['ignore', 'pipe', 'pipe'] });+ const closed = new Promise((done) => child.once('close', done));+ let output = '';+ child.stdout.setEncoding('utf8').on('data', (chunk) => { output += chunk; });+ const deadline = Date.now() + 30_000; // budget: hang ceiling for the generated board's view to print its link.+ while (Date.now() < deadline) {+ const link = /Pullboard view: (http:\/\/127\.0\.0\.1:\d+\/\?k=\S+)/u.exec(output);+ if (link) return { link: new URL(link[1]), stop: async () => { child.kill('SIGTERM'); await closed; } };+ await new Promise((done) => setTimeout(done, 25));+ }+ child.kill('SIGKILL');+ throw new Error('the stress board view printed no link');+}++test('expanding a roadmap row paints its detail within 100 ms [N26]', { timeout: 180_000 }, async (t) => {+ const executable = chromeExecutable();+ assert.ok(executable, 'Chrome is required to time a roadmap expand.');+ // A board our size: 1,038 items with their events, shouts and releases.+ const board = generateStressBoard({ seed: 'roadmap-expand-1039', size: 1_038 });+ const view = await startStressView(board), profile = mkdtempSync(join(tmpdir(), 'pullboard-roadmap-expand-chrome-'));+ const row = (key) => `[...document.querySelectorAll('#roadmap .milestone-item')].find((each) => each.dataset.roadmapKey === ${JSON.stringify(key)})`;+ const why = (key) => `${row(key)}.parentElement.querySelector('.milestone-why')`;+ /** Click one row and return what the frame after the click painted. */+ async function expand(key) {+ await chrome.stable(`window.__armExpand(${JSON.stringify(key)})`);+ await chrome.click(row(key));+ return chrome.stable('window.__painted');+ }+ const reads = async () => JSON.parse(await chrome.stable('JSON.stringify({ asked: window.__asked, answered: window.__answered })'));+ let chrome;+ try {+ chrome = await openRoadmapChrome(executable, 'about:blank', profile);+ await chrome.send('Page.addScriptToEvaluateOnNewDocument', { source: SLOW_DETAIL });+ await chrome.send('Page.navigate', { url: view.link.href });+ await chrome.waitFor('data?.project?.items?.length === 1038', 30_000); // budget: hang ceiling for the first read of a board our size.+ await press(chrome, "document.querySelector('[data-tab=roadmap]')");+ await chrome.waitFor("view.tab === 'roadmap' && document.querySelectorAll('#roadmap .milestone-item').length > 100", 30_000); // budget: hang ceiling for the first roadmap draw.+ // A row below the fold, never fetched ahead: its detail can only come from the delayed request.+ const far = await chrome.stable(`[...document.querySelectorAll('#roadmap .milestone-item[aria-expanded=false]')].filter((each) => /^i:#\\d+$/u.test(each.dataset.roadmapKey)+ && !each.closest('[hidden]') && each.getBoundingClientRect().top > innerHeight * 2).at(-1)?.dataset.roadmapKey`);+ assert.ok(far, 'the roadmap has a row below the fold');+ const farPath = '/items/' + far.slice(3);+ assert.equal((await reads()).asked.filter((path) => path.endsWith(farPath)).length, 0, 'the row below the fold was not read ahead');+ const painted = await expand(far);+ t.diagnostic(`click to paint ${Math.round(painted.ms)} ms on ${far}`);+ assert.equal(painted.expanded, 'true'); assert.equal(painted.shown, true, 'the row opens in the frame after the click');+ assert.equal(painted.loading, false, 'no loading state shows'); assert.equal(painted.block, true, 'the row paints its block at once');+ assert.ok(painted.title.trim() && /\bdot\b/u.test(painted.state), 'the row keeps its title and state');+ assert.ok(painted.fields.includes('Release'), `the fields the summary holds paint at once: ${painted.fields}`);+ assert.ok(!painted.fields.includes('Criterion'), 'the criterion is still on its way');+ assert.ok(painted.ms < 100, `click to paint is under 100 ms: ${Math.round(painted.ms)} ms`);+ // The delayed fields fill the same block in place, with no loading flash between.+ await chrome.waitFor(`${why(far)}.querySelector('.roadmap-criterion') && ${why(far)}.textContent.includes('History')`, 10_000); // budget: hang ceiling for the 500 ms delayed read.+ assert.equal(await chrome.stable('window.__sawLoading'), false, 'no loading state showed at any point');+ // A second expand is instant: its detail is kept, so it paints whole and reads nothing.+ const asked = (await reads()).asked.length;+ await chrome.click(row(far));+ const again = await expand(far);+ assert.ok(again.fields.includes('Criterion') && again.ms < 100, `a second expand paints whole at once: ${JSON.stringify(again)}`);+ // A row on screen is read ahead, so its first expand paints whole.+ const near = await chrome.stable(`[...document.querySelectorAll('#roadmap .milestone-item[aria-expanded=false]')].find((each) => /^i:#\\d+$/u.test(each.dataset.roadmapKey)+ && !each.closest('[hidden]') && each.getBoundingClientRect().top >= 0 && each.getBoundingClientRect().bottom <= innerHeight)?.dataset.roadmapKey`);+ assert.ok(near, 'a row is on screen');+ await chrome.waitFor(`window.__answered.some((path) => path.endsWith(${JSON.stringify('/items/' + near.slice(3))}))`, 20_000); // budget: hang ceiling for the read ahead queue.+ const ahead = await expand(near);+ assert.ok(ahead.fields.includes('Criterion') && !ahead.loading && ahead.ms < 100, `a row read ahead paints whole at once: ${JSON.stringify(ahead)}`);+ assert.equal((await reads()).asked.filter((path) => path.endsWith(farPath)).length, 1, 'the far row was read once');+ // A background refresh that moves no item reads no detail again.+ await chrome.waitFor('window.__asked.length === window.__answered.length', 30_000); // budget: hang ceiling for the reads ahead to drain.+ const settledReads = (await reads()).asked;+ assert.ok(settledReads.length >= asked, 'reads are counted');+ const shouted = spawnSync(process.execPath, [BIN, 'shout', 'all', 'A refresh that moves no item'], { cwd: board.root, env: board.env, encoding: 'utf8' });+ assert.equal(shouted.status, 0, shouted.stderr);+ await chrome.waitFor("data.project.shouts.some((each) => each.shout_text === 'A refresh that moves no item')", 20_000); // budget: hang ceiling for the next board poll.+ await chrome.waitFor('window.__asked.length === window.__answered.length', 10_000); // budget: hang ceiling for any read the refresh started.+ assert.deepEqual((await reads()).asked.slice(settledReads.length), [], 'the refresh fetched no detail of an item that has not moved');+ assert.deepEqual(chrome.exceptions, [], 'the roadmap raises no uncaught page exception');+ } finally {+ if (chrome) await closeSnapshotChrome(chrome);+ rmSync(profile, { recursive: true, force: true });+ await view.stop();+ removeStressBoard(board);+ }+});