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): draw moves out of lower states [N26,M1]

Corey Olson510e6b7a9e24
diff --git a/src/cockpit.js b/src/cockpit.js
index c98dc03b..eab28593 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -551,7 +551,7 @@ function timeline(item) {
const final = FLOW.states.some((f) => f.id === state && f.final);
const next = steps.slice(index + 1).find((n) => n.move);
const named = s.kind === 'reject' ? 'sent back' : state;
- const stay = !enters || final ? ''
+ const stay = !enters || (final && !next) ? ''
: !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')
@@ -588,7 +588,8 @@ function timeline(item) {
* tie, its states joined by straight arrows. A pair of states a move leads back along takes a dashed
* square route above the row, the further back the higher. The moves that keep a state are written
* in its box after a ↻. A state off the row sits below the last state on the row that leads to it,
- * and the routes into it join into one, labelled once. Final states have a double border. Boxes
+ * and routes into it from the row join into one, labelled once. Moves out of those states take
+ * separate routes below the boxes, with their words above each route. Final states have a double border. Boxes
* count the items there now; labels count the moves made along each route, or name its moves when
* none was. Words are wrapped and placed by a generous estimate of their width, so none overlaps.
*/
@@ -677,7 +678,8 @@ function flowSvg(p) {
const from = row.filter((r) => leads(r).includes(s.id));
pos.set(s.id, { x: from.length ? pos.get(from[from.length - 1]).x : W / 2, y: bottom + 80 + BH / 2 });
}
- const H = (below.length ? bottom + 80 + BH : bottom) + 14;
+ const outgoing = pairs.filter((pair) => pair.from !== pair.to && below.some((state) => state.id === pair.from));
+ const H = (below.length ? bottom + 80 + BH : bottom) + 14 + (outgoing.length ? 44 + 40 * (outgoing.length - 1) : 0);
const group = (pairList, route, label) => pairList.map((pair, n) => '<g><title>' + esc(says(pair)) + '</title><path class="edge' + (route.back ? ' back' : '') + '" d="' + route.d + '" marker-end="url(#pb-head' + (route.back ? '-back' : '') + ')"/>' + (n === 0 ? label : '') + '</g>').join('');
const tone = (said, extra = '') => 'tag' + (said.idle ? ' idle' : '') + extra;
@@ -694,7 +696,7 @@ function flowSvg(p) {
}
// Down from the row, joining into one route per state below, labelled once on the way in.
for (const s of below) {
- const t = pos.get(s.id), into = pairs.filter((pair) => pair.to === s.id && pos.has(pair.from) && pair.from !== s.id);
+ const t = pos.get(s.id), into = pairs.filter((pair) => pair.to === s.id && col(pair.from) >= 0);
const said = told(into), tTop = t.y - BH / 2;
const xs = into.map((pair) => pos.get(pair.from).x).sort((a, b) => a - b);
const left = xs.filter((x) => x < t.x - 0.5), right = xs.filter((x) => x > t.x + 0.5);
@@ -711,6 +713,16 @@ function flowSvg(p) {
routes.push(group([pair], { d }, n === 0 ? label : ''));
});
}
+ // A below-row state can move back into the row or on to another below-row state.
+ outgoing.forEach((pair, index) => {
+ const from = pos.get(pair.from), to = pos.get(pair.to);
+ const lane = bottom + 80 + BH + 26 + index * 40;
+ const side = to.x < from.x ? to.x + BW / 2 + 1 : to.x - BW / 2 - 1;
+ const said = told([pair]);
+ const room = Math.max(40, Math.abs(side - from.x) - 24);
+ const label = lines((from.x + side) / 2, lane - 8, wrap(said.words, room, 12), tone(said));
+ routes.push(group([pair], { d: path([[from.x, from.y + BH / 2], [from.x, lane], [side, lane], [side, to.y]]) }, label));
+ });
const boxes = FLOW.states.map((s) => {
const { x, y } = pos.get(s.id), box = inside.get(s.id), left = x - BW / 2, boxTop = y - BH / 2;
diff --git a/test/cockpit/activity.test.js b/test/cockpit/activity.test.js
index ebdaf402..dfc7df3b 100644
--- a/test/cockpit/activity.test.js
+++ b/test/cockpit/activity.test.js
@@ -9,6 +9,101 @@ import { MACHINE } from '../../src/machine.js';
import { machine, project, build, sendBack, fetchLive, startView, styleOf, element, storage, openPage, timelineRows, agentEntries, drawing, textBoxes, meet, accept, itemRow, chromeExecutable, openSnapshotChrome, closeSnapshotChrome } from './fixture.js';
+/** Verify a verified stay ends at its next state move, while a quiet merge remains untimed. */
+test('the timeline times a verified item that goes back to open [N26, M1]', async () => {
+ const box = machine();
+ project(box, 'alpha');
+ const view = await startView(box);
+ try {
+ const page = await openPage(view);
+ const history = [
+ ['add', '2026-10-12T12:00:00.000Z'],
+ ['claim', '2026-10-12T12:01:00.000Z'],
+ ['submit', '2026-10-12T12:02:00.000Z'],
+ ['accept', '2026-10-12T12:03:00.000Z'],
+ ['merged', '2026-10-12T12:03:30.000Z'],
+ ['reopen', '2026-10-12T12:05:00.000Z'],
+ ].map(([kind, at]) => ({ kind, by: 'coordinator', at }));
+ const rendered = JSON.parse(page.run(`(() => {
+ FLOW.moves.push({ verb: 'reopen', from: ['verified'], to: 'open', by: ['coordinator'], how: 'pullboard reopen <id>', checks: [] });
+ const item = ${JSON.stringify({ status: 'open', history })};
+ const finalVerified = timeline(item);
+ FLOW.states.find((state) => state.id === 'verified').final = false;
+ return JSON.stringify([finalVerified, timeline(item)]);
+ })()`));
+ const [finalRows, nonFinalRows] = rendered.map(timelineRows);
+ for (const rows of [finalRows, nonFinalRows]) {
+ assert.equal(rows.find((row) => row.event.startsWith('accept ')).stay, 'verified for 2m');
+ assert.equal(rows.find((row) => row.event.startsWith('merged ')).stay, '', 'a quiet event does not end the verified stay');
+ assert.equal(rows.find((row) => row.event.startsWith('reopen ')).dot, 'tl-open');
+ }
+ } finally {
+ await view.stop();
+ }
+});
+
+/** Verify a fixture lifecycle draws and labels an outgoing route from a below-row state. */
+test('the activity lifecycle draws a move out of a state below the row [N26, M1]', async () => {
+ const box = machine();
+ project(box, 'alpha');
+ const view = await startView(box);
+ try {
+ const page = await openPage(view);
+ const fixture = {
+ initial: 'open',
+ states: [
+ { id: 'open', means: 'waiting', final: false, entry: [] },
+ { id: 'claimed', means: 'building', final: false, entry: [] },
+ { id: 'submitted', means: 'waiting for review', final: false, entry: [] },
+ { id: 'verified', means: 'accepted', final: false, entry: [] },
+ { id: 'withdrawn', means: 'closed', final: true, entry: [] },
+ { id: 'deferred', means: 'waiting for another decision', final: false, entry: [] },
+ ],
+ moves: [
+ { verb: 'claim', from: ['open'], to: 'claimed', by: ['agent'], how: 'claim', checks: [] },
+ { verb: 'submit', from: ['claimed'], to: 'submitted', by: ['agent'], how: 'submit', checks: [] },
+ { verb: 'accept', from: ['submitted'], to: 'verified', by: ['coordinator'], how: 'accept', checks: [] },
+ { verb: 'withdraw', from: ['submitted'], to: 'withdrawn', by: ['coordinator'], how: 'withdraw', checks: [] },
+ { verb: 'reopen', from: ['verified'], to: 'open', by: ['coordinator'], how: 'reopen', checks: [] },
+ { verb: 'pause', from: ['open'], to: 'deferred', by: ['coordinator'], how: 'pause', checks: [] },
+ { verb: 'resume', from: ['deferred'], to: 'verified', by: ['coordinator'], how: 'resume', checks: [] },
+ ],
+ };
+ const svg = page.run(`(() => {
+ FLOW.initial = ${JSON.stringify(fixture.initial)};
+ FLOW.states.splice(0, FLOW.states.length, ...${JSON.stringify(fixture.states)});
+ FLOW.moves.splice(0, FLOW.moves.length, ...${JSON.stringify(fixture.moves)});
+ return flowSvg(data.project);
+ })()`);
+ const diagram = drawing(svg);
+ const route = diagram.routes.find((entry) => entry.pair === 'verified>open');
+ assert.ok(route, 'the fixture machine declares verified > open');
+ assert.equal(route.label, 'reopen (none yet)');
+ assert.ok(route.points.length >= 4, 'the outgoing route has a path from the below-row state to open');
+ const pairs = fixture.moves.flatMap((move) => move.from.map((from) => `${from}>${move.to}`));
+ assert.deepEqual(diagram.routes.map((entry) => entry.pair).sort(), pairs.sort(),
+ 'each move pair is drawn once, including between two below-row states');
+ /** Read a fixture state's box top to verify the selected longest path stays above it. */
+ const stateY = (state) => Number(new RegExp(`<g class="s-${state}"><title>[\\s\\S]*?<rect class="box" x="[\\d.]+" y="([\\d.]+)"`).exec(svg)?.[1]);
+ assert.ok(stateY('verified') > stateY('open'), 'verified is below the longest path to a final state');
+ assert.equal(stateY('deferred'), stateY('verified'), 'the fixture also includes a move between below-row states');
+ const segments = diagram.routes.flatMap((entry) => entry.points.slice(1).map(([x, y], index) => ({
+ left: Math.min(x, entry.points[index][0]),
+ right: Math.max(x, entry.points[index][0]) + 0.01,
+ top: Math.min(y, entry.points[index][1]),
+ bottom: Math.max(y, entry.points[index][1]) + 0.01,
+ })));
+ for (const words of ['reopen', 'resume']) {
+ const label = textBoxes(svg).find((entry) => entry.words === words);
+ assert.ok(label, `${words}: the outgoing move is labelled`);
+ assert.ok(segments.every((segment) => !meet(label, segment, 2)), `${words}: its label clears every route`);
+ }
+ } finally {
+ await view.stop();
+ }
+});
+
+
test("the history is a timeline of the item's states [N26]", async () => {
const box = machine();
const alpha = project(box, 'alpha');