@andrioid/paseo-attention-span 0.4.6 → 0.4.8
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 +3 -3
- package/client/attention-screen.tsx +83 -22
- package/client/coverage-settings.tsx +64 -2
- package/client/data.ts +9 -3
- package/docs/screenshots/desktop-dark-doing-acknowledge.png +0 -0
- package/docs/screenshots/desktop-dark-doing-clear.png +0 -0
- package/docs/screenshots/desktop-dark-doing-issue-sheet.png +0 -0
- package/docs/screenshots/desktop-dark-doing-reviewers.png +0 -0
- package/docs/screenshots/desktop-dark-doing-sheet.png +0 -0
- 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-settings.png +0 -0
- package/index.server.ts +2 -0
- package/package.json +1 -1
- package/requirements.yaml +3 -1
- package/server/classify.ts +19 -9
- package/server/fixture.ts +10 -2
- package/server/queries.ts +12 -5
- package/server/service.ts +39 -6
- package/server/setup.ts +4 -2
- package/server/store.ts +17 -1
- package/shared/attention.ts +4 -0
- package/shared/config.ts +22 -3
- package/shared/rpc.ts +6 -1
- package/shared/setup.ts +11 -0
package/OVERVIEW.md
CHANGED
|
@@ -53,7 +53,7 @@ When someone needs a nudge, **Copy list** next to their name copies their items
|
|
|
53
53
|
|
|
54
54
|
## Next up: for when your plate is clear
|
|
55
55
|
|
|
56
|
-
It does happen. Next up lists issues assigned to you first, because finishing what you've taken seems polite, and then open issues nobody's claimed. If your org uses issue fields for priority and effort, it ranks by those, so the important quick wins float to the top. Each issue shows its repo, priority, effort and scope, and whether someone already has a PR open for it. That last one has saved me from duplicating a colleague's work more than once.
|
|
56
|
+
It does happen. Next up lists issues assigned to you first, because finishing what you've taken seems polite, and then open issues nobody's claimed. If your org uses issue fields for priority and effort, it ranks by those, so the important quick wins float to the top. Fields called Priority, Effort and Scope are picked up on their own; if yours are called something else, pick them in Settings. Each issue shows its repo, priority, effort and scope, and whether someone already has a PR open for it. That last one has saved me from duplicating a colleague's work more than once.
|
|
57
57
|
|
|
58
58
|

|
|
59
59
|
|
|
@@ -132,7 +132,7 @@ Everything else lives in `~/.config/paseo-attention-span/config.json` on the dae
|
|
|
132
132
|
- `prompts`: your own prompt template per session type, if you don't like mine.
|
|
133
133
|
- `mergeMethods`: squash, merge or rebase, per repo.
|
|
134
134
|
- `codeRepos`: where an issue repo's code lives. The screen asks and fills this in, so you probably won't touch it.
|
|
135
|
-
- `nextUp`: where Next up picks from
|
|
135
|
+
- `nextUp`: where Next up picks from and which org issue fields mean priority, effort and scope, both also in Settings. A field's `order` (best first) is the one thing here only the file sets, for when the org's own option order isn't the ranking you want.
|
|
136
136
|
- `refreshMinutes` (15), `waitingTooLongDays` (3), `staleDraftDays` (30), `mentionDays` (30) and `historyWeeks` (4).
|
|
137
137
|
|
|
138
138
|
## Your data
|
|
@@ -145,4 +145,4 @@ Everything else lives in `~/.config/paseo-attention-span/config.json` on the dae
|
|
|
145
145
|
## What it doesn't do (yet)
|
|
146
146
|
|
|
147
147
|
- github.com only. No other forges and no GitHub Enterprise, for now.
|
|
148
|
-
- Apart from orgs and
|
|
148
|
+
- Apart from orgs, repos and Next up, settings are edited by hand. Yes, in JSON. Sorry.
|
|
@@ -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, checkoutPr, type FailingChecks, type Item, itemSessions, liftActive, looseSessions, type NextUpIssue, ownStack, type Reviewer, type Section, type SectionId, SECTIONS, type SubRow, TAB_FEED, type TabId, type Target, type WaitingGroup, type WaitingOn } from "../shared/attention";
|
|
7
|
+
import { type ActionId, type AgentSummary, type AttentionView, type Chip, checkoutPr, type FailingChecks, type Item, itemSessions, liftActive, looseSessions, type NextUpIssue, ownStack, type PersonRole, type Reviewer, type Section, type SectionId, SECTIONS, type SubRow, TAB_FEED, type TabId, type Target, type WaitingGroup, type WaitingOn } from "../shared/attention";
|
|
8
8
|
import { type AttentionConfig, nextUpSources, type SessionKind } from "../shared/config";
|
|
9
9
|
import { ago, linkList, repoLabel } from "../shared/format";
|
|
10
10
|
import { isClear } from "../shared/still";
|
|
@@ -314,7 +314,9 @@ function AttentionList({
|
|
|
314
314
|
const feed = view.feeds[TAB_FEED[tab]];
|
|
315
315
|
// Calm only once a refresh that worked says Doing is empty [ATT-18].
|
|
316
316
|
const clear = isClear(view, !!attention.error);
|
|
317
|
-
|
|
317
|
+
// ⟳ turns for any refresh of this tab's feed, but only my own press locks it: the cached view can still say a background one runs after it's done.
|
|
318
|
+
const pressed = attention.isRefreshing(TAB_FEED[tab]);
|
|
319
|
+
const refreshing = feed.refreshing || attention.isFetching || pressed;
|
|
318
320
|
const counts: Record<TabId, number> = {
|
|
319
321
|
history: view.history.filter((item) => item.section === "done").length,
|
|
320
322
|
doing: view.count,
|
|
@@ -389,7 +391,8 @@ function AttentionList({
|
|
|
389
391
|
<Pressable
|
|
390
392
|
accessibilityRole="button"
|
|
391
393
|
accessibilityLabel="Refresh now"
|
|
392
|
-
accessibilityState={{ busy: refreshing }}
|
|
394
|
+
accessibilityState={{ busy: refreshing, disabled: pressed }}
|
|
395
|
+
disabled={pressed}
|
|
393
396
|
style={styles.row}
|
|
394
397
|
onPress={() => void attention.refreshNow(TAB_FEED[tab]).catch(() => {})}
|
|
395
398
|
>
|
|
@@ -597,7 +600,7 @@ function ItemRow({ item, first, actions, group }: { item: Item; first: boolean;
|
|
|
597
600
|
const chips = sessions[0] ? [...own, agentSignal(sessions[0])] : own;
|
|
598
601
|
// The group names one; the card names the rest [WAI-01].
|
|
599
602
|
const others = group?.who ? (item.waitingOn ?? []).filter((who) => !samePerson(who, group.who!)) : [];
|
|
600
|
-
const waitingOn = group ? null : item.waitingOn ? <WaitingOnLine people={item.waitingOn} expanded={false} /> : null;
|
|
603
|
+
const waitingOn = group ? null : item.waitingOn ? <WaitingOnLine people={item.waitingOn} asked={item.wait?.reason === "question"} expanded={false} /> : null;
|
|
601
604
|
const alsoOn = others.length ? <Text style={styles.muted}>also waiting on {others.map((who) => who.login).join(", ")}</Text> : null;
|
|
602
605
|
const [sheet, setSheet] = useState<Sheet>(null);
|
|
603
606
|
const [confirm, setConfirm] = useState<"merge" | "close" | null>(null);
|
|
@@ -717,7 +720,7 @@ function ItemSheet({ item, chips, sessions, actions, ...handlers }: { item: Item
|
|
|
717
720
|
<>
|
|
718
721
|
<Meta facts={meta} chips={chips} />
|
|
719
722
|
{item.person ? <PersonQuote person={item.person} expanded /> : null}
|
|
720
|
-
{item.waitingOn ? <WaitingOnLine people={item.waitingOn} expanded /> : null}
|
|
723
|
+
{item.waitingOn ? <WaitingOnLine people={item.waitingOn} asked={item.wait?.reason === "question"} expanded /> : null}
|
|
721
724
|
{item.children.length > 0 ? <StackLine rows={item.children} merged={!!item.closedAt} links /> : null}
|
|
722
725
|
</>
|
|
723
726
|
}
|
|
@@ -922,13 +925,61 @@ function ReviewerSheet({
|
|
|
922
925
|
);
|
|
923
926
|
}
|
|
924
927
|
|
|
928
|
+
// What a face on a card is to it, where no quote says it: the icon of the tab or section that means the same, so whom I wait on
|
|
929
|
+
// reads like Waiting, and whose comments are left like Changes requested [ATT-19].
|
|
930
|
+
const ROLE_ICON: Record<PersonRole | "waiting", IconName> = { waiting: "hourglass", author: "pencil", changes: "changes" };
|
|
931
|
+
|
|
932
|
+
// A line that says what it means in words on hover, and to screen readers; phones rely on the icon [ATT-19]. The words sit
|
|
933
|
+
// beside the line in its flow, not floating over it, so a card's clipping can't cut them off: they wrap where space runs out.
|
|
934
|
+
function Explained({ text, children }: { text: string; children: ReactNode }) {
|
|
935
|
+
const styles = useStyles();
|
|
936
|
+
const [hovered, setHovered] = useState(false);
|
|
937
|
+
return (
|
|
938
|
+
<View accessibilityLabel={text} onPointerEnter={() => setHovered(true)} onPointerLeave={() => setHovered(false)} style={{ alignSelf: "flex-start", flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
939
|
+
<View style={{ flexShrink: 0 }}>{children}</View>
|
|
940
|
+
{hovered ? (
|
|
941
|
+
<View style={{ flexShrink: 1, backgroundColor: styles.c.surface2, borderColor: styles.c.border, borderWidth: 1, borderRadius: 6, paddingVertical: 2, paddingHorizontal: 8 }}>
|
|
942
|
+
<Text style={{ color: styles.c.foreground, fontSize: 12 }}>{text}</Text>
|
|
943
|
+
</View>
|
|
944
|
+
) : null}
|
|
945
|
+
</View>
|
|
946
|
+
);
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
// The icon sits tight against the faces it explains, apart from the name and time, so they read as one.
|
|
950
|
+
function Badged({ role, children }: { role: keyof typeof ROLE_ICON; children: ReactNode }) {
|
|
951
|
+
const styles = useStyles();
|
|
952
|
+
return (
|
|
953
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 2 }}>
|
|
954
|
+
<TablerIcon name={ROLE_ICON[role]} size={16} color={styles.c.foregroundMuted} />
|
|
955
|
+
{children}
|
|
956
|
+
</View>
|
|
957
|
+
);
|
|
958
|
+
}
|
|
959
|
+
|
|
925
960
|
// Who is waiting on me, or who I'm waiting on.
|
|
926
961
|
function PersonQuote({ person, expanded }: { person: NonNullable<Item["person"]>; expanded: boolean }) {
|
|
927
962
|
const styles = useStyles();
|
|
963
|
+
const name = <Text style={{ color: styles.c.foreground, fontSize: 12, fontWeight: "600" }}>{person.login}</Text>;
|
|
964
|
+
// An author line says who, not when: its time meant something different on each tab [ATT-19].
|
|
965
|
+
if (!person.snippet && person.role) {
|
|
966
|
+
const text = person.role === "author" ? `Opened by ${person.login}` : `${person.login}'s comments are left to address, since your last push ${ago(person.since)} ago`;
|
|
967
|
+
return (
|
|
968
|
+
<Explained text={text}>
|
|
969
|
+
<View style={styles.row}>
|
|
970
|
+
<Badged role={person.role}>
|
|
971
|
+
<Avatar url={person.avatarUrl} bot={person.bot} />
|
|
972
|
+
</Badged>
|
|
973
|
+
{name}
|
|
974
|
+
{person.role === "author" ? null : <Text style={styles.muted}>· {ago(person.since)}</Text>}
|
|
975
|
+
</View>
|
|
976
|
+
</Explained>
|
|
977
|
+
);
|
|
978
|
+
}
|
|
928
979
|
const line = (
|
|
929
980
|
<View style={styles.row}>
|
|
930
981
|
<Avatar url={person.avatarUrl} bot={person.bot} />
|
|
931
|
-
|
|
982
|
+
{name}
|
|
932
983
|
<Text style={styles.muted}>· {ago(person.since)}</Text>
|
|
933
984
|
</View>
|
|
934
985
|
);
|
|
@@ -947,7 +998,8 @@ function PersonQuote({ person, expanded }: { person: NonNullable<Item["person"]>
|
|
|
947
998
|
const MAX_FACES = 5;
|
|
948
999
|
|
|
949
1000
|
// Who my work waits on: one by name, several by picture, named on hover, and each by name in the sheet [WAI-02].
|
|
950
|
-
|
|
1001
|
+
// On an issue they're who my question tagged; on a PR, reviewers since my last push or reply [WAI-02, ATT-19].
|
|
1002
|
+
function WaitingOnLine({ people, asked, expanded }: { people: WaitingOn[]; asked: boolean; expanded: boolean }) {
|
|
951
1003
|
const styles = useStyles();
|
|
952
1004
|
const [hovered, setHovered] = useState<string | null>(null);
|
|
953
1005
|
const name = (login: string) => (
|
|
@@ -956,33 +1008,42 @@ function WaitingOnLine({ people, expanded }: { people: WaitingOn[]; expanded: bo
|
|
|
956
1008
|
</Text>
|
|
957
1009
|
);
|
|
958
1010
|
const since = (at: string) => <Text style={styles.muted}>· {ago(at)}</Text>;
|
|
1011
|
+
const explain = (logins: string[], at: string) => `Waiting on ${logins.join(", ")} since ${asked ? "you asked" : "your last push or reply"}, ${ago(at)} ago`;
|
|
959
1012
|
if (expanded || people.length === 1) {
|
|
960
1013
|
return (
|
|
961
1014
|
<View style={{ gap: 6 }}>
|
|
962
1015
|
{people.map((who) => (
|
|
963
|
-
<
|
|
964
|
-
<
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
1016
|
+
<Explained key={who.login} text={explain([who.login], who.since)}>
|
|
1017
|
+
<View style={styles.row}>
|
|
1018
|
+
<Badged role="waiting">
|
|
1019
|
+
<Avatar url={who.avatarUrl} team={who.team} />
|
|
1020
|
+
</Badged>
|
|
1021
|
+
{name(who.login)}
|
|
1022
|
+
{since(who.since)}
|
|
1023
|
+
</View>
|
|
1024
|
+
</Explained>
|
|
968
1025
|
))}
|
|
969
1026
|
</View>
|
|
970
1027
|
);
|
|
971
1028
|
}
|
|
972
1029
|
const earliest = people.map((who) => who.since).sort()[0];
|
|
973
1030
|
return (
|
|
974
|
-
<
|
|
975
|
-
<View style={
|
|
976
|
-
|
|
977
|
-
<View
|
|
978
|
-
|
|
1031
|
+
<Explained text={explain(people.map((who) => who.login), earliest)}>
|
|
1032
|
+
<View style={styles.row}>
|
|
1033
|
+
<Badged role="waiting">
|
|
1034
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 4 }}>
|
|
1035
|
+
{people.slice(0, MAX_FACES).map((who) => (
|
|
1036
|
+
<View key={who.login} onPointerEnter={() => setHovered(who.login)} onPointerLeave={() => setHovered((current) => (current === who.login ? null : current))}>
|
|
1037
|
+
<Avatar url={who.avatarUrl} team={who.team} />
|
|
1038
|
+
</View>
|
|
1039
|
+
))}
|
|
1040
|
+
{people.length > MAX_FACES ? <Text style={styles.muted}>+{people.length - MAX_FACES}</Text> : null}
|
|
979
1041
|
</View>
|
|
980
|
-
|
|
981
|
-
{
|
|
1042
|
+
</Badged>
|
|
1043
|
+
{hovered ? name(hovered) : null}
|
|
1044
|
+
{since(earliest)}
|
|
982
1045
|
</View>
|
|
983
|
-
|
|
984
|
-
{since(earliest)}
|
|
985
|
-
</View>
|
|
1046
|
+
</Explained>
|
|
986
1047
|
);
|
|
987
1048
|
}
|
|
988
1049
|
|
|
@@ -4,12 +4,14 @@ import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
import { Text, View } from "react-native";
|
|
6
6
|
import * as rpc from "../shared/rpc";
|
|
7
|
-
import
|
|
7
|
+
import { DEFAULT_FIELD, FIELD_ROLES, type FieldRole, sameField } from "../shared/config";
|
|
8
|
+
import type { ConfigStatus, CoverageKind, IssueField } from "../shared/setup";
|
|
8
9
|
import { VIEW_QUERY_KEY } from "./data";
|
|
9
10
|
import { Button, StylesProvider, useStyles } from "./ui";
|
|
10
11
|
|
|
11
12
|
const COVERAGE_QUERY_KEY = ["attention-span", "coverage"] as const;
|
|
12
13
|
const MY_ORGS_QUERY_KEY = ["attention-span", "my-orgs"] as const;
|
|
14
|
+
const FIELDS_QUERY_KEY = ["attention-span", "issue-fields"] as const;
|
|
13
15
|
// A caption belongs to the card above it, so it sits closer to that card than to the next heading.
|
|
14
16
|
const CAPTION = { marginTop: -24, marginBottom: 16 };
|
|
15
17
|
|
|
@@ -30,6 +32,7 @@ function Coverage() {
|
|
|
30
32
|
const save = useRpc(rpc.setCoverage);
|
|
31
33
|
const saveNextUp = useRpc(rpc.setNextUpSources);
|
|
32
34
|
const saveFollow = useRpc(rpc.setFollowThreads);
|
|
35
|
+
const saveFields = useRpc(rpc.setNextUpFields);
|
|
33
36
|
const coverage = useQuery({ queryKey: COVERAGE_QUERY_KEY, queryFn: () => fetchCoverage({}) });
|
|
34
37
|
const [saving, setSaving] = useState(false);
|
|
35
38
|
const [error, setError] = useState<string | null>(null);
|
|
@@ -42,7 +45,7 @@ function Coverage() {
|
|
|
42
45
|
</SettingsCard>
|
|
43
46
|
</SettingsSection>
|
|
44
47
|
);
|
|
45
|
-
const { orgs, repos, nextUp, followThreads } = coverage.data;
|
|
48
|
+
const { orgs, repos, nextUp, fields, followThreads } = coverage.data;
|
|
46
49
|
// A file that doesn't parse is left for the person who edited it.
|
|
47
50
|
if (coverage.data.error)
|
|
48
51
|
return (
|
|
@@ -61,6 +64,8 @@ function Coverage() {
|
|
|
61
64
|
await send();
|
|
62
65
|
queryClient.setQueryData(COVERAGE_QUERY_KEY, { ...coverage.data!, ...next });
|
|
63
66
|
await queryClient.invalidateQueries({ queryKey: VIEW_QUERY_KEY });
|
|
67
|
+
// Other orgs may have other fields.
|
|
68
|
+
if (next.orgs || next.repos || next.nextUp) void queryClient.invalidateQueries({ queryKey: FIELDS_QUERY_KEY });
|
|
64
69
|
} catch (failure) {
|
|
65
70
|
setError(`Saving failed: ${(failure as Error).message}`);
|
|
66
71
|
} finally {
|
|
@@ -106,6 +111,7 @@ function Coverage() {
|
|
|
106
111
|
: "None chosen: using your Paseo projects."}
|
|
107
112
|
</Text>
|
|
108
113
|
</View>
|
|
114
|
+
<NextUpFields value={fields} disabled={saving} onChange={(role, field) => write({ fields: { ...fields, [role]: field } }, () => saveFields({ [role]: field }))} />
|
|
109
115
|
<View style={{ gap: 8 }}>
|
|
110
116
|
<SettingsSection title="Replies">
|
|
111
117
|
<SettingsCard>
|
|
@@ -165,6 +171,62 @@ function NextUpSources({ value, disabled, onChange }: { value: ConfigStatus["nex
|
|
|
165
171
|
);
|
|
166
172
|
}
|
|
167
173
|
|
|
174
|
+
const ROLE_LABEL: Record<FieldRole, string> = { priority: "Priority", effort: "Effort", scope: "Scope" };
|
|
175
|
+
const ROLE_HINT: Record<FieldRole, string> = {
|
|
176
|
+
priority: "Ranks the list, in the field's order",
|
|
177
|
+
effort: "Breaks ties, in the field's order",
|
|
178
|
+
scope: "Adds a filter to Next up",
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// Which org issue fields rank and filter Next up [NXT-04], picked from the fields its orgs have. Until I pick, a field
|
|
182
|
+
// named after the role is used, so an org with Priority and Effort needs no setup.
|
|
183
|
+
function NextUpFields({ value, disabled, onChange }: { value: ConfigStatus["fields"]; disabled: boolean; onChange: (role: FieldRole, field: string | null) => Promise<void> }) {
|
|
184
|
+
const styles = useStyles();
|
|
185
|
+
const fetchFields = useRpc(rpc.issueFields);
|
|
186
|
+
const available = useQuery({ queryKey: FIELDS_QUERY_KEY, queryFn: () => fetchFields({}) });
|
|
187
|
+
const fields: IssueField[] = available.data?.fields ?? [];
|
|
188
|
+
const find = (name: string | null | undefined) => fields.find((field) => sameField(field.name, name ?? undefined));
|
|
189
|
+
// What each role uses now: the chosen field, or the one named after it if an org has it. Names match without case,
|
|
190
|
+
// so a field typed "priority" shows as GitHub's "Priority".
|
|
191
|
+
const current = (role: FieldRole): string | null => {
|
|
192
|
+
const chosen = role in value ? (value[role] ?? null) : DEFAULT_FIELD[role];
|
|
193
|
+
return find(chosen)?.name ?? (role in value ? chosen : null);
|
|
194
|
+
};
|
|
195
|
+
const none = available.isLoading ? "Loading…" : "None";
|
|
196
|
+
|
|
197
|
+
return (
|
|
198
|
+
<View style={{ gap: 8 }}>
|
|
199
|
+
<SettingsSection title="Next up fields">
|
|
200
|
+
<SettingsCard>
|
|
201
|
+
{FIELD_ROLES.map((role) => {
|
|
202
|
+
const chosen = current(role);
|
|
203
|
+
// A field no org has any more still shows, so it can be seen and changed.
|
|
204
|
+
const missing = chosen && available.data && !find(chosen) ? [{ label: `${chosen} (not found)`, value: chosen }] : [];
|
|
205
|
+
const hint = !(role in value) && chosen ? `${ROLE_HINT[role]}. Picked by its name` : ROLE_HINT[role];
|
|
206
|
+
return (
|
|
207
|
+
<SettingsSelect
|
|
208
|
+
key={role}
|
|
209
|
+
label={ROLE_LABEL[role]}
|
|
210
|
+
hint={hint}
|
|
211
|
+
error={role === "priority" && available.error ? (available.error as Error).message : null}
|
|
212
|
+
value={chosen ?? ""}
|
|
213
|
+
options={[{ label: none, value: "" }, ...missing, ...fields.map((field) => ({ label: field.name, value: field.name }))]}
|
|
214
|
+
disabled={disabled || !available.data}
|
|
215
|
+
onValueChange={(field) => void onChange(role, field || null)}
|
|
216
|
+
/>
|
|
217
|
+
);
|
|
218
|
+
})}
|
|
219
|
+
</SettingsCard>
|
|
220
|
+
</SettingsSection>
|
|
221
|
+
<Text style={[styles.muted, CAPTION]}>
|
|
222
|
+
{available.data && fields.length === 0
|
|
223
|
+
? "None of the organizations Next up looks in have issue fields, so it lists issues oldest first."
|
|
224
|
+
: "Org issue fields from the organizations Next up looks in. Values rank in the order the organization lists them."}
|
|
225
|
+
</Text>
|
|
226
|
+
</View>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
168
230
|
// Each name is checked on GitHub before it's saved; GitHub's exact name is what's kept.
|
|
169
231
|
function AddRow({ kind, placeholder, existing, disabled, onAdd }: { kind: CoverageKind; placeholder?: string; existing: string[]; disabled: boolean; onAdd: (name: string) => Promise<void> }) {
|
|
170
232
|
const styles = useStyles();
|
package/client/data.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { useRpc } from "@getpaseo/plugin/client";
|
|
2
|
-
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
2
|
+
import { useMutation, useMutationState, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
3
3
|
import { useCallback } from "react";
|
|
4
4
|
import type { AttentionView, FeedId } from "../shared/attention";
|
|
5
5
|
import { getAttention } from "../shared/rpc";
|
|
6
6
|
|
|
7
7
|
export const VIEW_QUERY_KEY = ["attention-span", "view"] as const;
|
|
8
|
+
const REFRESH_KEY = ["attention-span", "refresh"] as const;
|
|
8
9
|
|
|
9
10
|
// The server owns the GitHub refresh schedule; the app only reads its cache [FRESH-01, GH-01].
|
|
10
11
|
export function useAttention() {
|
|
@@ -18,6 +19,11 @@ export function useAttention() {
|
|
|
18
19
|
});
|
|
19
20
|
const setView = useCallback((view: AttentionView) => queryClient.setQueryData(VIEW_QUERY_KEY, view), [queryClient]);
|
|
20
21
|
// ⟳ fetches only the feed behind the tab I'm on.
|
|
21
|
-
const
|
|
22
|
-
|
|
22
|
+
const refresh = useMutation({ mutationKey: REFRESH_KEY, mutationFn: (feed: FeedId) => fetchAttention({ refresh: feed }), onSuccess: setView });
|
|
23
|
+
const refreshNow = refresh.mutateAsync;
|
|
24
|
+
// The server answers ⟳ only once its refresh is done, so the view can't say it's running; the pending call does.
|
|
25
|
+
// Kept in the query client, so it still shows after leaving the screen and coming back mid-refresh.
|
|
26
|
+
const pendingFeeds = useMutationState({ filters: { mutationKey: REFRESH_KEY, status: "pending" }, select: (mutation) => mutation.state.variables as FeedId });
|
|
27
|
+
const isRefreshing = useCallback((feed: FeedId) => pendingFeeds.includes(feed), [pendingFeeds]);
|
|
28
|
+
return { ...query, setView, refreshNow, isRefreshing };
|
|
23
29
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.server.ts
CHANGED
|
@@ -47,6 +47,8 @@ export default function contribute(server: PluginServerContext) {
|
|
|
47
47
|
server.handle(rpc.checkCoverage, ({ kind, name }) => checkCoverage(kind, name));
|
|
48
48
|
server.handle(rpc.setCoverage, ({ orgs, repos }) => ready(() => attention.setCoverage(orgs, repos)).then(() => ({ ok: true as const })));
|
|
49
49
|
server.handle(rpc.setNextUpSources, (sources) => ready(() => attention.setNextUpSources(sources)).then(() => ({ ok: true as const })));
|
|
50
|
+
server.handle(rpc.issueFields, () => ready(async () => ({ fields: await attention.issueFields() })));
|
|
51
|
+
server.handle(rpc.setNextUpFields, (fields) => ready(() => attention.setNextUpFields(fields)).then(() => ({ ok: true as const })));
|
|
50
52
|
server.handle(rpc.setFollowThreads, ({ on }) => ready(() => attention.setFollowThreads(on)).then(() => ({ ok: true as const })));
|
|
51
53
|
server.handle(rpc.myOrgs, async () => ({ orgs: await myOrgs() }));
|
|
52
54
|
server.handle(rpc.setScopes, ({ scopes }) => ready(() => attention.setScopes(scopes)).then(() => ({ ok: true as const })));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andrioid/paseo-attention-span",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
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
|
@@ -35,6 +35,7 @@ functional:
|
|
|
35
35
|
ATT-16: see recent comments without a mention on issues and pull requests I opened, until I reply, react or dismiss them; so that answers to my questions don't get lost, while other people's threads stay out unless someone tags me.
|
|
36
36
|
ATT-17: choose to follow threads I've commented on, so recent replies after mine there show without a tag, off by default; so that surfacing other people's threads is my choice, and the list stays signal, not noise.
|
|
37
37
|
ATT-18: see a calm, restful scene in Doing when nothing needs me, only once a refresh has confirmed it; so that a clear list feels like rest rather than a blank page, and calm never stands in for a check that failed or hasn't run.
|
|
38
|
+
ATT-19: tell at a glance what each person shown on an item is to it: someone I'm waiting on, who opened it, or whose comments are left to address, with an icon by their picture and the meaning in words when I point at it; so that a face and a time never leave me guessing.
|
|
38
39
|
mentions:
|
|
39
40
|
As a developer, I can:
|
|
40
41
|
MEN-01: see open threads where a person mentioned me and is still waiting for my response; so that I only hear about mentions when someone is waiting for me.
|
|
@@ -63,6 +64,7 @@ functional:
|
|
|
63
64
|
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.
|
|
64
65
|
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.
|
|
65
66
|
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.
|
|
67
|
+
PRS-15: see on my pull requests in Doing whom I asked to review and who hasn't yet, approved or not; so that I know someone I wanted to read it still hasn't before I merge or move on.
|
|
66
68
|
upstream:
|
|
67
69
|
As a developer, I can:
|
|
68
70
|
UPS-01: see my pull requests that conflict with their base; so that pull requests needing updates from upstream are easy to fix.
|
|
@@ -87,7 +89,7 @@ functional:
|
|
|
87
89
|
NXT-01: see open issues nobody is assigned to, apart from the work that needs me; so that I can get an idea of what to do next.
|
|
88
90
|
NXT-02: see unclaimed issues ordered by priority, then effort, then age; so that the most important quick wins come first.
|
|
89
91
|
NXT-03: filter unclaimed issues by scope, and have my choice remembered; so that I only see work I'd pick up.
|
|
90
|
-
NXT-04: choose in the app where unclaimed issues come from (my own repositories, organizations I belong to, or single repositories) and choose which issue fields the list uses; so that the plugin can be used elsewhere without editing files.
|
|
92
|
+
NXT-04: choose in the app where unclaimed issues come from (my own repositories, organizations I belong to, or single repositories) and choose which issue fields the list uses, with fields named Priority, Effort and Scope used until I do; so that the plugin can be used elsewhere without editing files.
|
|
91
93
|
NXT-05: claim an issue and start a session on it in one step; so that teammates see it's taken and I can start right away.
|
|
92
94
|
NXT-06: see issues assigned to me before unclaimed ones; so that I finish what I've taken before picking more.
|
|
93
95
|
NXT-07: claim an issue without starting a session, and give back one assigned to me; so that what I've taken matches what I'll do.
|
package/server/classify.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
type Target,
|
|
14
14
|
type WaitingOn,
|
|
15
15
|
} from "../shared/attention";
|
|
16
|
-
import type
|
|
16
|
+
import { type AttentionConfig, FIELD_ROLES, type MergeMethod, nextUpField, sameField } from "../shared/config";
|
|
17
17
|
import { ago, daysSince } from "../shared/format";
|
|
18
18
|
import { workChip, workKind } from "../shared/work";
|
|
19
19
|
import type { Actor, Comment, Details, HistoryResult, IssueNode, LinkedIssue, LiveResult, MentionNode, PickableNode, PullRequestNode, RequestedReviewer } from "./github-types";
|
|
@@ -53,6 +53,12 @@ const behindChip = (count: number, base: string) => chip(`${count} behind ${base
|
|
|
53
53
|
const person = (actor: Actor | null | undefined, since: string): Person | undefined =>
|
|
54
54
|
actor ? { login: actor.login, avatarUrl: actor.avatarUrl, bot: actor.__typename === "Bot", since } : undefined;
|
|
55
55
|
|
|
56
|
+
// Who opened it, which their line says with an icon rather than a quote [ATT-19].
|
|
57
|
+
const author = (actor: Actor | null | undefined, since: string): Person | undefined => {
|
|
58
|
+
const who = person(actor, since);
|
|
59
|
+
return who ? { ...who, role: "author" } : undefined;
|
|
60
|
+
};
|
|
61
|
+
|
|
56
62
|
// Search returns empty objects for result types a fragment doesn't cover.
|
|
57
63
|
const compact = <T>(nodes: (T | null | undefined)[]) => nodes.filter((node): node is T => !!node && Object.keys(node).length > 0);
|
|
58
64
|
|
|
@@ -203,7 +209,11 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
203
209
|
const waits = !rulesBlocked && (section === "too_long" || SECTIONS[section].tab === "waiting");
|
|
204
210
|
const changers = replied && !flags.ciPending ? bottom.latestReviews.nodes.filter((review) => review.state === "CHANGES_REQUESTED").map((review) => review.author) : [];
|
|
205
211
|
const asked = bottom.reviewRequests.nodes.map((request) => requested(request.requestedReviewer));
|
|
206
|
-
|
|
212
|
+
// In Doing, approved or not, whoever I asked that hasn't reviewed yet: people and teams, not bots. An approved PR stays
|
|
213
|
+
// mine to merge, but I see who meant to read it still hasn't. Waiting too long keeps Waiting's rule, and a PR the repo's rules
|
|
214
|
+
// block waits on nobody, so neither lands under a reviewer in Waiting [PRS-15, PRS-13].
|
|
215
|
+
const outstanding = SECTIONS[section].tab === "doing" && section !== "too_long" ? reviewers(asked.filter(isOther), waitingSince).filter((who) => !who.bot) : [];
|
|
216
|
+
const waitingOn = waits ? reviewers([...changers, ...asked].filter(isOther), waitingSince) : outstanding;
|
|
207
217
|
// 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
|
|
208
218
|
// running when nobody's on it [WAI-01].
|
|
209
219
|
const reason =
|
|
@@ -238,7 +248,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
238
248
|
person:
|
|
239
249
|
waiting ??
|
|
240
250
|
(section === "answered" ? answer : undefined) ??
|
|
241
|
-
(section === "changes" && s.botThreadsOnly ? { login: "review bot", bot: true, since: s.lastCommitAt } : undefined),
|
|
251
|
+
(section === "changes" && s.botThreadsOnly ? { login: "review bot", bot: true, since: s.lastCommitAt, role: "changes" as const } : undefined),
|
|
242
252
|
waitingOn: waitingOn.length > 0 ? waitingOn : undefined,
|
|
243
253
|
othersActivityAt: latest(...stack.map((pr) => state(pr).othersActivityAt), waiting?.since, answer?.since),
|
|
244
254
|
};
|
|
@@ -252,7 +262,7 @@ export function classify({ data, details, config, now }: ClassifyInput): Attenti
|
|
|
252
262
|
section: waiting ? "reply" : "review",
|
|
253
263
|
actions: waiting ? [...replyActions(waiting), "review"] : ["review"],
|
|
254
264
|
chips: stack.some((pr) => state(pr).ciFailing) ? [chip("CI failing", "bad")] : [],
|
|
255
|
-
person: waiting ??
|
|
265
|
+
person: waiting ?? author(stack[0].author, lastCommitAt),
|
|
256
266
|
othersActivityAt: latest(...stack.map((pr) => state(pr).othersActivityAt), lastCommitAt, waiting?.since),
|
|
257
267
|
};
|
|
258
268
|
};
|
|
@@ -429,7 +439,7 @@ export function classifyHistory(data: HistoryResult): Item[] {
|
|
|
429
439
|
if (issue) issue.children.push({ key: prKey(pr), number: pr.number, title: pr.title, url: pr.url, draft: false, chips: [], attention: false });
|
|
430
440
|
else items.push(kinded({ ...plain(pr, "pr", "done"), closedAt: pr.mergedAt }, pr));
|
|
431
441
|
}
|
|
432
|
-
for (const pr of compact(data.reviewed.nodes)) items.push(kinded({ ...plain(pr, "pr", "reviewed"), closedAt: pr.mergedAt, person:
|
|
442
|
+
for (const pr of compact(data.reviewed.nodes)) items.push(kinded({ ...plain(pr, "pr", "reviewed"), closedAt: pr.mergedAt, person: author(pr.author, pr.mergedAt) }, pr));
|
|
433
443
|
return items.sort(order);
|
|
434
444
|
}
|
|
435
445
|
|
|
@@ -565,13 +575,13 @@ export function mergeMethodFor(pr: PullRequestNode, config: AttentionConfig): Me
|
|
|
565
575
|
// ---- Next up: issues by priority, effort, then age [NXT-02] ----
|
|
566
576
|
|
|
567
577
|
function rankIssues(nodes: PickableNode[], details: Details, config: AttentionConfig): NextUpIssue[] {
|
|
568
|
-
const
|
|
569
|
-
const valueOf = (node: PickableNode, field: string | undefined) =>
|
|
570
|
-
|
|
578
|
+
const [priority, effort, scope] = FIELD_ROLES.map((role) => nextUpField(config, role));
|
|
579
|
+
const valueOf = (node: PickableNode, field: string | undefined) => node.issueFieldValues.nodes.find((value) => sameField(value.field?.name, field))?.name;
|
|
580
|
+
const optionsOf = (field: string) => Object.entries(details.fieldOptions).find(([name]) => sameField(name, field))?.[1];
|
|
571
581
|
// Position in the configured order (matched by name), else in the field's own options; missing goes last.
|
|
572
582
|
const position = (value: string | undefined, ranked: { field: string; order?: string[] } | undefined) => {
|
|
573
583
|
if (!value || !ranked) return Infinity;
|
|
574
|
-
const order = ranked.order ??
|
|
584
|
+
const order = ranked.order ?? optionsOf(ranked.field) ?? [];
|
|
575
585
|
const index = order.findIndex((name) => value.toLowerCase().includes(name.toLowerCase()));
|
|
576
586
|
return index < 0 ? Infinity : index;
|
|
577
587
|
};
|
package/server/fixture.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AgentSummary, ItemDetails, Reviewer, ReviewerChoices, Target } from "../shared/attention";
|
|
2
2
|
import type { SessionKind } from "../shared/config";
|
|
3
|
+
import type { IssueField } from "../shared/setup";
|
|
3
4
|
import type { Actor, Comment, Details, IssueNode, MentionNode, PickableNode, PullRequestNode, SearchResult } from "./github-types";
|
|
4
5
|
|
|
5
6
|
// Made-up GitHub data for tests and for previews without GitHub (PASEO_ATTENTION_SPAN_FIXTURE=1).
|
|
@@ -12,6 +13,13 @@ export const FIXTURE_ORGS = ["acme"];
|
|
|
12
13
|
export const FIXTURE_REPOS = [REPO, ISSUES_REPO, "acme/web", "me/tool"];
|
|
13
14
|
// The orgs Next up's org picker offers in previews [NXT-04].
|
|
14
15
|
export const FIXTURE_MY_ORGS = ["acme", "globex"];
|
|
16
|
+
// The org issue fields settings offers for Next up [NXT-04].
|
|
17
|
+
export const FIXTURE_ISSUE_FIELDS: IssueField[] = [
|
|
18
|
+
{ name: "Effort", options: ["🐟 Tiny (< 4h)", "🐇 Small (0.5-2d)", "🐂 Medium (2-5d)", "🦑 Large (1-2w)"], orgs: ["acme"] },
|
|
19
|
+
{ name: "Priority", options: ["🌋 P0 Urgent", "🏔 P1 High", "🏕P2 Medium", "🏝 P3 Low"], orgs: ["acme"] },
|
|
20
|
+
{ name: "Scope", options: ["🔙 Backend", "🖌 Frontend", "🕵 Full-stack", "📱 Mobile app"], orgs: ["acme"] },
|
|
21
|
+
{ name: "Team", options: ["Platform", "Payments"], orgs: ["acme"] },
|
|
22
|
+
];
|
|
15
23
|
const repository = { nameWithOwner: REPO, squashMergeAllowed: true, defaultBranchRef: { name: "main" } };
|
|
16
24
|
const avatar = (id: number) => `https://avatars.githubusercontent.com/u/${id}?v=4`;
|
|
17
25
|
|
|
@@ -144,7 +152,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
144
152
|
|
|
145
153
|
const data = search({
|
|
146
154
|
mine: [
|
|
147
|
-
pr(101, { title: "Show delivery dates on the order page" }, "FAILURE"),
|
|
155
|
+
pr(101, { title: "Show delivery dates on the order page", reviewRequests: { nodes: [{ requestedReviewer: alice }, { requestedReviewer: bot }] } }, "FAILURE"),
|
|
148
156
|
pr(102, { title: "Retry webhook deliveries with backoff", reviewThreads: { nodes: [thread(alice, 1), thread(bot, 2)] } }),
|
|
149
157
|
pr(103, { title: "Fetch supplier price files nightly", reviewDecision: "APPROVED", closingIssuesReferences: closes(90, "Supplier prices are a week out of date") }),
|
|
150
158
|
pr(104, { title: "Move price-file login into a service", isDraft: true, baseRefName: "branch-103", headRefName: "branch-104" }),
|
|
@@ -159,7 +167,7 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
159
167
|
pr(111, { title: "Faster product search", reviewRequests: { nodes: [{ requestedReviewer: bob }] }, commits: commit("SUCCESS", 0.3) }),
|
|
160
168
|
pr(112, { title: "Translate the checkout emails", reviewDecision: "CHANGES_REQUESTED", latestReviews: { nodes: [{ author: alice, state: "CHANGES_REQUESTED", submittedAt: daysAgo(2) }] }, commits: commit("SUCCESS", 1) }),
|
|
161
169
|
pr(113, { title: "Upgrade the payment SDK", reviewRequests: { nodes: [{ requestedReviewer: bob }, { requestedReviewer: alice }] } }, "PENDING"),
|
|
162
|
-
pr(114, { title: "Cache exchange rates daily", reviewDecision: "APPROVED" }),
|
|
170
|
+
pr(114, { title: "Cache exchange rates daily", reviewDecision: "APPROVED", latestReviews: { nodes: [{ author: alice, state: "APPROVED", submittedAt: daysAgo(1) }] }, reviewRequests: { nodes: [{ requestedReviewer: bob }] } }),
|
|
163
171
|
pr(115, { title: "Split the settings page into tabs", isDraft: true, mergeable: "CONFLICTING" }),
|
|
164
172
|
pr(116, { title: "Try a faster PDF renderer", isDraft: true }, "FAILURE"),
|
|
165
173
|
pr(117, { title: "Harden the upload endpoint", reviewThreads: { nodes: [thread(bot, 1)] } }),
|
package/server/queries.ts
CHANGED
|
@@ -208,14 +208,21 @@ export function detailsQuery(prs: PullRequestNode[], orgs: string[], refs: Issue
|
|
|
208
208
|
issueOrPullRequest(number: ${ref.number}) { ... on Issue { number title url state repository { nameWithOwner } } }
|
|
209
209
|
}`),
|
|
210
210
|
);
|
|
211
|
-
orgs.forEach((org, index) =>
|
|
212
|
-
fields.push(`o${index}: organization(login: ${JSON.stringify(org)}) {
|
|
213
|
-
issueFields(first: 50) { nodes { ... on IssueFieldSingleSelect { name options { name } } } }
|
|
214
|
-
}`),
|
|
215
|
-
);
|
|
211
|
+
orgs.forEach((org, index) => fields.push(orgFields(`o${index}`, org)));
|
|
216
212
|
return { query: `query Details {\n${fields.join("\n")}\n}`, compares };
|
|
217
213
|
}
|
|
218
214
|
|
|
215
|
+
// An org's single-select issue fields with their options, in the org's order [NXT-02].
|
|
216
|
+
const orgFields = (alias: string, org: string) => `${alias}: organization(login: ${JSON.stringify(org)}) {
|
|
217
|
+
issueFields(first: 50) { nodes { ... on IssueFieldSingleSelect { name options { name } } } }
|
|
218
|
+
}`;
|
|
219
|
+
export type OrgFields = { issueFields?: { nodes: { name?: string; options?: { name: string }[] }[] } } | null;
|
|
220
|
+
|
|
221
|
+
// The fields settings offers for Next up, from every org it might pick from [NXT-04]. An owner that's a person fails only its own field.
|
|
222
|
+
export function issueFieldsQuery(orgs: string[]): string {
|
|
223
|
+
return `query IssueFields {\n${orgs.map((org, index) => orgFields(`o${index}`, org)).join("\n")}\n}`;
|
|
224
|
+
}
|
|
225
|
+
|
|
219
226
|
// GitHub works out at most this many PRs' merge state per request; asked about more, it says BLOCKED for all of them, even
|
|
220
227
|
// in search and in a repo's PR list. Seen on 2026-11-04 [PRS-13].
|
|
221
228
|
export const MERGE_STATE_BATCH = 5;
|
package/server/service.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { Attention, AttentionView, FeedId, FeedStatus, Item, Reviewer } from "../shared/attention";
|
|
2
2
|
import type { PluginHandlerContext } from "@getpaseo/plugin/server";
|
|
3
|
-
import { AttentionConfig, githubRepoOf } from "../shared/config";
|
|
3
|
+
import { AttentionConfig, type FieldRole, githubRepoOf, nextUpField } from "../shared/config";
|
|
4
|
+
import type { IssueField } from "../shared/setup";
|
|
4
5
|
import { classify, classifyHistory } from "./classify";
|
|
5
6
|
import { FIXTURE, graphql } from "./gh";
|
|
6
|
-
import { fixture, FIXTURE_AGENTS } from "./fixture";
|
|
7
|
+
import { fixture, FIXTURE_AGENTS, FIXTURE_ISSUE_FIELDS } from "./fixture";
|
|
7
8
|
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
|
+
import { type CheckContext, detailsQuery, HISTORY_SEARCHES, issueFieldsQuery, type OrgFields, MERGE_STATE_BATCH, mergeStateQuery, mergeUnclaimed, prKey, requiredChecks, type SearchName, searchQuery, searchVariables, type UnclaimedSearch, unclaimedSearches } from "./queries";
|
|
9
10
|
import { toLookUp } from "./references";
|
|
10
|
-
import { loadConfig, loadState, moveOldFiles, saveCodeRepo, saveCoverage, saveFollowThreads, saveNextUpSources, saveState, State } from "./store";
|
|
11
|
+
import { loadConfig, loadState, moveOldFiles, saveCodeRepo, saveCoverage, saveFollowThreads, saveNextUpFields, saveNextUpSources, saveState, State } from "./store";
|
|
11
12
|
import { applyPending, buildView, doneItem, type Effect, isPending, SETTLE_MS } from "./view";
|
|
12
13
|
|
|
13
14
|
// History changes only when I finish something, so it's fetched daily, on ⟳ in its tab and after a merge.
|
|
@@ -107,6 +108,36 @@ export class AttentionService {
|
|
|
107
108
|
await this.refresh("live").catch(() => {});
|
|
108
109
|
}
|
|
109
110
|
|
|
111
|
+
// Which org issue fields Next up uses, chosen in settings [NXT-04]. Only the live feed has Next up.
|
|
112
|
+
async setNextUpFields(fields: Partial<Record<FieldRole, string | null>>): Promise<void> {
|
|
113
|
+
this.config = await saveNextUpFields(fields);
|
|
114
|
+
await this.refresh("live").catch(() => {});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// The single-select fields of every org Next up might pick from, merged by name, for settings [NXT-04]:
|
|
118
|
+
// the orgs chosen, the owners of the repos chosen and of my projects, and of the issues it last showed.
|
|
119
|
+
async issueFields(): Promise<IssueField[]> {
|
|
120
|
+
if (FIXTURE) return FIXTURE_ISSUE_FIELDS;
|
|
121
|
+
await this.reloadConfig().catch(() => {});
|
|
122
|
+
const { orgs, repos, nextUp } = this.config;
|
|
123
|
+
const live = this.state.live?.attention;
|
|
124
|
+
const shown = [...(live?.unclaimed ?? []), ...(live?.assigned ?? [])].map((issue) => issue.repo);
|
|
125
|
+
const owners = [...orgs, ...nextUp.orgs, ...[...repos, ...nextUp.repos, ...this.state.projectRepos, ...shown].map((repo) => repo.split("/")[0])];
|
|
126
|
+
const unique = [...new Map(owners.map((owner) => [owner.toLowerCase(), owner])).values()];
|
|
127
|
+
if (unique.length === 0) return [];
|
|
128
|
+
const result = await graphql<Record<string, OrgFields>>(issueFieldsQuery(unique));
|
|
129
|
+
const merged = new Map<string, IssueField>();
|
|
130
|
+
unique.forEach((org, index) => {
|
|
131
|
+
for (const field of result[`o${index}`]?.issueFields?.nodes ?? []) {
|
|
132
|
+
if (!field.name || !field.options) continue;
|
|
133
|
+
const known = merged.get(field.name.toLowerCase());
|
|
134
|
+
if (known) known.orgs.push(org);
|
|
135
|
+
else merged.set(field.name.toLowerCase(), { name: field.name, options: field.options.map((option) => option.name), orgs: [org] });
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
return [...merged.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
139
|
+
}
|
|
140
|
+
|
|
110
141
|
// Replies on others' threads without a tag [ATT-17]. Only the live feed has them.
|
|
111
142
|
async setFollowThreads(on: boolean): Promise<void> {
|
|
112
143
|
this.config = await saveFollowThreads(on);
|
|
@@ -265,8 +296,10 @@ export class AttentionService {
|
|
|
265
296
|
// Behind counts [UPS-07], required checks [PRS-14] and issue field option order [NXT-02].
|
|
266
297
|
private async details(data: Pick<LiveResult, "mine" | "assigned" | "unclaimed">): Promise<Details> {
|
|
267
298
|
const prs = data.mine.nodes.filter((pr) => pr?.headRefName && !pr.isCrossRepository);
|
|
268
|
-
const
|
|
269
|
-
|
|
299
|
+
const needsOptions = (["priority", "effort"] as const).some((role) => {
|
|
300
|
+
const field = nextUpField(this.config, role);
|
|
301
|
+
return field && !field.order;
|
|
302
|
+
});
|
|
270
303
|
const issues = [...data.unclaimed.nodes, ...data.assigned.nodes];
|
|
271
304
|
const orgs = needsOptions ? [...new Set(issues.map((issue) => issue?.repository?.nameWithOwner.split("/")[0]).filter(Boolean))] : [];
|
|
272
305
|
const refs = toLookUp(data.mine.nodes.filter((pr) => pr?.repository));
|
package/server/setup.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FIELD_ROLES } from "../shared/config";
|
|
1
2
|
import type { ConfigStatus, CoverageCheck, CoverageKind, SetupStatus } from "../shared/setup";
|
|
2
3
|
import { FIXTURE_MY_ORGS, FIXTURE_ORGS, FIXTURE_REPOS } from "./fixture";
|
|
3
4
|
import { FIXTURE, graphql, runGh } from "./gh";
|
|
@@ -22,9 +23,10 @@ async function ghStatus(): Promise<SetupStatus["gh"]> {
|
|
|
22
23
|
export async function configStatus(): Promise<ConfigStatus> {
|
|
23
24
|
try {
|
|
24
25
|
const { orgs, repos, nextUp, followThreads } = await loadConfig();
|
|
25
|
-
|
|
26
|
+
const fields = Object.fromEntries(FIELD_ROLES.flatMap((role) => (nextUp[role] === undefined ? [] : [[role, nextUp[role]?.field ?? null]])));
|
|
27
|
+
return { error: null, orgs, repos, nextUp: { mine: nextUp.mine, orgs: nextUp.orgs, repos: nextUp.repos }, fields, followThreads };
|
|
26
28
|
} catch (error) {
|
|
27
|
-
return { error: (error as Error).message, orgs: [], repos: [], nextUp: { mine: false, orgs: [], repos: [] }, followThreads: false };
|
|
29
|
+
return { error: (error as Error).message, orgs: [], repos: [], nextUp: { mine: false, orgs: [], repos: [] }, fields: {}, followThreads: false };
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
|
package/server/store.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { homedir } from "node:os";
|
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import type { Attention, Item, SectionId } from "../shared/attention";
|
|
6
|
-
import { AttentionConfig } from "../shared/config";
|
|
6
|
+
import { AttentionConfig, FIELD_ROLES, type FieldRole, sameField } from "../shared/config";
|
|
7
7
|
import type { Pending } from "./view";
|
|
8
8
|
|
|
9
9
|
// Local files in ~/.config/paseo-attention-span/ [PRIV-01].
|
|
@@ -86,6 +86,22 @@ export function saveNextUpSources(sources: Pick<AttentionConfig["nextUp"], "mine
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
// Which org issue fields Next up uses, from settings [NXT-04]: null turns one off, a role left out is kept as it is.
|
|
90
|
+
// A field kept as it was keeps its order.
|
|
91
|
+
export function saveNextUpFields(fields: Partial<Record<FieldRole, string | null>>): Promise<AttentionConfig> {
|
|
92
|
+
return updateConfig((file) => {
|
|
93
|
+
const nextUp = file.nextUp && typeof file.nextUp === "object" ? (file.nextUp as Record<string, unknown>) : {};
|
|
94
|
+
const chosen = Object.fromEntries(
|
|
95
|
+
FIELD_ROLES.filter((role) => fields[role] !== undefined).map((role) => {
|
|
96
|
+
const before = nextUp[role] as { field?: unknown } | null | undefined;
|
|
97
|
+
const field = fields[role]!;
|
|
98
|
+
return [role, field === null ? null : before && typeof before.field === "string" && sameField(before.field, field) ? { ...before, field } : { field }];
|
|
99
|
+
}),
|
|
100
|
+
);
|
|
101
|
+
return { ...file, nextUp: { ...nextUp, ...chosen } };
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
89
105
|
// Whether replies on others' threads count without a tag, from settings [ATT-17].
|
|
90
106
|
export function saveFollowThreads(followThreads: boolean): Promise<AttentionConfig> {
|
|
91
107
|
return updateConfig((file) => ({ ...file, followThreads }));
|
package/shared/attention.ts
CHANGED
|
@@ -61,9 +61,13 @@ export interface Chip {
|
|
|
61
61
|
icon?: "thumbUp";
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
export type PersonRole = "author" | "changes";
|
|
65
|
+
|
|
64
66
|
// The person (or bot) I'm waiting on, or who is waiting on me.
|
|
65
67
|
export interface Person {
|
|
66
68
|
login: string;
|
|
69
|
+
// What they are to the item, where no quote says it: who opened it, or whose comments are left to address [ATT-19].
|
|
70
|
+
role?: PersonRole;
|
|
67
71
|
avatarUrl?: string;
|
|
68
72
|
bot: boolean;
|
|
69
73
|
since: string;
|
package/shared/config.ts
CHANGED
|
@@ -48,9 +48,11 @@ export const AttentionConfig = z.object({
|
|
|
48
48
|
mine: z.boolean().default(false),
|
|
49
49
|
orgs: z.array(z.string()).default([]),
|
|
50
50
|
repos: z.array(z.string()).default([]),
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
// Which org issue fields rank and filter the list [NXT-02, NXT-03]. Left out, the field named after the role is used if
|
|
52
|
+
// the org has one; null turns it off.
|
|
53
|
+
priority: RankedField.nullable().optional(),
|
|
54
|
+
effort: RankedField.nullable().optional(),
|
|
55
|
+
scope: z.object({ field: z.string() }).nullable().optional(),
|
|
54
56
|
})
|
|
55
57
|
.default({ mine: false, orgs: [], repos: [] }),
|
|
56
58
|
});
|
|
@@ -70,6 +72,23 @@ export function nextUpSources({ nextUp }: Pick<AttentionConfig, "nextUp">): Next
|
|
|
70
72
|
];
|
|
71
73
|
}
|
|
72
74
|
|
|
75
|
+
// What Next up uses org issue fields for, chosen in settings [NXT-04].
|
|
76
|
+
export const FIELD_ROLES = ["priority", "effort", "scope"] as const;
|
|
77
|
+
export type FieldRole = (typeof FIELD_ROLES)[number];
|
|
78
|
+
// The field each role uses until I choose: one with the role's name, like "Priority".
|
|
79
|
+
export const DEFAULT_FIELD: Record<FieldRole, string> = { priority: "Priority", effort: "Effort", scope: "Scope" };
|
|
80
|
+
|
|
81
|
+
// The field a role uses: the chosen one, none if turned off, else the one named after it [NXT-04].
|
|
82
|
+
export function nextUpField({ nextUp }: Pick<AttentionConfig, "nextUp">, role: FieldRole): { field: string; order?: string[] } | undefined {
|
|
83
|
+
const chosen = nextUp[role];
|
|
84
|
+
return chosen === undefined ? { field: DEFAULT_FIELD[role] } : (chosen ?? undefined);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Org issue field names compare without case, as people type them in config.json.
|
|
88
|
+
export function sameField(a: string | undefined, b: string | undefined): boolean {
|
|
89
|
+
return !!a && !!b && a.toLowerCase() === b.toLowerCase();
|
|
90
|
+
}
|
|
91
|
+
|
|
73
92
|
// "owner/name" of a Paseo project with a GitHub remote, from its project key.
|
|
74
93
|
export function githubRepoOf(projectKey: string | null | undefined): string | null {
|
|
75
94
|
return /^remote:github\.com\/(.+)$/i.exec(projectKey ?? "")?.[1] ?? null;
|
package/shared/rpc.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { defineRpc } from "@getpaseo/plugin";
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import type { AttentionView, ItemDetails, ReviewerChoices, Target } from "./attention";
|
|
4
4
|
import { SessionKind } from "./config";
|
|
5
|
-
import type { ConfigStatus, CoverageCheck, SetupStatus } from "./setup";
|
|
5
|
+
import type { ConfigStatus, CoverageCheck, IssueField, SetupStatus } from "./setup";
|
|
6
6
|
import type { FeedbackInfo } from "./feedback";
|
|
7
7
|
import type { ReadyProvider } from "./providers";
|
|
8
8
|
import type { UpdateNotice } from "./update";
|
|
@@ -28,6 +28,11 @@ export const checkCoverage = defineRpc({ name: "config.check-coverage", input: z
|
|
|
28
28
|
export const setCoverage = defineRpc({ name: "config.set-coverage", input: z.object({ orgs: z.array(z.string()), repos: z.array(z.string()) }), output: done });
|
|
29
29
|
// Where Next up looks, chosen in settings [NXT-04]; orgs are picked from the ones I belong to.
|
|
30
30
|
export const setNextUpSources = defineRpc({ name: "config.set-next-up", input: z.object({ mine: z.boolean(), orgs: z.array(z.string()), repos: z.array(z.string()) }), output: done });
|
|
31
|
+
// The org issue fields settings offers for Next up, and which one each role uses [NXT-04].
|
|
32
|
+
export const issueFields = defineRpc({ name: "config.issue-fields", input: z.object({}), output: z.custom<{ fields: IssueField[] }>() });
|
|
33
|
+
// Only the roles given change; one left out keeps what config.json says, including finding its field by name.
|
|
34
|
+
const fieldChoice = z.string().nullable().optional();
|
|
35
|
+
export const setNextUpFields = defineRpc({ name: "config.set-next-up-fields", input: z.object({ priority: fieldChoice, effort: fieldChoice, scope: fieldChoice }), output: done });
|
|
31
36
|
// Replies on others' threads without a tag, from settings [ATT-17].
|
|
32
37
|
export const setFollowThreads = defineRpc({ name: "config.set-follow-threads", input: z.object({ on: z.boolean() }), output: done });
|
|
33
38
|
export const myOrgs = defineRpc({ name: "config.my-orgs", input: z.object({}), output: z.object({ orgs: z.array(z.string()) }) });
|
package/shared/setup.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { FieldRole } from "./config";
|
|
2
|
+
|
|
1
3
|
// What getting started needs, for the setup checklist [SET-01] and the settings screen [SRC-02].
|
|
2
4
|
|
|
3
5
|
export interface ConfigStatus {
|
|
@@ -7,6 +9,8 @@ export interface ConfigStatus {
|
|
|
7
9
|
repos: string[];
|
|
8
10
|
// Where Next up looks; none chosen falls back to `orgs` and `repos`, then my Paseo projects [NXT-04, NXT-08].
|
|
9
11
|
nextUp: { mine: boolean; orgs: string[]; repos: string[] };
|
|
12
|
+
// The issue field chosen for each role, null when turned off; a role left out uses the field named after it [NXT-04].
|
|
13
|
+
fields: Partial<Record<FieldRole, string | null>>;
|
|
10
14
|
// Replies on others' threads count without a tag [ATT-17].
|
|
11
15
|
followThreads: boolean;
|
|
12
16
|
}
|
|
@@ -29,3 +33,10 @@ export function blocks(status: SetupStatus): boolean {
|
|
|
29
33
|
// An org or repo checked on GitHub before it's saved: its exact name, or why it can't be added.
|
|
30
34
|
export type CoverageCheck = { name: string; error: null } | { name: null; error: string };
|
|
31
35
|
export type CoverageKind = "org" | "repo";
|
|
36
|
+
|
|
37
|
+
// A single-select issue field Next up can use, merged by name across the orgs that have it [NXT-04].
|
|
38
|
+
export interface IssueField {
|
|
39
|
+
name: string;
|
|
40
|
+
options: string[];
|
|
41
|
+
orgs: string[];
|
|
42
|
+
}
|