Skip to content

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.

fix(view): no init card while the board list loads [N26,H5]

Corey Olsoncbf7461c952f
diff --git a/src/cockpit.js b/src/cockpit.js
index b4d8b880..8df1dfde 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -141,7 +141,7 @@ ${hostedLocal && !snapshot ? '<div class="hosted-mark" aria-hidden="true"><svg v
<div class="top-find"><input id="q" type="search" placeholder="Search" aria-label="Search items, Spec, Doctrine and shouts" autocomplete="off"><div class="find-results" id="find-results" role="listbox" aria-label="Search results" hidden></div></div>
</header>
<main>
- <section class="card-panel first">
+ <section class="card-panel first" hidden>
<h2>No boards yet</h2>
<p>Run <code>pullboard init</code> in a git repo, or ask an agent to. Its board shows up here by itself.</p>
</section>
@@ -1055,8 +1055,10 @@ function render() {
const p = data.project;
const group = data.group;
renderSide();
- $('project-loading').hidden = data.root === view.root;
- if (data.root !== view.root) {
+ // A list that names a board no read has answered yet is still loading, never a machine without boards (#1035).
+ const listing = !p && !group && data.projects.some((entry) => entry.ok);
+ $('project-loading').hidden = data.root === view.root && !listing;
+ if (data.root !== view.root || listing) {
// Keep the cached picker available, but never label the last board's counts as the new one.
document.querySelectorAll('[data-pane]').forEach((pane) => { pane.hidden = true; });
for (const id of ['products', 'group-view', 'proof-stats', 'upgrade-note', 'person-requests', 'credentials', 'find-results']) $(id).hidden = true;
@@ -1071,6 +1073,8 @@ function render() {
// flashes them; with no board to show, one message says how a board starts, in their place.
document.body.classList.remove('loading');
document.body.classList.toggle('boardless', !p && !group);
+ // The card starts hidden, so even a page whose stylesheet is late never says it before the list is known empty.
+ document.querySelector('main > .first').hidden = Boolean(p || group);
$('group-view').hidden = !group;
$('tabs').hidden = Boolean(group);
document.querySelectorAll('[data-pane]').forEach((pane) => { pane.hidden = Boolean(group) || pane.dataset.pane !== view.tab; });
diff --git a/test/cockpit/projects.test.js b/test/cockpit/projects.test.js
index 22413a60..106338a3 100644
--- a/test/cockpit/projects.test.js
+++ b/test/cockpit/projects.test.js
@@ -94,6 +94,72 @@ test('a project switch never shows the old project\'s numbers [N26,A2]', { timeo
}
});
+test('the page never tells a person with boards to run init while the list loads [N26,H5]', { timeout: 120_000 }, async (t) => {
+ const executable = chromeExecutable();
+ if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for loading-state checks.');
+ const box = machine();
+ const alpha = project(box, 'alpha');
+ box.run(alpha.repo, 'add', 'web', 'Alpha waiting item', '--specs', 'G1', '--criterion', 'shown');
+ const empty = machine();
+ let view, bare, profile, chrome;
+ // What a person reads now: the page's visible text, as laid out, so a hidden card never counts.
+ const told = async () => chrome.stable("(document.body.innerText.match(/No boards yet|pullboard init/g) || []).join(' | ')");
+ try {
+ view = await startView(box);
+ bare = await startView(empty);
+ profile = mkdtempSync(join(tmpdir(), 'pullboard-list-loading-chrome-'));
+ chrome = await openSnapshotChrome(executable, 'about:blank', profile);
+ // Hold the board list and each board's state before real HTTP, so the page waits as on a loaded machine.
+ await chrome.send('Page.addScriptToEvaluateOnNewDocument', { source: `(() => {
+ const nativeFetch = window.fetch.bind(window);
+ const gate = window.__listGate = { list: true, state: true, blocked: [] };
+ gate.release = (kind) => { gate[kind] = false; gate.blocked.filter((entry) => entry.kind === kind).forEach((entry) => entry.resolve()); };
+ window.fetch = async (input, init) => {
+ const path = new URL(typeof input === 'string' ? input : input.url, location.href).pathname;
+ const kind = path === '/api/v1/boards' ? 'list' : /^\\/api\\/v1\\/boards\\/[^/]+\\/state$/.test(path) ? 'state' : null;
+ if (kind && gate[kind]) await new Promise((resolve) => gate.blocked.push({ kind, resolve }));
+ return nativeFetch(input, init);
+ };
+ })()` });
+ await chrome.send('Page.navigate', { url: view.link.href });
+ await chrome.waitFor("window.__listGate?.blocked.some((entry) => entry.kind === 'list')");
+ const polls = [];
+ for (let poll = 0; poll < 5; poll += 1) polls.push(await told());
+ // The list answers, but no board has: the names are known and the page is still loading. A Back press redraws it.
+ await chrome.stable("window.__listGate.release('list')");
+ await chrome.waitFor("window.__listGate.blocked.some((entry) => entry.kind === 'state') && document.querySelector('#proj-list .pname')?.textContent === 'alpha'");
+ for (let poll = 0; poll < 5; poll += 1) polls.push(await told());
+ await chrome.stable("dispatchEvent(new PopStateEvent('popstate', { state: null })), true");
+ for (let poll = 0; poll < 5; poll += 1) polls.push(await told());
+ await chrome.stable("window.__listGate.release('state')");
+ await chrome.waitFor(`data?.root === ${JSON.stringify(alpha.repo)} && !document.body.classList.contains('loading') && document.body.innerText.includes('Alpha waiting item')`);
+ polls.push(await told());
+ assert.deepEqual(polls.filter(Boolean), [], 'a person with a board never reads No boards yet or pullboard init while the list loads');
+
+ // A machine truly without a board says both, once its list is known to be empty.
+ await chrome.send('Page.navigate', { url: bare.link.href });
+ await chrome.waitFor("window.__listGate?.blocked.some((entry) => entry.kind === 'list')");
+ assert.equal(await told(), '', 'nothing about init shows before the empty list answers');
+ await chrome.stable("window.__listGate.release('list')");
+ await chrome.waitFor("document.body.classList.contains('boardless')");
+ assert.equal(await told(), 'No boards yet | pullboard init', 'a truly empty list says No boards yet and the init step');
+ assert.deepEqual(chrome.exceptions, [], 'the held list raises no uncaught exception');
+ } finally {
+ try {
+ if (chrome) {
+ await chrome.stable("window.__listGate?.release('list'), window.__listGate?.release('state')").catch(() => {});
+ await closeSnapshotChrome(chrome);
+ }
+ } finally {
+ try { if (profile) rmSync(profile, { recursive: true, force: true }); }
+ finally {
+ try { if (bare) await bare.stop(); }
+ finally { if (view) await view.stop(); }
+ }
+ }
+ }
+});
+
test('the sidebar lists every project and what needs the person [N26]', async () => {
const box = machine();
const alpha = project(box, 'alpha');
@@ -442,7 +508,7 @@ test('a machine with no board says how to start one [N26]', async () => {
assert.deepEqual(classes(early), ['loading'], 'and stays so while the first answer is on its way');
await early.release();
assert.deepEqual(classes(early), ['boardless'], 'then the message takes the place of the board');
- assert.match(page.html, /<main>\n {2}<section class="card-panel first">\n {4}<h2>No boards yet<\/h2>\n {4}<p>Run <code>pullboard init<\/code> in a git repo, or ask an agent to\. Its board shows up here by itself\.<\/p>\n {2}<\/section>\n/, 'the message says how a board starts');
+ assert.match(page.html, /<main>\n {2}<section class="card-panel first" hidden>\n {4}<h2>No boards yet<\/h2>\n {4}<p>Run <code>pullboard init<\/code> in a git repo, or ask an agent to\. Its board shows up here by itself\.<\/p>\n {2}<\/section>\n/, 'the message says how a board starts');
assert.equal(page.show('proj-list'), '<div class="empty">None yet.</div>');
assert.equal(page.element('products').hidden, true);