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): show read-only settings by scope [O5,O6,N26]

Corey Olson04905437d6d6
diff --git a/src/cockpit.js b/src/cockpit.js
index b17a2813..81b8db13 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -38,6 +38,8 @@ import { pageScriptPart1 } from './view/page-script-1.js';
import { pageScriptPart2 } from './view/page-script-2.js';
import { pageScriptPart3 } from './view/page-script-3.js';
import { pageScriptPart4 } from './view/page-script-4.js';
+import { settingsMarkup } from './view/settings-page.js';
+import { settingsPageScript } from './view/settings-page.js';
import { historyLoadingScript } from './view/history-loading.js';
/** The CLI's default phrases, ordered by depth for the existing prose inventory guard. */
@@ -118,6 +120,7 @@ ${hostedLocal && !snapshot ? '<div class="hosted-mark" aria-hidden="true"><svg v
<button class="theme-btn" id="theme" type="button" title="Theme: system"><svg class="sys" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="6" fill="none" stroke="currentColor" stroke-width="1.5"/><path fill="currentColor" d="M8 2a6 6 0 0 1 0 12Z"/></svg><svg class="sun" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="3" fill="none" stroke="currentColor" stroke-width="1.5"/><path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" d="M8 1.5v1.2M8 13.3v1.2M1.5 8h1.2M13.3 8h1.2M3.4 3.4l.85.85M11.75 11.75l.85.85M3.4 12.6l.85-.85M11.75 4.25l.85-.85"/></svg><svg class="moon" viewBox="0 0 16 16" aria-hidden="true"><path fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round" d="M13.6 9.6A6 6 0 1 1 6.4 2.4a5.2 5.2 0 0 0 7.2 7.2Z"/></svg></button>
</div>
<div class="side-body" id="side-body">
+ <button class="ghost" data-tab="settings" type="button">Settings</button>
<div class="label">Projects</div>
<nav id="proj-list" aria-label="Projects on this machine"></nav>
<button class="share-again" id="share-again" type="button" hidden>Link boards to pullboard.dev&hellip;</button>
@@ -139,6 +142,7 @@ ${hostedLocal && !snapshot ? '<div class="hosted-mark" aria-hidden="true"><svg v
<main>
<section class="card-panel first">
<h2>No boards yet</h2>
+ <button class="ghost" data-settings-open type="button">Settings for this machine</button>
<p>Run <code>pullboard init</code> in a git repo, or ask an agent to. Its board shows up here by itself.</p>
</section>
<p class="empty" id="project-loading" role="status" hidden>Loading project…</p>
@@ -209,6 +213,7 @@ ${hostedLocal && !snapshot ? '<div class="hosted-mark" aria-hidden="true"><svg v
<button class="ghost flow-show" id="flow-show" type="button" hidden>Show the lifecycle</button>
<div class="card-panel feed" id="activity"></div>
</section>
+ ${settingsMarkup()}
<section data-pane="roadmap" class="roadmap-layout" id="roadmap" aria-label="Roadmap"></section>
${hostedLocal && !snapshot ? starMarkup() : ''}
</main>
@@ -1073,6 +1078,7 @@ function render() {
renderHostedReleaseNote(p);
renderPersonRequests(p);
renderCredentials();
+ if (view.tab === 'settings') { $('group-view').hidden = true; showTab(); return; }
if (group) { renderGroup(group); return; }
if (!p) return;
$('proof-stats').hidden = false;
@@ -1450,7 +1456,7 @@ function render() {
* it, so it stays closed across reloads, and across restarts of the view, which serves from the
* same address again, until they open it. While hidden it is not drawn.
*/
-${pageScriptPart4(pageScope)}${historyLoadingScript()}</script>
+${settingsPageScript()}${pageScriptPart4(pageScope)}${historyLoadingScript()}</script>
</body>
</html>`;
}
diff --git a/src/serve.js b/src/serve.js
index 7562e8c7..bd98257c 100644
--- a/src/serve.js
+++ b/src/serve.js
@@ -592,7 +592,7 @@ export async function serveView({ port = 0, secret = randomBytes(18).toString('b
if (given.length !== key.length || !timingSafeEqual(given, key)) return json(res, 403, { error: 'this view needs its own address and secret: open the link pullboard view printed' });
try {
// The board, and the Roadmap at its own address (N38), are the one page.
- if (req.method === 'GET' && (url.pathname === '/' || /^\/(?:[^/]+\/)?(?:items|shouts|spec|doctrine|activity|roadmap)(?:\/[^/]+)?$/.test(url.pathname))) return reply(res, 200, 'text/html; charset=utf-8', cockpitPage(secret, { paths: true }));
+ if (req.method === 'GET' && (url.pathname === '/' || /^\/(?:[^/]+\/)?(?:items|shouts|spec|doctrine|activity|roadmap|settings)(?:\/[^/]+)?$/.test(url.pathname))) return reply(res, 200, 'text/html; charset=utf-8', cockpitPage(secret, { paths: true }));
if (req.method === 'GET' && url.pathname === '/view.css') return reply(res, 200, 'text/css; charset=utf-8', VIEW_CSS);
return json(res, 404, { error: 'no such page' });
} catch (error) {
diff --git a/src/view.css b/src/view.css
index 29bdcd3f..fe00238d 100644
--- a/src/view.css
+++ b/src/view.css
@@ -1007,3 +1007,16 @@ code.inline.long { white-space: break-spaces; overflow-wrap: anywhere; }
.hosted-page.loading .shell { display: none; }
.hosted-page.loading .hosted-mark { display: grid; place-items: center; min-height: 100vh; color: var(--ink-muted); }
.hosted-page.loading .hosted-mark svg { width: 56px; height: 56px; }
+
+/* Settings are literal API data: readable on narrow screens, with no editable fields. */
+#settings-pane { padding: 20px; }
+#settings-content [role="tablist"] { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 16px; }
+#settings-content [aria-selected="true"] { font-weight: 700; border-color: var(--accent); }
+#settings-content table { width: 100%; border-collapse: collapse; margin-top: 16px; }
+#settings-content th, #settings-content td { padding: 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
+#settings-content td { max-width: 40ch; overflow-wrap: anywhere; white-space: pre-wrap; }
+
+.boardless [data-pane="settings"]:not([hidden]) { display: block; }
+
+#settings-content .settings-table { overflow-x: auto; }
+#settings-content { overflow-wrap: anywhere; }
diff --git a/src/view/page-script-4.js b/src/view/page-script-4.js
index c03712e2..85fddeb8 100644
--- a/src/view/page-script-4.js
+++ b/src/view/page-script-4.js
@@ -18,11 +18,12 @@ function showTab() {
document.querySelectorAll('.tab').forEach((button) => button.classList.toggle('on', button.dataset.tab === view.tab));
countUnseen();
if (view.tab === 'shouts') foldShouts();
+ if (view.tab === 'settings') void showSettings();
}
/** Read the selected repo, tab and detail from a path or the hosted page's fragment. */
function placeAtAddress(page = data) {
- const tabs = ['items', 'shouts', 'spec', 'doctrine', 'activity', 'roadmap'];
+ const tabs = ['items', 'shouts', 'spec', 'doctrine', 'activity', 'roadmap', 'settings'];
const hash = location.hash || '';
let path = routed ? location.pathname || '/' : hash.slice(1);
if (hash === '#items/pipeline' || hash === '#roadmap') path = hash.slice(1);
diff --git a/src/view/settings-page.js b/src/view/settings-page.js
new file mode 100644
index 00000000..8f6bf81a
--- /dev/null
+++ b/src/view/settings-page.js
@@ -0,0 +1,75 @@
+/** Read-only Settings page markup and embedded API-only browser behavior [O5,O6,N26]. */
+
+/** Render the Settings pane; its only controls navigate scopes or refresh a GET. */
+export function settingsMarkup() {
+ return '<section data-pane="settings" class="card-panel" id="settings-pane" aria-label="Settings" hidden><h2>Settings</h2><p>Read-only settings from this computer. Change settings through the supported commands.</p><button type="button" data-settings-open>All local boards</button><div id="settings-content" aria-live="polite"></div></section>';
+}
+
+/** Embed the scoped settings reader beside the existing page API and escaped-text renderer. */
+function settingsReaderScript() {
+ return `
+const settingsPages = new Map();
+let settingsScope = 'machine';
+let settingsAllBoards = false;
+/** Preserve false, zero, empty strings and null distinctly in a setting cell. */
+function settingText(value) {
+ return value === null ? 'null' : typeof value === 'object' ? JSON.stringify(value) : String(value);
+}
+/** Draw only escaped API values, including refusal messages, without editing controls. */
+function drawSettings(entry) {
+ const labels = { machine: 'This machine', repo: 'This repo', board: 'This board' };
+ const scopes = Object.entries(labels).map(([scope, label]) => '<button type="button" role="tab" data-settings-scope="' + scope + '" aria-selected="' + (scope === settingsScope) + '">' + label + '</button>').join('');
+ const rows = (entry.rows || []).filter(row => row.scope === settingsScope);
+ const cells = rows.map(row => '<tr data-setting-key="' + esc(row.key) + '"><th scope="row">' + esc(row.key) + (row.root ? '<br><small>' + esc(row.root) + '</small>' : '') + '</th><td>' + esc(row.secret ? (row.value === 'set' ? 'set' : 'not set') : settingText(row.value)) + '</td><td>' + esc(row.secret ? 'not set' : settingText(row.default)) + '</td><td>' + esc(row.source) + (row.origin ? ' (' + esc(row.origin) + ')' : '') + '</td></tr>').join('');
+ $('settings-content').innerHTML = '<p>' + esc(entry.context || 'This computer') + '</p><div role="tablist" aria-label="Settings scope">' + scopes + '</div><button type="button" data-settings-refresh>Refresh settings</button>'
+ + (entry.error ? '<p role="alert">' + esc(entry.error) + '</p>' : entry.loading ? '<p role="status">Loading settings…</p>' : '<div class="settings-table"><table><thead><tr><th>Setting</th><th>Value</th><th>Default</th><th>Source</th></tr></thead><tbody>' + cells + '</tbody></table></div>' + (!rows.length ? '<p>No settings in this scope.</p>' : ''));
+}
+/** Read only the selected local board; neither relay nor snapshot implies machine access. */
+async function showSettings(force = false) {
+ if (view.tab !== 'settings' || !data) return;
+ const root = view.root;
+ const allBoards = settingsAllBoards;
+ const board = !settingsAllBoards && data.projects.find(entry => entry.root === root && entry.ok);
+ const source = board && boardSources.get(board.id);
+ const hasLocal = hosted.local ? Boolean(localSession && localConfirmed) : transportModule === null;
+ if (snapshot || !hasLocal || (board && source?.kind !== 'local')) {
+ drawSettings({ error: 'Settings are available from this computer’s local view. Relay views and snapshots do not include machine settings.' });
+ return;
+ }
+ const key = localReadBase + ':' + (board?.id || 'machine');
+ let entry = settingsPages.get(key);
+ if (entry && !force) { drawSettings(entry); return; }
+ entry = { loading: true, context: board ? 'Settings for ' + board.root : 'This computer and all authorized local repos and boards' };
+ settingsPages.set(key, entry);
+ drawSettings(entry);
+ try {
+ const reply = await jsonRequest('/api/v1/settings' + (board ? '?board=' + encodeURIComponent(board.id) : ''), undefined, localReadBase, localReadHeaders);
+ if (!Array.isArray(reply.settings)) throw new Error('The settings API returned no inventory.');
+ entry.rows = reply.settings;
+ } catch (error) { entry.error = String(error.message || error); }
+ entry.loading = false;
+ if (view.root === root && settingsAllBoards === allBoards && view.tab === 'settings' && settingsPages.get(key) === entry) drawSettings(entry);
+}
+`;
+}
+
+/** Embed navigation-only controls after the API reader, without adding a write path. */
+export function settingsPageScript() {
+ return settingsReaderScript() + `
+/** Settings controls only change the selected scope or issue another read. */
+document.addEventListener('click', event => {
+ if (event.target.closest('[data-tab]') || event.target.closest('[data-root]')) settingsAllBoards = false;
+ if (event.target.closest('[data-settings-open]')) {
+ settingsAllBoards = true;
+ openTab('settings');
+ render();
+ }
+ const scope = event.target.closest('[data-settings-scope]');
+ if (scope && ['machine', 'repo', 'board'].includes(scope.dataset.settingsScope)) {
+ settingsScope = scope.dataset.settingsScope;
+ void showSettings();
+ }
+ if (event.target.closest('[data-settings-refresh]')) void showSettings(true);
+});
+`;
+}
diff --git a/test/cockpit/settings-context.test.js b/test/cockpit/settings-context.test.js
new file mode 100644
index 00000000..16f418e4
--- /dev/null
+++ b/test/cockpit/settings-context.test.js
@@ -0,0 +1,73 @@
+/** Settings stay scoped to their API authority, even before the first board [O5,O6,N26]. */
+import assert from 'node:assert/strict';
+import { test } from 'node:test';
+import { join } from 'node:path';
+import { machine, project, startView, openPage, fetchLive, chromeExecutable, openSnapshotChrome, closeSnapshotChrome } from './fixture.js';
+
+test('machine Settings remain reachable without any boards and use only the global read API [O5,O6,N26]', async () => {
+ const box = machine();
+ const view = await startView(box);
+ try {
+ const page = await openPage(view);
+ const reply = await fetchLive(`${view.base}/settings`, { headers: { 'x-pullboard-key': view.key } });
+ assert.equal(reply.status, 200, 'the Settings address survives a browser reload');
+ await page.click({ settingsOpen: '' });
+ assert.match(page.show('settings-content'), /This machine/u);
+ assert.match(page.show('settings-content'), /gateSlots/u);
+ assert.ok(page.requests.some(request => request.path === '/api/v1/settings'));
+ assert.ok(page.requests.every(request => request.method === 'GET'));
+ } finally { await view.stop(); }
+});
+
+test('global Settings distinguish repos and never reuse another selected board inventory [O5,O6,N26]', async () => {
+ const box = machine();
+ const alpha = project(box, 'alpha', undefined, { lease: '47m' });
+ const beta = project(box, 'beta', undefined, { lease: '53m' });
+ const view = await startView(box);
+ try {
+ const page = await openPage(view);
+ await page.click({ root: alpha.repo });
+ await page.click({ tab: 'settings' });
+ await page.click({ settingsScope: 'repo' });
+ assert.match(page.show('settings-content'), /47m/u);
+ assert.doesNotMatch(page.show('settings-content'), /53m/u);
+ await page.click({ root: beta.repo });
+ await page.click({ tab: 'settings' });
+ assert.match(page.show('settings-content'), /53m/u);
+ assert.doesNotMatch(page.show('settings-content'), /47m/u);
+ await page.click({ settingsOpen: '' });
+ assert.match(page.show('settings-content'), /47m/u);
+ assert.match(page.show('settings-content'), /53m/u);
+ assert.ok(page.requests.every(request => request.method === 'GET'));
+ } finally { await view.stop(); }
+});
+
+
+test('Settings render hostile values as read-only text in a narrow real browser [O5,O6,N26]', { timeout: 90_000 }, async (t) => {
+ const executable = chromeExecutable();
+ if (!executable) return t.skip('Chrome is required for the actual Settings browser proof.');
+ const box = machine();
+ project(box, 'alpha', undefined, { name: '<img src=x onerror="document.body.textContent=\'settings-owned\'">' });
+ const view = await startView(box);
+ let chrome;
+ try {
+ chrome = await openSnapshotChrome(executable, view.link.href, join(box.dir, 'settings-chrome'));
+ await chrome.waitFor('document.body.classList.contains("loading") === false');
+ await chrome.send('Emulation.setDeviceMetricsOverride', { width: 320, height: 800, deviceScaleFactor: 1, mobile: false });
+ await chrome.click(`document.querySelector('#proj-switch')`);
+ await chrome.click(`document.querySelector('[data-tab="settings"]')`);
+ await chrome.waitFor('document.querySelectorAll("#settings-content tr[data-setting-key]").length > 0');
+ await chrome.click(`document.querySelector('[data-settings-scope="repo"]')`);
+ await chrome.waitFor('document.querySelector("#settings-content").textContent.includes("settings-owned")');
+ await chrome.send('Emulation.setDeviceMetricsOverride', { width: 320, height: 800, deviceScaleFactor: 1, mobile: false });
+ const seen = JSON.parse(await chrome.stable(`JSON.stringify({ text: document.querySelector('#settings-content').textContent, images: document.querySelectorAll('#settings-content img').length, editors: document.querySelectorAll('#settings-content input,#settings-content select,#settings-content textarea,#settings-content form').length, width: document.documentElement.scrollWidth, client: document.documentElement.clientWidth, pane: getComputedStyle(document.querySelector('#settings-pane')).display })`));
+ assert.match(seen.text, /<img src=x/u, 'the actual browser displays literal hostile text');
+ assert.equal(seen.images, 0);
+ assert.equal(seen.editors, 0);
+ assert.notEqual(seen.pane, 'none');
+ assert.ok(seen.width <= seen.client, `Settings do not make the phone page scroll sideways: ${seen.width}/${seen.client}`);
+ } finally {
+ if (chrome) await closeSnapshotChrome(chrome);
+ await view.stop();
+ }
+});
diff --git a/test/cockpit/settings.test.js b/test/cockpit/settings.test.js
new file mode 100644
index 00000000..379bf1a9
--- /dev/null
+++ b/test/cockpit/settings.test.js
@@ -0,0 +1,65 @@
+/** Settings are projected by the real local API, never read or changed by the page [O5,O6,N26]. */
+import assert from 'node:assert/strict';
+import { readFileSync } from 'node:fs';
+import { join } from 'node:path';
+import { test } from 'node:test';
+import { machine, project, startView, openPage, fetchLive, boardId } from './fixture.js';
+
+/** Escape the expected literal API text, independently of the page's renderer. */
+function text(value) {
+ const display = value !== null && typeof value === 'object' ? JSON.stringify(value) : String(value);
+ return display.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;').replaceAll("'", '&#39;');
+}
+
+test('the Settings page lists every setting by scope from the settings API and edits nothing [O5,O6,N26]', async () => {
+ const box = machine();
+ const alpha = project(box, 'alpha', undefined, { name: '<img src=x onerror="document.body.textContent=\'settings-owned\'">', lease: '47m', health: { sentinel: false }, claim: { reopenFirstRefusalMinutes: 0 } });
+ project(box, 'beta', undefined, { lease: '53m' });
+ box.env.PULLBOARD_RELAY_KEY = 'settings-page-private-fixture-key';
+ const view = await startView(box);
+ try {
+ const page = await openPage(view);
+ const id = await boardId(view, alpha.repo);
+ const url = new URL('/api/v1/settings', view.base);
+ url.searchParams.set('board', id);
+ const reply = await fetchLive(url, { headers: { 'x-pullboard-key': view.key } });
+ assert.equal(reply.status, 200);
+ const inventory = await reply.json();
+ const before = box.run(alpha.repo, 'export', '--json');
+ const config = readFileSync(join(alpha.repo, 'pullboard.json'), 'utf8');
+ assert.match(page.html, /data-tab="settings"[^>]*>Settings</u, 'Settings is reachable from the board navigation');
+ await page.click({ root: alpha.repo });
+ await page.click({ tab: 'settings' });
+ for (const scope of ['machine', 'repo', 'board']) {
+ await page.click({ settingsScope: scope });
+ const shown = page.show('settings-content');
+ const rows = inventory.settings.filter(row => row.scope === scope);
+ assert.ok(rows.length > 0, `real API has ${scope} settings`);
+ assert.equal((shown.match(/data-setting-key=/gu) || []).length, rows.length, 'every API setting appears once in its scope');
+ for (const row of rows) {
+ assert.ok(shown.includes(`data-setting-key="${row.key}"`), `${scope}: ${row.key}`);
+ assert.ok(shown.includes(text(row.source)), `source: ${row.key}`);
+ const start = shown.indexOf(`data-setting-key="${row.key}"`);
+ const rendered = shown.slice(start, shown.indexOf('</tr>', start));
+ assert.ok(rendered.includes('<td>' + text(row.value) + '</td><td>' + text(row.default) + '</td>'), `literal current value and default: ${row.key}`);
+ }
+ assert.match(shown, /Value/u);
+ assert.match(shown, /Default/u);
+ assert.match(shown, /Source/u);
+ assert.doesNotMatch(shown, /<(?:input|select|textarea|form)\b/u, 'settings have no editor');
+ assert.doesNotMatch(shown, /settings-page-private-fixture-key/u);
+ if (scope === 'repo') {
+ assert.match(shown, /47m/u);
+ assert.match(shown, />false</u, 'false remains visible');
+ assert.match(shown, />0</u, 'zero remains visible');
+ assert.match(shown, /&lt;img/u, 'hostile setting text is escaped');
+ assert.doesNotMatch(shown, /<img\b|<script\b/u, 'API strings never become executable markup');
+ }
+ if (scope === 'board') assert.match(shown, />set</u);
+ }
+ assert.ok(page.requests.some(request => request.path.startsWith('/api/v1/settings?board=')), 'page reads the settings API');
+ assert.ok(page.requests.every(request => request.method === 'GET'), 'navigation records no moves or setting writes');
+ assert.equal(readFileSync(join(alpha.repo, 'pullboard.json'), 'utf8'), config);
+ assert.equal(box.run(alpha.repo, 'export', '--json'), before, 'settings navigation changes no board data');
+ } finally { await view.stop(); }
+});