- ${typeof stageTrackerPreparationNodeHtml === 'function' ? stageTrackerPreparationNodeHtml(pr, stages, ctx) : ''}
${typeof stageTrackerRowToolsHtml === 'function' ? stageTrackerRowToolsHtml(pr) : ''}
${stageTrackerHeadColsHtml([ref], '', stageTrackerActedBadgeHtml(pr, nowMs) + stageTrackerChipsHtml(pr) + (typeof stageTrackerLeadButtonHtml === 'function' ? stageTrackerLeadButtonHtml(pr, nowMs) : ''))}
const trainKey = typeof stageTrackerTrainKey === 'function' ? stageTrackerTrainKey(item) : '';
if (typeof stageTrackerPreparationMark === 'function') stageTrackerPreparationMark(shown);
return `
- ${typeof stageTrackerPreparationNodeHtml === 'function' ? stageTrackerPreparationNodeHtml(item, stages, ctx) : ''}
${stageTrackerRowToolsHtml(item)}
${stageTrackerHeadColsHtml(prRefs, leadHtml, stageTrackerActedBadgeHtml(item, nowMs) + stageTrackerChipsHtml(shown) + (typeof stageTrackerLeadButtonHtml === 'function' ? stageTrackerLeadButtonHtml(item, nowMs, subRows) : ''), prTargetKey)}
+ ${typeof stageTrackerPreparationNodeHtml === 'function' ? stageTrackerPreparationNodeHtml(item, stages, ctx) : ''}
${stageTrackerStripItems(shown, stages, range, nowMs, ctx)}
${stageTrackerSinceHtml(shown, nowMs)}
${typeof stageTrackerHumanContextHtml === 'function' ? stageTrackerHumanContextHtml(item, stages, nowMs, subRows) : ''}${stageTrackerCurrentStageHtml(shown, stages, range, nowMs)}${typeof stageTrackerPreparationCommentHtml === 'function' ? stageTrackerPreparationCommentHtml(shown, ctx, stageTrackerItemKey(item)) : typeof stageTrackerEventHtml === 'function' ? stageTrackerEventHtml(stageTrackerItemKey(item), ctx) : ''}${typeof stageTrackerExecutionHtml === 'function' ? stageTrackerExecutionHtml(shown) : ''}${typeof stageTrackerReviewNotesHtml === 'function' ? stageTrackerReviewNotesHtml(item, ctx) : ''}${subs}
@@ -20208,7 +20214,8 @@
All labels
navCountDelta(document.getElementById(id), null);
}
}
- // Preparation decorates the existing rows; it never sorts or admits them.
+ // Keep complete issue/PR row units together in recorded preparation order.
+ // This changes display order only, never admission or pipeline stage.
var _stageTrackerPreparationShown = new Map();
var _stageTrackerPreparationRendered = new Map();
var _stageTrackerPreparationInline = [];
@@ -20224,7 +20231,7 @@
All labels
for (const it of adopted) {
if (!it) continue;
const put = pr => {
- const key = stageTrackerPreparationKey(it.repo, pr.number);
+ const key = stageTrackerPreparationKey(pr.repo || it.repo, pr.number);
if (it.kind === 'pr' || !byKey.has(key)) byKey.set(key, { item: pr, host: it, nested: it.kind === 'issue' });
};
if (it.kind === 'pr') put(it);
@@ -20236,6 +20243,44 @@
All labels
}
return byKey;
}
+ function stageTrackerPreparationContiguous(items, entryOf) {
+ const groups = new Map(), membership = new Map();
+ items.forEach((item, index) => {
+ const entry = item && entryOf(item);
+ if (!entry) return;
+ if (!groups.has(entry.groupIndex)) groups.set(entry.groupIndex, []);
+ groups.get(entry.groupIndex).push({ item, index, sequence: entry.sequence });
+ membership.set(index, entry.groupIndex);
+ });
+ for (const members of groups.values()) members.sort((a, b) => a.sequence - b.sequence || a.index - b.index);
+ const emitted = new Set(), out = [];
+ items.forEach((item, index) => {
+ if (!membership.has(index)) { out.push(item); return; }
+ const group = membership.get(index);
+ if (emitted.has(group)) return;
+ emitted.add(group);
+ out.push(...groups.get(group).map(member => member.item));
+ });
+ return out;
+ }
+ function stageTrackerPreparationOrderRows(data, items, stages) {
+ const byHost = new Map();
+ stageTrackerPreparationVisualModel(data, items, items, stages).forEach((group, groupIndex) => {
+ for (const entry of group.members) {
+ if (!entry.row || entry.location !== 'page') continue;
+ const host = entry.row.host;
+ if (typeof stageTrackerTrainKey === 'function' && stageTrackerTrainKey(host)) continue;
+ const key = stageTrackerItemKey(host), prior = byHost.get(key);
+ if (!prior || (prior.groupIndex === groupIndex && entry.sequence < prior.sequence)) {
+ byHost.set(key, { groupIndex, sequence: entry.sequence });
+ }
+ }
+ });
+ return stageTrackerPreparationContiguous(items, item => byHost.get(stageTrackerItemKey(item)));
+ }
+ function stageTrackerPreparationOrderLinked(linked, issue) {
+ return stageTrackerPreparationContiguous(linked, lp => stageTrackerPreparationEntry(stageTrackerLinkedPRItem(issue, lp)));
+ }
function stageTrackerPreparationVisualModel(data, listedRows, pageRows, stages) {
const known = stageTrackerPreparationRows(data && data.items, stages);
const listed = stageTrackerPreparationRows(listedRows, stages);
@@ -20310,20 +20355,20 @@
All labels
function stageTrackerPreparationRowInfo(item, stages) {
if (!item || (typeof stageTrackerTrainKey === 'function' && stageTrackerTrainKey(item))) return null;
const prs = item.kind === 'pr' ? [item] : item.kind === 'issue'
- ? stageTrackerLinkedSorted(item, stages).map(lp => stageTrackerLinkedPRItem(item, lp)) : [];
+ ? stageTrackerPreparationOrderLinked(stageTrackerLinkedSorted(item, stages), item).map(lp => stageTrackerLinkedPRItem(item, lp)) : [];
const members = prs.map(pr => stageTrackerPreparationEntry(pr));
if (!members.length || members.some(e => !e) || members.some(e => e.groupIndex !== members[0].groupIndex)) return null;
const ordered = members.every((e, i) => !i || e.sequence > members[i - 1].sequence);
return { groupIndex: members[0].groupIndex, members, ordered };
}
function stageTrackerPreparationAdjacent(a, b) {
- return !!(a && b && a.ordered && b.ordered && a.groupIndex === b.groupIndex
- && a.members[a.members.length - 1].sequence < b.members[0].sequence);
+ return !!(a && b && a.groupIndex === b.groupIndex);
}
function stageTrackerPreparationHelp(group) {
const q = group.queue;
const details = [`${q.repo || 'Repository unknown'} → ${q.base_ref || 'base unknown'}`,
q.message || 'FIFO follows first qualifying admission, not PR age or guaranteed merge order.',
+ 'The recorded front is first, then waiting tickets in preparation FIFO. Complete issue/PR row units stay together; ticket positions remain explicit when related PRs share one issue.',
'Preparation is not CI, review approval, a ready train seat, or native queue membership.'];
if (q.observed_at) details.push('Snapshot ' + q.observed_at);
for (const e of group.members) {
@@ -20379,8 +20424,9 @@
All labels
if (!info || ctx && ctx.preparationParent) return '';
const prev = ctx && ctx.preparationPrev !== undefined ? ctx.preparationPrev : stageTrackerPreparationRowInfo(ctx && ctx.prevRow, stages);
const next = ctx && ctx.preparationNext !== undefined ? ctx.preparationNext : stageTrackerPreparationRowInfo(ctx && ctx.nextRow, stages);
- const gap = !info.ordered || info.members.some((e, i) => i && e.sequence !== info.members[i - 1].sequence + 1)
- || stageTrackerPreparationAdjacent(prev, info) && info.members[0].sequence !== prev.members[prev.members.length - 1].sequence + 1;
+ const trail = stageTrackerPreparationAdjacent(prev, info)
+ ? [prev.members[prev.members.length - 1]].concat(info.members) : info.members;
+ const gap = trail.some((e, i) => i && Math.abs(e.sequence - trail[i - 1].sequence) > 1);
return ' ham-train' + stageTrackerTrainAccentClass(STAGE_TRACKER_PREPARATION_ACCENT) + ' ham-preparation-member'
+ (info.members.some(e => e.role === 'owner' && e.state === 'current') ? ' ham-train-front' : '')
+ (!stageTrackerPreparationAdjacent(info, next) ? ' ham-train-last' : '')
@@ -20410,14 +20456,16 @@
All labels
&& eventHtml && !eventHtml.includes('cue-event-tucked');
const parts = caption && !captionVisible ? [caption] : [];
if (!caption) parts.push('Current pipeline blocker unknown');
- parts.push(e.state === 'unverified'
+ const preparation = e.state === 'unverified'
? stageTrackerPreparationPlace(e) + ' · ' + (e.ticket.detail || 'current identity or eligibility unknown')
- : e.role === 'owner' ? 'preparing base' : 'queued for base refresh' + (e.ticket.behind ? ' behind PR #' + e.ticket.behind : ' · owner unknown'));
+ : e.role === 'owner' ? 'preparing base' : 'queued for base refresh' + (e.ticket.behind ? ' behind PR #' + e.ticket.behind : ' · owner unknown');
+ if (!caption.split(/\s+[·—]\s+/).includes(preparation)) parts.push(preparation);
parts.push('ticket age ' + stageTrackerPreparationAge(e.ticket, _stageTrackerPreparationNow));
if (e.row.nested) parts.push('shown under issue #' + e.row.host.number);
return eventHtml + ``;
}
function stageTrackerPreparationSubRows(linked, issue, stages, nowMs, ctx) {
+ linked = stageTrackerPreparationOrderLinked(linked, issue);
const parent = stageTrackerPreparationRowInfo(issue, stages);
const infos = linked.map(lp => stageTrackerPreparationRowInfo(stageTrackerLinkedPRItem(issue, lp), stages));
const seen = new Set();
@@ -20645,7 +20693,8 @@
All labels
// Repo chips ride the setting against how many repos the payload spans.
if (stageTrackerRepoChipOn(stageTrackerRepoChipSetting(), repos.length)) ctx.repoChips = { primary: stageTrackerPrimaryRepo(), active: f.repo };
const visible = stageTrackerVisible(d.items, f, ctx);
- const ordered = stageTrackerTrainContiguous(stageTrackerSort(visible, stages, f));
+ const sorted = stageTrackerTrainContiguous(stageTrackerSort(visible, stages, f));
+ const ordered = typeof stageTrackerPreparationOrderRows === 'function' ? stageTrackerPreparationOrderRows(d, sorted, stages) : sorted;
// A TV display (display=1&density=tv) shows the rows that fit the
// screen, ungrouped, with "+N more" in place of the pager.
const tv = typeof stageTrackerDisplayTv === 'function' && stageTrackerDisplayTv();
diff --git a/src/scripts/dashboard-mobile-shots.mjs b/src/scripts/dashboard-mobile-shots.mjs
index 07575795da..99ca72b8bc 100644
--- a/src/scripts/dashboard-mobile-shots.mjs
+++ b/src/scripts/dashboard-mobile-shots.mjs
@@ -27,6 +27,7 @@ import { spawn } from 'node:child_process';
import fs from 'node:fs';
import http from 'node:http';
import path from 'node:path';
+import { preparationRailLayoutFixture } from './fixtures/dashboard-preparation-rail.mjs';
const CHROME_CANDIDATES = [
process.env.CHROME_BIN,
@@ -246,6 +247,7 @@ async function main() {
}
const report = [];
+ const preparationRailReport = [];
let socket;
try {
const tabs = await waitForTabs();
@@ -279,6 +281,7 @@ async function main() {
// Each state callback is best-effort: a missing helper yields a skipped shot, not a harness error.
const setThemeJS = (theme) => `document.body.classList.toggle('light-mode', ${theme === 'light'}); document.documentElement.style.colorScheme = '${theme}'; true`;
const resetJS = `(() => {
+ document.getElementById('preparation-rail-layout-fixture')?.remove();
document.querySelectorAll('.config-overlay, .modal-overlay').forEach((el) => { el.classList.add('hidden'); });
document.documentElement.classList.remove('modal-open'); document.body.classList.remove('modal-open');
return true;
@@ -314,6 +317,17 @@ async function main() {
for (const theme of themes) {
await send('Page.navigate', { url: `file://${process.cwd()}/src/pkg/dashboard/static/index.html` });
await sleep(PAGE_SETTLE_MS);
+ // Absolute production URLs cannot load from file://. Use the same
+ // checked-in sidecars rather than silently testing without tokens.
+ await evaluate(`Promise.all(${JSON.stringify(['tokens.css', 'components.css'].map(name => ({
+ name, url: `file://${process.cwd()}/src/pkg/dashboard/static/${name}`,
+ })))}.map(({name, url}) => new Promise((resolve, reject) => {
+ const link = document.querySelector('link[href="/' + name + '"]');
+ if (!link) return reject(new Error('Missing production stylesheet ' + name));
+ link.onload = () => resolve(true);
+ link.onerror = () => reject(new Error('Cannot load production stylesheet ' + name));
+ link.href = url;
+ })))`);
await evaluate(setThemeJS(theme));
const sectionIDs = await evaluate(collapseAllJS);
@@ -324,6 +338,14 @@ async function main() {
states.push({ name: 'settings', run: async () => { await evaluate(collapseAllJS); return evaluate(settingsJS); } });
states.push({ name: 'knowledge-sources', run: async () => { await evaluate(collapseAllJS); return evaluate(knowledgeJS); } });
states.push({ name: 'terminal', run: async () => { await evaluate(collapseAllJS); return evaluate(terminalJS); } });
+ states.push({ name: 'preparation-rail', run: async () => {
+ await evaluate(collapseAllJS);
+ if (!await evaluate(expandOneJS('activity-monitor-section'))) throw new Error('Cannot expand actual Activity Monitor');
+ const result = await evaluate('(' + preparationRailLayoutFixture.toString() + ')()');
+ preparationRailReport.push({ viewport: vp.name, theme, ...result });
+ if (result.failures.length) throw new Error('Preparation rail layout: ' + result.failures.join('; '));
+ return true;
+ } });
for (const state of states) {
await evaluate(resetJS);
@@ -347,6 +369,7 @@ async function main() {
if (socket) socket.close();
await cleanup();
fs.writeFileSync(path.join(opts.out, 'overflow-report.json'), JSON.stringify(report, null, 2) + '\n');
+ fs.writeFileSync(path.join(opts.out, 'preparation-rail-layout.json'), JSON.stringify(preparationRailReport, null, 2) + '\n');
}
console.log(`wrote ${report.length} finding(s) to ${path.join(opts.out, 'overflow-report.json')}`);
}
diff --git a/src/scripts/fixtures/dashboard-preparation-rail.mjs b/src/scripts/fixtures/dashboard-preparation-rail.mjs
new file mode 100644
index 0000000000..06950a23f4
--- /dev/null
+++ b/src/scripts/fixtures/dashboard-preparation-rail.mjs
@@ -0,0 +1,108 @@
+// Runs against the generated SPA in the existing Chrome screenshot harness.
+export function preparationRailLayoutFixture() {
+ const nowMs = Date.parse('2026-10-31T12:00:00Z');
+ const repo = 'fixture/preparation';
+ const failures = [], geometry = [];
+ const check = (ok, message) => { if (!ok) failures.push(message); };
+ const host = document.createElement('div');
+ host.id = 'preparation-rail-layout-fixture';
+ const saved = [_stageTrackerPreparationShown, _stageTrackerPreparationRendered, _stageTrackerPreparationInline, _stageTrackerPreparationNow];
+ const pr = (number, stage) => ({ kind: 'pr', repo, number, stage, state: 'open',
+ head: 'head-' + number, base_ref: 'v5', title: 'Preparation connector layout fixture',
+ url: 'https://github.com/' + repo + '/pull/' + number,
+ caption: ('Current-head CI and review remain pending; this expanded caption must stay inside the preparation connector. ').repeat(12) });
+ const ticket = (item, role) => ({ number: item.number, role, state: 'current', head_sha: item.head,
+ current_head: item.head, since: '2026-10-31T11:00:00Z', pipeline: item.caption });
+ const append = (items, owner, waiting) => {
+ const queue = { repo, base_ref: 'v5', state: 'observed', owner: ticket(owner, 'owner'), waiting: waiting.map(p => ticket(p, 'waiting')) };
+ const data = { items, base_preparation: [queue] };
+ items = stageTrackerPreparationOrderRows(data, items, []);
+ stageTrackerPreparationVisualSync(data, items, items, [], nowMs);
+ const ctx = { nowMs, items, events: {}, noteTuck: false, sharedPRs: {}, workers: {} };
+ const rows = items.map((item, i) => ({ key: stageTrackerItemKey(item),
+ html: stageTrackerRowHtml(item, [], { ...ctx, prevRow: items[i - 1], nextRow: items[i + 1] }) }));
+ const block = document.createElement('div');
+ const rendered = stageTrackerPreparationInlineRows(rows, items, []);
+ block.innerHTML = rendered.map(row => row.html).join('');
+ // The production reconciler stamps keys separately from the row renderer.
+ [...block.children].forEach((element, index) => { element.dataset.hamKey = rendered[index].key; });
+ host.appendChild(block);
+ return block;
+ };
+ const rail = el => {
+ const rect = el.getBoundingClientRect(), style = getComputedStyle(el), pseudo = getComputedStyle(el, '::before');
+ const num = value => Number.parseFloat(value) || 0;
+ return { top: rect.top + num(style.borderTopWidth) + num(pseudo.top),
+ bottom: rect.bottom - num(style.borderBottomWidth) - num(pseudo.bottom),
+ x: rect.left + num(style.borderLeftWidth) + num(pseudo.left),
+ border: pseudo.borderLeftStyle, rowHeight: rect.height, content: pseudo.content };
+ };
+ const inspect = (block, selector, name, count) => {
+ const members = [...block.querySelectorAll(selector)];
+ check(members.length === count, name + ': exact member count');
+ check(block.querySelectorAll('.ham-preparation-head').length === 1, name + ': one header');
+ check(!block.textContent.includes('continuation'), name + ': no repeated continuation');
+ const lines = members.map(rail);
+ geometry.push({ name, lines });
+ for (let i = 0; i < members.length; i++) {
+ check(lines[i].content !== 'none' && lines[i].border === 'solid', name + ': original solid connector ' + i);
+ check(members[i].classList.contains('ham-train-last') === (i === members.length - 1), name + ': only final member ends rail');
+ const box = members[i].getBoundingClientRect();
+ check(Math.abs(lines[i].bottom - box.bottom) < 1, name + ': full member height including final caption and padding');
+ const node = members[i].querySelector(':scope > .ham-strip-row > .ham-preparation-node');
+ const strip = members[i].querySelector(':scope > .ham-strip-row');
+ if (node && strip) {
+ const dot = getComputedStyle(node, '::after'), hit = node.getBoundingClientRect(), anchor = strip.getBoundingClientRect();
+ const center = hit.top + Number.parseFloat(dot.top) + Number.parseFloat(dot.height) / 2;
+ lines[i].dot = { top: dot.top, height: dot.height, hitTop: hit.top, hitHeight: hit.height,
+ center, anchorTop: anchor.top, anchorHeight: anchor.height, transform: dot.transform };
+ check(Math.abs(center - (anchor.top + anchor.height / 2)) < 1,
+ name + ': dot stays on item anchor, not comment midpoint: ' + JSON.stringify(lines[i].dot));
+ } else check(false, name + ': actual member dot belongs to its strip anchor');
+ const caption = members[i].querySelector('.ham-preparation-comment');
+ check(caption && caption.getBoundingClientRect().height > 0, name + ': real expanded caption');
+ if (caption) check(lines[i].bottom >= caption.getBoundingClientRect().bottom, name + ': rail spans full caption');
+ if (i === members.length - 1) continue;
+ check(lines[i].bottom >= lines[i + 1].top, name + ': rail crosses caption, padding and inter-row gap');
+ check(Math.abs(lines[i].x - lines[i + 1].x) < 1, name + ': aligned rail gutter');
+ }
+ };
+ try {
+ document.getElementById(host.id)?.remove();
+ const owner = pr(45, 70), first = pr(9, 50), second = pr(2, 70);
+ const roots = append([second, first, owner], owner, [first, second]);
+ const singleOwner = pr(245, 50), single = append([singleOwner], singleOwner, []);
+ const nestedOwner = pr(145, 70), nestedWaiter = pr(109, 50), unrelated = pr(180, 90);
+ const issue = { kind: 'issue', repo, number: 500, stage: 40, title: 'Preserved mixed issue tree',
+ linked_prs: [unrelated, nestedOwner, nestedWaiter] };
+ const nested = append([issue], nestedOwner, [nestedWaiter]);
+ const panel = document.getElementById('activity-monitor-panel');
+ if (!panel) throw new Error('Actual Activity Monitor panel is missing');
+ panel.appendChild(host);
+ inspect(roots, '.ham-row.ham-preparation-member', 'root reverse-FIFO rows', 3);
+ check(roots.querySelector('.ham-preparation-member')?.dataset.hamKey === stageTrackerItemKey(owner), 'verified front is first despite scrambled source sort');
+ inspect(nested, '.ham-sub.ham-preparation-member', 'nested PRs with expanded captions', 2);
+ inspect(single, '.ham-row.ham-preparation-member', 'single-member train with multiline caption', 1);
+ for (const [block, selector, name, count] of [
+ [roots, '.ham-row.ham-preparation-member', 'last root dynamic comment', 3],
+ [nested, '.ham-sub.ham-preparation-member', 'last nested dynamic comment', 2],
+ [single, '.ham-row.ham-preparation-member', 'single dynamic comment', 1],
+ ]) {
+ const last = [...block.querySelectorAll(selector)].at(-1), before = last.getBoundingClientRect().height;
+ const comment = document.createElement('div');
+ comment.className = 'cue-event ham-preparation-comment';
+ comment.textContent = 'New live commentary must extend the final rail without moving the member anchor. '.repeat(24);
+ last.appendChild(comment);
+ check(last.getBoundingClientRect().height > before, name + ': layout really grew after commentary update');
+ inspect(block, selector, name, count);
+ }
+ const nonmember = nested.querySelector('[data-ham-sub-key="' + stageTrackerItemKey(unrelated) + '"]');
+ check(nonmember && !nonmember.classList.contains('ham-preparation-member'), 'unrelated child has no preparation membership');
+ host.scrollIntoView();
+ } catch (error) {
+ failures.push(String(error.stack || error));
+ } finally {
+ [_stageTrackerPreparationShown, _stageTrackerPreparationRendered, _stageTrackerPreparationInline, _stageTrackerPreparationNow] = saved;
+ }
+ return { failures, geometry };
+}