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, /
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|