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.

feat(view): render person-request receipts [H12,H5]

Corey Olson4316ca463799
diff --git a/src/cockpit.js b/src/cockpit.js
index 8903f524..0f29b142 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -34,13 +34,14 @@ function lifecycle() {
* folder, where a path the host does not serve would leave a reload with nothing.
*
* @param {string} [key] - The session's secret.
- * @param {{snapshot?: boolean, readOnly?: boolean, transportModule?: string|null, apiBase?: string, apiHeaders?: Record<string, string>, stylesheet?: string, paths?: boolean}} [options] - Served API connection and assets, whether the host also serves the page at /roadmap, or a static, read-only page with event replay.
+ * @param {{snapshot?: boolean, readOnly?: boolean, requests?: boolean, transportModule?: string|null, apiBase?: string, apiHeaders?: Record<string, string>, stylesheet?: string, paths?: boolean}} [options] - Served connection and assets, optional person requests over a read-only transport, host routes, or a static page with event replay.
* @returns {string}
*/
-export function cockpitPage(key = '', { snapshot = false, readOnly = false, transportModule = null, apiBase = '', apiHeaders = { 'x-pullboard-key': key }, stylesheet = null, paths = false } = {}) {
+export function cockpitPage(key = '', { snapshot = false, readOnly = false, requests = false, transportModule = null, apiBase = '', apiHeaders = { 'x-pullboard-key': key }, stylesheet = null, paths = false } = {}) {
if (transportModule !== null && (typeof transportModule !== 'string' || !transportModule.trim())) throw new TypeError('transportModule must be a non-empty module URL or null');
const connection = JSON.stringify(transportModule ? { base: '', headers: {} } : { base: apiBase.replace(/\/$/, ''), headers: apiHeaders }).replace(/</g, '\\u003c');
const moduleOption = JSON.stringify(transportModule).replace(/</g, '\\u003c');
+ const requestMode = Boolean(readOnly && requests && !snapshot && transportModule);
const css = stylesheet ?? (snapshot ? 'view.css' : transportModule ? '/view.css' : '/view.css?k=' + encodeURIComponent(key));
const cssAttribute = css.replace(/[&<>"']/g, (character) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[character]);
return `<!doctype html>
@@ -52,7 +53,7 @@ export function cockpitPage(key = '', { snapshot = false, readOnly = false, tran
<link rel="stylesheet" href="${cssAttribute}">
<link rel="icon" href="data:,">
</head>
-<body class="loading${snapshot ? ' snapshot' : ''}${readOnly ? ' read-only' : ''}">
+<body class="loading${snapshot ? ' snapshot' : ''}${readOnly ? ' read-only' : ''}${requestMode ? ' requests' : ''}">
<div class="shell">
<aside class="side" id="side" aria-label="Projects">
<div class="side-top">
@@ -94,6 +95,7 @@ export function cockpitPage(key = '', { snapshot = false, readOnly = false, tran
<section class="card-panel group-panel"><h2>Needs you</h2><div id="group-needs"></div></section>
<section class="card-panel group-panel"><h2>Activity</h2><div class="feed" id="group-activity"></div></section>
</section>
+ <section class="card-panel person-requests" id="person-requests" aria-label="Your requests" aria-live="polite" hidden></section>
<section data-pane="items" class="two">
<div class="primary">
<div class="card-panel toolbar"><div class="seg" id="state-chips" role="group" aria-label="Show"></div><input id="q" type="search" placeholder="Search" aria-label="Search titles, lanes or ids"><button class="go" id="new-item" type="button">New item</button></div>
@@ -146,6 +148,7 @@ export function cockpitPage(key = '', { snapshot = false, readOnly = false, tran
<script>
const snapshot = ${JSON.stringify(snapshot)};
const readOnly = ${JSON.stringify(readOnly)};
+const requests = ${JSON.stringify(requestMode)};
const transportModule = ${moduleOption};
const connection = ${connection};
let transport = null;
@@ -468,6 +471,53 @@ async function api(path, body) {
return json;
}
+/** Send only literal person intent; the transport seals it and generic API writes stay refused. */
+async function sendPersonRequest(root, move) {
+ if (!requests || snapshot || !readOnly) throw new Error('This view cannot send person requests.');
+ if (!['add', 'shout', 'answer', 'hold', 'spec-approve', 'spec-decline'].includes(move.verb)) throw new Error('Choose a person action from the view controls.');
+ if (!transport) throw transportLoadError || new Error('The browser transport is still loading.');
+ return transport.request(boardPath(root) + '/moves', move);
+}
+
+/** Name a person request using its public literal intent, without exposing its sealed document. */
+function requestLabel(request) {
+ const move = request.move;
+ const args = move?.args || {};
+ if (move?.verb === 'add') return 'New item: ' + (args.title || 'Untitled');
+ if (move?.verb === 'shout') return 'Shout to ' + (args.to || 'coordinator') + ': ' + (args.text || '');
+ if (move?.verb === 'answer') return 'Answer #' + move.item + ': ' + (args.text || '');
+ if (move?.verb === 'hold') return (args.off ? 'Release ' : 'Hold ') + (args.lane || '') + ' lane' + (!args.off && args.reason ? ': ' + args.reason : '');
+ if (move?.verb === 'spec-approve') return 'Approve row ' + (args.ids || '');
+ if (move?.verb === 'spec-decline') return 'Decline row ' + (args.ids || '');
+ return 'Person request';
+}
+
+/** Retain the native request status and the CLI's complete refusal guidance beside an action. */
+function requestNotice(request) {
+ const label = { waiting: 'Waiting', done: 'Done', refused: 'Refused' }[request.status] || 'Unknown status';
+ const error = request.status === 'refused' && request.error;
+ return label + ' · ' + requestLabel(request) + (error ? '\\n' + (error.code ? '[' + error.code + '] ' : '') + (error.message || '') + (error.next ? '\\n' + error.next : '') : '');
+}
+
+/** Show the public request receipts on every board tab and update the latest action's status. */
+function renderPersonRequests(project) {
+ const entries = project?.personRequests || [];
+ const panel = $('person-requests');
+ panel.hidden = !entries.length;
+ panel.innerHTML = entries.length ? '<h2>Your requests</h2><ul class="request-list">' + [...entries].sort((a, b) => b.sequence - a.sequence).map((request) => {
+ const status = { waiting: 'Waiting', done: 'Done', refused: 'Refused' }[request.status] || 'Unknown status';
+ const error = request.status === 'refused' && request.error;
+ const reason = error ? '<p class="request-error">' + (error.code ? '<b>' + esc(error.code) + '</b> ' : '') + esc(error.message || '') + '</p>' + (error.next ? '<p class="request-next">' + esc(error.next) + '</p>' : '') : '';
+ return '<li data-person-request="' + esc(request.id) + '"><span class="request-label">' + esc(requestLabel(request)) + '</span><span class="chip request-status ' + (request.status === 'done' ? 'ok' : request.status === 'refused' ? 'no' : 'warn') + '">' + status + '</span>' + reason + '</li>';
+ }).join('') + '</ul>' : '';
+ const active = view.request;
+ const current = active && active.root === view.root && active.run === view.acting && entries.find((request) => request.id === active.id);
+ if (current && !$('console').hidden) {
+ $('console').className = 'console' + (current.status === 'done' ? ' ok' : current.status === 'refused' ? ' no' : '');
+ $('console').textContent = requestNotice(current);
+ }
+}
+
/** A board's sidebar counts, derived from the same API state the page displays. */
function boardSummary(board, state) {
/** Count one item state for the sidebar. */
@@ -858,6 +908,7 @@ function render() {
$('tabs').hidden = Boolean(group);
document.querySelectorAll('[data-pane]').forEach((pane) => { pane.hidden = Boolean(group) || pane.dataset.pane !== view.tab; });
$('products').hidden = !p || !p.products.length;
+ renderPersonRequests(p);
if (group) { renderGroup(group); return; }
if (!p) return;
// Each product's progress (N28): the rows an accepted item cites, and its items by state.
@@ -1181,7 +1232,7 @@ async function code(ref, before) {
render();
}
-/** Translate the page's five actions into the public move shape and a familiar command label. */
+/** Translate person actions into their public literal intent and a familiar command label. */
function pageMove(command, args = {}) {
/** Trim form values before constructing the move and its display label. */
const text = (value) => String(value || '').trim();
@@ -1195,6 +1246,8 @@ function pageMove(command, args = {}) {
if (command === 'answer') return { body: { verb: 'answer', item: Number(args.id), args: { text: text(args.text), as: 'person' } }, label: ['answer', text(args.id), text(args.text), '--as', 'person'].join(' ') };
if (command === 'hold') return { body: { verb: 'hold', args: { lane: text(args.lane), reason: text(args.reason) } }, label: ['hold', text(args.lane), '--reason', text(args.reason)].join(' ') };
if (command === 'release') return { body: { verb: 'hold', args: { lane: text(args.lane), off: true } }, label: ['hold', text(args.lane), '--off'].join(' ') };
+ if (command === 'spec-approve') return { body: { verb: command, args: { ids: text(args.ids) } }, label: 'spec approve ' + text(args.ids) };
+ if (command === 'spec-decline') return { body: { verb: command, args: { ids: text(args.ids), reason: text(args.reason) } }, label: 'spec decline ' + text(args.ids) + ' --reason ' + text(args.reason) };
throw new Error('No view action ' + String(command) + '; choose add, shout, answer, hold or release.');
}
@@ -1209,7 +1262,7 @@ function moveMessage(move, result) {
/** Run a public API move beside its action and let only the latest one own the console and timer. */
async function act(command, args, anchor) {
const out = $('console');
- if (snapshot || readOnly) { out.hidden = false; out.className = 'console no'; out.textContent = snapshot ? 'This is a read-only snapshot.' : 'This is a read-only view.'; return false; }
+ if (snapshot || (readOnly && !requests)) { out.hidden = false; out.className = 'console no'; out.textContent = snapshot ? 'This is a read-only snapshot.' : 'This is a read-only view.'; return false; }
if (anchor) {
const target = anchor.matches('form')
? anchor.querySelector('.actions') || anchor.querySelector('[type="submit"]') || anchor
@@ -1217,25 +1270,30 @@ async function act(command, args, anchor) {
target.insertAdjacentElement(anchor.matches('form') ? 'beforebegin' : 'afterend', out);
}
const run = (view.acting = (view.acting || 0) + 1);
- const latest = () => run === view.acting;
+ const root = view.root;
+ const latest = () => run === view.acting && root === view.root;
+ view.request = null;
clearTimeout(view.closing);
out.hidden = false;
out.className = 'console';
- out.textContent = 'running…';
+ out.textContent = requests ? 'Request waiting…' : 'running…';
out.scrollIntoView({ block: 'nearest' });
try {
const move = pageMove(command, args);
- const result = await api(boardPath(view.root) + '/moves', move.body);
+ const result = requests ? await sendPersonRequest(root, move.body) : await api(boardPath(root) + '/moves', move.body);
+ const request = requests && result?.result?.request;
+ if (requests && (!request?.id || !['waiting', 'done', 'refused'].includes(request.status))) throw new Error('The request did not include its status; refresh the board to check it.');
if (latest()) {
- out.className = 'console ok';
- out.textContent = '$ pullboard ' + move.label + '\\n' + moveMessage(move.body, result.result);
+ out.className = 'console' + (requests ? request.status === 'done' ? ' ok' : request.status === 'refused' ? ' no' : '' : ' ok');
+ out.textContent = requests ? requestNotice(request) : '$ pullboard ' + move.label + '\\n' + moveMessage(move.body, result.result);
+ if (requests) view.request = { root, id: request.id, run };
out.scrollIntoView({ block: 'center' });
// What went through says so and then steps aside; a refusal stays until the person closes it.
- view.closing = setTimeout(() => { if (latest()) out.hidden = true; }, 6000);
+ if (!requests || request.status === 'done') view.closing = setTimeout(() => { if (latest()) out.hidden = true; }, 6000);
}
await refresh();
if (latest()) out.scrollIntoView({ block: 'center' });
- return true;
+ return !requests || request.status !== 'refused';
} catch (error) {
if (latest()) {
out.className = 'console no';
diff --git a/src/view.css b/src/view.css
index 6b9df189..e6e53d11 100644
--- a/src/view.css
+++ b/src/view.css
@@ -305,7 +305,17 @@ code.inline { padding: 0 3px; border-radius: 3px; background: color-mix(in srgb,
.snapshot-controls label { display: flex; align-items: center; gap: 6px; }
.snapshot-controls output { color: var(--ink-muted); font: 12px/1.5 var(--mono); }
.snapshot #new-item, .snapshot form, .snapshot [data-new], .snapshot [data-release], .snapshot [data-shout], .snapshot [data-go^="decide:"] { display: none !important; }
-.read-only #new-item, .read-only form, .read-only [data-new], .read-only [data-release], .read-only [data-shout], .read-only [data-go^="decide:"] { display: none !important; }
+.read-only:not(.requests) #new-item, .read-only:not(.requests) form, .read-only:not(.requests) [data-new], .read-only:not(.requests) [data-release], .read-only:not(.requests) [data-shout], .read-only:not(.requests) [data-go^="decide:"] { display: none !important; }
+.person-requests { margin-bottom: 12px; padding: 12px; min-width: 0; }
+.person-requests h2 { margin: 0 0 8px; font-size: 14px; }
+.request-list { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; }
+.request-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--line); }
+.request-list li:first-child { border-top: 0; }
+.request-label { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
+.request-status { align-self: start; font-size: 12px; }
+.request-error, .request-next { grid-column: 1 / -1; margin: 0; overflow-wrap: anywhere; font-size: 12px; }
+.request-error { color: var(--reject); }
+.request-next { color: var(--ink-muted); }
/* Every action keeps a usable touch target at either viewport, including inline controls. */
button, input, select, textarea, [data-item], [data-row] { min-height: 44px; }
diff --git a/test/cockpit.test.js b/test/cockpit.test.js
index 45b62e34..01ec4c18 100644
--- a/test/cockpit.test.js
+++ b/test/cockpit.test.js
@@ -2665,6 +2665,196 @@ test('served connection reaches an authenticated API on another origin and path
}
});
+test('relay person requests stay explicit, read-only and visible [H12,H5]', { timeout: 120_000 }, async (t) => {
+ const executable = chromeExecutable();
+ if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME to run the person-request transport proof.');
+
+ const box = machine();
+ const requestSpec = `# Person request fixture\n\n## G · Goals\n- G1 [approved, must] Existing item remains readable. | gate: test\n- G2 [draft, must] The person can approve this row. | gate: test\n`;
+ const app = project(box, 'person requests', requestSpec);
+ box.run(app.repo, 'add', 'web', 'Existing private item', '--specs', 'G1', '--criterion', 'remains readable');
+ box.run(app.repo, 'shout', 'person', 'Should this item ship?', '--decision');
+ const live = await startView(box);
+ const intents = [];
+ const records = [];
+ let chrome;
+ /** Build the opted-in page or a refusal control with the same read-only transport. */
+ const page = (options = {}) => cockpitPage('', {
+ readOnly: true, requests: true, transportModule: '/transport.js', stylesheet: '/view.css', ...options,
+ });
+ const transportModule = `/** Provide the permitted stand-in transport while leaving real board reads untouched. */
+ export async function createTransport({ onUpdate }) {
+ window.__transportCalls = [];
+ window.__setPersonRequest = async (id, status, error) => {
+ await fetch('/request-status', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id, status, error }) });
+ await onUpdate();
+ };
+ return { async request(path, body) {
+ window.__transportCalls.push({ path, body: body ?? null });
+ if (body) {
+ const response = await fetch('/intent', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
+ const document = await response.json();
+ if (!response.ok) throw new Error(document.error?.message || String(response.status));
+ return document;
+ }
+ const response = await fetch('/fixture' + path);
+ const document = await response.json();
+ if (!response.ok) throw new Error(document.error?.message || String(response.status));
+ if (new URL(path, location.origin).pathname.endsWith('/state')) document.state.personRequests = await (await fetch('/request-state')).json();
+ return document;
+ } };
+ }`;
+ /** Serve controlled request receipts and proxy reads to the actual private Git/SQLite board. */
+ async function fixtureRequest(request, response) {
+ const url = new URL(request.url, 'http://127.0.0.1');
+ if (url.pathname === '/request-state' && request.method === 'GET') {
+ return response.writeHead(200, { 'content-type': 'application/json' }).end(JSON.stringify(records));
+ }
+ if (url.pathname === '/request-status' && request.method === 'POST') {
+ const chunks = [];
+ for await (const chunk of request) chunks.push(chunk);
+ const update = JSON.parse(Buffer.concat(chunks).toString('utf8'));
+ const row = records.find(entry => entry.id === update.id);
+ row.status = update.status;
+ if (update.error) row.error = update.error;
+ return response.writeHead(200).end();
+ }
+ if (url.pathname === '/intent' && request.method === 'POST') {
+ const chunks = [];
+ for await (const chunk of request) chunks.push(chunk);
+ const move = JSON.parse(Buffer.concat(chunks).toString('utf8'));
+ const allowed = ['add', 'shout', 'answer', 'hold', 'spec-approve', 'spec-decline'].includes(move.verb)
+ && Object.keys(move).every(key => ['verb', 'item', 'args'].includes(key));
+ if (!allowed) return response.writeHead(400, { 'content-type': 'application/json' }).end(JSON.stringify({ error: { message: 'Only literal person requests are allowed.' } }));
+ intents.push(structuredClone(move));
+ const row = { id: 'request-' + intents.length, sequence: intents.length, at: '2026-10-08T00:00:00.000Z', by: 'person', move, status: 'waiting' };
+ records.push(row);
+ return response.writeHead(200, { 'content-type': 'application/json' }).end(JSON.stringify({ version: 1, event: { event_id: row.sequence, kind: 'request' }, result: { request: row } }));
+ }
+ if (url.pathname.startsWith('/fixture/')) {
+ if (request.method !== 'GET') return response.writeHead(405, { 'content-type': 'application/json' }).end(JSON.stringify({ error: { message: 'The read-only fixture accepts GET only.' } }));
+ const upstream = await fetch(live.base + url.pathname.slice('/fixture'.length) + url.search, { headers: { 'x-pullboard-key': live.key } });
+ return response.writeHead(upstream.status, { 'content-type': 'application/json' }).end(await upstream.text());
+ }
+ response.writeHead(404).end();
+ }
+ /** Serve each capability control and the same-origin stand-in request protocol. */
+ const pageServer = createServer(async (request, response) => {
+ const url = new URL(request.url, 'http://127.0.0.1');
+ if (url.pathname === '/' || url.pathname === '/without-capability' || url.pathname === '/snapshot') {
+ const body = url.pathname === '/'
+ ? page({})
+ : url.pathname === '/snapshot'
+ ? cockpitPage('', { snapshot: true, requests: true, stylesheet: '/view.css' })
+ : cockpitPage('', { readOnly: true, transportModule: '/transport.js', stylesheet: '/view.css' });
+ return response.writeHead(200, { 'content-type': 'text/html; charset=utf-8' }).end(body);
+ }
+ if (url.pathname.startsWith('/api/v1/') && url.pathname.endsWith('.json')) {
+ const target = url.pathname.slice(0, -'.json'.length) + url.search;
+ const upstream = await fetch(live.base + target, { headers: { 'x-pullboard-key': live.key } });
+ return response.writeHead(upstream.status, { 'content-type': 'application/json' }).end(await upstream.text());
+ }
+ if (url.pathname === '/transport.js') return response.writeHead(200, { 'content-type': 'text/javascript' }).end(transportModule);
+ if (url.pathname === '/view.css') return response.writeHead(200, { 'content-type': 'text/css' }).end(readFileSync(resolve(import.meta.dirname, '../src/view.css')));
+ return fixtureRequest(request, response);
+ });
+ await new Promise((resolve) => pageServer.listen(0, '127.0.0.1', resolve));
+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-person-request-chrome-'));
+ scratch.push(profile);
+ try {
+ chrome = await openSnapshotChrome(executable, `http://127.0.0.1:${pageServer.address().port}/`, profile);
+ await chrome.waitFor("typeof data === 'object' && !!data?.project && typeof window.__setPersonRequest === 'function'");
+ await chrome.send('Emulation.setDeviceMetricsOverride', { width: 375, height: 900, deviceScaleFactor: 1, mobile: false });
+ assert.equal(await chrome.evaluate('document.documentElement.scrollWidth <= document.documentElement.clientWidth'), true, 'the request view fits a phone viewport');
+ assert.equal(await chrome.evaluate("document.body.classList.contains('requests') && getComputedStyle(document.querySelector('#new-item')).display !== 'none' && document.querySelector('#new-item').getBoundingClientRect().height >= 44"), true, 'the explicit capability exposes usable person controls');
+ await chrome.evaluate("document.querySelector('[data-tab=\"shouts\"]').click(); document.querySelector('#shout-to').value = 'coordinator'; document.querySelector('#shout-text').value = 'Please review this item.'; document.querySelector('#shout-form').requestSubmit()");
+ await chrome.waitFor("data?.project?.personRequests?.length === 1");
+ assert.deepEqual(intents.at(-1), { verb: 'shout', args: { to: 'coordinator', text: 'Please review this item.' } });
+ assert.equal(await chrome.evaluate(`(async () => act('spec-approve', { ids: 'G2' }))()`), true);
+ assert.deepEqual(intents.at(-1), { verb: 'spec-approve', args: { ids: 'G2' } });
+
+ const ids = JSON.parse(await chrome.evaluate('JSON.stringify(data.project.personRequests.map(row => row.id))'));
+ assert.deepEqual(ids, ['request-1', 'request-2']);
+ assert.ok(await chrome.evaluate("[...document.querySelectorAll('[data-person-request]')].length === 2 && [...document.querySelectorAll('[data-person-request]')].every(node => node.querySelector('.request-status').textContent === 'Waiting')"), 'waiting receipts render from API state');
+
+ // A generic write and an unknown action are refused before they reach the stand-in transport.
+ const beforeRefused = intents.length;
+ const beforeTransport = await chrome.evaluate('window.__transportCalls.length');
+ assert.match(await chrome.evaluate(`(async () => { try { await api(boardPath(view.root) + '/moves', { verb: 'shout', args: { to: 'coordinator', text: 'direct writes stay refused' } }); return 'unexpected'; } catch (error) { return error.message; } })()`), /read-only view/i);
+ assert.equal(await chrome.evaluate(`(async () => act('exec', { command: 'true' }))()`), false);
+ assert.equal(intents.length, beforeRefused, 'refused shapes never reach the request server');
+ assert.equal(await chrome.evaluate('window.__transportCalls.length'), beforeTransport, 'refused writes never reach the browser transport');
+
+ const longTitle = 'Requested item ' + 'abcdefghij'.repeat(24);
+ const otherActions = [
+ ['add', { lane: 'web', title: longTitle, criterion: 'visible', specs: 'G1', brief: 'requested work' }, { verb: 'add', args: { lane: 'web', title: longTitle, criterion: 'visible', specs: 'G1', brief: 'requested work' } }],
+ ['answer', { id: 1, text: 'Ship it' }, { verb: 'answer', item: 1, args: { text: 'Ship it', as: 'person' } }],
+ ['hold', { lane: 'web', reason: 'Wait for the decision' }, { verb: 'hold', args: { lane: 'web', reason: 'Wait for the decision' } }],
+ ['release', { lane: 'web' }, { verb: 'hold', args: { lane: 'web', off: true } }],
+ ['spec-decline', { ids: 'G2', reason: 'Keep the present behavior' }, { verb: 'spec-decline', args: { ids: 'G2', reason: 'Keep the present behavior' } }],
+ ];
+ for (const [action, args, expected] of otherActions) {
+ assert.equal(await chrome.evaluate(`act(${JSON.stringify(action)}, ${JSON.stringify(args)})`), true, `${action} is a permitted person request`);
+ assert.deepEqual(intents.at(-1), expected, `${action} retains literal public CLI intent`);
+ }
+ const allActions = [['shout', { to: 'coordinator', text: 'must not send' }], ['spec-approve', { ids: 'G2' }], ...otherActions.map(([action, args]) => [action, args])];
+
+ // The no-capability read-only page and static snapshot cannot send person requests either.
+ await chrome.send('Page.navigate', { url: `http://127.0.0.1:${pageServer.address().port}/without-capability` });
+ await chrome.waitFor("typeof data === 'object' && !!data?.project && document.body?.classList.contains('read-only')");
+ const beforeDisabled = intents.length;
+ for (const [action, args] of allActions) assert.equal(await chrome.evaluate(`act(${JSON.stringify(action)}, ${JSON.stringify(args)})`), false, `${action} stays refused without the capability`);
+ assert.equal(intents.length, beforeDisabled, 'read-only without the explicit request capability refuses every action');
+ await chrome.send('Page.navigate', { url: `http://127.0.0.1:${pageServer.address().port}/snapshot` });
+ await chrome.waitFor("typeof data === 'object' && !!data?.project && document.body?.classList.contains('snapshot')");
+ for (const [action, args] of allActions) assert.equal(await chrome.evaluate(`act(${JSON.stringify(action)}, ${JSON.stringify(args)})`), false, `${action} stays refused in a snapshot`);
+ assert.match(await chrome.evaluate(`(async () => { try { await api('/api/v1/boards/demo/moves', { verb: 'shout' }); return 'unexpected'; } catch (error) { return error.message; } })()`), /read-only snapshot/i);
+ assert.equal(intents.length, beforeDisabled, 'snapshot mode cannot use the explicit request capability');
+
+ // A later actual API read may update status; refusal text is safe text and preserves CLI guidance.
+ await chrome.send('Page.navigate', { url: `http://127.0.0.1:${pageServer.address().port}/` });
+ await chrome.waitFor("typeof window.__setPersonRequest === 'function' && !!data?.project");
+ await chrome.evaluate(`window.__setPersonRequest('request-1', 'done')`);
+ await chrome.waitFor("document.querySelector('[data-person-request=\"request-1\"]')?.querySelector('.request-status')?.textContent === 'Done'");
+ const refusal = '<img src=x onerror=globalThis.requestInjection=true> UNKNOWN_SPEC; run pullboard spec check';
+ await chrome.evaluate(`window.__setPersonRequest('request-2', 'refused', { code: 'UNKNOWN_SPEC', message: ${JSON.stringify(refusal)}, next: 'run pullboard spec check' })`);
+ await chrome.waitFor("document.querySelector('[data-person-request=\"request-2\"]')?.textContent.includes('UNKNOWN_SPEC')");
+ assert.equal(await chrome.evaluate("document.querySelector('[data-person-request=\"request-2\"] img') === null"), true, 'refusal guidance is escaped, not interpreted as markup');
+ assert.equal(await chrome.evaluate("document.querySelector('[data-person-request=\"request-2\"] .request-error')?.textContent"), 'UNKNOWN_SPEC ' + refusal, 'the original CLI refusal message stays intact');
+ assert.equal(await chrome.evaluate('globalThis.requestInjection === undefined'), true, 'refusal content cannot execute in the page');
+ assert.equal(await chrome.evaluate("document.querySelector('[data-person-request=\"request-2\"]')?.textContent.includes('run pullboard spec check')"), true);
+ for (const width of [375, 1280]) {
+ await chrome.send('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false });
+ assert.equal(await chrome.evaluate('document.documentElement.scrollWidth <= document.documentElement.clientWidth'), true, `${width}px refusal view has no horizontal overflow`);
+ const layout = JSON.parse(await chrome.evaluate(`JSON.stringify({
+ statuses: [...document.querySelectorAll('.request-status')].map(node => node.textContent),
+ listFits: document.querySelector('.request-list').scrollWidth <= document.querySelector('.request-list').clientWidth,
+ readable: [...document.querySelectorAll('.request-label, .request-status, .request-error, .request-next')].every(node => {
+ const rect = node.getBoundingClientRect();
+ return rect.width > 0 && rect.height > 0 && rect.left >= 0 && rect.right <= innerWidth && parseFloat(getComputedStyle(node).fontSize) >= 12;
+ })
+ })`));
+ for (const status of ['Waiting', 'Done', 'Refused']) assert.ok(layout.statuses.includes(status), `${width}px renders ${status} from documented request status`);
+ assert.equal(layout.listFits, true, `${width}px keeps the request list inside its panel`);
+ assert.equal(layout.readable, true, `${width}px keeps request labels and refusal guidance readable`);
+ }
+ assert.deepEqual(intents, [
+ { verb: 'shout', args: { to: 'coordinator', text: 'Please review this item.' } },
+ { verb: 'spec-approve', args: { ids: 'G2' } },
+ ...otherActions.map(([, , expected]) => expected),
+ ]);
+ const privatePath = await chrome.evaluate('boardPath(view.root)');
+ const privateState = await (await fetch(live.base + privatePath + '/state', { headers: { 'x-pullboard-key': live.key } })).json();
+ assert.equal(privateState.state.items.length, 1, 'the stand-in request transport never executes an item move on the real board');
+ assert.equal(privateState.state.holds.length, 0, 'the request transport never changes a real lane hold');
+ assert.equal(privateState.state.shouts.length, 1, 'the request transport never posts a direct shout');
+ } finally {
+ if (chrome) { chrome.socket.close(); await stopOwnedChrome(chrome.child, chrome.stopped); }
+ await new Promise((resolve) => pageServer.close(resolve));
+ await live.stop();
+ }
+});
+
test('read-only pages use a local browser transport and refresh on its updates [N26,N27]', { timeout: 90_000 }, async (t) => {
const executable = chromeExecutable();
if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME to run the browser transport proof.');