@andrioid/paseo-attention-span 0.4.13 → 0.4.14

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 CHANGED
@@ -18,6 +18,8 @@ When there's nothing in it, you get a quiet horizon that follows the time of day
18
18
 
19
19
  Mentions only count while the person is still waiting for you. Reply or react and it's gone. On your own issues and PRs, a new comment from the last 30 days shows up under **Answered** even if it doesn't tag you. On other people's threads only tags count. The point is to pick out the signal, and most of what happens in threads you once commented on isn't. If you do want those replies, turn on **Follow threads I've commented on** in Settings. Team mentions are left out entirely, because "@everyone-in-backend" is not really a question for *me*. And if something's just an FYI, dismiss it. It stays gone until something new happens on it.
20
20
 
21
+ Sometimes other people move your work without asking: they merge your PR, close it, take it over, or unassign you from an issue. None of that is something to do, so it doesn't count, but it shouldn't happen behind your back either. Each one gets a line at the bottom of Doing, like "merged by dave 2h ago" or "phil took over", until you tap **Got it**.
22
+
21
23
  Every item has one main button that matches why it's there: Reply, Review, Fix CI, Merge. Open the item and you get every action, each with a line saying what it'll do. I wanted buttons you can press without wondering what's about to happen to your repo.
22
24
 
23
25
  ![An item's actions](docs/screenshots/desktop-dark-doing-sheet.png)
@@ -75,7 +77,7 @@ Some orgs keep issues in a separate repo from the code. When that happens, the f
75
77
 
76
78
  The issues and PRs you finished in recent weeks, grouped by week, plus the PRs you reviewed that got merged. Reviews are work too, even if nobody counts them.
77
79
 
78
- There's a copy button per week that gives you a Markdown list of links, each led by what kind of work it was: 🐞 bug, 🚀 feature, 🔧 task, or 🔀 for a PR that's none of those. The kind comes from the issue type, else the labels, else a title like "fix: …", so it works whether or not your repos use issue types. Cards show it too. Issues closed as not planned stay out of the list. That's my standup prep now, and it takes about four seconds.
80
+ There's a copy button per week that gives you a Markdown list of links, each led by what kind of work it was: 🐞 bug, 🚀 feature, 🔧 task, or 🔀 for a PR that's none of those. The kind comes from the issue type, else the labels, else a title like "fix: …", so it works whether or not your repos use issue types. Cards show it too. Issues closed as not planned stay out of the list. A PR someone else merged says who, and work that left your hands (a PR someone closed or took over, an issue you were taken off) sits apart under **Closed or handed off**, out of the list, even if its new owner merges it later. That's my standup prep now, and it takes about four seconds.
79
81
 
80
82
  ![History](docs/screenshots/desktop-dark-history.png)
81
83
 
@@ -7,6 +7,7 @@ import { Pressable, ScrollView, Text, View } from "react-native";
7
7
  import { type ActionId, type AgentSummary, type AttentionView, type Chip, checkoutPr, type FailingChecks, type Item, itemSessions, liftActive, looseSessions, type NextUpIssue, ownStack, type PersonRole, type Reviewer, type Section, type SectionId, SECTIONS, type SubRow, TAB_FEED, type TabId, type Target, type WaitingGroup, type WaitingOn } from "../shared/attention";
8
8
  import { type AttentionConfig, nextUpSources, type SessionKind } from "../shared/config";
9
9
  import { failingList, groupLabel, rerunHistory, summarizeRerun } from "../shared/checks";
10
+ import { changeText } from "../shared/changes";
10
11
  import { ago, linkList } from "../shared/format";
11
12
  import { isClear } from "../shared/still";
12
13
  import { workEmoji } from "../shared/work";
@@ -26,7 +27,7 @@ import { FeedbackAsk, FeedbackLine, type FeedbackScreen, FeedbackSheet } from ".
26
27
  import { branchWorkspaces, type FetchProviders, findCheckout, githubProjects, itemAgents, listProfiles, noProjectMessage, resolveAgentConfig, startSession } from "./sessions";
27
28
  import { SetupChecklist } from "./setup";
28
29
  import { UpdateNotice } from "./update";
29
- import { Avatar, Button, Hint, KeepStyles, LINE_HEIGHT, Loading, Meta, mix, SectionHeader, SpinningIcon, StylesProvider, TablerIcon, Toggle, useCopy, useHover, useStrongText, useStyles } from "./ui";
30
+ import { Avatar, Button, Disclosure, Hint, KeepStyles, LINE_HEIGHT, Loading, Meta, mix, SectionHeader, SpinningIcon, StylesProvider, TablerIcon, Toggle, useCopy, useHover, useStrongText, useStyles } from "./ui";
30
31
 
31
32
  // The agent icon marks every action that starts an agent session; the rest act on GitHub right away [ATT-13].
32
33
  const ACTION_ICONS: Record<ActionId, IconName> = {
@@ -45,6 +46,7 @@ const ACTION_ICONS: Record<ActionId, IconName> = {
45
46
  merge: "merge",
46
47
  close: "close",
47
48
  start: "agent",
49
+ got_it: "check",
48
50
  };
49
51
 
50
52
  function actionLabel(action: ActionId, item: Item): string {
@@ -66,6 +68,7 @@ function actionLabel(action: ActionId, item: Item): string {
66
68
  merge: "Merge",
67
69
  close: "Close draft",
68
70
  start: "Start",
71
+ got_it: "Got it",
69
72
  }[action];
70
73
  }
71
74
 
@@ -96,6 +99,7 @@ function actionDetail(action: Exclude<ActionId, "rerun">, item: Item): string {
96
99
  merge: `Merges ${pr} into ${base} (${target.mergeMethod}) now`,
97
100
  close: `Closes ${pr}. A comment is posted only if you write one`,
98
101
  start: "An agent reads the issue and proposes a plan",
102
+ got_it: "Clears this note. Nothing changes on GitHub",
99
103
  }[action];
100
104
  }
101
105
 
@@ -179,8 +183,10 @@ const SECTION_ICONS: Record<SectionId, IconName> = {
179
183
  wait_reviewer: "replyArrow",
180
184
  wait_ci: "clock",
181
185
  wait_answer: "reply",
186
+ changed: "team",
182
187
  done: "merge",
183
188
  reviewed: "review",
189
+ handed_off: "userShare",
184
190
  };
185
191
 
186
192
  const TABS: { id: TabId; label: string; icon: IconName }[] = [
@@ -247,6 +253,7 @@ function AttentionList({
247
253
  const dismiss = useRpc(rpc.dismissItem);
248
254
  const undismiss = useRpc(rpc.undismissItem);
249
255
  const restore = useRpc(rpc.restoreDismissed);
256
+ const gotIt = useRpc(rpc.gotIt);
250
257
  const saveScopes = useRpc(rpc.setScopes);
251
258
  const saveSources = useRpc(rpc.setSources);
252
259
  const saveProjects = useRpc(rpc.setProjectFilter);
@@ -397,6 +404,11 @@ function AttentionList({
397
404
  const session = ACTION_SESSION[action];
398
405
  const { target } = item;
399
406
  if (action === "reply") return void openExternalUrl(item.person?.url ?? item.url);
407
+ // [ATT-21]
408
+ if (action === "got_it" && item.change) {
409
+ const { id } = item.change;
410
+ return change(item.key, "Got it", () => gotIt({ id, on: true }), `Cleared the note on “${item.title}”`, () => gotIt({ id, on: false }));
411
+ }
400
412
  if (session) return void startWithDefaults(item.key, session, target);
401
413
  if (action === "update") change(item.key, "Update", () => update({ key: item.key, target }), `Updating PR ${target.number} with ${target.baseRefName}`);
402
414
  // [PRS-11]
@@ -625,7 +637,14 @@ interface Actions {
625
637
  }
626
638
 
627
639
  // What the card is: open, draft, merged or closed. Urgency stays in the chips and section headers.
640
+ // A note on what someone else did shows what happened instead; its words say it too, so color isn't the only sign [ATT-21].
628
641
  function stateMark(item: Item): CardProps["mark"] {
642
+ if (item.change) {
643
+ const kind = item.change.kind;
644
+ if (kind === "merged") return { icon: "merge", tone: "good" };
645
+ if (kind === "closed") return { icon: "prClosed", tone: "bad" };
646
+ return { icon: kind === "unassigned" ? "userMinus" : "userShare", tone: "warn" };
647
+ }
629
648
  if (item.closedAt) return item.kind === "pr" ? { icon: "merge", tone: "good" } : { icon: "issueClosed", tone: item.chips.length ? "neutral" : "good" };
630
649
  if (item.kind === "issue") return { icon: "issue", tone: "good" };
631
650
  return item.draft ? { icon: "draft", tone: "neutral" } : { icon: "pr", tone: "good" };
@@ -711,7 +730,11 @@ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean;
711
730
  title={item.title}
712
731
  meta={{
713
732
  place: { repo: item.repo, number: item.number, login: actions.login },
714
- when: item.closedAt ? `${item.kind === "pr" ? "merged" : "closed"} ${ago(item.closedAt)} ago` : undefined,
733
+ when: item.change
734
+ ? changeText(item.change)
735
+ : item.closedAt
736
+ ? `${item.kind === "pr" ? "merged" : "closed"} ${ago(item.closedAt)} ago${item.mergedBy ? ` by ${item.mergedBy}` : ""}`
737
+ : undefined,
715
738
  signals: chips,
716
739
  }}
717
740
  extra={
@@ -876,9 +899,9 @@ function sheetEntries(
876
899
  // History, where an issue is its own target, the first of the PRs that closed it.
877
900
  const pr = targetUrl(item) && item.target.kind === "pr" ? item.target : item.kind === "issue" && item.children[0] ? item.children[0] : undefined;
878
901
  entries.push(githubEntry(item, (url) => close(() => void openExternalUrl(url))(), pr));
879
- // Nothing's left to start on once it's merged or closed.
880
- if (!item.closedAt) entries.push(startAnotherEntry(sessions.length > 0, withOptions("Start session", fallbackKind(item))));
881
- if (inDoing) entries.push({ key: "dismiss", icon: "dismiss", label: "Dismiss", detail: "Hides it until something new happens on it", housekeeping: true, onPress: close(() => actions.dismiss(item)) });
902
+ // Nothing's left to start on once it's merged or closed, or out of my hands; a note is cleared with Got it, not dismissed [ATT-21].
903
+ if (!item.closedAt && !item.change) entries.push(startAnotherEntry(sessions.length > 0, withOptions("Start session", fallbackKind(item))));
904
+ if (inDoing && !item.change) entries.push({ key: "dismiss", icon: "dismiss", label: "Dismiss", detail: "Hides it until something new happens on it", housekeeping: true, onPress: close(() => actions.dismiss(item)) });
882
905
  return entries;
883
906
  }
884
907
 
@@ -1207,7 +1230,9 @@ function weekLabel(monday: Date): string {
1207
1230
  function History({ items, actions }: { items: Item[]; actions: Actions }) {
1208
1231
  const styles = useStyles();
1209
1232
  const copy = useCopy();
1210
- const [open, setOpen] = useState<string | null>(null);
1233
+ // Groups opened, as "<week>:<group>"; each opens on its own.
1234
+ const [open, setOpen] = useState<ReadonlySet<string>>(new Set());
1235
+ const toggle = (id: string) => setOpen((now) => (now.has(id) ? new Set([...now].filter((other) => other !== id)) : new Set([...now, id])));
1211
1236
  if (items.length === 0) return <Text style={styles.text}>Nothing finished in this period.</Text>;
1212
1237
  const weeks = new Map<number, Item[]>();
1213
1238
  for (const item of items) {
@@ -1218,6 +1243,8 @@ function History({ items, actions }: { items: Item[]; actions: Actions }) {
1218
1243
  for (const [week, all] of [...weeks].sort((a, b) => b[0] - a[0])) {
1219
1244
  const done = all.filter((item) => item.section === "done").sort((a, b) => b.closedAt!.localeCompare(a.closedAt!));
1220
1245
  const reviewed = all.filter((item) => item.section === "reviewed");
1246
+ // Out of the week's copy: it wasn't my finished work [HIS-06].
1247
+ const handed = all.filter((item) => item.section === "handed_off").sort((a, b) => b.closedAt!.localeCompare(a.closedAt!));
1221
1248
  // What was done, each led by its kind; not planned issues stay on screen but out of the report [HIS-03, HIS-04].
1222
1249
  const copied = done.filter((item) => !item.notPlanned);
1223
1250
  const label = weekLabel(new Date(week));
@@ -1250,7 +1277,7 @@ function History({ items, actions }: { items: Item[]; actions: Actions }) {
1250
1277
  <View style={{ gap: 8 }}>
1251
1278
  {/* Its copy lines up under the week's, at the right edge, like every Markdown copy. */}
1252
1279
  <View style={styles.row}>
1253
- <Toggle label={`Reviewed (${reviewed.length})`} active={open === label} onPress={() => setOpen(open === label ? null : label)} />
1280
+ <Disclosure label="Reviewed" count={reviewed.length} open={open.has(`${label}:reviewed`)} onPress={() => toggle(`${label}:reviewed`)} />
1254
1281
  <View style={{ flex: 1 }} />
1255
1282
  <View style={styles.overCard}>
1256
1283
  <Button
@@ -1266,7 +1293,13 @@ function History({ items, actions }: { items: Item[]; actions: Actions }) {
1266
1293
  />
1267
1294
  </View>
1268
1295
  </View>
1269
- {open === label ? <Card items={reviewed} actions={actions} /> : null}
1296
+ {open.has(`${label}:reviewed`) ? <Card items={reviewed} actions={actions} /> : null}
1297
+ </View>
1298
+ ) : null}
1299
+ {handed.length > 0 ? (
1300
+ <View style={{ gap: 8 }}>
1301
+ <Disclosure label="Closed or handed off" count={handed.length} open={open.has(`${label}:handed`)} onPress={() => toggle(`${label}:handed`)} />
1302
+ {open.has(`${label}:handed`) ? <Card items={handed} actions={actions} /> : null}
1270
1303
  </View>
1271
1304
  ) : null}
1272
1305
  </View>,
@@ -1293,7 +1326,7 @@ function StackLine({ rows, merged, links = false, target }: { rows: SubRow[]; me
1293
1326
  {row.title}
1294
1327
  </Text>
1295
1328
  <View style={[styles.wrap, { columnGap: 10, rowGap: 2 }]}>
1296
- <Meta lead={<NumberText number={row.number} />} facts={[]} chips={row.chips} />
1329
+ <Meta lead={<NumberText number={row.number} />} facts={merged && row.mergedBy ? [`merged by ${row.mergedBy}`] : []} chips={row.chips} />
1297
1330
  {row.key === target ? <Text style={{ color: styles.action, fontSize: 12, fontWeight: "600" }}>actions apply here</Text> : null}
1298
1331
  </View>
1299
1332
  </View>
package/client/icons.ts CHANGED
@@ -51,6 +51,11 @@ export const ICONS = {
51
51
  chevronRight: { 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=\"m9 6l6 6l-6 6\"/></svg>" },
52
52
  plus: { 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=\"M12 5v14m-7-7h14\"/></svg>" },
53
53
  check: { 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 12l5 5L20 7\"/></svg>" },
54
+ // Tabler git-pull-request-closed, user-share, user-minus and chevron-down: what others did to my work [ATT-21, HIS-06].
55
+ prClosed: { 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=\"M4 18a2 2 0 1 0 4 0a2 2 0 1 0-4 0M4 6a2 2 0 1 0 4 0a2 2 0 1 0-4 0m12 12a2 2 0 1 0 4 0a2 2 0 1 0-4 0M6 8v8m12-5v5M16 4l4 4m0-4l-4 4\"/></svg>" },
56
+ userShare: { 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-4h3m3 7l5-5m0 4.5V17h-4.5\"/></svg>" },
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
+ 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>" },
54
59
  // Tabler message-ai: marks actions that start or continue an agent session.
55
60
  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>" },
56
61
  } as const;
package/client/ui.tsx CHANGED
@@ -357,6 +357,21 @@ export function SectionHeader({ icon, title, count, action }: { icon: IconName |
357
357
  );
358
358
  }
359
359
 
360
+ // A group that opens in place, like a week's reviews in History: a chevron, its name and count. Each opens on its own, so
361
+ // they don't read as a choice between them [HIS-02, HIS-06].
362
+ export function Disclosure({ label, count, open, onPress }: { label: string; count: number; open: boolean; onPress: () => void }) {
363
+ const styles = useStyles();
364
+ return (
365
+ <Pressable accessibilityRole="button" accessibilityLabel={`${label}, ${count}`} accessibilityState={{ expanded: open }} onPress={onPress} hitSlop={6} style={[styles.row, { gap: 6, paddingVertical: 4 }]}>
366
+ <TablerIcon name={open ? "chevronDown" : "chevronRight"} size={14} />
367
+ <Text style={{ color: styles.c.foreground, fontSize: 13, fontWeight: "600" }}>
368
+ {label}
369
+ <Text style={{ color: styles.c.foregroundMuted, fontWeight: "400" }}> · {count}</Text>
370
+ </Text>
371
+ </Pressable>
372
+ );
373
+ }
374
+
360
375
  // Copy text and say so, since an icon-only button gives no other sign it worked.
361
376
  export function useCopy() {
362
377
  const toast = useToast();
@@ -40,7 +40,7 @@ flowchart LR
40
40
  - optional merge method per repo [PRS-04]
41
41
  - `codeRepos`: where an issue repo's code lives, for issues kept in their own repo [SES-07]
42
42
  - `nextUp`: where unclaimed issues come from (`mine`, `orgs`, `repos`, set in Settings) and the org issue fields for priority, effort and scope [NXT-04]
43
- - `state.json`: dismissals [ATT-08], the scopes, sources and project statuses ticked in Next up's filter [NXT-03, NXT-09], my Paseo projects' GitHub repos [NXT-08], the update put off with Not now [UPD-01] and the last fetch of each feed, so the screen shows instantly after a restart [PRIV-01].
43
+ - `state.json`: dismissals [ATT-08], what others did to my work, with which notes I've cleared [ATT-21, HIS-06], the scopes, sources and project statuses ticked in Next up's filter [NXT-03, NXT-09], my Paseo projects' GitHub repos [NXT-08], the update put off with Not now [UPD-01] and the last fetch of each feed, so the screen shows instantly after a restart [PRIV-01].
44
44
 
45
45
  ## Tabs
46
46
 
@@ -48,7 +48,7 @@ The tabs tell the story of my work, left to right: what I finished, what needs m
48
48
 
49
49
  | Tab | Shows |
50
50
  |---|---|
51
- | History | The last `historyWeeks` (default 4) by week, newest first, in the device's time zone: issues assigned to me that closed, with the PRs that closed them, and my other merged PRs [HIS-01]. Per week, a collapsed "Reviewed (n)" lists others' merged PRs I reviewed [HIS-02]. The copy icon on a week's heading copies its finished items, not the reviews, as a Markdown list of links; an issue and the PRs that closed it are one line, linking the issue; an issue closed as not planned isn't copied, and PRs that referred to it are listed on their own [HIS-03]. Each card has a plain chip (bug, feature or task) for what kind of work it was, and each copied line leads with its emoji: 🐞, 🚀 or 🔧; a PR of none of those leads with 🔀 and has no chip, an issue of none leads with nothing [HIS-04]. The first of these that names a kind decides: the issue type, the labels (bug beats feature beats task), a Conventional Commit title prefix (`fix:` bug, `feat:` feature, `chore:`, `refactor:`, `docs:`, `build:`, `ci:`, `test:`, `perf:`, `style:` task). Types and labels match only as whole names, ignoring case, emoji and wrappers like `type:` or `kind/`, so "bug", "Type: Bug 🐞" and "kind/bug" count but "not a bug" and "bug bash" don't. Until History is fetched again, what I just finished uses the issue type and title only. |
51
+ | History | The last `historyWeeks` (default 4) by week, newest first, in the device's time zone: issues assigned to me that closed, with the PRs that closed them, and my other merged PRs [HIS-01]. Per week, a collapsed "Reviewed · n" lists others' merged PRs I reviewed [HIS-02], and a collapsed "Closed or handed off · n" my PRs someone else closed without merging and work taken out of my hands, each in the same words as Changed by others, with no week copy [HIS-06]; each opens on its own, a chevron saying which are open. A PR that left my hands isn't listed as done even once its new owner merges it. A PR of mine someone else merged says so: "merged 2h ago by dave", with its copied line unchanged; under the issue it closed, its row in the sheet says "merged by dave" [HIS-05]. The copy icon on a week's heading copies its finished items, not the reviews, as a Markdown list of links; an issue and the PRs that closed it are one line, linking the issue; an issue closed as not planned isn't copied, and PRs that referred to it are listed on their own [HIS-03]. Each card has a plain chip (bug, feature or task) for what kind of work it was, and each copied line leads with its emoji: 🐞, 🚀 or 🔧; a PR of none of those leads with 🔀 and has no chip, an issue of none leads with nothing [HIS-04]. The first of these that names a kind decides: the issue type, the labels (bug beats feature beats task), a Conventional Commit title prefix (`fix:` bug, `feat:` feature, `chore:`, `refactor:`, `docs:`, `build:`, `ci:`, `test:`, `perf:`, `style:` task). Types and labels match only as whole names, ignoring case, emoji and wrappers like `type:` or `kind/`, so "bug", "Type: Bug 🐞" and "kind/bug" count but "not a bug" and "bug bash" don't. Until History is fetched again, what I just finished uses the issue type and title only. |
52
52
  | Doing | The sections below |
53
53
  | Waiting | My work where someone else has the next move [WAI-01]: *Waiting for review* (while GitHub records a review as owed: a pending request, or an approval or requested changes; or approved but blocked by a repo rule [PRS-13]), *Waiting for the reviewer* (after I replied or pushed), *CI running*, *Questions I asked* (threads where my comment is the last from a person, bots don't count, and my comments since someone else last spoke ask something: a question mark outside quotes, code and links, read from GitHub's rendered comments (`bodyHTML`) so code and links count however they were written; a statement, tagged or not, waits on nobody and isn't listed): on my own issues however old, on others' only while my comment is within `mentionDays` [ATT-11]. Each shows who it waits on, never a guess [WAI-02]: on a PR, the reviewers currently requested and, after I replied, whoever requested changes, but nobody when a repo rule blocks it; on a question, the people and teams my comments since the last answer tag, read from GitHub's rendered comments (`bodyHTML`), where only real accounts and teams I can see are linked, never in code; tags in quotes don't count, and only the last 10 comments are read. Waiting groups it all by who it waits on, not by those reasons [WAI-01]: one group per person or team (a person tagged with other capitals is one), whoever blocks the most items first, ties by whose oldest item has waited longest, then requested bots, who can't be nudged, and last *Not on a person* for work nobody is on record for. In each group, work with a session that needs me leads, then one that's working, then the rest, oldest first; a finished session I've seen doesn't lift it. Work waiting on several is under each, saying "also waiting on" the rest, and counts once in the tab. Each card says why it waits (review, re-review or question; nothing where its chips say, like approved, blocked by repo rules, or CI running) and since when. A group's **Copy list** copies its items oldest first as a Markdown list, each line led by why and how long ("- Review 2h: [title](url)"), for a nudge; a requested bot gets none [WAI-03]. My PRs in Doing that wait on people or teams I asked, approved or not, are listed here too, under each of them [PRS-15]. Once something has waited `waitingTooLongDays` (default 3), its age turns amber with ⌛ and says so on hover, but only where a nudge is fair: not while CI fails or runs, nor with conflicts, changes to make or a reply I owe (`nudgeable` in `server/rules.ts`) [ATT-11]. In Doing, one person shows by name, several by picture, named on hover and in the sheet. |
54
54
  | Next up | *Assigned to you* [NXT-06], then *Unclaimed* [NXT-01] |
@@ -80,8 +80,9 @@ Top to bottom. Each item appears once, under its most urgent reason [ATT-02]. `s
80
80
  | Needs upstream | My PRs with conflicts or an out-of-sync stack [UPS-01, UPS-02] |
81
81
  | 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 |
82
82
  | My drafts | My drafts, with their own state tags [PRS-05, PRS-06] |
83
+ | Changed by others | Notes, not work: someone else merged my PR, closed it without merging, took over or handed on my PR or an issue assigned to me, or unassigned me from one. One row per event, newest first, its tile showing what happened (merged green, closed red, handed over or unassigned amber) and its meta saying it in words: "merged by dave 2h ago", "closed by alice 1d ago, not merged", "phil took over 5h ago" (the same person took me off and assigned themselves), "dave handed it to carol 2d ago" (the one named is who took me off it, else, on a PR nobody had, who assigned the new owner), "bob unassigned you 3d ago"; without a name where GitHub has none. **Got it** clears a row (Undo brings it back); it has no Dismiss and nothing to start. Rows sit outside issue and stack grouping, don't count toward Doing's count or the sidebar's, and keep Doing from showing the horizon until cleared. Within `mentionDays` (default 30), so a first run catches up that far. A handover's row goes away if the work is mine again before Got it [ATT-21] |
83
84
 
84
- **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.
85
+ **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. Changed by others notes don't: the horizon waits until they're cleared [ATT-21].
85
86
 
86
87
  ## Rules
87
88
 
@@ -89,7 +90,8 @@ Top to bottom. Each item appears once, under its most urgent reason [ATT-02]. `s
89
90
  - **One item per stack** [ATT-04]: a stack is followed through base/head branch names, among my PRs and others' PRs requesting my review, whoever opened them; a PR from a fork never parents another. Only PRs those two searches return can be joined, so a PR in the stack that's neither mine nor asking for my review is left out. The item is led by the stack's bottom PR, with the rest listed beneath. My PRs in it are decided by their bottom PR, as before; others' PRs asking for my review add one Review for all of them, or a reply when one mentions me. Where a stack has both, its section is the more urgent of the two and it offers both, that one's actions first. GitHub actions act on my PRs, from my bottom one; a stack only asking for my review is never grouped under an issue. Sessions on any PR in the stack show on its item [SES-03, SES-08].
90
91
  - **Answers** [ATT-16]: on an issue a PR of mine closes, an answer leads the item like a mention does. From the issue itself only what's on me counts; its PRs say how the work is going.
91
92
  - **Mentions** [MEN-01..06]: a thread counts when a person @-mentioned me after my last comment, review or reaction there. Team mentions are ignored. A bot counts only when it opened a thread I need to resolve, and is marked with 🤖. The quote on a card is cut around the mention, so it's shown as plain text: links keep their text, Markdown marks and quoted replies go.
92
- - **Handed over** [PRS-08]: my PRs assigned to someone else, and not to me, are left out. Mentions of me on them still count.
93
+ - **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.
94
+ - **Changed by others** [ATT-21] (`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, issue closes and others' pushes don't. Merges and closes come from the live `ended` search: `mergedBy`, or the last close event's actor. 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 stays silent. So unassignments are noticed only for issues Attention Span has seen assigned to me; on the first run none count as gone. 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. Events are kept `historyWeeks` + 1 weeks, or `mentionDays` if longer.
93
95
  - **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.
94
96
  - **Behind base** [UPS-07] only matters when:
95
97
  1. the PR conflicts with its base,
@@ -186,15 +188,18 @@ One GraphQL request per search, sent in parallel. GitHub runs the searches in on
186
188
  - `is:issue is:open assignee:@me`
187
189
  - `is:open involves:@me updated:>=<30 days ago> sort:updated-desc`, 100 at most, issues and PRs with their last 10 conversation comments, as for mentions (for Answered and fresh questions) [ATT-16]
188
190
  - `is:issue is:open author:@me commenter:@me sort:updated-desc`, 50 at most, no date limit, the same fields (questions on my own issues nobody answered, however old) [ATT-11]
191
+ - `is:pr is:closed author:@me closed:>=<30 days ago> sort:updated-desc`, 50 at most, with `mergedBy`, the last close event's actor and assignees (Changed by others) [ATT-21]
189
192
  - `is:issue is:open no:assignee` (Next up, with issue type and field values, and projects when the login may read them [NXT-12]; one request per source [NXT-09], skipped when there's nowhere to look [NXT-08]). "My repos" needs my login, taken from the last fetch or asked once with `viewer { login }`
190
193
 
191
194
  Once my PRs and both issue searches are back, one batched **details** request asks for `Ref.compare` behind counts for my PRs, the open issues their descriptions refer to (at most 100), and the option order and colors of org issue fields when Next up needs them [NXT-02, NXT-10]. The other searches carry on meanwhile.
192
195
 
193
- A live refresh is 8 requests and about 85 points, of the 5,000 GitHub allows per hour. Points depend on how much a query asks for, not how many requests carry it; my PRs (34) and review requests (20) cost the most.
196
+ Then, only for PRs whose assignees changed to someone else and issues that left my assigned search, one request per 20 asks for their last 30 assign and unassign events (`assignmentsQuery`) [ATT-21]; usually none.
197
+
198
+ A live refresh is 9 requests and about 85 points, of the 5,000 GitHub allows per hour. Points depend on how much a query asks for, not how many requests carry it; my PRs (34) and review requests (20) cost the most.
194
199
 
195
200
  ### History
196
201
 
197
- One request with three searches, each from the Monday `historyWeeks` back: `is:pr is:merged author:@me`, `is:pr is:merged reviewed-by:@me -author:@me`, `is:issue is:closed assignee:@me`. Each result brings up to 20 label names, and issues their type [HIS-04]. About 4 points, mostly the label lists.
202
+ One request with three searches, each from the Monday `historyWeeks` back: `is:pr is:merged author:@me` (with `mergedBy` [HIS-05]), `is:pr is:merged reviewed-by:@me -author:@me`, `is:issue is:closed assignee:@me`, and the viewer's login. Each result brings up to 20 label names, and issues their type [HIS-04]. About 4 points, mostly the label lists.
198
203
 
199
204
  Every search is scoped to the configured orgs and repos; Next up's unclaimed issues as described under Next up.
200
205
 
package/index.server.ts CHANGED
@@ -40,6 +40,7 @@ export default function contribute(server: PluginServerContext) {
40
40
  server.handle(rpc.getAttention, ({ refresh }, { paseo }) => ready(() => (attention.connect(paseo), attention.get(refresh))));
41
41
  server.handle(rpc.dismissItem, ({ key }) => ready(() => attention.dismiss(key)));
42
42
  server.handle(rpc.undismissItem, ({ key }) => ready(() => attention.undismiss(key)));
43
+ server.handle(rpc.gotIt, ({ id, on }) => ready(() => attention.gotIt(id, on)));
43
44
  server.handle(rpc.restoreDismissed, () => ready(() => attention.restoreDismissed()));
44
45
  server.handle(rpc.setCodeRepo, ({ issueRepo, codeRepo }) => ready(() => attention.setCodeRepo(issueRepo, codeRepo)));
45
46
  server.handle(rpc.setupStatus, () => setupStatus());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrioid/paseo-attention-span",
3
- "version": "0.4.13",
3
+ "version": "0.4.14",
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
@@ -37,6 +37,7 @@ functional:
37
37
  ATT-18: see a calm, restful scene in Doing when nothing needs me, only once a refresh has confirmed it; so that a clear list feels like rest rather than a blank page, and calm never stands in for a check that failed or hasn't run.
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
+ ATT-21: see in Doing, below the work and not in its count, when someone else merged my PR, closed it without merging, took over or handed on my PR or an issue assigned to me, or unassigned me from one, each in a line like "merged by dave 2h ago" or "phil took over", until I tap Got it; so that I learn when others move my work without it changing what I have to do.
40
41
  mentions:
41
42
  As a developer, I can:
42
43
  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.
@@ -111,6 +112,8 @@ functional:
111
112
  HIS-02: see pull requests I reviewed that merged, apart from my own work; so that I can tell others what I got done.
112
113
  HIS-03: copy a week's finished work as a Markdown list of links, and the pull requests I reviewed that week as a list of their own; so that reporting progress is one paste.
113
114
  HIS-04: see what kind of work each finished item was, bug, feature or task, from its issue type, else its labels, else a Conventional Commit title like "fix: …", on its card and leading its copied line like "- 🐞 [title](link)", with PRs of no kind led by 🔀 and issues closed as not planned left out of the copy; so that a busy week's report skims at a glance in any repo.
115
+ HIS-05: see who merged a PR of mine when it wasn't me, as "merged 2h ago by dave", with its copied line unchanged; so that I know when someone else shipped my work.
116
+ HIS-06: see each week's PRs of mine that someone else closed without merging, and work taken out of my hands, apart under "Closed or handed off" and out of the week's copy, even once its new owner merges it; so that my report doesn't claim work that left my hands, and I can still see where it went.
114
117
  feedback:
115
118
  As a developer, I can:
116
119
  FB-01: tell the Attention Span project what to improve from the bottom of any tab, picking a problem, an idea or that I like it, with an agent that asks until it's clear, checks it against what's planned and already reported, and files it as an issue or a discussion, saying which and why, only once I approve the draft; so that feedback costs a minute and lands where it can be acted on or talked through.
@@ -0,0 +1,197 @@
1
+ import { isHandover, type OthersChange } from "../shared/changes";
2
+ import type { Item } from "../shared/attention";
3
+ import type { AssignmentEvent, AssignmentSubject, EndedPullRequest, LiveResult } from "./github-types";
4
+ import { prKey } from "./queries";
5
+
6
+ // Changed by others: what someone else did to my work, kept between refreshes so a note stays until Got it, and so History
7
+ // can list work that left my hands [ATT-21, HIS-06]. Pure, so every rule is testable; service.ts does the fetching.
8
+
9
+ export interface ChangeLedger {
10
+ events: OthersChange[];
11
+ // Events I've tapped Got it on.
12
+ gotIt: string[];
13
+ // Issue node id -> key, from the last assigned search that worked. Null until the first, so nothing counts as gone then:
14
+ // only issues seen assigned to me can be noticed leaving.
15
+ assigned: Record<string, string> | null;
16
+ // PR node id -> its assignees when last looked up, so each change of hands costs one lookup [GH-01].
17
+ handed: Record<string, string>;
18
+ }
19
+
20
+ export const EMPTY_LEDGER: ChangeLedger = { events: [], gotIt: [], assigned: null, handed: {} };
21
+
22
+ type Data = Pick<LiveResult, "mine" | "assigned" | "ended">;
23
+ // A lookup's answer per node id: the subject, null when it's gone or hidden, missing when the lookup failed.
24
+ export type Lookups = Map<string, AssignmentSubject | null>;
25
+
26
+ const same = (a: string | null | undefined, b: string | null | undefined) => !!a && !!b && a.toLowerCase() === b.toLowerCase();
27
+ const present = <T>(nodes: (T | null | undefined)[]) => nodes.filter((node): node is T => !!node && Object.keys(node).length > 0);
28
+ const logins = (subject: { assignees: { nodes: { login: string }[] } }) => subject.assignees.nodes.map((node) => node.login);
29
+ // Assigned to someone, and not to me: out of my hands [PRS-08]. A PR of mine with nobody assigned is still mine.
30
+ const handedOver = (subject: { assignees: { nodes: { login: string }[] } }, me: string) => {
31
+ const assignees = logins(subject);
32
+ return assignees.length > 0 && !assignees.some((login) => same(login, me));
33
+ };
34
+ const signature = (subject: { assignees: { nodes: { login: string }[] } }) =>
35
+ logins(subject)
36
+ .map((login) => login.toLowerCase())
37
+ .sort()
38
+ .join(",");
39
+
40
+ // My PRs, open or closed lately, that someone else has: each looked up once per change of hands.
41
+ function handedPrs(data: Data, me: string): { id: string; signature: string }[] {
42
+ const prs = [...present(data.mine.nodes), ...present(data.ended.nodes)].filter((pr) => pr.id && handedOver(pr, me));
43
+ return [...new Map(prs.map((pr) => [pr.id, { id: pr.id, signature: signature(pr) }])).values()];
44
+ }
45
+
46
+ const assignedNow = (data: Data): Record<string, string> =>
47
+ Object.fromEntries(present(data.assigned.nodes).flatMap((issue) => (issue.id ? [[issue.id, prKey(issue)]] : [])));
48
+
49
+ // What to look up: PRs whose hands changed since last looked, and issues no longer in my assigned search. An issue can leave
50
+ // the search for many reasons (search lag, a coverage change, its 50 results), so each is checked before anything is said.
51
+ export function changeCandidates(ledger: ChangeLedger, data: Data, me: string): string[] {
52
+ const prs = handedPrs(data, me)
53
+ .filter((pr) => ledger.handed[pr.id] !== pr.signature)
54
+ .map((pr) => pr.id);
55
+ const now = assignedNow(data);
56
+ const gone = ledger.assigned ? Object.keys(ledger.assigned).filter((id) => !(id in now)) : [];
57
+ return [...new Set([...prs, ...gone])];
58
+ }
59
+
60
+ const isAssignment = (node: AssignmentEvent | Record<string, never>): node is AssignmentEvent => "__typename" in node && "createdAt" in node;
61
+
62
+ // Who took it out of my hands, from GitHub's assign and unassign events [ATT-21]. Null when it's still mine, it was my own
63
+ // doing, or the events don't show it. An issue closed by now stays silent: issue closes are no big deal.
64
+ // The new owner is the latest of the current assignees to be assigned. It left my hands with whichever came last of my
65
+ // removal and the new owner's assignment, and whoever did that is named: "phil took over" when that's the new owner, else
66
+ // "dave handed it to carol". So a PR I unassigned myself from is still mine until someone else takes it.
67
+ export function handover(subject: AssignmentSubject, me: string): OthersChange | null {
68
+ const assignees = logins(subject);
69
+ if (assignees.some((login) => same(login, me))) return null;
70
+ if (subject.__typename === "Issue" && subject.state !== "OPEN") return null;
71
+ const events = present(subject.timelineItems.nodes)
72
+ .filter(isAssignment)
73
+ .sort((a, b) => a.createdAt.localeCompare(b.createdAt));
74
+ const removal = events.findLast((event) => event.__typename === "UnassignedEvent" && same(event.assignee?.login, me));
75
+ const given = events.findLast((event) => event.__typename === "AssignedEvent" && assignees.some((login) => same(login, event.assignee?.login)));
76
+ const to = given?.assignee?.login ?? assignees[0];
77
+ // A PR of mine with nobody on it is mine; an issue needs proof I was taken off it.
78
+ if (subject.__typename === "PullRequest" ? !to : !removal) return null;
79
+ const by = removal && given && to ? (given.createdAt > removal.createdAt ? given : removal) : (removal ?? given);
80
+ if (!by || same(by.actor?.login, me)) return null;
81
+ const actor = by.actor?.login;
82
+ const kind = !to ? "unassigned" : same(actor, to) ? "took_over" : "handed";
83
+ return change(subject, subject.__typename === "PullRequest" ? "pr" : "issue", kind, by.createdAt, actor, to);
84
+ }
85
+
86
+ // A PR of mine someone else merged or closed unmerged [ATT-21]. Whether it left my hands before it ended is up to nextLedger,
87
+ // which knows when that happened.
88
+ export function ended(pr: EndedPullRequest, me: string): OthersChange | null {
89
+ if (pr.merged) return same(pr.mergedBy?.login, me) || !pr.mergedAt ? null : change(pr, "pr", "merged", pr.mergedAt, pr.mergedBy?.login);
90
+ const closer = pr.timelineItems.nodes.at(-1)?.actor?.login;
91
+ return same(closer, me) ? null : change(pr, "pr", "closed", pr.closedAt, closer);
92
+ }
93
+
94
+ function change(
95
+ subject: { id: string; number: number; title: string; url: string; repository: { nameWithOwner: string } },
96
+ kind: "pr" | "issue",
97
+ what: OthersChange["kind"],
98
+ at: string,
99
+ actor?: string,
100
+ to?: string,
101
+ ): OthersChange {
102
+ return {
103
+ id: `${what}:${subject.id}:${at}`,
104
+ kind: what,
105
+ subjectId: subject.id,
106
+ subject: kind,
107
+ key: prKey(subject),
108
+ repo: subject.repository.nameWithOwner,
109
+ number: subject.number,
110
+ title: subject.title,
111
+ url: subject.url,
112
+ ...(actor ? { actor } : {}),
113
+ ...(to ? { to } : {}),
114
+ at,
115
+ };
116
+ }
117
+
118
+ // The ledger after a refresh. New events count only within `windowDays` (mentionDays), so a first run catches up that far
119
+ // and no further; kept for `keepDays`, long enough for History. Work back in my hands drops its handover. What couldn't be
120
+ // looked up is left to retry next time.
121
+ export function nextLedger(ledger: ChangeLedger, data: Data, me: string, lookups: Lookups, now: Date, windowDays: number, keepDays: number): ChangeLedger {
122
+ const since = (days: number) => new Date(now.getTime() - days * 86_400_000).toISOString();
123
+ const found: OthersChange[] = [];
124
+ const endedAt = new Map(present(data.ended.nodes).map((pr) => [pr.id, pr.mergedAt ?? pr.closedAt]));
125
+ // Assigning a PR once it's merged or closed hands nothing over.
126
+ const handovers = [...lookups.values()]
127
+ .map((subject) => (subject ? handover(subject, me) : null))
128
+ .filter((event): event is OthersChange => !!event && !(endedAt.has(event.subjectId) && event.at > endedAt.get(event.subjectId)!));
129
+ found.push(...handovers);
130
+ const handedAt = (id: string) => [...ledger.events, ...handovers].filter((event) => isHandover(event) && event.subjectId === id).map((event) => event.at);
131
+ for (const pr of present(data.ended.nodes)) {
132
+ // A PR someone else has whose hands aren't looked up yet waits a refresh, so a handover isn't reported as a merge.
133
+ if (handedOver(pr, me) && !lookups.has(pr.id) && ledger.handed[pr.id] !== signature(pr)) continue;
134
+ const event = ended(pr, me);
135
+ // One that left my hands before it ended was a handover, not my work merged or closed.
136
+ if (event && !handedAt(pr.id).some((at) => at <= event.at)) found.push(event);
137
+ }
138
+ // Mine again: my PRs with nobody else on them, and issues assigned to me.
139
+ const mineNow = new Set([...present(data.mine.nodes).filter((pr) => !handedOver(pr, me)).map((pr) => pr.id), ...Object.keys(assignedNow(data))]);
140
+ const known = new Set(ledger.events.map((event) => event.id));
141
+ const fresh = found.filter((event) => !known.has(event.id) && event.at >= since(windowDays));
142
+ const events = [...ledger.events, ...fresh]
143
+ .filter((event) => !(isHandover(event) && mineNow.has(event.subjectId)))
144
+ .filter((event) => event.at >= since(keepDays))
145
+ .sort((a, b) => b.at.localeCompare(a.at));
146
+ const ids = new Set(events.map((event) => event.id));
147
+
148
+ // Issues that left my search and couldn't be looked up stay, so they're checked again.
149
+ const assigned = assignedNow(data);
150
+ if (ledger.assigned) for (const [id, key] of Object.entries(ledger.assigned)) if (!(id in assigned) && !lookups.has(id)) assigned[id] = key;
151
+ // A PR's hands are settled once looked up; one that failed keeps its old signature, so it's asked again.
152
+ const handed: Record<string, string> = {};
153
+ for (const pr of handedPrs(data, me)) {
154
+ const before = ledger.handed[pr.id];
155
+ if (before !== undefined || lookups.has(pr.id)) handed[pr.id] = lookups.has(pr.id) ? pr.signature : before;
156
+ }
157
+ return { events, gotIt: ledger.gotIt.filter((id) => ids.has(id)), assigned, handed };
158
+ }
159
+
160
+ // What a refresh found, with the Got its tapped while it ran, as those changed the ledger after the refresh read it [ATT-21].
161
+ export function withGotIt(next: ChangeLedger, gotIt: string[]): ChangeLedger {
162
+ const ids = new Set(next.events.map((event) => event.id));
163
+ return { ...next, gotIt: gotIt.filter((id) => ids.has(id)) };
164
+ }
165
+
166
+ // The ledger as cards: Doing's notes not yet cleared, within `windowDays`, newest first [ATT-21]; History's work closed
167
+ // unmerged by others or taken out of my hands, from `historySince` [HIS-06].
168
+ export function changeItems(ledger: ChangeLedger, now: Date, windowDays: number, historySince: string): { doing: Item[]; history: Item[] } {
169
+ const since = new Date(now.getTime() - windowDays * 86_400_000).toISOString();
170
+ const gotIt = new Set(ledger.gotIt);
171
+ const base = (change: OthersChange): Omit<Item, "key" | "section"> => ({
172
+ kind: change.subject,
173
+ draft: false,
174
+ repo: change.repo,
175
+ number: change.number,
176
+ title: change.title,
177
+ url: change.url,
178
+ chips: [],
179
+ actions: [],
180
+ children: [],
181
+ target: { kind: change.subject, repo: change.repo, number: change.number, title: change.title, url: change.url },
182
+ othersActivityAt: change.at,
183
+ change,
184
+ });
185
+ const doing = ledger.events
186
+ .filter((change) => !gotIt.has(change.id) && change.at >= since)
187
+ .map((change): Item => ({ ...base(change), key: `change:${change.id}`, section: "changed", actions: ["got_it"] }));
188
+ const history = ledger.events
189
+ .filter((change) => change.kind !== "merged" && change.at >= historySince)
190
+ .map((change): Item => ({ ...base(change), key: `handed:${change.id}`, section: "handed_off", closedAt: change.at }));
191
+ return { doing, history };
192
+ }
193
+
194
+ // Keys of my PRs and issues that left my hands: a merge by their new owner isn't my finished work [HIS-06].
195
+ export function handedKeys(ledger: ChangeLedger): Set<string> {
196
+ return new Set(ledger.events.filter(isHandover).map((event) => event.key));
197
+ }
@@ -426,6 +426,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
426
426
  // My merged PRs under the closed issues they worked on, closed issues, and reviews [HIS-01, HIS-02, ATT-03].
427
427
  export function classifyHistory(data: HistoryResult): Item[] {
428
428
  const items: Item[] = [];
429
+ const me = data.viewer?.login.toLowerCase();
429
430
  const closed = new Map<string, Item>();
430
431
  // What kind of work it was, on the card and its copied line [HIS-04].
431
432
  const kinded = (item: Item, node: { title: string; labels?: { nodes: { name: string }[] }; issueType?: { name: string } | null }): Item => {
@@ -443,8 +444,11 @@ export function classifyHistory(data: HistoryResult): Item[] {
443
444
  // Each merged PR on its own: its branches are gone, so it can't be put back in its stack [ATT-03].
444
445
  const linked = { repo: pr.repository.nameWithOwner, body: pr.body, linked: pr.closingIssuesReferences.nodes.map(prKey) };
445
446
  const issue = closed.get(issueFor([linked], (key) => closed.has(key)) ?? "");
446
- if (issue) issue.children.push({ key: prKey(pr), number: pr.number, title: pr.title, url: pr.url, draft: false, chips: [], attention: false });
447
- else items.push(kinded({ ...plain(pr, "pr", "done"), closedAt: pr.mergedAt }, pr));
447
+ // Who merged it, when it wasn't me, alone or under its issue [HIS-05].
448
+ const by = pr.mergedBy?.login;
449
+ const mergedBy = by && me && by.toLowerCase() !== me ? { mergedBy: by } : {};
450
+ if (issue) issue.children.push({ key: prKey(pr), number: pr.number, title: pr.title, url: pr.url, draft: false, chips: [], attention: false, ...mergedBy });
451
+ else items.push(kinded({ ...plain(pr, "pr", "done"), closedAt: pr.mergedAt, ...mergedBy }, pr));
448
452
  }
449
453
  for (const pr of compact(data.reviewed.nodes)) items.push(kinded({ ...plain(pr, "pr", "reviewed"), closedAt: pr.mergedAt, person: author(pr.author, pr.mergedAt) }, pr));
450
454
  return items.sort(order);
package/server/fixture.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { AgentSummary, GithubColor, ItemDetails, Reviewer, ReviewerChoices, Target } from "../shared/attention";
2
+ import type { OthersChange } from "../shared/changes";
2
3
  import type { SessionKind } from "../shared/config";
3
4
  import type { IssueField } from "../shared/setup";
4
5
  import type { Actor, Comment, Details, IssueNode, MentionNode, PickableNode, PullRequestNode, SearchResult } from "./github-types";
@@ -134,6 +135,7 @@ export function builders(now: Date) {
134
135
  merged: nodes("merged") as SearchResult["merged"],
135
136
  reviewed: nodes("reviewed") as SearchResult["reviewed"],
136
137
  closed: nodes("closed") as SearchResult["closed"],
138
+ ended: nodes("ended") as SearchResult["ended"],
137
139
  };
138
140
  }
139
141
 
@@ -152,6 +154,8 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
152
154
  title,
153
155
  url: `https://github.com/${REPO}/pull/${number}`,
154
156
  mergedAt: daysAgo(days),
157
+ // Someone else merged one of them [HIS-05].
158
+ mergedBy: { login: number === 177 ? "dave" : number === 179 ? "carol" : "me" },
155
159
  repository,
156
160
  labels: labels(...names),
157
161
  closingIssuesReferences: { nodes: closesIssue ? [{ number: closesIssue, repository }] : [] },
@@ -282,6 +286,8 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
282
286
  merged(172, "Fix VAT on credit notes", 3, undefined, "bug"),
283
287
  merged(177, "chore: bump the build image", 4),
284
288
  merged(178, "Tidy the settings screen", 5),
289
+ // Handed over to carol before she merged it, so it isn't listed as mine [HIS-06].
290
+ merged(179, "Move invoices to the new queue", 1),
285
291
  merged(173, "Speed up the order list", 9, 174),
286
292
  merged(175, "Remove the old importer", 16),
287
293
  ],
@@ -310,6 +316,33 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
310
316
  };
311
317
  }
312
318
 
319
+ // What others did to my work, one of each kind, as the ledger keeps them [ATT-21, HIS-06]. #179 was handed over, then merged
320
+ // by its new owner, so History doesn't count it as mine.
321
+ export function fixtureChanges(now: Date): OthersChange[] {
322
+ const hoursAgo = (hours: number) => new Date(now.getTime() - hours * 3_600_000).toISOString();
323
+ const event = (kind: OthersChange["kind"], subject: "pr" | "issue", number: number, title: string, hours: number, actor?: string, to?: string): OthersChange => ({
324
+ id: `${kind}:F_${number}:${hoursAgo(hours)}`,
325
+ kind,
326
+ subjectId: `F_${number}`,
327
+ subject,
328
+ key: `${REPO}#${number}`,
329
+ repo: REPO,
330
+ number,
331
+ title,
332
+ url: `https://github.com/${REPO}/${subject === "pr" ? "pull" : "issues"}/${number}`,
333
+ ...(actor ? { actor } : {}),
334
+ ...(to ? { to } : {}),
335
+ at: hoursAgo(hours),
336
+ });
337
+ return [
338
+ event("merged", "pr", 183, "Retry failed webhooks", 2, "dave"),
339
+ event("took_over", "pr", 186, "Split the invoice PDF job", 5, "phil", "phil"),
340
+ event("closed", "pr", 169, "Cache exchange rates", 26, "alice"),
341
+ event("handed", "pr", 179, "Move invoices to the new queue", 50, "dave", "carol"),
342
+ event("unassigned", "issue", 160, "Refunds skip the ledger", 74, "bob"),
343
+ ];
344
+ }
345
+
313
346
  // Sessions the preview shows as started from items: working, needs me, failed, idle.
314
347
  // Each sits in its action's line in the sheet. Issue 90 has two: an old one with no kind, which leads, and Rebase stack on its PR.
315
348
  // #113 waits on CI while its Fix CI session works, though Fix CI isn't one of its actions any more.
package/server/gh.ts CHANGED
@@ -34,16 +34,28 @@ export function runGh(args: string[], input?: string, { timeoutMs }: { timeoutMs
34
34
 
35
35
  // GitHub's answer with its errors kept beside whatever data resolved, for callers that must tell a partial answer from a
36
36
  // whole one. Throws only when nothing came back at all.
37
- export async function graphqlResult<T>(query: string, variables: Record<string, unknown> = {}, options: { timeoutMs?: number } = {}): Promise<{ data: T | null; errors: string[] }> {
37
+ // `failures` says where each error was and what kind, for callers that tell a node GitHub can't find from one it failed on.
38
+ export interface GraphqlFailure {
39
+ message: string;
40
+ type?: string;
41
+ path?: (string | number)[];
42
+ }
43
+
44
+ export async function graphqlResult<T>(
45
+ query: string,
46
+ variables: Record<string, unknown> = {},
47
+ options: { timeoutMs?: number } = {},
48
+ ): Promise<{ data: T | null; errors: string[]; failures: GraphqlFailure[] }> {
38
49
  const { code, stdout, stderr } = await runGh(["api", "graphql", "--input", "-"], JSON.stringify({ query, variables }), options);
39
- let parsed: { data?: T | null; errors?: { message: string }[] } | undefined;
50
+ let parsed: { data?: T | null; errors?: GraphqlFailure[] } | undefined;
40
51
  try {
41
52
  parsed = JSON.parse(stdout);
42
53
  } catch {
43
54
  // Not JSON: an auth or network failure.
44
55
  }
45
- const errors = (parsed?.errors ?? []).map((error) => error.message);
46
- if (parsed?.data) return { data: parsed.data, errors };
56
+ const failures = parsed?.errors ?? [];
57
+ const errors = failures.map((error) => error.message);
58
+ if (parsed?.data) return { data: parsed.data, errors, failures };
47
59
  throw new Error(errors.join("; ") || stderr.trim() || `gh exited with ${code}`);
48
60
  }
49
61
 
@@ -96,6 +96,8 @@ export interface IssueNode {
96
96
  }
97
97
 
98
98
  export interface PickableNode {
99
+ // The issue's node id, which a transfer keeps [ATT-21].
100
+ id?: string;
99
101
  number: number;
100
102
  title: string;
101
103
  url: string;
@@ -128,6 +130,42 @@ export interface LiveResult {
128
130
  asked: Nodes<IssueNode>;
129
131
  assigned: Nodes<PickableNode>;
130
132
  unclaimed: Nodes<PickableNode>;
133
+ // My PRs closed lately [ATT-21].
134
+ ended: Nodes<EndedPullRequest>;
135
+ }
136
+
137
+ export interface EndedPullRequest {
138
+ id: string;
139
+ number: number;
140
+ title: string;
141
+ url: string;
142
+ merged: boolean;
143
+ mergedAt: string | null;
144
+ closedAt: string;
145
+ repository: Repo;
146
+ mergedBy: { login: string } | null;
147
+ assignees: Nodes<{ login: string }>;
148
+ timelineItems: Nodes<{ createdAt?: string; actor?: { login: string } | null }>;
149
+ }
150
+
151
+ // Who assigned or unassigned whom; actor and assignee are null for a deleted account [ATT-21].
152
+ export interface AssignmentEvent {
153
+ __typename: "AssignedEvent" | "UnassignedEvent";
154
+ createdAt: string;
155
+ actor: { login: string } | null;
156
+ assignee: { login?: string } | null;
157
+ }
158
+
159
+ export interface AssignmentSubject {
160
+ __typename: "PullRequest" | "Issue";
161
+ id: string;
162
+ number: number;
163
+ title: string;
164
+ url: string;
165
+ state: "OPEN" | "CLOSED" | "MERGED";
166
+ repository: Repo;
167
+ assignees: Nodes<{ login: string }>;
168
+ timelineItems: Nodes<AssignmentEvent | Record<string, never>>;
131
169
  }
132
170
 
133
171
  // One request for all three [HIS-01, HIS-02].
@@ -135,7 +173,9 @@ export interface LiveResult {
135
173
  type Labels = { labels?: Nodes<{ name: string }> };
136
174
 
137
175
  export interface HistoryResult {
138
- merged: Nodes<{ number: number; title: string; url: string; body?: string; mergedAt: string; repository: Repo; closingIssuesReferences: Nodes<{ number: number; repository: Repo }> } & Labels>;
176
+ // Who I am, to tell a merge by someone else [HIS-05]; missing in older fixtures.
177
+ viewer?: { login: string; id: string };
178
+ merged: Nodes<{ number: number; title: string; url: string; body?: string; mergedAt: string; mergedBy?: { login: string } | null; repository: Repo; closingIssuesReferences: Nodes<{ number: number; repository: Repo }> } & Labels>;
139
179
  reviewed: Nodes<{ number: number; title: string; url: string; mergedAt: string; repository: Repo; author: Actor | null } & Labels>;
140
180
  closed: Nodes<{ number: number; title: string; url: string; closedAt: string; stateReason: string | null; repository: Repo; issueType?: { name: string } | null } & Labels>;
141
181
  }
package/server/queries.ts CHANGED
@@ -28,9 +28,20 @@ const SEARCHES = {
28
28
  asked: { first: 50, nodes: THREAD },
29
29
  assigned: { first: 50, nodes: "...pickable" },
30
30
  unclaimed: { first: 100, nodes: "...pickable" },
31
+ // My PRs closed lately, with who merged or closed them, for Changed by others [ATT-21]. Who closed one comes from its last
32
+ // close event; assignees tell a PR handed over before it closed [PRS-08].
33
+ ended: {
34
+ first: 50,
35
+ nodes: `... on PullRequest {
36
+ id number title url merged mergedAt closedAt repository { nameWithOwner } mergedBy { login }
37
+ assignees(first: 10) { nodes { login } }
38
+ timelineItems(itemTypes: [CLOSED_EVENT], last: 1) { nodes { ... on ClosedEvent { createdAt actor { login } } } }
39
+ }`,
40
+ },
41
+ // Who merged it, when it wasn't me [HIS-05].
31
42
  merged: {
32
43
  first: 100,
33
- nodes: "... on PullRequest { number title url body mergedAt repository { nameWithOwner } labels(first: 20) { nodes { name } } closingIssuesReferences(first: 3) { nodes { number repository { nameWithOwner } } } }",
44
+ nodes: "... on PullRequest { number title url body mergedAt mergedBy { login } repository { nameWithOwner } labels(first: 20) { nodes { name } } closingIssuesReferences(first: 3) { nodes { number repository { nameWithOwner } } } }",
34
45
  },
35
46
  reviewed: { first: 100, nodes: "... on PullRequest { number title url mergedAt repository { nameWithOwner } author { ...author } labels(first: 20) { nodes { name } } }" },
36
47
  // Labels and type say what kind of work each was [HIS-04].
@@ -39,7 +50,7 @@ const SEARCHES = {
39
50
  export type SearchName = keyof typeof SEARCHES;
40
51
 
41
52
  // Doing, Waiting and Next up. History has its own, slower schedule.
42
- export const LIVE_SEARCHES = ["mine", "reviews", "mentions", "involved", "asked", "assigned", "unclaimed"] as const;
53
+ export const LIVE_SEARCHES = ["mine", "reviews", "mentions", "involved", "asked", "assigned", "unclaimed", "ended"] as const;
43
54
  export const HISTORY_SEARCHES = ["merged", "reviewed", "closed"] as const;
44
55
 
45
56
  const FRAGMENTS: Record<string, string> = {
@@ -51,7 +62,7 @@ const FRAGMENTS: Record<string, string> = {
51
62
  ... on PullRequestReviewComment { id url reactionGroups { viewerHasReacted } }
52
63
  }`,
53
64
  pickable: `fragment pickable on Issue {
54
- number title url createdAt
65
+ id number title url createdAt
55
66
  repository { nameWithOwner isFork defaultBranchRef { name } }
56
67
  issueType { name }
57
68
  issueFieldValues(first: 20) { nodes { ... on IssueFieldSingleSelectValue { name field { ... on IssueFieldCommon { name } } } } }
@@ -125,6 +136,11 @@ function startOfWeek(now: Date): Date {
125
136
  return monday;
126
137
  }
127
138
 
139
+ // Where History starts: whole weeks, from a Monday, so the oldest week isn't cut short [HIS-01].
140
+ export function historySince(now: Date, weeks: number): string {
141
+ return new Date(startOfWeek(now).getTime() - (weeks - 1) * 7 * 86_400_000).toISOString();
142
+ }
143
+
128
144
  // Where Next up looks for unclaimed issues [NXT-04, NXT-08]: one search per chosen source, so each issue says which
129
145
  // sources found it and no query outgrows GitHub's limit [NXT-09]. Without sources, the configured orgs and repos,
130
146
  // else my Paseo projects' repos. Never all of GitHub: unlike the other searches, this one isn't about me.
@@ -170,14 +186,15 @@ export function mergeUnclaimed(results: { source: string | null; nodes: (Pickabl
170
186
  export function searchVariables(config: AttentionConfig, now: Date): Record<Exclude<SearchName, "unclaimed">, string> {
171
187
  const scope = where(config.orgs, config.repos);
172
188
  const since = isoDate(new Date(now.getTime() - config.mentionDays * 86_400_000));
173
- // Whole weeks, from a Monday, so the oldest week isn't cut short.
174
- const history = isoDate(new Date(startOfWeek(now).getTime() - (config.historyWeeks - 1) * 7 * 86_400_000));
189
+ const history = isoDate(new Date(historySince(now, config.historyWeeks)));
175
190
  return {
176
191
  mine: `is:pr is:open author:@me ${scope}`,
177
192
  // By name only, not via a team [REV-01].
178
193
  reviews: `is:pr is:open user-review-requested:@me ${scope}`,
179
194
  mentions: `is:open mentions:@me updated:>=${since} ${scope}`,
180
195
  assigned: `is:issue is:open assignee:@me ${scope}`,
196
+ // Within the window Changed by others catches up over [ATT-21].
197
+ ended: `is:pr is:closed author:@me closed:>=${since} sort:updated-desc ${scope}`,
181
198
  // Threads I opened, commented on, was assigned or mentioned in, active lately: answers, and fresh questions [ATT-16].
182
199
  involved: `is:open involves:@me updated:>=${since} sort:updated-desc ${scope}`,
183
200
  // On my own issues a question nobody answered stays however old [ATT-11]. Newest first, so old ones go last.
@@ -189,6 +206,17 @@ export function searchVariables(config: AttentionConfig, now: Date): Record<Excl
189
206
  };
190
207
  }
191
208
 
209
+ // Who assigned and unassigned whom on PRs and issues that may have left my hands, by node id, a batch per request [ATT-21, GH-01].
210
+ // The last events are enough: a handover is the latest change of hands.
211
+ export const ASSIGNMENT_BATCH = 20;
212
+ const ASSIGNMENT_EVENT = "createdAt actor { login } assignee { ... on User { login } ... on Bot { login } ... on Mannequin { login } }";
213
+ export function assignmentsQuery(ids: string[]): string {
214
+ const subject = `id number title url state repository { nameWithOwner } assignees(first: 10) { nodes { login } }
215
+ timelineItems(itemTypes: [ASSIGNED_EVENT, UNASSIGNED_EVENT], last: 30) { nodes { __typename ... on AssignedEvent { ${ASSIGNMENT_EVENT} } ... on UnassignedEvent { ${ASSIGNMENT_EVENT} } } }`;
216
+ const fields = ids.map((id, index) => `a${index}: node(id: ${JSON.stringify(id)}) { __typename ... on PullRequest { ${subject} } ... on Issue { ${subject} } }`);
217
+ return `query Assignments {\n${fields.join("\n")}\n}`;
218
+ }
219
+
192
220
  export function prKey(node: { repository: { nameWithOwner: string }; number: number }): string {
193
221
  return `${node.repository.nameWithOwner}#${node.number}`;
194
222
  }
package/server/service.ts CHANGED
@@ -2,12 +2,15 @@ import type { Attention, AttentionView, FeedId, FeedStatus, GithubColor, Item, P
2
2
  import type { PluginHandlerContext } from "@getpaseo/plugin/server";
3
3
  import { AttentionConfig, type FieldRole, githubRepoOf, nextUpField } from "../shared/config";
4
4
  import type { IssueField } from "../shared/setup";
5
+ import { changeCandidates, nextLedger, type Lookups, withGotIt } from "./changes";
5
6
  import { classify, classifyHistory, issueBoardIds } from "./classify";
6
7
  import { probeAnswer, projectsFailure, projectsWarning, searchWithProjects } from "./projects";
7
8
  import { FIXTURE, graphql, graphqlResult } from "./gh";
8
- import { fixture, FIXTURE_AGENTS, FIXTURE_ISSUE_FIELDS } from "./fixture";
9
- import type { Details, HistoryResult, LinkedIssue, LiveResult, MergeStateStatus, PullRequestNode } from "./github-types";
9
+ import { fixture, FIXTURE_AGENTS, FIXTURE_ISSUE_FIELDS, fixtureChanges } from "./fixture";
10
+ import type { AssignmentSubject, Details, HistoryResult, LinkedIssue, LiveResult, MergeStateStatus, PullRequestNode } from "./github-types";
10
11
  import {
12
+ ASSIGNMENT_BATCH,
13
+ assignmentsQuery,
11
14
  type CheckContext,
12
15
  detailsQuery,
13
16
  HISTORY_SEARCHES,
@@ -118,6 +121,14 @@ export class AttentionService {
118
121
  return this.view();
119
122
  }
120
123
 
124
+ // Clears a Changed by others note, or brings it back for Undo; nothing changes on GitHub [ATT-21].
125
+ async gotIt(id: string, on: boolean): Promise<AttentionView> {
126
+ const gotIt = this.state.changes.gotIt.filter((other) => other !== id);
127
+ this.state.changes.gotIt = on && this.state.changes.events.some((event) => event.id === id) ? [...gotIt, id] : gotIt;
128
+ await this.save();
129
+ return this.view();
130
+ }
131
+
121
132
  async restoreDismissed(): Promise<AttentionView> {
122
133
  this.state.dismissed = {};
123
134
  await this.save();
@@ -282,9 +293,41 @@ export class AttentionService {
282
293
  const login = FIXTURE ? "me" : this.config.nextUp.mine ? await this.login() : null;
283
294
  const unclaimed = unclaimedSearches(this.config, projectRepos, login);
284
295
  const { data, details } = FIXTURE ? fixture(now) : await this.searchLive(now, unclaimed.searches);
296
+ await this.trackChanges(data, now);
285
297
  return { ...classify({ data, details, config: this.config, now }), unclaimedFrom: unclaimed.from };
286
298
  }
287
299
 
300
+ // What others did to my work since the last refresh [ATT-21]. Only PRs whose hands changed and issues that left my assigned
301
+ // search are looked up, a batch per request; a failed batch is asked again next time [GH-01]. Kept long enough for History.
302
+ private async trackChanges(data: LiveResult, now: Date): Promise<void> {
303
+ const ledger = this.state.changes;
304
+ if (FIXTURE) {
305
+ // Previews start each layout with a refresh, which brings the notes back: Got it would otherwise outlive a layout.
306
+ this.state.changes = { ...ledger, events: fixtureChanges(now), gotIt: [] };
307
+ return;
308
+ }
309
+ const me = data.viewer.login;
310
+ const candidates = changeCandidates(ledger, data, me);
311
+ const lookups: Lookups = new Map();
312
+ for (let at = 0; at < candidates.length; at += ASSIGNMENT_BATCH) {
313
+ const batch = candidates.slice(at, at + ASSIGNMENT_BATCH);
314
+ try {
315
+ const { data: result, failures } = await graphqlResult<Record<string, AssignmentSubject | null>>(assignmentsQuery(batch));
316
+ batch.forEach((id, index) => {
317
+ const alias = `a${index}`;
318
+ // A node GitHub can't find is gone for good; one it failed on is asked again next refresh.
319
+ const failed = failures.some((failure) => failure.path?.[0] === alias && failure.type !== "NOT_FOUND");
320
+ if (!failed) lookups.set(id, result?.[alias] ?? null);
321
+ });
322
+ } catch (error) {
323
+ console.error("Couldn't look up who changed my work:", (error as Error).message);
324
+ }
325
+ }
326
+ const keepDays = Math.max(this.config.mentionDays, this.config.historyWeeks * 7 + 7);
327
+ // A Got it tapped while this refresh ran still counts.
328
+ this.state.changes = withGotIt(nextLedger(ledger, data, me, lookups, now, this.config.mentionDays, keepDays), this.state.changes.gotIt);
329
+ }
330
+
288
331
  // The account gh is signed in as, for My repos [NXT-04]. Asked once, unless the last fetch already says.
289
332
  private async login(): Promise<string> {
290
333
  return (this.state.live?.attention.login || (await graphql<{ viewer: { login: string } }>("{ viewer { login } }")).viewer.login);
@@ -306,7 +349,7 @@ export class AttentionService {
306
349
 
307
350
  private async fetchHistory(now: Date): Promise<Item[]> {
308
351
  if (FIXTURE) return classifyHistory(fixture(now).data);
309
- return classifyHistory(await graphql<HistoryResult>(searchQuery(HISTORY_SEARCHES), this.variables(HISTORY_SEARCHES, now)));
352
+ return classifyHistory(await graphql<HistoryResult>(searchQuery(HISTORY_SEARCHES, true), this.variables(HISTORY_SEARCHES, now)));
310
353
  }
311
354
 
312
355
  // Whether the gh login may read projects, asked at most hourly, or now when Settings asks [NXT-12]. On only when GitHub
@@ -362,7 +405,7 @@ export class AttentionService {
362
405
  };
363
406
  const merge = (parts: Partial<LiveResult>[]) => Object.assign({}, ...parts) as LiveResult;
364
407
  const forDetails = Promise.all([search("mine"), search("assigned"), searchUnclaimed()]);
365
- const others = Promise.all([search("reviews"), search("mentions"), search("involved"), search("asked")]);
408
+ const others = Promise.all([search("reviews"), search("mentions"), search("involved"), search("asked"), search("ended")]);
366
409
  const afterThem = forDetails.then((parts) => this.details(merge(parts), projects, problems));
367
410
  try {
368
411
  const [first, rest, details] = await Promise.all([forDetails, others, afterThem]);
@@ -507,7 +550,11 @@ export class AttentionService {
507
550
  const now = Date.now();
508
551
  const pending = Object.fromEntries(Object.entries(this.state.pending).filter(([, entry]) => isPending(entry, this.fetchedAt(), now)));
509
552
  const shown = applyPending(this.state.live?.attention ?? null, this.state.history?.items ?? [], pending);
510
- return buildView(shown.attention, shown.history, this.state.dismissed, {
553
+ return buildView(
554
+ shown.attention,
555
+ shown.history,
556
+ this.state.dismissed,
557
+ {
511
558
  feeds: { live: status("live"), history: status("history") },
512
559
  scopes: this.state.scopes,
513
560
  sources: this.state.sources,
@@ -515,6 +562,8 @@ export class AttentionService {
515
562
  config: this.config,
516
563
  pending: Object.keys(pending).length,
517
564
  ...(FIXTURE ? { fixtureAgents: FIXTURE_AGENTS } : {}),
518
- });
565
+ },
566
+ this.state.changes,
567
+ );
519
568
  }
520
569
  }
package/server/store.ts CHANGED
@@ -4,6 +4,8 @@ import { join } from "node:path";
4
4
  import { z } from "zod";
5
5
  import { type Attention, type Item, type SectionId, SECTIONS } from "../shared/attention";
6
6
  import { AttentionConfig, FIELD_ROLES, type FieldRole, sameField } from "../shared/config";
7
+ import type { OthersChange } from "../shared/changes";
8
+ import { EMPTY_LEDGER } from "./changes";
7
9
  import type { Pending } from "./view";
8
10
 
9
11
  // Local files in ~/.config/paseo-attention-span/ [PRIV-01].
@@ -29,6 +31,16 @@ export const State = z.object({
29
31
  projectFilter: z.array(z.string()).default([]),
30
32
  // The update notice put off with Not now, by the version it offered [UPD-01].
31
33
  skippedUpdate: z.string().nullable().default(null).catch(null),
34
+ // What others did to my work, kept until Got it and for History [ATT-21, HIS-06].
35
+ changes: z
36
+ .object({
37
+ events: z.array(z.custom<OthersChange>((value) => typeof (value as OthersChange)?.id === "string" && typeof (value as OthersChange)?.at === "string")),
38
+ gotIt: z.array(z.string()),
39
+ assigned: z.record(z.string(), z.string()).nullable(),
40
+ handed: z.record(z.string(), z.string()),
41
+ })
42
+ .default(EMPTY_LEDGER)
43
+ .catch(EMPTY_LEDGER),
32
44
  // My Paseo projects' GitHub repos when last listed, for refreshes before the app has connected [NXT-08].
33
45
  projectRepos: z.array(z.string()).default([]),
34
46
  // The last fetch of each feed. A cache from an older version is dropped rather than shown wrong, like one with an item in a
package/server/view.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { type Attention, type AttentionView, type Chip, type FeedId, type FeedStatus, type Item, type NextUpIssue, type Section, SECTION_ORDER, SECTIONS, type TabId, type WaitingGroup } from "../shared/attention";
2
2
  import type { AttentionConfig } from "../shared/config";
3
3
  import { workChip, workKind } from "../shared/work";
4
+ import { type ChangeLedger, changeItems, EMPTY_LEDGER, handedKeys } from "./changes";
5
+ import { historySince } from "./queries";
4
6
  import type { State } from "./store";
5
7
 
6
8
  export interface ViewMeta {
@@ -126,25 +128,33 @@ export function waitingGroups(items: Item[]): WaitingGroup[] {
126
128
  // Waiting's work: its own sections, and my PRs in Doing while they wait on someone I asked [WAI-01, PRS-15].
127
129
  const inWaiting = (item: Item) => SECTIONS[item.section].tab === "waiting" || (SECTIONS[item.section].tab === "doing" && !!item.wait && !!item.waitingOn?.length);
128
130
 
129
- export function buildView(attention: Attention | null, history: Item[], dismissed: State["dismissed"], meta: ViewMeta): AttentionView {
131
+ export function buildView(attention: Attention | null, history: Item[], dismissed: State["dismissed"], meta: ViewMeta, ledger: ChangeLedger = EMPTY_LEDGER, now = new Date()): AttentionView {
130
132
  const items = [...(attention?.items ?? []), ...history];
131
- const visible = items.filter((item) => !isDismissed(item, dismissed));
133
+ // A PR that left my hands isn't my finished work, even once its new owner merges it [HIS-06].
134
+ const handed = handedKeys(ledger);
135
+ const visible = items
136
+ .filter((item) => !isDismissed(item, dismissed) && !(item.section === "done" && handed.has(item.key)))
137
+ .map((item) => (item.section === "done" && item.children.some((child) => handed.has(child.key)) ? { ...item, children: item.children.filter((child) => !handed.has(child.key)) } : item));
138
+ // Notes on what others did, and work that left my hands; never dismissed, only cleared with Got it [ATT-21, HIS-06].
139
+ const changes = changeItems(ledger, now, meta.config.mentionDays, historySince(now, meta.config.historyWeeks));
140
+ const shown = [...visible, ...changes.doing, ...changes.history];
132
141
  const sections = (tab: TabId): Section[] =>
133
142
  SECTION_ORDER.filter((id) => SECTIONS[id].tab === tab)
134
- .map((id) => ({ id, title: SECTIONS[id].title, items: visible.filter((item) => item.section === id) }))
143
+ .map((id) => ({ id, title: SECTIONS[id].title, items: shown.filter((item) => item.section === id) }))
135
144
  .filter((section) => section.items.length > 0);
136
145
  const doing = sections("doing");
137
146
  return {
138
147
  ...meta,
139
148
  login: attention?.login ?? null,
140
- count: doing.reduce((sum, section) => sum + section.items.length, 0),
149
+ // What needs me; notes on others' doings don't [ATT-09, ATT-21].
150
+ count: doing.reduce((sum, section) => sum + (section.id === "changed" ? 0 : section.items.length), 0),
141
151
  doing,
142
152
  waiting: waitingGroups(visible.filter(inWaiting)),
143
- history: visible.filter((item) => SECTIONS[item.section].tab === "history"),
153
+ history: shown.filter((item) => SECTIONS[item.section].tab === "history"),
144
154
  assigned: attention?.assigned ?? [],
145
155
  unclaimed: attention?.unclaimed ?? [],
146
156
  unclaimedFrom: attention?.unclaimedFrom ?? "config",
147
157
  projects: attention?.projects ?? [],
148
- dismissedCount: items.length - visible.length,
158
+ dismissedCount: items.filter((item) => isDismissed(item, dismissed)).length,
149
159
  };
150
160
  }
@@ -1,3 +1,4 @@
1
+ import type { OthersChange } from "./changes";
1
2
  import type { AttentionConfig, MergeMethod, SessionKind } from "./config";
2
3
  import type { WorkKind } from "./work";
3
4
 
@@ -22,6 +23,8 @@ export const SECTIONS = {
22
23
  // Nobody has the next move until I ask someone [PRS-12].
23
24
  needs_reviewer: { tab: "doing", title: "Needs a reviewer" },
24
25
  drafts: { tab: "doing", title: "My drafts" },
26
+ // What someone else did to my work: a note until Got it, never counted as needing me [ATT-21].
27
+ changed: { tab: "doing", title: "Changed by others" },
25
28
  // Waiting groups these by who they wait on, not by section [WAI-01].
26
29
  wait_review: { tab: "waiting", title: "Waiting for review" },
27
30
  wait_reviewer: { tab: "waiting", title: "Waiting for the reviewer" },
@@ -30,6 +33,8 @@ export const SECTIONS = {
30
33
  // [HIS-01, HIS-02]
31
34
  done: { tab: "history", title: "Done" },
32
35
  reviewed: { tab: "history", title: "Reviewed" },
36
+ // My PRs closed unmerged by others, and work taken out of my hands, out of the week's copy [HIS-06].
37
+ handed_off: { tab: "history", title: "Closed or handed off" },
33
38
  } as const satisfies Record<string, { tab: TabId; title: string }>;
34
39
  export type SectionId = keyof typeof SECTIONS;
35
40
  export const SECTION_ORDER = Object.keys(SECTIONS) as SectionId[];
@@ -50,7 +55,9 @@ export type ActionId =
50
55
  | "automerge"
51
56
  | "merge"
52
57
  | "close"
53
- | "start";
58
+ | "start"
59
+ // Clears a Changed by others note; nothing changes on GitHub [ATT-21].
60
+ | "got_it";
54
61
 
55
62
  // A short state label on a row [ATT-05]; tone picks its color.
56
63
  export interface Chip {
@@ -190,6 +197,8 @@ export interface SubRow {
190
197
  chips: Chip[];
191
198
  // Behind its parent, conflicting or failing CI: shown even when the stack is collapsed.
192
199
  attention: boolean;
200
+ // History only: who merged it, when it wasn't me [HIS-05].
201
+ mergedBy?: string;
193
202
  }
194
203
 
195
204
  export interface Item {
@@ -218,6 +227,10 @@ export interface Item {
218
227
  work?: WorkKind;
219
228
  // History only: an issue closed as not planned, kept out of the copied week [HIS-03].
220
229
  notPlanned?: true;
230
+ // History only: who merged my PR, when it wasn't me [HIS-05].
231
+ mergedBy?: string;
232
+ // Changed by others and Closed or handed off: what someone else did [ATT-21, HIS-06].
233
+ change?: OthersChange;
221
234
  }
222
235
 
223
236
  // The colors GitHub lets an org give issue field options and a project its Status options. GRAY is what nothing chosen looks
@@ -371,7 +384,7 @@ export interface FeedStatus {
371
384
  export interface AttentionView {
372
385
  feeds: Record<FeedId, FeedStatus>;
373
386
  login: string | null;
374
- // Items in Doing; the sidebar shows it [ATT-09].
387
+ // Items in Doing that need me; the sidebar shows it. Changed by others notes don't count [ATT-09, ATT-21].
375
388
  count: number;
376
389
  doing: Section[];
377
390
  waiting: WaitingGroup[];
@@ -0,0 +1,51 @@
1
+ import { ago } from "./format";
2
+
3
+ // What someone else did to my work without asking me: merged or closed my PR, took it over or handed it on, or unassigned me
4
+ // from an issue [ATT-21]. Issue closes, others' pushes and my own doings aren't here.
5
+ // merged someone else merged my PR
6
+ // closed someone else closed my PR without merging it
7
+ // took_over someone assigned themselves my PR or issue, and I'm off it
8
+ // handed someone assigned my PR or issue to a third person, and I'm off it
9
+ // unassigned someone took me off an issue and nobody has it now
10
+ export type OthersChangeKind = "merged" | "closed" | "took_over" | "handed" | "unassigned";
11
+
12
+ export interface OthersChange {
13
+ // Stable across refreshes, so Got it sticks to this event and no other on the same item.
14
+ id: string;
15
+ kind: OthersChangeKind;
16
+ // The PR's or issue's node id, which survives a transfer; key is "owner/name#number" as last seen.
17
+ subjectId: string;
18
+ subject: "pr" | "issue";
19
+ key: string;
20
+ repo: string;
21
+ number: number;
22
+ title: string;
23
+ url: string;
24
+ // Who did it; missing when GitHub doesn't say (a deleted account).
25
+ actor?: string;
26
+ // The new assignee, for took_over and handed.
27
+ to?: string;
28
+ at: string;
29
+ }
30
+
31
+ // Handovers take the work out of my hands; merges and closes end it.
32
+ export const HANDOVER_KINDS: readonly OthersChangeKind[] = ["took_over", "handed", "unassigned"];
33
+ export const isHandover = (change: Pick<OthersChange, "kind">) => HANDOVER_KINDS.includes(change.kind);
34
+
35
+ // The words on the card, so the tile's color is never the only way to tell [ATT-21]: "merged by dave 2h ago".
36
+ export function changeText(change: Pick<OthersChange, "kind" | "actor" | "to" | "at">, now = new Date()): string {
37
+ const age = `${ago(change.at, now)} ago`;
38
+ const { actor, to } = change;
39
+ switch (change.kind) {
40
+ case "merged":
41
+ return actor ? `merged by ${actor} ${age}` : `merged ${age}`;
42
+ case "closed":
43
+ return actor ? `closed by ${actor} ${age}, not merged` : `closed ${age}, not merged`;
44
+ case "took_over":
45
+ return actor ? `${actor} took over ${age}` : `taken over ${age}`;
46
+ case "handed":
47
+ return actor ? `${actor} handed it to ${to} ${age}` : `handed to ${to} ${age}`;
48
+ case "unassigned":
49
+ return actor ? `${actor} unassigned you ${age}` : `unassigned you ${age}`;
50
+ }
51
+ }
package/shared/rpc.ts CHANGED
@@ -17,6 +17,8 @@ export const getAttention = defineRpc({ name: "attention.get", input: z.object({
17
17
  export const dismissItem = defineRpc({ name: "attention.dismiss", input: z.object({ key: z.string() }), output: view });
18
18
  // Undo one dismissal [ATT-08].
19
19
  export const undismissItem = defineRpc({ name: "attention.undismiss", input: z.object({ key: z.string() }), output: view });
20
+ // Clears a Changed by others note; `on: false` brings it back for Undo. Nothing changes on GitHub [ATT-21].
21
+ export const gotIt = defineRpc({ name: "attention.got-it", input: z.object({ id: z.string(), on: z.boolean() }), output: view });
20
22
  export const restoreDismissed = defineRpc({ name: "attention.restore-dismissed", input: z.object({}), output: view });
21
23
  // Adds one entry to codeRepos in config.json [SES-07].
22
24
  export const setCodeRepo = defineRpc({ name: "config.set-code-repo", input: z.object({ issueRepo: z.string(), codeRepo: z.string() }), output: view });