paseo-follow-up 1.4.0-beta.13 → 1.4.0-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/OVERVIEW.md CHANGED
@@ -48,3 +48,5 @@ The Overseer (beta) is one Claude agent in a Follow-up workspace under `plugin-d
48
48
  Settings → Agents (`plugin-data/follow-through/agents.json`, its own file) chooses the provider, model, effort and mode for What's this about?, the Overseer, recovery agents and the priority ranker. Missing or invalid entries use the defaults. The provider and model list comes from Paseo's provider snapshot. It is read only when that settings screen opens, and cached for ten minutes. A changed Overseer setting is never applied mid-conversation: Home offers a restart, and the new Overseer is handed the old one's last steps (read from its transcript on disk when it isn't loaded). The old agent is left as it is. A recovery agent on a different provider than the main agent keeps the main agent's system prompt, MCP servers and tool policy, and drops its provider-specific model, mode and options. `FOLLOW_UP_OVERSEER_PROVIDER` ("provider/model") overrides the Overseer's setting; it exists only for isolated test daemons.
49
49
 
50
50
  The ranker behind AI priority (beta) runs inside Follow-up's worker as bounded one-shot jobs (Claude or Codex, per the ranker role) through the shared job runner (`server/ai-jobs.ts`), one at a time and only while the resource governor allows background work. It reads Follow-up's own state, `mcpproxy call tool-read` for `linear:list_issues` (assigned to you) and `slack-user:slack_search_public_and_private` (DMs and mentions, last 48 hours), `gh search prs --review-requested=@me`, and the planning artifact through one Claude turn limited to the Artifact tool. It hashes those inputs and calls the model only when they changed. It writes only `plugin-data/follow-through/priorities.json` (its ranking, which replaces its previous one) and `ranker.json` (input hash, run count, source health, the day's plan summary, and Linear issues no workspace covers). It never stores raw artifact HTML or share keys. The provider, model, cadence and daily cap come from the ranker role in Settings → Agents; the plan reader always uses Claude, the only provider with the Artifact tool.
51
+
52
+ Getting started keeps only its own progress in `plugin-data/follow-through/onboarding.json`: whether this host was a fresh or existing install when this version first started (existing if `state.json`, `inbox.json`, `reviewers.json`, `agents.json` or `brief.json` was already there), the current step, and whether the existing-install offer was shown or dismissed. An unreadable file counts as finished, so setup is never forced. Its choices are written through the same RPCs and display settings the Settings screen uses. The readiness checks run only when setup asks for them, at most once a minute unless you press Check again: `gh api user` on the daemon host, Paseo's provider snapshot (the same cached read Settings → Agents uses), Paseo's `config.json`, and the count of `hook-state/native-*.json` files. They never read an agent's timeline.
package/README.md CHANGED
@@ -22,6 +22,20 @@ paseo plugin install paseo-follow-up
22
22
 
23
23
  Needs Node 22+ and an authenticated GitHub CLI (`gh`) on the daemon host. Merge buttons use your saved Graphite CLI authentication. The installed plugin ID stays `follow-through`, so existing settings and tracked work carry over.
24
24
 
25
+ ## Getting started
26
+
27
+ The first time you open Follow-up from the sidebar, a short setup takes Home's place. It takes about two minutes, and **Skip setup** leaves it at any point.
28
+
29
+ <img alt="Follow-up's setup on a fresh install: an example PR going from failed checks to a repair to a merge only you can approve, the GitHub, Claude, Codex and agent tools checks, the three switches for what Follow-up does on its own, a default reviewer being added, the helpers and where things are, then Home" src="docs/media/follow-up-setup.gif" width="720">
30
+
31
+ 1. **What it is.** A worked example of one PR going from failed checks, to a repair sent to its agent, to a merge only you can approve, and how many of your workspaces Follow-up already follows.
32
+ 2. **Check your setup.** Whether the GitHub CLI is signed in (and as whom), whether Claude and Codex are available for the helper agents, and whether agents get Follow-up's tools. Anything missing shows the fix, with the command to copy. Checks run only while this step is open.
33
+ 3. **What Follow-up does without asking.** Follow every workspace (or turn single ones off), Send repairs automatically, and Trust bypass agents. They are on by default and save as you change them.
34
+ 4. **Reviewers.** Who **Add reviewers** asks: a default for every repository, and a list per repository Follow-up has seen. **Skip, set later** leaves it empty.
35
+ 5. **Helpers.** The Overseer and AI priority switches, which models they use (change them under Settings → Agents), and where Home, the workspace panel, Needs you and What's this about? live.
36
+
37
+ Every switch in setup is the same one Settings shows, so nothing is applied twice and nothing is lost if you stop halfway. Setup remembers its step, so a reload or another device picks up where you left off. Run it again any time from **Set up Follow-up again** at the top of Follow-up's settings, or ⌘K → **Follow-up: Set up again**. If Follow-up was already installed before this version, it doesn't open on its own: Home shows one dismissible line offering it, for a day.
38
+
25
39
  ## Use
26
40
 
27
41
  Follow-up follows every workspace as soon as it has an agent; there is nothing to turn on. Open a workspace and click the Follow-up icon in its header (or press ⌘K / Ctrl+K and choose **Follow-up: open for this workspace**) to see that workspace's panel. Its **Home** button opens Home, the list of every workspace. To leave a workspace or a project out, open the settings (**Follow-up: settings** in ⌘K): **Following** has the global switches, **Workspace exceptions** the per-workspace ones.
@@ -183,7 +197,7 @@ The choices live in `agents.json` in Follow-up's data folder. Anything missing o
183
197
  Install the beta:
184
198
 
185
199
  ```sh
186
- paseo plugin update follow-through --version 1.4.0-beta.13
200
+ paseo plugin update follow-through --version 1.4.0-beta.14
187
201
  # or, for a fresh install:
188
202
  paseo plugin install npm:paseo-follow-up@beta
189
203
  ```
package/client/home.tsx CHANGED
@@ -23,6 +23,8 @@ import { ListTop, SearchField, SortMenu, StatusStrip, UsageMeters, useOmnibox, u
23
23
  import { useHomeModel, useTick, type HomeSources } from "./home-data";
24
24
  import { useInbox, UndoBar, useNextRelay } from "./inbox";
25
25
  import { Spinner } from "./motion";
26
+ import { Setup, SetupOffer, useOnboarding } from "./onboarding";
27
+ import type { OnboardingView } from "../shared/onboarding";
26
28
  import { withAlpha, isLight, mergedColor, type Colors } from "./theme";
27
29
 
28
30
  export const HOME_SCREEN = "follow-through";
@@ -30,7 +32,8 @@ const mono = Platform.OS === "ios" ? "Menlo" : "ui-monospace, SFMono-Regular, Me
30
32
 
31
33
  export type HomeDeps = {
32
34
  sources: HomeSources;
33
- openSettings(): void;
35
+ /** Follow-up's settings, on a category when given (the setup flow's deep links). */
36
+ openSettings(category?: string): void;
34
37
  /** Docks the workspace's own panel in its explorer column. */
35
38
  openPanel(workspaceId: string): void;
36
39
  openLog(): void;
@@ -43,6 +46,16 @@ export type HomeDeps = {
43
46
  * With nothing selected the right side is the brief. `?view=log` shows what Follow-up did on its own.
44
47
  */
45
48
  export function FollowHome(props: PluginScreenProps & { deps: HomeDeps }) {
49
+ // Getting started takes Home's place on a fresh install (or after "Set up Follow-up again") until finished or skipped.
50
+ const onboarding = useOnboarding();
51
+ // Opened from "Set up again": read the flow's state afresh.
52
+ const { refetch } = onboarding;
53
+ useEffect(() => { if (props.params?.setup) void refetch(); }, [props.params?.setup, refetch]);
54
+ if (onboarding.data?.show) return <Setup theme={props.theme} compact={props.layout.compact} view={onboarding.data} deps={{ openSettings: props.deps.openSettings }} />;
55
+ return <HomeBody {...props} onboarding={onboarding.data} />;
56
+ }
57
+
58
+ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: OnboardingView | undefined }) {
46
59
  const { theme, layout, navigation, params = {}, deps } = props;
47
60
  const { inbox } = deps.sources;
48
61
  const c = theme.colors;
@@ -117,6 +130,7 @@ export function FollowHome(props: PluginScreenProps & { deps: HomeDeps }) {
117
130
  </View>
118
131
  {!omnibox.results && <StatusStrip theme={theme} model={model} filter={filter} onFilter={setFilter} touch={compact} dense={compact} />}
119
132
  {!omnibox.results && <UsageMeters theme={theme} sources={deps.sources} dense={compact} />}
133
+ {!omnibox.results && <SetupOffer theme={theme} compact={compact} view={props.onboarding} />}
120
134
  </ListTop>} />;
121
135
 
122
136
  if (compact) return <View style={{ flex: 1, backgroundColor: c.surface0 }}>
@@ -0,0 +1,437 @@
1
+ import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
2
+ import { Animated, Easing, Keyboard, Platform, Pressable, ScrollView, Text, View, type ViewStyle } from "react-native";
3
+ import { useRpc, useSettings } from "@getpaseo/plugin/client";
4
+ import { Icon, copyText, useToast } from "@getpaseo/plugin/client/ui";
5
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
6
+ import { agentSettingsRpc, followSettingsRpc, onboardingChecksRpc, onboardingRpc, setFollowSettingsRpc, setOnboardingRpc } from "../shared/contracts";
7
+ import { displayPreferences } from "../shared/display";
8
+ import { ONBOARDING_STEPS, autoSendWrites, checksSummary, type Check, type OnboardingStep, type OnboardingView } from "../shared/onboarding";
9
+ import { Button, IconButton, errorText, text, type Theme } from "./kit";
10
+ import { ReviewerSettings } from "./reviewers";
11
+ import { Spinner, useReducedMotion } from "./motion";
12
+ import { raised, runningColor, tint, withAlpha, type Colors } from "./theme";
13
+
14
+ /**
15
+ * Getting started: five steps that take a fresh install to a configured Follow-up. Shown in Home's place while the
16
+ * server says so (fresh install, or "Set up Follow-up again"), never forced on an existing install.
17
+ * Every switch writes through the Settings screen's own RPC or settings document as it changes; the flow itself only
18
+ * saves which step it's on, so a reload resumes there.
19
+ */
20
+
21
+ export const onboardingKey = ["follow-through", "onboarding"];
22
+ const checksKey = ["follow-through", "onboarding-checks"];
23
+ const followKey = ["follow-through", "follow-settings"];
24
+
25
+ /** The server's view of setup. Read once per Home mount (no polling) and refreshed after each action. */
26
+ export function useOnboarding() {
27
+ const read = useRpc(onboardingRpc);
28
+ return useQuery({ queryKey: onboardingKey, queryFn: () => read({}), staleTime: Infinity, retry: 1 });
29
+ }
30
+
31
+ export type SetupDeps = {
32
+ /** Opens Follow-up's settings, on a category when given (agents, reviewers, following). */
33
+ openSettings(category?: string): void;
34
+ };
35
+
36
+ const TITLES: Record<OnboardingStep, string> = {
37
+ intro: "Follow-up keeps your agents' PRs moving",
38
+ checks: "Check your setup",
39
+ defaults: "What Follow-up does without asking",
40
+ reviewers: "Who should review your PRs?",
41
+ helpers: "Helpers, and where things are",
42
+ };
43
+
44
+ /** Bottom clearance on phones. TODO(rebase): kit.tsx's bottomInset from the mobile rework replaces this. */
45
+ function bottomPad(compact: boolean): ViewStyle {
46
+ if (!compact) return { paddingBottom: 16 };
47
+ if (Platform.OS === "web") return { paddingBottom: "max(12px, env(safe-area-inset-bottom))" as unknown as number };
48
+ return { paddingBottom: Platform.OS === "ios" ? 34 : 24 };
49
+ }
50
+
51
+ export function Setup({ theme, compact, view, deps }: { theme: Theme; compact: boolean; view: OnboardingView; deps: SetupDeps }) {
52
+ const c = theme.colors; const t = text(c);
53
+ const act = useRpc(setOnboardingRpc); const cache = useQueryClient(); const toast = useToast();
54
+ const [step, setStep] = useState<OnboardingStep>(view.step);
55
+ const index = ONBOARDING_STEPS.indexOf(step);
56
+ const scroll = useRef<ScrollView>(null);
57
+ const follow = useFollowSettings();
58
+ // Checks start on the first frame so step 2 usually opens with its answers in. One cached call, never polled.
59
+ const checks = useChecks();
60
+ const move = useMutation({
61
+ mutationFn: (input: Parameters<typeof act>[0]) => act(input),
62
+ onSuccess: next => { if (!next.show) cache.setQueryData(onboardingKey, next); },
63
+ onError: error => toast.error(errorText(error)),
64
+ });
65
+ const go = (next: OnboardingStep) => { setStep(next); scroll.current?.scrollTo({ y: 0, animated: false }); move.mutate({ action: "step", step: next }); };
66
+ const finish = () => move.mutate({ action: "finish" }, { onSuccess: () => {
67
+ const n = follow.data?.workspaces.filter(w => w.enable_tracking && !w.optedOut).length ?? 0;
68
+ toast.show(n ? `Set up. Following ${n} workspace${n === 1 ? "" : "s"}.` : "Set up. Follow-up starts with your next workspace.", { variant: "success" });
69
+ } });
70
+ const skip = () => move.mutate({ action: "skip" }, { onSuccess: () => toast.show("Setup skipped. Set it up any time from Follow-up settings, Set up Follow-up again.") });
71
+ const last = index === ONBOARDING_STEPS.length - 1;
72
+ const keyboard = useKeyboardUp(compact);
73
+ const failing = step === "checks" && checks.data ? checksSummary(checks.data.checks).state === "fail" : false;
74
+
75
+ const body = step === "intro" ? <IntroStep theme={theme} compact={compact} follow={follow.data ?? null} />
76
+ : step === "checks" ? <ChecksStep theme={theme} compact={compact} checks={checks} deps={deps} />
77
+ : step === "defaults" ? <DefaultsStep theme={theme} compact={compact} />
78
+ : step === "reviewers" ? <ReviewerSettings theme={theme} compact={compact} />
79
+ : <HelpersStep theme={theme} compact={compact} deps={deps} checks={checks.data?.checks ?? null} />;
80
+ const lead: Record<OnboardingStep, string> = {
81
+ intro: "It follows your agents' pull requests until the work is done, sends fixes back to them, and asks you only for decisions.",
82
+ checks: "Follow-up reads PRs with the GitHub CLI, and its helper agents run on Claude or Codex. Checking is free.",
83
+ defaults: "These are on now. Change anything here; it saves as you go, and Settings has the same switches.",
84
+ reviewers: "When you press Add reviewers on a PR, Follow-up asks these people. Set a default for all repositories, or a list for one. Until then, PRs without reviewers show in Needs you.",
85
+ helpers: "Two optional agents. They read, summarise and rank. They never change code or message anyone.",
86
+ };
87
+ const column: ViewStyle = { width: "100%", maxWidth: 560, alignSelf: "center", paddingHorizontal: compact ? 16 : 24 };
88
+
89
+ return <View style={{ flex: 1, backgroundColor: c.surface0 }}>
90
+ <View style={[column, { flexDirection: "row", alignItems: "center", gap: 12, paddingTop: compact ? 8 : 20, paddingBottom: 8 }]}>
91
+ <Progress theme={theme} index={index} onPick={i => i < index && go(ONBOARDING_STEPS[i])} />
92
+ <Button theme={theme} compact={compact} kind="ghost" title="Skip setup" accessibilityHint="Leaves setup. Every setting keeps its current value." onPress={skip} disabled={move.isPending} />
93
+ </View>
94
+ <ScrollView ref={scroll} style={{ flex: 1 }} contentContainerStyle={{ paddingBottom: 24 }} keyboardShouldPersistTaps="handled">
95
+ <StepFade key={step} style={[column, { gap: compact ? 14 : 16, paddingTop: compact ? 8 : 20 }]}>
96
+ <View style={{ gap: 6 }}>
97
+ <Text accessibilityRole="header" style={{ color: c.foreground, fontSize: 20, lineHeight: 26, fontWeight: "600" }}>{TITLES[step]}</Text>
98
+ <Text style={[t.body, { color: c.foregroundMuted, maxWidth: 520 }]}>{lead[step]}</Text>
99
+ </View>
100
+ {body}
101
+ </StepFade>
102
+ </ScrollView>
103
+ {/* While typing a reviewer on a phone the bar steps aside, so Continue never sits over the keyboard. */}
104
+ {!keyboard && <View style={[{ borderTopWidth: 1, borderTopColor: c.border, backgroundColor: c.surface0, paddingTop: 12 }, bottomPad(compact)]}>
105
+ <View style={[column, { flexDirection: "row", alignItems: "center", gap: 8 }]}>
106
+ {index > 0 && (compact
107
+ ? <IconButton theme={theme} compact icon="ChevronLeft" label="Back" onPress={() => go(ONBOARDING_STEPS[index - 1])} />
108
+ : <Button theme={theme} kind="ghost" icon="ChevronLeft" title="Back" onPress={() => go(ONBOARDING_STEPS[index - 1])} />)}
109
+ {!compact && <View style={{ flex: 1 }} />}
110
+ {step === "reviewers" && <Button theme={theme} compact={compact} kind="ghost" title="Skip, set later" onPress={() => go(ONBOARDING_STEPS[index + 1])} />}
111
+ <Button theme={theme} compact={compact} grow={compact} kind="primary" icon={last ? "Check" : undefined}
112
+ title={last ? "Finish" : failing ? "Continue anyway" : "Continue"} loading={last && move.isPending}
113
+ onPress={() => last ? finish() : go(ONBOARDING_STEPS[index + 1])} />
114
+ </View>
115
+ </View>}
116
+ </View>;
117
+ }
118
+
119
+ /** Phones: whether the on-screen keyboard is up (native events; on the web, the visual viewport shrinking). */
120
+ function useKeyboardUp(compact: boolean): boolean {
121
+ const [up, setUp] = useState(false);
122
+ useEffect(() => {
123
+ if (!compact) return;
124
+ if (Platform.OS === "web") {
125
+ type Viewport = { height: number; addEventListener(e: "resize", f: () => void): void; removeEventListener(e: "resize", f: () => void): void };
126
+ const vv = (globalThis as { visualViewport?: Viewport }).visualViewport;
127
+ const win = globalThis as unknown as { innerHeight: number };
128
+ if (!vv) return;
129
+ const check = () => setUp(win.innerHeight - vv.height > 150);
130
+ vv.addEventListener("resize", check);
131
+ return () => vv.removeEventListener("resize", check);
132
+ }
133
+ const show = Keyboard.addListener(Platform.OS === "ios" ? "keyboardWillShow" : "keyboardDidShow", () => setUp(true));
134
+ const hide = Keyboard.addListener(Platform.OS === "ios" ? "keyboardWillHide" : "keyboardDidHide", () => setUp(false));
135
+ return () => { show.remove(); hide.remove(); };
136
+ }, [compact]);
137
+ return up;
138
+ }
139
+
140
+ /** "2 of 5" and one short segment per step, drawn like the stack bar but in neutral ink: progress isn't a PR state. */
141
+ function Progress({ theme, index, onPick }: { theme: Theme; index: number; onPick: (i: number) => void }) {
142
+ const c = theme.colors; const t = text(c);
143
+ return <View style={{ flex: 1, flexDirection: "row", alignItems: "center", gap: 10 }} accessibilityRole="progressbar" accessibilityLabel={`Step ${index + 1} of ${ONBOARDING_STEPS.length}`}
144
+ accessibilityValue={{ min: 1, max: ONBOARDING_STEPS.length, now: index + 1 }}>
145
+ <Text style={[t.small, { minWidth: 34 }]}>{`${index + 1} of ${ONBOARDING_STEPS.length}`}</Text>
146
+ <View style={{ flex: 1, maxWidth: 220, flexDirection: "row", gap: 3 }}>
147
+ {ONBOARDING_STEPS.map((s, i) => <Pressable key={s} disabled={i >= index} onPress={() => onPick(i)} accessibilityLabel={i < index ? `Back to step ${i + 1}` : undefined}
148
+ hitSlop={{ top: 12, bottom: 12 }} style={{ flex: 1, height: 14, justifyContent: "center" }}>
149
+ <View style={{ height: 3, borderRadius: 2, backgroundColor: i === index ? c.foreground : i < index ? withAlpha(c.foreground, 0.4) : c.border }} />
150
+ </Pressable>)}
151
+ </View>
152
+ </View>;
153
+ }
154
+
155
+ /** Step change: a short fade and rise; reduced motion gets the content at once. */
156
+ function StepFade({ children, style }: { children: ReactNode; style: ViewStyle | ViewStyle[] }) {
157
+ const reduced = useReducedMotion();
158
+ const v = useRef(new Animated.Value(reduced ? 1 : 0)).current;
159
+ useEffect(() => { if (!reduced) Animated.timing(v, { toValue: 1, duration: 180, easing: Easing.out(Easing.cubic), useNativeDriver: Platform.OS !== "web" }).start(); }, []);
160
+ return <Animated.View style={[style as ViewStyle, { opacity: v, transform: [{ translateY: v.interpolate({ inputRange: [0, 1], outputRange: [6, 0] }) }] }]}>{children}</Animated.View>;
161
+ }
162
+
163
+ function useFollowSettings() {
164
+ const read = useRpc(followSettingsRpc);
165
+ return useQuery({ queryKey: followKey, queryFn: () => read({}) });
166
+ }
167
+ function useChecks() {
168
+ const read = useRpc(onboardingChecksRpc);
169
+ return useQuery({ queryKey: checksKey, queryFn: () => read({}), staleTime: 60_000, refetchOnWindowFocus: false, retry: false });
170
+ }
171
+
172
+ const Panel = ({ c, children }: { c: Colors; children: ReactNode }) =>
173
+ <View style={{ ...raised(c), borderRadius: 10, backgroundColor: c.surface1, overflow: "hidden" }}>{children}</View>;
174
+
175
+ // ---------- 1. what it is ----------
176
+
177
+ const EXAMPLE = [
178
+ { glyph: "CircleX", tone: "danger", line: "Checks failed on #418", caption: "Follow-up notices" },
179
+ { glyph: "spinner", tone: "running", line: "Repair sent to the agent · 2m", caption: "and sends the fix to the agent that made the PR" },
180
+ { glyph: "CircleCheck", tone: "success", dot: "warning", line: "#418 approved", caption: "then asks you only for the decision" },
181
+ ] as const;
182
+
183
+ function IntroStep({ theme, compact, follow }: { theme: Theme; compact: boolean; follow: { workspaces: { enable_tracking: boolean; optedOut: boolean }[] } | null }) {
184
+ const c = theme.colors; const t = text(c);
185
+ const reduced = useReducedMotion();
186
+ const [phase, setPhase] = useState(reduced ? 2 : 0);
187
+ useEffect(() => { if (reduced || phase >= 2) return; const id = setTimeout(() => setPhase(p => p + 1), 1600); return () => clearTimeout(id); }, [phase, reduced]);
188
+ const n = follow?.workspaces.filter(w => w.enable_tracking && !w.optedOut).length ?? null;
189
+ const tone = (k: string) => k === "danger" ? c.statusDanger : k === "success" ? c.statusSuccess : runningColor(c);
190
+ const e = EXAMPLE[phase];
191
+ return <View style={{ gap: 14 }}>
192
+ <Panel c={c}>
193
+ <View style={{ padding: compact ? 14 : 16, gap: 10 }}>
194
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
195
+ <Text numberOfLines={1} style={[t.label, { flex: 1 }]}>TKT-1042 Add CSV export</Text>
196
+ <Text style={[t.small, { paddingHorizontal: 6, paddingVertical: 1, borderRadius: 4, backgroundColor: c.surface2 }]}>Example</Text>
197
+ </View>
198
+ {/* The stack bar: #417 merged, #418 the one this example follows. */}
199
+ <View style={{ flexDirection: "row", gap: 3, height: 4 }}>
200
+ <View style={{ flex: 1, borderRadius: 2, backgroundColor: c.foregroundMuted, opacity: 0.55 }} />
201
+ <View style={{ flex: 1, borderRadius: 2, backgroundColor: c.border, alignItems: "center", justifyContent: "center" }}>
202
+ <View style={{ width: 10, height: 4, borderRadius: 2, backgroundColor: tone(e.tone) }} />
203
+ </View>
204
+ </View>
205
+ <View accessibilityLiveRegion="polite" style={{ flexDirection: "row", alignItems: "center", gap: 8, minHeight: 20 }}>
206
+ {e.glyph === "spinner" ? <Spinner color={runningColor(c)} size={14} /> : <Icon name={e.glyph} size={14} color={tone(e.tone)} />}
207
+ <Text style={[t.body, { flex: 1 }]}>{e.line}</Text>
208
+ {phase === 2 && <View style={{ flexDirection: "row", alignItems: "center", gap: 4, paddingHorizontal: 7, minHeight: 22, borderRadius: 11, backgroundColor: tint(c.statusWarning, c) }}>
209
+ <Icon name="CircleAlert" size={12} color={c.statusWarning} />
210
+ <Text style={{ color: c.statusWarning, fontSize: 12, lineHeight: 16, fontWeight: "600" }}>Needs you: Merge #418</Text>
211
+ </View>}
212
+ </View>
213
+ </View>
214
+ {/* What Follow-up did, step by step: the rail fills as the example plays. */}
215
+ <View style={{ borderTopWidth: 1, borderTopColor: c.border, paddingHorizontal: compact ? 14 : 16, paddingVertical: 10, gap: 6 }}>
216
+ {EXAMPLE.map((x, i) => <View key={x.line} style={{ flexDirection: "row", alignItems: "center", gap: 8, opacity: i <= phase ? 1 : 0.35 }}>
217
+ <View style={{ width: 8, height: 8, borderRadius: 4, backgroundColor: i <= phase ? ("dot" in x ? c.statusWarning : tone(x.tone)) : c.border }} />
218
+ <Text style={t.meta}>{x.caption}</Text>
219
+ </View>)}
220
+ </View>
221
+ </Panel>
222
+ <View style={{ gap: 4 }}>
223
+ {[
224
+ ["Inbox", "Needs you", "One list of what only you can decide: a merge, a question, a permission."],
225
+ ["Wrench", "Repairs", "Review comments, conflicts and failed checks go to the workspace's agent in one batch."],
226
+ ["MessageCircleQuestion", "Questions", "Agents ask you here, with options and a recommendation. Your answer goes to their chat."],
227
+ ].map(([icon, title, line]) => <View key={title} style={{ flexDirection: "row", gap: 10, paddingVertical: 6 }}>
228
+ <Icon name={icon} size={16} color={c.foregroundMuted} />
229
+ <View style={{ flex: 1, gap: 1 }}><Text style={t.label}>{title}</Text><Text style={t.meta}>{line}</Text></View>
230
+ </View>)}
231
+ </View>
232
+ {n !== null && <View style={{ flexDirection: "row", alignItems: "center", gap: 8, minHeight: compact ? 44 : 36, paddingHorizontal: 12, borderRadius: 8, backgroundColor: c.surface1 }}>
233
+ <Icon name="Radar" size={14} color={c.foregroundMuted} />
234
+ <Text style={[t.body, { flex: 1 }]}>{n ? `Already following your ${n} workspace${n === 1 ? "" : "s"}. Step 3 lists them.` : "No workspaces yet. Follow-up starts with the next one you create."}</Text>
235
+ </View>}
236
+ </View>;
237
+ }
238
+
239
+ // ---------- 2. checks ----------
240
+
241
+ function ChecksStep({ theme, compact, checks, deps }: { theme: Theme; compact: boolean; checks: ReturnType<typeof useChecks>; deps: SetupDeps }) {
242
+ const c = theme.colors; const t = text(c);
243
+ const read = useRpc(onboardingChecksRpc); const cache = useQueryClient();
244
+ const again = useMutation({ mutationFn: () => read({ fresh: true }), onSuccess: data => cache.setQueryData(checksKey, data) });
245
+ const busy = checks.isPending || again.isPending;
246
+ const rows = checks.data?.checks ?? null;
247
+ const summary = rows ? checksSummary(rows) : null;
248
+ return <View style={{ gap: 10 }}>
249
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
250
+ <Text style={[t.meta, { flex: 1 }]}>{busy ? "Checking…" : summary?.line ?? ""}</Text>
251
+ <Button theme={theme} compact={compact} kind="secondary" icon="RefreshCw" title="Check again" loading={again.isPending} disabled={busy} onPress={() => again.mutate()} />
252
+ </View>
253
+ {(checks.error || again.error) && <Text accessibilityRole="alert" style={[t.meta, { color: c.statusDanger }]}>{errorText(checks.error ?? again.error)}</Text>}
254
+ <Panel c={c}>
255
+ {rows ? rows.map((row, i) => <CheckRow key={row.id} theme={theme} compact={compact} row={row} first={i === 0} checking={again.isPending} deps={deps} />)
256
+ : ["GitHub", "Claude", "Codex", "Agent tools"].map((label, i) => <CheckRow key={label} theme={theme} compact={compact} first={i === 0} checking deps={deps} row={{ id: label, label, state: "pending", detail: "Checking…", fix: null }} />)}
257
+ </Panel>
258
+ {summary?.state === "fail" && <Text style={t.meta}>You can continue anyway. Following and Needs you work without what's missing; each row says what it affects.</Text>}
259
+ </View>;
260
+ }
261
+
262
+ const GLYPH: Record<Check["state"], string> = { ok: "CircleCheck", warn: "CircleAlert", fail: "CircleX", pending: "CircleDashed", off: "CircleMinus" };
263
+ function CheckRow({ theme, compact, row, first, checking, deps }: { theme: Theme; compact: boolean; row: Check; first: boolean; checking: boolean; deps: SetupDeps }) {
264
+ const c = theme.colors; const t = text(c); const toast = useToast();
265
+ const [open, setOpen] = useState(false);
266
+ const color = row.state === "ok" ? c.statusSuccess : row.state === "warn" ? c.statusWarning : row.state === "fail" ? c.statusDanger : c.foregroundMuted;
267
+ return <View accessibilityLabel={`${row.label}: ${row.detail}`} style={{ flexDirection: "row", gap: 10, paddingHorizontal: compact ? 14 : 16, paddingVertical: 12, borderTopWidth: first ? 0 : 1, borderTopColor: c.border }}>
268
+ <View style={{ paddingTop: 1 }}>{checking ? <Spinner color={c.foregroundMuted} size={16} /> : <Icon name={GLYPH[row.state]} size={16} color={color} />}</View>
269
+ <View style={{ flex: 1, minWidth: 0, gap: 3 }}>
270
+ <Text style={t.label}>{row.label}</Text>
271
+ <Text style={t.meta}>{row.detail}</Text>
272
+ {row.fix && row.state === "warn" && !open && <Pressable accessibilityRole="button" accessibilityState={{ expanded: false }} onPress={() => setOpen(true)} style={{ minHeight: compact ? 44 : 28, justifyContent: "center", alignSelf: "flex-start" }}>
273
+ <Text style={[t.meta, { color: c.foreground, textDecorationLine: "underline" }]}>How to fix</Text>
274
+ </Pressable>}
275
+ {row.fix && (row.state !== "warn" || open) && <View style={{ gap: 6, marginTop: 4 }}>
276
+ <Text style={[t.meta, { color: c.foreground }]}>{row.fix.text}</Text>
277
+ {row.fix.command && <View style={{ flexDirection: "row", alignItems: "center", gap: 6, alignSelf: "flex-start", maxWidth: "100%", paddingLeft: 10, borderRadius: 6, backgroundColor: c.surface2 }}>
278
+ <Text selectable numberOfLines={1} style={{ flexShrink: 1, color: c.foreground, fontSize: 12, lineHeight: 17, fontFamily: Platform.OS === "ios" ? "Menlo" : "ui-monospace, SFMono-Regular, Menlo, monospace" }}>{row.fix.command}</Text>
279
+ <IconButton theme={theme} compact={compact} icon="Copy" label={`Copy ${row.fix.command}`} onPress={() => { void copyText(row.fix!.command!).then(() => toast.show("Copied", { variant: "success" }), () => toast.error("Couldn't copy here")); }} />
280
+ </View>}
281
+ {row.fix.settings && <Button theme={theme} compact={compact} kind="ghost" icon="Settings" title="Open Settings, Agents" onPress={() => deps.openSettings(row.fix!.settings!)} />}
282
+ </View>}
283
+ </View>
284
+ </View>;
285
+ }
286
+
287
+ // ---------- 3. what it does on its own ----------
288
+
289
+ function SwitchRow({ theme, compact, label, hint, value, onChange, disabled, first, children }: { theme: Theme; compact: boolean; label: string; hint: string; value: boolean | null; onChange: (v: boolean) => void; disabled?: boolean; first?: boolean; children?: ReactNode }) {
290
+ const c = theme.colors; const t = text(c);
291
+ const on = !!value;
292
+ return <View style={{ borderTopWidth: first ? 0 : 1, borderTopColor: c.border }}>
293
+ <Pressable accessibilityRole="switch" accessibilityState={{ checked: on, disabled: disabled || value === null }} aria-checked={on} accessibilityLabel={label} accessibilityHint={hint}
294
+ disabled={disabled || value === null} onPress={() => onChange(!on)}
295
+ style={({ pressed }) => ({ flexDirection: "row", alignItems: "center", gap: 12, paddingHorizontal: compact ? 14 : 16, paddingVertical: 12, minHeight: compact ? 56 : 48, backgroundColor: pressed ? c.surface2 : "transparent" })}>
296
+ <View style={{ flex: 1, minWidth: 0, gap: 2 }}>
297
+ <Text style={t.label}>{label}</Text>
298
+ <Text style={t.meta}>{hint}</Text>
299
+ </View>
300
+ <View style={{ width: 36, height: 22, borderRadius: 11, padding: 2, backgroundColor: on ? c.accent : c.surface2, borderWidth: on ? 0 : 1, borderColor: c.border, justifyContent: "center", opacity: value === null ? 0.4 : 1 }}>
301
+ <View style={{ width: 18, height: 18, borderRadius: 9, backgroundColor: on ? c.accentForeground : c.foregroundMuted, alignSelf: on ? "flex-end" : "flex-start" }} />
302
+ </View>
303
+ </Pressable>
304
+ {children}
305
+ </View>;
306
+ }
307
+
308
+ function DefaultsStep({ theme, compact }: { theme: Theme; compact: boolean }) {
309
+ const c = theme.colors; const t = text(c);
310
+ const follow = useFollowSettings(); const write = useRpc(setFollowSettingsRpc); const cache = useQueryClient(); const toast = useToast();
311
+ const display = useSettings(displayPreferences);
312
+ const [all, setAll] = useState(false);
313
+ const change = useMutation({
314
+ mutationFn: async (inputs: Parameters<typeof write>[0][]) => { let last = null; for (const input of inputs) last = await write(input); return last; },
315
+ onSuccess: value => { if (value) cache.setQueryData(followKey, value); void cache.invalidateQueries({ queryKey: ["follow-through", "project-settings"] }); },
316
+ onError: error => toast.error(errorText(error)),
317
+ });
318
+ const data = follow.data;
319
+ const list = data?.workspaces ?? [];
320
+ const followed = list.filter(w => w.enable_tracking && !w.optedOut).length;
321
+ const shown = all || list.length <= 8 ? list : list.slice(0, 5);
322
+ const trust = display.status === "ready" ? display.values.enable_trust_bypass : null;
323
+ const saveDisplay = (patch: Partial<typeof displayPreferences.schema._output>) => {
324
+ if (display.status !== "ready") return;
325
+ void display.save({ ...display.values, ...patch }, display.revision).catch(e => toast.error(errorText(e)));
326
+ };
327
+ return <View style={{ gap: 10 }}>
328
+ {follow.error && <Text accessibilityRole="alert" style={[t.meta, { color: c.statusDanger }]}>{errorText(follow.error)}</Text>}
329
+ <Panel c={c}>
330
+ <SwitchRow first theme={theme} compact={compact} label="Follow every workspace" hint="New and existing workspaces, except any you turn off below." value={data?.enable_follow_every ?? null} disabled={change.isPending}
331
+ onChange={v => change.mutate([{ enable_follow_every: v }])}>
332
+ {list.length > 0 && <View style={{ paddingLeft: compact ? 14 : 16, paddingBottom: 6 }}>
333
+ {shown.map(w => {
334
+ const on = w.enable_tracking && !w.optedOut;
335
+ return <Pressable key={w.id} accessibilityRole="checkbox" accessibilityState={{ checked: on }} aria-checked={on} accessibilityLabel={`Follow ${w.title}`} disabled={change.isPending}
336
+ onPress={() => change.mutate([{ workspace: { workspaceId: w.id, follow: !on } }])}
337
+ style={({ pressed }) => ({ flexDirection: "row", alignItems: "center", gap: 10, minHeight: compact ? 44 : 32, paddingRight: compact ? 14 : 16, borderTopWidth: 1, borderTopColor: c.border, backgroundColor: pressed ? c.surface2 : "transparent" })}>
338
+ <Text style={[t.body, { flex: 1, color: on ? c.foreground : c.foregroundMuted }]}>{w.title}</Text>
339
+ {(!on || w.dormant) && <Text style={t.small}>{on ? "Resting" : "Not followed"}</Text>}
340
+ <View style={{ width: 18, height: 18, borderRadius: 5, borderWidth: 1, borderColor: on ? c.accent : c.border, backgroundColor: on ? c.accent : "transparent", alignItems: "center", justifyContent: "center" }}>
341
+ {on && <Icon name="Check" size={12} color={c.accentForeground} />}
342
+ </View>
343
+ </Pressable>;
344
+ })}
345
+ {shown.length < list.length && <Pressable accessibilityRole="button" onPress={() => setAll(true)} style={{ minHeight: compact ? 44 : 32, justifyContent: "center", borderTopWidth: 1, borderTopColor: c.border }}>
346
+ <Text style={[t.meta, { color: c.foreground }]}>{`Show all ${list.length}`}</Text>
347
+ </Pressable>}
348
+ </View>}
349
+ </SwitchRow>
350
+ <SwitchRow theme={theme} compact={compact} label="Send repairs automatically" value={data?.enable_auto_sends_default ?? null} disabled={change.isPending}
351
+ hint={`Review threads and failed checks go to the workspace's agent on their own, once it's idle. Off: each batch waits for your click.${followed ? ` Here it also applies to the ${followed} already followed.` : ""}`}
352
+ onChange={v => change.mutate(autoSendWrites(v, list))} />
353
+ <SwitchRow theme={theme} compact={compact} label="Trust bypass agents" value={trust}
354
+ hint="An agent you started in bypass or full access sometimes still stops on a tool prompt. Follow-up approves those so it keeps going, and logs each one. Off brings the prompts back."
355
+ onChange={v => saveDisplay({ enable_trust_bypass: v })} />
356
+ </Panel>
357
+ <Text style={t.meta}>Follow-up never merges, requests reviewers, archives or messages people on its own.</Text>
358
+ </View>;
359
+ }
360
+
361
+ // ---------- 5. helpers and where to find things ----------
362
+
363
+ function HelpersStep({ theme, compact, deps, checks }: { theme: Theme; compact: boolean; deps: SetupDeps; checks: Check[] | null }) {
364
+ const c = theme.colors; const t = text(c);
365
+ const display = useSettings(displayPreferences); const toast = useToast();
366
+ const readAgents = useRpc(agentSettingsRpc);
367
+ const agents = useQuery({ queryKey: ["follow-through", "agent-settings", "summary"], queryFn: () => readAgents({}), staleTime: 60_000 });
368
+ const role = (r: string) => agents.data?.roles.find(x => x.role === r)?.summary ?? null;
369
+ const values = display.status === "ready" ? display.values : null;
370
+ const save = (patch: Partial<typeof displayPreferences.schema._output>) => { if (display.status === "ready") void display.save({ ...display.values, ...patch }, display.revision).catch(e => toast.error(errorText(e))); };
371
+ const claudeDown = checks?.find(x => x.id === "provider-claude")?.state === "fail";
372
+ const on = (summary: string | null) => summary ? ` Runs on ${summary}.` : "";
373
+ return <View style={{ gap: 14 }}>
374
+ <Panel c={c}>
375
+ <SwitchRow first theme={theme} compact={compact} label="Overseer" value={values?.enable_overseer ?? null} onChange={v => save({ enable_overseer: v })}
376
+ hint={`One agent you ask about all your workspaces, from Home's search box. It starts only when you click Start on Home.${on(role("overseer"))}`} />
377
+ <SwitchRow theme={theme} compact={compact} label="AI priority" value={values?.enable_ranker ?? null} onChange={v => save({ enable_ranker: v })}
378
+ hint={`Sorts Home by what matters most, from your Linear issues, Slack mentions and review requests. About once an hour on workdays.${on(role("ranker"))}`} />
379
+ <View style={{ flexDirection: compact ? "column" : "row", alignItems: compact ? "flex-start" : "center", gap: 8, paddingHorizontal: compact ? 14 : 16, paddingVertical: 10, borderTopWidth: 1, borderTopColor: c.border }}>
380
+ <Text style={[t.meta, { flex: compact ? undefined : 1 }]}>{`What's this about? summaries use ${role("about") ?? "a small model"}.${claudeDown ? " Claude isn't available here; switch the helpers to Codex in Settings." : ""}`}</Text>
381
+ {compact
382
+ ? <Pressable accessibilityRole="link" accessibilityLabel="Change models in Follow-up settings, Agents" onPress={() => deps.openSettings("agents")} style={{ minHeight: 44, justifyContent: "center" }}>
383
+ <Text style={[t.label, { textDecorationLine: "underline" }]}>Change models</Text>
384
+ </Pressable>
385
+ : <Button theme={theme} kind="ghost" icon="Bot" title="Change models" accessibilityLabel="Change models in Follow-up settings, Agents" onPress={() => deps.openSettings("agents")} />}
386
+ </View>
387
+ </Panel>
388
+ <View style={{ gap: 2 }}>
389
+ <Text accessibilityRole="header" style={{ color: c.foregroundMuted, fontSize: 11, lineHeight: 15, fontWeight: "600", letterSpacing: 0.5, textTransform: "uppercase", marginTop: 10, marginBottom: 4 }}>Where to find things</Text>
390
+ <TourRow theme={theme} thumb={<ThumbHome c={c} />} title="Home" line="Follow-up in the sidebar. Every workspace, with what needs you at the top." />
391
+ <TourRow theme={theme} thumb={<ThumbPanel c={c} />} title="Workspace panel"
392
+ line={compact ? "Tap Follow-up at the top of any workspace: its PRs, tasks and what the agent is doing." : "The Follow-up button in a workspace's header docks its PRs, tasks and what the agent is doing beside the chat."} />
393
+ <TourRow theme={theme} thumb={<ThumbNeeds c={c} />} title="Needs you" line="The decisions only you can make, one button each. A pill above the chat shows the same." />
394
+ <TourRow theme={theme} thumb={<ThumbAbout c={c} />} title="What's this about?" line="At the top of a workspace: a short summary of what it's for and where it stands, with its links." />
395
+ </View>
396
+ </View>;
397
+ }
398
+
399
+ function TourRow({ theme, thumb, title, line }: { theme: Theme; thumb: ReactNode; title: string; line: string }) {
400
+ const c = theme.colors; const t = text(c);
401
+ return <View style={{ flexDirection: "row", alignItems: "center", gap: 12, paddingVertical: 8 }}>
402
+ <View style={{ width: 56, height: 44, borderRadius: 8, borderWidth: 1, borderColor: c.border, backgroundColor: c.surface1, overflow: "hidden", padding: 6, gap: 4 }}>{thumb}</View>
403
+ <View style={{ flex: 1, minWidth: 0, gap: 1 }}><Text style={t.label}>{title}</Text><Text style={t.meta}>{line}</Text></View>
404
+ </View>;
405
+ }
406
+ // Token-drawn thumbnails: the shape of each surface, not a screenshot.
407
+ const bar = (c: Colors, w: `${number}%`, color = c.border, h = 3) => <View style={{ width: w, height: h, borderRadius: 2, backgroundColor: color }} />;
408
+ const ThumbHome = ({ c }: { c: Colors }) => <>{bar(c, "60%", c.statusWarning)}{bar(c, "90%")}{bar(c, "75%")}{bar(c, "85%")}</>;
409
+ const ThumbPanel = ({ c }: { c: Colors }) => <>{bar(c, "55%", c.foregroundMuted)}<View style={{ flexDirection: "row", gap: 2 }}>{bar(c, "30%", c.foregroundMuted, 4)}{bar(c, "30%", c.border, 4)}{bar(c, "30%", c.border, 4)}</View>{bar(c, "80%")}</>;
410
+ const ThumbNeeds = ({ c }: { c: Colors }) => <View style={{ flex: 1, borderRadius: 4, borderWidth: 1, borderColor: c.statusWarning, padding: 4, gap: 3 }}>{bar(c, "70%")}<View style={{ width: 16, height: 5, borderRadius: 2, backgroundColor: c.accent }} /></View>;
411
+ const ThumbAbout = ({ c }: { c: Colors }) => <><View style={{ flexDirection: "row", alignItems: "center", gap: 3 }}><Icon name="ChevronDown" size={8} color={c.foregroundMuted} />{bar(c, "60%", c.foregroundMuted)}</View>{bar(c, "90%")}{bar(c, "80%")}</>;
412
+
413
+ // ---------- existing installs ----------
414
+
415
+ /** The one quiet line an existing install sees on Home, for a day at most. */
416
+ export function SetupOffer({ theme, compact, view }: { theme: Theme; compact: boolean; view: OnboardingView | undefined }) {
417
+ const c = theme.colors; const t = text(c);
418
+ const act = useRpc(setOnboardingRpc); const cache = useQueryClient(); const toast = useToast();
419
+ const run = useMutation({ mutationFn: (action: "restart" | "dismiss-offer") => act({ action }), onSuccess: next => cache.setQueryData(onboardingKey, next), onError: e => toast.error(errorText(e)) });
420
+ if (!view?.offer) return null;
421
+ return <View style={{ flexDirection: compact ? "column" : "row", alignItems: compact ? "stretch" : "center", gap: compact ? 6 : 10, marginHorizontal: compact ? 12 : 16, paddingLeft: 12, paddingRight: 4, paddingVertical: 4, borderRadius: 8, backgroundColor: c.surface1 }}>
422
+ <View style={{ flex: compact ? undefined : 1, flexDirection: "row", alignItems: "center", gap: 8, paddingTop: compact ? 8 : 0 }}>
423
+ <Icon name="ListChecks" size={14} color={c.foregroundMuted} />
424
+ <Text style={[t.meta, { flex: 1 }]}>Follow-up has a two-minute setup that checks GitHub and shows what it does on its own.</Text>
425
+ </View>
426
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 2, justifyContent: compact ? "flex-end" : undefined }}>
427
+ <Button theme={theme} compact={compact} kind="ghost" title="Open setup" loading={run.isPending && run.variables === "restart"} onPress={() => run.mutate("restart")} />
428
+ <IconButton theme={theme} compact={compact} icon="X" label="Dismiss the setup offer" onPress={() => run.mutate("dismiss-offer")} />
429
+ </View>
430
+ </View>;
431
+ }
432
+
433
+ /** Settings and ⌘K: "Set up Follow-up again" starts the flow from the top and shows it on Home. */
434
+ export function useRestartSetup() {
435
+ const act = useRpc(setOnboardingRpc); const cache = useQueryClient();
436
+ return useMemo(() => async () => { const next = await act({ action: "restart" }); cache.setQueryData(onboardingKey, next); return next; }, [act, cache]);
437
+ }
@@ -48,7 +48,7 @@ const followKey = ["follow-through", "follow-settings"];
48
48
  * workspace", so they stay next to it. Workspaces replaces the old 100-option select: search, exceptions first,
49
49
  * one row open at a time, 25 rows and "Show more".
50
50
  */
51
- function FollowingCategory({ theme, compact }: { theme: Theme; compact: boolean }) {
51
+ function FollowingCategory({ theme, compact, openSetup }: { theme: Theme; compact: boolean; openSetup?: () => void }) {
52
52
  const c = theme.colors; const t = text(c);
53
53
  const read = useRpc(followSettingsRpc); const write = useRpc(setFollowSettingsRpc); const cache = useQueryClient(); const toast = useToast();
54
54
  const query = useQuery({ queryKey: followKey, queryFn: () => read({}), refetchInterval: 30000 });
@@ -60,6 +60,7 @@ function FollowingCategory({ theme, compact }: { theme: Theme; compact: boolean
60
60
  const data = query.data;
61
61
  const windowDays = data?.activeWindowDays ?? 3;
62
62
  return <>
63
+ {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>}
63
64
  <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.">
64
65
  {query.isPending && <ActivityIndicator accessibilityLabel="Loading following settings" color={c.foregroundMuted} style={{ alignSelf: "flex-start", marginVertical: 8 }} />}
65
66
  {query.error && <SettingsCard><SettingsAction label="Couldn't load following settings" hint={errorText(query.error)} actionLabel="Retry" onPress={() => void query.refetch()} /></SettingsCard>}
@@ -185,7 +186,7 @@ function useSummaries(): Partial<Record<SettingsCategory, string | null>> {
185
186
  * on this device. Phone: the category list, drilling in with a back row. Only the open category mounts, so only its
186
187
  * data loads.
187
188
  */
188
- export function FollowSettings({ theme, layout }: PluginSurfaceProps) {
189
+ export function FollowSettings({ theme, layout, openSetup }: PluginSurfaceProps & { openSetup?: () => void }) {
189
190
  const c = theme.colors; const t = text(c);
190
191
  const compact = layout.compact;
191
192
  const [category, setCategory] = useState<SettingsCategory>(() => readCategory());
@@ -193,7 +194,7 @@ export function FollowSettings({ theme, layout }: PluginSurfaceProps) {
193
194
  const [drilled, setDrilled] = useState(() => hasSavedCategory());
194
195
  const summaries = useSummaries();
195
196
  const pick = (id: SettingsCategory) => { writeCategory(id); setCategory(id); };
196
- const content = category === "following" ? <FollowingCategory theme={theme} compact={compact} />
197
+ const content = category === "following" ? <FollowingCategory theme={theme} compact={compact} openSetup={openSetup} />
197
198
  : category === "reviewers" ? <View style={{ gap: 8 }}>
198
199
  <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>
199
200
  <ReviewerSettings theme={theme} compact={compact} />
package/index.client.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import { contributeDisplay } from "./client/display";
2
2
  import { withButtonVisibility } from "./client/button-visibility";
3
- import { openExternalUrl, type PluginClientContext, type PluginButtonRegistration, type PluginScreenProps, type PluginWorkspacePanelProps } from "@getpaseo/plugin/client";
3
+ import { openExternalUrl, type PluginClientContext, type PluginButtonRegistration, type PluginScreenProps, type PluginSurfaceProps, type PluginWorkspacePanelProps } from "@getpaseo/plugin/client";
4
4
  import { Dimensions } from "react-native";
5
5
  import { FollowSettings } from "./client/settings";
6
6
  import { FollowHome, HOME_SCREEN } from "./client/home";
@@ -16,6 +16,8 @@ import { contributeInboxCommands } from "./client/inbox";
16
16
  import type { BriefDeps } from "./client/brief";
17
17
  import { inboxSidebarView, sidebarViewHost } from "./client/sidebar-view";
18
18
  import { contributeBrief } from "./client/brief";
19
+ import { setOnboardingRpc } from "./shared/contracts";
20
+ import { isCategory, writeCategory } from "./shared/settings-nav";
19
21
 
20
22
  /** Home. The same screen id the Overview had, so the sidebar row, ⌘K and saved links land on Home. */
21
23
  const OVERVIEW = HOME_SCREEN;
@@ -29,10 +31,14 @@ export default function contribute(host: PluginClientContext) {
29
31
  const client = visibility.client;
30
32
  const location = () => Dimensions.get("window").width < 768 ? "workspace" as const : "explorer" as const;
31
33
  const openPanel = (workspaceId: string) => client.openPanel(PANEL, { workspaceId, location: location() });
32
- const openSettings = () => client.openSettings("projects");
34
+ // A category (agents, reviewers, following) is saved first, so settings opens on it (drilled in on a phone).
35
+ const openSettings = (category?: string) => { if (isCategory(category)) writeCategory(category); client.openSettings("projects"); };
33
36
  const openOverview = () => client.openScreen({ screenId: OVERVIEW });
34
37
  const openLog = () => client.openScreen({ screenId: OVERVIEW, params: { view: "log" } });
35
38
  const openLarge = (workspaceId: string) => client.openScreen({ screenId: LARGE_SCREEN, params: { workspaceId } });
39
+ // "Set up Follow-up again" (Settings and ⌘K): restart the flow on the server, then open Home, which shows it.
40
+ const openSetup = () => { void client.rpc(setOnboardingRpc, { action: "restart" }).catch(() => undefined).then(() => client.openScreen({ screenId: OVERVIEW, params: { setup: String(Date.now()) } })); };
41
+ const Settings = (props: PluginSurfaceProps) => <FollowSettings {...props} openSetup={openSetup} />;
36
42
  const store = createLiveStore(client);
37
43
  const inbox = createInboxStore(host);
38
44
  const HeaderIcon = headerIcon(store);
@@ -64,8 +70,8 @@ export default function contribute(host: PluginClientContext) {
64
70
  const removers: (() => unknown)[] = [
65
71
  client.addScreen({ id: OVERVIEW, title: "Follow-up", Component: Overview }),
66
72
  client.addScreen({ id: LARGE_SCREEN, title: params => store.get(params.workspaceId ?? "")?.title ?? "Follow-up", Component: Large }),
67
- ...LEGACY_SETTINGS_SCREENS.map(id => client.addScreen({ id, title: "Follow-up settings", Component: FollowSettings })),
68
- client.addSettingsScreen({ id: "projects", title: "Follow-up", icon: "GitPullRequest", Component: FollowSettings }),
73
+ ...LEGACY_SETTINGS_SCREENS.map(id => client.addScreen({ id, title: "Follow-up settings", Component: Settings })),
74
+ client.addSettingsScreen({ id: "projects", title: "Follow-up", icon: "GitPullRequest", Component: Settings }),
69
75
  client.addWorkspacePanel({ id: PANEL, title: "Follow-up", icon: "GitPullRequest", locations: ["workspace", "explorer"], Component: Panel }),
70
76
  client.addCommandCenterItem({ id: "open-follow-through", title: "Follow-up: open for this workspace", icon: "GitPullRequest", keywords: ["PR", "stack", "repairs", "done", "archive"], context: "workspace", onSelect({ openPanel }) { openPanel(PANEL, { location: location() }); } }),
71
77
  client.addCommandCenterItem({ id: "open-follow-through-large", title: "Follow-up: open the larger view", icon: "Maximize2", keywords: ["expand", "full screen", "maximize", "PR", "stack"], context: "workspace", onSelect({ workspace, openScreen }) { openScreen({ screenId: LARGE_SCREEN, params: { workspaceId: workspace.id } }); } }),
@@ -79,6 +85,8 @@ export default function contribute(host: PluginClientContext) {
79
85
  client.addCommandCenterItem({ id: "follow-through-search", title: "Follow-up: Search", icon: "Search", keywords: ["search", "find", "workspace", "branch", "PR", "omnibox"], context: "global", onSelect({ openScreen }) { openScreen({ screenId: OVERVIEW }); setTimeout(() => extras.focusSearch(), 150); } }),
80
86
  client.addCommandCenterItem({ id: "follow-through-log", title: "Follow-up: Done while you were away", icon: "History", keywords: ["log", "overnight", "away", "repairs", "activity"], context: "global", onSelect({ openScreen }) { openScreen({ screenId: OVERVIEW, params: { view: "log" } }); } }),
81
87
  client.addCommandCenterItem({ id: "follow-through-settings", title: "Follow-up: settings", icon: "Settings", keywords: ["default", "following", "project", "display", "sidebar", "pill", "header", "inbox", "questions"], context: "global", onSelect() { openSettings(); } }),
88
+ // "Set up Follow-up again": the setup flow from the top, on Home.
89
+ client.addCommandCenterItem({ id: "follow-through-setup", title: "Follow-up: Set up again", icon: "ListChecks", keywords: ["setup", "onboarding", "getting started", "checks", "gh", "tour", "welcome"], context: "global", onSelect() { openSetup(); } }),
82
90
  client.addSlashCommand({ name: "follow-up", description: "Open this workspace's PRs and remaining work", argumentHint: "", context: "agent", onSubmit({ openPanel }) { openPanel(PANEL, { location: location() }); } }),
83
91
  contributeChat(client),
84
92
  contributeFollowUpPill(client, { inbox, live: store, openPanel, openNext }),
package/index.server.ts CHANGED
@@ -59,6 +59,8 @@ import { readTranscript } from "./server/transcript";
59
59
  import { AgentSettingsStore, ProviderCatalog, type CatalogSource } from "./server/agent-settings";
60
60
  import { labelsFor, providerName, resolveRole, roleSummary, type AgentSettingsView } from "./shared/agent-settings";
61
61
  import type { LoadSignals } from "./shared/agent-load";
62
+ import { OnboardingStore, ReadinessChecks, nativeAgentCount } from "./server/onboarding";
63
+ import { execFile } from "node:child_process";
62
64
  import { BRIEF_KIND, BRIEF_VERSION, prState, validateNeedsYou, type Brief, type NeedsYouRecord } from "./shared/brief";
63
65
 
64
66
  export default function contribute(server: PluginServerContext) {
@@ -84,6 +86,7 @@ export default function contribute(server: PluginServerContext) {
84
86
  const handlers = new Map<string, { input: { parseAsync(value: unknown): Promise<unknown> }; run: (input: any, context: PluginHandlerContext) => unknown }>();
85
87
  const handle: PluginServerContext["handle"] = (contract, handler) => { handlers.set(contract.name, { input: contract.input, run: handler as never }); server.handle(contract, handler); };
86
88
  const store = new Store(directory, 1_000);
89
+ const onboarding = new OnboardingStore(directory);
87
90
  store.onChanged = scopeWriter(directory);
88
91
  const agentHooks = new AgentHooks(directory, clientEntry());
89
92
  const historyCache = HistoryCache.at(directory);
@@ -219,6 +222,8 @@ export default function contribute(server: PluginServerContext) {
219
222
  await copyFile(join(directory, "state.json"), join(directory, "state.before-active-scope.json.bak"), 1).catch(error => { if (!["ENOENT", "EEXIST"].includes((error as NodeJS.ErrnoException).code ?? "")) throw error; });
220
223
  };
221
224
  const ready = (async () => {
225
+ // Getting started: fresh or existing is decided from what's on disk before anything below writes state.
226
+ await onboarding.init().catch(() => undefined);
222
227
  unlock = await store.lock();
223
228
  await mkdir(directory, { recursive: true, mode: 0o700 });
224
229
  await writeFile(bridge, mcpSource, { mode: 0o600 });
@@ -778,6 +783,25 @@ export default function contribute(server: PluginServerContext) {
778
783
  if (approved) console.warn(`[follow-up] trust bypass approved ${approved} prompt(s) already pending at load`);
779
784
  }).catch(() => undefined);
780
785
  handle(rpc.trustBypassRpc, async () => trust.recent(20));
786
+ handle(rpc.onboardingRpc, async () => { await requireReady(); return onboarding.view(); });
787
+ handle(rpc.setOnboardingRpc, async ({ action, step }) => { await requireReady(); return onboarding.act(action, step ?? null); });
788
+ // Readiness checks for the setup flow: gh, the helper providers and whether tools attach. On demand only, cached.
789
+ const readiness = new ReadinessChecks({
790
+ gh: () => new Promise((resolve, reject) => execFile("gh", ["api", "user", "--jq", ".login"], { timeout: 10_000 }, (error, stdout, stderr) => error ? reject(Object.assign(error, { stderr })) : resolve(stdout))),
791
+ catalog: () => providerCatalog.read(),
792
+ use: async () => {
793
+ const on = await inboxSettings();
794
+ const roles = await agentSettings.all();
795
+ const use: Record<string, string[]> = {};
796
+ const add = (provider: string, name: string) => { (use[provider] ??= []).push(name); };
797
+ if (on.enable_overseer !== false) add(roles.overseer.provider, "the Overseer");
798
+ add(roles.about.provider, "What's this about?");
799
+ if (on.enable_ranker !== false) add(roles.ranker.provider, "AI priority");
800
+ return use;
801
+ },
802
+ tools: async () => ({ config: await paseoConfig(), nativeAgents: await nativeAgentCount(directory), hookError }),
803
+ });
804
+ handle(rpc.onboardingChecksRpc, async ({ fresh }, { paseo }) => { await requireReady(); seen(paseo); return readiness.run(!!fresh); });
781
805
 
782
806
  const removers = [
783
807
  server.on("agent.permission_requested", async (event, { paseo }) => { trustApi = paseo; await trust.handle(event.agent, event.request as never).catch(() => undefined); }),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "paseo-follow-up",
3
3
  "private": false,
4
- "version": "1.4.0-beta.13",
4
+ "version": "1.4.0-beta.14",
5
5
  "description": "Follow every workspace PR stack in Paseo, answer agent questions, batch repairs for the main agent, and see what needs you.",
6
6
  "type": "module",
7
7
  "files": [
@@ -0,0 +1,99 @@
1
+ import { readdir, readFile, rename, writeFile } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { applyOnboarding, classifyGhError, classifyInstall, ghCheck, initialOnboarding, offerVisible, onboardingFileSchema, onboardingView, providerChecks, toolsCheck,
4
+ type Check, type Checks, type GhResult, type OnboardingAction, type OnboardingFile, type OnboardingStep, type OnboardingView, type ProviderInfo, type ProviderUse, type ToolsInput } from "../shared/onboarding";
5
+
6
+ /**
7
+ * Getting started's progress, in `onboarding.json` beside state.json. Created the first time the worker starts with
8
+ * this version: a host with any Follow-up data already on disk is an existing install and is never shown the flow
9
+ * unless the developer asks (Settings → Set up Follow-up again). Resumes from the saved step after a reload.
10
+ */
11
+ export class OnboardingStore {
12
+ private tail: Promise<unknown> = Promise.resolve();
13
+ private cached: OnboardingFile | null = null;
14
+ constructor(readonly directory: string, private now = () => new Date()) {}
15
+ private get path() { return join(this.directory, "onboarding.json"); }
16
+
17
+ /**
18
+ * Call once at worker start, before anything writes state.json: decides fresh or existing from what is on disk.
19
+ * Returns the file (created or as saved).
20
+ */
21
+ async init(present?: string[]): Promise<OnboardingFile> {
22
+ const saved = await this.load();
23
+ if (saved) return saved;
24
+ const files = present ?? await readdir(this.directory).catch(() => [] as string[]);
25
+ const file = initialOnboarding(classifyInstall(files), this.now());
26
+ await this.write(file);
27
+ return file;
28
+ }
29
+ private async load(): Promise<OnboardingFile | null> {
30
+ if (this.cached) return this.cached;
31
+ try { this.cached = onboardingFileSchema.parse(JSON.parse(await readFile(this.path, "utf8"))); return this.cached; }
32
+ // Missing: not initialised yet. Unreadable: treat as an existing install that finished, never force the flow.
33
+ catch (error) { if ((error as NodeJS.ErrnoException).code === "ENOENT") return null; this.cached = { ...initialOnboarding("existing", this.now()), status: "done", offerDismissed: true }; return this.cached; }
34
+ }
35
+ private async write(file: OnboardingFile) {
36
+ const tmp = `${this.path}.${process.pid}.tmp`;
37
+ await writeFile(tmp, JSON.stringify(file, null, 2), { mode: 0o600 });
38
+ await rename(tmp, this.path);
39
+ this.cached = file;
40
+ }
41
+ private mutate(work: (file: OnboardingFile) => OnboardingFile): Promise<OnboardingFile> {
42
+ const next = this.tail.then(async () => { const file = work((await this.load()) ?? await this.init()); await this.write(file); return file; });
43
+ this.tail = next.catch(() => undefined);
44
+ return next;
45
+ }
46
+ /** The client's view. The first time the existing-install offer is shown, its day starts. */
47
+ async view(): Promise<OnboardingView> {
48
+ let file = (await this.load()) ?? await this.init();
49
+ if (offerVisible(file, this.now().getTime()) && !file.offeredAt) file = await this.mutate(f => ({ ...f, offeredAt: this.now().toISOString() }));
50
+ return onboardingView(file, this.now().getTime());
51
+ }
52
+ async act(action: OnboardingAction, step: OnboardingStep | null = null): Promise<OnboardingView> {
53
+ const file = await this.mutate(f => applyOnboarding(f, action, step, this.now()));
54
+ return onboardingView(file, this.now().getTime());
55
+ }
56
+ }
57
+
58
+ export type CheckDeps = {
59
+ /** `gh api user --jq .login` on the daemon host. */
60
+ gh: () => Promise<string>;
61
+ catalog: () => Promise<{ providers: ProviderInfo[]; error: string | null } | null>;
62
+ /** Which helper roles use which provider right now. */
63
+ use: () => Promise<ProviderUse>;
64
+ tools: () => Promise<ToolsInput>;
65
+ now?: () => number;
66
+ };
67
+
68
+ /**
69
+ * The readiness checks. Run only when the setup flow asks (no polling), one run at a time, and cached for a minute
70
+ * so moving between steps doesn't re-run gh. `fresh` (Check again) skips the cache.
71
+ */
72
+ export class ReadinessChecks {
73
+ private cache: { at: number; value: Promise<Checks> } | null = null;
74
+ constructor(private deps: CheckDeps, private ttlMs = 60_000) {}
75
+ run(fresh = false): Promise<Checks> {
76
+ const now = (this.deps.now ?? Date.now)();
77
+ if (!fresh && this.cache && now - this.cache.at < this.ttlMs) return this.cache.value;
78
+ const value = this.collect(now);
79
+ this.cache = { at: now, value };
80
+ return value;
81
+ }
82
+ private async collect(now: number): Promise<Checks> {
83
+ const gh = async (): Promise<Check[]> => {
84
+ let result: GhResult;
85
+ try { const login = (await this.deps.gh()).trim(); result = login ? { login } : { error: "signed-out", message: "" }; }
86
+ catch (error) { result = classifyGhError(error); }
87
+ return [ghCheck(result)];
88
+ };
89
+ const providers = async (): Promise<Check[]> => providerChecks(await this.deps.catalog().catch(e => ({ providers: [], error: e instanceof Error ? e.message : String(e) })), await this.deps.use().catch(() => ({})));
90
+ const tools = async (): Promise<Check[]> => toolsCheck(await this.deps.tools());
91
+ const groups = await Promise.all([gh(), providers(), tools()]);
92
+ return { checks: groups.flat(), checkedAt: new Date(now).toISOString() };
93
+ }
94
+ }
95
+
96
+ /** Agents that got Follow-up's tools natively: one `hook-state/native-<agent>.json` per agent (see index.server.ts). */
97
+ export async function nativeAgentCount(directory: string): Promise<number> {
98
+ try { return (await readdir(join(directory, "hook-state"))).filter(n => /^native-[\w-]+\.json$/.test(n)).length; } catch { return 0; }
99
+ }
@@ -5,6 +5,7 @@ import { usageSchema } from "./usage";
5
5
  import { aboutViewSchema } from "./about";
6
6
  import { AGENT_ROLES, agentSettingsViewSchema, savedRoleSchema } from "./agent-settings";
7
7
  import { defineRpc } from "@getpaseo/plugin";
8
+ import { ONBOARDING_ACTIONS, ONBOARDING_STEPS, checksSchema, onboardingViewSchema } from "./onboarding";
8
9
  import { z } from "zod";
9
10
  import { inboxRowSchema } from "./inbox";
10
11
  import { briefSchema } from "./brief";
@@ -162,3 +163,10 @@ export const overseerRestartRpc = defineRpc({ name: "follow.overseer-restart", i
162
163
  /** Settings → Agents. `catalog` asks for Paseo's provider list (cached ten minutes; `fresh` re-reads it). */
163
164
  export const agentSettingsRpc = defineRpc({ name: "follow.agent-settings", input: z.object({ catalog: z.boolean().optional(), fresh: z.boolean().optional() }), output: agentSettingsViewSchema });
164
165
  export const setAgentSettingRpc = defineRpc({ name: "follow.set-agent-setting", input: z.strictObject({ role: z.enum(AGENT_ROLES), entry: savedRoleSchema.nullable() }), output: agentSettingsViewSchema });
166
+
167
+ // Getting started (1.4.0-beta.10): the setup flow's progress and its readiness checks. Choices write through the
168
+ // Settings screen's own RPCs and settings documents; these only hold where the flow is.
169
+ export const onboardingRpc = defineRpc({ name: "follow.onboarding", input: z.object({}), output: onboardingViewSchema });
170
+ export const setOnboardingRpc = defineRpc({ name: "follow.set-onboarding", input: z.strictObject({ action: z.enum(ONBOARDING_ACTIONS), step: z.enum(ONBOARDING_STEPS).optional() }), output: onboardingViewSchema });
171
+ /** Run on demand while the flow is open, cached a minute; `fresh` is Check again. Never polled. */
172
+ export const onboardingChecksRpc = defineRpc({ name: "follow.onboarding-checks", input: z.object({ fresh: z.boolean().optional() }), output: checksSchema });
@@ -0,0 +1,230 @@
1
+ import { z } from "zod";
2
+
3
+ /**
4
+ * Getting started (1.4.0-beta.10). A first-run setup that takes a fresh install from "what is this?" to a configured
5
+ * Follow-up in about two minutes. Pure, so install detection, the offer, the checks' copy and resume are testable.
6
+ *
7
+ * Every choice the flow offers writes through the RPC or settings document the Settings screen already uses
8
+ * (see `CHOICE_WRITES`); the flow keeps only its own progress in `plugin-data/follow-through/onboarding.json`.
9
+ */
10
+
11
+ export const ONBOARDING_STEPS = ["intro", "checks", "defaults", "reviewers", "helpers"] as const;
12
+ export type OnboardingStep = typeof ONBOARDING_STEPS[number];
13
+ export const isStep = (v: unknown): v is OnboardingStep => typeof v === "string" && (ONBOARDING_STEPS as readonly string[]).includes(v);
14
+
15
+ /**
16
+ * - `fresh`: no Follow-up data on this host when the worker first started with onboarding.
17
+ * - `existing`: Follow-up ran here before (state, inbox, reviewers or agent settings on disk). Never forced on them.
18
+ */
19
+ export const INSTALL_KINDS = ["fresh", "existing"] as const;
20
+ export type InstallKind = typeof INSTALL_KINDS[number];
21
+ /**
22
+ * - `new`: fresh install, not opened yet. Home shows the flow.
23
+ * - `active`: in progress (also after "Set up Follow-up again"). Home shows the flow at `step`.
24
+ * - `done` / `skipped`: finished or dismissed. Home is Home.
25
+ * - `idle`: an existing install that hasn't asked for it. Home may show the quiet offer.
26
+ */
27
+ export const ONBOARDING_STATUSES = ["new", "active", "done", "skipped", "idle"] as const;
28
+ export type OnboardingStatus = typeof ONBOARDING_STATUSES[number];
29
+
30
+ export const onboardingFileSchema = z.object({
31
+ version: z.literal(1),
32
+ install: z.enum(INSTALL_KINDS),
33
+ status: z.enum(ONBOARDING_STATUSES),
34
+ step: z.enum(ONBOARDING_STEPS).nullable().default(null),
35
+ createdAt: z.string(),
36
+ updatedAt: z.string().nullable().default(null),
37
+ /** When the existing-install offer was first shown; it disappears a day later. */
38
+ offeredAt: z.string().nullable().default(null),
39
+ offerDismissed: z.boolean().default(false),
40
+ });
41
+ export type OnboardingFile = z.infer<typeof onboardingFileSchema>;
42
+
43
+ /** What the client sees. `show` is the flow in place of Home; `offer` is the existing-install line. */
44
+ export const onboardingViewSchema = z.object({
45
+ install: z.enum(INSTALL_KINDS),
46
+ status: z.enum(ONBOARDING_STATUSES),
47
+ step: z.enum(ONBOARDING_STEPS),
48
+ show: z.boolean(),
49
+ offer: z.boolean(),
50
+ });
51
+ export type OnboardingView = z.infer<typeof onboardingViewSchema>;
52
+
53
+ /** Files that only exist once Follow-up has run on this host. Any one of them means an existing install. */
54
+ export const EXISTING_INSTALL_FILES = ["state.json", "inbox.json", "reviewers.json", "agents.json", "brief.json"] as const;
55
+
56
+ /** An existing install is one with any Follow-up data already on disk. */
57
+ export function classifyInstall(present: readonly string[]): InstallKind {
58
+ return present.some(name => (EXISTING_INSTALL_FILES as readonly string[]).includes(name)) ? "existing" : "fresh";
59
+ }
60
+
61
+ export function initialOnboarding(install: InstallKind, now: Date): OnboardingFile {
62
+ return { version: 1, install, status: install === "fresh" ? "new" : "idle", step: null, createdAt: now.toISOString(), updatedAt: null, offeredAt: null, offerDismissed: false };
63
+ }
64
+
65
+ export const OFFER_MS = 24 * 3600_000;
66
+
67
+ /** The existing-install offer: once, for a day from when it first showed, until dismissed or taken. */
68
+ export function offerVisible(file: OnboardingFile, now: number): boolean {
69
+ if (file.install !== "existing" || file.status !== "idle" || file.offerDismissed) return false;
70
+ return !file.offeredAt || now - Date.parse(file.offeredAt) < OFFER_MS;
71
+ }
72
+
73
+ export function onboardingView(file: OnboardingFile, now: number): OnboardingView {
74
+ return { install: file.install, status: file.status, step: file.step ?? "intro", show: file.status === "new" || file.status === "active", offer: offerVisible(file, now) };
75
+ }
76
+
77
+ export const ONBOARDING_ACTIONS = ["start", "step", "finish", "skip", "restart", "dismiss-offer"] as const;
78
+ export type OnboardingAction = typeof ONBOARDING_ACTIONS[number];
79
+
80
+ /** The flow's state machine. Pure: the server stores what this returns. */
81
+ export function applyOnboarding(file: OnboardingFile, action: OnboardingAction, step: OnboardingStep | null, now: Date): OnboardingFile {
82
+ const at = now.toISOString();
83
+ const next = { ...file, updatedAt: at };
84
+ switch (action) {
85
+ case "start": return { ...next, status: "active", step: file.status === "active" ? file.step ?? "intro" : "intro" };
86
+ case "step": return { ...next, status: file.status === "new" || file.status === "idle" ? "active" : file.status, step: step ?? file.step };
87
+ case "finish": return { ...next, status: "done" };
88
+ case "skip": return { ...next, status: "skipped", offerDismissed: true };
89
+ // "Set up Follow-up again" from Settings or ⌘K: always from the start, any install kind.
90
+ case "restart": return { ...next, status: "active", step: "intro", offerDismissed: true };
91
+ case "dismiss-offer": return { ...next, offerDismissed: true };
92
+ }
93
+ }
94
+
95
+ // ---------- readiness checks ----------
96
+
97
+ export const CHECK_STATES = ["ok", "warn", "fail", "pending", "off"] as const;
98
+ export type CheckState = typeof CHECK_STATES[number];
99
+ export const checkSchema = z.object({
100
+ id: z.string(),
101
+ label: z.string(),
102
+ state: z.enum(CHECK_STATES),
103
+ detail: z.string(),
104
+ /** How to fix it: a sentence, an optional command to copy, an optional Settings category to open. */
105
+ fix: z.object({ text: z.string(), command: z.string().nullable(), settings: z.string().nullable() }).nullable(),
106
+ });
107
+ export type Check = z.infer<typeof checkSchema>;
108
+ export const checksSchema = z.object({ checks: z.array(checkSchema), checkedAt: z.string() });
109
+ export type Checks = z.infer<typeof checksSchema>;
110
+ const fix = (text: string, command: string | null = null, settings: string | null = null) => ({ text, command, settings });
111
+
112
+ /** `gh api user` on the daemon host: its login, or how it failed. */
113
+ export type GhResult = { login: string } | { error: "missing" | "signed-out" | "network"; message: string };
114
+ export function classifyGhError(error: unknown): GhResult {
115
+ const e = error as { code?: unknown; stderr?: unknown; message?: unknown };
116
+ const message = String(e?.stderr || e?.message || error || "").trim().slice(0, 200);
117
+ if (e?.code === "ENOENT") return { error: "missing", message };
118
+ if (/auth login|not logged|logged in to no|HTTP 401|Bad credentials|authentication|GH_TOKEN/i.test(message)) return { error: "signed-out", message };
119
+ return { error: "network", message };
120
+ }
121
+ export function ghCheck(r: GhResult): Check {
122
+ const label = "GitHub";
123
+ if ("login" in r) return { id: "gh", label, state: "ok", detail: `Signed in as ${r.login}`, fix: null };
124
+ if (r.error === "missing") return { id: "gh", label, state: "fail", detail: "The GitHub CLI isn't installed on the computer running Paseo. Follow-up reads PRs and checks with it.", fix: fix("Install it from cli.github.com, then sign in.", "gh auth login") };
125
+ if (r.error === "signed-out") return { id: "gh", label, state: "fail", detail: "The GitHub CLI isn't signed in, so Follow-up can't read your PRs.", fix: fix("Sign in on the computer running Paseo, then check again.", "gh auth login") };
126
+ return { id: "gh", label, state: "warn", detail: `Couldn't reach GitHub${r.message ? `: ${r.message}` : "."}`, fix: fix("Check that computer's network, then check again.") };
127
+ }
128
+
129
+ export type ProviderInfo = { id: string; label: string; available: boolean; reason: string | null };
130
+ /** Which providers the helper roles use right now, e.g. { claude: ["Overseer", "What's this about?"] }. */
131
+ export type ProviderUse = Record<string, string[]>;
132
+ const PROVIDER_FIX: Record<string, { text: string; command: string }> = {
133
+ claude: { text: "Install Claude Code on the computer running Paseo and sign in.", command: "claude" },
134
+ codex: { text: "Install Codex on the computer running Paseo and sign in.", command: "codex login" },
135
+ };
136
+ const joinNames = (names: string[]) => names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names.at(-1)}` : names[0] ?? "";
137
+
138
+ /** One row per helper provider (Claude, Codex). A provider no helper uses is optional. */
139
+ export function providerChecks(catalog: { providers: ProviderInfo[]; error: string | null } | null, use: ProviderUse): Check[] {
140
+ if (!catalog || (catalog.error && !catalog.providers.length)) return [{ id: "providers", label: "Helper agents", state: "warn", detail: catalog?.error ?? "Couldn't read Paseo's providers.", fix: fix("Check again in a moment.") }];
141
+ const rows: Check[] = [];
142
+ const anyAvailable = ["claude", "codex"].some(id => catalog.providers.find(p => p.id === id)?.available);
143
+ for (const id of ["claude", "codex"]) {
144
+ const p = catalog.providers.find(x => x.id === id);
145
+ const label = p?.label || (id === "claude" ? "Claude" : "Codex");
146
+ const users = use[id] ?? [];
147
+ const usedBy = users.length ? `Used by ${joinNames(users)}.` : "Not used by any helper right now.";
148
+ if (p?.available) { rows.push({ id: `provider-${id}`, label, state: "ok", detail: `Available. ${usedBy}`, fix: null }); continue; }
149
+ if (p?.reason === "Still loading") { rows.push({ id: `provider-${id}`, label, state: "pending", detail: "Paseo is still checking this provider.", fix: fix("Check again in a few seconds.") }); continue; }
150
+ const why = p?.reason ? ` (${p.reason})` : "";
151
+ if (!users.length) { rows.push({ id: `provider-${id}`, label, state: "off", detail: `Not available${why}. Optional: no helper uses it.`, fix: null }); continue; }
152
+ const other = id === "claude" ? "codex" : "claude";
153
+ const otherOk = !!catalog.providers.find(x => x.id === other)?.available;
154
+ rows.push({ id: `provider-${id}`, label, state: "fail", detail: `Not available${why}. ${joinNames(users)} won't run until it is.`,
155
+ fix: otherOk ? fix(`${PROVIDER_FIX[id].text} Or switch those helpers to ${other === "codex" ? "Codex" : "Claude"} in Settings, Agents.`, PROVIDER_FIX[id].command, "agents")
156
+ : fix(PROVIDER_FIX[id].text, PROVIDER_FIX[id].command) });
157
+ }
158
+ if (!anyAvailable) rows.unshift({ id: "providers", label: "Helper agents", state: "fail", detail: "Neither Claude Code nor Codex is available, so the Overseer, What's this about? and AI priority can't run. Following PRs and Needs you still work.", fix: null });
159
+ return rows;
160
+ }
161
+
162
+ export type ToolsInput = {
163
+ /** Paseo's config.json (or null when unreadable). */
164
+ config: { daemon?: { mcp?: { enabled?: boolean; injectIntoAgents?: boolean } }; agents?: { providers?: Record<string, { paseoTools?: { enabled?: boolean; disabledTools?: string[] } }> } } | null;
165
+ /** Agents that got Follow-up's tools through Paseo's own MCP since install. */
166
+ nativeAgents: number;
167
+ hookError: string | null;
168
+ };
169
+ /** Whether Follow-up's tools reach agents: through Paseo's MCP, or a small bridge per agent; and its hooks. */
170
+ export function toolsCheck({ config, nativeAgents, hookError }: ToolsInput): Check[] {
171
+ const label = "Agent tools";
172
+ const mcpOff = config?.daemon?.mcp?.enabled === false || config?.daemon?.mcp?.injectIntoAgents === false;
173
+ const blocked = ["claude", "codex"].filter(id => { const p = config?.agents?.providers?.[id]?.paseoTools; return p?.enabled === false || !!p?.disabledTools?.some(n => n.startsWith("follow_")); });
174
+ const seen = nativeAgents ? ` Seen on ${nativeAgents} agent${nativeAgents === 1 ? "" : "s"} so far.` : "";
175
+ let row: Check;
176
+ if (mcpOff || blocked.length) {
177
+ const why = mcpOff ? "Paseo's MCP is off" : `Paseo's tools are off for ${joinNames(blocked.map(b => b === "claude" ? "Claude" : "Codex"))}`;
178
+ row = { id: "tools", label, state: "warn", detail: `${why}, so each agent gets Follow-up's tools through a small extra process. It works, and uses a little more memory.`,
179
+ fix: mcpOff ? fix("Optional. To serve them through Paseo instead, set this in Paseo's config.json (in Paseo's home folder) and restart Paseo.", `"daemon": { "mcp": { "enabled": true } }`) : fix("Optional. Turn Paseo tools back on for that provider in Paseo's config.json, under agents.providers.") };
180
+ } else if (!nativeAgents) {
181
+ row = { id: "tools", label, state: "pending", detail: "Checked when your first agent starts. Nothing to do.", fix: null };
182
+ } else row = { id: "tools", label, state: "ok", detail: `Agents get Follow-up's tools through Paseo.${seen}`, fix: null };
183
+ const rows = [row];
184
+ if (hookError) rows.push({ id: "hooks", label: "Agent instructions", state: "warn", detail: "Follow-up couldn't add its instructions for every provider. Following still works; agents just aren't reminded to report PRs.", fix: fix("Check the Claude Code and Codex hook settings, then restart Follow-up from Paseo's plugin settings.") });
185
+ return rows;
186
+ }
187
+
188
+ /** The rows the checks step leads with: the worst state first is the one to fix. */
189
+ export function checksSummary(checks: readonly Check[]): { state: CheckState; line: string } {
190
+ const fails = checks.filter(c => c.state === "fail").length;
191
+ const warns = checks.filter(c => c.state === "warn").length;
192
+ if (fails) return { state: "fail", line: warns ? `${fails} to fix, ${warns} to look at` : `${fails} thing${fails === 1 ? "" : "s"} to fix` };
193
+ if (warns) return { state: "warn", line: `Ready, with ${warns} note${warns === 1 ? "" : "s"}` };
194
+ if (checks.some(c => c.state === "pending")) return { state: "pending", line: "Ready so far" };
195
+ return { state: "ok", line: "All set" };
196
+ }
197
+
198
+ // ---------- choices ----------
199
+
200
+ /**
201
+ * Where each choice is saved: the RPC or settings document (and field) Settings uses for the same control.
202
+ * The client calls exactly these; tests hold them to the Settings screen's own.
203
+ */
204
+ export const CHOICE_WRITES = {
205
+ followEvery: { rpc: "follow.set-follow-settings", field: "enable_follow_every" },
206
+ followWorkspace: { rpc: "follow.set-follow-settings", field: "workspace.follow" },
207
+ autoSendDefault: { rpc: "follow.set-follow-settings", field: "enable_auto_sends_default" },
208
+ autoSendWorkspace: { rpc: "follow.set-follow-settings", field: "workspace.enable_auto_sends" },
209
+ reviewers: { rpc: "follow.save-reviewers", field: "reviewers" },
210
+ overseer: { settings: "display", field: "enable_overseer" },
211
+ ranker: { settings: "display", field: "enable_ranker" },
212
+ trustBypass: { settings: "display", field: "enable_trust_bypass" },
213
+ } as const;
214
+
215
+ type FollowRow = { id: string; enable_tracking: boolean; enable_auto_sends: boolean; optedOut: boolean };
216
+ /**
217
+ * "Send repairs automatically" in setup: the default for new workspaces, and the same switch for each workspace
218
+ * already followed whose value differs (Settings' per-workspace switch). Returns the inputs for set-follow-settings.
219
+ */
220
+ export function autoSendWrites(value: boolean, workspaces: readonly FollowRow[]): { enable_auto_sends_default?: boolean; workspace?: { workspaceId: string; enable_auto_sends: boolean } }[] {
221
+ return [{ enable_auto_sends_default: value }, ...workspaces.filter(w => w.enable_tracking && !w.optedOut && w.enable_auto_sends !== value).map(w => ({ workspace: { workspaceId: w.id, enable_auto_sends: value } }))];
222
+ }
223
+ /** "Choose workspaces": follow or stop following each one whose state differs from what was picked. */
224
+ export function followWrites(picked: ReadonlySet<string>, workspaces: readonly FollowRow[]): { workspace: { workspaceId: string; follow: boolean } }[] {
225
+ return workspaces.flatMap(w => {
226
+ const following = w.enable_tracking && !w.optedOut;
227
+ const want = picked.has(w.id);
228
+ return following === want ? [] : [{ workspace: { workspaceId: w.id, follow: want } }];
229
+ });
230
+ }