@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/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 { fixture, FIXTURE_AGENTS, FIXTURE_ISSUE_FIELDS, fixtureChanges } from "./fixture";
|
|
10
|
-
import type { AssignmentSubject, Details, HistoryResult, LinkedIssue, LiveResult, MergeStateStatus, PullRequestNode } from "./github-types";
|
|
12
|
+
import { fixture, FIXTURE_AGENTS, FIXTURE_ISSUE_FIELDS, fixtureChanges, fixtureGotIt } 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));
|
|
@@ -294,16 +339,17 @@ export class AttentionService {
|
|
|
294
339
|
const unclaimed = unclaimedSearches(this.config, projectRepos, login);
|
|
295
340
|
const { data, details } = FIXTURE ? fixture(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: 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.
|
|
@@ -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",
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AttentionView, WrapItem } from "./attention";
|
|
2
|
+
|
|
3
|
+
// Archiving a Wrap up row's sessions [ATT-22]. The screen names the row; the server checks, archives and acknowledges.
|
|
4
|
+
|
|
5
|
+
// A session with work archiving could lose, as the confirm sheet names it: "2 uncommitted files and 1 unpushed commit on
|
|
6
|
+
// branch". `unknown` when git and Paseo couldn't both say; the sheet says so instead.
|
|
7
|
+
export interface UnsavedSession {
|
|
8
|
+
agentId: string;
|
|
9
|
+
title: string | null;
|
|
10
|
+
branch?: string;
|
|
11
|
+
files?: number;
|
|
12
|
+
commits?: number;
|
|
13
|
+
unknown?: true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// What an archive request names: the row's item, its sessions, and the keys whose changes success acknowledges.
|
|
17
|
+
export interface ArchiveTarget {
|
|
18
|
+
itemKey: string;
|
|
19
|
+
agentIds: string[];
|
|
20
|
+
keys: string[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const archiveTarget = (item: WrapItem): ArchiveTarget => ({
|
|
24
|
+
itemKey: item.wrap.itemKey,
|
|
25
|
+
agentIds: item.wrap.sessions.map((session) => session.id),
|
|
26
|
+
keys: item.wrap.keys,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// What archiving answers. A refusal keeps the row and says why, or names the unsaved work to confirm. `warning`: the
|
|
30
|
+
// sessions were archived, but a worktree that should have gone stayed, and why.
|
|
31
|
+
export type ArchiveResult =
|
|
32
|
+
| { ok: true; warning?: string }
|
|
33
|
+
| { ok: false; reason: "working"; message: string }
|
|
34
|
+
| { ok: false; reason: "unsaved"; sessions: UnsavedSession[] };
|
|
35
|
+
|
|
36
|
+
// The answer the screen gets: the result, with the list after it.
|
|
37
|
+
export type ArchiveOutcome = ArchiveResult & { view: AttentionView };
|
package/shared/attention.ts
CHANGED
|
@@ -12,6 +12,8 @@ export const TAB_FEED: Record<TabId, FeedId> = { history: "history", doing: "liv
|
|
|
12
12
|
// Within a tab, top to bottom. The order is also the priority: an item appears once, under the first section whose rule
|
|
13
13
|
// holds, its most urgent reason [ATT-02]. Moving a line here changes which section wins.
|
|
14
14
|
export const SECTIONS = {
|
|
15
|
+
// Finished or out of my hands, with open Paseo sessions left to tidy up [ATT-22].
|
|
16
|
+
wrap: { tab: "doing", title: "Wrap up" },
|
|
15
17
|
reply: { tab: "doing", title: "Waiting for your reply" },
|
|
16
18
|
// Someone answered my question without mentioning me [ATT-16].
|
|
17
19
|
answered: { tab: "doing", title: "Answered" },
|
|
@@ -23,18 +25,18 @@ export const SECTIONS = {
|
|
|
23
25
|
// Nobody has the next move until I ask someone [PRS-12].
|
|
24
26
|
needs_reviewer: { tab: "doing", title: "Needs a reviewer" },
|
|
25
27
|
drafts: { tab: "doing", title: "My drafts" },
|
|
26
|
-
// What someone else did to my work: a note until Got it, never counted as needing me [ATT-21].
|
|
27
|
-
changed: { tab: "doing", title: "Changed by others" },
|
|
28
28
|
// Waiting groups these by who they wait on, not by section [WAI-01].
|
|
29
29
|
wait_review: { tab: "waiting", title: "Waiting for review" },
|
|
30
30
|
wait_reviewer: { tab: "waiting", title: "Waiting for the reviewer" },
|
|
31
31
|
wait_ci: { tab: "waiting", title: "CI running" },
|
|
32
32
|
wait_answer: { tab: "waiting", title: "Questions I asked" },
|
|
33
|
+
// What someone else did to my work, unread at the top of History [HIS-07].
|
|
34
|
+
changed: { tab: "history", title: "Changed by others" },
|
|
33
35
|
// [HIS-01, HIS-02]
|
|
34
36
|
done: { tab: "history", title: "Done" },
|
|
35
37
|
reviewed: { tab: "history", title: "Reviewed" },
|
|
36
|
-
//
|
|
37
|
-
handed_off: { tab: "history", title: "
|
|
38
|
+
// Cleared changes that weren't my finished work: a PR closed unmerged, work taken out of my hands, a reopen [HIS-06, HIS-07].
|
|
39
|
+
handed_off: { tab: "history", title: "Changed by others" },
|
|
38
40
|
} as const satisfies Record<string, { tab: TabId; title: string }>;
|
|
39
41
|
export type SectionId = keyof typeof SECTIONS;
|
|
40
42
|
export const SECTION_ORDER = Object.keys(SECTIONS) as SectionId[];
|
|
@@ -56,9 +58,12 @@ export type ActionId =
|
|
|
56
58
|
| "merge"
|
|
57
59
|
| "close"
|
|
58
60
|
| "start"
|
|
59
|
-
// Clears a Changed by others note; nothing changes on GitHub [
|
|
61
|
+
// Clears a Changed by others note; nothing changes on GitHub [HIS-07].
|
|
60
62
|
| "got_it";
|
|
61
63
|
|
|
64
|
+
// What History's filter can add to each week, both off at first [HIS-07].
|
|
65
|
+
export type HistoryFilter = "reviewed" | "changed";
|
|
66
|
+
|
|
62
67
|
// A short state label on a row [ATT-05]; tone picks its color.
|
|
63
68
|
export interface Chip {
|
|
64
69
|
text: string;
|
|
@@ -227,12 +232,54 @@ export interface Item {
|
|
|
227
232
|
work?: WorkKind;
|
|
228
233
|
// History only: an issue closed as not planned, kept out of the copied week [HIS-03].
|
|
229
234
|
notPlanned?: true;
|
|
235
|
+
// A PR of mine I closed without merging, for Wrap up's words [ATT-22].
|
|
236
|
+
closedUnmerged?: true;
|
|
230
237
|
// History only: who merged my PR, when it wasn't me [HIS-05].
|
|
231
238
|
mergedBy?: string;
|
|
232
|
-
//
|
|
239
|
+
// History only: who closed an issue assigned to me, when it wasn't me [HIS-07].
|
|
240
|
+
closedBy?: string;
|
|
241
|
+
// A Changed by others note, unread or cleared [HIS-06, HIS-07].
|
|
233
242
|
change?: OthersChange;
|
|
243
|
+
// Doing's Wrap up only: its open sessions and what finishing looked like [ATT-22].
|
|
244
|
+
wrap?: WrapInfo;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// A Wrap up row's sessions: all idle, or it wouldn't be there [ATT-22].
|
|
248
|
+
export interface WrapInfo {
|
|
249
|
+
sessions: AgentSummary[];
|
|
250
|
+
// The finished item's own key; the row's is prefixed with "wrap:" so it never collides with it.
|
|
251
|
+
itemKey: string;
|
|
252
|
+
// memberKeys of the finished item: what its sessions are on and what archiving acknowledges [ATT-22].
|
|
253
|
+
keys: string[];
|
|
254
|
+
// "merged by dave 2h ago" or "closed 6h ago by alice", made when the row is.
|
|
255
|
+
finish: string;
|
|
256
|
+
// A session on someone else's PR that merged: its card says "review session" in words.
|
|
257
|
+
review?: true;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// A Wrap up row: always with its sessions and keys [ATT-22].
|
|
261
|
+
export type WrapItem = Item & { section: "wrap"; wrap: WrapInfo };
|
|
262
|
+
|
|
263
|
+
// The GitHub work an item stands for: itself, the PRs under it, and the work a change note is about, spelled as GitHub
|
|
264
|
+
// spells them, since Paseo's labels match exactly. Compare them with keySet [ATT-03, ATT-04, HIS-07].
|
|
265
|
+
export function memberKeys(item: Pick<Item, "key" | "children"> & { change?: Pick<OthersChange, "key"> }): string[] {
|
|
266
|
+
return uniqueKeys([item.key, ...(item.change ? [item.change.key] : []), ...item.children.map((child) => child.key)]);
|
|
234
267
|
}
|
|
235
268
|
|
|
269
|
+
// Each key once, ignoring case, in the first spelling seen.
|
|
270
|
+
export function uniqueKeys(keys: string[]): string[] {
|
|
271
|
+
const unique = new Map<string, string>();
|
|
272
|
+
for (const key of keys) if (!unique.has(key.toLowerCase())) unique.set(key.toLowerCase(), key);
|
|
273
|
+
return [...unique.values()];
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// Keys for comparing: GitHub's owner and repo names ignore case.
|
|
277
|
+
export const keySet = (keys: Iterable<string>): Set<string> => new Set([...keys].map((key) => key.toLowerCase()));
|
|
278
|
+
|
|
279
|
+
// Each open stack's and issue group's member keys, lower case, under every member, and when it was last seen open; so a
|
|
280
|
+
// member that merges still knows its open siblings [ATT-04, ATT-22].
|
|
281
|
+
export type RememberedGroups = Record<string, { keys: string[]; at: string }>;
|
|
282
|
+
|
|
236
283
|
// The colors GitHub lets an org give issue field options and a project its Status options. GRAY is what nothing chosen looks
|
|
237
284
|
// like, so it's shown untinted [NXT-10].
|
|
238
285
|
export type GithubColor = "GRAY" | "BLUE" | "GREEN" | "YELLOW" | "ORANGE" | "RED" | "PINK" | "PURPLE";
|
|
@@ -321,6 +368,8 @@ export interface Attention {
|
|
|
321
368
|
projects?: ProjectInfo[];
|
|
322
369
|
// Repo -> who reviewed or was asked on my PRs there, latest first, for the reviewer picker [PRS-12].
|
|
323
370
|
reviewers?: Record<string, Reviewer[]>;
|
|
371
|
+
// My PRs I closed without merging lately: finished work for Wrap up, never shown in History [ATT-22].
|
|
372
|
+
ownClosed?: Item[];
|
|
324
373
|
}
|
|
325
374
|
|
|
326
375
|
export interface Section {
|
|
@@ -341,6 +390,21 @@ export interface AgentSummary {
|
|
|
341
390
|
title: string | null;
|
|
342
391
|
workspaceId: string | null;
|
|
343
392
|
lastActivityAt: string | null;
|
|
393
|
+
// Its workspace, for Wrap up: whether its worktree holds unsaved work, and whether it's Paseo's own worktree [ATT-22].
|
|
394
|
+
workspace?: SessionWorkspace;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
export interface SessionWorkspace {
|
|
398
|
+
kind: "directory" | "worktree" | "checkout" | "local_checkout";
|
|
399
|
+
name: string;
|
|
400
|
+
directory?: string;
|
|
401
|
+
branch?: string;
|
|
402
|
+
// Paseo's own reading: true when there are uncommitted changes; missing when it couldn't tell.
|
|
403
|
+
dirty?: boolean;
|
|
404
|
+
// Commits not on the upstream branch, from Paseo; missing when it couldn't tell.
|
|
405
|
+
ahead?: number;
|
|
406
|
+
// Previews only, where Paseo has no worktree: how many files are uncommitted, for the confirm sheet's words.
|
|
407
|
+
dirtyFiles?: number;
|
|
344
408
|
}
|
|
345
409
|
|
|
346
410
|
// An item's open sessions: started on it or on any PR under it, until it's merged or closed.
|
|
@@ -350,8 +414,13 @@ export function itemSessions(agents: AgentSummary[], item: Pick<Item, "key" | "c
|
|
|
350
414
|
return matchSessions(agents, [item.key, ...item.children.map((child) => child.key)]);
|
|
351
415
|
}
|
|
352
416
|
|
|
417
|
+
// A session is idle when it isn't working and doesn't need me; Wrap up and archiving both ask [ATT-22].
|
|
418
|
+
export function isIdle(agent: { status: string; requiresAttention?: boolean }): boolean {
|
|
419
|
+
return !agent.requiresAttention && agent.status !== "running" && agent.status !== "initializing";
|
|
420
|
+
}
|
|
421
|
+
|
|
353
422
|
export function matchSessions(agents: AgentSummary[], keys: string[]): AgentSummary[] {
|
|
354
|
-
const wanted =
|
|
423
|
+
const wanted = keySet(keys);
|
|
355
424
|
return agents
|
|
356
425
|
.filter((agent) => wanted.has(agent.itemKey.toLowerCase()))
|
|
357
426
|
.sort((a, b) => Number(b.requiresAttention) - Number(a.requiresAttention) || (b.lastActivityAt ?? "").localeCompare(a.lastActivityAt ?? ""));
|
|
@@ -384,11 +453,17 @@ export interface FeedStatus {
|
|
|
384
453
|
export interface AttentionView {
|
|
385
454
|
feeds: Record<FeedId, FeedStatus>;
|
|
386
455
|
login: string | null;
|
|
387
|
-
// Items in Doing that need me; the sidebar shows it
|
|
456
|
+
// Items in Doing that need me; the sidebar shows it, adding Wrap up's rows client-side [ATT-09, ATT-22].
|
|
388
457
|
count: number;
|
|
389
458
|
doing: Section[];
|
|
390
459
|
waiting: WaitingGroup[];
|
|
391
460
|
history: Item[];
|
|
461
|
+
// Every item key on Doing, Waiting or Next up before dismissals, so Wrap up knows what still isn't done [ATT-22].
|
|
462
|
+
activeKeys?: string[];
|
|
463
|
+
// My PRs I closed without merging, for Wrap up only [ATT-22].
|
|
464
|
+
ownClosed?: Item[];
|
|
465
|
+
// Key -> the keys of the stack or issue group it was last seen open in, lower case [ATT-22, ATT-04].
|
|
466
|
+
groups?: Record<string, string[]>;
|
|
392
467
|
assigned: NextUpIssue[];
|
|
393
468
|
unclaimed: NextUpIssue[];
|
|
394
469
|
unclaimedFrom: UnclaimedSource;
|
|
@@ -401,6 +476,8 @@ export interface AttentionView {
|
|
|
401
476
|
sources: string[];
|
|
402
477
|
// Project statuses ticked in Next up's filter, as projectFilterId makes them; none means all [NXT-03].
|
|
403
478
|
projectFilter: string[];
|
|
479
|
+
// Reviewed and Changed by others shown in each of History's weeks; none means finished only [HIS-07].
|
|
480
|
+
historyFilter: HistoryFilter[];
|
|
404
481
|
config: AttentionConfig;
|
|
405
482
|
// Changes I just made that GitHub's search hasn't caught up with; the app checks back sooner while there are any [FRESH-02].
|
|
406
483
|
pending: number;
|
package/shared/changes.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { ago } from "./format";
|
|
2
2
|
|
|
3
|
-
// What someone else did to my work without asking me: merged or closed my PR,
|
|
4
|
-
// from an issue [
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
|
|
3
|
+
// What someone else did to my work without asking me: merged or closed my PR, closed an issue assigned to me, reopened a PR
|
|
4
|
+
// of mine that was closed, took work over or handed it on, or unassigned me from an issue [HIS-07]. Others' pushes and my
|
|
5
|
+
// own doings aren't here.
|
|
6
|
+
// merged someone else merged my PR
|
|
7
|
+
// closed someone else closed my PR without merging it
|
|
8
|
+
// issue_closed someone else closed an issue assigned to me, as completed or not planned
|
|
9
|
+
// reopened someone else reopened a PR of mine that Attention Span had seen closed
|
|
10
|
+
// took_over someone assigned themselves my PR or issue, and I'm off it
|
|
11
|
+
// handed someone assigned my PR or issue to a third person, and I'm off it
|
|
12
|
+
// unassigned someone took me off an issue and nobody has it now
|
|
13
|
+
export type OthersChangeKind = "merged" | "closed" | "issue_closed" | "reopened" | "took_over" | "handed" | "unassigned";
|
|
11
14
|
|
|
12
15
|
export interface OthersChange {
|
|
13
16
|
// Stable across refreshes, so Got it sticks to this event and no other on the same item.
|
|
@@ -25,15 +28,21 @@ export interface OthersChange {
|
|
|
25
28
|
actor?: string;
|
|
26
29
|
// The new assignee, for took_over and handed.
|
|
27
30
|
to?: string;
|
|
31
|
+
// An issue closed as completed or not planned, for issue_closed [HIS-07].
|
|
32
|
+
reason?: "completed" | "not_planned";
|
|
33
|
+
// A cleared handover whose work came back to me: it stays in its week, but my later work on it is mine again [HIS-06].
|
|
34
|
+
returned?: true;
|
|
28
35
|
at: string;
|
|
29
36
|
}
|
|
30
37
|
|
|
31
|
-
// Handovers take the work out of my hands; merges and
|
|
38
|
+
// Handovers take the work out of my hands; merges, closes and reopens end something.
|
|
32
39
|
export const HANDOVER_KINDS: readonly OthersChangeKind[] = ["took_over", "handed", "unassigned"];
|
|
33
40
|
export const isHandover = (change: Pick<OthersChange, "kind">) => HANDOVER_KINDS.includes(change.kind);
|
|
41
|
+
// Work that ended: the week's Finished list says it, so it isn't repeated under Changed by others [HIS-07].
|
|
42
|
+
export const isFinishedChange = (change: Pick<OthersChange, "kind">) => change.kind === "merged" || change.kind === "issue_closed";
|
|
34
43
|
|
|
35
|
-
// The words on the card, so the tile's color is never the only way to tell [
|
|
36
|
-
export function changeText(change: Pick<OthersChange, "kind" | "actor" | "to" | "at">, now = new Date()): string {
|
|
44
|
+
// The words on the card, so the tile's color is never the only way to tell [HIS-07]: "merged by dave 2h ago".
|
|
45
|
+
export function changeText(change: Pick<OthersChange, "kind" | "actor" | "to" | "at" | "reason">, now = new Date()): string {
|
|
37
46
|
const age = `${ago(change.at, now)} ago`;
|
|
38
47
|
const { actor, to } = change;
|
|
39
48
|
switch (change.kind) {
|
|
@@ -41,6 +50,12 @@ export function changeText(change: Pick<OthersChange, "kind" | "actor" | "to" |
|
|
|
41
50
|
return actor ? `merged by ${actor} ${age}` : `merged ${age}`;
|
|
42
51
|
case "closed":
|
|
43
52
|
return actor ? `closed by ${actor} ${age}, not merged` : `closed ${age}, not merged`;
|
|
53
|
+
case "issue_closed": {
|
|
54
|
+
const as = change.reason === "not_planned" ? " as not planned" : change.reason === "completed" ? " as completed" : "";
|
|
55
|
+
return actor ? `closed by ${actor} ${age}${as}` : `closed ${age}${as}`;
|
|
56
|
+
}
|
|
57
|
+
case "reopened":
|
|
58
|
+
return actor ? `reopened by ${actor} ${age}` : `reopened ${age}`;
|
|
44
59
|
case "took_over":
|
|
45
60
|
return actor ? `${actor} took over ${age}` : `taken over ${age}`;
|
|
46
61
|
case "handed":
|
package/shared/got-it.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Got it on one Changed by others note and Mark all as read on them all wait for each other, so a note is never in two
|
|
2
|
+
// Undos at once, where undoing the one would bring back what the other cleared [HIS-07].
|
|
3
|
+
// Archive session and Archive all clean wait for each other the same way, so a row is never archived twice [ATT-22].
|
|
4
|
+
|
|
5
|
+
// The busy keys Mark all as read and Archive all clean run under; a row's own action runs under its item's key.
|
|
6
|
+
export const ALL_NOTES = "changed";
|
|
7
|
+
export const ALL_WRAP = "wrap";
|
|
8
|
+
|
|
9
|
+
export function noteBusy(busy: ReadonlySet<string>, key: string): boolean {
|
|
10
|
+
return busy.has(key) || busy.has(ALL_NOTES);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function allNotesBusy(busy: ReadonlySet<string>, keys: string[]): boolean {
|
|
14
|
+
return busy.has(ALL_NOTES) || keys.some((key) => busy.has(key));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function wrapBusy(busy: ReadonlySet<string>, key: string): boolean {
|
|
18
|
+
return busy.has(key) || busy.has(ALL_WRAP);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function allWrapBusy(busy: ReadonlySet<string>, keys: string[]): boolean {
|
|
22
|
+
return busy.has(ALL_WRAP) || keys.some((key) => busy.has(key));
|
|
23
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { HistoryFilter, Item } from "./attention";
|
|
2
|
+
import { linkList } from "./format";
|
|
3
|
+
import { workEmoji } from "./work";
|
|
4
|
+
|
|
5
|
+
// History's weeks: what each shows under the filter, and what its copy button copies [HIS-01, HIS-02, HIS-03, HIS-06, HIS-07].
|
|
6
|
+
// Pure, so the report's rules are testable; client/history.tsx draws it.
|
|
7
|
+
|
|
8
|
+
export interface HistoryWeek {
|
|
9
|
+
// The week's Monday, at midnight in the device's time zone.
|
|
10
|
+
monday: Date;
|
|
11
|
+
done: Item[];
|
|
12
|
+
// Others' merged PRs I reviewed, when Reviewed is shown [HIS-02].
|
|
13
|
+
reviewed: Item[];
|
|
14
|
+
// Cleared changes by others that aren't finished work, when Changed by others is shown [HIS-06, HIS-07].
|
|
15
|
+
changed: Item[];
|
|
16
|
+
// Markdown lists per kind, and how many links; never changes by others, nor issues closed as not planned [HIS-03, HIS-04].
|
|
17
|
+
copy: { text: string; links: number };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Monday-start weeks in the device's time zone.
|
|
21
|
+
export function weekOf(iso: string): Date {
|
|
22
|
+
const day = new Date(iso);
|
|
23
|
+
day.setHours(0, 0, 0, 0);
|
|
24
|
+
day.setDate(day.getDate() - ((day.getDay() + 6) % 7));
|
|
25
|
+
return day;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const newestFirst = (a: Item, b: Item) => b.closedAt!.localeCompare(a.closedAt!);
|
|
29
|
+
|
|
30
|
+
// The weeks with anything shown, newest first, and whether any week holds anything at all, even only what the filter
|
|
31
|
+
// hides: then the Filter button stays, so it can be turned on. Unread notes aren't in weeks; they sit above them.
|
|
32
|
+
export function historyWeeks(items: Item[], filter: HistoryFilter[]): { weeks: HistoryWeek[]; anything: boolean } {
|
|
33
|
+
const byWeek = new Map<number, Item[]>();
|
|
34
|
+
for (const item of items) {
|
|
35
|
+
if (item.section === "changed" || !item.closedAt) continue;
|
|
36
|
+
const week = weekOf(item.closedAt).getTime();
|
|
37
|
+
byWeek.set(week, [...(byWeek.get(week) ?? []), item]);
|
|
38
|
+
}
|
|
39
|
+
const weeks = [...byWeek]
|
|
40
|
+
.sort((a, b) => b[0] - a[0])
|
|
41
|
+
.map(([week, all]): HistoryWeek => {
|
|
42
|
+
const done = all.filter((item) => item.section === "done").sort(newestFirst);
|
|
43
|
+
const reviewed = filter.includes("reviewed") ? all.filter((item) => item.section === "reviewed") : [];
|
|
44
|
+
// A merge or an issue close someone else did is the week's Finished, so it isn't here too [HIS-07].
|
|
45
|
+
const changed = filter.includes("changed") ? all.filter((item) => item.section === "handed_off").sort(newestFirst) : [];
|
|
46
|
+
return { monday: new Date(week), done, reviewed, changed, copy: weekCopy(done, reviewed) };
|
|
47
|
+
})
|
|
48
|
+
.filter((week) => week.done.length + week.reviewed.length + week.changed.length > 0);
|
|
49
|
+
return { weeks, anything: byWeek.size > 0 };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// What was done, each led by its kind, then what I reviewed when that's shown, each under its own heading when both are
|
|
53
|
+
// there. Not planned issues stay on screen but out of the report [HIS-03, HIS-04].
|
|
54
|
+
function weekCopy(done: Item[], reviewed: Item[]): HistoryWeek["copy"] {
|
|
55
|
+
const finished = done.filter((item) => !item.notPlanned);
|
|
56
|
+
const list = (items: Item[]) => linkList(items.map((item) => ({ title: item.title, url: item.url, mark: workEmoji(item) })));
|
|
57
|
+
const finishedText = list(finished);
|
|
58
|
+
const reviewedText = list(reviewed);
|
|
59
|
+
const text = [finishedText && reviewedText ? `## Finished\n\n${finishedText}` : finishedText, reviewedText ? `## Reviewed\n\n${reviewedText}` : ""].filter(Boolean).join("\n\n");
|
|
60
|
+
return { text, links: finished.length + reviewed.length };
|
|
61
|
+
}
|