From 0228e3a6448211899dac252168c7eae190d07c12 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Wed, 28 Oct 2026 21:25:50 -0400 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20Activity=20Monitor:=20Accept=20?= =?UTF-8?q?triage=20on=20the=20label-less=20reporter-trust=20hold,=20leadi?= =?UTF-8?q?ng=20the=20row=20menu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A 000-new issue the reporter-trust gate holds for a maintainer (no stage label yet, next_mover: maintainer) offered no Accept triage: the menu predicate only fired on 015 / needs-triage. Offer it there too, lead every triage row's menu with it, hint what the click writes and as whom with the hive's next pass, carry the governor's next scanner pass in the result toast, and narrate the accepted 000-new row (server and optimistic alike) as waiting on the hive with the triage gate done. Fixes #15215 Signed-off-by: Andrew Anderson --- .../added-15215-accept-triage-new-row.md | 1 + .../dashboard/api_repo_item_accept_triage.go | 30 +++++++- .../api_repo_item_accept_triage_test.go | 26 +++++++ .../stage_tracker_accept_triage_test.go | 49 +++++++++++-- src/pkg/dashboard/stage_tracker_new.go | 47 ++++++++++-- src/pkg/dashboard/stage_tracker_new_test.go | 16 ++++ .../stage_tracker_row_actions_test.go | 9 +++ src/pkg/dashboard/static/index.html | 73 +++++++++++++++++-- 8 files changed, 228 insertions(+), 23 deletions(-) create mode 100644 changelog.d/added-15215-accept-triage-new-row.md diff --git a/changelog.d/added-15215-accept-triage-new-row.md b/changelog.d/added-15215-accept-triage-new-row.md new file mode 100644 index 0000000000..f24649c7e4 --- /dev/null +++ b/changelog.d/added-15215-accept-triage-new-row.md @@ -0,0 +1 @@ +- Activity Monitor: **Accept triage** now heads the "⋯" row menu of every issue waiting on a maintainer's triage — stage 015, the `needs-triage` pill, and the label-less 000-new row the reporter-trust gate holds before the first stage pass (previously only Hold / Re-evaluate / Mark needs-human were offered there). The hint reads *"adds `triage/accepted` as @you; the hive takes it on its next pass (≈N min)"*, the result toast carries the governor's next scanner pass, and the row reads accepted at once (015 → 010 actionable; a 000-new row flips to *triage ✓ → actionable (next)*), which the server narrates the same way once the label is on. Same audited, permission-gated write path as before ([#15215](https://github.com/hivecommons/hive/issues/15215)). diff --git a/src/pkg/dashboard/api_repo_item_accept_triage.go b/src/pkg/dashboard/api_repo_item_accept_triage.go index 6106e401cf..9c7ab44ea1 100644 --- a/src/pkg/dashboard/api_repo_item_accept_triage.go +++ b/src/pkg/dashboard/api_repo_item_accept_triage.go @@ -202,10 +202,38 @@ func (s *Server) handleRepoItemAcceptTriage(w http.ResponseWriter, r *http.Reque outcome += ", `" + strings.Join(remove, "`, `") + "` removed" } out.Result = &RowActionResult{Action: rowActionTriaged, Target: rowActionTarget(repoFull, rowActionTargetIssue, number), Outcome: outcome + ".", - Next: "The reporter-trust gate admits the issue on its next poll; the stage engine records 015 → 010."} + Next: acceptTriageNextText(s.governorNextPassIn(time.Now()))} jsonResponse(w, out) } +// acceptTriageNextText is the result's "next" line: the hive picks the +// issue up on its next scanner pass, with the governor's ETA when known. +func acceptTriageNextText(eta string) string { + next := "Hive picks it up on its next scanner pass" + if eta != "" { + next += " (≈" + eta + ")" + } + return next + "; the reporter-trust gate admits the issue on that poll and the stage engine records it 010 actionable." +} + +// governorNextPassIn is the governor's published next kick as an ETA +// ("13m", "due now"), or "" when none is published. +func (s *Server) governorNextPassIn(now time.Time) string { + if s == nil { + return "" + } + s.statusMu.RLock() + defer s.statusMu.RUnlock() + if s.status == nil { + return "" + } + t, ok := parseGovernorNextKick(s.status.Governor.NextKickAt) + if !ok { + return "" + } + return formatETA(t.Sub(now)) +} + // applyAcceptTriageToStatus patches the issue's labels in the status // snapshot so the activity monitor's next reconcile (and the stage tracker // it is built from) reads the accepted state before the next GitHub poll. diff --git a/src/pkg/dashboard/api_repo_item_accept_triage_test.go b/src/pkg/dashboard/api_repo_item_accept_triage_test.go index d543e72db8..50cab832f2 100644 --- a/src/pkg/dashboard/api_repo_item_accept_triage_test.go +++ b/src/pkg/dashboard/api_repo_item_accept_triage_test.go @@ -154,6 +154,10 @@ func TestRepoItemAcceptTriageAuthorizationAndLabels(t *testing.T) { t.Fatal("no audit entry for the accepted triage") } + if resp.Result == nil || resp.Result.Action != rowActionTriaged || resp.Result.Next != acceptTriageNextText("") { + t.Fatalf("result without a governor kick = %+v", resp.Result) + } + // The verified owner role passes without a repo permission lookup. mock.added, mock.removed, mock.created = nil, nil, nil if w := postAcceptTriage(t, srv, "", true); w.Code != http.StatusOK { @@ -308,3 +312,25 @@ func TestRepoItemAcceptTriagePlanAndStalenessRule(t *testing.T) { t.Fatalf("non-actionable #7 labels = %q", got) } } + +// The result's "next" line carries the governor's next pass when one is +// published, so the toast reads "≈13m" (hivecommons/hive#15215). +func TestRepoItemAcceptTriageNextPassETA(t *testing.T) { + now := time.Date(2026, 10, 28, 20, 0, 0, 0, time.UTC) + srv := newAcceptTriageServer(t, &acceptTriageMock{permission: "write"}) + if got := srv.governorNextPassIn(now); got != "" { + t.Fatalf("no status: eta = %q, want none", got) + } + srv.statusMu.Lock() + srv.status = &StatusPayload{Governor: FrontendGovernor{NextKickAt: now.Add(13 * time.Minute).Format(time.RFC3339)}} + srv.statusMu.Unlock() + if got := srv.governorNextPassIn(now); got != "13m" { + t.Fatalf("eta = %q, want 13m", got) + } + if got := acceptTriageNextText("13m"); !strings.HasPrefix(got, "Hive picks it up on its next scanner pass (≈13m);") { + t.Fatalf("next = %q", got) + } + if got := acceptTriageNextText(""); !strings.HasPrefix(got, "Hive picks it up on its next scanner pass;") { + t.Fatalf("next without eta = %q", got) + } +} diff --git a/src/pkg/dashboard/stage_tracker_accept_triage_test.go b/src/pkg/dashboard/stage_tracker_accept_triage_test.go index 789cb9654c..6f7b571fa8 100644 --- a/src/pkg/dashboard/stage_tracker_accept_triage_test.go +++ b/src/pkg/dashboard/stage_tracker_accept_triage_test.go @@ -6,11 +6,14 @@ import ( ) // The activity monitor row menu's "Accept triage" (Hub Admin request): shown -// only on an issue the chevron calls "Triage needed" (015, or the -// needs-triage pill on another stage), never on a PR; it posts to -// /items/{n}/accept-triage and re-renders the row as 010 Actionable with the -// 👤 next-move gone before the tracker's next payload confirms it. The pure -// helpers run under node like the rest of the row-actions suite. +// only on an issue the chevron calls "Triage needed" (015, the needs-triage +// pill on another stage, or a label-less 000-new issue the reporter-trust +// gate holds for a maintainer — hivecommons/hive#15215), never on a PR; it +// heads the menu, its hint says what it writes and as whom, it posts to +// /items/{n}/accept-triage and re-renders the row as 010 Actionable (a +// 000-new row: waiting on the hive) with the 👤 next-move gone before the +// tracker's next payload confirms it. The pure helpers run under node like +// the rest of the row-actions suite. func TestStageTrackerAcceptTriageMenuVisibility(t *testing.T) { html := indexHTML(t) @@ -25,20 +28,50 @@ func TestStageTrackerAcceptTriageMenuVisibility(t *testing.T) { } runStageTrackerRowActionsScript(t, stageTrackerRowActionsPreamble(t, html)+` const ids = as => as.map(a => a.id); -const ctx = { user: true, canHold: true, canHuman: true }; +const BT = String.fromCharCode(96); +const NOW = Date.parse('2026-10-28T20:00:00Z'); +const ctx = { user: true, canHold: true, canHuman: true, login: 'octo', nowMs: NOW, governor: { nextKickAt: '2026-10-28T20:13:20Z' } }; // The primary case: an issue at 015 "Triage needed". const triage = { repo: 'o/r', kind: 'issue', number: 1, title: 'From an untrusted reporter', url: 'https://github.com/o/r/issues/1', stage: 15, modifiers: [] }; let as = stageTrackerRowActions(triage, ctx); -assert.deepStrictEqual(ids(as), ['hold', 'retry', 'accept-triage', 'needs-human', 'open', 'copy'], 'Accept triage sits above Mark needs-human…'); +assert.deepStrictEqual(ids(as), ['accept-triage', 'hold', 'retry', 'needs-human', 'open', 'copy'], 'Accept triage heads the menu'); const accept = as.find(a => a.id === 'accept-triage'); assert.strictEqual(accept.label, 'Accept triage'); assert.strictEqual(accept.enabled, true); -assert.strictEqual(accept.hint, 'triage/accepted', 'the hint names the label the click applies'); +assert.strictEqual(accept.hint, 'adds ' + BT + 'triage/accepted' + BT + ' as @octo; the hive takes it on its next pass (≈13 min)', 'the hint names the label, the actor and the next pass'); +assert.strictEqual(as.find(a => a.id === 'hold').sep, true, 'a separator parts the lead from the generic items'); + +// Without a login or a published next kick the hint still reads. +assert.strictEqual(stageTrackerTriageHint(triage, { user: true, canHold: true }, NOW, null), 'adds ' + BT + 'triage/accepted' + BT + ' as you; the hive takes it on its next pass'); +assert.strictEqual(stageTrackerNextPassWord(-5), 'due now'); +assert.strictEqual(stageTrackerNextPassWord(20000), '≈1 min'); +assert.strictEqual(stageTrackerNextPassWord(null), ''); // The needs-triage pill on another stage (a claimed issue the gate still holds) also offers it. assert.ok(ids(stageTrackerRowActions({ ...triage, stage: 20, modifiers: ['needs-triage'] }, ctx)).includes('accept-triage')); +// A label-less 000-new issue the reporter-trust gate holds for a maintainer +// (hivecommons/hive#15215) offers it too; its hint reads the configured +// label and the row's own next pass. A 000-new issue the hive moves next +// (reporter admitted) does not: nothing to accept. +const fresh = { ...triage, stage: 0, stage_slug: '000-new', actor: 'maintainer', caption: 'New · waiting for a maintainer\'s triage (add ' + BT + 'triage/ok' + BT + '); the hive\'s next pass in 7m', + new: { next_mover: 'maintainer', next_mover_text: 'a maintainer\'s triage (add ' + BT + 'triage/ok' + BT + ')', next_pass_at: '2026-10-28T20:07:00Z', gates: [{ name: 'triage', state: 'next', text: 'a maintainer accepts triage (triage/ok)' }, { name: 'actionable', state: 'later', text: 'the stage-label pass marks it 010 actionable' }, { name: 'claimed', state: 'later', text: 'the scanner claims it (020)' }], text: 'New · waiting for a maintainer\'s triage (add ' + BT + 'triage/ok' + BT + '); the hive\'s next pass in 7m' } }; +as = stageTrackerRowActions(fresh, ctx); +assert.strictEqual(ids(as)[0], 'accept-triage', 'a 000-new reporter-trust hold leads with Accept triage'); +assert.strictEqual(as[0].hint, 'adds ' + BT + 'triage/ok' + BT + ' as @octo; the hive takes it on its next pass (≈7 min)'); +assert.ok(!ids(stageTrackerRowActions({ ...fresh, new: { ...fresh.new, next_mover: 'hive' } }, ctx)).includes('accept-triage'), 'an admitted reporter\'s new issue needs no triage'); +assert.ok(!ids(stageTrackerRowActions({ ...fresh, kind: 'pr', new: { next_mover: 'maintainer' } }, ctx)).includes('accept-triage')); +assert.ok(!ids(stageTrackerRowActions({ ...fresh, new: null }, ctx)).includes('accept-triage'), 'a plain Open row without the narration is not a triage hold'); +const freshAfter = stageTrackerTriageAccepted(fresh); +assert.strictEqual(freshAfter.stage, 0, 'no stage label to move yet'); +assert.strictEqual(freshAfter.new.next_mover, 'hive'); assert.strictEqual(freshAfter.actor, 'hive'); +assert.strictEqual(freshAfter.caption, 'New · waiting for the stage-label pass (→ 010 actionable), then the scanner'); +assert.deepStrictEqual(freshAfter.new.gates.map(g => g.name + ':' + g.state), ['triage:done', 'actionable:next', 'claimed:later']); +assert.strictEqual(freshAfter.new.gates[0].text, 'triage accepted (triage/ok)'); +assert.strictEqual(fresh.new.next_mover, 'maintainer', 'the input is not mutated'); +assert.ok(!stageTrackerTriageNeeded(freshAfter), 'once accepted the menu no longer offers it'); + // Not on a triaged issue, a parked issue, an open issue, or any PR. assert.ok(!ids(stageTrackerRowActions({ ...triage, stage: 10 }, ctx)).includes('accept-triage'), '010 Actionable is already triaged'); assert.ok(!ids(stageTrackerRowActions({ ...triage, stage: 45, modifiers: ['needs-decision'] }, ctx)).includes('accept-triage')); diff --git a/src/pkg/dashboard/stage_tracker_new.go b/src/pkg/dashboard/stage_tracker_new.go index 193ad5146c..f1f95393a6 100644 --- a/src/pkg/dashboard/stage_tracker_new.go +++ b/src/pkg/dashboard/stage_tracker_new.go @@ -93,7 +93,18 @@ func stageTrackerNewState(it StageTrackerItem, hasRec bool, filter *config.Issue if n.Since == nil { n.Since = it.UpdatedAt } - triagePending := it.Kind == "issue" && (it.Bucket == stageengineReporterTriageBucket || slices.Contains(it.Modifiers, modNeedsTriage)) + triageLabels := []string{config.DefaultUntrustedRequireLabels[0]} + if filter != nil { + if l := filter.ReporterTrustRequiredLabelsForNotice(); len(l) > 0 { + triageLabels = l + } + } + // The labels are the newer fact: once a maintainer's triage label is on + // (the row menu's Accept triage, or applied by hand) the reporter-trust + // gate admits the issue on its next poll, so the row waits on the hive + // even while the bucket still says reporter_triage. + triageAccepted := it.Kind == "issue" && stageTrackerHasAnyLabel(it.Labels, triageLabels) + triagePending := it.Kind == "issue" && !triageAccepted && (it.Bucket == stageengineReporterTriageBucket || slices.Contains(it.Modifiers, modNeedsTriage)) if t, ok := parseGovernorNextKick(governor.NextKickAt); ok { n.NextPassAt = &t if left := t.Sub(now); left > 0 { @@ -110,12 +121,7 @@ func stageTrackerNewState(it StageTrackerItem, hasRec bool, filter *config.Issue switch { case triagePending: n.NextMover = StageTrackerMoverMaintainer - labels := []string{"triage/accepted"} - if filter != nil { - if l := filter.ReporterTrustRequiredLabelsForNotice(); len(l) > 0 { - labels = l - } - } + labels := triageLabels n.NextMoverText = "a maintainer's triage (add `" + strings.Join(labels, "` or `") + "`)" n.Gates = []StageTrackerGate{ {Name: "triage", State: StageTrackerGateNext, Text: "a maintainer accepts triage (" + strings.Join(labels, " / ") + ")"}, @@ -132,8 +138,12 @@ func stageTrackerNewState(it StageTrackerItem, hasRec bool, filter *config.Issue default: n.NextMover = StageTrackerMoverHive n.NextMoverText = "the stage-label pass (→ 010 actionable), then the scanner" + triageGate := "reporter admitted; no triage label needed" + if triageAccepted { + triageGate = "triage accepted (" + strings.Join(stageTrackerLabelsOn(it.Labels, triageLabels), " / ") + ")" + } n.Gates = []StageTrackerGate{ - {Name: "triage", State: StageTrackerGateDone, Text: "reporter admitted; no triage label needed"}, + {Name: "triage", State: StageTrackerGateDone, Text: triageGate}, {Name: "actionable", State: StageTrackerGateNext, Text: "the stage-label pass marks it 010 actionable"}, {Name: "claimed", State: StageTrackerGateLater, Text: "the scanner claims it (020)"}, } @@ -147,6 +157,27 @@ func stageTrackerNewState(it StageTrackerItem, hasRec bool, filter *config.Issue return n } +// stageTrackerHasAnyLabel reports whether labels carries any of want +// (case-insensitive, trimmed). +func stageTrackerHasAnyLabel(labels, want []string) bool { + return len(stageTrackerLabelsOn(labels, want)) > 0 +} + +// stageTrackerLabelsOn returns the members of want that labels carries, in +// want's order. +func stageTrackerLabelsOn(labels, want []string) []string { + var on []string + for _, w := range want { + for _, l := range labels { + if strings.EqualFold(strings.TrimSpace(l), strings.TrimSpace(w)) { + on = append(on, strings.TrimSpace(w)) + break + } + } + } + return on +} + // parseGovernorNextKick reads FrontendGovernor.NextKickAt (RFC3339). func parseGovernorNextKick(s string) (time.Time, bool) { if s == "" { diff --git a/src/pkg/dashboard/stage_tracker_new_test.go b/src/pkg/dashboard/stage_tracker_new_test.go index 5350f8f4fe..5b67e72bc3 100644 --- a/src/pkg/dashboard/stage_tracker_new_test.go +++ b/src/pkg/dashboard/stage_tracker_new_test.go @@ -151,6 +151,22 @@ func TestStageTrackerNewState(t *testing.T) { if n == nil || n.NextMover != StageTrackerMoverMaintainer || n.Text != "New · waiting for a maintainer's triage (add `triage/accepted` or `kind/approved`); the hive's next pass in 5m" { t.Fatalf("reporter_triage issue = %+v", n) } + // The accept label already on (the row menu's Accept triage, before the + // gate's next poll moves the bucket): the hive is the next mover and the + // triage gate reads done (hivecommons/hive#15215). + accepted := triage + accepted.Labels = []string{"enhancement", "Kind/Approved"} + n = stageTrackerNewState(accepted, false, filter, gov, now) + if n == nil || n.NextMover != StageTrackerMoverHive || n.Text != "New · waiting for the stage-label pass (→ 010 actionable), then the scanner (next pass in 5m)" { + t.Fatalf("reporter_triage issue with the accept label = %+v", n) + } + if len(n.Gates) != 3 || n.Gates[0].State != StageTrackerGateDone || n.Gates[0].Text != "triage accepted (kind/approved)" || n.Gates[1].State != StageTrackerGateNext { + t.Fatalf("accepted gates = %+v", n.Gates) + } + accepted.Modifiers = []string{modNeedsTriage} + if n = stageTrackerNewState(accepted, false, filter, gov, now); n == nil || n.NextMover != StageTrackerMoverHive { + t.Fatalf("a stale needs-triage beside the accept label = %+v", n) + } labelled := base labelled.Modifiers = []string{modNeedsTriage} if n = stageTrackerNewState(labelled, false, nil, FrontendGovernor{}, now); n == nil || n.NextMover != StageTrackerMoverMaintainer || n.Text != "New · waiting for a maintainer's triage (add `triage/accepted`)" || n.NextPassAt != nil { diff --git a/src/pkg/dashboard/stage_tracker_row_actions_test.go b/src/pkg/dashboard/stage_tracker_row_actions_test.go index 21a10f6444..4d32b0bca5 100644 --- a/src/pkg/dashboard/stage_tracker_row_actions_test.go +++ b/src/pkg/dashboard/stage_tracker_row_actions_test.go @@ -28,6 +28,10 @@ func stageTrackerRowActionsPreamble(t *testing.T, html string) string { jsConstLine(t, html, "STAGE_TRACKER_WHY_ROLE"), jsConstLine(t, html, "STAGE_TRACKER_TRIAGE_STAGE"), jsConstLine(t, html, "STAGE_TRACKER_ACTIONABLE_STAGE"), + jsConstLine(t, html, "STAGE_TRACKER_TRIAGE_LABEL"), + jsConstLine(t, html, "STAGE_TRACKER_NEW_MOVER_MAINTAINER"), + jsConstLine(t, html, "STAGE_TRACKER_NEW_MOVER_HIVE"), + jsConstLine(t, html, "STAGE_TRACKER_MINUTE_MS"), jsConstLine(t, html, "STAGE_TRACKER_DELEGATE_POLL_MS"), jsConstLine(t, html, "STAGE_TRACKER_DELEGATE_POLL_MAX"), jsConstLine(t, html, "STAGE_TRACKER_DELEGATE_ALL_MIN"), @@ -60,6 +64,11 @@ func stageTrackerRowActionsPreamble(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerSupersederOptions"), jsFunc(t, html, "stageTrackerSupersederValid"), jsFunc(t, html, "stageTrackerTriageNeeded"), + jsFunc(t, html, "stageTrackerTriageNewState"), + jsFunc(t, html, "stageTrackerTriageLabel"), + jsFunc(t, html, "stageTrackerNextPassLeftMs"), + jsFunc(t, html, "stageTrackerNextPassWord"), + jsFunc(t, html, "stageTrackerTriageHint"), jsFunc(t, html, "stageTrackerTriageAccepted"), jsFunc(t, html, "stageTrackerDecisionOf"), jsFunc(t, html, "stageTrackerActionAllowed"), diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 9e0c333fe5..457427423e 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -17055,6 +17055,10 @@

All labels

// (hivecommons/hive#14586). Never on a PR. const STAGE_TRACKER_TRIAGE_STAGE = 15; const STAGE_TRACKER_ACTIONABLE_STAGE = 10; + const STAGE_TRACKER_TRIAGE_LABEL = 'triage/accepted'; + const STAGE_TRACKER_NEW_MOVER_MAINTAINER = 'maintainer'; + const STAGE_TRACKER_NEW_MOVER_HIVE = 'hive'; + const STAGE_TRACKER_MINUTE_MS = 60000; const STAGE_TRACKER_WHY_WRITE = 'Sign in with write access to this repo'; const STAGE_TRACKER_WHY_ROLE = 'Needs the merger or owner role'; const STAGE_TRACKER_DELEGATE_POLL_MS = 1500; @@ -17171,7 +17175,7 @@

All labels

const user = !!window._hiveUser || owner; if (typeof ensureRepoHoldPermission === 'function') ensureRepoHoldPermission(repo); const canHold = owner || (typeof repoHoldPermissionKnown === 'function' && repoHoldPermissionKnown(repo)) ? true : (user ? null : false); - return { user, canHold, canHuman: user && dashboardRoleAtLeast(role, 'merger') }; + return { user, canHold, canHuman: user && dashboardRoleAtLeast(role, 'merger'), login: String(window._hiveUser || ''), governor: (window._lastStatus && window._lastStatus.governor) || null }; } // Pure: the item a row's "Decide…" acts on. A PR parked at 085 (the // "Needs human decision" pill on the Merge gate column) decides itself; @@ -17250,7 +17254,49 @@

All labels

function stageTrackerTriageNeeded(item) { if (!item || item.kind === 'pr') return false; const mods = Array.isArray(item.modifiers) ? item.modifiers : []; - return (Number(item.stage) || 0) === STAGE_TRACKER_TRIAGE_STAGE || mods.indexOf('needs-triage') >= 0; + if ((Number(item.stage) || 0) === STAGE_TRACKER_TRIAGE_STAGE || mods.indexOf('needs-triage') >= 0) return true; + // A label-less 000-new issue the reporter-trust gate holds for a + // maintainer (next_mover: maintainer) before the first stage pass + // has even placed it at 015 (hivecommons/hive#15215). + const fresh = stageTrackerTriageNewState(item); + return !!fresh && fresh.next_mover === STAGE_TRACKER_NEW_MOVER_MAINTAINER; + } + // Pure: the 000-new narration of a row, or null (stageTrackerNewState + // without the dependency, for the row-actions helpers). + function stageTrackerTriageNewState(item) { + return item && (Number(item.stage) || 0) === 0 && item.new && typeof item.new === 'object' ? item.new : null; + } + // Pure: the triage label Accept triage applies — the one the row's + // 000-new narration names in backticks, else the default. + function stageTrackerTriageLabel(item) { + const fresh = stageTrackerTriageNewState(item); + const m = fresh && typeof fresh.next_mover_text === 'string' ? fresh.next_mover_text.match(/`([^`]+)`/) : null; + return m ? m[1] : STAGE_TRACKER_TRIAGE_LABEL; + } + // Pure: milliseconds until the hive's next pass for a row — the 000-new + // narration's next_pass_at, else the governor's published next kick — + // or null when neither is known. + function stageTrackerNextPassLeftMs(item, nowMs, governor) { + const fresh = stageTrackerTriageNewState(item); + let at = Date.parse((fresh && fresh.next_pass_at) || ''); + if (!at && governor) at = Date.parse(governor.nextKickAt || ''); + return at ? at - nowMs : null; + } + // Pure: "≈13 min" / "due now" from a next-pass delta, '' when unknown. + function stageTrackerNextPassWord(leftMs) { + if (leftMs == null || !Number.isFinite(leftMs)) return ''; + if (leftMs <= 0) return 'due now'; + const min = Math.max(1, Math.round(leftMs / STAGE_TRACKER_MINUTE_MS)); + return '≈' + min + ' min'; + } + // Pure: the Accept triage hint — what the click writes, as whom, and + // when the hive takes it: "adds `triage/accepted` as @you; the hive + // takes it on its next pass (≈13 min)". + function stageTrackerTriageHint(item, ctx, nowMs, governor) { + ctx = ctx || {}; + const who = ctx.login ? '@' + ctx.login : 'you'; + const when = stageTrackerNextPassWord(stageTrackerNextPassLeftMs(item, nowMs || Date.now(), governor)); + return 'adds `' + stageTrackerTriageLabel(item) + '` as ' + who + '; the hive takes it on its next pass' + (when ? ' (' + when + ')' : ''); } // Pure: the item as it reads once triage is accepted — 010 Actionable, // the needs-triage pill and the 👤 next-move gone — for the optimistic @@ -17263,6 +17309,17 @@

All labels

next.stage_slug = 'actionable'; next.stage_label = 'stage/010-actionable'; next.caption = ''; next.actor = ''; next.reason = ''; + return next; + } + // A 000-new row has no stage label to move yet: the triage gate reads + // done and the hive's stage-label pass is the next mover, exactly + // what the server narrates once the label is on. + const fresh = stageTrackerTriageNewState(item); + if (fresh && fresh.next_mover === STAGE_TRACKER_NEW_MOVER_MAINTAINER) { + const text = 'the stage-label pass (→ 010 actionable), then the scanner'; + const gates = (Array.isArray(fresh.gates) ? fresh.gates : []).map(g => g && g.name === 'triage' ? Object.assign({}, g, { state: 'done', text: 'triage accepted (' + stageTrackerTriageLabel(item) + ')' }) : (g && g.name === 'actionable' ? Object.assign({}, g, { state: 'next' }) : g)); + next.new = Object.assign({}, fresh, { next_mover: STAGE_TRACKER_NEW_MOVER_HIVE, next_mover_text: text, gates, text: 'New · waiting for ' + text }); + next.caption = next.new.text; next.actor = STAGE_TRACKER_NEW_MOVER_HIVE; } return next; } @@ -17316,19 +17373,23 @@

All labels

const taken = {}; for (const o of submenu) taken[o.id] = true; const lead = stageTrackerLeadActions(item, ctx, taken); + // Accept triage heads the menu of an issue waiting on a maintainer's + // triage (015, the needs-triage pill, or a 000-new reporter-trust + // hold): the ask the row makes has its answer first. + const triage = stageTrackerTriageNeeded(item); + if (triage) out.push({ id: 'accept-triage', label: 'Accept triage', hint: stageTrackerTriageHint(item, ctx, ctx.nowMs, ctx.governor), enabled: write, why: write ? '' : STAGE_TRACKER_WHY_WRITE, lead: true }); for (const a of lead) out.push(a); if (target) { const on = target === item ? '' : ' PR #' + (Number(target.number) || 0); - out.push({ id: 'decide', label: 'Decide' + on + '…', enabled: write, why: write ? '' : STAGE_TRACKER_WHY_WRITE, submenu, target, sep: lead.length > 0 }); + out.push({ id: 'decide', label: 'Decide' + on + '…', enabled: write, why: write ? '' : STAGE_TRACKER_WHY_WRITE, submenu, target, sep: lead.length > 0 || triage }); } // A nudged contributor PR the engine would adopt but for the owner's // say-so (maintainer_policy: ask) offers Adopt (hivecommons/hive#14524). if (typeof stageTrackerAdoptOffered === 'function' && stageTrackerAdoptOffered(item)) out.push({ id: 'decide:adopt', label: STAGE_TRACKER_ACTION_LABELS['decide:adopt'] + '…', hint: 'adoption', enabled: write && !!ctx.user, why: write && ctx.user ? '' : STAGE_TRACKER_WHY_WRITE }); out.push(has('hold') - ? { id: 'release', label: 'Release hold', enabled: write, why: write ? '' : STAGE_TRACKER_WHY_WRITE } - : { id: 'hold', label: 'Hold', enabled: write, why: write ? '' : STAGE_TRACKER_WHY_WRITE }); + ? { id: 'release', label: 'Release hold', enabled: write, why: write ? '' : STAGE_TRACKER_WHY_WRITE, sep: triage && !target } + : { id: 'hold', label: 'Hold', enabled: write, why: write ? '' : STAGE_TRACKER_WHY_WRITE, sep: triage && !target }); out.push({ id: 'retry', label: 'Re-evaluate now', hint: 'rescan', enabled: true, why: '' }); - if (stageTrackerTriageNeeded(item)) out.push({ id: 'accept-triage', label: 'Accept triage', hint: 'triage/accepted', enabled: write, why: write ? '' : STAGE_TRACKER_WHY_WRITE }); if (!has('needs-human')) out.push({ id: 'needs-human', label: 'Mark needs-human…', enabled: !!ctx.canHuman, why: ctx.canHuman ? '' : STAGE_TRACKER_WHY_ROLE }); out.push({ id: 'open', label: 'Open on GitHub', enabled: !!item.url, why: item.url ? '' : 'No GitHub link', sep: true }); out.push({ id: 'copy', label: 'Copy link', enabled: !!item.url, why: item.url ? '' : 'No GitHub link' }); From 7349e448ae8e5bda9ce9499d267c7c0ff142d692 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Wed, 28 Oct 2026 21:35:19 -0400 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=8C=B1=20test:=20lift=20the=20000-new?= =?UTF-8?q?=20helper=20into=20the=20stale-triage=20node=20fixture?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andrew Anderson --- src/pkg/dashboard/stage_tracker_stale_triage.test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pkg/dashboard/stage_tracker_stale_triage.test.js b/src/pkg/dashboard/stage_tracker_stale_triage.test.js index 86b87b32d6..b2edc72a0a 100644 --- a/src/pkg/dashboard/stage_tracker_stale_triage.test.js +++ b/src/pkg/dashboard/stage_tracker_stale_triage.test.js @@ -19,8 +19,10 @@ function pick(re, what) { const src = [ pick(/const STAGE_TRACKER_TRIAGE_STAGE = \d+;/, 'STAGE_TRACKER_TRIAGE_STAGE'), pick(/const STAGE_TRACKER_ACTIONABLE_STAGE = \d+;/, 'STAGE_TRACKER_ACTIONABLE_STAGE'), + pick(/const STAGE_TRACKER_NEW_MOVER_MAINTAINER = '[a-z]+';/, 'STAGE_TRACKER_NEW_MOVER_MAINTAINER'), pick(/function stageTrackerStaleLabelsText\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerStaleLabelsText'), pick(/function stageTrackerTriageNeeded\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerTriageNeeded'), + pick(/function stageTrackerTriageNewState\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerTriageNewState'), ].join('\n'); const { staleText, triageNeeded } = new Function(src + '; return { staleText: stageTrackerStaleLabelsText, triageNeeded: stageTrackerTriageNeeded };')(); @@ -40,4 +42,8 @@ test('a stale needs-triage is not "triage needed" and offers no Accept triage', assert.strictEqual(triageNeeded({ kind: 'issue', stage: 15, modifiers: [] }), true, '015 is triage needed by its stage word'); assert.strictEqual(triageNeeded({ kind: 'issue', stage: 10, modifiers: ['needs-triage'] }), true, 'the pill before the claim still counts'); assert.strictEqual(triageNeeded({ kind: 'pr', stage: 50, modifiers: ['needs-triage'] }), false); + // The label-less 000-new row the reporter-trust gate holds (hivecommons/hive#15215). + assert.strictEqual(triageNeeded({ kind: 'issue', stage: 0, modifiers: [], new: { next_mover: 'maintainer' } }), true, 'a 000-new reporter-trust hold is triage needed'); + assert.strictEqual(triageNeeded({ kind: 'issue', stage: 0, modifiers: [], new: { next_mover: 'hive' } }), false, 'an admitted reporter\'s new issue is not'); + assert.strictEqual(triageNeeded({ kind: 'issue', stage: 0, modifiers: [] }), false); });