@andrioid/paseo-attention-span 0.7.0 → 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.
Files changed (45) hide show
  1. package/OVERVIEW.md +2 -0
  2. package/client/attention-screen.tsx +3 -0
  3. package/client/entity.tsx +15 -3
  4. package/client/icons.ts +2 -0
  5. package/client/item-actions.ts +24 -0
  6. package/client/next-up.tsx +49 -7
  7. package/client/ui.tsx +4 -1
  8. package/client/wrap-up.tsx +51 -4
  9. package/docs/architecture.md +2 -1
  10. package/docs/screenshots/desktop-dark-doing-acknowledge.png +0 -0
  11. package/docs/screenshots/desktop-dark-doing-clear.png +0 -0
  12. package/docs/screenshots/desktop-dark-doing-issue-sheet.png +0 -0
  13. package/docs/screenshots/desktop-dark-doing-reviewers.png +0 -0
  14. package/docs/screenshots/desktop-dark-doing-sheet.png +0 -0
  15. package/docs/screenshots/desktop-dark-doing-wrap-dirty.png +0 -0
  16. package/docs/screenshots/desktop-dark-doing-wrap-multi.png +0 -0
  17. package/docs/screenshots/desktop-dark-doing-wrap.png +0 -0
  18. package/docs/screenshots/desktop-dark-doing.png +0 -0
  19. package/docs/screenshots/desktop-dark-history-filtered.png +0 -0
  20. package/docs/screenshots/desktop-dark-history-groups.png +0 -0
  21. package/docs/screenshots/desktop-dark-history.png +0 -0
  22. package/docs/screenshots/desktop-dark-next-up-setup.png +0 -0
  23. package/docs/screenshots/desktop-dark-next-up.png +0 -0
  24. package/docs/screenshots/desktop-dark-settings.png +0 -0
  25. package/docs/screenshots/desktop-dark-setup.png +0 -0
  26. package/docs/screenshots/desktop-dark-waiting.png +0 -0
  27. package/docs/screenshots/phone-dark-doing.png +0 -0
  28. package/docs/screenshots/phone-dark-history.png +0 -0
  29. package/docs/screenshots/phone-light-next-up-filtered.png +0 -0
  30. package/index.server.ts +2 -0
  31. package/package.json +1 -1
  32. package/requirements.yaml +2 -0
  33. package/server/classify.ts +29 -0
  34. package/server/fetch.ts +29 -3
  35. package/server/fixture.ts +16 -5
  36. package/server/github-types.ts +13 -0
  37. package/server/queries.ts +14 -0
  38. package/server/references.ts +12 -0
  39. package/server/service.ts +90 -11
  40. package/server/store.ts +17 -2
  41. package/server/view.ts +24 -4
  42. package/shared/attention.ts +26 -2
  43. package/shared/next-up-filter.ts +19 -0
  44. package/shared/rpc.ts +4 -0
  45. package/shared/wrap-up.ts +34 -9
package/OVERVIEW.md CHANGED
@@ -10,6 +10,8 @@ This is the one you'll live in. At the top is **Wrap up**: finished or handed-of
10
10
 
11
11
  Wrap up is the cleanup pass. A PR that merged, an issue that closed, work that left your hands, a review you finished on someone else's PR: if one of your sessions is still open on it, it sits here once the agent is idle, newest finish first. **Archive session** puts the session, the sub-agents it started and its worktree away. If anything is uncommitted or unpushed, or the worktree has terminals open, you get a sheet first, shaped like Paseo's own: "Uncommitted changes: 2 files (+12 −3)", "1 unpushed commit", the terminals it closes, with **Open session** beside **Archive**; several sessions get a list of their own. **Archive all clean** does the tidy ones in one go. A worktree another session still lives in stays, and so does its row, saying which session kept it, until the worktree goes or you dismiss it; a local checkout is never archived; and there's no Undo, which is exactly why it checks first. Archived work goes to History as already read, not as a new note.
12
12
 
13
+ Sometimes all the PRs under an issue merge and the issue stays open anyway: they went into a feature branch, or the description only mentioned it. Wrap up asks about those too, session or not: "Close #12? #34 and #35 merged 2h ago". **Close #12** closes it as completed, with Undo. The × keeps it open until another PR of yours merges under it, which covers "first of three" plans. While it's asking, the issue stays in Next up with a "PRs merged" pill. A session open on that work joins the question's row, and becomes an ordinary Archive session row once you've answered.
14
+
13
15
  ![Doing](docs/screenshots/desktop-dark-doing.png)
14
16
 
15
17
  Each item shows up once, under whichever reason is most urgent. An issue and the PRs that close it count as one item, and so does a stack of PRs. A stack is one change wearing several PRs, so it shouldn't take up five rows.
@@ -215,6 +215,7 @@ function AttentionList({
215
215
  login={view.login}
216
216
  fixture={!!view.fixtureAgents}
217
217
  openAgent={act.openAgent}
218
+ {...act.askActions}
218
219
  onArchive={(item, confirm, terminals) => act.archiveRows([item], confirm, item.key, terminals)}
219
220
  onArchiveAll={async () => {
220
221
  const clean = wrap.filter(cleanSingle);
@@ -260,6 +261,8 @@ function AttentionList({
260
261
  projects={view.projects}
261
262
  selectedProjects={view.projectFilter}
262
263
  onFilter={(change) => act.filterNextUp(view, change)}
264
+ byRepo={view.unclaimedByRepo ?? false}
265
+ onByRepo={(on) => act.groupNextUp(view, on)}
263
266
  // Narrowed to one repository, a new issue starts there [ISS-01].
264
267
  onNewIssue={() => setNewIssue({ nextUp: view.sources.length === 1 && view.sources[0].startsWith("repo:") ? view.sources[0].slice(5) : undefined })}
265
268
  agents={actions.agents}
package/client/entity.tsx CHANGED
@@ -26,13 +26,25 @@ export function NumberText({ number }: { number: number }) {
26
26
  // "#160 · acme/shop", to lead a Meta line: the number on its own first, then the repo with its name standing out from its
27
27
  // owner, so cards from several repos scan.
28
28
  export function PlaceText({ place }: { place: Place }) {
29
- const strong = useStrongText();
30
- const label = repoLabel(place.repo, place.login);
31
- const cut = label.lastIndexOf("/") + 1;
32
29
  return (
33
30
  <>
34
31
  <NumberText number={place.number} />
35
32
  {" · "}
33
+ <RepoText repo={place.repo} login={place.login} />
34
+ </>
35
+ );
36
+ }
37
+
38
+ // "acme/shop" with its name standing out from its owner; mine without the owner where `login` is given. Bold where it heads
39
+ // a group [NXT-14].
40
+ export function RepoText({ repo, login, bold }: { repo: string; login: string | null; bold?: boolean }) {
41
+ const { c } = useStyles();
42
+ const text = useStrongText();
43
+ const strong = bold ? { color: c.foreground, fontWeight: "600" as const } : text;
44
+ const label = repoLabel(repo, login);
45
+ const cut = label.lastIndexOf("/") + 1;
46
+ return (
47
+ <>
36
48
  {label.slice(0, cut)}
37
49
  <Text style={strong}>{label.slice(cut)}</Text>
38
50
  </>
package/client/icons.ts CHANGED
@@ -57,6 +57,8 @@ export const ICONS = {
57
57
  userMinus: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M8 7a4 4 0 1 0 8 0a4 4 0 0 0-8 0M6 21v-2a4 4 0 0 1 4-4h4c.348 0 .686.045 1.009.128M16 19h6\"/></svg>" },
58
58
  // Tabler archive: puts a finished item's Paseo sessions away [ATT-22].
59
59
  archive: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><path d=\"M3 4a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z\"/><path d=\"M5 8v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8M10 12h4\"/></g></svg>" },
60
+ // Tabler folder: a repository, as Unclaimed groups by them [NXT-14].
61
+ folder: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 4h4l3 3h7a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2\"/></svg>" },
60
62
  chevronDown: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m6 9l6 6l6-6\"/></svg>" },
61
63
  // Tabler message-ai: marks actions that start or continue an agent session.
62
64
  agent: { svg: "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><path d=\"M8 9h8m-8 4h3.5m-1.506 6.804L8 21v-3H6a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v4\"/><path d=\"M14 21v-4a2 2 0 1 1 4 0v4m-4-2h4m3-4v6\"/></g></svg>" },
@@ -102,8 +102,10 @@ export function useItemActions(attention: ReturnType<typeof useAttention>, navig
102
102
  const saveScopes = useRpc(rpc.setScopes);
103
103
  const saveSources = useRpc(rpc.setSources);
104
104
  const saveProjects = useRpc(rpc.setProjectFilter);
105
+ const saveByRepo = useRpc(rpc.setUnclaimedByRepo);
105
106
  const closeIssue = useRpc(rpc.closeIssue);
106
107
  const reopenIssue = useRpc(rpc.reopenIssue);
108
+ const keepOpen = useRpc(rpc.keepOpen);
107
109
  const update = useRpc(rpc.updateBranch);
108
110
  const merge = useRpc(rpc.mergePullRequest);
109
111
  const close = useRpc(rpc.closePullRequest);
@@ -340,6 +342,19 @@ export function useItemActions(attention: ReturnType<typeof useAttention>, navig
340
342
  },
341
343
  };
342
344
 
345
+ // Wrap up's "Close #12?": closes as completed, or keeps it open until another PR merges under it; each with Undo [ATT-24].
346
+ const askActions = {
347
+ onCloseIssue: (item: WrapItem) => {
348
+ const key = item.wrap.itemKey;
349
+ const target: Target = { kind: "issue", repo: item.repo, number: item.number, title: item.title, url: item.url };
350
+ change(item.key, "Close", () => closeIssue({ key, target, reason: "completed" }), `Closed #${item.number} as completed`, () => reopenIssue({ key, target }));
351
+ },
352
+ onKeepOpen: (item: WrapItem) => {
353
+ const key = item.wrap.itemKey;
354
+ change(item.key, "Keep open", () => keepOpen({ key, on: true }), `Kept #${item.number} open`, () => keepOpen({ key, on: false }));
355
+ },
356
+ };
357
+
343
358
  const failedSaving = (error: Error) => toast.error(`Saving the filter failed: ${error.message}`);
344
359
  // Ticks apply right away, like Next up's; the server remembers them [HIS-07].
345
360
  function filterHistory(view: AttentionView, next: HistoryFilter[]) {
@@ -355,6 +370,13 @@ export function useItemActions(attention: ReturnType<typeof useAttention>, navig
355
370
  if (change.sources) saveSources({ sources: change.sources }).catch(failedSaving);
356
371
  if (change.projectFilter) saveProjects({ projects: change.projectFilter }).catch(failedSaving);
357
372
  }
373
+ // Shown at once, and remembered; the saved view then wins over a refresh that started before it [NXT-14].
374
+ function groupNextUp(view: AttentionView, on: boolean) {
375
+ attention.setView({ ...view, unclaimedByRepo: on });
376
+ saveByRepo({ on })
377
+ .then((saved) => attention.setView(saved))
378
+ .catch((error: Error) => toast.error(`Saving the grouping failed: ${error.message}`));
379
+ }
358
380
 
359
381
  return {
360
382
  busy,
@@ -381,7 +403,9 @@ export function useItemActions(attention: ReturnType<typeof useAttention>, navig
381
403
  dismissKept: (row: KeptRow) => void run(`kept:${row.workspaceId}`, "Dismiss", async () => attention.setView(await dismissKept({ workspaceId: row.workspaceId }))),
382
404
  itemActions,
383
405
  issueActions,
406
+ askActions,
384
407
  filterHistory,
385
408
  filterNextUp,
409
+ groupNextUp,
386
410
  };
387
411
  }
@@ -13,15 +13,15 @@ import {
13
13
  type UnclaimedSource,
14
14
  } from "../shared/attention";
15
15
  import type { NextUpSource } from "../shared/config";
16
- import { CLEAR_FILTER, type FilterChange, nextUpFilter } from "../shared/next-up-filter";
16
+ import { CLEAR_FILTER, type FilterChange, nextUpFilter, repoGroups } from "../shared/next-up-filter";
17
17
  import type { IconName } from "./icons";
18
18
  import type { FetchDetails } from "./item-actions";
19
19
  import { CardList, CardRow, type Tone } from "./card";
20
20
  import { sessionEntry, startAnotherEntry } from "./session-menu";
21
21
  import { ActionSheet, DETAILS_STALE_MS, DetailLines, type DetailsQuery, detailsKey, FilterSheet, githubEntry, type SheetEntry, usePrefetchOnRest } from "./sheet";
22
- import { IssuePills, PlaceText } from "./entity";
22
+ import { IssuePills, PlaceText, RepoText } from "./entity";
23
23
  import { Still } from "./still";
24
- import { Button, FilterButton, Meta, SectionHeader, useStyles } from "./ui";
24
+ import { Button, FilterButton, Meta, SectionHeader, TablerIcon, useStyles } from "./ui";
25
25
 
26
26
  const TYPE_ICONS: Record<string, IconName> = { bug: "bug", feature: "feature", debt: "debt", task: "task", epic: "epic" };
27
27
 
@@ -42,6 +42,9 @@ interface Props {
42
42
  selectedProjects: string[];
43
43
  // Change any filter or all at once, so Clear empties them in one go.
44
44
  onFilter: (change: FilterChange) => void;
45
+ // Unclaimed grouped by repository, and turning it on or off [NXT-14].
46
+ byRepo: boolean;
47
+ onByRepo: (on: boolean) => void;
45
48
  agents: AgentSummary[];
46
49
  // Mine, so my repos show without the owner.
47
50
  login: string | null;
@@ -59,16 +62,18 @@ interface Props {
59
62
  onNewIssue: () => void;
60
63
  }
61
64
 
62
- type RowProps = Omit<Props, "calm" | "openSettings" | "assigned" | "unclaimed" | "unclaimedFrom" | "selected" | "sources" | "selectedSources" | "projects" | "selectedProjects" | "onFilter" | "onNewIssue">;
65
+ type RowProps = Omit<Props, "calm" | "openSettings" | "assigned" | "unclaimed" | "unclaimedFrom" | "selected" | "sources" | "selectedSources" | "projects" | "selectedProjects" | "onFilter" | "byRepo" | "onByRepo" | "onNewIssue">;
63
66
 
64
67
  // Assigned issues first [NXT-06], then unclaimed ones [NXT-01]; both already ranked by the server [NXT-02].
65
- export function NextUpList({ calm, openSettings, assigned, unclaimed, unclaimedFrom, selected, sources, selectedSources, projects, selectedProjects, onFilter, onNewIssue, ...rowProps }: Props) {
68
+ export function NextUpList({ calm, openSettings, assigned, unclaimed, unclaimedFrom, selected, sources, selectedSources, projects, selectedProjects, onFilter, byRepo, onByRepo, onNewIssue, ...rowProps }: Props) {
66
69
  const styles = useStyles();
67
70
  const filter = useMemo(
68
71
  () => nextUpFilter({ unclaimed, selected, sources, selectedSources, projects, selectedProjects }),
69
72
  [unclaimed, selected, sources, selectedSources, projects, selectedProjects],
70
73
  );
71
74
  const { shown, picked, groups } = filter;
75
+ // Only with two repositories or more is there anything to group [NXT-14].
76
+ const repos = useMemo(() => repoGroups(shown), [shown]);
72
77
  const [filtering, setFiltering] = useState(false);
73
78
 
74
79
  // Both point at where Next up looks: plainly when it has nowhere to look, quietly when it found nothing [NXT-13].
@@ -96,7 +101,18 @@ export function NextUpList({ calm, openSettings, assigned, unclaimed, unclaimedF
96
101
  count={shown.length}
97
102
  action={
98
103
  <View style={styles.wrap}>
99
- <Button label="New issue" icon="plus" variant="ghost" onPress={onNewIssue} />
104
+ {/* Just icons on a phone, so the header stays one line with Filter in it [NXT-14]. */}
105
+ {repos ? (
106
+ <Button
107
+ label={styles.compact ? undefined : "Group by repo"}
108
+ accessibilityLabel="Group by repo"
109
+ icon="folder"
110
+ variant={byRepo ? "calm" : "ghost"}
111
+ pressed={byRepo}
112
+ onPress={() => onByRepo(!byRepo)}
113
+ />
114
+ ) : null}
115
+ <Button label={styles.compact ? undefined : "New issue"} accessibilityLabel="New issue" icon="plus" variant="ghost" onPress={onNewIssue} />
100
116
  {groups.length > 0 ? <FilterButton count={picked} onPress={() => setFiltering(true)} /> : null}
101
117
  </View>
102
118
  }
@@ -114,6 +130,15 @@ export function NextUpList({ calm, openSettings, assigned, unclaimed, unclaimedF
114
130
  <Text style={styles.text}>No repos to look in. Register a project in Paseo, or choose where Next up looks in Settings.</Text>
115
131
  ) : shown.length === 0 ? (
116
132
  <Text style={styles.text}>{filter.empty}</Text>
133
+ ) : byRepo && repos ? (
134
+ <View style={{ gap: 8 }}>
135
+ {repos.map((group, index) => (
136
+ <View key={group.repo} style={{ gap: 8, marginTop: index ? 10 : 0 }}>
137
+ <RepoHeading repo={group.repo} count={group.issues.length} login={rowProps.login} />
138
+ <IssueList issues={group.issues} claim {...rowProps} />
139
+ </View>
140
+ ))}
141
+ </View>
117
142
  ) : (
118
143
  <IssueList issues={shown} claim {...rowProps} />
119
144
  )}
@@ -122,6 +147,21 @@ export function NextUpList({ calm, openSettings, assigned, unclaimed, unclaimedF
122
147
  );
123
148
  }
124
149
 
150
+ // A repository's name over its issues, standing out more than History's sub-groups, since it's what the list is sorted by
151
+ // [NXT-14]. Cards keep their repo too, for when this has scrolled away [NXT-10].
152
+ function RepoHeading({ repo, count, login }: { repo: string; count: number; login: string | null }) {
153
+ const styles = useStyles();
154
+ return (
155
+ <View style={[styles.row, { gap: 6, paddingVertical: 2 }]} accessibilityRole="header">
156
+ <TablerIcon name="folder" size={14} color={styles.c.foregroundMuted} />
157
+ <Text style={[styles.muted, { fontSize: 13 }]}>
158
+ <RepoText repo={repo} login={login} bold />
159
+ {` · ${count}`}
160
+ </Text>
161
+ </View>
162
+ );
163
+ }
164
+
125
165
  function IssueList({ issues, claim, ...rowProps }: RowProps & { issues: NextUpIssue[]; claim: boolean }) {
126
166
  return (
127
167
  <CardList>
@@ -132,8 +172,10 @@ function IssueList({ issues, claim, ...rowProps }: RowProps & { issues: NextUpIs
132
172
  );
133
173
  }
134
174
 
135
- // An open PR that closes it means someone may already be on it [NXT-10].
175
+ // An open PR that closes it means someone may already be on it [NXT-10]; my PRs under it all merged mean it may be done,
176
+ // while Wrap up asks [ATT-24].
136
177
  function prSignal(issue: NextUpIssue): Chip[] {
178
+ if (issue.prsMerged) return [{ text: "PRs merged", tone: "good" }];
137
179
  const [first, ...more] = issue.openPrs;
138
180
  if (!first) return [];
139
181
  return [{ text: `PR by ${first.author ?? "someone"}${more.length ? ` +${more.length}` : ""}`, tone: "warn" }];
package/client/ui.tsx CHANGED
@@ -294,7 +294,7 @@ export function useHover() {
294
294
  }
295
295
 
296
296
  // Calm by default: accent text on a subtle surface. Solid accent is for confirmations.
297
- // Busy: a spinner in place of the icon, and no second press while it runs.
297
+ // Busy: a spinner in place of the icon, and no second press while it runs. Pressed: a toggle, on or off, said as aria-pressed since React Native Web drops accessibilityState.
298
298
  export function Button({
299
299
  label,
300
300
  icon,
@@ -302,6 +302,7 @@ export function Button({
302
302
  variant = "plain",
303
303
  disabled,
304
304
  busy,
305
+ pressed,
305
306
  accessibilityLabel,
306
307
  }: {
307
308
  label?: string;
@@ -310,6 +311,7 @@ export function Button({
310
311
  variant?: Variant;
311
312
  disabled?: boolean;
312
313
  busy?: boolean;
314
+ pressed?: boolean;
313
315
  accessibilityLabel?: string;
314
316
  }) {
315
317
  const styles = useStyles();
@@ -321,6 +323,7 @@ export function Button({
321
323
  accessibilityRole="button"
322
324
  accessibilityLabel={accessibilityLabel ?? label ?? icon}
323
325
  accessibilityState={{ disabled: disabled || busy, busy }}
326
+ aria-pressed={pressed}
324
327
  disabled={disabled || busy}
325
328
  onPress={onPress}
326
329
  {...hover}
@@ -1,4 +1,5 @@
1
1
  import { useState } from "react";
2
+ import { openExternalUrl } from "@getpaseo/plugin/client";
2
3
  import { Text, View } from "react-native";
3
4
  import type { AgentSummary, WrapItem } from "../shared/attention";
4
5
  import { type ArchiveOutcome, type KeptRow, keptText, sheetLines, type UnsavedSession, unsavedWords } from "../shared/archive";
@@ -29,7 +30,22 @@ interface KeptProps {
29
30
  }
30
31
 
31
32
  // Finished or out-of-my-hands work whose Paseo sessions are all idle: the cleanup Doing owns [ATT-22].
32
- export function WrapUp({ items, onArchiveAll, kept, onArchiveWorktree, onDismissKept, ...row }: { items: WrapItem[]; onArchiveAll: () => Promise<void> } & RowProps & KeptProps) {
33
+ interface AskProps {
34
+ // Close as completed, with Undo, or Keep open until another PR merges under it [ATT-24].
35
+ onCloseIssue: (item: WrapItem) => void;
36
+ onKeepOpen: (item: WrapItem) => void;
37
+ }
38
+
39
+ export function WrapUp({
40
+ items,
41
+ onArchiveAll,
42
+ kept,
43
+ onArchiveWorktree,
44
+ onDismissKept,
45
+ onCloseIssue,
46
+ onKeepOpen,
47
+ ...row
48
+ }: { items: WrapItem[]; onArchiveAll: () => Promise<void> } & RowProps & KeptProps & AskProps) {
33
49
  const styles = useStyles();
34
50
  const clean = items.filter(cleanSingle);
35
51
  return (
@@ -53,9 +69,13 @@ export function WrapUp({ items, onArchiveAll, kept, onArchiveWorktree, onDismiss
53
69
  }
54
70
  />
55
71
  <CardList>
56
- {items.map((item, index) => (
57
- <WrapRow key={item.key} item={item} first={index === 0} {...row} />
58
- ))}
72
+ {items.map((item, index) =>
73
+ item.wrap.ask ? (
74
+ <AskRow key={item.key} item={item} first={index === 0} busy={row.busy} login={row.login} openSession={row.openAgent} onCloseIssue={onCloseIssue} onKeepOpen={onKeepOpen} />
75
+ ) : (
76
+ <WrapRow key={item.key} item={item} first={index === 0} {...row} />
77
+ ),
78
+ )}
59
79
  {kept.map((keptRow, index) => (
60
80
  <KeptWorktreeRow
61
81
  key={keptRow.workspaceId}
@@ -73,6 +93,33 @@ export function WrapUp({ items, onArchiveAll, kept, onArchiveWorktree, onDismiss
73
93
  );
74
94
  }
75
95
 
96
+ // An open issue whose PRs of mine all merged: "Close #12? #34 and #35 merged 2h ago", Close #12, or × to keep it open until
97
+ // another merges. A session open on the work waits for the usual row, which closing leaves behind [ATT-24].
98
+ function AskRow({
99
+ item,
100
+ first,
101
+ busy,
102
+ login,
103
+ openSession,
104
+ onCloseIssue,
105
+ onKeepOpen,
106
+ }: { item: WrapItem; first: boolean; busy: ReadonlySet<string>; login: string | null; openSession: (agentId: string) => void } & AskProps) {
107
+ const { sessions } = item.wrap;
108
+ const still = sessions.length > 1 ? ` · ${sessions.length} sessions still open` : sessions.length ? " · your session's still open" : "";
109
+ return (
110
+ <CardRow
111
+ first={first}
112
+ mark={stateMark(item)}
113
+ title={item.title}
114
+ meta={{ place: { repo: item.repo, number: item.number, login }, when: `Close #${item.number}? ${item.wrap.finish}${still}`, signals: [] }}
115
+ onOpen={() => (sessions[0] ? openSession(sessions[0].id) : void openExternalUrl(item.url))}
116
+ busy={wrapBusy(busy, item.key)}
117
+ primary={{ label: `Close #${item.number}`, accessibilityLabel: `Close #${item.number} as completed`, icon: "issueClosed", onPress: () => onCloseIssue(item) }}
118
+ secondary={[{ label: "Keep open", icon: "close", accessibilityLabel: `Keep #${item.number} open`, onPress: () => onKeepOpen(item) }]}
119
+ />
120
+ );
121
+ }
122
+
76
123
  // "merged by dave 2h ago · your session's still open": what finishing looked like, then the session it left behind [ATT-22].
77
124
  function wrapMeta({ wrap }: WrapItem): string {
78
125
  const still = wrap.review ? "your review session's still open" : wrap.sessions.length > 1 ? `${wrap.sessions.length} sessions still open` : "your session's still open";
@@ -84,7 +84,7 @@ Top to bottom. Each item appears once, under its most urgent reason [ATT-02]. `s
84
84
  | Needs upstream | My PRs with conflicts or an out-of-sync stack [UPS-01, UPS-02] |
85
85
  | Needs a reviewer | My PRs nobody has been asked to review, even while CI runs [PRS-12]. Only what GitHub records counts as asked: a pending request, an approval or requested changes. GitHub drops a reviewer's request once they review, so a review that only commented, by a person or a bot, leaves it here to re-request; the repo, not us, decides whose approval counts |
86
86
  | My drafts | My drafts, with their own state tags [PRS-05, PRS-06] |
87
- | Wrap up | First, the cleanup: finished or out-of-my-hands work whose unarchived Paseo sessions are all idle, including a review session on someone else's merged PR [ATT-22]. It takes merged, closed and handed-off items, mine or anyone's, including my own PRs I closed without merging ("closed 3h ago, not merged", from the live closed search, never listed in History) and my merged PRs from the same search, which stand in until History has them (`ownClosed` in `server/changes.ts`; History's entry wins) [FRESH-03], as far back as History and its ledger keep, with no age cutoff of its own; a stack or issue group enters only when everything its sessions serve is done, and counts once; one session never makes two rows. A busy session keeps its row out until idle. Newest finish first, each row saying what happened and what is still open: "merged by dave 2h ago · your session's still open", "merged by alice 1d ago · your review session's still open", "2 sessions still open", with an amber "unsaved changes" where a worktree has them. **Archive session** (plural for several) archives the item's agents and the sub-agents they started; a worktree goes too only when it's Paseo's and no other session lives in it, never a local checkout. A sub-agent still running or starting, or flagged for anything but finished or failed (a permission, say), keeps its session's row out, like a busy session; a finished or failed one Paseo still flags for attention doesn't (`subAgentBusy`), as nobody opens a sub-agent and reporting back is its parent's job. One idle session with nothing uncommitted or unpushed archives at once; unsaved or unknown work, or a terminal open in a worktree that goes, asks first in a sheet shaped like Paseo's own "Archive workspace" one: 'Archive "Split invoice PDF"?' when the worktree goes with it (else "Archive the session on #186?"), then each session's lines in Paseo's words ("Uncommitted changes: 2 files (+12 −3)", "1 unpushed commit", "Couldn't check for unsaved changes") and a muted "Closes terminals: dev, shell", with Open session and Archive; a terminal that opened after the sheet brings it back; the multi sheet notes "+1 sub-agent" under a session that has them; several sessions open a sheet listing each one's state with Open; archiving from there checks first too, and any unsaved work it finds gets the naming confirm. **Archive all clean · n** sits in the header with 2+ rows and archives every clean single-session row; it and single archives wait for each other like Got it and Mark all. Success acknowledges exactly the changes present at that moment, so they go to their week as cleared rather than History's unread notes; so does archiving a session Attention Span started in Paseo itself, for what others did up to then, once no session it started is left on that work; a failure keeps the row and says why, and a worktree that stayed after its sessions went keeps a row in Wrap up, uncounted, saying why, briefly, beside the archive mark ("Fix flaky test still in it", "dev server opened meanwhile", "Paseo: worktree is locked") with a button for the reason (Open session, Archive worktree, Try again) and × to dismiss; it goes once the worktree is archived anywhere, and keeps the horizon away until then. Until the session list has loaded, or when it fails, Wrap up isn't known: Doing says so instead of showing the horizon. There is no Undo: Paseo's SDK can't restore a workspace and its agents, so the dirty check and confirmation are the safeguard instead. Its rows count in Doing's and the sidebar's count, and keep the horizon away. |
87
+ | Wrap up | First, the cleanup: finished or out-of-my-hands work whose unarchived Paseo sessions are all idle, including a review session on someone else's merged PR [ATT-22]. It takes merged, closed and handed-off items, mine or anyone's, including my own PRs I closed without merging ("closed 3h ago, not merged", from the live closed search, never listed in History) and my merged PRs from the same search, which stand in until History has them (`ownClosed` in `server/changes.ts`; History's entry wins) [FRESH-03], as far back as History and its ledger keep, with no age cutoff of its own; a stack or issue group enters only when everything its sessions serve is done, and counts once; one session never makes two rows. A busy session keeps its row out until idle. Newest finish first, each row saying what happened and what is still open: "merged by dave 2h ago · your session's still open", "merged by alice 1d ago · your review session's still open", "2 sessions still open", with an amber "unsaved changes" where a worktree has them. **Archive session** (plural for several) archives the item's agents and the sub-agents they started; a worktree goes too only when it's Paseo's and no other session lives in it, never a local checkout. A sub-agent still running or starting, or flagged for anything but finished or failed (a permission, say), keeps its session's row out, like a busy session; a finished or failed one Paseo still flags for attention doesn't (`subAgentBusy`), as nobody opens a sub-agent and reporting back is its parent's job. One idle session with nothing uncommitted or unpushed archives at once; unsaved or unknown work, or a terminal open in a worktree that goes, asks first in a sheet shaped like Paseo's own "Archive workspace" one: 'Archive "Split invoice PDF"?' when the worktree goes with it (else "Archive the session on #186?"), then each session's lines in Paseo's words ("Uncommitted changes: 2 files (+12 −3)", "1 unpushed commit", "Couldn't check for unsaved changes") and a muted "Closes terminals: dev, shell", with Open session and Archive; a terminal that opened after the sheet brings it back; the multi sheet notes "+1 sub-agent" under a session that has them; several sessions open a sheet listing each one's state with Open; archiving from there checks first too, and any unsaved work it finds gets the naming confirm. **Archive all clean · n** sits in the header with 2+ rows and archives every clean single-session row; it and single archives wait for each other like Got it and Mark all. Success acknowledges exactly the changes present at that moment, so they go to their week as cleared rather than History's unread notes; so does archiving a session Attention Span started in Paseo itself, for what others did up to then, once no session it started is left on that work; a failure keeps the row and says why, and a worktree that stayed after its sessions went keeps a row in Wrap up, uncounted, saying why, briefly, beside the archive mark ("Fix flaky test still in it", "dev server opened meanwhile", "Paseo: worktree is locked") with a button for the reason (Open session, Archive worktree, Try again) and × to dismiss; it goes once the worktree is archived anywhere, and keeps the horizon away until then. Until the session list has loaded, or when it fails, Wrap up isn't known: Doing says so instead of showing the horizon. There is no Undo: Paseo's SDK can't restore a workspace and its agents, so the dirty check and confirmation are the safeguard instead. Its rows count in Doing's and the sidebar's count, and keep the horizon away. An open issue whose PRs of mine have all merged, with no PR open for it, gets a row too, with or without a session: "Close #12? #34 and #35 merged 2h ago", **Close #12** (as completed, no comment, Undo reopens) and × for Keep open, which lasts until another PR of mine merges under it (Undo too); its merged PRs' idle sessions join that row instead of making their own, and once it's closed they're the usual row. Archive all clean leaves it [ATT-24]. |
88
88
 
89
89
  **Nothing in Doing** shows a horizon instead of a list (`client/still.tsx`) [ATT-18], with "Nothing's on you. Enjoy the quiet." It follows the device's clock at fixed hours: a low sun in the morning (5–11), a high sun at midday (11–16), a setting sun in the evening (16–21), and a moon with a few stars at night, each in its own soft tint. It settles in on every arrival on the tab (the sky drifts up as it fades in, then its reflections, 700 ms; not with reduced motion), then holds still; when the hour changes while it's open, it crossfades. It shows only after a refresh that worked: before the first one there's a spinner, and after a failed one just the error. Items that are all dismissed count as clear; the "show them again" line sits faintly at the bottom. Wrap up's rows don't: the horizon waits until they're archived too [ATT-22]. Changed by others never touches Doing; it lives in History [HIS-07].
90
90
 
@@ -97,6 +97,7 @@ Top to bottom. Each item appears once, under its most urgent reason [ATT-02]. `s
97
97
  - **Handed over** [PRS-08]: my PRs assigned to someone else, and not to me, are left out. Mentions of me on them still count. A PR of mine with nobody assigned is mine.
98
98
  - **Changed by others** [HIS-07] (`server/changes.ts`) keeps a ledger of what others did, in `state.json`, by GitHub's node ids, which a transfer keeps. Only someone else's doing counts; my own actions and others' pushes don't. Merges, unmerged closes and issue closes come from live searches: `mergedBy`, the last close event's actor, and an issue's `stateReason`. A PR that left my hands before it ended counts as the handover, not the merge; one assigned to someone after it ended is still my merge, and a PR someone else has waits a refresh for its lookup rather than be called a merge. Handovers come from GitHub's assign and unassign events, which are separate, never one "handover": a PR is looked up when it's assigned to someone else and not me, once per change of its assignees; it left my hands with whichever came last of my removal and the new owner's assignment, so a PR I took myself off is mine until someone takes it, and an earlier round's removal doesn't name who took it this time; an issue when it leaves my assigned search since the last refresh that worked. Leaving the search proves nothing (search lag, a coverage change, its 50 results), so only an unassign event of me by someone else counts; one closed by then is left to its close note. So unassignments are noticed only for issues Attention Span has seen assigned to me; on the first run none count as gone. A PR seen closed unmerged is tracked; once it drops out of the closed search, as a reopen takes it out, a batch asks for its state and last reopen event. A reopen removes the old close from its week whoever did it, and only someone else's is a note; a merged one stops being tracked, and nothing older than the ledger's window is tracked. A first run tracks from then on, so old closes don't replay as new. A failed lookup, or one node in it GitHub failed on (anything but not found), is asked again on the next refresh. A PR handed over isn't listed under the finished issue it closed either; when a cleared handover's work comes back to me it stays in its week, marked returned, so my later work on it is mine again. Events are kept `historyWeeks` + 1 weeks, or `mentionDays` if longer; unread notes expire after `mentionDays` for History's top section.
99
99
  - **Wrap up** [ATT-22] (`shared/wrap-up.ts`, drawn by `client/wrap-up.tsx`) is assembled on the client from the sessions the screen and the sidebar already poll; the server archives and acknowledges. An item's identity is `memberKeys` in `shared/attention.ts`: its key, the PRs under it and the work a change note is about, spelled as GitHub spells them since Paseo's labels match exactly, and compared ignoring case (`shared/names.ts`, as all GitHub names are); Wrap up, archiving and acknowledging all use it. A finished item, reviewed PR, my own unmerged close, cleared change or unread change is a candidate; its sessions are the ones on any of its member keys. It enters when it has at least one unarchived session, every one is idle (not working and not needing me), none serves an item still in Doing or Waiting, and no session already belongs to another row. History lists a merged PR alone, as its branches are gone, so each live refresh remembers every open stack's and issue group's keys under each member (`groups` in `state.json`, kept as long as the ledger): a merged member whose remembered sibling is still open stays out, and so does its session. The screen freezes rows whose archive runs and Archive all clean while any row's archive runs (`shared/got-it.ts`). Archiving goes through `paseo.agents.ref(id).archive()`, sub-agents first (found by Paseo's `paseo.parent-agent-id` label, `subAgentsOf` in `shared/linked-sessions.ts`; one in another workspace is archived, its workspace left alone; archive lists every page of agents, archived ones too, so one under an archived sub-agent still counts, and a sub-agent that won't archive and stays open stops the archive before its session goes); a Paseo worktree is archived too, through `paseo.workspaces.archive`, which archives everything in it, only when every unarchived agent in it is being archived, and a local checkout never is. Workspaces are named as Paseo's sidebar names them: the title, else the branch. A worktree that stays is a `KeptRow` in `state.json` (`kept`) with its row's item; the `workspace.archived` hook forgets it, and remembers the workspace so an archive still running doesn't add it back, Dismiss forgets it, and Archive worktree or Try again runs the same checks on the worktree alone (`rpc.archiveWorktree`). Paseo closes a worktree's terminals when it archives it, so they're listed (`paseo.terminals.list`) right before archiving and named on the sheet; the confirm sends back the ids it named, and any other asks again. They're listed once more right before each worktree goes: one that opened while the sessions were being archived keeps its worktree, said in its kept row, as Paseo's SDK has no archive that checks and removes at once. Terminals that can't be listed don't keep the worktree, as Paseo would close them anyway. The plugin SDK says nothing of what a terminal runs, so an idle shell and a dev server are named alike. The dirty check reads Paseo's workspace snapshot and, for counts, `git status --porcelain`, `git diff --shortstat HEAD` for lines, and `git rev-list --count @{upstream}..HEAD` (with no upstream, `HEAD --not --remotes`) on the daemon host. Clean needs both answers: when either can't say, it's treated as dirty and the sheet says so (`unsavedOf` in `shared/archive.ts`, for the server and the screen alike). Agents and their status are listed again right before archiving, so a session that started working during the checks, or one that moved into the worktree, stops it. A session Attention Span started, archived in Paseo itself, is caught by the `agent.archived` hook in `index.server.ts` (`server/archived.ts`), even with the screen closed: once no other open session labelled with any key of its item's group is left, the group's changes up to the archive's `archivedAt` are acknowledged, so what others do later still shows. A sub-agent's archive, a restored session and a session without an item label acknowledge nothing; sessions linked only by their workspace neither acknowledge nor hold an acknowledgement back. Lists read every page, and a lookup that fails is tried again on the next hook event or list request, never taken as "none left"; tries are kept in memory, so an archive while the server isn't running, or one pending at a restart, isn't noticed, and Got it or Mark all clears its notes. A new list that brings other merged branches polls again at once, so a session linked by branch doesn't wait for the next round. When a session leaves the screen's 15-second poll (`useItemAgents` in `client/sessions.ts`, shared with the sidebar), the screen reads the server's view from memory first, so the notes acknowledged for it are cleared before its Wrap up row goes. Paseo's SDK has no `restoreWorkspace`, so there is no Undo; `server/archive.ts` confirms instead.
100
+ - **Close #12?** [ATT-24] (`classifyCloseAsks` in `server/classify.ts`): after History's searches, the issues my merged PRs refer to that History doesn't know closed (`mergedToLookUp` in `server/references.ts`, at most 100) are looked up, a batch per request, for their state and the open PRs GitHub links to them, anyone's. A merged PR is put under an issue as `issueFor` picks one, counting History's closed issues as issues so a PR that closed one isn't put under another it mentions. An issue that's open, with no linked PR open, is asked about (`asks` in `state.json`'s History); as History is fetched daily, each live refresh looks the asked issues up again (`askOff`, one batched request while any is asked; one that can't be looked up keeps asking); the view leaves out one with a PR of mine open under it in the live feed (a mention or answer on the issue alone doesn't count), one Next up knows has anyone's PR open, one the live lookup found closed or with a PR open, one whose latest merge is older than History's weeks, one kept open (`keptOpen`: the latest merge then, so a later one asks again; kept for History's weeks, so an ask missing from one fetch doesn't lose it) and one I just closed. Closing goes through `rpc.closeIssue`, its done item carrying the merged PRs with their branches, so a session linked by branch keeps its row, whether the issue is assigned to me or not; as History's search only finds closed issues assigned to me, it's kept in `closedAsks` for History's weeks, listed in History with its PRs under it rather than alone, and Undo forgets it; Next up's card gets a "PRs merged" pill (`prsMerged`).
100
101
 
101
102
  - **Dismiss** [ATT-08] hides an item until someone other than me comments, reviews or pushes, or its reason changes. My own actions and CI reruns don't bring it back.
102
103
  - **Behind base** [UPS-07] only matters when:
package/index.server.ts CHANGED
@@ -55,6 +55,7 @@ export default function contribute(server: PluginServerContext) {
55
55
  }).then(shown),
56
56
  );
57
57
  server.handle(rpc.dismissItem, ({ key }) => ready(() => attention.dismiss(key)).then(shown));
58
+ server.handle(rpc.keepOpen, ({ key, on }) => ready(() => attention.keepOpen(key, on)).then(shown));
58
59
  server.handle(rpc.undismissItem, ({ key }) => ready(() => attention.undismiss(key)).then(shown));
59
60
  server.handle(rpc.gotIt, ({ ids, on }) => ready(() => attention.gotIt(ids, on)).then(shown));
60
61
  server.handle(rpc.setHistoryFilter, ({ filter }) => ready(() => attention.setHistoryFilter(filter)).then(shown));
@@ -90,6 +91,7 @@ export default function contribute(server: PluginServerContext) {
90
91
  server.handle(rpc.setScopes, ({ scopes }) => ready(() => attention.setScopes(scopes)).then(() => ({ ok: true as const })));
91
92
  server.handle(rpc.setSources, ({ sources }) => ready(() => attention.setSources(sources)).then(() => ({ ok: true as const })));
92
93
  server.handle(rpc.setProjectFilter, ({ projects }) => ready(() => attention.setProjectFilter(projects)).then(() => ({ ok: true as const })));
94
+ server.handle(rpc.setUnclaimedByRepo, ({ on }) => ready(() => attention.setUnclaimedByRepo(on)).then(shown));
93
95
  server.handle(rpc.setNewIssueChoice, ({ repo, profileId }) => ready(() => attention.setNewIssueChoice(repo, profileId)).then(() => ({ ok: true as const })));
94
96
  server.handle(rpc.projectsAccess, () => ready(() => attention.projectsAccess(true)));
95
97
  server.handle(rpc.updateBranch, ({ key, target }) => act(key, () => updateBranch(target), chip("updating")));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrioid/paseo-attention-span",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "For when your attention is spread thin: the GitHub issues and pull requests waiting on you, grouped by why, with one-tap Paseo sessions.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/requirements.yaml CHANGED
@@ -38,6 +38,7 @@ functional:
38
38
  ATT-19: tell at a glance what each person shown on an item is to it: someone I'm waiting on, who opened it, or whose comments are left to address, with an icon by their picture and the meaning in words when I point at it; so that a face and a time never leave me guessing.
39
39
  ATT-20: tell which item a card is on every tab by its number first, then its repository with the repository's name standing out from its owner, which my own repositories leave out; so that cards from several repositories scan without reading each one in full.
40
40
  ATT-22: wrap up finished or out-of-my-hands work whose Paseo sessions are still open, archiving them, and the sub-agents they started, safely: naming unsaved changes and the open terminals archiving closes first, in a sheet shaped like Paseo's own, keeping worktrees another session lives in, leaving a row that says why a worktree stayed until it goes or is dismissed, and acknowledging what others did once it succeeds; so that leftover sessions get cleaned up without losing work or resurfacing old changes.
41
+ ATT-24: see in Wrap up an open issue whose grouped pull requests have all merged, with none still open for it, asking "Close #12?", and close it as completed with Undo or keep it open until another of them merges; so that finished work doesn't leave issues open behind it.
41
42
  mentions:
42
43
  As a developer, I can:
43
44
  MEN-01: see open threads where a person mentioned me and is still waiting for my response; so that I only hear about mentions when someone is waiting for me.
@@ -104,6 +105,7 @@ functional:
104
105
  NXT-11: close an issue from Next up as completed or not planned, with an optional comment, and undo it; so that work that's done or won't be done stops being suggested.
105
106
  NXT-12: see which open GitHub projects my Next up issues are on, and where on each board, once my gh login may read projects, with Settings saying the one command that allows it until then; so that I know whether work is planned or just an idea, without Next up breaking for anyone who hasn't allowed it.
106
107
  NXT-13: see a calm scene in Next up when it has nothing at all to show, pointing me to Settings, plainly when it has nowhere to look and quietly when it found nothing to pick up, the latter only once a refresh has confirmed it; so that an empty Next up says how to fill it rather than looking broken.
108
+ NXT-14: group unclaimed issues by repository, each under its name, the repository with the most important issue first and NXT-02's order within each, offered whenever more than one repository is shown, and have my choice remembered; so that I can see which project each issue belongs to when I have many going.
107
109
  waiting:
108
110
  As a developer, I can:
109
111
  WAI-01: see my work that is waiting on others, grouped by who it waits on with whoever blocks the most first, bots after people, and work no person holds up last, each group with work that has an active session first, and each card saying why it waits and for how long, including my pull requests in Doing that wait on whom I asked, where a pull request waits for review only once someone has been asked, and a thread only once my last words ask a question; so that I know that work is tracked and who is blocking me most.
@@ -3,6 +3,7 @@ import {
3
3
  baseItem,
4
4
  type Attention,
5
5
  type Chip,
6
+ type CloseAsk,
6
7
  type Item,
7
8
  type LastReview,
8
9
  type NextUpIssue,
@@ -496,6 +497,34 @@ export function classifyHistory(data: HistoryResult): Item[] {
496
497
  return items.sort(order);
497
498
  }
498
499
 
500
+ // Open issues my merged PRs worked on, picked as History picks a closed one, where no PR for it is still open, mine or
501
+ // anyone's that GitHub links: Wrap up offers to close each [ATT-24, ATT-03]. My open PRs grouped under one are in the live
502
+ // feed, so the view leaves those out.
503
+ export function classifyCloseAsks(data: HistoryResult): CloseAsk[] {
504
+ const referenced = new Map(Object.entries(data.referenced ?? {}));
505
+ // Closed issues count as issues too, so a PR that worked on one isn't put under another it mentions.
506
+ const closed = new Set(compact(data.closed.nodes).map(prKey));
507
+ const me = data.viewer?.login.toLowerCase();
508
+ const asks = new Map<string, CloseAsk>();
509
+ for (const pr of compact(data.merged.nodes)) {
510
+ const linked = { repo: pr.repository.nameWithOwner, body: pr.body, linked: pr.closingIssuesReferences.nodes.map(prKey) };
511
+ const key = issueFor([linked], (ref) => closed.has(ref) || referenced.has(ref));
512
+ const issue = key ? referenced.get(key) : undefined;
513
+ if (!key || !issue || issue.state !== "OPEN" || (issue.closedByPullRequestsReferences?.nodes ?? []).some((other) => other.state === "OPEN")) continue;
514
+ const ask = asks.get(key) ?? { key, repo: issue.repository.nameWithOwner, number: issue.number, title: issue.title, url: issue.url, prs: [], mergedAt: pr.mergedAt };
515
+ // Its branch, so a session on it still finds its row once the issue is closed; who merged it, as History says [ATT-22, HIS-05].
516
+ const by = pr.mergedBy?.login;
517
+ ask.prs.push({
518
+ key: prKey(pr), number: pr.number, title: pr.title, url: pr.url, draft: false, chips: [], attention: false, mergedAt: pr.mergedAt,
519
+ ...(pr.headRefName ? { headRefName: pr.headRefName } : {}),
520
+ ...(by && me && by.toLowerCase() !== me ? { mergedBy: by } : {}),
521
+ });
522
+ if (pr.mergedAt > ask.mergedAt) ask.mergedAt = pr.mergedAt;
523
+ asks.set(key, ask);
524
+ }
525
+ return [...asks.values()].map((ask) => ({ ...ask, prs: ask.prs.sort((a, b) => a.mergedAt!.localeCompare(b.mergedAt!)) }));
526
+ }
527
+
499
528
  // Whether my last comment on a thread is the last one from a person, and if not, the recent comments since that I haven't 👍'd.
500
529
  // On a thread I opened, my opening counts as my last word until I comment. Bots don't count [MEN-05]. Only the last comments
501
530
  // are fetched: on someone else's thread, once mine is out of them the conversation has moved on.
package/server/fetch.ts CHANGED
@@ -4,7 +4,7 @@ import type { IssueField } from "../shared/setup";
4
4
  import { type ChangeLedger, changeCandidates, nextLedger, reopenCandidates, withGotIt } from "./changes";
5
5
  import { issueBoardIds } from "./classify";
6
6
  import type { graphql, graphqlResult } from "./gh";
7
- import type { AssignmentSubject, Details, HistoryResult, LinkedIssue, LiveResult, MergeStateStatus, PullRequestNode, ReopenSubject } from "./github-types";
7
+ import type { AssignmentSubject, Details, HistoryResult, LinkedIssue, LiveResult, MergeStateStatus, PullRequestNode, ReferencedIssue, ReopenSubject } from "./github-types";
8
8
  import { searchWithProjects } from "./projects";
9
9
  import {
10
10
  ASSIGNMENT_BATCH,
@@ -21,6 +21,8 @@ import {
21
21
  PROJECTS_PROBE,
22
22
  projectStatusesQuery,
23
23
  type ProjectStatusesResult,
24
+ REFERENCED_BATCH,
25
+ referencedIssuesQuery,
24
26
  reopenQuery,
25
27
  requiredChecks,
26
28
  type SearchName,
@@ -28,7 +30,7 @@ import {
28
30
  searchVariables,
29
31
  type UnclaimedSearch,
30
32
  } from "./queries";
31
- import { toLookUp } from "./references";
33
+ import { type IssueRef, mergedToLookUp, toLookUp } from "./references";
32
34
 
33
35
  // What the service asks GitHub, one request shape each [GH-01]. Previews answer from made-up data instead (fixture.ts).
34
36
 
@@ -56,6 +58,8 @@ export interface GitHub {
56
58
  changes(ledger: ChangeLedger, data: LiveResult, now: Date, config: AttentionConfig, gotIt: () => string[]): Promise<ChangeLedger>;
57
59
  // From the oldest week's Monday in the device's `timeZone` [HIS-01].
58
60
  history(config: AttentionConfig, now: Date, timeZone: string): Promise<HistoryResult>;
61
+ // The issues Wrap up asks to close, looked up again on the live refresh: closed since, or a PR opened for them [ATT-24].
62
+ issues(refs: IssueRef[]): Promise<Record<string, ReferencedIssue>>;
59
63
  // The single-select fields of these orgs, merged by name [NXT-04].
60
64
  issueFields(owners: string[]): Promise<IssueField[]>;
61
65
  }
@@ -75,8 +79,9 @@ export function gitHub(gh: Gh): GitHub {
75
79
  probeProjects: () => gh.graphqlResult<{ viewer: { projectsV2: unknown } | null }>(PROJECTS_PROBE, {}, { timeoutMs: PROBE_TIMEOUT_MS }).catch((error: Error) => error),
76
80
  live: (config, now, unclaimed, projects) => searchLive(gh, config, now, unclaimed, projects),
77
81
  changes: (ledger, data, now, config, gotIt) => trackChanges(gh, ledger, data, now, config, gotIt),
78
- history: (config, now, timeZone) => gh.graphql<HistoryResult>(searchQuery(HISTORY_SEARCHES, true), variables(config, HISTORY_SEARCHES, now, timeZone)),
82
+ history: (config, now, timeZone) => searchHistory(gh, config, now, timeZone),
79
83
  issueFields: (owners) => issueFields(gh, owners),
84
+ issues: (refs) => lookUpIssues(gh, refs),
80
85
  };
81
86
  }
82
87
 
@@ -177,6 +182,27 @@ export async function projectStatuses(gh: Gh, ids: string[], problems: string[])
177
182
  return Object.fromEntries([...found].flatMap(([id, board]) => (board?.field?.options ? [[id, board.field.options]] : [])));
178
183
  }
179
184
 
185
+ // History's searches, then whether the issues my merged PRs refer to are still open, so Wrap up can offer to close one
186
+ // whose work is done [HIS-01, ATT-24]. A lookup that fails only leaves those out until the next fetch.
187
+ async function searchHistory(gh: Gh, config: AttentionConfig, now: Date, timeZone: string): Promise<HistoryResult> {
188
+ const data = await gh.graphql<HistoryResult>(searchQuery(HISTORY_SEARCHES, true), variables(config, HISTORY_SEARCHES, now, timeZone));
189
+ // Search answers {} for what isn't a PR or issue.
190
+ const refs = mergedToLookUp(data.merged.nodes.filter((pr) => pr?.repository), data.closed.nodes.filter((issue) => issue?.repository));
191
+ if (refs.length === 0) return data;
192
+ return { ...data, referenced: await lookUpIssues(gh, refs) };
193
+ }
194
+
195
+ // Issues by reference, a batch per request: whether each is open, and the open PRs GitHub links to it [ATT-24, GH-01].
196
+ // What a failed request asked about is left out, so it's taken as unknown, never as closed or free.
197
+ async function lookUpIssues(gh: Gh, refs: IssueRef[]): Promise<Record<string, ReferencedIssue>> {
198
+ if (refs.length === 0) return {};
199
+ const found = await lookupBatches<IssueRef, { issueOrPullRequest: Partial<ReferencedIssue> | null }>(gh, refs, "i", referencedIssuesQuery, {
200
+ size: REFERENCED_BATCH,
201
+ problem: (message) => console.error("Couldn't check the issues my merged PRs refer to:", message),
202
+ });
203
+ return Object.fromEntries([...found].flatMap(([, node]) => (node?.issueOrPullRequest?.repository ? [[prKey(node.issueOrPullRequest as ReferencedIssue), node.issueOrPullRequest as ReferencedIssue]] : [])));
204
+ }
205
+
180
206
  // My PRs' merge state, a few per request in parallel, as GitHub only works it out for a few at a time; search's answer
181
207
  // for more is BLOCKED for all [PRS-13]. A request that fails leaves its PRs to search's answer.
182
208
  async function mergeStates(gh: Gh, prs: PullRequestNode[]): Promise<Details["mergeState"]> {