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
fix(view): unread opens only the unread shouts [N26]
Corey Olson7a368bc43a4c
diff --git a/src/cockpit.js b/src/cockpit.jsindex 858504f6..2d208f59 100644--- a/src/cockpit.js+++ b/src/cockpit.js@@ -1285,8 +1285,11 @@ function render() {// The coordinator's mark is the board's own: a square with the Pullboard logo, so it stands out from the agents.const LEAD = '<svg viewBox="0 0 64 64" aria-hidden="true"><path fill="currentColor" d="M8 7h35a6 6 0 0 1 6 6v7H8a5 5 0 0 1-5-5v-3a5 5 0 0 1 5-5Z"/><rect width="56" height="14" x="3" y="25" fill="var(--accent)" rx="5"/><path fill="currentColor" d="M8 43h35a6 6 0 0 1 6 6v8H8a5 5 0 0 1-5-5v-4a5 5 0 0 1 5-5Z"/></svg>';const lead = (from) => from === 'coordinator';- const heard = view.agent ? p.shouts.filter((x) => x.shout_from === view.agent || x.shout_to === view.agent) : p.shouts;- const bar = '<div class="feed-bar">' + (view.agent ? '<span>Shouts with <b>' + esc(view.agent) + '</b> <button class="link" data-agent="" type="button">show all</button></span>' : '<span></span>')+ // Opened from the status bar's unread, the feed is exactly those shouts, the ones after the mark the person had.+ const unread = view.unread?.root === view.root ? view.unread : null;+ const heard = unread ? p.shouts.filter((x) => x.shout_id > unread.after) : view.agent ? p.shouts.filter((x) => x.shout_from === view.agent || x.shout_to === view.agent) : p.shouts;+ const bar = '<div class="feed-bar">' + (unread ? '<span><b>' + heard.length + '</b> unread <button class="link" data-unread type="button">show all</button></span>'+ : view.agent ? '<span>Shouts with <b>' + esc(view.agent) + '</b> <button class="link" data-agent="" type="button">show all</button></span>' : '<span></span>')+ '<button class="link" data-agents-toggle type="button">' + (view.agentsHidden ? 'Show agents' : 'Hide agents') + '</button></div>';$('shouts-pane').classList.toggle('bare', view.agentsHidden);// Who has heard a shout of the person's: the agents it reached whose inbox has read past it. Each agent's read@@ -1307,7 +1310,7 @@ function render() {+ (lead(x.shout_from) ? '<span class="avatar">' + LEAD + '</span>' : '<span class="avatar' + (initials(x.shout_from).length > 3 ? ' wide' : '') + '" aria-hidden="true">' + esc(initials(x.shout_from)) + '</span>') + '<div class="shout-main"><header><b class="who">' + esc(x.shout_from) + '</b><span class="to">→ ' + esc(x.shout_to) + '</span>'+ (itemOf(x) ? '<span class="item">#' + esc(itemOf(x)) + '</span>' : '') + mark(x) + '<time class="long" data-ago="' + esc(x.shout_at) + '" title="' + esc(when(x.shout_at)) + '">' + agoLong(x.shout_at) + '</time></header>'+ '<div class="text">' + rich(x.shout_text, titles) + '</div><button class="more" data-more type="button">' + (openShouts.has(x.shout_id) ? 'less' : 'more') + '</button>' + (inFeed ? band(x) + heardBy(x) : '') + evidence(x) + tail + '</div></article>';- $('feed').innerHTML = bar + (heard.length ? dayRules(heard, (x) => x.shout_at, card) : '<div class="empty">' + (view.agent ? 'No shouts with ' + esc(view.agent) + ' among the last forty.' : 'No shouts yet.') + '</div>');+ $('feed').innerHTML = bar + (heard.length ? dayRules(heard, (x) => x.shout_at, card) : '<div class="empty">' + (unread ? 'No unread shouts.' : view.agent ? 'No shouts with ' + esc(view.agent) + ' among the last forty.' : 'No shouts yet.') + '</div>');foldShouts();// Each ask waits here until it is answered (B21); the answer itself is typed in the form below. The// person answers the ones passed up to them; the rest wait on whoever holds them (B26).@@ -1358,7 +1361,7 @@ function render() {// countUnseen fills the unread shouts once the tab is drawn.const release = (p.milestones || []).find((m) => m.done < m.total), last = p.events[0];const part = (to, n, words, title) => n ? '<button type="button" data-status="' + to + '" title="' + esc(title) + '"><b>' + n + '</b> ' + words + '</button>' : '';- $('status-board').innerHTML = part('items', active.length, 'items', 'Show the active items') + '<button type="button" id="status-unread" data-status="shouts" title="Open Shouts" hidden></button>'+ $('status-board').innerHTML = part('items', active.length, 'items', 'Show the active items') + '<button type="button" id="status-unread" data-status="unread" title="Show the shouts you have not read" hidden></button>'+ part('shouts', busy.length, busy.length === 1 ? 'agent' : 'agents', 'Agents holding work: ' + busy.map((a) => a.agent_id).join(', '))+ part('verify', active.filter((i) => stateOf(i) === 'verify').length, 'to verify', 'Show the items waiting on a verdict')+ part('gated', active.filter(gatedOf).length, 'gated', 'Show the open items waiting on another item or a held lane')@@ -1559,9 +1562,17 @@ function answer(id) {/** Open what a status-bar part counts: its tab, narrowed to exactly those. */function statusGo(to) {+ view.unread = null;if (to.startsWith('item:')) return go(to);if (to === 'items') { view.state = 'active'; view.lane = null; view.before = null; $('q').value = ''; openTab('items'); }else if (to === 'verify' || to === 'gated') { view.state = to; view.lane = null; view.before = null; $('q').value = ''; openTab('items'); }+ else if (to === 'unread') {+ // Only the shouts after the mark the person had; opening Shouts then moves the mark past them.+ const key = 'pb.seen.' + view.root;+ view.unread = { root: view.root, after: Number(view.seen[key] ?? keep(key) ?? 0) };+ view.agent = null;+ openTab('shouts');+ }else openTab(to);showTab();render();@@ -1889,7 +1900,9 @@ $('shouts-pane').addEventListener('click', (event) => {if (folded) { view.open[folded.dataset.fold] = !view.open[folded.dataset.fold]; render(); return; }if (event.target.closest('[data-all-agents]')) { view.allAgents = !view.allAgents; render(); return; }if (event.target.closest('[data-agents-toggle]')) { view.agentsHidden = !view.agentsHidden; keep('pb.agents', view.agentsHidden ? 'hidden' : 'shown'); render(); return; }+ if (event.target.closest('[data-unread]')) { view.unread = null; render(); return; }if (!pick) return;+ view.unread = null;view.agent = pick.dataset.agent && pick.dataset.agent !== view.agent ? pick.dataset.agent : null;if (!view.answering) addressTo(view.agent);render();@@ -1904,7 +1917,7 @@ document.addEventListener('click', (event) => {if (t.id === 'console') { t.hidden = true; return; }if (t.dataset.status) { statusGo(t.dataset.status); return; }if (t.dataset.root) switchTo(t.dataset.root, t.dataset.go || '');- else if (t.dataset.tab) { openTab(t.dataset.tab); showTab(); }+ else if (t.dataset.tab) { view.unread = null; openTab(t.dataset.tab); showTab(); }else if (t.dataset.go) go(t.dataset.go, t.dataset.board);else if (t.dataset.item) pick(Number(t.dataset.item));else if (t.dataset.state) { view.state = t.dataset.state; render(); }diff --git a/src/view.css b/src/view.cssindex a9e697d4..eae62432 100644--- a/src/view.css+++ b/src/view.css@@ -118,7 +118,7 @@ main { padding: 16px 18px 56px; }.status #status-unread[hidden] { display: none; }/* With touch its parts are 44px targets; a mouse keeps the thin strip. On a phone it shows only when the view is cut off. */@media (pointer: coarse) { .status { height: 44px; } .status button { min-height: 44px; } main { padding-bottom: 72px; } }-@media (width < 480px) { .status:not(:has(.live:not(:empty))) { display: none; } main { padding-bottom: 28px; } }+@media (width < 480px) { .status:not(:has(.live:not(:empty))) { display: none; } .status { height: 44px; } .status button { min-height: 44px; } main { padding-bottom: 28px; } }.side { padding-bottom: 44px; }.first { display: none; max-width: 520px; margin: 10vh auto 0; padding: 22px 24px; }.first h2 { margin: 0 0 6px; font-size: 18px; }diff --git a/test/cockpit.test.js b/test/cockpit.test.jsindex 605851e2..d229d10c 100644--- a/test/cockpit.test.js+++ b/test/cockpit.test.js@@ -6374,6 +6374,7 @@ test('the board reads at a glance from the status bar [N26]', { timeout: 180_000box.git(alpha.repo, 'worktree', 'add', '-q', second, '-b', 'web/glance2');box.run(second, 'join', 'web');box.run(second, 'shout', 'coordinator', 'Free when you need me.');+ box.run(alpha.repo, 'shout', 'web', 'Pages first, then the footer.');box.run(alpha.web, 'shout', 'coordinator', 'Which colour for the button?', '--decision');const view = await startView(box);@@ -6553,12 +6554,20 @@ test('the board reads at a glance from the status bar [N26]', { timeout: 180_000await chrome.send('Emulation.setDeviceMetricsOverride', { width: 1280, height: 900, deviceScaleFactor: 1, mobile: false });await chrome.waitFor('innerWidth === 1280');- // A shout that lands while Items is open counts as unread in the bar; opening it reads it.+ // A shout that lands while Items is open counts as unread in the bar. The part opens exactly that shout, not the ones+ // already read beside it, and opening it reads it; show all brings the rest back.await click('[data-tab=items]');+ const alreadyRead = await chrome.evaluate('data.project.shouts.length');+ assert.ok(alreadyRead >= 2, `shouts the person has already read: ${alreadyRead}`);box.run(alpha.web, 'shout', 'coordinator', 'web-1 is on it');await chrome.waitFor("!document.querySelector('#status-unread')?.hidden && document.querySelector('#status-unread')?.textContent === '1 unread'", 15_000);await click('#status-unread');await chrome.waitFor("view.tab === 'shouts' && document.querySelector('#status-unread')?.hidden === true");+ const feed = async () => JSON.parse(await chrome.evaluate("JSON.stringify([...document.querySelectorAll('#feed .shout .text')].map((text) => text.textContent))"));+ assert.deepEqual([await feed(), await chrome.evaluate("document.querySelector('#feed .feed-bar span').textContent")], [['web-1 is on it'], '1 unread show all'],+ `1 unread opens that one shout, not the ${alreadyRead} already read`);+ await click('#feed [data-unread]');+ assert.equal((await feed()).length, alreadyRead + 1, 'show all brings back the shouts already read');// Cut off from the board, the bar turns red and says why.await chrome.evaluate("globalThis.fetch = () => Promise.reject(new TypeError('Failed to fetch'))");@@ -6570,6 +6579,7 @@ test('the board reads at a glance from the status bar [N26]', { timeout: 180_000await chrome.waitFor('innerWidth === 375');r = await read();assert.ok(r.barShown && r.live.startsWith('offline'), 'on a phone too, a view cut off from the board says so');+ assert.ok(r.bar.every((p) => p.height >= 44), `and its parts are 44px targets there: ${JSON.stringify(r.bar)}`);assert.deepEqual(chrome.exceptions, [], 'the page raises no uncaught exception');} finally {if (chrome) await closeSnapshotChrome(chrome);