@andrioid/paseo-attention-span 0.2.1 → 0.3.0
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 +11 -7
- package/client/attention-screen.tsx +182 -79
- package/client/card.tsx +5 -15
- package/client/coverage-settings.tsx +35 -4
- package/client/feedback.tsx +151 -0
- package/client/host.ts +8 -0
- package/client/icons.ts +3 -2
- package/client/next-up.tsx +29 -45
- package/client/session-menu.ts +18 -26
- package/client/sessions.ts +5 -2
- package/client/sheet.tsx +17 -72
- package/client/ui.tsx +0 -49
- package/docs/architecture.md +188 -0
- package/docs/screenshots/desktop-dark-doing-acknowledge.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-history.png +0 -0
- package/docs/screenshots/desktop-dark-next-up.png +0 -0
- package/docs/screenshots/desktop-dark-settings.png +0 -0
- package/docs/screenshots/desktop-dark-setup.png +0 -0
- package/docs/screenshots/desktop-dark-waiting.png +0 -0
- package/docs/screenshots/phone-dark-doing.png +0 -0
- package/docs/screenshots/phone-light-next-up-filtered.png +0 -0
- package/index.client.tsx +15 -5
- package/index.server.ts +28 -2
- package/package.json +5 -2
- package/requirements.yaml +128 -0
- package/server/actions.ts +31 -1
- package/server/classify.ts +150 -52
- package/server/feedback.ts +38 -0
- package/server/fixture.ts +48 -16
- package/server/github-types.ts +15 -2
- package/server/queries.ts +15 -4
- package/server/rules.ts +119 -0
- package/server/service.ts +15 -3
- package/server/setup.ts +3 -3
- package/server/store.ts +5 -0
- package/shared/attention.ts +36 -2
- package/shared/config.ts +3 -0
- package/shared/feedback.ts +91 -0
- package/shared/rpc.ts +12 -1
- package/shared/setup.ts +2 -0
- package/docs/screenshots/desktop-dark-doing-session-menu.png +0 -0
package/server/fixture.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { AgentSummary, ItemDetails, Target } from "../shared/attention";
|
|
1
|
+
import type { AgentSummary, ItemDetails, Reviewer, ReviewerChoices, Target } from "../shared/attention";
|
|
2
|
+
import type { SessionKind } from "../shared/config";
|
|
2
3
|
import type { Actor, Comment, Details, IssueNode, MentionNode, PickableNode, PullRequestNode, SearchResult } from "./github-types";
|
|
3
4
|
|
|
4
5
|
// Made-up GitHub data for tests and for previews without GitHub (PASEO_ATTENTION_SPAN_FIXTURE=1).
|
|
@@ -18,6 +19,7 @@ export const me: Actor = { __typename: "User", login: "me" };
|
|
|
18
19
|
export const alice: Actor = { __typename: "User", login: "alice", avatarUrl: avatar(1) };
|
|
19
20
|
export const bob: Actor = { __typename: "User", login: "bob", avatarUrl: avatar(2) };
|
|
20
21
|
export const bot: Actor = { __typename: "Bot", login: "reviewbot" };
|
|
22
|
+
const frontend = { __typename: "Team", combinedSlug: "acme/frontend", avatarUrl: avatar(9919) };
|
|
21
23
|
|
|
22
24
|
export function builders(now: Date) {
|
|
23
25
|
const daysAgo = (days: number) => new Date(now.getTime() - days * 86_400_000).toISOString();
|
|
@@ -72,8 +74,9 @@ export function builders(now: Date) {
|
|
|
72
74
|
};
|
|
73
75
|
}
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
// Someone else's issue unless `overrides` says otherwise.
|
|
78
|
+
function issue(number: number, comments: Comment[] = [], title = `Issue ${number}`, overrides: Partial<IssueNode> = {}): IssueNode {
|
|
79
|
+
return { __typename: "Issue", number, title, url: `https://github.com/${REPO}/issues/${number}`, createdAt: daysAgo(20), author: alice, repository, comments: { nodes: comments }, ...overrides };
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
function pickable(number: number, fields: Record<string, string>, createdDaysAgo = 10, type = "Bug", title = `Issue ${number}`, repo = REPO): PickableNode {
|
|
@@ -95,7 +98,8 @@ export function builders(now: Date) {
|
|
|
95
98
|
mine: nodes("mine") as SearchResult["mine"],
|
|
96
99
|
reviews: nodes("reviews") as SearchResult["reviews"],
|
|
97
100
|
mentions: nodes("mentions") as SearchResult["mentions"],
|
|
98
|
-
|
|
101
|
+
involved: nodes("involved") as SearchResult["involved"],
|
|
102
|
+
asked: nodes("asked") as SearchResult["asked"],
|
|
99
103
|
assigned: nodes("assigned") as SearchResult["assigned"],
|
|
100
104
|
unclaimed: nodes("unclaimed") as SearchResult["unclaimed"],
|
|
101
105
|
merged: nodes("merged") as SearchResult["merged"],
|
|
@@ -140,11 +144,12 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
140
144
|
pr(106, { title: "Keyboard navigation for calendar cards", isDraft: true, baseRefName: "a11y-1", headRefName: "a11y-2", reviewDecision: "APPROVED" }),
|
|
141
145
|
pr(107, { title: "Calendar: jump between weeks with keys", isDraft: true, baseRefName: "a11y-2", headRefName: "a11y-3" }, "FAILURE"),
|
|
142
146
|
pr(108, { title: "Company-scoped database layer", mergeable: "CONFLICTING" }),
|
|
143
|
-
|
|
147
|
+
// Asked a team, and nobody has looked for 6 days [ATT-11, PRS-12].
|
|
148
|
+
pr(109, { title: "Store uploads locally in development", reviewRequests: { nodes: [{ requestedReviewer: frontend }] }, commits: commit("SUCCESS", 6) }),
|
|
144
149
|
pr(110, { title: "requirements.yaml for the shop", isDraft: true, updatedAt: daysAgo(64) }),
|
|
145
150
|
pr(111, { title: "Faster product search", reviewRequests: { nodes: [{ requestedReviewer: bob }] }, commits: commit("SUCCESS", 0.3) }),
|
|
146
151
|
pr(112, { title: "Translate the checkout emails", reviewDecision: "CHANGES_REQUESTED", latestReviews: { nodes: [{ author: alice, state: "CHANGES_REQUESTED", submittedAt: daysAgo(2) }] }, commits: commit("SUCCESS", 1) }),
|
|
147
|
-
pr(113, { title: "Upgrade the payment SDK" }, "PENDING"),
|
|
152
|
+
pr(113, { title: "Upgrade the payment SDK", reviewRequests: { nodes: [{ requestedReviewer: bob }] } }, "PENDING"),
|
|
148
153
|
pr(114, { title: "Cache exchange rates daily", reviewDecision: "APPROVED" }),
|
|
149
154
|
pr(115, { title: "Split the settings page into tabs", isDraft: true, mergeable: "CONFLICTING" }),
|
|
150
155
|
pr(116, { title: "Try a faster PDF renderer", isDraft: true }, "FAILURE"),
|
|
@@ -153,6 +158,11 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
153
158
|
pr(119, { title: "Show stock levels on product cards", isDraft: true }),
|
|
154
159
|
pr(122, { title: "Round VAT per line, not per invoice", reviewDecision: "APPROVED", repository: { ...repository, autoMergeAllowed: true } }, "PENDING"),
|
|
155
160
|
pr(123, { title: "Archive offers older than a year", reviewDecision: "APPROVED", autoMergeRequest: { enabledAt: daysAgo(0.1) } }, "PENDING"),
|
|
161
|
+
// Nobody asked yet: green, so Merge too; and one still in CI [PRS-12].
|
|
162
|
+
pr(124, { title: "Export invoices as CSV", commits: commit("SUCCESS", 0.5) }),
|
|
163
|
+
pr(125, { title: "Log slow database queries" }, "PENDING"),
|
|
164
|
+
// A review that only commented keeps it waiting on that reviewer.
|
|
165
|
+
pr(126, { title: "Tidy the admin menu", latestReviews: { nodes: [{ author: alice, state: "COMMENTED", submittedAt: daysAgo(0.8) }] } }),
|
|
156
166
|
],
|
|
157
167
|
reviews: [pr(120, { title: "Add a status page", author: bob }), pr(121, { title: "Rework the cart totals", author: alice })],
|
|
158
168
|
mentions: [
|
|
@@ -176,7 +186,18 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
176
186
|
reviewThreads: { nodes: [{ isResolved: false, comments: { nodes: [comment(bot, "@me this endpoint leaks the API key in its response", 1)] } }] },
|
|
177
187
|
}),
|
|
178
188
|
],
|
|
179
|
-
|
|
189
|
+
involved: [
|
|
190
|
+
issue(140, [comment(alice, "", 9), comment(me, "Which customers see this?", 1)], "Invoice totals round wrong"),
|
|
191
|
+
// Answered on my own issue without mentioning me [ATT-16]; and a bot after my question, which doesn't count [MEN-05].
|
|
192
|
+
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 }),
|
|
193
|
+
issue(143, [comment(me, "Can we drop the old endpoint yet?", 1), comment(bot, "This issue has been labelled `needs-triage`.", 0.5)], "Retire the v1 orders endpoint"),
|
|
194
|
+
// A comment on my PR's conversation [ATT-16].
|
|
195
|
+
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) }),
|
|
196
|
+
// Someone else's old thread where people kept going after me: not mine to follow [ATT-16].
|
|
197
|
+
issue(144, [comment(me, "Same here on 2.3", 400), comment(bob, "+1", 300)], "Crash on startup"),
|
|
198
|
+
],
|
|
199
|
+
// My own issue, asked about long ago and never answered [ATT-11].
|
|
200
|
+
asked: [issue(141, [comment(me, "Is this still needed?", 40)], "Rotate the analytics token", { author: me, createdAt: daysAgo(90) })],
|
|
180
201
|
assigned: [
|
|
181
202
|
pickable(150, fields("🏔 P1 High", "🐇 Small (0.5-2d)", "🔙 Backend"), 20, "Bug", "Orders export times out for big shops"),
|
|
182
203
|
pickable(151, fields("🏕P2 Medium", "🐟 Tiny (< 4h)", "🔙 Backend"), 5, "Bug", "Price list import skips quoted rows", ISSUES_REPO),
|
|
@@ -207,10 +228,12 @@ export function fixture(now: Date): { data: SearchResult; details: Details } {
|
|
|
207
228
|
}
|
|
208
229
|
|
|
209
230
|
// Sessions the preview shows as started from items: working, needs me, failed, idle.
|
|
210
|
-
//
|
|
211
|
-
|
|
231
|
+
// Each sits in its action's line in the sheet. Issue 90 has two: an old one with no kind, which leads, and Rebase stack on its PR.
|
|
232
|
+
// #113 waits on CI while its Fix CI session works, though Fix CI isn't one of its actions any more.
|
|
233
|
+
const agent = (id: string, itemKey: string, kind: SessionKind | undefined, status: string, minutesAgo: number, requiresAttention = false): AgentSummary => ({
|
|
212
234
|
id,
|
|
213
235
|
itemKey,
|
|
236
|
+
kind,
|
|
214
237
|
status,
|
|
215
238
|
requiresAttention,
|
|
216
239
|
title: `Fixture session ${id}`,
|
|
@@ -218,17 +241,26 @@ const agent = (id: string, itemKey: string, status: string, minutesAgo: number,
|
|
|
218
241
|
lastActivityAt: new Date(Date.now() - minutesAgo * 60_000).toISOString(),
|
|
219
242
|
});
|
|
220
243
|
export const FIXTURE_AGENTS: AgentSummary[] = [
|
|
221
|
-
agent("agent-101", `${REPO}#101`, "running", 4),
|
|
222
|
-
agent("agent-102", `${REPO}#102`, "idle", 30, true),
|
|
223
|
-
agent("agent-108", `${REPO}#108`, "error", 90),
|
|
224
|
-
agent("agent-150", `${REPO}#150`, "idle", 300),
|
|
225
|
-
agent("agent-90", `${REPO}#90`, "idle", 120, true),
|
|
226
|
-
agent("agent-103", `${REPO}#103`, "running", 6),
|
|
227
|
-
agent("agent-113", `${REPO}#113`, "running", 2),
|
|
244
|
+
agent("agent-101", `${REPO}#101`, "fix", "running", 4),
|
|
245
|
+
agent("agent-102", `${REPO}#102`, "address", "idle", 30, true),
|
|
246
|
+
agent("agent-108", `${REPO}#108`, "rebase", "error", 90),
|
|
247
|
+
agent("agent-150", `${REPO}#150`, "start", "idle", 300),
|
|
248
|
+
agent("agent-90", `${REPO}#90`, undefined, "idle", 120, true),
|
|
249
|
+
agent("agent-103", `${REPO}#103`, "rebase", "running", 6),
|
|
250
|
+
agent("agent-113", `${REPO}#113`, "fix", "running", 2),
|
|
228
251
|
];
|
|
229
252
|
|
|
230
253
|
export const FIXTURE_CONTEXT = "Context from GitHub would go here (fixture mode).";
|
|
231
254
|
|
|
255
|
+
// What the reviewer picker offers in previews: GitHub's suggestion, who reviewed my other PRs, and a team [PRS-12].
|
|
256
|
+
export function fixtureReviewerChoices(recent: Reviewer[]): ReviewerChoices {
|
|
257
|
+
return {
|
|
258
|
+
suggested: [{ login: "carol", avatarUrl: avatar(3), team: false }],
|
|
259
|
+
recent,
|
|
260
|
+
teams: [{ login: "acme/frontend", team: true }, { login: "acme/payments", team: true }],
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
232
264
|
// What a sheet shows, made up: a size, the linked issue, and failing checks for Rerun.
|
|
233
265
|
export function fixtureDetails(subject: { kind: "pr" | "issue"; repo: string; number: number }, target: Target | undefined, checks: boolean): ItemDetails {
|
|
234
266
|
const pr = target?.kind === "pr" ? target : undefined;
|
package/server/github-types.ts
CHANGED
|
@@ -9,6 +9,13 @@ export interface Actor {
|
|
|
9
9
|
avatarUrl?: string;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export interface RequestedReviewer {
|
|
13
|
+
__typename?: string; // "User", "Team", ...
|
|
14
|
+
login?: string;
|
|
15
|
+
combinedSlug?: string;
|
|
16
|
+
avatarUrl?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
12
19
|
export interface Comment {
|
|
13
20
|
id?: string;
|
|
14
21
|
author: Actor | null;
|
|
@@ -44,7 +51,8 @@ export interface PullRequestNode {
|
|
|
44
51
|
assignees: Nodes<{ login: string }>;
|
|
45
52
|
closingIssuesReferences: Nodes<{ number: number; title: string; url: string; repository: Repo }>;
|
|
46
53
|
commits: Nodes<{ commit: { committedDate: string; statusCheckRollup: { state: string } | null } }>;
|
|
47
|
-
|
|
54
|
+
// A person, or a team by its "org/slug"; null when it can't be seen.
|
|
55
|
+
reviewRequests: Nodes<{ requestedReviewer: RequestedReviewer | null }>;
|
|
48
56
|
latestReviews: Nodes<{ author: Actor | null; state: string; submittedAt: string | null }>;
|
|
49
57
|
reviewThreads: Nodes<ReviewThread>;
|
|
50
58
|
comments: Nodes<Comment>;
|
|
@@ -67,7 +75,11 @@ export interface MentionNode {
|
|
|
67
75
|
reviewThreads?: Nodes<ReviewThread>;
|
|
68
76
|
}
|
|
69
77
|
|
|
78
|
+
// An issue or PR I'm in, with its last conversation comments.
|
|
70
79
|
export interface IssueNode {
|
|
80
|
+
__typename?: "Issue" | "PullRequest";
|
|
81
|
+
createdAt: string;
|
|
82
|
+
author: Actor | null;
|
|
71
83
|
number: number;
|
|
72
84
|
title: string;
|
|
73
85
|
url: string;
|
|
@@ -95,7 +107,8 @@ export interface LiveResult {
|
|
|
95
107
|
mine: Nodes<PullRequestNode>;
|
|
96
108
|
reviews: Nodes<PullRequestNode>;
|
|
97
109
|
mentions: Nodes<MentionNode>;
|
|
98
|
-
|
|
110
|
+
involved: Nodes<IssueNode>;
|
|
111
|
+
asked: Nodes<IssueNode>;
|
|
99
112
|
assigned: Nodes<PickableNode>;
|
|
100
113
|
unclaimed: Nodes<PickableNode>;
|
|
101
114
|
}
|
package/server/queries.ts
CHANGED
|
@@ -2,6 +2,11 @@ import type { UnclaimedSource } from "../shared/attention";
|
|
|
2
2
|
import type { AttentionConfig } from "../shared/config";
|
|
3
3
|
import type { PickableNode, PullRequestNode } from "./github-types";
|
|
4
4
|
|
|
5
|
+
// An issue or PR with its last conversation comments [ATT-16].
|
|
6
|
+
const THREAD = `__typename
|
|
7
|
+
... on Issue { number title url createdAt author { ...author } repository { nameWithOwner } comments(last: 10) { nodes { ...comment } } }
|
|
8
|
+
... on PullRequest { number title url createdAt author { ...author } repository { nameWithOwner } comments(last: 10) { nodes { ...comment } } }`;
|
|
9
|
+
|
|
5
10
|
// Each search with how many results it asks for and what it reads of each.
|
|
6
11
|
const SEARCHES = {
|
|
7
12
|
mine: { first: 50, nodes: "...pr" },
|
|
@@ -16,7 +21,10 @@ const SEARCHES = {
|
|
|
16
21
|
reviewThreads(last: 30) { nodes { isResolved comments(first: 20) { nodes { ...comment } } } }
|
|
17
22
|
}`,
|
|
18
23
|
},
|
|
19
|
-
|
|
24
|
+
// Threads I'm in, with their last conversation comments and what the 👍 picker needs, to tell whether I'm answered [ATT-16].
|
|
25
|
+
involved: { first: 100, nodes: THREAD },
|
|
26
|
+
// My own issues where I commented, for questions nobody answered however old [ATT-11].
|
|
27
|
+
asked: { first: 50, nodes: THREAD },
|
|
20
28
|
assigned: { first: 50, nodes: "...pickable" },
|
|
21
29
|
unclaimed: { first: 100, nodes: "...pickable" },
|
|
22
30
|
merged: {
|
|
@@ -29,7 +37,7 @@ const SEARCHES = {
|
|
|
29
37
|
export type SearchName = keyof typeof SEARCHES;
|
|
30
38
|
|
|
31
39
|
// Doing, Waiting and Next up. History has its own, slower schedule.
|
|
32
|
-
export const LIVE_SEARCHES = ["mine", "reviews", "mentions", "
|
|
40
|
+
export const LIVE_SEARCHES = ["mine", "reviews", "mentions", "involved", "asked", "assigned", "unclaimed"] as const;
|
|
33
41
|
export const HISTORY_SEARCHES = ["merged", "reviewed", "closed"] as const;
|
|
34
42
|
|
|
35
43
|
const FRAGMENTS: Record<string, string> = {
|
|
@@ -56,7 +64,7 @@ const FRAGMENTS: Record<string, string> = {
|
|
|
56
64
|
assignees(first: 10) { nodes { login } }
|
|
57
65
|
closingIssuesReferences(first: 5) { nodes { number title url repository { nameWithOwner } } }
|
|
58
66
|
commits(last: 1) { nodes { commit { committedDate statusCheckRollup { state } } } }
|
|
59
|
-
reviewRequests(first: 5) { nodes { requestedReviewer { ... on User { ...author } } } }
|
|
67
|
+
reviewRequests(first: 5) { nodes { requestedReviewer { ... on User { ...author } ... on Team { __typename combinedSlug avatarUrl } } } }
|
|
60
68
|
latestReviews(first: 10) { nodes { author { ...author } state submittedAt } }
|
|
61
69
|
reviewThreads(last: 30) {
|
|
62
70
|
nodes {
|
|
@@ -152,7 +160,10 @@ export function searchVariables(config: AttentionConfig, now: Date): Record<Excl
|
|
|
152
160
|
reviews: `is:pr is:open user-review-requested:@me ${scope}`,
|
|
153
161
|
mentions: `is:open mentions:@me updated:>=${since} ${scope}`,
|
|
154
162
|
assigned: `is:issue is:open assignee:@me ${scope}`,
|
|
155
|
-
commented
|
|
163
|
+
// Threads I opened, commented on, was assigned or mentioned in, active lately: answers, and fresh questions [ATT-16].
|
|
164
|
+
involved: `is:open involves:@me updated:>=${since} sort:updated-desc ${scope}`,
|
|
165
|
+
// On my own issues a question nobody answered stays however old [ATT-11]. Newest first, so old ones go last.
|
|
166
|
+
asked: `is:issue is:open author:@me commenter:@me sort:updated-desc ${scope}`,
|
|
156
167
|
// History [HIS-01, HIS-02]
|
|
157
168
|
merged: `is:pr is:merged author:@me merged:>=${history} ${scope}`,
|
|
158
169
|
reviewed: `is:pr is:merged reviewed-by:@me -author:@me merged:>=${history} ${scope}`,
|
package/server/rules.ts
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { type ActionId, type Person, SECTION_ORDER, type SectionId } from "../shared/attention";
|
|
2
|
+
|
|
3
|
+
// Which section an item goes in, as one rule per section. The regions of an item's state (CI, review, mergeability, draft)
|
|
4
|
+
// are flags; a rule is a guard over them. SECTIONS order is the priority: the first section whose rule holds wins [ATT-02].
|
|
5
|
+
|
|
6
|
+
export interface Rule<S> {
|
|
7
|
+
when: (s: S) => boolean;
|
|
8
|
+
// The first is the card's main action.
|
|
9
|
+
actions?: (s: S) => ActionId[];
|
|
10
|
+
// What it waits for, for Waiting too long's chip.
|
|
11
|
+
label?: (s: S) => string;
|
|
12
|
+
}
|
|
13
|
+
export type Rules<S> = { [K in SectionId]?: Rule<S> };
|
|
14
|
+
|
|
15
|
+
// The first section, in SECTIONS order, whose rule holds.
|
|
16
|
+
export function pick<S>(rules: Rules<S>, s: S): SectionId | undefined {
|
|
17
|
+
return SECTION_ORDER.find((id) => rules[id]?.when(s));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Reply on GitHub, or 👍 the waiting comments, which clears them too [MEN-02].
|
|
21
|
+
export function replyActions(waiting: Person | undefined): ActionId[] {
|
|
22
|
+
return waiting?.comments?.length ? ["reply", "acknowledge"] : ["reply"];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// ---- My PRs: a stack decided by its bottom PR [ATT-04] ----
|
|
26
|
+
|
|
27
|
+
export interface PrState {
|
|
28
|
+
draft: boolean;
|
|
29
|
+
// Someone mentioned me and is waiting [MEN-01].
|
|
30
|
+
waiting?: Person;
|
|
31
|
+
// Someone commented on it after me, lately, and I haven't 👍'd it [ATT-16].
|
|
32
|
+
answer?: Person;
|
|
33
|
+
ciFailing: boolean;
|
|
34
|
+
ciPending: boolean;
|
|
35
|
+
changes: boolean;
|
|
36
|
+
approved: boolean;
|
|
37
|
+
conflicts: boolean;
|
|
38
|
+
// Conflicts, or a PR above it no longer builds on its parent [UPS-01, UPS-02].
|
|
39
|
+
blocked: boolean;
|
|
40
|
+
autoMerge: boolean;
|
|
41
|
+
autoMergeAllowed: boolean;
|
|
42
|
+
behindBy: number;
|
|
43
|
+
stacked: boolean;
|
|
44
|
+
stale: boolean;
|
|
45
|
+
// Someone has the next move: a person or team is requested, or someone else has reviewed [PRS-12].
|
|
46
|
+
asked: boolean;
|
|
47
|
+
// I replied to the reviewer, or pushed after changes were requested.
|
|
48
|
+
replied: boolean;
|
|
49
|
+
// Waited at least waitingTooLongDays [ATT-11].
|
|
50
|
+
tooLong: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const waitingFor = (s: PrState) => (s.ciPending ? "CI running" : s.replied ? "waiting for the reviewer" : "waiting for review");
|
|
54
|
+
|
|
55
|
+
// Merge only once CI passed against the current base [PRS-04, UPS-07]. Until then, auto-merge if the repo allows it [PRS-10].
|
|
56
|
+
function readyActions(s: PrState): ActionId[] {
|
|
57
|
+
if (s.behindBy > 0) return [s.stacked ? "rebase" : "update"];
|
|
58
|
+
if (s.ciPending) return s.autoMergeAllowed ? ["automerge"] : [];
|
|
59
|
+
return ["merge"];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// A stale draft offers Refresh and Close instead of Rebase [PRS-07]; a healthy one, Ready for review [PRS-11].
|
|
63
|
+
function draftActions(s: PrState): ActionId[] {
|
|
64
|
+
if (s.stale) return ["refresh", "close"];
|
|
65
|
+
if (s.blocked) return ["rebase"];
|
|
66
|
+
if (s.ciFailing) return ["fix", "rerun"];
|
|
67
|
+
return ["ready"];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const PR_RULES: Rules<PrState> = {
|
|
71
|
+
reply: { when: (s) => !!s.waiting, actions: (s) => replyActions(s.waiting) },
|
|
72
|
+
answered: { when: (s) => !!s.answer, actions: (s) => replyActions(s.answer) },
|
|
73
|
+
// Rerun is for flaky checks, without an agent [PRS-09].
|
|
74
|
+
ci: { when: (s) => !s.draft && s.ciFailing, actions: () => ["fix", "rerun"] },
|
|
75
|
+
changes: { when: (s) => !s.draft && s.changes, actions: () => ["address"] },
|
|
76
|
+
// Auto-merge waiting on CI leaves nothing for me to do.
|
|
77
|
+
ready: { when: (s) => !s.draft && s.approved && !s.conflicts && !s.ciFailing && !s.changes && !(s.autoMerge && s.ciPending), actions: readyActions },
|
|
78
|
+
upstream: { when: (s) => !s.draft && s.blocked, actions: () => ["rebase"] },
|
|
79
|
+
// After too long it's mine to nudge [ATT-11].
|
|
80
|
+
too_long: { when: (s) => !s.draft && s.asked && s.tooLong, label: waitingFor },
|
|
81
|
+
// Mine until I ask someone, even while CI runs. Merge, for repos where nobody reviews, once CI passed on the current base [PRS-12, PRS-04].
|
|
82
|
+
needs_reviewer: {
|
|
83
|
+
when: (s) => !s.draft && !s.asked,
|
|
84
|
+
actions: (s) => (!s.ciFailing && !s.ciPending && s.behindBy === 0 ? ["request_review", "merge"] : ["request_review"]),
|
|
85
|
+
},
|
|
86
|
+
drafts: { when: (s) => s.draft, actions: draftActions },
|
|
87
|
+
// Otherwise it waits on others: CI, the reviewer after my reply, or a review [WAI-01].
|
|
88
|
+
wait_review: { when: (s) => !s.draft && s.asked && !s.ciPending && !s.replied, label: waitingFor },
|
|
89
|
+
wait_reviewer: { when: (s) => !s.draft && s.asked && !s.ciPending && s.replied, label: waitingFor },
|
|
90
|
+
wait_ci: { when: (s) => !s.draft && s.asked && s.ciPending, label: waitingFor },
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// ---- Issues and others' PRs I'm in [WAI-01, ATT-16] ----
|
|
94
|
+
|
|
95
|
+
export interface IssueState {
|
|
96
|
+
// I opened it.
|
|
97
|
+
authored: boolean;
|
|
98
|
+
// I follow threads I've commented on, so replies there count without a tag: the followThreads setting [ATT-17].
|
|
99
|
+
follow: boolean;
|
|
100
|
+
// My comment is the last one from a person; bots don't count [MEN-05].
|
|
101
|
+
mineLast: boolean;
|
|
102
|
+
// A person commented after me (or after I opened it) within mentionDays, and I haven't 👍'd it [MEN-02].
|
|
103
|
+
answered: boolean;
|
|
104
|
+
// My last comment is within mentionDays.
|
|
105
|
+
fresh: boolean;
|
|
106
|
+
// My last comment is at least waitingTooLongDays old.
|
|
107
|
+
tooLong: boolean;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// An issue may match none, and then isn't listed: an answer I 👍'd needs nothing more, nor an old thread of someone else's.
|
|
111
|
+
// Mentions come first, through their own search [MEN-01].
|
|
112
|
+
export const ISSUE_RULES: Rules<IssueState> = {
|
|
113
|
+
// A recent comment after mine, without mentioning me: mine until I reply, 👍 it or dismiss it [ATT-16].
|
|
114
|
+
// On someone else's thread only when I've allowed replies without a tag [ATT-17].
|
|
115
|
+
answered: { when: (s) => s.answered && (s.authored || s.follow) },
|
|
116
|
+
// Nobody answered for too long: mine to nudge. On my own issues however long ago, on others' only while fresh [ATT-11].
|
|
117
|
+
too_long: { when: (s) => s.mineLast && (s.authored || s.fresh) && s.tooLong, label: () => "waiting for an answer" },
|
|
118
|
+
wait_answer: { when: (s) => s.mineLast && (s.authored || s.fresh) },
|
|
119
|
+
};
|
package/server/service.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Attention, AttentionView, FeedId, FeedStatus, Item } from "../shared/attention";
|
|
1
|
+
import type { Attention, AttentionView, FeedId, FeedStatus, Item, Reviewer } from "../shared/attention";
|
|
2
2
|
import type { PluginHandlerContext } from "@getpaseo/plugin/server";
|
|
3
3
|
import { AttentionConfig, githubRepoOf } from "../shared/config";
|
|
4
4
|
import { classify, classifyHistory } from "./classify";
|
|
@@ -6,7 +6,7 @@ import { FIXTURE, graphql } from "./gh";
|
|
|
6
6
|
import { fixture, FIXTURE_AGENTS } from "./fixture";
|
|
7
7
|
import type { Details, HistoryResult, LiveResult } from "./github-types";
|
|
8
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";
|
|
9
|
+
import { loadConfig, loadState, moveOldFiles, saveCodeRepo, saveCoverage, saveFollowThreads, saveNextUpSources, saveState, State } from "./store";
|
|
10
10
|
import { applyPending, buildView, doneItem, type Effect, isPending, SETTLE_MS } 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.
|
|
@@ -106,6 +106,12 @@ export class AttentionService {
|
|
|
106
106
|
await this.refresh("live").catch(() => {});
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
// Replies on others' threads without a tag [ATT-17]. Only the live feed has them.
|
|
110
|
+
async setFollowThreads(on: boolean): Promise<void> {
|
|
111
|
+
this.config = await saveFollowThreads(on);
|
|
112
|
+
await this.refresh("live").catch(() => {});
|
|
113
|
+
}
|
|
114
|
+
|
|
109
115
|
async setScopes(scopes: string[]): Promise<void> {
|
|
110
116
|
this.state.scopes = scopes;
|
|
111
117
|
await this.save();
|
|
@@ -116,6 +122,12 @@ export class AttentionService {
|
|
|
116
122
|
await this.save();
|
|
117
123
|
}
|
|
118
124
|
|
|
125
|
+
// Who reviewed or was asked on my PRs in a repo, from the last fetch, and who I am [PRS-12].
|
|
126
|
+
reviewers(repo: string): { recent: Reviewer[]; login: string | null } {
|
|
127
|
+
const live = this.state.live?.attention;
|
|
128
|
+
return { recent: live?.reviewers?.[repo] ?? [], login: live?.login ?? null };
|
|
129
|
+
}
|
|
130
|
+
|
|
119
131
|
// A change on GitHub from one tap [SAFE-01], answered with the list as it is after it.
|
|
120
132
|
// GitHub's search takes seconds to show it, so its effect shows until a fetch can [FRESH-02]; no change (Undo) clears it.
|
|
121
133
|
async act(key: string, work: () => Promise<void>, change: Change): Promise<AttentionView> {
|
|
@@ -228,7 +240,7 @@ export class AttentionService {
|
|
|
228
240
|
};
|
|
229
241
|
const merge = (parts: Partial<LiveResult>[]) => Object.assign({}, ...parts) as LiveResult;
|
|
230
242
|
const forDetails = Promise.all([search("mine"), search("assigned"), searchUnclaimed()]);
|
|
231
|
-
const others = Promise.all([search("reviews"), search("mentions"), search("
|
|
243
|
+
const others = Promise.all([search("reviews"), search("mentions"), search("involved"), search("asked")]);
|
|
232
244
|
const afterThem = forDetails.then((parts) => this.details(merge(parts)));
|
|
233
245
|
const [first, rest, details] = await Promise.all([forDetails, others, afterThem]);
|
|
234
246
|
return { data: merge([...first, ...rest]), details };
|
package/server/setup.ts
CHANGED
|
@@ -21,10 +21,10 @@ async function ghStatus(): Promise<SetupStatus["gh"]> {
|
|
|
21
21
|
|
|
22
22
|
export async function configStatus(): Promise<ConfigStatus> {
|
|
23
23
|
try {
|
|
24
|
-
const { orgs, repos, nextUp } = await loadConfig();
|
|
25
|
-
return { error: null, orgs, repos, nextUp: { mine: nextUp.mine, orgs: nextUp.orgs, repos: nextUp.repos } };
|
|
24
|
+
const { orgs, repos, nextUp, followThreads } = await loadConfig();
|
|
25
|
+
return { error: null, orgs, repos, nextUp: { mine: nextUp.mine, orgs: nextUp.orgs, repos: nextUp.repos }, followThreads };
|
|
26
26
|
} catch (error) {
|
|
27
|
-
return { error: (error as Error).message, orgs: [], repos: [], nextUp: { mine: false, orgs: [], repos: [] } };
|
|
27
|
+
return { error: (error as Error).message, orgs: [], repos: [], nextUp: { mine: false, orgs: [], repos: [] }, followThreads: false };
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
package/server/store.ts
CHANGED
|
@@ -84,6 +84,11 @@ export function saveNextUpSources(sources: Pick<AttentionConfig["nextUp"], "mine
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
// Whether replies on others' threads count without a tag, from settings [ATT-17].
|
|
88
|
+
export function saveFollowThreads(followThreads: boolean): Promise<AttentionConfig> {
|
|
89
|
+
return updateConfig((file) => ({ ...file, followThreads }));
|
|
90
|
+
}
|
|
91
|
+
|
|
87
92
|
// What the screen writes changes only its own keys; everything else in the file is kept as it is.
|
|
88
93
|
// A file that doesn't read or parse is left alone.
|
|
89
94
|
async function updateConfig(change: (file: Record<string, unknown>) => Record<string, unknown>): Promise<AttentionConfig> {
|
package/shared/attention.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AttentionConfig, MergeMethod } from "./config";
|
|
1
|
+
import type { AttentionConfig, MergeMethod, SessionKind } from "./config";
|
|
2
2
|
|
|
3
3
|
// Tabs tell the story of my work: what I finished, what needs me, what waits on others, what's next.
|
|
4
4
|
export type TabId = "history" | "doing" | "waiting" | "next";
|
|
@@ -7,15 +7,20 @@ export type TabId = "history" | "doing" | "waiting" | "next";
|
|
|
7
7
|
export type FeedId = "live" | "history";
|
|
8
8
|
export const TAB_FEED: Record<TabId, FeedId> = { history: "history", doing: "live", waiting: "live", next: "live" };
|
|
9
9
|
|
|
10
|
-
// Within a tab, top to bottom
|
|
10
|
+
// Within a tab, top to bottom. The order is also the priority: an item appears once, under the first section whose rule
|
|
11
|
+
// holds, its most urgent reason [ATT-02]. Moving a line here changes which section wins.
|
|
11
12
|
export const SECTIONS = {
|
|
12
13
|
reply: { tab: "doing", title: "Waiting for your reply" },
|
|
14
|
+
// Someone answered my question without mentioning me [ATT-16].
|
|
15
|
+
answered: { tab: "doing", title: "Answered" },
|
|
13
16
|
review: { tab: "doing", title: "Review requested" },
|
|
14
17
|
ci: { tab: "doing", title: "CI failing" },
|
|
15
18
|
changes: { tab: "doing", title: "Changes requested" },
|
|
16
19
|
ready: { tab: "doing", title: "Ready to merge" },
|
|
17
20
|
upstream: { tab: "doing", title: "Needs upstream" },
|
|
18
21
|
too_long: { tab: "doing", title: "Waiting too long" },
|
|
22
|
+
// Nobody has the next move until I ask someone [PRS-12].
|
|
23
|
+
needs_reviewer: { tab: "doing", title: "Needs a reviewer" },
|
|
19
24
|
drafts: { tab: "doing", title: "My drafts" },
|
|
20
25
|
// [WAI-01]
|
|
21
26
|
wait_review: { tab: "waiting", title: "Waiting for review" },
|
|
@@ -41,6 +46,7 @@ export type ActionId =
|
|
|
41
46
|
| "rebase"
|
|
42
47
|
| "refresh"
|
|
43
48
|
| "ready"
|
|
49
|
+
| "request_review"
|
|
44
50
|
| "automerge"
|
|
45
51
|
| "merge"
|
|
46
52
|
| "close"
|
|
@@ -75,6 +81,24 @@ export interface WaitingComment {
|
|
|
75
81
|
url?: string;
|
|
76
82
|
}
|
|
77
83
|
|
|
84
|
+
// Someone who can be asked to review: a person, or a team as "org/slug" [PRS-12].
|
|
85
|
+
export interface Reviewer {
|
|
86
|
+
login: string;
|
|
87
|
+
avatarUrl?: string;
|
|
88
|
+
team: boolean;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// What the reviewer picker offers, fetched when it opens [PRS-12, GH-01].
|
|
92
|
+
export interface ReviewerChoices {
|
|
93
|
+
// GitHub's suggestions, from who touched the changed code.
|
|
94
|
+
suggested: Reviewer[];
|
|
95
|
+
// Who reviewed or was asked on my other PRs in the repo.
|
|
96
|
+
recent: Reviewer[];
|
|
97
|
+
teams: Reviewer[];
|
|
98
|
+
// Why teams are missing, when GitHub wouldn't list them.
|
|
99
|
+
teamsNote?: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
78
102
|
// GitHub's reasons for closing an issue that Next up offers [NXT-11].
|
|
79
103
|
export type IssueCloseReason = "completed" | "not_planned";
|
|
80
104
|
|
|
@@ -175,6 +199,8 @@ export interface Attention {
|
|
|
175
199
|
assigned: NextUpIssue[];
|
|
176
200
|
unclaimed: NextUpIssue[];
|
|
177
201
|
unclaimedFrom?: UnclaimedSource;
|
|
202
|
+
// Repo -> who reviewed or was asked on my PRs there, latest first, for the reviewer picker [PRS-12].
|
|
203
|
+
reviewers?: Record<string, Reviewer[]>;
|
|
178
204
|
}
|
|
179
205
|
|
|
180
206
|
export interface Section {
|
|
@@ -188,6 +214,8 @@ export interface AgentSummary {
|
|
|
188
214
|
id: string;
|
|
189
215
|
// The item it was started on: an issue or a PR.
|
|
190
216
|
itemKey: string;
|
|
217
|
+
// The action it was started for; sessions started before kinds were saved have none.
|
|
218
|
+
kind?: SessionKind;
|
|
191
219
|
status: string;
|
|
192
220
|
requiresAttention: boolean;
|
|
193
221
|
title: string | null;
|
|
@@ -209,6 +237,12 @@ export function matchSessions(agents: AgentSummary[], keys: string[]): AgentSumm
|
|
|
209
237
|
.sort((a, b) => Number(b.requiresAttention) - Number(a.requiresAttention) || (b.lastActivityAt ?? "").localeCompare(a.lastActivityAt ?? ""));
|
|
210
238
|
}
|
|
211
239
|
|
|
240
|
+
// Sessions none of the item's actions would have started: no kind saved, or the action's gone, like Fix CI once checks pass.
|
|
241
|
+
// They lead the sheet; the rest sit in their action's line [SES-03].
|
|
242
|
+
export function looseSessions(sessions: AgentSummary[], kinds: SessionKind[]): AgentSummary[] {
|
|
243
|
+
return sessions.filter((agent) => !agent.kind || !kinds.includes(agent.kind));
|
|
244
|
+
}
|
|
245
|
+
|
|
212
246
|
export interface FeedStatus {
|
|
213
247
|
fetchedAt: string | null;
|
|
214
248
|
refreshing: boolean;
|
package/shared/config.ts
CHANGED
|
@@ -36,6 +36,9 @@ export const AttentionConfig = z.object({
|
|
|
36
36
|
refreshMinutes: z.number().min(5).default(15),
|
|
37
37
|
staleDraftDays: z.number().positive().default(30),
|
|
38
38
|
mentionDays: z.number().positive().default(30),
|
|
39
|
+
// Follow threads I've commented on: a recent reply after mine on someone else's thread shows without a tag.
|
|
40
|
+
// Off: only my own threads and mentions [ATT-17].
|
|
41
|
+
followThreads: z.boolean().default(false),
|
|
39
42
|
// How many weeks History shows [HIS-01].
|
|
40
43
|
historyWeeks: z.number().int().positive().default(4),
|
|
41
44
|
// Unclaimed issues to pick from [NXT-04]. With no sources chosen, Next up looks in `orgs` and `repos` [NXT-08].
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Feedback to the Attention Span project, from the screen [FB-01].
|
|
2
|
+
// Built in on purpose: these prompts carry the rules about privacy, where it's filed and approval,
|
|
3
|
+
// so config.json can't replace them the way it can the session templates.
|
|
4
|
+
|
|
5
|
+
export const FEEDBACK_REPO = "andrioid/paseo-attention-span";
|
|
6
|
+
|
|
7
|
+
export interface FeedbackInfo {
|
|
8
|
+
// The plugin's own source, where a feedback session runs read-only; the home directory when it can't be found.
|
|
9
|
+
cwd: string;
|
|
10
|
+
hasSource: boolean;
|
|
11
|
+
version: string | null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type FeedbackKind = "problem" | "idea";
|
|
15
|
+
|
|
16
|
+
// The item label of a feedback session, so the line shows Continue while one is open [SES-03].
|
|
17
|
+
export const feedbackItemKey = (kind: FeedbackKind) => `feedback:${kind}`;
|
|
18
|
+
|
|
19
|
+
export interface FeedbackContext {
|
|
20
|
+
message: string;
|
|
21
|
+
// The plugin's source on this host, where the session runs, and its version.
|
|
22
|
+
dir: string | null;
|
|
23
|
+
version: string | null;
|
|
24
|
+
device: "phone" | "desktop";
|
|
25
|
+
platform: string;
|
|
26
|
+
theme: "dark" | "light";
|
|
27
|
+
tab: string;
|
|
28
|
+
// The last refresh's error, if it failed.
|
|
29
|
+
refreshError: string | null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const SHARED = `You're helping a user of Attention Span, a Paseo plugin, give feedback to its maintainers in ${FEEDBACK_REPO}.
|
|
33
|
+
|
|
34
|
+
They wrote:
|
|
35
|
+
> {{message}}
|
|
36
|
+
|
|
37
|
+
Context: {{context}}
|
|
38
|
+
|
|
39
|
+
How to work:
|
|
40
|
+
- {{where}} Do not edit any file.
|
|
41
|
+
- Reply in the language they write in. Write the post in English, in their voice ("I …").
|
|
42
|
+
- Ask one question at a time, and only what the checklist below still needs. Offer likely answers when you can. After about five questions, draft with what you have and say what's missing.
|
|
43
|
+
- Read requirements.yaml, docs/architecture.md and the code to understand what they describe. Find the Paseo version with \`paseo --version\`.
|
|
44
|
+
- You may read ~/.config/paseo-attention-span/config.json and state.json, and look items up with gh, to diagnose. Nothing from them goes in the post: no repository names, titles or logins they didn't write themselves.
|
|
45
|
+
- Search open issues and discussions in ${FEEDBACK_REPO} (\`gh issue list --repo ${FEEDBACK_REPO} --search …\`, and \`gh api graphql\` with \`search(type: DISCUSSION, query: "repo:${FEEDBACK_REPO} …")\`). If one matches, give its link and stop. Don't comment or react on it.
|
|
46
|
+
|
|
47
|
+
Where it goes: an issue if a maintainer could finish it and close it. Otherwise a discussion: Q&A for questions and for bugs nobody can reproduce yet, Ideas for broad or contested ideas. Say which and why; they may override it.
|
|
48
|
+
|
|
49
|
+
Keep posts skimmable: a few short lines up front, and anything longer (environment, logs, error text, likely cause, background) in a collapsed \`<details><summary>…</summary>\` block.
|
|
50
|
+
|
|
51
|
+
Show the whole draft, title included, then ask with your question tool: Post it / Change something / Cancel. Without a question tool, ask in plain text and post only after they reply "post". If you're in a plan or read-only mode, leave it only to post.
|
|
52
|
+
- Issue: \`gh issue create --repo ${FEEDBACK_REPO} --title … --body-file …\`, with the body in a temporary file outside this directory.
|
|
53
|
+
- Discussion: look up the repository ID and the category by its slug (\`ideas\` or \`q-a\`) with \`gh api graphql\` (\`repository { id discussionCategories { nodes { id slug } } }\`), then call the \`createDiscussion\` mutation.
|
|
54
|
+
|
|
55
|
+
Reply with the link, then archive this session with Paseo's archive_agent tool if you have it.`;
|
|
56
|
+
|
|
57
|
+
const PROBLEM = `This is a problem. Work out which kind it is, then cover its checklist:
|
|
58
|
+
- Broken: what they did, step by step; what they expected; what happened, with any error text; every time or only sometimes.
|
|
59
|
+
- Wrong list (something shows where it shouldn't, or doesn't show): the item's link, which list it's in and which they expected. Find the rule that put it there and say whether it's a bug, by design (cite the requirement ID) or a gap.
|
|
60
|
+
- Confusing: what was unclear, and where. Answer it first. Post only if the screen or docs should explain it better, or they want the answer public in Q&A.
|
|
61
|
+
|
|
62
|
+
Issue: title "Bug: <what goes wrong>", under 70 characters. Body: ## What happens (two or three lines), ## Steps, ## Expected, then collapsed blocks for Environment (versions, phone or desktop, theme) and, only if you found it, Likely cause (file:line, marked as a guess). Under about 150 words outside the collapsed blocks.`;
|
|
63
|
+
|
|
64
|
+
const IDEA = `This is an idea. Cover: what they're trying to do; how they do it today; why the current screen doesn't get them there. Check it against requirements.yaml: is it there already, deferred, a non-goal, or overlapping an ID?
|
|
65
|
+
|
|
66
|
+
Issue: a title in their words. Body: one short paragraph on why, then "Proposed requirement:" with one line in requirements.yaml's style (\`XXX-NN: <observable capability>; so that <value>.\`), then "Related: <IDs>". Put anything longer, like how they do it today, in a collapsed block.
|
|
67
|
+
Discussion: the title as a question or proposal, 2–4 short paragraphs, ending with the open question.`;
|
|
68
|
+
|
|
69
|
+
export function feedbackPrompt(kind: FeedbackKind, input: FeedbackContext): string {
|
|
70
|
+
const facts = [
|
|
71
|
+
`Attention Span ${input.version ?? "(version unknown)"}`,
|
|
72
|
+
`${input.device} (${input.platform})`,
|
|
73
|
+
`${input.theme} theme`,
|
|
74
|
+
`opened from the ${input.tab} tab`,
|
|
75
|
+
input.refreshError ? `the last refresh failed: ${input.refreshError}` : null,
|
|
76
|
+
].filter(Boolean);
|
|
77
|
+
const where = input.dir
|
|
78
|
+
? `You are in the plugin's installed source, read-only.`
|
|
79
|
+
: `The plugin's source isn't on this host: read it from GitHub with \`gh api repos/${FEEDBACK_REPO}/contents/<path>\`.`;
|
|
80
|
+
const values: Record<string, string> = { message: input.message.trim().replace(/\n/g, "\n> "), context: `${facts.join(", ")}.`, where };
|
|
81
|
+
const shared = SHARED.replace(/\{\{(\w+)\}\}/g, (match, name: string) => values[name] ?? match);
|
|
82
|
+
return `${shared}\n\n${kind === "problem" ? PROBLEM : IDEA}`;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// A theme only comes as colors, so dark or light is read off the background.
|
|
86
|
+
export function themeName(background: string): "dark" | "light" {
|
|
87
|
+
const hex = background.replace("#", "");
|
|
88
|
+
if (!/^[0-9a-f]{6}/i.test(hex)) return "dark";
|
|
89
|
+
const [r, g, b] = [0, 2, 4].map((at) => parseInt(hex.slice(at, at + 2), 16));
|
|
90
|
+
return 0.299 * r + 0.587 * g + 0.114 * b < 128 ? "dark" : "light";
|
|
91
|
+
}
|