diff --git a/changelog.d/fixed-preparation-inline-train.md b/changelog.d/fixed-preparation-inline-train.md new file mode 100644 index 0000000000..5cf6bca50a --- /dev/null +++ b/changelog.d/fixed-preparation-inline-train.md @@ -0,0 +1 @@ +- Restore the Activity Monitor's compact preparation train pill and side rail on actual tracker rows, retaining live pipeline comments without changing stages, sorting, linked trees, or ready/native queue membership. diff --git a/src/docs/dashboard.md b/src/docs/dashboard.md index 297cba3452..711f5598f6 100644 --- a/src/docs/dashboard.md +++ b/src/docs/dashboard.md @@ -2,58 +2,37 @@ ## Base preparation visibility -A directly visible **Preparation queue** overview above the pipeline reuses the -train's rail, marker and header styling without seating preparation work in a -ready merge train. A confirmed owner reads **Preparing** and confirmed waiters -are numbered in durable FIFO order of first qualifying admission, not PR -creation time or number. This is preparation order, not guaranteed merge order: -independently ready PRs may merge, invalid tickets can leave, and changed work -may qualify again at the end of the FIFO. - -The overview contains references to the actual PR rows, not copied or reparented -pipeline rows. Existing custom sorts, filters, pages, collapsed repo groups and -multiple-PR issue trees remain unchanged. Only PRs actually drawn on the current -page receive a rail entry; missing members are explicitly identified as on -another page/collapsed repo or hidden by the current filters. A member can keep -its true waiting ordinal when earlier confirmed members are not on the page. -Redundant preparation/behind-owner pills are suppressed only on PRs visibly -represented by that rail. Outside it the existing pills remain useful fallbacks; -unverified warnings and real CI / Review / held signals are never suppressed. -The gold header chip/popover no longer repeats preparation counts or tickets -when the rail is present, and is hidden when no genuine ready train exists. -Distinct ready-train information remains available in its existing train view -and ready-only queue popover; preparation is never promoted into those seats. - -Unverified recorded owners or tickets have a separate, unnumbered note. An -unverified waiting ticket prevents confirming the ordinal of later tickets; -their relative FIFO order remains visible but their position reads unverified. -No old admission-head proof is transferred to a refreshed head. Tooltips explain -the distinction from review approval, readiness and native queue membership. -The rail uses a labelled region/list, ordinary links, existing theme tokens, -and static markers with no animation (including reduced-motion mode). It reads -the existing cached tracker payload and adds no polling or store reads. - -The Activity Monitor's existing **Merge queue** chip also shows durable base -preparation tickets for repositories using the current-base gate, even when no -ready merge train exists. Its popover distinguishes the recorded owner from FIFO -waiting tickets and shows their admitted head, current snapshot head, ticket age, -and the existing pipeline caption when those heads match. Matching PR rows gain -**Preparing base** or **Waiting for preparation behind #N** annotations; their -underlying CI / Review stages do not change. - -The waiting count includes only open PR snapshots with matching ticket heads. -Known closed, merged, held, draft, or expired tickets are inactive and excluded -from the displayed queue and active count; unmatched tickets remain explicitly -unverified, not active waiters. Persisted FIFO ticket order is not a promise of -actual merge order. - -These are persisted lifecycle observations, not proof of green exact-head CI, -review approval, a ready train seat, or GitHub native queue membership. Changed -heads, held/draft/expired tickets, absent PRs, and unreadable/missing preparation -state are explicitly unverified or inactive. An owner may legitimately have a -different head after a refresh; this read-only view does not certify that change. -The existing tracker cache and refresh paths update this view; opening it never -admits, expires, or promotes work. +The Activity Monitor shows a compact **Preparation train** pill directly above +the actual tracker items and the original train's thin gold side rail through +their rows. Existing train styling and theme tokens supply its spacing, border, +markers and font. A white marker identifies an exact-current preparation owner; +an outlined marker identifies unverified observations. Neither changes CI / +Review chevrons or creates a ready or native queue seat. + +Subdued comments inside the corresponding PR row retain the current pipeline +caption and add base-refresh context, known ticket age, and the hosting issue +when nested. Redundant preparation-owner and waiting-behind badges are suppressed +only where that inline context is actually rendered. Other review, CI, hold and +ready-train signals remain unchanged. The gold ready-queue popover does not +duplicate preparation information; native observations stay separate. + +Preparation FIFO follows first qualifying admission, not PR creation time or +number. Sorts, filters, pagination, collapsed repositories and linked issue trees +are unchanged: a rail ends before unrelated or backwards-ordered items, with a +continuation pill when the group resumes. A dashed rail marks missing FIFO +members or linked-child order that differs from FIFO. Mixed issue trees mark +only the actual preparation children, without moving or copying them. + +Keyboard-focusable and hoverable node/header help provides exact identities, +snapshot time when known, admission versus current heads, unverified positions, +and off-page/filtered members. Unknown predecessors prevent confirmed waiting +ordinals. Unreadable snapshots explicitly say unavailable, not zero work. +Omitted preparation policy adds no train; inactive tickets are excluded. + +These are read-only lifecycle observations, not review approval, green exact-head +CI or guaranteed merge order. Refreshed heads receive no old-head proof. The +existing tracker cache and refresh paths update comments and rail membership; +the view adds no polling, animation, admission, expiration or promotion. The spoke dashboard is the operator UI served from `src/pkg/dashboard/static/index.html`. That file is **generated**: edit the diff --git a/src/pkg/dashboard/stage_tracker_preparation_visual.test.js b/src/pkg/dashboard/stage_tracker_preparation_visual.test.js index a9e693385d..ccd03b6a3e 100644 --- a/src/pkg/dashboard/stage_tracker_preparation_visual.test.js +++ b/src/pkg/dashboard/stage_tracker_preparation_visual.test.js @@ -1,5 +1,4 @@ -// Execute the shipped preparation projection/rendering helpers in CI. The -// pipeline owns filtering/sorting/paging; the rail only references its result. +// CI exercises the shipped projection and actual root/nested row renderers. const test = require('node:test'); const assert = require('node:assert/strict'); const fs = require('node:fs'); @@ -7,7 +6,8 @@ const path = require('node:path'); const vm = require('node:vm'); const source = name => fs.readFileSync(path.join(__dirname, 'static-src/js', name + '.js'), 'utf8'); const fn = (file, name) => { - const found = source(file).match(new RegExp('function ' + name + '\\([^\\n]*\\) \\{[\\s\\S]*?\\n \\}')); + const found = source(file).match(new RegExp('function ' + name + '\\([^\\n]*\\) \\{[^\\n]*\\}\\s*(?:\\n|$)')) + || source(file).match(new RegExp('function ' + name + '\\([^\\n]*\\) \\{[\\s\\S]*?\\n \\}')); assert.ok(found, name); return found[0]; }; @@ -17,15 +17,30 @@ const esc = value => String(value).replace(/[&<>"']/g, ch => ({ '&': '&', '< const plain = value => JSON.parse(JSON.stringify(value)); function load() { - const region = { hidden: true, innerHTML: '' }; const elements = new Map(); - let present = true; - const ctx = vm.createContext({ console, Date, esc, - document: { getElementById: id => id === 'activity-monitor-preparation' ? present ? region : null : elements.get(id) || null }, + const ctx = vm.createContext({ + console, Date, esc, document: { getElementById: id => elements.get(id) || null }, + STAGE_TRACKER_TERMINAL: 100, STAGE_TRACKER_PR_COLUMN: 40, + STAGE_TRACKER_LINKED_GLYPH: '↳', + STAGE_TRACKER_SOFT_LINK_TIP: 'soft link', stageTrackerAnchor: stage => Number(stage) || 0, - stageTrackerAttentionTier: () => 1, - stageTrackerNormalizeFilter: f => f, - STAGE_TRACKER_TERMINAL: 100, + stageTrackerLeadStage: it => it.stage, + stageTrackerAttentionTier: () => 1, stageTrackerNormalizeFilter: f => f, + stageTrackerTrainKey: it => it && it.merge_train ? it.merge_train.id : '', + stageTrackerTrainRowClass: it => it.merge_train ? ' ham-train ham-train-k0' : '', + stageTrackerPRRef: (n, url, kind, author, title) => `#${n} ${esc(title || '')}`, + stageTrackerPRPillsHtml: ref => ref, + stageTrackerTitleHtml: title => `${esc(title)}`, + stageTrackerTooltip: it => it.caption || '', + stageTrackerLinkedTip: () => 'linked PR', + stageTrackerIcon: () => '', + stageTrackerActedBadgeHtml: () => '', + stageTrackerRowToolsHtml: () => '', + stageTrackerMoveAttrs: () => '', + stageTrackerSinceHtml: () => '', + stageTrackerCurrentStageHtml: it => `${it.stage}`, + stageTrackerStripItems: (it, stages, range) => `
  • `, + stageTrackerEventHtml: (key, near) => near && near.events && near.events[key] ? `

    ${esc(near.events[key].text)}

    ` : '', }); const core = source('tracker-words-core'); for (const name of ['STAGE_TRACKER_TRAIN_ICON_PATH', 'STAGE_TRACKER_TRAIN_ICON_TITLE', 'STAGE_TRACKER_TRAIN_ACCENTS']) { @@ -34,277 +49,315 @@ function load() { vm.runInContext(found[0], ctx); } for (const name of ['stageTrackerTrainIconHtml', 'stageTrackerTrainAccentClass', 'stageTrackerOrdinal']) vm.runInContext(fn('tracker-words-core', name), ctx); - for (const name of ['stageTrackerLinkedSuperseder', 'stageTrackerLinkedSupersededGone']) vm.runInContext(fn('tracker-words-gate', name), ctx); - for (const name of ['stageTrackerLinkedPRItem', 'stageTrackerLinkedPROpen', 'stageTrackerLinkedDrawnHere', 'stageTrackerLinkedSorted', 'stageTrackerAdoptOrphanPRs']) vm.runInContext(fn('tracker-row-layout', name), ctx); + for (const name of ['stageTrackerLinkedSuperseder', 'stageTrackerLinkedSupersededGone', 'stageTrackerLinkedSupersededText', 'stageTrackerLinkedSupersededTip']) vm.runInContext(fn('tracker-words-gate', name), ctx); + for (const name of ['stageTrackerPRKey', 'stageTrackerItemKey', 'stageTrackerRowPRKeys']) vm.runInContext(fn('tracker-merged', name), ctx); + for (const name of ['stageTrackerLinkedPRItem', 'stageTrackerLinkedPROpen', 'stageTrackerLinkedDrawnHere', 'stageTrackerLinkedSorted', 'stageTrackerAdoptOrphanPRs', 'stageTrackerHeadColsHtml', 'stageTrackerSubRowHtml', 'stageTrackerRowHtml']) vm.runInContext(fn('tracker-row-layout', name), ctx); for (const name of ['stageTrackerPreparationWord', 'stageTrackerPreparationAge', 'stageTrackerPreparationChipHtml']) vm.runInContext(fn('tracker-queue', name), ctx); - for (const name of ['stageTrackerSort', 'stageTrackerPage']) vm.runInContext(fn('tracker-filter', name), ctx); + for (const name of ['stageTrackerSort', 'stageTrackerPage', 'stageTrackerPRIssueSlot']) vm.runInContext(fn('tracker-filter', name), ctx); + ctx.stageTrackerChipsHtml = item => ctx.stageTrackerPreparationChipHtml(item); vm.runInContext(source('tracker-preparation'), ctx); - return { ctx, region, elements, removeRegion() { present = false; } }; + return { ctx, elements }; } function fixture() { const pr = (number, stage, caption) => ({ kind: 'pr', repo: REPO, number, stage, caption, state: 'open', head: 'head-' + number, base_ref: 'v5', title: 'PR ' + number, url: 'https://github.com/' + REPO + '/pull/' + number, created_at: '2026-10-30T00:00:00Z' }); - const owner = pr(45, 70, 'Review · no free reviewer'); + const owner = pr(45, 70, 'Review swarm requested; waiting for a verdict on the current head'); const first = pr(9, 50, 'CI · checks pending'); const second = pr(2, 70, 'Review · exact-head bundle pending'); const ticket = (it, role) => ({ role, number: it.number, state: 'current', head_sha: it.head, current_head: it.head, since: '2026-10-31T00:30:00Z', pipeline: it.caption, detail: 'Ticket matches the current open PR snapshot', ...(role === 'waiting' ? { behind: owner.number } : {}) }); - const q = { repo: REPO, base_ref: 'v5', state: 'observed', owner: ticket(owner, 'owner'), waiting: [ticket(first, 'waiting'), ticket(second, 'waiting')] }; - owner.preparation = q.owner; - first.preparation = q.waiting[0]; - second.preparation = q.waiting[1]; + const q = { repo: REPO, base_ref: 'v5', state: 'observed', observed_at: '2026-10-31T00:59:00Z', + owner: ticket(owner, 'owner'), waiting: [ticket(first, 'waiting'), ticket(second, 'waiting')] }; + owner.preparation = q.owner; first.preparation = q.waiting[0]; second.preparation = q.waiting[1]; return { owner, first, second, q, data: { items: [second, first, owner], base_preparation: [q] } }; } +function render(ctx, f, page = f.data.items, listed = page, events = {}) { + ctx.stageTrackerPreparationVisualSync(f.data, listed, page, [], NOW); + const items = ctx.stageTrackerAdoptOrphanPRs(page); + const rows = items.map((item, i) => ({ key: ctx.stageTrackerItemKey(item), + html: ctx.stageTrackerRowHtml(item, [], { nowMs: NOW, events, prevRow: items[i - 1], nextRow: items[i + 1] }) })); + return plain(ctx.stageTrackerPreparationInlineRows(rows, items, [])); +} +function content(rows) { return rows.map(row => row.html).join(''); } +function rootKeys(rows) { return rows.filter(row => !row.key.startsWith('preparation')).map(row => row.key); } +function rootRow(rows, number, kind = 'pr') { + const row = rows.find(row => row.key === REPO + '/' + kind + '#' + number); + assert.ok(row, 'actual ' + kind + ' row #' + number); + return row; +} function model(ctx, f, listed = f.data.items, page = listed) { return ctx.stageTrackerPreparationVisualModel(f.data, listed, page, []); } -test('owner first and persisted FIFO, not PR number/age, with original stages and train facts unchanged', () => { - const { ctx } = load(), f = fixture(); - f.owner.merge_train = { id: 'real-ready-train', position: 2 }; - f.first.created_at = '2020-01-01T00:00:00Z'; - const before = plain(f.data); - const groups = model(ctx, f), html = ctx.stageTrackerPreparationVisualHtml(groups, NOW); - assert.equal(groups[0].owner.ticket.number, 45); - assert.deepEqual(plain(groups[0].waiting.map(e => [e.ticket.number, e.position])), [[9, 1], [2, 2]]); - assert.ok(html.indexOf('Preparing') < html.indexOf('Waiting 1st for preparation')); - assert.ok(html.indexOf('Waiting 1st for preparation') < html.indexOf('Waiting 2nd for preparation')); - assert.match(html, /Review · no free reviewer/); - assert.match(html, /CI · checks pending/); - assert.match(html, /ticket age 30m/); - assert.match(html, /not guaranteed merge order/); +test('original compact pill and connector decorate actual rows with FIFO help and live comments, not copied cards', () => { + const { ctx } = load(), f = fixture(), before = plain(f.data); + const rows = render(ctx, f, [f.owner, f.first, f.second]), html = content(rows); + assert.deepEqual(rootKeys(rows), [45, 9, 2].map(n => REPO + '/pr#' + n)); + assert.equal(rows[0].key, 'preparation:' + REPO + '/pr#45'); + assert.match(rows[0].html, /ham-train-head ham-train-k3 ham-preparation-head/); + assert.match(rows[0].html, /ham-train-chip.*Preparation train · 3 PRs · front: #45/); + assert.match(rows[1].html, /class="ham-row ham-train ham-train-k3 ham-preparation-member ham-train-front"/); + assert.match(rows[2].html, /class="ham-row ham-train ham-train-k3 ham-preparation-member"/); + assert.match(rows[3].html, /ham-train-last/); + assert.match(rows[1].html, /data-ham-stage="70"/); + assert.match(rows[2].html, /data-ham-stage="50"/); + assert.match(rows[2].html, /CI · checks pending · queued for base refresh behind PR #45 · ticket age 30m/); + assert.match(rows[1].html, /Review swarm requested; waiting for a verdict on the current head · preparing base/); + assert.match(rows[3].html, /Waiting 2nd for preparation/); + assert.doesNotMatch(html, /
  • { - const { ctx, region } = load(), f = fixture(); - ctx.stageTrackerPreparationVisualSync(f.data, f.data.items, f.data.items, [], NOW); +test('actual custom sorts, pagination and stage ranges are unchanged; backwards order starts separate runs', () => { + 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 before = plain(page), rows = render(ctx, f, page.rows, ordered); + 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(plain(model(ctx, f)[0].waiting.map(e => [e.ticket.number, e.position])), [[9, 1], [2, 2]]); +}); + +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 }; + f.data.items.push(other); + let rows = render(ctx, f, [f.owner, other, f.first, f.second]); + assert.match(rootRow(rows, 45).html, /ham-train-last/); + assert.doesNotMatch(rootRow(rows, 80).html, /ham-preparation-member|ham-preparation-node/); + assert.equal(rows.filter(row => row.key.startsWith('preparation:')).length, 2); + rows = render(ctx, f, [f.owner, f.second], [f.owner, f.second]); + assert.match(rootRow(rows, 2).html, /ham-preparation-gap/); + assert.match(rows[0].html, /2 of 3 PRs here/); + assert.match(rows[0].html, /#9 · Waiting 1st for preparation · hidden by filters/); + assert.deepEqual(rootKeys(rows), [45, 2].map(n => REPO + '/pr#' + n)); +}); + +test('off-page owner remains truthful in compact header/help with real waiting ordinal', () => { + const { ctx } = load(), f = fixture(); + const rows = render(ctx, f, [f.second], [f.owner, f.second]); + assert.match(rows[0].html, /1 of 3 PRs here · front: #45/); + assert.match(rows[0].html, /#45 · Preparing · another page or collapsed repo/); + assert.match(rows[1].html, /Waiting 2nd for preparation/); + assert.equal(rootKeys(rows).length, 1); +}); + +test('release/handoff clears former owner decoration and pill suppression; readmission preserves durable FIFO', () => { + const { ctx } = load(), f = fixture(); + render(ctx, f); assert.equal(ctx.stageTrackerPreparationChipHtml(f.first), ''); f.q.owner = { ...f.first.preparation, role: 'owner' }; f.first.preparation = f.q.owner; f.q.waiting = [f.second.preparation]; f.second.preparation.behind = f.first.number; - f.data.items = [f.first, f.second, f.owner]; - ctx.stageTrackerPreparationVisualSync(f.data, f.data.items, f.data.items, [], NOW); - assert.match(region.innerHTML, />#9 PR 9<\/a>/); - assert.doesNotMatch(region.innerHTML, /Owner #45|Waiting 2nd/); + const rows = render(ctx, f, [f.first, f.second, f.owner]); + assert.match(rows[0].html, /front: #9/); + assert.doesNotMatch(rootRow(rows, 45).html, /ham-preparation-member/); assert.equal(ctx.stageTrackerPreparationRepresented(f.owner), false); - assert.match(ctx.stageTrackerPreparationChipHtml(f.owner), /Preparing base/); - assert.equal(f.first.stage, 50); - assert.equal(f.second.stage, 70); -}); - -test('inactive merged/held/expired tickets are excluded and readmission uses new FIFO order', () => { - const { ctx } = load(), f = fixture(); - f.q.waiting.unshift(...['merged', 'held', 'expired'].map((detail, i) => ({ number: 100 + i, role: 'waiting', state: 'inactive', detail }))); - let groups = model(ctx, f); - assert.equal(groups[0].inactive, 3); - assert.deepEqual(plain(groups[0].waiting.map(e => e.position)), [1, 2]); - const html = ctx.stageTrackerPreparationVisualHtml(groups, NOW); - assert.match(html, /3 inactive tickets excluded/); - assert.doesNotMatch(html, /#100|#101|#102/); - f.q.waiting = [f.second.preparation, f.first.preparation]; - groups = model(ctx, f); - assert.deepEqual(plain(groups[0].waiting.map(e => [e.ticket.number, e.position])), [[2, 1], [9, 2]]); + f.q.waiting.push({ ...f.owner.preparation, role: 'waiting', behind: 9 }); + assert.deepEqual(plain(model(ctx, f)[0].waiting.map(e => e.ticket.number)), [2, 45]); }); -test('unverified refreshed owner stays ahead as a warning without old-head pipeline proof', () => { +test('unverified owner gets a hollow node and concise current commentary, never old-head review proof or redundant badge', () => { const { ctx } = load(), f = fixture(); - f.owner.head = 'own-refreshed-head'; - f.q.owner.state = 'unverified'; - f.q.owner.current_head = f.owner.head; + f.owner.head = 'refreshed'; + f.q.owner.state = 'unverified'; f.q.owner.current_head = f.owner.head; f.q.owner.detail = 'Head changed; current preparation unverified'; - f.q.owner.pipeline = 'old-head APPROVED proof'; - const groups = model(ctx, f), html = ctx.stageTrackerPreparationVisualHtml(groups, NOW); - assert.equal(groups[0].owner, null); - assert.equal(groups[0].unverified[0].ticket.number, 45); - assert.ok(html.indexOf('Unverified recorded owner #45') < html.indexOf('Waiting 1st')); - assert.doesNotMatch(html, /old-head APPROVED proof/); - assert.match(ctx.stageTrackerPreparationChipHtml(f.owner), /unverified/); -}); - -test('unknown predecessor prevents fabricated exact ranks for subsequent confirmed tickets', () => { - const { ctx } = load(), f = fixture(); - f.q.waiting.unshift({ number: 77, role: 'waiting', state: 'unverified', head_sha: 'missing', detail: 'Not in current tracker snapshot' }); - const groups = model(ctx, f), html = ctx.stageTrackerPreparationVisualHtml(groups, NOW); - assert.deepEqual(plain(groups[0].waiting.map(e => e.position)), [0, 0]); - assert.match(html, /position unverified/); - assert.match(html, /Unverified recorded ticket #77/); - assert.doesNotMatch(html, /Waiting 1st|Waiting 2nd/); + f.q.owner.pipeline = 'OLD HEAD APPROVED'; + const rows = render(ctx, f, [f.owner, f.first, f.second]); + assert.match(rows[0].html, /2 confirmed PRs · recorded front: #45/); + assert.match(rows[1].html, /ham-preparation-unverified/); + assert.doesNotMatch(rows[1].html, /ham-train-front|OLD HEAD APPROVED| { +test('unknown predecessor and exact repo/base/head mismatches never fabricate confirmed positions', () => { for (const change of [ - f => { f.first.head = 'new-head'; }, - f => { f.first.base_ref = 'different-base'; }, - f => { f.first.repo = 'someone/else'; }, - f => { f.first.preparation.current_head = 'different-current-head'; }, + f => { f.first.head = 'new-head'; }, f => { f.first.base_ref = 'other'; }, + f => { f.first.repo = 'someone/else'; }, f => { f.first.preparation.current_head = 'other'; }, f => { f.data.items = [f.owner, f.second]; }, ]) { - const { ctx } = load(), f = fixture(); - change(f); - const groups = model(ctx, f), html = ctx.stageTrackerPreparationVisualHtml(groups, NOW); - assert.ok(groups[0].unverified.some(e => e.ticket.number === f.first.number)); - assert.equal(groups[0].waiting[0].position, 0); - assert.doesNotMatch(html, /CI · checks pending/); + const { ctx } = load(), f = fixture(); change(f); + const group = model(ctx, f)[0]; + assert.ok(group.unverified.some(e => e.ticket.number === 9)); + assert.equal(group.waiting[0].position, 0); + assert.match(content(render(ctx, f)), /Waiting for preparation · position unverified/); } }); -test('filters and pagination preserve FIFO ordinals but never draw absent members as visible seats', () => { - const { ctx } = load(), f = fixture(); - const groups = model(ctx, f, [f.owner, f.second], [f.second]); - const html = ctx.stageTrackerPreparationVisualHtml(groups, NOW); - assert.equal(groups[0].owner.location, 'offpage'); - assert.deepEqual(plain(groups[0].waiting.map(e => [e.location, e.position])), [['filtered', 1], ['page', 2]]); - assert.match(html, /1 of 3 confirmed tickets shown/); - assert.match(html, /On another page or in a collapsed repo: Preparing #45/); - assert.match(html, /Not shown by the current filters: Waiting 1st for preparation #9/); - assert.equal((html.match(/
  • /); - assert.match(html, /Owner #45/); -}); - -test('actual number/custom sorting and page slice remain unchanged by the rail', () => { - const { ctx } = load(), f = fixture(); - const ordered = ctx.stageTrackerSort(f.data.items, [], { sort: 'number', dir: 'desc' }); - const page = ctx.stageTrackerPage(ordered, { size: 25, page: 1 }); - const before = plain(page); - const groups = model(ctx, f, ordered, page.rows); - ctx.stageTrackerPreparationVisualHtml(groups, NOW); - assert.deepEqual(plain(page), before); - assert.deepEqual(plain(page.rows.map(it => it.number)), [45, 9, 2]); - assert.deepEqual(plain(groups[0].waiting.map(e => e.ticket.number)), [9, 2]); - assert.deepEqual(plain(f.data.items.map(it => it.stage)), [70, 50, 70]); +test('inactive, closed, held and draft candidates do not become active rail members', () => { + for (const change of [ + f => { f.q.waiting[0].state = 'inactive'; }, + f => { f.first.state = 'closed'; }, f => { f.first.hold = { reason: 'human' }; }, + f => { f.first.modifiers = ['draft']; }, + ]) { + const { ctx } = load(), f = fixture(); change(f); + const group = model(ctx, f)[0]; + assert.equal(group.inactive, 1); + assert.deepEqual(plain(group.waiting.map(e => [e.ticket.number, e.position])), [[2, 1]]); + const rows = render(ctx, f); + assert.doesNotMatch(rootRow(rows, 9).html, /ham-preparation-member/); + } }); -test('linked multiple PRs and shared issue trees are referenced once without reparenting rows', () => { +test('multiple/shared issue trees keep their actual nested rows and PR stages without duplication or reparenting', () => { const { ctx } = load(), f = fixture(); - const issue = { kind: 'issue', repo: REPO, number: 500, stage: 40, + const issue = { kind: 'issue', repo: REPO, number: 500, stage: 40, title: 'linked issue', linked_prs: [{ ...f.first, drawn_under: 500 }, { ...f.second, drawn_under: 500 }] }; const other = { ...issue, number: 501, linked_prs: issue.linked_prs.map(lp => ({ ...lp })) }; f.data.items = [issue, other, f.owner]; - const before = plain(f.data); - const groups = model(ctx, f), html = ctx.stageTrackerPreparationVisualHtml(groups, NOW); - assert.equal(groups[0].waiting.length, 2); - assert.deepEqual(plain(groups[0].waiting.map(e => e.row.host.number)), [500, 500]); - assert.equal((html.match(/
  • { +test('mixed linked trees mark only preparation children and stop before an unrelated child', () => { const { ctx } = load(), f = fixture(); - const stale = { kind: 'issue', repo: REPO, number: 500, linked_prs: [{ ...f.first, head: 'old-linked-head' }] }; - f.data.items.push(stale); - const groups = model(ctx, f, [stale], [stale]); - assert.ok(groups[0].unverified.some(e => e.ticket.number === f.first.number)); - assert.equal(groups[0].waiting.some(e => e.ticket.number === f.first.number), false); + const unrelated = { ...f.first, number: 80, stage: 60, preparation: null, head: 'other' }; + const issue = { kind: 'issue', repo: REPO, number: 500, stage: 40, linked_prs: [f.first, unrelated, f.second] }; + f.data.items = [issue, f.owner]; + const html = content(render(ctx, f)); + assert.equal((html.match(/data-ham-sub-key="/g) || []).length, 3); + assert.match(html, /
    { - const { ctx, region, removeRegion } = load(), f = fixture(); - assert.match(ctx.stageTrackerPreparationChipHtml(f.first), /Waiting for preparation behind #45/); - ctx.stageTrackerPreparationVisualSync(f.data, [f.first], [f.first], [], NOW); - assert.equal(ctx.stageTrackerPreparationChipHtml(f.first), ''); - assert.match(ctx.stageTrackerPreparationChipHtml(f.second), /Waiting for preparation behind #45/); - assert.match(ctx.stageTrackerPreparationChipHtml(f.owner), /Preparing base/); - assert.equal(f.first.stage, 50); - assert.match(region.innerHTML, /Waiting 1st for preparation/); - f.first.preparation.state = 'unverified'; - assert.match(ctx.stageTrackerPreparationChipHtml(f.first), /unverified/); - f.first.preparation.state = 'current'; - f.first.head = 'changed-after-render'; - assert.match(ctx.stageTrackerPreparationChipHtml(f.first), /Waiting for preparation/); - f.first.head = f.first.preparation.head_sha; - removeRegion(); - ctx.stageTrackerPreparationVisualSync(f.data, f.data.items, f.data.items, [], NOW); - assert.match(ctx.stageTrackerPreparationChipHtml(f.first), /Waiting for preparation behind #45/); +test('single covering PR retains the original issue stage and PR-driven strip; its queue note names the actual issue', () => { + const { ctx } = load(), f = fixture(); + const issue = { kind: 'issue', repo: REPO, number: 500, stage: 40, linked_prs: [f.first] }; + f.data.items = [issue, f.owner, f.second]; + const html = rootRow(render(ctx, f), 500, 'issue').html; + assert.match(html, /data-ham-kind="issue".*data-ham-stage="40"/); + assert.match(html, /data-stage="50"/); + assert.match(html, /shown under issue #500/); + assert.doesNotMatch(html, /data-ham-sub-key=| { +test('still-rendered closed children prevent a parent rail through unrelated work', () => { const { ctx } = load(), f = fixture(); - const issue = { kind: 'issue', repo: REPO, number: 500, linked_prs: [{ ...f.first }] }; + const closed = { ...f.first, number: 80, stage: 75, state: 'closed', head: 'closed', preparation: null, superseded_by: f.first.number }; + const issue = { kind: 'issue', repo: REPO, number: 500, stage: 40, linked_prs: [f.first, closed] }; f.data.items = [issue, f.owner, f.second]; - ctx.stageTrackerPreparationVisualSync(f.data, f.data.items, f.data.items, [], NOW); - const shown = { ...issue, via_pr: true, preparation: f.first.preparation, head: f.first.head, stage: f.first.stage, hold: { reason: 'needs human' }, caption: f.first.caption }; - assert.equal(ctx.stageTrackerPreparationChipHtml(shown), ''); - assert.equal(shown.stage, 50); - assert.deepEqual(shown.hold, { reason: 'needs human' }); - assert.equal(shown.caption, 'CI · checks pending'); - shown.preparation = { ...shown.preparation, state: 'unverified' }; - assert.match(ctx.stageTrackerPreparationChipHtml(shown), /unverified/); + const html = rootRow(render(ctx, f), 500, 'issue').html; + assert.match(html, /
    { + const { ctx } = load(), f = fixture(); + f.owner.merge_train = { id: 'real-ready', position: 2 }; + const before = plain(f.data), rows = render(ctx, f), owner = rootRow(rows, 45); + assert.match(owner.html, /class="ham-row ham-train ham-train-k0"/); + assert.match(owner.html, /data-ham-train="real-ready"/); + assert.doesNotMatch(owner.html, /ham-train-k3|ham-preparation-member/); + assert.match(owner.html, /preparing base/); + assert.deepEqual(plain(f.data), before); + const filter = source('tracker-filter-render'); + assert.match(filter, /stageTrackerNativeQueueSync/); + assert.match(filter, /stageTrackerTrainContiguous\(stageTrackerSort/); }); -test('inactive policy hides the rail; unavailable/loading state is explicit and clears pill suppression', () => { - const { ctx, region } = load(), f = fixture(); - ctx.stageTrackerPreparationVisualSync(f.data, f.data.items, f.data.items, [], NOW); +test('comments dedupe current captions, retain current event detail, and use no synthetic event timestamp', () => { + const { ctx } = load(), f = fixture(), key = ctx.stageTrackerItemKey(f.first); + const events = { [key]: { text: f.first.caption, who: 'hive', at: NOW - 1000 } }, before = plain(events); + const html = render(ctx, f, [f.first], f.data.items, events)[1].html; + const comment = html.match(/
    .*?<\/div>/)[0]; + assert.doesNotMatch(comment, /CI · checks pending/); + assert.equal((html.match(/CI · checks pending<\/p>/g) || []).length, 1); + assert.match(comment, /ticket age 30m/); + assert.doesNotMatch(comment, /data-at=|data-cue-key=/); + assert.deepEqual(events, before); + f.first.caption = 'CI · failing current check'; + assert.match(content(render(ctx, f, [f.first])), /CI · failing current check · queued for base refresh/); + events[key].text = 'You approved'; + const actionHtml = content(render(ctx, f, [f.first], f.data.items, events)); + assert.match(actionHtml, /

    You approved<\/p>/); + assert.match(actionHtml, /CI · failing current check · queued for base refresh/); +}); + +test('policy omission adds no preparation; read errors and missing snapshots explicitly say unavailable, not zero', () => { + const { ctx } = load(), f = fixture(); + render(ctx, f); f.data.base_preparation = []; - ctx.stageTrackerPreparationVisualSync(f.data, f.data.items, f.data.items, [], NOW); - assert.equal(region.hidden, true); + assert.doesNotMatch(content(render(ctx, f)), /ham-preparation-head|ham-preparation-member/); assert.match(ctx.stageTrackerPreparationChipHtml(f.first), /Waiting for preparation/); delete f.data.base_preparation; assert.deepEqual(plain(model(ctx, f)), []); f.data.base_preparation = [{ repo: REPO, base_ref: 'v5', state: 'unavailable', message: 'durable snapshot read failed' }]; - ctx.stageTrackerPreparationVisualSync(f.data, f.data.items, [], [], NOW); - assert.equal(region.hidden, false); - assert.match(region.innerHTML, /durable snapshot read failed/); + const html = content(render(ctx, f)); + assert.match(html, /Preparation train · unavailable/); + assert.match(html, /durable snapshot read failed/); + assert.doesNotMatch(html, /0 PRs/); ctx.stageTrackerPreparationVisualSync(null, [], [], [], NOW); - assert.match(region.innerHTML, /Preparation queue unavailable/); - assert.doesNotMatch(region.innerHTML, /0 confirmed|

  • { +test('suppression starts only on actual rendered context, clears on handoff, and rejects changed heads', () => { const { ctx } = load(), f = fixture(); - f.first.title = ' & title'; - f.q.waiting[0].pipeline = ''; - const html = ctx.stageTrackerPreparationVisualHtml(model(ctx, f), NOW); - assert.match(html, /aria-label="Preparation queue"/); - assert.match(html, /aria-label="Confirmed preparation order on this page"/); - assert.match(html, /<img onerror="bad">/); - assert.doesNotMatch(html, /'; + f.owner.head = 'changed'; f.q.owner.state = 'unverified'; + const html = content(render(ctx, f)); + assert.match(html, /tabindex="0" data-stop="1" aria-label=/); + assert.match(html, /class="config-tooltip".*role="tooltip"/); + assert.match(html, /<script>bad\(\)<\/script>/); + assert.doesNotMatch(html, /