@andrioid/paseo-attention-span 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/OVERVIEW.md +2 -0
- package/client/attention-screen.tsx +47 -2
- package/client/icons.ts +1 -0
- package/client/ui.tsx +2 -2
- package/docs/architecture.md +4 -2
- package/docs/screenshots/desktop-dark-doing-too-long.png +0 -0
- package/docs/screenshots/desktop-dark-doing.png +0 -0
- package/docs/screenshots/desktop-dark-history-reviewed.png +0 -0
- package/docs/screenshots/desktop-dark-history.png +0 -0
- package/docs/screenshots/desktop-dark-next-up.png +0 -0
- package/docs/screenshots/desktop-dark-settings.png +0 -0
- package/docs/screenshots/desktop-dark-setup.png +0 -0
- package/docs/screenshots/desktop-dark-waiting.png +0 -0
- package/docs/screenshots/phone-dark-doing.png +0 -0
- package/docs/screenshots/phone-light-next-up-filtered.png +0 -0
- package/package.json +1 -1
- package/requirements.yaml +3 -0
- package/server/classify.ts +78 -17
- package/server/fixture.ts +21 -4
- package/server/github-types.ts +8 -0
- package/server/markdown.ts +22 -0
- package/server/queries.ts +31 -10
- package/server/rules.ts +16 -8
- package/server/service.ts +6 -3
- package/shared/attention.ts +11 -0
package/OVERVIEW.md
CHANGED
|
@@ -41,6 +41,8 @@ Anything that's sat in Waiting for more than three days moves back here under **
|
|
|
41
41
|
|
|
42
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.
|
|
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.
|
|
45
|
+
|
|
44
46
|
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
|

|
|
@@ -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, looseSessions, type NextUpIssue, type Reviewer, type Section, type SectionId, SECTIONS, type SubRow, TAB_FEED, type TabId, type Target, 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";
|
|
@@ -587,9 +587,10 @@ function ItemRow({ item, first, actions }: { item: Item; first: boolean; actions
|
|
|
587
587
|
signals: chips,
|
|
588
588
|
}}
|
|
589
589
|
extra={
|
|
590
|
-
item.person || children.length > 0 ? (
|
|
590
|
+
item.person || item.waitingOn || children.length > 0 ? (
|
|
591
591
|
<>
|
|
592
592
|
{item.person ? <PersonQuote person={item.person} expanded={false} /> : null}
|
|
593
|
+
{item.waitingOn ? <WaitingOnLine people={item.waitingOn} expanded={false} /> : null}
|
|
593
594
|
{children.length > 0 ? <StackLine rows={children} merged={!!item.closedAt} /> : null}
|
|
594
595
|
</>
|
|
595
596
|
) : null
|
|
@@ -668,6 +669,7 @@ function ItemSheet({ item, sessions, actions, ...handlers }: { item: Item; sessi
|
|
|
668
669
|
<>
|
|
669
670
|
<Meta facts={meta} chips={item.chips} />
|
|
670
671
|
{item.person ? <PersonQuote person={item.person} expanded /> : null}
|
|
672
|
+
{item.waitingOn ? <WaitingOnLine people={item.waitingOn} expanded /> : null}
|
|
671
673
|
{item.children.length > 0 ? <StackLine rows={item.children} merged={!!item.closedAt} links /> : null}
|
|
672
674
|
</>
|
|
673
675
|
}
|
|
@@ -893,6 +895,49 @@ function PersonQuote({ person, expanded }: { person: NonNullable<Item["person"]>
|
|
|
893
895
|
);
|
|
894
896
|
}
|
|
895
897
|
|
|
898
|
+
// Pictures on a card before the rest are counted, so a crowd fits a phone; the sheet names everyone.
|
|
899
|
+
const MAX_FACES = 5;
|
|
900
|
+
|
|
901
|
+
// Who my work waits on: one by name, several by picture, named on hover, and each by name in the sheet [WAI-02].
|
|
902
|
+
function WaitingOnLine({ people, expanded }: { people: WaitingOn[]; expanded: boolean }) {
|
|
903
|
+
const styles = useStyles();
|
|
904
|
+
const [hovered, setHovered] = useState<string | null>(null);
|
|
905
|
+
const name = (login: string) => (
|
|
906
|
+
<Text style={{ color: styles.c.foreground, fontSize: 12, fontWeight: "600", flexShrink: 1 }} numberOfLines={1}>
|
|
907
|
+
{login}
|
|
908
|
+
</Text>
|
|
909
|
+
);
|
|
910
|
+
const since = (at: string) => <Text style={styles.muted}>· {ago(at)}</Text>;
|
|
911
|
+
if (expanded || people.length === 1) {
|
|
912
|
+
return (
|
|
913
|
+
<View style={{ gap: 6 }}>
|
|
914
|
+
{people.map((who) => (
|
|
915
|
+
<View key={who.login} style={styles.row}>
|
|
916
|
+
<Avatar url={who.avatarUrl} team={who.team} />
|
|
917
|
+
{name(who.login)}
|
|
918
|
+
{since(who.since)}
|
|
919
|
+
</View>
|
|
920
|
+
))}
|
|
921
|
+
</View>
|
|
922
|
+
);
|
|
923
|
+
}
|
|
924
|
+
const earliest = people.map((who) => who.since).sort()[0];
|
|
925
|
+
return (
|
|
926
|
+
<View style={styles.row} accessibilityLabel={`Waiting on ${people.map((who) => who.login).join(", ")}`}>
|
|
927
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 4 }}>
|
|
928
|
+
{people.slice(0, MAX_FACES).map((who) => (
|
|
929
|
+
<View key={who.login} onPointerEnter={() => setHovered(who.login)} onPointerLeave={() => setHovered((current) => (current === who.login ? null : current))}>
|
|
930
|
+
<Avatar url={who.avatarUrl} team={who.team} />
|
|
931
|
+
</View>
|
|
932
|
+
))}
|
|
933
|
+
{people.length > MAX_FACES ? <Text style={styles.muted}>+{people.length - MAX_FACES}</Text> : null}
|
|
934
|
+
</View>
|
|
935
|
+
{hovered ? name(hovered) : null}
|
|
936
|
+
{since(earliest)}
|
|
937
|
+
</View>
|
|
938
|
+
);
|
|
939
|
+
}
|
|
940
|
+
|
|
896
941
|
function Sections({ sections, actions, empty }: { sections: Section[]; actions: Actions; empty: string }) {
|
|
897
942
|
const styles = useStyles();
|
|
898
943
|
if (sections.length === 0) return <Text style={styles.text}>{empty}</Text>;
|
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
|
|
package/docs/architecture.md
CHANGED
|
@@ -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;
|
|
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. |
|
|
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.
|
|
@@ -72,7 +72,7 @@ Top to bottom. Each item appears once, under its most urgent reason [ATT-02]. `s
|
|
|
72
72
|
| Review requested | PRs requesting my review by name, not via a team [REV-01] |
|
|
73
73
|
| CI failing | My PRs with failing checks [PRS-01] |
|
|
74
74
|
| Changes requested | My PRs with requested changes or unresolved threads [PRS-02] |
|
|
75
|
-
| Ready to merge | My approved,
|
|
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
78
|
| Needs a reviewer | My PRs nobody has been asked to review, even while CI runs [PRS-12] |
|
|
@@ -91,6 +91,8 @@ 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.
|
|
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.
|
|
94
96
|
- **Stale draft** [PRS-07]: a draft untouched for 30 days offers Refresh and Close instead of Rebase.
|
|
95
97
|
|
|
96
98
|
## Next up
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andrioid/paseo-attention-span",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
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
|
@@ -60,6 +60,8 @@ functional:
|
|
|
60
60
|
PRS-10: turn on auto-merge for an approved pull request whose checks are still running; so that it ships without me waiting for CI.
|
|
61
61
|
PRS-11: mark a healthy draft ready for review and pick its reviewers in one step; so that finished drafts reach reviewers.
|
|
62
62
|
PRS-12: see my pull requests that nobody has been asked to review, and ask people or teams from there, or merge where nobody reviews; so that work doesn't sit as "waiting" when nobody has the next move.
|
|
63
|
+
PRS-13: see an approved pull request that the repo's rules still block as waiting, without Merge; so that Merge is offered only when GitHub would allow it.
|
|
64
|
+
PRS-14: have checks the repo doesn't require not hold up a pull request, where the repo requires others; so that a failing or slow optional check doesn't keep finished work from shipping.
|
|
63
65
|
upstream:
|
|
64
66
|
As a developer, I can:
|
|
65
67
|
UPS-01: see my pull requests that conflict with their base; so that pull requests needing updates from upstream are easy to fix.
|
|
@@ -95,6 +97,7 @@ functional:
|
|
|
95
97
|
waiting:
|
|
96
98
|
As a developer, I can:
|
|
97
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.
|
|
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.
|
|
98
101
|
history:
|
|
99
102
|
As a developer, I can:
|
|
100
103
|
HIS-01: see the issues and pull requests I finished, grouped by week; so that I can tell others what I got done.
|
package/server/classify.ts
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
import {
|
|
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 { excerpt, plainText, taggedIn } from "./markdown";
|
|
6
19
|
import { prKey } from "./queries";
|
|
7
20
|
import { issueFor } from "./references";
|
|
8
|
-
import { ISSUE_RULES, type IssueState, pick, PR_RULES, type PrState, replyActions } from "./rules";
|
|
21
|
+
import { ISSUE_RULES, type IssueState, pick, PR_RULES, type PrState, replyActions, rulesBlock } from "./rules";
|
|
9
22
|
|
|
10
23
|
// Turns one refresh worth of GitHub data into what needs me. Pure, so every rule is testable.
|
|
11
24
|
|
|
@@ -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,
|
|
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);
|
|
@@ -79,6 +92,14 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
79
92
|
const state = (pr: PullRequestNode) => {
|
|
80
93
|
const commit = pr.commits.nodes[0]?.commit;
|
|
81
94
|
const ci = commit?.statusCheckRollup?.state;
|
|
95
|
+
const anyFailing = ci === "FAILURE" || ci === "ERROR";
|
|
96
|
+
const anyPending = ci === "PENDING" || ci === "EXPECTED";
|
|
97
|
+
const mergeBlocked = pr.mergeStateStatus === "BLOCKED";
|
|
98
|
+
// Where the repo requires checks, only those count; one that hasn't reported yet shows as GitHub blocking while CI runs.
|
|
99
|
+
// Where it requires none, every check counts [PRS-14].
|
|
100
|
+
const required = details.checks[prKey(pr)];
|
|
101
|
+
const ciFailing = required?.required ? required.failing > 0 : anyFailing;
|
|
102
|
+
const ciPending = !ciFailing && (required?.required ? required.pending > 0 || (anyPending && mergeBlocked) : anyPending);
|
|
82
103
|
const unresolved = pr.reviewThreads.nodes.filter((thread) => !thread.isResolved);
|
|
83
104
|
const last = (thread: (typeof unresolved)[number]) => thread.comments.nodes.at(-1);
|
|
84
105
|
const onMe = unresolved.filter((thread) => !isMe(last(thread)?.author));
|
|
@@ -86,9 +107,12 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
86
107
|
const changesRequestedAt = latest(...pr.latestReviews.nodes.filter((r) => r.state === "CHANGES_REQUESTED").map((r) => r.submittedAt));
|
|
87
108
|
const behindBy = details.behind[prKey(pr)] ?? 0;
|
|
88
109
|
return {
|
|
89
|
-
ciFailing
|
|
90
|
-
ciPending
|
|
110
|
+
ciFailing,
|
|
111
|
+
ciPending,
|
|
112
|
+
optionalFailing: !ciFailing && anyFailing,
|
|
113
|
+
optionalPending: !ciFailing && !ciPending && anyPending,
|
|
91
114
|
conflicts: pr.mergeable === "CONFLICTING",
|
|
115
|
+
mergeBlocked,
|
|
92
116
|
approved: pr.reviewDecision === "APPROVED",
|
|
93
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].
|
|
94
118
|
asked:
|
|
@@ -138,6 +162,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
138
162
|
changes: s.changes,
|
|
139
163
|
approved: s.approved,
|
|
140
164
|
conflicts: s.conflicts,
|
|
165
|
+
mergeBlocked: s.mergeBlocked,
|
|
141
166
|
blocked: s.conflicts || outOfSync,
|
|
142
167
|
autoMerge: s.autoMerge,
|
|
143
168
|
autoMergeAllowed: !!bottom.repository.autoMergeAllowed,
|
|
@@ -152,22 +177,27 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
152
177
|
const section = pick(PR_RULES, flags) ?? "wait_review";
|
|
153
178
|
const rule = PR_RULES[section];
|
|
154
179
|
const actions = rule?.actions?.(flags) ?? [];
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
180
|
+
const rulesBlocked = rulesBlock(flags);
|
|
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) : [];
|
|
160
188
|
|
|
161
189
|
const chips: Chip[] = [];
|
|
162
190
|
if (section === "too_long") chips.push(chip(`${rule?.label?.(flags)} · ${ago(waitingSince, now)}`, "warn"));
|
|
163
191
|
if (bottom.isDraft && s.stale) chips.push(chip(`untouched ${ago(bottom.updatedAt, now)}`, "warn"));
|
|
164
192
|
if (s.approved && !bottom.isDraft) chips.push(chip("approved", "good"));
|
|
193
|
+
if (rulesBlocked) chips.push(chip("blocked by repo rules", "warn"));
|
|
165
194
|
if (s.autoMerge) chips.push(chip("auto-merge on", "good"));
|
|
166
195
|
if (bottom.reviewDecision === "CHANGES_REQUESTED") chips.push(chip("changes requested", "warn"));
|
|
167
196
|
if (s.threadsOnMe > 0) chips.push(chip(`${s.threadsOnMe} unresolved`, "warn"));
|
|
168
197
|
if (s.ciFailing) chips.push(chip("CI failing", "bad"));
|
|
169
198
|
else if (s.ciPending) chips.push(chip("CI running", "warn"));
|
|
170
|
-
else if (
|
|
199
|
+
else if (s.optionalFailing) chips.push(chip("optional checks failing", "warn"));
|
|
200
|
+
else if (section === "ready" && s.behindBy === 0) chips.push(chip(s.optionalPending ? "required checks passed" : "CI passed", "good"));
|
|
171
201
|
if (s.conflicts) chips.push(chip("conflicts", "bad"));
|
|
172
202
|
if (s.behindBy > 0) chips.push(behindChip(s.behindBy, base));
|
|
173
203
|
if (stack.length > 1) chips.push(chip(`stack of ${stack.length}`));
|
|
@@ -182,8 +212,8 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
182
212
|
person:
|
|
183
213
|
waiting ??
|
|
184
214
|
(section === "answered" ? answer : undefined) ??
|
|
185
|
-
(section === "changes" && s.botThreadsOnly ? { login: "review bot", bot: true, since: s.lastCommitAt } : undefined)
|
|
186
|
-
|
|
215
|
+
(section === "changes" && s.botThreadsOnly ? { login: "review bot", bot: true, since: s.lastCommitAt } : undefined),
|
|
216
|
+
waitingOn: waitingOn.length > 0 ? waitingOn : undefined,
|
|
187
217
|
othersActivityAt: latest(...stack.map((pr) => state(pr).othersActivityAt), waiting?.since, answer?.since),
|
|
188
218
|
};
|
|
189
219
|
});
|
|
@@ -248,6 +278,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
248
278
|
url: lead?.url ?? bottom.url,
|
|
249
279
|
chips: [...(lead ? [chip(`PR #${bottom.number}`)] : []), ...unit.chips, ...(unit.section === section && unit.waited ? [unit.waited] : [])],
|
|
250
280
|
person: issueWaiting ?? unit.person,
|
|
281
|
+
waitingOn: issueWaiting ? undefined : unit.waitingOn,
|
|
251
282
|
actions: issueWaiting ? replyActions(issueWaiting) : unit.actions,
|
|
252
283
|
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)),
|
|
253
284
|
target: target(bottom, unit.stack),
|
|
@@ -312,7 +343,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
312
343
|
const found = answers.get(key);
|
|
313
344
|
const kind = issue.__typename === "PullRequest" ? "pr" : "issue";
|
|
314
345
|
if (listed.has(key) || !found || (kind === "pr" && found.flags.authored)) continue;
|
|
315
|
-
const { flags, person, mine } = found;
|
|
346
|
+
const { flags, person, mine, tagged } = found;
|
|
316
347
|
const section = pick(ISSUE_RULES, flags);
|
|
317
348
|
if (!section) continue;
|
|
318
349
|
listed.add(key);
|
|
@@ -322,6 +353,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
322
353
|
...plain(issue, kind, section),
|
|
323
354
|
chips: section === "answered" ? [] : [label ? chip(`${label} · ${ago(since, now)}`, "warn") : chip(ago(since, now))],
|
|
324
355
|
person,
|
|
356
|
+
waitingOn: section !== "answered" && tagged.length > 0 ? tagged : undefined,
|
|
325
357
|
actions: section === "answered" ? replyActions(person) : [],
|
|
326
358
|
// A new answer brings back a dismissed one [ATT-08].
|
|
327
359
|
othersActivityAt: person ? latest(...(person.comments ?? []).map((c) => c.createdAt)) : EPOCH,
|
|
@@ -370,7 +402,7 @@ export function threadState(
|
|
|
370
402
|
me: string,
|
|
371
403
|
now: Date,
|
|
372
404
|
config: Pick<AttentionConfig, "mentionDays" | "waitingTooLongDays" | "followThreads">,
|
|
373
|
-
): { flags: IssueState; person?: Person; mine: string } | null {
|
|
405
|
+
): { flags: IssueState; person?: Person; mine: string; tagged: WaitingOn[] } | null {
|
|
374
406
|
const authored = thread.author?.login.toLowerCase() === me;
|
|
375
407
|
const people = thread.comments.nodes.filter((c) => c.author && c.author.__typename !== "Bot");
|
|
376
408
|
const index = people.findLastIndex((c) => c.author?.login.toLowerCase() === me);
|
|
@@ -388,11 +420,13 @@ export function threadState(
|
|
|
388
420
|
fresh: recent(mine),
|
|
389
421
|
tooLong: daysSince(mine, now) >= config.waitingTooLongDays,
|
|
390
422
|
};
|
|
423
|
+
const tagged = flags.mineLast ? taggedSince(people, index, me, thread.url) : [];
|
|
391
424
|
const last = unread.at(-1);
|
|
392
|
-
if (!last?.author) return { flags, mine };
|
|
425
|
+
if (!last?.author) return { flags, mine, tagged };
|
|
393
426
|
return {
|
|
394
427
|
flags,
|
|
395
428
|
mine,
|
|
429
|
+
tagged,
|
|
396
430
|
person: {
|
|
397
431
|
login: last.author.login,
|
|
398
432
|
avatarUrl: last.author.avatarUrl,
|
|
@@ -405,6 +439,33 @@ export function threadState(
|
|
|
405
439
|
};
|
|
406
440
|
}
|
|
407
441
|
|
|
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;
|
|
447
|
+
const origin = new URL(url).origin;
|
|
448
|
+
const tagged: WaitingOn[] = [];
|
|
449
|
+
for (const comment of people.slice(first, last + 1)) {
|
|
450
|
+
for (const { login, team } of taggedIn(comment.bodyHTML)) {
|
|
451
|
+
const seen = (other: { login: string }) => other.login.toLowerCase() === login.toLowerCase();
|
|
452
|
+
if (login.toLowerCase() === me || tagged.some(seen)) continue;
|
|
453
|
+
tagged.push({ login, team, avatarUrl: team ? undefined : `${origin}/${login}.png?size=64`, since: comment.createdAt });
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
return tagged;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
// Reviewers once each, in order: people and teams by their own picture.
|
|
460
|
+
function reviewers(actors: (Actor | null | undefined)[], since: string): WaitingOn[] {
|
|
461
|
+
const list: WaitingOn[] = [];
|
|
462
|
+
for (const actor of actors) {
|
|
463
|
+
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 });
|
|
465
|
+
}
|
|
466
|
+
return list;
|
|
467
|
+
}
|
|
468
|
+
|
|
408
469
|
// A requested person, or a team by its "org/slug".
|
|
409
470
|
function requested(reviewer: RequestedReviewer | null | undefined): Actor | undefined {
|
|
410
471
|
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();
|
|
@@ -150,7 +152,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
150
152
|
pr(110, { title: "requirements.yaml for the shop", isDraft: true, updatedAt: daysAgo(64) }),
|
|
151
153
|
pr(111, { title: "Faster product search", reviewRequests: { nodes: [{ requestedReviewer: bob }] }, commits: commit("SUCCESS", 0.3) }),
|
|
152
154
|
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"),
|
|
155
|
+
pr(113, { title: "Upgrade the payment SDK", reviewRequests: { nodes: [{ requestedReviewer: bob }, { requestedReviewer: alice }] } }, "PENDING"),
|
|
154
156
|
pr(114, { title: "Cache exchange rates daily", reviewDecision: "APPROVED" }),
|
|
155
157
|
pr(115, { title: "Split the settings page into tabs", isDraft: true, mergeable: "CONFLICTING" }),
|
|
156
158
|
pr(116, { title: "Try a faster PDF renderer", isDraft: true }, "FAILURE"),
|
|
@@ -162,8 +164,13 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
162
164
|
// Nobody asked yet: green, so Merge too; and one still in CI [PRS-12].
|
|
163
165
|
pr(124, { title: "Export invoices as CSV", commits: commit("SUCCESS", 0.5) }),
|
|
164
166
|
pr(125, { title: "Log slow database queries" }, "PENDING"),
|
|
165
|
-
// A review that only commented
|
|
167
|
+
// A review that only commented, and nobody asked again: it waits, on nobody in particular [WAI-02].
|
|
166
168
|
pr(126, { title: "Tidy the admin menu", latestReviews: { nodes: [{ author: alice, state: "COMMENTED", submittedAt: daysAgo(0.8) }] } }),
|
|
169
|
+
// Approved and green, yet a repo rule blocks it, so it waits [PRS-13].
|
|
170
|
+
pr(127, { title: "Sign the release artifacts", reviewDecision: "APPROVED", mergeStateStatus: "BLOCKED" }),
|
|
171
|
+
// Only checks the repo doesn't require fail, or still run: ready all the same [PRS-14].
|
|
172
|
+
pr(128, { title: "Lazy-load product images", reviewDecision: "APPROVED", mergeStateStatus: "UNSTABLE" }, "FAILURE"),
|
|
173
|
+
pr(129, { title: "Compress API responses", reviewDecision: "APPROVED", mergeStateStatus: "UNSTABLE" }, "PENDING"),
|
|
167
174
|
],
|
|
168
175
|
reviews: [pr(120, { title: "Add a status page", author: bob }), pr(121, { title: "Rework the cart totals", author: alice })],
|
|
169
176
|
mentions: [
|
|
@@ -188,10 +195,19 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
188
195
|
}),
|
|
189
196
|
],
|
|
190
197
|
involved: [
|
|
191
|
-
|
|
198
|
+
// Questions that tag people wait on them: several by picture, one by name [WAI-02].
|
|
199
|
+
issue(
|
|
200
|
+
140,
|
|
201
|
+
[comment(alice, "", 9), comment(me, "@alice @bob which customers see this?", 1, { bodyHTML: `<p>${tag("alice")} ${tag("bob")} which customers see this?</p>` })],
|
|
202
|
+
"Invoice totals round wrong",
|
|
203
|
+
),
|
|
192
204
|
// Answered on my own issue without mentioning me [ATT-16]; and a bot after my question, which doesn't count [MEN-05].
|
|
193
205
|
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 }),
|
|
194
|
-
issue(
|
|
206
|
+
issue(
|
|
207
|
+
143,
|
|
208
|
+
[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)],
|
|
209
|
+
"Retire the v1 orders endpoint",
|
|
210
|
+
),
|
|
195
211
|
// A comment on my PR's conversation [ATT-16].
|
|
196
212
|
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) }),
|
|
197
213
|
// Someone else's old thread where people kept going after me: not mine to follow [ATT-16].
|
|
@@ -231,6 +247,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
231
247
|
behind: { [key(103)]: 1, [key(106)]: 12, [key(108)]: 139, [key(110)]: 2307, [key(114)]: 3, [key(115)]: 40 },
|
|
232
248
|
fieldOptions: { Priority: ["🌋 P0 Urgent", "🏔 P1 High", "🏕P2 Medium", "🏝 P3 Low"] },
|
|
233
249
|
issues: { [key(132)]: { number: 132, title: "The calendar can't be used with a keyboard", url: `https://github.com/${REPO}/issues/132`, repository } },
|
|
250
|
+
checks: { [key(128)]: { required: 2, failing: 0, pending: 0 }, [key(129)]: { required: 1, failing: 0, pending: 0 } },
|
|
234
251
|
},
|
|
235
252
|
};
|
|
236
253
|
}
|
package/server/github-types.ts
CHANGED
|
@@ -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 }[];
|
|
@@ -47,6 +49,8 @@ export interface PullRequestNode {
|
|
|
47
49
|
headRefOid: string;
|
|
48
50
|
isCrossRepository?: boolean;
|
|
49
51
|
mergeable: "MERGEABLE" | "CONFLICTING" | "UNKNOWN";
|
|
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";
|
|
50
54
|
reviewDecision: "APPROVED" | "CHANGES_REQUESTED" | "REVIEW_REQUIRED" | null;
|
|
51
55
|
autoMergeRequest?: { enabledAt: string } | null;
|
|
52
56
|
assignees: Nodes<{ login: string }>;
|
|
@@ -131,6 +135,10 @@ export interface Details {
|
|
|
131
135
|
fieldOptions: Record<string, string[]>;
|
|
132
136
|
// "owner/name#number" -> the open issue my PRs' descriptions refer to; PRs and closed issues are left out [ATT-03].
|
|
133
137
|
issues: Record<string, LinkedIssue>;
|
|
138
|
+
// "owner/name#number" -> the checks the repo requires on my PR's last commit, as far as they've reported [PRS-14].
|
|
139
|
+
checks: Record<string, RequiredChecks>;
|
|
134
140
|
}
|
|
135
141
|
|
|
142
|
+
export type RequiredChecks = { required: number; failing: number; pending: number };
|
|
143
|
+
|
|
136
144
|
export type LinkedIssue = { number: number; title: string; url: string; repository: Repo };
|
package/server/markdown.ts
CHANGED
|
@@ -71,3 +71,25 @@ 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
|
+
// 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 }[] {
|
|
78
|
+
let text = html ?? "";
|
|
79
|
+
// Innermost quotes first, so nested ones go whole.
|
|
80
|
+
let previous: string;
|
|
81
|
+
do {
|
|
82
|
+
previous = text;
|
|
83
|
+
text = text.replace(/<blockquote\b[^>]*>(?:(?!<blockquote\b)[\s\S])*?<\/blockquote>/g, "");
|
|
84
|
+
} while (text !== previous);
|
|
85
|
+
const tags: { login: string; team: boolean }[] = [];
|
|
86
|
+
for (const [, attributes] of text.matchAll(/<a\b([^>]*)>/g)) {
|
|
87
|
+
const kind = /\bclass="[^"]*\b(user|team)-mention\b/.exec(attributes)?.[1];
|
|
88
|
+
const path = /\bhref="(?:https?:\/\/[^/"]+)?([^"?#]*)/.exec(attributes)?.[1] ?? "";
|
|
89
|
+
const team = /^\/orgs\/([^/]+)\/teams\/([^/]+)\/?$/.exec(path);
|
|
90
|
+
const user = /^\/([^/]+)\/?$/.exec(path);
|
|
91
|
+
const login = kind === "team" && team ? `${team[1]}/${team[2]}` : kind === "user" && user ? user[1] : undefined;
|
|
92
|
+
if (login && !tags.some((tag) => tag.login.toLowerCase() === login.toLowerCase())) tags.push({ login, team: kind === "team" });
|
|
93
|
+
}
|
|
94
|
+
return tags;
|
|
95
|
+
}
|
package/server/queries.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { UnclaimedSource } from "../shared/attention";
|
|
2
2
|
import type { AttentionConfig } from "../shared/config";
|
|
3
|
-
import type { PickableNode, PullRequestNode } from "./github-types";
|
|
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 = {
|
|
@@ -60,7 +60,7 @@ const FRAGMENTS: Record<string, string> = {
|
|
|
60
60
|
id number title url body isDraft createdAt updatedAt
|
|
61
61
|
author { ...author }
|
|
62
62
|
repository { nameWithOwner squashMergeAllowed mergeCommitAllowed autoMergeAllowed defaultBranchRef { name } }
|
|
63
|
-
baseRefName headRefName headRefOid isCrossRepository mergeable reviewDecision
|
|
63
|
+
baseRefName headRefName headRefOid isCrossRepository mergeable mergeStateStatus reviewDecision
|
|
64
64
|
autoMergeRequest { enabledAt }
|
|
65
65
|
assignees(first: 10) { nodes { login } }
|
|
66
66
|
closingIssuesReferences(first: 5) { nodes { number title url repository { nameWithOwner } } }
|
|
@@ -181,15 +181,26 @@ const repository = (repo: string) => {
|
|
|
181
181
|
return `repository(owner: ${JSON.stringify(owner)}, name: ${JSON.stringify(name)})`;
|
|
182
182
|
};
|
|
183
183
|
|
|
184
|
-
// After my PRs and Next up's issues: how far my PRs are behind their bases,
|
|
185
|
-
// what the issues my PRs' descriptions refer to are [GH-01, ATT-03].
|
|
184
|
+
// After my PRs and Next up's issues: how far my PRs are behind their bases, which of their checks the repo requires, the
|
|
185
|
+
// option order of org issue fields, and what the issues my PRs' descriptions refer to are [GH-01, ATT-03, PRS-14].
|
|
186
186
|
export function detailsQuery(prs: PullRequestNode[], orgs: string[], refs: IssueRef[] = []): { query: string; compares: Record<string, string> } {
|
|
187
187
|
const compares: Record<string, string> = {};
|
|
188
|
-
const fields = prs.
|
|
188
|
+
const fields = prs.flatMap((pr, index) => {
|
|
189
189
|
compares[`c${index}`] = prKey(pr);
|
|
190
|
-
|
|
190
|
+
compares[`r${index}`] = prKey(pr);
|
|
191
|
+
const required = `isRequired(pullRequestNumber: ${pr.number})`;
|
|
192
|
+
// Apart from the compare, so a repo that won't say which checks are required costs only this field.
|
|
193
|
+
return [
|
|
194
|
+
`c${index}: ${repository(pr.repository.nameWithOwner)} {
|
|
191
195
|
ref(qualifiedName: ${JSON.stringify(`refs/heads/${pr.baseRefName}`)}) { compare(headRef: ${JSON.stringify(pr.headRefName)}) { behindBy } }
|
|
192
|
-
}
|
|
196
|
+
}`,
|
|
197
|
+
`r${index}: ${repository(pr.repository.nameWithOwner)} {
|
|
198
|
+
pullRequest(number: ${pr.number}) { commits(last: 1) { nodes { commit { statusCheckRollup { contexts(first: 100) { nodes {
|
|
199
|
+
... on CheckRun { status conclusion ${required} }
|
|
200
|
+
... on StatusContext { state ${required} }
|
|
201
|
+
} } } } } } }
|
|
202
|
+
}`,
|
|
203
|
+
];
|
|
193
204
|
});
|
|
194
205
|
refs.forEach((ref, index) =>
|
|
195
206
|
fields.push(`i${index}: ${repository(ref.repo)} {
|
|
@@ -203,3 +214,13 @@ export function detailsQuery(prs: PullRequestNode[], orgs: string[], refs: Issue
|
|
|
203
214
|
);
|
|
204
215
|
return { query: `query Details {\n${fields.join("\n")}\n}`, compares };
|
|
205
216
|
}
|
|
217
|
+
|
|
218
|
+
export type CheckContext = { status?: string; conclusion?: string | null; state?: string; isRequired?: boolean };
|
|
219
|
+
|
|
220
|
+
// How the checks the repo requires stand. A check run passes as success, neutral or skipped, like GitHub counts it [PRS-14].
|
|
221
|
+
export function requiredChecks(contexts: CheckContext[]): RequiredChecks {
|
|
222
|
+
const required = contexts.filter((context) => context.isRequired);
|
|
223
|
+
const pending = (c: CheckContext) => (c.state ? c.state === "PENDING" || c.state === "EXPECTED" : c.status !== "COMPLETED");
|
|
224
|
+
const failing = (c: CheckContext) => (c.state ? c.state === "FAILURE" || c.state === "ERROR" : !pending(c) && !["SUCCESS", "NEUTRAL", "SKIPPED"].includes(c.conclusion ?? ""));
|
|
225
|
+
return { required: required.length, failing: required.filter(failing).length, pending: required.filter(pending).length };
|
|
226
|
+
}
|
package/server/rules.ts
CHANGED
|
@@ -35,6 +35,8 @@ export interface PrState {
|
|
|
35
35
|
changes: boolean;
|
|
36
36
|
approved: boolean;
|
|
37
37
|
conflicts: boolean;
|
|
38
|
+
// GitHub says the repo's rules block merging it now, for whatever reason [PRS-13].
|
|
39
|
+
mergeBlocked: boolean;
|
|
38
40
|
// Conflicts, or a PR above it no longer builds on its parent [UPS-01, UPS-02].
|
|
39
41
|
blocked: boolean;
|
|
40
42
|
autoMerge: boolean;
|
|
@@ -50,6 +52,10 @@ export interface PrState {
|
|
|
50
52
|
tooLong: boolean;
|
|
51
53
|
}
|
|
52
54
|
|
|
55
|
+
// Approved and nothing I know of in the way, yet GitHub's rules still block it: signed commits, a required check that never
|
|
56
|
+
// reported, a resolved-conversations rule, and the like. Nothing for me to do here, so it waits [PRS-13].
|
|
57
|
+
export const rulesBlock = (s: PrState) => !s.draft && s.mergeBlocked && s.approved && !s.ciPending && !s.ciFailing && !s.changes && !s.conflicts;
|
|
58
|
+
|
|
53
59
|
const waitingFor = (s: PrState) => (s.ciPending ? "CI running" : s.replied ? "waiting for the reviewer" : "waiting for review");
|
|
54
60
|
|
|
55
61
|
// Merge only once CI passed against the current base [PRS-04, UPS-07]. Until then, auto-merge if the repo allows it [PRS-10].
|
|
@@ -74,19 +80,21 @@ export const PR_RULES: Rules<PrState> = {
|
|
|
74
80
|
ci: { when: (s) => !s.draft && s.ciFailing, actions: () => ["fix", "rerun"] },
|
|
75
81
|
changes: { when: (s) => !s.draft && s.changes, actions: () => ["address"] },
|
|
76
82
|
// Auto-merge waiting on CI leaves nothing for me to do.
|
|
77
|
-
|
|
83
|
+
// Blocked while CI runs counts as waiting on CI, which auto-merge covers [PRS-10, PRS-13].
|
|
84
|
+
ready: { when: (s) => !s.draft && s.approved && !s.conflicts && !s.ciFailing && !s.changes && !(s.autoMerge && s.ciPending) && !rulesBlock(s), actions: readyActions },
|
|
78
85
|
upstream: { when: (s) => !s.draft && s.blocked, actions: () => ["rebase"] },
|
|
79
|
-
// After too long it's mine to nudge [ATT-11].
|
|
80
|
-
too_long: { when: (s) => !s.draft && s.asked && s.tooLong, label: waitingFor },
|
|
81
|
-
// Mine until I ask someone, even while CI runs. Merge, for repos where nobody reviews, once CI passed on the current base
|
|
86
|
+
// After too long it's mine to nudge [ATT-11]; a rule has no one to nudge [PRS-13].
|
|
87
|
+
too_long: { when: (s) => !s.draft && s.asked && s.tooLong && !rulesBlock(s), label: waitingFor },
|
|
88
|
+
// Mine until I ask someone, even while CI runs. Merge, for repos where nobody reviews, once CI passed on the current base
|
|
89
|
+
// and GitHub's rules allow it [PRS-12, PRS-04, PRS-13].
|
|
82
90
|
needs_reviewer: {
|
|
83
91
|
when: (s) => !s.draft && !s.asked,
|
|
84
|
-
actions: (s) => (!s.ciFailing && !s.ciPending && s.behindBy === 0 ? ["request_review", "merge"] : ["request_review"]),
|
|
92
|
+
actions: (s) => (!s.ciFailing && !s.ciPending && s.behindBy === 0 && !s.mergeBlocked ? ["request_review", "merge"] : ["request_review"]),
|
|
85
93
|
},
|
|
86
94
|
drafts: { when: (s) => s.draft, actions: draftActions },
|
|
87
|
-
// Otherwise it waits on others: CI, the reviewer after my reply, or a review [WAI-01].
|
|
88
|
-
wait_review: { when: (s) => !s.draft && s.asked && !s.ciPending && !s.replied, label: waitingFor },
|
|
89
|
-
wait_reviewer: { when: (s) => !s.draft && s.asked && !s.ciPending && s.replied, label: waitingFor },
|
|
95
|
+
// Otherwise it waits on others: CI, the reviewer after my reply, or a review [WAI-01]. Blocked by rules waits with reviews [PRS-13].
|
|
96
|
+
wait_review: { when: (s) => !s.draft && s.asked && !s.ciPending && (!s.replied || rulesBlock(s)), label: waitingFor },
|
|
97
|
+
wait_reviewer: { when: (s) => !s.draft && s.asked && !s.ciPending && s.replied && !rulesBlock(s), label: waitingFor },
|
|
90
98
|
wait_ci: { when: (s) => !s.draft && s.asked && s.ciPending, label: waitingFor },
|
|
91
99
|
};
|
|
92
100
|
|
package/server/service.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { classify, classifyHistory } from "./classify";
|
|
|
5
5
|
import { FIXTURE, graphql } from "./gh";
|
|
6
6
|
import { fixture, FIXTURE_AGENTS } from "./fixture";
|
|
7
7
|
import type { Details, HistoryResult, LinkedIssue, LiveResult } from "./github-types";
|
|
8
|
-
import { detailsQuery, HISTORY_SEARCHES, mergeUnclaimed, prKey, type SearchName, searchQuery, searchVariables, type UnclaimedSearch, unclaimedSearches } from "./queries";
|
|
8
|
+
import { type CheckContext, detailsQuery, HISTORY_SEARCHES, 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";
|
|
@@ -252,7 +252,7 @@ export class AttentionService {
|
|
|
252
252
|
return Object.fromEntries(names.map((name) => [name, all[name]]));
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
// Behind counts [UPS-07] and issue field option order [NXT-02].
|
|
255
|
+
// Behind counts [UPS-07], required checks [PRS-14] and issue field option order [NXT-02].
|
|
256
256
|
private async details(data: Pick<LiveResult, "mine" | "assigned" | "unclaimed">): Promise<Details> {
|
|
257
257
|
const prs = data.mine.nodes.filter((pr) => pr?.headRefName && !pr.isCrossRepository);
|
|
258
258
|
const { priority, effort } = this.config.nextUp;
|
|
@@ -260,19 +260,22 @@ 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: {} };
|
|
263
|
+
const details: Details = { behind: {}, fieldOptions: {}, issues: {}, checks: {} };
|
|
264
264
|
if (prs.length === 0 && orgs.length === 0 && refs.length === 0) return details;
|
|
265
265
|
const { query, compares } = detailsQuery(prs, orgs as string[], refs);
|
|
266
266
|
type Result = {
|
|
267
267
|
ref?: { compare: { behindBy: number } | null } | null;
|
|
268
268
|
issueFields?: { nodes: { name?: string; options?: { name: string }[] }[] };
|
|
269
269
|
issueOrPullRequest?: (LinkedIssue & { state?: string }) | null;
|
|
270
|
+
pullRequest?: { commits: { nodes: { commit: { statusCheckRollup: { contexts: { nodes: CheckContext[] } } | null } }[] } } | null;
|
|
270
271
|
} | null;
|
|
271
272
|
// A reference to a repo I can't see fails only its own field.
|
|
272
273
|
const result = await graphql<Record<string, Result>>(query);
|
|
273
274
|
for (const [alias, value] of Object.entries(result)) {
|
|
274
275
|
const behindBy = value?.ref?.compare?.behindBy;
|
|
275
276
|
if (typeof behindBy === "number") details.behind[compares[alias]] = behindBy;
|
|
277
|
+
const contexts = value?.pullRequest?.commits.nodes[0]?.commit.statusCheckRollup?.contexts.nodes;
|
|
278
|
+
if (contexts) details.checks[compares[alias]] = requiredChecks(contexts);
|
|
276
279
|
for (const field of value?.issueFields?.nodes ?? []) if (field.name && field.options) details.fieldOptions[field.name] ??= field.options.map((o) => o.name);
|
|
277
280
|
const issue = value?.issueOrPullRequest; // empty for a PR
|
|
278
281
|
if (issue?.state === "OPEN") details.issues[prKey(issue)] = { number: issue.number, title: issue.title, url: issue.url, repository: issue.repository };
|
package/shared/attention.ts
CHANGED
|
@@ -72,6 +72,15 @@ 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
|
+
// Since I asked or tagged them, or last pushed or replied.
|
|
81
|
+
since: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
75
84
|
export interface WaitingComment {
|
|
76
85
|
// The comment's node, or the issue or PR when its description mentions me.
|
|
77
86
|
id: string;
|
|
@@ -142,6 +151,8 @@ export interface Item {
|
|
|
142
151
|
url: string;
|
|
143
152
|
chips: Chip[];
|
|
144
153
|
person?: Person;
|
|
154
|
+
// Waiting and Waiting too long only [WAI-02].
|
|
155
|
+
waitingOn?: WaitingOn[];
|
|
145
156
|
actions: ActionId[];
|
|
146
157
|
// Linked PRs under an issue, or the PRs above the bottom of a stack.
|
|
147
158
|
children: SubRow[];
|