@andrioid/paseo-attention-span 0.4.9 → 0.4.10
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 -1
- package/client/attention-screen.tsx +33 -17
- package/client/card.tsx +31 -8
- package/client/coverage-settings.tsx +36 -1
- package/client/entity.tsx +118 -0
- package/client/feedback.tsx +2 -2
- package/client/icons.ts +5 -0
- package/client/next-up.tsx +145 -74
- package/client/sheet.tsx +91 -10
- package/client/ui.tsx +97 -6
- package/docs/architecture.md +12 -6
- 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.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-waiting-too-long.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.server.ts +2 -0
- package/package.json +1 -1
- package/requirements.yaml +4 -2
- package/server/classify.ts +56 -12
- package/server/details.ts +3 -2
- package/server/fixture.ts +33 -9
- package/server/gh.ts +29 -12
- package/server/github-types.ts +19 -2
- package/server/projects.ts +47 -0
- package/server/queries.ts +41 -6
- package/server/service.ts +138 -22
- package/server/store.ts +2 -0
- package/server/view.ts +2 -0
- package/shared/attention.ts +57 -0
- package/shared/opening.ts +31 -0
- package/shared/rpc.ts +5 -1
package/client/next-up.tsx
CHANGED
|
@@ -2,15 +2,26 @@ import { openExternalUrl } from "@getpaseo/plugin/client";
|
|
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
|
3
3
|
import { useMemo, useState } from "react";
|
|
4
4
|
import { Pressable, Text, View } from "react-native";
|
|
5
|
-
import { ago
|
|
6
|
-
import {
|
|
5
|
+
import { ago } from "../shared/format";
|
|
6
|
+
import {
|
|
7
|
+
type AgentSummary,
|
|
8
|
+
type Chip,
|
|
9
|
+
type GithubColor,
|
|
10
|
+
type IssueCloseReason,
|
|
11
|
+
matchSessions,
|
|
12
|
+
type NextUpIssue,
|
|
13
|
+
type ProjectInfo,
|
|
14
|
+
projectFilterId,
|
|
15
|
+
projectFilterIds,
|
|
16
|
+
type UnclaimedSource,
|
|
17
|
+
} from "../shared/attention";
|
|
7
18
|
import type { NextUpSource } from "../shared/config";
|
|
8
19
|
import type { IconName } from "./icons";
|
|
9
20
|
import type { FetchDetails } from "./attention-screen";
|
|
10
21
|
import { CardList, CardRow, type Tone } from "./card";
|
|
11
22
|
import { sessionEntry, startAnotherEntry } from "./session-menu";
|
|
12
|
-
import { ActionSheet, DetailLines, type SheetEntry } from "./sheet";
|
|
13
|
-
import {
|
|
23
|
+
import { ActionSheet, DETAILS_STALE_MS, DetailLines, type DetailsQuery, detailsKey, Modal, type SheetEntry, useSheetOpener } from "./sheet";
|
|
24
|
+
import { githubColor, IssuePills, PlaceText } from "./entity";
|
|
14
25
|
import { Button, KeepStyles, Meta, SectionHeader, TablerIcon, useHover, useStyles } from "./ui";
|
|
15
26
|
|
|
16
27
|
const TYPE_ICONS: Record<string, IconName> = { bug: "bug", feature: "feature", debt: "debt", task: "task", epic: "epic" };
|
|
@@ -24,8 +35,11 @@ interface Props {
|
|
|
24
35
|
// Where Next up looks, and the sources I ticked; none means all [NXT-09].
|
|
25
36
|
sources: NextUpSource[];
|
|
26
37
|
selectedSources: string[];
|
|
27
|
-
//
|
|
28
|
-
|
|
38
|
+
// The projects Next up's issues are on, and the statuses I ticked; none means all [NXT-03, NXT-12].
|
|
39
|
+
projects: ProjectInfo[];
|
|
40
|
+
selectedProjects: string[];
|
|
41
|
+
// Change any filter or all at once, so Clear empties them in one go.
|
|
42
|
+
onFilter: (change: FilterChange) => void;
|
|
29
43
|
agents: AgentSummary[];
|
|
30
44
|
// Mine, so my repos show without the owner.
|
|
31
45
|
login: string | null;
|
|
@@ -41,26 +55,57 @@ interface Props {
|
|
|
41
55
|
onOpenAgent: (agentId: string) => void;
|
|
42
56
|
}
|
|
43
57
|
|
|
44
|
-
type
|
|
58
|
+
type FilterChange = { scopes?: string[]; sources?: string[]; projectFilter?: string[] };
|
|
59
|
+
|
|
60
|
+
type RowProps = Omit<Props, "assigned" | "unclaimed" | "unclaimedFrom" | "selected" | "sources" | "selectedSources" | "projects" | "selectedProjects" | "onFilter">;
|
|
45
61
|
|
|
46
62
|
// Assigned issues first [NXT-06], then unclaimed ones [NXT-01]; both already ranked by the server [NXT-02].
|
|
47
|
-
export function NextUpList({ assigned, unclaimed, unclaimedFrom, selected, sources, selectedSources, onFilter, ...rowProps }: Props) {
|
|
63
|
+
export function NextUpList({ assigned, unclaimed, unclaimedFrom, selected, sources, selectedSources, projects, selectedProjects, onFilter, ...rowProps }: Props) {
|
|
48
64
|
const styles = useStyles();
|
|
49
65
|
const scopes = useMemo(() => [...new Set(unclaimed.map((issue) => issue.scope).filter((scope): scope is string => !!scope))].sort(), [unclaimed]);
|
|
50
66
|
// Filter by the scopes I picked last time [NXT-03]; a picked scope with no issues left is ignored.
|
|
51
67
|
const active = selected.filter((scope) => scopes.includes(scope));
|
|
52
68
|
// And by source, when there's more than one [NXT-09]; a picked source no longer in settings is ignored.
|
|
53
69
|
const activeSources = sources.length > 1 ? selectedSources.filter((id) => sources.some((source) => source.id === id)) : [];
|
|
70
|
+
// And by project and status [NXT-03, NXT-12]; a picked status no longer offered is ignored.
|
|
71
|
+
const tree = useMemo(() => projectTree(unclaimed, projects), [unclaimed, projects]);
|
|
72
|
+
const leaves = tree.flatMap((node) => node.children.map((child) => child.id));
|
|
73
|
+
const activeProjects = selectedProjects.filter((id) => leaves.includes(id));
|
|
54
74
|
const shown = unclaimed.filter(
|
|
55
|
-
(issue) =>
|
|
75
|
+
(issue) =>
|
|
76
|
+
(active.length === 0 || (issue.scope && active.includes(issue.scope))) &&
|
|
77
|
+
(activeSources.length === 0 || issue.sources.some((id) => activeSources.includes(id))) &&
|
|
78
|
+
(activeProjects.length === 0 || projectFilterIds(issue).some((id) => activeProjects.includes(id))),
|
|
56
79
|
);
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
80
|
+
const flip = (list: string[], id: string) => (list.includes(id) ? list.filter((other) => other !== id) : [...list, id]);
|
|
81
|
+
const toggle = (scope: string) => onFilter({ scopes: flip(active, scope) });
|
|
82
|
+
const toggleSource = (id: string) => onFilter({ sources: flip(activeSources, id) });
|
|
83
|
+
// A project ticks or clears all its statuses at once; partly ticked, it clears them.
|
|
84
|
+
const toggleProject = (id: string) => {
|
|
85
|
+
const children = tree.find((node) => node.id === id)?.children.map((child) => child.id);
|
|
86
|
+
if (!children) return onFilter({ projectFilter: flip(activeProjects, id) });
|
|
87
|
+
const any = children.some((child) => activeProjects.includes(child));
|
|
88
|
+
onFilter({ projectFilter: any ? activeProjects.filter((other) => !children.includes(other)) : [...activeProjects, ...children] });
|
|
89
|
+
};
|
|
90
|
+
const narrowedBy = [activeSources.length ? "sources" : null, activeProjects.length ? "projects" : null, active.length ? "scopes" : null].filter(Boolean);
|
|
60
91
|
const [filtering, setFiltering] = useState(false);
|
|
61
|
-
|
|
92
|
+
// A project ticked whole counts once.
|
|
93
|
+
const projectsPicked = tree.reduce((sum, node) => {
|
|
94
|
+
const on = node.children.filter((child) => activeProjects.includes(child.id)).length;
|
|
95
|
+
return sum + (on === node.children.length ? 1 : on);
|
|
96
|
+
}, 0);
|
|
97
|
+
const picked = active.length + activeSources.length + projectsPicked;
|
|
98
|
+
const projectOptions: FilterOption[] = tree.flatMap((node) => {
|
|
99
|
+
if (node.children.length === 1 && node.children[0].id === node.id) return [{ id: node.id, label: node.title }];
|
|
100
|
+
const on = node.children.filter((child) => activeProjects.includes(child.id)).length;
|
|
101
|
+
return [
|
|
102
|
+
{ id: node.id, label: node.title, strong: true, state: on === 0 ? "off" : on === node.children.length ? "on" : "partial" },
|
|
103
|
+
...node.children.map((child) => ({ ...child, indent: true })),
|
|
104
|
+
];
|
|
105
|
+
});
|
|
62
106
|
const groups: FilterGroup[] = [
|
|
63
107
|
...(sources.length > 1 ? [{ title: "Source", options: sources, active: activeSources, onToggle: toggleSource }] : []),
|
|
108
|
+
...(projectOptions.length > 0 ? [{ title: "Project", options: projectOptions, active: activeProjects, onToggle: toggleProject }] : []),
|
|
64
109
|
...(scopes.length > 0 ? [{ title: "Scope", options: scopes.map((scope) => ({ id: scope, label: scope })), active, onToggle: toggle }] : []),
|
|
65
110
|
];
|
|
66
111
|
|
|
@@ -92,14 +137,14 @@ export function NextUpList({ assigned, unclaimed, unclaimedFrom, selected, sourc
|
|
|
92
137
|
{filtering ? (
|
|
93
138
|
<FilterSheet
|
|
94
139
|
groups={groups}
|
|
95
|
-
onClear={() => onFilter({ scopes: [], sources: [] })}
|
|
140
|
+
onClear={() => onFilter({ scopes: [], sources: [], projectFilter: [] })}
|
|
96
141
|
onClose={() => setFiltering(false)}
|
|
97
142
|
/>
|
|
98
143
|
) : null}
|
|
99
144
|
{unclaimedFrom === "none" ? (
|
|
100
145
|
<Text style={styles.text}>No repos to look in. Register a project in Paseo, or choose where Next up looks in Settings.</Text>
|
|
101
146
|
) : shown.length === 0 ? (
|
|
102
|
-
<Text style={styles.text}>No unclaimed issues{narrowedBy ? ` in these ${narrowedBy}` : ""}.</Text>
|
|
147
|
+
<Text style={styles.text}>No unclaimed issues{narrowedBy.length ? ` in these ${narrowedBy.join(" and ")}` : ""}.</Text>
|
|
103
148
|
) : (
|
|
104
149
|
<IssueList issues={shown} claim {...rowProps} />
|
|
105
150
|
)}
|
|
@@ -108,7 +153,38 @@ export function NextUpList({ assigned, unclaimed, unclaimedFrom, selected, sourc
|
|
|
108
153
|
);
|
|
109
154
|
}
|
|
110
155
|
|
|
111
|
-
//
|
|
156
|
+
// A project in the filter with its statuses under it, all of them in the board's order, dimmed where no unclaimed issue has
|
|
157
|
+
// one; "No status" where some issue on it has none, and "No project" last, where some issue is on none [NXT-03, NXT-12].
|
|
158
|
+
// Only projects the unclaimed issues are on; none at all when projects can't be read.
|
|
159
|
+
interface ProjectNode {
|
|
160
|
+
id: string;
|
|
161
|
+
title: string;
|
|
162
|
+
children: FilterOption[];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function projectTree(unclaimed: NextUpIssue[], projects: ProjectInfo[]): ProjectNode[] {
|
|
166
|
+
if (!unclaimed.some((issue) => issue.projects)) return [];
|
|
167
|
+
const on = (project: ProjectInfo) => unclaimed.flatMap((issue) => (issue.projects ?? []).filter((p) => p.id === project.id));
|
|
168
|
+
const nodes: ProjectNode[] = projects.flatMap((project) => {
|
|
169
|
+
const items = on(project);
|
|
170
|
+
if (items.length === 0) return [];
|
|
171
|
+
const statuses = project.statuses.map((status) => ({
|
|
172
|
+
id: projectFilterId(project, status.name),
|
|
173
|
+
label: status.name,
|
|
174
|
+
color: status.color,
|
|
175
|
+
dim: !items.some((item) => item.status === status.name),
|
|
176
|
+
}));
|
|
177
|
+
// A status the board no longer offers still filters, after the board's own.
|
|
178
|
+
const gone = [...new Set(items.map((item) => item.status).filter((name): name is string => !!name && !project.statuses.some((s) => s.name === name)))];
|
|
179
|
+
const none = items.some((item) => !item.status) ? [{ id: projectFilterId(project, null), label: "No status" }] : [];
|
|
180
|
+
return [{ id: project.id, title: project.title, children: [...statuses, ...gone.map((name) => ({ id: projectFilterId(project, name), label: name })), ...none] }];
|
|
181
|
+
});
|
|
182
|
+
const loose = unclaimed.some((issue) => issue.projects && issue.projects.length === 0);
|
|
183
|
+
const noProject = projectFilterId(null);
|
|
184
|
+
return loose ? [...nodes, { id: noProject, title: "No project", children: [{ id: noProject, label: "No project" }] }] : nodes;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Source, project and scope filters behind one button, so they take no room above the list [NXT-03, NXT-09].
|
|
112
188
|
// Ticks apply right away; a bottom sheet on phones, a dialog on desktop.
|
|
113
189
|
function FilterSheet({ groups, onClear, onClose }: { groups: FilterGroup[]; onClear: () => void; onClose: () => void }) {
|
|
114
190
|
const styles = useStyles();
|
|
@@ -122,7 +198,13 @@ function FilterSheet({ groups, onClear, onClose }: { groups: FilterGroup[]; onCl
|
|
|
122
198
|
<Text style={styles.muted}>{group.title}</Text>
|
|
123
199
|
<View style={[styles.card, { backgroundColor: styles.c.surface2 }]}>
|
|
124
200
|
{group.options.map((option, index) => (
|
|
125
|
-
<
|
|
201
|
+
<FilterRow
|
|
202
|
+
key={`${option.id}:${option.strong ? "project" : "leaf"}`}
|
|
203
|
+
option={option}
|
|
204
|
+
state={option.state ?? (group.active.includes(option.id) ? "on" : "off")}
|
|
205
|
+
first={index === 0}
|
|
206
|
+
onPress={() => group.onToggle(option.id)}
|
|
207
|
+
/>
|
|
126
208
|
))}
|
|
127
209
|
</View>
|
|
128
210
|
</View>
|
|
@@ -139,30 +221,50 @@ function FilterSheet({ groups, onClear, onClose }: { groups: FilterGroup[]; onCl
|
|
|
139
221
|
|
|
140
222
|
interface FilterGroup {
|
|
141
223
|
title: string;
|
|
142
|
-
options:
|
|
224
|
+
options: FilterOption[];
|
|
143
225
|
active: string[];
|
|
144
226
|
onToggle: (id: string) => void;
|
|
145
227
|
}
|
|
146
228
|
|
|
147
|
-
|
|
229
|
+
interface FilterOption {
|
|
230
|
+
id: string;
|
|
231
|
+
label: string;
|
|
232
|
+
// A project's statuses sit under it, each with its board color.
|
|
233
|
+
indent?: boolean;
|
|
234
|
+
color?: GithubColor;
|
|
235
|
+
// A status no unclaimed issue has right now.
|
|
236
|
+
dim?: boolean;
|
|
237
|
+
// A project, ticked as a whole, partly, or not, by its statuses.
|
|
238
|
+
strong?: boolean;
|
|
239
|
+
state?: "on" | "partial" | "off";
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function FilterRow({ option, state, first, onPress }: { option: FilterOption; state: "on" | "partial" | "off"; first: boolean; onPress: () => void }) {
|
|
148
243
|
const styles = useStyles();
|
|
149
244
|
const { hovered, hover } = useHover();
|
|
245
|
+
const checked = state === "on";
|
|
246
|
+
const color = githubColor(styles, option.color);
|
|
150
247
|
return (
|
|
151
248
|
<Pressable
|
|
152
249
|
accessibilityRole="checkbox"
|
|
153
|
-
accessibilityState={{ checked }}
|
|
154
|
-
aria-checked={checked}
|
|
155
|
-
accessibilityLabel={label}
|
|
250
|
+
accessibilityState={{ checked: state === "partial" ? "mixed" : checked }}
|
|
251
|
+
aria-checked={state === "partial" ? "mixed" : checked}
|
|
252
|
+
accessibilityLabel={option.label}
|
|
156
253
|
onPress={onPress}
|
|
157
254
|
{...hover}
|
|
158
255
|
style={({ pressed }) => [
|
|
159
256
|
styles.row,
|
|
160
|
-
{ paddingVertical: 10,
|
|
257
|
+
{ paddingVertical: 10, paddingRight: 12, paddingLeft: option.indent ? 40 : 12, backgroundColor: pressed || hovered ? styles.c.border : "transparent" },
|
|
161
258
|
first ? null : { borderTopWidth: 1, borderTopColor: styles.c.surface1 },
|
|
162
259
|
]}
|
|
163
260
|
>
|
|
164
|
-
<TablerIcon name={
|
|
165
|
-
|
|
261
|
+
<TablerIcon name={state === "on" ? "squareCheck" : state === "partial" ? "squareMinus" : "square"} size={18} color={state === "off" ? styles.c.foregroundMuted : styles.action} />
|
|
262
|
+
{option.indent ? (
|
|
263
|
+
<View
|
|
264
|
+
style={{ width: 8, height: 8, borderRadius: 4, ...(option.color ? { backgroundColor: color ?? styles.c.foregroundMuted } : { borderWidth: 1.5, borderColor: styles.c.foregroundMuted }) }}
|
|
265
|
+
/>
|
|
266
|
+
) : null}
|
|
267
|
+
<Text style={[styles.text, option.strong ? { fontWeight: "600" } : null, option.dim ? { opacity: 0.45 } : null]}>{option.label}</Text>
|
|
166
268
|
</Pressable>
|
|
167
269
|
);
|
|
168
270
|
}
|
|
@@ -177,14 +279,6 @@ function IssueList({ issues, claim, ...rowProps }: RowProps & { issues: NextUpIs
|
|
|
177
279
|
);
|
|
178
280
|
}
|
|
179
281
|
|
|
180
|
-
// What tells me whether to pick it up: where it lives and how old it is, then priority, effort and scope as tags [NXT-10].
|
|
181
|
-
// The type is the mark. The sheet has the full values.
|
|
182
|
-
const fullFacts = (issue: NextUpIssue) => [
|
|
183
|
-
`${issue.repo}#${issue.number}`,
|
|
184
|
-
`${ago(issue.createdAt)} old`,
|
|
185
|
-
...[issue.type, issue.priority, issue.effort, issue.scope].filter((v): v is string => !!v),
|
|
186
|
-
];
|
|
187
|
-
|
|
188
282
|
// An open PR that closes it means someone may already be on it [NXT-10].
|
|
189
283
|
function prSignal(issue: NextUpIssue): Chip[] {
|
|
190
284
|
const [first, ...more] = issue.openPrs;
|
|
@@ -192,36 +286,10 @@ function prSignal(issue: NextUpIssue): Chip[] {
|
|
|
192
286
|
return [{ text: `PR by ${first.author ?? "someone"}${more.length ? ` +${more.length}` : ""}`, tone: "warn" }];
|
|
193
287
|
}
|
|
194
288
|
|
|
195
|
-
//
|
|
196
|
-
function
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
const tags = [
|
|
200
|
-
issue.priority ? { key: "priority", text: shortValue(issue.priority), color: priorityColor } : null,
|
|
201
|
-
issue.effort ? { key: "effort", text: shortValue(issue.effort) } : null,
|
|
202
|
-
issue.scope ? { key: "scope", text: shortValue(issue.scope) } : null,
|
|
203
|
-
].filter((tag): tag is { key: string; text: string; color?: string } => !!tag);
|
|
204
|
-
if (tags.length === 0) return null;
|
|
205
|
-
return (
|
|
206
|
-
<View style={[styles.wrap, { gap: 4, marginTop: 2 }]}>
|
|
207
|
-
{tags.map((tag) => (
|
|
208
|
-
<Text
|
|
209
|
-
key={tag.key}
|
|
210
|
-
style={{
|
|
211
|
-
fontSize: 11,
|
|
212
|
-
color: tag.color ?? styles.c.foregroundMuted,
|
|
213
|
-
borderWidth: 1,
|
|
214
|
-
borderColor: tag.color ?? styles.c.border,
|
|
215
|
-
borderRadius: 4,
|
|
216
|
-
paddingHorizontal: 5,
|
|
217
|
-
paddingVertical: 1,
|
|
218
|
-
}}
|
|
219
|
-
>
|
|
220
|
-
{tag.text}
|
|
221
|
-
</Text>
|
|
222
|
-
))}
|
|
223
|
-
</View>
|
|
224
|
-
);
|
|
289
|
+
// What an issue's sheet fetches when it opens; its card fetches the same ahead, so the sheet opens complete [ATT-06].
|
|
290
|
+
function issueDetailsQuery(issue: NextUpIssue, fetchDetails: FetchDetails): DetailsQuery {
|
|
291
|
+
const subject = { kind: "issue" as const, repo: issue.repo, number: issue.number };
|
|
292
|
+
return { queryKey: detailsKey(subject, undefined, false), queryFn: () => fetchDetails({ subject, checks: false }) };
|
|
225
293
|
}
|
|
226
294
|
|
|
227
295
|
// The type as the card's mark: red bugs, green features and epics, amber debt, the rest quiet.
|
|
@@ -230,6 +298,8 @@ const TYPE_TONES: Record<string, Tone> = { bug: "bad", feature: "good", epic: "g
|
|
|
230
298
|
// Its main action and ›; tapping it opens the sheet with the description, Claim or Unclaim [ATT-06, NXT-07].
|
|
231
299
|
function IssueRow({ issue, claim, first, agents, login, busy, fetchDetails, onStart, onOptions, onClaim, onCloseIssue, onOpenAgent }: RowProps & { issue: NextUpIssue; claim: boolean; first: boolean }) {
|
|
232
300
|
const [sheet, setSheet] = useState(false);
|
|
301
|
+
// The sheet opens once its details are in; meanwhile › spins [ATT-06].
|
|
302
|
+
const opener = useSheetOpener(issueDetailsQuery(issue, fetchDetails), () => setSheet(true));
|
|
233
303
|
// Closing asks first, with the reason and an optional comment [NXT-11, SAFE-01].
|
|
234
304
|
const [closing, setClosing] = useState(false);
|
|
235
305
|
// An open session leads; without one, Start does [SES-03].
|
|
@@ -243,9 +313,11 @@ function IssueRow({ issue, claim, first, agents, login, busy, fetchDetails, onSt
|
|
|
243
313
|
mark={{ icon: TYPE_ICONS[type] ?? "issue", tone: TYPE_TONES[type] ?? "neutral" }}
|
|
244
314
|
title={issue.title}
|
|
245
315
|
accessibilityLabel={`${issue.type ? `${issue.type}: ` : ""}${issue.title}, more`}
|
|
246
|
-
meta={{ place:
|
|
247
|
-
extra={<
|
|
248
|
-
onOpen={
|
|
316
|
+
meta={{ place: { repo: issue.repo, number: issue.number, login }, when: `${ago(issue.createdAt)} old`, signals: prSignal(issue) }}
|
|
317
|
+
extra={<IssuePills issue={issue} />}
|
|
318
|
+
onOpen={opener.open}
|
|
319
|
+
opening={opener.opening}
|
|
320
|
+
hover={opener.hover}
|
|
249
321
|
busy={busy.has(issue.key)}
|
|
250
322
|
primary={
|
|
251
323
|
sessions[0]
|
|
@@ -253,7 +325,7 @@ function IssueRow({ issue, claim, first, agents, login, busy, fetchDetails, onSt
|
|
|
253
325
|
: // Claim first so teammates see it's taken [NXT-05].
|
|
254
326
|
{ label: startLabel, accessibilityLabel: `${startLabel} ${issue.title}`, icon: "agent", onPress: () => onStart(issue, claim) }
|
|
255
327
|
}
|
|
256
|
-
secondary={[{ label: `Details for #${issue.number}`, icon: "chevronRight", onPress:
|
|
328
|
+
secondary={[{ label: `Details for #${issue.number}`, icon: "chevronRight", onPress: opener.open }]}
|
|
257
329
|
confirm={
|
|
258
330
|
closing
|
|
259
331
|
? {
|
|
@@ -303,11 +375,7 @@ function IssueSheet({
|
|
|
303
375
|
onCloseIssue: () => void;
|
|
304
376
|
onClose: () => void;
|
|
305
377
|
}) {
|
|
306
|
-
const details = useQuery({
|
|
307
|
-
queryKey: ["attention-span", "details", issue.key, false],
|
|
308
|
-
queryFn: () => fetchDetails({ subject: { kind: "issue", repo: issue.repo, number: issue.number }, checks: false }),
|
|
309
|
-
staleTime: 60_000,
|
|
310
|
-
});
|
|
378
|
+
const details = useQuery({ ...issueDetailsQuery(issue, fetchDetails), staleTime: DETAILS_STALE_MS });
|
|
311
379
|
const close = (then: () => void) => () => (onClose(), then());
|
|
312
380
|
const startLabel = claim ? "Claim & start" : "Start";
|
|
313
381
|
const withOptions = close(() => onOptions(issue, claim, startLabel));
|
|
@@ -337,11 +405,14 @@ function IssueSheet({
|
|
|
337
405
|
onClose={onClose}
|
|
338
406
|
top={
|
|
339
407
|
<>
|
|
340
|
-
|
|
408
|
+
{/* The sheet always names the owner, even of my own repos. */}
|
|
409
|
+
<Meta lead={<PlaceText place={{ repo: issue.repo, number: issue.number, login: null }} />} facts={[`${ago(issue.createdAt)} old`, ...(issue.type ? [issue.type] : [])]} chips={prSignal(issue)} />
|
|
410
|
+
<IssuePills issue={issue} full />
|
|
341
411
|
</>
|
|
342
412
|
}
|
|
343
413
|
entries={entries}
|
|
344
|
-
|
|
414
|
+
// One line per open PR the card already knows closes it [ATT-06].
|
|
415
|
+
bottom={<DetailLines details={details.data} loading={details.isLoading} error={details.error} linkedLabel="PR" expected={issue.openPrs.length} />}
|
|
345
416
|
/>
|
|
346
417
|
);
|
|
347
418
|
}
|
package/client/sheet.tsx
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { openExternalUrl } from "@getpaseo/plugin/client";
|
|
2
|
-
import { Modal } from "@getpaseo/plugin/client/ui";
|
|
3
|
-
import
|
|
2
|
+
import { Modal as PaseoModal, type ModalComponent, type ModalProps } from "@getpaseo/plugin/client/ui";
|
|
3
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { type ReactNode, useEffect, useRef, useState } from "react";
|
|
4
5
|
import { Pressable, Text, View } from "react-native";
|
|
5
|
-
import type
|
|
6
|
+
import { type Chip, type ItemDetails, ownStack, type Target } from "../shared/attention";
|
|
7
|
+
import { LatestOnly, type PendingOpen } from "../shared/opening";
|
|
6
8
|
import type { IconName } from "./icons";
|
|
7
|
-
import { Button, HintArea, KeepStyles,
|
|
9
|
+
import { Button, HintArea, KeepStyles, LINE_HEIGHT, REST_MS, Signal, Skeleton, TablerIcon, toneColor, useCopy, useHover, useStyles } from "./ui";
|
|
8
10
|
|
|
9
11
|
// Tapping a card opens its sheet: what the card knows, every action saying what it will do, then what's fetched [ATT-06].
|
|
10
12
|
// Fetched details go last, so the actions don't move when they arrive. A bottom sheet on phones, a dialog on desktop.
|
|
@@ -91,17 +93,96 @@ function Badge(chip: Chip) {
|
|
|
91
93
|
);
|
|
92
94
|
}
|
|
93
95
|
|
|
94
|
-
//
|
|
95
|
-
export
|
|
96
|
+
// What a sheet fetches when it opens; the card and its sheet share it, so what the card fetched the sheet reuses.
|
|
97
|
+
export interface DetailsQuery {
|
|
98
|
+
queryKey: readonly unknown[];
|
|
99
|
+
queryFn: () => Promise<ItemDetails>;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Details keyed by everything the fetch reads: the item, the PR its actions apply to, and with `checks` the PRs of my stack,
|
|
103
|
+
// so the same issue in Doing (acting on its PR) and in Next up (no PR) don't share what each fetched [ATT-06].
|
|
104
|
+
export function detailsKey(subject: { kind: "pr" | "issue"; repo: string; number: number }, target: Target | undefined, checks: boolean): readonly unknown[] {
|
|
105
|
+
const pr = target?.kind === "pr" ? `${target.repo}#${target.number}` : null;
|
|
106
|
+
return ["attention-span", "details", subject.kind, `${subject.repo}#${subject.number}`, pr, checks, checks && target ? ownStack(target).map((p) => p.number) : []];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Fetched details stay fresh this long, so a sheet opened again, or after its card was pointed at, opens at once.
|
|
110
|
+
export const DETAILS_STALE_MS = 60_000;
|
|
111
|
+
// Tapped, a card waits this long at most for its details before its sheet opens anyway.
|
|
112
|
+
const OPEN_WAIT_MS = 1_500;
|
|
113
|
+
// Every card's pending open, so the newest tap wins.
|
|
114
|
+
const PENDING_OPENS = new LatestOnly();
|
|
115
|
+
|
|
116
|
+
// Another way into a sheet, like a card's own action opening its picker, takes over from a card still waiting to open its
|
|
117
|
+
// details sheet, which then doesn't open over it [ATT-06].
|
|
118
|
+
export function cancelPendingOpen(): void {
|
|
119
|
+
PENDING_OPENS.cancel();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Every dialog and sheet in the plugin: Paseo's Modal, which also takes over from a card still waiting to open its details
|
|
123
|
+
// sheet as it appears, so Filter, feedback or any other dialog never ends up under one that opened late [ATT-06]. A
|
|
124
|
+
// details sheet opening for itself is done waiting by then, so it cancels nothing.
|
|
125
|
+
function TakingOverModal(props: ModalProps) {
|
|
126
|
+
useEffect(cancelPendingOpen, []);
|
|
127
|
+
return <PaseoModal {...props} />;
|
|
128
|
+
}
|
|
129
|
+
export const Modal: ModalComponent = Object.assign(TakingOverModal, { Content: PaseoModal.Content });
|
|
130
|
+
|
|
131
|
+
// Opens a card's sheet once its details are in, so the sheet doesn't change once open; meanwhile the card says it's
|
|
132
|
+
// loading. Past OPEN_WAIT_MS it opens anyway and the skeletons hold the room; a failure opens it with its error line.
|
|
133
|
+
// Resting the pointer on the card fetches them ahead, best effort [ATT-06, GH-01].
|
|
134
|
+
// Another card tapped while one waits supersedes it, so only one sheet opens.
|
|
135
|
+
export function useSheetOpener(query: DetailsQuery, show: () => void) {
|
|
136
|
+
const client = useQueryClient();
|
|
137
|
+
const [opening, setOpening] = useState(false);
|
|
138
|
+
const rest = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
139
|
+
const pending = useRef<PendingOpen | null>(null);
|
|
140
|
+
const alive = useRef(true);
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
alive.current = true;
|
|
143
|
+
return () => {
|
|
144
|
+
alive.current = false;
|
|
145
|
+
clearTimeout(rest.current);
|
|
146
|
+
pending.current?.done();
|
|
147
|
+
};
|
|
148
|
+
}, []);
|
|
149
|
+
const fetch = () => client.fetchQuery({ ...query, staleTime: DETAILS_STALE_MS });
|
|
150
|
+
const open = () => {
|
|
151
|
+
if (opening) return;
|
|
152
|
+
setOpening(true);
|
|
153
|
+
const turn = PENDING_OPENS.start(() => alive.current && setOpening(false));
|
|
154
|
+
pending.current = turn;
|
|
155
|
+
const waited = new Promise((done) => setTimeout(done, OPEN_WAIT_MS));
|
|
156
|
+
void Promise.race([fetch().catch(() => undefined), waited]).then(() => {
|
|
157
|
+
if (!turn.isCurrent() || !alive.current) return;
|
|
158
|
+
turn.done();
|
|
159
|
+
setOpening(false);
|
|
160
|
+
show();
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
const hover = {
|
|
164
|
+
onHoverIn: () => {
|
|
165
|
+
clearTimeout(rest.current);
|
|
166
|
+
rest.current = setTimeout(() => void fetch().catch(() => undefined), REST_MS);
|
|
167
|
+
},
|
|
168
|
+
onHoverOut: () => clearTimeout(rest.current),
|
|
169
|
+
};
|
|
170
|
+
return { opening, open, hover };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// The PR's size and the linked issues or PRs, once fetched. Until then skeleton lines hold the room of the lines the card
|
|
174
|
+
// expects (`expected`: a PR's size, the PRs it knows close an issue), so the sheet doesn't jump when they arrive [ATT-06].
|
|
175
|
+
export function DetailLines({ details, loading, error, linkedLabel, expected }: { details?: ItemDetails; loading: boolean; error: unknown; linkedLabel: string; expected: number }) {
|
|
96
176
|
const styles = useStyles();
|
|
97
|
-
|
|
98
|
-
if (
|
|
177
|
+
const line = [styles.muted, { lineHeight: LINE_HEIGHT }];
|
|
178
|
+
if (loading) return <Skeleton lines={expected} label="Loading details" />;
|
|
179
|
+
if (!details) return error ? <Text style={line}>Couldn't load details: {(error as Error).message}</Text> : null;
|
|
99
180
|
return (
|
|
100
181
|
<>
|
|
101
|
-
{details.size ? <Text style={
|
|
182
|
+
{details.size ? <Text style={line}>{sizeText(details.size)}</Text> : null}
|
|
102
183
|
{details.linked.map((link) => (
|
|
103
184
|
<Pressable key={link.url} accessibilityRole="link" onPress={() => void openExternalUrl(link.url)}>
|
|
104
|
-
<Text style={
|
|
185
|
+
<Text style={line} numberOfLines={1}>
|
|
105
186
|
{linkedLabel} #{link.number} {link.title} · {link.state.toLowerCase()}
|
|
106
187
|
</Text>
|
|
107
188
|
</Pressable>
|
package/client/ui.tsx
CHANGED
|
@@ -16,6 +16,8 @@ export function makeStyles(theme: Theme, compact: boolean) {
|
|
|
16
16
|
return {
|
|
17
17
|
c,
|
|
18
18
|
compact,
|
|
19
|
+
// Themes don't say whether they're dark; their base surface does. Picks the shade of a color that reads on it.
|
|
20
|
+
dark: (luminance(c.surface0) ?? 0) < 0.5,
|
|
19
21
|
// Action text and icons. The accent is a fill: as text on a dark theme it's 2.5:1; this green is 5–6:1 on every surface.
|
|
20
22
|
action: c.statusSuccess,
|
|
21
23
|
screen: { flex: 1, backgroundColor: c.surface0 },
|
|
@@ -37,6 +39,52 @@ export function makeStyles(theme: Theme, compact: boolean) {
|
|
|
37
39
|
}
|
|
38
40
|
export type Styles = ReturnType<typeof makeStyles>;
|
|
39
41
|
|
|
42
|
+
// "#rgb", "#rrggbb" or "rgb(…)" as 0–255 channels; null for anything else.
|
|
43
|
+
function channels(color: string): [number, number, number] | null {
|
|
44
|
+
const hex = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(color.trim())?.[1];
|
|
45
|
+
if (hex) {
|
|
46
|
+
const full = hex.length === 3 ? [...hex].map((ch) => ch + ch).join("") : hex;
|
|
47
|
+
return [0, 2, 4].map((at) => parseInt(full.slice(at, at + 2), 16)) as [number, number, number];
|
|
48
|
+
}
|
|
49
|
+
const rgb = /^rgba?\(\s*(\d+)[\s,]+(\d+)[\s,]+(\d+)/i.exec(color.trim());
|
|
50
|
+
return rgb ? [Number(rgb[1]), Number(rgb[2]), Number(rgb[3])] : null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function luminance(color: string): number | null {
|
|
54
|
+
const rgb = channels(color);
|
|
55
|
+
return rgb ? (0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2]) / 255 : null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// `a` with `share` of it kept and the rest `b`; just `a` when either isn't a color this can read.
|
|
59
|
+
export function mix(a: string, b: string, share: number): string {
|
|
60
|
+
const [x, y] = [channels(a), channels(b)];
|
|
61
|
+
if (!x || !y) return a;
|
|
62
|
+
return `#${x.map((value, i) => Math.round(value * share + y[i] * (1 - share)).toString(16).padStart(2, "0")).join("")}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// A fact as an icon half and a value half: the icon, with an optional label, says what the value is, in words on hover and
|
|
66
|
+
// to screen readers. A color softly fills the value half. What goes in one is up to entity.tsx.
|
|
67
|
+
export function Pill({ icon, label, value, color, hint }: { icon: IconName; label?: string; value?: string; color?: string; hint: string }) {
|
|
68
|
+
const styles = useStyles();
|
|
69
|
+
const text = { fontSize: 11, lineHeight: 16 };
|
|
70
|
+
return (
|
|
71
|
+
<Hint text={hint} inline>
|
|
72
|
+
<View accessibilityLabel={hint} style={{ flexDirection: "row", alignItems: "stretch", borderWidth: 1, borderColor: styles.c.border, borderRadius: 999, overflow: "hidden" }}>
|
|
73
|
+
<View style={[styles.row, { gap: 4, paddingLeft: 7, paddingRight: label ? 7 : 6 }]}>
|
|
74
|
+
<TablerIcon name={icon} size={12} />
|
|
75
|
+
{label ? <Text style={[text, { color: styles.c.foregroundMuted }]}>{label}</Text> : null}
|
|
76
|
+
</View>
|
|
77
|
+
{value ? (
|
|
78
|
+
<View style={{ borderLeftWidth: 1, borderLeftColor: styles.c.border, paddingHorizontal: 7, justifyContent: "center" }}>
|
|
79
|
+
{color ? <View style={{ position: "absolute", top: 0, left: 0, right: 0, bottom: 0, backgroundColor: color, opacity: 0.08 }} /> : null}
|
|
80
|
+
<Text style={[text, { color: color ? mix(color, styles.c.foreground, 0.75) : mix(styles.c.foreground, styles.c.foregroundMuted, 0.8) }]}>{value}</Text>
|
|
81
|
+
</View>
|
|
82
|
+
) : null}
|
|
83
|
+
</View>
|
|
84
|
+
</Hint>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
40
88
|
const StylesContext = createContext<Styles | null>(null);
|
|
41
89
|
export const useStyles = () => useContext(StylesContext)!;
|
|
42
90
|
|
|
@@ -72,6 +120,34 @@ export function SpinningIcon({ name, size = 16, color, spinning }: { name: IconN
|
|
|
72
120
|
);
|
|
73
121
|
}
|
|
74
122
|
|
|
123
|
+
// Lines of quiet text that may arrive later keep this height, so a Skeleton can hold their place exactly.
|
|
124
|
+
export const LINE_HEIGHT = 16;
|
|
125
|
+
|
|
126
|
+
// Where lines of text will be once they've loaded: quiet bars, gently pulsing, each the height of the line it stands in for,
|
|
127
|
+
// so nothing moves when the text replaces them. Widths vary so they read as text, not boxes.
|
|
128
|
+
export function Skeleton({ lines, label }: { lines: number; label: string }) {
|
|
129
|
+
const styles = useStyles();
|
|
130
|
+
const pulse = useRef(new Animated.Value(0)).current;
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
const native = Platform.OS !== "web";
|
|
133
|
+
const half = (toValue: number) => Animated.timing(pulse, { toValue, duration: 700, easing: Easing.inOut(Easing.ease), useNativeDriver: native });
|
|
134
|
+
const loop = Animated.loop(Animated.sequence([half(1), half(0)]));
|
|
135
|
+
loop.start();
|
|
136
|
+
return () => loop.stop();
|
|
137
|
+
}, [pulse]);
|
|
138
|
+
if (lines <= 0) return null;
|
|
139
|
+
const opacity = pulse.interpolate({ inputRange: [0, 1], outputRange: [0.5, 1] });
|
|
140
|
+
return (
|
|
141
|
+
<View accessibilityLabel={label} style={{ gap: 10 }}>
|
|
142
|
+
{Array.from({ length: lines }, (_, index) => (
|
|
143
|
+
<View key={index} style={{ height: LINE_HEIGHT, justifyContent: "center" }}>
|
|
144
|
+
<Animated.View style={{ height: 10, borderRadius: 5, width: `${[42, 68, 55][index % 3]}%`, backgroundColor: styles.c.surface2, opacity }} />
|
|
145
|
+
</View>
|
|
146
|
+
))}
|
|
147
|
+
</View>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
75
151
|
// What's loading, with a spinner so it doesn't read as stuck.
|
|
76
152
|
export function Loading({ text }: { text: string }) {
|
|
77
153
|
const styles = useStyles();
|
|
@@ -120,8 +196,9 @@ export function HintArea({ style, children }: { style?: StyleProp<ViewStyle>; ch
|
|
|
120
196
|
);
|
|
121
197
|
}
|
|
122
198
|
|
|
123
|
-
// Resting the pointer this long shows a hint; passing over
|
|
124
|
-
const
|
|
199
|
+
// Resting the pointer this long shows a hint, or fetches a card's details ahead; passing over does neither.
|
|
200
|
+
export const REST_MS = 300;
|
|
201
|
+
const HINT_DELAY_MS = REST_MS;
|
|
125
202
|
|
|
126
203
|
// What something means, in words: on hover after a moment, and always to screen readers. It floats over the layout rather
|
|
127
204
|
// than in it, so showing it moves nothing, and it's sized to the room left in its HintArea: beside the content, wrapping
|
|
@@ -164,15 +241,28 @@ export function Hint({ text, inline, children }: { text: string; inline?: boolea
|
|
|
164
241
|
);
|
|
165
242
|
}
|
|
166
243
|
|
|
167
|
-
//
|
|
168
|
-
export function
|
|
244
|
+
// Quiet text that stands out a little within it, like an item's number among its facts.
|
|
245
|
+
export function useStrongText() {
|
|
246
|
+
const styles = useStyles();
|
|
247
|
+
return { color: mix(styles.c.foreground, styles.c.foregroundMuted, 0.85), fontWeight: "500" as const };
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// The line under a title: what leads it (which item it is, as text), then facts as quiet text joined by "·", then
|
|
251
|
+
// signals [ATT-05].
|
|
252
|
+
export function Meta({ lead, facts, chips }: { lead?: ReactNode; facts: string[]; chips: Chip[] }) {
|
|
169
253
|
const styles = useStyles();
|
|
170
254
|
const quiet = (chip: Chip) => chip.tone === "neutral" && !chip.icon && !chip.hint;
|
|
171
255
|
const text = [...facts, ...chips.filter(quiet).map((chip) => chip.text)];
|
|
172
256
|
const signals = chips.filter((chip) => !quiet(chip));
|
|
173
257
|
return (
|
|
174
258
|
<View style={[styles.wrap, { columnGap: 10, rowGap: 4 }]}>
|
|
175
|
-
{text.length ?
|
|
259
|
+
{lead || text.length ? (
|
|
260
|
+
<Text style={styles.muted}>
|
|
261
|
+
{lead}
|
|
262
|
+
{lead && text.length ? " · " : null}
|
|
263
|
+
{text.join(" · ")}
|
|
264
|
+
</Text>
|
|
265
|
+
) : null}
|
|
176
266
|
{signals.map((chip) => (
|
|
177
267
|
<Signal key={chip.text} {...chip} />
|
|
178
268
|
))}
|
|
@@ -268,7 +358,8 @@ export function useCopy() {
|
|
|
268
358
|
);
|
|
269
359
|
}
|
|
270
360
|
|
|
271
|
-
// Choice chips for options and filters:
|
|
361
|
+
// Choice chips for options and filters: tappable, filled when chosen. Next up's fact pills (Pill) aren't tappable, and lead
|
|
362
|
+
// with an icon half instead.
|
|
272
363
|
export function Toggle({ label, active, onPress }: { label: string; active: boolean; onPress: () => void }) {
|
|
273
364
|
const { c } = useStyles();
|
|
274
365
|
return (
|