@andrioid/paseo-attention-span 0.1.1 → 0.1.3
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 +109 -77
- package/client/card.tsx +129 -0
- package/client/coverage-settings.tsx +73 -20
- package/client/icons.ts +2 -0
- package/client/next-up.tsx +217 -47
- package/client/setup.tsx +3 -10
- package/client/sheet.tsx +30 -21
- package/client/ui.tsx +14 -3
- package/docs/screenshots/desktop-dark-doing.png +0 -0
- package/docs/screenshots/desktop-dark-next-up.png +0 -0
- package/docs/screenshots/phone-dark-doing.png +0 -0
- package/index.server.ts +7 -2
- package/package.json +1 -1
- package/server/actions.ts +15 -1
- package/server/classify.ts +21 -13
- package/server/fixture.ts +15 -7
- package/server/github-types.ts +5 -1
- package/server/queries.ts +44 -13
- package/server/service.ts +35 -10
- package/server/setup.ts +12 -5
- package/server/store.ts +15 -2
- package/server/view.ts +1 -0
- package/shared/attention.ts +12 -1
- package/shared/config.ts +20 -3
- package/shared/format.ts +15 -0
- package/shared/rpc.ts +8 -1
- package/shared/setup.ts +2 -0
package/server/classify.ts
CHANGED
|
@@ -362,19 +362,27 @@ function rankIssues(nodes: PickableNode[], details: Details, config: AttentionCo
|
|
|
362
362
|
return index < 0 ? Infinity : index;
|
|
363
363
|
};
|
|
364
364
|
return nodes
|
|
365
|
-
.map((node) =>
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
365
|
+
.map((node) => {
|
|
366
|
+
const rank = position(valueOf(node, priority?.field), priority);
|
|
367
|
+
return {
|
|
368
|
+
key: prKey(node),
|
|
369
|
+
repo: node.repository.nameWithOwner,
|
|
370
|
+
number: node.number,
|
|
371
|
+
title: node.title,
|
|
372
|
+
url: node.url,
|
|
373
|
+
createdAt: node.createdAt,
|
|
374
|
+
type: node.issueType?.name,
|
|
375
|
+
priority: valueOf(node, priority?.field),
|
|
376
|
+
effort: valueOf(node, effort?.field),
|
|
377
|
+
scope: valueOf(node, scope?.field),
|
|
378
|
+
defaultBranch: node.repository.defaultBranchRef?.name,
|
|
379
|
+
sources: node.sources ?? [],
|
|
380
|
+
priorityRank: Number.isFinite(rank) ? rank : undefined,
|
|
381
|
+
openPrs: (node.closedByPullRequestsReferences?.nodes ?? [])
|
|
382
|
+
.filter((pr) => pr?.state === "OPEN")
|
|
383
|
+
.map((pr) => ({ number: pr.number, url: pr.url, author: pr.author?.login ?? null })),
|
|
384
|
+
};
|
|
385
|
+
})
|
|
378
386
|
.sort(
|
|
379
387
|
(a, b) =>
|
|
380
388
|
position(a.priority, priority) - position(b.priority, priority) ||
|
package/server/fixture.ts
CHANGED
|
@@ -8,7 +8,9 @@ export const REPO = "acme/shop";
|
|
|
8
8
|
export const ISSUES_REPO = "acme/issues";
|
|
9
9
|
// What the settings screen can add in previews [SRC-02]; anything else isn't found.
|
|
10
10
|
export const FIXTURE_ORGS = ["acme"];
|
|
11
|
-
export const FIXTURE_REPOS = [REPO, ISSUES_REPO, "acme/web"];
|
|
11
|
+
export const FIXTURE_REPOS = [REPO, ISSUES_REPO, "acme/web", "me/tool"];
|
|
12
|
+
// The orgs Next up's org picker offers in previews [NXT-04].
|
|
13
|
+
export const FIXTURE_MY_ORGS = ["acme", "globex"];
|
|
12
14
|
const repository = { nameWithOwner: REPO, squashMergeAllowed: true, defaultBranchRef: { name: "main" } };
|
|
13
15
|
const avatar = (id: number) => `https://avatars.githubusercontent.com/u/${id}?v=4`;
|
|
14
16
|
|
|
@@ -179,13 +181,19 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
179
181
|
pickable(150, fields("🏔 P1 High", "🐇 Small (0.5-2d)", "🔙 Backend"), 20, "Bug", "Orders export times out for big shops"),
|
|
180
182
|
pickable(151, fields("🏕P2 Medium", "🐟 Tiny (< 4h)", "🔙 Backend"), 5, "Bug", "Price list import skips quoted rows", ISSUES_REPO),
|
|
181
183
|
],
|
|
184
|
+
// Found by the preview config's Next up sources [NXT-09].
|
|
182
185
|
unclaimed: [
|
|
183
|
-
pickable(160, fields("
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
{ ...pickable(160, fields("🌋 P0 Urgent", "🐂 Medium (2-5d)", "🕵 Full-stack"), 40, "Feature", "Follow-up emails for unanswered offers"), sources: ["org:acme"] },
|
|
187
|
+
// Nobody's assigned, but alice has a PR open for it [NXT-10].
|
|
188
|
+
{
|
|
189
|
+
...pickable(161, fields("🏝 P3 Low", "🐟 Tiny (< 4h)", "🔙 Backend"), 15, "Bug", "Deleted employee still shows in the calendar"),
|
|
190
|
+
closedByPullRequestsReferences: { nodes: [{ number: 190, url: `https://github.com/${REPO}/pull/190`, state: "OPEN", author: { login: "alice" } }] },
|
|
191
|
+
sources: ["org:acme"],
|
|
192
|
+
},
|
|
193
|
+
{ ...pickable(162, fields("🏝 P3 Low", "🐇 Small (0.5-2d)", "🔙 Backend"), 30, "Debt", "Merge the two import commands"), sources: ["org:acme"] },
|
|
194
|
+
{ ...pickable(163, fields("🏝 P3 Low", "🐇 Small (0.5-2d)", "🖌 Frontend"), 8, "Bug", "Moving a task in the calendar loses its colour"), sources: ["org:acme"] },
|
|
195
|
+
{ ...pickable(164, fields("🏝 P3 Low", "🦑 Large (1-2w)", "📱 Mobile app"), 60, "Feature", "Offline mode for time tracking"), sources: ["org:acme"] },
|
|
196
|
+
{ ...pickable(165, {}, 3, "Task", "Devcontainers for pull requests", "me/tool"), sources: ["mine"] },
|
|
189
197
|
],
|
|
190
198
|
merged: [merged(170, "Nightly backup check", 1, 171), merged(172, "Fix VAT on credit notes", 3), merged(173, "Speed up the order list", 9, 174), merged(175, "Remove the old importer", 16)],
|
|
191
199
|
reviewed: [
|
package/server/github-types.ts
CHANGED
|
@@ -80,9 +80,13 @@ export interface PickableNode {
|
|
|
80
80
|
title: string;
|
|
81
81
|
url: string;
|
|
82
82
|
createdAt: string;
|
|
83
|
-
repository: Repo;
|
|
83
|
+
repository: Repo & { isFork?: boolean };
|
|
84
84
|
issueType: { name: string } | null;
|
|
85
85
|
issueFieldValues: Nodes<{ name?: string; field?: { name: string } }>;
|
|
86
|
+
// Open PRs that close it, so a card can say someone is on it [NXT-10].
|
|
87
|
+
closedByPullRequestsReferences?: Nodes<{ number: number; url: string; state: string; author: { login: string } | null }>;
|
|
88
|
+
// Added after the search: the Next up sources that found it [NXT-09].
|
|
89
|
+
sources?: string[];
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
// One request per search, merged [GH-01].
|
package/server/queries.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { UnclaimedSource } from "../shared/attention";
|
|
2
2
|
import type { AttentionConfig } from "../shared/config";
|
|
3
|
-
import type { PullRequestNode } from "./github-types";
|
|
3
|
+
import type { PickableNode, PullRequestNode } from "./github-types";
|
|
4
4
|
|
|
5
5
|
// Each search with how many results it asks for and what it reads of each.
|
|
6
6
|
const SEARCHES = {
|
|
@@ -42,9 +42,10 @@ const FRAGMENTS: Record<string, string> = {
|
|
|
42
42
|
}`,
|
|
43
43
|
pickable: `fragment pickable on Issue {
|
|
44
44
|
number title url createdAt
|
|
45
|
-
repository { nameWithOwner defaultBranchRef { name } }
|
|
45
|
+
repository { nameWithOwner isFork defaultBranchRef { name } }
|
|
46
46
|
issueType { name }
|
|
47
47
|
issueFieldValues(first: 20) { nodes { ... on IssueFieldSingleSelectValue { name field { ... on IssueFieldCommon { name } } } } }
|
|
48
|
+
closedByPullRequestsReferences(first: 5, includeClosedPrs: false) { nodes { number url state author { login } } }
|
|
48
49
|
}`,
|
|
49
50
|
pr: `fragment pr on PullRequest {
|
|
50
51
|
id number title url isDraft createdAt updatedAt
|
|
@@ -98,18 +99,50 @@ function startOfWeek(now: Date): Date {
|
|
|
98
99
|
return monday;
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
// Where Next up looks for unclaimed issues
|
|
102
|
-
//
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
// Where Next up looks for unclaimed issues [NXT-04, NXT-08]: one search per chosen source, so each issue says which
|
|
103
|
+
// sources found it and no query outgrows GitHub's limit [NXT-09]. Without sources, the configured orgs and repos,
|
|
104
|
+
// else my Paseo projects' repos. Never all of GitHub: unlike the other searches, this one isn't about me.
|
|
105
|
+
export function unclaimedSearches(config: AttentionConfig, projectRepos: string[], login: string | null): { from: UnclaimedSource; searches: UnclaimedSearch[] } {
|
|
106
|
+
const search = (source: string | null, scope: string) => ({ source, query: `is:issue is:open no:assignee ${scope}` });
|
|
107
|
+
const { mine, orgs, repos } = config.nextUp;
|
|
108
|
+
if (mine || orgs.length || repos.length) {
|
|
109
|
+
if (mine && !login) throw new Error("Couldn't tell which GitHub account is yours, for My repos");
|
|
110
|
+
return {
|
|
111
|
+
from: "config",
|
|
112
|
+
searches: [
|
|
113
|
+
...(mine ? [search("mine", `user:${login} archived:false`)] : []),
|
|
114
|
+
...orgs.map((org) => search(`org:${org}`, where([org], []))),
|
|
115
|
+
...repos.map((repo) => search(`repo:${repo}`, where([], [repo]))),
|
|
116
|
+
],
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
if (config.orgs.length || config.repos.length) return { from: "config", searches: [search(null, where(config.orgs, config.repos))] };
|
|
120
|
+
return projectRepos.length ? { from: "projects", searches: [search(null, where([], projectRepos))] } : { from: "none", searches: [] };
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// One search's query, and the source it stands for; null when Next up has no sources of its own.
|
|
124
|
+
export interface UnclaimedSearch {
|
|
125
|
+
source: string | null;
|
|
126
|
+
query: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// An issue found by several sources is listed once, under each of them [NXT-09]. Forks don't count as my repos.
|
|
130
|
+
export function mergeUnclaimed(results: { source: string | null; nodes: (PickableNode | null)[] }[]): PickableNode[] {
|
|
131
|
+
const byKey = new Map<string, PickableNode>();
|
|
132
|
+
for (const { source, nodes } of results) {
|
|
133
|
+
for (const node of nodes) {
|
|
134
|
+
if (!node?.repository || (source === "mine" && node.repository.isFork)) continue;
|
|
135
|
+
const seen = byKey.get(prKey(node)) ?? { ...node, sources: [] };
|
|
136
|
+
if (source && !seen.sources!.includes(source)) seen.sources!.push(source);
|
|
137
|
+
byKey.set(prKey(node), seen);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return [...byKey.values()];
|
|
107
141
|
}
|
|
108
142
|
|
|
109
|
-
//
|
|
110
|
-
export function searchVariables(config: AttentionConfig, now: Date
|
|
143
|
+
// The searches about me. Next up's unclaimed issues have their own [NXT-04].
|
|
144
|
+
export function searchVariables(config: AttentionConfig, now: Date): Record<Exclude<SearchName, "unclaimed">, string> {
|
|
111
145
|
const scope = where(config.orgs, config.repos);
|
|
112
|
-
const unclaimed = unclaimedScope(config, projectRepos).scope;
|
|
113
146
|
const since = isoDate(new Date(now.getTime() - config.mentionDays * 86_400_000));
|
|
114
147
|
// Whole weeks, from a Monday, so the oldest week isn't cut short.
|
|
115
148
|
const history = isoDate(new Date(startOfWeek(now).getTime() - (config.historyWeeks - 1) * 7 * 86_400_000));
|
|
@@ -120,8 +153,6 @@ export function searchVariables(config: AttentionConfig, now: Date, projectRepos
|
|
|
120
153
|
mentions: `is:open mentions:@me updated:>=${since} ${scope}`,
|
|
121
154
|
assigned: `is:issue is:open assignee:@me ${scope}`,
|
|
122
155
|
commented: `is:issue is:open commenter:@me updated:>=${since} ${scope}`,
|
|
123
|
-
// [NXT-01, NXT-04, NXT-08]
|
|
124
|
-
unclaimed: unclaimed && `is:issue is:open no:assignee ${unclaimed}`,
|
|
125
156
|
// History [HIS-01, HIS-02]
|
|
126
157
|
merged: `is:pr is:merged author:@me merged:>=${history} ${scope}`,
|
|
127
158
|
reviewed: `is:pr is:merged reviewed-by:@me -author:@me merged:>=${history} ${scope}`,
|
package/server/service.ts
CHANGED
|
@@ -5,8 +5,8 @@ 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, LiveResult } from "./github-types";
|
|
8
|
-
import { detailsQuery, HISTORY_SEARCHES,
|
|
9
|
-
import { loadConfig, loadState, moveOldFiles, saveCodeRepo, saveCoverage, saveState, State } from "./store";
|
|
8
|
+
import { detailsQuery, HISTORY_SEARCHES, mergeUnclaimed, type SearchName, searchQuery, searchVariables, type UnclaimedSearch, unclaimedSearches } from "./queries";
|
|
9
|
+
import { loadConfig, loadState, moveOldFiles, saveCodeRepo, saveCoverage, saveNextUpSources, saveState, State } from "./store";
|
|
10
10
|
import { buildView } from "./view";
|
|
11
11
|
|
|
12
12
|
// History changes only when I finish something, so it's fetched daily, on ⟳ in its tab and after a merge.
|
|
@@ -93,11 +93,22 @@ export class AttentionService {
|
|
|
93
93
|
await this.refresh("live").catch(() => {});
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
// Where Next up looks, chosen in settings [NXT-04]. Only the live feed has Next up.
|
|
97
|
+
async setNextUpSources(sources: Pick<AttentionConfig["nextUp"], "mine" | "orgs" | "repos">): Promise<void> {
|
|
98
|
+
this.config = await saveNextUpSources(sources);
|
|
99
|
+
await this.refresh("live").catch(() => {});
|
|
100
|
+
}
|
|
101
|
+
|
|
96
102
|
async setScopes(scopes: string[]): Promise<void> {
|
|
97
103
|
this.state.scopes = scopes;
|
|
98
104
|
await this.save();
|
|
99
105
|
}
|
|
100
106
|
|
|
107
|
+
async setSources(sources: string[]): Promise<void> {
|
|
108
|
+
this.state.sources = sources;
|
|
109
|
+
await this.save();
|
|
110
|
+
}
|
|
111
|
+
|
|
101
112
|
// Concurrent callers share one refresh per feed.
|
|
102
113
|
refresh(id: FeedId): Promise<void> {
|
|
103
114
|
const feed = this.feeds[id];
|
|
@@ -133,8 +144,15 @@ export class AttentionService {
|
|
|
133
144
|
|
|
134
145
|
private async fetchLive(now: Date): Promise<Attention> {
|
|
135
146
|
const projectRepos = FIXTURE ? [] : await this.projectRepos();
|
|
136
|
-
const
|
|
137
|
-
|
|
147
|
+
const login = FIXTURE ? "me" : this.config.nextUp.mine ? await this.login() : null;
|
|
148
|
+
const unclaimed = unclaimedSearches(this.config, projectRepos, login);
|
|
149
|
+
const { data, details } = FIXTURE ? fixture(now) : await this.searchLive(now, unclaimed.searches);
|
|
150
|
+
return { ...classify({ data, details, config: this.config, now }), unclaimedFrom: unclaimed.from };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// The account gh is signed in as, for My repos [NXT-04]. Asked once, unless the last fetch already says.
|
|
154
|
+
private async login(): Promise<string> {
|
|
155
|
+
return (this.state.live?.attention.login || (await graphql<{ viewer: { login: string } }>("{ viewer { login } }")).viewer.login);
|
|
138
156
|
}
|
|
139
157
|
|
|
140
158
|
// My Paseo projects' GitHub repos, where Next up looks when no repos are chosen [NXT-08].
|
|
@@ -157,19 +175,25 @@ export class AttentionService {
|
|
|
157
175
|
}
|
|
158
176
|
|
|
159
177
|
// One request per search, in parallel. The details request starts once the searches it needs are back [GH-01].
|
|
160
|
-
private async searchLive(now: Date,
|
|
161
|
-
const all = searchVariables(this.config, now
|
|
162
|
-
const search =
|
|
163
|
-
|
|
178
|
+
private async searchLive(now: Date, unclaimed: UnclaimedSearch[]): Promise<{ data: LiveResult; details: Details }> {
|
|
179
|
+
const all = searchVariables(this.config, now);
|
|
180
|
+
const search = (name: keyof typeof all): Promise<Partial<LiveResult>> => graphql<Partial<LiveResult>>(searchQuery([name], name === "mine"), { [name]: all[name] });
|
|
181
|
+
// One per Next up source [NXT-09].
|
|
182
|
+
const searchUnclaimed = async (): Promise<Partial<LiveResult>> => {
|
|
183
|
+
const results = await Promise.all(
|
|
184
|
+
unclaimed.map(async ({ source, query }) => ({ source, nodes: (await graphql<Pick<LiveResult, "unclaimed">>(searchQuery(["unclaimed"]), { unclaimed: query })).unclaimed.nodes })),
|
|
185
|
+
);
|
|
186
|
+
return { unclaimed: { nodes: mergeUnclaimed(results) } };
|
|
187
|
+
};
|
|
164
188
|
const merge = (parts: Partial<LiveResult>[]) => Object.assign({}, ...parts) as LiveResult;
|
|
165
|
-
const forDetails = Promise.all([search("mine"), search("assigned"),
|
|
189
|
+
const forDetails = Promise.all([search("mine"), search("assigned"), searchUnclaimed()]);
|
|
166
190
|
const others = Promise.all([search("reviews"), search("mentions"), search("commented")]);
|
|
167
191
|
const afterThem = forDetails.then((parts) => this.details(merge(parts)));
|
|
168
192
|
const [first, rest, details] = await Promise.all([forDetails, others, afterThem]);
|
|
169
193
|
return { data: merge([...first, ...rest]), details };
|
|
170
194
|
}
|
|
171
195
|
|
|
172
|
-
private variables(names: readonly SearchName[], now: Date): Record<string, string
|
|
196
|
+
private variables(names: readonly Exclude<SearchName, "unclaimed">[], now: Date): Record<string, string> {
|
|
173
197
|
const all = searchVariables(this.config, now);
|
|
174
198
|
return Object.fromEntries(names.map((name) => [name, all[name]]));
|
|
175
199
|
}
|
|
@@ -241,6 +265,7 @@ export class AttentionService {
|
|
|
241
265
|
return buildView(this.state.live?.attention ?? null, this.state.history?.items ?? [], this.state.dismissed, {
|
|
242
266
|
feeds: { live: status("live"), history: status("history") },
|
|
243
267
|
scopes: this.state.scopes,
|
|
268
|
+
sources: this.state.sources,
|
|
244
269
|
config: this.config,
|
|
245
270
|
...(FIXTURE ? { fixtureAgents: FIXTURE_AGENTS } : {}),
|
|
246
271
|
});
|
package/server/setup.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ConfigStatus, CoverageCheck, CoverageKind, SetupStatus } from "../shared/setup";
|
|
2
|
-
import { FIXTURE_ORGS, FIXTURE_REPOS } from "./fixture";
|
|
3
|
-
import { FIXTURE, runGh } from "./gh";
|
|
2
|
+
import { FIXTURE_MY_ORGS, FIXTURE_ORGS, FIXTURE_REPOS } from "./fixture";
|
|
3
|
+
import { FIXTURE, graphql, runGh } from "./gh";
|
|
4
4
|
import { loadConfig } from "./store";
|
|
5
5
|
|
|
6
6
|
// What the setup checklist needs [SET-01]. Asked only when Attention Span can't load.
|
|
@@ -21,13 +21,20 @@ async function ghStatus(): Promise<SetupStatus["gh"]> {
|
|
|
21
21
|
|
|
22
22
|
export async function configStatus(): Promise<ConfigStatus> {
|
|
23
23
|
try {
|
|
24
|
-
const { orgs, repos } = await loadConfig();
|
|
25
|
-
return { error: null, orgs, repos };
|
|
24
|
+
const { orgs, repos, nextUp } = await loadConfig();
|
|
25
|
+
return { error: null, orgs, repos, nextUp: { mine: nextUp.mine, orgs: nextUp.orgs, repos: nextUp.repos } };
|
|
26
26
|
} catch (error) {
|
|
27
|
-
return { error: (error as Error).message, orgs: [], repos: [] };
|
|
27
|
+
return { error: (error as Error).message, orgs: [], repos: [], nextUp: { mine: false, orgs: [], repos: [] } };
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
// The orgs I belong to, for Next up's org picker [NXT-04]. Only these can be picked.
|
|
32
|
+
export async function myOrgs(): Promise<string[]> {
|
|
33
|
+
if (FIXTURE) return FIXTURE_MY_ORGS;
|
|
34
|
+
const { viewer } = await graphql<{ viewer: { organizations: { nodes: { login: string }[] } } }>("{ viewer { organizations(first: 100) { nodes { login } } } }");
|
|
35
|
+
return viewer.organizations.nodes.map((org) => org.login).sort((a, b) => a.localeCompare(b));
|
|
36
|
+
}
|
|
37
|
+
|
|
31
38
|
// An org or repo is checked on GitHub before it's saved, so a typo shows right away [SRC-02].
|
|
32
39
|
// Pasted GitHub URLs are accepted. The exact name GitHub returns is what gets saved.
|
|
33
40
|
export async function checkCoverage(kind: CoverageKind, input: string): Promise<CoverageCheck> {
|
package/server/store.ts
CHANGED
|
@@ -16,12 +16,17 @@ const STATE = join(DIR, "state.json");
|
|
|
16
16
|
export const State = z.object({
|
|
17
17
|
// Item key -> others' activity and section when dismissed [ATT-08].
|
|
18
18
|
dismissed: z.record(z.string(), z.object({ at: z.string(), section: z.custom<SectionId>() })).default({}),
|
|
19
|
-
//
|
|
19
|
+
// Scopes ticked in Next up's filter; none means all [NXT-03].
|
|
20
20
|
scopes: z.array(z.string()).default([]),
|
|
21
|
+
// Sources ticked in Next up's filter; none means all [NXT-09].
|
|
22
|
+
sources: z.array(z.string()).default([]),
|
|
21
23
|
// My Paseo projects' GitHub repos when last listed, for refreshes before the app has connected [NXT-08].
|
|
22
24
|
projectRepos: z.array(z.string()).default([]),
|
|
23
25
|
// The last fetch of each feed. A cache from an older version is dropped rather than shown wrong.
|
|
24
|
-
live: z
|
|
26
|
+
live: z
|
|
27
|
+
.object({ fetchedAt: z.string(), attention: z.custom<Attention>((value) => (value as Attention)?.unclaimed?.every?.((issue) => Array.isArray(issue.sources) && Array.isArray(issue.openPrs))) })
|
|
28
|
+
.nullable()
|
|
29
|
+
.catch(null),
|
|
25
30
|
history: z.object({ fetchedAt: z.string(), items: z.custom<Item[]>(Array.isArray) }).nullable().catch(null),
|
|
26
31
|
});
|
|
27
32
|
export type State = z.infer<typeof State>;
|
|
@@ -68,6 +73,14 @@ export function saveCoverage(orgs: string[], repos: string[]): Promise<Attention
|
|
|
68
73
|
return updateConfig((file) => ({ ...file, orgs, repos }));
|
|
69
74
|
}
|
|
70
75
|
|
|
76
|
+
// Where Next up looks, chosen in settings [NXT-04]. The fields and the rest of nextUp are kept.
|
|
77
|
+
export function saveNextUpSources(sources: Pick<AttentionConfig["nextUp"], "mine" | "orgs" | "repos">): Promise<AttentionConfig> {
|
|
78
|
+
return updateConfig((file) => {
|
|
79
|
+
const nextUp = file.nextUp && typeof file.nextUp === "object" ? (file.nextUp as Record<string, unknown>) : {};
|
|
80
|
+
return { ...file, nextUp: { ...nextUp, ...sources } };
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
71
84
|
// What the screen writes changes only its own keys; everything else in the file is kept as it is.
|
|
72
85
|
// A file that doesn't read or parse is left alone.
|
|
73
86
|
async function updateConfig(change: (file: Record<string, unknown>) => Record<string, unknown>): Promise<AttentionConfig> {
|
package/server/view.ts
CHANGED
package/shared/attention.ts
CHANGED
|
@@ -73,6 +73,9 @@ export interface WaitingComment {
|
|
|
73
73
|
url?: string;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
// GitHub's reasons for closing an issue that Next up offers [NXT-11].
|
|
77
|
+
export type IssueCloseReason = "completed" | "not_planned";
|
|
78
|
+
|
|
76
79
|
// What a session or GitHub action works on.
|
|
77
80
|
export interface Target {
|
|
78
81
|
kind: "pr" | "issue";
|
|
@@ -136,6 +139,12 @@ export interface NextUpIssue {
|
|
|
136
139
|
effort?: string;
|
|
137
140
|
scope?: string;
|
|
138
141
|
defaultBranch?: string;
|
|
142
|
+
// Ids of the Next up sources that found it; empty without sources of its own [NXT-09].
|
|
143
|
+
sources: string[];
|
|
144
|
+
// Its priority's place in the field's order, 0 first; missing when unknown [NXT-02].
|
|
145
|
+
priorityRank?: number;
|
|
146
|
+
// Open PRs that close it: someone may already be on it [NXT-10].
|
|
147
|
+
openPrs: { number: number; url: string; author: string | null }[];
|
|
139
148
|
}
|
|
140
149
|
|
|
141
150
|
// More about an item, fetched when its sheet opens rather than in every refresh [GH-01].
|
|
@@ -200,8 +209,10 @@ export interface AttentionView {
|
|
|
200
209
|
unclaimed: NextUpIssue[];
|
|
201
210
|
unclaimedFrom: UnclaimedSource;
|
|
202
211
|
dismissedCount: number;
|
|
203
|
-
//
|
|
212
|
+
// Scopes ticked in Next up's filter; none means all [NXT-03].
|
|
204
213
|
scopes: string[];
|
|
214
|
+
// Sources ticked in Next up's filter; none means all [NXT-09].
|
|
215
|
+
sources: string[];
|
|
205
216
|
config: AttentionConfig;
|
|
206
217
|
// Fixture mode only: made-up sessions, since the preview daemon has no agents.
|
|
207
218
|
fixtureAgents?: Record<string, AgentSummary>;
|
package/shared/config.ts
CHANGED
|
@@ -38,18 +38,35 @@ export const AttentionConfig = z.object({
|
|
|
38
38
|
mentionDays: z.number().positive().default(30),
|
|
39
39
|
// How many weeks History shows [HIS-01].
|
|
40
40
|
historyWeeks: z.number().int().positive().default(4),
|
|
41
|
-
// Unclaimed issues to pick from [NXT-04].
|
|
41
|
+
// Unclaimed issues to pick from [NXT-04]. With no sources chosen, Next up looks in `orgs` and `repos` [NXT-08].
|
|
42
42
|
nextUp: z
|
|
43
43
|
.object({
|
|
44
|
-
|
|
44
|
+
// Sources: my own repos (not forks), whole orgs, and single "owner/name" repos.
|
|
45
|
+
mine: z.boolean().default(false),
|
|
46
|
+
orgs: z.array(z.string()).default([]),
|
|
47
|
+
repos: z.array(z.string()).default([]),
|
|
45
48
|
priority: RankedField.optional(),
|
|
46
49
|
effort: RankedField.optional(),
|
|
47
50
|
scope: z.object({ field: z.string() }).optional(),
|
|
48
51
|
})
|
|
49
|
-
.default({}),
|
|
52
|
+
.default({ mine: false, orgs: [], repos: [] }),
|
|
50
53
|
});
|
|
51
54
|
export type AttentionConfig = z.infer<typeof AttentionConfig>;
|
|
52
55
|
|
|
56
|
+
// Where Next up looks, one search each; `id` is what the chips I pick remember [NXT-09].
|
|
57
|
+
export interface NextUpSource {
|
|
58
|
+
id: string;
|
|
59
|
+
label: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function nextUpSources({ nextUp }: Pick<AttentionConfig, "nextUp">): NextUpSource[] {
|
|
63
|
+
return [
|
|
64
|
+
...(nextUp.mine ? [{ id: "mine", label: "My repos" }] : []),
|
|
65
|
+
...nextUp.orgs.map((org) => ({ id: `org:${org}`, label: org })),
|
|
66
|
+
...nextUp.repos.map((repo) => ({ id: `repo:${repo}`, label: repo })),
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
|
|
53
70
|
// "owner/name" of a Paseo project with a GitHub remote, from its project key.
|
|
54
71
|
export function githubRepoOf(projectKey: string | null | undefined): string | null {
|
|
55
72
|
return /^remote:github\.com\/(.+)$/i.exec(projectKey ?? "")?.[1] ?? null;
|
package/shared/format.ts
CHANGED
|
@@ -14,3 +14,18 @@ export function ago(iso: string, now: Date = new Date()): string {
|
|
|
14
14
|
export function daysSince(iso: string, now: Date): number {
|
|
15
15
|
return (now.getTime() - new Date(iso).getTime()) / 86_400_000;
|
|
16
16
|
}
|
|
17
|
+
|
|
18
|
+
// A Markdown bullet list of links, for pasting a week's work into a report [HIS-03].
|
|
19
|
+
export function linkList(items: { title: string; url: string }[]): string {
|
|
20
|
+
return items.map(({ title, url }) => `- [${title.replace(/[[\]\\]/g, "\\$&")}](${url})`).join("\n");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// An issue field value for a card: "🐟 Tiny (< 4h)" -> "Tiny", "🏕P2 Medium" -> "P2 Medium" [NXT-10]. The sheet keeps the full value.
|
|
24
|
+
export function shortValue(value: string): string {
|
|
25
|
+
return (
|
|
26
|
+
value
|
|
27
|
+
.replace(/^[^\p{L}\p{N}]+/u, "")
|
|
28
|
+
.replace(/\s*\([^)]*\)\s*$/, "")
|
|
29
|
+
.trim() || value
|
|
30
|
+
);
|
|
31
|
+
}
|
package/shared/rpc.ts
CHANGED
|
@@ -23,8 +23,12 @@ export const setupStatus = defineRpc({ name: "setup.status", input: z.object({})
|
|
|
23
23
|
export const getCoverage = defineRpc({ name: "config.coverage", input: z.object({}), output: z.custom<ConfigStatus>() });
|
|
24
24
|
export const checkCoverage = defineRpc({ name: "config.check-coverage", input: z.object({ kind: z.enum(["org", "repo"]), name: z.string() }), output: z.custom<CoverageCheck>() });
|
|
25
25
|
export const setCoverage = defineRpc({ name: "config.set-coverage", input: z.object({ orgs: z.array(z.string()), repos: z.array(z.string()) }), output: done });
|
|
26
|
-
//
|
|
26
|
+
// Where Next up looks, chosen in settings [NXT-04]; orgs are picked from the ones I belong to.
|
|
27
|
+
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 });
|
|
28
|
+
export const myOrgs = defineRpc({ name: "config.my-orgs", input: z.object({}), output: z.object({ orgs: z.array(z.string()) }) });
|
|
29
|
+
// Remember the scopes and sources ticked in Next up's filter [NXT-03, NXT-09].
|
|
27
30
|
export const setScopes = defineRpc({ name: "next-up.scopes", input: z.object({ scopes: z.array(z.string()) }), output: done });
|
|
31
|
+
export const setSources = defineRpc({ name: "next-up.sources", input: z.object({ sources: z.array(z.string()) }), output: done });
|
|
28
32
|
|
|
29
33
|
// GitHub changes, each from an explicit tap [SAFE-01].
|
|
30
34
|
export const updateBranch = defineRpc({ name: "pr.update-branch", input: z.object({ target }), output: done });
|
|
@@ -32,6 +36,9 @@ export const mergePullRequest = defineRpc({ name: "pr.merge", input: z.object({
|
|
|
32
36
|
export const closePullRequest = defineRpc({ name: "pr.close", input: z.object({ target, comment: z.string().optional() }), output: done });
|
|
33
37
|
export const claimIssue = defineRpc({ name: "issue.claim", input: z.object({ target }), output: done });
|
|
34
38
|
export const unclaimIssue = defineRpc({ name: "issue.unclaim", input: z.object({ target }), output: done });
|
|
39
|
+
// Close an issue from Next up; reopen is its Undo [NXT-11].
|
|
40
|
+
export const closeIssue = defineRpc({ name: "issue.close", input: z.object({ target, reason: z.enum(["completed", "not_planned"]), comment: z.string().optional() }), output: done });
|
|
41
|
+
export const reopenIssue = defineRpc({ name: "issue.reopen", input: z.object({ target }), output: done });
|
|
35
42
|
// `ready: false` and `on: false` are the Undo of each.
|
|
36
43
|
export const setReady = defineRpc({ name: "pr.ready", input: z.object({ target, ready: z.boolean() }), output: done });
|
|
37
44
|
export const setAutoMerge = defineRpc({ name: "pr.auto-merge", input: z.object({ target, on: z.boolean() }), output: done });
|
package/shared/setup.ts
CHANGED
|
@@ -5,6 +5,8 @@ export interface ConfigStatus {
|
|
|
5
5
|
error: string | null;
|
|
6
6
|
orgs: string[];
|
|
7
7
|
repos: string[];
|
|
8
|
+
// Where Next up looks; none chosen falls back to `orgs` and `repos`, then my Paseo projects [NXT-04, NXT-08].
|
|
9
|
+
nextUp: { mine: boolean; orgs: string[]; repos: string[] };
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
export interface SetupStatus {
|