@andrioid/paseo-attention-span 0.6.0 → 0.7.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 +3 -1
- package/client/attention-screen.tsx +61 -1174
- package/client/coverage-settings.tsx +5 -4
- package/client/data.ts +4 -2
- package/client/feedback.tsx +21 -25
- package/client/history.tsx +12 -50
- package/client/item-actions.ts +387 -0
- package/client/item-row.tsx +450 -0
- package/client/new-issue.tsx +244 -0
- package/client/next-up.tsx +22 -183
- package/client/pickers.tsx +238 -0
- package/client/session-menu.ts +3 -11
- package/client/sessions.ts +58 -57
- package/client/setup.tsx +2 -1
- package/client/sheet.tsx +92 -15
- package/client/ui.tsx +23 -14
- package/client/wrap-up.tsx +151 -85
- package/docs/architecture.md +24 -13
- 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-wrap-dirty.png +0 -0
- package/docs/screenshots/desktop-dark-doing-wrap-multi.png +0 -0
- package/docs/screenshots/desktop-dark-doing-wrap.png +0 -0
- package/docs/screenshots/desktop-dark-doing.png +0 -0
- package/docs/screenshots/desktop-dark-history-filtered.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-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-dark-history.png +0 -0
- package/docs/screenshots/phone-light-next-up-filtered.png +0 -0
- package/index.client.tsx +19 -0
- package/index.server.ts +43 -26
- package/package.json +2 -1
- package/requirements.yaml +10 -3
- package/server/actions.ts +2 -1
- package/server/archive.ts +146 -67
- package/server/archived.ts +12 -16
- package/server/changes.ts +34 -54
- package/server/classify.ts +157 -139
- package/server/context.ts +95 -3
- package/server/feedback.ts +2 -6
- package/server/fetch.ts +262 -0
- package/server/fixture.ts +88 -14
- package/server/github-types.ts +5 -2
- package/server/markdown.ts +3 -1
- package/server/port.ts +46 -0
- package/server/queries.ts +34 -24
- package/server/service.ts +155 -272
- package/server/setup.ts +15 -14
- package/server/store.ts +94 -80
- package/server/update.ts +34 -13
- package/server/view.ts +16 -15
- package/shared/archive.ts +116 -13
- package/shared/attention.ts +63 -18
- package/shared/changes.ts +2 -1
- package/shared/config.ts +2 -6
- package/shared/drafting.ts +17 -0
- package/shared/feedback.ts +6 -5
- package/shared/format.ts +2 -1
- package/shared/history-report.ts +2 -1
- package/shared/item-sessions.ts +76 -0
- package/shared/item-view.ts +224 -0
- package/shared/linked-sessions.ts +59 -8
- package/shared/names.ts +17 -0
- package/shared/new-issue.ts +129 -0
- package/shared/next-up-filter.ts +137 -0
- package/shared/paging.ts +16 -0
- package/shared/prompts.ts +39 -22
- package/shared/rpc.ts +23 -10
- package/shared/setup.ts +3 -1
- package/shared/wrap-up.ts +20 -23
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { type PluginScreenParams, usePaseo, useRpc } from "@getpaseo/plugin/client";
|
|
2
|
+
import { TextInput, useToast } from "@getpaseo/plugin/client/ui";
|
|
3
|
+
import { useQuery } from "@tanstack/react-query";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Pressable, Text, View } from "react-native";
|
|
6
|
+
import type { AttentionView } from "../shared/attention";
|
|
7
|
+
import { codeRepoFor } from "../shared/config";
|
|
8
|
+
import { lastMessages, newIssueItemKey, newIssuePrompt, newIssueTag, newIssueTitle, prefillRepo, type SourceSession } from "../shared/new-issue";
|
|
9
|
+
import * as rpc from "../shared/rpc";
|
|
10
|
+
import { Dialog } from "./sheet";
|
|
11
|
+
import { githubProjects, ITEM_LABEL, LABEL, listProfiles, resolveAgentConfig } from "./sessions";
|
|
12
|
+
import { Button, Loading, TablerIcon, Toggle, useStyles } from "./ui";
|
|
13
|
+
|
|
14
|
+
// A new issue in a repository I cover, from ⌘K anywhere in Paseo or from Next up [ISS-01]. A line or two here, then an agent in
|
|
15
|
+
// my checkout asks until it's clear, checks for duplicates [ISS-02] and posts only once I approve the draft [SAFE-01].
|
|
16
|
+
|
|
17
|
+
// Where the sheet was opened from. ⌘K can't show a sheet of its own, so it opens the screen with these as its params.
|
|
18
|
+
export interface NewIssueRequest {
|
|
19
|
+
// A fresh one per pick, so a screen opened again with the same params doesn't show the sheet twice.
|
|
20
|
+
at: string;
|
|
21
|
+
workspaceId?: string;
|
|
22
|
+
agentId?: string;
|
|
23
|
+
// The repository Next up is narrowed to.
|
|
24
|
+
nextUp?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function newIssueParams(request: Pick<NewIssueRequest, "workspaceId" | "agentId">): PluginScreenParams {
|
|
28
|
+
return { newIssue: String(Date.now()), ...(request.workspaceId ? { workspaceId: request.workspaceId } : {}), ...(request.agentId ? { agentId: request.agentId } : {}) };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const seen = new Set<string>();
|
|
32
|
+
|
|
33
|
+
// The request in the screen's params, once per pick.
|
|
34
|
+
export function takeNewIssueRequest(params: PluginScreenParams | undefined): NewIssueRequest | null {
|
|
35
|
+
const at = params?.newIssue;
|
|
36
|
+
if (!at || seen.has(at)) return null;
|
|
37
|
+
seen.add(at);
|
|
38
|
+
return { at, workspaceId: params.workspaceId, agentId: params.agentId };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type Paseo = ReturnType<typeof usePaseo>;
|
|
42
|
+
|
|
43
|
+
interface SourceWorkspace {
|
|
44
|
+
projectId: string;
|
|
45
|
+
name: string;
|
|
46
|
+
directory: string;
|
|
47
|
+
branch: string | null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function sourceWorkspace(paseo: Paseo, workspaceId: string): Promise<SourceWorkspace | null> {
|
|
51
|
+
const { entries } = await paseo.workspaces.list();
|
|
52
|
+
const workspace = entries.find((entry) => entry.id === workspaceId);
|
|
53
|
+
if (!workspace) return null;
|
|
54
|
+
return {
|
|
55
|
+
projectId: workspace.projectId,
|
|
56
|
+
name: workspace.title ?? workspace.name,
|
|
57
|
+
directory: workspace.workspaceDirectory ?? workspace.projectRootPath,
|
|
58
|
+
branch: workspace.gitRuntime?.currentBranch ?? null,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// The session I came from: its title and last few messages. Reading them may fail; the rest still helps.
|
|
63
|
+
async function sourceSession(paseo: Paseo, agentId: string, workspace: SourceWorkspace | null): Promise<SourceSession> {
|
|
64
|
+
const agent = paseo.agents.ref(agentId);
|
|
65
|
+
const base = { workspace: workspace?.name ?? null, branch: workspace?.branch ?? null };
|
|
66
|
+
const page = await agent.timeline.refetch({ direction: "tail", limit: 40, projection: "projected" }).catch(() => null);
|
|
67
|
+
if (!agent.current()) await agent.refresh().catch(() => null);
|
|
68
|
+
return { ...base, title: agent.current()?.title ?? null, messages: page ? lastMessages(page.entries) : [] };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function NewIssueSheet({
|
|
72
|
+
request,
|
|
73
|
+
view,
|
|
74
|
+
onView,
|
|
75
|
+
onStarted,
|
|
76
|
+
onClose,
|
|
77
|
+
}: {
|
|
78
|
+
request: Omit<NewIssueRequest, "at">;
|
|
79
|
+
view: AttentionView;
|
|
80
|
+
onView: (view: AttentionView) => void;
|
|
81
|
+
onStarted: (agentId: string) => Promise<void>;
|
|
82
|
+
onClose: () => void;
|
|
83
|
+
}) {
|
|
84
|
+
const styles = useStyles();
|
|
85
|
+
const paseo = usePaseo();
|
|
86
|
+
const toast = useToast();
|
|
87
|
+
const fetchProviders = useRpc(rpc.readyProviders);
|
|
88
|
+
const remember = useRpc(rpc.setNewIssueChoice);
|
|
89
|
+
const setCodeRepo = useRpc(rpc.setCodeRepo);
|
|
90
|
+
const projects = useQuery({ queryKey: ["attention-span", "github-projects"], queryFn: () => githubProjects(paseo) });
|
|
91
|
+
const profiles = useQuery({ queryKey: ["attention-span", "profiles"], queryFn: () => listProfiles(paseo) });
|
|
92
|
+
const from = useQuery({
|
|
93
|
+
queryKey: ["attention-span", "new-issue-source", request.workspaceId ?? null],
|
|
94
|
+
queryFn: () => (request.workspaceId ? sourceWorkspace(paseo, request.workspaceId) : null),
|
|
95
|
+
});
|
|
96
|
+
const { repos } = view.newIssue;
|
|
97
|
+
const [message, setMessage] = useState("");
|
|
98
|
+
const [picked, setPicked] = useState<string | null>(null);
|
|
99
|
+
const [withContext, setWithContext] = useState(true);
|
|
100
|
+
const [profileId, setProfileId] = useState<string | null | undefined>(undefined);
|
|
101
|
+
const [options, setOptions] = useState(false);
|
|
102
|
+
const [starting, setStarting] = useState(false);
|
|
103
|
+
const [placing, setPlacing] = useState(false);
|
|
104
|
+
|
|
105
|
+
const workspaceRepo = from.data ? projects.data?.find((project) => project.projectId === from.data?.projectId)?.repo : null;
|
|
106
|
+
const repo = picked ?? prefillRepo(repos, { workspace: workspaceRepo, nextUp: request.nextUp, last: view.newIssue.repo });
|
|
107
|
+
// A remembered profile that's gone falls back to the default.
|
|
108
|
+
const knownProfile = view.newIssue.profileId && profiles.data?.some((profile) => profile.id === view.newIssue.profileId) ? view.newIssue.profileId : null;
|
|
109
|
+
const profile = profileId === undefined ? knownProfile : profileId;
|
|
110
|
+
// Where its code lives, if it's kept apart, and my checkout of that [SES-05, SES-07].
|
|
111
|
+
const codeRepo = repo ? codeRepoFor(view.config, repo) : null;
|
|
112
|
+
const checkout = codeRepo ? (projects.data?.find((project) => project.repo.toLowerCase() === codeRepo.toLowerCase()) ?? null) : null;
|
|
113
|
+
const loading = projects.isLoading || from.isLoading;
|
|
114
|
+
// Start waits for where I came from and my profiles, so a quick tap doesn't fall back to the project's checkout or the
|
|
115
|
+
// default profile.
|
|
116
|
+
const ready = !loading && !profiles.isLoading;
|
|
117
|
+
const noCheckout = !!repo && !loading && !checkout;
|
|
118
|
+
const fromSession = !!request.agentId;
|
|
119
|
+
|
|
120
|
+
async function place(code: string) {
|
|
121
|
+
if (!repo) return;
|
|
122
|
+
setPlacing(true);
|
|
123
|
+
try {
|
|
124
|
+
onView(await setCodeRepo({ issueRepo: repo, codeRepo: code }));
|
|
125
|
+
} catch (error) {
|
|
126
|
+
toast.error(`Saving where the code lives failed: ${(error as Error).message}`);
|
|
127
|
+
} finally {
|
|
128
|
+
setPlacing(false);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
async function start() {
|
|
133
|
+
if (!repo || !codeRepo || !checkout) return;
|
|
134
|
+
setStarting(true);
|
|
135
|
+
try {
|
|
136
|
+
// In the workspace I came from when it's a checkout of the code, else in the project's own checkout.
|
|
137
|
+
const here = request.workspaceId && from.data?.projectId === checkout.projectId ? from.data : null;
|
|
138
|
+
const dir = here?.directory ?? checkout.rootPath;
|
|
139
|
+
const source = fromSession && withContext && request.agentId ? await sourceSession(paseo, request.agentId, from.data ?? null) : null;
|
|
140
|
+
const title = newIssueTitle(repo, newIssueTag());
|
|
141
|
+
const prompt = newIssuePrompt({ message, repo, codeRepo, dir, source, title });
|
|
142
|
+
const { agent } = await resolveAgentConfig(paseo, () => fetchProviders({}).then((result) => result.providers), "start", view.config, profile ?? undefined);
|
|
143
|
+
const workspace = here && request.workspaceId ? paseo.workspaces.ref(request.workspaceId) : await paseo.workspaces.open({ cwd: checkout.rootPath });
|
|
144
|
+
const created = await workspace.agents.create({
|
|
145
|
+
config: agent,
|
|
146
|
+
title,
|
|
147
|
+
prompt,
|
|
148
|
+
labels: { [LABEL]: "1", [ITEM_LABEL]: newIssueItemKey(repo) },
|
|
149
|
+
});
|
|
150
|
+
onView({ ...view, newIssue: { ...view.newIssue, repo, profileId: profile } });
|
|
151
|
+
remember({ repo, profileId: profile }).catch(() => {}); // only next time's starting point
|
|
152
|
+
onClose();
|
|
153
|
+
await onStarted(created.id);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
toast.error(`Starting the session failed: ${(error as Error).message}`);
|
|
156
|
+
} finally {
|
|
157
|
+
setStarting(false);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const profileName = profile ? (profiles.data?.find((choice) => choice.id === profile)?.name ?? profile) : "Default";
|
|
162
|
+
const summary = [repo ?? "Pick a repository", fromSession ? (withContext ? "with this session's context" : "without this session's context") : null, `${profileName} profile`]
|
|
163
|
+
.filter(Boolean)
|
|
164
|
+
.join(" · ");
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<Dialog title="New issue" onClose={onClose}>
|
|
168
|
+
<View style={{ gap: 10 }}>
|
|
169
|
+
<Text style={styles.muted}>What should the issue be about?</Text>
|
|
170
|
+
<TextInput
|
|
171
|
+
style={[styles.input, { minHeight: 110 }]}
|
|
172
|
+
value={message}
|
|
173
|
+
onChangeText={setMessage}
|
|
174
|
+
placeholder={fromSession ? "File what we just found: …" : "Export fails when a month has no entries…"}
|
|
175
|
+
multiline
|
|
176
|
+
textAlignVertical="top"
|
|
177
|
+
autoFocus
|
|
178
|
+
/>
|
|
179
|
+
{repos.length === 0 ? (
|
|
180
|
+
<Text style={styles.danger}>No repositories to file in yet. Choose what Attention Span covers in Settings.</Text>
|
|
181
|
+
) : (
|
|
182
|
+
<Pressable accessibilityRole="button" accessibilityState={{ expanded: options }} onPress={() => setOptions(!options)} style={styles.row} hitSlop={6}>
|
|
183
|
+
<TablerIcon name={options ? "chevronDown" : "chevronRight"} size={14} color={styles.c.foregroundMuted} />
|
|
184
|
+
<Text style={[styles.muted, { flexShrink: 1 }]}>{summary}</Text>
|
|
185
|
+
</Pressable>
|
|
186
|
+
)}
|
|
187
|
+
{options || (!repo && repos.length > 0) ? (
|
|
188
|
+
<View style={{ gap: 10 }}>
|
|
189
|
+
<Text style={styles.muted}>Repository</Text>
|
|
190
|
+
<View style={styles.wrap}>
|
|
191
|
+
{repos.map((choice) => (
|
|
192
|
+
<Toggle key={choice} label={choice} active={choice === repo} onPress={() => setPicked(choice)} />
|
|
193
|
+
))}
|
|
194
|
+
</View>
|
|
195
|
+
{options && fromSession ? (
|
|
196
|
+
<>
|
|
197
|
+
<Text style={styles.muted}>Context</Text>
|
|
198
|
+
<View style={styles.wrap}>
|
|
199
|
+
<Toggle label="Include this session's last messages" active={withContext} onPress={() => setWithContext(!withContext)} />
|
|
200
|
+
</View>
|
|
201
|
+
</>
|
|
202
|
+
) : null}
|
|
203
|
+
{options ? (
|
|
204
|
+
<>
|
|
205
|
+
<Text style={styles.muted}>Agent profile</Text>
|
|
206
|
+
<View style={styles.wrap}>
|
|
207
|
+
<Toggle label="Default" active={!profile} onPress={() => setProfileId(null)} />
|
|
208
|
+
{profiles.data?.map((choice) => (
|
|
209
|
+
<Toggle key={choice.id} label={choice.name} active={profile === choice.id} onPress={() => setProfileId(choice.id)} />
|
|
210
|
+
))}
|
|
211
|
+
</View>
|
|
212
|
+
</>
|
|
213
|
+
) : null}
|
|
214
|
+
</View>
|
|
215
|
+
) : null}
|
|
216
|
+
{loading && repo ? <Loading text="Finding your checkout…" /> : null}
|
|
217
|
+
{noCheckout ? (
|
|
218
|
+
// Like SES-07: picked once, saved to codeRepos, so the next one goes straight there.
|
|
219
|
+
<View style={{ gap: 8 }}>
|
|
220
|
+
<Text style={styles.text}>
|
|
221
|
+
No Paseo project has {codeRepo} as its GitHub remote. Pick the project that holds the code for {repo}, or add it as a project in Paseo.
|
|
222
|
+
</Text>
|
|
223
|
+
<View style={styles.wrap}>
|
|
224
|
+
{projects.data?.map((project) => (
|
|
225
|
+
<Button key={project.projectId} label={project.repo} icon="play" variant="calm" disabled={placing} onPress={() => void place(project.repo)} />
|
|
226
|
+
))}
|
|
227
|
+
</View>
|
|
228
|
+
</View>
|
|
229
|
+
) : null}
|
|
230
|
+
<Text style={styles.muted}>An agent in your checkout asks what else it needs and shows you the issue before anything goes to GitHub.</Text>
|
|
231
|
+
<View style={styles.wrap}>
|
|
232
|
+
<Button
|
|
233
|
+
label={starting ? "Starting…" : "Start"}
|
|
234
|
+
icon="agent"
|
|
235
|
+
variant="solid"
|
|
236
|
+
disabled={starting || !ready || !message.trim() || !checkout}
|
|
237
|
+
onPress={() => void start()}
|
|
238
|
+
/>
|
|
239
|
+
<Button label="Cancel" onPress={onClose} />
|
|
240
|
+
</View>
|
|
241
|
+
</View>
|
|
242
|
+
</Dialog>
|
|
243
|
+
);
|
|
244
|
+
}
|
package/client/next-up.tsx
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
1
|
import { openExternalUrl } from "@getpaseo/plugin/client";
|
|
2
2
|
import { useQuery } from "@tanstack/react-query";
|
|
3
3
|
import { useMemo, useState } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { Text, View } from "react-native";
|
|
5
5
|
import { ago } from "../shared/format";
|
|
6
6
|
import {
|
|
7
7
|
type AgentSummary,
|
|
8
8
|
type Chip,
|
|
9
|
-
type GithubColor,
|
|
10
9
|
type IssueCloseReason,
|
|
11
10
|
matchSessions,
|
|
12
11
|
type NextUpIssue,
|
|
13
12
|
type ProjectInfo,
|
|
14
|
-
projectFilterId,
|
|
15
|
-
projectFilterIds,
|
|
16
13
|
type UnclaimedSource,
|
|
17
14
|
} from "../shared/attention";
|
|
18
15
|
import type { NextUpSource } from "../shared/config";
|
|
16
|
+
import { CLEAR_FILTER, type FilterChange, nextUpFilter } from "../shared/next-up-filter";
|
|
19
17
|
import type { IconName } from "./icons";
|
|
20
|
-
import type { FetchDetails } from "./
|
|
18
|
+
import type { FetchDetails } from "./item-actions";
|
|
21
19
|
import { CardList, CardRow, type Tone } from "./card";
|
|
22
20
|
import { sessionEntry, startAnotherEntry } from "./session-menu";
|
|
23
|
-
import { ActionSheet, DETAILS_STALE_MS, DetailLines, type DetailsQuery, detailsKey,
|
|
24
|
-
import {
|
|
21
|
+
import { ActionSheet, DETAILS_STALE_MS, DetailLines, type DetailsQuery, detailsKey, FilterSheet, githubEntry, type SheetEntry, usePrefetchOnRest } from "./sheet";
|
|
22
|
+
import { IssuePills, PlaceText } from "./entity";
|
|
25
23
|
import { Still } from "./still";
|
|
26
|
-
import { Button,
|
|
24
|
+
import { Button, FilterButton, Meta, SectionHeader, useStyles } from "./ui";
|
|
27
25
|
|
|
28
26
|
const TYPE_ICONS: Record<string, IconName> = { bug: "bug", feature: "feature", debt: "debt", task: "task", epic: "epic" };
|
|
29
27
|
|
|
@@ -57,61 +55,21 @@ interface Props {
|
|
|
57
55
|
// Close it, once I've confirmed the reason [NXT-11].
|
|
58
56
|
onCloseIssue: (issue: NextUpIssue, reason: IssueCloseReason, comment: string) => void;
|
|
59
57
|
onOpenAgent: (agentId: string) => void;
|
|
58
|
+
// The New issue sheet [ISS-01].
|
|
59
|
+
onNewIssue: () => void;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
type
|
|
63
|
-
|
|
64
|
-
type RowProps = Omit<Props, "calm" | "openSettings" | "assigned" | "unclaimed" | "unclaimedFrom" | "selected" | "sources" | "selectedSources" | "projects" | "selectedProjects" | "onFilter">;
|
|
62
|
+
type RowProps = Omit<Props, "calm" | "openSettings" | "assigned" | "unclaimed" | "unclaimedFrom" | "selected" | "sources" | "selectedSources" | "projects" | "selectedProjects" | "onFilter" | "onNewIssue">;
|
|
65
63
|
|
|
66
64
|
// Assigned issues first [NXT-06], then unclaimed ones [NXT-01]; both already ranked by the server [NXT-02].
|
|
67
|
-
export function NextUpList({ calm, openSettings, assigned, unclaimed, unclaimedFrom, selected, sources, selectedSources, projects, selectedProjects, onFilter, ...rowProps }: Props) {
|
|
65
|
+
export function NextUpList({ calm, openSettings, assigned, unclaimed, unclaimedFrom, selected, sources, selectedSources, projects, selectedProjects, onFilter, onNewIssue, ...rowProps }: Props) {
|
|
68
66
|
const styles = useStyles();
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// And by source, when there's more than one [NXT-09]; a picked source no longer in settings is ignored.
|
|
73
|
-
const activeSources = sources.length > 1 ? selectedSources.filter((id) => sources.some((source) => source.id === id)) : [];
|
|
74
|
-
// And by project and status [NXT-03, NXT-12]; a picked status no longer offered is ignored.
|
|
75
|
-
const tree = useMemo(() => projectTree(unclaimed, projects), [unclaimed, projects]);
|
|
76
|
-
const leaves = tree.flatMap((node) => node.children.map((child) => child.id));
|
|
77
|
-
const activeProjects = selectedProjects.filter((id) => leaves.includes(id));
|
|
78
|
-
const shown = unclaimed.filter(
|
|
79
|
-
(issue) =>
|
|
80
|
-
(active.length === 0 || (issue.scope && active.includes(issue.scope))) &&
|
|
81
|
-
(activeSources.length === 0 || issue.sources.some((id) => activeSources.includes(id))) &&
|
|
82
|
-
(activeProjects.length === 0 || projectFilterIds(issue).some((id) => activeProjects.includes(id))),
|
|
67
|
+
const filter = useMemo(
|
|
68
|
+
() => nextUpFilter({ unclaimed, selected, sources, selectedSources, projects, selectedProjects }),
|
|
69
|
+
[unclaimed, selected, sources, selectedSources, projects, selectedProjects],
|
|
83
70
|
);
|
|
84
|
-
const
|
|
85
|
-
const toggle = (scope: string) => onFilter({ scopes: flip(active, scope) });
|
|
86
|
-
const toggleSource = (id: string) => onFilter({ sources: flip(activeSources, id) });
|
|
87
|
-
// A project ticks or clears all its statuses at once; partly ticked, it clears them.
|
|
88
|
-
const toggleProject = (id: string) => {
|
|
89
|
-
const children = tree.find((node) => node.id === id)?.children.map((child) => child.id);
|
|
90
|
-
if (!children) return onFilter({ projectFilter: flip(activeProjects, id) });
|
|
91
|
-
const any = children.some((child) => activeProjects.includes(child));
|
|
92
|
-
onFilter({ projectFilter: any ? activeProjects.filter((other) => !children.includes(other)) : [...activeProjects, ...children] });
|
|
93
|
-
};
|
|
94
|
-
const narrowedBy = [activeSources.length ? "sources" : null, activeProjects.length ? "projects" : null, active.length ? "scopes" : null].filter(Boolean);
|
|
71
|
+
const { shown, picked, groups } = filter;
|
|
95
72
|
const [filtering, setFiltering] = useState(false);
|
|
96
|
-
// A project ticked whole counts once.
|
|
97
|
-
const projectsPicked = tree.reduce((sum, node) => {
|
|
98
|
-
const on = node.children.filter((child) => activeProjects.includes(child.id)).length;
|
|
99
|
-
return sum + (on === node.children.length ? 1 : on);
|
|
100
|
-
}, 0);
|
|
101
|
-
const picked = active.length + activeSources.length + projectsPicked;
|
|
102
|
-
const projectOptions: FilterOption[] = tree.flatMap((node) => {
|
|
103
|
-
if (node.children.length === 1 && node.children[0].id === node.id) return [{ id: node.id, label: node.title }];
|
|
104
|
-
const on = node.children.filter((child) => activeProjects.includes(child.id)).length;
|
|
105
|
-
return [
|
|
106
|
-
{ id: node.id, label: node.title, strong: true, state: on === 0 ? "off" : on === node.children.length ? "on" : "partial" },
|
|
107
|
-
...node.children.map((child) => ({ ...child, indent: true })),
|
|
108
|
-
];
|
|
109
|
-
});
|
|
110
|
-
const groups: FilterGroup[] = [
|
|
111
|
-
...(sources.length > 1 ? [{ title: "Source", options: sources, active: activeSources, onToggle: toggleSource }] : []),
|
|
112
|
-
...(projectOptions.length > 0 ? [{ title: "Project", options: projectOptions, active: activeProjects, onToggle: toggleProject }] : []),
|
|
113
|
-
...(scopes.length > 0 ? [{ title: "Scope", options: scopes.map((scope) => ({ id: scope, label: scope })), active, onToggle: toggle }] : []),
|
|
114
|
-
];
|
|
115
73
|
|
|
116
74
|
// Both point at where Next up looks: plainly when it has nowhere to look, quietly when it found nothing [NXT-13].
|
|
117
75
|
if (calm === "setup") {
|
|
@@ -137,28 +95,25 @@ export function NextUpList({ calm, openSettings, assigned, unclaimed, unclaimedF
|
|
|
137
95
|
title="Unclaimed"
|
|
138
96
|
count={shown.length}
|
|
139
97
|
action={
|
|
140
|
-
|
|
141
|
-
<Button
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
icon="filter"
|
|
145
|
-
variant={picked ? "calm" : "ghost"}
|
|
146
|
-
onPress={() => setFiltering(true)}
|
|
147
|
-
/>
|
|
148
|
-
) : null
|
|
98
|
+
<View style={styles.wrap}>
|
|
99
|
+
<Button label="New issue" icon="plus" variant="ghost" onPress={onNewIssue} />
|
|
100
|
+
{groups.length > 0 ? <FilterButton count={picked} onPress={() => setFiltering(true)} /> : null}
|
|
101
|
+
</View>
|
|
149
102
|
}
|
|
150
103
|
/>
|
|
104
|
+
{/* Source, project and scope filters behind one button, so they take no room above the list [NXT-03, NXT-09]. */}
|
|
151
105
|
{filtering ? (
|
|
152
106
|
<FilterSheet
|
|
153
107
|
groups={groups}
|
|
154
|
-
|
|
108
|
+
onToggle={(kind, id) => onFilter(filter.toggle(kind, id))}
|
|
109
|
+
onClear={() => onFilter(CLEAR_FILTER)}
|
|
155
110
|
onClose={() => setFiltering(false)}
|
|
156
111
|
/>
|
|
157
112
|
) : null}
|
|
158
113
|
{unclaimedFrom === "none" ? (
|
|
159
114
|
<Text style={styles.text}>No repos to look in. Register a project in Paseo, or choose where Next up looks in Settings.</Text>
|
|
160
115
|
) : shown.length === 0 ? (
|
|
161
|
-
<Text style={styles.text}>
|
|
116
|
+
<Text style={styles.text}>{filter.empty}</Text>
|
|
162
117
|
) : (
|
|
163
118
|
<IssueList issues={shown} claim {...rowProps} />
|
|
164
119
|
)}
|
|
@@ -167,122 +122,6 @@ export function NextUpList({ calm, openSettings, assigned, unclaimed, unclaimedF
|
|
|
167
122
|
);
|
|
168
123
|
}
|
|
169
124
|
|
|
170
|
-
// A project in the filter with its statuses under it, all of them in the board's order, dimmed where no unclaimed issue has
|
|
171
|
-
// one; "No status" where some issue on it has none, and "No project" last, where some issue is on none [NXT-03, NXT-12].
|
|
172
|
-
// Only projects the unclaimed issues are on; none at all when projects can't be read.
|
|
173
|
-
interface ProjectNode {
|
|
174
|
-
id: string;
|
|
175
|
-
title: string;
|
|
176
|
-
children: FilterOption[];
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function projectTree(unclaimed: NextUpIssue[], projects: ProjectInfo[]): ProjectNode[] {
|
|
180
|
-
if (!unclaimed.some((issue) => issue.projects)) return [];
|
|
181
|
-
const on = (project: ProjectInfo) => unclaimed.flatMap((issue) => (issue.projects ?? []).filter((p) => p.id === project.id));
|
|
182
|
-
const nodes: ProjectNode[] = projects.flatMap((project) => {
|
|
183
|
-
const items = on(project);
|
|
184
|
-
if (items.length === 0) return [];
|
|
185
|
-
const statuses = project.statuses.map((status) => ({
|
|
186
|
-
id: projectFilterId(project, status.name),
|
|
187
|
-
label: status.name,
|
|
188
|
-
color: status.color,
|
|
189
|
-
dim: !items.some((item) => item.status === status.name),
|
|
190
|
-
}));
|
|
191
|
-
// A status the board no longer offers still filters, after the board's own.
|
|
192
|
-
const gone = [...new Set(items.map((item) => item.status).filter((name): name is string => !!name && !project.statuses.some((s) => s.name === name)))];
|
|
193
|
-
const none = items.some((item) => !item.status) ? [{ id: projectFilterId(project, null), label: "No status" }] : [];
|
|
194
|
-
return [{ id: project.id, title: project.title, children: [...statuses, ...gone.map((name) => ({ id: projectFilterId(project, name), label: name })), ...none] }];
|
|
195
|
-
});
|
|
196
|
-
const loose = unclaimed.some((issue) => issue.projects && issue.projects.length === 0);
|
|
197
|
-
const noProject = projectFilterId(null);
|
|
198
|
-
return loose ? [...nodes, { id: noProject, title: "No project", children: [{ id: noProject, label: "No project" }] }] : nodes;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// Source, project and scope filters behind one button, so they take no room above the list [NXT-03, NXT-09].
|
|
202
|
-
// Ticks apply right away; a bottom sheet on phones, a dialog on desktop.
|
|
203
|
-
function FilterSheet({ groups, onClear, onClose }: { groups: FilterGroup[]; onClear: () => void; onClose: () => void }) {
|
|
204
|
-
const styles = useStyles();
|
|
205
|
-
const any = groups.some((group) => group.active.length > 0);
|
|
206
|
-
return (
|
|
207
|
-
<Modal title="Filter" open onOpenChange={(open) => (open ? null : onClose())}>
|
|
208
|
-
<Modal.Content>
|
|
209
|
-
<KeepStyles styles={styles}>
|
|
210
|
-
{groups.map((group) => (
|
|
211
|
-
<View key={group.title} style={{ gap: 6 }}>
|
|
212
|
-
<Text style={styles.muted}>{group.title}</Text>
|
|
213
|
-
<View style={[styles.card, { backgroundColor: styles.c.surface2 }]}>
|
|
214
|
-
{group.options.map((option, index) => (
|
|
215
|
-
<FilterRow
|
|
216
|
-
key={`${option.id}:${option.strong ? "project" : "leaf"}`}
|
|
217
|
-
option={option}
|
|
218
|
-
state={option.state ?? (group.active.includes(option.id) ? "on" : "off")}
|
|
219
|
-
first={index === 0}
|
|
220
|
-
onPress={() => group.onToggle(option.id)}
|
|
221
|
-
/>
|
|
222
|
-
))}
|
|
223
|
-
</View>
|
|
224
|
-
</View>
|
|
225
|
-
))}
|
|
226
|
-
<View style={[styles.row, { justifyContent: "flex-end" }]}>
|
|
227
|
-
<Button label="Clear" variant="ghost" disabled={!any} onPress={onClear} />
|
|
228
|
-
<Button label="Done" variant="solid" onPress={onClose} />
|
|
229
|
-
</View>
|
|
230
|
-
</KeepStyles>
|
|
231
|
-
</Modal.Content>
|
|
232
|
-
</Modal>
|
|
233
|
-
);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
interface FilterGroup {
|
|
237
|
-
title: string;
|
|
238
|
-
options: FilterOption[];
|
|
239
|
-
active: string[];
|
|
240
|
-
onToggle: (id: string) => void;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
interface FilterOption {
|
|
244
|
-
id: string;
|
|
245
|
-
label: string;
|
|
246
|
-
// A project's statuses sit under it, each with its board color.
|
|
247
|
-
indent?: boolean;
|
|
248
|
-
color?: GithubColor;
|
|
249
|
-
// A status no unclaimed issue has right now.
|
|
250
|
-
dim?: boolean;
|
|
251
|
-
// A project, ticked as a whole, partly, or not, by its statuses.
|
|
252
|
-
strong?: boolean;
|
|
253
|
-
state?: "on" | "partial" | "off";
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
function FilterRow({ option, state, first, onPress }: { option: FilterOption; state: "on" | "partial" | "off"; first: boolean; onPress: () => void }) {
|
|
257
|
-
const styles = useStyles();
|
|
258
|
-
const { hovered, hover } = useHover();
|
|
259
|
-
const checked = state === "on";
|
|
260
|
-
const color = githubColor(styles, option.color);
|
|
261
|
-
return (
|
|
262
|
-
<Pressable
|
|
263
|
-
accessibilityRole="checkbox"
|
|
264
|
-
accessibilityState={{ checked: state === "partial" ? "mixed" : checked }}
|
|
265
|
-
aria-checked={state === "partial" ? "mixed" : checked}
|
|
266
|
-
accessibilityLabel={option.label}
|
|
267
|
-
onPress={onPress}
|
|
268
|
-
{...hover}
|
|
269
|
-
style={({ pressed }) => [
|
|
270
|
-
styles.row,
|
|
271
|
-
{ paddingVertical: 10, paddingRight: 12, paddingLeft: option.indent ? 40 : 12, backgroundColor: pressed || hovered ? styles.c.border : "transparent" },
|
|
272
|
-
first ? null : { borderTopWidth: 1, borderTopColor: styles.c.surface1 },
|
|
273
|
-
]}
|
|
274
|
-
>
|
|
275
|
-
<TablerIcon name={state === "on" ? "squareCheck" : state === "partial" ? "squareMinus" : "square"} size={18} color={state === "off" ? styles.c.foregroundMuted : styles.action} />
|
|
276
|
-
{option.indent ? (
|
|
277
|
-
<View
|
|
278
|
-
style={{ width: 8, height: 8, borderRadius: 4, ...(option.color ? { backgroundColor: color ?? styles.c.foregroundMuted } : { borderWidth: 1.5, borderColor: styles.c.foregroundMuted }) }}
|
|
279
|
-
/>
|
|
280
|
-
) : null}
|
|
281
|
-
<Text style={[styles.text, option.strong ? { fontWeight: "600" } : null, option.dim ? { opacity: 0.45 } : null]}>{option.label}</Text>
|
|
282
|
-
</Pressable>
|
|
283
|
-
);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
125
|
function IssueList({ issues, claim, ...rowProps }: RowProps & { issues: NextUpIssue[]; claim: boolean }) {
|
|
287
126
|
return (
|
|
288
127
|
<CardList>
|