@andrioid/paseo-attention-span 0.6.1 → 0.7.1
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 +2 -0
- package/client/attention-screen.tsx +4 -1
- package/client/entity.tsx +15 -3
- package/client/icons.ts +2 -0
- package/client/item-actions.ts +49 -1
- package/client/next-up.tsx +49 -7
- package/client/pickers.tsx +4 -3
- package/client/ui.tsx +4 -1
- package/client/wrap-up.tsx +51 -4
- package/docs/architecture.md +4 -3
- 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-too-long.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.server.ts +2 -0
- package/package.json +1 -1
- package/requirements.yaml +4 -0
- package/server/classify.ts +44 -3
- package/server/context.ts +95 -3
- package/server/fetch.ts +29 -3
- package/server/fixture.ts +21 -5
- package/server/github-types.ts +15 -1
- package/server/queries.ts +15 -1
- package/server/references.ts +12 -0
- package/server/service.ts +90 -11
- package/server/store.ts +17 -2
- package/server/view.ts +24 -4
- package/shared/attention.ts +39 -2
- package/shared/item-view.ts +5 -4
- package/shared/next-up-filter.ts +19 -0
- package/shared/prompts.ts +39 -22
- package/shared/rpc.ts +4 -0
- package/shared/wrap-up.ts +34 -9
package/server/service.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Attention, type AttentionView, type FeedId, type FeedStatus, type HistoryFilter, type Item, memberKeys, type ProjectsAccess, type Reviewer } from "../shared/attention";
|
|
1
|
+
import { type Attention, type AttentionView, baseItem, type CloseAsk, type FeedId, type FeedStatus, type HistoryFilter, type Item, memberKeys, type ProjectsAccess, type Reviewer } from "../shared/attention";
|
|
2
2
|
import type { PluginHandlerContext } from "@getpaseo/plugin/server";
|
|
3
3
|
import { AttentionConfig, type FieldRole } from "../shared/config";
|
|
4
4
|
import { newIssueRepos } from "../shared/new-issue";
|
|
@@ -6,13 +6,13 @@ import type { IssueField } from "../shared/setup";
|
|
|
6
6
|
import type { ArchiveOutcome, ArchiveTarget, KeptRow, KeptWorktree } from "../shared/archive";
|
|
7
7
|
import { rememberGroups } from "../shared/wrap-up";
|
|
8
8
|
import { acknowledge, ownClosed } from "./changes";
|
|
9
|
-
import { classify, classifyHistory } from "./classify";
|
|
9
|
+
import { classify, classifyCloseAsks, classifyHistory } from "./classify";
|
|
10
10
|
import { probeAnswer, projectsFailure, projectsWarning } from "./projects";
|
|
11
11
|
import type { Port } from "./port";
|
|
12
|
-
import { isTimeZone, type UnclaimedSearch, unclaimedSearches } from "./queries";
|
|
13
|
-
import type { Details, LiveResult } from "./github-types";
|
|
12
|
+
import { historySince, isTimeZone, type UnclaimedSearch, unclaimedSearches } from "./queries";
|
|
13
|
+
import type { Details, LiveResult, ReferencedIssue } from "./github-types";
|
|
14
14
|
import { State } from "./store";
|
|
15
|
-
import { applyPending, buildView, doneItem, type Effect, isPending, SETTLE_MS } from "./view";
|
|
15
|
+
import { applyPending, buildView, doneItem, type Effect, isPending, type Pending, SETTLE_MS } from "./view";
|
|
16
16
|
import { keySet, uniqueKeys } from "../shared/names";
|
|
17
17
|
|
|
18
18
|
// History changes only when I finish something, so it's fetched daily, on ⟳ in its tab and after a merge.
|
|
@@ -114,6 +114,16 @@ export class AttentionService {
|
|
|
114
114
|
return this.view();
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
// Keep open: Wrap up stops asking to close the issue until another PR of mine merges under it; `on: false` is its Undo.
|
|
118
|
+
// Nothing changes on GitHub [ATT-24].
|
|
119
|
+
async keepOpen(key: string, on: boolean): Promise<AttentionView> {
|
|
120
|
+
const ask = this.state.history?.asks.find((candidate) => candidate.key === key);
|
|
121
|
+
if (on && ask) this.state.keptOpen[key] = ask.mergedAt;
|
|
122
|
+
if (!on) delete this.state.keptOpen[key];
|
|
123
|
+
await this.save();
|
|
124
|
+
return this.view();
|
|
125
|
+
}
|
|
126
|
+
|
|
117
127
|
// Clears Changed by others notes, or brings them back for Undo; nothing changes on GitHub [HIS-07].
|
|
118
128
|
async gotIt(ids: string[], on: boolean): Promise<AttentionView> {
|
|
119
129
|
const gotIt = this.state.changes.gotIt.filter((other) => !ids.includes(other));
|
|
@@ -265,6 +275,13 @@ export class AttentionService {
|
|
|
265
275
|
await this.save();
|
|
266
276
|
}
|
|
267
277
|
|
|
278
|
+
// Not a filter, so Clear leaves it [NXT-14]. Answered with the view, so a refresh that read the old choice can't undo it.
|
|
279
|
+
async setUnclaimedByRepo(on: boolean): Promise<AttentionView> {
|
|
280
|
+
this.state.unclaimedByRepo = on;
|
|
281
|
+
await this.save();
|
|
282
|
+
return this.view();
|
|
283
|
+
}
|
|
284
|
+
|
|
268
285
|
// "Not now" on an update notice holds until a newer one [UPD-01].
|
|
269
286
|
get skippedUpdate(): string | null {
|
|
270
287
|
return this.state.skippedUpdate;
|
|
@@ -286,11 +303,18 @@ export class AttentionService {
|
|
|
286
303
|
async act(key: string, work: () => Promise<void>, change: Change): Promise<AttentionView> {
|
|
287
304
|
await work();
|
|
288
305
|
const before = this.state.pending[key];
|
|
306
|
+
const wasClosed = key in this.state.closedAsks;
|
|
289
307
|
const at = new Date(this.port.now()).toISOString();
|
|
290
308
|
if (change) this.state.pending[key] = { at, effect: change.kind === "finished" ? this.finished(key, at, change.notPlanned) : change };
|
|
291
309
|
else delete this.state.pending[key];
|
|
310
|
+
// History's search only finds closed issues assigned to me, so one Wrap up asked to close is kept here, its merged PRs
|
|
311
|
+
// under it, for its week and its sessions' row; Undo forgets it [ATT-24, HIS-01].
|
|
312
|
+
const effect = this.state.pending[key]?.effect;
|
|
313
|
+
if (effect?.kind === "done" && this.state.history?.asks.some((ask) => ask.key === key)) this.state.closedAsks[key] = effect.item;
|
|
314
|
+
else if (!change) delete this.state.closedAsks[key];
|
|
292
315
|
await this.save();
|
|
293
|
-
|
|
316
|
+
// Undo of a close brings back its ask once History is fetched, even after the close stopped pending [ATT-24].
|
|
317
|
+
const history = change?.kind === "finished" || before?.effect.kind === "done" || (!change && wasClosed);
|
|
294
318
|
this.followUp("live");
|
|
295
319
|
if (history) this.followUp("history");
|
|
296
320
|
return this.view();
|
|
@@ -300,9 +324,17 @@ export class AttentionService {
|
|
|
300
324
|
private finished(key: string, at: string, notPlanned?: boolean): Effect {
|
|
301
325
|
const live = this.state.live?.attention;
|
|
302
326
|
const source = live?.items.find((item) => item.key === key) ?? live?.assigned.find((issue) => issue.key === key);
|
|
327
|
+
const ask = this.state.history?.asks.find((candidate) => candidate.key === key);
|
|
328
|
+
// An issue Wrap up asked to close keeps my merged PRs under it, assigned to me or not [ATT-24, HIS-01].
|
|
329
|
+
if (ask) return { kind: "done", item: { ...doneItem(source ?? this.askItem(ask), at, notPlanned), children: notPlanned ? [] : ask.prs } };
|
|
303
330
|
return source ? { kind: "done", item: doneItem(source, at, notPlanned) } : { kind: "gone" };
|
|
304
331
|
}
|
|
305
332
|
|
|
333
|
+
// An issue Wrap up asked to close, not in the live feed's lists [ATT-24].
|
|
334
|
+
private askItem(ask: CloseAsk): Item {
|
|
335
|
+
return baseItem({ key: ask.key, section: "done", kind: "issue", repo: ask.repo, number: ask.number, title: ask.title, url: ask.url });
|
|
336
|
+
}
|
|
337
|
+
|
|
306
338
|
// A PR of mine the live feed saw merged, which History doesn't list yet, perhaps merged on GitHub: History is fetched
|
|
307
339
|
// once its search has caught up, once per PR [FRESH-03]. Until then the live feed's own entry stands in (ownClosed).
|
|
308
340
|
private followMerges(): void {
|
|
@@ -350,7 +382,17 @@ export class AttentionService {
|
|
|
350
382
|
this.state.groups = rememberGroups(this.state.groups, this.state.live.attention.items, now, Math.max(this.config.mentionDays, this.config.historyWeeks * 7 + 7));
|
|
351
383
|
this.followMerges();
|
|
352
384
|
}
|
|
353
|
-
else
|
|
385
|
+
else {
|
|
386
|
+
const { open, ...history } = await this.fetchHistory(now);
|
|
387
|
+
this.state.history = { fetchedAt, ...history };
|
|
388
|
+
// Keep open, and an issue closed when asked, last as long as History's weeks: an ask missing from one fetch, while
|
|
389
|
+
// someone's PR is open or a lookup failed, may come back. A closed one History lists itself needs no keeping [ATT-24].
|
|
390
|
+
const since = historySince(now, this.config.historyWeeks, this.timeZone);
|
|
391
|
+
for (const [key, mergedAt] of Object.entries(this.state.keptOpen)) if (mergedAt < since) delete this.state.keptOpen[key];
|
|
392
|
+
const listed = new Set(this.state.history.items.map((item) => item.key));
|
|
393
|
+
// Reopened on GitHub, it's open again: only a lookup that answered says so, so a failed one keeps it.
|
|
394
|
+
for (const [key, item] of Object.entries(this.state.closedAsks)) if (listed.has(key) || open.has(key) || (item.closedAt ?? "") < since) delete this.state.closedAsks[key];
|
|
395
|
+
}
|
|
354
396
|
// Forget dismissals of items that are gone.
|
|
355
397
|
const keys = new Set(this.items().map((item) => item.key));
|
|
356
398
|
for (const key of Object.keys(this.state.dismissed)) if (!keys.has(key)) delete this.state.dismissed[key];
|
|
@@ -372,7 +414,23 @@ export class AttentionService {
|
|
|
372
414
|
const { data, details } = await this.searchLive(now, unclaimed.searches);
|
|
373
415
|
this.state.changes = await this.port.github.changes(this.state.changes, data, now, this.config, () => this.state.changes.gotIt);
|
|
374
416
|
const own = ownClosed(data, data.viewer.login);
|
|
375
|
-
|
|
417
|
+
const askOff = await this.askOff();
|
|
418
|
+
return { ...classify({ data, details, config: this.config, now }), unclaimedFrom: unclaimed.from, ...(own.length ? { ownClosed: own } : {}), ...(askOff.length ? { askOff } : {}) };
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
// History is fetched daily, so the issues it asks about are looked up again with each live refresh: one closed since,
|
|
422
|
+
// or with anyone's PR open for it, stops asking until History says otherwise [ATT-24, GH-01]. One that can't be looked
|
|
423
|
+
// up keeps asking.
|
|
424
|
+
private async askOff(): Promise<string[]> {
|
|
425
|
+
const asks = this.state.history?.asks ?? [];
|
|
426
|
+
if (asks.length === 0) return [];
|
|
427
|
+
const found = await this.port.github.issues(asks.map((ask) => ({ repo: ask.repo, number: ask.number }))).catch(() => ({}) as Record<string, ReferencedIssue>);
|
|
428
|
+
return asks
|
|
429
|
+
.filter((ask) => {
|
|
430
|
+
const issue = Object.entries(found).find(([key]) => key.toLowerCase() === ask.key.toLowerCase())?.[1];
|
|
431
|
+
return issue && (issue.state !== "OPEN" || (issue.closedByPullRequestsReferences?.nodes ?? []).some((pr) => pr.state === "OPEN"));
|
|
432
|
+
})
|
|
433
|
+
.map((ask) => ask.key);
|
|
376
434
|
}
|
|
377
435
|
|
|
378
436
|
// The account gh is signed in as, for My repos [NXT-04]. Asked once, unless the last fetch already says.
|
|
@@ -393,8 +451,11 @@ export class AttentionService {
|
|
|
393
451
|
return this.state.projectRepos;
|
|
394
452
|
}
|
|
395
453
|
|
|
396
|
-
|
|
397
|
-
|
|
454
|
+
// History, the issues to ask about closing, and which issues my merged PRs refer to were found open [ATT-24].
|
|
455
|
+
private async fetchHistory(now: Date): Promise<{ items: Item[]; asks: CloseAsk[]; open: Set<string> }> {
|
|
456
|
+
const data = await this.port.github.history(this.config, now, this.timeZone);
|
|
457
|
+
const open = new Set(Object.entries(data.referenced ?? {}).flatMap(([key, issue]) => (issue.state === "OPEN" ? [key] : [])));
|
|
458
|
+
return { items: classifyHistory(data), asks: classifyCloseAsks(data), open };
|
|
398
459
|
}
|
|
399
460
|
|
|
400
461
|
// Whether the gh login may read projects, asked at most hourly, or now when Settings asks [NXT-12]. On only when GitHub
|
|
@@ -490,6 +551,22 @@ export class AttentionService {
|
|
|
490
551
|
return newIssueRepos(this.config, this.state.projectRepos, [...shown, ...issues], attention?.login ?? null);
|
|
491
552
|
}
|
|
492
553
|
|
|
554
|
+
// History's asks, less those kept open since their latest merge, and an issue I just closed until History shows it [ATT-24].
|
|
555
|
+
private closeAsks(pending: Record<string, Pending>): CloseAsk[] {
|
|
556
|
+
const off = (key: string) => ["done", "gone"].includes(pending[key]?.effect.kind ?? "");
|
|
557
|
+
return (this.state.history?.asks ?? []).filter((ask) => !off(ask.key) && !((this.state.keptOpen[ask.key] ?? "") >= ask.mergedAt));
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// History as fetched, with the issues closed when Wrap up asked, which its search can't find, and their PRs under them
|
|
561
|
+
// rather than alone [ATT-24, HIS-01].
|
|
562
|
+
private historyItems(): Item[] {
|
|
563
|
+
const items = this.state.history?.items ?? [];
|
|
564
|
+
const listed = new Set(items.map((item) => item.key));
|
|
565
|
+
const closed = Object.values(this.state.closedAsks).filter((item) => !listed.has(item.key));
|
|
566
|
+
const under = new Set(closed.flatMap((item) => item.children.map((child) => child.key)));
|
|
567
|
+
return [...closed, ...items.filter((item) => !under.has(item.key))];
|
|
568
|
+
}
|
|
569
|
+
|
|
493
570
|
private view(): AttentionView {
|
|
494
571
|
const status = (id: FeedId): FeedStatus => ({
|
|
495
572
|
fetchedAt: this.state[id]?.fetchedAt ?? null,
|
|
@@ -498,7 +575,7 @@ export class AttentionService {
|
|
|
498
575
|
});
|
|
499
576
|
const now = this.port.now();
|
|
500
577
|
const pending = Object.fromEntries(Object.entries(this.state.pending).filter(([, entry]) => isPending(entry, this.fetchedAt(), now)));
|
|
501
|
-
const shown = applyPending(this.state.live?.attention ?? null, this.
|
|
578
|
+
const shown = applyPending(this.state.live?.attention ?? null, this.historyItems(), pending);
|
|
502
579
|
return buildView(
|
|
503
580
|
shown.attention,
|
|
504
581
|
shown.history,
|
|
@@ -508,12 +585,14 @@ export class AttentionService {
|
|
|
508
585
|
scopes: this.state.scopes,
|
|
509
586
|
sources: this.state.sources,
|
|
510
587
|
projectFilter: this.state.projectFilter,
|
|
588
|
+
unclaimedByRepo: this.state.unclaimedByRepo,
|
|
511
589
|
historyFilter: this.state.historyFilter,
|
|
512
590
|
groups: Object.fromEntries(Object.entries(this.state.groups).map(([key, group]) => [key, group.keys])),
|
|
513
591
|
config: this.config,
|
|
514
592
|
pending: Object.keys(pending).length,
|
|
515
593
|
newIssue: { repos: this.newIssueRepos(shown.attention), ...this.state.newIssue },
|
|
516
594
|
kept: this.state.kept,
|
|
595
|
+
closeAsks: this.closeAsks(pending),
|
|
517
596
|
},
|
|
518
597
|
this.state.changes,
|
|
519
598
|
new Date(now),
|
package/server/store.ts
CHANGED
|
@@ -2,7 +2,7 @@ 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 HistoryFilter, type Item, type RememberedGroups, type SectionId, SECTIONS } from "../shared/attention";
|
|
5
|
+
import { type Attention, type CloseAsk, type HistoryFilter, type Item, type RememberedGroups, type SectionId, SECTIONS } from "../shared/attention";
|
|
6
6
|
import { AttentionConfig, FIELD_ROLES, type FieldRole } from "../shared/config";
|
|
7
7
|
import type { KeptRow } from "../shared/archive";
|
|
8
8
|
import type { OthersChange } from "../shared/changes";
|
|
@@ -29,6 +29,8 @@ 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
|
+
// Unclaimed grouped by repository rather than one list by priority [NXT-14].
|
|
33
|
+
unclaimedByRepo: z.boolean().default(false).catch(false),
|
|
32
34
|
// Reviewed and Changed by others shown in each of History's weeks; none means finished only [HIS-07].
|
|
33
35
|
historyFilter: z.array(z.enum(["reviewed", "changed"])).default([]).catch([] as HistoryFilter[]),
|
|
34
36
|
// The device's IANA time zone, which History's weeks follow; the last device to send one wins. UTC until then [HIS-01].
|
|
@@ -50,6 +52,11 @@ export const State = z.object({
|
|
|
50
52
|
// 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
|
|
51
53
|
// siblings after History lists it on its own [ATT-22, ATT-04].
|
|
52
54
|
groups: z.record(z.string(), z.object({ keys: z.array(z.string()), at: z.string() })).default({}).catch({}) satisfies z.ZodType<RememberedGroups>,
|
|
55
|
+
// Issue key -> the latest merge under it when I chose Keep open; a later merge asks again [ATT-24].
|
|
56
|
+
keptOpen: z.record(z.string(), z.string()).default({}).catch({}),
|
|
57
|
+
// Issue key -> an issue closed when Wrap up asked, with my merged PRs under it, as History's search can't find one not
|
|
58
|
+
// assigned to me; kept for History's weeks [ATT-24].
|
|
59
|
+
closedAsks: z.record(z.string(), z.custom<Item>((value) => typeof (value as Item)?.key === "string" && Array.isArray((value as Item)?.children))).default({}).catch({}),
|
|
53
60
|
// Wrap up rows whose sessions were archived but whose worktree stayed, until it goes or is dismissed [ATT-22].
|
|
54
61
|
kept: z.array(z.custom<KeptRow>((value) => typeof (value as KeptRow)?.workspaceId === "string" && typeof (value as KeptRow)?.itemKey === "string")).default([]).catch([]),
|
|
55
62
|
// The repository and agent profile the New issue sheet last started with [ISS-01].
|
|
@@ -68,7 +75,15 @@ export const State = z.object({
|
|
|
68
75
|
})
|
|
69
76
|
.nullable()
|
|
70
77
|
.catch(null),
|
|
71
|
-
history: z
|
|
78
|
+
history: z
|
|
79
|
+
.object({
|
|
80
|
+
fetchedAt: z.string(),
|
|
81
|
+
items: z.custom<Item[]>(knownSections),
|
|
82
|
+
// Open issues whose PRs of mine have all merged, to ask about closing [ATT-24].
|
|
83
|
+
asks: z.array(z.custom<CloseAsk>((value) => typeof (value as CloseAsk)?.key === "string" && Array.isArray((value as CloseAsk)?.prs))).default([]).catch([]),
|
|
84
|
+
})
|
|
85
|
+
.nullable()
|
|
86
|
+
.catch(null),
|
|
72
87
|
});
|
|
73
88
|
export type State = z.infer<typeof State>;
|
|
74
89
|
|
package/server/view.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { type Attention, type AttentionView, baseItem, type Chip, type FeedId, type FeedStatus, type HistoryFilter, type Item, type NextUpIssue, type Section, SECTION_ORDER, SECTIONS, type TabId, type WaitingGroup } from "../shared/attention";
|
|
1
|
+
import { type Attention, type AttentionView, baseItem, type Chip, type CloseAsk, 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 type { KeptRow } from "../shared/archive";
|
|
4
4
|
import type { NewIssueInfo } from "../shared/new-issue";
|
|
5
|
+
import { keySet } from "../shared/names";
|
|
5
6
|
import { workChip, workKind } from "../shared/work";
|
|
6
7
|
import { type ChangeLedger, changeItems, EMPTY_LEDGER, handedKeys } from "./changes";
|
|
7
8
|
import { historySince } from "./queries";
|
|
@@ -12,12 +13,15 @@ export interface ViewMeta {
|
|
|
12
13
|
scopes: string[];
|
|
13
14
|
sources: string[];
|
|
14
15
|
projectFilter: string[];
|
|
16
|
+
unclaimedByRepo: boolean;
|
|
15
17
|
historyFilter: HistoryFilter[];
|
|
16
18
|
groups?: Record<string, string[]>;
|
|
17
19
|
config: AttentionConfig;
|
|
18
20
|
pending: number;
|
|
19
21
|
newIssue: NewIssueInfo;
|
|
20
22
|
kept?: KeptRow[];
|
|
23
|
+
// History's asks, less those kept open or just closed [ATT-24].
|
|
24
|
+
closeAsks?: CloseAsk[];
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
// What a tap on GitHub changed, shown until a fetch can show it for itself [FRESH-02].
|
|
@@ -150,6 +154,21 @@ export function buildView(attention: Attention | null, fetched: Item[], dismisse
|
|
|
150
154
|
.map((id) => ({ id, title: SECTIONS[id].title, items: shown.filter((item) => item.section === id) }))
|
|
151
155
|
.filter((section) => section.items.length > 0);
|
|
152
156
|
const doing = sections("doing");
|
|
157
|
+
const activeKeys = (attention?.items ?? []).flatMap((item) => [item.key, ...item.children.map((child) => child.key)]);
|
|
158
|
+
// Not done while a PR is open for it: one of mine grouped under it in the live feed (a mention on the issue alone doesn't
|
|
159
|
+
// count), anyone's Next up knows of, or what the live refresh found when it looked again; and not once it closed since.
|
|
160
|
+
// Only what merged within History's weeks counts, as History shows it, until it's fetched again [ATT-24, HIS-01].
|
|
161
|
+
const off = keySet([
|
|
162
|
+
...(attention?.items ?? []).filter((item) => item.kind === "issue" && item.children.length > 0).map((item) => item.key),
|
|
163
|
+
...[...(attention?.assigned ?? []), ...(attention?.unclaimed ?? [])].filter((issue) => issue.openPrs.length > 0).map((issue) => issue.key),
|
|
164
|
+
...(attention?.askOff ?? []),
|
|
165
|
+
]);
|
|
166
|
+
const closeAsks = (meta.closeAsks ?? [])
|
|
167
|
+
.filter((ask) => !off.has(ask.key.toLowerCase()) && Date.parse(ask.mergedAt) >= Date.parse(since))
|
|
168
|
+
.map((ask) => ({ ...ask, prs: ask.prs.filter((pr) => Date.parse(pr.mergedAt ?? ask.mergedAt) >= Date.parse(since)) }));
|
|
169
|
+
// Next up keeps an issue it asks about, saying its PRs merged [ATT-24].
|
|
170
|
+
const asked = keySet(closeAsks.map((ask) => ask.key));
|
|
171
|
+
const marked = (issues: NextUpIssue[]) => issues.map((issue) => (asked.has(issue.key.toLowerCase()) ? { ...issue, prsMerged: true as const } : issue));
|
|
153
172
|
return {
|
|
154
173
|
...meta,
|
|
155
174
|
login: attention?.login ?? null,
|
|
@@ -160,9 +179,10 @@ export function buildView(attention: Attention | null, fetched: Item[], dismisse
|
|
|
160
179
|
history: shown.filter((item) => SECTIONS[item.section].tab === "history"),
|
|
161
180
|
// Dismissed or not, these are still open; Wrap up must not call their sessions finished [ATT-22].
|
|
162
181
|
ownClosed: attention?.ownClosed ?? [],
|
|
163
|
-
activeKeys
|
|
164
|
-
|
|
165
|
-
|
|
182
|
+
activeKeys,
|
|
183
|
+
closeAsks,
|
|
184
|
+
assigned: marked(attention?.assigned ?? []),
|
|
185
|
+
unclaimed: marked(attention?.unclaimed ?? []),
|
|
166
186
|
unclaimedFrom: attention?.unclaimedFrom ?? "config",
|
|
167
187
|
projects: attention?.projects ?? [],
|
|
168
188
|
dismissedCount: items.filter((item) => isDismissed(item, dismissed)).length,
|
package/shared/attention.ts
CHANGED
|
@@ -181,6 +181,19 @@ export interface StackPr {
|
|
|
181
181
|
base: string;
|
|
182
182
|
// Someone else's, asking for my review; the rest are mine.
|
|
183
183
|
review?: true;
|
|
184
|
+
// Asking for my review again after I reviewed it: when, and on which commit [REV-02].
|
|
185
|
+
reviewed?: LastReview;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface LastReview {
|
|
189
|
+
at: string;
|
|
190
|
+
// The commit my review was made on; missing when GitHub no longer has it.
|
|
191
|
+
oid?: string;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// The PRs in a target's stack asking for my review again [REV-02].
|
|
195
|
+
export function reviewAgain(target: Pick<Target, "stack">): StackPr[] {
|
|
196
|
+
return (target.stack ?? []).filter((pr) => pr.review && pr.reviewed);
|
|
184
197
|
}
|
|
185
198
|
|
|
186
199
|
// The PRs of mine in a target's stack: what Rebase, Refresh and Rerun act on. Others' branches are never pushed [ATT-04].
|
|
@@ -259,7 +272,20 @@ export function baseItem({ key, section, kind, repo, number, title, url }: Pick<
|
|
|
259
272
|
return { key, section, kind, draft: false, repo, number, title, url, chips: [], actions: [], children: [], target: { kind, repo, number, title, url }, othersActivityAt };
|
|
260
273
|
}
|
|
261
274
|
|
|
262
|
-
//
|
|
275
|
+
// An open issue whose PRs of mine, grouped under it, have all merged, with none open for it: Wrap up asks "Close #12?" [ATT-24].
|
|
276
|
+
export interface CloseAsk {
|
|
277
|
+
key: string;
|
|
278
|
+
repo: string;
|
|
279
|
+
number: number;
|
|
280
|
+
title: string;
|
|
281
|
+
url: string;
|
|
282
|
+
// My merged PRs under it, oldest merge first, each with its mergedAt.
|
|
283
|
+
prs: SubRow[];
|
|
284
|
+
// The latest of their merges: Keep open lasts until a later one.
|
|
285
|
+
mergedAt: string;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// A Wrap up row's sessions: all idle, or it wouldn't be there [ATT-22, ATT-24].
|
|
263
289
|
export interface WrapInfo {
|
|
264
290
|
sessions: AgentSummary[];
|
|
265
291
|
// The finished item's own key; the row's is prefixed with "wrap:" so it never collides with it.
|
|
@@ -270,9 +296,12 @@ export interface WrapInfo {
|
|
|
270
296
|
finish: string;
|
|
271
297
|
// A session on someone else's PR that merged: its card says "review session" in words.
|
|
272
298
|
review?: true;
|
|
299
|
+
// An open issue whose PRs of mine all merged: the row asks "Close #12?", and has sessions only when one is open on that
|
|
300
|
+
// work. Closing leaves its sessions to the usual row [ATT-24].
|
|
301
|
+
ask?: true;
|
|
273
302
|
}
|
|
274
303
|
|
|
275
|
-
// A Wrap up row:
|
|
304
|
+
// A Wrap up row: with its sessions and keys; one asking to close an issue may have no session [ATT-22, ATT-24].
|
|
276
305
|
export type WrapItem = Item & { section: "wrap"; wrap: WrapInfo };
|
|
277
306
|
|
|
278
307
|
// The GitHub work an item stands for: itself, the PRs under it, and the work a change note is about, spelled as GitHub
|
|
@@ -341,6 +370,8 @@ export interface NextUpIssue {
|
|
|
341
370
|
projects?: IssueProject[];
|
|
342
371
|
// Open PRs that close it: someone may already be on it [NXT-10].
|
|
343
372
|
openPrs: { number: number; url: string; author: string | null }[];
|
|
373
|
+
// My PRs under it have all merged and Wrap up asks whether to close it [ATT-24].
|
|
374
|
+
prsMerged?: true;
|
|
344
375
|
}
|
|
345
376
|
|
|
346
377
|
// More about an item, fetched when its sheet opens rather than in every refresh [GH-01].
|
|
@@ -376,6 +407,8 @@ export interface Attention {
|
|
|
376
407
|
// My PRs that ended lately, closed by me unmerged or merged: finished work for Wrap up, never shown in History; a merged
|
|
377
408
|
// one stands in until History has it [ATT-22, FRESH-03].
|
|
378
409
|
ownClosed?: Item[];
|
|
410
|
+
// Issues Wrap up asks to close that the live refresh found closed since, or with a PR open for them [ATT-24].
|
|
411
|
+
askOff?: string[];
|
|
379
412
|
}
|
|
380
413
|
|
|
381
414
|
export interface Section {
|
|
@@ -492,6 +525,8 @@ export interface AttentionView {
|
|
|
492
525
|
ownClosed?: Item[];
|
|
493
526
|
// Key -> the keys of the stack or issue group it was last seen open in, lower case [ATT-22, ATT-04].
|
|
494
527
|
groups?: Record<string, string[]>;
|
|
528
|
+
// Open issues whose PRs of mine have all merged, not kept open since: Wrap up asks "Close #12?" [ATT-24].
|
|
529
|
+
closeAsks?: CloseAsk[];
|
|
495
530
|
assigned: NextUpIssue[];
|
|
496
531
|
unclaimed: NextUpIssue[];
|
|
497
532
|
unclaimedFrom: UnclaimedSource;
|
|
@@ -504,6 +539,8 @@ export interface AttentionView {
|
|
|
504
539
|
sources: string[];
|
|
505
540
|
// Project statuses ticked in Next up's filter, as projectFilterId makes them; none means all [NXT-03].
|
|
506
541
|
projectFilter: string[];
|
|
542
|
+
// Unclaimed grouped by repository rather than one list by priority [NXT-14].
|
|
543
|
+
unclaimedByRepo: boolean;
|
|
507
544
|
// Reviewed and Changed by others shown in each of History's weeks; none means finished only [HIS-07].
|
|
508
545
|
historyFilter: HistoryFilter[];
|
|
509
546
|
config: AttentionConfig;
|
package/shared/item-view.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// What an item's card and sheet say and offer, as plain data: client/attention-screen.tsx draws it and wires the presses
|
|
2
2
|
// [ATT-05, ATT-06].
|
|
3
|
-
import { type ActionId, type AgentSummary, type AttentionView, type Chip, type FailingChecks, isWorking, type Item, looseSessions, ownStack, SECTIONS, type SubRow, type TabId, type WaitingOn, type WrapItem } from "./attention";
|
|
3
|
+
import { type ActionId, type AgentSummary, type AttentionView, type Chip, type FailingChecks, isWorking, type Item, looseSessions, ownStack, reviewAgain, SECTIONS, type SubRow, type TabId, type WaitingOn, type WrapItem } from "./attention";
|
|
4
4
|
import { summarizeRerun } from "./checks";
|
|
5
5
|
import type { SessionKind } from "./config";
|
|
6
6
|
import { ago } from "./format";
|
|
@@ -28,7 +28,7 @@ export function actionLabel(action: ActionId, item: Item): string {
|
|
|
28
28
|
return {
|
|
29
29
|
reply: "Reply ↗",
|
|
30
30
|
acknowledge: "Acknowledge",
|
|
31
|
-
review: (item.target.stack?.length ?? 0) > 1 ? "Review stack" : "Review"
|
|
31
|
+
review: `${(item.target.stack?.length ?? 0) > 1 ? "Review stack" : "Review"}${reviewAgain(item.target).length ? " again" : ""}`,
|
|
32
32
|
fix: "Fix CI",
|
|
33
33
|
rerun: "Rerun failed jobs",
|
|
34
34
|
address: "Address comments",
|
|
@@ -57,8 +57,9 @@ export function actionDetail(action: Exclude<ActionId, "rerun">, item: Item): st
|
|
|
57
57
|
reply: item.person ? `Opens ${item.person.login}'s comment on GitHub` : "Opens it on GitHub",
|
|
58
58
|
acknowledge:
|
|
59
59
|
comments.length === 1 ? `Reacts to ${comments[0].author}'s comment, which clears it` : `Pick which of the ${comments.length} waiting comments to react to`,
|
|
60
|
-
review:
|
|
61
|
-
|
|
60
|
+
review: reviewAgain(target).length
|
|
61
|
+
? "An agent reviews what changed since your last review and checks your earlier comments. Nothing is posted"
|
|
62
|
+
: (target.stack?.length ?? 0) > 1
|
|
62
63
|
? `An agent reviews ${asking.map((p) => `#${p.number}`).join(", ") || "the stack"} in a checkout of the stack's top and reports back. Nothing is posted`
|
|
63
64
|
: "An agent reviews the PR in a checkout and reports back. Nothing is posted",
|
|
64
65
|
fix: "An agent reads the failing logs and commits a fix, without pushing",
|
package/shared/next-up-filter.ts
CHANGED
|
@@ -135,3 +135,22 @@ function projectTree(unclaimed: NextUpIssue[], projects: ProjectInfo[]): Project
|
|
|
135
135
|
const noProject = projectFilterId(null);
|
|
136
136
|
return loose ? [...nodes, { id: noProject, title: "No project", children: [{ id: noProject, label: "No project" }] }] : nodes;
|
|
137
137
|
}
|
|
138
|
+
|
|
139
|
+
// Unclaimed by repo [NXT-14]: a group per repository, led by the one with the top issue, each keeping NXT-02's order. Null
|
|
140
|
+
// with fewer than two repositories shown, so there's nothing to group and no switch to offer. Repositories match whatever
|
|
141
|
+
// their case, so one never splits in two.
|
|
142
|
+
export interface RepoGroup {
|
|
143
|
+
repo: string;
|
|
144
|
+
issues: NextUpIssue[];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function repoGroups(shown: NextUpIssue[]): RepoGroup[] | null {
|
|
148
|
+
const groups = new Map<string, RepoGroup>();
|
|
149
|
+
for (const issue of shown) {
|
|
150
|
+
const id = issue.repo.toLowerCase();
|
|
151
|
+
const group = groups.get(id);
|
|
152
|
+
if (group) group.issues.push(issue);
|
|
153
|
+
else groups.set(id, { repo: issue.repo, issues: [issue] });
|
|
154
|
+
}
|
|
155
|
+
return groups.size > 1 ? [...groups.values()] : null;
|
|
156
|
+
}
|
package/shared/prompts.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ActionId, ownStack, type Target } from "./attention";
|
|
1
|
+
import { type ActionId, ownStack, reviewAgain, type Target } from "./attention";
|
|
2
2
|
import type { AttentionConfig, SessionKind } from "./config";
|
|
3
3
|
|
|
4
4
|
// Built-in prompt templates [SES-04]. A template in config.json replaces one.
|
|
@@ -6,20 +6,30 @@ import type { AttentionConfig, SessionKind } from "./config";
|
|
|
6
6
|
// For Review of a stack, {{head}} is its top branch and {{review}} the PRs asking for my review.
|
|
7
7
|
const SWEEP = `Browser sweep, only if you're equipped to (you can run this repo's app and have browser tools): work out which pages and screens the change affects and check each one. If you can't, skip this and say so. Don't spend the session getting the app to run.`;
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const STACK_INTRO = "Review the pull requests {{review}} in {{repo}}, part of the stack {{stack}} (bottom first). You are in a checkout of the top branch, {{head}}, which has every PR's changes.";
|
|
10
|
+
const STACK_DIFF = "for each of {{review}}, read its description (linked below) and its diff against its own base (`git diff origin/<base>...origin/<head>`, branches below).";
|
|
11
|
+
const AGAIN_STEP = "what changed since your last review, that is the commits after the one you reviewed, found as the context below says. Check whether each of your earlier comments was addressed.";
|
|
12
|
+
const AGAIN_REPORT = "Your earlier comments, each: addressed, partly, or not, with where.";
|
|
13
|
+
|
|
14
|
+
// The built-in Review prompt: what to review, the sweep, and what to report.
|
|
15
|
+
function reviewTemplate(intro: string, read: string, touched: string, each: string, again?: string): string {
|
|
16
|
+
return `${intro}
|
|
11
17
|
|
|
12
|
-
1. Review: read
|
|
13
|
-
2. Investigate: dig into anything risky or unclear in
|
|
18
|
+
1. Review: ${read}
|
|
19
|
+
2. Investigate: dig into anything risky or unclear in ${touched}.
|
|
14
20
|
3. ${SWEEP}
|
|
15
|
-
4. Report back:
|
|
16
|
-
- Findings, most important first.
|
|
21
|
+
4. Report back${each}:
|
|
22
|
+
${again ? ` - ${again}\n` : ""} - Findings, most important first.
|
|
17
23
|
- Verdict: approve, request changes or comment, with a one-line reason.
|
|
18
24
|
- Draft review comments, ready to paste, each with file:line.
|
|
19
25
|
|
|
20
26
|
Do not post anything to GitHub.
|
|
21
27
|
|
|
22
|
-
{{context}}
|
|
28
|
+
{{context}}`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const PROMPT_TEMPLATES: Record<SessionKind, string> = {
|
|
32
|
+
review: reviewTemplate("Review pull request {{repo}}#{{number}}: \"{{title}}\" ({{url}}). You are in a checkout of the PR branch.", "read the description and the diff against {{base}}.", "the code it touches", ""),
|
|
23
33
|
|
|
24
34
|
fix: `The checks on pull request {{repo}}#{{number}} "{{title}}" ({{url}}) are failing.
|
|
25
35
|
|
|
@@ -63,19 +73,24 @@ Read the issue and the code it touches, then propose a plan before changing anyt
|
|
|
63
73
|
};
|
|
64
74
|
|
|
65
75
|
// Review of a stack, while config.json doesn't replace the review template: one session for every PR asking for my review [ATT-04].
|
|
66
|
-
export const REVIEW_STACK_TEMPLATE =
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
{
|
|
76
|
+
export const REVIEW_STACK_TEMPLATE = reviewTemplate(STACK_INTRO, `${STACK_DIFF} Review only those; the rest of the stack is context.`, "the code they touch", ", for each PR");
|
|
77
|
+
|
|
78
|
+
// Review asked for again after I reviewed, while config.json doesn't replace the review template: what changed since, and
|
|
79
|
+
// whether my earlier comments were taken up; the context says how to find it [REV-02].
|
|
80
|
+
export const REVIEW_AGAIN_TEMPLATE = reviewTemplate(
|
|
81
|
+
"Review pull request {{repo}}#{{number}}: \"{{title}}\" ({{url}}) again. You reviewed it before, and review was asked for again. You are in a checkout of the PR branch.",
|
|
82
|
+
`${AGAIN_STEP} For context, the PR's whole diff is against {{base}}.`,
|
|
83
|
+
"the code the new commits touch",
|
|
84
|
+
"",
|
|
85
|
+
AGAIN_REPORT,
|
|
86
|
+
);
|
|
87
|
+
export const REVIEW_STACK_AGAIN_TEMPLATE = reviewTemplate(
|
|
88
|
+
`${STACK_INTRO} You reviewed some of them before, and review was asked for again.`,
|
|
89
|
+
`${AGAIN_STEP} For a PR asking for your review that you haven't reviewed before, ${STACK_DIFF.replace(/^for each of \{\{review\}\}, r/, "r")} Review only {{review}}; the rest of the stack is context.`,
|
|
90
|
+
"the code the new commits touch",
|
|
91
|
+
", for each PR",
|
|
92
|
+
AGAIN_REPORT,
|
|
93
|
+
);
|
|
79
94
|
|
|
80
95
|
export const ACTION_SESSION: Partial<Record<ActionId, SessionKind>> = {
|
|
81
96
|
review: "review",
|
|
@@ -94,7 +109,9 @@ export function renderPrompt(
|
|
|
94
109
|
): string {
|
|
95
110
|
const stack = target.stack ?? [];
|
|
96
111
|
const reviewStack = kind === "review" && stack.length > 1;
|
|
97
|
-
const
|
|
112
|
+
const again = kind === "review" && reviewAgain(target).length > 0;
|
|
113
|
+
const builtIn = reviewStack ? (again ? REVIEW_STACK_AGAIN_TEMPLATE : REVIEW_STACK_TEMPLATE) : again ? REVIEW_AGAIN_TEMPLATE : PROMPT_TEMPLATES[kind];
|
|
114
|
+
const template = config.prompts[kind] ?? builtIn;
|
|
98
115
|
// Review reads the whole stack; the rest act on my PRs in it [ATT-04].
|
|
99
116
|
const shown = kind === "review" ? stack : ownStack(target);
|
|
100
117
|
const asking = stack.filter((pr) => pr.review);
|
package/shared/rpc.ts
CHANGED
|
@@ -26,6 +26,8 @@ export const getAttention = defineRpc({
|
|
|
26
26
|
export const dismissItem = defineRpc({ name: "attention.dismiss", input: z.object({ key: z.string() }), output: view });
|
|
27
27
|
// Undo one dismissal [ATT-08].
|
|
28
28
|
export const undismissItem = defineRpc({ name: "attention.undismiss", input: z.object({ key: z.string() }), output: view });
|
|
29
|
+
// Keep open: Wrap up stops asking "Close #12?" until another PR merges under it; `on: false` is its Undo [ATT-24].
|
|
30
|
+
export const keepOpen = defineRpc({ name: "issue.keep-open", input: z.object({ key: z.string(), on: z.boolean() }), output: view });
|
|
29
31
|
// Clears Changed by others notes, one or all of them; `on: false` brings them back for Undo. Nothing changes on GitHub [HIS-07].
|
|
30
32
|
export const gotIt = defineRpc({ name: "attention.got-it", input: z.object({ ids: z.array(z.string()), on: z.boolean() }), output: view });
|
|
31
33
|
// Reviewed and Changed by others in History's weeks; remembered in state.json [HIS-07].
|
|
@@ -72,6 +74,8 @@ export const setScopes = defineRpc({ name: "next-up.scopes", input: z.object({ s
|
|
|
72
74
|
export const setSources = defineRpc({ name: "next-up.sources", input: z.object({ sources: z.array(z.string()) }), output: done });
|
|
73
75
|
// And the project statuses [NXT-03].
|
|
74
76
|
export const setProjectFilter = defineRpc({ name: "next-up.projects", input: z.object({ projects: z.array(z.string()) }), output: done });
|
|
77
|
+
// Unclaimed grouped by repository, or not [NXT-14].
|
|
78
|
+
export const setUnclaimedByRepo = defineRpc({ name: "next-up.by-repo", input: z.object({ on: z.boolean() }), output: view });
|
|
75
79
|
// Whether the gh login may read projects, asked again now, for Settings [NXT-12].
|
|
76
80
|
export const projectsAccess = defineRpc({ name: "config.projects-access", input: z.object({}), output: z.custom<ProjectsAccess>() });
|
|
77
81
|
|