@andrioid/paseo-attention-span 0.4.14 → 0.5.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 +9 -5
- package/README.md +2 -2
- package/client/attention-screen.tsx +127 -141
- package/client/card.tsx +4 -2
- package/client/history.tsx +184 -0
- package/client/icons.ts +3 -1
- package/client/mark.ts +19 -0
- package/client/sessions.ts +50 -3
- package/client/ui.tsx +3 -3
- package/client/wrap-up.tsx +197 -0
- package/docs/architecture.md +17 -10
- 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-groups.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.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 +6 -1
- package/index.server.ts +21 -2
- package/package.json +8 -3
- package/requirements.yaml +10 -9
- package/server/archive.ts +132 -0
- package/server/archived.ts +120 -0
- package/server/changes.ts +184 -26
- package/server/classify.ts +9 -2
- package/server/fixture.ts +56 -12
- package/server/github-types.ts +29 -5
- package/server/queries.ts +33 -7
- package/server/service.ts +88 -17
- package/server/store.ts +10 -3
- package/server/view.ts +14 -5
- package/shared/archive.ts +37 -0
- package/shared/attention.ts +85 -8
- package/shared/changes.ts +26 -11
- package/shared/got-it.ts +23 -0
- package/shared/history-report.ts +61 -0
- package/shared/rpc.ts +23 -4
- package/shared/still.ts +4 -3
- package/shared/wrap-up.ts +126 -0
- package/docs/screenshots/desktop-dark-history-reviewed.png +0 -0
package/server/changes.ts
CHANGED
|
@@ -1,27 +1,42 @@
|
|
|
1
|
-
import { isHandover, type OthersChange } from "../shared/changes";
|
|
1
|
+
import { isFinishedChange, isHandover, type OthersChange } from "../shared/changes";
|
|
2
2
|
import type { Item } from "../shared/attention";
|
|
3
|
-
import type { AssignmentEvent, AssignmentSubject, EndedPullRequest, LiveResult } from "./github-types";
|
|
3
|
+
import type { AssignmentEvent, AssignmentSubject, ClosedIssue, EndedPullRequest, LiveResult, ReopenSubject } from "./github-types";
|
|
4
4
|
import { prKey } from "./queries";
|
|
5
5
|
|
|
6
|
-
// Changed by others: what someone else did to my work, kept between refreshes so a note stays until Got it
|
|
7
|
-
// can list work that left my hands [
|
|
6
|
+
// Changed by others: what someone else did to my work, kept between refreshes so a note stays until Got it or an archive
|
|
7
|
+
// acknowledges it, and so History can list work that left my hands [HIS-06, HIS-07, ATT-22]. Pure, so every rule is
|
|
8
|
+
// testable; service.ts does the fetching.
|
|
9
|
+
|
|
10
|
+
// A PR of mine closed and waiting to be seen reopened [HIS-07].
|
|
11
|
+
export interface TrackedPr {
|
|
12
|
+
key: string;
|
|
13
|
+
number: number;
|
|
14
|
+
title: string;
|
|
15
|
+
url: string;
|
|
16
|
+
repo: string;
|
|
17
|
+
closedAt: string;
|
|
18
|
+
}
|
|
8
19
|
|
|
9
20
|
export interface ChangeLedger {
|
|
10
21
|
events: OthersChange[];
|
|
11
|
-
// Events I've tapped Got it on.
|
|
22
|
+
// Events I've tapped Got it on, or an archive acknowledged.
|
|
12
23
|
gotIt: string[];
|
|
13
24
|
// Issue node id -> key, from the last assigned search that worked. Null until the first, so nothing counts as gone then:
|
|
14
25
|
// only issues seen assigned to me can be noticed leaving.
|
|
15
26
|
assigned: Record<string, string> | null;
|
|
16
27
|
// PR node id -> its assignees when last looked up, so each change of hands costs one lookup [GH-01].
|
|
17
28
|
handed: Record<string, string>;
|
|
29
|
+
// PR node id -> what Attention Span saw closed, so a reopen by someone else is noticed [HIS-07].
|
|
30
|
+
tracked: Record<string, TrackedPr>;
|
|
18
31
|
}
|
|
19
32
|
|
|
20
|
-
export const EMPTY_LEDGER: ChangeLedger = { events: [], gotIt: [], assigned: null, handed: {} };
|
|
33
|
+
export const EMPTY_LEDGER: ChangeLedger = { events: [], gotIt: [], assigned: null, handed: {}, tracked: {} };
|
|
21
34
|
|
|
22
|
-
type Data = Pick<LiveResult, "mine" | "assigned" | "ended"
|
|
35
|
+
type Data = Pick<LiveResult, "mine" | "assigned" | "ended"> & Partial<Pick<LiveResult, "closedIssues">>;
|
|
23
36
|
// A lookup's answer per node id: the subject, null when it's gone or hidden, missing when the lookup failed.
|
|
24
37
|
export type Lookups = Map<string, AssignmentSubject | null>;
|
|
38
|
+
// Reopen lookups: the PR as it is now, null when it's gone or hidden, missing when the lookup failed.
|
|
39
|
+
export type ReopenLookups = Map<string, ReopenSubject | null>;
|
|
25
40
|
|
|
26
41
|
const same = (a: string | null | undefined, b: string | null | undefined) => !!a && !!b && a.toLowerCase() === b.toLowerCase();
|
|
27
42
|
const present = <T>(nodes: (T | null | undefined)[]) => nodes.filter((node): node is T => !!node && Object.keys(node).length > 0);
|
|
@@ -57,10 +72,19 @@ export function changeCandidates(ledger: ChangeLedger, data: Data, me: string):
|
|
|
57
72
|
return [...new Set([...prs, ...gone])];
|
|
58
73
|
}
|
|
59
74
|
|
|
75
|
+
// Tracked PRs worth asking about: ones Attention Span saw closed that the closed search no longer shows, as a reopen takes
|
|
76
|
+
// them out of it [HIS-07, GH-01]. One still listed is still closed, so it costs nothing; past the search's 50 results it's
|
|
77
|
+
// asked about too.
|
|
78
|
+
export function reopenCandidates(ledger: ChangeLedger, data?: Pick<LiveResult, "ended">): string[] {
|
|
79
|
+
const listed = new Set(present(data?.ended.nodes ?? []).flatMap((pr) => (pr.id ? [pr.id] : [])));
|
|
80
|
+
return Object.keys(ledger.tracked).filter((id) => !listed.has(id));
|
|
81
|
+
}
|
|
82
|
+
|
|
60
83
|
const isAssignment = (node: AssignmentEvent | Record<string, never>): node is AssignmentEvent => "__typename" in node && "createdAt" in node;
|
|
61
84
|
|
|
62
|
-
// Who took it out of my hands, from GitHub's assign and unassign events [
|
|
63
|
-
// doing, or the events don't show it. An issue closed by now stays silent:
|
|
85
|
+
// Who took it out of my hands, from GitHub's assign and unassign events [HIS-07]. Null when it's still mine, it was my own
|
|
86
|
+
// doing, or the events don't show it. An issue closed by now stays silent: its close has its own note and this one would
|
|
87
|
+
// say the same thing twice.
|
|
64
88
|
// The new owner is the latest of the current assignees to be assigned. It left my hands with whichever came last of my
|
|
65
89
|
// removal and the new owner's assignment, and whoever did that is named: "phil took over" when that's the new owner, else
|
|
66
90
|
// "dave handed it to carol". So a PR I unassigned myself from is still mine until someone else takes it.
|
|
@@ -83,7 +107,7 @@ export function handover(subject: AssignmentSubject, me: string): OthersChange |
|
|
|
83
107
|
return change(subject, subject.__typename === "PullRequest" ? "pr" : "issue", kind, by.createdAt, actor, to);
|
|
84
108
|
}
|
|
85
109
|
|
|
86
|
-
// A PR of mine someone else merged or closed unmerged [
|
|
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,
|
|
87
111
|
// which knows when that happened.
|
|
88
112
|
export function ended(pr: EndedPullRequest, me: string): OthersChange | null {
|
|
89
113
|
if (pr.merged) return same(pr.mergedBy?.login, me) || !pr.mergedAt ? null : change(pr, "pr", "merged", pr.mergedAt, pr.mergedBy?.login);
|
|
@@ -91,6 +115,60 @@ export function ended(pr: EndedPullRequest, me: string): OthersChange | null {
|
|
|
91
115
|
return same(closer, me) ? null : change(pr, "pr", "closed", pr.closedAt, closer);
|
|
92
116
|
}
|
|
93
117
|
|
|
118
|
+
// My PRs I closed without merging, from the closed search: finished work whose sessions Wrap up puts away, though no note
|
|
119
|
+
// and no week lists them [ATT-22].
|
|
120
|
+
export function ownClosed(data: Pick<LiveResult, "ended">, me: string): Item[] {
|
|
121
|
+
return present(data.ended.nodes)
|
|
122
|
+
.filter((pr) => !pr.merged && same(pr.timelineItems.nodes.at(-1)?.actor?.login, me))
|
|
123
|
+
.map((pr) => ({
|
|
124
|
+
key: prKey(pr),
|
|
125
|
+
kind: "pr" as const,
|
|
126
|
+
section: "done" as const,
|
|
127
|
+
draft: false,
|
|
128
|
+
repo: pr.repository.nameWithOwner,
|
|
129
|
+
number: pr.number,
|
|
130
|
+
title: pr.title,
|
|
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
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// An issue assigned to me someone else closed, as completed or not planned [HIS-07]. My own closes are mine.
|
|
143
|
+
export function closedByOther(issue: ClosedIssue, me: string): OthersChange | null {
|
|
144
|
+
const closer = issue.timelineItems.nodes.at(-1)?.actor?.login;
|
|
145
|
+
if (same(closer, me)) return null;
|
|
146
|
+
const reason = issue.stateReason === "NOT_PLANNED" ? "not_planned" : issue.stateReason === "COMPLETED" ? "completed" : undefined;
|
|
147
|
+
return { ...change(issue, "issue", "issue_closed", issue.closedAt, closer), ...(reason ? { reason } : {}) };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// A PR Attention Span saw closed, now open again by someone else [HIS-07]. Only PRs already tracked count, so a first run
|
|
151
|
+
// doesn't announce every old reopen, and issues don't come here: they surface in Next up.
|
|
152
|
+
export function reopened(tracked: TrackedPr, subject: ReopenSubject, me: string): OthersChange | null {
|
|
153
|
+
if (subject.state !== "OPEN") return null;
|
|
154
|
+
const event = subject.timelineItems.nodes.at(-1);
|
|
155
|
+
const actor = event?.actor?.login;
|
|
156
|
+
if (!actor || same(actor, me)) return null;
|
|
157
|
+
return {
|
|
158
|
+
id: `reopened:${subject.id}:${event?.createdAt ?? tracked.closedAt}`,
|
|
159
|
+
kind: "reopened",
|
|
160
|
+
subjectId: subject.id,
|
|
161
|
+
subject: "pr",
|
|
162
|
+
key: tracked.key,
|
|
163
|
+
repo: tracked.repo,
|
|
164
|
+
number: tracked.number,
|
|
165
|
+
title: subject.title || tracked.title,
|
|
166
|
+
url: tracked.url,
|
|
167
|
+
actor,
|
|
168
|
+
at: event?.createdAt ?? new Date().toISOString(),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
94
172
|
function change(
|
|
95
173
|
subject: { id: string; number: number; title: string; url: string; repository: { nameWithOwner: string } },
|
|
96
174
|
kind: "pr" | "issue",
|
|
@@ -116,9 +194,18 @@ function change(
|
|
|
116
194
|
}
|
|
117
195
|
|
|
118
196
|
// The ledger after a refresh. New events count only within `windowDays` (mentionDays), so a first run catches up that far
|
|
119
|
-
// and no further; kept for `keepDays`, long enough for History. Work back in my hands drops its handover
|
|
120
|
-
// looked up is left to retry next time.
|
|
121
|
-
export function nextLedger(
|
|
197
|
+
// and no further; kept for `keepDays`, long enough for History. Work back in my hands drops its handover unless it was
|
|
198
|
+
// cleared, which stays in its week. What couldn't be looked up is left to retry next time.
|
|
199
|
+
export function nextLedger(
|
|
200
|
+
ledger: ChangeLedger,
|
|
201
|
+
data: Data,
|
|
202
|
+
me: string,
|
|
203
|
+
lookups: Lookups,
|
|
204
|
+
now: Date,
|
|
205
|
+
windowDays: number,
|
|
206
|
+
keepDays: number,
|
|
207
|
+
reopens: ReopenLookups = new Map(),
|
|
208
|
+
): ChangeLedger {
|
|
122
209
|
const since = (days: number) => new Date(now.getTime() - days * 86_400_000).toISOString();
|
|
123
210
|
const found: OthersChange[] = [];
|
|
124
211
|
const endedAt = new Map(present(data.ended.nodes).map((pr) => [pr.id, pr.mergedAt ?? pr.closedAt]));
|
|
@@ -127,7 +214,8 @@ export function nextLedger(ledger: ChangeLedger, data: Data, me: string, lookups
|
|
|
127
214
|
.map((subject) => (subject ? handover(subject, me) : null))
|
|
128
215
|
.filter((event): event is OthersChange => !!event && !(endedAt.has(event.subjectId) && event.at > endedAt.get(event.subjectId)!));
|
|
129
216
|
found.push(...handovers);
|
|
130
|
-
|
|
217
|
+
// A handover whose work came back to me no longer makes a later merge someone else's [HIS-06].
|
|
218
|
+
const handedAt = (id: string) => [...ledger.events, ...handovers].filter((event) => isHandover(event) && !event.returned && event.subjectId === id).map((event) => event.at);
|
|
131
219
|
for (const pr of present(data.ended.nodes)) {
|
|
132
220
|
// A PR someone else has whose hands aren't looked up yet waits a refresh, so a handover isn't reported as a merge.
|
|
133
221
|
if (handedOver(pr, me) && !lookups.has(pr.id) && ledger.handed[pr.id] !== signature(pr)) continue;
|
|
@@ -135,15 +223,56 @@ export function nextLedger(ledger: ChangeLedger, data: Data, me: string, lookups
|
|
|
135
223
|
// One that left my hands before it ended was a handover, not my work merged or closed.
|
|
136
224
|
if (event && !handedAt(pr.id).some((at) => at <= event.at)) found.push(event);
|
|
137
225
|
}
|
|
226
|
+
for (const issue of present(data.closedIssues?.nodes ?? [])) {
|
|
227
|
+
const event = closedByOther(issue, me);
|
|
228
|
+
if (event) found.push(event);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Track what Attention Span sees closed, so a later reopen by someone else is a change [HIS-07]. A merged PR can't reopen.
|
|
232
|
+
const tracked: Record<string, TrackedPr> = { ...ledger.tracked };
|
|
233
|
+
for (const pr of present(data.ended.nodes)) {
|
|
234
|
+
if (pr.merged || !pr.id) continue;
|
|
235
|
+
tracked[pr.id] = { key: prKey(pr), number: pr.number, title: pr.title, url: pr.url, repo: pr.repository.nameWithOwner, closedAt: pr.closedAt };
|
|
236
|
+
}
|
|
237
|
+
// A reopen takes the old close out of History's week and adds a note. A lookup that failed keeps the PR tracked.
|
|
238
|
+
const reopenedIds = new Set<string>();
|
|
239
|
+
for (const [id, subject] of reopens) {
|
|
240
|
+
const before = tracked[id];
|
|
241
|
+
if (!subject) {
|
|
242
|
+
delete tracked[id];
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
// Merged: it can't reopen any more. Still closed: keep watching it.
|
|
246
|
+
if (subject.state === "MERGED") {
|
|
247
|
+
delete tracked[id];
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
if (subject.state !== "OPEN") continue;
|
|
251
|
+
// Open again: the old close leaves its week whoever reopened it; only someone else's reopen is a note.
|
|
252
|
+
delete tracked[id];
|
|
253
|
+
reopenedIds.add(id);
|
|
254
|
+
const event = before ? reopened(before, subject, me) : null;
|
|
255
|
+
if (event) found.push(event);
|
|
256
|
+
}
|
|
257
|
+
|
|
138
258
|
// Mine again: my PRs with nobody else on them, and issues assigned to me.
|
|
139
259
|
const mineNow = new Set([...present(data.mine.nodes).filter((pr) => !handedOver(pr, me)).map((pr) => pr.id), ...Object.keys(assignedNow(data))]);
|
|
140
260
|
const known = new Set(ledger.events.map((event) => event.id));
|
|
141
261
|
const fresh = found.filter((event) => !known.has(event.id) && event.at >= since(windowDays));
|
|
262
|
+
const cleared = new Set(ledger.gotIt);
|
|
142
263
|
const events = [...ledger.events, ...fresh]
|
|
143
|
-
|
|
264
|
+
// A reopen leaves the closed PR's week; its note takes its place.
|
|
265
|
+
.filter((event) => !(event.kind === "closed" && reopenedIds.has(event.subjectId)))
|
|
266
|
+
.flatMap((event) => {
|
|
267
|
+
if (!isHandover(event) || !mineNow.has(event.subjectId)) return [event];
|
|
268
|
+
// Back in my hands: an uncleared handover goes; a cleared one stays in its week, marked so my later work is mine.
|
|
269
|
+
return cleared.has(event.id) ? [{ ...event, returned: true as const }] : [];
|
|
270
|
+
})
|
|
144
271
|
.filter((event) => event.at >= since(keepDays))
|
|
145
272
|
.sort((a, b) => b.at.localeCompare(a.at));
|
|
146
273
|
const ids = new Set(events.map((event) => event.id));
|
|
274
|
+
// Nothing older than the window is worth tracking, whether or not its lookup worked [GH-01].
|
|
275
|
+
for (const [id, pr] of Object.entries(tracked)) if (pr.closedAt < since(keepDays)) delete tracked[id];
|
|
147
276
|
|
|
148
277
|
// Issues that left my search and couldn't be looked up stay, so they're checked again.
|
|
149
278
|
const assigned = assignedNow(data);
|
|
@@ -154,18 +283,29 @@ export function nextLedger(ledger: ChangeLedger, data: Data, me: string, lookups
|
|
|
154
283
|
const before = ledger.handed[pr.id];
|
|
155
284
|
if (before !== undefined || lookups.has(pr.id)) handed[pr.id] = lookups.has(pr.id) ? pr.signature : before;
|
|
156
285
|
}
|
|
157
|
-
return { events, gotIt: ledger.gotIt.filter((id) => ids.has(id)), assigned, handed };
|
|
286
|
+
return { events, gotIt: ledger.gotIt.filter((id) => ids.has(id)), assigned, handed, tracked };
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// An archive acknowledges exactly the events on its work at that moment, keyed by "owner/name#number" [ATT-22].
|
|
290
|
+
// `upTo` keeps what others did after then unread: a session archived in Paseo acknowledges only what came before it.
|
|
291
|
+
export function acknowledge(ledger: ChangeLedger, keys: string[], upTo?: string): ChangeLedger {
|
|
292
|
+
const wanted = new Set(keys.map((key) => key.toLowerCase()));
|
|
293
|
+
const before = (at: string) => !upTo || Date.parse(at) <= Date.parse(upTo);
|
|
294
|
+
const ids = ledger.events.filter((event) => wanted.has(event.key.toLowerCase()) && before(event.at)).map((event) => event.id);
|
|
295
|
+
return { ...ledger, gotIt: [...new Set([...ledger.gotIt, ...ids])] };
|
|
158
296
|
}
|
|
159
297
|
|
|
160
|
-
// What a refresh found, with the Got its tapped while it ran, as those changed the ledger after the refresh
|
|
298
|
+
// What a refresh found, with the Got its, and archives, tapped while it ran, as those changed the ledger after the refresh
|
|
299
|
+
// read it [HIS-07, ATT-22].
|
|
161
300
|
export function withGotIt(next: ChangeLedger, gotIt: string[]): ChangeLedger {
|
|
162
301
|
const ids = new Set(next.events.map((event) => event.id));
|
|
163
302
|
return { ...next, gotIt: gotIt.filter((id) => ids.has(id)) };
|
|
164
303
|
}
|
|
165
304
|
|
|
166
|
-
// The ledger as cards:
|
|
167
|
-
//
|
|
168
|
-
|
|
305
|
+
// The ledger as cards: History's unread notes, newest first, what was cleared into each week, and the finished work a live
|
|
306
|
+
// refresh saw before History's daily fetch did [HIS-07]. Unread notes expire after `windowDays`; cleared ones stay
|
|
307
|
+
// `historySince`, out of the week's copy [HIS-06, HIS-07].
|
|
308
|
+
export function changeItems(ledger: ChangeLedger, now: Date, windowDays: number, historySince: string): { notes: Item[]; history: Item[]; finished: Item[] } {
|
|
169
309
|
const since = new Date(now.getTime() - windowDays * 86_400_000).toISOString();
|
|
170
310
|
const gotIt = new Set(ledger.gotIt);
|
|
171
311
|
const base = (change: OthersChange): Omit<Item, "key" | "section"> => ({
|
|
@@ -180,18 +320,36 @@ export function changeItems(ledger: ChangeLedger, now: Date, windowDays: number,
|
|
|
180
320
|
children: [],
|
|
181
321
|
target: { kind: change.subject, repo: change.repo, number: change.number, title: change.title, url: change.url },
|
|
182
322
|
othersActivityAt: change.at,
|
|
323
|
+
closedAt: change.at,
|
|
183
324
|
change,
|
|
184
325
|
});
|
|
185
|
-
const
|
|
326
|
+
const notes = ledger.events
|
|
186
327
|
.filter((change) => !gotIt.has(change.id) && change.at >= since)
|
|
187
328
|
.map((change): Item => ({ ...base(change), key: `change:${change.id}`, section: "changed", actions: ["got_it"] }));
|
|
188
329
|
const history = ledger.events
|
|
189
|
-
|
|
190
|
-
.
|
|
191
|
-
|
|
330
|
+
// A merge or an issue close is the week's Finished, not a change repeated under it [HIS-07].
|
|
331
|
+
.filter((change) => gotIt.has(change.id) && !isFinishedChange(change) && change.at >= historySince)
|
|
332
|
+
.map((change): Item => ({ ...base(change), key: `handed:${change.id}`, section: "handed_off", actions: [] }));
|
|
333
|
+
// A merge or close someone else did is finished work at once, not only when History's daily fetch catches up [HIS-07].
|
|
334
|
+
const finished = ledger.events
|
|
335
|
+
.filter((change) => isFinishedChange(change) && change.at >= historySince)
|
|
336
|
+
.map(
|
|
337
|
+
(change): Item => ({
|
|
338
|
+
...base(change),
|
|
339
|
+
key: change.key,
|
|
340
|
+
section: "done",
|
|
341
|
+
// The week's cards say it in the finished wording, not the note's: "merged 2h ago by dave" [HIS-05, HIS-07].
|
|
342
|
+
change: undefined,
|
|
343
|
+
...(change.kind === "merged" && change.actor ? { mergedBy: change.actor } : {}),
|
|
344
|
+
...(change.kind === "issue_closed" && change.actor ? { closedBy: change.actor } : {}),
|
|
345
|
+
...(change.reason === "not_planned" ? { notPlanned: true as const, chips: [{ text: "not planned", tone: "neutral" as const }] } : {}),
|
|
346
|
+
}),
|
|
347
|
+
);
|
|
348
|
+
return { notes, history, finished };
|
|
192
349
|
}
|
|
193
350
|
|
|
194
|
-
// Keys of my PRs and issues
|
|
351
|
+
// Keys of my PRs and issues still out of my hands: a merge by their new owner isn't my finished work [HIS-06]. A cleared
|
|
352
|
+
// handover whose work came back to me doesn't hide what I later finish.
|
|
195
353
|
export function handedKeys(ledger: ChangeLedger): Set<string> {
|
|
196
|
-
return new Set(ledger.events.filter(isHandover).map((event) => event.key));
|
|
354
|
+
return new Set(ledger.events.filter((event) => isHandover(event) && !event.returned).map((event) => event.key));
|
|
197
355
|
}
|
package/server/classify.ts
CHANGED
|
@@ -435,7 +435,10 @@ export function classifyHistory(data: HistoryResult): Item[] {
|
|
|
435
435
|
};
|
|
436
436
|
for (const issue of compact(data.closed.nodes)) {
|
|
437
437
|
const notPlanned = issue.stateReason === "NOT_PLANNED";
|
|
438
|
-
|
|
438
|
+
// Who closed it, when it wasn't me [HIS-07].
|
|
439
|
+
const closer = issue.timelineItems?.nodes.at(-1)?.actor?.login;
|
|
440
|
+
const closedBy = closer && me && closer.toLowerCase() !== me ? { closedBy: closer } : {};
|
|
441
|
+
const item = kinded({ ...plain(issue, "issue", "done"), closedAt: issue.closedAt, chips: notPlanned ? [chip("not planned")] : [], ...closedBy, ...(notPlanned ? { notPlanned: true as const } : {}) }, issue);
|
|
439
442
|
// Not planned issues get no PRs under them: the PRs were still done, so they're listed on their own [HIS-03].
|
|
440
443
|
if (!notPlanned) closed.set(prKey(issue), item);
|
|
441
444
|
items.push(item);
|
|
@@ -450,7 +453,11 @@ export function classifyHistory(data: HistoryResult): Item[] {
|
|
|
450
453
|
if (issue) issue.children.push({ key: prKey(pr), number: pr.number, title: pr.title, url: pr.url, draft: false, chips: [], attention: false, ...mergedBy });
|
|
451
454
|
else items.push(kinded({ ...plain(pr, "pr", "done"), closedAt: pr.mergedAt, ...mergedBy }, pr));
|
|
452
455
|
}
|
|
453
|
-
for (const pr of compact(data.reviewed.nodes))
|
|
456
|
+
for (const pr of compact(data.reviewed.nodes)) {
|
|
457
|
+
const by = pr.mergedBy?.login;
|
|
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));
|
|
460
|
+
}
|
|
454
461
|
return items.sort(order);
|
|
455
462
|
}
|
|
456
463
|
|
package/server/fixture.ts
CHANGED
|
@@ -136,6 +136,7 @@ export function builders(now: Date) {
|
|
|
136
136
|
reviewed: nodes("reviewed") as SearchResult["reviewed"],
|
|
137
137
|
closed: nodes("closed") as SearchResult["closed"],
|
|
138
138
|
ended: nodes("ended") as SearchResult["ended"],
|
|
139
|
+
closedIssues: nodes("closedIssues") as SearchResult["closedIssues"],
|
|
139
140
|
};
|
|
140
141
|
}
|
|
141
142
|
|
|
@@ -155,7 +156,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
155
156
|
url: `https://github.com/${REPO}/pull/${number}`,
|
|
156
157
|
mergedAt: daysAgo(days),
|
|
157
158
|
// Someone else merged one of them [HIS-05].
|
|
158
|
-
mergedBy: { login: number === 177 ? "dave" : number === 179 ? "carol" : "me" },
|
|
159
|
+
mergedBy: { login: number === 177 || number === 183 ? "dave" : number === 179 ? "carol" : "me" },
|
|
159
160
|
repository,
|
|
160
161
|
labels: labels(...names),
|
|
161
162
|
closingIssuesReferences: { nodes: closesIssue ? [{ number: closesIssue, repository }] : [] },
|
|
@@ -169,6 +170,8 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
169
170
|
repository,
|
|
170
171
|
issueType: type ? { name: type } : null,
|
|
171
172
|
labels: labels(...names),
|
|
173
|
+
// #188 was closed by someone else [HIS-07].
|
|
174
|
+
timelineItems: { nodes: [{ actor: { login: number === 188 ? "alice" : "me" } }] },
|
|
172
175
|
});
|
|
173
176
|
|
|
174
177
|
const data = search({
|
|
@@ -282,25 +285,30 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
282
285
|
{ ...pickable(165, {}, 3, "Task", "Devcontainers for pull requests", "me/tool"), projectItems: { nodes: [] }, sources: ["mine"] },
|
|
283
286
|
],
|
|
284
287
|
merged: [
|
|
285
|
-
merged(
|
|
288
|
+
merged(183, "Retry failed webhooks", 2 / 24, undefined, "feature"),
|
|
286
289
|
merged(172, "Fix VAT on credit notes", 3, undefined, "bug"),
|
|
287
290
|
merged(177, "chore: bump the build image", 4),
|
|
288
|
-
merged(
|
|
291
|
+
merged(170, "Nightly backup check", 1, 171),
|
|
289
292
|
// Handed over to carol before she merged it, so it isn't listed as mine [HIS-06].
|
|
290
293
|
merged(179, "Move invoices to the new queue", 1),
|
|
291
294
|
merged(173, "Speed up the order list", 9, 174),
|
|
292
295
|
merged(175, "Remove the old importer", 16),
|
|
293
296
|
],
|
|
294
297
|
reviewed: [
|
|
295
|
-
{ number:
|
|
296
|
-
{ number:
|
|
297
|
-
{ number: 182, title: "Sentry release tracking", url: `https://github.com/${REPO}/pull/182`, mergedAt: daysAgo(11), repository, author: alice },
|
|
298
|
+
{ number: 190, title: "Add the VAT export", url: `https://github.com/${REPO}/pull/190`, mergedAt: daysAgo(1), mergedBy: { login: "alice" }, repository, author: alice, labels: labels("feature") },
|
|
299
|
+
{ number: 191, title: "Speed up the search index", url: `https://github.com/${REPO}/pull/191`, mergedAt: daysAgo(3), mergedBy: { login: "bob" }, repository, author: bob },
|
|
300
|
+
{ number: 182, title: "Sentry release tracking", url: `https://github.com/${REPO}/pull/182`, mergedAt: daysAgo(11), mergedBy: { login: "alice" }, repository, author: alice },
|
|
298
301
|
],
|
|
299
302
|
closed: [
|
|
303
|
+
closed(188, "Export fails on empty months", 6 / 24, "COMPLETED", "Bug"),
|
|
300
304
|
closed(171, "Backups are never verified", 1, "COMPLETED", "Feature"),
|
|
301
305
|
closed(174, "Order list takes 8 seconds", 9, "COMPLETED", undefined, "type: bug"),
|
|
302
306
|
closed(176, "Dark mode for the admin", 10, "NOT_PLANNED", undefined, "enhancement"),
|
|
303
307
|
],
|
|
308
|
+
// The live close search sees the same issue, so its close is a note too [HIS-07].
|
|
309
|
+
closedIssues: [
|
|
310
|
+
{ id: "I_188", number: 188, title: "Export fails on empty months", url: `https://github.com/${REPO}/issues/188`, closedAt: daysAgo(6 / 24), stateReason: "COMPLETED", repository, timelineItems: { nodes: [{ actor: { login: "alice" } }] } },
|
|
311
|
+
],
|
|
304
312
|
});
|
|
305
313
|
return {
|
|
306
314
|
data,
|
|
@@ -316,7 +324,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
316
324
|
};
|
|
317
325
|
}
|
|
318
326
|
|
|
319
|
-
// What others did to my work, one of each kind, as the ledger keeps them [
|
|
327
|
+
// What others did to my work, one of each kind, as the ledger keeps them [HIS-07, HIS-06]. #179 was handed over, then merged
|
|
320
328
|
// by its new owner, so History doesn't count it as mine.
|
|
321
329
|
export function fixtureChanges(now: Date): OthersChange[] {
|
|
322
330
|
const hoursAgo = (hours: number) => new Date(now.getTime() - hours * 3_600_000).toISOString();
|
|
@@ -335,28 +343,58 @@ export function fixtureChanges(now: Date): OthersChange[] {
|
|
|
335
343
|
at: hoursAgo(hours),
|
|
336
344
|
});
|
|
337
345
|
return [
|
|
346
|
+
{ ...event("reopened", "pr", 181, "Paginate the order export", 1, "bob") },
|
|
338
347
|
event("merged", "pr", 183, "Retry failed webhooks", 2, "dave"),
|
|
339
348
|
event("took_over", "pr", 186, "Split the invoice PDF job", 5, "phil", "phil"),
|
|
349
|
+
{ ...event("issue_closed", "issue", 188, "Export fails on empty months", 6, "alice"), reason: "completed" as const },
|
|
340
350
|
event("closed", "pr", 169, "Cache exchange rates", 26, "alice"),
|
|
341
|
-
event("handed", "pr", 179, "Move invoices to the new queue",
|
|
342
|
-
event("unassigned", "issue", 160, "Refunds skip the ledger",
|
|
351
|
+
event("handed", "pr", 179, "Move invoices to the new queue", 96, "dave", "carol"),
|
|
352
|
+
event("unassigned", "issue", 160, "Refunds skip the ledger", 192, "bob"),
|
|
353
|
+
event("closed", "pr", 170, "Drop the legacy CSV import", 216, "bob"),
|
|
343
354
|
];
|
|
344
355
|
}
|
|
345
356
|
|
|
357
|
+
// The notes History already shows as cleared in the preview: their week's Changed by others has them [HIS-07].
|
|
358
|
+
export function fixtureGotIt(now: Date): string[] {
|
|
359
|
+
return fixtureChanges(now)
|
|
360
|
+
.filter((change) => (change.number === 179 || change.number === 170) && change.kind !== "merged")
|
|
361
|
+
.map((change) => change.id);
|
|
362
|
+
}
|
|
363
|
+
|
|
346
364
|
// Sessions the preview shows as started from items: working, needs me, failed, idle.
|
|
347
365
|
// Each sits in its action's line in the sheet. Issue 90 has two: an old one with no kind, which leads, and Rebase stack on its PR.
|
|
348
366
|
// #113 waits on CI while its Fix CI session works, though Fix CI isn't one of its actions any more.
|
|
349
367
|
// #120's was started outside Attention Span, in a workspace Paseo linked to the PR, so it has no kind [SES-08].
|
|
350
368
|
// #197's too, so it shows on its stack, led by #196 [ATT-04].
|
|
351
|
-
const agent = (
|
|
369
|
+
const agent = (
|
|
370
|
+
id: string,
|
|
371
|
+
itemKey: string,
|
|
372
|
+
kind: SessionKind | undefined,
|
|
373
|
+
status: string,
|
|
374
|
+
minutesAgo: number,
|
|
375
|
+
requiresAttention = false,
|
|
376
|
+
workspace?: AgentSummary["workspace"],
|
|
377
|
+
title = `Fixture session ${id}`,
|
|
378
|
+
): AgentSummary => ({
|
|
352
379
|
id,
|
|
353
380
|
itemKey,
|
|
354
381
|
kind,
|
|
355
382
|
status,
|
|
356
383
|
requiresAttention,
|
|
357
|
-
title
|
|
358
|
-
workspaceId: null,
|
|
384
|
+
title,
|
|
385
|
+
workspaceId: workspace ? `WS_${id}` : null,
|
|
359
386
|
lastActivityAt: new Date(Date.now() - minutesAgo * 60_000).toISOString(),
|
|
387
|
+
...(workspace ? { workspace } : {}),
|
|
388
|
+
});
|
|
389
|
+
// A worktree Paseo made, clean or with uncommitted or unpushed work [ATT-22].
|
|
390
|
+
const sessionWorkspace = (branch: string, dirty: boolean | undefined, ahead: number | undefined, worktree = true, dirtyFiles?: number): AgentSummary["workspace"] => ({
|
|
391
|
+
kind: worktree ? "worktree" : "local_checkout",
|
|
392
|
+
name: `Workspace for ${branch}`,
|
|
393
|
+
directory: `/tmp/attention-span/${branch}`,
|
|
394
|
+
branch,
|
|
395
|
+
...(dirty === undefined ? {} : { dirty }),
|
|
396
|
+
...(ahead === undefined ? {} : { ahead }),
|
|
397
|
+
...(dirtyFiles === undefined ? {} : { dirtyFiles }),
|
|
360
398
|
});
|
|
361
399
|
export const FIXTURE_AGENTS: AgentSummary[] = [
|
|
362
400
|
agent("agent-101", `${REPO}#101`, "fix", "running", 4),
|
|
@@ -368,6 +406,12 @@ export const FIXTURE_AGENTS: AgentSummary[] = [
|
|
|
368
406
|
agent("agent-113", `${REPO}#113`, "fix", "running", 2),
|
|
369
407
|
agent("agent-120", `${REPO}#120`, undefined, "running", 3),
|
|
370
408
|
agent("agent-197", `${REPO}#197`, undefined, "idle", 15),
|
|
409
|
+
// Wrap up: finished work whose sessions are all idle [ATT-22].
|
|
410
|
+
agent("agent-183", `${REPO}#183`, "fix", "idle", 20, false, sessionWorkspace("retry-webhooks", false, 0), "Retry webhooks"),
|
|
411
|
+
agent("agent-186", `${REPO}#186`, "fix", "idle", 40, false, sessionWorkspace("split-invoice-pdf", true, 1, true, 2), "Split invoice PDF"),
|
|
412
|
+
agent("agent-190", `${REPO}#190`, "review", "idle", 60, false, sessionWorkspace("add-vat-export", false, 0), "Review PR 190: Add the VAT export"),
|
|
413
|
+
agent("agent-172", `${REPO}#172`, "fix", "idle", 240, false, sessionWorkspace("fix-vat-credit-notes", false, 0), "Fix VAT on credit notes"),
|
|
414
|
+
agent("agent-172b", `${REPO}#172`, "address", "idle", 250, false, sessionWorkspace("credit-note-tests", undefined, undefined), "Credit note tests"),
|
|
371
415
|
];
|
|
372
416
|
|
|
373
417
|
export const FIXTURE_CONTEXT = "Context from GitHub would go here (fixture mode).";
|
package/server/github-types.ts
CHANGED
|
@@ -96,7 +96,7 @@ export interface IssueNode {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
export interface PickableNode {
|
|
99
|
-
// The issue's node id, which a transfer keeps [
|
|
99
|
+
// The issue's node id, which a transfer keeps [HIS-07].
|
|
100
100
|
id?: string;
|
|
101
101
|
number: number;
|
|
102
102
|
title: string;
|
|
@@ -130,8 +130,32 @@ export interface LiveResult {
|
|
|
130
130
|
asked: Nodes<IssueNode>;
|
|
131
131
|
assigned: Nodes<PickableNode>;
|
|
132
132
|
unclaimed: Nodes<PickableNode>;
|
|
133
|
-
// My PRs closed lately [
|
|
133
|
+
// My PRs closed lately [HIS-07].
|
|
134
134
|
ended: Nodes<EndedPullRequest>;
|
|
135
|
+
// Issues assigned to me closed lately, for a change by others [HIS-07].
|
|
136
|
+
closedIssues: Nodes<ClosedIssue>;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface ClosedIssue {
|
|
140
|
+
id: string;
|
|
141
|
+
number: number;
|
|
142
|
+
title: string;
|
|
143
|
+
url: string;
|
|
144
|
+
closedAt: string;
|
|
145
|
+
stateReason: string | null;
|
|
146
|
+
repository: Repo;
|
|
147
|
+
timelineItems: Nodes<{ createdAt?: string; actor?: { login: string } | null }>;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// A PR of mine known to have been closed, as it is now [HIS-07].
|
|
151
|
+
export interface ReopenSubject {
|
|
152
|
+
id: string;
|
|
153
|
+
number: number;
|
|
154
|
+
title: string;
|
|
155
|
+
url: string;
|
|
156
|
+
state: "OPEN" | "CLOSED" | "MERGED";
|
|
157
|
+
repository: Repo;
|
|
158
|
+
timelineItems: Nodes<{ createdAt?: string; actor?: { login: string } | null }>;
|
|
135
159
|
}
|
|
136
160
|
|
|
137
161
|
export interface EndedPullRequest {
|
|
@@ -148,7 +172,7 @@ export interface EndedPullRequest {
|
|
|
148
172
|
timelineItems: Nodes<{ createdAt?: string; actor?: { login: string } | null }>;
|
|
149
173
|
}
|
|
150
174
|
|
|
151
|
-
// Who assigned or unassigned whom; actor and assignee are null for a deleted account [
|
|
175
|
+
// Who assigned or unassigned whom; actor and assignee are null for a deleted account [HIS-07].
|
|
152
176
|
export interface AssignmentEvent {
|
|
153
177
|
__typename: "AssignedEvent" | "UnassignedEvent";
|
|
154
178
|
createdAt: string;
|
|
@@ -176,8 +200,8 @@ export interface HistoryResult {
|
|
|
176
200
|
// Who I am, to tell a merge by someone else [HIS-05]; missing in older fixtures.
|
|
177
201
|
viewer?: { login: string; id: string };
|
|
178
202
|
merged: Nodes<{ number: number; title: string; url: string; body?: string; mergedAt: string; mergedBy?: { login: string } | null; repository: Repo; closingIssuesReferences: Nodes<{ number: number; repository: Repo }> } & Labels>;
|
|
179
|
-
reviewed: Nodes<{ number: number; title: string; url: string; mergedAt: string; repository: Repo; author: Actor | null } & Labels>;
|
|
180
|
-
closed: Nodes<{ number: number; title: string; url: string; closedAt: string; stateReason: string | null; repository: Repo; issueType?: { name: string } | null } & Labels>;
|
|
203
|
+
reviewed: Nodes<{ number: number; title: string; url: string; mergedAt: string; mergedBy?: { login: string } | null; repository: Repo; author: Actor | null } & Labels>;
|
|
204
|
+
closed: Nodes<{ number: number; title: string; url: string; closedAt: string; stateReason: string | null; repository: Repo; issueType?: { name: string } | null; timelineItems?: Nodes<{ actor?: { login: string } | null }> } & Labels>;
|
|
181
205
|
}
|
|
182
206
|
|
|
183
207
|
export type SearchResult = LiveResult & HistoryResult;
|
package/server/queries.ts
CHANGED
|
@@ -28,7 +28,7 @@ const SEARCHES = {
|
|
|
28
28
|
asked: { first: 50, nodes: THREAD },
|
|
29
29
|
assigned: { first: 50, nodes: "...pickable" },
|
|
30
30
|
unclaimed: { first: 100, nodes: "...pickable" },
|
|
31
|
-
// My PRs closed lately, with who merged or closed them, for Changed by others [
|
|
31
|
+
// My PRs closed lately, with who merged or closed them, for Changed by others [HIS-07]. Who closed one comes from its last
|
|
32
32
|
// close event; assignees tell a PR handed over before it closed [PRS-08].
|
|
33
33
|
ended: {
|
|
34
34
|
first: 50,
|
|
@@ -38,19 +38,31 @@ const SEARCHES = {
|
|
|
38
38
|
timelineItems(itemTypes: [CLOSED_EVENT], last: 1) { nodes { ... on ClosedEvent { createdAt actor { login } } } }
|
|
39
39
|
}`,
|
|
40
40
|
},
|
|
41
|
+
// Issues assigned to me closed lately, so someone else's close is a change too [HIS-07]. Bounded like `ended`.
|
|
42
|
+
closedIssues: {
|
|
43
|
+
first: 50,
|
|
44
|
+
nodes: `... on Issue {
|
|
45
|
+
id number title url closedAt stateReason repository { nameWithOwner }
|
|
46
|
+
timelineItems(itemTypes: [CLOSED_EVENT], last: 1) { nodes { ... on ClosedEvent { createdAt actor { login } } } }
|
|
47
|
+
}`,
|
|
48
|
+
},
|
|
41
49
|
// Who merged it, when it wasn't me [HIS-05].
|
|
42
50
|
merged: {
|
|
43
51
|
first: 100,
|
|
44
52
|
nodes: "... on PullRequest { number title url body mergedAt mergedBy { login } repository { nameWithOwner } labels(first: 20) { nodes { name } } closingIssuesReferences(first: 3) { nodes { number repository { nameWithOwner } } } }",
|
|
45
53
|
},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
// Who merged someone else's PR I reviewed, for the week's Changed by others copy and Wrap up [HIS-02, ATT-22].
|
|
55
|
+
reviewed: { first: 100, nodes: "... on PullRequest { number title url mergedAt mergedBy { login } repository { nameWithOwner } author { ...author } labels(first: 20) { nodes { name } } }" },
|
|
56
|
+
// Labels and type say what kind of work each was [HIS-04]; the close event's actor says who closed it [HIS-07].
|
|
57
|
+
closed: {
|
|
58
|
+
first: 100,
|
|
59
|
+
nodes: "... on Issue { number title url closedAt stateReason repository { nameWithOwner } issueType { name } labels(first: 20) { nodes { name } } timelineItems(itemTypes: [CLOSED_EVENT], last: 1) { nodes { ... on ClosedEvent { actor { login } } } } }",
|
|
60
|
+
},
|
|
49
61
|
};
|
|
50
62
|
export type SearchName = keyof typeof SEARCHES;
|
|
51
63
|
|
|
52
64
|
// Doing, Waiting and Next up. History has its own, slower schedule.
|
|
53
|
-
export const LIVE_SEARCHES = ["mine", "reviews", "mentions", "involved", "asked", "assigned", "unclaimed", "ended"] as const;
|
|
65
|
+
export const LIVE_SEARCHES = ["mine", "reviews", "mentions", "involved", "asked", "assigned", "unclaimed", "ended", "closedIssues"] as const;
|
|
54
66
|
export const HISTORY_SEARCHES = ["merged", "reviewed", "closed"] as const;
|
|
55
67
|
|
|
56
68
|
const FRAGMENTS: Record<string, string> = {
|
|
@@ -193,8 +205,10 @@ export function searchVariables(config: AttentionConfig, now: Date): Record<Excl
|
|
|
193
205
|
reviews: `is:pr is:open user-review-requested:@me ${scope}`,
|
|
194
206
|
mentions: `is:open mentions:@me updated:>=${since} ${scope}`,
|
|
195
207
|
assigned: `is:issue is:open assignee:@me ${scope}`,
|
|
196
|
-
// Within the window Changed by others catches up over [
|
|
208
|
+
// Within the window Changed by others catches up over [HIS-07].
|
|
197
209
|
ended: `is:pr is:closed author:@me closed:>=${since} sort:updated-desc ${scope}`,
|
|
210
|
+
// Issues assigned to me that closed lately: someone else's close is a change too [HIS-07].
|
|
211
|
+
closedIssues: `is:issue is:closed assignee:@me closed:>=${since} sort:updated-desc ${scope}`,
|
|
198
212
|
// Threads I opened, commented on, was assigned or mentioned in, active lately: answers, and fresh questions [ATT-16].
|
|
199
213
|
involved: `is:open involves:@me updated:>=${since} sort:updated-desc ${scope}`,
|
|
200
214
|
// On my own issues a question nobody answered stays however old [ATT-11]. Newest first, so old ones go last.
|
|
@@ -206,7 +220,7 @@ export function searchVariables(config: AttentionConfig, now: Date): Record<Excl
|
|
|
206
220
|
};
|
|
207
221
|
}
|
|
208
222
|
|
|
209
|
-
// Who assigned and unassigned whom on PRs and issues that may have left my hands, by node id, a batch per request [
|
|
223
|
+
// Who assigned and unassigned whom on PRs and issues that may have left my hands, by node id, a batch per request [HIS-07, GH-01].
|
|
210
224
|
// The last events are enough: a handover is the latest change of hands.
|
|
211
225
|
export const ASSIGNMENT_BATCH = 20;
|
|
212
226
|
const ASSIGNMENT_EVENT = "createdAt actor { login } assignee { ... on User { login } ... on Bot { login } ... on Mannequin { login } }";
|
|
@@ -217,6 +231,18 @@ export function assignmentsQuery(ids: string[]): string {
|
|
|
217
231
|
return `query Assignments {\n${fields.join("\n")}\n}`;
|
|
218
232
|
}
|
|
219
233
|
|
|
234
|
+
// PRs Attention Span saw closed, by node id, a batch per request: only a state and a reopen event [HIS-07, GH-01].
|
|
235
|
+
export function reopenQuery(ids: string[]): string {
|
|
236
|
+
const fields = ids.map(
|
|
237
|
+
(id, index) => `a${index}: node(id: ${JSON.stringify(id)}) {
|
|
238
|
+
... on PullRequest { id number title url state repository { nameWithOwner }
|
|
239
|
+
timelineItems(itemTypes: [REOPENED_EVENT], last: 1) { nodes { ... on ReopenedEvent { createdAt actor { login } } } }
|
|
240
|
+
}
|
|
241
|
+
}`,
|
|
242
|
+
);
|
|
243
|
+
return `query Reopened {\n${fields.join("\n")}\n}`;
|
|
244
|
+
}
|
|
245
|
+
|
|
220
246
|
export function prKey(node: { repository: { nameWithOwner: string }; number: number }): string {
|
|
221
247
|
return `${node.repository.nameWithOwner}#${node.number}`;
|
|
222
248
|
}
|