diff --git a/changelog.d/fixed-tracker-no-destructive-lead-chip.md b/changelog.d/fixed-tracker-no-destructive-lead-chip.md new file mode 100644 index 0000000000..98f6a8bb7f --- /dev/null +++ b/changelog.d/fixed-tracker-no-destructive-lead-chip.md @@ -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. diff --git a/src/pkg/dashboard/stage_tracker_decision.go b/src/pkg/dashboard/stage_tracker_decision.go index 910f3dad30..e058be76ac 100644 --- a/src/pkg/dashboard/stage_tracker_decision.go +++ b/src/pkg/dashboard/stage_tracker_decision.go @@ -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 @@ -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) @@ -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 { diff --git a/src/pkg/dashboard/stage_tracker_decision_redundant_test.go b/src/pkg/dashboard/stage_tracker_decision_redundant_test.go index 25846b0ab5..ec3cc4ac5b 100644 --- a/src/pkg/dashboard/stage_tracker_decision_redundant_test.go +++ b/src/pkg/dashboard/stage_tracker_decision_redundant_test.go @@ -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) @@ -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) + } } diff --git a/src/pkg/dashboard/stage_tracker_lead_action_test.go b/src/pkg/dashboard/stage_tracker_lead_action_test.go index eddb39752a..ea28fc7b66 100644 --- a/src/pkg/dashboard/stage_tracker_lead_action_test.go +++ b/src/pkg/dashboard/stage_tracker_lead_action_test.go @@ -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"]`, } { @@ -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: [] }, diff --git a/src/pkg/dashboard/stage_tracker_presence.test.js b/src/pkg/dashboard/stage_tracker_presence.test.js index 75f56ab359..f826c0f47b 100644 --- a/src/pkg/dashboard/stage_tracker_presence.test.js +++ b/src/pkg/dashboard/stage_tracker_presence.test.js @@ -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, /^/); - assert.match(flat(chip), /waiting on ]*>]*><\/svg><\/span>@zoe<\/span>$/); + assert.match(flat(chip), /waiting on ]*>]*><\/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) } }; diff --git a/src/pkg/dashboard/stage_tracker_presence_test.go b/src/pkg/dashboard/stage_tracker_presence_test.go index 83a27911f8..4e103b65a7 100644 --- a/src/pkg/dashboard/stage_tracker_presence_test.go +++ b/src/pkg/dashboard/stage_tracker_presence_test.go @@ -300,7 +300,7 @@ const w = stageTrackerPresenceChipHtml(online); assert.ok(/^waiting on ]*>[\s\S]*<\/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(/^waiting on ]*>]*>[\s\S]*<\/svg><\/span>@zoe<\/span>$/.test(hw), hw); +assert.ok(/^waiting on ]*>]*>[\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. diff --git a/src/pkg/dashboard/stage_tracker_row_actions_test.go b/src/pkg/dashboard/stage_tracker_row_actions_test.go index 379f391ac6..7abec59ba5 100644 --- a/src/pkg/dashboard/stage_tracker_row_actions_test.go +++ b/src/pkg/dashboard/stage_tracker_row_actions_test.go @@ -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"), @@ -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' }] } }; diff --git a/src/pkg/dashboard/static-src/js/tracker-actions.js b/src/pkg/dashboard/static-src/js/tracker-actions.js index e17860ba44..04aed59200 100644 --- a/src/pkg/dashboard/static-src/js/tracker-actions.js +++ b/src/pkg/dashboard/static-src/js/tracker-actions.js @@ -358,11 +358,19 @@ const server = d && Array.isArray(d.options) ? d.options : []; const out = []; for (const o of server) { - if (!o || !o.action || STAGE_TRACKER_GENERIC_ACTIONS.indexOf(o.action) >= 0 || o.action.indexOf('decide:') !== 0 || (taken && taken[o.action])) continue; + // A server-marked lead (`lead`) heads the menu even when the + // Decide… submenu lists the same verb generically: the row's + // answer is this one, with its consequence. + if (!o || !o.action || STAGE_TRACKER_GENERIC_ACTIONS.indexOf(o.action) >= 0 || o.action.indexOf('decide:') !== 0 || (taken && taken[o.action] && !o.lead)) continue; const allowed = stageTrackerActionAllowed(o.action, ctx); const enabled = !!o.enabled && allowed.enabled; const why = enabled ? '' : (o.enabled ? allowed.why : (o.reason_if_disabled || 'Not available on this row')); - out.push({ id: o.action, label: o.label || STAGE_TRACKER_ACTION_LABELS[o.action] || o.action, hint: o.consequence || '', enabled, why, danger: /^decide:close-/.test(o.action), lead: true, target: dec.item }); + // A destructive option never leads the row on its own: only when + // the server marks it (`lead`, the reviewer named the PR that + // supersedes this one) does a close become the inline button. It + // still sits in the ⋯ menu either way. + const danger = /^decide:close-/.test(o.action); + out.push({ id: o.action, label: o.label || STAGE_TRACKER_ACTION_LABELS[o.action] || o.action, hint: o.consequence || '', enabled, why, danger, lead: !danger || !!o.lead, target: dec.item }); } return out; } @@ -434,8 +442,9 @@ const lead = actions.find(a => a.lead); if (lead) return lead; const decide = actions.find(a => a.id === 'decide'); - if (decide && Array.isArray(decide.submenu) && decide.submenu.length) { - const o = decide.submenu.find(x => x.enabled) || decide.submenu[0]; + const safe = decide && Array.isArray(decide.submenu) ? decide.submenu.filter(x => x && !x.danger) : []; + if (safe.length) { + const o = safe.find(x => x.enabled) || safe[0]; const enabled = !!decide.enabled && !!o.enabled; return Object.assign({}, o, { target: decide.target, enabled, why: enabled ? '' : (decide.enabled ? o.why : decide.why) }); } @@ -455,12 +464,28 @@ const host = typeof window !== 'undefined' && window.location ? String(window.location.hostname || '') : ''; if ((host === 'localhost' || host === '127.0.0.1') && typeof console !== 'undefined' && console.warn) console.warn('[tracker] ' + msg); } + // Pure: the lead the row itself renders. An issue row whose lead acts + // on a nested PR (stageTrackerDecisionTarget resolved to the one parked + // PR) renders none when that PR has its own sub-row carrying the same + // button — "Let hive decide" showed twice per item (hive#15320 → + // #15647, hive#15338 → #15648). The ⋯ menu's "Decide PR #N…" stays on + // the parent. subRows: the linked PRs drawn as sub-rows, or none. + function stageTrackerLeadActionOnRow(item, ctx, subRows) { + const a = stageTrackerLeadAction(item, ctx); + if (!a || !a.target || !Array.isArray(subRows) || !subRows.length || item.kind !== 'issue') return a; + const t = a.target; + if (t.kind !== 'pr') return a; + const lp = subRows.find(x => x && Number(x.number) === Number(t.number) && !x.superseded && (!x.repo || !t.repo || x.repo === t.repo)); + if (!lp) return a; + const sub = typeof stageTrackerLinkedPRItem === 'function' ? stageTrackerLinkedPRItem(item, lp) : null; + return sub && stageTrackerLeadAction(sub, ctx) ? null : a; + } // The inline lead button for a row: a real
${stageTrackerRowToolsHtml(item)}
- ${stageTrackerHeadColsHtml(prRefs, leadHtml, stageTrackerActedBadgeHtml(item, nowMs) + stageTrackerChipsHtml(shown) + (typeof stageTrackerLeadButtonHtml === 'function' ? stageTrackerLeadButtonHtml(item, nowMs) : ''))} + ${stageTrackerHeadColsHtml(prRefs, leadHtml, stageTrackerActedBadgeHtml(item, nowMs) + stageTrackerChipsHtml(shown) + (typeof stageTrackerLeadButtonHtml === 'function' ? stageTrackerLeadButtonHtml(item, nowMs, subRows) : ''))}
    ${stageTrackerStripItems(shown, stages, range, nowMs, ctx)}
diff --git a/src/pkg/dashboard/static-src/js/tracker-words.js b/src/pkg/dashboard/static-src/js/tracker-words.js index 8824f20dce..73dc452b26 100644 --- a/src/pkg/dashboard/static-src/js/tracker-words.js +++ b/src/pkg/dashboard/static-src/js/tracker-words.js @@ -1436,11 +1436,14 @@ } // The waiting-on pill for a row with presence but no adoption line (071 // Needs author, 072 before the first nudge, a human's PR): "waiting on - // [person] @zoe" — the glyph says who, the title says the rest. + // [person] @zoe" — the glyph says who, the title says the rest. A + // person's own PR reads "waiting on @zoe to push": the hive waits for + // their commit, it is not asking anyone to close it. function stageTrackerPresenceChipText(item) { const p = stageTrackerPresenceOf(item); if (!p) return ''; - const text = 'waiting on @' + p.login; + const ownPR = item && item.kind === 'pr' && item.author_kind === 'human' && p.kind === 'human' && String(item.author || '').toLowerCase() === String(p.login).toLowerCase(); + const text = 'waiting on @' + p.login + (ownPR ? ' to push' : ''); // Guarded: the test harnesses load helpers by name. return typeof stageTrackerReworkSuffix === 'function' ? stageTrackerReworkSuffix(text, item) : text; } diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index b15cdca94d..1c509a74d3 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -15869,11 +15869,14 @@

Where to get help

} // The waiting-on pill for a row with presence but no adoption line (071 // Needs author, 072 before the first nudge, a human's PR): "waiting on - // [person] @zoe" — the glyph says who, the title says the rest. + // [person] @zoe" — the glyph says who, the title says the rest. A + // person's own PR reads "waiting on @zoe to push": the hive waits for + // their commit, it is not asking anyone to close it. function stageTrackerPresenceChipText(item) { const p = stageTrackerPresenceOf(item); if (!p) return ''; - const text = 'waiting on @' + p.login; + const ownPR = item && item.kind === 'pr' && item.author_kind === 'human' && p.kind === 'human' && String(item.author || '').toLowerCase() === String(p.login).toLowerCase(); + const text = 'waiting on @' + p.login + (ownPR ? ' to push' : ''); // Guarded: the test harnesses load helpers by name. return typeof stageTrackerReworkSuffix === 'function' ? stageTrackerReworkSuffix(text, item) : text; } @@ -17108,12 +17111,14 @@

Where to get help

// stageTrackerLeadActionHtml), computed against the viewer's own // permissions on the item's repo; '' where the actions module or a // viewer context is absent (the node harness lifts this file alone). - function stageTrackerLeadButtonHtml(item, nowMs) { + // subRows: the linked PRs drawn as sub-rows under an issue row — a lead + // that acts on one of them renders there, never on both rows. + function stageTrackerLeadButtonHtml(item, nowMs, subRows) { if (typeof stageTrackerLeadActionHtml !== 'function' || typeof stageTrackerActionCtx !== 'function' || !item) return ''; const ctx = stageTrackerActionCtx(item.repo); if (!ctx) return ''; ctx.nowMs = typeof nowMs === 'number' ? nowMs : Date.now(); - return stageTrackerLeadActionHtml(item, ctx); + return stageTrackerLeadActionHtml(item, ctx, subRows); } // PR link, then the lineage chip (null = none), then the base pill. function stageTrackerPRPillsHtml(ref, lineage, baseRef) { @@ -17348,7 +17353,7 @@

Where to get help

const nowMs = Number(ctx.nowMs) || Date.now(); const isIssue = item.kind === 'issue'; const title = item.title || ''; - let prRefs = [], shown = item, range = null, subs = ''; + let prRefs = [], shown = item, range = null, subs = '', subRows = null; if (isIssue) { const linked = stageTrackerLinkedSorted(item, stages); if (linked.length === 1) { @@ -17364,6 +17369,7 @@

Where to get help

range = { to: 20 }; if (stageTrackerAnchor(item.stage, stages, item.kind) <= 20) shown = Object.assign({}, item, { stage: 40 }); subs = linked.map(lp => stageTrackerSubRowHtml(lp, item, stages, nowMs, ctx)).join(''); + subRows = linked; } } // Invariant (owner): the issue slot on the left never holds a PR. A @@ -17409,7 +17415,7 @@

Where to get help

return `
${stageTrackerRowToolsHtml(item)}
- ${stageTrackerHeadColsHtml(prRefs, leadHtml, stageTrackerActedBadgeHtml(item, nowMs) + stageTrackerChipsHtml(shown) + (typeof stageTrackerLeadButtonHtml === 'function' ? stageTrackerLeadButtonHtml(item, nowMs) : ''))} + ${stageTrackerHeadColsHtml(prRefs, leadHtml, stageTrackerActedBadgeHtml(item, nowMs) + stageTrackerChipsHtml(shown) + (typeof stageTrackerLeadButtonHtml === 'function' ? stageTrackerLeadButtonHtml(item, nowMs, subRows) : ''))}
    ${stageTrackerStripItems(shown, stages, range, nowMs, ctx)}
@@ -19414,11 +19420,19 @@

All labels

const server = d && Array.isArray(d.options) ? d.options : []; const out = []; for (const o of server) { - if (!o || !o.action || STAGE_TRACKER_GENERIC_ACTIONS.indexOf(o.action) >= 0 || o.action.indexOf('decide:') !== 0 || (taken && taken[o.action])) continue; + // A server-marked lead (`lead`) heads the menu even when the + // Decide… submenu lists the same verb generically: the row's + // answer is this one, with its consequence. + if (!o || !o.action || STAGE_TRACKER_GENERIC_ACTIONS.indexOf(o.action) >= 0 || o.action.indexOf('decide:') !== 0 || (taken && taken[o.action] && !o.lead)) continue; const allowed = stageTrackerActionAllowed(o.action, ctx); const enabled = !!o.enabled && allowed.enabled; const why = enabled ? '' : (o.enabled ? allowed.why : (o.reason_if_disabled || 'Not available on this row')); - out.push({ id: o.action, label: o.label || STAGE_TRACKER_ACTION_LABELS[o.action] || o.action, hint: o.consequence || '', enabled, why, danger: /^decide:close-/.test(o.action), lead: true, target: dec.item }); + // A destructive option never leads the row on its own: only when + // the server marks it (`lead`, the reviewer named the PR that + // supersedes this one) does a close become the inline button. It + // still sits in the ⋯ menu either way. + const danger = /^decide:close-/.test(o.action); + out.push({ id: o.action, label: o.label || STAGE_TRACKER_ACTION_LABELS[o.action] || o.action, hint: o.consequence || '', enabled, why, danger, lead: !danger || !!o.lead, target: dec.item }); } return out; } @@ -19490,8 +19504,9 @@

All labels

const lead = actions.find(a => a.lead); if (lead) return lead; const decide = actions.find(a => a.id === 'decide'); - if (decide && Array.isArray(decide.submenu) && decide.submenu.length) { - const o = decide.submenu.find(x => x.enabled) || decide.submenu[0]; + const safe = decide && Array.isArray(decide.submenu) ? decide.submenu.filter(x => x && !x.danger) : []; + if (safe.length) { + const o = safe.find(x => x.enabled) || safe[0]; const enabled = !!decide.enabled && !!o.enabled; return Object.assign({}, o, { target: decide.target, enabled, why: enabled ? '' : (decide.enabled ? o.why : decide.why) }); } @@ -19511,12 +19526,28 @@

All labels

const host = typeof window !== 'undefined' && window.location ? String(window.location.hostname || '') : ''; if ((host === 'localhost' || host === '127.0.0.1') && typeof console !== 'undefined' && console.warn) console.warn('[tracker] ' + msg); } + // Pure: the lead the row itself renders. An issue row whose lead acts + // on a nested PR (stageTrackerDecisionTarget resolved to the one parked + // PR) renders none when that PR has its own sub-row carrying the same + // button — "Let hive decide" showed twice per item (hive#15320 → + // #15647, hive#15338 → #15648). The ⋯ menu's "Decide PR #N…" stays on + // the parent. subRows: the linked PRs drawn as sub-rows, or none. + function stageTrackerLeadActionOnRow(item, ctx, subRows) { + const a = stageTrackerLeadAction(item, ctx); + if (!a || !a.target || !Array.isArray(subRows) || !subRows.length || item.kind !== 'issue') return a; + const t = a.target; + if (t.kind !== 'pr') return a; + const lp = subRows.find(x => x && Number(x.number) === Number(t.number) && !x.superseded && (!x.repo || !t.repo || x.repo === t.repo)); + if (!lp) return a; + const sub = typeof stageTrackerLinkedPRItem === 'function' ? stageTrackerLinkedPRItem(item, lp) : null; + return sub && stageTrackerLeadAction(sub, ctx) ? null : a; + } // The inline lead button for a row: a real