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-rereview-pill-attribution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity Monitor: a pushed head with nothing against it now waits on `🐝 hive reviewer · re-review of <sha>` instead of the PR author (`rework.owed_by`), the Review chevron is the lit one once CI is green, and the GraphQL PR batch no longer caches a truncated `statusCheckRollup` page as the head's full check list — which had read `CI 7/11 · required check "test" hasn't reported` on an all-green head with 70+ contexts (#16635).
32 changes: 28 additions & 4 deletions src/pkg/dashboard/stage_tracker_activity.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function constLine(source, name) {
return match[0];
}
const trackConsts = ['STAGE_TRACKER_WORKFLOW_APPROVAL_BLOCKER', 'STAGE_TRACKER_WORKFLOW_APPROVAL_TIP', 'STAGE_TRACKER_RING_SEGMENT_GAP_MAX', 'STAGE_TRACKER_RING_RADIUS', 'STAGE_TRACKER_RING_GAP_DEG'].map(name => constLine(strip, name)).join('\n');
const trackFns = ['stageTrackerTrackLead', 'stageTrackerWaitingOnPerson', 'stageTrackerTrackRunning', 'stageTrackerWorkflowApprovalPending', 'stageTrackerRingSvg', 'stageTrackerStalledTrack', 'stageTrackerQueueAheadWord', 'stageTrackerStageTrack', 'stageTrackerHiveOwnsRepair', 'stageTrackerTrackWord', 'stageTrackerActivityTrackHtml'].map(name => fn(strip, name)).join('\n');
const trackFns = ['stageTrackerHiveOwesReReview', 'stageTrackerTrackLead', 'stageTrackerWaitingOnPerson', 'stageTrackerTrackRunning', 'stageTrackerWorkflowApprovalPending', 'stageTrackerRingSvg', 'stageTrackerStalledTrack', 'stageTrackerQueueAheadWord', 'stageTrackerStageTrack', 'stageTrackerHiveOwnsRepair', 'stageTrackerTrackWord', 'stageTrackerActivityTrackHtml'].map(name => fn(strip, name)).join('\n');
const track = new Function('esc', 'stageTrackerIcon', trackConsts + '\n' + trackFns + ';return stageTrackerActivityTrackHtml;')(esc, (n, cls) => `<svg class="${cls}" data-icon="${n}"></svg>`);
const getAnchor = new Function(globals + anchor + ';return stageTrackerAnchor;')();
const header = new Function('esc', 'stageTrackerIcon', globals + fn(strip, 'stageTrackerHeaderHtml') + ';return stageTrackerHeaderHtml;')(esc, () => '');
Expand Down Expand Up @@ -493,7 +493,7 @@ test('Hive #16434 shape: missing current-head CI and review stay unknown but vis
assert.match(cells.ci, /title="Current pipeline phase · CI: CI \?\/\? · no checks reported yet · /);
assert.doesNotMatch(cells.ci, /no checks reported yet</);
assert.match(cells.review, /ham-activity-track active ham-current/);
assert.match(cells.review, /Review · re-review pending \(new head\)</);
assert.match(cells.review, /Review · re-review of head</);
assert.doesNotMatch(cells.cells[3], /aria-current|data-motion/);
});

Expand Down Expand Up @@ -802,7 +802,7 @@ test('#16484: count grammar — CI passed/total and Review done/total across eve
assert.equal(review('unassigned', { perspectives_done: 0 }), 'Review 0/5 · queued');
assert.equal(review('unassigned', { perspectives_done: 0, queue_ahead: 3 }), 'Review 0/5 · queued, 3 ahead');
assert.equal(review('unknown', { perspectives_done: 0 }), 'Review 0/5 · queued');
assert.equal(review('unknown', { perspectives_done: 0 }, { push: { state: 'pushed', sha: 'h', next: 're-review' } }), 'Review 0/5 · re-review pending (new head)');
assert.equal(review('unknown', { perspectives_done: 0 }, { push: { state: 'pushed', sha: 'h', next: 're-review' } }), 'Review 0/5 · re-review of h');
assert.equal(review('unknown'), 'Review 3/5 · perspectives', 'partial verdicts with no aggregate verdict yet');
assert.equal(word({ head: 'h', review_activity: { head: 'h', state: 'approved' } }, 'review', true), 'Review approved', 'older servers without counts');
assert.equal(word({ head: 'h' }, 'review', false), '');
Expand All @@ -822,7 +822,7 @@ test('#16484: the three screenshot rows — both tracks lit with counts, swarm r
// #16599: the pending re-review is not in motion and not the stage's own
// track (070) → glyph alone, its words in the tooltip.
assert.equal(cls(cells.review), 'todo', 'a pending re-review is an inactive glyph (#16599)'); assert.equal(text(cells.review), '');
assert.match(cells.review, /aria-label="[^"]*Review: Review 0\/5 · re-review pending \(new head\) · /);
assert.match(cells.review, /aria-label="[^"]*Review: Review 0\/5 · re-review of d3c0824 · /);
assert.doesNotMatch(cells.review, /data-motion/);
assert.match(cells.review, /hive is waiting on CI for new head d3c0824/, 'the tooltip still says which track leads');
// #16491: review swarm requested, no bundle yet; CI shows its count.
Expand Down Expand Up @@ -855,3 +855,27 @@ test('#16484: the three screenshot rows — both tracks lit with counts, swarm r
assert.match(cell, /<svg /);
}
});

test('#16615: CI green on the pushed head + re-review owed by the hive → Review lit with the head, CI a green ring', () => {
const head = 'd88928e16f21ab6e653e5d06f137926bc0db1c0d';
const fresh = (state, extra = {}) => ({ head, state, caption: state, source: 'github-check-runs', observed_at: new Date(now).toISOString(), ...extra });
const text = cell => cell.match(/aria-describedby="[^"]+">([^]*?)<span id=/)[1].replace(/<[^>]*>/g, '');
const cls = cell => cell.match(/class="ham-seg ham-activity-track ([a-z -]+?)(?: ham-current)?"/)[1];
const item = livePR({ head, stage: 72, display_column: 50, author: 'thatguywob', author_kind: 'clanker',
push: { state: 'waiting', login: 'thatguywob' },
code_activity: { head, state: 'fix_pushed', caption: 'Fix pushed d88928e · re-review pending', actor: '@thatguywob', source: 'rework-commit' },
rework: { state: 'pushed', actor: 'thatguywob', evidence: 'commit', head, owed_by: 'hive-reviewer' },
ci_activity: fresh('passing', { checks_passed: 11, checks_total: 11, caption: 'CI green' }),
review_activity: fresh('unknown', { perspectives_done: 0, perspectives_total: 5 }) });
const cells = physicalTracks(item);
assert.equal(cls(cells.ci), 'done', 'CI complete: icon only'); assert.equal(text(cells.ci), '');
assert.match(cells.ci, /data-verdict="pass"/, 'green ring');
assert.match(cls(cells.review), /^active/, 'the owed re-review is the lit chevron');
assert.equal(text(cells.review), 'Review 0/5 · re-review of d88928e');
assert.match(cells.review, /hive is waiting on review for new head d88928e/);
assert.equal((cells.ci + cells.review).match(/ham-activity-track active/g).length, 1, 'exactly one active track');
// While CI still runs on the pushed head, CI is the lit one and Review waits as a glyph.
const running = physicalTracks({ ...item, ci_activity: fresh('running', { checks_passed: 7, checks_total: 11, active: true }) });
assert.equal(cls(running.ci), 'active'); assert.equal(text(running.ci), 'CI 7/11 · running');
assert.equal(cls(running.review), 'todo'); assert.equal(text(running.review), '');
});
1 change: 1 addition & 0 deletions src/pkg/dashboard/stage_tracker_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ func (s *Server) buildStageTracker(status *StatusPayload, store *stagelabels.Sto
stageTrackerApplyCodeActivity(&activityItem, dispatchState, status, now)
stageTrackerApplyRemediation(&activityItem, dispatchState, status, stageTrackerFixerAgent(cfg), now)
it.CodeActivity, it.Remediation, it.ReviewActivity, it.DisplayColumn, it.Caption = activityItem.CodeActivity, activityItem.Remediation, activityItem.ReviewActivity, activityItem.DisplayColumn, activityItem.Caption
stageTrackerApplyReworkOwedBy(it)
}
stageTrackerApplyReauthor(resp.Items, store, status.GitHubBaseURL, now)
resp.NeedsHuman, resp.OnHold = stageTrackerHumanCounts(resp.Items)
Expand Down
47 changes: 46 additions & 1 deletion src/pkg/dashboard/stage_tracker_presence.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ const src = [
pick(/function stageTrackerPresenceInPillHtml\(item, text\) \{[\s\S]*?\n \}\n/, 'stageTrackerPresenceInPillHtml'),
pick(/function stageTrackerPresenceChipText\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerPresenceChipText'),
pick(/function stageTrackerPresenceChipHtml\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerPresenceChipHtml'),
pick(/const STAGE_TRACKER_REWORK_WORDS = [^\n]*\n/, 'STAGE_TRACKER_REWORK_WORDS'),
pick(/function stageTrackerReworkOf\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerReworkOf'),
pick(/function stageTrackerReworkWord\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerReworkWord'),
pick(/const STAGE_TRACKER_REWORK_OWED_BY_HIVE = [^\n]*\n/, 'STAGE_TRACKER_REWORK_OWED_BY_HIVE'),
pick(/function stageTrackerReReviewOwedByHive\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerReReviewOwedByHive'),
pick(/function stageTrackerReReviewWord\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerReReviewWord'),
pick(/function stageTrackerHiveReviewerChipText\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerHiveReviewerChipText'),
pick(/function stageTrackerReworkSuffix\(text, item\) \{[\s\S]*?\n \}\n/, 'stageTrackerReworkSuffix'),
pick(/function stageTrackerReworkTip\(item, nowMs\) \{[\s\S]*?\n \}\n/, 'stageTrackerReworkTip'),
].join('\n');

// The clock the tooltips are rendered against, and the stubs the lifted
Expand All @@ -52,7 +61,7 @@ const stubs = `
Date.now = () => ${NOW};
`;
const api = new Function(stubs + src + `; return { of: stageTrackerPresenceOf, tip: stageTrackerPresenceTip, aria: stageTrackerPresenceAria, dot: stageTrackerPresenceDotHtml,
inPill: stageTrackerPresenceInPillHtml, chipText: stageTrackerPresenceChipText, chip: stageTrackerPresenceChipHtml, adoptionChip: stageTrackerAdoptionChipHtml, icons: STAGE_TRACKER_ICONS };`)();
inPill: stageTrackerPresenceInPillHtml, chipText: stageTrackerPresenceChipText, chip: stageTrackerPresenceChipHtml, adoptionChip: stageTrackerAdoptionChipHtml, adoptionChipText: stageTrackerAdoptionChipText, reworkTip: stageTrackerReworkTip, icons: STAGE_TRACKER_ICONS };`)();
// Collapse an inline SVG's body so the surrounding markup can be matched exactly.
const flat = (h) => h.replace(/<svg ([^>]*)>[\s\S]*?<\/svg>/g, '<svg $1></svg>');

Expand Down Expand Up @@ -170,3 +179,39 @@ test('style ratchet: the indicator uses classes and tokens, no inline styles; re
assert.match(html, /\.ham-presence-unknown \.ham-presence-dot \{[^\n]*border: var\(--line-width\) solid var\(--text-faint\)[^\n]*background: transparent/);
assert.match(html, /@media \(prefers-reduced-motion: reduce\) \{ \.ham-presence-online \.ham-presence-dot \{ animation: none; \} \}/);
});

// hivecommons/hive#16615: @thatguywob (a clanker) pushed d88928e after the
// ask; every check on it is green and no findings stand against it. The
// re-review is the HIVE reviewer's to deliver — the pill must not say the
// hive waits on the clanker.
const head16615 = 'd88928e16f21ab6e653e5d06f137926bc0db1c0d';
const pushed16615 = { repo: 'hivecommons/hive', number: 16615, kind: 'pr', stage: 72, head: head16615, author: 'thatguywob', author_kind: 'clanker',
adoption: { author: 'thatguywob', due: false, since: iso(NOW - 4 * MIN), nudges: 1, author_online: false, author_registered: true, policy: 'adopt', text: 'waiting on @thatguywob (offline 4m, 1 nudge)' },
presence: { login: 'thatguywob', state: 'offline', kind: 'clanker', since: iso(NOW - 4 * MIN), last_seen: iso(NOW - 10 * MIN), next: 'adopt', adopt_at: iso(NOW + 11 * MIN) },
rework: { state: 'pushed', actor: 'thatguywob', requested_at: iso(NOW - 4 * MIN), since: iso(NOW - 3 * MIN), evidence: 'commit', head: head16615, owed_by: 'hive-reviewer' },
ci_activity: { head: head16615, state: 'passing', caption: 'CI green' },
review_activity: { head: head16615, state: 'unknown', perspectives_done: 0, perspectives_total: 5 } };

test('#16615: a pushed, green head waits on the hive reviewer, not the clanker that pushed it', () => {
assert.strictEqual(api.adoptionChipText(pushed16615), 'waiting on 🐝 hive reviewer · re-review of d88928e');
assert.strictEqual(api.chipText(pushed16615), 'waiting on 🐝 hive reviewer · re-review of d88928e');
const chip = api.adoptionChip(pushed16615);
assert.match(chip, />waiting on 🐝 hive reviewer · re-review of d88928e</, 'pill text as rendered');
assert.doesNotMatch(chip, /ham-presence-dot|@thatguywob · re-review/, 'no author presence glyph, no author attribution on the pill');
assert.match(api.reworkTip(pushed16615, NOW), /@thatguywob pushed a new head .* · hive reviewer owes the re-review of d88928e$/);
// Older servers without owed_by: the same answer from the activities.
const legacy = { ...pushed16615, rework: { ...pushed16615.rework, owed_by: undefined } };
assert.strictEqual(api.adoptionChipText(legacy), 'waiting on 🐝 hive reviewer · re-review of d88928e');
});

test('#16615: the author keeps the pill only when the pushed head asks them for something', () => {
const owes = (extra) => api.adoptionChipText({ ...pushed16615, rework: { ...pushed16615.rework, owed_by: undefined }, ...extra });
assert.strictEqual(owes({ ci_activity: { head: head16615, state: 'failing' } }), 'waiting on @thatguywob · re-review pending', 'red CI on the pushed head is theirs to fix');
assert.strictEqual(owes({ review_activity: { head: head16615, state: 'changes_requested' } }), 'waiting on @thatguywob · re-review pending', 'findings on the pushed head are theirs');
assert.strictEqual(owes({ reason: 'conflicting' }), 'waiting on @thatguywob · re-review pending', 'a conflict nobody rebases is theirs');
assert.strictEqual(owes({ reason: 'conflicting', rebase: { attempt: 1, max: 2 } }), 'waiting on 🐝 hive reviewer · re-review of d88928e', 'the hive rebasing it is the hive\'s move');
assert.strictEqual(api.adoptionChipText({ ...pushed16615, rework: { ...pushed16615.rework, owed_by: 'author' } }), 'waiting on @thatguywob · re-review pending', 'the server\'s word wins over the activities');
assert.strictEqual(api.adoptionChipText({ ...pushed16615, rework: { ...pushed16615.rework, owed_by: undefined, state: 'acknowledged' } }), 'waiting on @thatguywob · acknowledged', 'before the push the author owes the rework');
const authorChip = api.adoptionChip({ ...pushed16615, rework: { ...pushed16615.rework, owed_by: undefined }, ci_activity: { head: head16615, state: 'failing' } });
assert.match(authorChip, /ham-presence-dot/, 'the author pill keeps its presence glyph');
});
45 changes: 45 additions & 0 deletions src/pkg/dashboard/stage_tracker_rework.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,51 @@ type StageTrackerRework struct {
Ahead int `json:"ahead,omitempty"`
// Head is the new head on a pushed state.
Head string `json:"head,omitempty"`
// OwedBy names who owes the next move on a pushed state
// (hivecommons/hive#16615): "hive-reviewer" when the new head needs the
// hive's re-review and nothing on it is the author's to fix, so the
// waiting-on pill names the hive, not the author; "author" when they
// still owe something on the pushed head — red CI, changes requested on
// it, or a conflict nobody in the hive is rebasing. Empty on the other
// states (and from older servers, which the dashboard reads from the
// activities instead).
OwedBy string `json:"owed_by,omitempty"`
}

// Who owes the next move on a pushed head.
const (
reworkOwedByHiveReviewer = "hive-reviewer"
reworkOwedByAuthor = "author"
)

// stageTrackerApplyReworkOwedBy fills Rework.OwedBy once the row's CI and
// review activity are known (they are derived after the rework field).
func stageTrackerApplyReworkOwedBy(it *StageTrackerItem) {
if it == nil || it.Rework == nil || it.Rework.State != reworkStatePushed {
return
}
it.Rework.OwedBy = stageTrackerReworkOwedBy(*it)
}

// stageTrackerReworkOwedBy answers "who owes the next move on the pushed
// head?" The author owes it only when the head itself asks them for
// something: CI failing on it, review findings against it, or a merge
// conflict the hive is not rebasing. Otherwise the re-review of the new
// head is the hive reviewer's to deliver.
func stageTrackerReworkOwedBy(it StageTrackerItem) string {
onHead := func(a *StageTrackerActivity) bool {
return a != nil && (a.Head == "" || it.Head == "" || strings.EqualFold(a.Head, it.Head))
}
if onHead(it.CIActivity) && it.CIActivity.State == "failing" {
return reworkOwedByAuthor
}
if onHead(it.ReviewActivity) && it.ReviewActivity.State == "changes_requested" {
return reworkOwedByAuthor
}
if strings.Contains(strings.ToLower(it.Reason), "conflict") && it.Rebase == nil {
return reworkOwedByAuthor
}
return reworkOwedByHiveReviewer
}

// StageTrackerFixWork is the hub's fix-queue standing for one PR and one
Expand Down
Loading
Loading