@andrioid/paseo-attention-span 0.3.7 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/OVERVIEW.md CHANGED
@@ -33,17 +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
- Each item shows who you're waiting on, but only when that's on record: the reviewers you asked, the reviewer who asked for changes, or the people you tagged in your question. Otherwise it shows nobody rather than a guess. That way, when something has waited too long, you know whom to nudge.
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
45
 
46
- There's nothing to do here. That's the point. It's tracked, so you can stop holding it in your head.
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.
47
47
 
48
48
  ![Waiting](docs/screenshots/desktop-dark-waiting.png)
49
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, type WaitingOn } 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,10 +607,11 @@ function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions
587
607
  signals: chips,
588
608
  }}
589
609
  extra={
590
- item.person || item.waitingOn || children.length > 0 ? (
610
+ item.person || waitingOn || alsoOn || children.length > 0 ? (
591
611
  <>
592
612
  {item.person ? <PersonQuote person={item.person} expanded={false} /> : null}
593
- {item.waitingOn ? <WaitingOnLine people={item.waitingOn} expanded={false} /> : null}
613
+ {waitingOn}
614
+ {alsoOn}
594
615
  {children.length > 0 ? <StackLine rows={children} merged={!!item.closedAt} /> : null}
595
616
  </>
596
617
  ) : null
@@ -627,7 +648,7 @@ function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions
627
648
  }
628
649
  overlay={
629
650
  <>
630
- {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}
631
652
  {sheet === "acknowledge" ? <AcknowledgeSheet item={item} onReact={(ids) => (setSheet(null), actions.acknowledge(item, ids))} onClose={() => setSheet(null)} /> : null}
632
653
  {sheet === "reviewers" || sheet === "reviewers-after-ready" ? (
633
654
  <ReviewerSheet
@@ -650,7 +671,7 @@ interface SheetHandlers {
650
671
  }
651
672
 
652
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].
653
- 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) {
654
675
  const checks = item.actions.includes("rerun");
655
676
  const details = useQuery({
656
677
  queryKey: ["attention-span", "details", item.key, checks],
@@ -667,7 +688,7 @@ function ItemSheet({ item, sessions, actions, ...handlers }: { item: Item; sessi
667
688
  onClose={handlers.onClose}
668
689
  top={
669
690
  <>
670
- <Meta facts={meta} chips={item.chips} />
691
+ <Meta facts={meta} chips={chips} />
671
692
  {item.person ? <PersonQuote person={item.person} expanded /> : null}
672
693
  {item.waitingOn ? <WaitingOnLine people={item.waitingOn} expanded /> : null}
673
694
  {item.children.length > 0 ? <StackLine rows={item.children} merged={!!item.closedAt} links /> : null}
@@ -949,16 +970,45 @@ function Sections({ sections, actions, empty }: { sections: Section[]; actions:
949
970
  ));
950
971
  }
951
972
 
952
- function Card({ items, actions }: { items: Item[]; actions: Actions }) {
973
+ function Card({ items, actions, group }: { items: Item[]; actions: Actions; group?: WaitingGroup }) {
953
974
  return (
954
975
  <CardList>
955
976
  {items.map((item, index) => (
956
- <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} />
957
978
  ))}
958
979
  </CardList>
959
980
  );
960
981
  }
961
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
+
962
1012
  // Monday-start weeks in the device's time zone.
963
1013
  function weekOf(iso: string): Date {
964
1014
  const day = new Date(iso);
package/client/ui.tsx CHANGED
@@ -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; 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]. 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. One shows by name, several by picture, named on hover and in the sheet. *Waiting too long* shows the same people. |
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. *Waiting too long* items show here too, flagged "waited too long". 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]. 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.
@@ -75,7 +75,7 @@ Top to bottom. Each item appears once, under its most urgent reason [ATT-02]. `s
75
75
  | Ready to merge | My approved PRs without conflicts or failing checks, that GitHub's rules let me merge [PRS-03, PRS-13] |
76
76
  | Needs upstream | My PRs with conflicts or an out-of-sync stack [UPS-01, UPS-02] |
77
77
  | Waiting too long | Waiting items older than `waitingTooLongDays` (default 3); it's mine to nudge [ATT-11] |
78
- | Needs a reviewer | My PRs nobody has been asked to review, even while CI runs [PRS-12] |
78
+ | 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 |
79
79
  | My drafts | My drafts, with their own state tags [PRS-05, PRS-06] |
80
80
 
81
81
  ## Rules
@@ -91,7 +91,7 @@ Top to bottom. Each item appears once, under its most urgent reason [ATT-02]. `s
91
91
  2. a stacked PR no longer builds on its parent's head,
92
92
  3. it is ready to merge (CI ran against an old base).
93
93
  Otherwise the behind count is shown on rows that appear anyway, but never puts an item on the list by itself. Its chip stays neutral; only conflicts are flagged, in red.
94
- - **Repo rules** [PRS-13]: GitHub's `mergeStateStatus` says whether branch protection and rulesets let a PR merge now, but not which rule blocks it. Approvals already show in `reviewDecision`, conflicts in `mergeable`, and running CI blocks too, so a block only counts as a rule's when none of those explain it: an approved PR without conflicts, failing checks, requested changes or running CI. It then waits in Waiting for review with a "blocked by repo rules" chip, no Merge and no person, and never moves to Waiting too long. Needs a reviewer offers Merge only when GitHub doesn't say blocked. `UNKNOWN` (not computed yet) decides nothing.
94
+ - **Repo rules** [PRS-13]: GitHub's `mergeStateStatus` says whether branch protection and rulesets let a PR merge now, but not which rule blocks it. Approvals already show in `reviewDecision`, conflicts in `mergeable`, and running CI blocks too, so a block only counts as a rule's when none of those explain it: an approved PR without conflicts, failing checks, requested changes or running CI. It then waits in Waiting for review with a "blocked by repo rules" chip, no Merge and no person, and never moves to Waiting too long. Needs a reviewer offers Merge only when GitHub doesn't say blocked. `UNKNOWN` (not computed yet) decides nothing. GitHub works out the merge state for at most five PRs per request; asked about more, through search, a repo's PR list or aliases alike, it says `BLOCKED` for all of them (seen 2026-11-04). So the state is asked five PRs per request, in parallel, and search's answer is only the fallback when a request fails.
95
95
  - **Required checks** [PRS-14]: the details request asks which checks on each of my PRs the repo requires (`isRequired`). Where some are required, only they count: failing optional checks leave the PR ready with an "optional checks failing" chip, and optional ones still running don't hold up Merge. A required check that hasn't reported yet isn't listed, so GitHub blocking while CI runs counts as CI running. Where none are required, every check counts.
96
96
  - **Stale draft** [PRS-07]: a draft untouched for 30 days offers Refresh and Close instead of Rebase.
97
97
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andrioid/paseo-attention-span",
3
- "version": "0.3.7",
3
+ "version": "0.4.1",
4
4
  "description": "For when your attention is spread thin: the GitHub issues and pull requests waiting on you, grouped by why, with one-tap Paseo sessions.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/requirements.yaml CHANGED
@@ -96,8 +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
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.
101
102
  history:
102
103
  As a developer, I can:
103
104
  HIS-01: see the issues and pull requests I finished, grouped by week; so that I can tell others what I got done.
@@ -15,7 +15,7 @@ import {
15
15
  import type { AttentionConfig, MergeMethod } from "../shared/config";
16
16
  import { ago, daysSince } from "../shared/format";
17
17
  import type { Actor, Comment, Details, HistoryResult, IssueNode, LinkedIssue, LiveResult, MentionNode, PickableNode, PullRequestNode, RequestedReviewer } from "./github-types";
18
- import { excerpt, plainText, taggedIn } from "./markdown";
18
+ import { asksQuestion, excerpt, plainText, taggedIn } from "./markdown";
19
19
  import { prKey } from "./queries";
20
20
  import { issueFor } from "./references";
21
21
  import { ISSUE_RULES, type IssueState, pick, PR_RULES, type PrState, replyActions, rulesBlock } from "./rules";
@@ -94,7 +94,8 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
94
94
  const ci = commit?.statusCheckRollup?.state;
95
95
  const anyFailing = ci === "FAILURE" || ci === "ERROR";
96
96
  const anyPending = ci === "PENDING" || ci === "EXPECTED";
97
- const mergeBlocked = pr.mergeStateStatus === "BLOCKED";
97
+ // Asked a few PRs at a time where we could; search's answer is BLOCKED for all once there are more than a few [PRS-13].
98
+ const mergeBlocked = (details.mergeState[prKey(pr)] ?? pr.mergeStateStatus) === "BLOCKED";
98
99
  // Where the repo requires checks, only those count; one that hasn't reported yet shows as GitHub blocking while CI runs.
99
100
  // Where it requires none, every check counts [PRS-14].
100
101
  const required = details.checks[prKey(pr)];
@@ -114,12 +115,10 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
114
115
  conflicts: pr.mergeable === "CONFLICTING",
115
116
  mergeBlocked,
116
117
  approved: pr.reviewDecision === "APPROVED",
117
- // A request counts even when its reviewer can't be seen, like a team I can't read; so does any review [PRS-12].
118
- asked:
119
- pr.reviewRequests.nodes.length > 0 ||
120
- pr.latestReviews.nodes.some((review) => isOther(review.author)) ||
121
- pr.reviewDecision === "APPROVED" ||
122
- pr.reviewDecision === "CHANGES_REQUESTED",
118
+ // Only what GitHub records as owed: a pending request, even one whose reviewer I can't see, or a decision. Who has
119
+ // reviewed doesn't count; GitHub drops a reviewer's request once they review, so a comment leaves the next move to
120
+ // me. The repo decides what counts as a review, not us [PRS-12].
121
+ asked: pr.reviewRequests.nodes.length > 0 || pr.reviewDecision === "APPROVED" || pr.reviewDecision === "CHANGES_REQUESTED",
123
122
  autoMerge: !!pr.autoMergeRequest,
124
123
  threadsOnMe: onMe.length,
125
124
  botThreadsOnly: onMe.length > 0 && onMe.every((thread) => (thread.opener?.nodes[0] ?? last(thread))?.author?.__typename === "Bot"),
@@ -185,9 +184,18 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
185
184
  const changers = replied && !flags.ciPending ? bottom.latestReviews.nodes.filter((review) => review.state === "CHANGES_REQUESTED").map((review) => review.author) : [];
186
185
  const asked = bottom.reviewRequests.nodes.map((request) => requested(request.requestedReviewer));
187
186
  const waitingOn = waits ? reviewers([...changers, ...asked].filter(isOther), waitingSince) : [];
187
+ // 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
188
+ // running when nobody's on it [WAI-01].
189
+ const reason =
190
+ waitingOn.length > 0
191
+ ? replied
192
+ ? "re-review"
193
+ : "review"
194
+ : rulesBlocked || s.approved || s.ciPending
195
+ ? undefined
196
+ : "review";
188
197
 
189
198
  const chips: Chip[] = [];
190
- if (section === "too_long") chips.push(chip(`${rule?.label?.(flags)} · ${ago(waitingSince, now)}`, "warn"));
191
199
  if (bottom.isDraft && s.stale) chips.push(chip(`untouched ${ago(bottom.updatedAt, now)}`, "warn"));
192
200
  if (s.approved && !bottom.isDraft) chips.push(chip("approved", "good"));
193
201
  if (rulesBlocked) chips.push(chip("blocked by repo rules", "warn"));
@@ -207,8 +215,8 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
207
215
  section,
208
216
  actions,
209
217
  chips,
210
- // How long it has waited, shown only while it sits in a Waiting section.
211
- waited: SECTIONS[section].tab === "waiting" ? chip(ago(waitingSince, now)) : undefined,
218
+ // Waiting too long shows in Waiting too, under whoever it waits on [WAI-01].
219
+ wait: section === "too_long" || SECTIONS[section].tab === "waiting" ? { reason, since: waitingSince, overdue: section === "too_long" ? rule?.label?.(flags) : undefined } : undefined,
212
220
  person:
213
221
  waiting ??
214
222
  (section === "answered" ? answer : undefined) ??
@@ -276,9 +284,10 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
276
284
  number: lead?.number ?? bottom.number,
277
285
  title: lead?.title ?? bottom.title,
278
286
  url: lead?.url ?? bottom.url,
279
- chips: [...(lead ? [chip(`PR #${bottom.number}`)] : []), ...unit.chips, ...(unit.section === section && unit.waited ? [unit.waited] : [])],
287
+ chips: [...(lead ? [chip(`PR #${bottom.number}`)] : []), ...unit.chips],
280
288
  person: issueWaiting ?? unit.person,
281
289
  waitingOn: issueWaiting ? undefined : unit.waitingOn,
290
+ wait: issueWaiting ? undefined : unit.wait,
282
291
  actions: issueWaiting ? replyActions(issueWaiting) : unit.actions,
283
292
  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)),
284
293
  target: target(bottom, unit.stack),
@@ -351,9 +360,9 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
351
360
  const since = person?.since ?? mine;
352
361
  items.push({
353
362
  ...plain(issue, kind, section),
354
- chips: section === "answered" ? [] : [label ? chip(`${label} · ${ago(since, now)}`, "warn") : chip(ago(since, now))],
355
363
  person,
356
364
  waitingOn: section !== "answered" && tagged.length > 0 ? tagged : undefined,
365
+ wait: section === "answered" ? undefined : { reason: "question", since, overdue: label },
357
366
  actions: section === "answered" ? replyActions(person) : [],
358
367
  // A new answer brings back a dismissed one [ATT-08].
359
368
  othersActivityAt: person ? latest(...(person.comments ?? []).map((c) => c.createdAt)) : EPOCH,
@@ -411,16 +420,21 @@ export function threadState(
411
420
  const after = people.slice(index + 1);
412
421
  const recent = (at: string) => daysSince(at, now) < config.mentionDays;
413
422
  const unread = after.filter((c) => recent(c.createdAt) && !c.reactionGroups?.some((group) => group.viewerHasReacted));
423
+ // My comments since someone else last spoke; bots don't end the run.
424
+ let first = index;
425
+ while (first > 0 && people[first - 1].author?.login.toLowerCase() === me) first -= 1;
426
+ const run = index >= 0 ? people.slice(first, index + 1) : [];
414
427
  const flags: IssueState = {
415
428
  authored,
416
429
  follow: config.followThreads,
417
430
  // Opening a thread isn't asking a question; a comment is.
418
431
  mineLast: index >= 0 && after.length === 0,
432
+ question: run.some((comment) => asksQuestion(comment.bodyHTML)),
419
433
  answered: unread.length > 0,
420
434
  fresh: recent(mine),
421
435
  tooLong: daysSince(mine, now) >= config.waitingTooLongDays,
422
436
  };
423
- const tagged = flags.mineLast ? taggedSince(people, index, me, thread.url) : [];
437
+ const tagged = flags.mineLast ? taggedSince(run, me, thread.url) : [];
424
438
  const last = unread.at(-1);
425
439
  if (!last?.author) return { flags, mine, tagged };
426
440
  return {
@@ -439,14 +453,12 @@ export function threadState(
439
453
  };
440
454
  }
441
455
 
442
- // Who my comments tag since someone else last spoke, each from the first comment that tags them; bots don't end the run, and
443
- // only the fetched comments count. A tag gives just a name, so a person's picture is GitHub's for that name [WAI-02].
444
- function taggedSince(people: Comment[], last: number, me: string, url: string): WaitingOn[] {
445
- let first = last;
446
- while (first > 0 && people[first - 1].author?.login.toLowerCase() === me) first -= 1;
456
+ // Who my comments since someone else last spoke tag, each from the first comment that tags them; only the fetched comments
457
+ // count. A tag gives just a name, so a person's picture is GitHub's for that name [WAI-02].
458
+ function taggedSince(run: Comment[], me: string, url: string): WaitingOn[] {
447
459
  const origin = new URL(url).origin;
448
460
  const tagged: WaitingOn[] = [];
449
- for (const comment of people.slice(first, last + 1)) {
461
+ for (const comment of run) {
450
462
  for (const { login, team } of taggedIn(comment.bodyHTML)) {
451
463
  const seen = (other: { login: string }) => other.login.toLowerCase() === login.toLowerCase();
452
464
  if (login.toLowerCase() === me || tagged.some(seen)) continue;
@@ -461,7 +473,7 @@ function reviewers(actors: (Actor | null | undefined)[], since: string): Waiting
461
473
  const list: WaitingOn[] = [];
462
474
  for (const actor of actors) {
463
475
  if (!actor || list.some((other) => other.login.toLowerCase() === actor.login.toLowerCase())) continue;
464
- list.push({ login: actor.login, avatarUrl: actor.avatarUrl, team: actor.__typename === "Team", since });
476
+ list.push({ login: actor.login, avatarUrl: actor.avatarUrl, team: actor.__typename === "Team", ...(actor.__typename === "Bot" ? { bot: true } : {}), since });
465
477
  }
466
478
  return list;
467
479
  }
package/server/fixture.ts CHANGED
@@ -58,7 +58,9 @@ export function builders(now: Date) {
58
58
 
59
59
  function comment(author: Actor, body: string, days: number, extra: Partial<Comment> = {}): Comment {
60
60
  comments += 1;
61
- 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 };
62
64
  }
63
65
 
64
66
  function mention(number: number, comments: Comment[], overrides: Partial<MentionNode> = {}): MentionNode {
@@ -164,7 +166,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
164
166
  // Nobody asked yet: green, so Merge too; and one still in CI [PRS-12].
165
167
  pr(124, { title: "Export invoices as CSV", commits: commit("SUCCESS", 0.5) }),
166
168
  pr(125, { title: "Log slow database queries" }, "PENDING"),
167
- // A review that only commented, and nobody asked again: it waits, on nobody in particular [WAI-02].
169
+ // A review that only commented, and nobody asked again: GitHub says nobody owes a look, so it's mine to re-request [PRS-12].
168
170
  pr(126, { title: "Tidy the admin menu", latestReviews: { nodes: [{ author: alice, state: "COMMENTED", submittedAt: daysAgo(0.8) }] } }),
169
171
  // Approved and green, yet a repo rule blocks it, so it waits [PRS-13].
170
172
  pr(127, { title: "Sign the release artifacts", reviewDecision: "APPROVED", mergeStateStatus: "BLOCKED" }),
@@ -210,6 +212,8 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
210
212
  ),
211
213
  // A comment on my PR's conversation [ATT-16].
212
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"),
213
217
  // Someone else's old thread where people kept going after me: not mine to follow [ATT-16].
214
218
  issue(144, [comment(me, "Same here on 2.3", 400), comment(bob, "+1", 300)], "Crash on startup"),
215
219
  ],
@@ -248,6 +252,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
248
252
  fieldOptions: { Priority: ["🌋 P0 Urgent", "🏔 P1 High", "🏕P2 Medium", "🏝 P3 Low"] },
249
253
  issues: { [key(132)]: { number: 132, title: "The calendar can't be used with a keyboard", url: `https://github.com/${REPO}/issues/132`, repository } },
250
254
  checks: { [key(128)]: { required: 2, failing: 0, pending: 0 }, [key(129)]: { required: 1, failing: 0, pending: 0 } },
255
+ mergeState: {},
251
256
  },
252
257
  };
253
258
  }
@@ -50,7 +50,8 @@ export interface PullRequestNode {
50
50
  isCrossRepository?: boolean;
51
51
  mergeable: "MERGEABLE" | "CONFLICTING" | "UNKNOWN";
52
52
  // GitHub's own answer to whether the repo's rules let it merge now; BLOCKED doesn't say which rule [PRS-13].
53
- mergeStateStatus?: "BEHIND" | "BLOCKED" | "CLEAN" | "DIRTY" | "DRAFT" | "HAS_HOOKS" | "UNKNOWN" | "UNSTABLE";
53
+ // Wrong when a request asks about more than a few PRs, as search does, so Details' answer comes first.
54
+ mergeStateStatus?: MergeStateStatus;
54
55
  reviewDecision: "APPROVED" | "CHANGES_REQUESTED" | "REVIEW_REQUIRED" | null;
55
56
  autoMergeRequest?: { enabledAt: string } | null;
56
57
  assignees: Nodes<{ login: string }>;
@@ -137,8 +138,12 @@ export interface Details {
137
138
  issues: Record<string, LinkedIssue>;
138
139
  // "owner/name#number" -> the checks the repo requires on my PR's last commit, as far as they've reported [PRS-14].
139
140
  checks: Record<string, RequiredChecks>;
141
+ // "owner/name#number" -> my PR's merge state, asked a few PRs at a time: asked about more, GitHub says BLOCKED [PRS-13].
142
+ mergeState: Record<string, MergeStateStatus>;
140
143
  }
141
144
 
145
+ export type MergeStateStatus = "BEHIND" | "BLOCKED" | "CLEAN" | "DIRTY" | "DRAFT" | "HAS_HOOKS" | "UNKNOWN" | "UNSTABLE";
146
+
142
147
  export type RequiredChecks = { required: number; failing: number; pending: number };
143
148
 
144
149
  export type LinkedIssue = { number: number; title: string; url: string; repository: Repo };
@@ -72,16 +72,30 @@ export function plainText(markdown: string): string {
72
72
  .replace(/^[ \t]*(?:[-*+]|\d+[.)])[ \t]+(?:\[[ xX]\][ \t]+)?/gm, "");
73
73
  }
74
74
 
75
- // People and teams tagged in a comment, from GitHub's rendering of it: GitHub links a tag only to an account that exists and
76
- // 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].
77
- export function taggedIn(html: string | undefined): { login: string; team: boolean }[] {
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 {
78
77
  let text = html ?? "";
79
- // Innermost quotes first, so nested ones go whole.
80
78
  let previous: string;
81
79
  do {
82
80
  previous = text;
83
81
  text = text.replace(/<blockquote\b[^>]*>(?:(?!<blockquote\b)[\s\S])*?<\/blockquote>/g, "");
84
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);
85
99
  const tags: { login: string; team: boolean }[] = [];
86
100
  for (const [, attributes] of text.matchAll(/<a\b([^>]*)>/g)) {
87
101
  const kind = /\bclass="[^"]*\b(user|team)-mention\b/.exec(attributes)?.[1];
package/server/queries.ts CHANGED
@@ -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 {
@@ -215,6 +215,20 @@ export function detailsQuery(prs: PullRequestNode[], orgs: string[], refs: Issue
215
215
  return { query: `query Details {\n${fields.join("\n")}\n}`, compares };
216
216
  }
217
217
 
218
+ // GitHub works out at most this many PRs' merge state per request; asked about more, it says BLOCKED for all of them, even
219
+ // in search and in a repo's PR list. Seen on 2026-11-04 [PRS-13].
220
+ export const MERGE_STATE_BATCH = 5;
221
+
222
+ // The merge state of up to MERGE_STATE_BATCH PRs, in one request; m0, m1, … map back to their keys.
223
+ export function mergeStateQuery(prs: PullRequestNode[]): { query: string; keys: Record<string, string> } {
224
+ const keys: Record<string, string> = {};
225
+ const fields = prs.map((pr, index) => {
226
+ keys[`m${index}`] = prKey(pr);
227
+ return `m${index}: ${repository(pr.repository.nameWithOwner)} { pullRequest(number: ${pr.number}) { mergeStateStatus } }`;
228
+ });
229
+ return { query: `query MergeState {\n${fields.join("\n")}\n}`, keys };
230
+ }
231
+
218
232
  export type CheckContext = { status?: string; conclusion?: string | null; state?: string; isRequired?: boolean };
219
233
 
220
234
  // How the checks the repo requires stand. A check run passes as success, neutral or skipped, like GitHub counts it [PRS-14].
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/service.ts CHANGED
@@ -4,8 +4,8 @@ import { AttentionConfig, githubRepoOf } from "../shared/config";
4
4
  import { classify, classifyHistory } from "./classify";
5
5
  import { FIXTURE, graphql } from "./gh";
6
6
  import { fixture, FIXTURE_AGENTS } from "./fixture";
7
- import type { Details, HistoryResult, LinkedIssue, LiveResult } from "./github-types";
8
- import { type CheckContext, detailsQuery, HISTORY_SEARCHES, mergeUnclaimed, prKey, requiredChecks, type SearchName, searchQuery, searchVariables, type UnclaimedSearch, unclaimedSearches } from "./queries";
7
+ import type { Details, HistoryResult, LinkedIssue, LiveResult, MergeStateStatus, PullRequestNode } from "./github-types";
8
+ import { type CheckContext, detailsQuery, HISTORY_SEARCHES, MERGE_STATE_BATCH, mergeStateQuery, mergeUnclaimed, prKey, requiredChecks, type SearchName, searchQuery, searchVariables, type UnclaimedSearch, unclaimedSearches } from "./queries";
9
9
  import { toLookUp } from "./references";
10
10
  import { loadConfig, loadState, moveOldFiles, saveCodeRepo, saveCoverage, saveFollowThreads, saveNextUpSources, saveState, State } from "./store";
11
11
  import { applyPending, buildView, doneItem, type Effect, isPending, SETTLE_MS } from "./view";
@@ -260,8 +260,9 @@ export class AttentionService {
260
260
  const issues = [...data.unclaimed.nodes, ...data.assigned.nodes];
261
261
  const orgs = needsOptions ? [...new Set(issues.map((issue) => issue?.repository?.nameWithOwner.split("/")[0]).filter(Boolean))] : [];
262
262
  const refs = toLookUp(data.mine.nodes.filter((pr) => pr?.repository));
263
- const details: Details = { behind: {}, fieldOptions: {}, issues: {}, checks: {} };
264
- if (prs.length === 0 && orgs.length === 0 && refs.length === 0) return details;
263
+ const mergeStates = this.mergeStates(data.mine.nodes.filter((pr) => pr?.repository));
264
+ const details: Details = { behind: {}, fieldOptions: {}, issues: {}, checks: {}, mergeState: {} };
265
+ if (prs.length === 0 && orgs.length === 0 && refs.length === 0) return { ...details, mergeState: await mergeStates };
265
266
  const { query, compares } = detailsQuery(prs, orgs as string[], refs);
266
267
  type Result = {
267
268
  ref?: { compare: { behindBy: number } | null } | null;
@@ -280,7 +281,21 @@ export class AttentionService {
280
281
  const issue = value?.issueOrPullRequest; // empty for a PR
281
282
  if (issue?.state === "OPEN") details.issues[prKey(issue)] = { number: issue.number, title: issue.title, url: issue.url, repository: issue.repository };
282
283
  }
283
- return details;
284
+ return { ...details, mergeState: await mergeStates };
285
+ }
286
+
287
+ // My PRs' merge state, a few per request in parallel, as GitHub only works it out for a few at a time; search's answer
288
+ // for more is BLOCKED for all [PRS-13]. A request that fails leaves its PRs to search's answer.
289
+ private async mergeStates(prs: PullRequestNode[]): Promise<Details["mergeState"]> {
290
+ const batches = Array.from({ length: Math.ceil(prs.length / MERGE_STATE_BATCH) }, (_, i) => prs.slice(i * MERGE_STATE_BATCH, (i + 1) * MERGE_STATE_BATCH));
291
+ const results = await Promise.all(
292
+ batches.map(async (batch) => {
293
+ const { query, keys } = mergeStateQuery(batch);
294
+ const result = await graphql<Record<string, { pullRequest: { mergeStateStatus?: MergeStateStatus } | null } | null>>(query).catch(() => ({}) as Record<string, never>);
295
+ return Object.entries(result).flatMap(([alias, value]) => (value?.pullRequest?.mergeStateStatus ? [[keys[alias], value.pullRequest.mergeStateStatus] as const] : []));
296
+ }),
297
+ );
298
+ return Object.fromEntries(results.flat());
284
299
  }
285
300
 
286
301
  private async reloadConfig(): Promise<void> {
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" },
@@ -77,10 +77,29 @@ export interface WaitingOn {
77
77
  login: string;
78
78
  avatarUrl?: string;
79
79
  team: boolean;
80
+ // A requested bot reviewer: nobody to send a list to [WAI-03].
81
+ bot?: boolean;
80
82
  // Since I asked or tagged them, or last pushed or replied.
81
83
  since: string;
82
84
  }
83
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
+
84
103
  export interface WaitingComment {
85
104
  // The comment's node, or the issue or PR when its description mentions me.
86
105
  id: string;
@@ -153,6 +172,7 @@ export interface Item {
153
172
  person?: Person;
154
173
  // Waiting and Waiting too long only [WAI-02].
155
174
  waitingOn?: WaitingOn[];
175
+ wait?: Wait;
156
176
  actions: ActionId[];
157
177
  // Linked PRs under an issue, or the PRs above the bottom of a stack.
158
178
  children: SubRow[];
@@ -248,6 +268,17 @@ export function matchSessions(agents: AgentSummary[], keys: string[]): AgentSumm
248
268
  .sort((a, b) => Number(b.requiresAttention) - Number(a.requiresAttention) || (b.lastActivityAt ?? "").localeCompare(a.lastActivityAt ?? ""));
249
269
  }
250
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
+
251
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.
252
283
  // They lead the sheet; the rest sit in their action's line [SES-03].
253
284
  export function looseSessions(sessions: AgentSummary[], kinds: SessionKind[]): AgentSummary[] {
@@ -267,7 +298,7 @@ export interface AttentionView {
267
298
  // Items in Doing; the sidebar shows it [ATT-09].
268
299
  count: number;
269
300
  doing: Section[];
270
- waiting: Section[];
301
+ waiting: WaitingGroup[];
271
302
  history: Item[];
272
303
  assigned: NextUpIssue[];
273
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].