@andrioid/paseo-attention-span 0.6.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 (71) hide show
  1. package/OVERVIEW.md +3 -1
  2. package/client/attention-screen.tsx +61 -1174
  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 +12 -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 +22 -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/ui.tsx +23 -14
  17. package/client/wrap-up.tsx +151 -85
  18. package/docs/architecture.md +22 -11
  19. package/docs/screenshots/desktop-dark-doing-acknowledge.png +0 -0
  20. package/docs/screenshots/desktop-dark-doing-clear.png +0 -0
  21. package/docs/screenshots/desktop-dark-doing-issue-sheet.png +0 -0
  22. package/docs/screenshots/desktop-dark-doing-reviewers.png +0 -0
  23. package/docs/screenshots/desktop-dark-doing-sheet.png +0 -0
  24. package/docs/screenshots/desktop-dark-doing-wrap-dirty.png +0 -0
  25. package/docs/screenshots/desktop-dark-doing-wrap-multi.png +0 -0
  26. package/docs/screenshots/desktop-dark-doing-wrap.png +0 -0
  27. package/docs/screenshots/desktop-dark-doing.png +0 -0
  28. package/docs/screenshots/desktop-dark-next-up-setup.png +0 -0
  29. package/docs/screenshots/desktop-dark-next-up.png +0 -0
  30. package/docs/screenshots/desktop-dark-settings.png +0 -0
  31. package/docs/screenshots/phone-dark-doing.png +0 -0
  32. package/docs/screenshots/phone-light-next-up-filtered.png +0 -0
  33. package/index.client.tsx +19 -0
  34. package/index.server.ts +43 -26
  35. package/package.json +2 -1
  36. package/requirements.yaml +8 -3
  37. package/server/actions.ts +2 -1
  38. package/server/archive.ts +146 -67
  39. package/server/archived.ts +12 -16
  40. package/server/changes.ts +34 -54
  41. package/server/classify.ts +142 -136
  42. package/server/feedback.ts +2 -6
  43. package/server/fetch.ts +262 -0
  44. package/server/fixture.ts +83 -14
  45. package/server/github-types.ts +3 -1
  46. package/server/markdown.ts +3 -1
  47. package/server/port.ts +46 -0
  48. package/server/queries.ts +33 -23
  49. package/server/service.ts +155 -272
  50. package/server/setup.ts +15 -14
  51. package/server/store.ts +94 -80
  52. package/server/update.ts +34 -13
  53. package/server/view.ts +16 -15
  54. package/shared/archive.ts +116 -13
  55. package/shared/attention.ts +50 -18
  56. package/shared/changes.ts +2 -1
  57. package/shared/config.ts +2 -6
  58. package/shared/drafting.ts +17 -0
  59. package/shared/feedback.ts +6 -5
  60. package/shared/format.ts +2 -1
  61. package/shared/history-report.ts +2 -1
  62. package/shared/item-sessions.ts +76 -0
  63. package/shared/item-view.ts +223 -0
  64. package/shared/linked-sessions.ts +59 -8
  65. package/shared/names.ts +17 -0
  66. package/shared/new-issue.ts +129 -0
  67. package/shared/next-up-filter.ts +137 -0
  68. package/shared/paging.ts +16 -0
  69. package/shared/rpc.ts +23 -10
  70. package/shared/setup.ts +3 -1
  71. package/shared/wrap-up.ts +20 -23
@@ -0,0 +1,237 @@
1
+ import { usePaseo, useRpc } from "@getpaseo/plugin/client";
2
+ import { Markdown, TextInput, useToast } from "@getpaseo/plugin/client/ui";
3
+ import { useQuery } from "@tanstack/react-query";
4
+ import { useState } from "react";
5
+ import { Text, View } from "react-native";
6
+ import { checkoutPr, type Item, type Reviewer } from "../shared/attention";
7
+ import type { AttentionConfig } from "../shared/config";
8
+ import { ago } from "../shared/format";
9
+ import { renderPrompt } from "../shared/prompts";
10
+ import * as rpc from "../shared/rpc";
11
+ import type { OptionsSpec } from "./item-actions";
12
+ import { branchWorkspaces, findCheckout, githubProjects, listProfiles, noProjectMessage, resolveAgentConfig, startSession, useStartRpcs } from "./sessions";
13
+ import { Dialog } from "./sheet";
14
+ import { Avatar, Button, CheckRow, Loading, TablerIcon, Toggle, useStyles } from "./ui";
15
+
16
+ // The dialogs a card or the screen opens before acting: which comments to 👍, who should review, a session's options, and
17
+ // where an issue's code lives.
18
+
19
+ // Pick which waiting comments get a 👍, after reading them in full; all are picked to start [MEN-07].
20
+ export function AcknowledgeSheet({ item, onReact, onClose }: { item: Item; onReact: (ids: string[]) => void; onClose: () => void }) {
21
+ const styles = useStyles();
22
+ const comments = item.person?.comments ?? [];
23
+ const [picked, setPicked] = useState(() => new Set(comments.map((c) => c.id)));
24
+ const toggle = (id: string) => setPicked((now) => (now.has(id) ? new Set([...now].filter((other) => other !== id)) : new Set([...now, id])));
25
+ return (
26
+ <Dialog title={`Acknowledge: ${item.title}`} onClose={onClose}>
27
+ <View style={styles.row}>
28
+ <TablerIcon name="thumbUp" size={14} />
29
+ <Text style={[styles.muted, { flexShrink: 1 }]}>Tells them you've seen it, and clears it from your list.</Text>
30
+ </View>
31
+ {comments.map((c) => (
32
+ <CheckRow key={c.id} checked={picked.has(c.id)} label={`Comment from ${c.author}`} onPress={() => toggle(c.id)} style={[styles.quote, styles.row, { alignItems: "flex-start", gap: 10 }]}>
33
+ <View style={{ flex: 1, gap: 4 }}>
34
+ <Text style={{ color: styles.c.foreground, fontSize: 12, fontWeight: "600" }}>
35
+ {c.author} <Text style={[styles.muted, { fontWeight: "400" }]}>· {ago(c.createdAt)}</Text>
36
+ </Text>
37
+ <Markdown>{c.body}</Markdown>
38
+ </View>
39
+ </CheckRow>
40
+ ))}
41
+ <View style={styles.wrap}>
42
+ <Button
43
+ label={`${picked.size} comment${picked.size === 1 ? "" : "s"}`}
44
+ icon="thumbUp"
45
+ accessibilityLabel={`Acknowledge ${picked.size} comment${picked.size === 1 ? "" : "s"}`}
46
+ variant="solid"
47
+ disabled={picked.size === 0}
48
+ onPress={() => onReact(comments.filter((c) => picked.has(c.id)).map((c) => c.id))}
49
+ />
50
+ <Button label="Cancel" onPress={onClose} />
51
+ </View>
52
+ </Dialog>
53
+ );
54
+ }
55
+
56
+ // Who should review a PR: GitHub's suggestions, who reviewed my other PRs in the repo, its teams, or anyone typed in.
57
+ // All start unticked; requesting keeps whoever is already asked [PRS-12].
58
+ export function ReviewerSheet({
59
+ item,
60
+ afterReady,
61
+ onRequest,
62
+ onClose,
63
+ }: {
64
+ item: Item;
65
+ afterReady: boolean;
66
+ onRequest: (reviewers: string[]) => void;
67
+ onClose: () => void;
68
+ }) {
69
+ const styles = useStyles();
70
+ const fetchReviewers = useRpc(rpc.reviewerChoices);
71
+ const choices = useQuery({ queryKey: ["attention-span", "reviewers", item.target.repo, item.target.number], queryFn: () => fetchReviewers({ target: item.target }), staleTime: 60_000 });
72
+ const [picked, setPicked] = useState<ReadonlySet<string>>(new Set());
73
+ const [typed, setTyped] = useState<Reviewer[]>([]);
74
+ const [text, setText] = useState("");
75
+ const toggle = (login: string) => setPicked((now) => (now.has(login) ? new Set([...now].filter((other) => other !== login)) : new Set([...now, login])));
76
+ // Each person or team once, in the first group that has them.
77
+ const seen = new Set<string>();
78
+ const once = (list: Reviewer[]) => list.filter((reviewer) => !seen.has(reviewer.login.toLowerCase()) && seen.add(reviewer.login.toLowerCase()));
79
+ const groups = [
80
+ { title: "Added", list: once(typed) },
81
+ { title: "Suggested by GitHub", list: once(choices.data?.suggested ?? []) },
82
+ { title: "Recent on your PRs here", list: once(choices.data?.recent ?? []) },
83
+ { title: "Teams", list: once(choices.data?.teams ?? []) },
84
+ ];
85
+ const add = () => {
86
+ const login = text.trim().replace(/^@/, "");
87
+ if (!login) return;
88
+ setTyped((now) => [...now, { login, team: login.includes("/") }]);
89
+ setPicked((now) => new Set([...now, login]));
90
+ setText("");
91
+ };
92
+ const count = `${picked.size} reviewer${picked.size === 1 ? "" : "s"}`;
93
+ return (
94
+ <Dialog title={`${afterReady ? "Ready for review" : "Request review"}: ${item.title}`} onClose={onClose}>
95
+ <Text style={styles.muted}>{afterReady ? `PR ${item.target.number} is out of draft. Who should review it?` : `Who should review PR ${item.target.number}?`}</Text>
96
+ {choices.isLoading ? <Loading text="Loading suggestions…" /> : null}
97
+ {choices.error ? <Text style={styles.danger}>Couldn't load suggestions: {(choices.error as Error).message}</Text> : null}
98
+ {groups.map(({ title, list }) =>
99
+ list.length > 0 ? (
100
+ <View key={title} style={{ gap: 4 }}>
101
+ <Text style={[styles.muted, { fontSize: 12 }]}>{title}</Text>
102
+ {list.map((reviewer) => (
103
+ <CheckRow key={reviewer.login} checked={picked.has(reviewer.login)} label={reviewer.login} onPress={() => toggle(reviewer.login)} style={[styles.row, { paddingVertical: 4 }]}>
104
+ {reviewer.team ? <TablerIcon name="claim" size={18} color={styles.c.foregroundMuted} /> : <Avatar url={reviewer.avatarUrl} />}
105
+ <Text style={{ color: styles.c.foreground, fontSize: 13 }}>{reviewer.login}</Text>
106
+ </CheckRow>
107
+ ))}
108
+ </View>
109
+ ) : null,
110
+ )}
111
+ {choices.data?.teamsNote ? <Text style={styles.muted}>{choices.data.teamsNote}</Text> : null}
112
+ <View style={styles.row}>
113
+ <TextInput
114
+ style={[styles.input, { flex: 1 }]}
115
+ placeholder="Login, or org/team"
116
+ placeholderTextColor={styles.c.foregroundMuted}
117
+ value={text}
118
+ onChangeText={setText}
119
+ onSubmitEditing={add}
120
+ autoCapitalize="none"
121
+ autoCorrect={false}
122
+ />
123
+ <Button label="Add" variant="calm" disabled={!text.trim()} onPress={add} />
124
+ </View>
125
+ <View style={styles.wrap}>
126
+ <Button
127
+ label={`Request ${count}`}
128
+ icon="claim"
129
+ variant="solid"
130
+ disabled={picked.size === 0}
131
+ onPress={() => onRequest([...picked])}
132
+ />
133
+ <Button label={afterReady ? "Skip" : "Cancel"} onPress={onClose} />
134
+ </View>
135
+ </Dialog>
136
+ );
137
+ }
138
+
139
+ // Session options in a modal: a bottom sheet on phones [SES-02].
140
+ export function SessionOptions({ spec, config, started, onClose }: { spec: OptionsSpec; config: AttentionConfig; started: (agentId: string) => Promise<void>; onClose: () => void }) {
141
+ const styles = useStyles();
142
+ const paseo = usePaseo();
143
+ const toast = useToast();
144
+ const { fetchContext, defaultBranch, fetchProviders } = useStartRpcs();
145
+ const { itemKey, kind, target } = spec;
146
+ const options = useQuery({
147
+ queryKey: ["attention-span", "options", itemKey, kind],
148
+ queryFn: async () => {
149
+ const [{ context }, profiles, checkout, defaults] = await Promise.all([
150
+ fetchContext({ kind, target }),
151
+ listProfiles(paseo),
152
+ findCheckout(paseo, config, target, defaultBranch),
153
+ // Without a ready provider, still show the options; starting reports the error.
154
+ resolveAgentConfig(paseo, fetchProviders, kind, config).catch(() => ({ label: "No agent provider is ready" })),
155
+ ]);
156
+ const workspaces = checkout.project ? await branchWorkspaces(paseo, checkout.project.projectId, checkoutPr(kind, target).head) : [];
157
+ return { prompt: renderPrompt(kind, target, context, config), profiles, checkout, workspaces, defaultLabel: defaults.label };
158
+ },
159
+ staleTime: 60_000,
160
+ });
161
+ const [workspaceId, setWorkspaceId] = useState<string>();
162
+ const [profileId, setProfileId] = useState<string>();
163
+ const [prompt, setPrompt] = useState<string | null>(null);
164
+ const [starting, setStarting] = useState(false);
165
+ const data = options.data;
166
+
167
+ async function start() {
168
+ if (!data) return;
169
+ setStarting(true);
170
+ try {
171
+ await spec.before?.();
172
+ await started(await startSession(paseo, { itemKey, kind, target, prompt: prompt ?? data.prompt, config: config, fetchProviders: fetchProviders, checkout: data.checkout, profileId, workspaceId }));
173
+ onClose();
174
+ } catch (error) {
175
+ toast.error(`Starting the session failed: ${(error as Error).message}`);
176
+ } finally {
177
+ setStarting(false);
178
+ }
179
+ }
180
+
181
+ return (
182
+ <Dialog title={spec.title} onClose={onClose}>
183
+ {options.isLoading ? <Loading text="Loading context…" /> : null}
184
+ {!options.isLoading && !data ? <Text style={styles.danger}>{(options.error as Error)?.message ?? "No options"}</Text> : null}
185
+ {data && !data.checkout.project ? <Text style={styles.danger}>{noProjectMessage(data.checkout, target)}</Text> : null}
186
+ {data?.checkout.project ? (
187
+ <View style={{ gap: 10 }}>
188
+ <Text style={styles.muted}>Workspace</Text>
189
+ <View style={styles.wrap}>
190
+ <Toggle label="New worktree" active={!workspaceId} onPress={() => setWorkspaceId(undefined)} />
191
+ {data.workspaces.map((w) => (
192
+ <Toggle key={w.id} label={w.name} active={workspaceId === w.id} onPress={() => setWorkspaceId(w.id)} />
193
+ ))}
194
+ </View>
195
+ <Text style={styles.muted}>Agent profile</Text>
196
+ <View style={styles.wrap}>
197
+ <Toggle label={data.defaultLabel} active={!profileId} onPress={() => setProfileId(undefined)} />
198
+ {data.profiles.map((p) => (
199
+ <Toggle key={p.id} label={p.name} active={profileId === p.id} onPress={() => setProfileId(p.id)} />
200
+ ))}
201
+ </View>
202
+ <Text style={styles.muted}>Prompt</Text>
203
+ <TextInput style={[styles.input, { minHeight: 180 }]} value={prompt ?? data.prompt} onChangeText={setPrompt} multiline textAlignVertical="top" />
204
+ <View style={styles.wrap}>
205
+ <Button label={starting ? "Starting…" : "Start session"} icon="agent" variant="solid" disabled={starting} onPress={() => void start()} />
206
+ <Button label="Cancel" onPress={onClose} />
207
+ </View>
208
+ </View>
209
+ ) : null}
210
+ </Dialog>
211
+ );
212
+ }
213
+
214
+ // Where an issue repo's code lives, picked from my Paseo projects and saved to config.json [SES-07].
215
+ export function CodeRepoPicker({ issueRepo, missing, onPick, onClose }: { issueRepo: string; missing: string; onPick: (repo: string) => void; onClose: () => void }) {
216
+ const styles = useStyles();
217
+ const paseo = usePaseo();
218
+ const projects = useQuery({ queryKey: ["attention-span", "github-projects"], queryFn: () => githubProjects(paseo) });
219
+ return (
220
+ <Dialog title={`Where does the code for ${issueRepo} live?`} onClose={onClose}>
221
+ <View style={{ gap: 10 }}>
222
+ <Text style={styles.text}>No Paseo project has {missing} as its GitHub remote. Pick the project that holds the code for issues in {issueRepo}.</Text>
223
+ {projects.isLoading ? <Loading text="Loading projects…" /> : null}
224
+ {projects.data?.length === 0 ? <Text style={styles.danger}>No Paseo project has a GitHub remote. Add the code repository as a project first.</Text> : null}
225
+ <View style={styles.wrap}>
226
+ {projects.data?.map((project) => (
227
+ <Button key={project.projectId} label={project.repo} icon="play" variant="calm" onPress={() => onPick(project.repo)} />
228
+ ))}
229
+ </View>
230
+ <Text style={styles.muted}>Saved to codeRepos in config.json, so the next start goes straight there.</Text>
231
+ <View style={styles.wrap}>
232
+ <Button label="Cancel" onPress={onClose} />
233
+ </View>
234
+ </View>
235
+ </Dialog>
236
+ );
237
+ }
@@ -1,18 +1,10 @@
1
- import type { AgentSummary, Chip } from "../shared/attention";
1
+ import type { AgentSummary } from "../shared/attention";
2
2
  import { ago } from "../shared/format";
3
+ import { sessionBadge } from "../shared/item-view";
3
4
  import type { SheetEntry } from "./sheet";
4
5
 
5
- // A session started from the item, as a signal [ATT-07].
6
- export function agentSignal(agent: AgentSummary): Chip {
7
- if (agent.requiresAttention) return { text: "agent needs you", tone: "warn" };
8
- if (agent.status === "running" || agent.status === "initializing") return { text: "agent working", tone: "good" };
9
- if (agent.status === "error") return { text: "agent failed", tone: "bad" };
10
- return { text: "agent idle", tone: "neutral" };
11
- }
12
-
13
6
  // A session as a sheet line, under the name of what started it: it opens the session, its state at the end [SES-03, ATT-07].
14
7
  export function sessionEntry(agent: AgentSummary, label: string, onOpen: (agentId: string) => void): SheetEntry {
15
- const signal = agentSignal(agent);
16
8
  // Non-breaking, so "2h ago" doesn't split across lines beside a badge on phones.
17
9
  const when = agent.lastActivityAt ? `${ago(agent.lastActivityAt)} ago`.replace(/ /g, "\u00a0") : null;
18
10
  return {
@@ -20,7 +12,7 @@ export function sessionEntry(agent: AgentSummary, label: string, onOpen: (agentI
20
12
  icon: "agent",
21
13
  label,
22
14
  detail: [agent.title, when].filter(Boolean).join(" · ") || undefined,
23
- badge: { ...signal, text: signal.text.replace(/^agent /, "") },
15
+ badge: sessionBadge(agent),
24
16
  onPress: () => onOpen(agent.id),
25
17
  };
26
18
  }
@@ -1,11 +1,15 @@
1
1
  import { usePaseo, useRpc } from "@getpaseo/plugin/client";
2
2
  import { useQuery, useQueryClient } from "@tanstack/react-query";
3
- import { type AgentSummary, checkoutPr, type SessionWorkspace, sessionTitle, type Target } from "../shared/attention";
4
- import { linkedSessions } from "../shared/linked-sessions";
3
+ import { useEffect } from "react";
4
+ import { type AgentSummary, type AttentionView, checkoutPr, sessionTitle, type Target } from "../shared/attention";
5
+ import { closedBranches } from "../shared/linked-sessions";
6
+ import { ITEM_LABEL, KIND_LABEL, LABEL, SESSION_LABELS, sessionsFrom } from "../shared/item-sessions";
7
+ import { everyPage } from "../shared/paging";
5
8
  import { chooseAgent, type ReadyProvider } from "../shared/providers";
6
9
  import { type AttentionConfig, codeRepoFor, githubRepoOf, SessionKind } from "../shared/config";
7
- import { getAttention } from "../shared/rpc";
10
+ import * as rpc from "../shared/rpc";
8
11
  import { VIEW_QUERY_KEY } from "./data";
12
+ import { sameName } from "../shared/names";
9
13
 
10
14
  type Paseo = ReturnType<typeof usePaseo>;
11
15
 
@@ -18,76 +22,64 @@ export const AGENTS_QUERY_KEY = ["attention-span", "agents"] as const;
18
22
  export function useItemAgents() {
19
23
  const paseo = usePaseo();
20
24
  const queryClient = useQueryClient();
21
- const fetchAttention = useRpc(getAttention);
25
+ const fetchAttention = useRpc(rpc.getAttention);
26
+ // A list that brings other merged branches than the last poll linked by polls again at once, so a session on a branch
27
+ // just merged reaches Wrap up without waiting for the next round [ATT-22, FRESH-03]. A poll already running finishes
28
+ // first, then sees the change and polls once more.
29
+ const branchesNow = () => closedBranches(queryClient.getQueryData<AttentionView>(VIEW_QUERY_KEY) ?? {});
30
+ const pollAgain = () => {
31
+ if (signature(branchesNow()) !== linkedBy.get(queryClient)) void queryClient.refetchQueries({ queryKey: AGENTS_QUERY_KEY }, { cancelRefetch: false });
32
+ };
33
+ useEffect(
34
+ () =>
35
+ queryClient.getQueryCache().subscribe((event) => {
36
+ if (event.type === "updated" && event.query.queryKey[1] === VIEW_QUERY_KEY[1]) pollAgain();
37
+ }),
38
+ [queryClient],
39
+ );
22
40
  return useQuery({
23
41
  queryKey: AGENTS_QUERY_KEY,
24
42
  refetchInterval: 15_000,
25
43
  queryFn: async () => {
26
44
  const before = queryClient.getQueryData<AgentSummary[]>(AGENTS_QUERY_KEY);
27
- const agents = await itemAgents(paseo);
45
+ // My merged and closed PRs' branches, from the list already loaded, for sessions Paseo no longer links [ATT-22].
46
+ const branches = branchesNow();
47
+ linkedBy.set(queryClient, signature(branches));
48
+ const agents = await itemAgents(paseo, branches);
28
49
  const now = new Set(agents.map((agent) => agent.id));
29
50
  if (before?.some((agent) => !now.has(agent.id))) {
30
51
  await fetchAttention({ cached: true })
31
52
  .then((view) => queryClient.setQueryData(VIEW_QUERY_KEY, view))
32
53
  .catch(() => {}); // the view's own poll catches up
33
54
  }
55
+ // A list that arrived while this poll ran: once it's done, poll again.
56
+ setTimeout(pollAgain, 0);
34
57
  return agents;
35
58
  },
36
59
  });
37
60
  }
38
61
 
39
- // Labels tie an agent to the item it works on [ATT-07, SES-03].
40
- export const LABEL = "attention-span";
41
- export const ITEM_LABEL = "attention-span-item";
42
- // The action it was started for, so the sheet shows it in that action's line.
43
- export const KIND_LABEL = "attention-span-kind";
44
- // Sessions started under the plugin's earlier names, "GitHub attention" and "GitHub inbox".
45
- const OLD_LABELS = ["github-attention", "github-inbox"];
46
-
47
- // What Paseo knows about the workspace a session runs in, for Wrap up's unsaved-work check [ATT-22].
48
- function sessionWorkspace(workspace: (Awaited<ReturnType<Paseo["workspaces"]["list"]>>["entries"][number])): SessionWorkspace {
49
- const git = workspace.gitRuntime;
50
- return {
51
- kind: workspace.workspaceKind,
52
- name: workspace.title ?? workspace.name,
53
- directory: workspace.workspaceDirectory ?? workspace.projectRootPath,
54
- ...(git?.currentBranch ? { branch: git.currentBranch } : {}),
55
- ...(typeof git?.isDirty === "boolean" ? { dirty: git.isDirty } : {}),
56
- ...(typeof git?.aheadOfOrigin === "number" ? { ahead: git.aheadOfOrigin } : {}),
57
- };
58
- }
62
+ const signature = (branches: Map<string, string>) => [...branches].join("\n");
63
+ // The branches the last poll linked by, one record per app, shared by the screen's and the sidebar's copies of the poll.
64
+ const linkedBy = new WeakMap<object, string>();
65
+
66
+ // Labels tie an agent to the item it works on [ATT-07, SES-03]; kept with the rest of the session list in shared.
67
+ export { ITEM_LABEL, KIND_LABEL, LABEL };
59
68
 
60
- // Agents started from Attention Span, each with the item it was started on, and the agents
61
- // started outside it in a workspace that belongs to an item [SES-08].
62
- export async function itemAgents(paseo: Paseo): Promise<AgentSummary[]> {
63
- const labels = [LABEL, ...OLD_LABELS];
69
+ // Agents started from Attention Span, each with the item it was started on, and the agents started outside it in a
70
+ // workspace that belongs to an item [SES-08]. Every page, so a session or sub-agent past the first isn't missed [ATT-22].
71
+ export async function itemAgents(paseo: Paseo, branches = new Map<string, string>()): Promise<AgentSummary[]> {
64
72
  const [lists, all, workspaces] = await Promise.all([
65
- Promise.all(labels.map((label) => paseo.agents.list({ filter: { labels: { [label]: "1" } } }))),
66
- paseo.agents.list(),
73
+ Promise.all(SESSION_LABELS.map((label) => everyPage((page) => paseo.agents.list({ filter: { labels: { [label]: "1" } }, page })))),
74
+ everyPage((page) => paseo.agents.list({ page })),
67
75
  paseo.workspaces.list(),
68
76
  ]);
69
- const byId = new Map<string, AgentSummary>();
70
- for (const { agent } of lists.flatMap((list) => list.entries)) {
71
- const itemKey = labels.map((label) => agent.labels?.[`${label}-item`]).find(Boolean);
72
- if (!itemKey || agent.archivedAt) continue;
73
- byId.set(agent.id, {
74
- id: agent.id,
75
- itemKey,
76
- kind: SessionKind.safeParse(agent.labels?.[KIND_LABEL]).data,
77
- status: agent.status,
78
- requiresAttention: !!agent.requiresAttention,
79
- title: agent.title ?? null,
80
- workspaceId: agent.workspaceId ?? null,
81
- lastActivityAt: agent.updatedAt ?? null,
82
- });
83
- }
84
- const labelled = [...byId.values()];
85
- const unlabelled = all.entries.map((entry) => entry.agent).filter((agent) => !labels.some((label) => agent.labels?.[label]));
86
- const byWorkspace = new Map(workspaces.entries.map((workspace) => [workspace.id, sessionWorkspace(workspace)]));
87
- return [...labelled, ...linkedSessions(labelled, unlabelled, workspaces.entries)].map((agent) => {
88
- const workspace = agent.workspaceId ? byWorkspace.get(agent.workspaceId) : undefined;
89
- return workspace ? { ...agent, workspace } : agent;
90
- });
77
+ return sessionsFrom(
78
+ lists.flat().map((entry) => entry.agent),
79
+ all.map((entry) => entry.agent),
80
+ workspaces.entries,
81
+ branches,
82
+ );
91
83
  }
92
84
 
93
85
  export interface ProjectMatch {
@@ -110,7 +102,7 @@ export async function githubProjects(paseo: Paseo): Promise<GitHubProject[]> {
110
102
 
111
103
  // The local checkout is the registered Paseo project with the repo's GitHub remote [SES-05].
112
104
  export async function findProject(paseo: Paseo, repo: string): Promise<ProjectMatch | null> {
113
- return (await githubProjects(paseo)).find((project) => project.repo.toLowerCase() === repo.toLowerCase()) ?? null;
105
+ return (await githubProjects(paseo)).find((project) => sameName(project.repo, repo)) ?? null;
114
106
  }
115
107
 
116
108
  export interface Checkout {
@@ -129,12 +121,12 @@ export async function findCheckout(
129
121
  ): Promise<Checkout> {
130
122
  const repo = target.kind === "issue" ? codeRepoFor(config, target.repo) : target.repo;
131
123
  const project = await findProject(paseo, repo);
132
- if (repo.toLowerCase() === target.repo.toLowerCase()) return { repo, project, baseBranch: target.defaultBranch };
124
+ if (sameName(repo, target.repo)) return { repo, project, baseBranch: target.defaultBranch };
133
125
  return { repo, project, baseBranch: project ? ((await defaultBranch(repo)) ?? undefined) : undefined };
134
126
  }
135
127
 
136
128
  export function noProjectMessage(checkout: Checkout, target: Target): string {
137
- const where = checkout.repo === target.repo ? checkout.repo : `${checkout.repo}, where ${target.repo}'s code lives,`;
129
+ const where = sameName(checkout.repo, target.repo) ? checkout.repo : `${checkout.repo}, where ${target.repo}'s code lives,`;
138
130
  return `No Paseo project has ${where} as its GitHub remote. Add the repository as a project first.`;
139
131
  }
140
132
 
@@ -166,6 +158,15 @@ type AgentConfig = Parameters<Paseo["agents"]["create"]>[0]["config"];
166
158
  // Asks the plugin's server, whose snapshot always has the entries [SES-06].
167
159
  export type FetchProviders = () => Promise<ReadyProvider[]>;
168
160
 
161
+ // What a start asks the plugin's server: the prompt's context, a repo's default branch, and the ready providers [SES-01, SES-02].
162
+ export function useStartRpcs() {
163
+ const fetchContext = useRpc(rpc.sessionContext);
164
+ const fetchDefaultBranch = useRpc(rpc.defaultBranch);
165
+ const fetchReadyProviders = useRpc(rpc.readyProviders);
166
+ const fetchProviders: FetchProviders = () => fetchReadyProviders({}).then((result) => result.providers);
167
+ return { fetchContext, fetchProviders, defaultBranch: async (repo: string) => (await fetchDefaultBranch({ repo })).name };
168
+ }
169
+
169
170
  // The profile configured for the session type, then "default", then Paseo's defaults [SES-01, SES-06].
170
171
  export async function resolveAgentConfig(
171
172
  paseo: Paseo,
@@ -177,7 +178,7 @@ export async function resolveAgentConfig(
177
178
  const { config: daemon } = await paseo.config.get();
178
179
  const profiles = daemon.agentProfiles ?? [];
179
180
  const byName = (name: string | undefined) =>
180
- name ? profiles.find((p) => p.id === name || p.name.toLowerCase() === name.toLowerCase()) : undefined;
181
+ name ? profiles.find((p) => p.id === name || sameName(p.name, name)) : undefined;
181
182
  const profile = profileId ? byName(profileId) : (byName(config.profiles[kind]) ?? byName(config.profiles.default));
182
183
  // A profile that names its model needs no provider lookup.
183
184
  const providers = profile?.model ? [] : await fetchProviders();
package/client/setup.tsx CHANGED
@@ -5,6 +5,7 @@ import { AttentionConfig } from "../shared/config";
5
5
  import type { SetupStatus } from "../shared/setup";
6
6
  import { githubProjects, listProfiles } from "./sessions";
7
7
  import { Button, useCopy, useStyles } from "./ui";
8
+ import { sameName } from "../shared/names";
8
9
 
9
10
  type State = "done" | "missing" | "optional";
10
11
 
@@ -118,7 +119,7 @@ function Mark({ state }: { state: State }) {
118
119
 
119
120
  // Which agent sessions will use: the profile named for the session type, then "default", then Paseo's defaults [SES-06].
120
121
  function agentLine(names: string[], profiles: AttentionConfig["profiles"]): Line {
121
- const has = (name: string) => names.some((candidate) => candidate.toLowerCase() === name.toLowerCase());
122
+ const has = (name: string) => names.some((candidate) => sameName(candidate, name));
122
123
  const fallback = has(profiles.default) ? `the ${profiles.default} profile` : "Paseo's default agent";
123
124
  const review = has(profiles.review ?? "") ? `the ${profiles.review} profile` : fallback;
124
125
  if (!has(profiles.default) && !has(profiles.review ?? ""))
package/client/sheet.tsx CHANGED
@@ -4,11 +4,92 @@ import { useQueryClient } from "@tanstack/react-query";
4
4
  import { type ReactNode, useEffect, useRef } from "react";
5
5
  import { Animated, Platform, Pressable, Text, View } from "react-native";
6
6
  import { type Chip, type ItemDetails, ownStack, type Target } from "../shared/attention";
7
+ import type { FilterGroup, FilterOption } from "../shared/next-up-filter";
8
+ import { githubColor } from "./entity";
7
9
  import type { IconName } from "./icons";
8
- import { Button, Hint, HintArea, KeepStyles, LINE_HEIGHT, REST_MS, Signal, Skeleton, TablerIcon, toneColor, useCopy, useHover, useStyles } from "./ui";
10
+ import { Button, CheckRow, Hint, HintArea, KeepStyles, LINE_HEIGHT, REST_MS, Signal, Skeleton, TablerIcon, toneColor, useCopy, useHover, useStyles } from "./ui";
9
11
 
10
- // Every dialog and sheet in the plugin is Paseo's Modal.
11
- export { Modal };
12
+ // Every dialog and sheet in the plugin is Paseo's Modal: a bottom sheet on phones, a dialog on desktop.
13
+ export function Dialog({ title, onClose, children }: { title: string; onClose: () => void; children: ReactNode }) {
14
+ const styles = useStyles();
15
+ return (
16
+ <Modal title={title} open onOpenChange={(open) => (open ? null : onClose())}>
17
+ <Modal.Content>
18
+ <KeepStyles styles={styles}>{children}</KeepStyles>
19
+ </Modal.Content>
20
+ </Modal>
21
+ );
22
+ }
23
+
24
+ // A filter's ticks in groups, applied right away: Next up's sources, projects and scopes, and what History's weeks show
25
+ // [NXT-03, NXT-09, HIS-07].
26
+ export function FilterSheet<K extends string>({
27
+ groups,
28
+ onToggle,
29
+ onClear,
30
+ onClose,
31
+ }: {
32
+ groups: (Omit<FilterGroup, "kind"> & { kind: K })[];
33
+ onToggle: (kind: K, id: string) => void;
34
+ onClear: () => void;
35
+ onClose: () => void;
36
+ }) {
37
+ const styles = useStyles();
38
+ const any = groups.some((group) => group.active.length > 0);
39
+ return (
40
+ <Dialog title="Filter" onClose={onClose}>
41
+ {groups.map((group) => (
42
+ <View key={group.title} style={{ gap: 6 }}>
43
+ <Text style={styles.muted}>{group.title}</Text>
44
+ <View style={[styles.card, { backgroundColor: styles.c.surface2 }]}>
45
+ {group.options.map((option, index) => (
46
+ <FilterRow
47
+ key={`${option.id}:${option.strong ? "project" : "leaf"}`}
48
+ option={option}
49
+ state={option.state ?? (group.active.includes(option.id) ? "on" : "off")}
50
+ first={index === 0}
51
+ onPress={() => onToggle(group.kind, option.id)}
52
+ />
53
+ ))}
54
+ </View>
55
+ </View>
56
+ ))}
57
+ <View style={[styles.row, { justifyContent: "flex-end" }]}>
58
+ <Button label="Clear" variant="ghost" disabled={!any} onPress={onClear} />
59
+ <Button label="Done" variant="solid" onPress={onClose} />
60
+ </View>
61
+ </Dialog>
62
+ );
63
+ }
64
+
65
+ function FilterRow({ option, state, first, onPress }: { option: FilterOption; state: "on" | "partial" | "off"; first: boolean; onPress: () => void }) {
66
+ const styles = useStyles();
67
+ const { hovered, hover } = useHover();
68
+ const color = githubColor(styles, option.color);
69
+ return (
70
+ <CheckRow
71
+ checked={state === "partial" ? "mixed" : state === "on"}
72
+ label={option.label}
73
+ disabled={option.disabled}
74
+ onPress={onPress}
75
+ {...hover}
76
+ style={({ pressed }) => [
77
+ styles.row,
78
+ { paddingVertical: 10, paddingRight: 12, paddingLeft: option.indent ? 40 : 12, backgroundColor: !option.disabled && (pressed || hovered) ? styles.c.border : "transparent" },
79
+ first ? null : { borderTopWidth: 1, borderTopColor: styles.c.surface1 },
80
+ option.disabled ? { opacity: 0.65 } : null,
81
+ ]}
82
+ >
83
+ {option.indent ? (
84
+ <View
85
+ style={{ width: 8, height: 8, borderRadius: 4, ...(option.color ? { backgroundColor: color ?? styles.c.foregroundMuted } : { borderWidth: 1.5, borderColor: styles.c.foregroundMuted }) }}
86
+ />
87
+ ) : null}
88
+ <Text style={[styles.text, { flex: 1 }, option.strong ? { fontWeight: "600" } : null, option.dim ? { opacity: 0.45 } : null]}>{option.label}</Text>
89
+ {option.note ? <Text style={styles.muted}>{option.note}</Text> : null}
90
+ </CheckRow>
91
+ );
92
+ }
12
93
 
13
94
  // Tapping a card opens its sheet at once: what the card knows, every action saying what it will do, then what's fetched.
14
95
  // Fetched details go last, so the actions don't move when they arrive. A bottom sheet on phones, a dialog on desktop [ATT-06].
@@ -46,18 +127,14 @@ export function ActionSheet({ title, top, entries, bottom, onClose }: { title: s
46
127
  const work = entries.filter((entry) => !entry.housekeeping);
47
128
  const housekeeping = entries.filter((entry) => entry.housekeeping);
48
129
  return (
49
- <Modal title={title} open onOpenChange={(open) => (open ? null : onClose())}>
50
- <Modal.Content>
51
- <KeepStyles styles={styles}>
52
- <HintArea style={{ gap: 10 }}>{top}</HintArea>
53
- <View style={{ gap: 10 }}>
54
- <EntryGroup entries={work} />
55
- <EntryGroup entries={housekeeping} />
56
- </View>
57
- <View style={{ gap: 10 }}>{bottom}</View>
58
- </KeepStyles>
59
- </Modal.Content>
60
- </Modal>
130
+ <Dialog title={title} onClose={onClose}>
131
+ <HintArea style={{ gap: 10 }}>{top}</HintArea>
132
+ <View style={{ gap: 10 }}>
133
+ <EntryGroup entries={work} />
134
+ <EntryGroup entries={housekeeping} />
135
+ </View>
136
+ <View style={{ gap: 10 }}>{bottom}</View>
137
+ </Dialog>
61
138
  );
62
139
  }
63
140
 
package/client/ui.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { PluginScreenProps } from "@getpaseo/plugin/client";
2
2
  import { copyText, Icon, useToast } from "@getpaseo/plugin/client/ui";
3
3
  import { createContext, type ReactNode, type RefObject, useContext, useEffect, useMemo, useRef, useState } from "react";
4
- import { ActivityIndicator, Animated, Dimensions, Easing, Image, Platform, Pressable, type StyleProp, Text, View, type ViewStyle } from "react-native";
4
+ import { ActivityIndicator, Animated, Dimensions, Easing, Image, Platform, Pressable, type PressableProps, type StyleProp, Text, View, type ViewStyle } from "react-native";
5
5
  import type { Chip } from "../shared/attention";
6
6
  import { HINT_GAP, type HintPlacement, hintPlacement } from "../shared/hint";
7
7
  import { ICONS, type IconName } from "./icons";
@@ -341,6 +341,22 @@ export function Button({
341
341
  );
342
342
  }
343
343
 
344
+ // Filter, with how many ticks are on [NXT-03, HIS-07].
345
+ export function FilterButton({ count, onPress }: { count: number; onPress: () => void }) {
346
+ return <Button label={count ? `Filter · ${count}` : "Filter"} accessibilityLabel={count ? `Filter, ${count} on` : "Filter"} icon="filter" variant={count ? "calm" : "ghost"} onPress={onPress} />;
347
+ }
348
+
349
+ // A tick box, then what it's for: filters and pickers. Mixed is a project with some of its statuses ticked [NXT-12].
350
+ export function CheckRow({ checked, label, children, ...pressable }: { checked: boolean | "mixed"; label: string; children: ReactNode } & Omit<PressableProps, "children">) {
351
+ const styles = useStyles();
352
+ return (
353
+ <Pressable accessibilityRole="checkbox" accessibilityState={{ checked, disabled: !!pressable.disabled }} aria-checked={checked} accessibilityLabel={label} {...pressable}>
354
+ <TablerIcon name={checked === "mixed" ? "squareMinus" : checked ? "squareCheck" : "square"} size={18} color={checked ? styles.action : styles.c.foregroundMuted} />
355
+ {children}
356
+ </Pressable>
357
+ );
358
+ }
359
+
344
360
  // Sentence case, with the count as quiet text.
345
361
  // The icon may be a picture instead, like the avatar of whom Waiting's work waits on.
346
362
  export function SectionHeader({ icon, title, count, action }: { icon: IconName | ReactNode; title: string; count: number; action?: ReactNode }) {
@@ -357,19 +373,12 @@ export function SectionHeader({ icon, title, count, action }: { icon: IconName |
357
373
  );
358
374
  }
359
375
 
360
- // A group that opens in place, like a week's reviews in History: a chevron, its name and count. Each opens on its own, so
361
- // they don't read as a choice between them [HIS-02, HIS-06].
362
- export function Disclosure({ label, count, open, onPress }: { label: string; count: number; open: boolean; onPress: () => void }) {
363
- const styles = useStyles();
364
- return (
365
- <Pressable accessibilityRole="button" accessibilityLabel={`${label}, ${count}`} accessibilityState={{ expanded: open }} onPress={onPress} hitSlop={6} style={[styles.row, { gap: 6, paddingVertical: 4 }]}>
366
- <TablerIcon name={open ? "chevronDown" : "chevronRight"} size={14} />
367
- <Text style={{ color: styles.c.foreground, fontSize: 13, fontWeight: "600" }}>
368
- {label}
369
- <Text style={{ color: styles.c.foregroundMuted, fontWeight: "400" }}> · {count}</Text>
370
- </Text>
371
- </Pressable>
372
- );
376
+ // A theme colour, see-through, so a badge reads on any surface; colours that aren't #rrggbb fall back to none.
377
+ export function tint(color: string, alpha: number): string {
378
+ const hex = /^#([0-9a-f]{6})/i.exec(color)?.[1];
379
+ if (!hex) return "transparent";
380
+ const [r, g, b] = [0, 2, 4].map((at) => parseInt(hex.slice(at, at + 2), 16));
381
+ return `rgba(${r}, ${g}, ${b}, ${alpha})`;
373
382
  }
374
383
 
375
384
  // Copy text and say so, since an icon-only button gives no other sign it worked.