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): style the hosted normal-list next actions [N26,H5]

Corey Olson1b1f390b156e
diff --cc src/cockpit.js
index 393d879e,7304bf49..3861bfe2
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@@ -2356,7 -2337,7 +2356,7 @@@ function render()
+ '<div><h3>People and commits</h3><dl class="kv">' + (item.owner && s === 'building' ? '<dt>holding</dt><dd>' + esc(agentName(item.owner)) + '</dd>' : '') + (item.builtBy ? '<dt>built by</dt><dd>' + esc(agentName(item.builtBy)) + '</dd>' : '') + (item.verifiedBy ? '<dt>verified by</dt><dd>' + esc(agentName(item.verifiedBy)) + '</dd>' : '') + (item.commit ? '<dt>commit</dt><dd><code>' + esc(item.commit.slice(0, 12)) + '</code></dd>' : '') + (item.merged ? '<dt>merged</dt><dd><code>' + esc(item.merged.slice(0, 12)) + '</code></dd>' : '') + (item.blockedBy.length ? '<dt>waits on</dt><dd class="waits-on">' + item.blockedBy.map((id) => '<span class="wait-unit"><a class="ref" href="' + esc(itemAddress(id)) + '" data-go="item:' + id + '">#' + id + '</a></span>').join(', ') + '</dd>' : '') + '</dl></div>'
+ (back && !earlier.length ? '' : '<div><h3>' + (back ? 'Earlier verdicts' : 'Verdicts') + '</h3>' + (earlier.length ? earlier.map((v) => verdictHtml(v, titles)).join('') : '<div class="muted">None yet.</div>') + '</div>')
+ '<div><h3>History</h3>' + timeline(item) + '</div>'
-- + '<div class="links"><button data-shout="' + esc(item.lane) + '" data-about="' + item.id + '" type="button">Shout the ' + esc(item.lane) + ' lane about #' + item.id + '</button><button data-new type="button">New item</button></div></div>';
++ + '<div class="links"><button class="ghost" data-shout="' + esc(item.lane) + '" data-about="' + item.id + '" type="button">Shout the ' + esc(item.lane) + ' lane about #' + item.id + '</button><button class="go" data-new type="button">New item</button></div></div>';
}
// Every #id in a shout that names an item opens it, whatever stands next to it. The ids are found in
diff --cc src/view.css
index 015dfcb7,70967c54..4424d35d
--- a/src/view.css
+++ b/src/view.css
@@@ -431,6 -396,6 +431,7 @@@ input:disabled { background: var(--surf
.rowref { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; font-size: 13px; padding: 3px 0; }
.rowref code { font-weight: 600; }
.links { display: flex; flex-wrap: wrap; gap: 6px; }
++.links > button { min-height: var(--tap); }
.links-item { border: 1px solid var(--line); background: var(--surface-2); border-radius: 6px; padding: 3px 9px; cursor: pointer; font-size: 12.5px; min-height: var(--tap); display: flex; align-items: center; }
.panel-form { display: grid; gap: 10px; }
diff --cc test/cockpit/local-origin.test.js
index 72769a49,b3d5a63f..fa39c853
--- a/test/cockpit/local-origin.test.js
+++ b/test/cockpit/local-origin.test.js
@@@ -430,160 -343,6 +430,184 @@@ test('a foreign origin or wrong Host i
}
});
+test('every hosted page state says what it is and what to do next [N26,H5]', { timeout: 120_000 }, async () => { // budget: hang ceiling for six hosted page loads in Chrome, one with a real round trip.
+ const executable = chromeExecutable();
+ assert.ok(executable, 'the hosted page check needs real Chrome');
+ const box = machine();
+ const board = project(box, 'hosted-states');
+ box.run(board.repo, 'add', 'web', 'A board the hosted page lists', '--specs', 'G1');
+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-hosted-states-'));
+ const relay = createRelayBrowserHandler({ authenticate: async () => { if (stand.signedIn) return { kind: 'session' }; throw new Refused('AUTH_REQUIRED', 'Sign in.'); } });
+ // What the stand-in answers: the relay's real page and assets, a relay client that has paired no board, the
+ // account's linked boards, and this machine's default view address, closed unless the test names a view.
+ const stand = { signedIn: false, linked: [], local: null };
+ const client = 'export function rememberPairing() { return null; }\nexport async function createTransport() { return { async request(path) { if (path === "/api/v1/boards") return { version: 1, boards: [], warnings: [] }; throw new Error("no paired board"); } }; }\n';
+ let view, chrome, listener, old;
+ const failures = [];
+ try {
+ view = await startView(box);
+ chrome = await openSnapshotChrome(executable, 'about:blank', profile);
+ listener = ({ data }) => {
+ const message = JSON.parse(String(data));
+ if (message.method !== 'Fetch.requestPaused') return;
+ const { requestId, request: asked } = message.params;
+ const address = new URL(asked.url);
+ const fulfil = (type, body, headers = []) => chrome.send('Fetch.fulfillRequest', { requestId, responseCode: 200, responseHeaders: [{ name: 'Content-Type', value: type }, { name: 'Cache-Control', value: 'no-store' }, ...headers], body: Buffer.from(body).toString('base64') });
+ (async () => {
+ if (address.origin === LOCAL) {
+ if (!stand.local) return chrome.send('Fetch.failRequest', { requestId, errorReason: 'ConnectionRefused' });
+ const reply = await call({ base: stand.local }, address.pathname + address.search, { method: asked.method, headers: Object.fromEntries(Object.entries(asked.headers).filter(([name]) => name.toLowerCase() !== 'host')) });
+ return chrome.send('Fetch.fulfillRequest', { requestId, responseCode: reply.status, responseHeaders: Object.entries(reply.headers).filter(([name]) => !['content-length', 'transfer-encoding', 'connection', 'keep-alive', 'date'].includes(name)).map(([name, value]) => ({ name, value: String(value) })), body: Buffer.from(reply.body).toString('base64') });
+ }
+ if (address.pathname === '/relay/client.js') return fulfil('text/javascript', client);
+ if (address.pathname === '/api/v1/boards') return fulfil('application/json', JSON.stringify({ version: 1, boards: stand.linked, warnings: [] }));
+ let head = {}, body = '';
+ const handled = await relay({ method: 'GET', url: address.pathname, headers: {} }, { writeHead: (status, headers) => { head = headers; }, end: (content) => { body = content ?? ''; } });
+ if (!handled) return chrome.send('Fetch.failRequest', { requestId, errorReason: 'Failed' });
+ // The relay's own policy, which also lets the page reach the test view's own port the round trip names.
+ const policy = head['content-security-policy'].replace("connect-src 'self'", "connect-src 'self' " + view.base);
+ return fulfil(head['content-type'], body, [{ name: 'Content-Security-Policy', value: policy }]);
+ })().catch((error) => failures.push(error.message));
+ };
+ chrome.socket.addEventListener('message', listener);
+ await chrome.send('Fetch.enable', { patterns: [{ urlPattern: HOSTED + '/*', requestStage: 'Request' }, { urlPattern: LOCAL + '/*', requestStage: 'Request' }] });
+ // A browser that has refused this page its local network permission, as Chrome reports it.
+ await chrome.send('Page.addScriptToEvaluateOnNewDocument', { source: `(() => {
+ if (location.origin !== ${JSON.stringify(HOSTED)} || location.search !== '?blocked') return;
+ const query = navigator.permissions.query.bind(navigator.permissions);
+ navigator.permissions.query = (asked) => ['loopback-network', 'local-network-access'].includes(asked?.name) ? Promise.resolve({ state: 'denied' }) : query(asked);
+ })()` });
+ const shown = `JSON.stringify((() => {
+ const on = (element) => Boolean(element) && !element.hidden && element.getClientRects().length > 0;
+ const text = (id) => on(document.getElementById(id)) ? document.getElementById(id).textContent.trim() : null;
+ const probe = document.body.appendChild(document.createElement('span'));
+ const tokens = ['--accent-strong', '--ink', '--ink-muted', '--surface'].map((token) => { probe.style.color = 'var(' + token + ')'; return getComputedStyle(probe).color; });
+ probe.remove();
+ return {
+ state: document.getElementById('local-note').dataset.state, heading: text('local-note-title'), text: text('local-note-text'), hint: text('local-note-hint'), command: text('local-note-code'),
+ steps: [...document.querySelectorAll('#local-note-links a, #local-note-links button')].filter(on).map((step) => [step.textContent.trim(), step.getAttribute('href')]),
+ ways: on(document.getElementById('ways-in')) ? [...document.querySelectorAll('#ways-in dt')].map((title) => title.textContent) : null,
+ waysText: text('ways-in'), side: document.getElementById('side-hint').hidden ? null : document.getElementById('side-hint').textContent, banner: on(document.getElementById('relay-notice')), browser: hostedBrowser(navigator),
+ defaults: [...document.querySelectorAll('*')].filter((element) => ['rgb(0, 0, 238)', 'rgb(85, 26, 139)'].includes(getComputedStyle(element).color)).map((element) => element.outerHTML.slice(0, 80)),
+ bare: [...document.querySelectorAll('a')].filter((link) => on(link) && !link.className && !tokens.includes(getComputedStyle(link).color)).map((link) => link.outerHTML.slice(0, 80)),
+ };
+ })())`;
+ /** Open the hosted page at this address and read the state it settles in. */
+ const open = async (address, state) => {
+ await chrome.send('Page.navigate', { url: HOSTED + '/' + address });
+ await chrome.waitFor(`location.search === ${JSON.stringify(address.split('#')[0])} && document.querySelector('#local-note')?.dataset.state === ${JSON.stringify(state)} && !document.querySelector('#local-note').hidden`, 20_000); // budget: hang ceiling for one refused loopback request and an empty relay list.
+ const seen = JSON.parse(await chrome.stable(shown));
+ await proofShot(chrome, 'hosted-' + state + '-phone', 390);
+ await proofShot(chrome, 'hosted-' + state, 1280);
+ assert.deepEqual(seen.defaults, [], `${state}: no element keeps the browser's default link colours`);
+ assert.deepEqual(seen.bare, [], `${state}: every link has a class or the view's colours`);
+ assert.deepEqual(seen.ways, ['The local view', 'This computer through pullboard.dev', 'Your phone and other devices', 'A second computer'], `${state}: the Ways in panel lists every route`);
+ for (const command of ['pullboard view', 'pullboard relay on --all', 'pullboard relay pair', 'pullboard relay join <code>']) assert.ok(seen.waysText.includes(command), `${state}: Ways in names ${command}`);
+ assert.ok(seen.side, `${state}: the empty sidebar says what fills it`);
+ return seen;
+ };
+ const retry = [['Try again', null]];
+
+ const blocked = await open('?blocked', 'blocked');
+ assert.equal(blocked.heading, 'Let this page reach Pullboard');
+ assert.match(blocked.text, new RegExp('^' + blocked.browser + ' has refused this page access to apps on this device'), 'the line names the browser and what it refused');
+ assert.equal(blocked.browser, 'Chrome', 'the fixture Chrome is named as Chrome');
+ assert.match(blocked.hint ?? '', /^In Chrome, click the icon at the left of the address bar, turn on Local network access, then try again\.$/, 'the step is the one for this browser');
+ assert.deepEqual(blocked.steps, retry, 'and its button tries again');
+
+ const absent = await open('?absent', 'not-running');
+ assert.equal(absent.heading, 'Start Pullboard on this computer');
+ assert.match(absent.text, /cannot reach a local view on this computer/);
+ assert.equal(absent.command, 'pullboard view', 'the next step is the command that starts the local view');
+ assert.deepEqual(absent.steps, retry);
+ assert.equal(await chrome.stable("document.querySelector('#local-note-copy').textContent"), 'Copy', 'the command has a copy button');
+ assert.equal(absent.banner, false, 'the relay\'s banner stays out of it');
+
+ const out = await open('?out#board=' + 'b'.repeat(32) + '&key=k1', 'signed-out');
+ assert.equal(out.heading, 'Sign in to pair this browser');
+ assert.deepEqual(out.steps, [['Sign in with GitHub', '/auth/github/start']], 'the next step is signing in');
+ assert.equal(out.banner, false, 'the state speaks for the relay\'s banner');
+
+ stand.signedIn = true;
+ const none = await open('?in', 'no-linked');
+ assert.equal(none.heading, 'No linked boards yet');
+ assert.equal(none.command, 'pullboard relay on --all', 'the next step links the boards');
+ assert.equal(none.banner, false);
+ assert.equal(await chrome.stable("document.querySelector('#local-note-sign-in').hidden"), true, 'a signed-in person is not asked to sign in');
+
+ stand.linked = [{ id: 'a'.repeat(32), repository: 'acme/web', linkedAt: 0 }];
+ const unpaired = await open('?linked', 'unpaired');
+ assert.equal(unpaired.heading, 'Pair this browser');
+ assert.match(unpaired.text, /^You are signed in, .*acme\/web\. Each browser pairs once before it can read it\..*scan its QR:$/, 'the line says the person is signed in, names the board, that each browser pairs once, and the QR');
+ assert.equal(unpaired.command, 'pullboard relay on --all', 'the next step prints the QR');
+
+ // This machine's view: the normal list, with no state over it.
+ stand.signedIn = false;
+ stand.linked = [];
+ stand.local = view.base;
+ // The person allowed this page to reach this device, under whichever permission names this Chrome knows.
+ for (const permissions of [['loopbackNetwork', 'localNetwork', 'localNetworkAccess'], ['localNetworkAccess']]) {
+ try { await chrome.send('Browser.grantPermissions', { origin: HOSTED, permissions }); break; } catch { /* a name this Chrome does not have */ }
+ }
+ // A view from before 0.8.29 refuses the hosted page without the header that would let it read the refusal.
+ old = createServer((req, res) => { res.writeHead(403, { 'content-type': 'application/json' }); res.end(JSON.stringify({ error: 'this view needs its own address and secret: open the link pullboard view printed' })); });
+ await new Promise((ready) => old.listen(0, '127.0.0.1', ready));
+ stand.local = 'http://127.0.0.1:' + old.address().port;
+ const outdated = await open('?old', 'too-old');
+ assert.equal(outdated.heading, 'Update Pullboard on this computer', 'an old view is told apart from none');
+ assert.equal(outdated.command, 'npm i -g pullboard', 'the next step updates Pullboard');
+ assert.deepEqual(outdated.steps, retry);
+ stand.local = view.base;
+ await chrome.send('Page.navigate', { url: HOSTED + '/?list' });
+ await chrome.waitFor("location.origin === 'https://app.pullboard.dev' && document.querySelector('#chain')?.textContent.includes('A board the hosted page lists')", 30_000); // budget: hang ceiling for the discovery, one round trip and the first board read.
+ const list = JSON.parse(await chrome.stable(`JSON.stringify({ note: document.querySelector('#local-note').hidden, ways: document.querySelector('#ways-in').hidden, heading: document.querySelector('#proj-list .proj.on .pname')?.textContent, source: document.querySelector('#proj-list .proj.on .src')?.textContent, tab: document.querySelector('.tab.on')?.textContent, step: document.querySelector('#new-item').getClientRects().length > 0, side: document.querySelector('#side-hint').hidden, state: JSON.parse(${shown}) })`));
- await proofShot(chrome, 'hosted-list-phone', 390);
- await proofShot(chrome, 'hosted-list', 1280);
++ // Normal-list next actions use the view styles at both sizes and in both themes (outside review 950).
++ for (const width of [390, 1280]) {
++ await chrome.send('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false });
++ for (const theme of ['light', 'dark']) {
++ await chrome.stable(`document.documentElement.dataset.theme = '${theme}'`);
++ const controls = JSON.parse(await chrome.stable(`JSON.stringify((() => {
++ const probe = document.createElement('button'); probe.textContent = 'UA reference'; document.body.append(probe);
++ const signature = (element) => { const style = getComputedStyle(element); return {
++ appearance: style.appearance, background: style.backgroundColor, radius: style.borderRadius,
++ border: style.borderTopStyle, width: style.borderTopWidth, padding: style.padding,
++ }; };
++ const baseline = signature(probe);
++ const actions = [...document.querySelectorAll('#detail button[data-shout], #detail button[data-new]')]
++ .filter((element) => element.getClientRects().length).map((element) => ({ text: element.textContent,
++ style: signature(element), height: element.getBoundingClientRect().height }));
++ probe.remove(); return { baseline, actions };
++ })())`));
++ assert.equal(controls.actions.length, 2, `both next actions appear at ${width}px in ${theme}`);
++ for (const action of controls.actions) {
++ assert.notDeepEqual(action.style, controls.baseline, `${action.text} uses the view styles at ${width}px in ${theme}`);
++ if (width === 390) assert.ok(action.height >= 44, `${action.text} retains a phone touch target in ${theme}`);
++ }
++ }
++ await proofShot(chrome, width === 390 ? 'hosted-list-phone' : 'hosted-list', width);
++ }
++ await chrome.stable('delete document.documentElement.dataset.theme');
+ assert.deepEqual({ note: list.note, ways: list.ways, side: list.side }, { note: true, ways: true, side: true }, 'the list shows with no state, panel or hint over it');
+ assert.equal(list.heading, 'hosted-states', 'the sidebar names the board shown');
+ assert.equal(list.source, 'this computer', 'with a quiet label for where it comes from');
+ assert.equal(list.tab, 'Items', 'its items are open');
+ assert.equal(list.step, true, 'and the next step is a new item');
+ assert.deepEqual(list.state.defaults, [], 'no element keeps the browser\'s default link colours');
+ assert.deepEqual(list.state.bare, [], 'every link has a class or the view\'s colours');
+ assert.deepEqual(chrome.exceptions, [], 'Chrome reports no uncaught exceptions');
+ } finally {
+ try { if (chrome) { if (listener) chrome.socket.removeEventListener('message', listener); await closeSnapshotChrome(chrome); } }
+ finally {
+ try { if (old) await new Promise((closed) => { old.close(closed); old.closeAllConnections(); }); }
+ finally {
+ try { if (view) await view.stop(); }
+ finally { rmSync(profile, { recursive: true, force: true }); }
+ }
+ }
+ }
+ assert.deepEqual(failures, [], 'the stand-in hosted page was served');
+});
+
test('the local view hands its secret only to the hosted page [N26,A2]', { timeout: 60_000 }, async () => { // budget: hang ceiling for one real view and a few local requests.
const box = machine();
project(box, 'local-origin-handoff');