diff --git a/.github/scripts/integration-governance.cjs b/.github/scripts/integration-governance.cjs index 694421521c..488d35bd1a 100644 --- a/.github/scripts/integration-governance.cjs +++ b/.github/scripts/integration-governance.cjs @@ -9,7 +9,7 @@ const MAX_COMMITS = 1000; const MAX_AUTHOR_BATCH = 50; // This literal is inside the enrolled .github closure. A caller-supplied // preparedBy.sourceSHA must never choose a new executable verifier tree. -const TRUSTED_SCRIPTS_TREE = 'b1b6477108b28bda15e93735f2f6723568d0281d'; +const TRUSTED_SCRIPTS_TREE = '308d64dd1ac3bf1061a4dced3071647236327e51'; const SOURCE = 'https://github.com/kubernetes-sigs/kubebuilder-release-tools/tree/012269a88fa4c034a0acf1ba84c26b195c0dbab4'; const sha = value => crypto.createHash('sha256').update(value).digest('hex'); const git = (args, cwd = process.cwd()) => diff --git a/.github/workflows/dashboard-mobile-shots.yml b/.github/workflows/dashboard-mobile-shots.yml index 9461a16d64..f55eb1242c 100644 --- a/.github/workflows/dashboard-mobile-shots.yml +++ b/.github/workflows/dashboard-mobile-shots.yml @@ -8,6 +8,7 @@ on: paths: - 'src/pkg/dashboard/**' - 'src/scripts/dashboard-mobile-shots.mjs' + - 'src/scripts/fixtures/dashboard-preparation-rail.mjs' - '.github/workflows/dashboard-mobile-shots.yml' concurrency: @@ -30,18 +31,19 @@ jobs: node-version: '22' # The self-hosted fleet ships no browser (#11810): fetch Chrome for Testing - # into RUNNER_TEMP and hand it to the harness via CHROME_BIN. Best-effort — - # if the download fails the harness prints SKIP instead of crashing. + # with its Linux runtime dependencies and hand the working executable + # to the harness via CHROME_BIN. The minimal fleet lacks libnspr4. - name: Install Chrome for Testing id: chrome continue-on-error: true run: | set -euo pipefail - out="$(npx --yes @puppeteer/browsers@2 install chrome@stable --path "$RUNNER_TEMP/chrome-for-testing" | tail -n 1)" + sudo apt-get update + out="$(sudo env "PATH=$PATH" npx --yes @puppeteer/browsers@2 install chrome@stable --install-deps --path "$RUNNER_TEMP/chrome-for-testing" | tail -n 1)" bin="${out#* }" test -x "$bin" - echo "CHROME_BIN=$bin" >> "$GITHUB_ENV" "$bin" --version + echo "CHROME_BIN=$bin" >> "$GITHUB_ENV" - name: Capture mobile screenshots and overflow report run: node src/scripts/dashboard-mobile-shots.mjs --out dashboard-mobile-shots-out diff --git a/changelog.d/fixed-preparation-continuous-connector.md b/changelog.d/fixed-preparation-continuous-connector.md new file mode 100644 index 0000000000..18d8da9226 --- /dev/null +++ b/changelog.d/fixed-preparation-continuous-connector.md @@ -0,0 +1 @@ +- Group complete preparation issue/PR row units into a front-first FIFO block with an uninterrupted connector through captions and nested spacing; preserve unrelated rows and child associations, distinguish unverified recorded fronts, and validate geometry in Chrome with its required runtime dependencies. diff --git a/src/docs/dashboard-sections/activity-monitor.md b/src/docs/dashboard-sections/activity-monitor.md index f8ee28b880..2e54eb5489 100644 --- a/src/docs/dashboard-sections/activity-monitor.md +++ b/src/docs/dashboard-sections/activity-monitor.md @@ -245,6 +245,19 @@ It counts under **Needs attention**. Before the merge gate only the held-workflo #### Merge train +**Preparation is a separate, not-yet-ready train.** Its compact gold header and +original thin rail annotate actual preparation members without changing their +CI/review stages. Before pagination, complete issue/PR row units form a contiguous +block at the first preparation unit's position: the recorded front is first, +then waiters in durable ticket FIFO. Nonmember units retain their relative order. +Related PRs stay with their issue; nested preparation children follow FIFO while +nonmember siblings retain their relative order. Explicit ticket positions remain +the authority when one issue contains non-adjacent tickets. Adjacent members share +one header and a continuous connector through expanded captions, row padding and +nested PR spacing. An unrelated row or child ends the rail rather than acquiring +misleading membership. A missing, closed or stale front is never synthesized as a +verified owner; recorded/unverified metadata remains explicit. + When several approved PRs to the same base touch the same files, the automerge lanes merge them one at a time ([#15117](https://github.com/hivecommons/hive/issues/15117)). The tracker renders every train contiguously, in merge order, with a thin left rail linking the rows and a header chip `🚆 merge train · 4 PRs · 1st: #15074` — the glyph is an inline-SVG railcar (14px, currentColor, hover *Merge queue*), the same icon the **Merge queue** column header and its chevrons wear; overlapping files are listed beside it. Pill wording per state is the PR's place in the queue (the owner's words — `front` and `queued-behind` appear nowhere a person reads): the head reads "Merge queued · 1st of 4 · ~13m" (its own soak left plus the next pass); the others "Merge queued · 2nd of 4 · ~4m", "Merge queued · 3rd of 4", … (`1st 2nd 3rd 4th … 11th 12th 13th 21st`, always with the queue length, countdown to its turn); when the page draws more than one train each queue word ends with its train's tag — "Merge queued · 1st of 2 · train main.go" (the first overlapping file's basename, else the head `#N`) — and the hover leads *Train of 2 PRs overlapping main.go; merges after #15567.*, so two "1st"s on one page tell apart (one train → no tag); the header and every member row of a train share one rail accent (`.ham-train-k0…k3`, cycling in page order); once the front merged and the hive is rebasing a conflicting sibling, "Rebasing · attempt 1/2"; when the loop guard (`auto_merge.merge_train.max_rebase_attempts`) is spent, "Needs human decision · rebase failed twice" at stage/085 with the decision option "Rebase, then merge as maintainer". The tooltip lists the PRs ahead and the overlapping files. Waiting siblings are never red, never `needs human`; a `needs-rebase` label on one is reported under `stale_labels`, the train repairs it. Each item carries `merge_gate.state` (`queued-behind` / `rebasing` / `rebase-exhausted` / `front`, with an honest `reason` such as `behind #15074 in merge train (3rd of 4, overlapping files: stage_tracker.go, index.html)`) and `merge_train{id, state, front, position, size, attempt, max_attempts, overlap_files, ahead, members}`; the id is `#` and `members` is the whole roster in merge order. diff --git a/src/pkg/dashboard/stage_tracker_preparation_visual.test.js b/src/pkg/dashboard/stage_tracker_preparation_visual.test.js index 74377bdf15..e584a2b0d7 100644 --- a/src/pkg/dashboard/stage_tracker_preparation_visual.test.js +++ b/src/pkg/dashboard/stage_tracker_preparation_visual.test.js @@ -111,19 +111,84 @@ test('original compact pill and connector decorate actual rows with FIFO help an assert.deepEqual(plain(f.data), before); }); -test('actual custom sorts, pagination and stage ranges are unchanged; backwards order starts separate runs', () => { +test('preparation FIFO overrides custom row sort before pagination without mutating its input', () => { const { ctx } = load(), f = fixture(); const ordered = ctx.stageTrackerSort(f.data.items, [], { sort: 'number', dir: 'asc' }); - const page = ctx.stageTrackerPage(ordered, { size: 25, page: 1 }); + const original = plain(ordered); + const prepared = ctx.stageTrackerPreparationOrderRows(f.data, ordered, []); + const page = ctx.stageTrackerPage(prepared, { size: 25, page: 1 }); const before = plain(page), rows = render(ctx, f, page.rows, ordered); + assert.deepEqual(plain(ordered), original); assert.deepEqual(plain(page), before); - assert.deepEqual(rootKeys(rows), page.rows.map(it => ctx.stageTrackerItemKey(it))); - assert.equal(rows.filter(row => row.key.startsWith('preparation:')).length, 3); - assert.match(content(rows), /continuation/); - for (const row of rows.filter(row => !row.key.startsWith('preparation:'))) assert.match(row.html, /ham-train-last/); + assert.deepEqual(rootKeys(rows), [45, 9, 2].map(n => REPO + '/pr#' + n)); + assert.equal(rows.filter(row => row.key.startsWith('preparation:')).length, 1); + assert.doesNotMatch(content(rows), /continuation/); + const members = rows.filter(row => !row.key.startsWith('preparation:')); + for (const row of members.slice(0, -1)) assert.doesNotMatch(row.html, /ham-train-last|ham-preparation-gap/); + assert.match(members.at(-1).html, /ham-train-last/); assert.deepEqual(plain(model(ctx, f)[0].waiting.map(e => [e.ticket.number, e.position])), [[9, 1], [2, 2]]); }); +test('scrambled preparation units form one front-first block while nonmembers retain their relative order', () => { + const { ctx } = load(), f = fixture(); + const others = [81, 82, 83].map(number => ({ ...f.first, number, preparation: null, head: 'other-' + number })); + const source = [others[0], f.second, others[1], f.owner, others[2], f.first]; + f.data.items = source; + const before = plain(source); + const ordered = ctx.stageTrackerPreparationOrderRows(f.data, source, []); + assert.deepEqual(plain(ordered.map(it => it.number)), [81, 45, 9, 2, 82, 83]); + assert.equal(new Set(ordered).size, source.length); + assert.deepEqual(plain(source), before); + const rows = render(ctx, f, ordered); + assert.equal(rows.filter(row => row.key.startsWith('preparation:')).length, 1); + for (const other of others) assert.doesNotMatch(rootRow(rows, other.number).html, /ham-preparation-member|ham-preparation-node/); +}); + +test('a nested front moves its complete issue unit and preserves unrelated children without duplicate PR rows', () => { + const { ctx } = load(), f = fixture(); + const unrelated = { ...f.first, number: 84, head: 'unrelated', preparation: null }; + const issue = { kind: 'issue', repo: REPO, number: 500, stage: 40, linked_prs: [unrelated, f.owner] }; + f.data.items = [f.second, issue, f.first]; + const before = plain(f.data); + const ordered = ctx.stageTrackerPreparationOrderRows(f.data, f.data.items, []); + assert.deepEqual(plain(ordered.map(it => [it.kind, it.number])), [['issue', 500], ['pr', 9], ['pr', 2]]); + assert.deepEqual(plain(issue.linked_prs.map(it => it.number)), [84, 45]); + assert.deepEqual(plain(f.data), before); + const rows = render(ctx, f, ordered), html = content(rows); + assert.deepEqual(rootKeys(rows), [REPO + '/issue#500', REPO + '/pr#9', REPO + '/pr#2']); + assert.equal((html.match(/data-ham-sub-key="hivecommons\/hive\/pr#45"/g) || []).length, 1); + assert.doesNotMatch(html, /data-ham-key="hivecommons\/hive\/pr#45"/); +}); + +test('nested preparation children follow FIFO as one block while nonmember siblings keep their original order', () => { + const { ctx } = load(), f = fixture(); + const others = [85, 86].map(number => ({ ...f.first, number, preparation: null, head: 'other-' + number })); + const issue = { kind: 'issue', repo: REPO, number: 501, stage: 40, + linked_prs: [others[0], f.second, others[1], f.owner, f.first] }; + f.data.items = [issue]; + ctx.stageTrackerPreparationVisualSync(f.data, f.data.items, f.data.items, [], NOW); + const ordered = ctx.stageTrackerPreparationOrderLinked(issue.linked_prs, issue); + assert.deepEqual(plain(ordered.map(lp => lp.number)), [85, 45, 9, 2, 86]); + assert.deepEqual(plain(issue.linked_prs.map(lp => lp.number)), [85, 2, 86, 45, 9]); +}); + +test('missing, closed and stale recorded fronts never become verified owners or fabricated rows when ordering', () => { + for (const state of ['missing', 'closed', 'stale']) { + const { ctx } = load(), f = fixture(); + if (state === 'missing') f.data.items = [f.second, f.first]; + if (state === 'closed') f.owner.state = 'closed'; + if (state === 'stale') f.owner.head = 'new-owner-head'; + const ordered = ctx.stageTrackerPreparationOrderRows(f.data, f.data.items, []); + assert.equal(new Set(ordered).size, f.data.items.length, state); + if (state === 'missing') assert.deepEqual(plain(ordered.map(it => it.number)), [9, 2]); + const rows = render(ctx, f, ordered), html = content(rows); + assert.doesNotMatch(html, /ham-train-front/); + assert.match(rows.find(row => row.key.startsWith('preparation:')).html, /recorded front: #45/); + if (state === 'missing') assert.doesNotMatch(html, /data-ham-key="hivecommons\/hive\/pr#45"/); + if (state === 'stale') assert.match(rootRow(rows, 45).html, /ham-preparation-unverified/); + } +}); + test('unrelated rows terminate rails; filtered FIFO gaps use dashed continuation without inventing adjacency', () => { const { ctx } = load(), f = fixture(); const other = { ...f.first, number: 80, head: 'other', preparation: null }; @@ -148,6 +213,18 @@ test('off-page owner remains truthful in compact header/help with real waiting o assert.equal(rootKeys(rows).length, 1); }); +test('preparation commentary deduplicates the exact canonical clause, not a different owner-number prefix', () => { + const { ctx } = load(), f = fixture(); + f.first.caption = 'Review swarm requested; waiting for a verdict on the current head — queued for base refresh behind PR #45'; + let html = rootRow(render(ctx, f, [f.owner, f.first, f.second]), 9).html; + let body = html.match(/ham-preparation-comment">([^<]*)/)[1]; + assert.equal((body.match(/queued for base refresh behind PR #45/g) || []).length, 1); + f.first.caption = 'Review pending — queued for base refresh behind PR #4'; + html = rootRow(render(ctx, f, [f.owner, f.first, f.second]), 9).html; + body = html.match(/ham-preparation-comment">([^<]*)/)[1]; + assert.match(body, /behind PR #4 · queued for base refresh behind PR #45/); +}); + test('release/handoff clears former owner decoration and pill suppression; readmission preserves durable FIFO', () => { const { ctx } = load(), f = fixture(); render(ctx, f); @@ -221,7 +298,7 @@ test('multiple/shared issue trees keep their actual nested rows and PR stages wi assert.match(html, /data-ham-stage="70" data-ham-sub-key="hivecommons\/hive\/pr#2"/); assert.match(html, /shown under issue #500/); assert.deepEqual(plain(f.data), before); - assert.match(rootRow(rows, 500, 'issue').html, /ham-preparation-gap/); + assert.doesNotMatch(rootRow(rows, 500, 'issue').html, /ham-preparation-gap/); }); test('mixed linked trees mark only preparation children and stop before an unrelated child', () => { @@ -362,3 +439,27 @@ test('gold summary stays ready-only without the removed external region', () => assert.equal(count.textContent, '1'); assert.doesNotMatch(chip.title, /preparation|owner|waiting/); }); + +test('expanded captions and adjacent nested members share a full-height connector without moving unrelated children', () => { + const { ctx } = load(), f = fixture(); + f.owner.stage = 50; f.first.stage = 70; + f.first.caption = 'Expanded current-head CI and review detail. '.repeat(24); + f.q.waiting = [f.first.preparation]; + const unrelated = { ...f.second, number: 80, stage: 90, preparation: null, head: 'other' }; + const issue = { kind: 'issue', repo: REPO, number: 500, stage: 40, linked_prs: [f.owner, unrelated, f.first] }; + f.data.items = [issue]; + const before = plain(f.data), html = content(render(ctx, f)); + assert.deepEqual(plain(f.data), before); + assert.equal((html.match(/ham-preparation-head/g) || []).length, 1); + assert.equal((html.match(/ham-train-last/g) || []).length, 1); + assert.doesNotMatch(html, /continuation/); + assert.match(html, /class="ham-sub" data-ham-kind="pr" data-ham-stage="90"/); + assert.match(html, /ham-preparation-member ham-train-last" data-ham-kind="pr" data-ham-stage="70"/); + assert.match(html, /ham-preparation-member ham-train-front" data-ham-kind="pr" data-ham-stage="50"/); + assert.match(html, /Expanded current-head CI and review detail\./); + const childKey = number => html.indexOf('data-ham-sub-key="' + REPO + '/pr#' + number + '"'); + assert.ok(childKey(80) < childKey(45)); + assert.ok(childKey(45) < childKey(9)); + const css = fs.readFileSync(path.join(__dirname, 'static-src/css/tracker.css'), 'utf8'); + assert.match(css, /\.ham-row\.ham-preparation-member::before \{ top: calc\(-1 \* var\(--line-width\)\)/); +}); diff --git a/src/pkg/dashboard/static-src/css/tracker.css b/src/pkg/dashboard/static-src/css/tracker.css index 7feb1bab1e..7784736e8f 100644 --- a/src/pkg/dashboard/static-src/css/tracker.css +++ b/src/pkg/dashboard/static-src/css/tracker.css @@ -206,13 +206,20 @@ .ham-row.ham-train-front::after { background: var(--text); } .ham-train-head + .ham-row.ham-train { border-top: 0; } .ham-preparation-head { flex-wrap: wrap; } + .ham-row.ham-preparation-member::before { top: calc(-1 * var(--line-width)); } + .ham-row.ham-preparation-member.ham-train-last::before { bottom: 0; } + .ham-row.ham-preparation-member::after { display: none; } .ham-preparation-head .ham-train-chip { white-space: normal; } .ham-preparation-head .ham-preparation-help { background: none; border-color: var(--ham-train-accent); color: var(--muted); } .ham-preparation-help::before { content: '?'; } - .config-info.ham-preparation-node { position: absolute; left: calc(var(--sp-2) - 2px); top: calc(50% - var(--sp-2)); width: calc(var(--sp-2) * 2); height: calc(var(--sp-2) * 2); margin: 0; padding: 0; border: 0; background: transparent; z-index: 1; } + .config-info.ham-preparation-node { position: absolute; left: calc(var(--sp-2) - 2px); top: 50%; transform: translateY(-50%); width: calc(var(--sp-2) * 2); height: calc(var(--sp-2) * 2); margin: 0; padding: 0; border: 0; background: transparent; z-index: 1; } + .ham-row.ham-preparation-member > .ham-strip-row > .ham-preparation-node { left: calc(var(--sp-2) - var(--sp-5) - 2px); } + .ham-preparation-node::before { content: none; } + .ham-preparation-node::after { content: ''; position: absolute; left: 1px; top: calc(50% - 3px); width: 6px; height: 6px; border-radius: var(--r-pill); background: var(--ham-train-accent); } + .ham-train-front > .ham-strip-row > .ham-preparation-node::after { background: var(--text); } .ham-preparation-node:focus-visible { outline: var(--focus-ring-width) solid var(--ham-train-accent); outline-offset: var(--sp-1); } .ham-row.ham-preparation-gap::before, .ham-sub.ham-preparation-member.ham-preparation-gap::before { border-left-style: dashed; } - .ham-row.ham-preparation-unverified::after, .ham-sub.ham-preparation-member.ham-preparation-unverified::after { background: var(--bg); box-shadow: 0 0 0 var(--line-width) var(--ham-train-accent); } + .ham-preparation-unverified > .ham-strip-row > .ham-preparation-node::after { background: var(--bg); box-shadow: 0 0 0 var(--line-width) var(--ham-train-accent); } .ham-preparation-comment { animation: none; } .ham-human-context { animation: none; } /* Mixed issue trees keep their existing children; only actual prep PRs @@ -220,10 +227,9 @@ .ham-row > .ham-preparation-head { margin-left: calc(-1 * var(--sp-2)); } .ham-sub.ham-preparation-member { position: relative; --ham-train-accent: var(--amber); } .ham-sub.ham-preparation-member::before { content: ''; position: absolute; left: 2px; top: calc(-1 * var(--sp-3) - var(--sp-2)); bottom: 0; border-left: var(--line-width) solid var(--ham-train-accent); } - .ham-sub.ham-preparation-member.ham-train-last::before { bottom: 50%; } - .ham-sub.ham-preparation-member::after { content: ''; position: absolute; left: -1px; top: calc(50% - 3px); width: 6px; height: 6px; border-radius: var(--r-pill); background: var(--ham-train-accent); } - .ham-sub.ham-preparation-member.ham-train-front::after { background: var(--text); } + .ham-sub.ham-preparation-member.ham-train-last::before { bottom: 0; } .ham-sub .config-info.ham-preparation-node { left: calc(-1 * var(--sp-1)); } + .ham-sub .ham-preparation-node::after { left: 3px; } .ham-group-toggle { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 1.4em; height: 1.4em; padding: 0; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font: inherit; cursor: pointer; } .ham-group-toggle:hover { color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); } .ham-group-toggle:focus-visible { outline: var(--focus-ring-width) solid var(--line-strong); outline-offset: 1px; } diff --git a/src/pkg/dashboard/static-src/js/tracker-filter-render.js b/src/pkg/dashboard/static-src/js/tracker-filter-render.js index 42397a752f..eec8afd7ff 100644 --- a/src/pkg/dashboard/static-src/js/tracker-filter-render.js +++ b/src/pkg/dashboard/static-src/js/tracker-filter-render.js @@ -89,7 +89,8 @@ // 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/pkg/dashboard/static-src/js/tracker-preparation.js b/src/pkg/dashboard/static-src/js/tracker-preparation.js index d75227f867..b810e82e40 100644 --- a/src/pkg/dashboard/static-src/js/tracker-preparation.js +++ b/src/pkg/dashboard/static-src/js/tracker-preparation.js @@ -1,4 +1,5 @@ - // 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 = []; @@ -14,7 +15,7 @@ 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); @@ -26,6 +27,44 @@ } 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); @@ -100,20 +139,20 @@ 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) { @@ -169,8 +208,9 @@ 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' : '') @@ -200,14 +240,16 @@ && 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 + `
${esc(parts.join(' · '))}
`; } 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(); diff --git a/src/pkg/dashboard/static-src/js/tracker-row-layout.js b/src/pkg/dashboard/static-src/js/tracker-row-layout.js index 5472cb549a..9a18548399 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row-layout.js +++ b/src/pkg/dashboard/static-src/js/tracker-row-layout.js @@ -237,12 +237,12 @@ `; } return `
- ${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) : ''))}
+ ${typeof stageTrackerPreparationNodeHtml === 'function' ? stageTrackerPreparationNodeHtml(pr, stages, ctx) : ''}
    ${stageTrackerStripItems(pr, stages, { from: STAGE_TRACKER_PR_COLUMN }, nowMs, ctx)}
${stageTrackerSinceHtml(pr, nowMs)}
diff --git a/src/pkg/dashboard/static-src/js/tracker-row-render.js b/src/pkg/dashboard/static-src/js/tracker-row-render.js index 9ae7da4494..ee8a699d9e 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row-render.js +++ b/src/pkg/dashboard/static-src/js/tracker-row-render.js @@ -159,12 +159,12 @@ 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} diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 75ba494323..a5133153cc 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -1543,13 +1543,20 @@ .ham-row.ham-train-front::after { background: var(--text); } .ham-train-head + .ham-row.ham-train { border-top: 0; } .ham-preparation-head { flex-wrap: wrap; } + .ham-row.ham-preparation-member::before { top: calc(-1 * var(--line-width)); } + .ham-row.ham-preparation-member.ham-train-last::before { bottom: 0; } + .ham-row.ham-preparation-member::after { display: none; } .ham-preparation-head .ham-train-chip { white-space: normal; } .ham-preparation-head .ham-preparation-help { background: none; border-color: var(--ham-train-accent); color: var(--muted); } .ham-preparation-help::before { content: '?'; } - .config-info.ham-preparation-node { position: absolute; left: calc(var(--sp-2) - 2px); top: calc(50% - var(--sp-2)); width: calc(var(--sp-2) * 2); height: calc(var(--sp-2) * 2); margin: 0; padding: 0; border: 0; background: transparent; z-index: 1; } + .config-info.ham-preparation-node { position: absolute; left: calc(var(--sp-2) - 2px); top: 50%; transform: translateY(-50%); width: calc(var(--sp-2) * 2); height: calc(var(--sp-2) * 2); margin: 0; padding: 0; border: 0; background: transparent; z-index: 1; } + .ham-row.ham-preparation-member > .ham-strip-row > .ham-preparation-node { left: calc(var(--sp-2) - var(--sp-5) - 2px); } + .ham-preparation-node::before { content: none; } + .ham-preparation-node::after { content: ''; position: absolute; left: 1px; top: calc(50% - 3px); width: 6px; height: 6px; border-radius: var(--r-pill); background: var(--ham-train-accent); } + .ham-train-front > .ham-strip-row > .ham-preparation-node::after { background: var(--text); } .ham-preparation-node:focus-visible { outline: var(--focus-ring-width) solid var(--ham-train-accent); outline-offset: var(--sp-1); } .ham-row.ham-preparation-gap::before, .ham-sub.ham-preparation-member.ham-preparation-gap::before { border-left-style: dashed; } - .ham-row.ham-preparation-unverified::after, .ham-sub.ham-preparation-member.ham-preparation-unverified::after { background: var(--bg); box-shadow: 0 0 0 var(--line-width) var(--ham-train-accent); } + .ham-preparation-unverified > .ham-strip-row > .ham-preparation-node::after { background: var(--bg); box-shadow: 0 0 0 var(--line-width) var(--ham-train-accent); } .ham-preparation-comment { animation: none; } .ham-human-context { animation: none; } /* Mixed issue trees keep their existing children; only actual prep PRs @@ -1557,10 +1564,9 @@ .ham-row > .ham-preparation-head { margin-left: calc(-1 * var(--sp-2)); } .ham-sub.ham-preparation-member { position: relative; --ham-train-accent: var(--amber); } .ham-sub.ham-preparation-member::before { content: ''; position: absolute; left: 2px; top: calc(-1 * var(--sp-3) - var(--sp-2)); bottom: 0; border-left: var(--line-width) solid var(--ham-train-accent); } - .ham-sub.ham-preparation-member.ham-train-last::before { bottom: 50%; } - .ham-sub.ham-preparation-member::after { content: ''; position: absolute; left: -1px; top: calc(50% - 3px); width: 6px; height: 6px; border-radius: var(--r-pill); background: var(--ham-train-accent); } - .ham-sub.ham-preparation-member.ham-train-front::after { background: var(--text); } + .ham-sub.ham-preparation-member.ham-train-last::before { bottom: 0; } .ham-sub .config-info.ham-preparation-node { left: calc(-1 * var(--sp-1)); } + .ham-sub .ham-preparation-node::after { left: 3px; } .ham-group-toggle { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 1.4em; height: 1.4em; padding: 0; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font: inherit; cursor: pointer; } .ham-group-toggle:hover { color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); } .ham-group-toggle:focus-visible { outline: var(--focus-ring-width) solid var(--line-strong); outline-offset: 1px; } @@ -18350,12 +18356,12 @@

Where to get help

`; } return `
- ${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) : ''))}
+ ${typeof stageTrackerPreparationNodeHtml === 'function' ? stageTrackerPreparationNodeHtml(pr, stages, ctx) : ''}
    ${stageTrackerStripItems(pr, stages, { from: STAGE_TRACKER_PR_COLUMN }, nowMs, ctx)}
${stageTrackerSinceHtml(pr, nowMs)}
@@ -18656,12 +18662,12 @@

Where to get help

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 + `
${esc(parts.join(' · '))}
`; } 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 }; +}