@andrioid/paseo-attention-span 0.4.13 → 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 +10 -4
- package/README.md +2 -2
- package/client/attention-screen.tsx +142 -123
- package/client/card.tsx +4 -2
- package/client/history.tsx +184 -0
- package/client/icons.ts +7 -0
- package/client/mark.ts +19 -0
- package/client/sessions.ts +50 -3
- package/client/ui.tsx +18 -3
- package/client/wrap-up.tsx +197 -0
- package/docs/architecture.md +19 -7
- 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 -1
- package/package.json +8 -3
- package/requirements.yaml +11 -7
- package/server/archive.ts +132 -0
- package/server/archived.ts +120 -0
- package/server/changes.ts +355 -0
- package/server/classify.ts +15 -4
- package/server/fixture.ts +85 -8
- package/server/gh.ts +16 -4
- package/server/github-types.ts +67 -3
- package/server/queries.ts +62 -8
- package/server/service.ts +131 -11
- package/server/store.ts +20 -1
- package/server/view.ts +25 -6
- package/shared/archive.ts +37 -0
- package/shared/attention.ts +93 -3
- package/shared/changes.ts +66 -0
- package/shared/got-it.ts +23 -0
- package/shared/history-report.ts +61 -0
- package/shared/rpc.ts +23 -2
- package/shared/still.ts +4 -3
- package/shared/wrap-up.ts +126 -0
- package/docs/screenshots/desktop-dark-history-reviewed.png +0 -0
package/shared/attention.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { OthersChange } from "./changes";
|
|
1
2
|
import type { AttentionConfig, MergeMethod, SessionKind } from "./config";
|
|
2
3
|
import type { WorkKind } from "./work";
|
|
3
4
|
|
|
@@ -11,6 +12,8 @@ export const TAB_FEED: Record<TabId, FeedId> = { history: "history", doing: "liv
|
|
|
11
12
|
// Within a tab, top to bottom. The order is also the priority: an item appears once, under the first section whose rule
|
|
12
13
|
// holds, its most urgent reason [ATT-02]. Moving a line here changes which section wins.
|
|
13
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" },
|
|
14
17
|
reply: { tab: "doing", title: "Waiting for your reply" },
|
|
15
18
|
// Someone answered my question without mentioning me [ATT-16].
|
|
16
19
|
answered: { tab: "doing", title: "Answered" },
|
|
@@ -27,9 +30,13 @@ export const SECTIONS = {
|
|
|
27
30
|
wait_reviewer: { tab: "waiting", title: "Waiting for the reviewer" },
|
|
28
31
|
wait_ci: { tab: "waiting", title: "CI running" },
|
|
29
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" },
|
|
30
35
|
// [HIS-01, HIS-02]
|
|
31
36
|
done: { tab: "history", title: "Done" },
|
|
32
37
|
reviewed: { tab: "history", title: "Reviewed" },
|
|
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" },
|
|
33
40
|
} as const satisfies Record<string, { tab: TabId; title: string }>;
|
|
34
41
|
export type SectionId = keyof typeof SECTIONS;
|
|
35
42
|
export const SECTION_ORDER = Object.keys(SECTIONS) as SectionId[];
|
|
@@ -50,7 +57,12 @@ export type ActionId =
|
|
|
50
57
|
| "automerge"
|
|
51
58
|
| "merge"
|
|
52
59
|
| "close"
|
|
53
|
-
| "start"
|
|
60
|
+
| "start"
|
|
61
|
+
// Clears a Changed by others note; nothing changes on GitHub [HIS-07].
|
|
62
|
+
| "got_it";
|
|
63
|
+
|
|
64
|
+
// What History's filter can add to each week, both off at first [HIS-07].
|
|
65
|
+
export type HistoryFilter = "reviewed" | "changed";
|
|
54
66
|
|
|
55
67
|
// A short state label on a row [ATT-05]; tone picks its color.
|
|
56
68
|
export interface Chip {
|
|
@@ -190,6 +202,8 @@ export interface SubRow {
|
|
|
190
202
|
chips: Chip[];
|
|
191
203
|
// Behind its parent, conflicting or failing CI: shown even when the stack is collapsed.
|
|
192
204
|
attention: boolean;
|
|
205
|
+
// History only: who merged it, when it wasn't me [HIS-05].
|
|
206
|
+
mergedBy?: string;
|
|
193
207
|
}
|
|
194
208
|
|
|
195
209
|
export interface Item {
|
|
@@ -218,8 +232,54 @@ export interface Item {
|
|
|
218
232
|
work?: WorkKind;
|
|
219
233
|
// History only: an issue closed as not planned, kept out of the copied week [HIS-03].
|
|
220
234
|
notPlanned?: true;
|
|
235
|
+
// A PR of mine I closed without merging, for Wrap up's words [ATT-22].
|
|
236
|
+
closedUnmerged?: true;
|
|
237
|
+
// History only: who merged my PR, when it wasn't me [HIS-05].
|
|
238
|
+
mergedBy?: string;
|
|
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].
|
|
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)]);
|
|
267
|
+
}
|
|
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()];
|
|
221
274
|
}
|
|
222
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
|
+
|
|
223
283
|
// The colors GitHub lets an org give issue field options and a project its Status options. GRAY is what nothing chosen looks
|
|
224
284
|
// like, so it's shown untinted [NXT-10].
|
|
225
285
|
export type GithubColor = "GRAY" | "BLUE" | "GREEN" | "YELLOW" | "ORANGE" | "RED" | "PINK" | "PURPLE";
|
|
@@ -308,6 +368,8 @@ export interface Attention {
|
|
|
308
368
|
projects?: ProjectInfo[];
|
|
309
369
|
// Repo -> who reviewed or was asked on my PRs there, latest first, for the reviewer picker [PRS-12].
|
|
310
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[];
|
|
311
373
|
}
|
|
312
374
|
|
|
313
375
|
export interface Section {
|
|
@@ -328,6 +390,21 @@ export interface AgentSummary {
|
|
|
328
390
|
title: string | null;
|
|
329
391
|
workspaceId: string | null;
|
|
330
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;
|
|
331
408
|
}
|
|
332
409
|
|
|
333
410
|
// An item's open sessions: started on it or on any PR under it, until it's merged or closed.
|
|
@@ -337,8 +414,13 @@ export function itemSessions(agents: AgentSummary[], item: Pick<Item, "key" | "c
|
|
|
337
414
|
return matchSessions(agents, [item.key, ...item.children.map((child) => child.key)]);
|
|
338
415
|
}
|
|
339
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
|
+
|
|
340
422
|
export function matchSessions(agents: AgentSummary[], keys: string[]): AgentSummary[] {
|
|
341
|
-
const wanted =
|
|
423
|
+
const wanted = keySet(keys);
|
|
342
424
|
return agents
|
|
343
425
|
.filter((agent) => wanted.has(agent.itemKey.toLowerCase()))
|
|
344
426
|
.sort((a, b) => Number(b.requiresAttention) - Number(a.requiresAttention) || (b.lastActivityAt ?? "").localeCompare(a.lastActivityAt ?? ""));
|
|
@@ -371,11 +453,17 @@ export interface FeedStatus {
|
|
|
371
453
|
export interface AttentionView {
|
|
372
454
|
feeds: Record<FeedId, FeedStatus>;
|
|
373
455
|
login: string | null;
|
|
374
|
-
// Items in Doing; the sidebar shows it [ATT-09].
|
|
456
|
+
// Items in Doing that need me; the sidebar shows it, adding Wrap up's rows client-side [ATT-09, ATT-22].
|
|
375
457
|
count: number;
|
|
376
458
|
doing: Section[];
|
|
377
459
|
waiting: WaitingGroup[];
|
|
378
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[]>;
|
|
379
467
|
assigned: NextUpIssue[];
|
|
380
468
|
unclaimed: NextUpIssue[];
|
|
381
469
|
unclaimedFrom: UnclaimedSource;
|
|
@@ -388,6 +476,8 @@ export interface AttentionView {
|
|
|
388
476
|
sources: string[];
|
|
389
477
|
// Project statuses ticked in Next up's filter, as projectFilterId makes them; none means all [NXT-03].
|
|
390
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[];
|
|
391
481
|
config: AttentionConfig;
|
|
392
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].
|
|
393
483
|
pending: number;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ago } from "./format";
|
|
2
|
+
|
|
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";
|
|
14
|
+
|
|
15
|
+
export interface OthersChange {
|
|
16
|
+
// Stable across refreshes, so Got it sticks to this event and no other on the same item.
|
|
17
|
+
id: string;
|
|
18
|
+
kind: OthersChangeKind;
|
|
19
|
+
// The PR's or issue's node id, which survives a transfer; key is "owner/name#number" as last seen.
|
|
20
|
+
subjectId: string;
|
|
21
|
+
subject: "pr" | "issue";
|
|
22
|
+
key: string;
|
|
23
|
+
repo: string;
|
|
24
|
+
number: number;
|
|
25
|
+
title: string;
|
|
26
|
+
url: string;
|
|
27
|
+
// Who did it; missing when GitHub doesn't say (a deleted account).
|
|
28
|
+
actor?: string;
|
|
29
|
+
// The new assignee, for took_over and handed.
|
|
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;
|
|
35
|
+
at: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Handovers take the work out of my hands; merges, closes and reopens end something.
|
|
39
|
+
export const HANDOVER_KINDS: readonly OthersChangeKind[] = ["took_over", "handed", "unassigned"];
|
|
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";
|
|
43
|
+
|
|
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 {
|
|
46
|
+
const age = `${ago(change.at, now)} ago`;
|
|
47
|
+
const { actor, to } = change;
|
|
48
|
+
switch (change.kind) {
|
|
49
|
+
case "merged":
|
|
50
|
+
return actor ? `merged by ${actor} ${age}` : `merged ${age}`;
|
|
51
|
+
case "closed":
|
|
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}`;
|
|
59
|
+
case "took_over":
|
|
60
|
+
return actor ? `${actor} took over ${age}` : `taken over ${age}`;
|
|
61
|
+
case "handed":
|
|
62
|
+
return actor ? `${actor} handed it to ${to} ${age}` : `handed to ${to} ${age}`;
|
|
63
|
+
case "unassigned":
|
|
64
|
+
return actor ? `${actor} unassigned you ${age}` : `unassigned you ${age}`;
|
|
65
|
+
}
|
|
66
|
+
}
|
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
|
+
}
|
package/shared/rpc.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { defineRpc } from "@getpaseo/plugin";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import type { AttentionView, ItemDetails, ProjectsAccess, ReviewerChoices, Target } from "./attention";
|
|
4
|
+
import type { ArchiveOutcome } from "./archive";
|
|
4
5
|
import { SessionKind } from "./config";
|
|
5
6
|
import type { ConfigStatus, CoverageCheck, IssueField, SetupStatus } from "./setup";
|
|
6
7
|
import type { FeedbackInfo } from "./feedback";
|
|
@@ -12,11 +13,31 @@ const view = z.custom<AttentionView>();
|
|
|
12
13
|
const target = z.custom<Target>();
|
|
13
14
|
const done = z.object({ ok: z.literal(true) });
|
|
14
15
|
|
|
15
|
-
// The cached view. Feeds older than their schedule are refreshed from GitHub first; `refresh` fetches that feed now (⟳)
|
|
16
|
-
|
|
16
|
+
// The cached view. Feeds older than their schedule are refreshed from GitHub first; `refresh` fetches that feed now (⟳);
|
|
17
|
+
// `cached` skips GitHub altogether, for a view that only needs what the server already knows.
|
|
18
|
+
export const getAttention = defineRpc({
|
|
19
|
+
name: "attention.get",
|
|
20
|
+
input: z
|
|
21
|
+
.object({ refresh: z.enum(["live", "history"]).optional(), cached: z.boolean().optional() })
|
|
22
|
+
.refine((input) => !(input.refresh && input.cached), "refresh and cached don't go together"),
|
|
23
|
+
output: view,
|
|
24
|
+
});
|
|
17
25
|
export const dismissItem = defineRpc({ name: "attention.dismiss", input: z.object({ key: z.string() }), output: view });
|
|
18
26
|
// Undo one dismissal [ATT-08].
|
|
19
27
|
export const undismissItem = defineRpc({ name: "attention.undismiss", input: z.object({ key: z.string() }), output: view });
|
|
28
|
+
// Clears Changed by others notes, one or all of them; `on: false` brings them back for Undo. Nothing changes on GitHub [HIS-07].
|
|
29
|
+
export const gotIt = defineRpc({ name: "attention.got-it", input: z.object({ ids: z.array(z.string()), on: z.boolean() }), output: view });
|
|
30
|
+
// Reviewed and Changed by others in History's weeks; remembered in state.json [HIS-07].
|
|
31
|
+
export const setHistoryFilter = defineRpc({ name: "history.filter", input: z.object({ filter: z.array(z.enum(["reviewed", "changed"])) }), output: view });
|
|
32
|
+
// Archives a Wrap up row's sessions, acknowledging what others did to the work [ATT-22]. `confirm` is the unsaved-work sheet.
|
|
33
|
+
export const archiveSessions = defineRpc({
|
|
34
|
+
name: "attention.archive",
|
|
35
|
+
input: z.object({
|
|
36
|
+
targets: z.array(z.object({ itemKey: z.string(), agentIds: z.array(z.string()), keys: z.array(z.string()) })),
|
|
37
|
+
confirm: z.boolean(),
|
|
38
|
+
}),
|
|
39
|
+
output: z.custom<ArchiveOutcome>(),
|
|
40
|
+
});
|
|
20
41
|
export const restoreDismissed = defineRpc({ name: "attention.restore-dismissed", input: z.object({}), output: view });
|
|
21
42
|
// Adds one entry to codeRepos in config.json [SES-07].
|
|
22
43
|
export const setCodeRepo = defineRpc({ name: "config.set-code-repo", input: z.object({ issueRepo: z.string(), codeRepo: z.string() }), output: view });
|
package/shared/still.ts
CHANGED
|
@@ -13,8 +13,9 @@ export function sceneAt(date: Date): Scene {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
// Calm only when it's true: Doing is empty after a refresh that worked. Dismissed items don't count;
|
|
16
|
-
// they're not on me until something new happens [ATT-08].
|
|
17
|
-
|
|
16
|
+
// they're not on me until something new happens [ATT-08]. Wrap up's rows do: the horizon waits for them [ATT-18, ATT-22].
|
|
17
|
+
// Loading, a failed refresh or none yet show plainly.
|
|
18
|
+
export function isClear(view: Pick<AttentionView, "doing" | "feeds">, failed = false, wrap = 0): boolean {
|
|
18
19
|
const live = view.feeds.live;
|
|
19
|
-
return view.doing.length === 0 && !!live.fetchedAt && !live.error && !failed;
|
|
20
|
+
return view.doing.length === 0 && wrap === 0 && !!live.fetchedAt && !live.error && !failed;
|
|
20
21
|
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { type AgentSummary, type AttentionView, isIdle, type Item, keySet, matchSessions, memberKeys, type RememberedGroups, type SessionWorkspace, type WrapItem } from "./attention";
|
|
2
|
+
import { ago } from "./format";
|
|
3
|
+
import { changeText } from "./changes";
|
|
4
|
+
|
|
5
|
+
// Wrap up: finished or out-of-my-hands work whose unarchived Paseo sessions are all idle [ATT-22]. Pure, so the rules are
|
|
6
|
+
// testable. It's assembled on the client, which already polls Paseo's sessions for the screen and the sidebar's count; the
|
|
7
|
+
// server archives and acknowledges.
|
|
8
|
+
|
|
9
|
+
export type SessionCleanliness = "clean" | "dirty" | "unknown";
|
|
10
|
+
|
|
11
|
+
// What archiving would lose in a session's worktree, from Paseo's snapshot: clean only when it says both that nothing is
|
|
12
|
+
// uncommitted and that nothing is ahead. The server asks git again before archiving [ATT-22].
|
|
13
|
+
export function sessionCleanliness(agent: AgentSummary): SessionCleanliness {
|
|
14
|
+
const workspace = agent.workspace;
|
|
15
|
+
if (!workspace) return "unknown";
|
|
16
|
+
if (workspace.dirty === true || (workspace.ahead ?? 0) > 0) return "dirty";
|
|
17
|
+
if (workspace.dirty === false && workspace.ahead === 0) return "clean";
|
|
18
|
+
return "unknown";
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// "uncommitted changes and 1 unpushed commit on branch": what the multi-session sheet says about a session, from Paseo's
|
|
22
|
+
// snapshot, which doesn't count files.
|
|
23
|
+
export function unsavedText(agent: AgentSummary): string {
|
|
24
|
+
const workspace: SessionWorkspace | undefined = agent.workspace;
|
|
25
|
+
if (sessionCleanliness(agent) === "unknown") return "Couldn't check for unsaved changes";
|
|
26
|
+
const parts: string[] = [];
|
|
27
|
+
if (workspace?.dirty) parts.push("uncommitted changes");
|
|
28
|
+
const ahead = workspace?.ahead ?? 0;
|
|
29
|
+
if (ahead > 0) parts.push(`${ahead} unpushed commit${ahead === 1 ? "" : "s"}`);
|
|
30
|
+
const what = parts.join(" and ") || "unsaved changes";
|
|
31
|
+
return workspace?.branch ? `${what} on ${workspace.branch}` : what;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// A row with one session, clean: Archive session archives it at once, whatever happened on GitHub [ATT-22].
|
|
35
|
+
export function cleanSingle(item: WrapItem): boolean {
|
|
36
|
+
return item.wrap.sessions.length === 1 && sessionCleanliness(item.wrap.sessions[0]) === "clean";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// What finishing looked like, in the same words the cards use [HIS-05, HIS-07].
|
|
40
|
+
function finishText(item: Item, now: Date): string {
|
|
41
|
+
if (item.change) return changeText(item.change, now);
|
|
42
|
+
const at = item.closedAt ?? item.othersActivityAt;
|
|
43
|
+
const age = `${ago(at, now)} ago`;
|
|
44
|
+
if (item.section === "reviewed") return `merged ${age}${item.mergedBy ? ` by ${item.mergedBy}` : ""}`;
|
|
45
|
+
if (item.closedUnmerged) return `closed ${age}, not merged`;
|
|
46
|
+
if (item.kind === "pr") return `merged ${age}${item.mergedBy ? ` by ${item.mergedBy}` : ""}`;
|
|
47
|
+
return `closed ${age}${item.closedBy ? ` by ${item.closedBy}` : ""}${item.notPlanned ? " as not planned" : ""}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Remembers each open stack's and issue group's member keys under every member, so a member that merges or closes still
|
|
51
|
+
// knows its open siblings: History lists a merged PR alone, as its branches are gone [ATT-22, ATT-04]. Forgotten after
|
|
52
|
+
// keepDays.
|
|
53
|
+
export function rememberGroups(groups: RememberedGroups, items: Pick<Item, "key" | "children">[], now: Date, keepDays: number): RememberedGroups {
|
|
54
|
+
const at = now.toISOString();
|
|
55
|
+
const since = new Date(now.getTime() - keepDays * 86_400_000).toISOString();
|
|
56
|
+
const next = Object.fromEntries(Object.entries(groups).filter(([, group]) => group.at >= since));
|
|
57
|
+
for (const item of items) {
|
|
58
|
+
if (item.children.length === 0) continue;
|
|
59
|
+
const keys = [...keySet(memberKeys(item))];
|
|
60
|
+
for (const key of keys) next[key] = { keys, at };
|
|
61
|
+
}
|
|
62
|
+
return next;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// The finished work and changes that could appear in Wrap up: my done and reviewed items, my own unmerged closes, work that
|
|
66
|
+
// left my hands, and a change on finished work that History hasn't fetched yet [ATT-22, HIS-01, HIS-07]. A done item beats
|
|
67
|
+
// the note about it.
|
|
68
|
+
function candidates(view: WrapView): Item[] {
|
|
69
|
+
const seen = new Set<string>();
|
|
70
|
+
const ordered = [...view.history, ...(view.ownClosed ?? [])].sort((a, b) => Number(a.section === "changed") - Number(b.section === "changed"));
|
|
71
|
+
return ordered.filter((item) => {
|
|
72
|
+
// A reopened PR is open again, not work to wrap up.
|
|
73
|
+
if (item.section === "changed" && (!item.change || item.change.kind === "reopened")) return false;
|
|
74
|
+
const key = item.key.toLowerCase();
|
|
75
|
+
if (seen.has(key)) return false;
|
|
76
|
+
seen.add(key);
|
|
77
|
+
return true;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// What Wrap up reads from the view.
|
|
82
|
+
export type WrapView = Pick<AttentionView, "history" | "doing" | "waiting"> & Partial<Pick<AttentionView, "activeKeys" | "groups" | "ownClosed">>;
|
|
83
|
+
|
|
84
|
+
// What Doing's Wrap up shows, newest finish first. A row needs at least one open session, all idle. A stack or issue group
|
|
85
|
+
// enters once, and only when everything its sessions serve is done: a key still open in Doing or Waiting, or a remembered
|
|
86
|
+
// sibling of one, keeps the group out [ATT-22].
|
|
87
|
+
export function wrapItems(view: WrapView, agents: AgentSummary[], now = new Date()): WrapItem[] {
|
|
88
|
+
if (agents.length === 0) return [];
|
|
89
|
+
const active = keySet([...(view.activeKeys ?? []), ...[...view.doing.flatMap((section) => section.items), ...view.waiting.flatMap((group) => group.items)].flatMap(memberKeys)]);
|
|
90
|
+
const groups = view.groups ?? {};
|
|
91
|
+
const serving = (key: string) => [key.toLowerCase(), ...(groups[key.toLowerCase()] ?? [])].some((other) => active.has(other));
|
|
92
|
+
const rows: { item: WrapItem; at: string }[] = [];
|
|
93
|
+
const used = new Set<string>();
|
|
94
|
+
for (const item of candidates(view)) {
|
|
95
|
+
const keys = memberKeys(item);
|
|
96
|
+
const sessions = matchSessions(agents, keys);
|
|
97
|
+
if (sessions.length === 0) continue;
|
|
98
|
+
// The group's sessions must all be idle, none may serve work that's still active, and a session belongs to one row only.
|
|
99
|
+
if (sessions.some((agent) => !isIdle(agent) || serving(agent.itemKey) || used.has(agent.id)) || keys.some(serving)) continue;
|
|
100
|
+
for (const agent of sessions) used.add(agent.id);
|
|
101
|
+
rows.push({
|
|
102
|
+
item: {
|
|
103
|
+
...item,
|
|
104
|
+
key: `wrap:${item.key}`,
|
|
105
|
+
section: "wrap",
|
|
106
|
+
actions: [],
|
|
107
|
+
chips: [],
|
|
108
|
+
wrap: { sessions, itemKey: item.key, keys, finish: finishText(item, now), ...(item.section === "reviewed" ? { review: true as const } : {}) },
|
|
109
|
+
},
|
|
110
|
+
at: item.closedAt ?? item.change?.at ?? item.othersActivityAt,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return rows.sort((a, b) => b.at.localeCompare(a.at)).map(({ item }) => item);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// The unread changes History shows: every note except the ones already in Wrap up, where archiving is the acknowledgement
|
|
117
|
+
// [HIS-07, ATT-22]. A note whose work has no session left, or whose sessions are busy, stays unread.
|
|
118
|
+
export function unreadChanges(notes: Item[], wrap: WrapItem[]): Item[] {
|
|
119
|
+
const inWrap = keySet(wrap.flatMap((item) => item.wrap.keys));
|
|
120
|
+
return notes.filter((note) => !memberKeys(note).some((key) => inWrap.has(key.toLowerCase())));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Doing's and the sidebar's count: what needs me, plus the rows Wrap up asks me to clean up [ATT-09, ATT-22].
|
|
124
|
+
export function doingCount(view: Pick<AttentionView, "count">, wrap: WrapItem[]): number {
|
|
125
|
+
return view.count + wrap.length;
|
|
126
|
+
}
|
|
Binary file
|