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): times say which day they were [N26]

Corey Olsonf869228b6a40
diff --git a/src/cockpit.js b/src/cockpit.js
index 65281488..504c22cb 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -176,8 +176,8 @@ input, select { border: 1px solid var(--line-strong); background: var(--surface)
.sentback h3 { color: var(--reject); }
.sentback .verdict { border-left: 0; padding: 0; margin: 0; }
.meta .why { flex-basis: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--reject); }
-.hist { display: grid; gap: 2px; font-size: 12.5px; }
-.hist div { display: grid; grid-template-columns: 4.2em minmax(0, 1fr); gap: 8px; }
+.hist { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; font-size: 12.5px; }
+.hist div { display: contents; }
.hist time, .feed time { color: var(--ink-faint); font: 12px var(--mono); }
.rowref { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; font-size: 13px; padding: 3px 0; }
.rowref code { font-weight: 600; }
@@ -192,7 +192,9 @@ input, select { border: 1px solid var(--line-strong); background: var(--surface)
.inline label { flex: 1 1 150px; min-width: 0; }
.feed { padding: 6px 10px 10px; display: grid; }
.feed > div { display: grid; grid-template-columns: 4.6em minmax(0, 1fr); gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
-.feed > div:first-child { border-top: 0; }
+.feed > div:first-child, .feed > .day + div { border-top: 0; }
+.feed .day { margin: 0; padding: 12px 0 4px; font: 600 11px/1 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); }
+.feed .day:first-child { padding-top: 6px; }
.feed button.ref { border: 0; background: none; padding: 0; color: var(--accent-strong); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.agent { display: grid; gap: 2px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 13px; }
.agent:first-child { border-top: 0; }
@@ -313,6 +315,15 @@ const esc = (text) => String(text ?? '').replace(/[&<>"']/g, (c) => ({ '&': '&am
const ago = (iso) => { const m = Math.round((Date.now() - Date.parse(iso)) / 60000); return m < 1 ? 'now' : m < 60 ? m + 'm' : m < 2880 ? Math.round(m / 60) + 'h' : Math.round(m / 1440) + 'd'; };
const clock = (iso) => new Date(iso).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hourCycle: 'h23' });
const when = (iso) => (new Date(iso).toDateString() === new Date().toDateString() ? '' : new Date(iso).toLocaleDateString([], { month: 'short', day: 'numeric' }) + ' ') + clock(iso);
+// A day as a feed names it: Today, Yesterday, or its weekday and date.
+const dayName = (iso) => {
+ const then = new Date(iso).toDateString(), today = new Date();
+ if (then === today.toDateString()) return 'Today';
+ today.setDate(today.getDate() - 1);
+ return then === today.toDateString() ? 'Yesterday' : new Date(iso).toLocaleDateString([], { weekday: 'short', month: 'short', day: 'numeric' });
+};
+// A feed's rows, newest first, with the day named above each run of rows from the same day.
+const byDay = (rows, at, row) => rows.map((x, i) => (i && new Date(at(x)).toDateString() === new Date(at(rows[i - 1])).toDateString() ? '' : '<h4 class="day">' + dayName(at(x)) + '</h4>') + row(x)).join('');
const firstLine = (text) => String(text ?? '').split('\\n').map((line) => line.trim()).find(Boolean) || '';
// The latest verdict is a reject and no accept followed: open again, being reworked, resubmitted, or
// withdrawn after it.
@@ -564,7 +575,7 @@ function render() {
+ (item.brief ? '<div><h3>Brief</h3><div class="text muted">' + esc(item.brief) + '</div></div>' : '')
+ '<div><h3>People and commits</h3><dl class="kv">' + (item.owner && s === 'building' ? '<dt>holding</dt><dd>' + esc(item.owner) + '</dd>' : '') + (item.builtBy ? '<dt>built by</dt><dd>' + esc(item.builtBy) + '</dd>' : '') + (item.verifiedBy ? '<dt>verified by</dt><dd>' + esc(item.verifiedBy) + '</dd>' : '') + (item.commit ? '<dt>commit</dt><dd><code>' + esc(item.commit.slice(0, 12)) + '</code></dd>' : '') + (item.merged ? '<dt>merged</dt><dd><code>' + esc(item.merged.slice(0, 12)) + '</code></dd>' : '') + (item.blockedBy.length ? '<dt>waits on</dt><dd>' + item.blockedBy.map((id) => '#' + id).join(', ') + '</dd>' : '') + '</dl></div>'
+ (back && !earlier.length ? '' : '<div><h3>' + (back ? 'Earlier verdicts' : 'Verdicts') + '</h3>' + (earlier.length ? earlier.map(verdictHtml).join('') : '<div class="muted">None yet.</div>') + '</div>')
- + '<div><h3>History</h3><div class="hist">' + item.history.map((e) => '<div><time>' + clock(e.at) + '</time><span>' + esc(e.by) + ' ' + esc(e.kind) + '</span></div>').join('') + '</div></div>'
+ + '<div><h3>History</h3><div class="hist">' + item.history.map((e) => '<div><time>' + when(e.at) + '</time><span>' + esc(e.by) + ' ' + esc(e.kind) + '</span></div>').join('') + '</div></div>'
+ '<div class="links"><button data-shout="' + esc(item.lane) + '" data-about="' + item.id + '" type="button">Shout the ' + esc(item.lane) + ' lane about #' + item.id + '</button><button data-new type="button">New item</button></div></div>';
}
@@ -576,7 +587,7 @@ 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 ? p.shouts.map((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>').join('') : '<div class="empty">No shouts yet.</div>';
+ $('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>';
$('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.
@@ -609,7 +620,7 @@ function render() {
}
$('flow').innerHTML = flowSvg(p);
- $('activity').innerHTML = p.events.length ? p.events.map((e) => '<div><time>' + clock(e.event_at) + '</time><div><b>' + esc(e.event_by) + '</b> ' + esc(e.event_kind) + (e.item_id ? ' <button class="ref" data-go="item:' + e.item_id + '" type="button">#' + e.item_id + '</button>' : '') + '</div></div>').join('') : '<div class="empty">No activity yet.</div>';
+ $('activity').innerHTML = p.events.length ? byDay(p.events, (e) => e.event_at, (e) => '<div><time>' + clock(e.event_at) + '</time><div><b>' + esc(e.event_by) + '</b> ' + esc(e.event_kind) + (e.item_id ? ' <button class="ref" data-go="item:' + e.item_id + '" type="button">#' + e.item_id + '</button>' : '') + '</div></div>') : '<div class="empty">No activity yet.</div>';
showTab();
}
diff --git a/test/cockpit.test.js b/test/cockpit.test.js
index 57813792..cf98185e 100644
--- a/test/cockpit.test.js
+++ b/test/cockpit.test.js
@@ -189,10 +189,27 @@ async function settle(inflight) {
}
/**
- * Open the page a view serves, at a window width, and wait for its first board. show(id) is what
- * that region holds; click() and type() act as the person would.
+ * The browser's Date with its clock moved some days on, as the page would read it then.
*/
-async function openPage(view, { width = 1280 } = {}) {
+function daysOn(days) {
+ const shift = days * 86_400_000;
+ return class extends Date {
+ constructor(...args) {
+ super(...(args.length ? args : [Date.now() + shift]));
+ }
+
+ static now() {
+ return Date.now() + shift;
+ }
+ };
+}
+
+/**
+ * Open the page a view serves, at a window width, and wait for its first board; `later` moves the
+ * page's clock that many days on. show(id) is what that region holds; click() and type() act as
+ * the person would.
+ */
+async function openPage(view, { width = 1280, later = 0 } = {}) {
const html = await (await fetch(view.link)).text();
const script = html.slice(html.indexOf('<script>') + '<script>'.length, html.lastIndexOf('</script>'));
const known = new Set([...html.matchAll(/\bid="([^"]+)"/g)].map((match) => match[1]));
@@ -218,6 +235,7 @@ async function openPage(view, { width = 1280 } = {}) {
innerHeight: 800,
matchMedia: (query) => ({ matches: width <= Number(/max-width:\s*(\d+)px/.exec(query)?.[1] ?? Infinity) }),
setInterval: () => 0,
+ ...(later ? { Date: daysOn(later) } : {}),
setTimeout,
clearTimeout,
fetch: (path, init) => {
@@ -721,3 +739,40 @@ test('the detail opens on the top item, not a blank form [N26]', async () => {
await view.stop();
}
});
+
+test('times say which day they were [N26]', async () => {
+ const box = machine();
+ const alpha = project(box, 'alpha');
+ box.run(alpha.repo, 'add', 'web', 'Greeting', '--specs', 'G1', '--criterion', 'greets');
+ build(box, alpha, 1, 'greeting.html');
+ box.run(alpha.repo, 'shout', 'web', '#1 is in');
+ const view = await startView(box);
+ try {
+ const days = (html) => [...html.matchAll(/<h4 class="day">([^<]*)<\/h4>/g)].map((match) => match[1]);
+ const times = (html) => [...html.matchAll(/<time>([^<]*)<\/time>/g)].map((match) => match[1]);
+ const bare = (list) => list.length > 0 && list.every((time) => /^\d\d:\d\d$/.test(time));
+
+ const now = await openPage(view);
+ assert.deepEqual([days(now.show('feed')), days(now.show('activity'))], [['Today'], ['Today']]);
+ assert.ok(bare(times(now.show('detail'))), 'a history from today shows bare times');
+
+ const tomorrow = await openPage(view, { later: 1 });
+ assert.deepEqual([days(tomorrow.show('feed')), days(tomorrow.show('activity'))], [['Yesterday'], ['Yesterday']]);
+
+ const weekday = new Date().toLocaleDateString([], { weekday: 'short', month: 'short', day: 'numeric' });
+ const date = new Date().toLocaleDateString([], { month: 'short', day: 'numeric' });
+ const later = await openPage(view, { later: 2 });
+ assert.deepEqual([days(later.show('feed')), days(later.show('activity'))], [[weekday], [weekday]], 'two days on, the feeds name the day');
+ assert.ok(bare(times(later.show('feed'))) && bare(times(later.show('activity'))), 'their rows keep the clock time');
+ const history = times(later.show('detail'));
+ assert.ok(history.length === 3 && history.every((time) => new RegExp(`^${date} \\d\\d:\\d\\d$`).test(time)), `the history dates each move: ${history}`);
+
+ // A heading wherever the day changes, and only there.
+ const at = (day, hour) => new Date(2026, 9, day, hour).toISOString();
+ const rows = JSON.stringify([at(6, 15), at(6, 9), at(5, 20), at(3, 12)].map((iso) => ({ iso })));
+ const html = now.run(`byDay(${rows}, (x) => x.iso, () => '<div></div>')`);
+ assert.equal(html.replace(/<h4 class="day">[^<]*<\/h4>/g, 'H').replaceAll('<div></div>', 'r'), 'HrrHrHr');
+ } finally {
+ await view.stop();
+ }
+});