@andrioid/paseo-attention-span 0.4.14 → 0.6.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 +13 -5
- package/README.md +2 -2
- package/client/attention-screen.tsx +140 -143
- package/client/card.tsx +4 -2
- package/client/history.tsx +189 -0
- package/client/icons.ts +3 -1
- package/client/mark.ts +19 -0
- package/client/next-up.tsx +16 -2
- package/client/sessions.ts +50 -3
- package/client/still.tsx +70 -27
- 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-setup.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 +9 -3
- package/requirements.yaml +13 -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 +71 -12
- package/server/github-types.ts +29 -5
- package/server/queries.ts +33 -7
- package/server/service.ts +90 -19
- 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 +29 -7
- package/shared/wrap-up.ts +126 -0
- package/docs/screenshots/desktop-dark-history-reviewed.png +0 -0
package/server/fixture.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
1
3
|
import type { AgentSummary, GithubColor, ItemDetails, Reviewer, ReviewerChoices, Target } from "../shared/attention";
|
|
2
4
|
import type { OthersChange } from "../shared/changes";
|
|
3
5
|
import type { SessionKind } from "../shared/config";
|
|
4
6
|
import type { IssueField } from "../shared/setup";
|
|
5
7
|
import type { Actor, Comment, Details, IssueNode, MentionNode, PickableNode, PullRequestNode, SearchResult } from "./github-types";
|
|
8
|
+
import { DIR } from "./store";
|
|
6
9
|
|
|
7
10
|
// Made-up GitHub data for tests and for previews without GitHub (PASEO_ATTENTION_SPAN_FIXTURE=1).
|
|
8
11
|
|
|
@@ -136,6 +139,7 @@ export function builders(now: Date) {
|
|
|
136
139
|
reviewed: nodes("reviewed") as SearchResult["reviewed"],
|
|
137
140
|
closed: nodes("closed") as SearchResult["closed"],
|
|
138
141
|
ended: nodes("ended") as SearchResult["ended"],
|
|
142
|
+
closedIssues: nodes("closedIssues") as SearchResult["closedIssues"],
|
|
139
143
|
};
|
|
140
144
|
}
|
|
141
145
|
|
|
@@ -155,7 +159,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
155
159
|
url: `https://github.com/${REPO}/pull/${number}`,
|
|
156
160
|
mergedAt: daysAgo(days),
|
|
157
161
|
// Someone else merged one of them [HIS-05].
|
|
158
|
-
mergedBy: { login: number === 177 ? "dave" : number === 179 ? "carol" : "me" },
|
|
162
|
+
mergedBy: { login: number === 177 || number === 183 ? "dave" : number === 179 ? "carol" : "me" },
|
|
159
163
|
repository,
|
|
160
164
|
labels: labels(...names),
|
|
161
165
|
closingIssuesReferences: { nodes: closesIssue ? [{ number: closesIssue, repository }] : [] },
|
|
@@ -169,6 +173,8 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
169
173
|
repository,
|
|
170
174
|
issueType: type ? { name: type } : null,
|
|
171
175
|
labels: labels(...names),
|
|
176
|
+
// #188 was closed by someone else [HIS-07].
|
|
177
|
+
timelineItems: { nodes: [{ actor: { login: number === 188 ? "alice" : "me" } }] },
|
|
172
178
|
});
|
|
173
179
|
|
|
174
180
|
const data = search({
|
|
@@ -282,25 +288,30 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
282
288
|
{ ...pickable(165, {}, 3, "Task", "Devcontainers for pull requests", "me/tool"), projectItems: { nodes: [] }, sources: ["mine"] },
|
|
283
289
|
],
|
|
284
290
|
merged: [
|
|
285
|
-
merged(
|
|
291
|
+
merged(183, "Retry failed webhooks", 2 / 24, undefined, "feature"),
|
|
286
292
|
merged(172, "Fix VAT on credit notes", 3, undefined, "bug"),
|
|
287
293
|
merged(177, "chore: bump the build image", 4),
|
|
288
|
-
merged(
|
|
294
|
+
merged(170, "Nightly backup check", 1, 171),
|
|
289
295
|
// Handed over to carol before she merged it, so it isn't listed as mine [HIS-06].
|
|
290
296
|
merged(179, "Move invoices to the new queue", 1),
|
|
291
297
|
merged(173, "Speed up the order list", 9, 174),
|
|
292
298
|
merged(175, "Remove the old importer", 16),
|
|
293
299
|
],
|
|
294
300
|
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 },
|
|
301
|
+
{ 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") },
|
|
302
|
+
{ number: 191, title: "Speed up the search index", url: `https://github.com/${REPO}/pull/191`, mergedAt: daysAgo(3), mergedBy: { login: "bob" }, repository, author: bob },
|
|
303
|
+
{ number: 182, title: "Sentry release tracking", url: `https://github.com/${REPO}/pull/182`, mergedAt: daysAgo(11), mergedBy: { login: "alice" }, repository, author: alice },
|
|
298
304
|
],
|
|
299
305
|
closed: [
|
|
306
|
+
closed(188, "Export fails on empty months", 6 / 24, "COMPLETED", "Bug"),
|
|
300
307
|
closed(171, "Backups are never verified", 1, "COMPLETED", "Feature"),
|
|
301
308
|
closed(174, "Order list takes 8 seconds", 9, "COMPLETED", undefined, "type: bug"),
|
|
302
309
|
closed(176, "Dark mode for the admin", 10, "NOT_PLANNED", undefined, "enhancement"),
|
|
303
310
|
],
|
|
311
|
+
// The live close search sees the same issue, so its close is a note too [HIS-07].
|
|
312
|
+
closedIssues: [
|
|
313
|
+
{ 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" } }] } },
|
|
314
|
+
],
|
|
304
315
|
});
|
|
305
316
|
return {
|
|
306
317
|
data,
|
|
@@ -316,7 +327,19 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
316
327
|
};
|
|
317
328
|
}
|
|
318
329
|
|
|
319
|
-
//
|
|
330
|
+
// A quiet day: GitHub has nothing for me, so the preview can show the empty tabs' scenes [ATT-18, HIS-08, WAI-04, NXT-13].
|
|
331
|
+
// On while this file exists in the plugin's folder; the shooter creates it last.
|
|
332
|
+
export const quiet = () => existsSync(join(DIR, "fixture-quiet"));
|
|
333
|
+
|
|
334
|
+
// The fixture, or nothing in it on a quiet day.
|
|
335
|
+
export function fixtureNow(now: Date): ReturnType<typeof fixture> {
|
|
336
|
+
const { data, details } = fixture(now);
|
|
337
|
+
if (!quiet()) return { data, details };
|
|
338
|
+
const empty = Object.fromEntries(Object.entries(data).map(([key, value]) => [key, key === "viewer" ? value : { nodes: [] }]));
|
|
339
|
+
return { data: empty as unknown as SearchResult, details };
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// 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
343
|
// by its new owner, so History doesn't count it as mine.
|
|
321
344
|
export function fixtureChanges(now: Date): OthersChange[] {
|
|
322
345
|
const hoursAgo = (hours: number) => new Date(now.getTime() - hours * 3_600_000).toISOString();
|
|
@@ -335,28 +358,58 @@ export function fixtureChanges(now: Date): OthersChange[] {
|
|
|
335
358
|
at: hoursAgo(hours),
|
|
336
359
|
});
|
|
337
360
|
return [
|
|
361
|
+
{ ...event("reopened", "pr", 181, "Paginate the order export", 1, "bob") },
|
|
338
362
|
event("merged", "pr", 183, "Retry failed webhooks", 2, "dave"),
|
|
339
363
|
event("took_over", "pr", 186, "Split the invoice PDF job", 5, "phil", "phil"),
|
|
364
|
+
{ ...event("issue_closed", "issue", 188, "Export fails on empty months", 6, "alice"), reason: "completed" as const },
|
|
340
365
|
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",
|
|
366
|
+
event("handed", "pr", 179, "Move invoices to the new queue", 96, "dave", "carol"),
|
|
367
|
+
event("unassigned", "issue", 160, "Refunds skip the ledger", 192, "bob"),
|
|
368
|
+
event("closed", "pr", 170, "Drop the legacy CSV import", 216, "bob"),
|
|
343
369
|
];
|
|
344
370
|
}
|
|
345
371
|
|
|
372
|
+
// The notes History already shows as cleared in the preview: their week's Changed by others has them [HIS-07].
|
|
373
|
+
export function fixtureGotIt(now: Date): string[] {
|
|
374
|
+
return fixtureChanges(now)
|
|
375
|
+
.filter((change) => (change.number === 179 || change.number === 170) && change.kind !== "merged")
|
|
376
|
+
.map((change) => change.id);
|
|
377
|
+
}
|
|
378
|
+
|
|
346
379
|
// Sessions the preview shows as started from items: working, needs me, failed, idle.
|
|
347
380
|
// 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
381
|
// #113 waits on CI while its Fix CI session works, though Fix CI isn't one of its actions any more.
|
|
349
382
|
// #120's was started outside Attention Span, in a workspace Paseo linked to the PR, so it has no kind [SES-08].
|
|
350
383
|
// #197's too, so it shows on its stack, led by #196 [ATT-04].
|
|
351
|
-
const agent = (
|
|
384
|
+
const agent = (
|
|
385
|
+
id: string,
|
|
386
|
+
itemKey: string,
|
|
387
|
+
kind: SessionKind | undefined,
|
|
388
|
+
status: string,
|
|
389
|
+
minutesAgo: number,
|
|
390
|
+
requiresAttention = false,
|
|
391
|
+
workspace?: AgentSummary["workspace"],
|
|
392
|
+
title = `Fixture session ${id}`,
|
|
393
|
+
): AgentSummary => ({
|
|
352
394
|
id,
|
|
353
395
|
itemKey,
|
|
354
396
|
kind,
|
|
355
397
|
status,
|
|
356
398
|
requiresAttention,
|
|
357
|
-
title
|
|
358
|
-
workspaceId: null,
|
|
399
|
+
title,
|
|
400
|
+
workspaceId: workspace ? `WS_${id}` : null,
|
|
359
401
|
lastActivityAt: new Date(Date.now() - minutesAgo * 60_000).toISOString(),
|
|
402
|
+
...(workspace ? { workspace } : {}),
|
|
403
|
+
});
|
|
404
|
+
// A worktree Paseo made, clean or with uncommitted or unpushed work [ATT-22].
|
|
405
|
+
const sessionWorkspace = (branch: string, dirty: boolean | undefined, ahead: number | undefined, worktree = true, dirtyFiles?: number): AgentSummary["workspace"] => ({
|
|
406
|
+
kind: worktree ? "worktree" : "local_checkout",
|
|
407
|
+
name: `Workspace for ${branch}`,
|
|
408
|
+
directory: `/tmp/attention-span/${branch}`,
|
|
409
|
+
branch,
|
|
410
|
+
...(dirty === undefined ? {} : { dirty }),
|
|
411
|
+
...(ahead === undefined ? {} : { ahead }),
|
|
412
|
+
...(dirtyFiles === undefined ? {} : { dirtyFiles }),
|
|
360
413
|
});
|
|
361
414
|
export const FIXTURE_AGENTS: AgentSummary[] = [
|
|
362
415
|
agent("agent-101", `${REPO}#101`, "fix", "running", 4),
|
|
@@ -368,6 +421,12 @@ export const FIXTURE_AGENTS: AgentSummary[] = [
|
|
|
368
421
|
agent("agent-113", `${REPO}#113`, "fix", "running", 2),
|
|
369
422
|
agent("agent-120", `${REPO}#120`, undefined, "running", 3),
|
|
370
423
|
agent("agent-197", `${REPO}#197`, undefined, "idle", 15),
|
|
424
|
+
// Wrap up: finished work whose sessions are all idle [ATT-22].
|
|
425
|
+
agent("agent-183", `${REPO}#183`, "fix", "idle", 20, false, sessionWorkspace("retry-webhooks", false, 0), "Retry webhooks"),
|
|
426
|
+
agent("agent-186", `${REPO}#186`, "fix", "idle", 40, false, sessionWorkspace("split-invoice-pdf", true, 1, true, 2), "Split invoice PDF"),
|
|
427
|
+
agent("agent-190", `${REPO}#190`, "review", "idle", 60, false, sessionWorkspace("add-vat-export", false, 0), "Review PR 190: Add the VAT export"),
|
|
428
|
+
agent("agent-172", `${REPO}#172`, "fix", "idle", 240, false, sessionWorkspace("fix-vat-credit-notes", false, 0), "Fix VAT on credit notes"),
|
|
429
|
+
agent("agent-172b", `${REPO}#172`, "address", "idle", 250, false, sessionWorkspace("credit-note-tests", undefined, undefined), "Credit note tests"),
|
|
371
430
|
];
|
|
372
431
|
|
|
373
432
|
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
|
}
|
package/server/service.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Attention, type AttentionView, type FeedId, type FeedStatus, type GithubColor, type HistoryFilter, type Item, keySet, memberKeys, type ProjectsAccess, type Reviewer, uniqueKeys } from "../shared/attention";
|
|
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 {
|
|
5
|
+
import type { ArchiveOutcome, ArchiveTarget } from "../shared/archive";
|
|
6
|
+
import { archiveSessions } from "./archive";
|
|
7
|
+
import { rememberGroups } from "../shared/wrap-up";
|
|
8
|
+
import { acknowledge, changeCandidates, ownClosed, nextLedger, type Lookups, type ReopenLookups, reopenCandidates, withGotIt } from "./changes";
|
|
6
9
|
import { classify, classifyHistory, issueBoardIds } from "./classify";
|
|
7
10
|
import { probeAnswer, projectsFailure, projectsWarning, searchWithProjects } from "./projects";
|
|
8
11
|
import { FIXTURE, graphql, graphqlResult } from "./gh";
|
|
9
|
-
import {
|
|
10
|
-
import type { AssignmentSubject, Details, HistoryResult, LinkedIssue, LiveResult, MergeStateStatus, PullRequestNode } from "./github-types";
|
|
12
|
+
import { FIXTURE_AGENTS, FIXTURE_ISSUE_FIELDS, fixtureChanges, fixtureGotIt, fixtureNow, quiet } from "./fixture";
|
|
13
|
+
import type { AssignmentSubject, Details, HistoryResult, LinkedIssue, LiveResult, MergeStateStatus, PullRequestNode, ReopenSubject } from "./github-types";
|
|
11
14
|
import {
|
|
12
15
|
ASSIGNMENT_BATCH,
|
|
13
16
|
assignmentsQuery,
|
|
@@ -23,6 +26,7 @@ import {
|
|
|
23
26
|
PROJECTS_PROBE,
|
|
24
27
|
projectStatusesQuery,
|
|
25
28
|
type ProjectStatusesResult,
|
|
29
|
+
reopenQuery,
|
|
26
30
|
requiredChecks,
|
|
27
31
|
type SearchName,
|
|
28
32
|
searchQuery,
|
|
@@ -100,9 +104,10 @@ export class AttentionService {
|
|
|
100
104
|
}
|
|
101
105
|
|
|
102
106
|
// ⟳ fetches its tab's feed now; otherwise feeds older than their schedule are fetched first.
|
|
103
|
-
|
|
107
|
+
// `cached` answers from memory, with no GitHub refresh first.
|
|
108
|
+
async get(refresh?: FeedId, cached?: boolean): Promise<AttentionView> {
|
|
104
109
|
if (refresh) await this.refresh(refresh).catch(() => {});
|
|
105
|
-
else await this.refreshStale();
|
|
110
|
+
else if (!cached) await this.refreshStale();
|
|
106
111
|
return this.view();
|
|
107
112
|
}
|
|
108
113
|
|
|
@@ -121,10 +126,11 @@ export class AttentionService {
|
|
|
121
126
|
return this.view();
|
|
122
127
|
}
|
|
123
128
|
|
|
124
|
-
// Clears
|
|
125
|
-
async gotIt(
|
|
126
|
-
const gotIt = this.state.changes.gotIt.filter((other) => other
|
|
127
|
-
|
|
129
|
+
// Clears Changed by others notes, or brings them back for Undo; nothing changes on GitHub [HIS-07].
|
|
130
|
+
async gotIt(ids: string[], on: boolean): Promise<AttentionView> {
|
|
131
|
+
const gotIt = this.state.changes.gotIt.filter((other) => !ids.includes(other));
|
|
132
|
+
const known = ids.filter((id) => this.state.changes.events.some((event) => event.id === id));
|
|
133
|
+
this.state.changes.gotIt = on ? [...gotIt, ...known] : gotIt;
|
|
128
134
|
await this.save();
|
|
129
135
|
return this.view();
|
|
130
136
|
}
|
|
@@ -135,6 +141,42 @@ export class AttentionService {
|
|
|
135
141
|
return this.view();
|
|
136
142
|
}
|
|
137
143
|
|
|
144
|
+
// Reviewed and Changed by others in each of History's weeks [HIS-07].
|
|
145
|
+
async setHistoryFilter(filter: HistoryFilter[]): Promise<AttentionView> {
|
|
146
|
+
this.state.historyFilter = [...new Set(filter)];
|
|
147
|
+
await this.save();
|
|
148
|
+
return this.view();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Archive acknowledges exactly the events on the work at that moment, including ones a refresh added meanwhile; `upTo`
|
|
152
|
+
// leaves out what came after then [HIS-07, ATT-22].
|
|
153
|
+
async acknowledge(keys: string[], upTo?: string): Promise<AttentionView> {
|
|
154
|
+
this.state.changes = acknowledge(this.state.changes, keys, upTo);
|
|
155
|
+
await this.save();
|
|
156
|
+
return this.view();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// The keys of the item's whole stack or issue group: its own members, as GitHub spells them, since Paseo's labels match
|
|
160
|
+
// exactly, plus what was remembered while it was open [ATT-22, ATT-04].
|
|
161
|
+
groupKeysOf(itemKey: string): string[] {
|
|
162
|
+
const wanted = itemKey.toLowerCase();
|
|
163
|
+
const view = this.view();
|
|
164
|
+
const items = [...view.history, ...(view.ownClosed ?? []), ...view.doing.flatMap((section) => section.items), ...view.waiting.flatMap((group) => group.items)];
|
|
165
|
+
const found = items.map(memberKeys).filter((keys) => keySet(keys).has(wanted)).flat();
|
|
166
|
+
return uniqueKeys([itemKey, ...found, ...(this.state.groups[wanted]?.keys ?? [])]);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Archive a Wrap up row's sessions; success acknowledges the events on that work, so they go to their week as cleared, not
|
|
170
|
+
// History's unread notes [ATT-22, HIS-07]. A failure leaves the row to try again.
|
|
171
|
+
async archive(paseo: PluginHandlerContext["paseo"], targets: ArchiveTarget[], confirm: boolean): Promise<ArchiveOutcome> {
|
|
172
|
+
// Previews have no Paseo agents, but still acknowledge, so their screenshots can show the cleanup.
|
|
173
|
+
if (FIXTURE) return { ok: true, view: await this.acknowledge(targets.flatMap((target) => target.keys)) };
|
|
174
|
+
const answer = await archiveSessions(paseo, targets.flatMap((target) => target.agentIds), confirm);
|
|
175
|
+
if (!answer.ok) return { ...answer, view: this.view() };
|
|
176
|
+
const view = await this.acknowledge(targets.flatMap((target) => target.keys));
|
|
177
|
+
return answer.warning ? { ok: true, view, warning: answer.warning } : { ok: true, view };
|
|
178
|
+
}
|
|
179
|
+
|
|
138
180
|
// Remember where an issue repo's code lives [SES-07].
|
|
139
181
|
async setCodeRepo(issueRepo: string, codeRepo: string): Promise<AttentionView> {
|
|
140
182
|
this.config = await saveCodeRepo(issueRepo, codeRepo);
|
|
@@ -272,7 +314,10 @@ export class AttentionService {
|
|
|
272
314
|
await this.reloadConfig();
|
|
273
315
|
const now = new Date();
|
|
274
316
|
const fetchedAt = now.toISOString();
|
|
275
|
-
if (id === "live")
|
|
317
|
+
if (id === "live") {
|
|
318
|
+
this.state.live = { fetchedAt, attention: await this.fetchLive(now) };
|
|
319
|
+
this.state.groups = rememberGroups(this.state.groups, this.state.live.attention.items, now, Math.max(this.config.mentionDays, this.config.historyWeeks * 7 + 7));
|
|
320
|
+
}
|
|
276
321
|
else this.state.history = { fetchedAt, items: await this.fetchHistory(now) };
|
|
277
322
|
// Forget dismissals of items that are gone.
|
|
278
323
|
const keys = new Set(this.items().map((item) => item.key));
|
|
@@ -292,18 +337,19 @@ export class AttentionService {
|
|
|
292
337
|
const projectRepos = FIXTURE ? [] : await this.projectRepos();
|
|
293
338
|
const login = FIXTURE ? "me" : this.config.nextUp.mine ? await this.login() : null;
|
|
294
339
|
const unclaimed = unclaimedSearches(this.config, projectRepos, login);
|
|
295
|
-
const { data, details } = FIXTURE ?
|
|
340
|
+
const { data, details } = FIXTURE ? fixtureNow(now) : await this.searchLive(now, unclaimed.searches);
|
|
296
341
|
await this.trackChanges(data, now);
|
|
297
|
-
|
|
342
|
+
const own = FIXTURE ? [] : ownClosed(data, data.viewer.login);
|
|
343
|
+
return { ...classify({ data, details, config: this.config, now }), unclaimedFrom: unclaimed.from, ...(own.length ? { ownClosed: own } : {}) };
|
|
298
344
|
}
|
|
299
345
|
|
|
300
|
-
// What others did to my work since the last refresh [
|
|
346
|
+
// What others did to my work since the last refresh [HIS-07]. Only PRs whose hands changed and issues that left my assigned
|
|
301
347
|
// search are looked up, a batch per request; a failed batch is asked again next time [GH-01]. Kept long enough for History.
|
|
302
348
|
private async trackChanges(data: LiveResult, now: Date): Promise<void> {
|
|
303
349
|
const ledger = this.state.changes;
|
|
304
350
|
if (FIXTURE) {
|
|
305
351
|
// 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:
|
|
352
|
+
this.state.changes = { ...ledger, events: quiet() ? [] : fixtureChanges(now), gotIt: fixtureGotIt(now) };
|
|
307
353
|
return;
|
|
308
354
|
}
|
|
309
355
|
const me = data.viewer.login;
|
|
@@ -323,9 +369,32 @@ export class AttentionService {
|
|
|
323
369
|
console.error("Couldn't look up who changed my work:", (error as Error).message);
|
|
324
370
|
}
|
|
325
371
|
}
|
|
372
|
+
const reopens = await this.reopenLookups(reopenCandidates(ledger, data));
|
|
326
373
|
const keepDays = Math.max(this.config.mentionDays, this.config.historyWeeks * 7 + 7);
|
|
327
|
-
// A Got it tapped while this refresh ran still counts.
|
|
328
|
-
|
|
374
|
+
// A Got it tapped, or an archive acknowledging, while this refresh ran still counts.
|
|
375
|
+
// Got its tapped while the lookups ran decide too, so a handover cleared meanwhile survives its work coming back.
|
|
376
|
+
const current = { ...ledger, gotIt: this.state.changes.gotIt };
|
|
377
|
+
this.state.changes = withGotIt(nextLedger(current, data, me, lookups, now, this.config.mentionDays, keepDays, reopens), this.state.changes.gotIt);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// PRs Attention Span saw closed, asked about a batch per request so a reopen by someone else is noticed [HIS-07, GH-01].
|
|
381
|
+
// A batch that fails leaves its PRs tracked for the next refresh; one GitHub can't find is gone.
|
|
382
|
+
private async reopenLookups(candidates: string[]): Promise<ReopenLookups> {
|
|
383
|
+
const lookups: ReopenLookups = new Map();
|
|
384
|
+
for (let at = 0; at < candidates.length; at += ASSIGNMENT_BATCH) {
|
|
385
|
+
const batch = candidates.slice(at, at + ASSIGNMENT_BATCH);
|
|
386
|
+
try {
|
|
387
|
+
const { data, failures } = await graphqlResult<Record<string, ReopenSubject | null>>(reopenQuery(batch));
|
|
388
|
+
batch.forEach((id, index) => {
|
|
389
|
+
const alias = `a${index}`;
|
|
390
|
+
const failed = failures.some((failure) => failure.path?.[0] === alias && failure.type !== "NOT_FOUND");
|
|
391
|
+
if (!failed) lookups.set(id, data?.[alias] ?? null);
|
|
392
|
+
});
|
|
393
|
+
} catch (error) {
|
|
394
|
+
console.error("Couldn't check whether a closed PR reopened:", (error as Error).message);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return lookups;
|
|
329
398
|
}
|
|
330
399
|
|
|
331
400
|
// The account gh is signed in as, for My repos [NXT-04]. Asked once, unless the last fetch already says.
|
|
@@ -348,7 +417,7 @@ export class AttentionService {
|
|
|
348
417
|
}
|
|
349
418
|
|
|
350
419
|
private async fetchHistory(now: Date): Promise<Item[]> {
|
|
351
|
-
if (FIXTURE) return classifyHistory(
|
|
420
|
+
if (FIXTURE) return classifyHistory(fixtureNow(now).data);
|
|
352
421
|
return classifyHistory(await graphql<HistoryResult>(searchQuery(HISTORY_SEARCHES, true), this.variables(HISTORY_SEARCHES, now)));
|
|
353
422
|
}
|
|
354
423
|
|
|
@@ -405,7 +474,7 @@ export class AttentionService {
|
|
|
405
474
|
};
|
|
406
475
|
const merge = (parts: Partial<LiveResult>[]) => Object.assign({}, ...parts) as LiveResult;
|
|
407
476
|
const forDetails = Promise.all([search("mine"), search("assigned"), searchUnclaimed()]);
|
|
408
|
-
const others = Promise.all([search("reviews"), search("mentions"), search("involved"), search("asked"), search("ended")]);
|
|
477
|
+
const others = Promise.all([search("reviews"), search("mentions"), search("involved"), search("asked"), search("ended"), search("closedIssues")]);
|
|
409
478
|
const afterThem = forDetails.then((parts) => this.details(merge(parts), projects, problems));
|
|
410
479
|
try {
|
|
411
480
|
const [first, rest, details] = await Promise.all([forDetails, others, afterThem]);
|
|
@@ -559,6 +628,8 @@ export class AttentionService {
|
|
|
559
628
|
scopes: this.state.scopes,
|
|
560
629
|
sources: this.state.sources,
|
|
561
630
|
projectFilter: this.state.projectFilter,
|
|
631
|
+
historyFilter: this.state.historyFilter,
|
|
632
|
+
groups: Object.fromEntries(Object.entries(this.state.groups).map(([key, group]) => [key, group.keys])),
|
|
562
633
|
config: this.config,
|
|
563
634
|
pending: Object.keys(pending).length,
|
|
564
635
|
...(FIXTURE ? { fixtureAgents: FIXTURE_AGENTS } : {}),
|
package/server/store.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { mkdir, readFile, rename, stat, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { type Attention, type Item, type SectionId, SECTIONS } from "../shared/attention";
|
|
5
|
+
import { type Attention, type HistoryFilter, type Item, type RememberedGroups, type SectionId, SECTIONS } from "../shared/attention";
|
|
6
6
|
import { AttentionConfig, FIELD_ROLES, type FieldRole, sameField } from "../shared/config";
|
|
7
7
|
import type { OthersChange } from "../shared/changes";
|
|
8
|
-
import { EMPTY_LEDGER } from "./changes";
|
|
8
|
+
import { type ChangeLedger, EMPTY_LEDGER } from "./changes";
|
|
9
9
|
import type { Pending } from "./view";
|
|
10
10
|
|
|
11
11
|
// Local files in ~/.config/paseo-attention-span/ [PRIV-01].
|
|
@@ -29,18 +29,25 @@ export const State = z.object({
|
|
|
29
29
|
sources: z.array(z.string()).default([]),
|
|
30
30
|
// Project statuses ticked in Next up's filter; none means all [NXT-03].
|
|
31
31
|
projectFilter: z.array(z.string()).default([]),
|
|
32
|
+
// Reviewed and Changed by others shown in each of History's weeks; none means finished only [HIS-07].
|
|
33
|
+
historyFilter: z.array(z.enum(["reviewed", "changed"])).default([]).catch([] as HistoryFilter[]),
|
|
32
34
|
// The update notice put off with Not now, by the version it offered [UPD-01].
|
|
33
35
|
skippedUpdate: z.string().nullable().default(null).catch(null),
|
|
34
|
-
// What others did to my work, kept until Got it and for History [
|
|
36
|
+
// What others did to my work, kept until Got it or an archive and for History [HIS-06, HIS-07, ATT-22].
|
|
35
37
|
changes: z
|
|
36
38
|
.object({
|
|
37
39
|
events: z.array(z.custom<OthersChange>((value) => typeof (value as OthersChange)?.id === "string" && typeof (value as OthersChange)?.at === "string")),
|
|
38
40
|
gotIt: z.array(z.string()),
|
|
39
41
|
assigned: z.record(z.string(), z.string()).nullable(),
|
|
40
42
|
handed: z.record(z.string(), z.string()),
|
|
43
|
+
// PRs seen closed, to notice a reopen by someone else [HIS-07].
|
|
44
|
+
tracked: z.record(z.string(), z.custom<ChangeLedger["tracked"][string]>((value) => typeof (value as { key?: string })?.key === "string")).default({}),
|
|
41
45
|
})
|
|
42
46
|
.default(EMPTY_LEDGER)
|
|
43
47
|
.catch(EMPTY_LEDGER),
|
|
48
|
+
// Key -> the keys of the stack or issue group it was last seen in, and when, so Wrap up still knows a merged PR's open
|
|
49
|
+
// siblings after History lists it on its own [ATT-22, ATT-04].
|
|
50
|
+
groups: z.record(z.string(), z.object({ keys: z.array(z.string()), at: z.string() })).default({}).catch({}) satisfies z.ZodType<RememberedGroups>,
|
|
44
51
|
// My Paseo projects' GitHub repos when last listed, for refreshes before the app has connected [NXT-08].
|
|
45
52
|
projectRepos: z.array(z.string()).default([]),
|
|
46
53
|
// 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
|
package/server/view.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Attention, type AttentionView, type Chip, type FeedId, type FeedStatus, type Item, type NextUpIssue, type Section, SECTION_ORDER, SECTIONS, type TabId, type WaitingGroup } from "../shared/attention";
|
|
1
|
+
import { type Attention, type AttentionView, type Chip, type FeedId, type FeedStatus, type HistoryFilter, type Item, type NextUpIssue, type Section, SECTION_ORDER, SECTIONS, type TabId, type WaitingGroup } from "../shared/attention";
|
|
2
2
|
import type { AttentionConfig } from "../shared/config";
|
|
3
3
|
import { workChip, workKind } from "../shared/work";
|
|
4
4
|
import { type ChangeLedger, changeItems, EMPTY_LEDGER, handedKeys } from "./changes";
|
|
@@ -10,6 +10,8 @@ export interface ViewMeta {
|
|
|
10
10
|
scopes: string[];
|
|
11
11
|
sources: string[];
|
|
12
12
|
projectFilter: string[];
|
|
13
|
+
historyFilter: HistoryFilter[];
|
|
14
|
+
groups?: Record<string, string[]>;
|
|
13
15
|
config: AttentionConfig;
|
|
14
16
|
pending: number;
|
|
15
17
|
}
|
|
@@ -135,9 +137,13 @@ export function buildView(attention: Attention | null, history: Item[], dismisse
|
|
|
135
137
|
const visible = items
|
|
136
138
|
.filter((item) => !isDismissed(item, dismissed) && !(item.section === "done" && handed.has(item.key)))
|
|
137
139
|
.map((item) => (item.section === "done" && item.children.some((child) => handed.has(child.key)) ? { ...item, children: item.children.filter((child) => !handed.has(child.key)) } : item));
|
|
138
|
-
// Notes on what others did,
|
|
140
|
+
// Notes on what others did, what was cleared into a week, and finished work a live refresh saw first; never dismissed,
|
|
141
|
+
// only cleared with Got it or an archive [HIS-06, HIS-07, ATT-22].
|
|
139
142
|
const changes = changeItems(ledger, now, meta.config.mentionDays, historySince(now, meta.config.historyWeeks));
|
|
140
|
-
|
|
143
|
+
// History's daily fetch has the richer item; one seen live fills in until then, so a merge or close shows in its week now.
|
|
144
|
+
const knownDone = new Set(visible.filter((item) => SECTIONS[item.section].tab === "history" && item.section === "done").flatMap((item) => [item.key, ...item.children.map((child) => child.key)]));
|
|
145
|
+
const liveFinished = changes.finished.filter((item) => !knownDone.has(item.key));
|
|
146
|
+
const shown = [...visible, ...liveFinished, ...changes.notes, ...changes.history];
|
|
141
147
|
const sections = (tab: TabId): Section[] =>
|
|
142
148
|
SECTION_ORDER.filter((id) => SECTIONS[id].tab === tab)
|
|
143
149
|
.map((id) => ({ id, title: SECTIONS[id].title, items: shown.filter((item) => item.section === id) }))
|
|
@@ -146,11 +152,14 @@ export function buildView(attention: Attention | null, history: Item[], dismisse
|
|
|
146
152
|
return {
|
|
147
153
|
...meta,
|
|
148
154
|
login: attention?.login ?? null,
|
|
149
|
-
// What needs me;
|
|
150
|
-
count: doing.reduce((sum, section) => sum +
|
|
155
|
+
// What needs me; Wrap up's cleanup rows are added client-side, where the sessions are [ATT-09, ATT-22].
|
|
156
|
+
count: doing.reduce((sum, section) => sum + section.items.length, 0),
|
|
151
157
|
doing,
|
|
152
158
|
waiting: waitingGroups(visible.filter(inWaiting)),
|
|
153
159
|
history: shown.filter((item) => SECTIONS[item.section].tab === "history"),
|
|
160
|
+
// Dismissed or not, these are still open; Wrap up must not call their sessions finished [ATT-22].
|
|
161
|
+
ownClosed: attention?.ownClosed ?? [],
|
|
162
|
+
activeKeys: (attention?.items ?? []).flatMap((item) => [item.key, ...item.children.map((child) => child.key)]),
|
|
154
163
|
assigned: attention?.assigned ?? [],
|
|
155
164
|
unclaimed: attention?.unclaimed ?? [],
|
|
156
165
|
unclaimedFrom: attention?.unclaimedFrom ?? "config",
|