@andrioid/paseo-attention-span 0.5.0 → 0.6.1

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.
Files changed (73) hide show
  1. package/OVERVIEW.md +7 -1
  2. package/client/attention-screen.tsx +74 -1176
  3. package/client/coverage-settings.tsx +5 -4
  4. package/client/data.ts +4 -2
  5. package/client/feedback.tsx +21 -25
  6. package/client/history.tsx +17 -50
  7. package/client/item-actions.ts +363 -0
  8. package/client/item-row.tsx +450 -0
  9. package/client/new-issue.tsx +244 -0
  10. package/client/next-up.tsx +36 -183
  11. package/client/pickers.tsx +237 -0
  12. package/client/session-menu.ts +3 -11
  13. package/client/sessions.ts +58 -57
  14. package/client/setup.tsx +2 -1
  15. package/client/sheet.tsx +92 -15
  16. package/client/still.tsx +70 -27
  17. package/client/ui.tsx +23 -14
  18. package/client/wrap-up.tsx +151 -85
  19. package/docs/architecture.md +22 -11
  20. package/docs/screenshots/desktop-dark-doing-acknowledge.png +0 -0
  21. package/docs/screenshots/desktop-dark-doing-clear.png +0 -0
  22. package/docs/screenshots/desktop-dark-doing-issue-sheet.png +0 -0
  23. package/docs/screenshots/desktop-dark-doing-reviewers.png +0 -0
  24. package/docs/screenshots/desktop-dark-doing-sheet.png +0 -0
  25. package/docs/screenshots/desktop-dark-doing-wrap-dirty.png +0 -0
  26. package/docs/screenshots/desktop-dark-doing-wrap-multi.png +0 -0
  27. package/docs/screenshots/desktop-dark-doing-wrap.png +0 -0
  28. package/docs/screenshots/desktop-dark-doing.png +0 -0
  29. package/docs/screenshots/desktop-dark-next-up-setup.png +0 -0
  30. package/docs/screenshots/desktop-dark-next-up.png +0 -0
  31. package/docs/screenshots/desktop-dark-settings.png +0 -0
  32. package/docs/screenshots/phone-dark-doing.png +0 -0
  33. package/docs/screenshots/phone-light-next-up-filtered.png +0 -0
  34. package/index.client.tsx +19 -0
  35. package/index.server.ts +43 -26
  36. package/package.json +3 -1
  37. package/requirements.yaml +11 -3
  38. package/server/actions.ts +2 -1
  39. package/server/archive.ts +146 -67
  40. package/server/archived.ts +12 -16
  41. package/server/changes.ts +34 -54
  42. package/server/classify.ts +142 -136
  43. package/server/feedback.ts +2 -6
  44. package/server/fetch.ts +262 -0
  45. package/server/fixture.ts +91 -7
  46. package/server/github-types.ts +3 -1
  47. package/server/markdown.ts +3 -1
  48. package/server/port.ts +46 -0
  49. package/server/queries.ts +33 -23
  50. package/server/service.ts +155 -272
  51. package/server/setup.ts +15 -14
  52. package/server/store.ts +94 -80
  53. package/server/update.ts +34 -13
  54. package/server/view.ts +16 -15
  55. package/shared/archive.ts +116 -13
  56. package/shared/attention.ts +50 -18
  57. package/shared/changes.ts +2 -1
  58. package/shared/config.ts +2 -6
  59. package/shared/drafting.ts +17 -0
  60. package/shared/feedback.ts +6 -5
  61. package/shared/format.ts +2 -1
  62. package/shared/history-report.ts +2 -1
  63. package/shared/item-sessions.ts +76 -0
  64. package/shared/item-view.ts +223 -0
  65. package/shared/linked-sessions.ts +59 -8
  66. package/shared/names.ts +17 -0
  67. package/shared/new-issue.ts +129 -0
  68. package/shared/next-up-filter.ts +137 -0
  69. package/shared/paging.ts +16 -0
  70. package/shared/rpc.ts +23 -10
  71. package/shared/setup.ts +3 -1
  72. package/shared/still.ts +28 -7
  73. 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
+ }
@@ -1,32 +1,34 @@
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 { Pressable, Text, View } from "react-native";
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 "./attention-screen";
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, githubEntry, Modal, type SheetEntry, usePrefetchOnRest } from "./sheet";
24
- import { githubColor, IssuePills, PlaceText } from "./entity";
25
- import { Button, KeepStyles, Meta, SectionHeader, TablerIcon, useHover, useStyles } from "./ui";
21
+ import { ActionSheet, DETAILS_STALE_MS, DetailLines, type DetailsQuery, detailsKey, FilterSheet, githubEntry, type SheetEntry, usePrefetchOnRest } from "./sheet";
22
+ import { IssuePills, PlaceText } from "./entity";
23
+ import { Still } from "./still";
24
+ import { Button, FilterButton, Meta, SectionHeader, useStyles } from "./ui";
26
25
 
27
26
  const TYPE_ICONS: Record<string, IconName> = { bug: "bug", feature: "feature", debt: "debt", task: "task", epic: "epic" };
28
27
 
29
28
  interface Props {
29
+ // Nothing at all to show: nowhere to look yet, or nothing to pick up after a refresh that worked [NXT-13].
30
+ calm: "setup" | "clear" | null;
31
+ openSettings?: () => void;
30
32
  assigned: NextUpIssue[];
31
33
  unclaimed: NextUpIssue[];
32
34
  unclaimedFrom: UnclaimedSource;
@@ -53,61 +55,31 @@ interface Props {
53
55
  // Close it, once I've confirmed the reason [NXT-11].
54
56
  onCloseIssue: (issue: NextUpIssue, reason: IssueCloseReason, comment: string) => void;
55
57
  onOpenAgent: (agentId: string) => void;
58
+ // The New issue sheet [ISS-01].
59
+ onNewIssue: () => void;
56
60
  }
57
61
 
58
- type FilterChange = { scopes?: string[]; sources?: string[]; projectFilter?: string[] };
59
-
60
- type RowProps = Omit<Props, "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">;
61
63
 
62
64
  // Assigned issues first [NXT-06], then unclaimed ones [NXT-01]; both already ranked by the server [NXT-02].
63
- export function NextUpList({ 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) {
64
66
  const styles = useStyles();
65
- const scopes = useMemo(() => [...new Set(unclaimed.map((issue) => issue.scope).filter((scope): scope is string => !!scope))].sort(), [unclaimed]);
66
- // Filter by the scopes I picked last time [NXT-03]; a picked scope with no issues left is ignored.
67
- const active = selected.filter((scope) => scopes.includes(scope));
68
- // And by source, when there's more than one [NXT-09]; a picked source no longer in settings is ignored.
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));
74
- const shown = unclaimed.filter(
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))),
67
+ const filter = useMemo(
68
+ () => nextUpFilter({ unclaimed, selected, sources, selectedSources, projects, selectedProjects }),
69
+ [unclaimed, selected, sources, selectedSources, projects, selectedProjects],
79
70
  );
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);
71
+ const { shown, picked, groups } = filter;
91
72
  const [filtering, setFiltering] = useState(false);
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
- });
106
- const groups: FilterGroup[] = [
107
- ...(sources.length > 1 ? [{ title: "Source", options: sources, active: activeSources, onToggle: toggleSource }] : []),
108
- ...(projectOptions.length > 0 ? [{ title: "Project", options: projectOptions, active: activeProjects, onToggle: toggleProject }] : []),
109
- ...(scopes.length > 0 ? [{ title: "Scope", options: scopes.map((scope) => ({ id: scope, label: scope })), active, onToggle: toggle }] : []),
110
- ];
73
+
74
+ // Both point at where Next up looks: plainly when it has nowhere to look, quietly when it found nothing [NXT-13].
75
+ if (calm === "setup") {
76
+ const way = openSettings ? { label: "Open settings", onPress: openSettings } : undefined;
77
+ return <Still shore="signpost" title="Nowhere to look yet." line="Choose where Next up finds issues." way={way} />;
78
+ }
79
+ if (calm === "clear") {
80
+ const way = openSettings ? { label: "Look in more places", onPress: openSettings, link: true } : undefined;
81
+ return <Still shore="signpost" title="Nothing ready for work." line="Want more to choose from?" way={way} />;
82
+ }
111
83
 
112
84
  return (
113
85
  <View style={{ gap: 24 }}>
@@ -123,28 +95,25 @@ export function NextUpList({ assigned, unclaimed, unclaimedFrom, selected, sourc
123
95
  title="Unclaimed"
124
96
  count={shown.length}
125
97
  action={
126
- groups.length > 0 ? (
127
- <Button
128
- label={picked ? `Filter · ${picked}` : "Filter"}
129
- accessibilityLabel={picked ? `Filter, ${picked} on` : "Filter"}
130
- icon="filter"
131
- variant={picked ? "calm" : "ghost"}
132
- onPress={() => setFiltering(true)}
133
- />
134
- ) : 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>
135
102
  }
136
103
  />
104
+ {/* Source, project and scope filters behind one button, so they take no room above the list [NXT-03, NXT-09]. */}
137
105
  {filtering ? (
138
106
  <FilterSheet
139
107
  groups={groups}
140
- onClear={() => onFilter({ scopes: [], sources: [], projectFilter: [] })}
108
+ onToggle={(kind, id) => onFilter(filter.toggle(kind, id))}
109
+ onClear={() => onFilter(CLEAR_FILTER)}
141
110
  onClose={() => setFiltering(false)}
142
111
  />
143
112
  ) : null}
144
113
  {unclaimedFrom === "none" ? (
145
114
  <Text style={styles.text}>No repos to look in. Register a project in Paseo, or choose where Next up looks in Settings.</Text>
146
115
  ) : shown.length === 0 ? (
147
- <Text style={styles.text}>No unclaimed issues{narrowedBy.length ? ` in these ${narrowedBy.join(" and ")}` : ""}.</Text>
116
+ <Text style={styles.text}>{filter.empty}</Text>
148
117
  ) : (
149
118
  <IssueList issues={shown} claim {...rowProps} />
150
119
  )}
@@ -153,122 +122,6 @@ export function NextUpList({ assigned, unclaimed, unclaimedFrom, selected, sourc
153
122
  );
154
123
  }
155
124
 
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].
188
- // Ticks apply right away; a bottom sheet on phones, a dialog on desktop.
189
- function FilterSheet({ groups, onClear, onClose }: { groups: FilterGroup[]; onClear: () => void; onClose: () => void }) {
190
- const styles = useStyles();
191
- const any = groups.some((group) => group.active.length > 0);
192
- return (
193
- <Modal title="Filter" open onOpenChange={(open) => (open ? null : onClose())}>
194
- <Modal.Content>
195
- <KeepStyles styles={styles}>
196
- {groups.map((group) => (
197
- <View key={group.title} style={{ gap: 6 }}>
198
- <Text style={styles.muted}>{group.title}</Text>
199
- <View style={[styles.card, { backgroundColor: styles.c.surface2 }]}>
200
- {group.options.map((option, index) => (
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
- />
208
- ))}
209
- </View>
210
- </View>
211
- ))}
212
- <View style={[styles.row, { justifyContent: "flex-end" }]}>
213
- <Button label="Clear" variant="ghost" disabled={!any} onPress={onClear} />
214
- <Button label="Done" variant="solid" onPress={onClose} />
215
- </View>
216
- </KeepStyles>
217
- </Modal.Content>
218
- </Modal>
219
- );
220
- }
221
-
222
- interface FilterGroup {
223
- title: string;
224
- options: FilterOption[];
225
- active: string[];
226
- onToggle: (id: string) => void;
227
- }
228
-
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 }) {
243
- const styles = useStyles();
244
- const { hovered, hover } = useHover();
245
- const checked = state === "on";
246
- const color = githubColor(styles, option.color);
247
- return (
248
- <Pressable
249
- accessibilityRole="checkbox"
250
- accessibilityState={{ checked: state === "partial" ? "mixed" : checked }}
251
- aria-checked={state === "partial" ? "mixed" : checked}
252
- accessibilityLabel={option.label}
253
- onPress={onPress}
254
- {...hover}
255
- style={({ pressed }) => [
256
- styles.row,
257
- { paddingVertical: 10, paddingRight: 12, paddingLeft: option.indent ? 40 : 12, backgroundColor: pressed || hovered ? styles.c.border : "transparent" },
258
- first ? null : { borderTopWidth: 1, borderTopColor: styles.c.surface1 },
259
- ]}
260
- >
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>
268
- </Pressable>
269
- );
270
- }
271
-
272
125
  function IssueList({ issues, claim, ...rowProps }: RowProps & { issues: NextUpIssue[]; claim: boolean }) {
273
126
  return (
274
127
  <CardList>