@andrioid/paseo-attention-span 0.3.6 → 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 +1 -1
- package/docs/screenshots/desktop-dark-waiting.png +0 -0
- package/package.json +1 -1
- package/requirements.yaml +1 -0
- package/server/classify.ts +59 -14
- package/server/fixture.ts +15 -4
- package/server/github-types.ts +2 -0
- package/server/markdown.ts +22 -0
- package/server/queries.ts +3 -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.
|
|
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
|
@@ -97,6 +97,7 @@ functional:
|
|
|
97
97
|
waiting:
|
|
98
98
|
As a developer, I can:
|
|
99
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.
|
|
100
101
|
history:
|
|
101
102
|
As a developer, I can:
|
|
102
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,8 +1,21 @@
|
|
|
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
21
|
import { ISSUE_RULES, type IssueState, pick, PR_RULES, type PrState, replyActions, rulesBlock } from "./rules";
|
|
@@ -44,7 +57,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
44
57
|
// What each thread I'm in is waiting for: an answer, or me [ATT-16]. Both searches can find one; it's the same thread.
|
|
45
58
|
const threads = new Map<string, IssueNode>();
|
|
46
59
|
for (const node of [...compact(data.involved.nodes), ...compact(data.asked.nodes)]) threads.set(prKey(node), node);
|
|
47
|
-
const answers = new Map<string,
|
|
60
|
+
const answers = new Map<string, NonNullable<ReturnType<typeof threadState>>>();
|
|
48
61
|
for (const [key, node] of threads) {
|
|
49
62
|
const found = threadState(node, me, now, config);
|
|
50
63
|
if (found) answers.set(key, found);
|
|
@@ -165,11 +178,13 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
165
178
|
const rule = PR_RULES[section];
|
|
166
179
|
const actions = rule?.actions?.(flags) ?? [];
|
|
167
180
|
const rulesBlocked = rulesBlock(flags);
|
|
168
|
-
// Who it waits on
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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) : [];
|
|
173
188
|
|
|
174
189
|
const chips: Chip[] = [];
|
|
175
190
|
if (section === "too_long") chips.push(chip(`${rule?.label?.(flags)} · ${ago(waitingSince, now)}`, "warn"));
|
|
@@ -197,9 +212,8 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
197
212
|
person:
|
|
198
213
|
waiting ??
|
|
199
214
|
(section === "answered" ? answer : undefined) ??
|
|
200
|
-
(section === "changes" && s.botThreadsOnly ? { login: "review bot", bot: true, since: s.lastCommitAt } : undefined)
|
|
201
|
-
|
|
202
|
-
(!rulesBlocked && (section === "too_long" || SECTIONS[section].tab === "waiting") ? person(reviewer, waitingSince) : undefined),
|
|
215
|
+
(section === "changes" && s.botThreadsOnly ? { login: "review bot", bot: true, since: s.lastCommitAt } : undefined),
|
|
216
|
+
waitingOn: waitingOn.length > 0 ? waitingOn : undefined,
|
|
203
217
|
othersActivityAt: latest(...stack.map((pr) => state(pr).othersActivityAt), waiting?.since, answer?.since),
|
|
204
218
|
};
|
|
205
219
|
});
|
|
@@ -264,6 +278,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
264
278
|
url: lead?.url ?? bottom.url,
|
|
265
279
|
chips: [...(lead ? [chip(`PR #${bottom.number}`)] : []), ...unit.chips, ...(unit.section === section && unit.waited ? [unit.waited] : [])],
|
|
266
280
|
person: issueWaiting ?? unit.person,
|
|
281
|
+
waitingOn: issueWaiting ? undefined : unit.waitingOn,
|
|
267
282
|
actions: issueWaiting ? replyActions(issueWaiting) : unit.actions,
|
|
268
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)),
|
|
269
284
|
target: target(bottom, unit.stack),
|
|
@@ -328,7 +343,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
328
343
|
const found = answers.get(key);
|
|
329
344
|
const kind = issue.__typename === "PullRequest" ? "pr" : "issue";
|
|
330
345
|
if (listed.has(key) || !found || (kind === "pr" && found.flags.authored)) continue;
|
|
331
|
-
const { flags, person, mine } = found;
|
|
346
|
+
const { flags, person, mine, tagged } = found;
|
|
332
347
|
const section = pick(ISSUE_RULES, flags);
|
|
333
348
|
if (!section) continue;
|
|
334
349
|
listed.add(key);
|
|
@@ -338,6 +353,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
338
353
|
...plain(issue, kind, section),
|
|
339
354
|
chips: section === "answered" ? [] : [label ? chip(`${label} · ${ago(since, now)}`, "warn") : chip(ago(since, now))],
|
|
340
355
|
person,
|
|
356
|
+
waitingOn: section !== "answered" && tagged.length > 0 ? tagged : undefined,
|
|
341
357
|
actions: section === "answered" ? replyActions(person) : [],
|
|
342
358
|
// A new answer brings back a dismissed one [ATT-08].
|
|
343
359
|
othersActivityAt: person ? latest(...(person.comments ?? []).map((c) => c.createdAt)) : EPOCH,
|
|
@@ -386,7 +402,7 @@ export function threadState(
|
|
|
386
402
|
me: string,
|
|
387
403
|
now: Date,
|
|
388
404
|
config: Pick<AttentionConfig, "mentionDays" | "waitingTooLongDays" | "followThreads">,
|
|
389
|
-
): { flags: IssueState; person?: Person; mine: string } | null {
|
|
405
|
+
): { flags: IssueState; person?: Person; mine: string; tagged: WaitingOn[] } | null {
|
|
390
406
|
const authored = thread.author?.login.toLowerCase() === me;
|
|
391
407
|
const people = thread.comments.nodes.filter((c) => c.author && c.author.__typename !== "Bot");
|
|
392
408
|
const index = people.findLastIndex((c) => c.author?.login.toLowerCase() === me);
|
|
@@ -404,11 +420,13 @@ export function threadState(
|
|
|
404
420
|
fresh: recent(mine),
|
|
405
421
|
tooLong: daysSince(mine, now) >= config.waitingTooLongDays,
|
|
406
422
|
};
|
|
423
|
+
const tagged = flags.mineLast ? taggedSince(people, index, me, thread.url) : [];
|
|
407
424
|
const last = unread.at(-1);
|
|
408
|
-
if (!last?.author) return { flags, mine };
|
|
425
|
+
if (!last?.author) return { flags, mine, tagged };
|
|
409
426
|
return {
|
|
410
427
|
flags,
|
|
411
428
|
mine,
|
|
429
|
+
tagged,
|
|
412
430
|
person: {
|
|
413
431
|
login: last.author.login,
|
|
414
432
|
avatarUrl: last.author.avatarUrl,
|
|
@@ -421,6 +439,33 @@ export function threadState(
|
|
|
421
439
|
};
|
|
422
440
|
}
|
|
423
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
|
+
|
|
424
469
|
// A requested person, or a team by its "org/slug".
|
|
425
470
|
function requested(reviewer: RequestedReviewer | null | undefined): Actor | undefined {
|
|
426
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,7 +164,7 @@ 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) }] } }),
|
|
167
169
|
// Approved and green, yet a repo rule blocks it, so it waits [PRS-13].
|
|
168
170
|
pr(127, { title: "Sign the release artifacts", reviewDecision: "APPROVED", mergeStateStatus: "BLOCKED" }),
|
|
@@ -193,10 +195,19 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
193
195
|
}),
|
|
194
196
|
],
|
|
195
197
|
involved: [
|
|
196
|
-
|
|
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
|
+
),
|
|
197
204
|
// Answered on my own issue without mentioning me [ATT-16]; and a bot after my question, which doesn't count [MEN-05].
|
|
198
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 }),
|
|
199
|
-
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
|
+
),
|
|
200
211
|
// A comment on my PR's conversation [ATT-16].
|
|
201
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) }),
|
|
202
213
|
// Someone else's old thread where people kept going after me: not mine to follow [ATT-16].
|
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 }[];
|
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
|
@@ -3,10 +3,10 @@ import type { AttentionConfig } from "../shared/config";
|
|
|
3
3
|
import type { PickableNode, PullRequestNode, RequiredChecks } from "./github-types";
|
|
4
4
|
import type { IssueRef } from "./references";
|
|
5
5
|
|
|
6
|
-
// An issue or PR with its last conversation comments [ATT-16].
|
|
6
|
+
// An issue or PR with its last conversation comments [ATT-16], rendered too for who my questions tag [WAI-02].
|
|
7
7
|
const THREAD = `__typename
|
|
8
|
-
... on Issue { number title url createdAt author { ...author } repository { nameWithOwner } comments(last: 10) { nodes { ...comment } } }
|
|
9
|
-
... on PullRequest { number title url createdAt author { ...author } repository { nameWithOwner } comments(last: 10) { nodes { ...comment } } }`;
|
|
8
|
+
... on Issue { number title url createdAt author { ...author } repository { nameWithOwner } comments(last: 10) { nodes { ...comment bodyHTML } } }
|
|
9
|
+
... on PullRequest { number title url createdAt author { ...author } repository { nameWithOwner } comments(last: 10) { nodes { ...comment bodyHTML } } }`;
|
|
10
10
|
|
|
11
11
|
// Each search with how many results it asks for and what it reads of each.
|
|
12
12
|
const SEARCHES = {
|
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[];
|