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/added-tracker-draft-pill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Hive activity monitor: draft PRs (forge draft bit or prow `do-not-merge/work-in-progress`) now wear a muted `draft` pill with a tooltip explaining the review and merge lanes skip them, and their Open cell reads "Draft · since …" without the stale tint, instead of a bare "Open · since …" that looked stuck (#14572).
2 changes: 1 addition & 1 deletion src/docs/dashboard-sections.md

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion src/pkg/dashboard/stage_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,12 @@ const (
modSentinel = "sentinel"
)

// prowWIPLabel is prow's work-in-progress marker: it rides every draft PR
// (and a "WIP" title) and is dropped when the author marks the PR ready.
// On the tracker it is the draft state, not a maintainer hold, so a row
// wearing only it reads "draft" rather than "hold" (hivecommons/hive#14572).
const prowWIPLabel = "do-not-merge/work-in-progress"

// Lane names.
const (
laneIssue = "issue"
Expand Down Expand Up @@ -767,9 +773,15 @@ func stageTrackerClassifyModifiers(labels []string, hiveID string, rec stagelabe
set[modBlocked] = true
case stagelabels.UnauthorizedLabel:
set[modUnauthorized] = true
case prowWIPLabel:
// Prow's WIP label is the draft marker, present whether or not
// the snapshot's draft bit made it this far.
draft = true
}
}
if len(holdLabels(labels, hiveID)) > 0 {
if len(slices.DeleteFunc(holdLabels(labels, hiveID), func(l string) bool {
return strings.EqualFold(strings.TrimSpace(l), prowWIPLabel)
})) > 0 {
set[modHold] = true
}
if hasRec {
Expand Down
49 changes: 49 additions & 0 deletions src/pkg/dashboard/stage_tracker_draft_modifier_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package dashboard

import (
"slices"
"testing"
"time"

"github.com/hivecommons/hive/pkg/stagelabels"
)

// A draft PR reports the draft modifier whether the snapshot's draft bit or
// prow's do-not-merge/work-in-progress label says so, and that WIP label is
// the draft state on the tracker — not a maintainer hold — while a real hold
// label still leads a draft (hivecommons/hive#14572).
func TestStageTrackerModifiers_Draft(t *testing.T) {
now := time.Date(2026, 10, 27, 14, 0, 0, 0, time.UTC)
cases := []struct {
name string
labels []string
draft bool
want []string
}{
{name: "draft bit only", labels: []string{"size/L", "author/clanker"}, draft: true, want: []string{modDraft}},
{name: "prow WIP label only", labels: []string{"do-not-merge/work-in-progress", "size/L"}, want: []string{modDraft}},
{name: "prow WIP label, any case", labels: []string{" Do-Not-Merge/Work-In-Progress "}, want: []string{modDraft}},
{name: "draft bit and WIP label", labels: []string{"do-not-merge/work-in-progress"}, draft: true, want: []string{modDraft}},
{name: "neither", labels: []string{"size/L", "author/clanker"}, want: nil},
{name: "draft and hold: hold leads", labels: []string{"do-not-merge/hold"}, draft: true, want: []string{modHold, modDraft}},
{name: "WIP and hold: hold leads", labels: []string{"do-not-merge/work-in-progress", "hold"}, want: []string{modHold, modDraft}},
{name: "hold only is not a draft", labels: []string{"do-not-merge/hold"}, want: []string{modHold}},
{name: "draft and blocked", labels: []string{"blocked"}, draft: true, want: []string{modBlocked, modDraft}},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
// A PR before the merge gate: hold, blocked and draft are
// actionable-now pills, so none of them is deferred.
got, deferred := stageTrackerModifiers(tc.labels, "hv", stagelabels.Record{}, false, nil, now, tc.draft, "", "pr", stagelabels.PRInProgress, false)
if len(deferred) != 0 {
t.Fatalf("deferred = %v, want none", deferred)
}
if len(got) == 0 && len(tc.want) == 0 {
return
}
if !slices.Equal(got, tc.want) {
t.Fatalf("modifiers = %v, want %v", got, tc.want)
}
})
}
}
2 changes: 2 additions & 0 deletions src/pkg/dashboard/stage_tracker_motion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ func TestStageTrackerMotionRowStamp(t *testing.T) {
jsConstLine(t, html, "STAGE_TRACKER_TRAIL_HOPS"),
jsConstLine(t, html, "STAGE_TRACKER_MOD_PRIORITY"),
jsConstLine(t, html, "STAGE_TRACKER_MOD_TEXT"),
jsConstLine(t, html, "STAGE_TRACKER_DRAFT_TIP"),
jsConstLine(t, html, "STAGE_TRACKER_CAP_COLUMN"),
jsFunc(t, html, "esc"),
jsFunc(t, html, "agentNowAgo"),
Expand Down Expand Up @@ -501,6 +502,7 @@ func TestStageTrackerMotionPreviewSample(t *testing.T) {
jsConstLine(t, html, "STAGE_TRACKER_PRE_MERGE_SOAK"),
jsConstLine(t, html, "STAGE_TRACKER_ACTIVE_WORD"),
jsConstLine(t, html, "STAGE_TRACKER_MOD_TEXT"),
jsConstLine(t, html, "STAGE_TRACKER_DRAFT_TIP"),
jsConstLine(t, html, "STAGE_TRACKER_ACTOR"),
jsConstLine(t, html, "STAGE_TRACKER_TERMINAL"),
stageTrackerSentinelJS(t, html),
Expand Down
1 change: 1 addition & 0 deletions src/pkg/dashboard/stage_tracker_regressed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func TestStageTrackerRegressedPillExplainsItself(t *testing.T) {
"function esc(s) { return String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\"/g, '&quot;'); }",
jsConstLine(t, html, "STAGE_TRACKER_MOD_PRIORITY"),
jsConstLine(t, html, "STAGE_TRACKER_MOD_TEXT"),
jsConstLine(t, html, "STAGE_TRACKER_DRAFT_TIP"),
jsFunc(t, html, "stageTrackerStageWord"),
jsConstLine(t, html, "STAGE_TRACKER_NEEDS_DECISION"),
stageTrackerManualMergeJS(t, html),
Expand Down
1 change: 1 addition & 0 deletions src/pkg/dashboard/stage_tracker_repo_grouping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func stageTrackerRepoGroupingHarness(t *testing.T, html string) string {
jsConstLine(t, html, "STAGE_TRACKER_PRE_MERGE_SOAK"),
jsConstLine(t, html, "STAGE_TRACKER_ACTIVE_WORD"),
jsConstLine(t, html, "STAGE_TRACKER_MOD_TEXT"),
jsConstLine(t, html, "STAGE_TRACKER_DRAFT_TIP"),
jsConstLine(t, html, "STAGE_TRACKER_ACTOR"),
jsConstLine(t, html, "STAGE_TRACKER_TERMINAL"),
stageTrackerSentinelJS(t, html),
Expand Down
27 changes: 27 additions & 0 deletions src/pkg/dashboard/stage_tracker_ui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func TestStageTrackerRows(t *testing.T) {
jsConstLine(t, html, "STAGE_TRACKER_PRE_MERGE_SOAK"),
jsConstLine(t, html, "STAGE_TRACKER_ACTIVE_WORD"),
jsConstLine(t, html, "STAGE_TRACKER_MOD_TEXT"),
jsConstLine(t, html, "STAGE_TRACKER_DRAFT_TIP"),
jsConstLine(t, html, "STAGE_TRACKER_ACTOR"),
jsConstLine(t, html, "STAGE_TRACKER_TERMINAL"),
stageTrackerSentinelJS(t, html),
Expand Down Expand Up @@ -328,6 +329,32 @@ assert.strictEqual(openWord(row), 'Open · hold', 'hold is a human instruction:
assert.deepStrictEqual(segStates(row), ['active ham-open-hold', T, T, T, T, T, 'todo cap']);
row = stageTrackerRowHtml({ repo: 'acme/console', number: 28, kind: 'pr', title: 'Blocked later', stage: 50, modifiers: ['blocked'] }, stages, ctx);
assert.ok(!row.includes('ham-open-blocked') && !row.includes('Open · blocked'), 'blocked past Open is a chip, not an Open word');
// A draft PR with no stage (hivecommons/hive#14572): the far-right pill
// reads "draft" with the explanatory tooltip, the Open word reads "Draft",
// keeps its age but never tints stale — nothing is stuck, the lanes skip
// drafts until the author marks it ready.
row = stageTrackerRowHtml({ repo: 'acme/console', number: 14427, kind: 'pr', title: 'WIP: image scanner', stage: 0, stage_since: new Date(now - 18 * 3600000).toISOString(), labels: ['do-not-merge/work-in-progress'], modifiers: ['draft'] }, stages, ctx);
assert.strictEqual(openWord(row), 'Draft · since 18h', row);
assert.deepStrictEqual(segStates(row), ['active ham-open-draft', T, T, T, T, T, 'todo cap'], 'draft: its own class, no hold/blocked class');
assert.ok(row.includes('ham-mod-draft" title="' + STAGE_TRACKER_DRAFT_TIP + '">draft</span>'), 'draft pill with tooltip: ' + row);
assert.ok(strip(row).includes(' — ' + STAGE_TRACKER_DRAFT_TIP + ' — open since '), 'chevron tooltip explains the draft: ' + strip(row));
assert.ok(tooltip(row).includes('Open · draft'), tooltip(row));
assert.ok(tooltip(row).includes('Flags: draft'), tooltip(row));
row = stageTrackerRowHtml({ repo: 'acme/console', number: 14428, kind: 'pr', title: 'Old draft', stage: 0, stage_since: new Date(now - 5 * 86400000).toISOString(), modifiers: ['draft'] }, stages, ctx);
assert.strictEqual(openWord(row), 'Draft · since 5d');
assert.deepStrictEqual(segStates(row), ['active ham-open-draft', T, T, T, T, T, 'todo cap'], 'a long-lived draft is not stale: it is waiting on its author');
assert.strictEqual(stageTrackerCurrentStageHtml({ stage: 0, stage_since: new Date(now - 18 * 3600000).toISOString(), modifiers: ['draft'] }, stages, null, now), '<p class="ham-current-stage">Draft · since 18h</p>', 'the compact caption carries it too');
// Draft plus a human hold: hold leads the pill ("hold +1") and the Open word,
// and the folded draft still explains itself on hover.
row = stageTrackerRowHtml({ repo: 'acme/console', number: 31, kind: 'pr', title: 'Held draft', stage: 0, stage_since: new Date(now - 3 * 86400000).toISOString(), labels: ['do-not-merge/hold'], modifiers: ['hold', 'draft'] }, stages, ctx);
assert.strictEqual(openWord(row), 'Open · hold', 'hold wins the Open word over draft');
assert.deepStrictEqual(segStates(row), ['active ham-open-hold', T, T, T, T, T, 'todo cap']);
assert.ok(row.includes('ham-mod-hold" title="' + STAGE_TRACKER_DRAFT_TIP + '">hold +1</span>'), 'hold leads, draft folded: ' + row);
row = stageTrackerRowHtml({ repo: 'acme/console', number: 32, kind: 'pr', title: 'Still drafting', stage: 50, modifiers: ['draft'] }, stages, ctx);
assert.ok(!row.includes('ham-open-draft') && !row.includes('>Draft'), 'draft past Open is a chip, not an Open word: ' + row);
assert.ok(row.includes('ham-mod-draft"'), row);
assert.strictEqual(stageTrackerHeadline({ stage: 0, modifiers: ['draft'] }), 'Open · draft');
assert.strictEqual(stageTrackerHeadline({ stage: 0, modifiers: ['hold', 'draft'] }), 'Open · on hold', 'hold leads the headline too');
row = stageTrackerRowHtml({ repo: 'acme/console', number: 24, kind: 'issue', title: 'Staged', stage: 10, stage_since: new Date(now - 3 * 86400000).toISOString() }, stages, ctx);
assert.ok(!row.includes('since '), 'a staged item has no Open age');
assert.strictEqual(stageTrackerCurrentStageHtml({ stage: 0, stage_since: new Date(now - 14 * 3600000).toISOString() }, stages, null, now), '<p class="ham-current-stage">Open · since 14h</p>', 'the compact caption carries it too');
Expand Down
33 changes: 24 additions & 9 deletions src/pkg/dashboard/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1519,6 +1519,8 @@
.ham-seg.active.ham-open-hold .ham-seg-t::before { content: '⏸'; margin-right: var(--sp-1); }
.ham-seg.active.ham-open-blocked { background: var(--yellow); color: var(--surface-0); }
.ham-seg.active.ham-open-blocked .ham-seg-t::before { content: '⛔'; margin-right: var(--sp-1); }
.ham-seg.active.ham-open-draft { background: var(--band-draft); color: var(--surface-0); }
.ham-seg.active.ham-open-draft .ham-seg-t::before { content: '✎'; margin-right: var(--sp-1); }
.ham-seg.active.ham-open-stale { background: color-mix(in srgb, var(--amber) 65%, var(--red)); }
.ham-detour { white-space: normal; overflow-wrap: anywhere; }
.ham-current-stage { display: none; margin: 0; font-size: var(--fs-xs); color: var(--muted); overflow-wrap: anywhere; }
Expand Down Expand Up @@ -13934,6 +13936,7 @@ <h3 class="faq-group-title">Where to get help</h3>
if (mods.indexOf('regressed') >= 0 && !stageTrackerRegressionHandled(item)) return 'Sent back';
if (n === 0 && mods.indexOf('hold') >= 0) return 'Open · on hold' + (holdLabels.length ? ' (' + holdLabels.join(', ') + ')' : '');
if (n === 0 && mods.indexOf('blocked') >= 0) return 'Open · blocked';
if (n === 0 && mods.indexOf('draft') >= 0) return 'Open · draft';
// An issue parked on a person (045, or a pre-045 085 with no covering
// PR) is parked itself, so no "(its PR)" suffix.
const viaPR = item.kind === 'issue' && n >= 50 && (n !== 85 || item.via_pr) ? ' (its PR)' : '';
Expand Down Expand Up @@ -14047,24 +14050,31 @@ <h3 class="faq-group-title">Where to get help</h3>
const openHold = n === 0 && state === 'active' && mods.indexOf('hold') >= 0;
// hold is a human instruction, so it wins over blocked when both are present.
const openBlocked = n === 0 && state === 'active' && !openHold && mods.indexOf('blocked') >= 0;
// A draft PR with no stage is the author's, not the hive's: the
// Open word says so, muted, and it never tints stale (#14572).
const openDraft = n === 0 && state === 'active' && !openHold && !openBlocked && mods.indexOf('draft') >= 0;
if (openHold) word = 'Open · hold';
else if (openBlocked) word = 'Open · blocked';
// A plain or blocked Open step (no stage label, not held) says how
// long it has sat there, from the same instant the since column
// shows — a stale blocked item is exactly what should stand out.
else if (openDraft) word = 'Draft';
// A plain, blocked or draft Open step (no stage label, not held)
// says how long it has sat there, from the same instant the since
// column shows — a stale blocked item is exactly what should stand out.
let openSince = null;
if (n === 0 && state === 'active' && !openHold && !detour && nowMs) {
const os = stageTrackerOpenSince(item);
if (os.ms) { word += ' · since ' + stageTrackerShortAgo(nowMs - os.ms); openSince = Object.assign({ stale: nowMs - os.ms > STAGE_TRACKER_OPEN_STALE_DAYS * 86400000 }, os); }
if (os.ms) { word += ' · since ' + stageTrackerShortAgo(nowMs - os.ms); openSince = Object.assign({ stale: !openDraft && nowMs - os.ms > STAGE_TRACKER_OPEN_STALE_DAYS * 86400000 }, os); }
}
return { number: n, code: n ? String(n).padStart(3, '0') : '', short: word, label: tipStage.label || st.label || String(n), description: tipStage.description || st.description || '', state, terminal: false, detour: n === anchor ? detour : null, hold: openHold, blocked: openBlocked, openSince };
return { number: n, code: n ? String(n).padStart(3, '0') : '', short: word, label: tipStage.label || st.label || String(n), description: tipStage.description || st.description || '', state, terminal: false, detour: n === anchor ? detour : null, hold: openHold, blocked: openBlocked, draft: openDraft, openSince };
});
segs.push({ number: STAGE_TRACKER_TERMINAL, code: '', short: 'Merged', label: 'Merged', description: 'Merged — the pipeline is complete', state: terminal ? 'active' : 'todo', terminal, cap: true, detour: null });
return segs;
}

const STAGE_TRACKER_MOD_PRIORITY = ['stalled', 'regressed', 'hold', 'unauthorized', 'needs-human', 'needs-decision', 'needs-triage', 'possible-dupe', 'needs-rebase', 'blocked', 'draft'];
const STAGE_TRACKER_MOD_TEXT = { 'needs-decision': 'needs human decision', 'needs-triage': 'triage needed', 'possible-dupe': 'possible dupe' };
// The draft pill and the Draft chevron explain themselves on hover: no
// maintainer action is pending, the lanes resume when the author is ready.
const STAGE_TRACKER_DRAFT_TIP = 'Draft PR — hive review and merge lanes skip drafts until the author marks it ready for review.';
// 16-unit monochrome stroke icons, one per strip column (and the two kinds).
const STAGE_TRACKER_ICONS = {
0: '<circle cx="8" cy="8" r="5"/>',
Expand Down Expand Up @@ -14161,12 +14171,13 @@ <h3 class="faq-group-title">Where to get help</h3>
return segs.map(sg => {
if (sg.number < from || sg.number > to) return `<li class="ham-seg blank${sg.cap ? ' cap' : ''}" aria-hidden="true"></li>`;
const sentinel = !!(sg.detour && sg.detour.sentinel);
const cls = ['ham-seg', sg.state, sg.cap ? 'cap' : '', sg.cap && sg.terminal ? 'merged' : '', sg.detour ? 'detoured' : '', sg.hold ? 'ham-open-hold' : '', sg.blocked ? 'ham-open-blocked' : '', sg.openSince && sg.openSince.stale ? 'ham-open-stale' : '', sentinel ? 'ham-sentinel' : ''].filter(Boolean).join(' ');
const cls = ['ham-seg', sg.state, sg.cap ? 'cap' : '', sg.cap && sg.terminal ? 'merged' : '', sg.detour ? 'detoured' : '', sg.hold ? 'ham-open-hold' : '', sg.blocked ? 'ham-open-blocked' : '', sg.draft ? 'ham-open-draft' : '', sg.openSince && sg.openSince.stale ? 'ham-open-stale' : '', sentinel ? 'ham-sentinel' : ''].filter(Boolean).join(' ');
const active = sg.state === 'active';
let tip = '';
if (active) {
tip = sg.label + (sg.description ? ' — ' + sg.description : '');
if (sg.blocked) tip += ' — ' + stageTrackerBlockedTip(item);
if (sg.draft) tip += ' — ' + STAGE_TRACKER_DRAFT_TIP;
if (sg.openSince) tip += ' — open since ' + new Date(sg.openSince.ms).toISOString() + (sg.openSince.fromCreated ? ' (opened)' : '');
// The shared Merge gate word hides 080 vs 095 vs 100; the chevron tooltip carries it.
if (!sg.detour && (curStage === 60 || curStage === 80)) tip = sg.label + ' — not yet admitted' + (item.caption || item.reason ? ' — ' + (item.caption || item.reason) : '');
Expand Down Expand Up @@ -14299,11 +14310,15 @@ <h3 class="faq-group-title">Where to get help</h3>
const recheck = mods[0] === 'blocked' ? /^blocked until (\S+)/i.exec(String(item.bucket_reason || '')) : null;
const recheckMs = recheck ? Date.parse(recheck[1]) : NaN;
if (!isNaN(recheckMs)) text += ' · re-check at ' + agentNowClockTime(recheckMs, Date.now());
// The regressed pill (lead or folded into "+1") explains itself on hover.
// The regressed pill (lead or folded into "+1") explains itself on
// hover; failing that, a draft pill (lead or folded) does.
const regressed = stageTrackerRegressionText(item, Date.now());
// An unauthorized pill names the missing App permission and the human step.
// An unauthorized pill names the missing App permission and the human step;
// the regressed pill explains itself; a blocked pill names what it waits on;
// failing all three, a draft pill does.
const tip = (mods.indexOf('unauthorized') >= 0 && String(item.unauthorized || '').trim()) || regressed
|| (mods.indexOf('blocked') >= 0 && Array.isArray(item.blocked_on) && item.blocked_on.length ? 'Withheld from the scanner until ' + item.blocked_on.join(', ') + (item.blocked_on.length > 1 ? ' close' : ' closes') : '');
|| (mods.indexOf('blocked') >= 0 && Array.isArray(item.blocked_on) && item.blocked_on.length ? 'Withheld from the scanner until ' + item.blocked_on.join(', ') + (item.blocked_on.length > 1 ? ' close' : ' closes') : '')
|| (mods.indexOf('draft') >= 0 ? STAGE_TRACKER_DRAFT_TIP : '');
const cls = 'ham-mod-' + mods[0] + (handled && mods[0] === 'regressed' ? ' ham-mod-handled' : '');
return sentinel + `<span class="ham-badge ham-badge-mod ${esc(cls)}"${tip ? ` title="${esc(tip)}"` : ''}>${esc(text)}${mods.length > 1 ? ' +' + (mods.length - 1) : ''}</span>`;
}
Expand Down
Loading