From 99d549be89a4607121b0a568f91ed416b9cd16ae Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Wed, 4 Nov 2026 14:55:03 -0500 Subject: [PATCH] fix(dashboard): accept triage advances the issue to 010 actionable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clicking Accept triage added triage/accepted but wrote no stage label, so an issue the reporter-trust gate had parked at 000-new (no stage label, no engine record) kept reading "New" until the stage engine's next pass; the tracker's 015→010 override only covered a stored 015 record. The handler now writes stage/010-actionable with the accept label when the issue carries no stage label or stage/015 (removes before adds, so a single stage label; never regresses a later stage; skipped on a held issue), and a retry on an accepted-but-unstaged issue adds the stage label instead of no-op'ing. The tracker derives 010 for triage/accepted with no stage label and no record rather than 000-new. Signed-off-by: Andrew Anderson --- .../fixed-accept-triage-advances-stage.md | 1 + .../dashboard/api_repo_item_accept_triage.go | 112 +++++++++++--- .../api_repo_item_accept_triage_test.go | 141 ++++++++++++++++-- .../stage_tracker_accept_triage_test.go | 34 +++++ src/pkg/dashboard/stage_tracker_build.go | 3 + 5 files changed, 255 insertions(+), 36 deletions(-) create mode 100644 changelog.d/fixed-accept-triage-advances-stage.md diff --git a/changelog.d/fixed-accept-triage-advances-stage.md b/changelog.d/fixed-accept-triage-advances-stage.md new file mode 100644 index 0000000000..f8b1b6ece9 --- /dev/null +++ b/changelog.d/fixed-accept-triage-advances-stage.md @@ -0,0 +1 @@ +- Activity Monitor "Accept triage" now moves the issue to 010 Actionable in the same request: the handler writes `stage/010-actionable` alongside `triage/accepted` when the issue has no stage label or wears `stage/015-triage-needed` (never regressing a later stage, never on a held issue), and the tracker no longer reads an issue carrying `triage/accepted` with no stage label as 000-new while waiting for the engine's next pass. diff --git a/src/pkg/dashboard/api_repo_item_accept_triage.go b/src/pkg/dashboard/api_repo_item_accept_triage.go index 8eaf71ebed..98081e0d35 100644 --- a/src/pkg/dashboard/api_repo_item_accept_triage.go +++ b/src/pkg/dashboard/api_repo_item_accept_triage.go @@ -18,14 +18,18 @@ import ( // theirs — add the reporter-trust triage label (`triage/accepted` or the // first of `issue_filter.reporter_trust.untrusted_require_labels`) and drop // the awaiting label (`needs-triage` / `reporter_trust.awaiting_label`). The -// labels are the whole signal: the reporter-trust gate admits the issue on -// its next poll, the stage engine moves 015 → 010 (never a regression), and -// a label-driven repository's own sweep reads the approval label exactly as -// if the maintainer had applied it by hand. A Hive-written -// `stage/015-triage-needed` label is removed with the awaiting label so the -// chevron does not keep reading "Triage needed" until the engine's next -// cycle. Authorised like Hold (write permission on the repo or the verified -// owner role); attributed to the signed-in dashboard user in the audit log. +// labels are the signal the reporter-trust gate admits the issue on at its +// next poll, and a label-driven repository's own sweep reads the approval +// label exactly as if the maintainer had applied it by hand. The handler +// also moves the stage in the same request: an issue with no stage label +// (parked 000-new by the gate) or wearing a Hive-written +// `stage/015-triage-needed` gets `stage/010-actionable` (015 removed with +// the awaiting label), so the row leaves "New" / "Triage needed" on the next +// poll instead of waiting for the engine's cycle (hivecommons/hive#16652 +// sat at "New" after the click). A higher stage is never regressed; the +// engine's next pass may refine 010. Authorised like Hold (write permission +// on the repo or the verified owner role); attributed to the signed-in +// dashboard user in the audit log. const ( acceptTriageAuditAction = "repo_item_accept_triage" @@ -97,15 +101,26 @@ func acceptTriagePlan(labels []string, accept string, awaiting []string) (add, r return add, remove } -// stageTrackerAcceptedTriageRecord reports whether rec parks the issue at -// 015 while its labels already say triage was accepted (the accept label is -// on, no awaiting label and no 015 stage label remain). The labels are the -// newer fact; the record is waiting on the engine's next reconcile, and the -// row reads 010 Actionable meanwhile. -func (s *Server) stageTrackerAcceptedTriageRecord(rec stagelabels.Record, labels []string) bool { - if rec.Stage != stagelabels.TriageNeeded { - return false +// acceptTriageStageAdvance is pure: the stage label to add so the accepted +// issue reads 010 Actionable, or "" when it already carries a stage label +// other than 015 (a claim or a covering PR is further along and is never +// regressed) or is on hold (the reconciler strips stage labels from a held +// item; the row reads "on hold" whatever the stage). stageOf reads the +// item's current stage from its labels. +func acceptTriageStageAdvance(labels []string, hiveID string, stageOf func([]string) stagelabels.Stage) string { + if len(holdLabels(labels, hiveID)) > 0 { + return "" } + switch stageOf(labels) { + case stagelabels.None, stagelabels.TriageNeeded: + return stagelabels.Actionable.Label() + } + return "" +} + +// acceptTriageLabelsAccepted reports whether labels say triage was accepted: +// the accept label is on and no awaiting label and no 015 stage label remain. +func (s *Server) acceptTriageLabelsAccepted(labels []string) bool { accept, awaiting := s.acceptTriageLabels() if !acceptTriageHasLabel(labels, accept) { return false @@ -114,6 +129,31 @@ func (s *Server) stageTrackerAcceptedTriageRecord(rec stagelabels.Record, labels return len(remove) == 0 } +// stageTrackerAcceptedTriageStage is the stage the tracker shows for an +// issue the engine has no stage for (no record, or a record at None) whose +// labels already say triage was accepted: 010 Actionable rather than +// 000-new, until the engine's next pass records it. "New" is never derived +// from the mere absence of a stage label when the accept label is present +// (hivecommons/hive#16652). +func (s *Server) stageTrackerAcceptedTriageStage(stage stagelabels.Stage, rec stagelabels.Record, hasRec bool, labels []string) stagelabels.Stage { + if stage != stagelabels.None || (hasRec && rec.Stage != stagelabels.None) { + return stage + } + if s.acceptTriageLabelsAccepted(labels) { + return stagelabels.Actionable + } + return stage +} + +// stageTrackerAcceptedTriageRecord reports whether rec parks the issue at +// 015 while its labels already say triage was accepted (the accept label is +// on, no awaiting label and no 015 stage label remain). The labels are the +// newer fact; the record is waiting on the engine's next reconcile, and the +// row reads 010 Actionable meanwhile. +func (s *Server) stageTrackerAcceptedTriageRecord(rec stagelabels.Record, labels []string) bool { + return rec.Stage == stagelabels.TriageNeeded && s.acceptTriageLabelsAccepted(labels) +} + func (s *Server) handleRepoItemAcceptTriage(w http.ResponseWriter, r *http.Request) { owner, repoName, number, ok := s.parseRepoItemPath(w, r) if !ok { @@ -156,8 +196,13 @@ func (s *Server) handleRepoItemAcceptTriage(w http.ResponseWriter, r *http.Reque } accept, awaiting := s.acceptTriageLabels() add, remove := acceptTriagePlan(labels, accept, awaiting) + hiveID := "" + if s.deps.Config != nil { + hiveID = s.deps.Config.HiveID + } + stageLabel := acceptTriageStageAdvance(labels, hiveID, labelStage) out := repoAcceptTriageResponse{OK: true, Repo: repoFull, Number: number, AcceptLabel: accept, Added: []string{}, Removed: []string{}} - if len(add) == 0 && len(remove) == 0 { + if len(add) == 0 && len(remove) == 0 && stageLabel == "" { out.MinStatusSeq, err = s.refreshAcceptedTriage(ctx, repoFull, number) if err != nil { jsonError(w, "Triage is already accepted on GitHub, but the work handoff could not be refreshed: "+err.Error(), http.StatusBadGateway) @@ -170,17 +215,21 @@ func (s *Server) handleRepoItemAcceptTriage(w http.ResponseWriter, r *http.Reque jsonResponse(w, out) return } + alreadyAccepted := len(add) == 0 if len(add) > 0 { if err := s.deps.GHClient.EnsureIssueLabel(ctx, repoFull, accept, acceptTriageLabelColor, acceptTriageLabelDescription); err != nil { jsonError(w, err.Error(), http.StatusBadGateway) return } - if err := s.deps.GHClient.AddLabels(ctx, repoFull, number, add); err != nil { + } + if stageLabel != "" { + if err := s.deps.GHClient.EnsureIssueLabel(ctx, repoFull, stageLabel, stagelabels.StageColor, stagelabels.Actionable.Description()); err != nil { jsonError(w, err.Error(), http.StatusBadGateway) return } - out.Added = add } + // Removes before adds so the issue never carries two stage labels + // (015 off before 010 on), matching stagelabels.Enforce. for _, label := range remove { if err := s.deps.GHClient.RemoveLabel(ctx, repoFull, number, label); err != nil { jsonError(w, err.Error(), http.StatusBadGateway) @@ -188,13 +237,29 @@ func (s *Server) handleRepoItemAcceptTriage(w http.ResponseWriter, r *http.Reque } } out.Removed = remove + if stageLabel != "" { + add = append(add, stageLabel) + } + if len(add) > 0 { + if err := s.deps.GHClient.AddLabels(ctx, repoFull, number, add); err != nil { + jsonError(w, err.Error(), http.StatusBadGateway) + return + } + out.Added = add + } s.auditFromRequest(r, acceptTriageAuditAction, auditDetail("repo", repoFull, "number", strconv.Itoa(number), "added", strings.Join(add, ","), "removed", strings.Join(remove, ",")), "") out.MinStatusSeq, err = s.refreshAcceptedTriage(ctx, repoFull, number) if err != nil { jsonError(w, "Triage labels were saved on GitHub, but the work handoff could not be refreshed: "+err.Error(), http.StatusBadGateway) return } - outcome := "Triage accepted: `" + accept + "` added" + outcome := "Triage accepted: `" + strings.Join(add, "`, `") + "` added" + if alreadyAccepted { + outcome = "Triage already accepted: `" + strings.Join(add, "`, `") + "` added" + if len(add) == 0 { + outcome = "Triage already accepted" + } + } if len(remove) > 0 { outcome += ", `" + strings.Join(remove, "`, `") + "` removed" } @@ -241,14 +306,15 @@ func (s *Server) refreshAcceptedTriage(ctx context.Context, repo string, number return seq, nil } -// 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. +// acceptTriageNextText is the result's "next" line: the row reads 010 +// actionable now; 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." + return next + "; the row reads 010 actionable now and the reporter-trust gate admits the issue on that poll." } // governorNextPassIn is the governor's published next kick as an ETA 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 4eb10299b2..8e0309c260 100644 --- a/src/pkg/dashboard/api_repo_item_accept_triage_test.go +++ b/src/pkg/dashboard/api_repo_item_accept_triage_test.go @@ -156,18 +156,21 @@ func TestRepoItemAcceptTriageAuthorizationAndLabels(t *testing.T) { if !resp.OK || resp.AlreadyAccepted || resp.AcceptLabel != "triage/accepted" { t.Fatalf("response = %+v", resp) } - if got := strings.Join(mock.added, ","); got != "triage/accepted" { - t.Fatalf("added = %q, want triage/accepted", got) + if got := strings.Join(mock.added, ","); got != "triage/accepted,stage/010-actionable" { + t.Fatalf("added = %q, want triage/accepted and the 010 stage label", got) } - if got := strings.Join(mock.created, ","); got != "triage/accepted" { - t.Fatalf("created = %q, want the accept label ensured", got) + if got := strings.Join(mock.created, ","); got != "triage/accepted,stage/010-actionable" { + t.Fatalf("created = %q, want the accept and stage labels ensured", got) } if got := strings.Join(mock.removed, ","); got != "needs-triage,stage/015-triage-needed" { t.Fatalf("removed = %q, want needs-triage and the 015 stage label", got) } - if strings.Join(resp.Removed, ",") != "needs-triage,stage/015-triage-needed" || strings.Join(resp.Added, ",") != "triage/accepted" { + if strings.Join(resp.Removed, ",") != "needs-triage,stage/015-triage-needed" || strings.Join(resp.Added, ",") != "triage/accepted,stage/010-actionable" { t.Fatalf("response labels = %+v", resp) } + if got := labelStage(mock.issueLabels); got != stagelabels.Actionable { + t.Fatalf("issue stage after accept = %v labels=%v, want 010 and exactly one stage label", got, mock.issueLabels) + } var audited bool for _, entry := range srv.GetAudit().Recent(10) { @@ -195,13 +198,79 @@ func TestRepoItemAcceptTriageAuthorizationAndLabels(t *testing.T) { if w := postAcceptTriage(t, srv, "", true); w.Code != http.StatusOK { t.Fatalf("owner: code=%d body=%s", w.Code, w.Body.String()) } - if strings.Join(mock.added, ",") != "triage/accepted" { + if strings.Join(mock.added, ",") != "triage/accepted,stage/010-actionable" { t.Fatalf("owner added = %v", mock.added) } } +// An issue the reporter-trust gate parked at 000-new (no awaiting label, no +// stage label — hivecommons/hive#16652) leaves "New" in the same request: +// the handler writes stage/010-actionable with the accept label instead of +// waiting for the engine's next pass. A stage further along is never +// regressed. +func TestRepoItemAcceptTriageAdvancesStage(t *testing.T) { + mock := &acceptTriageMock{permission: "write", issueLabels: []string{"bug", "help wanted"}} + srv := newAcceptTriageServer(t, mock) + w := postAcceptTriage(t, srv, "writer", false) + if w.Code != http.StatusOK { + t.Fatalf("code=%d body=%s", w.Code, w.Body.String()) + } + var resp repoAcceptTriageResponse + _ = json.Unmarshal(w.Body.Bytes(), &resp) + if strings.Join(mock.added, ",") != "triage/accepted,stage/010-actionable" || len(mock.removed) != 0 { + t.Fatalf("000-new issue: added=%v removed=%v", mock.added, mock.removed) + } + if resp.AlreadyAccepted || strings.Join(resp.Added, ",") != "triage/accepted,stage/010-actionable" { + t.Fatalf("response = %+v", resp) + } + if resp.Result == nil || resp.Result.Action != rowActionTriaged || !strings.Contains(resp.Result.Outcome, "`stage/010-actionable` added") { + t.Fatalf("result = %+v", resp.Result) + } + + // Accept label already on but no stage label (the state #16652 was left + // in): a retry adds only the stage label and is not a no-op. + mock.added, mock.removed, mock.created = nil, nil, nil + mock.issueLabels = []string{"bug", "triage/accepted"} + w = postAcceptTriage(t, srv, "writer", false) + if w.Code != http.StatusOK { + t.Fatalf("retry: code=%d body=%s", w.Code, w.Body.String()) + } + resp = repoAcceptTriageResponse{} + _ = json.Unmarshal(w.Body.Bytes(), &resp) + if strings.Join(mock.added, ",") != "stage/010-actionable" || len(mock.removed) != 0 || resp.AlreadyAccepted { + t.Fatalf("retry: added=%v removed=%v resp=%+v", mock.added, mock.removed, resp) + } + if resp.Result == nil || resp.Result.Action != rowActionTriaged || !strings.HasPrefix(resp.Result.Outcome, "Triage already accepted: `stage/010-actionable` added") { + t.Fatalf("retry result = %+v", resp.Result) + } + + // Accepted and already 010: a true no-op. + mock.added, mock.removed = nil, nil + mock.issueLabels = []string{"bug", "triage/accepted", "stage/010-actionable"} + w = postAcceptTriage(t, srv, "writer", false) + resp = repoAcceptTriageResponse{} + _ = json.Unmarshal(w.Body.Bytes(), &resp) + if w.Code != http.StatusOK || !resp.AlreadyAccepted || len(mock.added)+len(mock.removed) != 0 { + t.Fatalf("already 010: code=%d resp=%+v added=%v removed=%v", w.Code, resp, mock.added, mock.removed) + } + + // Claimed (020) is further along than 010: only the triage labels move. + mock.added, mock.removed = nil, nil + mock.issueLabels = []string{"needs-triage", "stage/020-claimed"} + w = postAcceptTriage(t, srv, "writer", false) + if w.Code != http.StatusOK { + t.Fatalf("claimed: code=%d body=%s", w.Code, w.Body.String()) + } + if strings.Join(mock.added, ",") != "triage/accepted" || strings.Join(mock.removed, ",") != "needs-triage" { + t.Fatalf("claimed: added=%v removed=%v, must not regress 020", mock.added, mock.removed) + } + if got := labelStage(mock.issueLabels); got != stagelabels.Claimed { + t.Fatalf("claimed stage after accept = %v labels=%v", got, mock.issueLabels) + } +} + func TestRepoItemAcceptTriageIdempotentAndIssuesOnly(t *testing.T) { - mock := &acceptTriageMock{permission: "maintain", issueLabels: []string{"bug", "triage/accepted"}} + mock := &acceptTriageMock{permission: "maintain", issueLabels: []string{"bug", "triage/accepted", "stage/010-actionable"}} srv := newAcceptTriageServer(t, mock) w := postAcceptTriage(t, srv, "writer", false) @@ -222,13 +291,14 @@ func TestRepoItemAcceptTriageIdempotentAndIssuesOnly(t *testing.T) { } } - // Accepted label on, but the awaiting label lingers: only the removal happens. + // Accepted label on, but the awaiting label lingers: the removal happens + // and the stage-less issue is advanced to 010. mock.issueLabels = []string{"triage/accepted", "needs-triage"} w = postAcceptTriage(t, srv, "writer", false) if w.Code != http.StatusOK { t.Fatalf("lingering awaiting: code=%d body=%s", w.Code, w.Body.String()) } - if len(mock.added) != 0 || strings.Join(mock.removed, ",") != "needs-triage" { + if strings.Join(mock.added, ",") != "stage/010-actionable" || strings.Join(mock.removed, ",") != "needs-triage" { t.Fatalf("lingering awaiting: added=%v removed=%v", mock.added, mock.removed) } resp = repoAcceptTriageResponse{} @@ -282,8 +352,8 @@ func TestRepoItemAcceptTriageUsesConfiguredLabels(t *testing.T) { if w.Code != http.StatusOK { t.Fatalf("code=%d body=%s", w.Code, w.Body.String()) } - if strings.Join(mock.added, ",") != "triage/ok" { - t.Fatalf("added = %v, want the first configured accept label", mock.added) + if strings.Join(mock.added, ",") != "triage/ok,stage/010-actionable" { + t.Fatalf("added = %v, want the first configured accept label and the 010 stage", mock.added) } if strings.Join(mock.removed, ",") != "awaiting-maintainer,needs-triage" { t.Fatalf("removed = %v", mock.removed) @@ -318,6 +388,42 @@ func TestRepoItemAcceptTriagePlanAndStalenessRule(t *testing.T) { t.Fatal("only a 015 record is retired") } + // The stage advance the handler writes: 010 for a stage-less or 015 + // issue, nothing for one further along. + if got := acceptTriageStageAdvance([]string{"bug"}, "h1", labelStage); got != "stage/010-actionable" { + t.Fatalf("stage-less advance = %q", got) + } + if got := acceptTriageStageAdvance([]string{"stage/015-triage-needed"}, "h1", labelStage); got != "stage/010-actionable" { + t.Fatalf("015 advance = %q", got) + } + for _, l := range []string{"stage/010-actionable", "stage/020-claimed", "stage/040-covered-by-pr", "hold", "hive-pause/h1"} { + if got := acceptTriageStageAdvance([]string{l}, "h1", labelStage); got != "" { + t.Fatalf("%s advance = %q, want none", l, got) + } + } + + // Tracker derivation: triage/accepted with no stage label and no engine + // record is 010, not 000-new (hivecommons/hive#16652); an awaiting label + // still on, or a record / label stage, is left alone. + none := stagelabels.Record{} + if got := srv.stageTrackerAcceptedTriageStage(stagelabels.None, none, false, []string{"bug", "triage/accepted"}); got != stagelabels.Actionable { + t.Fatalf("accepted without stage = %v, want 010", got) + } + if got := srv.stageTrackerAcceptedTriageStage(stagelabels.None, none, true, []string{"triage/accepted"}); got != stagelabels.Actionable { + t.Fatalf("accepted with a None record = %v, want 010", got) + } + if got := srv.stageTrackerAcceptedTriageStage(stagelabels.None, none, false, []string{"triage/accepted", "needs-triage"}); got != stagelabels.None { + t.Fatalf("awaiting label still on = %v, want none", got) + } + if got := srv.stageTrackerAcceptedTriageStage(stagelabels.None, none, false, []string{"bug"}); got != stagelabels.None { + t.Fatalf("not accepted = %v, want none", got) + } + if got := srv.stageTrackerAcceptedTriageStage(stagelabels.Claimed, none, false, []string{"triage/accepted"}); got != stagelabels.Claimed { + t.Fatalf("label stage kept = %v", got) + } + if got := srv.stageTrackerAcceptedTriageStage(stagelabels.None, stagelabels.Record{Stage: stagelabels.IssueNeedsDecision}, true, []string{"triage/accepted"}); got != stagelabels.None { + t.Fatalf("record stage wins = %v", got) + } } // The result's "next" line carries the governor's next pass when one is @@ -411,7 +517,7 @@ func TestAcceptTriageRefreshesWorkAndRetryAfterReload(t *testing.T) { t.Fatal(err) } } - if strings.Join(mock.added, ",") != "triage/accepted" || strings.Join(mock.removed, ",") != "needs-triage" { + if strings.Join(mock.added, ",") != "triage/accepted,stage/010-actionable" || strings.Join(mock.removed, ",") != "needs-triage" { t.Fatalf("retry repeated label writes: added=%v removed=%v", mock.added, mock.removed) } } @@ -425,7 +531,7 @@ func TestAcceptTriageHandoffFailuresAndConcurrentGates(t *testing.T) { wantErrorText string }{ {name: "read failure after write", mock: acceptTriageMock{issueLabels: []string{"needs-triage"}, failRead: 2}, wantStatus: http.StatusBadGateway, wantErrorText: "labels were saved"}, - {name: "read failure on retry", mock: acceptTriageMock{issueLabels: []string{"triage/accepted"}, failRead: 2}, wantStatus: http.StatusBadGateway, wantErrorText: "already accepted"}, + {name: "read failure on retry", mock: acceptTriageMock{issueLabels: []string{"triage/accepted", "stage/010-actionable"}, failRead: 2}, wantStatus: http.StatusBadGateway, wantErrorText: "already accepted"}, {name: "revoked during refresh", mock: acceptTriageMock{issueLabels: []string{"triage/accepted"}, refreshLabels: []string{"needs-triage"}}, wantStatus: http.StatusBadGateway, wantErrorText: "issue changed"}, {name: "label removal failed", mock: acceptTriageMock{issueLabels: []string{"needs-triage"}, failRemove: true}, wantStatus: http.StatusBadGateway}, {name: "hold remains", mock: acceptTriageMock{issueLabels: []string{"needs-triage", "hold"}}, wantStatus: http.StatusOK, wantBucket: github.WebhookBucketHeld}, @@ -454,6 +560,15 @@ func TestAcceptTriageHandoffFailuresAndConcurrentGates(t *testing.T) { if strings.Join(tc.mock.removed, ",") != "needs-triage" { t.Fatalf("triage removed a hold/human gate: %v", tc.mock.removed) } + // A held issue is "on hold" whatever its stage: no stage label + // is written for the reconciler to strip again. + wantAdded := "triage/accepted,stage/010-actionable" + if tc.wantBucket == github.WebhookBucketHeld { + wantAdded = "triage/accepted" + } + if got := strings.Join(tc.mock.added, ","); got != wantAdded { + t.Fatalf("added = %q, want %q", got, wantAdded) + } }) } } diff --git a/src/pkg/dashboard/stage_tracker_accept_triage_test.go b/src/pkg/dashboard/stage_tracker_accept_triage_test.go index c00f233f32..faafaa1333 100644 --- a/src/pkg/dashboard/stage_tracker_accept_triage_test.go +++ b/src/pkg/dashboard/stage_tracker_accept_triage_test.go @@ -3,6 +3,10 @@ package dashboard import ( "strings" "testing" + "time" + + "github.com/hivecommons/hive/pkg/github" + "github.com/hivecommons/hive/pkg/stagelabels" ) // The activity monitor row menu's "Accept triage" (Hub Admin request): shown @@ -135,3 +139,33 @@ let refreshed = 0; function stageTrackerAfterActions() { refreshed++; } })().catch(e => { console.error(e); process.exit(1); }); `) } + +// A row whose labels carry triage/accepted but no stage label and no engine +// record (hivecommons/hive#16652: the click landed, the pod rolled before +// the engine's pass) reads 010 Actionable, not 000-new; the same labels +// with needs-triage still on stay 000-new. +func TestStageTrackerAcceptedTriageWithoutStageLabelIsNotNew(t *testing.T) { + now := time.Date(2026, 10, 20, 12, 0, 0, 0, time.UTC) + t.Cleanup(github.ResetWebhookTrackerForTestWithClock(func() time.Time { return now })) + s, store := stageTrackerFixture(t, now) + opened := now.Add(-7 * time.Minute) + accepted := github.RepoWorkIssue{Repo: "acme/console", Number: 16652, Title: "lack of SSO looks like crashed application", Author: "pat", AuthorIsHuman: true, Labels: []string{"bug", "help wanted", "triage/accepted"}, CreatedAt: opened, UpdatedAt: opened, Bucket: "reporter_triage", Reason: "Awaiting maintainer triage label"} + waiting := github.RepoWorkIssue{Repo: "acme/console", Number: 16653, Title: "Still waiting", Author: "pat", AuthorIsHuman: true, Labels: []string{"bug", "triage/accepted", "needs-triage"}, CreatedAt: opened, UpdatedAt: opened, Bucket: "reporter_triage", Reason: "Awaiting maintainer triage label"} + s.applyWebhookItemSnapshots([]github.WebhookItemSnapshot{ + {Repo: "acme/console", Number: 16652, State: "open", Title: accepted.Title, Author: "pat", Labels: accepted.Labels, UpdatedAt: opened, + Patch: github.WebhookItemPatch{Bucket: github.WebhookBucketUnknown, WorkIssue: &accepted}}, + {Repo: "acme/console", Number: 16653, State: "open", Title: waiting.Title, Author: "pat", Labels: waiting.Labels, UpdatedAt: opened, + Patch: github.WebhookItemPatch{Bucket: github.WebhookBucketUnknown, WorkIssue: &waiting}}, + }) + resp := s.buildStageTracker(s.status, store, now) + it := trackerItem(t, resp, "issue", 16652) + if it.Stage != stagelabels.Actionable.Number() || it.StageSlug == StageTrackerNewSlug || it.New != nil { + t.Fatalf("#16652 = stage %d slug %q new %+v, want 010 actionable", it.Stage, it.StageSlug, it.New) + } + if hasMod(it, modNeedsTriage) { + t.Fatalf("#16652 still asks for triage: %+v", it) + } + if other := trackerItem(t, resp, "issue", 16653); other.Stage != 0 || other.StageSlug != StageTrackerNewSlug { + t.Fatalf("#16653 = stage %d slug %q, want 000-new while needs-triage is on", other.Stage, other.StageSlug) + } +} diff --git a/src/pkg/dashboard/stage_tracker_build.go b/src/pkg/dashboard/stage_tracker_build.go index 4da5dbebd6..be870c95c0 100644 --- a/src/pkg/dashboard/stage_tracker_build.go +++ b/src/pkg/dashboard/stage_tracker_build.go @@ -321,6 +321,9 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto if stage == stagelabels.None && !(ok && rec.Stage != stagelabels.None) { stage = bucketStage(bucket) } + // Triage accepted on the labels but no stage anywhere yet: 010, not + // 000-new, until the engine's next pass (hivecommons/hive#16652). + stage = s.stageTrackerAcceptedTriageStage(stage, rec, ok, issue.Labels) // A held issue is "Open · on hold" whatever stage label or store // record the hold caught it with; the reconciler drops both on its // next cycle (hivecommons/hive#13012).