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
feat(view): merge facts into item timeline [B33,B29]
Corey Olson5dc8d879382e
diff --git a/src/cockpit.js b/src/cockpit.jsindex 6b8eaca5..11b7cd88 100644--- a/src/cockpit.js+++ b/src/cockpit.js@@ -212,6 +212,12 @@ const codeRef = (ref, before) => {: '<span class="code">' + c.lines.map((line, n) => '<span><i>' + (c.from + n) + '</i>' + esc(line) + '</span>').join('') + (c.more ? '<span class="more">the first ' + c.lines.length + ' lines</span>' : '') + '</span>';return '<button class="ref" data-code="' + esc(ref) + '"' + (before ? ' data-before="' + esc(before) + '"' : '') + ' type="button" aria-expanded="' + open + '">' + esc(ref) + '</button>' + shown;};+/** Format the API's structured fact binding as the live reference the code preview accepts. */+function factCodeRef(ref) {+ if (!ref || typeof ref !== 'object') return String(ref ?? '');+ const lines = ref.start === ref.end ? String(ref.start) : ref.start + '-' + ref.end;+ return ref.path + ':' + lines + '@' + ref.commit;+}const tone = (s) => s === 'approved' ? 'ok' : s === 'pending' ? 'no' : s === 'draft' ? 'warn' : '';/** A doctrine rule's source, with a version only when it comes from the shipped standard. */const ruleSource = (row) => row.origin === 'standard' ? 'standard ' + row.version : 'repo';@@ -251,6 +257,7 @@ function replay(item) {};for (const e of item.history) {const verb = e.kind === 'renew' ? 'claim' : e.kind;+ if (e.kind !== 'add' && !FLOW.moves.some((move) => move.verb === verb)) continue;// A renew is the claim that stays claimed; a claim logged as such is the one that arrives.const fits = (s) => FLOW.moves.find((m) => m.verb === verb && m.from.includes(s) && (verb !== 'claim' || (e.kind === 'renew') === (m.to === s)));const lapse = fits(at) ? null : clock.find((m) => m.from.includes(at) && fits(m.to));@@ -289,19 +296,49 @@ const span = (ms) => {*/function timeline(item) {const steps = replay(item);- return '<ol class="tl">' + steps.map((s, i) => {+ const entries = Array.isArray(item.thread) && item.thread.length+ ? item.thread+ : item.history.map((entry, eventId) => ({ type: 'move', eventId: eventId + 1, ...entry }));+ const facts = entries.filter((entry) => entry.type === 'fact');+ const replacements = new Map(facts.filter((fact) => fact.supersedes).map((fact) => [fact.supersedes, fact]));+ const rows = [];+ let stepIndex = 0;+ /** Render a lifecycle step, keeping inferred clock lapses between recorded moves. */+ const moveRow = (s, event, index) => {const enters = s.move ? s.move.to : s.kind === 'add' ? FLOW.initial : null;const state = enters || s.from;const final = FLOW.states.some((f) => f.id === state && f.final);- const next = steps.slice(i + 1).find((n) => n.move);+ const next = steps.slice(index + 1).find((n) => n.move);const named = s.kind === 'reject' ? 'sent back' : state;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>';+ rows.push('<li class="tl-' + esc(state) + (s.kind === 'reject' ? ' tl-back' : '') + (enters ? '' : ' tl-quiet') + '"' + (event ? ' data-event-id="' + event.eventId + '"' : '') + '><time>' + (s.at ? when(s.at) : '') + '</time><span><b>' + esc(s.kind) + '</b> ' + esc(s.by) + '</span>' + (stay ? '<small>' + stay + '</small>' : '') + '</li>');+ };+ /** Render one API fact with its identity, replacement and committed code binding. */+ const factRow = (fact) => {+ const replacement = replacements.get(fact.id);+ const judgement = ['decision', 'rejection', 'supersession', 'root-cause'].includes(fact.kind);+ rows.push('<li id="fact-' + esc(fact.id) + '" class="tl-fact' + (judgement ? ' tl-judgement' : '') + (replacement ? ' tl-superseded' : '') + '" data-event-id="' + fact.eventId + '"><time>' + when(fact.at) + '</time><span class="tl-fact-head"><span class="chip">' + esc(fact.kind) + '</span> <b>' + esc(fact.by) + '</b></span><span class="tl-body">' + esc(fact.text) + '</span><small>' + age(fact.at) + (replacement ? ' · <a class="thread-replacement" href="#fact-' + esc(replacement.id) + '">replaced by ' + esc(replacement.kind) + '</a>' : '') + '</small>' + (fact.ref ? '<div class="tl-code">' + codeRef(factCodeRef(fact.ref), '') + '</div>' : '') + '</li>');+ };+ for (const entry of entries) {+ if (entry.type === 'fact') { factRow(entry); continue; }+ while (stepIndex < steps.length && !(steps[stepIndex].kind === entry.kind && steps[stepIndex].by === entry.by && steps[stepIndex].at === entry.at)) {+ moveRow(steps[stepIndex], null, stepIndex);+ stepIndex += 1;+ }+ if (stepIndex < steps.length) {+ moveRow(steps[stepIndex], entry, stepIndex);+ stepIndex += 1;+ }+ }+ while (stepIndex < steps.length) {+ moveRow(steps[stepIndex], null, stepIndex);+ stepIndex += 1;+ }+ return '<ol class="tl">' + rows.join('') + '</ol>';}/**diff --git a/src/view.css b/src/view.cssindex f434b7ac..965666dc 100644--- a/src/view.css+++ b/src/view.css@@ -226,6 +226,17 @@ input:disabled { background: var(--surface-2); color: var(--ink-muted); }.tl li::after { content: ''; position: absolute; left: 4px; top: 16px; bottom: 0; width: 2px; border-radius: 2px; background: var(--c); opacity: .55; }.tl li:last-child { padding-bottom: 0; } .tl li:last-child::after { display: none; }.tl .tl-claimed { --c: var(--blue); } .tl .tl-submitted { --c: var(--warn); } .tl .tl-verified { --c: var(--accent); } .tl .tl-withdrawn { --c: var(--ink-faint); } .tl .tl-back { --c: var(--reject); }+.tl { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }+.tl li.tl-fact { --c: var(--violet); }+.tl li.tl-judgement { --c: var(--warn); }+.tl li.tl-superseded { opacity: .56; }+.tl .tl-fact-head, .tl .tl-body, .tl .tl-code { grid-column: 2; min-width: 0; }+.tl .tl-fact-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }+.tl .tl-body { white-space: pre-wrap; overflow-wrap: anywhere; }+.tl .tl-fact-head .chip { flex: 0 0 auto; }+.tl .tl-code { max-width: 100%; overflow-wrap: anywhere; }+.tl .tl-code button.ref { white-space: normal; overflow-wrap: anywhere; text-align: left; }+.tl .thread-replacement { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }.tl b { font-weight: 600; }.tl small { grid-column: 2; color: var(--ink-faint); font-size: 12px; }.tl time, .feed time { color: var(--ink-faint); font: 12px var(--mono); }diff --git a/test/cockpit.test.js b/test/cockpit.test.jsindex 6e7272a2..f135ca2f 100644--- a/test/cockpit.test.js+++ b/test/cockpit.test.js@@ -3194,6 +3194,117 @@ test('real Chrome styles shout code and item text without growing linked lines [}});+test("item detail merges API facts and moves in one responsive timeline [B33,B29]", { timeout: 120_000 }, async (t) => {+ const executable = chromeExecutable();+ if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for item-thread rendering checks.');++ const box = machine();+ const alpha = project(box, 'item-thread');+ box.run(alpha.repo, 'add', 'web', 'Thread fixture', '--specs', 'G1', '--criterion', 'The item keeps its evidence.');+ box.run(alpha.web, 'claim', '1');+ const sourceHead = box.git(alpha.repo, 'rev-parse', 'HEAD');+ /** Append a real board fact and return the identity the correction must name. */+ const addFact = (kind, text, ...flags) => JSON.parse(box.run(alpha.web, 'fact', '1', kind, text, ...flags, '--json')).fact;+ const oldNote = addFact('note', 'Earlier observation, now replaced.');+ addFact('capture', 'Captured the rendered page.', '--ref', `SPEC.md:1-2@${sourceHead}`);+ box.run(alpha.web, 'release', '1');+ addFact('measurement', 'The view settles in 8 seconds.');+ box.run(alpha.web, 'claim', '1');+ addFact('diff', 'The detail gained a thread.');+ addFact('decision', 'Keep the thread in the item.');+ addFact('rejection', 'The first layout wrapped poorly.');+ const replacement = addFact('supersession', 'Correction: the note is replaced.', '--supersedes', oldNote.id);+ addFact('root-cause', 'The missing projection hid the facts.');++ const view = await startView(box);+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-item-thread-chrome-'));+ let chrome;+ try {+ const apiState = await boardOf(view, alpha.repo);+ const expected = apiState.items.find((item) => item.id === 1).thread;+ assert.deepEqual(expected.filter((entry) => entry.type === 'fact').map((entry) => entry.kind),+ ['note', 'capture', 'measurement', 'diff', 'decision', 'rejection', 'supersession', 'root-cause'],+ 'the API provides every fact in append order');+ chrome = await openSnapshotChrome(executable, view.link.href, profile);+ await chrome.waitFor('typeof data !== "undefined" && data?.project?.items?.find((item) => item.id === 1)?.thread?.length === ' + expected.length);+ await chrome.waitFor('document.querySelectorAll("#detail .tl [data-event-id]").length === ' + expected.length);+ const expectedIds = expected.map((entry) => entry.eventId);+ for (const width of [375, 1280]) {+ await chrome.send('Emulation.setDeviceMetricsOverride', { width, height: 1000, deviceScaleFactor: 1, mobile: false });+ await chrome.waitFor(`innerWidth === ${width} && document.querySelector('#detail .tl')?.getBoundingClientRect().width > 0`);+ const rendered = JSON.parse(await chrome.evaluate(`JSON.stringify((() => {+ const timeline = document.querySelector('#detail .tl');+ const old = document.querySelector('#detail #fact-${oldNote.id}');+ const replacement = document.querySelector('#detail #fact-${replacement.id}');+ const live = document.querySelector('#detail #fact-${expected.find((entry) => entry.type === 'fact' && entry.kind === 'capture').id}');+ const plain = document.querySelector('#detail .tl-fact:not(.tl-judgement):not(.tl-superseded)');+ const judgementColors = Object.fromEntries(['decision', 'rejection', 'supersession', 'root-cause'].map((kind) => {+ const row = [...timeline.querySelectorAll('.tl-fact')].find((entry) => entry.querySelector('.tl-fact-head .chip')?.textContent === kind);+ return [kind, row ? getComputedStyle(row, '::before').backgroundColor : null];+ }));+ return {+ ids: [...timeline.querySelectorAll('[data-event-id]')].map((row) => Number(row.dataset.eventId)),+ rows: timeline.querySelectorAll('li').length,+ kinds: [...timeline.querySelectorAll('.tl-fact-head .chip')].map((chip) => chip.textContent),+ authors: [...timeline.querySelectorAll('.tl-fact-head b')].map((name) => name.textContent),+ ages: timeline.querySelectorAll('.tl-fact small time[data-ago]').length,+ oldClass: old?.className,+ replacementHref: old?.querySelector('.thread-replacement')?.getAttribute('href'),+ oldOpacity: Number(old && getComputedStyle(old).opacity),+ replacementOpacity: Number(replacement && getComputedStyle(replacement).opacity),+ liveOpacity: Number(live && getComputedStyle(live).opacity),+ plainMarker: plain ? getComputedStyle(plain, '::before').backgroundColor : null,+ judgementColors,+ judgementKinds: Object.keys(judgementColors).filter((kind) => judgementColors[kind] !== null),+ ref: timeline.querySelector('.tl-fact button[data-code]')?.dataset.code,+ viewport: document.documentElement.clientWidth,+ pageWidth: Math.max(document.documentElement.scrollWidth, document.body.scrollWidth),+ };+ })())`));+ assert.deepEqual(rendered.ids, expectedIds, `${width}px: moves and facts follow the API's event order`);+ assert.equal(rendered.rows, expected.length, `${width}px: each API event appears exactly once`);+ const expectedFacts = expected.filter((entry) => entry.type === 'fact');+ assert.deepEqual(rendered.kinds, expectedFacts.map((entry) => entry.kind), `${width}px: every fact kind is a visible chip`);+ assert.deepEqual(rendered.authors, expectedFacts.map((entry) => entry.by), `${width}px: each fact names its API author`);+ assert.equal(rendered.ages, expectedFacts.length, `${width}px: each fact shows its age`);+ assert.match(rendered.oldClass, /tl-superseded/, `${width}px: the earlier fact is visibly dimmed`);+ assert.equal(rendered.replacementHref, `#fact-${replacement.id}`, `${width}px: the earlier fact links to its replacement`);+ assert.ok(rendered.oldOpacity < rendered.replacementOpacity && rendered.oldOpacity < rendered.liveOpacity,+ `${width}px: computed opacity dims the superseded fact`);+ assert.deepEqual(rendered.judgementKinds, ['decision', 'rejection', 'supersession', 'root-cause'], `${width}px: all judgement kinds appear`);+ for (const [kind, color] of Object.entries(rendered.judgementColors)) {+ assert.notEqual(color, rendered.plainMarker, `${width}px: ${kind} uses a distinct computed marker color`);+ }+ assert.equal(rendered.ref, `SPEC.md:1-2@${sourceHead}`, `${width}px: the committed code reference is actionable`);+ assert.equal(rendered.pageWidth, rendered.viewport, `${width}px: the timeline causes no sideways page scroll`);+ }+ const scrollBefore = JSON.parse(await chrome.evaluate(`JSON.stringify({ page: document.documentElement.scrollTop, detail: document.querySelector('#detail').scrollTop })`));+ await chrome.evaluate(`document.querySelector('#detail #fact-${oldNote.id} .thread-replacement').click()`);+ await chrome.waitFor(`location.hash === '#fact-${replacement.id}' && document.querySelector('#detail #fact-${replacement.id}')`);+ const target = JSON.parse(await chrome.evaluate(`JSON.stringify((() => {+ const detail = document.querySelector('#detail'), fact = document.querySelector('#detail #fact-${replacement.id}');+ const box = fact.getBoundingClientRect(), panel = detail.getBoundingClientRect();+ return { item: view.item, id: fact.id, text: document.querySelector('#detail h2')?.textContent,+ page: document.documentElement.scrollTop, detail: detail.scrollTop,+ visible: box.top >= panel.top && box.bottom <= panel.bottom };+ })())`));+ assert.equal(target.id, `fact-${replacement.id}`, 'the replacement anchor resolves to a visible fact');+ assert.equal(target.item, 1, 'following the link keeps the same item selected');+ assert.equal(target.text, '#1Thread fixture', 'the item detail stays open after following the replacement link');+ assert.ok(target.page > scrollBefore.page || target.detail > scrollBefore.detail,+ 'following the replacement anchor scrolls to its existing target');+ assert.equal(target.visible, true, 'the replacement is visible after following its link');+ await chrome.evaluate(`document.querySelector('#detail .tl-fact button[data-code]').click()`);+ await chrome.waitFor(`document.querySelector('#detail .tl-fact button[data-code]')?.getAttribute('aria-expanded') === 'true'`);+ await chrome.waitFor(`document.querySelector('#detail .tl-fact .code')?.textContent.includes('Demo spec')`);+ assert.match(await chrome.evaluate(`document.querySelector('#detail .tl-fact .code')?.textContent || ''`), /Demo spec/, 'the code reference opens the committed lines');+ } finally {+ if (chrome) await closeSnapshotChrome(chrome);+ await view.stop();+ rmSync(profile, { recursive: true, force: true });+ }+});+test('wait references stay on one line and link to every prerequisite at phone and desktop widths [N26]', { timeout: 90_000 }, async (t) => {const executable = chromeExecutable();if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for prerequisite layout checks.');