Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-merge-gate-issue-row-pill-overflow.md
Original file line number Diff line number Diff line change
@@ -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).
2 changes: 2 additions & 0 deletions src/docs/dashboard-sections.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
101 changes: 100 additions & 1 deletion src/pkg/dashboard/stage_tracker_merge_gate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"+`
Expand Down Expand Up @@ -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, '&amp;').replace(/</g, '&lt;').replace(/\"/g, '&quot;'); }\n"+
jsConstLine(t, html, "STAGE_TRACKER_TERMINAL")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_PRE_MERGE_SOAK")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_MERGE_GATE_WORD")+"\n"+
jsConstBlock(t, html, "STAGE_TRACKER_GATE_REASON_WORDS")+"\n"+
jsConstBlock(t, html, "STAGE_TRACKER_ICONS")+"\n"+
jsFunc(t, html, "stageTrackerIcon")+"\n"+
jsFunc(t, html, "stageTrackerAgoText")+"\n"+
jsFunc(t, html, "stageTrackerMergeGateStateOf")+"\n"+
jsFunc(t, html, "stageTrackerShortLeft")+"\n"+
jsFunc(t, html, "stageTrackerGateReasonText")+"\n"+
stageTrackerMergeGateInfoJS(t, html)+"\n"+
jsFunc(t, html, "stageTrackerMergeGateWordHtml")+"\n"+
jsFunc(t, html, "stageTrackerGateCueHtml")+"\n"+`
const assert = require('assert');
const now = Date.parse('2026-10-28T21:20:00Z');
const iso = ms => 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, '<span class="ham-seg-t">Awaiting merge gate <span class="ham-gate-detail">Β· CI still running (build-and-test)</span></span>', 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 <stage>", not "(PR at <stage>)".
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), '<span class="ham-seg-t">Awaiting merge gate</span>');
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');
`)
}
48 changes: 42 additions & 6 deletions src/pkg/dashboard/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14219,16 +14219,52 @@ <h3 class="faq-group-title">Where to get help</h3>
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 <stage>"
// 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;
Expand All @@ -14240,7 +14276,7 @@ <h3 class="faq-group-title">Where to get help</h3>
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 };
Expand All @@ -14251,7 +14287,7 @@ <h3 class="faq-group-title">Where to get help</h3>
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 Β·
Expand Down
Loading