diff --git a/changelog.d/fixed-merge-gate-issue-row-pill-overflow.md b/changelog.d/fixed-merge-gate-issue-row-pill-overflow.md new file mode 100644 index 0000000000..01a15a5c91 --- /dev/null +++ b/changelog.d/fixed-merge-gate-issue-row-pill-overflow.md @@ -0,0 +1 @@ +- Activity Monitor: an issue row whose covering PR is at the merge gate no longer concatenates its lane reason ("open PR #15090 covers it (PR at 060-reviewed)") into the merge-gate pill as a two-line clipped label; the pill is the stage word plus a gate fact only, the issue row reads the gate from the nested PR so it agrees with the PR sub-row, and the cover reason leads the glyph tooltip as "Open PR #15090 covers it · at 060-reviewed" (#15101). diff --git a/src/docs/dashboard-sections.md b/src/docs/dashboard-sections.md index de829790a3..ab8fb4e845 100644 --- a/src/docs/dashboard-sections.md +++ b/src/docs/dashboard-sections.md @@ -721,6 +721,8 @@ Fed by `GET /api/stage-tracker`. Every issue and pull request follows the same p | 100 merge queue | **Merging** | — | ⟳ spinning — *Admitted and soaked; hive is merging it now (GitHub merge queue / merge window).* | | 110 | **Merged** (the ✓ cap) | — | — | +An **issue row** whose covering PR is at the gate reads the gate from that nested PR (`linked_prs[].merge_gate`), so the issue row and its PR sub-row always show the same word and detail; the issue's own lane reason — *open PR #15090 covers it (PR at 060-reviewed)* — is never a gate reason and never appears in the pill (it did briefly after [#15084](https://github.com/hivecommons/hive/pull/15084), as a two-line clipped pill — [#15101](https://github.com/hivecommons/hive/issues/15101)); it leads the glyph's tooltip instead, as *Open PR #15090 covers it · at 060-reviewed — Review approved, …*. + The glyph is drawn for **every** row on the gate, so two rows in the same state always look the same; the ⬡ / 🤖 / 👤 icon *after* the word is whose move it is (`STAGE_TRACKER_ACTOR`), unchanged. The *working* spin (an agent on the item right now) stays a separate cue and now also carries its sentence as tooltip and `aria-label` (*Working now: reviewer reviewed it · 2m ago*). `next_sweep_at` comes from the automerge lanes' sweep clock (`automerge.SweepSnapshot()` — the next periodic floor pass, 5 min event-driven or the legacy 10 s tick); webhook-named passes run sooner, which the tooltip says. `last_sweep_at` is the stage record's `last_seen` (when a lane last evaluated the PR). **Cue tokens.** The three cues of the legend above (state pill, working spin, decision badge) share one `tracker-cues` CSS block on `.ham-row`: `--cue-state` (what the row waits on — the pill and this popover), `--cue-work` (the hive is working right now — the chevron spin), `--cue-decision` (what people and the hive decided — the ✓ badge). Nothing else blinks; motion stays in the 150–300 ms range. diff --git a/src/pkg/dashboard/stage_tracker_merge_gate_test.go b/src/pkg/dashboard/stage_tracker_merge_gate_test.go index 942a6158e6..8efca099a5 100644 --- a/src/pkg/dashboard/stage_tracker_merge_gate_test.go +++ b/src/pkg/dashboard/stage_tracker_merge_gate_test.go @@ -180,7 +180,7 @@ func TestStageTrackerMergeGateNode(t *testing.T) { jsFunc(t, html, "stageTrackerMergeGateStateOf")+"\n"+ jsFunc(t, html, "stageTrackerShortLeft")+"\n"+ jsFunc(t, html, "stageTrackerGateReasonText")+"\n"+ - jsFunc(t, html, "stageTrackerMergeGateInfo")+"\n"+ + stageTrackerMergeGateInfoJS(t, html)+"\n"+ jsFunc(t, html, "stageTrackerMergeGateWordHtml")+"\n"+ jsFunc(t, html, "stageTrackerGateCueHtml")+"\n"+ jsFunc(t, html, "stageTrackerGateCountdownSync")+"\n"+` @@ -259,3 +259,102 @@ assert.deepStrictEqual([n1.textContent, n2.textContent], ['· sweep due now', ' console.log('merge-gate helpers ok'); `) } + +// stageTrackerMergeGateInfoJS lifts stageTrackerMergeGateInfo with the +// helpers it reads: the issue row's cover reason parser and the nested PR +// it mirrors (hivecommons/hive#15101). +func stageTrackerMergeGateInfoJS(t *testing.T, html string) string { + t.Helper() + return jsConstLine(t, html, "STAGE_TRACKER_COVER_REASON_RE") + "\n" + + jsFunc(t, html, "stageTrackerCoverReasonText") + "\n" + + jsFunc(t, html, "stageTrackerCoveringPR") + "\n" + + jsFunc(t, html, "stageTrackerMergeGateInfo") + "\n" + + jsFunc(t, html, "stageTrackerMergeGateInfoFor") +} + +// TestStageTrackerMergeGateIssueRowPillNode: the regression #15084 shipped +// (hivecommons/hive#15101). An issue row mirrors its covering PR's stage, +// and its lane reason is "open PR #15090 covers it (PR at 060-reviewed)". +// The gate pill read that lane reason as a gate reason and drew it as the +// pill's detail — a two-line, clipped "Awaiting merge gate · open PR #15090 +// covers it (PR at 060-reviewe…". The pill is the word alone (plus a gate +// fact when there is one); the cover reason moves to the tooltip, and the +// issue row reads the gate from the nested PR so both rows agree. +func TestStageTrackerMergeGateIssueRowPillNode(t *testing.T) { + html := indexHTML(t) + runStageTrackerRowActionsScript(t, "function esc(s) { return String(s).replace(/&/g, '&').replace(/ new Date(ms).toISOString(); +const leak = /covers it|\(PR at/; + +// Captured 17:17 ET after roll dd412e4: #15088 → PR #15090, both at 060. +const pr15090 = { repo: 'hivecommons/hive', number: 15090, kind: 'pr', stage: 60, stage_slug: 'reviewed', reason: 'required-check-pending:build-and-test', + merge_gate: { state: 'gate-pending', reason: 'required-check-pending:build-and-test', last_sweep_at: iso(now - 120000), next_sweep_at: iso(now + 42000) } }; +const issue15088 = { repo: 'hivecommons/hive', number: 15088, kind: 'issue', stage: 60, stage_slug: 'reviewed', mirrored: true, + reason: 'open PR #15090 covers it (PR at 060-reviewed)', caption: 'PR in progress · open PR #15090 covers it (PR at 060-reviewed)', + linked_prs: [{ number: 15090, stage: 60, merge_gate: pr15090.merge_gate }] }; + +// The pill is one line: the word plus the PR's gate fact, never the lane reason. +const pill = stageTrackerMergeGateWordHtml(issue15088, now); +assert.strictEqual(pill, 'Awaiting merge gate · CI still running (build-and-test)', pill); +assert.ok(!leak.test(pill), 'pill label must not carry the cover reason: ' + pill); +// The issue row and its PR sub-row agree on word, detail and cue. +const a = stageTrackerMergeGateInfo(issue15088, now), b = stageTrackerMergeGateInfo(pr15090, now); +assert.deepStrictEqual([a.word, a.detail, a.cue, a.state], [b.word, b.detail, b.cue, b.state]); +// The cover reason leads the tooltip — "· at ", not "(PR at )". +assert.ok(a.tip.startsWith('Open PR #15090 covers it · at 060-reviewed — Review approved, not yet admitted to auto merge — CI still running (build-and-test).'), a.tip); +assert.ok(!/\(PR at/.test(a.tip), a.tip); +const glyph = stageTrackerGateCueHtml(issue15088, now); +assert.ok(glyph.includes('title="' + esc(a.tip) + '"') && glyph.includes('aria-label="' + esc(a.tip) + '"'), glyph); +assert.ok(!/title="[^"]*covers it/.test(pill), 'the pill itself has no title'); +// The PR row's tooltip does not grow the cover lead. +assert.ok(b.tip.startsWith('Review approved, not yet admitted'), b.tip); + +// Older payload: the nested PR carries no merge_gate. The stage alone picks +// the word and the lane reason still stays out of the pill. +const bare = Object.assign({}, issue15088, { linked_prs: [{ number: 15090, stage: 60 }] }); +const bareInfo = stageTrackerMergeGateInfo(bare, now); +assert.deepStrictEqual([bareInfo.word, bareInfo.detail], ['Awaiting merge gate', '']); +assert.strictEqual(stageTrackerMergeGateWordHtml(bare, now), 'Awaiting merge gate'); +assert.ok(bareInfo.tip.startsWith('Open PR #15090 covers it · at 060-reviewed — Review approved, not yet admitted to auto merge.'), bareInfo.tip); +// No linked_prs at all (issue row alone): same. +const alone = Object.assign({}, issue15088, { linked_prs: undefined }); +assert.ok(!leak.test(stageTrackerMergeGateWordHtml(alone, now))); +// A reason that names no PR (older "open PR covers it" token) is not a gate reason either. +const tok = Object.assign({}, alone, { reason: 'open PR covers it' }); +assert.strictEqual(stageTrackerMergeGateInfo(tok, now).detail, ''); + +// The issue row follows the PR's live gate state when the mirrored stage lags it +// (soaking PR, issue still labelled 060): both rows say Soaking. +const soakPR = { number: 15029, kind: 'pr', stage: 95, merge_gate: { state: 'soaking', soak_until: iso(now + 300000), soak_remaining_seconds: 300 } }; +const soakIssue = { number: 15023, kind: 'issue', stage: 60, reason: 'open PR #15029 covers it (PR at 095-pre-merge-soak)', linked_prs: [{ number: 15029, stage: 95, merge_gate: soakPR.merge_gate }] }; +assert.strictEqual(stageTrackerMergeGateInfo(soakIssue, now).word, stageTrackerMergeGateInfo(soakPR, now).word); +assert.strictEqual(stageTrackerMergeGateInfo(soakIssue, now).detail, '5m left'); +// Two linked PRs: the one the reason names wins. +const two = Object.assign({}, issue15088, { linked_prs: [{ number: 15001, stage: 60, merge_gate: { state: 'ready' } }, { number: 15090, stage: 60, merge_gate: pr15090.merge_gate }] }); +assert.strictEqual(stageTrackerMergeGateInfo(two, now).word, 'Awaiting merge gate'); +assert.strictEqual(stageTrackerCoveringPR(two).number, 15090); +assert.strictEqual(stageTrackerCoveringPR(pr15090), null, 'PR rows have no covering PR'); + +// The cover reason parser. +assert.strictEqual(stageTrackerCoverReasonText({ reason: 'open PR #15090 covers it (PR at 060-reviewed)' }), 'open PR #15090 covers it · at 060-reviewed'); +assert.strictEqual(stageTrackerCoverReasonText({ reason: 'open PR #7 covers it' }), 'open PR #7 covers it'); +assert.strictEqual(stageTrackerCoverReasonText({ reason: 'check-pending' }), ''); +assert.strictEqual(stageTrackerCoverReasonText({}), ''); +console.log('merge-gate issue-row pill ok'); +`) +} diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 33140c3241..b89d934192 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -14219,16 +14219,52 @@

Where to get help

if (!words) return raw; return words + (detail ? ' (' + detail + ')' : ''); } + // Pure: "open PR #15090 covers it · at 060-reviewed" from an issue row's + // lane reason ("open PR #15090 covers it (PR at 060-reviewed)"); '' for + // any other reason. The lane reason is the issue's, never a gate token, + // so it must not be read as one (hivecommons/hive#15084 regression). + const STAGE_TRACKER_COVER_REASON_RE = /^open PR #(\d+) covers it(?: \(PR at ([^)]*)\))?$/i; + function stageTrackerCoverReasonText(item) { + const m = STAGE_TRACKER_COVER_REASON_RE.exec(String((item && item.reason) || '').trim()); + if (!m) return ''; + return 'open PR #' + m[1] + ' covers it' + (m[2] ? ' · at ' + m[2] : ''); + } + // Pure: the nested PR an issue row mirrors — the one its lane reason + // names, else the linked PR at the issue's mirrored stage. null for PR + // rows and for issues with no linked PR. The issue row reads the gate + // from it so the row and its PR sub-row never disagree. + function stageTrackerCoveringPR(item) { + if (!item || item.kind === 'pr') return null; + const prs = Array.isArray(item.linked_prs) ? item.linked_prs : []; + if (!prs.length) return null; + const m = STAGE_TRACKER_COVER_REASON_RE.exec(String(item.reason || '').trim()); + const n = m ? Number(m[1]) : 0; + return prs.find(p => n && Number(p.number) === n) || prs.find(p => Number(p.stage) === Number(item.stage)) || null; + } // Pure: { word, detail, tip, cue } for an item on the gate, null off it. // word — the pill word (STAGE_TRACKER_MERGE_GATE_WORD) - // detail — the live part after " · " ("next sweep in 42s", "7m left") - // tip — one plain sentence for the glyph's title + aria-label + // detail — the live part after " · " ("next sweep in 42s", "7m left"); + // always a gate fact, never the issue's lane reason + // tip — one plain sentence for the glyph's title + aria-label; on + // an issue row it leads with "open PR #N covers it · at " // cue — 'running' (sweep on it now) | 'waiting' | 'soaking' | 'merging' | '' // until — ms epoch the detail counts down to (0 when none) function stageTrackerMergeGateInfo(item, nowMs) { - const state = stageTrackerMergeGateStateOf(item); + const cover = stageTrackerCoveringPR(item); + const src = cover && cover.merge_gate && cover.merge_gate.state ? cover : item; + const state = stageTrackerMergeGateStateOf(src); if (!state || state === 'merged') return null; - const mg = (item && item.merge_gate) || {}; + const info = stageTrackerMergeGateInfoFor(src, item, nowMs); + const coverWhy = stageTrackerCoverReasonText(item); + if (coverWhy) info.tip = coverWhy.charAt(0).toUpperCase() + coverWhy.slice(1) + ' — ' + info.tip; + return info; + } + // src carries the merge_gate / stage read; item is the row itself (its + // lane reason stands in for a gate reason only on a PR row). + function stageTrackerMergeGateInfoFor(src, item, nowMs) { + const state = stageTrackerMergeGateStateOf(src); + const mg = (src && src.merge_gate) || {}; + const laneReason = item && item.kind !== 'issue' && !stageTrackerCoverReasonText(item) ? item.reason : ''; nowMs = typeof nowMs === 'number' ? nowMs : Date.now(); const word = STAGE_TRACKER_MERGE_GATE_WORD[state] || state; const nextAt = mg.next_sweep_at ? Date.parse(mg.next_sweep_at) : 0; @@ -14240,7 +14276,7 @@

Where to get help

const nextWords = nextAt > nowMs ? 'next sweep in ' + stageTrackerShortLeft(nextAt - nowMs) : (nextAt > 0 ? 'sweep due now' : ''); const sooner = ' A GitHub event on the PR (check run, review, push) triggers a pass sooner.'; if (state === 'soaking') { - const soakSec = Number(mg.soak_remaining_seconds) || Number(item.soak_remaining_seconds) || 0; + const soakSec = Number(mg.soak_remaining_seconds) || Number(src.soak_remaining_seconds) || Number(item.soak_remaining_seconds) || 0; const until = mg.soak_until ? Date.parse(mg.soak_until) : (soakSec > 0 ? nowMs + soakSec * 1000 : 0); const left = until > nowMs ? stageTrackerShortLeft(until - nowMs) : ''; return { state, word, detail: left ? left + ' left' : 'soak window complete', tip: left ? 'Admitted by the automerge lane; waiting for the soak window: ' + left + ' left. hive merges on its first sweep after that.' + lastSeen : 'Admitted; the soak window is complete — hive merges on its next sweep' + (nextWords ? ' (' + nextWords + ')' : '') + '.' + lastSeen, cue: 'soaking', until: left ? until : 0 }; @@ -14251,7 +14287,7 @@

Where to get help

if (state === 'merging') { return { state, word, detail: '', tip: 'Admitted and soaked; hive is merging it now (GitHub merge queue / merge window).' + lastSeen, cue: 'merging', until: 0 }; } - const why = stageTrackerGateReasonText(mg.reason || item.reason); + const why = stageTrackerGateReasonText(mg.reason || laneReason); return { state, word, detail: why, tip: 'Review approved, not yet admitted to auto merge' + (why ? ' — ' + why : '') + '.' + (nextWords ? ' hive re-checks the gate on its ' + nextWords.replace(/^next /, 'next ') + '.' : '') + sooner + lastSeen, cue: 'waiting', until: 0 }; } // Pure: the pill word with its live detail — "Ready for auto merge ·