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-15215-accept-triage-new-row.md
Original file line number Diff line number Diff line change
@@ -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)).
30 changes: 29 additions & 1 deletion src/pkg/dashboard/api_repo_item_accept_triage.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dashboard

import (
Expand Down Expand Up @@ -202,10 +202,38 @@
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.
Expand Down
26 changes: 26 additions & 0 deletions src/pkg/dashboard/api_repo_item_accept_triage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}
49 changes: 41 additions & 8 deletions src/pkg/dashboard/stage_tracker_accept_triage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'));
Expand Down
47 changes: 39 additions & 8 deletions src/pkg/dashboard/stage_tracker_new.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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, " / ") + ")"},
Expand All @@ -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)"},
}
Expand All @@ -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 == "" {
Expand Down
16 changes: 16 additions & 0 deletions src/pkg/dashboard/stage_tracker_new_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions src/pkg/dashboard/stage_tracker_row_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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"),
Expand Down
6 changes: 6 additions & 0 deletions src/pkg/dashboard/stage_tracker_stale_triage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };')();

Expand All @@ -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);
});
Loading
Loading