@andrioid/paseo-attention-span 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/OVERVIEW.md +3 -1
- package/client/attention-screen.tsx +61 -1174
- package/client/coverage-settings.tsx +5 -4
- package/client/data.ts +4 -2
- package/client/feedback.tsx +21 -25
- package/client/history.tsx +12 -50
- package/client/item-actions.ts +387 -0
- package/client/item-row.tsx +450 -0
- package/client/new-issue.tsx +244 -0
- package/client/next-up.tsx +22 -183
- package/client/pickers.tsx +238 -0
- package/client/session-menu.ts +3 -11
- package/client/sessions.ts +58 -57
- package/client/setup.tsx +2 -1
- package/client/sheet.tsx +92 -15
- package/client/ui.tsx +23 -14
- package/client/wrap-up.tsx +151 -85
- package/docs/architecture.md +24 -13
- package/docs/screenshots/desktop-dark-doing-acknowledge.png +0 -0
- package/docs/screenshots/desktop-dark-doing-clear.png +0 -0
- package/docs/screenshots/desktop-dark-doing-issue-sheet.png +0 -0
- package/docs/screenshots/desktop-dark-doing-reviewers.png +0 -0
- package/docs/screenshots/desktop-dark-doing-sheet.png +0 -0
- package/docs/screenshots/desktop-dark-doing-wrap-dirty.png +0 -0
- package/docs/screenshots/desktop-dark-doing-wrap-multi.png +0 -0
- package/docs/screenshots/desktop-dark-doing-wrap.png +0 -0
- package/docs/screenshots/desktop-dark-doing.png +0 -0
- package/docs/screenshots/desktop-dark-history-filtered.png +0 -0
- package/docs/screenshots/desktop-dark-history.png +0 -0
- package/docs/screenshots/desktop-dark-next-up.png +0 -0
- package/docs/screenshots/desktop-dark-settings.png +0 -0
- package/docs/screenshots/desktop-dark-setup.png +0 -0
- package/docs/screenshots/desktop-dark-waiting-too-long.png +0 -0
- package/docs/screenshots/desktop-dark-waiting.png +0 -0
- package/docs/screenshots/phone-dark-doing.png +0 -0
- package/docs/screenshots/phone-dark-history.png +0 -0
- package/docs/screenshots/phone-light-next-up-filtered.png +0 -0
- package/index.client.tsx +19 -0
- package/index.server.ts +43 -26
- package/package.json +2 -1
- package/requirements.yaml +10 -3
- package/server/actions.ts +2 -1
- package/server/archive.ts +146 -67
- package/server/archived.ts +12 -16
- package/server/changes.ts +34 -54
- package/server/classify.ts +157 -139
- package/server/context.ts +95 -3
- package/server/feedback.ts +2 -6
- package/server/fetch.ts +262 -0
- package/server/fixture.ts +88 -14
- package/server/github-types.ts +5 -2
- package/server/markdown.ts +3 -1
- package/server/port.ts +46 -0
- package/server/queries.ts +34 -24
- package/server/service.ts +155 -272
- package/server/setup.ts +15 -14
- package/server/store.ts +94 -80
- package/server/update.ts +34 -13
- package/server/view.ts +16 -15
- package/shared/archive.ts +116 -13
- package/shared/attention.ts +63 -18
- package/shared/changes.ts +2 -1
- package/shared/config.ts +2 -6
- package/shared/drafting.ts +17 -0
- package/shared/feedback.ts +6 -5
- package/shared/format.ts +2 -1
- package/shared/history-report.ts +2 -1
- package/shared/item-sessions.ts +76 -0
- package/shared/item-view.ts +224 -0
- package/shared/linked-sessions.ts +59 -8
- package/shared/names.ts +17 -0
- package/shared/new-issue.ts +129 -0
- package/shared/next-up-filter.ts +137 -0
- package/shared/paging.ts +16 -0
- package/shared/prompts.ts +39 -22
- package/shared/rpc.ts +23 -10
- package/shared/setup.ts +3 -1
- package/shared/wrap-up.ts +20 -23
package/server/changes.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { isFinishedChange, isHandover, type OthersChange } from "../shared/changes";
|
|
2
|
-
import type
|
|
2
|
+
import { baseItem, type Item, type SectionId } from "../shared/attention";
|
|
3
3
|
import type { AssignmentEvent, AssignmentSubject, ClosedIssue, EndedPullRequest, LiveResult, ReopenSubject } from "./github-types";
|
|
4
4
|
import { prKey } from "./queries";
|
|
5
|
+
import { keySet, sameName } from "../shared/names";
|
|
5
6
|
|
|
6
7
|
// Changed by others: what someone else did to my work, kept between refreshes so a note stays until Got it or an archive
|
|
7
8
|
// acknowledges it, and so History can list work that left my hands [HIS-06, HIS-07, ATT-22]. Pure, so every rule is
|
|
@@ -38,13 +39,12 @@ export type Lookups = Map<string, AssignmentSubject | null>;
|
|
|
38
39
|
// Reopen lookups: the PR as it is now, null when it's gone or hidden, missing when the lookup failed.
|
|
39
40
|
export type ReopenLookups = Map<string, ReopenSubject | null>;
|
|
40
41
|
|
|
41
|
-
const same = (a: string | null | undefined, b: string | null | undefined) => !!a && !!b && a.toLowerCase() === b.toLowerCase();
|
|
42
42
|
const present = <T>(nodes: (T | null | undefined)[]) => nodes.filter((node): node is T => !!node && Object.keys(node).length > 0);
|
|
43
43
|
const logins = (subject: { assignees: { nodes: { login: string }[] } }) => subject.assignees.nodes.map((node) => node.login);
|
|
44
44
|
// Assigned to someone, and not to me: out of my hands [PRS-08]. A PR of mine with nobody assigned is still mine.
|
|
45
45
|
const handedOver = (subject: { assignees: { nodes: { login: string }[] } }, me: string) => {
|
|
46
46
|
const assignees = logins(subject);
|
|
47
|
-
return assignees.length > 0 && !assignees.some((login) =>
|
|
47
|
+
return assignees.length > 0 && !assignees.some((login) => sameName(login, me));
|
|
48
48
|
};
|
|
49
49
|
const signature = (subject: { assignees: { nodes: { login: string }[] } }) =>
|
|
50
50
|
logins(subject)
|
|
@@ -88,72 +88,64 @@ const isAssignment = (node: AssignmentEvent | Record<string, never>): node is As
|
|
|
88
88
|
// The new owner is the latest of the current assignees to be assigned. It left my hands with whichever came last of my
|
|
89
89
|
// removal and the new owner's assignment, and whoever did that is named: "phil took over" when that's the new owner, else
|
|
90
90
|
// "dave handed it to carol". So a PR I unassigned myself from is still mine until someone else takes it.
|
|
91
|
-
|
|
91
|
+
function handover(subject: AssignmentSubject, me: string): OthersChange | null {
|
|
92
92
|
const assignees = logins(subject);
|
|
93
|
-
if (assignees.some((login) =>
|
|
93
|
+
if (assignees.some((login) => sameName(login, me))) return null;
|
|
94
94
|
if (subject.__typename === "Issue" && subject.state !== "OPEN") return null;
|
|
95
95
|
const events = present(subject.timelineItems.nodes)
|
|
96
96
|
.filter(isAssignment)
|
|
97
97
|
.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
98
|
-
const removal = events.findLast((event) => event.__typename === "UnassignedEvent" &&
|
|
99
|
-
const given = events.findLast((event) => event.__typename === "AssignedEvent" && assignees.some((login) =>
|
|
98
|
+
const removal = events.findLast((event) => event.__typename === "UnassignedEvent" && sameName(event.assignee?.login, me));
|
|
99
|
+
const given = events.findLast((event) => event.__typename === "AssignedEvent" && assignees.some((login) => sameName(login, event.assignee?.login)));
|
|
100
100
|
const to = given?.assignee?.login ?? assignees[0];
|
|
101
101
|
// A PR of mine with nobody on it is mine; an issue needs proof I was taken off it.
|
|
102
102
|
if (subject.__typename === "PullRequest" ? !to : !removal) return null;
|
|
103
103
|
const by = removal && given && to ? (given.createdAt > removal.createdAt ? given : removal) : (removal ?? given);
|
|
104
|
-
if (!by ||
|
|
104
|
+
if (!by || sameName(by.actor?.login, me)) return null;
|
|
105
105
|
const actor = by.actor?.login;
|
|
106
|
-
const kind = !to ? "unassigned" :
|
|
106
|
+
const kind = !to ? "unassigned" : sameName(actor, to) ? "took_over" : "handed";
|
|
107
107
|
return change(subject, subject.__typename === "PullRequest" ? "pr" : "issue", kind, by.createdAt, actor, to);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
// A PR of mine someone else merged or closed unmerged [HIS-07]. Whether it left my hands before it ended is up to nextLedger,
|
|
111
111
|
// which knows when that happened.
|
|
112
|
-
|
|
113
|
-
if (pr.merged) return
|
|
112
|
+
function ended(pr: EndedPullRequest, me: string): OthersChange | null {
|
|
113
|
+
if (pr.merged) return sameName(pr.mergedBy?.login, me) || !pr.mergedAt ? null : change(pr, "pr", "merged", pr.mergedAt, pr.mergedBy?.login);
|
|
114
114
|
const closer = pr.timelineItems.nodes.at(-1)?.actor?.login;
|
|
115
|
-
return
|
|
115
|
+
return sameName(closer, me) ? null : change(pr, "pr", "closed", pr.closedAt, closer);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
// My PRs
|
|
119
|
-
// and no week lists
|
|
118
|
+
// My PRs that ended lately, from the closed search, as finished work whose sessions Wrap up puts away [ATT-22]: those I
|
|
119
|
+
// closed without merging, which no note and no week lists, and merged ones, which stand in for History's entry until its
|
|
120
|
+
// next fetch has them [FRESH-03]. A merge by someone else says who.
|
|
120
121
|
export function ownClosed(data: Pick<LiveResult, "ended">, me: string): Item[] {
|
|
121
122
|
return present(data.ended.nodes)
|
|
122
|
-
.filter((pr) =>
|
|
123
|
-
.map((pr) =>
|
|
124
|
-
key: prKey(pr),
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
url: pr.url,
|
|
132
|
-
chips: [],
|
|
133
|
-
actions: [],
|
|
134
|
-
children: [],
|
|
135
|
-
target: { kind: "pr" as const, repo: pr.repository.nameWithOwner, number: pr.number, title: pr.title, url: pr.url },
|
|
136
|
-
othersActivityAt: pr.closedAt,
|
|
137
|
-
closedAt: pr.closedAt,
|
|
138
|
-
closedUnmerged: true as const,
|
|
139
|
-
}));
|
|
123
|
+
.filter((pr) => pr.merged || sameName(pr.timelineItems.nodes.at(-1)?.actor?.login, me))
|
|
124
|
+
.map((pr) => {
|
|
125
|
+
const item = baseItem({ key: prKey(pr), section: "done", kind: "pr", repo: pr.repository.nameWithOwner, number: pr.number, title: pr.title, url: pr.url }, pr.closedAt);
|
|
126
|
+
// Its branch, so a session left on it finds its row in Wrap up [ATT-22].
|
|
127
|
+
const target = { ...item.target, ...(pr.headRefName ? { headRefName: pr.headRefName } : {}) };
|
|
128
|
+
if (!pr.merged) return { ...item, target, closedAt: pr.closedAt, closedUnmerged: true as const };
|
|
129
|
+
const by = pr.mergedBy?.login;
|
|
130
|
+
return { ...item, target, closedAt: pr.mergedAt ?? pr.closedAt, ...(by && !sameName(by, me) ? { mergedBy: by } : {}) };
|
|
131
|
+
});
|
|
140
132
|
}
|
|
141
133
|
|
|
142
134
|
// An issue assigned to me someone else closed, as completed or not planned [HIS-07]. My own closes are mine.
|
|
143
|
-
|
|
135
|
+
function closedByOther(issue: ClosedIssue, me: string): OthersChange | null {
|
|
144
136
|
const closer = issue.timelineItems.nodes.at(-1)?.actor?.login;
|
|
145
|
-
if (
|
|
137
|
+
if (sameName(closer, me)) return null;
|
|
146
138
|
const reason = issue.stateReason === "NOT_PLANNED" ? "not_planned" : issue.stateReason === "COMPLETED" ? "completed" : undefined;
|
|
147
139
|
return { ...change(issue, "issue", "issue_closed", issue.closedAt, closer), ...(reason ? { reason } : {}) };
|
|
148
140
|
}
|
|
149
141
|
|
|
150
142
|
// A PR Attention Span saw closed, now open again by someone else [HIS-07]. Only PRs already tracked count, so a first run
|
|
151
143
|
// doesn't announce every old reopen, and issues don't come here: they surface in Next up.
|
|
152
|
-
|
|
144
|
+
function reopened(tracked: TrackedPr, subject: ReopenSubject, me: string): OthersChange | null {
|
|
153
145
|
if (subject.state !== "OPEN") return null;
|
|
154
146
|
const event = subject.timelineItems.nodes.at(-1);
|
|
155
147
|
const actor = event?.actor?.login;
|
|
156
|
-
if (!actor ||
|
|
148
|
+
if (!actor || sameName(actor, me)) return null;
|
|
157
149
|
return {
|
|
158
150
|
id: `reopened:${subject.id}:${event?.createdAt ?? tracked.closedAt}`,
|
|
159
151
|
kind: "reopened",
|
|
@@ -289,7 +281,7 @@ export function nextLedger(
|
|
|
289
281
|
// An archive acknowledges exactly the events on its work at that moment, keyed by "owner/name#number" [ATT-22].
|
|
290
282
|
// `upTo` keeps what others did after then unread: a session archived in Paseo acknowledges only what came before it.
|
|
291
283
|
export function acknowledge(ledger: ChangeLedger, keys: string[], upTo?: string): ChangeLedger {
|
|
292
|
-
const wanted =
|
|
284
|
+
const wanted = keySet(keys);
|
|
293
285
|
const before = (at: string) => !upTo || Date.parse(at) <= Date.parse(upTo);
|
|
294
286
|
const ids = ledger.events.filter((event) => wanted.has(event.key.toLowerCase()) && before(event.at)).map((event) => event.id);
|
|
295
287
|
return { ...ledger, gotIt: [...new Set([...ledger.gotIt, ...ids])] };
|
|
@@ -308,36 +300,24 @@ export function withGotIt(next: ChangeLedger, gotIt: string[]): ChangeLedger {
|
|
|
308
300
|
export function changeItems(ledger: ChangeLedger, now: Date, windowDays: number, historySince: string): { notes: Item[]; history: Item[]; finished: Item[] } {
|
|
309
301
|
const since = new Date(now.getTime() - windowDays * 86_400_000).toISOString();
|
|
310
302
|
const gotIt = new Set(ledger.gotIt);
|
|
311
|
-
const base = (change: OthersChange
|
|
312
|
-
kind: change.subject,
|
|
313
|
-
draft: false,
|
|
314
|
-
repo: change.repo,
|
|
315
|
-
number: change.number,
|
|
316
|
-
title: change.title,
|
|
317
|
-
url: change.url,
|
|
318
|
-
chips: [],
|
|
319
|
-
actions: [],
|
|
320
|
-
children: [],
|
|
321
|
-
target: { kind: change.subject, repo: change.repo, number: change.number, title: change.title, url: change.url },
|
|
322
|
-
othersActivityAt: change.at,
|
|
303
|
+
const base = (change: OthersChange, key: string, section: SectionId): Item => ({
|
|
304
|
+
...baseItem({ key, section, kind: change.subject, repo: change.repo, number: change.number, title: change.title, url: change.url }, change.at),
|
|
323
305
|
closedAt: change.at,
|
|
324
306
|
change,
|
|
325
307
|
});
|
|
326
308
|
const notes = ledger.events
|
|
327
309
|
.filter((change) => !gotIt.has(change.id) && change.at >= since)
|
|
328
|
-
.map((change): Item => ({ ...base(change
|
|
310
|
+
.map((change): Item => ({ ...base(change, `change:${change.id}`, "changed"), actions: ["got_it"] }));
|
|
329
311
|
const history = ledger.events
|
|
330
312
|
// A merge or an issue close is the week's Finished, not a change repeated under it [HIS-07].
|
|
331
313
|
.filter((change) => gotIt.has(change.id) && !isFinishedChange(change) && change.at >= historySince)
|
|
332
|
-
.map((change)
|
|
314
|
+
.map((change) => base(change, `handed:${change.id}`, "handed_off"));
|
|
333
315
|
// A merge or close someone else did is finished work at once, not only when History's daily fetch catches up [HIS-07].
|
|
334
316
|
const finished = ledger.events
|
|
335
317
|
.filter((change) => isFinishedChange(change) && change.at >= historySince)
|
|
336
318
|
.map(
|
|
337
319
|
(change): Item => ({
|
|
338
|
-
...base(change),
|
|
339
|
-
key: change.key,
|
|
340
|
-
section: "done",
|
|
320
|
+
...base(change, change.key, "done"),
|
|
341
321
|
// The week's cards say it in the finished wording, not the note's: "merged 2h ago by dave" [HIS-05, HIS-07].
|
|
342
322
|
change: undefined,
|
|
343
323
|
...(change.kind === "merged" && change.actor ? { mergedBy: change.actor } : {}),
|
package/server/classify.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ActionId,
|
|
3
|
+
baseItem,
|
|
3
4
|
type Attention,
|
|
4
5
|
type Chip,
|
|
5
6
|
type Item,
|
|
7
|
+
type LastReview,
|
|
6
8
|
type NextUpIssue,
|
|
7
9
|
type IssueProject,
|
|
8
10
|
type Person,
|
|
@@ -15,7 +17,7 @@ import {
|
|
|
15
17
|
type Target,
|
|
16
18
|
type WaitingOn,
|
|
17
19
|
} from "../shared/attention";
|
|
18
|
-
import { type AttentionConfig, FIELD_ROLES, type MergeMethod, nextUpField
|
|
20
|
+
import { type AttentionConfig, FIELD_ROLES, type MergeMethod, nextUpField } from "../shared/config";
|
|
19
21
|
import { ago, daysSince } from "../shared/format";
|
|
20
22
|
import { workChip, workKind } from "../shared/work";
|
|
21
23
|
import type { Actor, Comment, Details, HistoryResult, IssueNode, LinkedIssue, LiveResult, MentionNode, PickableNode, ProjectItemNode, PullRequestNode, RequestedReviewer } from "./github-types";
|
|
@@ -23,6 +25,7 @@ import { asksQuestion, excerpt, plainText, taggedIn } from "./markdown";
|
|
|
23
25
|
import { prKey } from "./queries";
|
|
24
26
|
import { issueFor } from "./references";
|
|
25
27
|
import { ISSUE_RULES, type IssueState, nudgeable, pick, PR_RULES, type PrState, replyActions, rulesBlock } from "./rules";
|
|
28
|
+
import { sameName } from "../shared/names";
|
|
26
29
|
|
|
27
30
|
// Turns one refresh worth of GitHub data into what needs me. Pure, so every rule is testable.
|
|
28
31
|
|
|
@@ -64,6 +67,121 @@ const author = (actor: Actor | null | undefined, since: string): Person | undefi
|
|
|
64
67
|
// Search returns empty objects for result types a fragment doesn't cover.
|
|
65
68
|
const compact = <T>(nodes: (T | null | undefined)[]) => nodes.filter((node): node is T => !!node && Object.keys(node).length > 0);
|
|
66
69
|
|
|
70
|
+
// Stacks, followed through base/head branch names, among my PRs and those asking for my review, whoever opened them; each
|
|
71
|
+
// from its bottom PR up [ATT-04]. A fork's branch isn't the repo's, so a PR from a fork is never a parent.
|
|
72
|
+
function buildStacks(prs: PullRequestNode[]) {
|
|
73
|
+
const byHead = new Map(prs.filter((pr) => !pr.isCrossRepository).map((pr) => [`${pr.repository.nameWithOwner}\0${pr.headRefName}`, pr]));
|
|
74
|
+
const parentOf = (pr: PullRequestNode) => {
|
|
75
|
+
const parent = byHead.get(`${pr.repository.nameWithOwner}\0${pr.baseRefName}`);
|
|
76
|
+
return parent === pr ? undefined : parent;
|
|
77
|
+
};
|
|
78
|
+
const stacks: PullRequestNode[][] = [];
|
|
79
|
+
const seen = new Set<PullRequestNode>();
|
|
80
|
+
const walk = (pr: PullRequestNode, stack: PullRequestNode[]) => {
|
|
81
|
+
if (seen.has(pr)) return;
|
|
82
|
+
seen.add(pr);
|
|
83
|
+
stack.push(pr);
|
|
84
|
+
for (const child of prs.filter((candidate) => parentOf(candidate) === pr)) walk(child, stack);
|
|
85
|
+
};
|
|
86
|
+
const byNumber = [...prs].sort((a, b) => a.number - b.number);
|
|
87
|
+
for (const pr of byNumber) if (!parentOf(pr)) stacks.push([]), walk(pr, stacks[stacks.length - 1]);
|
|
88
|
+
for (const pr of byNumber) if (!seen.has(pr)) stacks.push([pr]); // cycles, in theory
|
|
89
|
+
return { stacks, parentOf };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// What each PR's checks, reviews and branches say, worked out once per PR.
|
|
93
|
+
function prState(
|
|
94
|
+
pr: PullRequestNode,
|
|
95
|
+
{
|
|
96
|
+
details,
|
|
97
|
+
config,
|
|
98
|
+
now,
|
|
99
|
+
isMe,
|
|
100
|
+
isOther,
|
|
101
|
+
parentOf,
|
|
102
|
+
}: { details: Details; config: AttentionConfig; now: Date; isMe: (actor: Actor | null | undefined) => boolean; isOther: (actor: Actor | null | undefined) => boolean; parentOf: (pr: PullRequestNode) => PullRequestNode | undefined },
|
|
103
|
+
) {
|
|
104
|
+
const commit = pr.commits.nodes[0]?.commit;
|
|
105
|
+
const ci = commit?.statusCheckRollup?.state;
|
|
106
|
+
const anyFailing = ci === "FAILURE" || ci === "ERROR";
|
|
107
|
+
const anyPending = ci === "PENDING" || ci === "EXPECTED";
|
|
108
|
+
// Asked a few PRs at a time where we could; search's answer is BLOCKED for all once there are more than a few [PRS-13].
|
|
109
|
+
const mergeBlocked = (details.mergeState[prKey(pr)] ?? pr.mergeStateStatus) === "BLOCKED";
|
|
110
|
+
// Where the repo requires checks, only those count; one that hasn't reported yet shows as GitHub blocking while CI runs.
|
|
111
|
+
// Where it requires none, every check counts [PRS-14].
|
|
112
|
+
const required = details.checks[prKey(pr)];
|
|
113
|
+
const ciFailing = required?.required ? required.failing > 0 : anyFailing;
|
|
114
|
+
const ciPending = !ciFailing && (required?.required ? required.pending > 0 || (anyPending && mergeBlocked) : anyPending);
|
|
115
|
+
const unresolved = pr.reviewThreads.nodes.filter((thread) => !thread.isResolved);
|
|
116
|
+
const last = (thread: (typeof unresolved)[number]) => thread.comments.nodes.at(-1);
|
|
117
|
+
const onMe = unresolved.filter((thread) => !isMe(last(thread)?.author));
|
|
118
|
+
const lastCommitAt = commit?.committedDate ?? pr.createdAt;
|
|
119
|
+
const changesRequestedAt = latest(...pr.latestReviews.nodes.filter((r) => r.state === "CHANGES_REQUESTED").map((r) => r.submittedAt));
|
|
120
|
+
const behindBy = details.behind[prKey(pr)] ?? 0;
|
|
121
|
+
return {
|
|
122
|
+
ciFailing,
|
|
123
|
+
ciPending,
|
|
124
|
+
optionalFailing: !ciFailing && anyFailing,
|
|
125
|
+
optionalPending: !ciFailing && !ciPending && anyPending,
|
|
126
|
+
conflicts: pr.mergeable === "CONFLICTING",
|
|
127
|
+
mergeBlocked,
|
|
128
|
+
approved: pr.reviewDecision === "APPROVED",
|
|
129
|
+
// Only what GitHub records as owed: a pending request, even one whose reviewer I can't see, or a decision. Who has
|
|
130
|
+
// reviewed doesn't count; GitHub drops a reviewer's request once they review, so a comment leaves the next move to
|
|
131
|
+
// me. The repo decides what counts as a review, not us [PRS-12].
|
|
132
|
+
asked: pr.reviewRequests.nodes.length > 0 || pr.reviewDecision === "APPROVED" || pr.reviewDecision === "CHANGES_REQUESTED",
|
|
133
|
+
autoMerge: !!pr.autoMergeRequest,
|
|
134
|
+
threadsOnMe: onMe.length,
|
|
135
|
+
botThreadsOnly: onMe.length > 0 && onMe.every((thread) => (thread.opener?.nodes[0] ?? last(thread))?.author?.__typename === "Bot"),
|
|
136
|
+
// Requested changes stay mine until I push after them.
|
|
137
|
+
changes: onMe.length > 0 || (pr.reviewDecision === "CHANGES_REQUESTED" && !(lastCommitAt > changesRequestedAt)),
|
|
138
|
+
repliedAt: latest(...unresolved.filter((thread) => isMe(last(thread)?.author)).map((thread) => last(thread)?.createdAt)),
|
|
139
|
+
lastCommitAt,
|
|
140
|
+
behindBy,
|
|
141
|
+
// A stacked PR no longer builds on its parent's latest version [UPS-02].
|
|
142
|
+
outOfSync: !!parentOf(pr) && behindBy > 0,
|
|
143
|
+
stale: daysSince(pr.updatedAt, now) >= config.staleDraftDays,
|
|
144
|
+
othersActivityAt: latest(
|
|
145
|
+
...pr.comments.nodes.filter((c) => isOther(c.author)).map((c) => c.createdAt),
|
|
146
|
+
...pr.reviewThreads.nodes.flatMap((t) => t.comments.nodes).filter((c) => isOther(c.author)).map((c) => c.createdAt),
|
|
147
|
+
...pr.latestReviews.nodes.filter((r) => isOther(r.author)).map((r) => r.submittedAt),
|
|
148
|
+
),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
type PrFacts = ReturnType<typeof prState>;
|
|
153
|
+
|
|
154
|
+
// A PR's chips in order, as [when, chip]: the item's from my stack's bottom PR, and each sub-row's [ATT-04, UPS-07].
|
|
155
|
+
type ChipFacts = { pr: PullRequestNode; s: PrFacts; base: string; now: Date; section?: SectionId; rulesBlocked?: boolean; own?: boolean };
|
|
156
|
+
type ChipRule = [when: (c: ChipFacts) => boolean, chip: Chip | ((c: ChipFacts) => Chip)];
|
|
157
|
+
const CI_FAILING: ChipRule = [({ s }) => s.ciFailing, chip("CI failing", "bad")];
|
|
158
|
+
const CONFLICTS: ChipRule = [({ s }) => s.conflicts, chip("conflicts", "bad")];
|
|
159
|
+
const BEHIND: ChipRule = [({ s }) => s.behindBy > 0, ({ s, base }) => behindChip(s.behindBy, base)];
|
|
160
|
+
const PR_CHIPS: ChipRule[] = [
|
|
161
|
+
[({ pr, s }) => pr.isDraft && s.stale, ({ pr, now }) => chip(`untouched ${ago(pr.updatedAt, now)}`, "warn")],
|
|
162
|
+
[({ pr, s }) => s.approved && !pr.isDraft, chip("approved", "good")],
|
|
163
|
+
[({ rulesBlocked }) => !!rulesBlocked, chip("blocked by repo rules", "warn")],
|
|
164
|
+
[({ s }) => s.autoMerge, chip("auto-merge on", "good")],
|
|
165
|
+
[({ pr }) => pr.reviewDecision === "CHANGES_REQUESTED", chip("changes requested", "warn")],
|
|
166
|
+
[({ s }) => s.threadsOnMe > 0, ({ s }) => chip(`${s.threadsOnMe} unresolved`, "warn")],
|
|
167
|
+
// One CI chip at most: failing, running, optional checks failing, or passed once ready on the current base [PRS-14].
|
|
168
|
+
CI_FAILING,
|
|
169
|
+
[({ s }) => s.ciPending, chip("CI running", "warn")],
|
|
170
|
+
[({ s }) => s.optionalFailing && !s.ciPending, chip("optional checks failing", "warn")],
|
|
171
|
+
[({ s, section }) => section === "ready" && s.behindBy === 0 && !s.ciFailing && !s.ciPending && !s.optionalFailing, ({ s }) => chip(s.optionalPending ? "required checks passed" : "CI passed", "good")],
|
|
172
|
+
CONFLICTS,
|
|
173
|
+
BEHIND,
|
|
174
|
+
];
|
|
175
|
+
const SUB_CHIPS: ChipRule[] = [
|
|
176
|
+
[({ s }) => s.approved, chip("approved", "good")],
|
|
177
|
+
// Only mine are mine to ask someone on [PRS-12].
|
|
178
|
+
[({ pr, s, own }) => !!own && !pr.isDraft && !s.asked, chip("no reviewer", "warn")],
|
|
179
|
+
CI_FAILING,
|
|
180
|
+
CONFLICTS,
|
|
181
|
+
BEHIND,
|
|
182
|
+
];
|
|
183
|
+
const chipsFor = (rules: ChipRule[], facts: ChipFacts) => rules.filter(([when]) => when(facts)).map(([, made]) => (typeof made === "function" ? made(facts) : made));
|
|
184
|
+
|
|
67
185
|
export function classify({ data, details, config, now }: ClassifyInput): Attention {
|
|
68
186
|
const me = data.viewer.login.toLowerCase();
|
|
69
187
|
const isMe = (actor: { login: string } | null | undefined) => actor?.login.toLowerCase() === me;
|
|
@@ -97,74 +215,11 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
97
215
|
const requests = compact(data.reviews.nodes).filter((pr) => !ownKeys.has(prKey(pr)));
|
|
98
216
|
const isOwn = (pr: PullRequestNode) => ownKeys.has(prKey(pr));
|
|
99
217
|
|
|
100
|
-
// Stacks, followed through base/head branch names, among my PRs and those asking for my review, whoever opened them [ATT-04].
|
|
101
|
-
// A fork's branch isn't the repo's, so a PR from a fork is never a parent.
|
|
102
218
|
const prs = [...mine, ...requests];
|
|
103
|
-
const
|
|
104
|
-
const parentOf = (pr: PullRequestNode) => {
|
|
105
|
-
const parent = byHead.get(`${pr.repository.nameWithOwner}\0${pr.baseRefName}`);
|
|
106
|
-
return parent === pr ? undefined : parent;
|
|
107
|
-
};
|
|
108
|
-
const stacks: PullRequestNode[][] = [];
|
|
109
|
-
const seen = new Set<PullRequestNode>();
|
|
110
|
-
const walk = (pr: PullRequestNode, stack: PullRequestNode[]) => {
|
|
111
|
-
if (seen.has(pr)) return;
|
|
112
|
-
seen.add(pr);
|
|
113
|
-
stack.push(pr);
|
|
114
|
-
for (const child of prs.filter((candidate) => parentOf(candidate) === pr)) walk(child, stack);
|
|
115
|
-
};
|
|
116
|
-
const byNumber = [...prs].sort((a, b) => a.number - b.number);
|
|
117
|
-
for (const pr of byNumber) if (!parentOf(pr)) stacks.push([]), walk(pr, stacks[stacks.length - 1]);
|
|
118
|
-
for (const pr of byNumber) if (!seen.has(pr)) stacks.push([pr]); // cycles, in theory
|
|
219
|
+
const { stacks, parentOf } = buildStacks(prs);
|
|
119
220
|
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
const ci = commit?.statusCheckRollup?.state;
|
|
123
|
-
const anyFailing = ci === "FAILURE" || ci === "ERROR";
|
|
124
|
-
const anyPending = ci === "PENDING" || ci === "EXPECTED";
|
|
125
|
-
// Asked a few PRs at a time where we could; search's answer is BLOCKED for all once there are more than a few [PRS-13].
|
|
126
|
-
const mergeBlocked = (details.mergeState[prKey(pr)] ?? pr.mergeStateStatus) === "BLOCKED";
|
|
127
|
-
// Where the repo requires checks, only those count; one that hasn't reported yet shows as GitHub blocking while CI runs.
|
|
128
|
-
// Where it requires none, every check counts [PRS-14].
|
|
129
|
-
const required = details.checks[prKey(pr)];
|
|
130
|
-
const ciFailing = required?.required ? required.failing > 0 : anyFailing;
|
|
131
|
-
const ciPending = !ciFailing && (required?.required ? required.pending > 0 || (anyPending && mergeBlocked) : anyPending);
|
|
132
|
-
const unresolved = pr.reviewThreads.nodes.filter((thread) => !thread.isResolved);
|
|
133
|
-
const last = (thread: (typeof unresolved)[number]) => thread.comments.nodes.at(-1);
|
|
134
|
-
const onMe = unresolved.filter((thread) => !isMe(last(thread)?.author));
|
|
135
|
-
const lastCommitAt = commit?.committedDate ?? pr.createdAt;
|
|
136
|
-
const changesRequestedAt = latest(...pr.latestReviews.nodes.filter((r) => r.state === "CHANGES_REQUESTED").map((r) => r.submittedAt));
|
|
137
|
-
const behindBy = details.behind[prKey(pr)] ?? 0;
|
|
138
|
-
return {
|
|
139
|
-
ciFailing,
|
|
140
|
-
ciPending,
|
|
141
|
-
optionalFailing: !ciFailing && anyFailing,
|
|
142
|
-
optionalPending: !ciFailing && !ciPending && anyPending,
|
|
143
|
-
conflicts: pr.mergeable === "CONFLICTING",
|
|
144
|
-
mergeBlocked,
|
|
145
|
-
approved: pr.reviewDecision === "APPROVED",
|
|
146
|
-
// Only what GitHub records as owed: a pending request, even one whose reviewer I can't see, or a decision. Who has
|
|
147
|
-
// reviewed doesn't count; GitHub drops a reviewer's request once they review, so a comment leaves the next move to
|
|
148
|
-
// me. The repo decides what counts as a review, not us [PRS-12].
|
|
149
|
-
asked: pr.reviewRequests.nodes.length > 0 || pr.reviewDecision === "APPROVED" || pr.reviewDecision === "CHANGES_REQUESTED",
|
|
150
|
-
autoMerge: !!pr.autoMergeRequest,
|
|
151
|
-
threadsOnMe: onMe.length,
|
|
152
|
-
botThreadsOnly: onMe.length > 0 && onMe.every((thread) => (thread.opener?.nodes[0] ?? last(thread))?.author?.__typename === "Bot"),
|
|
153
|
-
// Requested changes stay mine until I push after them.
|
|
154
|
-
changes: onMe.length > 0 || (pr.reviewDecision === "CHANGES_REQUESTED" && !(lastCommitAt > changesRequestedAt)),
|
|
155
|
-
repliedAt: latest(...unresolved.filter((thread) => isMe(last(thread)?.author)).map((thread) => last(thread)?.createdAt)),
|
|
156
|
-
lastCommitAt,
|
|
157
|
-
behindBy,
|
|
158
|
-
// A stacked PR no longer builds on its parent's latest version [UPS-02].
|
|
159
|
-
outOfSync: !!parentOf(pr) && behindBy > 0,
|
|
160
|
-
stale: daysSince(pr.updatedAt, now) >= config.staleDraftDays,
|
|
161
|
-
othersActivityAt: latest(
|
|
162
|
-
...pr.comments.nodes.filter((c) => isOther(c.author)).map((c) => c.createdAt),
|
|
163
|
-
...pr.reviewThreads.nodes.flatMap((t) => t.comments.nodes).filter((c) => isOther(c.author)).map((c) => c.createdAt),
|
|
164
|
-
...pr.latestReviews.nodes.filter((r) => isOther(r.author)).map((r) => r.submittedAt),
|
|
165
|
-
),
|
|
166
|
-
};
|
|
167
|
-
};
|
|
221
|
+
const states = new Map(prs.map((pr) => [pr, prState(pr, { details, config, now, isMe, isOther, parentOf })]));
|
|
222
|
+
const state = (pr: PullRequestNode) => states.get(pr)!;
|
|
168
223
|
|
|
169
224
|
const items: Item[] = [];
|
|
170
225
|
const listed = new Set<string>();
|
|
@@ -226,19 +281,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
226
281
|
? undefined
|
|
227
282
|
: "review";
|
|
228
283
|
|
|
229
|
-
const chips:
|
|
230
|
-
if (bottom.isDraft && s.stale) chips.push(chip(`untouched ${ago(bottom.updatedAt, now)}`, "warn"));
|
|
231
|
-
if (s.approved && !bottom.isDraft) chips.push(chip("approved", "good"));
|
|
232
|
-
if (rulesBlocked) chips.push(chip("blocked by repo rules", "warn"));
|
|
233
|
-
if (s.autoMerge) chips.push(chip("auto-merge on", "good"));
|
|
234
|
-
if (bottom.reviewDecision === "CHANGES_REQUESTED") chips.push(chip("changes requested", "warn"));
|
|
235
|
-
if (s.threadsOnMe > 0) chips.push(chip(`${s.threadsOnMe} unresolved`, "warn"));
|
|
236
|
-
if (s.ciFailing) chips.push(chip("CI failing", "bad"));
|
|
237
|
-
else if (s.ciPending) chips.push(chip("CI running", "warn"));
|
|
238
|
-
else if (s.optionalFailing) chips.push(chip("optional checks failing", "warn"));
|
|
239
|
-
else if (section === "ready" && s.behindBy === 0) chips.push(chip(s.optionalPending ? "required checks passed" : "CI passed", "good"));
|
|
240
|
-
if (s.conflicts) chips.push(chip("conflicts", "bad"));
|
|
241
|
-
if (s.behindBy > 0) chips.push(behindChip(s.behindBy, base));
|
|
284
|
+
const chips = chipsFor(PR_CHIPS, { pr: bottom, s, base, now, section, rulesBlocked });
|
|
242
285
|
|
|
243
286
|
return {
|
|
244
287
|
section,
|
|
@@ -255,14 +298,22 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
255
298
|
};
|
|
256
299
|
};
|
|
257
300
|
|
|
258
|
-
//
|
|
301
|
+
// My last review of a PR asking for it again. GitHub drops my request once I review, so a request alongside a review of
|
|
302
|
+
// mine is a re-request; a push since then without one doesn't list it at all [REV-02].
|
|
303
|
+
const lastReview = (pr: PullRequestNode): LastReview | undefined => {
|
|
304
|
+
const review = pr.latestReviews.nodes.find((r) => isMe(r.author));
|
|
305
|
+
if (!review) return undefined;
|
|
306
|
+
return { at: review.submittedAt ?? EPOCH, ...(review.commit?.oid ? { oid: review.commit.oid } : {}) };
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
// Others' PRs in a stack that ask for my review: one Review for them all [REV-01, ATT-04], marked when it's asked again [REV-02].
|
|
259
310
|
const reviewPart = (stack: PullRequestNode[]): Part => {
|
|
260
311
|
const waiting = stack.map((pr) => mentions.get(prKey(pr))).find(Boolean);
|
|
261
312
|
const lastCommitAt = latest(...stack.map((pr) => state(pr).lastCommitAt));
|
|
262
313
|
return {
|
|
263
314
|
section: waiting ? "reply" : "review",
|
|
264
315
|
actions: waiting ? [...replyActions(waiting), "review"] : ["review"],
|
|
265
|
-
chips: stack.some((pr) => state(pr).ciFailing) ? [chip("CI failing", "bad")] : [],
|
|
316
|
+
chips: [...(stack.some(lastReview) ? [chip("review again")] : []), ...(stack.some((pr) => state(pr).ciFailing) ? [chip("CI failing", "bad")] : [])],
|
|
266
317
|
person: waiting ?? author(stack[0].author, lastCommitAt),
|
|
267
318
|
othersActivityAt: latest(...stack.map((pr) => state(pr).othersActivityAt), lastCommitAt, waiting?.since),
|
|
268
319
|
};
|
|
@@ -292,14 +343,8 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
292
343
|
const subRow = (pr: PullRequestNode, index: number, stack: PullRequestNode[]): SubRow => {
|
|
293
344
|
const s = state(pr);
|
|
294
345
|
const parent = parentOf(pr);
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
if (s.approved) chips.push(chip("approved", "good"));
|
|
298
|
-
// Only mine are mine to ask someone on [PRS-12].
|
|
299
|
-
if (isOwn(pr) && !pr.isDraft && !s.asked) chips.push(chip("no reviewer", "warn"));
|
|
300
|
-
if (s.ciFailing) chips.push(chip("CI failing", "bad"));
|
|
301
|
-
if (s.conflicts) chips.push(chip("conflicts", "bad"));
|
|
302
|
-
if (s.behindBy > 0) chips.push(behindChip(s.behindBy, parent ? `#${parent.number}` : pr.baseRefName));
|
|
346
|
+
const facts = { pr, s, base: parent ? `#${parent.number}` : pr.baseRefName, now, own: isOwn(pr) };
|
|
347
|
+
const chips = [...(stack.length > 1 ? [chip(`${index + 1}/${stack.length}`)] : []), ...chipsFor(SUB_CHIPS, facts)];
|
|
303
348
|
return { key: prKey(pr), number: pr.number, title: pr.title, url: pr.url, draft: pr.isDraft, chips, attention: s.outOfSync || s.conflicts || s.ciFailing };
|
|
304
349
|
};
|
|
305
350
|
|
|
@@ -315,7 +360,10 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
315
360
|
headRefOid: pr.headRefOid,
|
|
316
361
|
defaultBranch: pr.repository.defaultBranchRef?.name,
|
|
317
362
|
mergeMethod: mergeMethodFor(pr, config),
|
|
318
|
-
stack: stack.map((p) =>
|
|
363
|
+
stack: stack.map((p) => {
|
|
364
|
+
const reviewed = isOwn(p) ? undefined : lastReview(p);
|
|
365
|
+
return { number: p.number, head: p.headRefName, base: p.baseRefName, ...(isOwn(p) ? {} : { review: true as const }), ...(reviewed ? { reviewed } : {}) };
|
|
366
|
+
}),
|
|
319
367
|
});
|
|
320
368
|
|
|
321
369
|
// One item per issue: my PRs grouped under the issue they work on [ATT-03]. Otherwise one per unit, led by its bottom PR.
|
|
@@ -368,24 +416,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
368
416
|
const waiting = mentions.get(key);
|
|
369
417
|
if (!waiting || listed.has(key)) continue;
|
|
370
418
|
listed.add(key);
|
|
371
|
-
|
|
372
|
-
const repo = node.repository.nameWithOwner;
|
|
373
|
-
items.push({
|
|
374
|
-
key,
|
|
375
|
-
section: "reply",
|
|
376
|
-
kind,
|
|
377
|
-
draft: false,
|
|
378
|
-
repo,
|
|
379
|
-
number: node.number,
|
|
380
|
-
title: node.title,
|
|
381
|
-
url: node.url,
|
|
382
|
-
chips: [],
|
|
383
|
-
person: waiting,
|
|
384
|
-
actions: replyActions(waiting),
|
|
385
|
-
children: [],
|
|
386
|
-
target: { kind, repo, number: node.number, title: node.title, url: node.url },
|
|
387
|
-
othersActivityAt: waiting.since,
|
|
388
|
-
});
|
|
419
|
+
items.push({ ...plain(node, node.__typename === "PullRequest" ? "pr" : "issue", "reply"), person: waiting, actions: replyActions(waiting), othersActivityAt: waiting.since });
|
|
389
420
|
}
|
|
390
421
|
|
|
391
422
|
// Issues and others' PRs I'm in: answered, or waiting on others, too long after waitingTooLongDays [WAI-01, ATT-11, ATT-16].
|
|
@@ -433,6 +464,11 @@ export function classifyHistory(data: HistoryResult): Item[] {
|
|
|
433
464
|
const work = workKind({ type: node.issueType?.name, labels: node.labels?.nodes.map((label) => label.name), title: node.title });
|
|
434
465
|
return work ? { ...item, work, chips: [workChip(work), ...item.chips] } : item;
|
|
435
466
|
};
|
|
467
|
+
// Who merged a PR, when it wasn't me, alone or under its issue [HIS-05].
|
|
468
|
+
const mergedBy = (pr: { mergedBy?: { login: string } | null }) => {
|
|
469
|
+
const by = pr.mergedBy?.login;
|
|
470
|
+
return by && me && by.toLowerCase() !== me ? { mergedBy: by } : {};
|
|
471
|
+
};
|
|
436
472
|
for (const issue of compact(data.closed.nodes)) {
|
|
437
473
|
const notPlanned = issue.stateReason === "NOT_PLANNED";
|
|
438
474
|
// Who closed it, when it wasn't me [HIS-07].
|
|
@@ -447,22 +483,19 @@ export function classifyHistory(data: HistoryResult): Item[] {
|
|
|
447
483
|
// Each merged PR on its own: its branches are gone, so it can't be put back in its stack [ATT-03].
|
|
448
484
|
const linked = { repo: pr.repository.nameWithOwner, body: pr.body, linked: pr.closingIssuesReferences.nodes.map(prKey) };
|
|
449
485
|
const issue = closed.get(issueFor([linked], (key) => closed.has(key)) ?? "");
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
486
|
+
const head = pr.headRefName ? { headRefName: pr.headRefName } : {};
|
|
487
|
+
if (issue) issue.children.push({ key: prKey(pr), number: pr.number, title: pr.title, url: pr.url, draft: false, chips: [], attention: false, ...mergedBy(pr), ...head, mergedAt: pr.mergedAt });
|
|
488
|
+
else {
|
|
489
|
+
const item = plain(pr, "pr", "done");
|
|
490
|
+
items.push(kinded({ ...item, target: { ...item.target, ...head }, closedAt: pr.mergedAt, ...mergedBy(pr) }, pr));
|
|
491
|
+
}
|
|
455
492
|
}
|
|
456
493
|
for (const pr of compact(data.reviewed.nodes)) {
|
|
457
|
-
|
|
458
|
-
const mergedBy = by && me && by.toLowerCase() !== me ? { mergedBy: by } : {};
|
|
459
|
-
items.push(kinded({ ...plain(pr, "pr", "reviewed"), closedAt: pr.mergedAt, person: author(pr.author, pr.mergedAt), ...mergedBy }, pr));
|
|
494
|
+
items.push(kinded({ ...plain(pr, "pr", "reviewed"), closedAt: pr.mergedAt, person: author(pr.author, pr.mergedAt), ...mergedBy(pr) }, pr));
|
|
460
495
|
}
|
|
461
496
|
return items.sort(order);
|
|
462
497
|
}
|
|
463
498
|
|
|
464
|
-
// Whether my last comment on an issue is the last one from a person, and if not, the answers since that I haven't 👍'd.
|
|
465
|
-
// Bots don't count [MEN-05]. Only the last comments are fetched: once mine is out of them the conversation has moved on.
|
|
466
499
|
// Whether my last comment on a thread is the last one from a person, and if not, the recent comments since that I haven't 👍'd.
|
|
467
500
|
// On a thread I opened, my opening counts as my last word until I comment. Bots don't count [MEN-05]. Only the last comments
|
|
468
501
|
// are fetched: on someone else's thread, once mine is out of them the conversation has moved on.
|
|
@@ -519,7 +552,7 @@ function taggedSince(run: Comment[], me: string, url: string): WaitingOn[] {
|
|
|
519
552
|
const tagged: WaitingOn[] = [];
|
|
520
553
|
for (const comment of run) {
|
|
521
554
|
for (const { login, team } of taggedIn(comment.bodyHTML)) {
|
|
522
|
-
const seen = (other: { login: string }) => other.login
|
|
555
|
+
const seen = (other: { login: string }) => sameName(other.login, login);
|
|
523
556
|
if (login.toLowerCase() === me || tagged.some(seen)) continue;
|
|
524
557
|
tagged.push({ login, team, avatarUrl: team ? undefined : `${origin}/${login}.png?size=64`, since: comment.createdAt });
|
|
525
558
|
}
|
|
@@ -531,7 +564,7 @@ function taggedSince(run: Comment[], me: string, url: string): WaitingOn[] {
|
|
|
531
564
|
function reviewers(actors: (Actor | null | undefined)[], since: string): WaitingOn[] {
|
|
532
565
|
const list: WaitingOn[] = [];
|
|
533
566
|
for (const actor of actors) {
|
|
534
|
-
if (!actor || list.some((other) => other.login
|
|
567
|
+
if (!actor || list.some((other) => sameName(other.login, actor.login))) continue;
|
|
535
568
|
list.push({ login: actor.login, avatarUrl: actor.avatarUrl, team: actor.__typename === "Team", ...(actor.__typename === "Bot" ? { bot: true } : {}), since });
|
|
536
569
|
}
|
|
537
570
|
return list;
|
|
@@ -566,22 +599,7 @@ function recentReviewers(mine: PullRequestNode[], isOther: (actor: Actor | null
|
|
|
566
599
|
|
|
567
600
|
// An item with nothing to act on: waiting, history.
|
|
568
601
|
function plain(node: { repository: { nameWithOwner: string }; number: number; title: string; url: string }, kind: "pr" | "issue", section: SectionId): Item {
|
|
569
|
-
|
|
570
|
-
return {
|
|
571
|
-
key: prKey(node),
|
|
572
|
-
section,
|
|
573
|
-
kind,
|
|
574
|
-
draft: false,
|
|
575
|
-
repo,
|
|
576
|
-
number: node.number,
|
|
577
|
-
title: node.title,
|
|
578
|
-
url: node.url,
|
|
579
|
-
chips: [],
|
|
580
|
-
actions: [],
|
|
581
|
-
children: [],
|
|
582
|
-
target: { kind, repo, number: node.number, title: node.title, url: node.url },
|
|
583
|
-
othersActivityAt: EPOCH,
|
|
584
|
-
};
|
|
602
|
+
return baseItem({ key: prKey(node), section, kind, repo: node.repository.nameWithOwner, number: node.number, title: node.title, url: node.url });
|
|
585
603
|
}
|
|
586
604
|
|
|
587
605
|
export function mergeMethodFor(pr: PullRequestNode, config: AttentionConfig): MergeMethod {
|
|
@@ -593,11 +611,11 @@ export function mergeMethodFor(pr: PullRequestNode, config: AttentionConfig): Me
|
|
|
593
611
|
|
|
594
612
|
function rankIssues(nodes: PickableNode[], details: Details, config: AttentionConfig): NextUpIssue[] {
|
|
595
613
|
const [priority, effort, scope] = FIELD_ROLES.map((role) => nextUpField(config, role));
|
|
596
|
-
const valueOf = (node: PickableNode, field: string | undefined) => node.issueFieldValues.nodes.find((value) =>
|
|
614
|
+
const valueOf = (node: PickableNode, field: string | undefined) => node.issueFieldValues.nodes.find((value) => sameName(value.field?.name, field))?.name;
|
|
597
615
|
// A field of the issue's own org: its options' order, or the colors it gave them. Two orgs may both have a Priority field,
|
|
598
616
|
// ordered and colored differently [NXT-02, NXT-10].
|
|
599
617
|
const ofOrg = <T,>(byOrg: Record<string, Record<string, T>> | undefined, node: PickableNode, field: string) =>
|
|
600
|
-
Object.entries(byOrg?.[node.repository.nameWithOwner.split("/")[0].toLowerCase()] ?? {}).find(([name]) =>
|
|
618
|
+
Object.entries(byOrg?.[node.repository.nameWithOwner.split("/")[0].toLowerCase()] ?? {}).find(([name]) => sameName(name, field))?.[1];
|
|
601
619
|
// Position in the configured order (matched by name), else in the issue's org's own options; missing goes last.
|
|
602
620
|
const position = (node: PickableNode, ranked: { field: string; order?: string[] } | undefined) => {
|
|
603
621
|
const value = valueOf(node, ranked?.field);
|