paseo-follow-up 1.4.0-beta.2 → 1.4.0-beta.21

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 (92) hide show
  1. package/OVERVIEW.md +15 -4
  2. package/README.md +59 -6
  3. package/client/about.tsx +22 -12
  4. package/client/agents.tsx +132 -0
  5. package/client/brief.tsx +200 -72
  6. package/client/chat.tsx +12 -4
  7. package/client/display.tsx +62 -11
  8. package/client/header.tsx +40 -19
  9. package/client/home-chrome.tsx +135 -40
  10. package/client/home-list.tsx +90 -35
  11. package/client/home-view.ts +66 -8
  12. package/client/home.tsx +268 -77
  13. package/client/inbox-store.ts +15 -7
  14. package/client/keys.ts +3 -0
  15. package/client/kit.tsx +46 -15
  16. package/client/large.tsx +9 -10
  17. package/client/live.tsx +8 -6
  18. package/client/needs-you.tsx +36 -8
  19. package/client/onboarding.tsx +455 -0
  20. package/client/panel.tsx +98 -23
  21. package/client/pill.tsx +41 -21
  22. package/client/pr-controls.tsx +38 -14
  23. package/client/pr-sheet.tsx +8 -6
  24. package/client/questions.tsx +6 -4
  25. package/client/reviewers.tsx +63 -21
  26. package/client/settings-shell.tsx +77 -0
  27. package/client/settings.tsx +145 -49
  28. package/client/shipping.tsx +186 -0
  29. package/client/spec.tsx +1 -1
  30. package/client/stacks.tsx +4 -3
  31. package/client/tasks.tsx +1 -1
  32. package/client/theme.ts +21 -0
  33. package/client/visibility.ts +7 -0
  34. package/client/workspace-data.ts +37 -0
  35. package/docs/screenshots/decision-card-answered-phone-light.png +0 -0
  36. package/docs/screenshots/decision-card-expanded-chat-light.png +0 -0
  37. package/docs/screenshots/decision-card-partial-phone-dark.png +0 -0
  38. package/docs/screenshots/decision-card-unanswered-phone-dark.png +0 -0
  39. package/index.client.tsx +27 -8
  40. package/index.server.ts +257 -24
  41. package/package.json +5 -3
  42. package/server/about.ts +15 -4
  43. package/server/agent-actions.ts +75 -6
  44. package/server/agent-hook.mjs +54 -16
  45. package/server/agent-parity.ts +149 -0
  46. package/server/agent-settings.ts +124 -0
  47. package/server/ai-jobs.ts +88 -23
  48. package/server/daemon.ts +165 -105
  49. package/server/directory.ts +165 -0
  50. package/server/discovery.ts +34 -6
  51. package/server/engine.ts +31 -9
  52. package/server/etag.ts +14 -0
  53. package/server/github.ts +66 -5
  54. package/server/hook-source.ts +1 -1
  55. package/server/inbox-directory.ts +14 -19
  56. package/server/inbox.ts +28 -1
  57. package/server/mcp-source.ts +1 -1
  58. package/server/mcp.d.mts +3 -1
  59. package/server/mcp.mjs +83 -10
  60. package/server/native-tools.ts +3 -2
  61. package/server/onboarding.ts +101 -0
  62. package/server/overseer-prompt-source.ts +1 -1
  63. package/server/overseer-prompt.md +1 -0
  64. package/server/overseer.ts +72 -8
  65. package/server/pr-actions.ts +91 -15
  66. package/server/pr-workflow.ts +188 -0
  67. package/server/questions.ts +1 -1
  68. package/server/ranker.ts +431 -0
  69. package/server/recovery-config.ts +17 -0
  70. package/server/scopes.ts +20 -8
  71. package/server/tasks.ts +9 -3
  72. package/server/trust-bypass.ts +125 -0
  73. package/shared/about.ts +8 -3
  74. package/shared/activity.ts +3 -1
  75. package/shared/agent-settings.ts +169 -0
  76. package/shared/attention.ts +8 -4
  77. package/shared/brief.ts +44 -0
  78. package/shared/chat.ts +3 -1
  79. package/shared/contracts.ts +42 -4
  80. package/shared/display.ts +16 -1
  81. package/shared/headline.ts +5 -0
  82. package/shared/home.ts +6 -0
  83. package/shared/model.ts +12 -1
  84. package/shared/onboarding.ts +243 -0
  85. package/shared/overseer.ts +10 -2
  86. package/shared/pr-actions.ts +26 -4
  87. package/shared/pr-workflow.ts +133 -0
  88. package/shared/questions.ts +17 -0
  89. package/shared/ranker.ts +237 -0
  90. package/shared/search.ts +25 -5
  91. package/shared/settings-nav.ts +97 -0
  92. package/skills/follow-through/SKILL.md +3 -1
@@ -1,11 +1,13 @@
1
1
  import { useEffect, useMemo, useState } from "react";
2
2
  import { Pressable, Text, TextInput, View } from "react-native";
3
3
  import { useRpc } from "@getpaseo/plugin/client";
4
- import { Icon, useToast } from "@getpaseo/plugin/client/ui";
4
+ import { Icon, SettingsAction, SettingsCard, useToast } from "@getpaseo/plugin/client/ui";
5
5
  import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
6
6
  import { reviewerSettingsRpc, reviewerSuggestionsRpc, saveReviewersRpc } from "../shared/contracts";
7
7
  import { MAX_REVIEWERS, TEAM_SLUG, USER_LOGIN, isTeam, resolveReviewers, reviewerConfig, reviewerLabel, sameLogin, setReviewerConfig, type ReviewerEntry } from "../shared/reviewers";
8
8
  import { Button, Switch, errorText, text, type Theme } from "./kit";
9
+ import { Disclosure } from "./settings-shell";
10
+ import { repoSummary, reposSummary, reviewersConfigured } from "../shared/settings-nav";
9
11
 
10
12
  export const reviewerSettingsKey = ["follow-through", "reviewer-settings"];
11
13
 
@@ -79,39 +81,79 @@ function AddReviewer({ repo, theme, compact, taken, onAdd }: { repo: string | nu
79
81
  }
80
82
 
81
83
  /** One list (a repository, or the default for all repos) with its chips and Add reviewer. Saves on every change. */
82
- function ReviewerList({ repo, list, theme, compact, fallback, first }: { repo: string | null; list: ReviewerEntry[]; theme: Theme; compact: boolean; fallback?: string | null; first?: boolean }) {
84
+ function ReviewerList({ repo, list, theme, compact, fallback, first, titled = true, startAdding = false }: { repo: string | null; list: ReviewerEntry[]; theme: Theme; compact: boolean; fallback?: string | null; first?: boolean; titled?: boolean; startAdding?: boolean }) {
83
85
  const c = theme.colors; const t = text(c);
84
86
  const save = useRpc(saveReviewersRpc); const cache = useQueryClient(); const toast = useToast();
85
- const [adding, setAdding] = useState(false);
87
+ const [adding, setAdding] = useState(startAdding);
86
88
  const change = useMutation({ mutationFn: (next: ReviewerEntry[]) => save({ repo, reviewers: next }), onSuccess: data => { cache.setQueryData(reviewerSettingsKey, data); setReviewerConfig(data.config); }, onError: error => toast.error(errorText(error)) });
87
- return <View style={{ gap: 8, paddingHorizontal: 14, paddingVertical: 12, borderTopWidth: first ? 0 : 1, borderTopColor: c.border }}>
88
- <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
89
- <Icon name={repo ? "GitPullRequest" : "Globe"} size={13} color={c.foregroundMuted} />
90
- <Text numberOfLines={1} style={[t.label, { flex: 1, minWidth: 0 }]}>{repo ?? "Default for all repos"}</Text>
91
- {adding ? <Button theme={theme} compact={compact} kind="ghost" icon="Check" title="Done" accessibilityLabel={`Done adding to ${repo ?? "the default list"}`} onPress={() => setAdding(false)} />
92
- : list.length < MAX_REVIEWERS && <Button theme={theme} compact={compact} kind="ghost" icon="UserPlus" title="Add reviewer" accessibilityLabel={`Add reviewer to ${repo ?? "the default list"}`} onPress={() => setAdding(true)} />}
93
- </View>
94
- {list.length > 0 ? <View style={{ flexDirection: "row", flexWrap: "wrap", gap: 6 }}>
95
- {list.map((r, i) => <ReviewerChip key={r.login} r={r} theme={theme} compact={compact} onRemove={change.isPending ? undefined : () => change.mutate(list.filter((_, j) => j !== i))} />)}
96
- </View> : <Text style={t.meta}>{fallback ?? "Nobody yet. Add reviewers opens a picker."}</Text>}
89
+ const action = adding ? <Button theme={theme} compact={compact} kind="ghost" icon="Check" title="Done" accessibilityLabel={`Done adding to ${repo ?? "the default list"}`} onPress={() => setAdding(false)} />
90
+ : list.length < MAX_REVIEWERS ? <Button theme={theme} compact={compact} kind="ghost" icon="UserPlus" title="Add reviewer" accessibilityLabel={`Add reviewer to ${repo ?? "the default list"}`} onPress={() => setAdding(true)} /> : null;
91
+ const chips = list.length > 0 ? list.map((r, i) => <ReviewerChip key={r.login} r={r} theme={theme} compact={compact} onRemove={change.isPending ? undefined : () => change.mutate(list.filter((_, j) => j !== i))} />)
92
+ : <Text style={[t.meta, titled ? null : { flex: 1, minWidth: 0 }]}>{fallback ?? "Nobody yet. Add reviewers opens a picker."}</Text>;
93
+ return <View style={{ gap: 8, paddingHorizontal: 14, paddingVertical: titled ? 12 : 8, paddingLeft: titled ? 14 : 58, borderTopWidth: first ? 0 : 1, borderTopColor: c.border }}>
94
+ {titled ? <>
95
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
96
+ <Icon name={repo ? "GitPullRequest" : "Globe"} size={13} color={c.foregroundMuted} />
97
+ <Text numberOfLines={1} style={[t.label, { flex: 1, minWidth: 0 }]}>{repo ?? "Default for all repos"}</Text>
98
+ {action}
99
+ </View>
100
+ {list.length > 0 ? <View style={{ flexDirection: "row", flexWrap: "wrap", gap: 6 }}>{chips}</View> : chips}
101
+ </> : /* Inside a fold the header already names the repo: chips and Add share one row, indented under it. */
102
+ <View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 6 }}>{chips}<View style={{ flex: 1 }} />{action}</View>}
97
103
  {adding && <AddReviewer repo={repo} theme={theme} compact={compact} taken={list.map(r => r.login)} onAdd={r => change.mutate([...list, r])} />}
98
104
  </View>;
99
105
  }
100
106
 
101
- /** Settings → Reviewers: who "Add reviewers" asks, per repository, with a default for the rest. */
107
+ /**
108
+ * Settings → Reviewers: who "Add reviewers" asks. The default list stays open; the repositories fold away behind one
109
+ * line ("3 with their own list · 5 use the default"), collapsed by default once anything is set. Inside, each
110
+ * repository with a list folds to its names, and the ones on the default fold together.
111
+ */
102
112
  export function ReviewerSettings({ theme, compact = false }: { theme: Theme; compact?: boolean }) {
103
113
  const c = theme.colors; const t = text(c);
104
114
  const query = useReviewerSettings();
105
115
  const data = query.data;
116
+ if (query.isPending) return <Text style={t.meta}>Loading reviewers…</Text>;
117
+ if (query.error || !data) return <SettingsCard><SettingsAction label="Couldn't load reviewers" hint={query.error ? errorText(query.error) : undefined} actionLabel="Retry" onPress={() => void query.refetch()} /></SettingsCard>;
118
+ const own = data.repos.filter(r => (data.config.repos[r] ?? []).length > 0).sort((a, b) => a.localeCompare(b));
119
+ const rest = data.repos.filter(r => !own.includes(r));
120
+ const fallback = data.config.defaults.length ? `Uses the default: ${data.config.defaults.map(reviewerLabel).join(", ")}` : null;
106
121
  return <View style={{ gap: 8 }}>
107
- {query.isPending && <Text style={t.meta}>Loading reviewers…</Text>}
108
- {query.error && <Text accessibilityRole="alert" style={[t.meta, { color: c.statusDanger }]}>{errorText(query.error)}</Text>}
109
- {data && <View style={{ borderRadius: 10, borderWidth: 1, borderColor: c.border, backgroundColor: c.surface1, overflow: "hidden" }}>
122
+ <View style={{ borderRadius: 10, borderWidth: 1, borderColor: c.border, backgroundColor: c.surface1, overflow: "hidden" }}>
110
123
  <ReviewerList first repo={null} list={data.config.defaults} theme={theme} compact={compact} fallback="Nobody. Repositories without their own list open the picker." />
111
- {data.repos.map(repo => <ReviewerList key={repo} repo={repo} list={data.config.repos[repo] ?? []} theme={theme} compact={compact}
112
- fallback={data.config.defaults.length ? `Uses the default: ${data.config.defaults.map(reviewerLabel).join(", ")}` : null} />)}
113
- </View>}
114
- {data && !data.repos.length && <Text style={t.meta}>Repositories show here once Follow-up has seen a PR in them.</Text>}
124
+ </View>
125
+ {data.repos.length > 0 ? <Disclosure id="reviewers.repos" title="Repositories" summary={reposSummary(data.repos, data.config)}
126
+ defaultOpen={!reviewersConfigured(data.config)} theme={theme} compact={compact}>
127
+ {own.map((repo, i) => <View key={repo} style={{ borderTopWidth: i ? 1 : 0, borderTopColor: c.border }}>
128
+ <Disclosure framed={false} id={`reviewers.repo.${repo}`} title={repo} summary={repoSummary(data.config.repos[repo] ?? [], data.config.defaults)} defaultOpen={false} theme={theme} compact={compact}>
129
+ <ReviewerList first titled={false} repo={repo} list={data.config.repos[repo] ?? []} theme={theme} compact={compact} fallback={fallback} />
130
+ </Disclosure>
131
+ </View>)}
132
+ {rest.length > 0 && <DefaultRepos repos={rest} defaults={data.config.defaults} theme={theme} compact={compact} first={!own.length} />}
133
+ </Disclosure> : <Text style={t.meta}>Repositories show here once Follow-up has seen a PR in them.</Text>}
134
+ </View>;
135
+ }
136
+
137
+ /**
138
+ * Repositories on the default, in one row: their names, each a button that gives it its own list (it then moves up
139
+ * with the others). No third level, and the default's names aren't repeated per repository.
140
+ */
141
+ function DefaultRepos({ repos, defaults, theme, compact, first }: { repos: string[]; defaults: ReviewerEntry[]; theme: Theme; compact: boolean; first: boolean }) {
142
+ const c = theme.colors; const t = text(c);
143
+ const [editing, setEditing] = useState<string | null>(null);
144
+ return <View style={{ borderTopWidth: first ? 0 : 1, borderTopColor: c.border }}>
145
+ <View style={{ paddingLeft: 36, paddingRight: 14, paddingVertical: 10, gap: 6 }}>
146
+ <Text style={t.meta}>{`On the default${defaults.length ? ` (${defaults.map(reviewerLabel).join(", ")})` : ""}. Give one its own list:`}</Text>
147
+ <View style={{ flexDirection: "row", flexWrap: "wrap", gap: 6 }}>
148
+ {repos.map(repo => <Pressable key={repo} accessibilityRole="button" accessibilityLabel={`Give ${repo} its own list`} accessibilityState={{ selected: editing === repo }} onPress={() => setEditing(editing === repo ? null : repo)}
149
+ style={state => ({ flexDirection: "row", alignItems: "center", gap: 5, minHeight: compact ? 44 : 28, paddingHorizontal: 8, borderRadius: 6, borderWidth: 1, borderColor: editing === repo ? c.foregroundMuted : c.border, backgroundColor: state.pressed ? c.surface2 : "transparent" })}>
150
+ <Icon name="GitPullRequest" size={12} color={c.foregroundMuted} />
151
+ <Text numberOfLines={1} style={{ color: c.foreground, fontSize: 12, lineHeight: 16 }}>{repo}</Text>
152
+ <Icon name={editing === repo ? "X" : "Plus"} size={12} color={c.foregroundMuted} />
153
+ </Pressable>)}
154
+ </View>
155
+ </View>
156
+ {editing && <ReviewerList key={editing} repo={editing} list={[]} theme={theme} compact={compact} startAdding fallback="Add the first reviewer for this repository." />}
115
157
  </View>;
116
158
  }
117
159
 
@@ -0,0 +1,77 @@
1
+ import { useState, type ReactNode } from "react";
2
+ import { Pressable, Text, View } from "react-native";
3
+ import { Icon } from "@getpaseo/plugin/client/ui";
4
+ import { readOpen, writeOpen, SETTINGS_CATEGORIES, type SettingsCategory } from "../shared/settings-nav";
5
+ import { text, type Theme } from "./kit";
6
+
7
+ /**
8
+ * One collapsible block: chevron, title, a one-line summary and a count. Open or closed is remembered per device
9
+ * (`follow-up.settings.fold.<id>`); until the developer chooses, `defaultOpen` decides. The body mounts only when
10
+ * open, so whatever it loads (gh suggestions, long lists) waits until then.
11
+ */
12
+ export function Disclosure({ id, title, summary, count, defaultOpen, theme, compact, children, framed = true }: {
13
+ id: string; title: string; summary?: string | null; count?: string | number | null; defaultOpen: boolean; theme: Theme; compact: boolean; children: ReactNode; framed?: boolean;
14
+ }) {
15
+ const c = theme.colors; const t = text(c, compact);
16
+ const [open, setOpen] = useState(() => readOpen(id, defaultOpen));
17
+ const toggle = () => { const next = !open; writeOpen(id, next); setOpen(next); };
18
+ const header = <Pressable accessibilityRole="button" accessibilityState={{ expanded: open }} aria-expanded={open}
19
+ accessibilityLabel={`${title}${summary ? `, ${summary}` : ""}`} accessibilityHint={open ? "Collapses" : "Expands"} onPress={toggle}
20
+ style={state => ({ flexDirection: "row", alignItems: "center", gap: 8, minHeight: compact ? 48 : 36, paddingLeft: framed ? (compact ? 16 : 14) : 36, paddingRight: compact ? 16 : 14, paddingVertical: 6,
21
+ backgroundColor: state.pressed ? c.surface2 : (state as { hovered?: boolean }).hovered ? (framed ? c.surface2 : c.surface1) : "transparent" })}>
22
+ <Icon name={open ? "ChevronDown" : "ChevronRight"} size={14} color={c.foregroundMuted} />
23
+ <Text numberOfLines={1} style={[t.label, { flexShrink: 0 }]}>{title}</Text>
24
+ <Text numberOfLines={1} style={[t.meta, { flex: 1, minWidth: 0 }]}>{summary ?? ""}</Text>
25
+ {count != null && count !== "" && <Text style={[t.meta, { fontVariant: ["tabular-nums"] }]}>{count}</Text>}
26
+ </Pressable>;
27
+ // Nested: the chevron sits under the parent's title (one fixed step in), and the body indents to this title.
28
+ if (!framed) return <View>{header}{open && <View>{children}</View>}</View>;
29
+ return <View style={{ borderRadius: 10, borderWidth: 1, borderColor: c.border, backgroundColor: c.surface1, overflow: "hidden" }}>
30
+ {header}
31
+ {open && <View style={{ borderTopWidth: 1, borderTopColor: c.border }}>{children}</View>}
32
+ </View>;
33
+ }
34
+
35
+ /** Desktop: one row of tabs under the host's own settings nav (a second rail would squeeze the cards). */
36
+ export function CategoryTabs({ value, onChange, theme }: { value: SettingsCategory; onChange: (id: SettingsCategory) => void; theme: Theme }) {
37
+ const c = theme.colors;
38
+ return <View accessibilityRole="tablist" style={{ flexDirection: "row", gap: 4, borderBottomWidth: 1, borderBottomColor: c.border, backgroundColor: c.surface0 }}>
39
+ {SETTINGS_CATEGORIES.map(cat => {
40
+ const active = cat.id === value;
41
+ return <Pressable key={cat.id} accessibilityRole="tab" accessibilityState={{ selected: active }} aria-selected={active} onPress={() => onChange(cat.id)}
42
+ style={state => ({ flexDirection: "row", alignItems: "center", gap: 6, height: 36, paddingHorizontal: 10, marginBottom: -1, borderBottomWidth: 2,
43
+ borderBottomColor: active ? c.foreground : "transparent", borderTopLeftRadius: 6, borderTopRightRadius: 6,
44
+ backgroundColor: !active && (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
45
+ <Icon name={cat.icon} size={14} color={active ? c.foreground : c.foregroundMuted} />
46
+ <Text style={{ color: active ? c.foreground : c.foregroundMuted, fontSize: 13, lineHeight: 18, fontWeight: active ? "600" : "400" }}>{cat.title}</Text>
47
+ </Pressable>;
48
+ })}
49
+ </View>;
50
+ }
51
+
52
+ /** Phone: the category list. Each row's line comes from data already loaded, else a fixed description; it fetches nothing. */
53
+ export function CategoryList({ onOpen, summaries, theme }: { onOpen: (id: SettingsCategory) => void; summaries: Partial<Record<SettingsCategory, string | null>>; theme: Theme }) {
54
+ const c = theme.colors; const t = text(c, true);
55
+ return <View style={{ borderRadius: 10, borderWidth: 1, borderColor: c.border, backgroundColor: c.surface1, overflow: "hidden" }}>
56
+ {SETTINGS_CATEGORIES.map((cat, i) => <Pressable key={cat.id} accessibilityRole="button" accessibilityLabel={cat.title} accessibilityHint={summaries[cat.id] ?? cat.blurb} onPress={() => onOpen(cat.id)}
57
+ style={state => ({ flexDirection: "row", alignItems: "center", gap: 12, minHeight: 56, paddingHorizontal: 16, paddingVertical: 8, borderTopWidth: i ? 1 : 0, borderTopColor: c.border, backgroundColor: state.pressed ? c.surface2 : "transparent" })}>
58
+ <Icon name={cat.icon} size={18} color={c.foregroundMuted} />
59
+ <View style={{ flex: 1, minWidth: 0, gap: 1 }}>
60
+ <Text style={t.label}>{cat.title}</Text>
61
+ <Text numberOfLines={1} style={t.meta}>{summaries[cat.id] ?? cat.blurb}</Text>
62
+ </View>
63
+ <Icon name="ChevronRight" size={16} color={c.foregroundMuted} />
64
+ </Pressable>)}
65
+ </View>;
66
+ }
67
+
68
+ /** Phone: the back row above a drilled-in category. */
69
+ export function BackHeader({ title, onBack, theme }: { title: string; onBack: () => void; theme: Theme }) {
70
+ const c = theme.colors;
71
+ // The whole row goes back (44 px tall), not just the chevron.
72
+ return <Pressable accessibilityRole="button" accessibilityLabel={`Back to settings from ${title}`} onPress={onBack}
73
+ style={state => ({ flexDirection: "row", alignItems: "center", gap: 6, minHeight: 48, marginHorizontal: -8, paddingHorizontal: 8, borderRadius: 8, backgroundColor: state.pressed ? c.surface2 : "transparent" })}>
74
+ <Icon name="ChevronLeft" size={18} color={c.foregroundMuted} />
75
+ <Text accessibilityRole="header" style={text(c, true).title}>{title}</Text>
76
+ </Pressable>;
77
+ }
@@ -1,14 +1,23 @@
1
1
  import { useState } from "react";
2
- import { ActivityIndicator, ScrollView, Text } from "react-native";
2
+ import { ActivityIndicator, Pressable, ScrollView, Text, TextInput, View } from "react-native";
3
3
  import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
4
4
  import { useRpc, useSettings } from "@getpaseo/plugin/client";
5
- import { SettingsAction, SettingsCard, SettingsSection, SettingsSelect, SettingsSwitch, useToast } from "@getpaseo/plugin/client/ui";
5
+ import { Icon, SettingsAction, SettingsCard, SettingsSection, SettingsSelect, SettingsSwitch, useToast } from "@getpaseo/plugin/client/ui";
6
6
  import { QUESTION_MODES, QUESTION_MODE_RULES, questionPreferences, type QuestionMode } from "../shared/questions";
7
- import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
7
+ import { skipToken, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
8
8
  import { followSettingsRpc, projectSettingsRpc, setFollowSettingsRpc, setProjectTrackingRpc } from "../shared/contracts";
9
- import { errorText, text } from "./kit";
10
- import { DisplaySections } from "./display";
11
- import { ReviewerSettings } from "./reviewers";
9
+ import { Switch, bottomInset, errorText, space, text, type Theme } from "./kit";
10
+ import { DisplaySections, PermissionsSection, PreferenceSwitch } from "./display";
11
+ import { ReviewerSettings, reviewerSettingsKey } from "./reviewers";
12
+ import { AgentSettings, agentSettingsKey } from "./agents";
13
+ import { ShippingSettings } from "./shipping";
14
+ import { BackHeader, CategoryList, CategoryTabs, Disclosure } from "./settings-shell";
15
+ import {
16
+ categoryTitle, followingSummary, hasSavedCategory, projectsOpenByDefault, projectsSummary, readCategory, reviewersSummary, workspaceRows, workspaceState, workspacesOpenByDefault, workspacesSummary,
17
+ writeCategory, type SettingsCategory, type WorkspaceSetting,
18
+ } from "../shared/settings-nav";
19
+ import type { AgentSettingsView } from "../shared/agent-settings";
20
+ import type { ReviewerConfig } from "../shared/reviewers";
12
21
 
13
22
  const settingsKey = ["follow-through", "project-settings"];
14
23
 
@@ -36,29 +45,28 @@ function QuestionSettings({ theme }: Pick<PluginSurfaceProps, "theme">) {
36
45
  const followKey = ["follow-through", "follow-settings"];
37
46
 
38
47
  /**
39
- * Following (1.3.0-beta.2): Follow-up follows every workspace by default, so tracking never shows anywhere else.
40
- * The rare exception is a per-workspace switch here, next to that workspace's own auto-send switch.
48
+ * Following: the three switches, then Projects and Workspaces as folds. Both lists are exceptions to "Follow every
49
+ * workspace", so they stay next to it. Workspaces replaces the old 100-option select: search, exceptions first,
50
+ * one row open at a time, 25 rows and "Show more".
41
51
  */
42
- function FollowingSettings({ theme }: Pick<PluginSurfaceProps, "theme">) {
43
- const c = theme.colors; const t = text(c);
52
+ function FollowingCategory({ theme, compact, openSetup }: { theme: Theme; compact: boolean; openSetup?: () => void }) {
53
+ const c = theme.colors; const t = text(c, compact);
44
54
  const read = useRpc(followSettingsRpc); const write = useRpc(setFollowSettingsRpc); const cache = useQueryClient(); const toast = useToast();
45
55
  const query = useQuery({ queryKey: followKey, queryFn: () => read({}), refetchInterval: 30000 });
46
- const [picked, setPicked] = useState("");
47
56
  const change = useMutation({
48
57
  mutationFn: (input: Parameters<typeof write>[0]) => write(input),
49
58
  onSuccess: value => { cache.setQueryData(followKey, value); void cache.invalidateQueries({ queryKey: settingsKey }); },
50
59
  onError: error => toast.error(errorText(error)),
51
60
  });
52
61
  const data = query.data;
53
- const chosen = data?.workspaces.find(w => w.id === picked) ?? null;
54
- const exceptions = data?.workspaces.filter(w => w.optedOut || (w.enable_tracking && !w.parked && w.enable_auto_sends !== data.enable_auto_sends_default)) ?? [];
55
62
  const windowDays = data?.activeWindowDays ?? 3;
56
63
  return <>
57
- <SettingsSection title="Following" info="Follow-up follows every workspace's PR stack, tasks and repairs as soon as the workspace has an agent. Turn Follow every workspace off to follow only the projects switched on below. Follow-up never merges, requests reviewers or archives on its own.">
64
+ {openSetup && <SettingsCard><SettingsAction label="Set up Follow-up again" hint="Check GitHub and the helper agents, and review what Follow-up does on its own. About two minutes." actionLabel="Open setup" onPress={openSetup} /></SettingsCard>}
65
+ <SettingsSection title="Defaults" info="Follow-up follows every workspace's PR stack, tasks and repairs as soon as the workspace has an agent. Turn Follow every workspace off to follow only the projects switched on below. Follow-up never merges, requests reviewers or archives on its own.">
58
66
  {query.isPending && <ActivityIndicator accessibilityLabel="Loading following settings" color={c.foregroundMuted} style={{ alignSelf: "flex-start", marginVertical: 8 }} />}
59
67
  {query.error && <SettingsCard><SettingsAction label="Couldn't load following settings" hint={errorText(query.error)} actionLabel="Retry" onPress={() => void query.refetch()} /></SettingsCard>}
60
68
  {data && <SettingsCard>
61
- <SettingsSwitch label="Follow every workspace" hint="New and existing workspaces, except the exceptions below." value={data.enable_follow_every} disabled={change.isPending}
69
+ <SettingsSwitch label="Follow every workspace" hint="New and existing workspaces, except the ones turned off under Workspaces below." value={data.enable_follow_every} disabled={change.isPending}
62
70
  onValueChange={value => change.mutate({ enable_follow_every: value })} />
63
71
  <SettingsSwitch label="Send repairs automatically" hint="Review threads and red CI go to the workspace's agent on their own. Applies to workspaces Follow-up starts following from now on." value={data.enable_auto_sends_default} disabled={change.isPending}
64
72
  onValueChange={value => change.mutate({ enable_auto_sends_default: value })} />
@@ -68,29 +76,18 @@ function FollowingSettings({ theme }: Pick<PluginSurfaceProps, "theme">) {
68
76
  onValueChange={value => change.mutate({ activeWindowDays: Number(value) })} />
69
77
  </SettingsCard>}
70
78
  </SettingsSection>
71
- {!!data?.workspaces.length && <SettingsSection title="Workspace exceptions" info="Stop following one workspace, or change its auto-send. Following it again picks up its PRs on the next refresh.">
72
- <SettingsCard>
73
- <SettingsSelect label="Workspace" value={picked} options={[{ value: "", label: "Choose a workspace" }, ...data.workspaces.map(w => ({ value: w.id, label: w.dormant ? `${w.title} · resting` : w.title }))]} onValueChange={setPicked} />
74
- {chosen && <SettingsSwitch label="Follow this workspace" value={!chosen.optedOut && chosen.enable_tracking} disabled={change.isPending}
75
- onValueChange={value => change.mutate({ workspace: { workspaceId: chosen.id, follow: value } }, { onSuccess: () => toast.show(value ? `Following ${chosen.title}` : `Stopped following ${chosen.title}`, { variant: "success" }) })} />}
76
- {chosen && !chosen.optedOut && chosen.enable_tracking && <SettingsSwitch label="Send repairs automatically" hint={chosen.parked ? "Resting. Auto-send was paused and comes back when the workspace is active again. Changing it here makes your choice stick." : chosen.dormant ? "Resting. Nothing is sent until you start a turn there." : undefined} value={chosen.enable_auto_sends} disabled={change.isPending}
77
- onValueChange={value => change.mutate({ workspace: { workspaceId: chosen.id, enable_auto_sends: value } })} />}
78
- </SettingsCard>
79
- {exceptions.length > 0 && <SettingsCard>
80
- {exceptions.map(w => <SettingsAction key={w.id} label={w.title} hint={(w.optedOut || !w.enable_tracking ? "Not followed" : w.enable_auto_sends ? "Sends repairs automatically" : "Repairs wait for you") + (w.dormant && !w.optedOut && w.enable_tracking ? " · resting" : "")}
81
- actionLabel="Edit" onPress={() => setPicked(w.id)} />)}
82
- </SettingsCard>}
83
- {!exceptions.length && <Text style={t.meta}>No exceptions. Every workspace is followed the same way.</Text>}
84
- </SettingsSection>}
79
+ <ShippingSettings theme={theme} compact={compact} />
80
+ <PermissionsSection theme={theme} />
81
+ <ProjectsFold theme={theme} compact={compact} />
82
+ {data && (data.workspaces.length
83
+ ? <WorkspacesFold theme={theme} compact={compact} all={data.workspaces} autoDefault={data.enable_auto_sends_default} busy={change.isPending}
84
+ set={(workspace, label) => change.mutate({ workspace }, { onSuccess: () => { if (label) toast.show(label, { variant: "success" }); } })} />
85
+ : <Text style={t.meta}>Workspaces appear here once they have an agent.</Text>)}
85
86
  </>;
86
87
  }
87
88
 
88
- /**
89
- * Follow-up's one settings screen: Following (and its exceptions), Projects, Questions, Sidebar & pills and the
90
- * Needs-you inbox. Each project switch is one project; the hint shows which repository it is.
91
- */
92
- export function FollowSettings({ theme, layout }: PluginSurfaceProps) {
93
- const c = theme.colors; const t = text(c);
89
+ function ProjectsFold({ theme, compact }: { theme: Theme; compact: boolean }) {
90
+ const c = theme.colors; const t = text(c, compact);
94
91
  const read = useRpc(projectSettingsRpc); const write = useRpc(setProjectTrackingRpc); const cache = useQueryClient(); const toast = useToast();
95
92
  const query = useQuery({ queryKey: settingsKey, queryFn: () => read({}), refetchInterval: 15000 });
96
93
  const change = useMutation({
@@ -103,23 +100,122 @@ export function FollowSettings({ theme, layout }: PluginSurfaceProps) {
103
100
  },
104
101
  onError: error => toast.error(errorText(error)),
105
102
  });
106
- return <ScrollView style={{ flex: 1, backgroundColor: c.surface0 }} contentContainerStyle={{ padding: layout.compact ? 16 : 24, gap: 18, maxWidth: 720, width: "100%", alignSelf: "center", paddingBottom: 40 }}>
107
- <FollowingSettings theme={theme} />
108
- <SettingsSection title="Projects" info="With Follow every workspace on, every project is followed unless you turn it off here. Off stops following the project's new workspaces; ones already followed stay followed (stop one under Workspace exceptions). With Follow every workspace off, only the projects on here are followed.">
109
- {query.isPending && <ActivityIndicator accessibilityLabel="Loading projects" color={c.foregroundMuted} style={{ alignSelf: "flex-start", marginVertical: 8 }} />}
110
- {query.error && <SettingsCard><SettingsAction label="Couldn't load projects" hint={errorText(query.error)} actionLabel="Retry" onPress={() => void query.refetch()} /></SettingsCard>}
111
- {query.data?.projects.length === 0 && <Text style={t.meta}>Projects appear here once you add them to Paseo.</Text>}
112
- {!!query.data?.projects.length && <SettingsCard>
113
- {query.data.projects.map(project => <SettingsSwitch key={project.id} label={project.name}
103
+ const projects = query.data?.projects;
104
+ if (query.isPending) return <ActivityIndicator accessibilityLabel="Loading projects" color={c.foregroundMuted} style={{ alignSelf: "flex-start", marginVertical: 8 }} />;
105
+ if (query.error || !projects) return <SettingsCard><SettingsAction label="Couldn't load projects" hint={query.error ? errorText(query.error) : undefined} actionLabel="Retry" onPress={() => void query.refetch()} /></SettingsCard>;
106
+ if (!projects.length) return <Text style={t.meta}>Projects appear here once you add them to Paseo.</Text>;
107
+ return <Disclosure id="following.projects" title="Projects" summary={projectsSummary(projects)} defaultOpen={projectsOpenByDefault(projects.length)} theme={theme} compact={compact}>
108
+ <Text style={[t.meta, { paddingHorizontal: 14, paddingTop: 10 }]}>With Follow every workspace on, a project that's off stops following its new workspaces; ones already followed stay followed (turn one off under Workspaces). With it off, only the projects on here are followed.</Text>
109
+ <View style={{ padding: 8 }}><SettingsCard>
110
+ {projects.map(project => <SettingsSwitch key={project.id} label={project.name}
114
111
  hint={project.key.startsWith("remote:") ? project.key.slice(7) : project.path.split("/").filter(Boolean).slice(-2).join("/")}
115
112
  value={project.enable_default_tracking} disabled={change.isPending}
116
113
  onValueChange={value => change.mutate({ projectId: project.id, enable_default_tracking: value })} />)}
117
- </SettingsCard>}
118
- </SettingsSection>
119
- <SettingsSection title="Reviewers" info="Who Add reviewers asks on a PR. Set a list per repository, or a default for every repository without one. A login is a GitHub user (octocat) or a team (org/team). Teammates each keep their own lists.">
120
- <ReviewerSettings theme={theme} compact={layout.compact} />
121
- </SettingsSection>
114
+ </SettingsCard></View>
115
+ </Disclosure>;
116
+ }
117
+
118
+ function WorkspacesFold({ theme, compact, all, autoDefault, busy, set }: { theme: Theme; compact: boolean; all: WorkspaceSetting[]; autoDefault: boolean; busy: boolean;
119
+ set: (w: { workspaceId: string; follow?: boolean; enable_auto_sends?: boolean }, toast?: string) => void }) {
120
+ const c = theme.colors; const t = text(c, compact);
121
+ const [q, setQ] = useState("");
122
+ const [cap, setCap] = useState(25);
123
+ const [openId, setOpenId] = useState<string | null>(null);
124
+ const view = workspaceRows(all, autoDefault, q, cap);
125
+ return <Disclosure id="following.workspaces" title="Workspaces" summary={workspacesSummary(all, autoDefault)} defaultOpen={workspacesOpenByDefault(view.exceptions)} theme={theme} compact={compact}>
126
+ <View style={{ padding: 10, paddingBottom: 6 }}>
127
+ <TextInput accessibilityLabel="Search workspaces" value={q} onChangeText={v => { setQ(v); setOpenId(null); }} placeholder={`Search ${all.length} workspaces`} placeholderTextColor={c.foregroundMuted}
128
+ autoCapitalize="none" autoCorrect={false}
129
+ style={{ minHeight: compact ? 44 : 32, paddingHorizontal: 10, borderRadius: 6, borderWidth: 1, borderColor: c.border, color: c.foreground, fontSize: 13, backgroundColor: c.surface0 }} />
130
+ </View>
131
+ {!view.rows.length && <Text style={[t.meta, { paddingHorizontal: 14, paddingBottom: 12 }]}>{`No workspace matches "${q.trim()}".`}</Text>}
132
+ {view.rows.map(w => {
133
+ const open = openId === w.id;
134
+ const followed = !w.optedOut && w.enable_tracking;
135
+ const exception = view.exceptions > 0 && (w.optedOut || !w.enable_tracking || (!w.parked && w.enable_auto_sends !== autoDefault));
136
+ return <View key={w.id} style={{ borderTopWidth: 1, borderTopColor: c.border }}>
137
+ <Pressable accessibilityRole="button" accessibilityState={{ expanded: open }} aria-expanded={open} accessibilityLabel={`${w.title}, ${workspaceState(w)}`} onPress={() => setOpenId(open ? null : w.id)}
138
+ style={state => ({ flexDirection: "row", alignItems: "center", gap: 10, minHeight: compact ? 52 : 44, paddingHorizontal: compact ? 16 : 14, paddingVertical: compact ? 12 : 6, backgroundColor: state.pressed ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface2 : "transparent" })}>
139
+ <View style={{ flex: 1, minWidth: 0, gap: 1 }}>
140
+ <Text numberOfLines={1} style={t.body}>{w.title}</Text>
141
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 6 }}>
142
+ {exception && <View accessibilityLabel="Exception" style={{ width: 6, height: 6, borderRadius: 3, backgroundColor: c.statusWarning }} />}
143
+ <Text numberOfLines={1} style={[t.meta, { flex: 1 }]}>{workspaceState(w)}</Text>
144
+ </View>
145
+ </View>
146
+ <Icon name={open ? "ChevronUp" : "ChevronDown"} size={14} color={c.foregroundMuted} />
147
+ </Pressable>
148
+ {/* Compact rows: two switches under the open workspace, not two full settings rows. */}
149
+ {open && <View style={{ paddingLeft: 14, paddingRight: 14, paddingBottom: 10, gap: 4 }}>
150
+ <Switch theme={theme} compact={compact} label="Follow this workspace" value={followed} disabled={busy}
151
+ onChange={value => set({ workspaceId: w.id, follow: value }, value ? `Following ${w.title}` : `Stopped following ${w.title}`)} />
152
+ {followed && <Switch theme={theme} compact={compact} label="Send repairs automatically" hint={w.parked ? "Resting. Auto-send was paused and comes back when the workspace is active again. Changing it here makes your choice stick." : w.dormant ? "Resting. Nothing is sent until you start a turn there." : undefined}
153
+ value={w.enable_auto_sends} disabled={busy} onChange={value => set({ workspaceId: w.id, enable_auto_sends: value })} />}
154
+ </View>}
155
+ </View>;
156
+ })}
157
+ {view.hidden > 0 && <Pressable accessibilityRole="button" onPress={() => setCap(n => n + 25)}
158
+ style={state => ({ minHeight: compact ? 44 : 36, justifyContent: "center", paddingHorizontal: 14, borderTopWidth: 1, borderTopColor: c.border, backgroundColor: state.pressed ? c.surface2 : "transparent" })}>
159
+ <Text style={[t.meta, { color: c.foreground }]}>{`Show ${Math.min(25, view.hidden)} more (${view.hidden} left)`}</Text>
160
+ </Pressable>}
161
+ </Disclosure>;
162
+ }
163
+
164
+ /** Agents: Questions, then the four agent cards. The Overseer and AI priority switches lead their own cards. */
165
+ function AgentsCategory({ theme, compact }: { theme: Theme; compact: boolean }) {
166
+ return <>
122
167
  <QuestionSettings theme={theme} />
123
- <DisplaySections theme={theme} />
168
+ <AgentSettings theme={theme} compact={compact} toggles={{ overseer: <PreferenceSwitch field="enable_overseer" theme={theme} />, ranker: <PreferenceSwitch field="enable_ranker" theme={theme} /> }} />
169
+ </>;
170
+ }
171
+
172
+ /** Each category's one line, from data already loaded (never fetched for it). */
173
+ function useSummaries(): Partial<Record<SettingsCategory, string | null>> {
174
+ // skipToken: subscribe to what's cached (re-rendering when it arrives) without ever fetching for the summary.
175
+ const follow = useQuery({ queryKey: followKey, queryFn: skipToken }).data as Parameters<typeof followingSummary>[0] | undefined;
176
+ const reviewers = useQuery({ queryKey: reviewerSettingsKey, queryFn: skipToken }).data as { config: ReviewerConfig } | undefined;
177
+ const agents = useQuery({ queryKey: agentSettingsKey, queryFn: skipToken }).data as AgentSettingsView | undefined;
178
+ const changed = agents?.roles.filter(r => !r.isDefault).length ?? 0;
179
+ return {
180
+ following: follow ? followingSummary(follow) : null,
181
+ reviewers: reviewers ? reviewersSummary(reviewers.config) : null,
182
+ agents: agents ? (changed ? `${changed} of ${agents.roles.length} changed from the defaults` : "Every agent on its default") : null,
183
+ };
184
+ }
185
+
186
+ /**
187
+ * Follow-up's settings, in four categories. Desktop: tabs under the host's own settings nav, the last one remembered
188
+ * on this device. Phone: the category list, drilling in with a back row. Only the open category mounts, so only its
189
+ * data loads.
190
+ */
191
+ export function FollowSettings({ theme, layout, openSetup }: PluginSurfaceProps & { openSetup?: () => void }) {
192
+ const compact = layout.compact;
193
+ const c = theme.colors; const t = text(c, compact);
194
+ const [category, setCategory] = useState<SettingsCategory>(() => readCategory());
195
+ // The phone reopens in the last category, like desktop; before any pick it starts on the list.
196
+ const [drilled, setDrilled] = useState(() => hasSavedCategory());
197
+ const summaries = useSummaries();
198
+ const pick = (id: SettingsCategory) => { writeCategory(id); setCategory(id); };
199
+ const content = category === "following" ? <FollowingCategory theme={theme} compact={compact} openSetup={openSetup} />
200
+ : category === "reviewers" ? <View style={{ gap: 8 }}>
201
+ <Text style={t.meta}>Who Add reviewers asks on a PR: a list per repository, or the default for every repository without one. A login is a GitHub user (octocat) or a team (org/team). Teammates each keep their own lists.</Text>
202
+ <ReviewerSettings theme={theme} compact={compact} />
203
+ </View>
204
+ : category === "agents" ? <AgentsCategory theme={theme} compact={compact} />
205
+ : <DisplaySections theme={theme} />;
206
+ // Phones: the shared gutter and the bottom inset (the gesture bar), like every other Follow-up surface.
207
+ const page = { padding: compact ? space(true).gutter : 24, gap: 18, maxWidth: 720, width: "100%" as const, alignSelf: "center" as const, paddingBottom: 40 };
208
+ // The host's header sits right above: no extra top space on a phone.
209
+ if (compact) return <ScrollView style={{ flex: 1, backgroundColor: c.surface0 }} contentContainerStyle={{ ...page, paddingTop: 4, ...bottomInset(true, 28) }}>
210
+ {drilled ? <>
211
+ <BackHeader title={categoryTitle(category)} onBack={() => setDrilled(false)} theme={theme} />
212
+ {content}
213
+ </> : <CategoryList summaries={summaries} theme={theme} onOpen={id => { pick(id); setDrilled(true); }} />}
214
+ </ScrollView>;
215
+ const line = summaries[category];
216
+ return <ScrollView style={{ flex: 1, backgroundColor: c.surface0 }} stickyHeaderIndices={[0]} contentContainerStyle={{ ...page, paddingTop: 0 }}>
217
+ <View style={{ paddingTop: 24, backgroundColor: c.surface0 }}><CategoryTabs value={category} onChange={pick} theme={theme} /></View>
218
+ {line ? <Text style={[t.meta, { marginTop: -6 }]}>{line}</Text> : null}
219
+ {content}
124
220
  </ScrollView>;
125
221
  }