@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
|
@@ -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
|
+
}
|
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,13 +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 });
|
|
20
|
-
// Clears
|
|
21
|
-
export const gotIt = defineRpc({ name: "attention.got-it", input: z.object({
|
|
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
|
+
});
|
|
22
41
|
export const restoreDismissed = defineRpc({ name: "attention.restore-dismissed", input: z.object({}), output: view });
|
|
23
42
|
// Adds one entry to codeRepos in config.json [SES-07].
|
|
24
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
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { AttentionView } from "./attention";
|
|
1
|
+
import type { AttentionView, FeedStatus } from "./attention";
|
|
2
|
+
import { historyWeeks } from "./history-report";
|
|
2
3
|
|
|
3
|
-
// The empty
|
|
4
|
+
// The empty tabs: a horizon that follows the device's clock [ATT-18, HIS-08, WAI-04, NXT-13].
|
|
4
5
|
export type Scene = "morning" | "midday" | "evening" | "night";
|
|
5
6
|
|
|
6
7
|
// Fixed local hours, the same every day: morning 5–11, midday 11–16, evening 16–21, night 21–5.
|
|
@@ -12,9 +13,30 @@ export function sceneAt(date: Date): Scene {
|
|
|
12
13
|
return "night";
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
// Calm only when it's true:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
// Calm only when it's true: a refresh of the tab's feed worked. Loading, a failed refresh or none yet show plainly.
|
|
17
|
+
const refreshed = (feed: FeedStatus, failed: boolean) => !!feed.fetchedAt && !feed.error && !failed;
|
|
18
|
+
|
|
19
|
+
// Doing is empty. Dismissed items don't count; they're not on me until something new happens [ATT-08].
|
|
20
|
+
// Wrap up's rows do: the horizon waits for them [ATT-18, ATT-22].
|
|
21
|
+
export function isClear(view: Pick<AttentionView, "doing" | "feeds">, failed = false, wrap = 0): boolean {
|
|
22
|
+
return view.doing.length === 0 && wrap === 0 && refreshed(view.feeds.live, failed);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Nothing waits on anyone [WAI-04].
|
|
26
|
+
export function waitingClear(view: Pick<AttentionView, "waiting" | "feeds">, failed = false): boolean {
|
|
27
|
+
return view.waiting.length === 0 && refreshed(view.feeds.live, failed);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Nothing finished in History's weeks and no unread notes above them. A filter hiding everything isn't rest:
|
|
31
|
+
// that week still holds something, so it shows plainly [HIS-08].
|
|
32
|
+
export function historyClear(view: Pick<AttentionView, "history" | "feeds">, notes: number, failed = false): boolean {
|
|
33
|
+
return notes === 0 && !historyWeeks(view.history, []).anything && refreshed(view.feeds.history, failed);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Next up with nothing in it at all, not even behind a filter [NXT-13]. Nowhere to look is a setting, so it shows
|
|
37
|
+
// straight away; nothing to pick up waits for a refresh that worked.
|
|
38
|
+
export function nextUpClear(view: Pick<AttentionView, "assigned" | "unclaimed" | "unclaimedFrom" | "feeds">, failed = false): "setup" | "clear" | null {
|
|
39
|
+
if (view.assigned.length > 0 || view.unclaimed.length > 0) return null;
|
|
40
|
+
if (view.unclaimedFrom === "none") return "setup";
|
|
41
|
+
return refreshed(view.feeds.live, failed) ? "clear" : null;
|
|
20
42
|
}
|
|
@@ -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
|