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.

fix(view): a stay beside a lapse says its length was not logged [N26]

Corey Olson2f69c075e4c9
diff --git a/src/cockpit.js b/src/cockpit.js
index fa690ce2..e36e3db7 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -406,7 +406,8 @@ const span = (ms) => {
* reject in the colour of work sent back, and the item's creation (logged as add) one in the start
* state's colour; an event that moves nothing is a hollow dot. Between the dots runs a line in the
* colour of the state the item stayed in, and under each dot that began a stay, how long it lasted,
- * or how long so far while the item can still leave. A lapse has a row but no time.
+ * or how long so far while the item can still leave. A lapse has a row but no time, so a stay that
+ * ends or begins at one says its length was not logged rather than guess it.
*/
function timeline(item) {
const steps = replay(item);
@@ -416,8 +417,11 @@ function timeline(item) {
const final = FLOW.states.some((f) => f.id === state && f.final);
const next = steps.slice(i + 1).find((n) => n.move);
const named = s.kind === 'reject' ? 'sent back' : state;
- // A stay after a lapse has no start to count from, and one that ends in a lapse no end.
- const stay = !enters || !s.at || final ? '' : !next ? esc(named) + ' for ' + age(s.at) + ' so far' : next.at ? esc(named + ' for ' + span(Date.parse(next.at) - Date.parse(s.at))) : '';
+ const stay = !enters || final ? ''
+ : !s.at ? esc(named + (next ? ' after the ' : ' so far since the ') + s.kind + ', length not logged')
+ : !next ? esc(named) + ' for ' + age(s.at) + ' so far'
+ : !next.at ? esc(named + ' until the ' + next.kind + ', length not logged')
+ : esc(named + ' for ' + span(Date.parse(next.at) - Date.parse(s.at)));
return '<li class="tl-' + esc(state) + (s.kind === 'reject' ? ' tl-back' : '') + (enters ? '' : ' tl-quiet') + '"><time>' + (s.at ? when(s.at) : '') + '</time><span><b>' + esc(s.kind) + '</b> ' + esc(s.by) + '</span>' + (stay ? '<small>' + stay + '</small>' : '') + '</li>';
}).join('') + '</ol>';
}
diff --git a/test/cockpit.test.js b/test/cockpit.test.js
index a31ffcce..05f374d8 100644
--- a/test/cockpit.test.js
+++ b/test/cockpit.test.js
@@ -472,7 +472,21 @@ test("the history is a timeline of the item's states [N26]", async () => {
['tl-open', 'lapse the clock', true],
['tl-claimed', 'claim web-2', false],
]);
- assert.deepEqual(lapsed.map((row) => row.stay.replace(/ for .*/, ' for')), ['open for', '', '', 'claimed for'], 'a stay that ends in a lapse, or starts with one, has no length to show');
+ assert.deepEqual(lapsed.map((row) => row.stay.replace(/ for .*/, ' for')), [
+ 'open for',
+ 'claimed until the lapse, length not logged',
+ 'open after the lapse, length not logged',
+ 'claimed for',
+ ], 'a stay that ends or begins at an untimed lapse says its length was not logged');
+ assert.equal(lapsed[0].stay, 'open for 5m');
+
+ // A lease that ran out with nothing after it: the item reads open, and has been since the lapse.
+ const idle = { status: 'open', history: [{ kind: 'add', by: 'web-1', at: at(0) }, { kind: 'claim', by: 'web-1', at: at(5) }] };
+ assert.deepEqual(timelineRows(page.run(`timeline(${JSON.stringify(idle)})`)).map((row) => [row.event, row.stay]), [
+ ['add web-1', 'open for 5m'],
+ ['claim web-1', 'claimed until the lapse, length not logged'],
+ ['lapse the clock', 'open so far since the lapse, length not logged'],
+ ]);
} finally {
await view.stop();
}