diff --git a/changelog.d/changed-hive-permission-pill-wording.md b/changelog.d/changed-hive-permission-pill-wording.md new file mode 100644 index 0000000000..e21b15a3bc --- /dev/null +++ b/changelog.d/changed-hive-permission-pill-wording.md @@ -0,0 +1 @@ +- Activity Monitor: the muted pill a PR wears while the hive's GitHub App is missing a permission now reads "hive bot lacks permission" instead of "unauthorized", and its tooltip, the row hover line, the Needs-attention chip title, the needs-human tip, the human-merge gate word and the decision popover say the same — nobody did anything illegitimate, the App installation lacks one permission (hivecommons/hive#16639). The `hive:unauthorized` label, comment marker and API fields are unchanged. diff --git a/src/pkg/dashboard/stage_tracker_caption.go b/src/pkg/dashboard/stage_tracker_caption.go index 3168e11912..a4f5321107 100644 --- a/src/pkg/dashboard/stage_tracker_caption.go +++ b/src/pkg/dashboard/stage_tracker_caption.go @@ -457,12 +457,16 @@ func unauthorizedStepWords(step string) string { return strings.ReplaceAll(strings.TrimSpace(step), "-", " ") } -// Tooltip for the unauthorized pill, per step; the generic form serves a -// label whose stage reason does not (or no longer) names the step. +// Tooltip for the hive-bot-lacks-permission pill, per step; the generic +// form serves a label whose stage reason does not (or no longer) names the +// step. Operator wording says "hive bot lacks permission", never +// "unauthorized" (hivecommons/hive#16639): nobody did anything illegitimate, +// the App installation is missing one permission. The label name +// hive:unauthorized is a contract and stays. const ( - stageTrackerUnauthorizedApproveRuns = "The hive's GitHub App lacks `actions: write`, so it cannot approve the workflow runs GitHub is holding for this head. A maintainer must click Approve and run on the PR's checks banner (or the Actions tab); see the hive:unauthorized comment for the run ids. Hive resumes, and clears the label, once the required checks report." - stageTrackerUnauthorizedGeneric = "The hive's GitHub App lacks a permission for the next step, so only a person can take it; the hive:unauthorized comment on the PR names the permission and the step. Hive resumes, and clears the label, once the step is done." - stageTrackerUnauthorizedMergeWF = "The hive's GitHub App lacks `workflows: write`, so it cannot merge this owner-approved PR that edits .github/workflows files. A maintainer must click Merge on GitHub (the approval already stands), or grant the App Workflows: Read and write so the hive can merge such PRs itself." + stageTrackerUnauthorizedApproveRuns = "The hive bot's GitHub App is missing the 'actions: write' permission needed to approve the workflow runs GitHub is holding for this head, so a person has to take that step: click Approve and run on the PR's checks banner (or the Actions tab); the `hive:unauthorized` comment on the PR lists the run ids. Hive resumes and clears the label once the required checks report." + stageTrackerUnauthorizedGeneric = "The hive bot's GitHub App is missing a permission needed for the next step, so a person has to take that step. The `hive:unauthorized` comment on the PR names the permission and the action; hive resumes and clears the label once it's done." + stageTrackerUnauthorizedMergeWF = "The hive bot's GitHub App is missing the 'workflows: write' permission needed to merge this owner-approved PR that edits .github/workflows files, so a person has to take that step: click Merge on GitHub (the approval already stands), or grant the App Workflows: Read and write so the hive can merge such PRs itself." ) // stageTrackerUnauthorized derives the gate word and the tooltip for an @@ -480,7 +484,7 @@ func stageTrackerUnauthorized(reason string) (step, tip string) { if rest == stageengineprstage.UnauthorizedStepMergeWorkflowPath { return step, stageTrackerUnauthorizedMergeWF } - return step, "The hive's GitHub App lacks the permission to " + step + ", so only a person can take that step; the hive:unauthorized comment on the PR names the permission and the action. Hive resumes, and clears the label, once the step is done." + return step, "The hive bot's GitHub App is missing the permission needed to " + step + ", so a person has to take that step. The `hive:unauthorized` comment on the PR names the permission and the action; hive resumes and clears the label once it's done." } // stageTrackerManualMergeReason reports whether a bare stage reason is a @@ -506,7 +510,7 @@ var stageTrackerHumanMergeReasonWords = map[string][2]string{ stageengineprstage.HumanMergeReasonMergeMethod: {"merge method", "The repo does not allow the merge method this PR needs"}, stageengineprstage.HumanMergeReasonAutoMergeOff: {"auto-merge off", "Auto-merge is off for this repo, so a person merges"}, stageengineprstage.HumanMergeReasonUntrustedAuthor: {"untrusted author", "Hive won't merge it alone — the author isn't a trusted author yet"}, - stageengineprstage.HumanMergeReasonUnauthorized: {"unauthorized", "GitHub does not let hive merge here; a person merges"}, + stageengineprstage.HumanMergeReasonUnauthorized: {"hive bot lacks permission", "The hive bot's GitHub App is missing the permission to merge here; a person merges"}, stageengineprstage.HumanMergeReasonReviewerDeferred: {"reviewer deferred", "A reviewer asked for a person to merge this one"}, stageengineprstage.HumanMergeReasonBreakingChange: {"human merge", "Breaking change — owner merges; hive never merges a ⚠️-titled or needs-owner-merge PR"}, } diff --git a/src/pkg/dashboard/stage_tracker_decision_lanes.go b/src/pkg/dashboard/stage_tracker_decision_lanes.go index 68850309a7..e994922330 100644 --- a/src/pkg/dashboard/stage_tracker_decision_lanes.go +++ b/src/pkg/dashboard/stage_tracker_decision_lanes.go @@ -60,9 +60,9 @@ func decisionForUnauthorized(it StageTrackerItem, held bool) *StageTrackerDecisi step := strings.TrimSpace(it.UnauthorizedStep) if step == "" { _, tip := stageTrackerUnauthorized(it.Reason) - d.Question = "The hive's GitHub App lacks a permission for the next step. " + tip + d.Question = "The hive bot lacks a permission for the next step. " + tip } else { - d.Question = "The hive's GitHub App may not " + unauthorizedStepWords(step) + " here. Do that step on GitHub, then re-evaluate so the hive picks it up." + d.Question = "The hive bot's GitHub App is missing the permission to " + unauthorizedStepWords(step) + " here. Do that step on GitHub, then re-evaluate so the hive picks it up." } d.Blocker = strings.TrimSpace(it.Unauthorized) if d.Blocker == "" { diff --git a/src/pkg/dashboard/stage_tracker_decision_pr.go b/src/pkg/dashboard/stage_tracker_decision_pr.go index 0ee6c76d32..5fc5fbc303 100644 --- a/src/pkg/dashboard/stage_tracker_decision_pr.go +++ b/src/pkg/dashboard/stage_tracker_decision_pr.go @@ -50,7 +50,7 @@ func decisionForPR(it StageTrackerItem, verdict *review.Aggregate, sentinelLabel switch { case it.UnauthorizedStep != "": d.AskedBy = decisionAskedByApp - d.Question = "The hive's GitHub App may not " + unauthorizedStepWords(it.UnauthorizedStep) + " here. A maintainer has to do that step on GitHub." + d.Question = "The hive bot's GitHub App is missing the permission to " + unauthorizedStepWords(it.UnauthorizedStep) + " here. A maintainer has to do that step on GitHub." d.Blocker = strings.TrimSpace(it.Unauthorized) delegateOK, delegateWhy = false, decisionWhyNoPermission approveOK, approveWhy = false, decisionWhyApproveNoGrant diff --git a/src/pkg/dashboard/stage_tracker_pills_gate_test.go b/src/pkg/dashboard/stage_tracker_pills_gate_test.go index b3f805643d..9024aaa40a 100644 --- a/src/pkg/dashboard/stage_tracker_pills_gate_test.go +++ b/src/pkg/dashboard/stage_tracker_pills_gate_test.go @@ -133,7 +133,7 @@ func TestStageTrackerDeferredPillsPayload(t *testing.T) { if !strings.Contains(string(raw), `"modifiers":[],"deferred_modifiers":["sentinel","needs-human"]`) || !strings.Contains(string(raw), `"sentinel_alert":true`) { t.Fatalf("payload: %s", raw) } - if held := trackerItem(t, resp, "pr", 141); held.Stage != 72 || !hasMod(held, modUnauthorized) || len(held.DeferredModifiers) != 0 || held.UnauthorizedStep != "approve workflow runs" || !strings.Contains(held.Unauthorized, "`actions: write`") { + if held := trackerItem(t, resp, "pr", 141); held.Stage != 72 || !hasMod(held, modUnauthorized) || len(held.DeferredModifiers) != 0 || held.UnauthorizedStep != "approve workflow runs" || !strings.Contains(held.Unauthorized, "'actions: write'") { t.Fatalf("PR 141 = stage %d mods %v deferred %v step %q", held.Stage, held.Modifiers, held.DeferredModifiers, held.UnauthorizedStep) } if refused := trackerItem(t, resp, "pr", 142); refused.Stage != 50 || hasMod(refused, modUnauthorized) || !slices.Equal(refused.DeferredModifiers, []string{modUnauthorized}) || refused.UnauthorizedStep != "merge" { @@ -225,7 +225,7 @@ const gate80 = { kind: 'pr', stage: 80, modifiers: [], sentinel_alert: true, hea assert.ok(stageTrackerChipsHtml(gate80).includes('ham-badge-sentinel'), 'sentinel chip at 080'); // Actionable-now pills show wherever the row stands. assert.ok(stageTrackerChipsHtml({ kind: 'pr', stage: 50, modifiers: ['hold'], deferred_modifiers: ['needs-human'] }).includes('>hold<')); -assert.ok(stageTrackerChipsHtml({ kind: 'pr', stage: 72, modifiers: ['unauthorized'], unauthorized: 'needs actions: write' }).includes('>unauthorized<')); +assert.ok(stageTrackerChipsHtml({ kind: 'pr', stage: 72, modifiers: ['unauthorized'], unauthorized: 'needs actions: write' }).includes('>hive bot lacks permission<')); assert.ok(stageTrackerNeedsAttention({ kind: 'pr', stage: 50, modifiers: ['hold'], deferred_modifiers: ['needs-human'] })); // A payload without the field (older server) renders exactly as before. assert.ok(stageTrackerChipsHtml({ kind: 'pr', stage: 50, modifiers: ['needs-human'], sentinel_alert: true }).includes('ham-badge-sentinel')); diff --git a/src/pkg/dashboard/stage_tracker_unauthorized_test.go b/src/pkg/dashboard/stage_tracker_unauthorized_test.go index 2fd5d63a1f..4f57a14db2 100644 --- a/src/pkg/dashboard/stage_tracker_unauthorized_test.go +++ b/src/pkg/dashboard/stage_tracker_unauthorized_test.go @@ -31,11 +31,11 @@ func TestStageTrackerUnauthorizedFromReason(t *testing.T) { for _, tc := range []struct { name, reason, wantStep, wantTip string }{ - {name: "approve workflow runs", reason: approve, wantStep: "approve workflow runs", wantTip: "`actions: write`"}, + {name: "approve workflow runs", reason: approve, wantStep: "approve workflow runs", wantTip: "'actions: write'"}, {name: "human-approved suffix is stripped", reason: approve + ":human-approved@pat", wantStep: "approve workflow runs", wantTip: "Approve and run"}, - {name: "another step", reason: prstage.StageReasonUnauthorizedPrefix + "update-branch", wantStep: "update branch", wantTip: "permission to update branch"}, - {name: "label without a reason", reason: "contributor-lane:soaking(1h)", wantTip: "lacks a permission for the next step"}, - {name: "empty", reason: "", wantTip: "lacks a permission for the next step"}, + {name: "another step", reason: prstage.StageReasonUnauthorizedPrefix + "update-branch", wantStep: "update branch", wantTip: "permission needed to update branch"}, + {name: "label without a reason", reason: "contributor-lane:soaking(1h)", wantTip: "missing a permission needed for the next step"}, + {name: "empty", reason: "", wantTip: "missing a permission needed for the next step"}, } { t.Run(tc.name, func(t *testing.T) { step, tip := stageTrackerUnauthorized(tc.reason) @@ -63,7 +63,7 @@ func TestStageTrackerUnauthorizedPayload(t *testing.T) { s.statusMu.Unlock() resp := s.buildStageTracker(s.status, store, now) it := trackerItem(t, resp, "pr", 130) - if it.Stage != 85 || !hasMod(it, modUnauthorized) || it.UnauthorizedStep != "approve workflow runs" || !strings.Contains(it.Unauthorized, "`actions: write`") { + if it.Stage != 85 || !hasMod(it, modUnauthorized) || it.UnauthorizedStep != "approve workflow runs" || !strings.Contains(it.Unauthorized, "'actions: write'") { t.Fatalf("row = stage %d mods %v step %q tip %q", it.Stage, it.Modifiers, it.UnauthorizedStep, it.Unauthorized) } if !strings.HasPrefix(it.Caption, "Waiting for a maintainer · approve workflow runs on GitHub") || !strings.Contains(it.Caption, "not permitted to approve workflow runs") || it.Actor != "maintainer" { @@ -73,7 +73,7 @@ func TestStageTrackerUnauthorizedPayload(t *testing.T) { if err != nil { t.Fatal(err) } - if !strings.Contains(string(raw), `"unauthorized_step":"approve workflow runs"`) || !strings.Contains(string(raw), `"unauthorized":"The hive's GitHub App lacks`) { + if !strings.Contains(string(raw), `"unauthorized_step":"approve workflow runs"`) || !strings.Contains(string(raw), `"unauthorized":"The hive bot's GitHub App is missing`) { t.Fatalf("payload lacks the unauthorized fields: %s", raw) } if clean := trackerItem(t, resp, "pr", 101); clean.UnauthorizedStep != "" || clean.Unauthorized != "" || hasMod(clean, modUnauthorized) { @@ -118,15 +118,15 @@ func TestStageTrackerUnauthorizedJS(t *testing.T) { jsFunc(t, html, "stageTrackerChipsHtml"), jsFunc(t, html, "stageTrackerNeedsAttention"), }, "\n") + ` -const tip = "The hive's GitHub App lacks \u0060actions: write\u0060, so it cannot approve the workflow runs."; +const tip = "The hive bot's GitHub App is missing the 'actions: write' permission needed to approve the workflow runs."; const item = { kind: 'pr', stage: 85, modifiers: ['unauthorized'], unauthorized_step: 'approve workflow runs', unauthorized: tip }; const pill = stageTrackerChipsHtml(item); -assert.ok(pill.includes('ham-mod-unauthorized') && pill.includes('>unauthorized<'), pill); +assert.ok(pill.includes('ham-mod-unauthorized') && pill.includes('>hive bot lacks permission<'), pill); assert.ok(pill.includes('title="' + esc(tip) + '"'), pill); assert.ok(STAGE_TRACKER_HUMAN_MODS.includes('unauthorized') && STAGE_TRACKER_MOTION_HUMAN_MODS.includes('unauthorized')); assert.ok(stageTrackerNeedsAttention(item)); // unauthorized outranks the needs-* chips but yields to hold, a human instruction. -assert.ok(stageTrackerChipsHtml({ stage: 85, modifiers: ['needs-decision', 'unauthorized'] }).includes('>unauthorized +1<')); +assert.ok(stageTrackerChipsHtml({ stage: 85, modifiers: ['needs-decision', 'unauthorized'] }).includes('>hive bot lacks permission +1<')); assert.ok(stageTrackerChipsHtml({ stage: 10, modifiers: ['unauthorized', 'hold'] }).includes('>hold +1<')); // The 085 chevron names the human step owed; without a step the generic word stays. assert.strictEqual(stageTrackerUnauthorizedWord(item), 'Waiting for a maintainer · approve workflow runs on GitHub'); diff --git a/src/pkg/dashboard/static-src/html/tracker.html b/src/pkg/dashboard/static-src/html/tracker.html index 1c9c43ddb4..2e8a126309 100644 --- a/src/pkg/dashboard/static-src/html/tracker.html +++ b/src/pkg/dashboard/static-src/html/tracker.html @@ -24,7 +24,7 @@