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.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
feat(view): the detail opens on the top item, not a blank form [N26]
Corey Olson7bbb7961fc6a
diff --git a/src/cockpit.js b/src/cockpit.jsindex 0f33c86e..7d92a8dd 100644--- a/src/cockpit.js+++ b/src/cockpit.js@@ -157,6 +157,7 @@ input, select { border: 1px solid var(--line-strong); background: var(--surface).panel-form { display: grid; gap: 10px; }.panel-form label, .inline label { display: grid; gap: 4px; font-size: 12px; color: var(--ink-muted); }.panel-form input, .panel-form select, .inline input, .inline select { width: 100%; }+.actions { display: flex; gap: 8px; } .actions .go { flex: 1; }.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; padding: 10px; }.inline label { flex: 1 1 150px; min-width: 0; }.feed { padding: 6px 10px 10px; display: grid; }@@ -222,7 +223,7 @@ input, select { border: 1px solid var(--line-strong); background: var(--surface)<label>Title<input id="add-title" required placeholder="What to build"></label><label>Criterion<input id="add-criterion" placeholder="How a verifier knows it is done"></label><label>Spec rows<input id="add-specs" placeholder="G1,G2"></label>- <button class="go" type="submit">Add item</button>+ <div class="actions"><button class="go" type="submit">Add item</button><button class="ghost" id="add-cancel" type="button">Cancel</button></div></form></aside></section>@@ -306,8 +307,11 @@ async function refresh() {$('live').textContent = 'live · ' + new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit', hourCycle: 'h23' });}-function render() {- const p = data.project;+/**+ * The sidebar: every project, the one shown, and what needs the person elsewhere. A switch draws only+ * this until the new board arrives, so the main column never mixes the old board with the new pick.+ */+function renderSide() {// Every project stays in view with what needs the person there, so one look covers them all.$('proj-list').innerHTML = data.projects.length ? data.projects.map((x) => {const on = x.root === view.root;@@ -316,8 +320,15 @@ function render() {const elsewhere = data.projects.filter((x) => x.root !== view.root).reduce((n, x) => n + needCount(x), 0);$('proj-elsewhere').textContent = elsewhere ? elsewhere + ' elsewhere' : '';$('proj-elsewhere').hidden = !elsewhere;- if (!p) { $('proj-name').textContent = 'No project'; return; }- $('proj-name').textContent = (data.projects.find((x) => x.root === view.root) || { name: p.root.split('/').pop() }).name;+ const p = data.project;+ $('proj-name').textContent = p ? (data.projects.find((x) => x.root === view.root) || { name: p.root.split('/').pop() }).name : 'No project';+}++/** Draw the board shown: the sidebar, then every tab's panes from the project's board. */+function render() {+ const p = data.project;+ renderSide();+ if (!p) return;const items = p.items.filter((i) => i.status !== 'withdrawn');const by = (s) => items.filter((i) => stateOf(i) === s);const active = items.filter((i) => stateOf(i) !== 'verified');@@ -357,6 +368,8 @@ function render() {.filter((i) => !lane || i.lane === lane).filter((i) => !q || ('#' + i.id + ' ' + i.title + ' ' + i.specs.join(' ') + ' ' + (i.criterion || '')).toLowerCase().includes(q)).sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));+ // With nothing picked, the detail shows the first row, and keeps it when a refresh reorders the list.+ if (!view.adding && !p.items.some((i) => i.id === view.item)) view.item = shown.length ? shown[0].id : null;$('chain').innerHTML = shown.length ? shown.map((i) => {const s = stateOf(i);const who = s === 'building' ? i.owner : [i.builtBy, i.verifiedBy].filter(Boolean).join(' → ');@@ -364,8 +377,12 @@ function render() {}).join('') : '<li class="empty">' + (items.length ? 'No items match.' : 'No items yet. Add the first one with New item.') + '</li>';const item = p.items.find((i) => i.id === view.item);- $('add-form').hidden = !(view.adding || !item);- $('detail').hidden = !item || view.adding;+ // The form shows when asked for, or when the project has nothing yet to show instead.+ const adding = view.adding || !items.length;+ $('add-form').hidden = !adding;+ $('add-cancel').hidden = !items.length;+ $('detail').hidden = adding;+ if (!item) $('detail').innerHTML = '<div class="empty">Pick an item to see its criterion, verdicts and history.</div>';if (item && !view.adding) {const s = stateOf(item);const cited = item.specs.map((id) => p.spec.find((r) => r.id === id) || { id, status: 'missing', text: '(not in SPEC.md)' });@@ -458,7 +475,9 @@ function switchTo(root) {view.adding = false;keep('pb.project', root);fold(false);- if (data) render();+ // The board that arrives is drawn even if it matches the last one seen, so the pick is made from it.+ seen = '';+ if (data) renderSide();document.body.classList.add('switching');refresh().catch(() => { $('live').textContent = 'offline: is pullboard view still running?'; }).finally(() => document.body.classList.remove('switching'));}@@ -480,7 +499,9 @@ document.addEventListener('click', (event) => {else if (t.dataset.shout) { $('shout-to').value = t.dataset.shout; $('shout-text').value = '#' + t.dataset.about + ': '; view.tab = 'shouts'; showTab(); $('shout-text').focus(); }else if (t.dataset.new !== undefined) { view.adding = true; render(); $('add-title').focus(); }});-$('new-item').addEventListener('click', () => { view.adding = true; view.item = null; render(); $('add-title').focus(); });+// The form covers the picked item rather than dropping it, so Cancel brings it back.+$('new-item').addEventListener('click', () => { view.adding = true; render(); $('add-title').focus(); });+$('add-cancel').addEventListener('click', () => { view.adding = false; render(); });$('q').addEventListener('input', () => render());$('lane-filter').addEventListener('change', () => render());$('add-form').addEventListener('submit', async (event) => {diff --git a/test/cockpit.test.js b/test/cockpit.test.jsindex fd95eea6..cc3c0cb6 100644--- a/test/cockpit.test.js+++ b/test/cockpit.test.js@@ -246,6 +246,11 @@ async function openPage(view, { width = 1280 } = {}) {for (const listener of node(id).listeners.input ?? []) listener({ target: node(id) });await settle(inflight);},+ // A click on a button with its own listener, or a form's submit.+ async fire(id, type) {+ for (const listener of node(id).listeners[type] ?? []) listener({ target: node(id), preventDefault() {} });+ await settle(inflight);+ },};}@@ -407,3 +412,58 @@ test('a sent-back item shows why first [N26]', async () => {await view.stop();}});++test('the detail opens on the top item, not a blank form [N26]', async () => {+ const box = machine();+ const alpha = project(box, 'alpha');+ box.run(alpha.repo, 'add', 'web', 'Greeting', '--specs', 'G1', '--criterion', 'greets');+ box.run(alpha.repo, 'add', 'web', 'Farewell', '--specs', 'G2', '--criterion', 'says goodbye');+ // Beta's first row is #3, while its #1 and #2 share ids with alpha's first row and pick.+ const beta = project(box, 'beta');+ for (const title of ['Beta one', 'Beta two', 'Beta three']) box.run(beta.repo, 'add', 'web', title, '--specs', 'G1', '--criterion', 'renders');+ const empty = project(box, 'empty');+ const done = project(box, 'done');+ box.run(done.repo, 'add', 'web', 'Shipped page', '--specs', 'G1', '--criterion', 'renders');+ build(box, done, 1, 'shipped.html');+ accept(box, done, 1);+ const view = await startView(box);+ try {+ const page = await openPage(view);+ const shown = () => /<h2><span>#(\d+)<\/span>([^<]*)</.exec(page.show('detail'))?.slice(1).join(' ');+ const rows = () => [...page.show('chain').matchAll(/<li class="row( on)?" data-item="(\d+)"/g)].map((match) => match[2] + (match[1] ? '*' : ''));+ const form = () => [page.element('add-form').hidden, page.element('detail').hidden];++ assert.equal(shown(), '2 Farewell', 'the first row, the item updated last');+ assert.deepEqual(rows(), ['2*', '1'], 'its row is marked');+ assert.deepEqual(form(), [true, false], 'no blank form');++ box.run(alpha.web, 'claim', '1');+ page.element('shout-to').value = 'web';+ page.element('shout-text').value = 'Greeting is claimed';+ await page.fire('shout-form', 'submit');+ assert.deepEqual(rows(), ['1', '2*'], 'the refresh put the claimed item first');+ assert.equal(shown(), '2 Farewell', 'and the pick held');++ await page.fire('new-item', 'click');+ assert.deepEqual(form(), [false, true], 'New item opens the form');+ assert.equal(page.element('add-cancel').hidden, false);+ await page.fire('add-cancel', 'click');+ assert.deepEqual(form(), [true, false], 'Cancel closes it');+ assert.equal(shown(), '2 Farewell', 'and brings back the item it covered');++ await page.click({ root: beta.repo, classes: 'proj side' });+ assert.equal(shown(), '3 Beta three', "the new project's first row, not an id from alpha");+ assert.deepEqual(rows(), ['3*', '2', '1']);++ await page.click({ root: empty.repo, classes: 'proj side' });+ assert.deepEqual(form(), [false, true], 'a project with no items opens on the form');+ assert.equal(page.element('add-cancel').hidden, true, 'with nothing to go back to');++ await page.click({ root: done.repo, classes: 'proj side' });+ assert.deepEqual(rows(), [], 'Active shows nothing: the only item is verified');+ assert.deepEqual(form(), [true, false]);+ assert.match(page.show('detail'), /Pick an item to see its criterion, verdicts and history\./);+ } finally {+ await view.stop();+ }+});