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): the view opens on the rules, then what needs you [N26]

Corey Olson0c45beb03abc
diff --git a/src/cockpit.js b/src/cockpit.js
index b17a2813..5aea067c 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -15,6 +15,7 @@ import {
} from './view/star.js';
import { commandPhrases } from './help.js';
import { personNeeds } from './needs.js';
+import { homeRules } from './view/home.js';
import {
drawHosted,
hostedBrowser,
@@ -98,7 +99,7 @@ export function cockpitPage(key = '', { snapshot = false, readOnly = false, requ
const releaseInfo = hostedReleaseInfo(hostedReleaseVersion, hostedReleaseVersions, releaseHosted);
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]);
- const pageScope = { STAR_KEY, applyStateDelta, closePageDialog, connection, drawHosted, hostedBrowser, hostedOptions, hostedReleaseDistance, hostedReleaseNote, hostedState, lifecycle, moduleOption, openPageDialog, pageStartup, paths, personNeeds, readOnly, releaseHosted, releaseInfo, requestMode, roadmapBlock, roadmapHeaders, roadmapSummary, sharingPresentation, snapshot, staleChip, tabValue, transportModule };
+ const pageScope = { STAR_KEY, applyStateDelta, closePageDialog, connection, drawHosted, hostedBrowser, hostedOptions, hostedReleaseDistance, hostedReleaseNote, homeRules, hostedState, lifecycle, moduleOption, openPageDialog, pageStartup, paths, personNeeds, readOnly, releaseHosted, releaseInfo, requestMode, roadmapBlock, roadmapHeaders, roadmapSummary, sharingPresentation, snapshot, staleChip, tabValue, transportModule };
return `<!doctype html>
<html lang="en">
<head>
@@ -127,6 +128,7 @@ ${hostedLocal && !snapshot ? '<div class="hosted-mark" aria-hidden="true"><svg v
<div class="body">
<header class="top">
<nav class="tabs" id="tabs" aria-label="Board">
+ <button class="tab" data-tab="home" type="button">Home</button>
<button class="tab" data-tab="items" type="button">Items</button>
<button class="tab" data-tab="shouts" type="button">Shouts</button>
<button class="tab" data-tab="spec" type="button">Spec</button>
@@ -161,6 +163,7 @@ ${hostedLocal && !snapshot ? '<div class="hosted-mark" aria-hidden="true"><svg v
<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="home" class="home" aria-label="Home"><section class="card-panel home-card" id="home-rules" aria-label="Your rules"></section><section class="card-panel home-card" aria-label="Needs you"><h2>Needs you</h2><ol class="needs home-needs" id="home-needs"></ol><p class="empty" id="home-calm" hidden>Nothing needs you.</p></section></section>
<section data-pane="items" class="two">
<div class="primary">
<section class="card-panel proof-stats" id="proof-stats" aria-label="Board proof stats" hidden></section>
@@ -1118,10 +1121,15 @@ function render() {
+ (at ? '<span class="row-age">' + age(at) + '</span>' : '') + '<div class="meta"><span class="why"><b>NEEDS YOU</b> ' + esc(kind) + '</span></div></div><span class="chip warn">' + esc(action) + '</span></li>';
const needKind = (entry) => entry[3] === 'decide' ? needRow([entry[0], '', entry[2], entry[3], entry[4]], 'a decision, asked by ' + entry[1], 'decide')
: entry[0].startsWith('spec:') ? needRow(entry, 'an open question in SPEC.md', 'answer') : needRow(entry, entry[3], 'release');
- $('needs').innerHTML = needs.map(needKind).join('')
+ const needsHtml = needs.map(needKind).join('')
+ rigorDrafts.map(row => needRow([row.target, row.ref, row.text], 'a proved Rigor draft', 'Approve or Decline')).join('')
+ sentinelDrafts.map(row => sentinelDraftRow(row)).join('')
+ (drafts ? needRow(['tab:spec', String(drafts), 'draft spec rows to approve or drop'], 'Spec rows waiting on you', 'review') : '');
+ $('needs').innerHTML = needsHtml;
+ // Home reads the rules first, then the same calls (#967).
+ $('home-rules').innerHTML = homeRules(p.spec);
+ $('home-needs').innerHTML = needsHtml;
+ $('home-calm').hidden = Boolean(needsHtml);
const lanes = p.lanes;
const working = lanes.filter((l) => l !== 'coordinator');
diff --git a/src/view.css b/src/view.css
index 6ccdaae5..4ef1c85a 100644
--- a/src/view.css
+++ b/src/view.css
@@ -77,6 +77,13 @@ button, input, select, textarea { font: inherit; color: inherit; }
.group-view { display: grid; gap: 14px; max-width: 1000px; }
.group-panel { padding: 14px 16px; }
.group-panel h2 { margin: 0 0 10px; font-size: 17px; }
+.home { display: grid; gap: 14px; max-width: 760px; }
+.home-card { padding: 14px 16px; }
+.home-card h2 { margin: 0 0 10px; font-size: 17px; }
+.home-counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0 0 10px; }
+.home-counts dt { color: var(--ink-muted); font-size: 13px; }
+.home-counts dd { margin: 2px 0 0; font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
+.home-needs { margin: 0; padding: 0; border-bottom: 0; }
.group-need { display: grid; grid-template-columns: minmax(90px, auto) auto minmax(0, 1fr) auto; align-items: baseline; gap: 5px 10px; width: 100%; padding: 9px 0; text-align: left; border: 0; border-top: 1px solid var(--line); background: none; }
.group-need:hover { background: var(--surface-2); }
.group-need > b { color: var(--ink-muted); }
diff --git a/src/view/home.js b/src/view/home.js
new file mode 100644
index 00000000..8c3ed2bd
--- /dev/null
+++ b/src/view/home.js
@@ -0,0 +1,16 @@
+/**
+ * The first screen's rules card (#967): how many Spec rows are approved, and how many of those name a gate or none,
+ * so a person reads whether the rules hold before the work queue. It counts the rows the board sends as they are;
+ * whether a gate runs, passes or was contradicted is the server's to report, so nothing here guesses at it.
+ *
+ * @param {Array<{ status: string, gate?: string }>} spec - The board's Spec rows, as the server projects them.
+ * @returns {string} The card's HTML.
+ */
+export function homeRules(spec) {
+ const approved = (spec ?? []).filter((row) => row.status === 'approved');
+ const gated = approved.filter((row) => String(row.gate ?? '').trim()).length;
+ const counts = [['approved', 'Approved', approved.length], ['gated', 'Name a gate', gated], ['ungated', 'No gate', approved.length - gated]];
+ return '<h2>Your rules</h2><dl class="home-counts">'
+ + counts.map(([key, label, n]) => '<div data-home-count="' + key + '"><dt>' + label + '</dt><dd>' + n + '</dd></div>').join('')
+ + '</dl><button class="link" data-go="tab:spec" type="button">Open the Spec</button>';
+}
diff --git a/src/view/page-script-1.js b/src/view/page-script-1.js
index d6683008..e58e6859 100644
--- a/src/view/page-script-1.js
+++ b/src/view/page-script-1.js
@@ -77,7 +77,7 @@ function addressTab() {
if (typeof location === 'undefined') return null;
if (snapshot) {
const tab = (location.hash || '').slice(1).split('/')[0] || '';
- return ['items', 'shouts', 'spec', 'doctrine', 'activity', 'roadmap'].includes(tab) ? tab : null;
+ return ['home', 'items', 'shouts', 'spec', 'doctrine', 'activity', 'roadmap'].includes(tab) ? tab : null;
}
if (location.hash === '#items/pipeline') return 'items';
if (/^#items\\/\\d+$/.test(location.hash)) return 'items';
@@ -93,10 +93,10 @@ function itemAddress(id, root = view.root) {
const path = prefix + '/items/' + encodeURIComponent(String(id));
return routed ? path + location.search : location.pathname + location.search + '#' + path.slice(1);
}
-/** The tab the board's own address shows: the one last picked there, or Items. */
-function homeTab() {
+/** The tab the board's own address shows: the one last picked there, else Home on a board with no items yet and Items on one with work (#967). */
+function homeTab(page) {
const kept = keep('pb.tab');
- return kept && kept !== 'roadmap' ? kept : 'items';
+ return kept && kept !== 'roadmap' ? kept : page?.project && !page.project.items?.length ? 'home' : 'items';
}
const view = { roadmapOpen: new Map(), root: keep('pb.project'), tab: addressTab() || homeTab(), itemsView: typeof location !== 'undefined' && location.hash === '#items/pipeline' ? 'pipeline' : 'list', filterOpen: false, seen: {}, code: {}, item: null, adding: false, declining: null, state: 'active', rows: { spec: 'decide', doctrine: 'all' }, row: { spec: null, doctrine: null }, agent: null, allAgents: false, agentsHidden: keep('pb.agents') === 'hidden', statsOpen: false, open: {}, addressDetail: null, shout: null, scrollPlace: false };
let switchGeneration = 0;
diff --git a/src/view/page-script-2.js b/src/view/page-script-2.js
index bab0000f..75001d74 100644
--- a/src/view/page-script-2.js
+++ b/src/view/page-script-2.js
@@ -6,7 +6,7 @@
* @returns {string} The script text of this part.
*/
export function pageScriptPart2(scope) {
- const { STAR_KEY, closePageDialog, connection, drawHosted, hostedBrowser, hostedReleaseDistance, hostedReleaseNote, hostedState, lifecycle, openPageDialog, personNeeds, releaseHosted, releaseInfo, roadmapBlock, roadmapHeaders, roadmapSummary, sharingPresentation, staleChip, transportModule } = scope;
+ const { STAR_KEY, closePageDialog, connection, drawHosted, homeRules, hostedBrowser, hostedReleaseDistance, hostedReleaseNote, hostedState, lifecycle, openPageDialog, personNeeds, releaseHosted, releaseInfo, roadmapBlock, roadmapHeaders, roadmapSummary, sharingPresentation, staleChip, transportModule } = scope;
return `let detailRead = null;
const addressedShouts = new Map();
const $ = (id) => document.getElementById(id);
@@ -310,6 +310,7 @@ function shoutAgentName(id) {
}
/** Render a review note with escaped text and references bound to the selected board. */
const verdictHtml = (v, titles) => '<div class="verdict ' + (v.decision === 'ACCEPT' ? 'yes' : 'no') + '"><b>' + esc(v.decision) + ' ' + esc(v.reason) + '</b><span class="by">' + esc(agentName(v.by)) + ' · ' + when(v.at) + ' · at ' + esc(String(v.commit || '').slice(0, 12)) + '</span><div class="note">' + inline(visibleVerdictNote(v.reason, v.note), titles) + '</div></div>';
+const homeRules = (${homeRules.toString()});
const roadmapSummary = (${roadmapSummary.toString()}), roadmapHeaders = (${roadmapHeaders.toString()});
const stateOf = (i) => i.status === 'claimed' ? 'building' : i.status === 'submitted' ? 'verify' : i.status === 'verified' ? 'verified' : i.status === 'withdrawn' ? 'withdrawn' : i.verdict && i.verdict.decision === 'REJECT' ? 'back' : 'open';
const STATES = { building: ['building', 'busy'], verify: ['to verify', 'warn'], back: ['sent back', 'no'], verified: ['verified', 'ok'], open: ['unclaimed', 'free'], withdrawn: ['withdrawn', ''] };
diff --git a/src/view/page-script-4.js b/src/view/page-script-4.js
index c03712e2..765c4b2b 100644
--- a/src/view/page-script-4.js
+++ b/src/view/page-script-4.js
@@ -22,7 +22,7 @@ function showTab() {
/** 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 = ['home', 'items', 'shouts', 'spec', 'doctrine', 'activity', 'roadmap'];
const hash = location.hash || '';
let path = routed ? location.pathname || '/' : hash.slice(1);
if (hash === '#items/pipeline' || hash === '#roadmap') path = hash.slice(1);
@@ -35,7 +35,7 @@ function placeAtAddress(page = data) {
const named = (repo || group) && tabs.includes(parts[1]);
const root = named ? repo?.root || group.key : null;
if (named) parts.shift();
- const tab = tabs.includes(parts[0]) ? parts.shift() : (!path && transportModule && globalThis.history?.state?.tab) || homeTab();
+ const tab = tabs.includes(parts[0]) ? parts.shift() : (!path && transportModule && globalThis.history?.state?.tab) || homeTab(page);
return { root, tab, detail: parts[0] ?? null };
}
@@ -101,7 +101,7 @@ function fromAddress(event) {
}
if (snapshot) {
const kept = event?.state || {};
- const place = location.hash ? placeAtAddress() : { root: null, tab: kept.tab || homeTab(), detail: kept.detail ?? null };
+ const place = location.hash ? placeAtAddress() : { root: null, tab: kept.tab || homeTab(data), detail: kept.detail ?? null };
applyPlace(place, kept);
if (kept.root && kept.root !== view.root) return switchTo(kept.root, view.item, false);
} else {
diff --git a/test/cockpit/home.test.js b/test/cockpit/home.test.js
new file mode 100644
index 00000000..10a9dccd
--- /dev/null
+++ b/test/cockpit/home.test.js
@@ -0,0 +1,54 @@
+/** The view opens on whether the rules hold, then what needs the person; Items stay one click away [N26,U91]. */
+import assert from 'node:assert/strict';
+import { test } from 'node:test';
+import { fetchLive, machine, openPage, project, startView, storage } from './fixture.js';
+
+/** Two gated rows, one approved aim with no gate, and an open question for the person. */
+const SPEC = `# Home spec
+
+## G · Goals
+- G1 [approved, must] The page renders. | gate: web test
+- G2 [approved, must] The page says goodbye. | gate: web test
+- G3 [approved, aim] The page reads well.
+- G4 [pending, must] Should the page greet a visitor? | gate: review
+`;
+
+/** One count from the rules card, by its key. */
+function count(html, key) {
+ return Number(new RegExp(`data-home-count="${key}"><dt>[^<]+</dt><dd>(\\d+)</dd>`).exec(html)?.[1]);
+}
+
+test('the first screen shows the rules and their proof before the work queue [N26]', async () => {
+ const box = machine();
+ const alpha = project(box, 'alpha', SPEC);
+ const view = await startView(box);
+ try {
+ const html = await (await fetchLive(view.link)).text();
+ const before = (first, then) => html.includes(first) && html.indexOf(first) < html.indexOf(then);
+ assert.ok(before('data-tab="home"', 'data-tab="items"'), 'Home is the first tab, Items the next');
+ assert.ok(before('data-pane="home"', 'data-pane="items"'), 'the rules come before the work queue');
+
+ // A new board opens on its rules: counted from the rows the board sends, then the calls waiting on the person.
+ const fresh = await openPage(view, { store: storage() });
+ assert.equal(fresh.run('view.tab'), 'home', 'a board with no items yet opens on Home');
+ const rules = fresh.show('home-rules');
+ assert.deepEqual(['approved', 'gated', 'ungated'].map((key) => count(rules, key)), [3, 2, 1], 'approved rows, those naming a gate, and those with none');
+ assert.match(rules, /data-go="tab:spec"/, 'the rules card opens the Spec');
+ assert.match(fresh.show('home-needs'), /Should the page greet a visitor\?[^]*?NEEDS YOU/, 'below the rules, what needs the person');
+ assert.equal(fresh.element('home-calm').hidden, true, 'no calm line while something waits');
+
+ // An existing board keeps opening on Items; one click switches, and that choice is kept.
+ box.run(alpha.repo, 'add', 'web', 'Render the page', '--specs', 'G1');
+ const store = storage();
+ const working = await openPage(view, { store });
+ assert.equal(working.run('view.tab'), 'items', 'a board with work opens on Items');
+ await working.click({ tab: 'home' });
+ assert.equal(working.run('view.tab'), 'home');
+ assert.equal(store.getItem('pb.tab'), 'home', 'the choice is kept');
+ assert.equal((await openPage(view, { store })).run('view.tab'), 'home', 'the next visit opens where the person left it');
+ await working.click({ tab: 'items' });
+ assert.equal((await openPage(view, { store })).run('view.tab'), 'items', 'Items is one click back, and kept too');
+ } finally {
+ await view.stop();
+ }
+});