diff --git a/changelog.d/fixed-returned-to-clanker-owner.md b/changelog.d/fixed-returned-to-clanker-owner.md new file mode 100644 index 0000000000..97091dbb82 --- /dev/null +++ b/changelog.d/fixed-returned-to-clanker-owner.md @@ -0,0 +1 @@ +- Activity Monitor: "Returned to" rows now name the clanker's owner (`@login's clanker`) even when an issue is drawn through its covering PR, instead of the issue author (the hive App bot); rows the supersession sweep found superseded say "Superseded by #N · decide" and the "Close as superseded by…" prompt is prefilled with that PR. diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index 86125788ff..76a2b90291 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -1598,11 +1598,12 @@ func adoptedWorkCaption(reason string) string { } // stageTrackerReturnedToHiveCaption rewrites a 072 caption for a -// clanker-authored PR so it names whose hive the PR went back to and who -// sent it: "Returned to @thatguywob's hive — @clubanderson requested -// changes" (hivecommons/hive#15159). The human has already acted and -// nothing is owed by a maintainer, so the "@x must act" tail goes; the -// contributor's hive is the actor. +// clanker-authored PR so it names whose clanker the PR went back to and +// who sent it: "Returned to @thatguywob's clanker — @clubanderson +// requested changes" (hivecommons/hive#15159). The human has already acted +// and nothing is owed by a maintainer, so the "@x must act" tail goes; the +// contributor's clanker is the actor. author is the person the clanker +// acts for (the PR's GitHub author), never the hive App's bot login. func stageTrackerReturnedToHiveCaption(caption, author string, requesters []string) string { who := strings.TrimSpace(author) if who == "" { @@ -1618,7 +1619,7 @@ func stageTrackerReturnedToHiveCaption(caption, author string, requesters []stri if by := mentionLogins(requesters); by != "" { rest = strings.Replace(rest, " — a maintainer requested changes", " — "+by+" requested changes", 1) } - return head + "'s hive" + rest + return head + "'s clanker" + rest } // mentionLogins is "@a", "@a and @b" or "@a, @b and @c" for the given diff --git a/src/pkg/dashboard/stage_tracker_adoption_test.go b/src/pkg/dashboard/stage_tracker_adoption_test.go index a3fbd580e6..4e3da98ec0 100644 --- a/src/pkg/dashboard/stage_tracker_adoption_test.go +++ b/src/pkg/dashboard/stage_tracker_adoption_test.go @@ -377,8 +377,8 @@ func TestStageTrackerAdoptionPersonAuthoredSaysNotAdopted(t *testing.T) { } } -// hivecommons/hive#15159: a clanker-authored 072 row names whose hive the -// PR went back to and who sent it; the "@x must act" tail — a person's +// hivecommons/hive#15159: a clanker-authored 072 row names whose clanker +// the PR went back to and who sent it; the "@x must act" tail — a person's // turn — goes. func TestStageTrackerReturnedToHiveCaption(t *testing.T) { cases := []struct { @@ -386,11 +386,11 @@ func TestStageTrackerReturnedToHiveCaption(t *testing.T) { requesters []string want string }{ - {"Returned to @thatguywob — a maintainer requested changes — @thatguywob must act", []string{"clubanderson"}, "Returned to @thatguywob's hive — @clubanderson requested changes"}, - {"Returned to @thatguywob — a maintainer requested changes — @thatguywob must act", nil, "Returned to @thatguywob's hive — a maintainer requested changes"}, - {"Returned to @thatguywob — a maintainer requested changes — @thatguywob must act (2 nudges sent)", []string{"a", "b"}, "Returned to @thatguywob's hive — @a and @b requested changes (2 nudges sent)"}, - {"Returned to @thatguywob — review swarm requested changes — @thatguywob must act", []string{"clubanderson"}, "Returned to @thatguywob's hive — review swarm requested changes"}, - {"Returned to @thatguywob — review swarm requested changes — waiting on @thatguywob (offline 2h)", nil, "Returned to @thatguywob's hive — review swarm requested changes — waiting on @thatguywob (offline 2h)"}, + {"Returned to @thatguywob — a maintainer requested changes — @thatguywob must act", []string{"clubanderson"}, "Returned to @thatguywob's clanker — @clubanderson requested changes"}, + {"Returned to @thatguywob — a maintainer requested changes — @thatguywob must act", nil, "Returned to @thatguywob's clanker — a maintainer requested changes"}, + {"Returned to @thatguywob — a maintainer requested changes — @thatguywob must act (2 nudges sent)", []string{"a", "b"}, "Returned to @thatguywob's clanker — @a and @b requested changes (2 nudges sent)"}, + {"Returned to @thatguywob — review swarm requested changes — @thatguywob must act", []string{"clubanderson"}, "Returned to @thatguywob's clanker — review swarm requested changes"}, + {"Returned to @thatguywob — review swarm requested changes — waiting on @thatguywob (offline 2h)", nil, "Returned to @thatguywob's clanker — review swarm requested changes — waiting on @thatguywob (offline 2h)"}, {"Returned to contributor", nil, "Returned to contributor"}, } for _, tc := range cases { diff --git a/src/pkg/dashboard/stage_tracker_presence.test.js b/src/pkg/dashboard/stage_tracker_presence.test.js index 17d35aefc3..75f56ab359 100644 --- a/src/pkg/dashboard/stage_tracker_presence.test.js +++ b/src/pkg/dashboard/stage_tracker_presence.test.js @@ -69,7 +69,7 @@ const human = { repo: 'hivecommons/hive', number: 15000, kind: 'pr', stage: 71, presence: { login: 'zoe', state: 'unknown', kind: 'human', since: iso(NOW - 40 * MIN), next: 'wait' } }; test('online clanker: robot head + filled dot, "hive is waiting for them", last seen in words', () => { - assert.strictEqual(api.tip(online14989, NOW), "Waiting on @Danathar's hive (clanker · online, last seen 2 min ago) — hive is waiting for them"); + assert.strictEqual(api.tip(online14989, NOW), "Waiting on @Danathar's clanker (online, last seen 2 min ago) — hive is waiting for them"); const dot = api.dot(online14989, NOW); assert.match(dot, /class="ham-presence ham-presence-online ham-presence-clanker"/); assert.ok(dot.includes(api.icons.clanker), 'draws the robot head'); @@ -79,19 +79,19 @@ test('online clanker: robot head + filled dot, "hive is waiting for them", last assert.match(dot, /data-ham-presence="online"/); // The online grace still projects an adopt-at: the tooltip says so after the wait. const graced = Object.assign({}, online14989, { presence: Object.assign({}, online14989.presence, { adopt_at: iso(NOW + 2 * HOUR) }) }); - assert.strictEqual(api.tip(graced, NOW), "Waiting on @Danathar's hive (clanker · online, last seen 2 min ago) — hive is waiting for them; adopts at 16:32 UTC (in 2h) if nothing moves"); + assert.strictEqual(api.tip(graced, NOW), "Waiting on @Danathar's clanker (online, last seen 2 min ago) — hive is waiting for them; adopts at 16:32 UTC (in 2h) if nothing moves"); }); test('offline clanker: filled square, offline span, adopt-at clock with countdown', () => { - assert.strictEqual(api.tip(offline14524, NOW), "Waiting on @hanthor's hive (clanker · offline 26h) — hive will adopt at 15:10 UTC (in 38m)"); + assert.strictEqual(api.tip(offline14524, NOW), "Waiting on @hanthor's clanker (offline 26h) — hive will adopt at 15:10 UTC (in 38m)"); assert.match(api.dot(offline14524, NOW), /ham-presence-offline/); assert.match(api.dot(offline14524, NOW), /aria-label="@hanthor: clanker offline — hive will adopt at 15:10 UTC \(in 38m\)"/); // Past due. const due = Object.assign({}, offline14524, { presence: Object.assign({}, offline14524.presence, { adopt_at: iso(NOW - MIN) }) }); - assert.strictEqual(api.tip(due, NOW), "Waiting on @hanthor's hive (clanker · offline 26h) — hive will adopt due now"); + assert.strictEqual(api.tip(due, NOW), "Waiting on @hanthor's clanker (offline 26h) — hive will adopt due now"); // Held (maintainer_policy ask): no adopt_at, next=wait — the dot does not promise an adoption the text denies. const held = Object.assign({}, offline14524, { presence: Object.assign({}, offline14524.presence, { next: 'wait', adopt_at: '' }) }); - assert.strictEqual(api.tip(held, NOW), "Waiting on @hanthor's hive (clanker · offline 26h) — hive is waiting for them"); + assert.strictEqual(api.tip(held, NOW), "Waiting on @hanthor's clanker (offline 26h) — hive is waiting for them"); // Long absences read in days. const days = Object.assign({}, offline14524, { presence: Object.assign({}, offline14524.presence, { since: iso(NOW - 80 * HOUR), last_seen: iso(NOW - 80 * HOUR) }) }); assert.match(api.tip(days, NOW), /offline 3d\) — /); @@ -112,14 +112,14 @@ test('human: the person glyph and the handle only — no dot, no "(human · no c 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) } }; - assert.strictEqual(api.tip(foreign, NOW), "Waiting on @bot-x's hive (clanker · not registered here) — hive will adopt at 14:37 UTC (in 5m)"); + assert.strictEqual(api.tip(foreign, NOW), "Waiting on @bot-x's clanker (not registered here) — hive will adopt at 14:37 UTC (in 5m)"); assert.match(flat(api.dot(foreign, NOW)), /class="ham-presence ham-presence-unknown ham-presence-clanker"[^>]*>]*><\/svg><\/i><\/span>$/); }); test('the indicator sits inside the adoption pill just before the @login and its line joins the tooltip', () => { const chip = api.adoptionChip(offline14524); - assert.match(chip, /^]*>]*><\/svg><\/i><\/span>@hanthor<\/span>$/); // A 071 row has no adoption line: the muted waiting pill carries the dot instead, never both. assert.strictEqual(api.chip(offline14524), '', 'no second pill beside the adoption one'); diff --git a/src/pkg/dashboard/stage_tracker_presence_test.go b/src/pkg/dashboard/stage_tracker_presence_test.go index 08641782e0..83a27911f8 100644 --- a/src/pkg/dashboard/stage_tracker_presence_test.go +++ b/src/pkg/dashboard/stage_tracker_presence_test.go @@ -271,10 +271,10 @@ const ask = { kind: 'pr', repo: 'hivecommons/hive', number: 14524, stage: 72, au decision_needed: { question: '@hanthor maintains this repository and has been offline for 26h; adopt the PR?', asked_by: 'the hive', since: iso(NOW - 26 * HOUR), blocker: 'maintainer_policy is ask', options: [{ action: 'decide:adopt', label: 'Adopt (hive takes over)', enabled: true }] }, presence: { login: 'hanthor', state: 'offline', kind: 'clanker', since: iso(NOW - 26 * HOUR), last_seen: iso(NOW - 26 * HOUR), next: 'wait' } }; -assert.strictEqual(stageTrackerPresenceTip(online, NOW), "Waiting on @Danathar's hive (clanker · online, last seen 2 min ago) — hive is waiting for them"); -assert.match(stageTrackerPresenceTip(offline, NOW), /^Waiting on @hanthor's hive \(clanker · offline 26h\) — hive will adopt at \S+ .*\(in 38m\)$/); +assert.strictEqual(stageTrackerPresenceTip(online, NOW), "Waiting on @Danathar's clanker (online, last seen 2 min ago) — hive is waiting for them"); +assert.match(stageTrackerPresenceTip(offline, NOW), /^Waiting on @hanthor's clanker \(offline 26h\) — hive will adopt at \S+ .*\(in 38m\)$/); assert.strictEqual(stageTrackerPresenceTip(human, NOW), 'Waiting on @zoe (human) — waiting for a human reply'); -assert.strictEqual(stageTrackerPresenceTip(ask, NOW), "Waiting on @hanthor's hive (clanker · offline 26h) — hive is waiting for them", 'held adoption promises no adopt-at'); +assert.strictEqual(stageTrackerPresenceTip(ask, NOW), "Waiting on @hanthor's clanker (offline 26h) — hive is waiting for them", 'held adoption promises no adopt-at'); // Kind glyph + state class + aria per state; role=img so it reads out. for (const [item, state, kind, word] of [[online, 'online', 'clanker', 'clanker online'], [offline, 'offline', 'clanker', 'clanker offline'], [human, 'unknown', 'human', 'human']]) { @@ -289,15 +289,15 @@ assert.ok(!stageTrackerPresenceDotHtml(human, NOW).includes(STAGE_TRACKER_ICONS. // Inside the adoption pill, before the @login; the presence line joins the title and aria-label. const chip = stageTrackerAdoptionChipHtml(offline); assert.ok(/>waiting on ]*>]*><\/svg><\/i><\/span>@hanthor<\/span>$/.test(chip.replace(/]*)>[\s\S]*?<\/svg>/, '')), chip); -assert.ok(chip.includes("title=\"waiting on @hanthor (offline 26h, 2 nudges) · Waiting on @hanthor's hive (clanker · offline 26h)"), chip); -assert.ok(chip.includes("aria-label=\"Adoption — waiting on @hanthor (offline 26h, 2 nudges) · Waiting on @hanthor's hive (clanker"), chip); +assert.ok(chip.includes("title=\"waiting on @hanthor (offline 26h, 2 nudges) · Waiting on @hanthor's clanker (offline 26h)"), chip); +assert.ok(chip.includes("aria-label=\"Adoption — waiting on @hanthor (offline 26h, 2 nudges) · Waiting on @hanthor's clanker ("), chip); assert.strictEqual(stageTrackerPresenceChipHtml(offline), '', 'one pill, not two'); // The "adopt?" trigger carries the dot in front of its word. const trig = stageTrackerAdoptionChipHtml(ask); assert.ok(/]*>[\s\S]*<\/span>adopt\?<\/button>$/.test(trig), trig); // No adoption line (071, a human): the muted waiting pill carries it. const w = stageTrackerPresenceChipHtml(online); -assert.ok(/^waiting on ]*>[\s\S]*<\/i><\/span>@Danathar<\/span>$/.test(w), w); +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); @@ -305,7 +305,7 @@ 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. const pop = stageTrackerDecisionPopHtml(ask, [], NOW, ''); -assert.ok(/

]*>[\s\S]*?<\/span>Waiting on @hanthor's hive \(clanker · offline 26h\) — hive is waiting for them<\/p>/.test(pop), pop); +assert.ok(/

]*>[\s\S]*?<\/span>Waiting on @hanthor's clanker \(offline 26h\) — hive is waiting for them<\/p>/.test(pop), pop); assert.ok(!stageTrackerDecisionPopHtml(Object.assign({}, ask, { presence: null }), [], NOW, '').includes('ham-decision-presence')); // Sub-rows and the popover's nested-PR lookup carry the field. `, diff --git a/src/pkg/dashboard/stage_tracker_rework_test.go b/src/pkg/dashboard/stage_tracker_rework_test.go index d4f60930cc..9f56e47d83 100644 --- a/src/pkg/dashboard/stage_tracker_rework_test.go +++ b/src/pkg/dashboard/stage_tracker_rework_test.go @@ -224,7 +224,7 @@ assert.match(stageTrackerReworkTip(working, NOW), /^@Danathar's clanker picked u assert.match(stageTrackerReworkTip(pushed, NOW), /^@Danathar pushed a new head 1 min ago \(.*\) · re-review pending$/); // The pill keeps its class, dot and login; title and aria carry the rework line after the presence line. const chip = stageTrackerPresenceChipHtml(acked); -assert.ok(/^waiting on ]*>[\s\S]*<\/span>@Danathar · acknowledged<\/span>$/.test(chip), chip); +assert.ok(/^waiting on ]*>[\s\S]*<\/span>@Danathar · acknowledged<\/span>$/.test(chip), chip); // Same on the 072 adoption pill. const adopt = Object.assign({}, working, { stage: 72, adoption: { author: 'Danathar', due: false, nudges: 1, author_online: true, author_registered: true, policy: 'adopt', text: 'waiting on @Danathar (online, 1 nudge)' } }); const achip = stageTrackerAdoptionChipHtml(adopt); diff --git a/src/pkg/dashboard/stage_tracker_row_actions_test.go b/src/pkg/dashboard/stage_tracker_row_actions_test.go index 972a17b648..05ee269064 100644 --- a/src/pkg/dashboard/stage_tracker_row_actions_test.go +++ b/src/pkg/dashboard/stage_tracker_row_actions_test.go @@ -63,6 +63,7 @@ func stageTrackerRowActionsPreamble(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerDelegateTargets"), jsFunc(t, html, "stageTrackerDecideOptions"), jsFunc(t, html, "stageTrackerSupersederOptions"), + jsFunc(t, html, "stageTrackerSupersederDefault"), jsFunc(t, html, "stageTrackerSupersederValid"), jsFunc(t, html, "stageTrackerTriageNeeded"), jsFunc(t, html, "stageTrackerTriageNewState"), @@ -312,6 +313,13 @@ assert.strictEqual(stageTrackerSupersederValid('o/r#457', [tgt]), true); assert.strictEqual(stageTrackerSupersederValid('https://github.com/o/r/pull/457', [tgt]), true); assert.strictEqual(typeof stageTrackerSupersederValid('458', [tgt]), 'string', 'self-supersession is refused'); assert.strictEqual(typeof stageTrackerSupersederValid('nope', [tgt]), 'string'); +// The prompt prefills the sweep's finding (hive's hive #15303 → #15304), the +// lone sibling when there is no finding, and nothing otherwise. +assert.strictEqual(stageTrackerSupersederDefault([{ repo: 'o/r', number: 458, superseded: { reason: 'superseded', closer_pr: 457, closer_repo: 'r' } }]), 'o/r#457'); +assert.strictEqual(stageTrackerSupersederDefault([{ repo: 'o/r', number: 458, superseded: { closer_pr: 457, closer_repo: 'o/other' } }]), 'o/other#457'); +assert.strictEqual(stageTrackerSupersederDefault([{ repo: 'o/r', number: 458, superseded: true, siblings: [457] }]), 'o/r#457'); +assert.strictEqual(stageTrackerSupersederDefault([{ repo: 'o/r', number: 458, siblings: [1, 2] }]), ''); +assert.strictEqual(stageTrackerSupersederDefault([{ repo: 'o/r', number: 458, superseded: { closer_pr: 457 } }, { repo: 'o/r', number: 459 }]), '', 'bulk selections are not prefilled'); // A reader: hold/decide disabled with the reason; needs-human needs merger. as = stageTrackerRowActions(parked, { user: false, canHold: false, canHuman: false }); diff --git a/src/pkg/dashboard/stage_tracker_sentinel_lane_test.go b/src/pkg/dashboard/stage_tracker_sentinel_lane_test.go index 1dd3d3780b..b6602a8996 100644 --- a/src/pkg/dashboard/stage_tracker_sentinel_lane_test.go +++ b/src/pkg/dashboard/stage_tracker_sentinel_lane_test.go @@ -30,6 +30,8 @@ func stageTrackerSentinelJS(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerSentinelTip"), jsFunc(t, html, "stageTrackerSentinelInLane"), jsFunc(t, html, "stageTrackerSentinelAsSuffix"), + jsFunc(t, html, "stageTrackerReturnedAuthor"), + jsFunc(t, html, "stageTrackerToolingSuffix"), jsFunc(t, html, "stageTrackerReturnedWord"), jsFunc(t, html, "stageTrackerDirectionCarrier"), jsFunc(t, html, "stageTrackerSentinelChipHtml"), @@ -379,31 +381,46 @@ assert.ok(generic.includes('Sentinel flagged security-relevant changes: ' + esc( // 071/072 + sentinel (hivecommons/hive#15159): the chevron keeps the // routing word — the human already acted — with the alert as a suffix, // never "needs human"; the chip is folded into the word. -assert.strictEqual(stageTrackerReturnedWord({ stage: 72, kind: 'pr', author: 'thatguywob', author_kind: 'clanker' }, 'Returned to contributor'), "Returned to @thatguywob's hive"); +assert.strictEqual(stageTrackerReturnedWord({ stage: 72, kind: 'pr', author: 'thatguywob', author_kind: 'clanker' }, 'Returned to contributor'), "Returned to @thatguywob's clanker"); +assert.strictEqual(stageTrackerReturnedWord({ stage: 72, kind: 'pr', author: 'bee', author_kind: 'hive' }, 'Returned to contributor'), "Returned to @bee's hive"); +// An issue row drawn through its one covering PR names the PR's author, +// not the issue's (hive's hive: #15133 was filed by hivecommons-hive[bot]; +// its PR #15307 is @thatguywob's clanker's). +const viaPR = { stage: 72, kind: 'issue', via_pr: true, number: 15133, author: 'hivecommons-hive[bot]', author_kind: 'hive', linked_prs: [{ number: 15307, author: 'thatguywob', author_kind: 'clanker', stage: 72 }] }; +assert.strictEqual(stageTrackerReturnedWord(viaPR, 'Returned to contributor'), "Returned to @thatguywob's clanker"); +assert.strictEqual(stageTrackerReturnedWord(Object.assign({}, viaPR, { stage: 71 }), 'Needs author'), 'Needs @thatguywob'); +// A PR drawn under another issue is not this row's; only the issue's own +// author is left to name. +assert.strictEqual(stageTrackerReturnedWord(Object.assign({}, viaPR, { linked_prs: [Object.assign({}, viaPR.linked_prs[0], { drawn_under: 15100 })] }), 'Returned to contributor'), "Returned to @hivecommons-hive[bot]'s hive"); +// A row the sweep marked superseded says so instead of "Returned to": +// nothing is owed by the author; a maintainer closes it (#15303 / #15304). +assert.strictEqual(stageTrackerReturnedWord({ stage: 72, kind: 'pr', author: 'thatguywob', author_kind: 'clanker', superseded: { reason: 'superseded', closer_pr: 15304, closer_repo: 'hive' } }, 'Returned to contributor'), 'Superseded by #15304 · decide'); +assert.strictEqual(stageTrackerReturnedWord(Object.assign({ stage: 72, kind: 'pr', author: 'thatguywob', author_kind: 'clanker', superseded: { closer_pr: 15304 } }, flagged), 'x'), 'Superseded by #15304 · decide · sentinel'); +assert.strictEqual(stageTrackerReturnedWord({ stage: 72, kind: 'pr', author: 'thatguywob', author_kind: 'clanker', superseded: true }, 'Returned to contributor'), "Returned to @thatguywob's clanker", 'a bare nested flag names no closer'); assert.strictEqual(stageTrackerReturnedWord({ stage: 72, kind: 'pr', author: 'sam', author_kind: 'human' }, 'Returned to contributor'), 'Returned to @sam'); assert.strictEqual(stageTrackerReturnedWord({ stage: 71, kind: 'pr', author: 'sam' }, 'Needs author'), 'Needs @sam'); assert.strictEqual(stageTrackerReturnedWord({ stage: 72, kind: 'pr' }, 'Returned to contributor'), 'Returned to contributor', 'no author → stage word'); -assert.strictEqual(stageTrackerReturnedWord(Object.assign({ stage: 72, kind: 'pr', author: 'thatguywob', author_kind: 'clanker' }, flagged), 'x'), "Returned to @thatguywob's hive · sentinel"); +assert.strictEqual(stageTrackerReturnedWord(Object.assign({ stage: 72, kind: 'pr', author: 'thatguywob', author_kind: 'clanker' }, flagged), 'x'), "Returned to @thatguywob's clanker · sentinel"); assert.ok(stageTrackerSentinelAsSuffix(P('o/r', 1, 72, flagged)) && stageTrackerSentinelAsSuffix(P('o/r', 1, 71, flagged))); assert.ok(!stageTrackerSentinelAsSuffix(P('o/r', 1, 85, flagged)) && !stageTrackerSentinelAsSuffix(I('o/r', 1, 72, flagged))); const returned = stageTrackerRowHtml(P('o/r', 15159, 72, Object.assign({ author: 'thatguywob', author_kind: 'clanker' }, flagged)), stages, ctx); const retLit = /

  • ]*)>([\s\S]*?)<\/li>/.exec(returned); assert.ok(retLit, 'the lit 072 chevron is tinted: ' + returned); -assert.ok(retLit[2].includes("Returned to @thatguywob's hive · sentinel"), 'routing word with sentinel suffix: ' + retLit[2]); +assert.ok(retLit[2].includes("Returned to @thatguywob's clanker · sentinel"), 'routing word with sentinel suffix: ' + retLit[2]); assert.ok(!returned.includes('needs human') && !returned.includes('Needs human'), 'no needs-human wording at 072: ' + returned); -assert.ok(retLit[1].includes("aria-label=\"Returned to @thatguywob's hive · sentinel — " + TIP + '"'), 'aria names the routing: ' + retLit[1]); +assert.ok(retLit[1].includes("aria-label=\"Returned to @thatguywob's clanker · sentinel — " + TIP + '"'), 'aria names the routing: ' + retLit[1]); assert.ok(retLit[1].includes(' — ' + TIP), 'the tooltip carries the reason: ' + retLit[1]); assert.ok(!returned.includes('ham-badge-sentinel'), 'no chip when the word carries the suffix'); const needsAuthor = stageTrackerRowHtml(P('o/r', 15160, 71, Object.assign({ author: 'sam', author_kind: 'human' }, flagged)), stages, ctx); assert.ok(needsAuthor.includes('Needs @sam · sentinel') && !needsAuthor.includes('needs human'), needsAuthor); const returnedClean = stageTrackerRowHtml(P('o/r', 15161, 72, { author: 'thatguywob', author_kind: 'clanker' }), stages, ctx); -assert.ok(returnedClean.includes("Returned to @thatguywob's hive") && !returnedClean.includes('ham-sentinel') && !returnedClean.includes('entinel'), returnedClean); +assert.ok(returnedClean.includes("Returned to @thatguywob's clanker") && !returnedClean.includes('ham-sentinel') && !returnedClean.includes('entinel'), returnedClean); // 085 still says it in full. assert.ok(stageTrackerRowHtml(P('o/r', 15162, 85, flagged), stages, ctx).includes('Sentinel alert · needs human')); -// Give direction on a clanker PR is carried to the contributor's hive, not -// to the hive's own fixer. -assert.strictEqual(stageTrackerDirectionCarrier([{ kind: 'pr', author: 'thatguywob', author_kind: 'clanker' }]), "@thatguywob's hive"); -assert.strictEqual(stageTrackerDirectionCarrier([{ kind: 'pr', author: '@a', author_kind: 'clanker' }, { kind: 'pr', author: 'b', author_kind: 'clanker' }]), "the contributor's hive"); +// Give direction on a clanker PR is carried to the contributor's clanker, +// not to the hive's own fixer. +assert.strictEqual(stageTrackerDirectionCarrier([{ kind: 'pr', author: 'thatguywob', author_kind: 'clanker' }]), "@thatguywob's clanker"); +assert.strictEqual(stageTrackerDirectionCarrier([{ kind: 'pr', author: '@a', author_kind: 'clanker' }, { kind: 'pr', author: 'b', author_kind: 'clanker' }]), "the contributor's clanker"); assert.strictEqual(stageTrackerDirectionCarrier([{ kind: 'pr', author: 'x', author_kind: 'clanker' }, { kind: 'pr', author: 'hive[bot]', author_kind: 'hive' }]), 'the author agent'); assert.strictEqual(stageTrackerDirectionCarrier([]), 'the author agent'); diff --git a/src/pkg/dashboard/stage_tracker_ui_test.go b/src/pkg/dashboard/stage_tracker_ui_test.go index f08e6849f9..f7d16825d8 100644 --- a/src/pkg/dashboard/stage_tracker_ui_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_test.go @@ -471,8 +471,8 @@ assert.strictEqual(stageTrackerAnchor(95, stages, 'pr'), STAGE_TRACKER_MERGE_COL // PR returned to contributor: detour badge rides Review; chip cap = author kind + first modifier (+N). row = stageTrackerRowHtml({ repo: 'acme/console', number: 102, kind: 'pr', title: 'Fix flaky', stage: 72, lane: 'contributor', tier: 'trusted', author: 'karibhou', author_kind: 'clanker', author_kind_source: 'inferred', modifiers: ['needs-rebase', 'needs-human'], caption: 'Returned to @karibhou', history: [{number:50,slug:'review-pending'},{number:60,slug:'reviewed'},{number:72,slug:'returned-to-contributor',from:60}] }, stages, ctx); assert.deepStrictEqual(segStates(row), [D, D, D, D, 'active detoured', T, 'todo cap']); -// hivecommons/hive#15159: the chevron names the routing — the contributor's hive, for a clanker's PR. -assert.ok(row.includes('Returned to @karibhou's hive'), row); +// hivecommons/hive#15159: the chevron names the routing — the contributor's clanker, for a clanker's PR. +assert.ok(row.includes('Returned to @karibhou's clanker'), row); // Invariant: a PR never occupies the issue slot. A PR with no linked issue // puts the muted "no linked issue" placeholder on the left and names itself // — author icon, #N, title — in the PR column, where a covering PR sits on diff --git a/src/pkg/dashboard/static-src/js/tracker-actions.js b/src/pkg/dashboard/static-src/js/tracker-actions.js index f43bb5eb6a..49461d203b 100644 --- a/src/pkg/dashboard/static-src/js/tracker-actions.js +++ b/src/pkg/dashboard/static-src/js/tracker-actions.js @@ -220,13 +220,13 @@ } // Pure: who carries a direction on these PRs — the hive's own author // agent, or (a clanker-authored PR, hivecommons/hive#15159) the owning - // contributor's hive, which is nudged with the text. + // contributor's clanker, which is nudged with the text. function stageTrackerDirectionCarrier(items) { const list = (items || []).filter(it => it && it.kind === 'pr'); if (!list.length || !list.every(it => it.author_kind === 'clanker')) return 'the author agent'; const authors = Array.from(new Set(list.map(it => String(it.author || '').replace(/^@/, '')).filter(Boolean))); - if (authors.length === 1) return "@" + authors[0] + "'s hive"; - return "the contributor's hive"; + if (authors.length === 1) return "@" + authors[0] + "'s clanker"; + return "the contributor's clanker"; } // Pure: the decision choices for one decision target. On an issue // parked at 045 the verbs are /hive approve and /hive decision. On a PR @@ -1159,6 +1159,24 @@ } return out.sort((a, b) => Number(b.value.split('#')[1]) - Number(a.value.split('#')[1])); } + // Pure: the pre-filled winner for "Close as superseded by": the merged + // PR the supersession sweep already detected on the row (its closer — + // #15303 sat superseded by #15304 with the field empty), else, for a + // nested PR with exactly one open sibling under the same issue (two PRs + // for one issue), that sibling; '' when neither is known. A closer in + // another repo is only named when the sweep spelt it owner/repo. + function stageTrackerSupersederDefault(items) { + const one = Array.isArray(items) && items.length === 1 ? items[0] : null; + if (!one) return ''; + const sup = one.superseded && typeof one.superseded === 'object' ? one.superseded : null; + const closer = sup ? Number(sup.closer_pr) || 0 : 0; + if (closer) { + const cr = String(sup.closer_repo || ''); + return (cr.indexOf('/') >= 0 ? cr : String(one.repo || '')) + '#' + closer; + } + if (Array.isArray(one.siblings) && one.siblings.length === 1) return one.repo + '#' + one.siblings[0]; + return ''; + } // Pure: validates a "superseded by" reference; "" is allowed (no winner named). function stageTrackerSupersederValid(s, items) { s = String(s || '').trim(); @@ -1420,9 +1438,7 @@ } case 'decide:close-superseded': { const options = stageTrackerSupersederOptions(_stageTracker, items); - // A nested PR with exactly one open sibling under the same issue - // (two PRs for one issue): the sibling is the likely winner. - const sibling = items.length === 1 && Array.isArray(items[0].siblings) && items[0].siblings.length === 1 ? items[0].repo + '#' + items[0].siblings[0] : ''; + const sibling = stageTrackerSupersederDefault(items); const by = await hivePrompt({ title: 'Close as superseded by', label: 'Which pull request supersedes ' + refs + '? (#number, owner/repo#number or URL; leave empty if none)', placeholder: options.length ? options[0].value : '#123', defaultValue: sibling, options, validate: s => stageTrackerSupersederValid(s, items) }); if (by == null) return null; const v = await stageTrackerAsk(id, 'prompt', { title: 'Close as superseded', label: 'Comment for ' + refs + ' (optional)', placeholder: 'Why this is closed', confirmLabel: 'Close' }); diff --git a/src/pkg/dashboard/static-src/js/tracker-words.js b/src/pkg/dashboard/static-src/js/tracker-words.js index d328b0f0ab..47fd7d93a7 100644 --- a/src/pkg/dashboard/static-src/js/tracker-words.js +++ b/src/pkg/dashboard/static-src/js/tracker-words.js @@ -932,14 +932,14 @@ return 'at ' + agentNowClockTime(at, nowMs) + ' (' + inWords + ')'; } // The plain-words tooltip: - // Waiting on @Danathar's hive (clanker · online, last seen 2 min ago) — hive is waiting for them - // Waiting on @hanthor's hive (clanker · offline 26h) — hive will adopt at 15:10 (in 38m) + // Waiting on @Danathar's clanker (online, last seen 2 min ago) — hive is waiting for them + // Waiting on @hanthor's clanker (offline 26h) — hive will adopt at 15:10 (in 38m) // Waiting on @zoe (human) — waiting for a human reply function stageTrackerPresenceTip(item, nowMs) { const p = stageTrackerPresenceOf(item); if (!p) return ''; const now = Number(nowMs) || Date.now(); - const hive = "Waiting on @" + p.login + "'s hive (clanker · "; + const hive = "Waiting on @" + p.login + "'s clanker ("; const adopt = stageTrackerPresenceAdoptAt(p, now); let head, next; if (p.state === 'online') { @@ -1145,15 +1145,40 @@ const st = Number(item && item.stage) || 0; return !!(item && item.sentinel_alert) && (st === 71 || st === 72) && (item.kind === 'pr' || !!item.via_pr); } + // Pure: whose PR a 071/072 row waits on — the row's own author, or, for + // an issue row drawn through its one covering PR (via_pr), that PR's + // author. The issue's author is whoever filed it (on hive's hive the + // reviewer's bot, hivecommons-hive[bot]); naming them on the chevron + // read "Returned to @hivecommons-hive[bot]'s hive" for a clanker's PR. + function stageTrackerReturnedAuthor(item) { + let src = item || {}; + if (src.via_pr && Array.isArray(src.linked_prs)) { + const here = src.linked_prs.filter(lp => lp && lp.author && (!Number(lp.drawn_under) || Number(lp.drawn_under) === (Number(src.number) || 0))); + if (here.length === 1) src = here[0]; + } + return { author: String(src.author || '').replace(/^@/, ''), kind: String(src.author_kind || '') }; + } + // "'s clanker" for a clanker's PR (the person's relay agent picks it + // up), "'s hive" for another hive's, nothing for a person's own. + function stageTrackerToolingSuffix(kind) { + if (kind === 'clanker') return "'s clanker"; + if (kind === 'hive') return "'s hive"; + return ''; + } // The 071/072 chevron word names the routing: "Needs @author" at 071, - // "Returned to @author's hive" at 072 for a clanker-authored PR (the + // "Returned to @author's clanker" at 072 for a clanker-authored PR (the // contributor's agent picks it up), "Returned to @author" for a human's. + // A row already superseded by a merged PR says that instead — nothing + // is owed by the author; a maintainer closes it (hivecommons/hive#15303 + // sat as "Returned to …" while its issue was closed by #15304). function stageTrackerReturnedWord(item, fallback) { const st = Number(item && item.stage) || 0; - const author = String((item && item.author) || '').replace(/^@/, ''); + const sup = item && item.superseded && typeof item.superseded === 'object' ? Number(item.superseded.closer_pr) || 0 : 0; + const who = stageTrackerReturnedAuthor(item); let text = fallback; - if (author && st === 71) text = 'Needs @' + author; - else if (author && st === 72) text = 'Returned to @' + author + (item.author_kind === 'human' ? '' : "'s hive"); + if (sup) text = 'Superseded by #' + sup + ' · decide'; + else if (who.author && st === 71) text = 'Needs @' + who.author; + else if (who.author && st === 72) text = 'Returned to @' + who.author + stageTrackerToolingSuffix(who.kind); return text + (stageTrackerSentinelAsSuffix(item) ? ' · ' + STAGE_TRACKER_SENTINEL_CHIP : ''); } diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 2428f0540b..1cf4588fce 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -15065,14 +15065,14 @@

    Where to get help

    return 'at ' + agentNowClockTime(at, nowMs) + ' (' + inWords + ')'; } // The plain-words tooltip: - // Waiting on @Danathar's hive (clanker · online, last seen 2 min ago) — hive is waiting for them - // Waiting on @hanthor's hive (clanker · offline 26h) — hive will adopt at 15:10 (in 38m) + // Waiting on @Danathar's clanker (online, last seen 2 min ago) — hive is waiting for them + // Waiting on @hanthor's clanker (offline 26h) — hive will adopt at 15:10 (in 38m) // Waiting on @zoe (human) — waiting for a human reply function stageTrackerPresenceTip(item, nowMs) { const p = stageTrackerPresenceOf(item); if (!p) return ''; const now = Number(nowMs) || Date.now(); - const hive = "Waiting on @" + p.login + "'s hive (clanker · "; + const hive = "Waiting on @" + p.login + "'s clanker ("; const adopt = stageTrackerPresenceAdoptAt(p, now); let head, next; if (p.state === 'online') { @@ -15278,15 +15278,40 @@

    Where to get help

    const st = Number(item && item.stage) || 0; return !!(item && item.sentinel_alert) && (st === 71 || st === 72) && (item.kind === 'pr' || !!item.via_pr); } + // Pure: whose PR a 071/072 row waits on — the row's own author, or, for + // an issue row drawn through its one covering PR (via_pr), that PR's + // author. The issue's author is whoever filed it (on hive's hive the + // reviewer's bot, hivecommons-hive[bot]); naming them on the chevron + // read "Returned to @hivecommons-hive[bot]'s hive" for a clanker's PR. + function stageTrackerReturnedAuthor(item) { + let src = item || {}; + if (src.via_pr && Array.isArray(src.linked_prs)) { + const here = src.linked_prs.filter(lp => lp && lp.author && (!Number(lp.drawn_under) || Number(lp.drawn_under) === (Number(src.number) || 0))); + if (here.length === 1) src = here[0]; + } + return { author: String(src.author || '').replace(/^@/, ''), kind: String(src.author_kind || '') }; + } + // "'s clanker" for a clanker's PR (the person's relay agent picks it + // up), "'s hive" for another hive's, nothing for a person's own. + function stageTrackerToolingSuffix(kind) { + if (kind === 'clanker') return "'s clanker"; + if (kind === 'hive') return "'s hive"; + return ''; + } // The 071/072 chevron word names the routing: "Needs @author" at 071, - // "Returned to @author's hive" at 072 for a clanker-authored PR (the + // "Returned to @author's clanker" at 072 for a clanker-authored PR (the // contributor's agent picks it up), "Returned to @author" for a human's. + // A row already superseded by a merged PR says that instead — nothing + // is owed by the author; a maintainer closes it (hivecommons/hive#15303 + // sat as "Returned to …" while its issue was closed by #15304). function stageTrackerReturnedWord(item, fallback) { const st = Number(item && item.stage) || 0; - const author = String((item && item.author) || '').replace(/^@/, ''); + const sup = item && item.superseded && typeof item.superseded === 'object' ? Number(item.superseded.closer_pr) || 0 : 0; + const who = stageTrackerReturnedAuthor(item); let text = fallback; - if (author && st === 71) text = 'Needs @' + author; - else if (author && st === 72) text = 'Returned to @' + author + (item.author_kind === 'human' ? '' : "'s hive"); + if (sup) text = 'Superseded by #' + sup + ' · decide'; + else if (who.author && st === 71) text = 'Needs @' + who.author; + else if (who.author && st === 72) text = 'Returned to @' + who.author + stageTrackerToolingSuffix(who.kind); return text + (stageTrackerSentinelAsSuffix(item) ? ' · ' + STAGE_TRACKER_SENTINEL_CHIP : ''); } @@ -18129,13 +18154,13 @@

    All labels

    } // Pure: who carries a direction on these PRs — the hive's own author // agent, or (a clanker-authored PR, hivecommons/hive#15159) the owning - // contributor's hive, which is nudged with the text. + // contributor's clanker, which is nudged with the text. function stageTrackerDirectionCarrier(items) { const list = (items || []).filter(it => it && it.kind === 'pr'); if (!list.length || !list.every(it => it.author_kind === 'clanker')) return 'the author agent'; const authors = Array.from(new Set(list.map(it => String(it.author || '').replace(/^@/, '')).filter(Boolean))); - if (authors.length === 1) return "@" + authors[0] + "'s hive"; - return "the contributor's hive"; + if (authors.length === 1) return "@" + authors[0] + "'s clanker"; + return "the contributor's clanker"; } // Pure: the decision choices for one decision target. On an issue // parked at 045 the verbs are /hive approve and /hive decision. On a PR @@ -19068,6 +19093,24 @@

    All labels

    } return out.sort((a, b) => Number(b.value.split('#')[1]) - Number(a.value.split('#')[1])); } + // Pure: the pre-filled winner for "Close as superseded by": the merged + // PR the supersession sweep already detected on the row (its closer — + // #15303 sat superseded by #15304 with the field empty), else, for a + // nested PR with exactly one open sibling under the same issue (two PRs + // for one issue), that sibling; '' when neither is known. A closer in + // another repo is only named when the sweep spelt it owner/repo. + function stageTrackerSupersederDefault(items) { + const one = Array.isArray(items) && items.length === 1 ? items[0] : null; + if (!one) return ''; + const sup = one.superseded && typeof one.superseded === 'object' ? one.superseded : null; + const closer = sup ? Number(sup.closer_pr) || 0 : 0; + if (closer) { + const cr = String(sup.closer_repo || ''); + return (cr.indexOf('/') >= 0 ? cr : String(one.repo || '')) + '#' + closer; + } + if (Array.isArray(one.siblings) && one.siblings.length === 1) return one.repo + '#' + one.siblings[0]; + return ''; + } // Pure: validates a "superseded by" reference; "" is allowed (no winner named). function stageTrackerSupersederValid(s, items) { s = String(s || '').trim(); @@ -19329,9 +19372,7 @@

    All labels

    } case 'decide:close-superseded': { const options = stageTrackerSupersederOptions(_stageTracker, items); - // A nested PR with exactly one open sibling under the same issue - // (two PRs for one issue): the sibling is the likely winner. - const sibling = items.length === 1 && Array.isArray(items[0].siblings) && items[0].siblings.length === 1 ? items[0].repo + '#' + items[0].siblings[0] : ''; + const sibling = stageTrackerSupersederDefault(items); const by = await hivePrompt({ title: 'Close as superseded by', label: 'Which pull request supersedes ' + refs + '? (#number, owner/repo#number or URL; leave empty if none)', placeholder: options.length ? options[0].value : '#123', defaultValue: sibling, options, validate: s => stageTrackerSupersederValid(s, items) }); if (by == null) return null; const v = await stageTrackerAsk(id, 'prompt', { title: 'Close as superseded', label: 'Comment for ' + refs + ' (optional)', placeholder: 'Why this is closed', confirmLabel: 'Close' });