diff --git a/changelog.d/fixed-adoption-pair-no-human-decision.md b/changelog.d/fixed-adoption-pair-no-human-decision.md new file mode 100644 index 0000000000..5773ad49ed --- /dev/null +++ b/changelog.d/fixed-adoption-pair-no-human-decision.md @@ -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) diff --git a/src/docs/dashboard-copy-inventory.md b/src/docs/dashboard-copy-inventory.md index 8d036c1673..dba66eeb04 100644 --- a/src/docs/dashboard-copy-inventory.md +++ b/src/docs/dashboard-copy-inventory.md @@ -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` | diff --git a/src/docs/hive-merge.md b/src/docs/hive-merge.md index faafdf1492..54ca0ead4c 100644 --- a/src/docs/hive-merge.md +++ b/src/docs/hive-merge.md @@ -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 `` comment per head naming the failing checks / review asks (re-nudged diff --git a/src/pkg/dashboard/stage_tracker.go b/src/pkg/dashboard/stage_tracker.go index bb91d7f91d..85d897fafc 100644 --- a/src/pkg/dashboard/stage_tracker.go +++ b/src/pkg/dashboard/stage_tracker.go @@ -3215,8 +3215,30 @@ func stageTrackerLinkedPRProgress(it *StageTrackerItem) { 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 @@ -3231,6 +3253,35 @@ func stageTrackerLinkedPRProgress(it *StageTrackerItem) { 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`) diff --git a/src/pkg/dashboard/stage_tracker_adoption_pair_test.go b/src/pkg/dashboard/stage_tracker_adoption_pair_test.go new file mode 100644 index 0000000000..0ddcfe48ee --- /dev/null +++ b/src/pkg/dashboard/stage_tracker_adoption_pair_test.go @@ -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")) +} diff --git a/src/pkg/dashboard/stage_tracker_cues_test.go b/src/pkg/dashboard/stage_tracker_cues_test.go index b89c54cfcf..ce4f30d495 100644 --- a/src/pkg/dashboard/stage_tracker_cues_test.go +++ b/src/pkg/dashboard/stage_tracker_cues_test.go @@ -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"), diff --git a/src/pkg/dashboard/stage_tracker_merge_failed_column_test.go b/src/pkg/dashboard/stage_tracker_merge_failed_column_test.go index 9f39f7e320..e0b67dff52 100644 --- a/src/pkg/dashboard/stage_tracker_merge_failed_column_test.go +++ b/src/pkg/dashboard/stage_tracker_merge_failed_column_test.go @@ -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'); diff --git a/src/pkg/dashboard/stage_tracker_rework_test.go b/src/pkg/dashboard/stage_tracker_rework_test.go index 9f56e47d83..504664849a 100644 --- a/src/pkg/dashboard/stage_tracker_rework_test.go +++ b/src/pkg/dashboard/stage_tracker_rework_test.go @@ -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"), diff --git a/src/pkg/dashboard/static-src/js/tracker-actions.js b/src/pkg/dashboard/static-src/js/tracker-actions.js index c4e5c2916f..6cc1191b69 100644 --- a/src/pkg/dashboard/static-src/js/tracker-actions.js +++ b/src/pkg/dashboard/static-src/js/tracker-actions.js @@ -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; diff --git a/src/pkg/dashboard/static-src/js/tracker-motion.js b/src/pkg/dashboard/static-src/js/tracker-motion.js index ea5bffb440..9f8c36d8ec 100644 --- a/src/pkg/dashboard/static-src/js/tracker-motion.js +++ b/src/pkg/dashboard/static-src/js/tracker-motion.js @@ -66,10 +66,12 @@ 'needs-rebase': ['needs a rebase', 'rebased'], 'needs-human': ['waiting on a person', 'a person answered'], 'needs-decision': ['waiting on a decision', 'decision made'], 'needs-triage': ['waiting on triage', 'triage accepted'], draft: ['marked draft', 'ready for review'], unauthorized: ['blocked on permission', 'permission granted'], }; + // The issue's own "covered by PR" stage (stagelabels.CoveredByPR). + const STAGE_TRACKER_EVENT_COVERED_BY_PR = 40; // Pure: key → the fields the event line watches. function stageTrackerStateMap(items) { const out = {}; - const put = (key, it) => { out[key] = { stage: Number(it.stage) || 0, label: it.stage_label || '', caption: it.caption || '', mods: (Array.isArray(it.modifiers) ? it.modifiers : []).slice().sort(), rework: it.rework && it.rework.state ? String(it.rework.state) : '', reworkActor: it.rework && it.rework.actor ? String(it.rework.actor) : '' }; }; + const put = (key, it) => { out[key] = { stage: Number(it.stage) || 0, label: it.stage_label || '', caption: it.caption || '', kind: it.kind || '', mirrored: !!it.mirrored, mods: (Array.isArray(it.modifiers) ? it.modifiers : []).slice().sort(), rework: it.rework && it.rework.state ? String(it.rework.state) : '', reworkActor: it.rework && it.rework.actor ? String(it.rework.actor) : '' }; }; for (const it of (Array.isArray(items) ? items : [])) { if (!it || !it.kind || !(Number(it.number) > 0)) continue; put(stageTrackerItemKey(it), it); @@ -96,10 +98,16 @@ if (next.stage !== prev.stage) { if (next.stage >= STAGE_TRACKER_TERMINAL) return 'merged'; const sg = (stages || []).find(x => Number(x.number) === next.stage); - // Plain words, never a stage slug ("fell back to stage/060-reviewed"). - const named = typeof stageTrackerStageName === 'function' ? stageTrackerStageName({ label: next.label, short: '' }) || stageTrackerStageName(sg) : ''; + // Plain words, never a stage slug ("fell back to stage/060-reviewed"); + // the stages table's own word first ("Covered by PR"), the lane's + // label humanised ("Covered by pr") only without a table. + const named = typeof stageTrackerStageName === 'function' ? stageTrackerStageName(sg) || stageTrackerStageName({ label: next.label, short: '' }) : ''; const name = named || next.label || (sg && (sg.label || sg.short)) || ('stage ' + next.stage); - const back = stageTrackerStageFell(prev, next, stages); + // An issue that stops mirroring its PR's stage and sits at its own + // "covered by PR" did not regress — the hive re-pointed the claim + // (an adoption copy took over, hivecommons/hive#15495). + const unmirrored = prev.kind === 'issue' && prev.mirrored && !next.mirrored && next.stage === STAGE_TRACKER_EVENT_COVERED_BY_PR; + const back = !unmirrored && stageTrackerStageFell(prev, next, stages); const why = (back || next.stage < prev.stage) && next.caption ? ' — ' + next.caption : ''; return (back ? 'fell back to ' : 'moved to ') + name + why; } diff --git a/src/pkg/dashboard/static-src/js/tracker-row.js b/src/pkg/dashboard/static-src/js/tracker-row.js index 22a75a9652..d67145a284 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row.js +++ b/src/pkg/dashboard/static-src/js/tracker-row.js @@ -920,7 +920,7 @@ // parent issue's. `parent` names the issue; `siblings` the other open // PRs under it (the superseded-by prompt pre-fills the one sibling). function stageTrackerLinkedPRItem(issue, lp) { - const open = Array.isArray(issue.linked_prs) ? issue.linked_prs.filter(x => x && x.number !== lp.number && stageTrackerLinkedPROpen(x)) : []; + const open = Array.isArray(issue.linked_prs) ? issue.linked_prs.filter(x => x && x.number !== lp.number && stageTrackerLinkedPROpen(x, issue)) : []; return { repo: issue.repo, number: lp.number, kind: 'pr', title: lp.title || '', url: lp.url || '', author: lp.author || '', author_kind: lp.author_kind || '', stage: lp.stage || 0, stage_since: lp.stage_since || '', stage_slug: lp.stage_slug || '', modifiers: lp.modifiers || [], deferred_modifiers: lp.deferred_modifiers || [], caption: lp.caption || '', reason: lp.reason || '', human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', base_ref: lp.base_ref || '', decision_needed: lp.decision_needed || null, @@ -928,14 +928,25 @@ last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, decided: lp.decided || null, adopted_by: Number(lp.adopted_by) || 0, adopted_by_state: lp.adopted_by_state || '', adopted_from: lp.adopted_from || null, lineage: lp.lineage || null, state: lp.state || '', superseded_by: Number(lp.superseded_by) || 0 }; } - // Pure: whether a linked PR is still open (not merged / closed / superseded). - function stageTrackerLinkedPROpen(lp) { - return !!lp && !lp.superseded && String(lp.state || '') !== 'closed' && (Number(lp.stage) || 0) < STAGE_TRACKER_TERMINAL && (Array.isArray(lp.modifiers) ? lp.modifiers : []).indexOf('merged') < 0; + // Pure: whether a linked PR is still open (not merged / closed / + // superseded). With `issue`, an adopted original whose hive copy is + // listed under the same issue counts as superseded even while GitHub + // still has it open (the write-back gate kept it at 072): the pair + // {original, copy} is one logical PR, so #15495 never reads as "2 + // PRs" needing a human to pick (hivecommons/hive#15495). + function stageTrackerLinkedPROpen(lp, issue) { + if (!lp || lp.superseded || String(lp.state || '') === 'closed' || (Number(lp.stage) || 0) >= STAGE_TRACKER_TERMINAL || (Array.isArray(lp.modifiers) ? lp.modifiers : []).indexOf('merged') >= 0) return false; + const by = Number(lp.superseded_by || lp.adopted_by) || 0; + if (by > 0 && issue && lp.adopted_by_state !== 'closed' && lp.adopted_by_state !== 'closed-twice' && lp.adopted_by_state !== 'copy-failed') { + const linked = Array.isArray(issue.linked_prs) ? issue.linked_prs : []; + if (linked.some(x => x && Number(x.number) === by && String(x.state || '') !== 'closed')) return false; + } + return true; } // Pure: an issue's open nested PRs as row items. function stageTrackerNestedOpenPRs(issue) { if (!issue || issue.kind === 'pr') return []; - return (Array.isArray(issue.linked_prs) ? issue.linked_prs : []).filter(stageTrackerLinkedPROpen).map(lp => stageTrackerLinkedPRItem(issue, lp)); + return (Array.isArray(issue.linked_prs) ? issue.linked_prs : []).filter(lp => stageTrackerLinkedPROpen(lp, issue)).map(lp => stageTrackerLinkedPRItem(issue, lp)); } // Lineage: where an adopted PR came from (`lineage`: {kind, from_number, // from_url, from_author, from_author_kind, to_number, to_url, at, diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 8868da5eaa..81933af9d4 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -16594,7 +16594,7 @@

Where to get help

// parent issue's. `parent` names the issue; `siblings` the other open // PRs under it (the superseded-by prompt pre-fills the one sibling). function stageTrackerLinkedPRItem(issue, lp) { - const open = Array.isArray(issue.linked_prs) ? issue.linked_prs.filter(x => x && x.number !== lp.number && stageTrackerLinkedPROpen(x)) : []; + const open = Array.isArray(issue.linked_prs) ? issue.linked_prs.filter(x => x && x.number !== lp.number && stageTrackerLinkedPROpen(x, issue)) : []; return { repo: issue.repo, number: lp.number, kind: 'pr', title: lp.title || '', url: lp.url || '', author: lp.author || '', author_kind: lp.author_kind || '', stage: lp.stage || 0, stage_since: lp.stage_since || '', stage_slug: lp.stage_slug || '', modifiers: lp.modifiers || [], deferred_modifiers: lp.deferred_modifiers || [], caption: lp.caption || '', reason: lp.reason || '', human_approver: lp.human_approver || '', manual_merge: !!lp.manual_merge, human_merge_reason: lp.human_merge_reason || '', human_merge_reason_text: lp.human_merge_reason_text || '', sentinel_alert: !!lp.sentinel_alert, sentinel_reason: lp.sentinel_reason || '', head: lp.head || '', base_ref: lp.base_ref || '', decision_needed: lp.decision_needed || null, @@ -16602,14 +16602,25 @@

Where to get help

last_operator_action: lp.last_operator_action || null, operator_action_count: lp.operator_action_count || 0, hold: lp.hold || null, stage_actor: lp.stage_actor || null, claimant: lp.claimant || null, presence: lp.presence || null, rework: lp.rework || null, merge_gate: lp.merge_gate || null, merge_train: lp.merge_train || null, decided: lp.decided || null, adopted_by: Number(lp.adopted_by) || 0, adopted_by_state: lp.adopted_by_state || '', adopted_from: lp.adopted_from || null, lineage: lp.lineage || null, state: lp.state || '', superseded_by: Number(lp.superseded_by) || 0 }; } - // Pure: whether a linked PR is still open (not merged / closed / superseded). - function stageTrackerLinkedPROpen(lp) { - return !!lp && !lp.superseded && String(lp.state || '') !== 'closed' && (Number(lp.stage) || 0) < STAGE_TRACKER_TERMINAL && (Array.isArray(lp.modifiers) ? lp.modifiers : []).indexOf('merged') < 0; + // Pure: whether a linked PR is still open (not merged / closed / + // superseded). With `issue`, an adopted original whose hive copy is + // listed under the same issue counts as superseded even while GitHub + // still has it open (the write-back gate kept it at 072): the pair + // {original, copy} is one logical PR, so #15495 never reads as "2 + // PRs" needing a human to pick (hivecommons/hive#15495). + function stageTrackerLinkedPROpen(lp, issue) { + if (!lp || lp.superseded || String(lp.state || '') === 'closed' || (Number(lp.stage) || 0) >= STAGE_TRACKER_TERMINAL || (Array.isArray(lp.modifiers) ? lp.modifiers : []).indexOf('merged') >= 0) return false; + const by = Number(lp.superseded_by || lp.adopted_by) || 0; + if (by > 0 && issue && lp.adopted_by_state !== 'closed' && lp.adopted_by_state !== 'closed-twice' && lp.adopted_by_state !== 'copy-failed') { + const linked = Array.isArray(issue.linked_prs) ? issue.linked_prs : []; + if (linked.some(x => x && Number(x.number) === by && String(x.state || '') !== 'closed')) return false; + } + return true; } // Pure: an issue's open nested PRs as row items. function stageTrackerNestedOpenPRs(issue) { if (!issue || issue.kind === 'pr') return []; - return (Array.isArray(issue.linked_prs) ? issue.linked_prs : []).filter(stageTrackerLinkedPROpen).map(lp => stageTrackerLinkedPRItem(issue, lp)); + return (Array.isArray(issue.linked_prs) ? issue.linked_prs : []).filter(lp => stageTrackerLinkedPROpen(lp, issue)).map(lp => stageTrackerLinkedPRItem(issue, lp)); } // Lineage: where an adopted PR came from (`lineage`: {kind, from_number, // from_url, from_author, from_author_kind, to_number, to_url, at, @@ -17072,10 +17083,12 @@

Where to get help

'needs-rebase': ['needs a rebase', 'rebased'], 'needs-human': ['waiting on a person', 'a person answered'], 'needs-decision': ['waiting on a decision', 'decision made'], 'needs-triage': ['waiting on triage', 'triage accepted'], draft: ['marked draft', 'ready for review'], unauthorized: ['blocked on permission', 'permission granted'], }; + // The issue's own "covered by PR" stage (stagelabels.CoveredByPR). + const STAGE_TRACKER_EVENT_COVERED_BY_PR = 40; // Pure: key → the fields the event line watches. function stageTrackerStateMap(items) { const out = {}; - const put = (key, it) => { out[key] = { stage: Number(it.stage) || 0, label: it.stage_label || '', caption: it.caption || '', mods: (Array.isArray(it.modifiers) ? it.modifiers : []).slice().sort(), rework: it.rework && it.rework.state ? String(it.rework.state) : '', reworkActor: it.rework && it.rework.actor ? String(it.rework.actor) : '' }; }; + const put = (key, it) => { out[key] = { stage: Number(it.stage) || 0, label: it.stage_label || '', caption: it.caption || '', kind: it.kind || '', mirrored: !!it.mirrored, mods: (Array.isArray(it.modifiers) ? it.modifiers : []).slice().sort(), rework: it.rework && it.rework.state ? String(it.rework.state) : '', reworkActor: it.rework && it.rework.actor ? String(it.rework.actor) : '' }; }; for (const it of (Array.isArray(items) ? items : [])) { if (!it || !it.kind || !(Number(it.number) > 0)) continue; put(stageTrackerItemKey(it), it); @@ -17102,10 +17115,16 @@

Where to get help

if (next.stage !== prev.stage) { if (next.stage >= STAGE_TRACKER_TERMINAL) return 'merged'; const sg = (stages || []).find(x => Number(x.number) === next.stage); - // Plain words, never a stage slug ("fell back to stage/060-reviewed"). - const named = typeof stageTrackerStageName === 'function' ? stageTrackerStageName({ label: next.label, short: '' }) || stageTrackerStageName(sg) : ''; + // Plain words, never a stage slug ("fell back to stage/060-reviewed"); + // the stages table's own word first ("Covered by PR"), the lane's + // label humanised ("Covered by pr") only without a table. + const named = typeof stageTrackerStageName === 'function' ? stageTrackerStageName(sg) || stageTrackerStageName({ label: next.label, short: '' }) : ''; const name = named || next.label || (sg && (sg.label || sg.short)) || ('stage ' + next.stage); - const back = stageTrackerStageFell(prev, next, stages); + // An issue that stops mirroring its PR's stage and sits at its own + // "covered by PR" did not regress — the hive re-pointed the claim + // (an adoption copy took over, hivecommons/hive#15495). + const unmirrored = prev.kind === 'issue' && prev.mirrored && !next.mirrored && next.stage === STAGE_TRACKER_EVENT_COVERED_BY_PR; + const back = !unmirrored && stageTrackerStageFell(prev, next, stages); const why = (back || next.stage < prev.stage) && next.caption ? ' — ' + next.caption : ''; return (back ? 'fell back to ' : 'moved to ') + name + why; } @@ -18667,10 +18686,12 @@

All labels

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; diff --git a/src/pkg/github/automerge/automerge_contributor_adopt.go b/src/pkg/github/automerge/automerge_contributor_adopt.go index 41ecd9e5e9..18a22cb0a5 100644 --- a/src/pkg/github/automerge/automerge_contributor_adopt.go +++ b/src/pkg/github/automerge/automerge_contributor_adopt.go @@ -63,6 +63,12 @@ var adoptClosesPattern = regexp.MustCompile(`(?im)^\s*(?:fixes|closes|resolves|r var adoptHiveRunPattern = regexp.MustCompile(`(?im)^\s*Hive-Run\s*:\s*(?:[\w.-]+/[\w.-]+)?#(\d+)\s*$`) +// adoptRefsNotePattern matches a soft `Refs #N — partial` line: the +// reference carries into the copy as a bare `Refs #N` so the issue keeps +// its "covered by" link (hivecommons/hive#15499 read "no linked issue" +// because its original #15400 only had an annotated Refs line). +var adoptRefsNotePattern = regexp.MustCompile(`(?im)^\s*refs\s+((?:[\w.-]+/[\w.-]+)?#\d+)\s*[—–-]\s*\S.*$`) + // adoptionGrace returns the grace that applies to the record's first nudge. func adoptionGrace(rec stagelabels.Record, policy StageLabelPolicy) time.Duration { if rec.NudgeOnline { @@ -332,6 +338,11 @@ func adoptionCloses(body string) []string { for _, m := range adoptClosesPattern.FindAllString(body, -1) { add(m) } + for _, m := range adoptRefsNotePattern.FindAllStringSubmatch(body, -1) { + if len(m) == 2 { + add("Refs " + m[1]) + } + } for _, m := range adoptHiveRunPattern.FindAllStringSubmatch(body, -1) { if len(m) == 2 { add("Fixes #" + m[1]) diff --git a/src/pkg/github/automerge/automerge_contributor_adopt_test.go b/src/pkg/github/automerge/automerge_contributor_adopt_test.go index fd9c72d1f7..5cf058f47d 100644 --- a/src/pkg/github/automerge/automerge_contributor_adopt_test.go +++ b/src/pkg/github/automerge/automerge_contributor_adopt_test.go @@ -2377,10 +2377,12 @@ func TestAdoptionSupersederMergedCloseRefusedMarksSupersededOpen(t *testing.T) { } } -// hivecommons/hive#14471: a `Refs #N` line travels into the superseder body. +// hivecommons/hive#14471: a `Refs #N` line travels into the superseder body; +// hivecommons/hive#15499: an annotated `Refs #N — partial` travels as the +// bare reference, so the copy keeps the issue link its original had. func TestAdoptionClosesCarriesRefs(t *testing.T) { - got := adoptionCloses("Refs #14389 — addresses root cause 2\nRefs #5\nCloses #12\n") - if len(got) != 2 || got[0] != "Refs #5" || got[1] != "Closes #12" { + got := adoptionCloses("Refs #14389 — addresses root cause 2\nRefs #5\nCloses #12\nRefs #15395 - partial\nRefs #5 — again\n") + if len(got) != 4 || got[0] != "Refs #5" || got[1] != "Closes #12" || got[2] != "Refs #14389" || got[3] != "Refs #15395" { t.Fatalf("adoptionCloses: %v", got) } }