From 1293fa2087cd75c197c7bec460d71212c5317329 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Fri, 30 Oct 2026 00:31:05 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20PRs=20at=20CI=20/=20Review=20rid?= =?UTF-8?q?e=20no=20merge=20train;=20header=20counts=20only=20queued=20rid?= =?UTF-8?q?ers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The merge train is a merge-queue concept: only PRs at 080+ ride it. A PR still at CI / Review whose files overlap a queued PR gets a lightweight "overlaps #N — will queue behind it" hint instead of a rail or ordinal. The header counts only the riders in this payload (never the planner's wider grouping — hive's own page read "2 of 9 PRs here · not in this view: 7 more" over two queued PRs), says where undrawn members are (on another page / hidden by the filter / not in this payload), and its hover explains the order: shared files, merge one at a time, each rebased onto the base only after the PR ahead merges; a member reads "Nth of M · after Fixes #15653 Signed-off-by: Andrew Anderson --- ...ixed-merge-train-ci-review-overlap-hint.md | 3 + src/docs/api-reference/dashboard-misc.md | 2 +- src/docs/dashboard-sections.md | 4 +- src/pkg/dashboard/stage_tracker.go | 7 + src/pkg/dashboard/stage_tracker_links.go | 2 +- .../dashboard/stage_tracker_merge_train.go | 249 +++++++++++++----- .../stage_tracker_merge_train_overlap_test.go | 179 +++++++++++++ ...ge_tracker_merge_train_provisional_test.go | 52 +--- .../stage_tracker_merge_train_test.go | 38 ++- .../stage_tracker_overlap_hint.test.js | 78 ++++++ src/pkg/dashboard/static-src/css/tracker.css | 1 + .../dashboard/static-src/js/tracker-filter.js | 2 +- .../dashboard/static-src/js/tracker-row.js | 6 +- .../static-src/js/tracker-words-core.js | 150 +++++++++-- src/pkg/dashboard/static/index.html | 159 +++++++++-- 15 files changed, 752 insertions(+), 180 deletions(-) create mode 100644 changelog.d/fixed-merge-train-ci-review-overlap-hint.md create mode 100644 src/pkg/dashboard/stage_tracker_merge_train_overlap_test.go create mode 100644 src/pkg/dashboard/stage_tracker_overlap_hint.test.js diff --git a/changelog.d/fixed-merge-train-ci-review-overlap-hint.md b/changelog.d/fixed-merge-train-ci-review-overlap-hint.md new file mode 100644 index 0000000000..0780094301 --- /dev/null +++ b/changelog.d/fixed-merge-train-ci-review-overlap-hint.md @@ -0,0 +1,3 @@ +- The Activity Monitor no longer draws a merge train over PRs that are still at CI / Review: the merge train is a merge-queue concept, so only PRs at 080 and beyond ride one and the header counts only them. A PR short of the queue whose files overlap another open PR's now shows a muted "overlaps #N" badge ("overlaps #15637 (sidebar.html, index.html) — will queue behind it") instead of a rail, ordinal or "1st:" header ([#15653](https://github.com/hivecommons/hive/issues/15653)). + +The train header no longer says "not in this view: 7 more" over PRs that were never in the merge queue: `size`/`members` count only the PRs riding in this payload, and when the page does not draw every member the header says why — `on another page: #N`, `hidden by the filter: #N`, `not in this payload: #N`. The header's hover explains the mechanics (members touch the same files, merge one at a time in order, each rebased onto the base only after the PR ahead merges) and a member's hover says its slot, `Position: 3rd of 4 · after #X merges`. diff --git a/src/docs/api-reference/dashboard-misc.md b/src/docs/api-reference/dashboard-misc.md index 622af0a7cb..69d7fc126a 100644 --- a/src/docs/api-reference/dashboard-misc.md +++ b/src/docs/api-reference/dashboard-misc.md @@ -39,7 +39,7 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f | `GET` | `/api/budget-ignore` | Dashboard auth/session | Budget Ignore Get | `pkg/dashboard/api.go:172` | | `POST` | `/api/budget-ignore` | Owner only | Budget Ignore Set | `pkg/dashboard/api.go:173` | | `GET` | `/api/summaries` | Dashboard auth/session | Summaries | `pkg/dashboard/api.go:185` | -| `GET` | `/api/stage-tracker` | Dashboard auth/session | Stage Tracker: every open issue and pull request of the watched repos for the Hive activity monitor — actionable, held, claimed, in-progress, covered-by-PR, filtered (`needs-*`), draft and exempt-labelled items alike, each with `stage`, `stage_since`, `labels`, `created_at`, `author_kind`, `modifiers`, `claimant: {kind: hive-agent|clanker|person, login, agent, hive, since, source: claim-ledger|claim-comment|assignee|kick-history|author}` naming who holds a claimed / in-progress issue or a PR under review or rework (absent when nobody is named; mirrored onto `linked_prs[]`), (PRs) `sentinel_alert` / `sentinel_findings` / `sentinel_reason` when the sentinel flagged the PR, `decision_needed` on a row parked on a person (085 / 045 / 015, the needs-human pill; mirrored onto the issue's `linked_prs[]` entry): `{question, asked_by, since, blocker, blocker_reason, options: [{action, label, enabled, reason_if_disabled}]}` — the reviewer's own decision question when the verdict record has one, the blocker in plain words, and the applicable actions under the row context menu's action ids (`decide:delegate` first), (PRs) `lineage` on the hive's copy of an adopted PR — `{kind: adopted|superseded|rebased-by-hive, from_number, from_url, from_author, from_author_kind, to_number, to_url, at, reason}`, derived from the stage store's adoption record or the `hive/adopt-` head branch, mirrored onto the issue's `linked_prs[]` entry; absent on every other row — and (issues) `linked_prs`; items with no stage yet report stage `0` "Open"; `needs_human_labels` is the "a person must act" label set behind the monitor's Needs human facet (the same list as `/api/status.labelPresets[needs-human]`); `recently_merged` lists the PRs (`repo`, `number`, `merged_at`) whose `pr_merged` audit entry is under 30 minutes old, so a client diffing two payloads can tell a merge from a close; a PR in a conflict-aware merge train carries `merge_train` `{id, state, front, position, size, attempt, max_attempts, overlap_files, ahead, length, head_number, head_state, head_reason, head_since, eta_s, eta_at, eta_basis, late, stalled, stalled_s}` — `head_state` one of `needs-human` / `ci` / `soaking` / `ready` / `merging` / `fixing` / `unknown` with `head_reason` in plain words; `eta_s` / `eta_at` the estimated wait for this member's own merge attempt (own remaining soak + each PR ahead's remaining soak or one sweep + the next sweep tick; absent while the head waits on a person or CI), `eta_at` anchored to the member's first estimate at its position so a countdown survives polls, `eta_basis` its short reading ("2 ahead · head soaking 12m · next sweep in 40s"), `late` once now has overrun the first estimate twice over, `stalled` / `stalled_s` once the head has sat longer than `governor.merge_train_stall_warn_s` ([#15395](https://github.com/hivecommons/hive/issues/15395)); a PR the queue holds because another open PR declares the same `Fixes #N` carries no `merge_train` and a `merge_gate` of `{state: "duplicate-of:", duplicate_of, duplicate_issue}` plus the `needs-decision` modifier (the queue keeps one PR per issue: green first, then the earlier-opened); a PR GitHub reports conflicting on its own, or one under repair (stage/070, 071, 072, 074, 085, or a red required check), carries no `merge_train` and is not counted in any member's `size` / `length` — a repaired member the view dropped carries `left_train: {why: fixing|needs-author|returned-to-contributor|adopted-by-hive|needs-decision|checks-failing, note}` instead (mirrored onto the issue's `linked_prs[]` entry), and a train left with one member reports no `merge_train` at all — the state slugs (`front`, `queued-behind`) are payload values only, the SPA renders ordinal places ("Merge queued · 1st of 2", with the train's tag when more than one train is on the page). Served from a server-side cache rebuilt at most every `dashboard.stage_tracker.cache_ttl_s` (default `governor.eval_interval_s`) from the spoke's existing snapshot — a request never calls GitHub. Carries `generated_at`, `source` (`cache` or `fresh`), `cache_ttl_s`, an `ETag` and `Cache-Control: private, max-age=`; `If-None-Match` yields 304. Each hit is recorded under REST caller `dashboard:stage-tracker` so `/api/gh-rate-limits` shows it charged nothing. | `pkg/dashboard/api.go:186` | +| `GET` | `/api/stage-tracker` | Dashboard auth/session | Stage Tracker: every open issue and pull request of the watched repos for the Hive activity monitor — actionable, held, claimed, in-progress, covered-by-PR, filtered (`needs-*`), draft and exempt-labelled items alike, each with `stage`, `stage_since`, `labels`, `created_at`, `author_kind`, `modifiers`, `claimant: {kind: hive-agent|clanker|person, login, agent, hive, since, source: claim-ledger|claim-comment|assignee|kick-history|author}` naming who holds a claimed / in-progress issue or a PR under review or rework (absent when nobody is named; mirrored onto `linked_prs[]`), (PRs) `sentinel_alert` / `sentinel_findings` / `sentinel_reason` when the sentinel flagged the PR, `decision_needed` on a row parked on a person (085 / 045 / 015, the needs-human pill; mirrored onto the issue's `linked_prs[]` entry): `{question, asked_by, since, blocker, blocker_reason, options: [{action, label, enabled, reason_if_disabled}]}` — the reviewer's own decision question when the verdict record has one, the blocker in plain words, and the applicable actions under the row context menu's action ids (`decide:delegate` first), (PRs) `lineage` on the hive's copy of an adopted PR — `{kind: adopted|superseded|rebased-by-hive, from_number, from_url, from_author, from_author_kind, to_number, to_url, at, reason}`, derived from the stage store's adoption record or the `hive/adopt-` head branch, mirrored onto the issue's `linked_prs[]` entry; absent on every other row — and (issues) `linked_prs`; items with no stage yet report stage `0` "Open"; `needs_human_labels` is the "a person must act" label set behind the monitor's Needs human facet (the same list as `/api/status.labelPresets[needs-human]`); `recently_merged` lists the PRs (`repo`, `number`, `merged_at`) whose `pr_merged` audit entry is under 30 minutes old, so a client diffing two payloads can tell a merge from a close; a PR in a conflict-aware merge train carries `merge_train` `{id, state, front, position, size, attempt, max_attempts, overlap_files, ahead, length, head_number, head_state, head_reason, head_since, eta_s, eta_at, eta_basis, late, stalled, stalled_s}` — `head_state` one of `needs-human` / `ci` / `soaking` / `ready` / `merging` / `fixing` / `unknown` with `head_reason` in plain words; `eta_s` / `eta_at` the estimated wait for this member's own merge attempt (own remaining soak + each PR ahead's remaining soak or one sweep + the next sweep tick; absent while the head waits on a person or CI), `eta_at` anchored to the member's first estimate at its position so a countdown survives polls, `eta_basis` its short reading ("2 ahead · head soaking 12m · next sweep in 40s"), `late` once now has overrun the first estimate twice over, `stalled` / `stalled_s` once the head has sat longer than `governor.merge_train_stall_warn_s` ([#15395](https://github.com/hivecommons/hive/issues/15395)); a PR the queue holds because another open PR declares the same `Fixes #N` carries no `merge_train` and a `merge_gate` of `{state: "duplicate-of:", duplicate_of, duplicate_issue}` plus the `needs-decision` modifier (the queue keeps one PR per issue: green first, then the earlier-opened); a PR GitHub reports conflicting on its own, or one under repair (stage/070, 071, 072, 074, 085, or a red required check), carries no `merge_train` and is not counted in any member's `size` / `length` — a repaired member the view dropped carries `left_train: {why: fixing|needs-author|returned-to-contributor|adopted-by-hive|needs-decision|checks-failing, note}` instead (mirrored onto the issue's `linked_prs[]` entry), and a train left with one member reports no `merge_train` at all; a PR short of the merge queue (below stage/080) the planner ordered rides no train either — it carries `overlap: {behind, with, files, note}` ("overlaps #15637 (sidebar.html, index.html) — will queue behind it") and no `merge_train`, and counts in no member's `size` — the state slugs (`front`, `queued-behind`) are payload values only, the SPA renders ordinal places ("Merge queued · 1st of 2", with the train's tag when more than one train is on the page). Served from a server-side cache rebuilt at most every `dashboard.stage_tracker.cache_ttl_s` (default `governor.eval_interval_s`) from the spoke's existing snapshot — a request never calls GitHub. Carries `generated_at`, `source` (`cache` or `fresh`), `cache_ttl_s`, an `ETag` and `Cache-Control: private, max-age=`; `If-None-Match` yields 304. Each hit is recorded under REST caller `dashboard:stage-tracker` so `/api/gh-rate-limits` shows it charged nothing. | `pkg/dashboard/api.go:186` | | `POST` | `/api/prs/{owner}/{repo}/{number}/queue-automerge` | Merger/owner role | Queue PRAuto Merge | `pkg/dashboard/api.go:187` | | `GET` | `/api/inference/models/{backend}` | Dashboard auth/session | Inference Models | `pkg/dashboard/api.go:363` | | `GET` | `/api/hive-id` | Dashboard auth/session | Hive IDGet | `pkg/dashboard/api.go:425` | diff --git a/src/docs/dashboard-sections.md b/src/docs/dashboard-sections.md index d849cd66e7..60d0b1fbce 100644 --- a/src/docs/dashboard-sections.md +++ b/src/docs/dashboard-sections.md @@ -933,12 +933,14 @@ When several approved PRs to the same base touch the same files, the automerge l 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. -**The header counts the rows under it.** A member drawn as a sub-row of its linked issue (`nested_under`) still sits in the train run — the issue row rides its open PR's train, in that PR's merge order, and wears the rail — so a train of three is three rows under one header whether or not its PRs have issues. When a filter or tab hides some members, the header says so and names them: `merge train · 1 of 3 PRs here · 1st: #15425 · not in this view: #15529, #15530`; it never claims `3 PRs` over one row (hive's v5#15425 did, with #15529 and #15530 drawn under their issues). No member on the page, no header. +**The header counts the rows under it.** A member drawn as a sub-row of its linked issue (`nested_under`) still sits in the train run — the issue row rides its open PR's train, in that PR's merge order, and wears the rail — so a train of three is three rows under one header whether or not its PRs have issues. When the page does not carry every member, the header says where the rest are and names them — `merge train · 1 of 3 PRs here · 1st: #15425 · on another page: #15529 · hidden by the filter: #15530` (`not in this payload: #N` for one the server no longer lists) — never a bare "not in this view" (owner: *what does 'not in this view' mean?*) and never `3 PRs` over one row (hive's v5#15425 did, with #15529 and #15530 drawn under their issues). `size` / `members` count only the PRs in the merge queue in this payload, never the planner's wider grouping (hive's own header once read `2 of 9 PRs here · not in this view: 7 more` where the seven were PRs still at CI / Review). The header's hover says the mechanics: the members touch the same files, so they merge one at a time in order, and each is rebased onto the base only after the PR ahead merges; a member's own hover adds its slot, *Position: 3rd of 4 · after #15085 merges*. No member on the page, no header. **Who rides.** A PR the lane leaves to a person is not a train member and never its head: an author below the lane's trust (`untrusted-author-role`, `contributor-lane:no-linked-issue`, …), the title/label human-merge rule, a human-merge path, a merge GitHub refused for review, and every other `human_merge_reason` code except the catch-all `policy`. The lane's verdict is remembered per lane and head (`noteMergeTrainOutcome`); a new head starts clean. A head the lane last saw unable to merge on its own (red required check, terminal hold, permanent refusal) stays a member but never fronts. **PRs under repair leave the train.** A PR somebody is fixing is not a train member either: the planner (`mergeTrainUnderRepair`) skips a PR at 070 fixing, 071 needs-author, 072 returned-to-contributor or 085 needs-decision (label or stage store), and the tracker (`stageTrackerTrainUnderRepair`) drops one whose stage says so (074 adopted-by-hive included) or whose `reason` is a red required check (`required-check-failing:` / `check-failing:` / `ci-red`) — hive's own #15405 once led a header as `merge train · 2 PRs · 1st: #15405` while its own chevron read *Fixing* (a maintainer had just requested changes). The dropped row carries `left_train: {why, note}` and no `merge_train`: no ordinal, no rail, and its hover ends with the one muted line *Merge train: left the merge train while being fixed; rejoins when green*. The survivors close ranks — `size`, `position`, `front`, `ahead`, `members` are recomputed, and the next in line fronts when the front itself left — and a train left with one member is no train: no header, no ordinal, the 080 row back to *Green and approved; waiting for the automerge lane to admit it*. The exception is the `rebase-exhausted` tail at 085: the train put it there, and it stays so the person who rebases it sees where it merges. Provisional members (050 / 060 with nothing red, [#15580](https://github.com/hivecommons/hive/issues/15580)) keep their slot. +**The train starts at 080.** The merge train is a merge-queue concept: only PRs at 080 and beyond — green, approved, soaking or merging — ride one, and the header counts only them. A PR the planner has ordered while it is still at CI / Review (050 / 060) rides no train (`stageTrackerBelowMergeQueue`): hive's own page once led `merge train · 2 PRs · 1st: #15637 — overlapping: sidebar.html, index.html` over #15637 and #15633 while both chevrons read *CI / Review*. Such a row carries `overlap: {behind, with, files, note}` instead of `merge_train` — no rail, no ordinal, no header — and shows one muted badge **overlaps #15637** whose hover is the note, *Not in the merge queue yet: overlaps #15637 (sidebar.html, index.html) — will queue behind it* (the planner's own front reads *overlaps #15633 (…) — merges ahead of it once both are ready*). The members that do ride close ranks around it, and a train left with one 080 member is no train. + **Queue position, countdown, stall** ([#15395](https://github.com/hivecommons/hive/issues/15395)). The queued chip is its place in the queue and nothing else — **Merge queued · 2nd of 6 · ~4m** — so it reads the same whether or not a merge sweep is evaluating it: the sweep is the spinning ⬡ glyph and a *Checking now…* line in the hover, never a change of words (one label per chevron), and no state slug (`queued-behind`, `front`) ever reaches the page. The hover is the place sentence — *2nd of 6 in the merge queue · behind #15253 (soaking, 12m left) · ETA ~25m (2 ahead · head soaking 12m · next pass in 40s). Hive merges one at a time, in order.*; the head's reads *1st of 6 in the merge queue · merges next · ETA ~13m.* — or, when the head is on a person or on CI, the blocker instead of a clock: *… behind #15253 (waiting for a maintainer (untrusted author)) · no estimate until #15253 moves.* Every train state — the 1st included — lights the **Merge queue** column, whatever numeric stage the lane holds the head at (the train's facts are mirrored onto a head still at 050/060; hive's own #15400 once lit CI / Review beside its 2nd-place sibling) — a head under repair is no member (below) and lights CI / Review. The server adds to each member's `merge_train`: `length`, `head_number`, `head_state` (`needs-human` / `ci` / `soaking` / `ready` / `merging` / `fixing` / `unknown`), `head_reason` (plain words), `head_since`, `eta_s`, `eta_at`, `eta_basis`, `late`, `stalled`, `stalled_s`. **One PR per issue** ([#15395](https://github.com/hivecommons/hive/issues/15395)). Two open PRs declaring the same `Fixes #N` never both ride the queue (hive's own #15402 and #15407, both for #15396, once sat side by side as "waiting its turn"). Before the trains are grouped the sweep keeps one PR per closing issue — a green head (not conflicting, not blocked on a red required check) beats a red one; among equals the earlier-opened wins — and holds the other out of every train with the stage reason `merge-train:duplicate-of#:/0:0/0:`. The held row's gate reads `duplicate-of:` (`merge_gate.duplicate_of`, `merge_gate.duplicate_issue`), its chip **Duplicate of #15402 · needs a pick** with no clock, it carries no `merge_train`, and it wears `needs-decision` so both PRs sit under their issue with the hold visible. *Let hive decide* on either row takes the existing supersede path (rule `one-pr-per-issue`): on the held PR it closes it as superseded by the kept one with a credit comment, through the same write gate as every delegate close; on the kept PR it releases it and names the duplicate the queue holds (or, if the kept PR has since gone red, only recommends the fix — the queue re-picks on its next pass, so an earlier red PR yields to a later green one). diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index 7b3484f1e4..fa79b6d3d7 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -441,6 +441,12 @@ type StageTrackerItem struct { // parked on a decision, or red (stageTrackerTrainUnderRepair). The // row rides no train and wears no ordinal; the hover says so. LeftTrain *StageTrackerLeftTrain `json:"left_train,omitempty"` + // Overlap is set on a PR short of the merge queue (below 080) whose + // changed files overlap another open PR's: the planner has ordered + // them, but the merge train is a merge-queue concept and this row is + // not in the queue yet. No train, no ordinal — one hint naming the PR + // it will queue behind (stageTrackerOverlapHint). + Overlap *StageTrackerOverlap `json:"overlap,omitempty"` // BlockedOn lists the open GitHub "blocked by" dependencies ("repo#N") // of an issue the scheduler withholds from every kick until they close // (scheduler.partitionBlockedIssues). Without it a sequenced sub-issue @@ -639,6 +645,7 @@ type StageTrackerLinkedPR struct { // LeftTrain mirrors the nested PR's own row field so the sub-row's // hover can say it left its train while under repair. LeftTrain *StageTrackerLeftTrain `json:"left_train,omitempty"` + Overlap *StageTrackerOverlap `json:"overlap,omitempty"` Soak *StageTrackerSoak `json:"soak,omitempty"` // Adoption mirrors the nested PR's own row field (hivecommons/hive#14524). Adoption *StageTrackerAdoption `json:"adoption,omitempty"` diff --git a/src/pkg/dashboard/stage_tracker_links.go b/src/pkg/dashboard/stage_tracker_links.go index 72ee3642ff..5f397b22a8 100644 --- a/src/pkg/dashboard/stage_tracker_links.go +++ b/src/pkg/dashboard/stage_tracker_links.go @@ -335,7 +335,7 @@ func stageTrackerResolveLinkedPRs(items []StageTrackerItem, open func(repo strin lp.BaseRef = pr.BaseRef lp.DecisionNeeded = pr.DecisionNeeded lp.SoakRemainingSeconds, lp.MergeGate = pr.SoakRemainingSeconds, pr.MergeGate - lp.MergeTrain, lp.LeftTrain = pr.MergeTrain, pr.LeftTrain + lp.MergeTrain, lp.LeftTrain, lp.Overlap = pr.MergeTrain, pr.LeftTrain, pr.Overlap lp.Soak = pr.Soak lp.LastOperatorAction, lp.OperatorActionCount = pr.LastOperatorAction, pr.OperatorActionCount lp.Decided, lp.AdoptedFrom = pr.Decided, pr.AdoptedFrom diff --git a/src/pkg/dashboard/stage_tracker_merge_train.go b/src/pkg/dashboard/stage_tracker_merge_train.go index 18eb5e414b..8a82dd09be 100644 --- a/src/pkg/dashboard/stage_tracker_merge_train.go +++ b/src/pkg/dashboard/stage_tracker_merge_train.go @@ -83,21 +83,18 @@ type StageTrackerMergeTrain struct { Late bool `json:"late,omitempty"` Stalled bool `json:"stalled,omitempty"` StalledS int64 `json:"stalled_s,omitempty"` - // Provisional is true while this member's own stage is still short of - // the merge gate (050 review pending / CI, 060, 070…): the planner has - // ordered it, but the slot is a forecast, not a state. The SPA keeps - // the stage's blocker as the headline and words the slot as a suffix - // ("CI / Review · queued 1st once ready") so the chevron never - // contradicts the caption (hive's own #15577 read "Merge queued · 1st" - // over "check build-and-test still running"). - Provisional bool `json:"provisional,omitempty"` } -// stageTrackerMergeTrainProvisional reports whether a train member at -// stage is holding its queue slot ahead of being merge-ready: anything -// below 080 awaiting merge admission. -func stageTrackerMergeTrainProvisional(stage int) bool { - return stage > 0 && stage < stagelabels.AwaitingMergeAdmission.Number() +// stageTrackerBelowMergeQueue reports whether a PR at stage is short of +// the merge queue: anything below 080 awaiting merge admission. The +// merge train is a merge-queue concept — only PRs at 080 and beyond +// (green, approved, soaking or merging) ride one. A PR the planner has +// ordered while it is still at CI / Review is not a member: hive's own +// page led "merge train · 2 PRs · 1st: #15637" over #15637 and #15633 +// while both chevrons read CI / Review (hivecommons/hive#15653; #15581 had +// admitted them provisionally). +func stageTrackerBelowMergeQueue(stage int) bool { + return stage < stagelabels.AwaitingMergeAdmission.Number() } // Head states a merge train reports on its members (HeadState). The SPA @@ -239,13 +236,77 @@ type StageTrackerLeftTrain struct { position int } +// StageTrackerOverlap is the hint on a PR short of the merge queue whose +// files overlap another open PR's: Behind is the PR it will queue behind +// once both are merge-ready (0 when this one is the planner's front), +// With the other overlapping PRs, Files the overlapping files and Note +// the one line the row shows — "overlaps #15637 (sidebar.html, +// index.html) — will queue behind it". The row has no merge_train, no +// ordinal and no rail: the train starts at 080. +type StageTrackerOverlap struct { + Behind int `json:"behind,omitempty"` + With []int `json:"with,omitempty"` + Files []string `json:"files,omitempty"` + Note string `json:"note"` + // trainID and position remember the planner's slot so the members + // that do ride can close ranks (stageTrackerMergeTrainPostPass). + trainID string + position int +} + +// stageTrackerOverlapHint builds the hint for a PR at number, out of a +// train whose planner's front is front and whose other members are +// others (number excluded by the caller). +func stageTrackerOverlapHint(number, front int, others []int, files []string) *StageTrackerOverlap { + o := &StageTrackerOverlap{With: append([]int(nil), others...), Files: append([]string(nil), files...)} + paren := "" + if len(files) > 0 { + paren = " (" + strings.Join(files, ", ") + ")" + } + if number != front && front > 0 { + o.Behind = front + o.Note = "overlaps #" + strconv.Itoa(front) + paren + " — will queue behind it" + return o + } + names := make([]string, 0, len(others)) + for _, n := range others { + names = append(names, "#"+strconv.Itoa(n)) + } + them := "it" + if len(others) > 1 { + them = "them" + } + o.Note = "overlaps " + strings.Join(names, ", ") + paren + " — merges ahead of " + them + " once both are ready" + if len(others) > 1 { + o.Note = strings.Replace(o.Note, "once both are ready", "once all are ready", 1) + } + return o +} + +// stageTrackerLeaveMergeTrainBelowQueue takes a PR short of the merge +// queue out of its train and leaves the overlap hint in its place. +func stageTrackerLeaveMergeTrainBelowQueue(it *StageTrackerItem, front int, others []int) { + if it == nil || it.MergeTrain == nil { + return + } + mt := it.MergeTrain + pos := mt.Position + if mt.State == MergeGateStateTrainFront { + pos = 1 + } + stageTrackerLeaveMergeTrain(it, "") + it.Overlap = stageTrackerOverlapHint(it.Number, front, others, mt.OverlapFiles) + it.Overlap.trainID, it.Overlap.position = mt.ID, pos +} + // stageTrackerTrainUnderRepair names why a PR at stage, with reason, is // not a train member right now — "" when it may ride. A PR being fixed // (070), waiting on its author (071) or contributor (072), freshly // adopted (074), parked on a human decision (085), or whose required // checks are red is somebody's to repair first; the planner may still -// have ordered it, but the view never seats it (hivecommons/hive#15581 -// admits 050/060 provisionally only while nothing is red). +// have ordered it, but the view never seats it. A PR short of the merge +// queue is not under repair but rides no train either +// (stageTrackerBelowMergeQueue). // // stageTrackerItemColumn reads the same predicate for the chevron // column, and stageTrackerUnderRepair in the SPA mirrors it: membership @@ -314,9 +375,8 @@ func stageTrackerLeaveMergeTrain(it *StageTrackerItem, why string) { // stageTrackerMergeTrainFrontGate words the gate of the member merging // first: "1st in the merge queue; merges next (1st of 2, overlapping -// files: a.go)", or "merges first once it is ready" while its own stage -// is short of the gate. promoted is a member that was queued behind a -// front that just left: its queued words are stale and are replaced. +// files: a.go)". promoted is a member that was queued behind a front +// that just left: its queued words are stale and are replaced. func stageTrackerMergeTrainFrontGate(front *StageTrackerItem, size int, files []string, promoted bool) { if front.MergeGate == nil { front.MergeGate = &StageTrackerMergeGate{} @@ -325,11 +385,7 @@ func stageTrackerMergeTrainFrontGate(front *StageTrackerItem, size int, files [] front.MergeGate.State = MergeGateStateTrainFront } if front.MergeGate.Reason == "" || promoted { - next := "merges next" - if stageTrackerMergeTrainProvisional(front.Stage) { - next = "merges first once it is ready" - } - front.MergeGate.Reason = "1st in the merge queue; " + next + " (1st of " + strconv.Itoa(size) + ", overlapping files: " + strings.Join(files, ", ") + ")" + front.MergeGate.Reason = "1st in the merge queue; merges next (1st of " + strconv.Itoa(size) + ", overlapping files: " + strings.Join(files, ", ") + ")" } } @@ -338,62 +394,113 @@ func stageTrackerMergeTrainFrontGate(front *StageTrackerItem, size int, files [] // reason) is marked from its siblings' records, and every member learns // the PRs ahead of it. Members are matched on repo and base. A member // under repair (stageTrackerTrainUnderRepair) leaves the train first — -// the front included — the rest close ranks (size, place, front and -// ahead recomputed), and a train left with one member is no train at -// all: no header, no ordinal (hivecommons/hive#15405 led a header as -// "1st: #15405" while its own chevron read "Fixing"). +// the front included — as does one short of the merge queue +// (stageTrackerBelowMergeQueue, which keeps an overlap hint instead); +// the rest close ranks (size, place, front and ahead recomputed), and a +// train left with one member is no train at all: no header, no ordinal +// (hivecommons/hive#15405 led a header as "1st: #15405" while its own +// chevron read "Fixing"; hive's own #15637/#15633 led one while both +// read CI / Review). func stageTrackerMergeTrainPostPass(items []StageTrackerItem, opts mergeTrainQueueOptions, mem *mergeTrainMemory) { type trainKey struct{ repo, id string } - members := map[trainKey][]int{} + // Every row the planner ordered, by train, before the view decides who + // rides; the overlap hint on a row that does not names the rest. + ordered := map[trainKey][]int{} + samples := map[trainKey]*StageTrackerMergeTrain{} + var keys []trainKey for i := range items { it := &items[i] if it.MergeTrain == nil || it.Kind != "pr" { continue } - // A rebase-exhausted tail sits at 085 by the train's own doing; - // it stays so the person who rebases it sees where it merges. - if it.MergeTrain.State != MergeGateStateRebaseExhausted { - if why := stageTrackerTrainUnderRepair(it.Stage, it.Reason); why != "" { - stageTrackerLeaveMergeTrain(it, why) - continue - } + k := trainKey{it.Repo, it.MergeTrain.ID} + if _, seen := samples[k]; !seen { + samples[k] = it.MergeTrain + keys = append(keys, k) } - members[trainKey{it.Repo, it.MergeTrain.ID}] = append(members[trainKey{it.Repo, it.MergeTrain.ID}], i) + ordered[k] = append(ordered[k], i) } - for key, idx := range members { - sample := items[idx[0]].MergeTrain + for _, key := range keys { + sample := *samples[key] frontIdx := -1 - frontLeft := false for i := range items { it := &items[i] if it.Kind == "pr" && it.Repo == key.repo && it.Number == sample.Front && it.Stage < stageTrackerMergedStage { - if why := stageTrackerTrainUnderRepair(it.Stage, it.Reason); why != "" { - it.LeftTrain = &StageTrackerLeftTrain{Why: why, Note: stageTrackerLeftTrainNote, trainID: sample.ID, position: 1} - frontLeft = true - break - } frontIdx = i break } } + roster := func(except int) []int { + var out []int + if frontIdx >= 0 && items[frontIdx].Number != except { + out = append(out, items[frontIdx].Number) + } + for _, i := range ordered[key] { + if items[i].Number != except { + out = append(out, items[i].Number) + } + } + sort.Ints(out) + return out + } + var idx []int + for _, i := range ordered[key] { + it := &items[i] + // A rebase-exhausted tail sits at 085 by the train's own doing; + // it stays so the person who rebases it sees where it merges. + if it.MergeTrain.State != MergeGateStateRebaseExhausted { + if why := stageTrackerTrainUnderRepair(it.Stage, it.Reason); why != "" { + stageTrackerLeaveMergeTrain(it, why) + continue + } + if stageTrackerBelowMergeQueue(it.Stage) { + stageTrackerLeaveMergeTrainBelowQueue(it, sample.Front, roster(it.Number)) + continue + } + } + idx = append(idx, i) + } + frontLeft := false if frontIdx >= 0 && items[frontIdx].MergeTrain == nil { front := &items[frontIdx] - front.MergeTrain = &StageTrackerMergeTrain{ - ID: sample.ID, State: MergeGateStateTrainFront, Front: sample.Front, Position: 1, Size: sample.Size, - OverlapFiles: append([]string(nil), sample.OverlapFiles...), - } - stageTrackerMergeTrainFrontGate(front, sample.Size, sample.OverlapFiles, false) - if front.Stage == stagelabels.AwaitingMergeAdmission.Number() { - front.Caption = stageTrackerMergeTrainFrontCaption(sample) + if why := stageTrackerTrainUnderRepair(front.Stage, front.Reason); why != "" { + front.LeftTrain = &StageTrackerLeftTrain{Why: why, Note: stageTrackerLeftTrainNote, trainID: sample.ID, position: 1} + frontLeft = true + } else if stageTrackerBelowMergeQueue(front.Stage) { + front.Overlap = stageTrackerOverlapHint(front.Number, sample.Front, roster(front.Number), sample.OverlapFiles) + front.Overlap.trainID, front.Overlap.position = sample.ID, 1 + frontLeft = true + } else { + front.MergeTrain = &StageTrackerMergeTrain{ + ID: sample.ID, State: MergeGateStateTrainFront, Front: sample.Front, Position: 1, Size: sample.Size, + OverlapFiles: append([]string(nil), sample.OverlapFiles...), + } + stageTrackerMergeTrainFrontGate(front, sample.Size, sample.OverlapFiles, false) + if front.Stage == stagelabels.AwaitingMergeAdmission.Number() { + front.Caption = stageTrackerMergeTrainFrontCaption(&sample) + } + idx = append(idx, frontIdx) } - idx = append(idx, frontIdx) } - // The slots the view has emptied: survivors behind them move up. + if len(idx) == 0 { + continue + } + // The queue is the members that ride in this payload — never the + // planner's count, which includes PRs the view does not seat + // (below 080, under repair, a record another lane overwrote): + // hive's own header read "2 of 9 PRs here · not in this view: 7 + // more" over the only two PRs actually queued (hivecommons/hive#15653). + // Members the view sent elsewhere; one survivor is no train. var dropped []int for i := range items { it := &items[i] - if it.Kind == "pr" && it.Repo == key.repo && it.MergeTrain == nil && it.LeftTrain != nil && it.LeftTrain.trainID == sample.ID { + if it.Kind != "pr" || it.Repo != key.repo || it.MergeTrain != nil { + continue + } + if it.LeftTrain != nil && it.LeftTrain.trainID == sample.ID { dropped = append(dropped, it.LeftTrain.position) + } else if it.Overlap != nil && it.Overlap.trainID == sample.ID { + dropped = append(dropped, it.Overlap.position) } } if len(dropped) > 0 { @@ -403,22 +510,31 @@ func stageTrackerMergeTrainPostPass(items []StageTrackerItem, opts mergeTrainQue } continue } - for _, i := range idx { - mt := items[i].MergeTrain - moved := 0 - for _, p := range dropped { - if p > 0 && p < mt.Position { - moved++ - } - } - mt.Position -= moved - mt.Size = max(sample.Size-len(dropped), len(idx)) - } } - // Members in merge order, so each one's Ahead is the prefix. + // Riders keep their planner order but take slots 1..N: a member + // the planner seated 5th of 9 whose seven neighbours never rode + // (below the merge queue, under repair, or not in this payload) + // is 2nd of 2 here, never "5th of 2". sort.Slice(idx, func(a, b int) bool { return items[idx[a]].MergeTrain.Position < items[idx[b]].MergeTrain.Position }) + for n, i := range idx { + items[i].MergeTrain.Position = n + 1 + } + for _, i := range idx { + mt := items[i].MergeTrain + mt.Size = len(idx) + // The front's gate and caption counted the planner's size; + // say the size of the train that rides. + if mt.State == MergeGateStateTrainFront && mt.Size != sample.Size { + front := &items[i] + stageTrackerMergeTrainFrontGate(front, mt.Size, mt.OverlapFiles, true) + if front.Stage == stagelabels.AwaitingMergeAdmission.Number() && front.Caption == stageTrackerMergeTrainFrontCaption(&sample) { + front.Caption = stageTrackerMergeTrainFrontCaption(mt) + } + } + } + // Members in merge order, so each one's Ahead is the prefix. if frontLeft { // The old front is out; the member now in slot 1 leads. newFront := 0 @@ -443,7 +559,6 @@ func stageTrackerMergeTrainPostPass(items []StageTrackerItem, opts mergeTrainQue } items[i].MergeTrain.Ahead = ahead items[i].MergeTrain.Members = append([]int(nil), members...) - items[i].MergeTrain.Provisional = stageTrackerMergeTrainProvisional(items[i].Stage) } var head *StageTrackerItem if frontIdx >= 0 { diff --git a/src/pkg/dashboard/stage_tracker_merge_train_overlap_test.go b/src/pkg/dashboard/stage_tracker_merge_train_overlap_test.go new file mode 100644 index 0000000000..831e219b4d --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_merge_train_overlap_test.go @@ -0,0 +1,179 @@ +package dashboard + +import ( + "encoding/json" + "strings" + "testing" + "time" + + "github.com/hivecommons/hive/pkg/github" + "github.com/hivecommons/hive/pkg/stageengine/prstage" + "github.com/hivecommons/hive/pkg/stagelabels" +) + +// hive's own page, 2026-10-29 20:00 EDT: "⛁ merge train · 2 PRs · 1st: +// #15637 — overlapping: sidebar.html, index.html" under two PRs whose +// chevrons both read CI / Review — #15637 (Twitch community links) and +// #15633 (the hive's adopted copy of #15566). The planner had ordered +// them; neither was at 080. The merge train is a merge-queue concept: +// a PR short of 080 rides no train, counts in no header, and instead +// carries an `overlap` hint naming the PR it will queue behind. +func TestStageTrackerMergeTrainCIReviewPairRidesNoTrain(t *testing.T) { + now := time.Date(2026, 10, 30, 0, 0, 0, 0, time.UTC) + s, store := stageTrackerFixture(t, now) + overlap := []string{"sidebar.html", "index.html"} + store.Observe(stagelabels.Key("acme/console", 15637), stagelabels.ReviewPending, "required-check-pending:build-and-test") + store.Observe(stagelabels.Key("acme/console", 15633), stagelabels.ReviewPending, + prstage.MergeTrain{State: prstage.MergeTrainStateQueuedBehind, Front: 15637, Position: 2, Size: 2, OverlapFiles: overlap}.Reason()) + s.statusMu.Lock() + s.status.Repos[0].OpenPrs = append(s.status.Repos[0].OpenPrs, + FrontendPR{PullRequest: github.PullRequest{Number: 15637, Title: "Twitch community links", Author: "clubanderson", BaseRef: "v5", Labels: []string{stagelabels.ReviewPending.Label()}}}, + FrontendPR{PullRequest: github.PullRequest{Number: 15633, Title: "Adopted copy", Author: "hive-app[bot]", AppAuthored: true, BaseRef: "v5", Labels: []string{stagelabels.ReviewPending.Label(), "author/hive"}}}) + s.statusMu.Unlock() + resp := s.buildStageTracker(s.status, store, now) + + front := trackerItem(t, resp, "pr", 15637) + rider := trackerItem(t, resp, "pr", 15633) + for _, it := range []StageTrackerItem{front, rider} { + if it.Stage != stagelabels.ReviewPending.Number() { + t.Fatalf("#%d stage = %d, want 050", it.Number, it.Stage) + } + if it.MergeTrain != nil { + t.Errorf("#%d at CI / Review rides no merge train: %+v", it.Number, it.MergeTrain) + } + if it.LeftTrain != nil { + t.Errorf("#%d is not under repair; no left_train note: %+v", it.Number, it.LeftTrain) + } + if it.MergeGate != nil && (it.MergeGate.State == MergeGateStateQueuedBehind || it.MergeGate.State == MergeGateStateTrainFront) { + t.Errorf("#%d gate keeps the train's words: %+v", it.Number, it.MergeGate) + } + } + if rider.Overlap == nil || rider.Overlap.Behind != 15637 || strings.Join(rider.Overlap.Files, ",") != "sidebar.html,index.html" { + t.Fatalf("rider overlap = %+v", rider.Overlap) + } + if want := "overlaps #15637 (sidebar.html, index.html) — will queue behind it"; rider.Overlap.Note != want { + t.Errorf("rider note = %q, want %q", rider.Overlap.Note, want) + } + if front.Overlap == nil || front.Overlap.Behind != 0 || len(front.Overlap.With) != 1 || front.Overlap.With[0] != 15633 { + t.Fatalf("front overlap = %+v", front.Overlap) + } + if want := "overlaps #15633 (sidebar.html, index.html) — merges ahead of it once both are ready"; front.Overlap.Note != want { + t.Errorf("front note = %q, want %q", front.Overlap.Note, want) + } + raw, err := json.Marshal(rider) + if err != nil { + t.Fatal(err) + } + if !strings.Contains(string(raw), `"overlap":{"behind":15637,"with":[15637],"files":["sidebar.html","index.html"],"note":"overlaps #15637`) { + t.Errorf("payload lacks the overlap hint:\n%s", raw) + } + if strings.Contains(string(raw), `"merge_train"`) || strings.Contains(string(raw), `provisional`) { + t.Errorf("payload still carries a train:\n%s", raw) + } +} + +// A train of three where one member is still at 050: the two 080 rows +// are the train (size 2, the 050 row counted nowhere), and the 050 row +// carries the hint naming the front. +func TestStageTrackerMergeTrainCountsOnlyMergeQueueMembers(t *testing.T) { + now := time.Date(2026, 10, 30, 0, 0, 0, 0, time.UTC) + s, store := stageTrackerFixture(t, now) + overlap := []string{"tracker-words.js"} + queued := func(pos int) string { + return prstage.MergeTrain{State: prstage.MergeTrainStateQueuedBehind, Front: 15600, Position: pos, Size: 3, OverlapFiles: overlap}.Reason() + } + store.Observe(stagelabels.Key("acme/console", 15600), stagelabels.AwaitingMergeAdmission, "") + store.Observe(stagelabels.Key("acme/console", 15601), stagelabels.ReviewPending, queued(2)) + store.Observe(stagelabels.Key("acme/console", 15602), stagelabels.AwaitingMergeAdmission, queued(3)) + s.statusMu.Lock() + for n, stage := range map[int]stagelabels.Stage{15600: stagelabels.AwaitingMergeAdmission, 15601: stagelabels.ReviewPending, 15602: stagelabels.AwaitingMergeAdmission} { + s.status.Repos[0].OpenPrs = append(s.status.Repos[0].OpenPrs, + FrontendPR{PullRequest: github.PullRequest{Number: n, Title: "Tracker words", Author: "someone", BaseRef: "v5", Labels: []string{stage.Label()}}}) + } + s.statusMu.Unlock() + resp := s.buildStageTracker(s.status, store, now) + + front := trackerItem(t, resp, "pr", 15600) + pending := trackerItem(t, resp, "pr", 15601) + tail := trackerItem(t, resp, "pr", 15602) + if front.MergeTrain == nil || tail.MergeTrain == nil { + t.Fatalf("the two 080 rows ride: front=%+v tail=%+v", front.MergeTrain, tail.MergeTrain) + } + if front.MergeTrain.Size != 2 || tail.MergeTrain.Size != 2 || tail.MergeTrain.Position != 2 || len(tail.MergeTrain.Members) != 2 { + t.Errorf("the 050 row counts in no header: front=%+v tail=%+v", front.MergeTrain, tail.MergeTrain) + } + if front.MergeGate == nil || !strings.Contains(front.MergeGate.Reason, "1st of 2") || strings.Contains(front.MergeGate.Reason, "once it is ready") { + t.Errorf("front gate = %+v", front.MergeGate) + } + if pending.MergeTrain != nil || pending.Overlap == nil || pending.Overlap.Behind != 15600 { + t.Errorf("the 050 row rides no train and hints at the front: train=%+v overlap=%+v", pending.MergeTrain, pending.Overlap) + } +} + +// Two overlapping PRs, the planner's front still at 050 and the sibling +// at 080: no train (one merge-queue member is no train), the 080 row +// back to its own caption, the 050 row with the hint. +func TestStageTrackerMergeTrainPendingFrontLeavesLoneRider(t *testing.T) { + now := time.Date(2026, 10, 30, 0, 0, 0, 0, time.UTC) + s, store := stageTrackerFixture(t, now) + store.Observe(stagelabels.Key("acme/console", 15577), stagelabels.ReviewPending, "required-check-pending:build-and-test") + store.Observe(stagelabels.Key("acme/console", 15578), stagelabels.AwaitingMergeAdmission, + prstage.MergeTrain{State: prstage.MergeTrainStateQueuedBehind, Front: 15577, Position: 2, Size: 2, OverlapFiles: []string{"tracker-words.js"}}.Reason()) + s.statusMu.Lock() + for n, stage := range map[int]stagelabels.Stage{15577: stagelabels.ReviewPending, 15578: stagelabels.AwaitingMergeAdmission} { + s.status.Repos[0].OpenPrs = append(s.status.Repos[0].OpenPrs, + FrontendPR{PullRequest: github.PullRequest{Number: n, Title: "Tracker words", Author: "someone", BaseRef: "v5", Labels: []string{stage.Label()}}}) + } + s.statusMu.Unlock() + resp := s.buildStageTracker(s.status, store, now) + front := trackerItem(t, resp, "pr", 15577) + rider := trackerItem(t, resp, "pr", 15578) + if front.MergeTrain != nil || rider.MergeTrain != nil { + t.Fatalf("no train of one: front=%+v rider=%+v", front.MergeTrain, rider.MergeTrain) + } + if front.Overlap == nil || front.Overlap.Behind != 0 || len(front.Overlap.With) != 1 || front.Overlap.With[0] != 15578 { + t.Errorf("front overlap = %+v", front.Overlap) + } + if rider.Overlap != nil || rider.Caption != stageTrackerAwaitingAdmissionCaption { + t.Errorf("080 rider: overlap=%+v caption=%q", rider.Overlap, rider.Caption) + } +} + +// Owner, hive's own page: "merge train · 2 of 9 PRs here · 1st: #15516 · +// not in this view: 7 more" — "what does 'not in this view' mean? if there +// are 7 not ready to merge, then why are they mentioned?". The planner +// grouped nine overlapping PRs but only two carried a train record in the +// payload; the other seven were below the merge queue or no longer listed. +// Size and Members count the PRs riding in this payload, nothing wider. +func TestStageTrackerMergeTrainSizeCountsRidersInPayload(t *testing.T) { + now := time.Date(2026, 10, 30, 0, 0, 0, 0, time.UTC) + s, store := stageTrackerFixture(t, now) + overlap := []string{"dashboard-misc.md", "dashboard-sections.md"} + store.Observe(stagelabels.Key("acme/console", 15516), stagelabels.AwaitingMergeAdmission, "") + store.Observe(stagelabels.Key("acme/console", 15563), stagelabels.AwaitingMergeAdmission, + prstage.MergeTrain{State: prstage.MergeTrainStateQueuedBehind, Front: 15516, Position: 5, Size: 9, OverlapFiles: overlap}.Reason()) + s.statusMu.Lock() + for _, n := range []int{15516, 15563} { + s.status.Repos[0].OpenPrs = append(s.status.Repos[0].OpenPrs, + FrontendPR{PullRequest: github.PullRequest{Number: n, Title: "Docs", Author: "someone", BaseRef: "v5", Labels: []string{stagelabels.AwaitingMergeAdmission.Label()}}}) + } + s.statusMu.Unlock() + resp := s.buildStageTracker(s.status, store, now) + + front := trackerItem(t, resp, "pr", 15516) + second := trackerItem(t, resp, "pr", 15563) + if front.MergeTrain == nil || second.MergeTrain == nil { + t.Fatalf("both 080 rows ride: front=%+v second=%+v", front.MergeTrain, second.MergeTrain) + } + for _, mt := range []*StageTrackerMergeTrain{front.MergeTrain, second.MergeTrain} { + if mt.Size != 2 || len(mt.Members) != 2 { + t.Errorf("size counts the two riders in this payload, not the planner's nine: %+v", mt) + } + } + if second.MergeTrain.Position != 2 || len(second.MergeTrain.Ahead) != 1 || second.MergeTrain.Ahead[0] != 15516 { + t.Errorf("close ranks to 2nd of 2 behind the front: %+v", second.MergeTrain) + } + if front.MergeGate == nil || !strings.Contains(front.MergeGate.Reason, "1st of 2") { + t.Errorf("front gate = %+v", front.MergeGate) + } +} diff --git a/src/pkg/dashboard/stage_tracker_merge_train_provisional_test.go b/src/pkg/dashboard/stage_tracker_merge_train_provisional_test.go index 384323b7ee..3027d3e987 100644 --- a/src/pkg/dashboard/stage_tracker_merge_train_provisional_test.go +++ b/src/pkg/dashboard/stage_tracker_merge_train_provisional_test.go @@ -1,58 +1,12 @@ package dashboard import ( - "strings" "testing" - "time" - - "github.com/hivecommons/hive/pkg/github" - "github.com/hivecommons/hive/pkg/stageengine/prstage" - "github.com/hivecommons/hive/pkg/stagelabels" ) -// A train's front still at 050 (CI running, no verdict) — hive's own -// #15577 — carries its queue slot as provisional, its gate reason says -// "once it is ready", and the siblings parked behind it at 080 do not. -func TestStageTrackerMergeTrainProvisionalFront(t *testing.T) { - now := time.Date(2026, 10, 30, 0, 0, 0, 0, time.UTC) - s, store := stageTrackerFixture(t, now) - overlap := []string{"tracker-words.js"} - store.Observe(stagelabels.Key("acme/console", 15577), stagelabels.ReviewPending, "required-check-pending:build-and-test") - store.Observe(stagelabels.Key("acme/console", 15578), stagelabels.AwaitingMergeAdmission, - prstage.MergeTrain{State: prstage.MergeTrainStateQueuedBehind, Front: 15577, Position: 2, Size: 2, OverlapFiles: overlap}.Reason()) - s.statusMu.Lock() - for n, stage := range map[int]string{15577: "stage/050-review-pending", 15578: "stage/080-awaiting-merge-admission"} { - s.status.Repos[0].OpenPrs = append(s.status.Repos[0].OpenPrs, - FrontendPR{PullRequest: github.PullRequest{Number: n, Title: "Tracker words", Author: "someone", BaseRef: "v5", Labels: []string{stage}}}) - } - s.statusMu.Unlock() - resp := s.buildStageTracker(s.status, store, now) - var front, rider *StageTrackerItem - for i := range resp.Items { - switch resp.Items[i].Number { - case 15577: - front = &resp.Items[i] - case 15578: - rider = &resp.Items[i] - } - } - if front == nil || front.MergeTrain == nil || rider == nil || rider.MergeTrain == nil { - t.Fatalf("expected both rows to carry merge_train: front=%+v rider=%+v", front, rider) - } - if !front.MergeTrain.Provisional { - t.Errorf("front at 050 should carry merge_train.provisional: %+v", front.MergeTrain) - } - if front.MergeGate == nil || !strings.Contains(front.MergeGate.Reason, "once it is ready") || strings.Contains(front.MergeGate.Reason, "merges next") { - t.Errorf("provisional front's gate reason should say once it is ready, not merges next: %+v", front.MergeGate) - } - if rider.MergeTrain.Provisional { - t.Errorf("rider at 080 is merge-ready; its slot is not provisional: %+v", rider.MergeTrain) - } - if !stageTrackerMergeTrainProvisional(stagelabels.Reviewed.Number()) || stageTrackerMergeTrainProvisional(stagelabels.AwaitingMergeAdmission.Number()) || stageTrackerMergeTrainProvisional(0) { - t.Errorf("provisional is every stage between 0 and 080, exclusive") - } -} - +// The server seats no train member below 080 any more (hivecommons/ +// hive#15653 — stage_tracker_merge_train_overlap_test.go); the SPA keeps +// the provisional words as the fallback for a payload that still does. // Ratchet (hive's own #15577: the chevron read "Merge queued · 1st" while // the caption said "check build-and-test still running"): for every // stage × queue state the chevron headline — the gate chip's word, else diff --git a/src/pkg/dashboard/stage_tracker_merge_train_test.go b/src/pkg/dashboard/stage_tracker_merge_train_test.go index 86510b83cf..010e7b1c9c 100644 --- a/src/pkg/dashboard/stage_tracker_merge_train_test.go +++ b/src/pkg/dashboard/stage_tracker_merge_train_test.go @@ -262,6 +262,8 @@ func TestStageTrackerMergeTrainSPA(t *testing.T) { jsFunc(t, html, "stageTrackerTrainOrder"), jsFunc(t, html, "stageTrackerTrainContiguous"), jsFunc(t, html, "stageTrackerTrainMissing"), + jsConstLine(t, html, "STAGE_TRACKER_TRAIN_MECHANICS"), + jsFunc(t, html, "stageTrackerTrainWhere"), jsFunc(t, html, "stageTrackerTrainHeaderText"), jsFunc(t, html, "stageTrackerTrainHeaderHtml"), jsFunc(t, html, "stageTrackerTrainRowClass"), @@ -298,8 +300,10 @@ assert.strictEqual(lit(other).short, 'Ready for auto merge'); // Tooltip: the queue ahead and the overlapping files. const tip = stageTrackerTooltip(third, now); -assert.ok(tip.includes('Merge train: 4 PRs to v5 touch the same files; they merge one at a time, in order (1st: #15074)'), tip); -assert.ok(tip.includes('Position: 3rd of 4 · ahead: #15074, #15085'), tip); +assert.ok(tip.includes('Merge train: 4 PRs in the merge queue to v5 touch the same files, so they merge one at a time, in order (1st: #15074)'), tip); +assert.ok(tip.includes('rebased onto the base only after the PR ahead of it merges'), tip); +assert.ok(tip.includes('Position: 3rd of 4 · after #15085 merges · ahead: #15074, #15085'), tip); +assert.ok(stageTrackerTooltip(second, now).includes('Position: 2nd of 4 · after #15074 merges'), 'second tip'); assert.ok(tip.includes('The PR ahead merged; rebase attempt 1 of 2 in progress'), tip); assert.ok(tip.includes('Overlapping files: stage_tracker.go, index.html'), tip); assert.ok(stageTrackerTooltip(front, now).includes('Position: 1st — merges next'), 'front tip'); @@ -389,15 +393,31 @@ assert.deepStrictEqual(fullRows.map(r => r.key), ['train:hivecommons/hive|v5#154 assert.ok(fullRows[0].html.includes(' merge train · 3 PRs · 1st: #15425'), fullRows[0].html); assert.strictEqual(stageTrackerTrainRowClass(issue2, t1, issue3), ' ham-train'); assert.strictEqual(stageTrackerTrainRowClass(issue3, issue2, plainIssue), ' ham-train ham-train-last'); -// A view that carries only the head (a filter hid the other two) says so -// and names them — never "3 PRs" over one row. -const partRows = stageTrackerTrainRows([t1, plainIssue], (it) => ({ key: String(it.number), html: '' })); +// A page that carries only the head says where the rest are — on another +// page, hidden by the filter — and names them; never "3 PRs" over one row, +// and never a bare "not in this view" (owner: "what does 'not in this +// view' mean?"). +const where = stageTrackerTrainWhere([t1, issue2, plainIssue], [t1, issue2, issue3, plainIssue]); +assert.deepStrictEqual(Object.keys(where.listed).sort(), ['15425', '15529']); +assert.deepStrictEqual(Object.keys(where.known).sort(), ['15425', '15529', '15530']); +const partRows = stageTrackerTrainRows([t1, plainIssue], (it) => ({ key: String(it.number), html: '' }), where); assert.deepStrictEqual(partRows.map(r => r.key), ['train:hivecommons/hive|v5#15425', '15425', '15499']); -assert.ok(partRows[0].html.includes(' merge train · 1 of 3 PRs here · 1st: #15425 · not in this view: #15529, #15530'), partRows[0].html); +assert.ok(partRows[0].html.includes(' merge train · 1 of 3 PRs here · 1st: #15425 · on another page: #15529 · hidden by the filter: #15530'), partRows[0].html); assert.ok(!partRows[0].html.includes('3 PRs ·'), partRows[0].html); -assert.strictEqual(stageTrackerTrainHeaderText(t1.merge_train, [15425, 15530]), 'merge train · 2 of 3 PRs here · 1st: #15425 · not in this view: #15529'); -// Without a member list the header still counts honestly. -assert.strictEqual(stageTrackerTrainHeaderText({ id: 'v5#1', front: 1, size: 3 }, [1]), 'merge train · 1 of 3 PRs here · 1st: #1 · not in this view: 2 more'); +assert.ok(!partRows[0].html.includes('not in this view'), partRows[0].html); +assert.ok(partRows[0].html.includes('rebased onto the base only after the PR ahead of it merges'), 'header hover explains the order: ' + partRows[0].html); +assert.ok(!partRows[0].html.includes('Position:'), 'the header speaks for the train, not one slot: ' + partRows[0].html); +// All on the page: a plain count. +assert.strictEqual(stageTrackerTrainHeaderText(t1.merge_train, [15425, 15529, 15530], where), 'merge train · 3 PRs · 1st: #15425'); +// Some on another page only. +assert.strictEqual(stageTrackerTrainHeaderText(t1.merge_train, [15425], stageTrackerTrainWhere([t1, issue2, issue3], [t1, issue2, issue3])), 'merge train · 1 of 3 PRs here · 1st: #15425 · on another page: #15529, #15530'); +// Some filtered out only. +assert.strictEqual(stageTrackerTrainHeaderText(t1.merge_train, [15425], stageTrackerTrainWhere([t1], [t1, issue2, issue3])), 'merge train · 1 of 3 PRs here · 1st: #15425 · hidden by the filter: #15529, #15530'); +// A member the payload does not carry at all is said so, not guessed. +assert.strictEqual(stageTrackerTrainHeaderText(t1.merge_train, [15425, 15530], stageTrackerTrainWhere([t1, issue3], [t1, issue3])), 'merge train · 2 of 3 PRs here · 1st: #15425 · not in this payload: #15529'); +// Without the where context the header still says only what it knows. +assert.strictEqual(stageTrackerTrainHeaderText(t1.merge_train, [15425, 15530]), 'merge train · 2 of 3 PRs here · 1st: #15425 · not on this page: #15529'); +assert.strictEqual(stageTrackerTrainHeaderText({ id: 'v5#1', front: 1, size: 3 }, [1]), 'merge train · 1 of 3 PRs here · 1st: #1 · not on this page: 2 more'); assert.strictEqual(stageTrackerTrainHeaderText(t1.merge_train, [15425, 15529, 15530]), 'merge train · 3 PRs · 1st: #15425'); assert.strictEqual(stageTrackerTrainHeaderText(t1.merge_train), 'merge train · 3 PRs · 1st: #15425'); // No members on the page, no header. diff --git a/src/pkg/dashboard/stage_tracker_overlap_hint.test.js b/src/pkg/dashboard/stage_tracker_overlap_hint.test.js new file mode 100644 index 0000000000..4e4400ac65 --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_overlap_hint.test.js @@ -0,0 +1,78 @@ +// hive's own page, 2026-10-29 20:00 EDT: "⛁ merge train · 2 PRs · 1st: +// #15637 — overlapping: sidebar.html, index.html" under #15637 and #15633 +// while both chevrons read CI / Review. The merge train is a merge-queue +// concept: a PR short of 080 carries `overlap: {behind, with, files, note}` +// and no `merge_train` — one muted "overlaps #15637" badge on the row, no +// header, no rail, no ordinal. The helpers are lifted out of index.html so +// this runs against the shipped source. +const test = require('node:test'); +const assert = require('node:assert'); +const fs = require('node:fs'); +const path = require('node:path'); + +const html = fs.readFileSync(path.join(__dirname, 'static', 'index.html'), 'utf8'); + +function pick(re, what) { + const m = html.match(re); + assert.ok(m, what + ' not found in index.html'); + return m[0]; +} +const fn = name => pick(new RegExp('function ' + name + '\\([^)]*\\) \\{[\\s\\S]*?\\n \\}\\n'), name); + +const src = [ + "function esc(s) { return String(s).replace(/&/g, '&').replace(/ { + for (const it of [rider15633, front15637]) { + assert.strictEqual(api.trainKey(it), '', '#' + it.number + ' must group into no train'); + } + assert.strictEqual(api.badgeText(rider15633), 'overlaps #15637'); + assert.strictEqual(api.badgeText(front15637), 'overlaps #15633'); + assert.strictEqual(api.tip(rider15633), 'overlaps #15637 (sidebar.html, index.html) — will queue behind it'); + const badge = api.badgeHtml(rider15633); + assert.match(badge, /class="ham-badge ham-badge-overlap"/); + assert.match(badge, />overlaps #15637 { + const riding = Object.assign({}, rider15633, { stage: 80, merge_train: { id: 'v5#15637', state: 'queued-behind', front: 15637, position: 2, size: 2 } }); + assert.strictEqual(api.badgeText(riding), ''); + assert.strictEqual(api.badgeHtml(riding), ''); + const left = { repo: 'hivecommons/hive', number: 15405, kind: 'pr', stage: 70, left_train: { why: 'fixing', note: 'left the merge train while being fixed; rejoins when green' } }; + assert.strictEqual(api.badgeText(left), ''); + assert.deepStrictEqual(api.lines(left), ['Merge train: left the merge train while being fixed; rejoins when green']); + assert.strictEqual(api.badgeText({ kind: 'pr', number: 1, stage: 50 }), ''); + assert.deepStrictEqual(api.lines({ kind: 'pr', number: 1, stage: 50 }), []); + // An older payload without the note still reads the same sentence. + const bare = { kind: 'pr', number: 2, stage: 50, overlap: { behind: 7, with: [7], files: ['a.go'] } }; + assert.strictEqual(api.tip(bare), 'overlaps #7 (a.go) — will queue behind it'); + const bareFront = { kind: 'pr', number: 7, stage: 50, overlap: { with: [2, 3], files: ['a.go'] } }; + assert.strictEqual(api.badgeText(bareFront), 'overlaps #2 +1'); + assert.strictEqual(api.tip(bareFront), 'overlaps #2, #3 (a.go) — merges ahead of them once all are ready'); +}); diff --git a/src/pkg/dashboard/static-src/css/tracker.css b/src/pkg/dashboard/static-src/css/tracker.css index 7130a4da6a..3d43718e2b 100644 --- a/src/pkg/dashboard/static-src/css/tracker.css +++ b/src/pkg/dashboard/static-src/css/tracker.css @@ -266,6 +266,7 @@ /* "supersedes N": the closed original a live PR replaced (hive PR 15135 follow-up). Muted — a trace, not a call to act. */ .ham-badge-supersedes { color: var(--text-faint); border-color: var(--line-subtle); text-decoration: none; } .ham-badge-supersedes:hover { color: var(--text-muted); } + .ham-badge-overlap { color: var(--text-faint); border-color: var(--line-subtle); } /* Waiting-on pill without an adoption clock (071, 072 before the nudge, a human's PR): muted, hive PR 15051. */ .ham-badge-waiting { color: var(--text-faint); border-color: var(--line-subtle); } /* Presence indicator on a waiting-on pill (hive PR 15051): who the row diff --git a/src/pkg/dashboard/static-src/js/tracker-filter.js b/src/pkg/dashboard/static-src/js/tracker-filter.js index 9f8a2e0ba9..69aba16eaf 100644 --- a/src/pkg/dashboard/static-src/js/tracker-filter.js +++ b/src/pkg/dashboard/static-src/js/tracker-filter.js @@ -701,7 +701,7 @@ ? { key: e.group.key, html: stageTrackerGroupHeaderHtml(e.group, stages, ctx) } : itemRow(pageItems[i], i); const rows = stageTrackerPinnedRows(el, [{ key: STAGE_TRACKER_HEADER_KEY, html: stageTrackerHeaderHtml(stages) }] - .concat(stageTrackerTrainRows(page.rows, rowOf)), nowMs); + .concat(stageTrackerTrainRows(page.rows, rowOf, typeof stageTrackerTrainWhere === 'function' ? stageTrackerTrainWhere(ordered, d.items) : null)), nowMs); const rec = stageTrackerReconcile(el, rows, { effect, hidden: document.hidden }); if (rec.deferred) stageTrackerScheduleSettle(); // Selection is keyed on the row, never baked into its HTML, so a kept diff --git a/src/pkg/dashboard/static-src/js/tracker-row.js b/src/pkg/dashboard/static-src/js/tracker-row.js index 57ee1b917a..8be9bc4ed0 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row.js +++ b/src/pkg/dashboard/static-src/js/tracker-row.js @@ -612,7 +612,7 @@ } function stageTrackerChipsHtml(item) { - const sentinel = stageTrackerSentinelChipHtml(item) + (typeof stageTrackerAdoptionChipHtml === 'function' ? stageTrackerAdoptionChipHtml(item) : '') + (typeof stageTrackerPresenceChipHtml === 'function' ? stageTrackerPresenceChipHtml(item) : '') + (typeof stageTrackerReroutePillHtml === 'function' ? stageTrackerReroutePillHtml(item) : '') + (typeof stageTrackerSupersedesChipHtml === 'function' ? stageTrackerSupersedesChipHtml(item, Date.now()) : ''); + const sentinel = stageTrackerSentinelChipHtml(item) + (typeof stageTrackerAdoptionChipHtml === 'function' ? stageTrackerAdoptionChipHtml(item) : '') + (typeof stageTrackerPresenceChipHtml === 'function' ? stageTrackerPresenceChipHtml(item) : '') + (typeof stageTrackerReroutePillHtml === 'function' ? stageTrackerReroutePillHtml(item) : '') + (typeof stageTrackerSupersedesChipHtml === 'function' ? stageTrackerSupersedesChipHtml(item, Date.now()) : '') + (typeof stageTrackerOverlapBadgeHtml === 'function' ? stageTrackerOverlapBadgeHtml(item) : ''); const mods = (Array.isArray(item.modifiers) ? item.modifiers.slice() : []) .sort((x, y) => STAGE_TRACKER_MOD_PRIORITY.indexOf(x) - STAGE_TRACKER_MOD_PRIORITY.indexOf(y)); if (!mods.length) return sentinel; @@ -949,7 +949,7 @@ stage: lp.stage || 0, stage_since: lp.stage_since || '', stage_slug: lp.stage_slug || '', modifiers: lp.modifiers || [], deferred_modifiers: lp.deferred_modifiers || [], caption: lp.caption || '', reason: lp.reason || '', human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', base_ref: lp.base_ref || '', decision_needed: lp.decision_needed || null, adoption: lp.adoption || null, takeover: lp.takeover || null, superseded: !!lp.superseded, supersedes: lp.supersedes || null, parent: Number(issue.number) || 0, siblings: open.map(x => Number(x.number) || 0), - last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, + last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || null, decided: lp.decided || null, adopted_by: Number(lp.adopted_by) || 0, adopted_by_state: lp.adopted_by_state || '', adopted_from: lp.adopted_from || null, lineage: lp.lineage || null, state: lp.state || '', superseded_by: Number(lp.superseded_by) || 0 }; } // Pure: whether a linked PR is still open (not merged / closed / @@ -1323,7 +1323,7 @@ const who = (lp.author_kind || 'hive') + (lp.author ? ' · @' + lp.author : ''); prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRPillsHtml(stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)), (lp.lineage && typeof stageTrackerLineageChipHtml === 'function' ? stageTrackerLineageChipHtml(lp, nowMs) : '') || (typeof stageTrackerAdoptedFromChipHtml === 'function' ? stageTrackerAdoptedFromChipHtml(lp, nowMs) : '') || null, lp.base_ref)]; shown = Object.assign({}, item, { via_pr: true, stage: stageTrackerLeadStage(lp), stage_since: lp.stage_since || item.stage_since, modifiers: lp.modifiers || item.modifiers, deferred_modifiers: lp.deferred_modifiers || item.deferred_modifiers || [], caption: lp.caption || item.caption, reason: lp.reason || item.reason, - human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', decision_needed: lp.decision_needed || null, hold: lp.hold || null, adoption: lp.adoption || null, stage_actor: lp.stage_actor || item.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, decided: lp.decided || item.decided || null }); + human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', decision_needed: lp.decision_needed || null, hold: lp.hold || null, adoption: lp.adoption || null, stage_actor: lp.stage_actor || item.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || null, decided: lp.decided || item.decided || null }); } else if (linked.length) { // Several covering PRs: the issue strip ends at Claimed, all passed // and nothing lit; one sub-row per PR carries the live chevron. diff --git a/src/pkg/dashboard/static-src/js/tracker-words-core.js b/src/pkg/dashboard/static-src/js/tracker-words-core.js index cf1b5cbf07..b194c1ab10 100644 --- a/src/pkg/dashboard/static-src/js/tracker-words-core.js +++ b/src/pkg/dashboard/static-src/js/tracker-words-core.js @@ -201,9 +201,11 @@ if (lower.indexOf('required-check-failing:') === 0 || lower.indexOf('check-failing:') === 0 || lower === 'ci-red') return 'checks-failing'; return ''; } - // The first merge-ready stage (080 awaiting merge admission). A train - // member below it holds a provisional slot: the planner has ordered - // it, but CI / the review verdict / the fixer still stand in front. + // The first merge-ready stage (080 awaiting merge admission). The + // server seats no train member below it (a PR short of the queue + // carries an `overlap` hint instead); the provisional words below are + // the fallback for a payload that still does, so the chevron never + // contradicts the caption. const STAGE_TRACKER_MERGE_READY = 80; // The blocker headline for a provisional train member, by stage — // the same words the stage column shows (stageTrackerShort in Go), so @@ -413,6 +415,8 @@ else if (why) tip += ' · no estimate until #' + p.head + ' moves'; return tip + '.' + order; } + // One sentence of merge-train mechanics for every train hover. + const STAGE_TRACKER_TRAIN_MECHANICS = 'Each one is rebased onto the base only after the PR ahead of it merges — it cannot be rebased before that. Only green, approved PRs (merge queue, 080+) are counted; a PR still at CI / Review is not in the train.'; // The muted hover note on a PR the server took out of its merge train // while it is under repair (left_train: {why, note} — fixing, needs // author, needs decision, red checks). The row rides no train and @@ -424,16 +428,83 @@ if (!lt || typeof lt !== 'object' || stageTrackerTrain(item)) return ''; return String(lt.note || STAGE_TRACKER_LEFT_TRAIN_NOTE); } + /* ---- overlap hint (a PR short of the merge queue) --------------------- + The merge train is a merge-queue concept: only PRs at 080 and + beyond ride one. A PR still at CI / Review whose files overlap + another open PR's carries `overlap: {behind, with, files, note}` + instead of `merge_train` — hive's own page once drew "merge train · + 2 PRs · 1st: #15637" under two rows that both read CI / Review. The + row shows one muted badge, "overlaps #15637", whose hover is the + note: "overlaps #15637 (sidebar.html, index.html) — will queue + behind it". No rail, no ordinal, no header. */ + // Pure: the row's overlap hint, or null when it rides a train or + // overlaps nothing. + function stageTrackerOverlap(item) { + const o = item && item.overlap; + if (!o || typeof o !== 'object' || stageTrackerTrain(item)) return null; + const withPRs = (Array.isArray(o.with) ? o.with : []).map(Number).filter(n => n > 0); + if (!(Number(o.behind) > 0) && !withPRs.length) return null; + return o; + } + // Pure: the badge word — "overlaps #15637" (the PR it queues behind, + // else the first PR it overlaps, "+1" for the rest). + function stageTrackerOverlapBadgeText(item) { + const o = stageTrackerOverlap(item); + if (!o) return ''; + const withPRs = (Array.isArray(o.with) ? o.with : []).map(Number).filter(n => n > 0); + const lead = Number(o.behind) > 0 ? Number(o.behind) : withPRs[0]; + const rest = withPRs.filter(n => n !== lead).length; + return 'overlaps #' + lead + (Number(o.behind) > 0 ? '' : (rest > 0 ? ' +' + rest : '')); + } + // Pure: the hover sentence — the server's note, else built from the + // parts the same way. + function stageTrackerOverlapTip(item) { + const o = stageTrackerOverlap(item); + if (!o) return ''; + if (o.note) return String(o.note); + const files = (Array.isArray(o.files) ? o.files : []).filter(Boolean); + const paren = files.length ? ' (' + files.join(', ') + ')' : ''; + if (Number(o.behind) > 0) return 'overlaps #' + Number(o.behind) + paren + ' — will queue behind it'; + const withPRs = (Array.isArray(o.with) ? o.with : []).map(Number).filter(n => n > 0); + return 'overlaps ' + withPRs.map(n => '#' + n).join(', ') + paren + ' — merges ahead of ' + (withPRs.length > 1 ? 'them once all are ready' : 'it once both are ready'); + } + // Pure: the muted badge beside the row's chips; '' without a hint. + function stageTrackerOverlapBadgeHtml(item) { + const text = stageTrackerOverlapBadgeText(item); + if (!text) return ''; + const tip = 'Not in the merge queue yet: ' + stageTrackerOverlapTip(item); + return `${esc(text)}`; + } // Tooltip lines: the queue ahead and the overlapping files — or, for a - // PR that left its train, the one muted note. - function stageTrackerTrainLines(item) { + // PR that left its train, the one muted note — or, for a PR short of + // the merge queue, the overlap hint. + // header is true for the train header's own hover, which speaks for + // the whole train rather than one member's slot. + function stageTrackerTrainLines(item, header) { const mt = stageTrackerTrain(item); - if (!mt) { const left = stageTrackerLeftTrainNote(item); return left ? ['Merge train: ' + left] : []; } + if (!mt) { + const left = stageTrackerLeftTrainNote(item); + if (left) return ['Merge train: ' + left]; + // Guarded: test harnesses lift this function on its own. + const over = typeof stageTrackerOverlapTip === 'function' ? stageTrackerOverlapTip(item) : ''; + return over ? ['Not in the merge queue yet: ' + over] : []; + } const ahead = Array.isArray(mt.ahead) ? mt.ahead.filter(n => Number(n) > 0) : []; const files = Array.isArray(mt.overlap_files) ? mt.overlap_files.filter(Boolean) : []; - const lines = ['Merge train: ' + (Number(mt.size) || 0) + ' PRs to ' + (String(mt.id || '').split('#')[0] || 'the same base') + ' touch the same files; they merge one at a time, in order' + (mt.front ? ' (1st: #' + mt.front + ')' : '')]; - if (mt.state === STAGE_TRACKER_TRAIN_STATE_FRONT) lines.push('Position: 1st — merges next; the lane then updates or rebases the others'); - else lines.push('Position: ' + stageTrackerOrdinal(mt.position) + ' of ' + (Number(mt.size) || 0) + (ahead.length ? ' · ahead: ' + ahead.map(n => '#' + n).join(', ') : '')); + const size = Number(mt.size) || 0; + const base = String(mt.id || '').split('#')[0] || 'the same base'; + // The mechanics the owner asked about: shared files mean a fixed + // order, and a member can only rebase once the one ahead has merged. + const lines = ['Merge train: ' + size + ' PRs in the merge queue to ' + base + ' touch the same files, so they merge one at a time, in order' + (mt.front ? ' (1st: #' + mt.front + ')' : '')]; + // Guarded: test harnesses lift this function without the constant. + if (typeof STAGE_TRACKER_TRAIN_MECHANICS !== 'undefined') lines.push(STAGE_TRACKER_TRAIN_MECHANICS); + if (header) { + // nothing more: the header speaks for the whole train + } else if (mt.state === STAGE_TRACKER_TRAIN_STATE_FRONT) lines.push('Position: 1st — merges next; the lane then updates or rebases the others'); + else { + const prev = ahead.length ? ahead[ahead.length - 1] : (Number(mt.front) || 0); + lines.push('Position: ' + stageTrackerOrdinal(mt.position) + ' of ' + size + (prev ? ' · after #' + prev + ' merges' : '') + (ahead.length > 1 ? ' · ahead: ' + ahead.map(n => '#' + n).join(', ') : '')); + } if (mt.state === STAGE_TRACKER_TRAIN_STATE_REBASING) lines.push('The PR ahead merged; rebase attempt ' + (Number(mt.attempt) || 0) + ' of ' + (Number(mt.max_attempts) || 0) + ' in progress'); if (mt.state === STAGE_TRACKER_TRAIN_STATE_EXHAUSTED) lines.push('Rebase failed ' + (Number(mt.attempt) || 0) + ' of ' + (Number(mt.max_attempts) || 0) + ' times — a maintainer rebases, then merges'); if (files.length) lines.push('Overlapping files: ' + files.join(', ')); @@ -497,14 +568,36 @@ (shown || []).forEach(n => { here[Number(n)] = true; }); return Object.keys(known).map(Number).filter(n => !here[n]).sort((a, b) => a - b); } + // Pure: where a train's members are on the client, for the header's + // missing line — listed: PR numbers in the filtered, ordered list + // (any page); known: PR numbers in the whole payload. Built once per + // render in tracker-filter.js from the rows the train helpers see (a + // PR drawn under its issue counts under its own number). + function stageTrackerTrainWhere(listed, known) { + const nums = rows => { + const out = {}; + (Array.isArray(rows) ? rows : []).forEach(it => { + const rt = stageTrackerRowTrain(it && it.item ? it.item : it); + if (rt && rt.pr > 0) out[rt.pr] = true; + if (it && it.kind === 'pr' && Number(it.number) > 0) out[Number(it.number)] = true; + }); + return out; + }; + return { listed: nums(listed), known: nums(known) }; + } // Header line over a train's rows: "merge train · 4 PRs · 1st: #15074". // The count is the rows drawn under the header, never the server's // size alone: with shown (the PR numbers rendered in this run) a - // train the view only partly carries reads "merge train · 1 of 3 PRs - // here · 1st: #15425 · not in this view: #15529, #15530" so the header - // never claims rows that are not there (the train icon sits in front - // of it in the HTML). - function stageTrackerTrainHeaderText(mt, shown) { + // train the page only partly carries says where the rest are — + // "merge train · 1 of 3 PRs here · 1st: #15425 · on another page: + // #15529, #15530" or "… · hidden by the filter: #15529" — so the header + // never claims rows that are not there and never leaves the owner + // asking what "not in this view" means. The server's size counts + // only PRs in the merge queue (080 and beyond); a PR still at CI / + // Review is not a member and is not mentioned here (hivecommons/hive#15653). + // where is stageTrackerTrainWhere's answer; without it the rest read + // "not on this page". + function stageTrackerTrainHeaderText(mt, shown, where) { const size = Number(mt.size) || 0; const front = Number(mt.front) || 0; if (!Array.isArray(shown)) return 'merge train · ' + size + ' PRs · 1st: #' + front; @@ -512,23 +605,34 @@ let text = 'merge train · ' + (here < size ? here + ' of ' + size + ' PRs here' : here + (here === 1 ? ' PR' : ' PRs')) + ' · 1st: #' + front; if (here < size) { const missing = stageTrackerTrainMissing(mt, shown); - const named = missing.map(n => '#' + n); const unnamed = size - here - missing.length; - if (unnamed > 0) named.push(unnamed + ' more'); - text += ' · not in this view: ' + (named.length ? named.join(', ') : (size - here) + ' PRs'); + if (!where || !where.listed) { + const named = missing.map(n => '#' + n); + if (unnamed > 0) named.push(unnamed + ' more'); + text += ' · not on this page: ' + (named.length ? named.join(', ') : (size - here) + ' PRs'); + return text; + } + const paged = missing.filter(n => where.listed[n]); + const filtered = missing.filter(n => !where.listed[n] && where.known && where.known[n]); + const gone = missing.filter(n => !where.listed[n] && !(where.known && where.known[n])); + if (paged.length) text += ' · on another page: ' + paged.map(n => '#' + n).join(', '); + if (filtered.length) text += ' · hidden by the filter: ' + filtered.map(n => '#' + n).join(', '); + const rest = gone.map(n => '#' + n); + if (unnamed > 0) rest.push(unnamed + ' more'); + if (rest.length) text += ' · not in this payload: ' + rest.join(', '); } return text; } // idx is the train's accent slot on the page (stageTrackerTrainIndex); // the header and its rows share the rail colour it picks. - function stageTrackerTrainHeaderHtml(item, shown, idx) { + function stageTrackerTrainHeaderHtml(item, shown, idx, where) { const rt = stageTrackerRowTrain(item); if (!rt) return ''; const mt = rt.mt; const files = Array.isArray(mt.overlap_files) ? mt.overlap_files.filter(Boolean) : []; - const tip = stageTrackerTrainLines(item.kind === 'pr' ? item : { merge_train: mt }).join('\n'); + const tip = stageTrackerTrainLines(item.kind === 'pr' ? item : { merge_train: mt }, true).join('\n'); return `
- ${stageTrackerTrainIconHtml('ham-train-icon')} ${esc(stageTrackerTrainHeaderText(mt, shown))}${files.length ? `overlapping: ${esc(files.join(', '))}` : ''} + ${stageTrackerTrainIconHtml('ham-train-icon')} ${esc(stageTrackerTrainHeaderText(mt, shown, where))}${files.length ? `overlapping: ${esc(files.join(', '))}` : ''}
`; } // Row classes for a train member: the rail, whether it leads / ends @@ -547,7 +651,9 @@ // Inserts a train header entry before the first row of each train run. // Entries are {key, html}; items are the page's row items in order. The // header counts the run it heads — the rows actually drawn under it. - function stageTrackerTrainRows(items, rowOf) { + // where (stageTrackerTrainWhere) tells the header where the members + // it does not draw are. + function stageTrackerTrainRows(items, rowOf, where) { const out = []; let prevKey = ''; const list = items || []; @@ -564,7 +670,7 @@ if (!m || stageTrackerTrainKey(m) !== k) break; shown.push(stageTrackerRowTrain(m).pr); } - out.push({ key: 'train:' + k, html: stageTrackerTrainHeaderHtml(it, shown, trains.index[k]) }); + out.push({ key: 'train:' + k, html: stageTrackerTrainHeaderHtml(it, shown, trains.index[k], where) }); } prevKey = k; out.push(rowOf(e, i)); diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 09e41b7753..d0c33f547a 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -1595,6 +1595,7 @@ /* "supersedes N": the closed original a live PR replaced (hive PR 15135 follow-up). Muted — a trace, not a call to act. */ .ham-badge-supersedes { color: var(--text-faint); border-color: var(--line-subtle); text-decoration: none; } .ham-badge-supersedes:hover { color: var(--text-muted); } + .ham-badge-overlap { color: var(--text-faint); border-color: var(--line-subtle); } /* Waiting-on pill without an adoption clock (071, 072 before the nudge, a human's PR): muted, hive PR 15051. */ .ham-badge-waiting { color: var(--text-faint); border-color: var(--line-subtle); } /* Presence indicator on a waiting-on pill (hive PR 15051): who the row @@ -14641,9 +14642,11 @@

Where to get help

if (lower.indexOf('required-check-failing:') === 0 || lower.indexOf('check-failing:') === 0 || lower === 'ci-red') return 'checks-failing'; return ''; } - // The first merge-ready stage (080 awaiting merge admission). A train - // member below it holds a provisional slot: the planner has ordered - // it, but CI / the review verdict / the fixer still stand in front. + // The first merge-ready stage (080 awaiting merge admission). The + // server seats no train member below it (a PR short of the queue + // carries an `overlap` hint instead); the provisional words below are + // the fallback for a payload that still does, so the chevron never + // contradicts the caption. const STAGE_TRACKER_MERGE_READY = 80; // The blocker headline for a provisional train member, by stage — // the same words the stage column shows (stageTrackerShort in Go), so @@ -14853,6 +14856,8 @@

Where to get help

else if (why) tip += ' · no estimate until #' + p.head + ' moves'; return tip + '.' + order; } + // One sentence of merge-train mechanics for every train hover. + const STAGE_TRACKER_TRAIN_MECHANICS = 'Each one is rebased onto the base only after the PR ahead of it merges — it cannot be rebased before that. Only green, approved PRs (merge queue, 080+) are counted; a PR still at CI / Review is not in the train.'; // The muted hover note on a PR the server took out of its merge train // while it is under repair (left_train: {why, note} — fixing, needs // author, needs decision, red checks). The row rides no train and @@ -14864,16 +14869,83 @@

Where to get help

if (!lt || typeof lt !== 'object' || stageTrackerTrain(item)) return ''; return String(lt.note || STAGE_TRACKER_LEFT_TRAIN_NOTE); } + /* ---- overlap hint (a PR short of the merge queue) --------------------- + The merge train is a merge-queue concept: only PRs at 080 and + beyond ride one. A PR still at CI / Review whose files overlap + another open PR's carries `overlap: {behind, with, files, note}` + instead of `merge_train` — hive's own page once drew "merge train · + 2 PRs · 1st: #15637" under two rows that both read CI / Review. The + row shows one muted badge, "overlaps #15637", whose hover is the + note: "overlaps #15637 (sidebar.html, index.html) — will queue + behind it". No rail, no ordinal, no header. */ + // Pure: the row's overlap hint, or null when it rides a train or + // overlaps nothing. + function stageTrackerOverlap(item) { + const o = item && item.overlap; + if (!o || typeof o !== 'object' || stageTrackerTrain(item)) return null; + const withPRs = (Array.isArray(o.with) ? o.with : []).map(Number).filter(n => n > 0); + if (!(Number(o.behind) > 0) && !withPRs.length) return null; + return o; + } + // Pure: the badge word — "overlaps #15637" (the PR it queues behind, + // else the first PR it overlaps, "+1" for the rest). + function stageTrackerOverlapBadgeText(item) { + const o = stageTrackerOverlap(item); + if (!o) return ''; + const withPRs = (Array.isArray(o.with) ? o.with : []).map(Number).filter(n => n > 0); + const lead = Number(o.behind) > 0 ? Number(o.behind) : withPRs[0]; + const rest = withPRs.filter(n => n !== lead).length; + return 'overlaps #' + lead + (Number(o.behind) > 0 ? '' : (rest > 0 ? ' +' + rest : '')); + } + // Pure: the hover sentence — the server's note, else built from the + // parts the same way. + function stageTrackerOverlapTip(item) { + const o = stageTrackerOverlap(item); + if (!o) return ''; + if (o.note) return String(o.note); + const files = (Array.isArray(o.files) ? o.files : []).filter(Boolean); + const paren = files.length ? ' (' + files.join(', ') + ')' : ''; + if (Number(o.behind) > 0) return 'overlaps #' + Number(o.behind) + paren + ' — will queue behind it'; + const withPRs = (Array.isArray(o.with) ? o.with : []).map(Number).filter(n => n > 0); + return 'overlaps ' + withPRs.map(n => '#' + n).join(', ') + paren + ' — merges ahead of ' + (withPRs.length > 1 ? 'them once all are ready' : 'it once both are ready'); + } + // Pure: the muted badge beside the row's chips; '' without a hint. + function stageTrackerOverlapBadgeHtml(item) { + const text = stageTrackerOverlapBadgeText(item); + if (!text) return ''; + const tip = 'Not in the merge queue yet: ' + stageTrackerOverlapTip(item); + return `${esc(text)}`; + } // Tooltip lines: the queue ahead and the overlapping files — or, for a - // PR that left its train, the one muted note. - function stageTrackerTrainLines(item) { + // PR that left its train, the one muted note — or, for a PR short of + // the merge queue, the overlap hint. + // header is true for the train header's own hover, which speaks for + // the whole train rather than one member's slot. + function stageTrackerTrainLines(item, header) { const mt = stageTrackerTrain(item); - if (!mt) { const left = stageTrackerLeftTrainNote(item); return left ? ['Merge train: ' + left] : []; } + if (!mt) { + const left = stageTrackerLeftTrainNote(item); + if (left) return ['Merge train: ' + left]; + // Guarded: test harnesses lift this function on its own. + const over = typeof stageTrackerOverlapTip === 'function' ? stageTrackerOverlapTip(item) : ''; + return over ? ['Not in the merge queue yet: ' + over] : []; + } const ahead = Array.isArray(mt.ahead) ? mt.ahead.filter(n => Number(n) > 0) : []; const files = Array.isArray(mt.overlap_files) ? mt.overlap_files.filter(Boolean) : []; - const lines = ['Merge train: ' + (Number(mt.size) || 0) + ' PRs to ' + (String(mt.id || '').split('#')[0] || 'the same base') + ' touch the same files; they merge one at a time, in order' + (mt.front ? ' (1st: #' + mt.front + ')' : '')]; - if (mt.state === STAGE_TRACKER_TRAIN_STATE_FRONT) lines.push('Position: 1st — merges next; the lane then updates or rebases the others'); - else lines.push('Position: ' + stageTrackerOrdinal(mt.position) + ' of ' + (Number(mt.size) || 0) + (ahead.length ? ' · ahead: ' + ahead.map(n => '#' + n).join(', ') : '')); + const size = Number(mt.size) || 0; + const base = String(mt.id || '').split('#')[0] || 'the same base'; + // The mechanics the owner asked about: shared files mean a fixed + // order, and a member can only rebase once the one ahead has merged. + const lines = ['Merge train: ' + size + ' PRs in the merge queue to ' + base + ' touch the same files, so they merge one at a time, in order' + (mt.front ? ' (1st: #' + mt.front + ')' : '')]; + // Guarded: test harnesses lift this function without the constant. + if (typeof STAGE_TRACKER_TRAIN_MECHANICS !== 'undefined') lines.push(STAGE_TRACKER_TRAIN_MECHANICS); + if (header) { + // nothing more: the header speaks for the whole train + } else if (mt.state === STAGE_TRACKER_TRAIN_STATE_FRONT) lines.push('Position: 1st — merges next; the lane then updates or rebases the others'); + else { + const prev = ahead.length ? ahead[ahead.length - 1] : (Number(mt.front) || 0); + lines.push('Position: ' + stageTrackerOrdinal(mt.position) + ' of ' + size + (prev ? ' · after #' + prev + ' merges' : '') + (ahead.length > 1 ? ' · ahead: ' + ahead.map(n => '#' + n).join(', ') : '')); + } if (mt.state === STAGE_TRACKER_TRAIN_STATE_REBASING) lines.push('The PR ahead merged; rebase attempt ' + (Number(mt.attempt) || 0) + ' of ' + (Number(mt.max_attempts) || 0) + ' in progress'); if (mt.state === STAGE_TRACKER_TRAIN_STATE_EXHAUSTED) lines.push('Rebase failed ' + (Number(mt.attempt) || 0) + ' of ' + (Number(mt.max_attempts) || 0) + ' times — a maintainer rebases, then merges'); if (files.length) lines.push('Overlapping files: ' + files.join(', ')); @@ -14937,14 +15009,36 @@

Where to get help

(shown || []).forEach(n => { here[Number(n)] = true; }); return Object.keys(known).map(Number).filter(n => !here[n]).sort((a, b) => a - b); } + // Pure: where a train's members are on the client, for the header's + // missing line — listed: PR numbers in the filtered, ordered list + // (any page); known: PR numbers in the whole payload. Built once per + // render in tracker-filter.js from the rows the train helpers see (a + // PR drawn under its issue counts under its own number). + function stageTrackerTrainWhere(listed, known) { + const nums = rows => { + const out = {}; + (Array.isArray(rows) ? rows : []).forEach(it => { + const rt = stageTrackerRowTrain(it && it.item ? it.item : it); + if (rt && rt.pr > 0) out[rt.pr] = true; + if (it && it.kind === 'pr' && Number(it.number) > 0) out[Number(it.number)] = true; + }); + return out; + }; + return { listed: nums(listed), known: nums(known) }; + } // Header line over a train's rows: "merge train · 4 PRs · 1st: #15074". // The count is the rows drawn under the header, never the server's // size alone: with shown (the PR numbers rendered in this run) a - // train the view only partly carries reads "merge train · 1 of 3 PRs - // here · 1st: #15425 · not in this view: #15529, #15530" so the header - // never claims rows that are not there (the train icon sits in front - // of it in the HTML). - function stageTrackerTrainHeaderText(mt, shown) { + // train the page only partly carries says where the rest are — + // "merge train · 1 of 3 PRs here · 1st: #15425 · on another page: + // #15529, #15530" or "… · hidden by the filter: #15529" — so the header + // never claims rows that are not there and never leaves the owner + // asking what "not in this view" means. The server's size counts + // only PRs in the merge queue (080 and beyond); a PR still at CI / + // Review is not a member and is not mentioned here (hivecommons/hive#15653). + // where is stageTrackerTrainWhere's answer; without it the rest read + // "not on this page". + function stageTrackerTrainHeaderText(mt, shown, where) { const size = Number(mt.size) || 0; const front = Number(mt.front) || 0; if (!Array.isArray(shown)) return 'merge train · ' + size + ' PRs · 1st: #' + front; @@ -14952,23 +15046,34 @@

Where to get help

let text = 'merge train · ' + (here < size ? here + ' of ' + size + ' PRs here' : here + (here === 1 ? ' PR' : ' PRs')) + ' · 1st: #' + front; if (here < size) { const missing = stageTrackerTrainMissing(mt, shown); - const named = missing.map(n => '#' + n); const unnamed = size - here - missing.length; - if (unnamed > 0) named.push(unnamed + ' more'); - text += ' · not in this view: ' + (named.length ? named.join(', ') : (size - here) + ' PRs'); + if (!where || !where.listed) { + const named = missing.map(n => '#' + n); + if (unnamed > 0) named.push(unnamed + ' more'); + text += ' · not on this page: ' + (named.length ? named.join(', ') : (size - here) + ' PRs'); + return text; + } + const paged = missing.filter(n => where.listed[n]); + const filtered = missing.filter(n => !where.listed[n] && where.known && where.known[n]); + const gone = missing.filter(n => !where.listed[n] && !(where.known && where.known[n])); + if (paged.length) text += ' · on another page: ' + paged.map(n => '#' + n).join(', '); + if (filtered.length) text += ' · hidden by the filter: ' + filtered.map(n => '#' + n).join(', '); + const rest = gone.map(n => '#' + n); + if (unnamed > 0) rest.push(unnamed + ' more'); + if (rest.length) text += ' · not in this payload: ' + rest.join(', '); } return text; } // idx is the train's accent slot on the page (stageTrackerTrainIndex); // the header and its rows share the rail colour it picks. - function stageTrackerTrainHeaderHtml(item, shown, idx) { + function stageTrackerTrainHeaderHtml(item, shown, idx, where) { const rt = stageTrackerRowTrain(item); if (!rt) return ''; const mt = rt.mt; const files = Array.isArray(mt.overlap_files) ? mt.overlap_files.filter(Boolean) : []; - const tip = stageTrackerTrainLines(item.kind === 'pr' ? item : { merge_train: mt }).join('\n'); + const tip = stageTrackerTrainLines(item.kind === 'pr' ? item : { merge_train: mt }, true).join('\n'); return `
- ${stageTrackerTrainIconHtml('ham-train-icon')} ${esc(stageTrackerTrainHeaderText(mt, shown))}${files.length ? `overlapping: ${esc(files.join(', '))}` : ''} + ${stageTrackerTrainIconHtml('ham-train-icon')} ${esc(stageTrackerTrainHeaderText(mt, shown, where))}${files.length ? `overlapping: ${esc(files.join(', '))}` : ''}
`; } // Row classes for a train member: the rail, whether it leads / ends @@ -14987,7 +15092,9 @@

Where to get help

// Inserts a train header entry before the first row of each train run. // Entries are {key, html}; items are the page's row items in order. The // header counts the run it heads — the rows actually drawn under it. - function stageTrackerTrainRows(items, rowOf) { + // where (stageTrackerTrainWhere) tells the header where the members + // it does not draw are. + function stageTrackerTrainRows(items, rowOf, where) { const out = []; let prevKey = ''; const list = items || []; @@ -15004,7 +15111,7 @@

Where to get help

if (!m || stageTrackerTrainKey(m) !== k) break; shown.push(stageTrackerRowTrain(m).pr); } - out.push({ key: 'train:' + k, html: stageTrackerTrainHeaderHtml(it, shown, trains.index[k]) }); + out.push({ key: 'train:' + k, html: stageTrackerTrainHeaderHtml(it, shown, trains.index[k], where) }); } prevKey = k; out.push(rowOf(e, i)); @@ -16717,7 +16824,7 @@

Where to get help

} function stageTrackerChipsHtml(item) { - const sentinel = stageTrackerSentinelChipHtml(item) + (typeof stageTrackerAdoptionChipHtml === 'function' ? stageTrackerAdoptionChipHtml(item) : '') + (typeof stageTrackerPresenceChipHtml === 'function' ? stageTrackerPresenceChipHtml(item) : '') + (typeof stageTrackerReroutePillHtml === 'function' ? stageTrackerReroutePillHtml(item) : '') + (typeof stageTrackerSupersedesChipHtml === 'function' ? stageTrackerSupersedesChipHtml(item, Date.now()) : ''); + const sentinel = stageTrackerSentinelChipHtml(item) + (typeof stageTrackerAdoptionChipHtml === 'function' ? stageTrackerAdoptionChipHtml(item) : '') + (typeof stageTrackerPresenceChipHtml === 'function' ? stageTrackerPresenceChipHtml(item) : '') + (typeof stageTrackerReroutePillHtml === 'function' ? stageTrackerReroutePillHtml(item) : '') + (typeof stageTrackerSupersedesChipHtml === 'function' ? stageTrackerSupersedesChipHtml(item, Date.now()) : '') + (typeof stageTrackerOverlapBadgeHtml === 'function' ? stageTrackerOverlapBadgeHtml(item) : ''); const mods = (Array.isArray(item.modifiers) ? item.modifiers.slice() : []) .sort((x, y) => STAGE_TRACKER_MOD_PRIORITY.indexOf(x) - STAGE_TRACKER_MOD_PRIORITY.indexOf(y)); if (!mods.length) return sentinel; @@ -17054,7 +17161,7 @@

Where to get help

stage: lp.stage || 0, stage_since: lp.stage_since || '', stage_slug: lp.stage_slug || '', modifiers: lp.modifiers || [], deferred_modifiers: lp.deferred_modifiers || [], caption: lp.caption || '', reason: lp.reason || '', human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', base_ref: lp.base_ref || '', decision_needed: lp.decision_needed || null, adoption: lp.adoption || null, takeover: lp.takeover || null, superseded: !!lp.superseded, supersedes: lp.supersedes || null, parent: Number(issue.number) || 0, siblings: open.map(x => Number(x.number) || 0), - last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, + last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || null, decided: lp.decided || null, adopted_by: Number(lp.adopted_by) || 0, adopted_by_state: lp.adopted_by_state || '', adopted_from: lp.adopted_from || null, lineage: lp.lineage || null, state: lp.state || '', superseded_by: Number(lp.superseded_by) || 0 }; } // Pure: whether a linked PR is still open (not merged / closed / @@ -17428,7 +17535,7 @@

Where to get help

const who = (lp.author_kind || 'hive') + (lp.author ? ' · @' + lp.author : ''); prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRPillsHtml(stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)), (lp.lineage && typeof stageTrackerLineageChipHtml === 'function' ? stageTrackerLineageChipHtml(lp, nowMs) : '') || (typeof stageTrackerAdoptedFromChipHtml === 'function' ? stageTrackerAdoptedFromChipHtml(lp, nowMs) : '') || null, lp.base_ref)]; shown = Object.assign({}, item, { via_pr: true, stage: stageTrackerLeadStage(lp), stage_since: lp.stage_since || item.stage_since, modifiers: lp.modifiers || item.modifiers, deferred_modifiers: lp.deferred_modifiers || item.deferred_modifiers || [], caption: lp.caption || item.caption, reason: lp.reason || item.reason, - human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', decision_needed: lp.decision_needed || null, hold: lp.hold || null, adoption: lp.adoption || null, stage_actor: lp.stage_actor || item.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, decided: lp.decided || item.decided || null }); + human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', decision_needed: lp.decision_needed || null, hold: lp.hold || null, adoption: lp.adoption || null, stage_actor: lp.stage_actor || item.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, left_train: lp.left_train || null, overlap: lp.overlap || null, decided: lp.decided || item.decided || null }); } else if (linked.length) { // Several covering PRs: the issue strip ends at Claimed, all passed // and nothing lit; one sub-row per PR carries the live chevron. @@ -18909,7 +19016,7 @@

All labels

? { key: e.group.key, html: stageTrackerGroupHeaderHtml(e.group, stages, ctx) } : itemRow(pageItems[i], i); const rows = stageTrackerPinnedRows(el, [{ key: STAGE_TRACKER_HEADER_KEY, html: stageTrackerHeaderHtml(stages) }] - .concat(stageTrackerTrainRows(page.rows, rowOf)), nowMs); + .concat(stageTrackerTrainRows(page.rows, rowOf, typeof stageTrackerTrainWhere === 'function' ? stageTrackerTrainWhere(ordered, d.items) : null)), nowMs); const rec = stageTrackerReconcile(el, rows, { effect, hidden: document.hidden }); if (rec.deferred) stageTrackerScheduleSettle(); // Selection is keyed on the row, never baked into its HTML, so a kept