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): a decision waits in Needs-you until answered [B21,N27]

Corey Olson42c12dedeff8
diff --git a/src/cockpit.js b/src/cockpit.js
index af482e82..e366f24a 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -133,6 +133,7 @@ main { padding: 16px 18px 28px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; }
.toolbar input { flex: 1 1 96px; }
input, select, textarea { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; padding: 7px 9px; min-width: 0; }
+input:disabled { background: var(--surface-2); color: var(--ink-muted); }
.go { border: 0; background: var(--ink); color: var(--surface); border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.go:hover { background: var(--accent-strong); color: var(--on-accent); }
.ghost { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; padding: 5px 10px; cursor: pointer; }
@@ -146,6 +147,14 @@ input, select, textarea { border: 1px solid var(--line-strong); background: var(
.ny span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-muted); }
.ny em { font-style: normal; color: var(--warn); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (width < 480px) { .ny { grid-template-columns: auto minmax(0, 1fr); row-gap: 1px; } .ny em { grid-column: 2; } }
+.ask { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 6px 4px; }
+.ask p { margin: 0; overflow-wrap: anywhere; }
+.ask small { color: var(--ink-muted); }
+.ask button { grid-row: 1 / span 2; grid-column: 2; }
+.answering { flex: 1 1 100%; display: flex; gap: 10px; align-items: baseline; justify-content: space-between; margin: 0; font-size: 13px; color: var(--ink-muted); }
+.answering > span { min-width: 0; overflow-wrap: anywhere; }
+.mark { font: 600 11px var(--mono); padding: 0 6px; border-radius: 999px; background: var(--surface-2); color: var(--ink-muted); }
+.mark.ask { display: inline; background: var(--warn-soft); color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 2px; }
.chips button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 9px; cursor: pointer; font-size: 13px; }
@@ -315,7 +324,8 @@ input, select, textarea { border: 1px solid var(--line-strong); background: var(
</section>
<section data-pane="shouts" class="two narrow">
<div class="primary">
- <form id="shout-form" class="card-panel inline"><label>To<input id="shout-to" list="shout-targets" required placeholder="all, a lane or an agent"></label><datalist id="shout-targets"></datalist><label style="flex:4 1 260px">Message<input id="shout-text" required></label><button class="go" type="submit">Shout</button></form>
+ <section class="needs-you" id="decisions" aria-label="Decisions needed" hidden></section>
+ <form id="shout-form" class="card-panel inline"><p class="answering" id="answering" hidden><span>Answering <b id="answering-who"></b>: <span id="answering-q"></span></span><button class="ghost" id="answer-cancel" type="button">Cancel</button></p><label>To<input id="shout-to" list="shout-targets" required placeholder="all, a lane or an agent"></label><datalist id="shout-targets"></datalist><label style="flex:4 1 260px">Message<input id="shout-text" required></label><button class="go" id="shout-send" type="submit">Shout</button></form>
<div class="card-panel feed" id="feed"></div>
</div>
<aside class="card-panel detail" aria-label="Agents and lanes">
@@ -615,8 +625,10 @@ function render() {
$('count-spec').textContent = p.spec.filter((r) => ['pending', 'draft'].includes(r.status)).length || '';
$('count-doctrine').textContent = p.practice.filter((r) => ['pending', 'draft'].includes(r.status)).length || '';
- // What needs the person, first: questions, work sent back, work waiting for a verdict, held lanes.
+ // What needs the person, first: decisions asked, questions, work sent back, work waiting for a
+ // verdict, held lanes.
const needs = [
+ ...p.decisions.map((d) => ['decide:' + d.shout_id, d.shout_from, d.shout_text, 'decide', d.shout_at]),
...p.spec.filter((r) => r.status === 'pending').map((r) => ['spec:' + r.id, r.id, r.text, 'answer in SPEC.md']),
...by('back').map((i) => ['item:' + i.id, '#' + i.id, i.title, 'sent back: ' + i.verdict.reason]),
...by('verify').map((i) => ['item:' + i.id, '#' + i.id, i.title, (i.reviewer ? 'being reviewed by ' + i.reviewer : rejected(i) ? 'resubmitted after ' + i.verdict.reason : 'to verify'), i.updatedAt]),
@@ -691,7 +703,11 @@ function render() {
const id = /^#\\d+$/.test(part) ? String(Number(part.slice(1))) : '';
return titles.has(id) ? '<button class="ref" data-go="item:' + id + '" title="' + esc(titles.get(id)) + '" type="button">' + esc(part) + '</button>' : esc(part);
}).join('');
- $('feed').innerHTML = p.shouts.length ? byDay(p.shouts, (x) => x.shout_at, (x) => '<div><time>' + clock(x.shout_at) + '</time><div><b>' + esc(x.shout_from) + ' → ' + esc(x.shout_to) + '</b> ' + linked(x.shout_text) + '</div></div>') : '<div class="empty">No shouts yet.</div>';
+ const mark = (x) => (x.shout_decision ? '<span class="mark ask">decision</span> ' : x.shout_answers ? '<span class="mark">answer</span> ' : '');
+ $('feed').innerHTML = p.shouts.length ? byDay(p.shouts, (x) => x.shout_at, (x) => '<div><time>' + clock(x.shout_at) + '</time><div><b>' + esc(x.shout_from) + ' → ' + esc(x.shout_to) + '</b> ' + mark(x) + linked(x.shout_text) + '</div></div>') : '<div class="empty">No shouts yet.</div>';
+ // Each ask waits here until it is answered (B21); the answer itself is typed in the form below.
+ $('decisions').hidden = !p.decisions.length;
+ $('decisions').innerHTML = '<div class="head"><i></i>Decision needed</div>' + p.decisions.map((d) => '<div class="ask"><p><small><b>' + esc(d.shout_from) + '</b> asks, ' + age(d.shout_at) + '</small></p><p>' + linked(d.shout_text) + '</p><button class="ghost" data-go="decide:' + d.shout_id + '" type="button">Answer</button></div>').join('');
$('shout-targets').innerHTML = ['all', ...lanes, ...p.agents.map((a) => a.agent_id)].map((t) => '<option value="' + esc(t) + '">').join('');
// Each agent with what it holds: its claim, then its work sent back, then its work waiting for a
// verdict. The worktree path is there on hover; what the person reads is who is doing what.
@@ -755,11 +771,31 @@ function countUnseen() {
$('count-shouts').textContent = (p.unseen && p.unseen.since === seen ? p.unseen.count : p.shouts.filter((x) => x.shout_id > seen).length) || '';
}
+/**
+ * Put the shout form in answer mode for an open decision (B21), or back to a plain shout with null.
+ * The form is never redrawn, so what the person types survives every refresh; only its answer line,
+ * its To and its button change. The To the person had comes back when the answer is done.
+ */
+function answer(id) {
+ const ask = id === null ? null : data.project.decisions.find((d) => d.shout_id === id) || null;
+ if (ask && !view.answering) view.to = $('shout-to').value;
+ if (!ask && view.answering) $('shout-to').value = view.to || '';
+ view.answering = ask ? ask.shout_id : null;
+ $('answering').hidden = !ask;
+ $('answering-who').textContent = ask ? ask.shout_from : '';
+ $('answering-q').textContent = ask ? ask.shout_text : '';
+ if (ask) $('shout-to').value = ask.shout_from;
+ $('shout-to').disabled = Boolean(ask);
+ $('shout-send').textContent = ask ? 'Answer' : 'Shout';
+ if (ask) $('shout-text').focus();
+}
+
function go(target) {
const [kind, id] = target.split(':');
if (kind === 'item') { view.tab = 'items'; view.state = 'all'; view.before = null; }
else if (kind === 'spec') { view.tab = 'spec'; view.row.spec = id; view.rows.spec = 'all'; }
else if (kind === 'tab') view.tab = id;
+ else if (kind === 'decide') { view.tab = 'shouts'; answer(Number(id)); }
keep('pb.tab', view.tab);
if (kind === 'item') pick(Number(id));
else render();
@@ -864,12 +900,13 @@ document.addEventListener('click', (event) => {
else if (t.dataset.rows) { const [kind, f] = t.dataset.rows.split(':'); view.rows[kind] = f; render(); }
else if (t.dataset.row) { const [kind, id] = t.dataset.row.split(':'); view.row[kind] = id; render(); }
else if (t.dataset.release) act('release', { lane: t.dataset.release });
- 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.shout) { answer(null); $('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(); }
});
// 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(); });
+$('answer-cancel').addEventListener('click', () => answer(null));
// Each press moves on one, from the system's theme to light, then dark, and back; this browser keeps it.
$('theme').addEventListener('click', () => {
const next = { light: 'dark', dark: 'system' }[document.documentElement.dataset.theme] || 'light';
@@ -888,7 +925,10 @@ $('add-form').addEventListener('submit', async (event) => {
});
$('shout-form').addEventListener('submit', async (event) => {
event.preventDefault();
- if (await act('shout', { to: $('shout-to').value, text: $('shout-text').value })) $('shout-text').value = '';
+ const text = $('shout-text').value;
+ if (!(await (view.answering ? act('answer', { id: view.answering, text }) : act('shout', { to: $('shout-to').value, text })))) return;
+ $('shout-text').value = '';
+ answer(null);
});
$('hold-form').addEventListener('submit', async (event) => {
event.preventDefault();
diff --git a/src/serve.js b/src/serve.js
index 837fa9a2..bc7d5bb1 100644
--- a/src/serve.js
+++ b/src/serve.js
@@ -119,6 +119,8 @@ export function projectState(root, { seen = null } = {}) {
};
}),
shouts: store.recentShouts(board, 40),
+ // Every ask still waiting for an answer, however far back the forty shouts reach (B21).
+ decisions: store.openDecisions(board),
events: log.slice(-80).reverse(),
agents: store.listAgents(board).map((agent) => ({ ...agent, lastMoveAt: lastMove.get(agent.agent_id) ?? null })),
holds: store.laneHolds(board),
@@ -144,6 +146,7 @@ export function actionArgs(command, args = {}) {
return ['add', text(args.lane), text(args.title), ...(text(args.criterion) ? ['--criterion', text(args.criterion)] : []), ...(text(args.specs) ? ['--specs', text(args.specs)] : []), ...(text(args.brief) ? ['--brief', text(args.brief)] : [])];
}
if (command === 'shout') return ['shout', text(args.to), text(args.text)];
+ if (command === 'answer') return ['answer', text(args.id), text(args.text)];
if (command === 'hold') return ['hold', text(args.lane), '--reason', text(args.reason)];
if (command === 'release') return ['hold', text(args.lane), '--off'];
return null;
diff --git a/test/cockpit.test.js b/test/cockpit.test.js
index 6636d11d..7db2597d 100644
--- a/test/cockpit.test.js
+++ b/test/cockpit.test.js
@@ -1027,6 +1027,58 @@ test('shout ids, search and narrow windows reach the item [N26]', async () => {
}
});
+test('a decision waits in needs-you until the view answers it [B21, N27]', async () => {
+ const box = machine();
+ const alpha = project(box, 'alpha');
+ box.run(alpha.web, 'shout', 'coordinator', 'Greet in <b>French</b> first?', '--decision');
+ // Forty shouts after it: the ask is older than every shout the feed loads, and still waits.
+ for (let n = 0; n < 40; n += 1) box.run(alpha.web, 'shout', 'all', `note ${n}`);
+ const view = await startView(box);
+ try {
+ const page = await openPage(view);
+ // The question as the page escapes it, written as a pattern.
+ const question = 'Greet in &lt;b&gt;French&lt;/b&gt; first\\?';
+ assert.match(page.show('needs'), new RegExp(`^<div class="head"><i></i>Needs you</div><button class="ny" data-go="decide:1" type="button"><code>web-1</code><span>${question}</span><em>decide, <time data-ago="[^"]+">now</time> →</em></button>`), 'first in Needs-you: who asks, what, and since when');
+ assert.equal(page.element('decisions').hidden, false);
+ assert.match(page.show('decisions'), new RegExp(`^<div class="head"><i></i>Decision needed</div><div class="ask"><p><small><b>web-1</b> asks, <time data-ago="[^"]+">now</time></small></p><p>${question}</p><button class="ghost" data-go="decide:1" type="button">Answer</button></div>$`), 'and above the shouts, with an Answer button');
+ assert.doesNotMatch(page.show('feed'), /Greet in/, 'though the feed no longer reaches it');
+
+ const form = () => ({
+ answering: !page.element('answering').hidden,
+ who: page.element('answering-who').textContent,
+ question: page.element('answering-q').textContent,
+ to: page.element('shout-to').value,
+ locked: Boolean(page.element('shout-to').disabled),
+ button: page.element('shout-send').textContent,
+ });
+ page.element('shout-to').value = 'web';
+ await page.click({ go: 'decide:1' });
+ assert.equal(page.run('view.tab'), 'shouts');
+ assert.deepEqual(form(), { answering: true, who: 'web-1', question: 'Greet in <b>French</b> first?', to: 'web-1', locked: true, button: 'Answer' }, 'Answer turns the form to answering the asker');
+ await page.fire('answer-cancel', 'click');
+ assert.deepEqual(form(), { answering: false, who: '', question: '', to: 'web', locked: false, button: 'Shout' }, 'Cancel gives back the plain shout');
+
+ await page.click({ go: 'decide:1' });
+ page.element('shout-text').value = 'French, then English';
+ await page.fire('shout-form', 'submit');
+ assert.equal(page.element('console').textContent.split('\n')[0], '$ pullboard answer 1 French, then English');
+ assert.equal(page.element('console').className, 'console ok');
+ assert.match(box.run(alpha.web, 'inbox'), /coordinator -> web-1: answers #1: French, then English/, 'the answer reaches the asker');
+ assert.deepEqual(form(), { answering: false, who: '', question: '', to: 'web', locked: false, button: 'Shout' }, 'the form is a plain shout again');
+ assert.equal(page.element('shout-text').value, '');
+ assert.doesNotMatch(page.show('needs'), /decide:/, 'an answered decision leaves Needs-you');
+ assert.equal(page.element('decisions').hidden, true, 'and the banner');
+
+ box.run(alpha.web, 'shout', 'coordinator', 'Ship today?', '--decision');
+ await page.run('refresh()');
+ const feed = page.show('feed');
+ assert.match(feed, /<b>web-1 → coordinator<\/b> <span class="mark ask">decision<\/span> Ship today\?/, 'the feed marks an ask');
+ assert.match(feed, /<b>coordinator → web-1<\/b> <span class="mark">answer<\/span> French, then English/, 'and an answer');
+ assert.match(page.show('needs'), /data-go="decide:43"/);
+ } finally {
+ await view.stop();
+ }
+});
test('the shouts tab counts shouts you have not seen [N26]', async () => {
const box = machine();
const alpha = project(box, 'alpha');