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/fixed-tracker-no-destructive-lead-chip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity Monitor tracker: a human-authored PR waiting on its own author no longer leads with the red "Close as superseded" inline button (a close leads only when the server marks it `lead`, i.e. the reviewer named the superseding PR) and its pill reads "waiting on @author to push"; an issue and its asking nested PR render "Let hive decide" once, on the PR sub-row, instead of twice.
10 changes: 9 additions & 1 deletion src/pkg/dashboard/stage_tracker_decision.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ type StageTrackerDecisionOption struct {
// URL is set on link options (open:app-settings): the SPA opens it
// instead of posting an action (hivecommons/hive#15099).
URL string `json:"url,omitempty"`
// Lead marks a destructive option (decide:close-*) the row may show as
// its inline lead button. The SPA never leads a row with a close
// unless the server says the close is the answer — a reviewer naming
// the PR that supersedes this one (RedundantOf). Without it a human's
// PR waiting on its author led with "Close as superseded" just because
// the non-destructive options already sat in the Decide… submenu.
Lead bool `json:"lead,omitempty"`
}

// Action ids shared with the SPA's row context menu
Expand Down Expand Up @@ -555,7 +562,7 @@ func decisionForWaitingOnAuthor(it StageTrackerItem, held bool) *StageTrackerDec
if clause := decisionPlainReason(strings.TrimSpace(it.Reason)); strings.TrimSpace(it.Reason) != "" && clause != "the hive parked it" {
what = "a new commit (" + clause + ")"
}
d.Question = "This PR waits on " + who + " for " + what + ". The hive never rewrites a person's PR. Wait for them, or close it?"
d.Question = "This PR waits on " + who + " to push " + what + ". The hive never rewrites a person's PR; it waits unless you say otherwise."
d.Blocker = "Nothing for the hive to do until " + who + " pushes."
if held {
d.Blocker += " " + decisionHeldBlocker(it.Hold)
Expand Down Expand Up @@ -884,6 +891,7 @@ func decisionForPR(it StageTrackerItem, verdict *review.Aggregate, sentinelLabel
func decisionLeadWithCloseSuperseded(opts []StageTrackerDecisionOption, redundantOf int) []StageTrackerDecisionOption {
lead := decisionOption(decisionActionCloseSuperseded, "Close as superseded", true, "")
lead.Consequence = "Closes this PR as superseded by #" + strconv.Itoa(redundantOf) + ", which already carries its change."
lead.Lead = true
out := make([]StageTrackerDecisionOption, 0, len(opts)+1)
out = append(out, lead)
for _, o := range opts {
Expand Down
38 changes: 38 additions & 0 deletions src/pkg/dashboard/stage_tracker_decision_redundant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,18 @@ func TestDecisionForPRRedundantOfLeadsWithCloseSuperseded(t *testing.T) {
if len(d.Options) == 0 || d.Options[0].Action != decisionActionCloseSuperseded || !strings.Contains(d.Options[0].Consequence, "#15427") {
t.Fatalf("lead option = %+v, want close-superseded naming #15427", d.Options)
}
// The one place a close is the row's inline lead: the server says so.
if !d.Options[0].Lead {
t.Fatalf("redundant-of close-superseded not marked lead: %+v", d.Options[0])
}
seen := 0
for _, o := range d.Options {
if o.Action == decisionActionCloseSuperseded {
seen++
}
if o.Lead && o.Action != decisionActionCloseSuperseded {
t.Fatalf("unexpected lead option %+v", o)
}
}
if seen != 1 {
t.Fatalf("close-superseded listed %d times", seen)
Expand All @@ -62,4 +69,35 @@ func TestDecisionForPRRedundantOfLeadsWithCloseSuperseded(t *testing.T) {
if plain.RedundantOf != 0 || plain.Options[0].Action != decisionActionDelegate {
t.Fatalf("plain decision = %+v", plain)
}
for _, o := range plain.Options {
if o.Lead {
t.Fatalf("plain decision marks %s lead", o.Action)
}
}
}

// A human's PR waiting on its own author offers the closes in the menu but
// never marks one as the row's lead — the SPA shows no destructive inline
// button for a row that only waits on a person to push.
func TestDecisionForWaitingOnAuthorNeverLeadsWithClose(t *testing.T) {
it := StageTrackerItem{Repo: "hivecommons/hive", Number: 15626, Kind: "pr", Stage: 72, Author: "clubanderson", AuthorKind: authorKindHuman, Reason: "changes-requested"}
d := decisionForWaitingOnAuthor(it, false)
if d == nil || len(d.Options) == 0 || d.Options[0].Action != decisionActionDelegate {
t.Fatalf("decision = %+v", d)
}
if !strings.Contains(d.Question, "waits on @clubanderson to push") || strings.Contains(d.Question, "close it?") {
t.Fatalf("question = %q", d.Question)
}
closes := 0
for _, o := range d.Options {
if o.Lead {
t.Fatalf("option %s marked lead on a waiting-on-author row", o.Action)
}
if strings.HasPrefix(o.Action, "decide:close-") {
closes++
}
}
if closes != 2 {
t.Fatalf("closes in the menu = %d, want 2: %+v", closes, d.Options)
}
}
31 changes: 30 additions & 1 deletion src/pkg/dashboard/stage_tracker_lead_action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestStageTrackerLeadActionInline(t *testing.T) {
`class="ham-lead-act`,
`e.target.closest('.ham-lead-act[data-ham-act]')`,
`stageTrackerDecisionRun(item, b.dataset.hamAct)`,
`stageTrackerChipsHtml(shown) + (typeof stageTrackerLeadButtonHtml === 'function' ? stageTrackerLeadButtonHtml(item, nowMs) : '')`,
`stageTrackerChipsHtml(shown) + (typeof stageTrackerLeadButtonHtml === 'function' ? stageTrackerLeadButtonHtml(item, nowMs, subRows) : '')`,
`stageTrackerChipsHtml(pr) + (typeof stageTrackerLeadButtonHtml === 'function' ? stageTrackerLeadButtonHtml(pr, nowMs) : '')`,
`.ham-lead-act[aria-disabled="true"]`,
} {
Expand Down Expand Up @@ -85,6 +85,35 @@ if (typeof stageTrackerAdoptOffered === 'function') {
assert.strictEqual(labelOf(stageTrackerLeadActionHtml(returned, ctx)), 'Adopt…');
}

// One button per ask (owner: "there are 2 hive decide for each of these
// items... should only be 1"). An issue with several linked PRs draws one
// sub-row per PR; when its one parked PR asks (hive#15320 → #15647 at 085),
// the issue row's lead resolves to that PR too. The sub-row — the row with
// the Needs-human-decision chevron — carries the button; the parent renders
// none, while its ⋯ menu keeps "Decide PR #N…".
const asking = { number: 15647, url: 'https://github.com/o/r/pull/15647', title: 'Fix it', author: 'hive', author_kind: 'hive', stage: 85, modifiers: ['needs-decision'],
decision_needed: { question: 'Approve or send back?', options: [{ action: 'decide:delegate', label: 'Let hive decide', enabled: true }, { action: 'decide:approve', label: 'Approve', enabled: true }, { action: 'hold', label: 'Hold', enabled: true }] } };
const closedPR = { number: 15600, url: 'https://github.com/o/r/pull/15600', title: 'First try', author: 'hive', author_kind: 'hive', stage: 50, modifiers: [], state: 'closed' };
const parent = { repo: 'o/r', kind: 'issue', number: 15320, title: 'Tracker lead chips', url: 'https://github.com/o/r/issues/15320', stage: 40, actor: 'maintainer', modifiers: [], linked_prs: [asking, closedPR] };
const sub = stageTrackerLinkedPRItem(parent, asking);
const parentLead = stageTrackerLeadAction(parent, ctx);
assert.strictEqual(parentLead.id, 'decide:delegate');
assert.strictEqual(parentLead.target.number, 15647, 'the parent row\'s lead acts on the nested PR');
assert.strictEqual(stageTrackerLeadAction(sub, ctx).id, 'decide:delegate');
// Without sub-rows (one covering PR, no nested line) the issue row keeps its button.
assert.strictEqual(buttons(stageTrackerLeadActionHtml(parent, ctx)), 1);
// With the PR drawn as a sub-row, the parent yields nothing and the pair renders exactly one.
assert.strictEqual(stageTrackerLeadActionOnRow(parent, ctx, parent.linked_prs), null, 'the sub-row carries the button');
const pairHtml = stageTrackerLeadActionHtml(parent, ctx, parent.linked_prs) + stageTrackerLeadActionHtml(sub, ctx);
assert.strictEqual(buttons(pairHtml), 1, 'one Let hive decide per item: ' + pairHtml);
assert.ok(pairHtml.includes('aria-label="Let hive decide — o/r#15647"'), pairHtml);
// The parent's ⋯ menu still offers Decide PR #N….
const parentMenu = stageTrackerRowActions(parent, ctx).find(a => a.id === 'decide');
assert.ok(parentMenu && parentMenu.label === 'Decide PR #15647…', JSON.stringify(parentMenu));
// A lead that is the issue's own (045 parked issue, sub-rows that ask nothing) stays on the parent.
const ownAsk = { ...parked, linked_prs: [{ ...closedPR, number: 15601 }, { ...closedPR, number: 15602 }] };
assert.strictEqual(stageTrackerLeadActionOnRow(ownAsk, ctx, ownAsk.linked_prs).id, 'decide:delegate');

// Rows that wait on nobody here render no button.
for (const it of [
{ repo: 'o/r', kind: 'issue', number: 8, title: 'Flaky test', url: 'https://github.com/o/r/issues/8', stage: 20, actor: 'hive', modifiers: [] },
Expand Down
4 changes: 2 additions & 2 deletions src/pkg/dashboard/stage_tracker_presence.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ test('human: the person glyph and the handle only — no dot, no "(human · no c
assert.ok(!dot.includes(api.icons.clanker), 'never the robot head');
assert.ok(!dot.includes('ham-presence-dot'), 'a human carries no state dot');
assert.match(dot, /aria-label="@zoe: human — waiting for a human reply"/);
assert.strictEqual(api.chipText(human), 'waiting on @zoe');
assert.strictEqual(api.chipText(human), 'waiting on @zoe to push', "a person's own PR says what the hive waits for");
const chip = api.chip(human);
assert.match(chip, /^<span class="ham-badge ham-badge-waiting" title="Waiting on @zoe \(human\) — waiting for a human reply" aria-label="Waiting on @zoe \(human\) — waiting for a human reply">/);
assert.match(flat(chip), /waiting on <span class="ham-presence ham-presence-unknown ham-presence-human"[^>]*><svg [^>]*><\/svg><\/span>@zoe<\/span>$/);
assert.match(flat(chip), /waiting on <span class="ham-presence ham-presence-unknown ham-presence-human"[^>]*><svg [^>]*><\/svg><\/span>@zoe to push<\/span>$/);
assert.ok(!chip.includes('no clanker'));
// An unregistered clanker (another hive's PR) is unknown too — robot head + hollow ring — and adoption's clock runs.
const foreign = { presence: { login: 'bot-x', state: 'unknown', kind: 'clanker', since: iso(NOW - 10 * MIN), next: 'adopt', adopt_at: iso(NOW + 5 * MIN) } };
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/dashboard/stage_tracker_presence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ const w = stageTrackerPresenceChipHtml(online);
assert.ok(/^<span class="ham-badge ham-badge-waiting" title="Waiting on @Danathar&#39;s clanker \(online, last seen 2 min ago\) — hive is waiting for them" aria-label="Waiting on @Danathar&#39;s clanker \([^"]*">waiting on <span class="ham-presence ham-presence-online ham-presence-clanker"[^>]*>[\s\S]*<i class="ham-presence-dot"><\/i><\/span>@Danathar<\/span>$/.test(w), w);
// A human: the person glyph and the handle, nothing else — no dot, no "(human · no clanker)" qualifier.
const hw = stageTrackerPresenceChipHtml(human);
assert.ok(/^<span class="ham-badge ham-badge-waiting" title="Waiting on @zoe \(human\) — waiting for a human reply" aria-label="Waiting on @zoe \(human\) — waiting for a human reply">waiting on <span class="ham-presence ham-presence-unknown ham-presence-human"[^>]*><svg [^>]*>[\s\S]*<\/svg><\/span>@zoe<\/span>$/.test(hw), hw);
assert.ok(/^<span class="ham-badge ham-badge-waiting" title="Waiting on @zoe \(human\) — waiting for a human reply" aria-label="Waiting on @zoe \(human\) — waiting for a human reply">waiting on <span class="ham-presence ham-presence-unknown ham-presence-human"[^>]*><svg [^>]*>[\s\S]*<\/svg><\/span>@zoe to push<\/span>$/.test(hw), hw);
assert.ok(!hw.includes('no clanker') && !hw.includes('ham-presence-dot'), hw);
assert.strictEqual(stageTrackerPresenceChipHtml({ kind: 'pr', stage: 71 }), '');
// The Needs-human popover names the presence under the question.
Expand Down
43 changes: 40 additions & 3 deletions src/pkg/dashboard/stage_tracker_row_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func stageTrackerRowActionsPreamble(t *testing.T, html string) string {
jsFunc(t, html, "stageTrackerLeadAction"),
jsFunc(t, html, "stageTrackerMaintainerMoved"),
jsFunc(t, html, "stageTrackerDevWarn"),
jsFunc(t, html, "stageTrackerLeadActionOnRow"),
jsFunc(t, html, "stageTrackerLeadActionHtml"),
jsFunc(t, html, "stageTrackerMenuTextHtml"),
jsFunc(t, html, "stageTrackerFlatActions"),
Expand Down Expand Up @@ -1320,17 +1321,53 @@ assert.strictEqual(STAGE_TRACKER_ACTING_CAPTIONS['decide:merge-now'], 'Merging
assert.strictEqual(STAGE_TRACKER_ACTION_WORDS.merged, 'merged');
assert.strictEqual(STAGE_TRACKER_ACTION_WORDS['queued-for-merge'], 'queued for merge');

// A human-authored PR waiting on its author (072): no Decide… submenu, so
// the server's close answers lead, with their consequences.
// A human-authored PR waiting on its author (072): no Decide… submenu. The
// server's close answers stay in the ⋯ menu with their consequences, but a
// destructive option never leads the row on its own — the row shows no
// inline button rather than "Close as superseded".
const waiting = { repo: 'o/r', kind: 'pr', number: 9, url: 'u', author: 'someone', author_kind: 'human', stage: 72, modifiers: [],
decision_needed: { question: 'This PR waits on @someone for a new commit.', options: [
decision_needed: { question: 'This PR waits on @someone to push a new commit.', options: [
{ action: 'decide:close-superseded', label: 'Close as superseded', enabled: true, consequence: 'closes #9 unmerged, naming the PR that replaces it' },
{ action: 'decide:close-wontfix', label: "Close as won't fix", enabled: true, consequence: 'closes #9 unmerged' },
{ action: 'hold', label: 'Hold', enabled: true } ] } };
as = stageTrackerRowActions(waiting, writer);
assert.deepStrictEqual(ids(as), ['decide:close-superseded', 'decide:close-wontfix', 'hold', 'retry', 'needs-human', 'open', 'copy']);
assert.ok(as[0].danger && as[1].danger);
assert.ok(!as[0].lead && !as[1].lead, 'a close is never the inline lead by default');
assert.strictEqual(as[0].hint, 'closes #9 unmerged, naming the PR that replaces it');
assert.strictEqual(stageTrackerLeadAction(waiting, writer), null, 'no inline button for a PR waiting on its author');
assert.strictEqual(stageTrackerLeadActionHtml(waiting, writer), '');

// The live shape (hivecommons/hive#15626, #15641): a human's PR parked at
// 085 after the review swarm sent it back — delegate and hold sit in the
// Decide… submenu, so the closes were the first options left over and
// "Close as superseded" became the red lead. Now the lead is the
// non-destructive submenu answer.
const sentBack = { repo: 'o/r', kind: 'pr', number: 15626, url: 'u', author: 'clubanderson', author_kind: 'human', stage: 85, modifiers: ['needs-decision'],
rework: { state: 'acknowledged', actor: 'clubanderson' },
decision_needed: { question: 'This PR waits on @clubanderson to push a new commit.', options: [
{ action: 'decide:delegate', label: 'Let hive decide', enabled: true },
{ action: 'decide:close-superseded', label: 'Close as superseded', enabled: true, consequence: 'Closes #15626, naming the PR that replaces it' },
{ action: 'decide:close-wontfix', label: "Close as won't fix", enabled: true, consequence: 'Closes #15626 without merging' },
{ action: 'hold', label: 'Hold', enabled: true } ] } };
let leadSB = stageTrackerLeadAction(sentBack, writer);
assert.ok(leadSB && !/^decide:close-/.test(leadSB.id), 'sent-back PR never leads with a close: ' + JSON.stringify(leadSB));
assert.ok(!leadSB.danger);
const sbDecide = stageTrackerRowActions(sentBack, writer).find(a => a.id === 'decide');
assert.ok(sbDecide && sbDecide.submenu.some(o => o.id === 'decide:close-superseded' && o.danger), 'the Decide… submenu still offers the close');

// When the server says the close IS the answer (lead: the reviewer named
// the PR that supersedes this one — RedundantOf), Close as superseded
// still leads.
const redundant = { ...sentBack, number: 15499, decision_needed: { question: 'q', redundant_of: 15400, options: [
{ action: 'decide:close-superseded', label: 'Close as superseded', enabled: true, lead: true, consequence: 'Closes this PR as superseded by #15400, which already carries its change.' },
{ action: 'decide:delegate', label: 'Let hive decide', enabled: true },
{ action: 'decide:close-wontfix', label: "Close as won't fix", enabled: true },
{ action: 'hold', label: 'Hold', enabled: true } ] } };
leadSB = stageTrackerLeadAction(redundant, writer);
assert.strictEqual(leadSB.id, 'decide:close-superseded');
assert.ok(leadSB.danger && leadSB.lead);
assert.strictEqual(leadSB.hint, 'Closes this PR as superseded by #15400, which already carries its change.');

// A server-disabled lead keeps the server's plain-words reason.
const refused = { ...pr317, decision_needed: { ...decision090, options: [{ action: 'decide:merge-now', label: 'Approve & merge as maintainer', enabled: false, reason_if_disabled: 'Release the hold first' }] } };
Expand Down
Loading
Loading