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-adoption-pair-no-human-decision.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity monitor: an issue whose only PRs are a contributor's original and the hive's adoption copy of it no longer offers "Let hive decide β€” all 2 PRs" or reads "fell back to Covered by pr β€” Covered by PR #N β€” …; PR #M β€” … changes requested". The pair is one logical PR: the caption reads "Covered by #N (adopted from @author's #M) β€” in CI / review", the superseded original's verdict never gates the issue, the feed says "moved to" when an issue stops mirroring its PR, and the copy's body carries the original's annotated `Refs #N` lines so it keeps the issue link. (hivecommons/hive#15549)
1 change: 1 addition & 0 deletions src/docs/dashboard-copy-inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ The new hover, verbatim (title line omitted):
| `stageTrackerLeadActionHtml` (`tracker-actions.js`) | the row header's inline lead button (chip slot) | β€” (the lead sat in the β‹― menu only) | the menu entry's label (1–4), its hint as the hover | `TestStageTrackerLeadActionInline`, `TestStageTrackerMaintainerRowsHaveLeadAction` |
| Toasts (`STAGE_TRACKER_ACTING_CAPTIONS`, acted labels) | toast | 2–4 each | unchanged | β€” |
| `stageTrackerStripItems` holder token + `stageTrackerClaimantIconKind` (`tracker-row.js`) on the PR in progress chevron ([#15541](https://github.com/hivecommons/hive/issues/15541)) | lit chevron word, chevron hover | *PR in progress* (bare; the holder token only reached PRs from review on) | *PR in progress Β· scanner ⬑*, *PR in progress Β· @odttlnt's clanker πŸ€–*, *PR in progress Β· @clubanderson πŸ‘€* β€” the same token and hover line as *Claimed Β·*; the name ellipsizes before the one-line sub-row wraps; a detour word that already names them (*Returned to @bob's clanker*) does not repeat them | `TestStageTrackerClaimantChevronJS`, `TestStageTrackerPRClaimant`, `TestStageTrackerClaimantStage` |
| `stageTrackerLinkedPRProgress` (Go) + `stageTrackerEventText` / `stageTrackerNestedOpenPRs` (`tracker-motion.js`, `tracker-row.js`) on an adoption pair ([#15495](https://github.com/hivecommons/hive/issues/15495)) | issue row caption, feed line, inline lead button | *fell back to Covered by pr β€” Covered by PR #15537 β€” Review swarm requested; … ; PR #15508 β€” Hive adopted this PR … β€” changes requested* (48) and a *Let hive decide β€” all 2 PRs* lead on a row with nothing to decide | *Covered by #15537 (adopted from @mendezr's #15508) β€” in CI / review* (11); the feed says *moved to* when an issue stops mirroring its PR; the pair counts as one open PR so no lead button | `TestStageTrackerLinkedPRProgressCollapsesAdoptionPair`, `TestStageTrackerAdoptionPairIsOneOpenPR`, `TestStageTrackerEventTextUnmirroredCoveredByPR` |
| `stageTrackerSelectionTriage` (`tracker-actions.js`) | selection bar lead button / bulk β‹― menu entry, summary toast | β€” (no bulk Accept triage; one row at a time) | *Accept triage (4 selected)* / *Accept triage (2 of 4)* with the hint *skips the 2 not waiting on triage*; one toast *Accepted 4 issues* | `TestStageTrackerBulkAcceptTriage` |
| Settings β†’ Features β†’ Auto-merge β†’ "Merge only on current base" help (`renderGovFeatures`, `config-features.js`) and the Repos-tab override row / repo-card `current-base` chip ([#15335](https://github.com/hivecommons/hive/issues/15335)) | settingHelpMark popover, checkbox label, chip hover | β€” (new) | 56 (help), 5 (row label), 1 (chip) | `TestCurrentBaseSettingsMarkupNodeGuard` |

Expand Down
12 changes: 12 additions & 0 deletions src/docs/hive-merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,18 @@ writes the same stage on each linked issue (`stage/040-covered-by-pr` until
then), so the issue list and the PR list read the same
([#12436](https://github.com/hivecommons/hive/issues/12436)).

An adoption pair is one logical PR everywhere a person might otherwise be
asked to pick between PRs (hivecommons/hive#15495). When the write-back gate
keeps the contributor's original open after supersession (`needs-opt-in-label`,
a fork the hive cannot edit), it sits at 072 "superseded by #N" and the
issue's caption, open-PR count, parked-PR check and "Let hive decide β€” all N
PRs" fan-out all see only the hive's copy: the original's review verdict never
gates the issue, and the copy's body carries every `Fixes #N` / `Refs #N` line
of the original (an annotated `Refs #N β€” partial` travels as the bare
reference, so the copy keeps the issue link). The original counts again only
when the copy is closed without merging (`adopted_by_state` closed /
closed-twice / copy-failed).

A clanker PR entering `stage/072-returned-to-contributor` also triggers the
contributor nudge: the sweep posts one `<!-- hive:contributor-nudge head=…
-->` comment per head naming the failing checks / review asks (re-nudged
Expand Down
51 changes: 51 additions & 0 deletions src/pkg/dashboard/stage_tracker.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package dashboard

import (
Expand Down Expand Up @@ -3215,8 +3215,30 @@
if it.StageSlug == StageTrackerNewSlug {
it.StageSlug = ""
}
// listed: the PRs under this issue that are still open on GitHub.
listed := make(map[int]bool, len(it.LinkedPRs))
for _, pr := range it.LinkedPRs {
listed[pr.Number] = pr.State != "closed"
}
progress := make([]string, 0, len(it.LinkedPRs))
for _, pr := range it.LinkedPRs {
// An adoption pair {original, hive's copy} is one logical PR: the
// copy speaks for both, and the superseded original's verdicts
// ("changes requested", "fork not editable") never reach the
// issue's caption (hivecommons/hive#15495 read as needing a human).
if stageTrackerLinkedPRSupersededByListed(pr, listed) {
continue
}
if from := stageTrackerLinkedPRAdoptedFrom(pr, listed); from != "" {
text := fmt.Sprintf("#%d (adopted from %s)", pr.Number, from)
if phrase := stageTrackerStagePhrase(stageByNumber(pr.Stage)); phrase != "" {
text += " β€” " + phrase
} else if pr.Caption != "" {
text += " β€” " + pr.Caption
}
progress = append(progress, text)
continue
}
text := fmt.Sprintf("PR #%d", pr.Number)
if pr.Caption != "" {
text += " β€” " + pr.Caption
Expand All @@ -3231,6 +3253,35 @@
it.Actor = "its PR"
}

// stageTrackerLinkedPRSupersededByListed reports whether lp is the
// original of an adoption pair whose hive copy is itself listed open under
// the same issue (or a closed original the copy replaced): the pair is one
// logical PR and the copy carries the issue. An original whose copy was
// closed without merging is not superseded β€” the hive re-adopts or a
// person decides, and the original speaks for itself again.
func stageTrackerLinkedPRSupersededByListed(lp StageTrackerLinkedPR, listed map[int]bool) bool {
if lp.State == "closed" {
return true
}
if lp.AdoptedBy > 0 && listed[lp.AdoptedBy] && lp.AdoptedByState != stageTrackerAdoptedClosed && lp.AdoptedByState != stageTrackerAdoptedClosedTwice && lp.AdoptedByState != stageTrackerAdoptedCopyFailed {
return true
}
return lp.Lineage != nil && lp.Lineage.Kind == lineageSuperseded && lp.Lineage.ToNumber > 0 && listed[lp.Lineage.ToNumber]
}

// stageTrackerLinkedPRAdoptedFrom is "@author's #N" for the hive's copy of
// an adopted PR whose original is listed under the same issue, "" otherwise.
func stageTrackerLinkedPRAdoptedFrom(lp StageTrackerLinkedPR, listed map[int]bool) string {
l := lp.Lineage
if l == nil || l.Kind != lineageAdopted || l.FromNumber <= 0 || !listed[l.FromNumber] {
return ""
}
if l.FromAuthor != "" {
return "@" + l.FromAuthor + "'s #" + strconv.Itoa(l.FromNumber)
}
return "#" + strconv.Itoa(l.FromNumber)
}

// stageTrackerClosedIssueAnchor returns the closed issue a standalone PR
// row re-anchors around, or nil. A PR nested under a listed issue, a PR
// with an open closing link, and a PR whose links are all soft (`Refs #N`)
Expand Down
125 changes: 125 additions & 0 deletions src/pkg/dashboard/stage_tracker_adoption_pair_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package dashboard

import (
"strings"
"testing"
)

// hivecommons/hive#15495 / #15500: an issue whose only two PRs were a
// contributor's original and the hive's adoption copy of it read "Let hive
// decide β€” all 2 PRs" with the caption "fell back to Covered by pr β€”
// Covered by PR #15537 β€” …; PR #15508 β€” … changes requested". The pair is
// one logical PR: the server caption speaks for the copy only and the SPA
// counts one open PR, so nothing on the row asks a person.

func adoptionPairIssue() StageTrackerItem {
return StageTrackerItem{Kind: "issue", Repo: "hivecommons/hive", Number: 15495, Stage: trackerNumberCoveredByPR,
LinkedPRs: []StageTrackerLinkedPR{
{Number: 15508, Author: "mendezr", AuthorKind: "clanker", Stage: trackerNumberReturned, State: "open", AdoptedBy: 15537,
Caption: "Hive adopted this PR; hive is addressing the review findings (superseded by #15537) β€” changes requested",
Lineage: &StageTrackerLineage{Kind: lineageSuperseded, ToNumber: 15537}},
{Number: 15537, Author: "hivecommons-hive[bot]", AuthorKind: "hive", Stage: trackerNumberReviewPending, State: "open",
Caption: "Review swarm requested; waiting for a verdict on the current head β€” review gate: no review bundle",
Lineage: &StageTrackerLineage{Kind: lineageAdopted, FromNumber: 15508, FromAuthor: "mendezr", FromAuthorKind: "clanker"}},
}}
}

func TestStageTrackerLinkedPRProgressCollapsesAdoptionPair(t *testing.T) {
it := adoptionPairIssue()
stageTrackerLinkedPRProgress(&it)
if it.Caption != "Covered by #15537 (adopted from @mendezr's #15508) β€” in CI / review" {
t.Fatalf("caption = %q", it.Caption)
}
if strings.Contains(it.Caption, "changes requested") || strings.Contains(it.Caption, "PR #15508") {
t.Fatalf("the superseded original's verdict reached the issue: %q", it.Caption)
}

// The copy closed without merging: the original speaks for itself again.
it = adoptionPairIssue()
it.LinkedPRs[0].AdoptedByState = stageTrackerAdoptedClosed
it.LinkedPRs[1].State = "closed"
stageTrackerLinkedPRProgress(&it)
if !strings.HasPrefix(it.Caption, "Covered by PR #15508 β€” ") || strings.Contains(it.Caption, "PR #15537") {
t.Fatalf("orphaned original must carry the issue: %q", it.Caption)
}

// A closed original whose copy merged is not listed as progress at all.
it = adoptionPairIssue()
it.LinkedPRs[0].State = "closed"
it.LinkedPRs[0].Lineage = nil
it.LinkedPRs[1].Lineage = nil
stageTrackerLinkedPRProgress(&it)
if it.Caption != "Covered by PR #15537 β€” "+adoptionPairIssue().LinkedPRs[1].Caption {
t.Fatalf("closed original listed: %q", it.Caption)
}

// Two unrelated open PRs still list both β€” the dup-PR path is untouched.
it = adoptionPairIssue()
it.LinkedPRs[0].AdoptedBy, it.LinkedPRs[0].Lineage, it.LinkedPRs[1].Lineage = 0, nil, nil
stageTrackerLinkedPRProgress(&it)
if !strings.Contains(it.Caption, "PR #15508 β€” ") || !strings.Contains(it.Caption, "; PR #15537 β€” ") {
t.Fatalf("independent PRs collapsed: %q", it.Caption)
}
}

func TestStageTrackerAdoptionPairIsOneOpenPR(t *testing.T) {
html := indexHTML(t)
runStageTrackerRowActionsScript(t, stageTrackerRowActionsPreamble(t, html)+`
const ids = as => as.map(a => a.id);
const ctx = { user: true, canHold: true, canHuman: true };
const pair = { repo: 'hivecommons/hive', kind: 'issue', number: 15495, url: 'u', stage: 40, modifiers: [],
linked_prs: [
{ number: 15508, title: 'Link memo', url: 'p1', author: 'mendezr', author_kind: 'clanker', stage: 72, state: 'open', adopted_by: 15537, modifiers: ['needs-decision'] },
{ number: 15537, title: 'Link memo', url: 'p2', author: 'hivecommons-hive[bot]', author_kind: 'hive', stage: 50, state: 'open', modifiers: [], lineage: { kind: 'adopted', from_number: 15508, from_author: 'mendezr' } },
] };
assert.deepStrictEqual(stageTrackerNestedOpenPRs(pair).map(x => x.number), [15537], 'the adopted original is not an open PR of the issue');
assert.deepStrictEqual(stageTrackerParkedNestedPRs(pair), [], "the original's changes-requested does not park the issue");
assert.strictEqual(stageTrackerDecisionTarget(pair), null);
assert.deepStrictEqual(stageTrackerDelegateTargets(pair), [], 'nothing for a person to decide');
let as = stageTrackerRowActions(pair, ctx);
assert.ok(!ids(as).includes('decide:delegate-all') && !ids(as).includes('decide'), ids(as).join(','));
assert.strictEqual(stageTrackerLeadAction(pair, ctx), null, 'no inline "Let hive decide" lead on an adoption pair');
assert.deepStrictEqual(stageTrackerLinkedPRItem(pair, pair.linked_prs[1]).siblings, [], 'the copy has no competing sibling');

// The copy closed without merging: the original is open again and the two
// rows are what they are.
const orphaned = { ...pair, linked_prs: [{ ...pair.linked_prs[0], adopted_by_state: 'closed' }, { ...pair.linked_prs[1], state: 'closed' }] };
assert.deepStrictEqual(stageTrackerNestedOpenPRs(orphaned).map(x => x.number), [15508]);
// A copy listed under a different issue does not collapse this one.
const elsewhere = { ...pair, linked_prs: [pair.linked_prs[0], { number: 999, url: 'x', stage: 50, state: 'open', modifiers: [] }] };
assert.deepStrictEqual(stageTrackerNestedOpenPRs(elsewhere).map(x => x.number), [15508, 999]);
assert.strictEqual(stageTrackerRowActions(elsewhere, ctx)[0].id, 'decide:delegate-all', 'two genuinely competing PRs still offer the fan-out');
`)
}

func TestStageTrackerEventTextUnmirroredCoveredByPR(t *testing.T) {
html := indexHTML(t)
runStageTrackerRowActionsScript(t, strings.Join([]string{
"const assert = require('assert');",
jsConstLine(t, html, "STAGE_TRACKER_TERMINAL"),
jsConstLine(t, html, "STAGE_TRACKER_EVENT_COVERED_BY_PR"),
jsConstBlock(t, html, "STAGE_TRACKER_EVENT_MOD_WORDS"),
jsFunc(t, html, "stageTrackerItemKey"),
jsFunc(t, html, "stageTrackerStageName"),
jsFunc(t, html, "stageTrackerStateMap"),
jsFunc(t, html, "stageTrackerStageFell"),
jsFunc(t, html, "stageTrackerEventText"),
`
const stages = [{ number: 40, label: 'stage/040-covered-by-pr', short: 'Covered by PR' }, { number: 50, label: 'stage/050-review-pending', short: 'CI / Review' }];
const caption = "Covered by #15537 (adopted from @mendezr's #15508) β€” in CI / review";
const before = stageTrackerStateMap([{ repo: 'o/r', kind: 'issue', number: 15495, stage: 50, stage_label: 'stage/050-review-pending', mirrored: true, caption: 'Review swarm requested' }]);
const after = stageTrackerStateMap([{ repo: 'o/r', kind: 'issue', number: 15495, stage: 40, stage_label: 'stage/040-covered-by-pr', caption }]);
const key = 'o/r/issue#15495';
assert.strictEqual(before[key].kind, 'issue'); assert.strictEqual(before[key].mirrored, true); assert.strictEqual(after[key].mirrored, false);
// The claim moved from the original to the copy: not a fall, and the stage
// table's own word, never the slug humanised ("Covered by pr").
assert.strictEqual(stageTrackerEventText(before[key], after[key], stages), 'moved to Covered by PR β€” ' + caption);
// A PR genuinely dropping 50 β†’ 40 (no falls_to table) still reads as a fall.
const prBefore = { stage: 50, label: 'stage/050-review-pending', caption: '', kind: 'pr', mirrored: false, mods: [] };
const prAfter = { stage: 40, label: 'stage/040-covered-by-pr', caption: 'PR closed', kind: 'pr', mirrored: false, mods: [] };
assert.strictEqual(stageTrackerEventText(prBefore, prAfter, stages), 'fell back to Covered by PR β€” PR closed');
// Without a stages table the label still humanises.
assert.strictEqual(stageTrackerEventText(prBefore, prAfter, []), 'fell back to Covered by pr β€” PR closed');
`,
}, "\n"))
}
1 change: 1 addition & 0 deletions src/pkg/dashboard/stage_tracker_cues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func stageTrackerCuesJS(t *testing.T, html string) string {
jsFunc(t, html, "stageTrackerCueClasses"),
jsFunc(t, html, "stageTrackerStateMap"),
jsFunc(t, html, "stageTrackerStageFell"),
jsConstLine(t, html, "STAGE_TRACKER_EVENT_COVERED_BY_PR"),
jsFunc(t, html, "stageTrackerEventText"),
jsFunc(t, html, "stageTrackerEventsNext"),
jsFunc(t, html, "stageTrackerNoteOwnerEvent"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func TestStageTrackerMergeFailedColumnNode(t *testing.T) {
jsFunc(t, html, "stageTrackerMergeGateWordHtml")+"\n"+
jsFunc(t, html, "stageTrackerStageName")+"\n"+
jsFunc(t, html, "stageTrackerStageFell")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_EVENT_COVERED_BY_PR")+"\n"+
jsFunc(t, html, "stageTrackerEventText")+"\n"+`
const assert = require('assert');
const now = Date.parse('2026-10-29T15:04:00Z');
Expand Down
1 change: 1 addition & 0 deletions src/pkg/dashboard/stage_tracker_rework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func TestStageTrackerReworkJS(t *testing.T) {
jsConstBlock(t, html, "STAGE_TRACKER_EVENT_MOD_WORDS"),
jsFunc(t, html, "stageTrackerStateMap"),
jsFunc(t, html, "stageTrackerStageFell"),
jsConstLine(t, html, "STAGE_TRACKER_EVENT_COVERED_BY_PR"),
jsFunc(t, html, "stageTrackerEventText"),
jsConstLine(t, html, "STAGE_TRACKER_REWORK_EVENT_WORDS"),
jsFunc(t, html, "stageTrackerReworkEventText"),
Expand Down
6 changes: 4 additions & 2 deletions src/pkg/dashboard/static-src/js/tracker-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,12 @@
function stageTrackerPRParked(it) {
return !!it && (!!it.superseded || (Array.isArray(it.modifiers) ? it.modifiers : []).indexOf('needs-decision') >= 0 || STAGE_TRACKER_DECISION_STAGES.indexOf(Number(it.stage) || 0) >= 0 || !!it.manual_merge || !!it.human_merge_reason);
}
// Pure: the parked nested PRs of an issue row, as row items.
// Pure: the parked nested PRs of an issue row, as row items. An adopted
// original whose hive copy is listed under the issue is not parked β€”
// its "changes requested" belongs to the pair the copy now carries.
function stageTrackerParkedNestedPRs(item) {
if (!item || item.kind === 'pr') return [];
return (Array.isArray(item.linked_prs) ? item.linked_prs : []).filter(lp => lp && stageTrackerPRParked(lp)).map(lp => stageTrackerLinkedPRItem(item, lp));
return (Array.isArray(item.linked_prs) ? item.linked_prs : []).filter(lp => lp && stageTrackerPRParked(lp) && (!!lp.superseded || stageTrackerLinkedPROpen(lp, item))).map(lp => stageTrackerLinkedPRItem(item, lp));
}
function stageTrackerDecisionTarget(item) {
if (!item) return null;
Expand Down
Loading
Loading