@andrioid/paseo-attention-span 0.4.12 → 0.4.14
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 +81 -34
- package/client/icons.ts +7 -0
- package/client/next-up.tsx +3 -2
- package/client/sheet.tsx +74 -9
- package/client/ui.tsx +17 -0
- package/docs/architecture.md +12 -7
- 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-history-reviewed.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-waiting.png +0 -0
- package/docs/screenshots/phone-dark-doing.png +0 -0
- package/index.server.ts +1 -0
- package/package.json +1 -1
- package/requirements.yaml +4 -1
- package/server/changes.ts +197 -0
- package/server/classify.ts +6 -2
- package/server/fixture.ts +33 -0
- package/server/gh.ts +16 -4
- package/server/github-types.ts +41 -1
- package/server/queries.ts +33 -5
- package/server/service.ts +55 -6
- package/server/store.ts +12 -0
- package/server/view.ts +16 -6
- package/shared/attention.ts +15 -2
- package/shared/changes.ts +51 -0
- package/shared/rpc.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andrioid/paseo-attention-span",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.14",
|
|
4
4
|
"description": "For when your attention is spread thin: the GitHub issues and pull requests waiting on you, grouped by why, with one-tap Paseo sessions.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/requirements.yaml
CHANGED
|
@@ -37,6 +37,7 @@ functional:
|
|
|
37
37
|
ATT-18: see a calm, restful scene in Doing when nothing needs me, only once a refresh has confirmed it; so that a clear list feels like rest rather than a blank page, and calm never stands in for a check that failed or hasn't run.
|
|
38
38
|
ATT-19: tell at a glance what each person shown on an item is to it: someone I'm waiting on, who opened it, or whose comments are left to address, with an icon by their picture and the meaning in words when I point at it; so that a face and a time never leave me guessing.
|
|
39
39
|
ATT-20: tell which item a card is on every tab by its number first, then its repository with the repository's name standing out from its owner, which my own repositories leave out; so that cards from several repositories scan without reading each one in full.
|
|
40
|
+
ATT-21: see in Doing, below the work and not in its count, when someone else merged my PR, closed it without merging, took over or handed on my PR or an issue assigned to me, or unassigned me from one, each in a line like "merged by dave 2h ago" or "phil took over", until I tap Got it; so that I learn when others move my work without it changing what I have to do.
|
|
40
41
|
mentions:
|
|
41
42
|
As a developer, I can:
|
|
42
43
|
MEN-01: see open threads where a person mentioned me and is still waiting for my response; so that I only hear about mentions when someone is waiting for me.
|
|
@@ -109,8 +110,10 @@ functional:
|
|
|
109
110
|
As a developer, I can:
|
|
110
111
|
HIS-01: see the issues and pull requests I finished, grouped by week; so that I can tell others what I got done.
|
|
111
112
|
HIS-02: see pull requests I reviewed that merged, apart from my own work; so that I can tell others what I got done.
|
|
112
|
-
HIS-03: copy a week's finished work as a Markdown list of links; so that reporting progress is one paste.
|
|
113
|
+
HIS-03: copy a week's finished work as a Markdown list of links, and the pull requests I reviewed that week as a list of their own; so that reporting progress is one paste.
|
|
113
114
|
HIS-04: see what kind of work each finished item was, bug, feature or task, from its issue type, else its labels, else a Conventional Commit title like "fix: …", on its card and leading its copied line like "- 🐞 [title](link)", with PRs of no kind led by 🔀 and issues closed as not planned left out of the copy; so that a busy week's report skims at a glance in any repo.
|
|
115
|
+
HIS-05: see who merged a PR of mine when it wasn't me, as "merged 2h ago by dave", with its copied line unchanged; so that I know when someone else shipped my work.
|
|
116
|
+
HIS-06: see each week's PRs of mine that someone else closed without merging, and work taken out of my hands, apart under "Closed or handed off" and out of the week's copy, even once its new owner merges it; so that my report doesn't claim work that left my hands, and I can still see where it went.
|
|
114
117
|
feedback:
|
|
115
118
|
As a developer, I can:
|
|
116
119
|
FB-01: tell the Attention Span project what to improve from the bottom of any tab, picking a problem, an idea or that I like it, with an agent that asks until it's clear, checks it against what's planned and already reported, and files it as an issue or a discussion, saying which and why, only once I approve the draft; so that feedback costs a minute and lands where it can be acted on or talked through.
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { isHandover, type OthersChange } from "../shared/changes";
|
|
2
|
+
import type { Item } from "../shared/attention";
|
|
3
|
+
import type { AssignmentEvent, AssignmentSubject, EndedPullRequest, LiveResult } from "./github-types";
|
|
4
|
+
import { prKey } from "./queries";
|
|
5
|
+
|
|
6
|
+
// Changed by others: what someone else did to my work, kept between refreshes so a note stays until Got it, and so History
|
|
7
|
+
// can list work that left my hands [ATT-21, HIS-06]. Pure, so every rule is testable; service.ts does the fetching.
|
|
8
|
+
|
|
9
|
+
export interface ChangeLedger {
|
|
10
|
+
events: OthersChange[];
|
|
11
|
+
// Events I've tapped Got it on.
|
|
12
|
+
gotIt: string[];
|
|
13
|
+
// Issue node id -> key, from the last assigned search that worked. Null until the first, so nothing counts as gone then:
|
|
14
|
+
// only issues seen assigned to me can be noticed leaving.
|
|
15
|
+
assigned: Record<string, string> | null;
|
|
16
|
+
// PR node id -> its assignees when last looked up, so each change of hands costs one lookup [GH-01].
|
|
17
|
+
handed: Record<string, string>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const EMPTY_LEDGER: ChangeLedger = { events: [], gotIt: [], assigned: null, handed: {} };
|
|
21
|
+
|
|
22
|
+
type Data = Pick<LiveResult, "mine" | "assigned" | "ended">;
|
|
23
|
+
// A lookup's answer per node id: the subject, null when it's gone or hidden, missing when the lookup failed.
|
|
24
|
+
export type Lookups = Map<string, AssignmentSubject | null>;
|
|
25
|
+
|
|
26
|
+
const same = (a: string | null | undefined, b: string | null | undefined) => !!a && !!b && a.toLowerCase() === b.toLowerCase();
|
|
27
|
+
const present = <T>(nodes: (T | null | undefined)[]) => nodes.filter((node): node is T => !!node && Object.keys(node).length > 0);
|
|
28
|
+
const logins = (subject: { assignees: { nodes: { login: string }[] } }) => subject.assignees.nodes.map((node) => node.login);
|
|
29
|
+
// Assigned to someone, and not to me: out of my hands [PRS-08]. A PR of mine with nobody assigned is still mine.
|
|
30
|
+
const handedOver = (subject: { assignees: { nodes: { login: string }[] } }, me: string) => {
|
|
31
|
+
const assignees = logins(subject);
|
|
32
|
+
return assignees.length > 0 && !assignees.some((login) => same(login, me));
|
|
33
|
+
};
|
|
34
|
+
const signature = (subject: { assignees: { nodes: { login: string }[] } }) =>
|
|
35
|
+
logins(subject)
|
|
36
|
+
.map((login) => login.toLowerCase())
|
|
37
|
+
.sort()
|
|
38
|
+
.join(",");
|
|
39
|
+
|
|
40
|
+
// My PRs, open or closed lately, that someone else has: each looked up once per change of hands.
|
|
41
|
+
function handedPrs(data: Data, me: string): { id: string; signature: string }[] {
|
|
42
|
+
const prs = [...present(data.mine.nodes), ...present(data.ended.nodes)].filter((pr) => pr.id && handedOver(pr, me));
|
|
43
|
+
return [...new Map(prs.map((pr) => [pr.id, { id: pr.id, signature: signature(pr) }])).values()];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const assignedNow = (data: Data): Record<string, string> =>
|
|
47
|
+
Object.fromEntries(present(data.assigned.nodes).flatMap((issue) => (issue.id ? [[issue.id, prKey(issue)]] : [])));
|
|
48
|
+
|
|
49
|
+
// What to look up: PRs whose hands changed since last looked, and issues no longer in my assigned search. An issue can leave
|
|
50
|
+
// the search for many reasons (search lag, a coverage change, its 50 results), so each is checked before anything is said.
|
|
51
|
+
export function changeCandidates(ledger: ChangeLedger, data: Data, me: string): string[] {
|
|
52
|
+
const prs = handedPrs(data, me)
|
|
53
|
+
.filter((pr) => ledger.handed[pr.id] !== pr.signature)
|
|
54
|
+
.map((pr) => pr.id);
|
|
55
|
+
const now = assignedNow(data);
|
|
56
|
+
const gone = ledger.assigned ? Object.keys(ledger.assigned).filter((id) => !(id in now)) : [];
|
|
57
|
+
return [...new Set([...prs, ...gone])];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const isAssignment = (node: AssignmentEvent | Record<string, never>): node is AssignmentEvent => "__typename" in node && "createdAt" in node;
|
|
61
|
+
|
|
62
|
+
// Who took it out of my hands, from GitHub's assign and unassign events [ATT-21]. Null when it's still mine, it was my own
|
|
63
|
+
// doing, or the events don't show it. An issue closed by now stays silent: issue closes are no big deal.
|
|
64
|
+
// The new owner is the latest of the current assignees to be assigned. It left my hands with whichever came last of my
|
|
65
|
+
// removal and the new owner's assignment, and whoever did that is named: "phil took over" when that's the new owner, else
|
|
66
|
+
// "dave handed it to carol". So a PR I unassigned myself from is still mine until someone else takes it.
|
|
67
|
+
export function handover(subject: AssignmentSubject, me: string): OthersChange | null {
|
|
68
|
+
const assignees = logins(subject);
|
|
69
|
+
if (assignees.some((login) => same(login, me))) return null;
|
|
70
|
+
if (subject.__typename === "Issue" && subject.state !== "OPEN") return null;
|
|
71
|
+
const events = present(subject.timelineItems.nodes)
|
|
72
|
+
.filter(isAssignment)
|
|
73
|
+
.sort((a, b) => a.createdAt.localeCompare(b.createdAt));
|
|
74
|
+
const removal = events.findLast((event) => event.__typename === "UnassignedEvent" && same(event.assignee?.login, me));
|
|
75
|
+
const given = events.findLast((event) => event.__typename === "AssignedEvent" && assignees.some((login) => same(login, event.assignee?.login)));
|
|
76
|
+
const to = given?.assignee?.login ?? assignees[0];
|
|
77
|
+
// A PR of mine with nobody on it is mine; an issue needs proof I was taken off it.
|
|
78
|
+
if (subject.__typename === "PullRequest" ? !to : !removal) return null;
|
|
79
|
+
const by = removal && given && to ? (given.createdAt > removal.createdAt ? given : removal) : (removal ?? given);
|
|
80
|
+
if (!by || same(by.actor?.login, me)) return null;
|
|
81
|
+
const actor = by.actor?.login;
|
|
82
|
+
const kind = !to ? "unassigned" : same(actor, to) ? "took_over" : "handed";
|
|
83
|
+
return change(subject, subject.__typename === "PullRequest" ? "pr" : "issue", kind, by.createdAt, actor, to);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// A PR of mine someone else merged or closed unmerged [ATT-21]. Whether it left my hands before it ended is up to nextLedger,
|
|
87
|
+
// which knows when that happened.
|
|
88
|
+
export function ended(pr: EndedPullRequest, me: string): OthersChange | null {
|
|
89
|
+
if (pr.merged) return same(pr.mergedBy?.login, me) || !pr.mergedAt ? null : change(pr, "pr", "merged", pr.mergedAt, pr.mergedBy?.login);
|
|
90
|
+
const closer = pr.timelineItems.nodes.at(-1)?.actor?.login;
|
|
91
|
+
return same(closer, me) ? null : change(pr, "pr", "closed", pr.closedAt, closer);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function change(
|
|
95
|
+
subject: { id: string; number: number; title: string; url: string; repository: { nameWithOwner: string } },
|
|
96
|
+
kind: "pr" | "issue",
|
|
97
|
+
what: OthersChange["kind"],
|
|
98
|
+
at: string,
|
|
99
|
+
actor?: string,
|
|
100
|
+
to?: string,
|
|
101
|
+
): OthersChange {
|
|
102
|
+
return {
|
|
103
|
+
id: `${what}:${subject.id}:${at}`,
|
|
104
|
+
kind: what,
|
|
105
|
+
subjectId: subject.id,
|
|
106
|
+
subject: kind,
|
|
107
|
+
key: prKey(subject),
|
|
108
|
+
repo: subject.repository.nameWithOwner,
|
|
109
|
+
number: subject.number,
|
|
110
|
+
title: subject.title,
|
|
111
|
+
url: subject.url,
|
|
112
|
+
...(actor ? { actor } : {}),
|
|
113
|
+
...(to ? { to } : {}),
|
|
114
|
+
at,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 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. What couldn't be
|
|
120
|
+
// looked up is left to retry next time.
|
|
121
|
+
export function nextLedger(ledger: ChangeLedger, data: Data, me: string, lookups: Lookups, now: Date, windowDays: number, keepDays: number): ChangeLedger {
|
|
122
|
+
const since = (days: number) => new Date(now.getTime() - days * 86_400_000).toISOString();
|
|
123
|
+
const found: OthersChange[] = [];
|
|
124
|
+
const endedAt = new Map(present(data.ended.nodes).map((pr) => [pr.id, pr.mergedAt ?? pr.closedAt]));
|
|
125
|
+
// Assigning a PR once it's merged or closed hands nothing over.
|
|
126
|
+
const handovers = [...lookups.values()]
|
|
127
|
+
.map((subject) => (subject ? handover(subject, me) : null))
|
|
128
|
+
.filter((event): event is OthersChange => !!event && !(endedAt.has(event.subjectId) && event.at > endedAt.get(event.subjectId)!));
|
|
129
|
+
found.push(...handovers);
|
|
130
|
+
const handedAt = (id: string) => [...ledger.events, ...handovers].filter((event) => isHandover(event) && event.subjectId === id).map((event) => event.at);
|
|
131
|
+
for (const pr of present(data.ended.nodes)) {
|
|
132
|
+
// 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
|
+
if (handedOver(pr, me) && !lookups.has(pr.id) && ledger.handed[pr.id] !== signature(pr)) continue;
|
|
134
|
+
const event = ended(pr, me);
|
|
135
|
+
// One that left my hands before it ended was a handover, not my work merged or closed.
|
|
136
|
+
if (event && !handedAt(pr.id).some((at) => at <= event.at)) found.push(event);
|
|
137
|
+
}
|
|
138
|
+
// Mine again: my PRs with nobody else on them, and issues assigned to me.
|
|
139
|
+
const mineNow = new Set([...present(data.mine.nodes).filter((pr) => !handedOver(pr, me)).map((pr) => pr.id), ...Object.keys(assignedNow(data))]);
|
|
140
|
+
const known = new Set(ledger.events.map((event) => event.id));
|
|
141
|
+
const fresh = found.filter((event) => !known.has(event.id) && event.at >= since(windowDays));
|
|
142
|
+
const events = [...ledger.events, ...fresh]
|
|
143
|
+
.filter((event) => !(isHandover(event) && mineNow.has(event.subjectId)))
|
|
144
|
+
.filter((event) => event.at >= since(keepDays))
|
|
145
|
+
.sort((a, b) => b.at.localeCompare(a.at));
|
|
146
|
+
const ids = new Set(events.map((event) => event.id));
|
|
147
|
+
|
|
148
|
+
// Issues that left my search and couldn't be looked up stay, so they're checked again.
|
|
149
|
+
const assigned = assignedNow(data);
|
|
150
|
+
if (ledger.assigned) for (const [id, key] of Object.entries(ledger.assigned)) if (!(id in assigned) && !lookups.has(id)) assigned[id] = key;
|
|
151
|
+
// A PR's hands are settled once looked up; one that failed keeps its old signature, so it's asked again.
|
|
152
|
+
const handed: Record<string, string> = {};
|
|
153
|
+
for (const pr of handedPrs(data, me)) {
|
|
154
|
+
const before = ledger.handed[pr.id];
|
|
155
|
+
if (before !== undefined || lookups.has(pr.id)) handed[pr.id] = lookups.has(pr.id) ? pr.signature : before;
|
|
156
|
+
}
|
|
157
|
+
return { events, gotIt: ledger.gotIt.filter((id) => ids.has(id)), assigned, handed };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// What a refresh found, with the Got its tapped while it ran, as those changed the ledger after the refresh read it [ATT-21].
|
|
161
|
+
export function withGotIt(next: ChangeLedger, gotIt: string[]): ChangeLedger {
|
|
162
|
+
const ids = new Set(next.events.map((event) => event.id));
|
|
163
|
+
return { ...next, gotIt: gotIt.filter((id) => ids.has(id)) };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// The ledger as cards: Doing's notes not yet cleared, within `windowDays`, newest first [ATT-21]; History's work closed
|
|
167
|
+
// unmerged by others or taken out of my hands, from `historySince` [HIS-06].
|
|
168
|
+
export function changeItems(ledger: ChangeLedger, now: Date, windowDays: number, historySince: string): { doing: Item[]; history: Item[] } {
|
|
169
|
+
const since = new Date(now.getTime() - windowDays * 86_400_000).toISOString();
|
|
170
|
+
const gotIt = new Set(ledger.gotIt);
|
|
171
|
+
const base = (change: OthersChange): Omit<Item, "key" | "section"> => ({
|
|
172
|
+
kind: change.subject,
|
|
173
|
+
draft: false,
|
|
174
|
+
repo: change.repo,
|
|
175
|
+
number: change.number,
|
|
176
|
+
title: change.title,
|
|
177
|
+
url: change.url,
|
|
178
|
+
chips: [],
|
|
179
|
+
actions: [],
|
|
180
|
+
children: [],
|
|
181
|
+
target: { kind: change.subject, repo: change.repo, number: change.number, title: change.title, url: change.url },
|
|
182
|
+
othersActivityAt: change.at,
|
|
183
|
+
change,
|
|
184
|
+
});
|
|
185
|
+
const doing = ledger.events
|
|
186
|
+
.filter((change) => !gotIt.has(change.id) && change.at >= since)
|
|
187
|
+
.map((change): Item => ({ ...base(change), key: `change:${change.id}`, section: "changed", actions: ["got_it"] }));
|
|
188
|
+
const history = ledger.events
|
|
189
|
+
.filter((change) => change.kind !== "merged" && change.at >= historySince)
|
|
190
|
+
.map((change): Item => ({ ...base(change), key: `handed:${change.id}`, section: "handed_off", closedAt: change.at }));
|
|
191
|
+
return { doing, history };
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Keys of my PRs and issues that left my hands: a merge by their new owner isn't my finished work [HIS-06].
|
|
195
|
+
export function handedKeys(ledger: ChangeLedger): Set<string> {
|
|
196
|
+
return new Set(ledger.events.filter(isHandover).map((event) => event.key));
|
|
197
|
+
}
|
package/server/classify.ts
CHANGED
|
@@ -426,6 +426,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
426
426
|
// My merged PRs under the closed issues they worked on, closed issues, and reviews [HIS-01, HIS-02, ATT-03].
|
|
427
427
|
export function classifyHistory(data: HistoryResult): Item[] {
|
|
428
428
|
const items: Item[] = [];
|
|
429
|
+
const me = data.viewer?.login.toLowerCase();
|
|
429
430
|
const closed = new Map<string, Item>();
|
|
430
431
|
// What kind of work it was, on the card and its copied line [HIS-04].
|
|
431
432
|
const kinded = (item: Item, node: { title: string; labels?: { nodes: { name: string }[] }; issueType?: { name: string } | null }): Item => {
|
|
@@ -443,8 +444,11 @@ export function classifyHistory(data: HistoryResult): Item[] {
|
|
|
443
444
|
// Each merged PR on its own: its branches are gone, so it can't be put back in its stack [ATT-03].
|
|
444
445
|
const linked = { repo: pr.repository.nameWithOwner, body: pr.body, linked: pr.closingIssuesReferences.nodes.map(prKey) };
|
|
445
446
|
const issue = closed.get(issueFor([linked], (key) => closed.has(key)) ?? "");
|
|
446
|
-
|
|
447
|
-
|
|
447
|
+
// Who merged it, when it wasn't me, alone or under its issue [HIS-05].
|
|
448
|
+
const by = pr.mergedBy?.login;
|
|
449
|
+
const mergedBy = by && me && by.toLowerCase() !== me ? { mergedBy: by } : {};
|
|
450
|
+
if (issue) issue.children.push({ key: prKey(pr), number: pr.number, title: pr.title, url: pr.url, draft: false, chips: [], attention: false, ...mergedBy });
|
|
451
|
+
else items.push(kinded({ ...plain(pr, "pr", "done"), closedAt: pr.mergedAt, ...mergedBy }, pr));
|
|
448
452
|
}
|
|
449
453
|
for (const pr of compact(data.reviewed.nodes)) items.push(kinded({ ...plain(pr, "pr", "reviewed"), closedAt: pr.mergedAt, person: author(pr.author, pr.mergedAt) }, pr));
|
|
450
454
|
return items.sort(order);
|
package/server/fixture.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AgentSummary, GithubColor, ItemDetails, Reviewer, ReviewerChoices, Target } from "../shared/attention";
|
|
2
|
+
import type { OthersChange } from "../shared/changes";
|
|
2
3
|
import type { SessionKind } from "../shared/config";
|
|
3
4
|
import type { IssueField } from "../shared/setup";
|
|
4
5
|
import type { Actor, Comment, Details, IssueNode, MentionNode, PickableNode, PullRequestNode, SearchResult } from "./github-types";
|
|
@@ -134,6 +135,7 @@ export function builders(now: Date) {
|
|
|
134
135
|
merged: nodes("merged") as SearchResult["merged"],
|
|
135
136
|
reviewed: nodes("reviewed") as SearchResult["reviewed"],
|
|
136
137
|
closed: nodes("closed") as SearchResult["closed"],
|
|
138
|
+
ended: nodes("ended") as SearchResult["ended"],
|
|
137
139
|
};
|
|
138
140
|
}
|
|
139
141
|
|
|
@@ -152,6 +154,8 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
152
154
|
title,
|
|
153
155
|
url: `https://github.com/${REPO}/pull/${number}`,
|
|
154
156
|
mergedAt: daysAgo(days),
|
|
157
|
+
// Someone else merged one of them [HIS-05].
|
|
158
|
+
mergedBy: { login: number === 177 ? "dave" : number === 179 ? "carol" : "me" },
|
|
155
159
|
repository,
|
|
156
160
|
labels: labels(...names),
|
|
157
161
|
closingIssuesReferences: { nodes: closesIssue ? [{ number: closesIssue, repository }] : [] },
|
|
@@ -282,6 +286,8 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
282
286
|
merged(172, "Fix VAT on credit notes", 3, undefined, "bug"),
|
|
283
287
|
merged(177, "chore: bump the build image", 4),
|
|
284
288
|
merged(178, "Tidy the settings screen", 5),
|
|
289
|
+
// Handed over to carol before she merged it, so it isn't listed as mine [HIS-06].
|
|
290
|
+
merged(179, "Move invoices to the new queue", 1),
|
|
285
291
|
merged(173, "Speed up the order list", 9, 174),
|
|
286
292
|
merged(175, "Remove the old importer", 16),
|
|
287
293
|
],
|
|
@@ -310,6 +316,33 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
310
316
|
};
|
|
311
317
|
}
|
|
312
318
|
|
|
319
|
+
// What others did to my work, one of each kind, as the ledger keeps them [ATT-21, HIS-06]. #179 was handed over, then merged
|
|
320
|
+
// by its new owner, so History doesn't count it as mine.
|
|
321
|
+
export function fixtureChanges(now: Date): OthersChange[] {
|
|
322
|
+
const hoursAgo = (hours: number) => new Date(now.getTime() - hours * 3_600_000).toISOString();
|
|
323
|
+
const event = (kind: OthersChange["kind"], subject: "pr" | "issue", number: number, title: string, hours: number, actor?: string, to?: string): OthersChange => ({
|
|
324
|
+
id: `${kind}:F_${number}:${hoursAgo(hours)}`,
|
|
325
|
+
kind,
|
|
326
|
+
subjectId: `F_${number}`,
|
|
327
|
+
subject,
|
|
328
|
+
key: `${REPO}#${number}`,
|
|
329
|
+
repo: REPO,
|
|
330
|
+
number,
|
|
331
|
+
title,
|
|
332
|
+
url: `https://github.com/${REPO}/${subject === "pr" ? "pull" : "issues"}/${number}`,
|
|
333
|
+
...(actor ? { actor } : {}),
|
|
334
|
+
...(to ? { to } : {}),
|
|
335
|
+
at: hoursAgo(hours),
|
|
336
|
+
});
|
|
337
|
+
return [
|
|
338
|
+
event("merged", "pr", 183, "Retry failed webhooks", 2, "dave"),
|
|
339
|
+
event("took_over", "pr", 186, "Split the invoice PDF job", 5, "phil", "phil"),
|
|
340
|
+
event("closed", "pr", 169, "Cache exchange rates", 26, "alice"),
|
|
341
|
+
event("handed", "pr", 179, "Move invoices to the new queue", 50, "dave", "carol"),
|
|
342
|
+
event("unassigned", "issue", 160, "Refunds skip the ledger", 74, "bob"),
|
|
343
|
+
];
|
|
344
|
+
}
|
|
345
|
+
|
|
313
346
|
// Sessions the preview shows as started from items: working, needs me, failed, idle.
|
|
314
347
|
// 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.
|
|
315
348
|
// #113 waits on CI while its Fix CI session works, though Fix CI isn't one of its actions any more.
|
package/server/gh.ts
CHANGED
|
@@ -34,16 +34,28 @@ export function runGh(args: string[], input?: string, { timeoutMs }: { timeoutMs
|
|
|
34
34
|
|
|
35
35
|
// GitHub's answer with its errors kept beside whatever data resolved, for callers that must tell a partial answer from a
|
|
36
36
|
// whole one. Throws only when nothing came back at all.
|
|
37
|
-
|
|
37
|
+
// `failures` says where each error was and what kind, for callers that tell a node GitHub can't find from one it failed on.
|
|
38
|
+
export interface GraphqlFailure {
|
|
39
|
+
message: string;
|
|
40
|
+
type?: string;
|
|
41
|
+
path?: (string | number)[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function graphqlResult<T>(
|
|
45
|
+
query: string,
|
|
46
|
+
variables: Record<string, unknown> = {},
|
|
47
|
+
options: { timeoutMs?: number } = {},
|
|
48
|
+
): Promise<{ data: T | null; errors: string[]; failures: GraphqlFailure[] }> {
|
|
38
49
|
const { code, stdout, stderr } = await runGh(["api", "graphql", "--input", "-"], JSON.stringify({ query, variables }), options);
|
|
39
|
-
let parsed: { data?: T | null; errors?:
|
|
50
|
+
let parsed: { data?: T | null; errors?: GraphqlFailure[] } | undefined;
|
|
40
51
|
try {
|
|
41
52
|
parsed = JSON.parse(stdout);
|
|
42
53
|
} catch {
|
|
43
54
|
// Not JSON: an auth or network failure.
|
|
44
55
|
}
|
|
45
|
-
const
|
|
46
|
-
|
|
56
|
+
const failures = parsed?.errors ?? [];
|
|
57
|
+
const errors = failures.map((error) => error.message);
|
|
58
|
+
if (parsed?.data) return { data: parsed.data, errors, failures };
|
|
47
59
|
throw new Error(errors.join("; ") || stderr.trim() || `gh exited with ${code}`);
|
|
48
60
|
}
|
|
49
61
|
|
package/server/github-types.ts
CHANGED
|
@@ -96,6 +96,8 @@ export interface IssueNode {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
export interface PickableNode {
|
|
99
|
+
// The issue's node id, which a transfer keeps [ATT-21].
|
|
100
|
+
id?: string;
|
|
99
101
|
number: number;
|
|
100
102
|
title: string;
|
|
101
103
|
url: string;
|
|
@@ -128,6 +130,42 @@ export interface LiveResult {
|
|
|
128
130
|
asked: Nodes<IssueNode>;
|
|
129
131
|
assigned: Nodes<PickableNode>;
|
|
130
132
|
unclaimed: Nodes<PickableNode>;
|
|
133
|
+
// My PRs closed lately [ATT-21].
|
|
134
|
+
ended: Nodes<EndedPullRequest>;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface EndedPullRequest {
|
|
138
|
+
id: string;
|
|
139
|
+
number: number;
|
|
140
|
+
title: string;
|
|
141
|
+
url: string;
|
|
142
|
+
merged: boolean;
|
|
143
|
+
mergedAt: string | null;
|
|
144
|
+
closedAt: string;
|
|
145
|
+
repository: Repo;
|
|
146
|
+
mergedBy: { login: string } | null;
|
|
147
|
+
assignees: Nodes<{ login: string }>;
|
|
148
|
+
timelineItems: Nodes<{ createdAt?: string; actor?: { login: string } | null }>;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Who assigned or unassigned whom; actor and assignee are null for a deleted account [ATT-21].
|
|
152
|
+
export interface AssignmentEvent {
|
|
153
|
+
__typename: "AssignedEvent" | "UnassignedEvent";
|
|
154
|
+
createdAt: string;
|
|
155
|
+
actor: { login: string } | null;
|
|
156
|
+
assignee: { login?: string } | null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface AssignmentSubject {
|
|
160
|
+
__typename: "PullRequest" | "Issue";
|
|
161
|
+
id: string;
|
|
162
|
+
number: number;
|
|
163
|
+
title: string;
|
|
164
|
+
url: string;
|
|
165
|
+
state: "OPEN" | "CLOSED" | "MERGED";
|
|
166
|
+
repository: Repo;
|
|
167
|
+
assignees: Nodes<{ login: string }>;
|
|
168
|
+
timelineItems: Nodes<AssignmentEvent | Record<string, never>>;
|
|
131
169
|
}
|
|
132
170
|
|
|
133
171
|
// One request for all three [HIS-01, HIS-02].
|
|
@@ -135,7 +173,9 @@ export interface LiveResult {
|
|
|
135
173
|
type Labels = { labels?: Nodes<{ name: string }> };
|
|
136
174
|
|
|
137
175
|
export interface HistoryResult {
|
|
138
|
-
|
|
176
|
+
// Who I am, to tell a merge by someone else [HIS-05]; missing in older fixtures.
|
|
177
|
+
viewer?: { login: string; id: string };
|
|
178
|
+
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>;
|
|
139
179
|
reviewed: Nodes<{ number: number; title: string; url: string; mergedAt: string; repository: Repo; author: Actor | null } & Labels>;
|
|
140
180
|
closed: Nodes<{ number: number; title: string; url: string; closedAt: string; stateReason: string | null; repository: Repo; issueType?: { name: string } | null } & Labels>;
|
|
141
181
|
}
|
package/server/queries.ts
CHANGED
|
@@ -28,9 +28,20 @@ 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 [ATT-21]. Who closed one comes from its last
|
|
32
|
+
// close event; assignees tell a PR handed over before it closed [PRS-08].
|
|
33
|
+
ended: {
|
|
34
|
+
first: 50,
|
|
35
|
+
nodes: `... on PullRequest {
|
|
36
|
+
id number title url merged mergedAt closedAt repository { nameWithOwner } mergedBy { login }
|
|
37
|
+
assignees(first: 10) { nodes { login } }
|
|
38
|
+
timelineItems(itemTypes: [CLOSED_EVENT], last: 1) { nodes { ... on ClosedEvent { createdAt actor { login } } } }
|
|
39
|
+
}`,
|
|
40
|
+
},
|
|
41
|
+
// Who merged it, when it wasn't me [HIS-05].
|
|
31
42
|
merged: {
|
|
32
43
|
first: 100,
|
|
33
|
-
nodes: "... on PullRequest { number title url body mergedAt repository { nameWithOwner } labels(first: 20) { nodes { name } } closingIssuesReferences(first: 3) { nodes { number repository { nameWithOwner } } } }",
|
|
44
|
+
nodes: "... on PullRequest { number title url body mergedAt mergedBy { login } repository { nameWithOwner } labels(first: 20) { nodes { name } } closingIssuesReferences(first: 3) { nodes { number repository { nameWithOwner } } } }",
|
|
34
45
|
},
|
|
35
46
|
reviewed: { first: 100, nodes: "... on PullRequest { number title url mergedAt repository { nameWithOwner } author { ...author } labels(first: 20) { nodes { name } } }" },
|
|
36
47
|
// Labels and type say what kind of work each was [HIS-04].
|
|
@@ -39,7 +50,7 @@ const SEARCHES = {
|
|
|
39
50
|
export type SearchName = keyof typeof SEARCHES;
|
|
40
51
|
|
|
41
52
|
// Doing, Waiting and Next up. History has its own, slower schedule.
|
|
42
|
-
export const LIVE_SEARCHES = ["mine", "reviews", "mentions", "involved", "asked", "assigned", "unclaimed"] as const;
|
|
53
|
+
export const LIVE_SEARCHES = ["mine", "reviews", "mentions", "involved", "asked", "assigned", "unclaimed", "ended"] as const;
|
|
43
54
|
export const HISTORY_SEARCHES = ["merged", "reviewed", "closed"] as const;
|
|
44
55
|
|
|
45
56
|
const FRAGMENTS: Record<string, string> = {
|
|
@@ -51,7 +62,7 @@ const FRAGMENTS: Record<string, string> = {
|
|
|
51
62
|
... on PullRequestReviewComment { id url reactionGroups { viewerHasReacted } }
|
|
52
63
|
}`,
|
|
53
64
|
pickable: `fragment pickable on Issue {
|
|
54
|
-
number title url createdAt
|
|
65
|
+
id number title url createdAt
|
|
55
66
|
repository { nameWithOwner isFork defaultBranchRef { name } }
|
|
56
67
|
issueType { name }
|
|
57
68
|
issueFieldValues(first: 20) { nodes { ... on IssueFieldSingleSelectValue { name field { ... on IssueFieldCommon { name } } } } }
|
|
@@ -125,6 +136,11 @@ function startOfWeek(now: Date): Date {
|
|
|
125
136
|
return monday;
|
|
126
137
|
}
|
|
127
138
|
|
|
139
|
+
// Where History starts: whole weeks, from a Monday, so the oldest week isn't cut short [HIS-01].
|
|
140
|
+
export function historySince(now: Date, weeks: number): string {
|
|
141
|
+
return new Date(startOfWeek(now).getTime() - (weeks - 1) * 7 * 86_400_000).toISOString();
|
|
142
|
+
}
|
|
143
|
+
|
|
128
144
|
// Where Next up looks for unclaimed issues [NXT-04, NXT-08]: one search per chosen source, so each issue says which
|
|
129
145
|
// sources found it and no query outgrows GitHub's limit [NXT-09]. Without sources, the configured orgs and repos,
|
|
130
146
|
// else my Paseo projects' repos. Never all of GitHub: unlike the other searches, this one isn't about me.
|
|
@@ -170,14 +186,15 @@ export function mergeUnclaimed(results: { source: string | null; nodes: (Pickabl
|
|
|
170
186
|
export function searchVariables(config: AttentionConfig, now: Date): Record<Exclude<SearchName, "unclaimed">, string> {
|
|
171
187
|
const scope = where(config.orgs, config.repos);
|
|
172
188
|
const since = isoDate(new Date(now.getTime() - config.mentionDays * 86_400_000));
|
|
173
|
-
|
|
174
|
-
const history = isoDate(new Date(startOfWeek(now).getTime() - (config.historyWeeks - 1) * 7 * 86_400_000));
|
|
189
|
+
const history = isoDate(new Date(historySince(now, config.historyWeeks)));
|
|
175
190
|
return {
|
|
176
191
|
mine: `is:pr is:open author:@me ${scope}`,
|
|
177
192
|
// By name only, not via a team [REV-01].
|
|
178
193
|
reviews: `is:pr is:open user-review-requested:@me ${scope}`,
|
|
179
194
|
mentions: `is:open mentions:@me updated:>=${since} ${scope}`,
|
|
180
195
|
assigned: `is:issue is:open assignee:@me ${scope}`,
|
|
196
|
+
// Within the window Changed by others catches up over [ATT-21].
|
|
197
|
+
ended: `is:pr is:closed author:@me closed:>=${since} sort:updated-desc ${scope}`,
|
|
181
198
|
// Threads I opened, commented on, was assigned or mentioned in, active lately: answers, and fresh questions [ATT-16].
|
|
182
199
|
involved: `is:open involves:@me updated:>=${since} sort:updated-desc ${scope}`,
|
|
183
200
|
// On my own issues a question nobody answered stays however old [ATT-11]. Newest first, so old ones go last.
|
|
@@ -189,6 +206,17 @@ export function searchVariables(config: AttentionConfig, now: Date): Record<Excl
|
|
|
189
206
|
};
|
|
190
207
|
}
|
|
191
208
|
|
|
209
|
+
// Who assigned and unassigned whom on PRs and issues that may have left my hands, by node id, a batch per request [ATT-21, GH-01].
|
|
210
|
+
// The last events are enough: a handover is the latest change of hands.
|
|
211
|
+
export const ASSIGNMENT_BATCH = 20;
|
|
212
|
+
const ASSIGNMENT_EVENT = "createdAt actor { login } assignee { ... on User { login } ... on Bot { login } ... on Mannequin { login } }";
|
|
213
|
+
export function assignmentsQuery(ids: string[]): string {
|
|
214
|
+
const subject = `id number title url state repository { nameWithOwner } assignees(first: 10) { nodes { login } }
|
|
215
|
+
timelineItems(itemTypes: [ASSIGNED_EVENT, UNASSIGNED_EVENT], last: 30) { nodes { __typename ... on AssignedEvent { ${ASSIGNMENT_EVENT} } ... on UnassignedEvent { ${ASSIGNMENT_EVENT} } } }`;
|
|
216
|
+
const fields = ids.map((id, index) => `a${index}: node(id: ${JSON.stringify(id)}) { __typename ... on PullRequest { ${subject} } ... on Issue { ${subject} } }`);
|
|
217
|
+
return `query Assignments {\n${fields.join("\n")}\n}`;
|
|
218
|
+
}
|
|
219
|
+
|
|
192
220
|
export function prKey(node: { repository: { nameWithOwner: string }; number: number }): string {
|
|
193
221
|
return `${node.repository.nameWithOwner}#${node.number}`;
|
|
194
222
|
}
|
package/server/service.ts
CHANGED
|
@@ -2,12 +2,15 @@ import type { Attention, AttentionView, FeedId, FeedStatus, GithubColor, Item, P
|
|
|
2
2
|
import type { PluginHandlerContext } from "@getpaseo/plugin/server";
|
|
3
3
|
import { AttentionConfig, type FieldRole, githubRepoOf, nextUpField } from "../shared/config";
|
|
4
4
|
import type { IssueField } from "../shared/setup";
|
|
5
|
+
import { changeCandidates, nextLedger, type Lookups, withGotIt } from "./changes";
|
|
5
6
|
import { classify, classifyHistory, issueBoardIds } from "./classify";
|
|
6
7
|
import { probeAnswer, projectsFailure, projectsWarning, searchWithProjects } from "./projects";
|
|
7
8
|
import { FIXTURE, graphql, graphqlResult } from "./gh";
|
|
8
|
-
import { fixture, FIXTURE_AGENTS, FIXTURE_ISSUE_FIELDS } from "./fixture";
|
|
9
|
-
import type { Details, HistoryResult, LinkedIssue, LiveResult, MergeStateStatus, PullRequestNode } from "./github-types";
|
|
9
|
+
import { fixture, FIXTURE_AGENTS, FIXTURE_ISSUE_FIELDS, fixtureChanges } from "./fixture";
|
|
10
|
+
import type { AssignmentSubject, Details, HistoryResult, LinkedIssue, LiveResult, MergeStateStatus, PullRequestNode } from "./github-types";
|
|
10
11
|
import {
|
|
12
|
+
ASSIGNMENT_BATCH,
|
|
13
|
+
assignmentsQuery,
|
|
11
14
|
type CheckContext,
|
|
12
15
|
detailsQuery,
|
|
13
16
|
HISTORY_SEARCHES,
|
|
@@ -118,6 +121,14 @@ export class AttentionService {
|
|
|
118
121
|
return this.view();
|
|
119
122
|
}
|
|
120
123
|
|
|
124
|
+
// Clears a Changed by others note, or brings it back for Undo; nothing changes on GitHub [ATT-21].
|
|
125
|
+
async gotIt(id: string, on: boolean): Promise<AttentionView> {
|
|
126
|
+
const gotIt = this.state.changes.gotIt.filter((other) => other !== id);
|
|
127
|
+
this.state.changes.gotIt = on && this.state.changes.events.some((event) => event.id === id) ? [...gotIt, id] : gotIt;
|
|
128
|
+
await this.save();
|
|
129
|
+
return this.view();
|
|
130
|
+
}
|
|
131
|
+
|
|
121
132
|
async restoreDismissed(): Promise<AttentionView> {
|
|
122
133
|
this.state.dismissed = {};
|
|
123
134
|
await this.save();
|
|
@@ -282,9 +293,41 @@ export class AttentionService {
|
|
|
282
293
|
const login = FIXTURE ? "me" : this.config.nextUp.mine ? await this.login() : null;
|
|
283
294
|
const unclaimed = unclaimedSearches(this.config, projectRepos, login);
|
|
284
295
|
const { data, details } = FIXTURE ? fixture(now) : await this.searchLive(now, unclaimed.searches);
|
|
296
|
+
await this.trackChanges(data, now);
|
|
285
297
|
return { ...classify({ data, details, config: this.config, now }), unclaimedFrom: unclaimed.from };
|
|
286
298
|
}
|
|
287
299
|
|
|
300
|
+
// What others did to my work since the last refresh [ATT-21]. Only PRs whose hands changed and issues that left my assigned
|
|
301
|
+
// search are looked up, a batch per request; a failed batch is asked again next time [GH-01]. Kept long enough for History.
|
|
302
|
+
private async trackChanges(data: LiveResult, now: Date): Promise<void> {
|
|
303
|
+
const ledger = this.state.changes;
|
|
304
|
+
if (FIXTURE) {
|
|
305
|
+
// Previews start each layout with a refresh, which brings the notes back: Got it would otherwise outlive a layout.
|
|
306
|
+
this.state.changes = { ...ledger, events: fixtureChanges(now), gotIt: [] };
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
const me = data.viewer.login;
|
|
310
|
+
const candidates = changeCandidates(ledger, data, me);
|
|
311
|
+
const lookups: Lookups = new Map();
|
|
312
|
+
for (let at = 0; at < candidates.length; at += ASSIGNMENT_BATCH) {
|
|
313
|
+
const batch = candidates.slice(at, at + ASSIGNMENT_BATCH);
|
|
314
|
+
try {
|
|
315
|
+
const { data: result, failures } = await graphqlResult<Record<string, AssignmentSubject | null>>(assignmentsQuery(batch));
|
|
316
|
+
batch.forEach((id, index) => {
|
|
317
|
+
const alias = `a${index}`;
|
|
318
|
+
// A node GitHub can't find is gone for good; one it failed on is asked again next refresh.
|
|
319
|
+
const failed = failures.some((failure) => failure.path?.[0] === alias && failure.type !== "NOT_FOUND");
|
|
320
|
+
if (!failed) lookups.set(id, result?.[alias] ?? null);
|
|
321
|
+
});
|
|
322
|
+
} catch (error) {
|
|
323
|
+
console.error("Couldn't look up who changed my work:", (error as Error).message);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
const keepDays = Math.max(this.config.mentionDays, this.config.historyWeeks * 7 + 7);
|
|
327
|
+
// A Got it tapped while this refresh ran still counts.
|
|
328
|
+
this.state.changes = withGotIt(nextLedger(ledger, data, me, lookups, now, this.config.mentionDays, keepDays), this.state.changes.gotIt);
|
|
329
|
+
}
|
|
330
|
+
|
|
288
331
|
// The account gh is signed in as, for My repos [NXT-04]. Asked once, unless the last fetch already says.
|
|
289
332
|
private async login(): Promise<string> {
|
|
290
333
|
return (this.state.live?.attention.login || (await graphql<{ viewer: { login: string } }>("{ viewer { login } }")).viewer.login);
|
|
@@ -306,7 +349,7 @@ export class AttentionService {
|
|
|
306
349
|
|
|
307
350
|
private async fetchHistory(now: Date): Promise<Item[]> {
|
|
308
351
|
if (FIXTURE) return classifyHistory(fixture(now).data);
|
|
309
|
-
return classifyHistory(await graphql<HistoryResult>(searchQuery(HISTORY_SEARCHES), this.variables(HISTORY_SEARCHES, now)));
|
|
352
|
+
return classifyHistory(await graphql<HistoryResult>(searchQuery(HISTORY_SEARCHES, true), this.variables(HISTORY_SEARCHES, now)));
|
|
310
353
|
}
|
|
311
354
|
|
|
312
355
|
// Whether the gh login may read projects, asked at most hourly, or now when Settings asks [NXT-12]. On only when GitHub
|
|
@@ -362,7 +405,7 @@ export class AttentionService {
|
|
|
362
405
|
};
|
|
363
406
|
const merge = (parts: Partial<LiveResult>[]) => Object.assign({}, ...parts) as LiveResult;
|
|
364
407
|
const forDetails = Promise.all([search("mine"), search("assigned"), searchUnclaimed()]);
|
|
365
|
-
const others = Promise.all([search("reviews"), search("mentions"), search("involved"), search("asked")]);
|
|
408
|
+
const others = Promise.all([search("reviews"), search("mentions"), search("involved"), search("asked"), search("ended")]);
|
|
366
409
|
const afterThem = forDetails.then((parts) => this.details(merge(parts), projects, problems));
|
|
367
410
|
try {
|
|
368
411
|
const [first, rest, details] = await Promise.all([forDetails, others, afterThem]);
|
|
@@ -507,7 +550,11 @@ export class AttentionService {
|
|
|
507
550
|
const now = Date.now();
|
|
508
551
|
const pending = Object.fromEntries(Object.entries(this.state.pending).filter(([, entry]) => isPending(entry, this.fetchedAt(), now)));
|
|
509
552
|
const shown = applyPending(this.state.live?.attention ?? null, this.state.history?.items ?? [], pending);
|
|
510
|
-
return buildView(
|
|
553
|
+
return buildView(
|
|
554
|
+
shown.attention,
|
|
555
|
+
shown.history,
|
|
556
|
+
this.state.dismissed,
|
|
557
|
+
{
|
|
511
558
|
feeds: { live: status("live"), history: status("history") },
|
|
512
559
|
scopes: this.state.scopes,
|
|
513
560
|
sources: this.state.sources,
|
|
@@ -515,6 +562,8 @@ export class AttentionService {
|
|
|
515
562
|
config: this.config,
|
|
516
563
|
pending: Object.keys(pending).length,
|
|
517
564
|
...(FIXTURE ? { fixtureAgents: FIXTURE_AGENTS } : {}),
|
|
518
|
-
|
|
565
|
+
},
|
|
566
|
+
this.state.changes,
|
|
567
|
+
);
|
|
519
568
|
}
|
|
520
569
|
}
|
package/server/store.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { join } from "node:path";
|
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { type Attention, type Item, type SectionId, SECTIONS } from "../shared/attention";
|
|
6
6
|
import { AttentionConfig, FIELD_ROLES, type FieldRole, sameField } from "../shared/config";
|
|
7
|
+
import type { OthersChange } from "../shared/changes";
|
|
8
|
+
import { EMPTY_LEDGER } from "./changes";
|
|
7
9
|
import type { Pending } from "./view";
|
|
8
10
|
|
|
9
11
|
// Local files in ~/.config/paseo-attention-span/ [PRIV-01].
|
|
@@ -29,6 +31,16 @@ export const State = z.object({
|
|
|
29
31
|
projectFilter: z.array(z.string()).default([]),
|
|
30
32
|
// The update notice put off with Not now, by the version it offered [UPD-01].
|
|
31
33
|
skippedUpdate: z.string().nullable().default(null).catch(null),
|
|
34
|
+
// What others did to my work, kept until Got it and for History [ATT-21, HIS-06].
|
|
35
|
+
changes: z
|
|
36
|
+
.object({
|
|
37
|
+
events: z.array(z.custom<OthersChange>((value) => typeof (value as OthersChange)?.id === "string" && typeof (value as OthersChange)?.at === "string")),
|
|
38
|
+
gotIt: z.array(z.string()),
|
|
39
|
+
assigned: z.record(z.string(), z.string()).nullable(),
|
|
40
|
+
handed: z.record(z.string(), z.string()),
|
|
41
|
+
})
|
|
42
|
+
.default(EMPTY_LEDGER)
|
|
43
|
+
.catch(EMPTY_LEDGER),
|
|
32
44
|
// My Paseo projects' GitHub repos when last listed, for refreshes before the app has connected [NXT-08].
|
|
33
45
|
projectRepos: z.array(z.string()).default([]),
|
|
34
46
|
// The last fetch of each feed. A cache from an older version is dropped rather than shown wrong, like one with an item in a
|