@andrioid/paseo-attention-span 0.3.6 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/OVERVIEW.md CHANGED
@@ -33,15 +33,17 @@ A PR you opened isn't waiting on anyone until you've asked someone to review it,
33
33
 
34
34
  ![Request review](docs/screenshots/desktop-dark-doing-reviewers.png)
35
35
 
36
- Anything that's sat in Waiting for more than three days moves back here under **Waiting too long**. Usually that means someone forgot, and sometimes the someone is me.
36
+ Anything that's sat in Waiting for more than three days shows up here too, under **Waiting too long**. Usually that means someone forgot, and sometimes the someone is me.
37
37
 
38
38
  ![Waiting too long](docs/screenshots/desktop-dark-doing-too-long.png)
39
39
 
40
40
  ## Waiting: out of your hands
41
41
 
42
- This is your work where someone else has the next move: waiting for the review you asked for, waiting for the reviewer to look again, CI running, or a question you asked that nobody's answered yet.
42
+ This is your work where someone else has the next move: the review you asked for, the reviewer looking again, CI running, or a question you asked that nobody's answered yet. Only questions count: a comment that just tells people something, even one that tags them, isn't waiting on anyone.
43
43
 
44
- There's nothing to do here. That's the point. It's tracked, so you can stop holding it in your head.
44
+ It's grouped by who you're waiting on, whoever blocks the most first, and each item says why and for how long. Work with a session that's running or needs you leads its group. Who counts only when it's on record: the reviewers you asked, the reviewer who asked for changes, or the people you tagged in your question. Work that waits on nobody in particular, like CI or a repo rule, sits at the bottom rather than under a guess. Work that waited too long shows here as well as in Doing.
45
+
46
+ When someone needs a nudge, **Copy list** next to their name copies their items oldest first, one line each like "Review 2h: [title](link)", ready to paste into a message. Otherwise there's nothing to do here. That's the point. It's tracked, so you can stop holding it in your head.
45
47
 
46
48
  ![Waiting](docs/screenshots/desktop-dark-waiting.png)
47
49
 
@@ -4,7 +4,7 @@ import { Markdown, Modal, TextInput, useToast } from "@getpaseo/plugin/client/ui
4
4
  import { useQuery, useQueryClient } from "@tanstack/react-query";
5
5
  import { type ReactNode, useState } from "react";
6
6
  import { Pressable, ScrollView, Text, View } from "react-native";
7
- import { type ActionId, type AgentSummary, type AttentionView, type Chip, type FailingChecks, type Item, itemSessions, looseSessions, type NextUpIssue, type Reviewer, type Section, type SectionId, SECTIONS, type SubRow, TAB_FEED, type TabId, type Target } from "../shared/attention";
7
+ import { type ActionId, type AgentSummary, type AttentionView, type Chip, type FailingChecks, type Item, itemSessions, liftActive, looseSessions, type NextUpIssue, 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 { ago, linkList, repoLabel } from "../shared/format";
10
10
  import { ACTION_SESSION, renderPrompt } from "../shared/prompts";
@@ -304,11 +304,11 @@ function AttentionList({
304
304
  // Each tab shows how fresh its own feed is.
305
305
  const feed = view.feeds[TAB_FEED[tab]];
306
306
  const refreshing = feed.refreshing || attention.isFetching;
307
- const tooLong = view.doing.find((section) => section.id === "too_long")?.items.length ?? 0;
308
307
  const counts: Record<TabId, number> = {
309
308
  history: view.history.filter((item) => item.section === "done").length,
310
309
  doing: view.count,
311
- waiting: view.waiting.reduce((sum, section) => sum + section.items.length, 0),
310
+ // Work waiting on several people counts once.
311
+ waiting: new Set(view.waiting.flatMap((group) => group.items.map((item) => item.key))).size,
312
312
  next: view.assigned.length + view.unclaimed.length,
313
313
  };
314
314
 
@@ -421,16 +421,7 @@ function AttentionList({
421
421
  ) : null}
422
422
  </>
423
423
  ) : null}
424
- {tab === "waiting" ? (
425
- <>
426
- <Sections sections={view.waiting} actions={actions} empty="Nothing is waiting on others." />
427
- {tooLong > 0 ? (
428
- <Pressable accessibilityRole="button" onPress={() => switchTab("doing")}>
429
- <Text style={styles.muted}>{tooLong} more waited too long and moved to Doing →</Text>
430
- </Pressable>
431
- ) : null}
432
- </>
433
- ) : null}
424
+ {tab === "waiting" ? <Waiting groups={view.waiting} actions={actions} /> : null}
434
425
  {tab === "next" ? (
435
426
  <NextUpList
436
427
  assigned={view.assigned}
@@ -548,10 +539,39 @@ type Sheet = "item" | "acknowledge" | "reviewers" | "reviewers-after-ready" | nu
548
539
  // A session on an item that has no session action of its own starts with this prompt; it's editable first.
549
540
  const fallbackKind = (item: Item): SessionKind => (item.target.kind === "issue" ? "start" : "review");
550
541
 
551
- function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions: Actions }) {
542
+ // How long it has waited, and why: in Waiting with a flag once it's too long, in Doing's Waiting too long as its own warning [WAI-01, ATT-11].
543
+ function waitChips(item: Item, inWaiting: boolean): Chip[] {
544
+ const { wait } = item;
545
+ if (!wait) return [];
546
+ const age = ago(wait.since);
547
+ if (!inWaiting) return wait.overdue ? [{ text: `${wait.overdue} · ${age}`, tone: "warn" }] : [];
548
+ return [
549
+ ...(wait.overdue ? [{ text: "waited too long", tone: "warn" as const }] : []),
550
+ ...(wait.reason ? [{ text: wait.reason, tone: "neutral" as const }] : []),
551
+ { text: age, tone: "neutral" },
552
+ ];
553
+ }
554
+
555
+ // "Review 2h", "Question 3d": why and how long, to lead a line in a nudge [WAI-03].
556
+ function nudgeLead(item: Item): string | undefined {
557
+ if (!item.wait) return undefined;
558
+ const { reason, since } = item.wait;
559
+ return reason ? `${reason[0].toUpperCase()}${reason.slice(1)} ${ago(since)}` : ago(since);
560
+ }
561
+
562
+ const samePerson = (a: WaitingOn, b: WaitingOn) => a.team === b.team && a.login.toLowerCase() === b.login.toLowerCase();
563
+
564
+ // In Waiting, a card sits under one of whom it waits on: its group.
565
+ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean; actions: Actions; group?: WaitingGroup }) {
566
+ const styles = useStyles();
552
567
  // An open session leads; without one, the item's own action does [SES-03].
553
568
  const sessions = itemSessions(actions.agents, item);
554
- const chips = sessions[0] ? [...item.chips, agentSignal(sessions[0])] : item.chips;
569
+ const own = [...waitChips(item, !!group), ...item.chips];
570
+ const chips = sessions[0] ? [...own, agentSignal(sessions[0])] : own;
571
+ // The group names one; the card names the rest [WAI-01].
572
+ const others = group?.who ? (item.waitingOn ?? []).filter((who) => !samePerson(who, group.who!)) : [];
573
+ const waitingOn = group ? null : item.waitingOn ? <WaitingOnLine people={item.waitingOn} expanded={false} /> : null;
574
+ const alsoOn = others.length ? <Text style={styles.muted}>also waiting on {others.map((who) => who.login).join(", ")}</Text> : null;
555
575
  const [sheet, setSheet] = useState<Sheet>(null);
556
576
  const [confirm, setConfirm] = useState<"merge" | "close" | null>(null);
557
577
  const main = item.actions[0];
@@ -587,9 +607,11 @@ function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions
587
607
  signals: chips,
588
608
  }}
589
609
  extra={
590
- item.person || children.length > 0 ? (
610
+ item.person || waitingOn || alsoOn || children.length > 0 ? (
591
611
  <>
592
612
  {item.person ? <PersonQuote person={item.person} expanded={false} /> : null}
613
+ {waitingOn}
614
+ {alsoOn}
593
615
  {children.length > 0 ? <StackLine rows={children} merged={!!item.closedAt} /> : null}
594
616
  </>
595
617
  ) : null
@@ -626,7 +648,7 @@ function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions
626
648
  }
627
649
  overlay={
628
650
  <>
629
- {sheet === "item" ? <ItemSheet item={item} sessions={sessions} actions={actions} {...handlers} /> : null}
651
+ {sheet === "item" ? <ItemSheet item={item} chips={own} sessions={sessions} actions={actions} {...handlers} /> : null}
630
652
  {sheet === "acknowledge" ? <AcknowledgeSheet item={item} onReact={(ids) => (setSheet(null), actions.acknowledge(item, ids))} onClose={() => setSheet(null)} /> : null}
631
653
  {sheet === "reviewers" || sheet === "reviewers-after-ready" ? (
632
654
  <ReviewerSheet
@@ -649,7 +671,7 @@ interface SheetHandlers {
649
671
  }
650
672
 
651
673
  // What the card already knows on top, then every action, then what's fetched when it opens, so nothing jumps as it loads [ATT-06, GH-01].
652
- function ItemSheet({ item, sessions, actions, ...handlers }: { item: Item; sessions: AgentSummary[]; actions: Actions } & SheetHandlers) {
674
+ function ItemSheet({ item, chips, sessions, actions, ...handlers }: { item: Item; chips: Chip[]; sessions: AgentSummary[]; actions: Actions } & SheetHandlers) {
653
675
  const checks = item.actions.includes("rerun");
654
676
  const details = useQuery({
655
677
  queryKey: ["attention-span", "details", item.key, checks],
@@ -666,8 +688,9 @@ function ItemSheet({ item, sessions, actions, ...handlers }: { item: Item; sessi
666
688
  onClose={handlers.onClose}
667
689
  top={
668
690
  <>
669
- <Meta facts={meta} chips={item.chips} />
691
+ <Meta facts={meta} chips={chips} />
670
692
  {item.person ? <PersonQuote person={item.person} expanded /> : null}
693
+ {item.waitingOn ? <WaitingOnLine people={item.waitingOn} expanded /> : null}
671
694
  {item.children.length > 0 ? <StackLine rows={item.children} merged={!!item.closedAt} links /> : null}
672
695
  </>
673
696
  }
@@ -893,6 +916,49 @@ function PersonQuote({ person, expanded }: { person: NonNullable<Item["person"]>
893
916
  );
894
917
  }
895
918
 
919
+ // Pictures on a card before the rest are counted, so a crowd fits a phone; the sheet names everyone.
920
+ const MAX_FACES = 5;
921
+
922
+ // Who my work waits on: one by name, several by picture, named on hover, and each by name in the sheet [WAI-02].
923
+ function WaitingOnLine({ people, expanded }: { people: WaitingOn[]; expanded: boolean }) {
924
+ const styles = useStyles();
925
+ const [hovered, setHovered] = useState<string | null>(null);
926
+ const name = (login: string) => (
927
+ <Text style={{ color: styles.c.foreground, fontSize: 12, fontWeight: "600", flexShrink: 1 }} numberOfLines={1}>
928
+ {login}
929
+ </Text>
930
+ );
931
+ const since = (at: string) => <Text style={styles.muted}>· {ago(at)}</Text>;
932
+ if (expanded || people.length === 1) {
933
+ return (
934
+ <View style={{ gap: 6 }}>
935
+ {people.map((who) => (
936
+ <View key={who.login} style={styles.row}>
937
+ <Avatar url={who.avatarUrl} team={who.team} />
938
+ {name(who.login)}
939
+ {since(who.since)}
940
+ </View>
941
+ ))}
942
+ </View>
943
+ );
944
+ }
945
+ const earliest = people.map((who) => who.since).sort()[0];
946
+ return (
947
+ <View style={styles.row} accessibilityLabel={`Waiting on ${people.map((who) => who.login).join(", ")}`}>
948
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 4 }}>
949
+ {people.slice(0, MAX_FACES).map((who) => (
950
+ <View key={who.login} onPointerEnter={() => setHovered(who.login)} onPointerLeave={() => setHovered((current) => (current === who.login ? null : current))}>
951
+ <Avatar url={who.avatarUrl} team={who.team} />
952
+ </View>
953
+ ))}
954
+ {people.length > MAX_FACES ? <Text style={styles.muted}>+{people.length - MAX_FACES}</Text> : null}
955
+ </View>
956
+ {hovered ? name(hovered) : null}
957
+ {since(earliest)}
958
+ </View>
959
+ );
960
+ }
961
+
896
962
  function Sections({ sections, actions, empty }: { sections: Section[]; actions: Actions; empty: string }) {
897
963
  const styles = useStyles();
898
964
  if (sections.length === 0) return <Text style={styles.text}>{empty}</Text>;
@@ -904,16 +970,45 @@ function Sections({ sections, actions, empty }: { sections: Section[]; actions:
904
970
  ));
905
971
  }
906
972
 
907
- function Card({ items, actions }: { items: Item[]; actions: Actions }) {
973
+ function Card({ items, actions, group }: { items: Item[]; actions: Actions; group?: WaitingGroup }) {
908
974
  return (
909
975
  <CardList>
910
976
  {items.map((item, index) => (
911
- <ItemRow key={item.key} item={item} first={index === 0} actions={actions} />
977
+ <ItemRow key={item.key} item={item} first={index === 0} actions={actions} group={group} />
912
978
  ))}
913
979
  </CardList>
914
980
  );
915
981
  }
916
982
 
983
+ // Waiting by who it waits on, each with a list to copy for a nudge, oldest first; a bot gets none, as there's nobody to send
984
+ // it to. Last, the work no person holds up. Cards with an active session lead their group [WAI-01, WAI-03].
985
+ function Waiting({ groups, actions }: { groups: WaitingGroup[]; actions: Actions }) {
986
+ const styles = useStyles();
987
+ const copy = useCopy();
988
+ if (groups.length === 0) return <Text style={styles.text}>Nothing is waiting on others.</Text>;
989
+ return groups.map((group) => {
990
+ const { who, items } = group;
991
+ const links = `${items.length} link${items.length === 1 ? "" : "s"}`;
992
+ const nudge = (login: string) =>
993
+ copy(linkList(items.map((item) => ({ ...item, lead: nudgeLead(item) }))), `Copied ${links} for ${login}`);
994
+ return (
995
+ <View key={who ? `${who.team ? "team" : "user"}:${who.login.toLowerCase()}` : "nobody"}>
996
+ <SectionHeader
997
+ icon={who ? <Avatar url={who.avatarUrl} team={who.team} bot={who.bot} /> : "clock"}
998
+ title={who?.login ?? "Not on a person"}
999
+ count={items.length}
1000
+ action={
1001
+ who && !who.bot ? (
1002
+ <Button icon="copy" label={styles.compact ? undefined : "Copy list"} variant="ghost" accessibilityLabel={`Copy what waits on ${who.login}`} onPress={() => nudge(who.login)} />
1003
+ ) : null
1004
+ }
1005
+ />
1006
+ <Card items={liftActive(items, actions.agents)} actions={actions} group={group} />
1007
+ </View>
1008
+ );
1009
+ });
1010
+ }
1011
+
917
1012
  // Monday-start weeks in the device's time zone.
918
1013
  function weekOf(iso: string): Date {
919
1014
  const day = new Date(iso);
package/client/icons.ts CHANGED
@@ -4,6 +4,7 @@ export const ICONS = {
4
4
  draft: { 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-5h.01M18 6h.01\"/></svg>" },
5
5
  issue: { 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=\"M11 12a1 1 0 1 0 2 0a1 1 0 1 0-2 0\"/><path d=\"M3 12a9 9 0 1 0 18 0a9 9 0 1 0-18 0\"/></g></svg>" },
6
6
  bot: { 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 6a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2zm6-4v2m-3 8v9m6-9v9M5 16l4-2m6 0l4 2M9 18h6M10 8v.01M14 8v.01\"/></svg>" },
7
+ team: { 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 7a4 4 0 1 0 8 0a4 4 0 1 0-8 0M3 21v-2a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v2m1-17.87a4 4 0 0 1 0 7.75M21 21v-2a4 4 0 0 0-3-3.85\"/></svg>" },
7
8
  reply: { 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=\"M18 4a3 3 0 0 1 3 3v8a3 3 0 0 1-3 3h-5l-5 3v-3H6a3 3 0 0 1-3-3V7a3 3 0 0 1 3-3z\"/><path d=\"m11 8l-3 3l3 3m5-3H8\"/></g></svg>" },
8
9
  review: { 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=\"M10 12a2 2 0 1 0 4 0a2 2 0 0 0-4 0\"/><path d=\"M21 12q-3.6 6-9 6t-9-6q3.6-6 9-6t9 6\"/></g></svg>" },
9
10
  ci: { 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 9v4m-1.637-9.409L2.257 17.125a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636-2.87L13.637 3.59a1.914 1.914 0 0 0-3.274 0M12 16h.01\"/></svg>" },
package/client/ui.tsx CHANGED
@@ -114,9 +114,9 @@ export function Meta({ facts, chips }: { facts: string[]; chips: Chip[] }) {
114
114
  );
115
115
  }
116
116
 
117
- export function Avatar({ url, bot, size = 18 }: { url?: string; bot?: boolean; size?: number }) {
117
+ export function Avatar({ url, bot, team, size = 18 }: { url?: string; bot?: boolean; team?: boolean; size?: number }) {
118
118
  const styles = useStyles();
119
- if (bot || !url) return <TablerIcon name={bot ? "bot" : "issue"} size={size} />;
119
+ if (bot || !url) return <TablerIcon name={bot ? "bot" : team ? "team" : "issue"} size={size} />;
120
120
  return <Image source={{ uri: url }} style={{ width: size, height: size, borderRadius: size / 2, backgroundColor: styles.c.surface2 }} />;
121
121
  }
122
122
 
@@ -177,11 +177,12 @@ export function Button({
177
177
  }
178
178
 
179
179
  // Sentence case, with the count as quiet text.
180
- export function SectionHeader({ icon, title, count, action }: { icon: IconName; title: string; count: number; action?: ReactNode }) {
180
+ // The icon may be a picture instead, like the avatar of whom Waiting's work waits on.
181
+ export function SectionHeader({ icon, title, count, action }: { icon: IconName | ReactNode; title: string; count: number; action?: ReactNode }) {
181
182
  const styles = useStyles();
182
183
  return (
183
184
  <View style={[styles.row, { marginBottom: 10 }]}>
184
- <TablerIcon name={icon} size={15} />
185
+ {typeof icon === "string" ? <TablerIcon name={icon as IconName} size={15} /> : icon}
185
186
  <Text style={{ color: styles.c.foreground, fontSize: 13, fontWeight: "600", flex: 1 }}>
186
187
  {title}
187
188
  <Text style={{ color: styles.c.foregroundMuted, fontWeight: "400" }}> · {count}</Text>
@@ -50,7 +50,7 @@ The tabs tell the story of my work, left to right: what I finished, what needs m
50
50
  |---|---|
51
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 [HIS-03]. |
52
52
  | Doing | The sections below |
53
- | Waiting | My work where someone else has the next move [WAI-01]: *Waiting for review* (once a person or team is asked, or someone else has reviewed; with the requested reviewer or team; 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): on my own issues however old, on others' only while my comment is within `mentionDays` [ATT-11] |
53
+ | Waiting | My work where someone else has the next move [WAI-01]: *Waiting for review* (once a person or team is asked, or someone else has reviewed; 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. *Waiting too long* items show here too, flagged "waited too long". Each card says why it waits (review, re-review, question, or nobody asked again after a review that only commented; nothing where its chips say, like approved, blocked by repo rules, or CI running with nobody asked) 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]. Outside Waiting, as in *Waiting too long*, 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] |
55
55
 
56
56
  Every card in every tab is the same component, `CardRow` in `client/card.tsx` [ATT-05]: a tinted mark for what it is, a title of at most two lines, then "repo #number", when it happened and signal chips, then content only some lists have (tags, a quote, a stack line), and its actions: on the right on desktop, labelled under the text on phones. A change on GitHub asks first in a `ConfirmBar` on the card [SAFE-01]. Tabs differ only in what they pass in: each maps its data to the card's mark, meta, actions and slots. Marks and signals take a tone, never a raw theme color, because some themes draw `accent` close to white.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrioid/paseo-attention-span",
3
- "version": "0.3.6",
3
+ "version": "0.4.0",
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
@@ -96,7 +96,9 @@ functional:
96
96
  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.
97
97
  waiting:
98
98
  As a developer, I can:
99
- WAI-01: see my work that is waiting on others, grouped by what it waits for, where a pull request waits for review only once someone has been asked; so that I know that work is tracked.
99
+ 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 work that waited too long, 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.
100
+ WAI-02: see who my waiting work waits on: reviewers I asked, reviewers who asked for changes and people I tagged in my unanswered question, and nobody where none of those apply; so that I know whom to nudge without guessing.
101
+ WAI-03: copy the list of my work waiting on one person or team, oldest first, each line a Markdown link led by why and for how long, like "Review 2h: [title](link)"; so that nudging them is one paste they can skim.
100
102
  history:
101
103
  As a developer, I can:
102
104
  HIS-01: see the issues and pull requests I finished, grouped by week; so that I can tell others what I got done.
@@ -1,8 +1,21 @@
1
- import { type Attention, type Chip, type Item, type NextUpIssue, type Person, type Reviewer, SECTION_ORDER, SECTIONS, type SectionId, type SubRow, type Target } from "../shared/attention";
1
+ import {
2
+ type Attention,
3
+ type Chip,
4
+ type Item,
5
+ type NextUpIssue,
6
+ type Person,
7
+ type Reviewer,
8
+ SECTION_ORDER,
9
+ SECTIONS,
10
+ type SectionId,
11
+ type SubRow,
12
+ type Target,
13
+ type WaitingOn,
14
+ } from "../shared/attention";
2
15
  import type { AttentionConfig, MergeMethod } from "../shared/config";
3
16
  import { ago, daysSince } from "../shared/format";
4
17
  import type { Actor, Comment, Details, HistoryResult, IssueNode, LinkedIssue, LiveResult, MentionNode, PickableNode, PullRequestNode, RequestedReviewer } from "./github-types";
5
- import { excerpt, plainText } from "./markdown";
18
+ import { asksQuestion, excerpt, plainText, taggedIn } from "./markdown";
6
19
  import { prKey } from "./queries";
7
20
  import { issueFor } from "./references";
8
21
  import { ISSUE_RULES, type IssueState, pick, PR_RULES, type PrState, replyActions, rulesBlock } from "./rules";
@@ -44,7 +57,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
44
57
  // What each thread I'm in is waiting for: an answer, or me [ATT-16]. Both searches can find one; it's the same thread.
45
58
  const threads = new Map<string, IssueNode>();
46
59
  for (const node of [...compact(data.involved.nodes), ...compact(data.asked.nodes)]) threads.set(prKey(node), node);
47
- const answers = new Map<string, { flags: IssueState; person?: Person; mine: string }>();
60
+ const answers = new Map<string, NonNullable<ReturnType<typeof threadState>>>();
48
61
  for (const [key, node] of threads) {
49
62
  const found = threadState(node, me, now, config);
50
63
  if (found) answers.set(key, found);
@@ -165,14 +178,27 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
165
178
  const rule = PR_RULES[section];
166
179
  const actions = rule?.actions?.(flags) ?? [];
167
180
  const rulesBlocked = rulesBlock(flags);
168
- // Who it waits on: the reviewer who asked for changes, else who's requested, else who reviewed.
169
- const reviewer = replied
170
- ? bottom.latestReviews.nodes.find((review) => review.state === "CHANGES_REQUESTED")?.author
171
- : (bottom.reviewRequests.nodes.map((request) => requested(request.requestedReviewer)).find(Boolean) ??
172
- bottom.latestReviews.nodes.find((review) => isOther(review.author))?.author);
181
+ // Who it waits on, only from what GitHub records: who I asked, and while it waits for the reviewer after my reply, who
182
+ // asked for changes; while CI runs, only who I asked. Someone who reviewed and wasn't asked again owes nothing. A rule,
183
+ // not a person, holds up a PR the rules block [WAI-02, PRS-13].
184
+ const waits = !rulesBlocked && (section === "too_long" || SECTIONS[section].tab === "waiting");
185
+ const changers = replied && !flags.ciPending ? bottom.latestReviews.nodes.filter((review) => review.state === "CHANGES_REQUESTED").map((review) => review.author) : [];
186
+ const asked = bottom.reviewRequests.nodes.map((request) => requested(request.requestedReviewer));
187
+ const waitingOn = waits ? reviewers([...changers, ...asked].filter(isOther), waitingSince) : [];
188
+ // Why it waits, where the chips don't already say: approved ones say so, so do the rules that block them, and so does CI
189
+ // running when nobody's on it [WAI-01].
190
+ const reason =
191
+ waitingOn.length > 0
192
+ ? replied
193
+ ? "re-review"
194
+ : "review"
195
+ : rulesBlocked || s.approved || s.ciPending
196
+ ? undefined
197
+ : bottom.reviewRequests.nodes.length > 0
198
+ ? "review"
199
+ : "nobody asked again";
173
200
 
174
201
  const chips: Chip[] = [];
175
- if (section === "too_long") chips.push(chip(`${rule?.label?.(flags)} · ${ago(waitingSince, now)}`, "warn"));
176
202
  if (bottom.isDraft && s.stale) chips.push(chip(`untouched ${ago(bottom.updatedAt, now)}`, "warn"));
177
203
  if (s.approved && !bottom.isDraft) chips.push(chip("approved", "good"));
178
204
  if (rulesBlocked) chips.push(chip("blocked by repo rules", "warn"));
@@ -192,14 +218,13 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
192
218
  section,
193
219
  actions,
194
220
  chips,
195
- // How long it has waited, shown only while it sits in a Waiting section.
196
- waited: SECTIONS[section].tab === "waiting" ? chip(ago(waitingSince, now)) : undefined,
221
+ // Waiting too long shows in Waiting too, under whoever it waits on [WAI-01].
222
+ wait: section === "too_long" || SECTIONS[section].tab === "waiting" ? { reason, since: waitingSince, overdue: section === "too_long" ? rule?.label?.(flags) : undefined } : undefined,
197
223
  person:
198
224
  waiting ??
199
225
  (section === "answered" ? answer : undefined) ??
200
- (section === "changes" && s.botThreadsOnly ? { login: "review bot", bot: true, since: s.lastCommitAt } : undefined) ??
201
- // A rule, not a person, holds it up [PRS-13].
202
- (!rulesBlocked && (section === "too_long" || SECTIONS[section].tab === "waiting") ? person(reviewer, waitingSince) : undefined),
226
+ (section === "changes" && s.botThreadsOnly ? { login: "review bot", bot: true, since: s.lastCommitAt } : undefined),
227
+ waitingOn: waitingOn.length > 0 ? waitingOn : undefined,
203
228
  othersActivityAt: latest(...stack.map((pr) => state(pr).othersActivityAt), waiting?.since, answer?.since),
204
229
  };
205
230
  });
@@ -262,8 +287,10 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
262
287
  number: lead?.number ?? bottom.number,
263
288
  title: lead?.title ?? bottom.title,
264
289
  url: lead?.url ?? bottom.url,
265
- chips: [...(lead ? [chip(`PR #${bottom.number}`)] : []), ...unit.chips, ...(unit.section === section && unit.waited ? [unit.waited] : [])],
290
+ chips: [...(lead ? [chip(`PR #${bottom.number}`)] : []), ...unit.chips],
266
291
  person: issueWaiting ?? unit.person,
292
+ waitingOn: issueWaiting ? undefined : unit.waitingOn,
293
+ wait: issueWaiting ? undefined : unit.wait,
267
294
  actions: issueWaiting ? replyActions(issueWaiting) : unit.actions,
268
295
  children: lead ? grouped.flatMap((u) => u.stack.map((pr, i) => subRow(pr, i, u.stack))) : unit.stack.slice(1).map((pr, i) => subRow(pr, i + 1, unit.stack)),
269
296
  target: target(bottom, unit.stack),
@@ -328,7 +355,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
328
355
  const found = answers.get(key);
329
356
  const kind = issue.__typename === "PullRequest" ? "pr" : "issue";
330
357
  if (listed.has(key) || !found || (kind === "pr" && found.flags.authored)) continue;
331
- const { flags, person, mine } = found;
358
+ const { flags, person, mine, tagged } = found;
332
359
  const section = pick(ISSUE_RULES, flags);
333
360
  if (!section) continue;
334
361
  listed.add(key);
@@ -336,8 +363,9 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
336
363
  const since = person?.since ?? mine;
337
364
  items.push({
338
365
  ...plain(issue, kind, section),
339
- chips: section === "answered" ? [] : [label ? chip(`${label} · ${ago(since, now)}`, "warn") : chip(ago(since, now))],
340
366
  person,
367
+ waitingOn: section !== "answered" && tagged.length > 0 ? tagged : undefined,
368
+ wait: section === "answered" ? undefined : { reason: "question", since, overdue: label },
341
369
  actions: section === "answered" ? replyActions(person) : [],
342
370
  // A new answer brings back a dismissed one [ATT-08].
343
371
  othersActivityAt: person ? latest(...(person.comments ?? []).map((c) => c.createdAt)) : EPOCH,
@@ -386,7 +414,7 @@ export function threadState(
386
414
  me: string,
387
415
  now: Date,
388
416
  config: Pick<AttentionConfig, "mentionDays" | "waitingTooLongDays" | "followThreads">,
389
- ): { flags: IssueState; person?: Person; mine: string } | null {
417
+ ): { flags: IssueState; person?: Person; mine: string; tagged: WaitingOn[] } | null {
390
418
  const authored = thread.author?.login.toLowerCase() === me;
391
419
  const people = thread.comments.nodes.filter((c) => c.author && c.author.__typename !== "Bot");
392
420
  const index = people.findLastIndex((c) => c.author?.login.toLowerCase() === me);
@@ -395,20 +423,27 @@ export function threadState(
395
423
  const after = people.slice(index + 1);
396
424
  const recent = (at: string) => daysSince(at, now) < config.mentionDays;
397
425
  const unread = after.filter((c) => recent(c.createdAt) && !c.reactionGroups?.some((group) => group.viewerHasReacted));
426
+ // My comments since someone else last spoke; bots don't end the run.
427
+ let first = index;
428
+ while (first > 0 && people[first - 1].author?.login.toLowerCase() === me) first -= 1;
429
+ const run = index >= 0 ? people.slice(first, index + 1) : [];
398
430
  const flags: IssueState = {
399
431
  authored,
400
432
  follow: config.followThreads,
401
433
  // Opening a thread isn't asking a question; a comment is.
402
434
  mineLast: index >= 0 && after.length === 0,
435
+ question: run.some((comment) => asksQuestion(comment.bodyHTML)),
403
436
  answered: unread.length > 0,
404
437
  fresh: recent(mine),
405
438
  tooLong: daysSince(mine, now) >= config.waitingTooLongDays,
406
439
  };
440
+ const tagged = flags.mineLast ? taggedSince(run, me, thread.url) : [];
407
441
  const last = unread.at(-1);
408
- if (!last?.author) return { flags, mine };
442
+ if (!last?.author) return { flags, mine, tagged };
409
443
  return {
410
444
  flags,
411
445
  mine,
446
+ tagged,
412
447
  person: {
413
448
  login: last.author.login,
414
449
  avatarUrl: last.author.avatarUrl,
@@ -421,6 +456,31 @@ export function threadState(
421
456
  };
422
457
  }
423
458
 
459
+ // Who my comments since someone else last spoke tag, each from the first comment that tags them; only the fetched comments
460
+ // count. A tag gives just a name, so a person's picture is GitHub's for that name [WAI-02].
461
+ function taggedSince(run: Comment[], me: string, url: string): WaitingOn[] {
462
+ const origin = new URL(url).origin;
463
+ const tagged: WaitingOn[] = [];
464
+ for (const comment of run) {
465
+ for (const { login, team } of taggedIn(comment.bodyHTML)) {
466
+ const seen = (other: { login: string }) => other.login.toLowerCase() === login.toLowerCase();
467
+ if (login.toLowerCase() === me || tagged.some(seen)) continue;
468
+ tagged.push({ login, team, avatarUrl: team ? undefined : `${origin}/${login}.png?size=64`, since: comment.createdAt });
469
+ }
470
+ }
471
+ return tagged;
472
+ }
473
+
474
+ // Reviewers once each, in order: people and teams by their own picture.
475
+ function reviewers(actors: (Actor | null | undefined)[], since: string): WaitingOn[] {
476
+ const list: WaitingOn[] = [];
477
+ for (const actor of actors) {
478
+ if (!actor || list.some((other) => other.login.toLowerCase() === actor.login.toLowerCase())) continue;
479
+ list.push({ login: actor.login, avatarUrl: actor.avatarUrl, team: actor.__typename === "Team", ...(actor.__typename === "Bot" ? { bot: true } : {}), since });
480
+ }
481
+ return list;
482
+ }
483
+
424
484
  // A requested person, or a team by its "org/slug".
425
485
  function requested(reviewer: RequestedReviewer | null | undefined): Actor | undefined {
426
486
  const login = reviewer?.login ?? reviewer?.combinedSlug;
package/server/fixture.ts CHANGED
@@ -20,6 +20,8 @@ export const alice: Actor = { __typename: "User", login: "alice", avatarUrl: ava
20
20
  export const bob: Actor = { __typename: "User", login: "bob", avatarUrl: avatar(2) };
21
21
  export const bot: Actor = { __typename: "Bot", login: "reviewbot" };
22
22
  const frontend = { __typename: "Team", combinedSlug: "acme/frontend", avatarUrl: avatar(9919) };
23
+ // A tag as GitHub renders it in a comment [WAI-02].
24
+ const tag = (login: string) => `<a class="user-mention notranslate" data-hovercard-type="user" href="https://github.com/${login}">@${login}</a>`;
23
25
 
24
26
  export function builders(now: Date) {
25
27
  const daysAgo = (days: number) => new Date(now.getTime() - days * 86_400_000).toISOString();
@@ -56,7 +58,9 @@ export function builders(now: Date) {
56
58
 
57
59
  function comment(author: Actor, body: string, days: number, extra: Partial<Comment> = {}): Comment {
58
60
  comments += 1;
59
- return { id: `IC_${comments}`, author, body, createdAt: daysAgo(days), url: `https://github.com/${REPO}/issues/1#c${comments}`, reactionGroups: [], ...extra };
61
+ // GitHub renders it too; plain text is enough for made-up comments, which pass their own rendering where it matters.
62
+ const bodyHTML = `<p>${body.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")}</p>`;
63
+ return { id: `IC_${comments}`, author, body, bodyHTML, createdAt: daysAgo(days), url: `https://github.com/${REPO}/issues/1#c${comments}`, reactionGroups: [], ...extra };
60
64
  }
61
65
 
62
66
  function mention(number: number, comments: Comment[], overrides: Partial<MentionNode> = {}): MentionNode {
@@ -150,7 +154,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
150
154
  pr(110, { title: "requirements.yaml for the shop", isDraft: true, updatedAt: daysAgo(64) }),
151
155
  pr(111, { title: "Faster product search", reviewRequests: { nodes: [{ requestedReviewer: bob }] }, commits: commit("SUCCESS", 0.3) }),
152
156
  pr(112, { title: "Translate the checkout emails", reviewDecision: "CHANGES_REQUESTED", latestReviews: { nodes: [{ author: alice, state: "CHANGES_REQUESTED", submittedAt: daysAgo(2) }] }, commits: commit("SUCCESS", 1) }),
153
- pr(113, { title: "Upgrade the payment SDK", reviewRequests: { nodes: [{ requestedReviewer: bob }] } }, "PENDING"),
157
+ pr(113, { title: "Upgrade the payment SDK", reviewRequests: { nodes: [{ requestedReviewer: bob }, { requestedReviewer: alice }] } }, "PENDING"),
154
158
  pr(114, { title: "Cache exchange rates daily", reviewDecision: "APPROVED" }),
155
159
  pr(115, { title: "Split the settings page into tabs", isDraft: true, mergeable: "CONFLICTING" }),
156
160
  pr(116, { title: "Try a faster PDF renderer", isDraft: true }, "FAILURE"),
@@ -162,7 +166,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
162
166
  // Nobody asked yet: green, so Merge too; and one still in CI [PRS-12].
163
167
  pr(124, { title: "Export invoices as CSV", commits: commit("SUCCESS", 0.5) }),
164
168
  pr(125, { title: "Log slow database queries" }, "PENDING"),
165
- // A review that only commented keeps it waiting on that reviewer.
169
+ // A review that only commented, and nobody asked again: it waits, on nobody in particular [WAI-02].
166
170
  pr(126, { title: "Tidy the admin menu", latestReviews: { nodes: [{ author: alice, state: "COMMENTED", submittedAt: daysAgo(0.8) }] } }),
167
171
  // Approved and green, yet a repo rule blocks it, so it waits [PRS-13].
168
172
  pr(127, { title: "Sign the release artifacts", reviewDecision: "APPROVED", mergeStateStatus: "BLOCKED" }),
@@ -193,12 +197,23 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
193
197
  }),
194
198
  ],
195
199
  involved: [
196
- issue(140, [comment(alice, "", 9), comment(me, "Which customers see this?", 1)], "Invoice totals round wrong"),
200
+ // Questions that tag people wait on them: several by picture, one by name [WAI-02].
201
+ issue(
202
+ 140,
203
+ [comment(alice, "", 9), comment(me, "@alice @bob which customers see this?", 1, { bodyHTML: `<p>${tag("alice")} ${tag("bob")} which customers see this?</p>` })],
204
+ "Invoice totals round wrong",
205
+ ),
197
206
  // Answered on my own issue without mentioning me [ATT-16]; and a bot after my question, which doesn't count [MEN-05].
198
207
  issue(142, [comment(me, "Does this happen on every shop, or only some?", 2), comment(alice, "Only the Danish one, as far as I can tell. It started after the **VAT change** on Monday.", 0.4)], "Order confirmation shows the wrong VAT", { author: me }),
199
- issue(143, [comment(me, "Can we drop the old endpoint yet?", 1), comment(bot, "This issue has been labelled `needs-triage`.", 0.5)], "Retire the v1 orders endpoint"),
208
+ issue(
209
+ 143,
210
+ [comment(me, "@bob can we drop the old endpoint yet?", 1, { bodyHTML: `<p>${tag("bob")} can we drop the old endpoint yet?</p>` }), comment(bot, "This issue has been labelled `needs-triage`.", 0.5)],
211
+ "Retire the v1 orders endpoint",
212
+ ),
200
213
  // A comment on my PR's conversation [ATT-16].
201
214
  issue(111, [comment(bob, "Big change. Could you split the index migration into its own PR?", 0.2)], "Faster product search", { __typename: "PullRequest", author: me, createdAt: daysAgo(2) }),
215
+ // A statement that tags someone isn't a question: nobody owes me an answer, so it's not listed [WAI-01].
216
+ issue(145, [comment(me, "@bob deployed the fix to staging.", 0.5, { bodyHTML: `<p>${tag("bob")} deployed the fix to staging.</p>` })], "Checkout hangs on slow networks"),
202
217
  // Someone else's old thread where people kept going after me: not mine to follow [ATT-16].
203
218
  issue(144, [comment(me, "Same here on 2.3", 400), comment(bob, "+1", 300)], "Crash on startup"),
204
219
  ],
@@ -20,6 +20,8 @@ export interface Comment {
20
20
  id?: string;
21
21
  author: Actor | null;
22
22
  body?: string;
23
+ // Threads I'm in only: GitHub's rendering, where tags of real accounts are links [WAI-02].
24
+ bodyHTML?: string;
23
25
  createdAt: string;
24
26
  url?: string;
25
27
  reactionGroups?: { viewerHasReacted: boolean }[];
@@ -71,3 +71,39 @@ export function plainText(markdown: string): string {
71
71
  .replace(/^[ \t]*#{1,6}[ \t]+/gm, "")
72
72
  .replace(/^[ \t]*(?:[-*+]|\d+[.)])[ \t]+(?:\[[ xX]\][ \t]+)?/gm, "");
73
73
  }
74
+
75
+ // A comment as GitHub rendered it, without quoted replies: someone else's words. Innermost quotes first, so nested ones go whole.
76
+ function ownWords(html: string | undefined): string {
77
+ let text = html ?? "";
78
+ let previous: string;
79
+ do {
80
+ previous = text;
81
+ text = text.replace(/<blockquote\b[^>]*>(?:(?!<blockquote\b)[\s\S])*?<\/blockquote>/g, "");
82
+ } while (text !== previous);
83
+ return text;
84
+ }
85
+
86
+ // Whether a comment asks something: a question mark in my own words. GitHub's rendering says what's code or a link, however
87
+ // it was written (unclosed or indented code, bare URLs), so neither counts, and HTML comments aren't rendered at all [WAI-01].
88
+ export function asksQuestion(html: string | undefined): boolean {
89
+ const prose = ownWords(html)
90
+ .replace(/<(pre|code|a)\b[^>]*>[\s\S]*?<\/\1>/g, "")
91
+ .replace(/<[^>]*>/g, "");
92
+ return /[??]/.test(prose);
93
+ }
94
+
95
+ // People and teams tagged in a comment, from GitHub's rendering of it: GitHub links a tag only to an account that exists and
96
+ // a team I can see, and never in code. Tags in quoted replies are someone else's words, so they don't count [WAI-02].
97
+ export function taggedIn(html: string | undefined): { login: string; team: boolean }[] {
98
+ const text = ownWords(html);
99
+ const tags: { login: string; team: boolean }[] = [];
100
+ for (const [, attributes] of text.matchAll(/<a\b([^>]*)>/g)) {
101
+ const kind = /\bclass="[^"]*\b(user|team)-mention\b/.exec(attributes)?.[1];
102
+ const path = /\bhref="(?:https?:\/\/[^/"]+)?([^"?#]*)/.exec(attributes)?.[1] ?? "";
103
+ const team = /^\/orgs\/([^/]+)\/teams\/([^/]+)\/?$/.exec(path);
104
+ const user = /^\/([^/]+)\/?$/.exec(path);
105
+ const login = kind === "team" && team ? `${team[1]}/${team[2]}` : kind === "user" && user ? user[1] : undefined;
106
+ if (login && !tags.some((tag) => tag.login.toLowerCase() === login.toLowerCase())) tags.push({ login, team: kind === "team" });
107
+ }
108
+ return tags;
109
+ }
package/server/queries.ts CHANGED
@@ -3,10 +3,10 @@ import type { AttentionConfig } from "../shared/config";
3
3
  import type { PickableNode, PullRequestNode, RequiredChecks } from "./github-types";
4
4
  import type { IssueRef } from "./references";
5
5
 
6
- // An issue or PR with its last conversation comments [ATT-16].
6
+ // An issue or PR with its last conversation comments [ATT-16], rendered too for who my questions tag [WAI-02].
7
7
  const THREAD = `__typename
8
- ... on Issue { number title url createdAt author { ...author } repository { nameWithOwner } comments(last: 10) { nodes { ...comment } } }
9
- ... on PullRequest { number title url createdAt author { ...author } repository { nameWithOwner } comments(last: 10) { nodes { ...comment } } }`;
8
+ ... on Issue { number title url createdAt author { ...author } repository { nameWithOwner } comments(last: 10) { nodes { ...comment bodyHTML } } }
9
+ ... on PullRequest { number title url createdAt author { ...author } repository { nameWithOwner } comments(last: 10) { nodes { ...comment bodyHTML } } }`;
10
10
 
11
11
  // Each search with how many results it asks for and what it reads of each.
12
12
  const SEARCHES = {
@@ -65,7 +65,7 @@ const FRAGMENTS: Record<string, string> = {
65
65
  assignees(first: 10) { nodes { login } }
66
66
  closingIssuesReferences(first: 5) { nodes { number title url repository { nameWithOwner } } }
67
67
  commits(last: 1) { nodes { commit { committedDate statusCheckRollup { state } } } }
68
- reviewRequests(first: 5) { nodes { requestedReviewer { ... on User { ...author } ... on Team { __typename combinedSlug avatarUrl } } } }
68
+ reviewRequests(first: 5) { nodes { requestedReviewer { ... on User { ...author } ... on Bot { ...author } ... on Team { __typename combinedSlug avatarUrl } } } }
69
69
  latestReviews(first: 10) { nodes { author { ...author } state submittedAt } }
70
70
  reviewThreads(last: 30) {
71
71
  nodes {
package/server/rules.ts CHANGED
@@ -107,6 +107,8 @@ export interface IssueState {
107
107
  follow: boolean;
108
108
  // My comment is the last one from a person; bots don't count [MEN-05].
109
109
  mineLast: boolean;
110
+ // My comments since someone else last spoke ask something; a statement, tagged or not, waits on nobody [WAI-01].
111
+ question: boolean;
110
112
  // A person commented after me (or after I opened it) within mentionDays, and I haven't 👍'd it [MEN-02].
111
113
  answered: boolean;
112
114
  // My last comment is within mentionDays.
@@ -122,6 +124,6 @@ export const ISSUE_RULES: Rules<IssueState> = {
122
124
  // On someone else's thread only when I've allowed replies without a tag [ATT-17].
123
125
  answered: { when: (s) => s.answered && (s.authored || s.follow) },
124
126
  // Nobody answered for too long: mine to nudge. On my own issues however long ago, on others' only while fresh [ATT-11].
125
- too_long: { when: (s) => s.mineLast && (s.authored || s.fresh) && s.tooLong, label: () => "waiting for an answer" },
126
- wait_answer: { when: (s) => s.mineLast && (s.authored || s.fresh) },
127
+ too_long: { when: (s) => s.mineLast && s.question && (s.authored || s.fresh) && s.tooLong, label: () => "waiting for an answer" },
128
+ wait_answer: { when: (s) => s.mineLast && s.question && (s.authored || s.fresh) },
127
129
  };
package/server/view.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type Attention, type AttentionView, type Chip, type FeedId, type FeedStatus, type Item, type NextUpIssue, type Section, SECTION_ORDER, SECTIONS, type TabId } from "../shared/attention";
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 type { State } from "./store";
4
4
 
@@ -85,6 +85,36 @@ export function isDismissed(item: Item, dismissed: State["dismissed"]): boolean
85
85
  return !!entry && entry.section === item.section && item.othersActivityAt <= entry.at;
86
86
  }
87
87
 
88
+ // Waiting by who it waits on, so I know whom to nudge: whoever blocks the most first, ties by the longest wait, then bots, who
89
+ // can't be nudged, and last the work no person holds up. Each one's work oldest first; the screen lifts work with an active
90
+ // session. Waiting too long shows here too [WAI-01, WAI-03].
91
+ export function waitingGroups(items: Item[]): WaitingGroup[] {
92
+ const oldest = (list: Item[]) => list.map((item) => item.wait?.since ?? "").sort()[0] ?? "";
93
+ const people = new Map<string, WaitingGroup>();
94
+ const nobody: Item[] = [];
95
+ for (const item of items) {
96
+ if (!item.waitingOn?.length) nobody.push(item);
97
+ for (const who of item.waitingOn ?? []) {
98
+ const key = `${who.team ? "team" : "user"}:${who.login.toLowerCase()}`;
99
+ const group = people.get(key) ?? { who: { ...who }, items: [] };
100
+ // A requested bot is a bot wherever else its name turns up, like a tag [WAI-03].
101
+ if (who.bot) group.who!.bot = true;
102
+ group.items.push(item);
103
+ people.set(key, group);
104
+ }
105
+ }
106
+ const byWait = (a: Item, b: Item) => (a.wait?.since ?? "").localeCompare(b.wait?.since ?? "");
107
+ const groups = [...people.values()].map((group) => ({ ...group, items: group.items.sort(byWait) }));
108
+ groups.sort(
109
+ (a, b) =>
110
+ Number(!!a.who!.bot) - Number(!!b.who!.bot) ||
111
+ b.items.length - a.items.length ||
112
+ oldest(a.items).localeCompare(oldest(b.items)) ||
113
+ a.who!.login.localeCompare(b.who!.login),
114
+ );
115
+ return nobody.length ? [...groups, { items: nobody.sort(byWait) }] : groups;
116
+ }
117
+
88
118
  export function buildView(attention: Attention | null, history: Item[], dismissed: State["dismissed"], meta: ViewMeta): AttentionView {
89
119
  const items = [...(attention?.items ?? []), ...history];
90
120
  const visible = items.filter((item) => !isDismissed(item, dismissed));
@@ -98,7 +128,7 @@ export function buildView(attention: Attention | null, history: Item[], dismisse
98
128
  login: attention?.login ?? null,
99
129
  count: doing.reduce((sum, section) => sum + section.items.length, 0),
100
130
  doing,
101
- waiting: sections("waiting"),
131
+ waiting: waitingGroups(visible.filter((item) => item.section === "too_long" || SECTIONS[item.section].tab === "waiting")),
102
132
  history: visible.filter((item) => SECTIONS[item.section].tab === "history"),
103
133
  assigned: attention?.assigned ?? [],
104
134
  unclaimed: attention?.unclaimed ?? [],
@@ -22,7 +22,7 @@ export const SECTIONS = {
22
22
  // Nobody has the next move until I ask someone [PRS-12].
23
23
  needs_reviewer: { tab: "doing", title: "Needs a reviewer" },
24
24
  drafts: { tab: "doing", title: "My drafts" },
25
- // [WAI-01]
25
+ // Waiting groups these by who they wait on, not by section [WAI-01].
26
26
  wait_review: { tab: "waiting", title: "Waiting for review" },
27
27
  wait_reviewer: { tab: "waiting", title: "Waiting for the reviewer" },
28
28
  wait_ci: { tab: "waiting", title: "CI running" },
@@ -72,6 +72,34 @@ export interface Person {
72
72
  comments?: WaitingComment[];
73
73
  }
74
74
 
75
+ // Someone my waiting work waits on: a reviewer I asked, one who asked for changes, or someone I tagged. Never a guess [WAI-02].
76
+ export interface WaitingOn {
77
+ login: string;
78
+ avatarUrl?: string;
79
+ team: boolean;
80
+ // A requested bot reviewer: nobody to send a list to [WAI-03].
81
+ bot?: boolean;
82
+ // Since I asked or tagged them, or last pushed or replied.
83
+ since: string;
84
+ }
85
+
86
+ // What my waiting work waits for: on items in Waiting, and in Waiting too long, which Waiting shows too [WAI-01].
87
+ export interface Wait {
88
+ // In a word or two: "review", "re-review", "question". None where the chips already say, like blocked by repo rules.
89
+ reason?: string;
90
+ // Since I asked, tagged, pushed or replied.
91
+ since: string;
92
+ // Waiting too long only: what it waited for, for its chip in Doing [ATT-11].
93
+ overdue?: string;
94
+ }
95
+
96
+ // Waiting's work under someone it waits on, longest wait first; the last group, without anyone, is work no person holds up.
97
+ // Work waiting on several people is under each [WAI-01, WAI-03].
98
+ export interface WaitingGroup {
99
+ who?: WaitingOn;
100
+ items: Item[];
101
+ }
102
+
75
103
  export interface WaitingComment {
76
104
  // The comment's node, or the issue or PR when its description mentions me.
77
105
  id: string;
@@ -142,6 +170,9 @@ export interface Item {
142
170
  url: string;
143
171
  chips: Chip[];
144
172
  person?: Person;
173
+ // Waiting and Waiting too long only [WAI-02].
174
+ waitingOn?: WaitingOn[];
175
+ wait?: Wait;
145
176
  actions: ActionId[];
146
177
  // Linked PRs under an issue, or the PRs above the bottom of a stack.
147
178
  children: SubRow[];
@@ -237,6 +268,17 @@ export function matchSessions(agents: AgentSummary[], keys: string[]): AgentSumm
237
268
  .sort((a, b) => Number(b.requiresAttention) - Number(a.requiresAttention) || (b.lastActivityAt ?? "").localeCompare(a.lastActivityAt ?? ""));
238
269
  }
239
270
 
271
+ // Work in Waiting with an active session first: one that needs me, then one that's working. A finished session I've seen
272
+ // doesn't lift it. Otherwise the order stays as it was [WAI-01].
273
+ export function liftActive(items: Item[], agents: AgentSummary[]): Item[] {
274
+ const rank = (item: Item) => {
275
+ const agent = itemSessions(agents, item)[0];
276
+ if (agent?.requiresAttention) return 0;
277
+ return agent?.status === "running" || agent?.status === "initializing" ? 1 : 2;
278
+ };
279
+ return items.map((item) => ({ item, rank: rank(item) })).sort((a, b) => a.rank - b.rank).map(({ item }) => item);
280
+ }
281
+
240
282
  // Sessions none of the item's actions would have started: no kind saved, or the action's gone, like Fix CI once checks pass.
241
283
  // They lead the sheet; the rest sit in their action's line [SES-03].
242
284
  export function looseSessions(sessions: AgentSummary[], kinds: SessionKind[]): AgentSummary[] {
@@ -256,7 +298,7 @@ export interface AttentionView {
256
298
  // Items in Doing; the sidebar shows it [ATT-09].
257
299
  count: number;
258
300
  doing: Section[];
259
- waiting: Section[];
301
+ waiting: WaitingGroup[];
260
302
  history: Item[];
261
303
  assigned: NextUpIssue[];
262
304
  unclaimed: NextUpIssue[];
package/shared/format.ts CHANGED
@@ -15,9 +15,10 @@ export function daysSince(iso: string, now: Date): number {
15
15
  return (now.getTime() - new Date(iso).getTime()) / 86_400_000;
16
16
  }
17
17
 
18
- // A Markdown bullet list of links, for pasting a week's work into a report [HIS-03].
19
- export function linkList(items: { title: string; url: string }[]): string {
20
- return items.map(({ title, url }) => `- [${title.replace(/[[\]\\]/g, "\\$&")}](${url})`).join("\n");
18
+ // A Markdown bullet list of links, for pasting a week's work into a report [HIS-03], or a nudge, each led by why and how
19
+ // long so it skims down the left edge: "- Review 2h: [title](url)" [WAI-03].
20
+ export function linkList(items: { title: string; url: string; lead?: string }[]): string {
21
+ return items.map(({ title, url, lead }) => `- ${lead ? `${lead}: ` : ""}[${title.replace(/[[\]\\]/g, "\\$&")}](${url})`).join("\n");
21
22
  }
22
23
 
23
24
  // Where a card's item lives: "app" for my own repos, "acme/app" for anyone else's, so same-named repos don't blur [ATT-05, NXT-10].