From fa84263530439b6a364db91a7d2261e2bc9e9659 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Thu, 29 Oct 2026 18:48:16 -0400 Subject: [PATCH] fix(dashboard): stalled merge-queue chevrons read their words MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Riders behind a stalled train head (#15529, #15530 behind untrusted-author #15425) drew an active amber chevron with no visible words: the stalled label was in the DOM but painted --yellow (.ham-queue-stalled) on the amber .ham-seg.active fill. The text now inherits the chevron colour and reads "Merge queue · stalled — waiting on #15425 (needs maintainer merge) · 1h21m" (head row: "Merge queue · stalled — needs maintainer merge · 1h21m"), every head_state has words, and an unmapped merge_train.state falls back to its humanised name plus place instead of an empty string. Ratchets: node test over every train state x stalled x head_state x place asserts non-empty, slug-free chevron words; Go test asserts every emitted merge_train carries a documented state/head_state. Signed-off-by: Andrew Anderson --- .../fixed-empty-merge-queue-chevron.md | 1 + src/docs/dashboard-copy-inventory.md | 1 + src/docs/dashboard-sections.md | 4 +- src/docs/operator-reference.md | 2 +- .../stage_tracker_merge_gate_test.go | 3 + .../stage_tracker_merge_train_queue_test.go | 97 ++++++++++++++++++- .../stage_tracker_merge_train_test.go | 5 +- src/pkg/dashboard/static-src/css/tracker.css | 4 + .../dashboard/static-src/js/tracker-queue.js | 2 +- .../dashboard/static-src/js/tracker-words.js | 39 ++++++-- src/pkg/dashboard/static/index.html | 45 +++++++-- 11 files changed, 180 insertions(+), 23 deletions(-) create mode 100644 changelog.d/fixed-empty-merge-queue-chevron.md diff --git a/changelog.d/fixed-empty-merge-queue-chevron.md b/changelog.d/fixed-empty-merge-queue-chevron.md new file mode 100644 index 0000000000..f49a45f3f3 --- /dev/null +++ b/changelog.d/fixed-empty-merge-queue-chevron.md @@ -0,0 +1 @@ +- Activity Monitor: a stalled merge train's chevron no longer renders as an empty amber chevron — the stall words were painted ochre on amber; they now inherit the chevron colour and read `Merge queue · stalled — waiting on # (needs maintainer merge) · 1h21m`, every `merge_train.state`/`head_state` maps to words, and an unmapped state falls back to its humanised name plus place instead of `''` diff --git a/src/docs/dashboard-copy-inventory.md b/src/docs/dashboard-copy-inventory.md index 84d3e6cf4d..6ef6e257de 100644 --- a/src/docs/dashboard-copy-inventory.md +++ b/src/docs/dashboard-copy-inventory.md @@ -102,6 +102,7 @@ old name). | `STAGE_TRACKER_TRAIN_STATE_WORD` (`tracker-words.js`) | chevron label, gate pill | `front` → *Next to merge*, `queued-behind` → *In merge queue* | both *Merge queued*; the place tells them apart | `TestStageTrackerMergeTrainStateSlugsNeverLeak` | | `stageTrackerTrainWord` | chevron label | *In merge queue · 2 of 6* / *front* (leaked) | *Merge queued · 1st* / *· 2nd* / *· 3rd* … + *· ~4m* countdown | `TestStageTrackerMergeTrainOrdinalWords` | | `stageTrackerOrdinal` | chevron, hover, popover | — | `1st 2nd 3rd 4th … 11th 12th 13th 21st 22nd 23rd` | same | +| `stageTrackerTrainStalledWord` + `STAGE_TRACKER_TRAIN_HEAD_STALL_WORD` | chevron label (stalled train), Merge queue popover | *Merge queue stalled · head #15425 waiting for a maintainer (untrusted author) 1h21m* — painted `--yellow` on the amber active chevron, so the row read as an **empty** chevron (#15529, #15530) | rider: *Merge queue · stalled — waiting on #15425 (needs maintainer merge) · 1h21m*; head row: *Merge queue · stalled — needs maintainer merge · 1h21m*; the why comes from `head_state` (`needs-human` → *needs maintainer merge* / *needs a human decision*, `ci` → *waiting for CI*, `soaking` → *soak overran*, `ready` → *waiting for a merge sweep*, `merging` → *merge call in flight*, `fixing` → *being fixed by its author*, `unknown` → *head not in this view*); an unmapped `merge_train.state` falls back to its humanised name + place (*Waiting for front · 3rd*), never `''`; `.ham-seg.active .ham-queue-stalled` inherits the chevron's text colour | `TestStageTrackerMergeTrainStateSlugsNeverLeak` (every state × stalled × head_state × place), `TestStageTrackerMergeTrainPayloadStates` | | `stageTrackerTrainQueueTip` | chevron hover | *Behind #15253 … Estimated turn: ~25m.* / *Front of the merge queue* | *2nd of 6 in the merge queue · behind #15253 · ETA ~25m.* / *1st of 6 in the merge queue · merges next · ETA ~4m.*; *· merge sweep running* lives here only (one label per chevron, #15416) | same | | `stageTrackerTrainHeaderText` + `stageTrackerTrainIconHtml` | train header chip | `⛓ merge train · 2 PRs · front #15400` | 🚆 (inline-SVG railcar, hover *Merge queue*) `merge train · 2 PRs · 1st: #15400` | `TestStageTrackerMergeTrain` | | `stageTrackerQueueMemberState` (`tracker-queue.js`) | Merge queue popover | *front of the queue* | *merges next* | `TestStageTrackerMergeQueuePopover` | diff --git a/src/docs/dashboard-sections.md b/src/docs/dashboard-sections.md index 684501a83e..2ff5d1bd12 100644 --- a/src/docs/dashboard-sections.md +++ b/src/docs/dashboard-sections.md @@ -923,7 +923,7 @@ The tooltip lists the PRs ahead and the overlapping files. Waiting siblings are - **Countdown to auto-merge.** `eta_s` is the member's own remaining soak, plus — for each PR ahead — its remaining soak or, with no clock of its own, one sweep (the lanes' floor cadence), plus the wait for the next sweep tick; `eta_basis` is the short reading ("2 ahead · head soaking 12m · next sweep in 40s"). The chip's `· ~4m` counts down in place from `eta_at` on the same tick as the soak clock, and `eta_at` is anchored server-side to the member's first estimate at its position (re-anchored only when a fresh estimate runs more than a sweep longer), so a poll re-render never resets it. Past the estimate it reads *any sweep now*; past twice the first estimate `late` is set and the chip reads *running late* with the estimate kept in the hover. Always a `~`: an estimate, not a promise. A head on a person, on CI or being fixed — or a member that is itself a person's — carries no estimate and the blocker instead. - **Merge queue popover.** The sticky bar's **🚆 Merge queue N** chip (hidden with no train) opens a popover listing every train in merge order — ordinal, #, title, state in words, ETA — with the head's blocker on the front row; same pattern as the **Merged** popover (click outside / Escape closes). - **Who rides.** A PR GitHub reports conflicting (`mergeable: CONFLICTING` / `DIRTY`) on its own, or one at **072 Returned to contributor** (by label or by the hive's stage record), is neither a member nor counted in the queue's length and draws no train idle comment — hive's own #15307 once read `queued-behind#15424:4/6` while conflicting at 072. A conflicting PR rides only while the train itself is repairing it (its rebase was requested behind a merged head and the loop guard still has attempts). -- **Stall warning.** Once the head has sat in one stage longer than `governor.merge_train_stall_warn_s` (default 3600) and is not merging — a soaking head counts only once its own clock has overrun — every member's chip turns to **Merge queue stalled · head #15253 waiting for CI 3h**, the popover marks the train, and the activity log records one `merge train stalled` line per train per hour. +- **Stall warning.** Once the head has sat in one stage longer than `governor.merge_train_stall_warn_s` (default 3600) and is not merging — a soaking head counts only once its own clock has overrun — every member's chip turns to **Merge queue · stalled — waiting on #15253 (waiting for CI) · 3h** (the head's own row: **Merge queue · stalled — waiting for CI · 3h**; an untrusted-author head reads *needs maintainer merge*), the popover marks the train, and the activity log records one `merge train stalled` line per train per hour. #### Pills before the merge gate @@ -1193,7 +1193,7 @@ Every PR at the gate now carries `merge_gate: {state, reason, sweep_running, las | 080 awaiting merge admission | **Ready for auto merge** | *next sweep in 42s* (counts down in place; *sweep due now* once past) | 🕓 clock — *Approved and green; waiting for hive's merge sweep — next sweep in 42s. …* | | 095 pre-merge soak | **Soaking** | *7m left* (counts down; *soak window complete* once past) | 🕓 clock — *Admitted by the automerge lane; waiting for the soak window: 7m left. hive merges on its first sweep after that.* | | any of the above while a pass is evaluating this PR | the stage's word | *merge sweep running* | ⟳ (static) — *hive's merge sweep is running on this PR now.* | -| 080 in a merge train (`merge_gate.state: queued-behind` / `front`) | **Merge queued · 2nd · ~4m** / **Merge queued · 1st** (ordinal place and countdown; **Merge queue stalled · head #15253 waiting for CI 3h** once stalled) | *~4m* (counts down to its estimated turn from `merge_train.eta_at`; *any sweep now* once past; *running late* past twice the first estimate; nothing while the head is on a person or CI) — the words never change with the sweep | 🕓 clock, or ⟳ spinning while a sweep evaluates it — *Behind #15253 (soaking, 12m left) and 1 more. Hive merges one at a time, in order. Estimated turn: ~25m (2 ahead · head soaking 12m · next sweep in 40s). Checking now… Last checked 12s ago.* | +| 080 in a merge train (`merge_gate.state: queued-behind` / `front`) | **Merge queued · 2nd · ~4m** / **Merge queued · 1st** (ordinal place and countdown; **Merge queue · stalled — waiting on #15253 (waiting for CI) · 3h** once stalled) | *~4m* (counts down to its estimated turn from `merge_train.eta_at`; *any sweep now* once past; *running late* past twice the first estimate; nothing while the head is on a person or CI) — the words never change with the sweep | 🕓 clock, or ⟳ spinning while a sweep evaluates it — *Behind #15253 (soaking, 12m left) and 1 more. Hive merges one at a time, in order. Estimated turn: ~25m (2 ahead · head soaking 12m · next sweep in 40s). Checking now… Last checked 12s ago.* | | 100 merge queue | **Merging** | — | ⟳ (static) — *Admitted and soaked; hive is merging it now (GitHub merge queue / merge window).* | | any stage while hive's merge call is in flight (`merge_gate.merging_since`, `merge_path`) | **Merging** | *merge call in flight*, then *merge landed* while the SPA holds the row | ⟳ (static) — *hive is merging it now (automerge sweep) — the merge call has been in flight since 3s ago.* | | any stage after GitHub refused hive's merge call (`merge_gate.state: merge-failed`, `merge_failed`, `merge_failed_kind`, `merge_failed_text`, `merge_failed_at`) | **Merge failed** | the refusal translated to a short phrase — *branch protection*, *needs rebase*, *not allowed*, *review required*, or *retrying* while the sweep is on it; never GitHub's raw text | 🕓 clock — *hive tried to merge this (maintainer merge from the dashboard) 9s ago and GitHub refused — branch protection blocks it. The lane re-evaluates it on its next pass. Details: 405 Pull Request is not mergeable* | diff --git a/src/docs/operator-reference.md b/src/docs/operator-reference.md index 5fda95f7c2..0dec23abf4 100644 --- a/src/docs/operator-reference.md +++ b/src/docs/operator-reference.md @@ -247,7 +247,7 @@ Go callers keep reading `cfg.Agents`, `cfg.Governor.Gateways` and so on through | `review.reviewers.autoscale.*` | `enabled: false`; when on: `min: 1`, `max: 4` (≤ the replicas cap 5), `target_backlog_per_reviewer: 2`, `scale_up_cycles: 2`, `scale_down_cycles: 5`, `cooldown: 5m`, `cpu_per_reviewer: 1.0`, `mem_per_reviewer_mb: 2048`, `agent` unset (first `role: reviewer` agent, else `reviewer_agents[0]`); owner-only. | Sizes the reviewer lane to its backlog ([#14685](https://github.com/hivecommons/hive/issues/14685)): adds a `reviewer-N` replica after `scale_up_cycles` cycles with more PRs waiting for a free reviewer than `target_backlog_per_reviewer` per reviewer (or a wait older than the review-pending stage dwell), drains the top replica after `scale_down_cycles` idle cycles and retires it only when its turn ends. Scale-ups are refused by named guards (`at-max`, `cooldown`, `saturated` kicks, `provider-budget`, `provider-headroom`, `max-parallel-reviews`, cgroup `cpu` / `memory`). Decisions log as `reviewer autoscale: 2→3 reason=…`; state is in `/api/status.reviewerAutoscale`. See [review-swarm.md](review-swarm.md#reviewer-autoscale-reviewreviewersautoscale). | | `review.contributor_prs.base_sync` | Off by default; owner-only. | Lets PR follow-up use GitHub's update-branch API on hive-authored lane PRs whose head is in a contributor fork, whose `mergeable_state` is `behind`/`dirty`, and whose author enabled "allow edits by maintainers". `behind` PRs get a GitHub-authored merge commit; `dirty`/422 falls back to the `hive-base-moved` repair note and kick. This requires an agent/proxy mode with `ISSUES_PRS_MERGE` because `PUT /pulls/{n}/update-branch` is merge-scoped. It does not rewrite history and does not add a human/bot-authored DCO commit; the repository's "Sign-off survives the squash" check examines the PR's own commits, not GitHub's update-branch merge commit. | | `governor.advisory.post_retry_backoff_s` | `3600` seconds. `HIVE_ADVISORY_POST_RETRY_BACKOFF_S` overrides the default when the key is unset; a negative value disables the pause. | How long the advisory digest write is paused after GitHub refuses it with `403 Resource not accessible by integration`. That refusal is structural (foreign-authored comment, repo dropped from the installation, or repo transferred to another owner), so per-cycle retries only burn API quota. The failed edit first falls back to creating a fresh App-authored comment; if the create is refused too, the error is recorded for the hub health row — naming the new `owner/repo` when the repository has moved — and attempts pause for this window. See [advisory.md](advisory.md#when-the-write-is-refused). | -| `governor.merge_train_stall_warn_s` | `3600` seconds; `0` disables | How long the head of a merge train may sit in one stage before the Activity Monitor reads the train **stalled** — the queued chip turns to "Merge queue stalled · head #15253 waiting for CI 3h", the Merge queue popover marks the train, and the activity log records one `merge train stalled` line per train per hour naming the head, its state and how long. A soaking head is on its clock, not stalled, until that clock itself overruns the window ([#15395](https://github.com/hivecommons/hive/issues/15395)). | +| `governor.merge_train_stall_warn_s` | `3600` seconds; `0` disables | How long the head of a merge train may sit in one stage before the Activity Monitor reads the train **stalled** — the queued chip turns to "Merge queue · stalled — waiting on #15253 (waiting for CI) · 3h", the Merge queue popover marks the train, and the activity log records one `merge train stalled` line per train per hour naming the head, its state and how long. A soaking head is on its clock, not stalled, until that clock itself overruns the window ([#15395](https://github.com/hivecommons/hive/issues/15395)). | | `governor.trajectory.enabled` | Defaults to enabled. | The lane no-ops until a reviewer endpoint and model resolve from `governor.trajectory` or `governor.litellm`. | | `governor.kick_limits.max_issues` / `max_prs` | `100` / `50` | Caps on every issue list and every PR list (actionable, stale drafts, merge-eligible, CI-failing) rendered into a kick prompt; a cut list ends with an explicit "… and N more" line. An absent key or a negative value means the default; an explicit `0` opts out of the cap entirely (`KickListUnlimited` — every item is listed), and anything above `500` is pinned to `500`. Editable without touching this file under **Settings → Repos → Kick prompt list caps**. Truncation drops the *newest, lowest-priority* items: issues are listed oldest first, and PRs in review-priority order (fixes, then refactors/docs, then tests, oldest first within each class), so lowering a cap never hides the most urgent work. Raise `max_prs` only if your agents actually work more than 50 PRs per turn; the tail of a long list costs tokens and delivery time on every kick without changing behaviour (#7368). | | `project.agents_md_max_bytes` | `8192`; values under `2048` are raised to `2048`. | Caps the repo `AGENTS.md` block prepended to a kick. Whole sections (split at `#`/`##` headings; each resolved skill is its own unit) are kept or dropped, never clipped mid-rule; when any are dropped the kick carries a one-line `⚠️ AGENTS.md exceeded N bytes; … — read AGENTS.md …` warning naming them and the scheduler logs it. See [agents-md.md](agents-md.md#size-cap-whole-sections-visible-warning). | diff --git a/src/pkg/dashboard/stage_tracker_merge_gate_test.go b/src/pkg/dashboard/stage_tracker_merge_gate_test.go index 90c5f1a36b..bbc523b389 100644 --- a/src/pkg/dashboard/stage_tracker_merge_gate_test.go +++ b/src/pkg/dashboard/stage_tracker_merge_gate_test.go @@ -322,6 +322,9 @@ func stageTrackerTrainQueueJS(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerOrdinal"), jsFunc(t, html, "stageTrackerShortLeft"), jsFunc(t, html, "stageTrackerTrainPlace"), + jsConstLine(t, html, "STAGE_TRACKER_TRAIN_STALLED_LEAD"), + jsConstLine(t, html, "STAGE_TRACKER_TRAIN_HEAD_STALL_WORD"), + jsFunc(t, html, "stageTrackerTrainStallWhy"), jsFunc(t, html, "stageTrackerTrainStalledWord"), jsFunc(t, html, "stageTrackerTrainWord"), jsFunc(t, html, "stageTrackerTrainEtaAt"), diff --git a/src/pkg/dashboard/stage_tracker_merge_train_queue_test.go b/src/pkg/dashboard/stage_tracker_merge_train_queue_test.go index 170e13ed86..a5abbe699a 100644 --- a/src/pkg/dashboard/stage_tracker_merge_train_queue_test.go +++ b/src/pkg/dashboard/stage_tracker_merge_train_queue_test.go @@ -4,11 +4,14 @@ import ( "bytes" "encoding/json" "log/slog" + "slices" "strings" "testing" "time" + "github.com/hivecommons/hive/pkg/github" "github.com/hivecommons/hive/pkg/stageengine/prstage" + "github.com/hivecommons/hive/pkg/stagelabels" ) // The chip's queue facts (hivecommons/hive#15395): position / length, the @@ -261,7 +264,7 @@ assert.ok(s.tip.startsWith('3rd of 3 in the merge queue · behind #15315 (soakin // Stalled: the chip says so, names the head and how long; the markup wears the stalled class. const stalled = mk(15374, 'tracker: queue', Object.assign({ state: 'queued-behind', position: 3, ahead: [15315, 15319], stalled: true, stalled_s: 3 * 3600 }, headFacts), { sweep_running: true }); const st = stageTrackerMergeGateInfo(stalled, now); -assert.strictEqual(st.word, 'Merge queue stalled · head #15315 waiting for a maintainer (untrusted author) 3h'); +assert.strictEqual(st.word, 'Merge queue · stalled — waiting on #15315 (needs maintainer merge) · 3h'); assert.ok(stageTrackerMergeGateWordHtml(stalled, now).includes('class="ham-seg-t ham-queue-stalled"')); assert.strictEqual(stageTrackerMergeGateInfo(mk(15374, 't', Object.assign({ state: 'queued-behind', position: 3, stalled: true, stalled_s: 3 * 3600 }, headFacts), { sweep_running: false }), now).word, st.word, 'stalled label is sweep-stable too'); // The front row reads its place too. @@ -332,6 +335,59 @@ var mergeTrainStateSlugs = []string{ prstage.MergeTrainStateDuplicateOf, } +// mergeTrainHeadStates is every head_state a merge train reports on its +// members; STAGE_TRACKER_TRAIN_HEAD_STALL_WORD must word each one. +var mergeTrainHeadStates = []string{ + mergeTrainHeadNeedsHuman, mergeTrainHeadCI, mergeTrainHeadSoaking, mergeTrainHeadReady, + mergeTrainHeadMerging, mergeTrainHeadFixing, mergeTrainHeadUnknown, +} + +// TestStageTrackerMergeTrainPayloadStates: every merge_train the tracker +// emits carries a state from the documented set and, once the queue facts +// are on it, a head_state from the documented set — the SPA's word tables +// are keyed on exactly these (hivecommons/hive#15530's chevrons read empty). +func TestStageTrackerMergeTrainPayloadStates(t *testing.T) { + now := time.Date(2026, 10, 29, 15, 6, 0, 0, time.UTC) + s, store := stageTrackerFixture(t, now) + overlap := []string{"tracker-row.js", "index.html"} + store.Observe(stagelabels.Key("acme/console", 15425), stagelabels.ReadyForHumanMerge, "") + for i, n := range []int{15529, 15530} { + store.Observe(stagelabels.Key("acme/console", n), stagelabels.AwaitingMergeAdmission, + prstage.MergeTrain{State: prstage.MergeTrainStateQueuedBehind, Front: 15425, Position: i + 2, Size: 3, OverlapFiles: overlap}.Reason()) + } + s.statusMu.Lock() + for _, n := range []int{15425, 15529, 15530} { + stage := "stage/080-awaiting-merge-admission" + if n == 15425 { + stage = "stage/090-ready-for-human-merge" + } + s.status.Repos[0].OpenPrs = append(s.status.Repos[0].OpenPrs, + FrontendPR{PullRequest: github.PullRequest{Number: n, Title: "Tracker change", Author: "someone", BaseRef: "v5", Labels: []string{stage}}}) + } + s.statusMu.Unlock() + resp := s.buildStageTracker(s.status, store, now) + seen := 0 + for _, it := range resp.Items { + mt := it.MergeTrain + if mt == nil { + continue + } + seen++ + if !slices.Contains(mergeTrainStateSlugs, mt.State) { + t.Errorf("#%d merge_train.state %q is not a documented train state %v", it.Number, mt.State, mergeTrainStateSlugs) + } + if mt.HeadState != "" && !slices.Contains(mergeTrainHeadStates, mt.HeadState) { + t.Errorf("#%d merge_train.head_state %q is not a documented head state %v", it.Number, mt.HeadState, mergeTrainHeadStates) + } + if mt.Position <= 0 || mt.Size <= 0 { + t.Errorf("#%d merge_train has no place: %+v", it.Number, mt) + } + } + if seen < 3 { + t.Fatalf("expected the head and both riders to carry merge_train, saw %d", seen) + } +} + // TestStageTrackerMergeTrainStateSlugsNeverLeak renders every train state // through the chip words (with and without a soak clock and a running // sweep) and fails if a slug shows up where a person reads. @@ -344,6 +400,13 @@ func TestStageTrackerMergeTrainStateSlugsNeverLeak(t *testing.T) { } } slugsJSON, _ := json.Marshal(mergeTrainStateSlugs) + headStatesJSON, _ := json.Marshal(mergeTrainHeadStates) + stallTable := jsConstLine(t, html, "STAGE_TRACKER_TRAIN_HEAD_STALL_WORD") + for _, hs := range mergeTrainHeadStates { + if !strings.Contains(stallTable, "'"+hs+"'") && !strings.Contains(stallTable, " "+hs+":") { + t.Errorf("STAGE_TRACKER_TRAIN_HEAD_STALL_WORD has no words for head_state %q: %s", hs, stallTable) + } + } runStageTrackerRowActionsScript(t, "function esc(s) { return String(s).replace(/&/g, '&').replace(/ s !== 'duplicate-of')) for (const stalled of [false, true]) for (const hs of [...headStates, '']) for (const pos of [0, 1, 2, 3]) { + const mt = { id: 'v5#15425', state, front: 15425, head_number: 15425, size: 3, length: 3, attempt: 1, max_attempts: 2, head_state: hs, head_reason: hs === 'needs-human' ? 'waiting for a maintainer (untrusted author)' : '', stalled, stalled_s: stalled ? 4851 : 0 }; + if (pos) mt.position = pos; + const item = { repo: 'hivecommons/hive', number: 15530, kind: 'pr', title: 't', stage: 80, modifiers: stalled ? ['stalled'] : [], merge_train: mt, merge_gate: { state, sweep_running: true, last_sweep_at: '2026-10-29T15:05:30Z' } }; + const label = state + (stalled ? '/stalled' : '') + '/' + (hs || 'no-head') + '/pos' + pos; + const word = stageTrackerTrainWord(item); + assert.ok(word && word.trim() && !leaks(word, state), label + ' train word: ' + JSON.stringify(word)); + const info = stageTrackerMergeGateInfo(item, now); + assert.ok(info && info.word && info.word.trim(), label + ' chip word: ' + JSON.stringify(info)); + const text = stageTrackerMergeGateWordHtml(item, now).replace(/<[^>]+>/g, '').trim(); + assert.ok(text && !leaks(text, state), label + ' chip html: ' + JSON.stringify(text)); + if (stalled && (state === 'front' || state === 'queued-behind')) assert.ok(word.startsWith(STAGE_TRACKER_TRAIN_STALLED_LEAD) && word.includes('1h21m'), label + ': ' + word); +} +// The owner's two rows (#15529 2nd, #15530 3rd behind #15425, head needs +// a maintainer): the chevron says what it waits on and why. +const mk = (n, title, mt, gate) => ({ repo: 'hivecommons/hive', number: n, kind: 'pr', title, stage: 80, modifiers: mt.stalled ? ['stalled'] : [], merge_train: mt, merge_gate: Object.assign({ state: mt.state, sweep_running: true }, gate || {}) }); +const rider = mk(15530, 'issue-row linked PR', { state: 'queued-behind', position: 3, ahead: [15425, 15529], front: 15425, head_number: 15425, id: 'v5#15425', head_state: 'needs-human', head_reason: 'waiting for a maintainer (untrusted author)', stalled: true, stalled_s: 4851 }, { sweep_running: true }); +assert.strictEqual(stageTrackerTrainWord(rider), 'Merge queue · stalled — waiting on #15425 (needs maintainer merge) · 1h21m'); +assert.strictEqual(stageTrackerMergeGateWordHtml(rider, now).replace(/<[^>]+>/g, ''), 'Merge queue · stalled — waiting on #15425 (needs maintainer merge) · 1h21m'); +// The head's own row says what it needs, not "waiting on" itself. +const headRow = mk(15425, 'head', { state: 'front', position: 1, ahead: [], front: 15425, head_number: 15425, id: 'v5#15425', head_state: 'needs-human', head_reason: 'waiting for a maintainer (untrusted author)', stalled: true, stalled_s: 4851 }); +assert.strictEqual(stageTrackerTrainWord(headRow), 'Merge queue · stalled — needs maintainer merge · 1h21m'); +// A head on a human decision reads the decision, not a merge. +assert.strictEqual(stageTrackerTrainStallWhy({ head_state: 'needs-human', head_reason: 'waiting for a human decision' }), 'needs a human decision'); +// An unmapped head_state falls back to the head's plain-word reason. +assert.strictEqual(stageTrackerTrainStallWhy({ head_state: 'something-new', head_reason: 'doing a thing; details' }), 'doing a thing'); assert.strictEqual(stageTrackerMergeGateStateWord('front'), 'Merge queued'); assert.strictEqual(stageTrackerMergeGateStateWord('duplicate-of:15402'), 'Duplicate of #15402'); // The held duplicate's chip: "Duplicate of #15402 · needs a pick", the hover names the issue and the pick rule. diff --git a/src/pkg/dashboard/stage_tracker_merge_train_test.go b/src/pkg/dashboard/stage_tracker_merge_train_test.go index 1b383e15ec..0caf697564 100644 --- a/src/pkg/dashboard/stage_tracker_merge_train_test.go +++ b/src/pkg/dashboard/stage_tracker_merge_train_test.go @@ -236,6 +236,9 @@ func TestStageTrackerMergeTrainSPA(t *testing.T) { jsFunc(t, html, "stageTrackerOrdinal"), jsFunc(t, html, "stageTrackerShortLeft"), jsFunc(t, html, "stageTrackerTrainPlace"), + jsConstLine(t, html, "STAGE_TRACKER_TRAIN_STALLED_LEAD"), + jsConstLine(t, html, "STAGE_TRACKER_TRAIN_HEAD_STALL_WORD"), + jsFunc(t, html, "stageTrackerTrainStallWhy"), jsFunc(t, html, "stageTrackerTrainStalledWord"), jsFunc(t, html, "stageTrackerTrainWord"), jsFunc(t, html, "stageTrackerTrainEtaAt"), @@ -303,7 +306,7 @@ const thirdQ = mk(15374, 80, { state: 'queued-behind', position: 3, ahead: [1531 assert.strictEqual(stageTrackerTrainWord(thirdQ), 'Merge queued · 3rd'); assert.strictEqual(stageTrackerTrainQueueTip(thirdQ.merge_train), '3rd of 3 in the merge queue · behind #15315 (waiting for a maintainer (untrusted author)) · no estimate until #15315 moves. Hive merges one at a time, in order.'); const stalledQ = mk(15374, 80, { state: 'queued-behind', position: 3, ahead: [15315, 15319], length: 3, head_number: 15315, head_state: 'ci', head_reason: 'waiting for CI', stalled: true, stalled_s: 3 * 3600 }); -assert.strictEqual(stageTrackerTrainWord(stalledQ), 'Merge queue stalled · head #15315 waiting for CI 3h'); +assert.strictEqual(stageTrackerTrainWord(stalledQ), 'Merge queue · stalled — waiting on #15315 (waiting for CI) · 3h'); assert.ok(stageTrackerTrainQueueTip(stalledQ.merge_train).includes('#15315 has not moved for 3h'), stageTrackerTrainQueueTip(stalledQ.merge_train)); // Neither slug nor the word "front" reaches a person: chevron word, hover, // tooltip lines, header chip and the ⛓-era header text (owner: "i dont diff --git a/src/pkg/dashboard/static-src/css/tracker.css b/src/pkg/dashboard/static-src/css/tracker.css index cade002a7b..6451e724d9 100644 --- a/src/pkg/dashboard/static-src/css/tracker.css +++ b/src/pkg/dashboard/static-src/css/tracker.css @@ -510,6 +510,10 @@ .ham-queue-train { margin: var(--sp-3) 0 var(--sp-2); font-weight: var(--fw-semibold); } .ham-queue-train:first-of-type { margin-top: 0; } .ham-queue-stalled { color: var(--yellow); } + /* Inside a lit chevron the word keeps the chevron's ink: ochre on the + amber fill was invisible, so a stalled train's chevrons read empty + (just the ⟳ and the actor glyph). */ + .ham-seg.active .ham-seg-t.ham-queue-stalled { color: inherit; } .merge-banners { position: fixed; right: var(--sp-6); bottom: var(--sp-6); z-index: var(--z-merge-banner); display: flex; flex-direction: column; gap: var(--sp-3); max-width: min(26rem, calc(100vw - 2 * var(--sp-6))); pointer-events: none; } .merge-banner { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--sp-4); align-items: start; padding: var(--sp-4) var(--sp-5); border: var(--line-width) solid var(--line); border-left: 3px solid var(--green); border-radius: var(--r); background: var(--panel-strong); color: var(--text); box-shadow: var(--shadow-raised); font-size: var(--fs-sm); pointer-events: auto; animation: merge-banner-in 220ms ease-out both; } .merge-banner.merge-banner-out { animation: merge-banner-out 180ms ease-in both; } diff --git a/src/pkg/dashboard/static-src/js/tracker-queue.js b/src/pkg/dashboard/static-src/js/tracker-queue.js index fa92803270..61f6a44111 100644 --- a/src/pkg/dashboard/static-src/js/tracker-queue.js +++ b/src/pkg/dashboard/static-src/js/tracker-queue.js @@ -42,7 +42,7 @@ const place = stageTrackerTrainPlace(t.mt); const stalled = stageTrackerTrainStalledWord(t.mt); const base = String(t.mt.id || '').split('#')[0] || 'base'; - const title = `
${stageTrackerTrainIconHtml('ham-train-icon')} ${esc(String(t.repo || ''))} → ${esc(base)} · ${esc(String(place.len))} PRs · head #${esc(String(place.head))}${stalled ? ' · ' + esc(stalled.replace(/^Merge queue stalled · /, 'stalled: ')) : ''}
`; + const title = `
${stageTrackerTrainIconHtml('ham-train-icon')} ${esc(String(t.repo || ''))} → ${esc(base)} · ${esc(String(place.len))} PRs · head #${esc(String(place.head))}${stalled ? ' · ' + esc(stalled.replace(STAGE_TRACKER_TRAIN_STALLED_LEAD, 'stalled: ')) : ''}
`; const rows = t.members.map(it => { const mt = it.merge_train || {}; const n = esc(String(it.number || '')); diff --git a/src/pkg/dashboard/static-src/js/tracker-words.js b/src/pkg/dashboard/static-src/js/tracker-words.js index 342ae32db7..1cc39d517a 100644 --- a/src/pkg/dashboard/static-src/js/tracker-words.js +++ b/src/pkg/dashboard/static-src/js/tracker-words.js @@ -197,21 +197,43 @@ function stageTrackerTrainPlace(mt) { return { head: Number(mt.head_number || mt.front) || 0, len: Number(mt.length || mt.size) || 0, pos: Number(mt.position) || 0 }; } - // Pure: "Merge queue stalled · head #15253 waiting for CI 3h" for a - // train whose head has sat past governor.merge_train_stall_warn_s; '' - // otherwise. The server decides stalled; the words are the head's - // plain-word reason plus how long. + // The stalled chip's lead — "Merge queue · stalled — …". The popover + // and the queue header strip it down to "stalled: …". + const STAGE_TRACKER_TRAIN_STALLED_LEAD = 'Merge queue · stalled — '; + // Why a stalled train's head is not moving, by merge_train.head_state + // (mergeTrainHead* in Go) — short enough for a chevron. A head on a + // person says what the person has to do (the owner's ask: "waiting on + // #15425 (needs maintainer merge)"), not "waiting for a maintainer". + const STAGE_TRACKER_TRAIN_HEAD_STALL_WORD = { 'needs-human': 'needs maintainer merge', ci: 'waiting for CI', soaking: 'soak overran', ready: 'waiting for a merge sweep', merging: 'merge call in flight', fixing: 'being fixed by its author', unknown: 'head not in this view' }; + // Pure: the short reason a stalled head is stuck — the head_state + // table, a human-decision head told apart by its reason, else the + // head's own plain-word reason cut at its first clause. + function stageTrackerTrainStallWhy(mt) { + const reason = String(mt.head_reason || '').replace(/[.;].*$/, '').trim(); + const state = String(mt.head_state || ''); + if (state === 'needs-human' && /decision/i.test(reason)) return 'needs a human decision'; + return STAGE_TRACKER_TRAIN_HEAD_STALL_WORD[state] || reason; + } + // Pure: "Merge queue · stalled — waiting on #15425 (needs maintainer + // merge) · 1h 20m" for a member behind a head that has sat past + // governor.merge_train_stall_warn_s; the head's own row reads "Merge + // queue · stalled — needs maintainer merge · 1h 20m"; '' when not + // stalled. The server decides stalled; the words say why and how long. function stageTrackerTrainStalledWord(mt) { if (!mt || !mt.stalled) return ''; const p = stageTrackerTrainPlace(mt); - const why = String(mt.head_reason || '').replace(/[.;].*$/, '').trim(); + const why = stageTrackerTrainStallWhy(mt); const dur = stageTrackerShortLeft((Number(mt.stalled_s) || 0) * 1000); - return 'Merge queue stalled · head #' + p.head + (why ? ' ' + why : '') + (dur ? ' ' + dur : ''); + const isHead = mt.state === STAGE_TRACKER_TRAIN_STATE_FRONT || p.pos === 1; + const what = isHead ? (why || 'the head has not moved') : 'waiting on #' + p.head + (why ? ' (' + why + ')' : ''); + return STAGE_TRACKER_TRAIN_STALLED_LEAD + what + (dur ? ' · ' + dur : ''); } // The chevron word for a train member ('' for a row not in a train). // The queued word is the place only — "Merge queued · 2nd" — so it // reads the same with the merge sweep on or off (#15395); never the - // state slug, never "front" or "queued-behind". + // state slug, never "front" or "queued-behind", and never '' for a + // state this table does not know: an unmapped slug reads spelled out + // with the row's place ("Waiting for front · 3rd"). function stageTrackerTrainWord(item) { const mt = stageTrackerTrain(item); if (!mt) return ''; @@ -224,7 +246,8 @@ case STAGE_TRACKER_TRAIN_STATE_REBASING: return 'Rebasing · attempt ' + (Number(mt.attempt) || 0) + '/' + (Number(mt.max_attempts) || 0); case STAGE_TRACKER_TRAIN_STATE_EXHAUSTED: return 'Needs human decision · rebase failed ' + (Number(mt.attempt) === 2 ? 'twice' : (Number(mt.attempt) || 0) + ' times'); } - return STAGE_TRACKER_TRAIN_STATE_WORD[mt.state] || stageTrackerMergeGateStateWord(mt.state); + const word = STAGE_TRACKER_TRAIN_STATE_WORD[mt.state] || stageTrackerMergeGateStateWord(mt.state) || STAGE_TRACKER_TRAIN_STATE_WORD[STAGE_TRACKER_TRAIN_STATE_QUEUED]; + return p.pos > 0 ? word + ' · ' + stageTrackerOrdinal(p.pos) : word; } // Pure: the member's countdown target in ms (eta_at, else now+eta_s); // 0 with no estimate. diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index b5b8aed762..609926b5f7 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -1835,6 +1835,10 @@ .ham-queue-train { margin: var(--sp-3) 0 var(--sp-2); font-weight: var(--fw-semibold); } .ham-queue-train:first-of-type { margin-top: 0; } .ham-queue-stalled { color: var(--yellow); } + /* Inside a lit chevron the word keeps the chevron's ink: ochre on the + amber fill was invisible, so a stalled train's chevrons read empty + (just the ⟳ and the actor glyph). */ + .ham-seg.active .ham-seg-t.ham-queue-stalled { color: inherit; } .merge-banners { position: fixed; right: var(--sp-6); bottom: var(--sp-6); z-index: var(--z-merge-banner); display: flex; flex-direction: column; gap: var(--sp-3); max-width: min(26rem, calc(100vw - 2 * var(--sp-6))); pointer-events: none; } .merge-banner { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--sp-4); align-items: start; padding: var(--sp-4) var(--sp-5); border: var(--line-width) solid var(--line); border-left: 3px solid var(--green); border-radius: var(--r); background: var(--panel-strong); color: var(--text); box-shadow: var(--shadow-raised); font-size: var(--fs-sm); pointer-events: auto; animation: merge-banner-in 220ms ease-out both; } .merge-banner.merge-banner-out { animation: merge-banner-out 180ms ease-in both; } @@ -14427,21 +14431,43 @@

Where to get help

function stageTrackerTrainPlace(mt) { return { head: Number(mt.head_number || mt.front) || 0, len: Number(mt.length || mt.size) || 0, pos: Number(mt.position) || 0 }; } - // Pure: "Merge queue stalled · head #15253 waiting for CI 3h" for a - // train whose head has sat past governor.merge_train_stall_warn_s; '' - // otherwise. The server decides stalled; the words are the head's - // plain-word reason plus how long. + // The stalled chip's lead — "Merge queue · stalled — …". The popover + // and the queue header strip it down to "stalled: …". + const STAGE_TRACKER_TRAIN_STALLED_LEAD = 'Merge queue · stalled — '; + // Why a stalled train's head is not moving, by merge_train.head_state + // (mergeTrainHead* in Go) — short enough for a chevron. A head on a + // person says what the person has to do (the owner's ask: "waiting on + // #15425 (needs maintainer merge)"), not "waiting for a maintainer". + const STAGE_TRACKER_TRAIN_HEAD_STALL_WORD = { 'needs-human': 'needs maintainer merge', ci: 'waiting for CI', soaking: 'soak overran', ready: 'waiting for a merge sweep', merging: 'merge call in flight', fixing: 'being fixed by its author', unknown: 'head not in this view' }; + // Pure: the short reason a stalled head is stuck — the head_state + // table, a human-decision head told apart by its reason, else the + // head's own plain-word reason cut at its first clause. + function stageTrackerTrainStallWhy(mt) { + const reason = String(mt.head_reason || '').replace(/[.;].*$/, '').trim(); + const state = String(mt.head_state || ''); + if (state === 'needs-human' && /decision/i.test(reason)) return 'needs a human decision'; + return STAGE_TRACKER_TRAIN_HEAD_STALL_WORD[state] || reason; + } + // Pure: "Merge queue · stalled — waiting on #15425 (needs maintainer + // merge) · 1h 20m" for a member behind a head that has sat past + // governor.merge_train_stall_warn_s; the head's own row reads "Merge + // queue · stalled — needs maintainer merge · 1h 20m"; '' when not + // stalled. The server decides stalled; the words say why and how long. function stageTrackerTrainStalledWord(mt) { if (!mt || !mt.stalled) return ''; const p = stageTrackerTrainPlace(mt); - const why = String(mt.head_reason || '').replace(/[.;].*$/, '').trim(); + const why = stageTrackerTrainStallWhy(mt); const dur = stageTrackerShortLeft((Number(mt.stalled_s) || 0) * 1000); - return 'Merge queue stalled · head #' + p.head + (why ? ' ' + why : '') + (dur ? ' ' + dur : ''); + const isHead = mt.state === STAGE_TRACKER_TRAIN_STATE_FRONT || p.pos === 1; + const what = isHead ? (why || 'the head has not moved') : 'waiting on #' + p.head + (why ? ' (' + why + ')' : ''); + return STAGE_TRACKER_TRAIN_STALLED_LEAD + what + (dur ? ' · ' + dur : ''); } // The chevron word for a train member ('' for a row not in a train). // The queued word is the place only — "Merge queued · 2nd" — so it // reads the same with the merge sweep on or off (#15395); never the - // state slug, never "front" or "queued-behind". + // state slug, never "front" or "queued-behind", and never '' for a + // state this table does not know: an unmapped slug reads spelled out + // with the row's place ("Waiting for front · 3rd"). function stageTrackerTrainWord(item) { const mt = stageTrackerTrain(item); if (!mt) return ''; @@ -14454,7 +14480,8 @@

Where to get help

case STAGE_TRACKER_TRAIN_STATE_REBASING: return 'Rebasing · attempt ' + (Number(mt.attempt) || 0) + '/' + (Number(mt.max_attempts) || 0); case STAGE_TRACKER_TRAIN_STATE_EXHAUSTED: return 'Needs human decision · rebase failed ' + (Number(mt.attempt) === 2 ? 'twice' : (Number(mt.attempt) || 0) + ' times'); } - return STAGE_TRACKER_TRAIN_STATE_WORD[mt.state] || stageTrackerMergeGateStateWord(mt.state); + const word = STAGE_TRACKER_TRAIN_STATE_WORD[mt.state] || stageTrackerMergeGateStateWord(mt.state) || STAGE_TRACKER_TRAIN_STATE_WORD[STAGE_TRACKER_TRAIN_STATE_QUEUED]; + return p.pos > 0 ? word + ' · ' + stageTrackerOrdinal(p.pos) : word; } // Pure: the member's countdown target in ms (eta_at, else now+eta_s); // 0 with no estimate. @@ -21380,7 +21407,7 @@

All labels

const place = stageTrackerTrainPlace(t.mt); const stalled = stageTrackerTrainStalledWord(t.mt); const base = String(t.mt.id || '').split('#')[0] || 'base'; - const title = `
${stageTrackerTrainIconHtml('ham-train-icon')} ${esc(String(t.repo || ''))} → ${esc(base)} · ${esc(String(place.len))} PRs · head #${esc(String(place.head))}${stalled ? ' · ' + esc(stalled.replace(/^Merge queue stalled · /, 'stalled: ')) : ''}
`; + const title = `
${stageTrackerTrainIconHtml('ham-train-icon')} ${esc(String(t.repo || ''))} → ${esc(base)} · ${esc(String(place.len))} PRs · head #${esc(String(place.head))}${stalled ? ' · ' + esc(stalled.replace(STAGE_TRACKER_TRAIN_STALLED_LEAD, 'stalled: ')) : ''}
`; const rows = t.members.map(it => { const mt = it.merge_train || {}; const n = esc(String(it.number || ''));