paseo-follow-up 1.4.0-beta.5 → 1.4.0-beta.6

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
@@ -33,6 +33,8 @@ Every root agent Paseo launches (tracked or not) gets Follow-up's action tools:
33
33
 
34
34
  This is a trusted, unsandboxed plugin. It reads workspace metadata, saved agent history and configuration, GitHub status and existing CLI authentication, and keeps its state in `plugin-data/follow-through` on the daemon host. It attaches scoped agent tools per session (served by Paseo's own MCP as `follow_*` on Paseo 0.15+, a per-launch stdio bridge otherwise; never a global MCP registration, and it removes the user-scope `follow-through` entry older versions wrote, keeping a `.follow-through-unregister.bak` of each file) and reversible provider hooks for tracked sessions and, while the Needs-you inbox is on, the `needs_you` tool and its Stop-hook nudge for root agents (see below). To find the spec link it reads completed Claude Artifact publish results in the workspace's root sessions, never page content, chat links or the repository; a link you set wins over the agent's, which wins over detection. Repair prompts go to your configured agent and provider. For the provider meters it calls the Smart Session plugin's `smart-session.subscriptions` and `smart-session.budget` RPCs at most once a minute, or reads the newest rows of its `plugin-data/smart-session/accounts-YYYY-MM.jsonl`; it never asks ZeroSub to refresh or switch. It has no Slack identity and no background channel scanning; replies to stakeholders need your authorization and a sent-message receipt from the agent.
35
35
 
36
+ Follow-up reads Paseo's agent, workspace and project lists into one in-memory directory shared by discovery, runtime checks, the Needs-you inbox, the Overseer and every client RPC. It reads the lists once at start, then patches the directory from lifecycle events: turn started or ended, permission requested or resolved, agent created, closed or archived, workspace created or archived. A change marks it dirty, and a dirty directory re-reads at most once a minute; a clean one re-reads every ten minutes. Before anything that would load an agent (a timeline or provider-subagent read), Follow-up re-reads that one agent, because the cached copy may predate Paseo unloading it. Provider subagents are asked about only when a send is due or waiting for acknowledgment, or completion is being checked. The Done label is sent only when it changes. In the app, the panel, the larger view and the pill draw from the client's shared workspace poll, which runs every 15 s plus a refresh shortly after Paseo reports an agent change. The inbox runs the same way and passes the tag of the list it holds, so an unchanged list comes back empty. Display preferences re-read once a minute. None of these poll while the app is hidden.
37
+
36
38
  Reviewer lists live in `plugin-data/follow-through/reviewers.json` (owner-only), apart from `state.json`. Each list is per repository, plus a default for repositories without one, and each user keeps their own. Collaborator and team suggestions are read with `gh api` only when you open Add reviewer. They are cached for ten minutes, and never polled.
37
39
 
38
40
  The Needs-you inbox (beta) keeps one flag per root agent in `plugin-data/follow-through/inbox.json`. When a turn starts it reads the newest user message from the agent's recent timeline to tell your messages from automation, and it reads, never writes, Defer's `plugin-data/defer/queue.json`, Smart Session's `plugin-data/smart-session/compactions.json`, Session Guard's `plugin-data/session-guard/state.json` and Paseo's schedule records. An unknown or unreadable format counts as your message, which clears a flag rather than adding one. Signing off also clears Paseo's own unread dot for that agent. The first-run import and the restart check read only Paseo's agent list: an agent's last activity is its unread time or your last message to it, never Paseo's `updatedAt` (which the daemon rewrites in bulk), and they don't fetch timelines, which would load every agent. Closed and archived agents are never imported. Turning the inbox off stops all of this.
package/README.md CHANGED
@@ -170,7 +170,7 @@ The choices live in `agents.json` in Follow-up's data folder. Anything missing o
170
170
  Install the beta:
171
171
 
172
172
  ```sh
173
- paseo plugin update follow-through --version 1.4.0-beta.5
173
+ paseo plugin update follow-through --version 1.4.0-beta.6
174
174
  # or, for a fresh install:
175
175
  paseo plugin install npm:paseo-follow-up@beta
176
176
  ```
@@ -190,6 +190,7 @@ Betas publish to npm's `beta` dist-tag, so `paseo plugin update` without `--vers
190
190
  - Follow-up never merges, turns on merge when ready, requests reviewers or archives on its own. **Merge** re-checks the stack, lists any PRs underneath that would merge first, and asks again.
191
191
  - A merged PR is not the end: tasks such as production checks and open questions keep the workspace open until the main agent declares Done and everything has settled.
192
192
  - Answers go out only when you click Send. Follow-up never answers for you.
193
+ - **It stays light on Paseo (1.4).** Follow-up keeps one shared view of Paseo's agents and workspaces. It reads the full list once at start, then updates it from Paseo's events: turns, permissions, archives and new agents or workspaces. It re-reads the list at most once a minute after a change, and every ten minutes otherwise. Home, the workspace panel, the pills and the Needs-you inbox all read that shared view, so opening them never makes Paseo list your workspaces again. In the app, the panel and pills draw from one shared poll that refreshes when an agent changes. The Needs-you list answers "unchanged" in a few bytes when nothing moved, and nothing polls while the app is in the background. At 120 workspaces and idle, Follow-up's worker makes about 1 request a minute to Paseo, down from about 60. With the app open it was about 140.
193
194
 
194
195
  ### Agents can do what you can click
195
196
 
package/client/brief.tsx CHANGED
@@ -1,4 +1,5 @@
1
1
  import { useState } from "react";
2
+ import { browserKey, BROWSER_POLL_MS } from "./keys";
2
3
  import { Platform, Pressable, Text, View, useWindowDimensions } from "react-native";
3
4
  import { useQuery } from "@tanstack/react-query";
4
5
  import { openExternalUrl, useRpc, type PluginClientContext, type PluginTimelineItemProps } from "@getpaseo/plugin/client";
@@ -109,7 +110,7 @@ export function BriefCard({ item, theme, layout, agentId, deps, embedded = false
109
110
  const [details, setDetails] = useState(false);
110
111
  const [sheet, setSheet] = useState<{ key: string; intent: "merge" | "reviewers" } | null>(null);
111
112
  const workspace = b.workspaceId ? deps.workspace(b.workspaceId) : undefined;
112
- const browser = useQuery({ queryKey: ["follow-through", "browser"], queryFn: () => browserRead({}), refetchInterval: 5000, enabled: !!sheet });
113
+ const browser = useQuery({ queryKey: browserKey, queryFn: () => browserRead({}), refetchInterval: BROWSER_POLL_MS, enabled: !!sheet });
113
114
  if (b.state !== "open") return <Collapsed b={b} c={c} now={now} />;
114
115
 
115
116
  const attention = c.statusWarning;
@@ -7,6 +7,7 @@ import { useEffect } from "react";
7
7
  import { ActivityIndicator, Text, View } from "react-native";
8
8
  import { displayPreferences, displayRpc } from "../shared/display";
9
9
  import { sidebarVisibility } from "./sidebar-visibility";
10
+ import { appVisible, onVisible } from "./visibility";
10
11
 
11
12
  type Display = import("zod").infer<typeof displayPreferences.schema>;
12
13
  const listeners = new Set<(values: Display) => void>();
@@ -98,11 +99,14 @@ export function contributeDisplay(client: PluginClientContext, item: PluginSideb
98
99
  // Retain the last valid preference through temporary disconnects.
99
100
  } finally { pending = false; }
100
101
  };
102
+ // Changes made on this client notify at once; other clients' changes are picked up within a minute, and not at all
103
+ // while the app is hidden (it reads once on return).
101
104
  void refresh();
102
- const timer = setInterval(() => void refresh(), 5000);
105
+ const timer = setInterval(() => { if (appVisible()) void refresh(); }, 60_000);
106
+ const offVisible = onVisible(() => void refresh());
103
107
  return () => {
104
108
  disposed = true;
105
- clearInterval(timer);
109
+ clearInterval(timer); offVisible();
106
110
  listeners.delete(update);
107
111
  sidebar.dispose();
108
112
  };
@@ -5,6 +5,7 @@ import type { Priority } from "../shared/priorities";
5
5
  import { DEFAULT_SORT, isSortMode, type SortMode } from "../shared/sort";
6
6
  import type { AgentLite } from "../shared/search";
7
7
  import { NO_USAGE, USAGE_POLL_MS, type Usage } from "../shared/usage";
8
+ import { onVisible, whileVisible } from "./visibility";
8
9
 
9
10
  /**
10
11
  * What Home adds on top of the inbox, live and Paseo stores (1.3.0-beta.2): the sort choice (per device), external
@@ -39,16 +40,27 @@ export function createHomeExtras(client: PluginClientContext) {
39
40
  const emitSoon = () => { if (pending) return; pending = setTimeout(() => { pending = null; emit(); }, 250); };
40
41
 
41
42
  const timers: ReturnType<typeof setTimeout>[] = [];
43
+ // Nothing polls while the app is hidden; each poll runs once when it comes back (1.4.0).
44
+ const runs: (() => Promise<void>)[] = [];
42
45
  const poll = (ms: number, work: () => Promise<boolean>) => {
43
- const run = async () => { try { if (await work()) emit(); } catch { /* keep the last answer */ } if (!stopped) timers.push(setTimeout(() => void run(), ms)); };
46
+ let waiting = false;
47
+ const run = async () => {
48
+ waiting = false;
49
+ try { if (await work()) emit(); } catch { /* keep the last answer */ }
50
+ if (stopped) return;
51
+ const next = whileVisible(ms, () => void run());
52
+ if (next) timers.push(next); else waiting = true;
53
+ };
54
+ runs.push(async () => { if (waiting) await run(); });
44
55
  void run();
45
56
  };
57
+ const offVisible = onVisible(() => { for (const r of runs) void r(); });
46
58
  poll(PRIORITY_POLL_MS, async () => {
47
59
  const next = (await client.rpc(prioritiesRpc, {})).items;
48
60
  if (JSON.stringify(next) === JSON.stringify(priorities)) return false;
49
61
  priorities = next; return true;
50
62
  });
51
- poll(10_000, async () => {
63
+ poll(15_000, async () => {
52
64
  const next = await client.rpc(overseerStatusRpc, {});
53
65
  if (JSON.stringify(next) === JSON.stringify(overseer)) return false;
54
66
  overseer = next; return true;
@@ -67,21 +79,32 @@ export function createHomeExtras(client: PluginClientContext) {
67
79
  if (prior && prior.title === next.title && prior.workspaceId === next.workspaceId) return;
68
80
  agents.set(a.id, next); emitSoon();
69
81
  };
82
+ // Push for the inbox and live stores (1.4.0): an agent's status, attention or permissions changing is when Needs you
83
+ // and the pills can change, so those stores re-read then instead of polling every few seconds.
84
+ const activity = new Set<() => void>();
85
+ const signatures = new Map<string, string>();
86
+ const noteActivity = (a: unknown) => {
87
+ const x = a as { id?: string; status?: string; requiresAttention?: boolean; attentionReason?: string | null; pendingPermissions?: unknown[]; archivedAt?: string | null } | undefined;
88
+ if (!x?.id) return;
89
+ const signature = [x.status, x.requiresAttention, x.attentionReason, x.pendingPermissions?.length ?? 0, x.archivedAt].join("|");
90
+ const prior = signatures.get(x.id); signatures.set(x.id, signature);
91
+ if (prior !== undefined && prior !== signature) for (const l of activity) l();
92
+ };
70
93
  const unsubscribe = client.paseo.agents.subscribe(update => {
71
94
  const u = update as { kind: string; agent?: AgentEntry["agent"]; agentId?: string };
72
- if (u.kind === "remove") { if (u.agentId && agents.delete(u.agentId)) emitSoon(); }
73
- else putAgent(u.agent);
95
+ if (u.kind === "remove") { if (u.agentId && agents.delete(u.agentId)) emitSoon(); if (u.agentId) signatures.delete(u.agentId); for (const l of activity) l(); }
96
+ else { putAgent(u.agent); noteActivity(u.agent); }
74
97
  });
75
98
  let release: (() => Promise<void>) | null = null;
76
99
  void (async () => {
77
100
  const page = await client.paseo.agents.list({ subscribe: {}, page: { limit: 200 } });
78
101
  if (stopped) { await page.subscription.release(); return; }
79
102
  release = () => page.subscription.release();
80
- (page.entries as AgentEntry[]).forEach(e => putAgent(e.agent));
103
+ (page.entries as AgentEntry[]).forEach(e => { putAgent(e.agent); noteActivity(e.agent); });
81
104
  let cursor = page.pageInfo.nextCursor;
82
105
  for (let i = 0; cursor && !stopped && i < 20; i++) {
83
106
  const next = await client.paseo.agents.list({ page: { limit: 200, cursor } });
84
- (next.entries as AgentEntry[]).forEach(e => putAgent(e.agent));
107
+ (next.entries as AgentEntry[]).forEach(e => { putAgent(e.agent); noteActivity(e.agent); });
85
108
  if (next.pageInfo.nextCursor === cursor) break;
86
109
  cursor = next.pageInfo.nextCursor;
87
110
  }
@@ -105,7 +128,9 @@ export function createHomeExtras(client: PluginClientContext) {
105
128
  /** Bumped by ⌘K "Follow-up: Search"; the visible search field focuses when it changes. */
106
129
  focusToken: () => focusToken,
107
130
  focusSearch() { focusToken++; emit(); },
108
- async stop() { stopped = true; for (const t of timers) clearTimeout(t); if (pending) clearTimeout(pending); listeners.clear(); unsubscribe(); await release?.(); },
131
+ /** Calls `listener` when an agent's status, attention or permissions change (see above). */
132
+ onActivity(listener: () => void) { activity.add(listener); return () => { activity.delete(listener); }; },
133
+ async stop() { stopped = true; offVisible(); activity.clear(); for (const t of timers) clearTimeout(t); if (pending) clearTimeout(pending); listeners.clear(); unsubscribe(); await release?.(); },
109
134
  };
110
135
  }
111
136
  export type HomeExtras = ReturnType<typeof createHomeExtras>;
package/client/home.tsx CHANGED
@@ -1,4 +1,5 @@
1
1
  import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
2
+ import { browserKey, BROWSER_POLL_MS } from "./keys";
2
3
  import { Platform, Pressable, ScrollView, Text, TextInput, View } from "react-native";
3
4
  import { usePaseo, useRpc, type PluginScreenProps } from "@getpaseo/plugin/client";
4
5
  import { Icon, useToast } from "@getpaseo/plugin/client/ui";
@@ -213,7 +214,7 @@ function DetailPane({ s, model, theme, compact, deps, openFull, signOffNext, onB
213
214
  const tail = useTail(agent.handle, `${row?.seq ?? 0}:${agent.status ?? ""}`);
214
215
  const browserRead = useRpc(browserStatusRpc);
215
216
  const [sheet, setSheet] = useState<{ key: string; intent: "merge" | "reviewers" } | null>(null);
216
- const browser = useQuery({ queryKey: ["follow-through", "browser"], queryFn: () => browserRead({}), refetchInterval: 5000, enabled: !!sheet });
217
+ const browser = useQuery({ queryKey: browserKey, queryFn: () => browserRead({}), refetchInterval: BROWSER_POLL_MS, enabled: !!sheet });
217
218
  const [question, setQuestion] = useState<string | null>(null);
218
219
  const [laterOpen, setLaterOpen] = useState(false);
219
220
  const [busy, setBusy] = useState<string | null>(null);
@@ -3,13 +3,15 @@ import { inboxActRpc, inboxListRpc } from "../shared/contracts";
3
3
  import type { RpcInput, RpcOutput } from "@getpaseo/plugin";
4
4
  import type { InboxRow } from "../shared/inbox";
5
5
  import { subscribeDisplay } from "./display";
6
- import { onVisible, pollDelay } from "./visibility";
6
+ import { onVisible, whileVisible } from "./visibility";
7
7
 
8
8
  type List = RpcOutput<typeof inboxListRpc>;
9
9
  export type Recent = { agentIds: string[]; label: string; at: number; batch: boolean };
10
- const POLL_MS = 4_000;
11
- /** While the app is hidden (1.3.0-beta.4). */
12
- const HIDDEN_POLL_MS = 30_000;
10
+ /**
11
+ * The backstop poll. Changes arrive sooner by push: an agent's status or attention changing in Paseo's agent stream
12
+ * calls `nudge` (1.4.0). Nothing polls while the app is hidden; it refreshes once on return.
13
+ */
14
+ const POLL_MS = 15_000;
13
15
 
14
16
  /**
15
17
  * One shared poll of the inbox for every surface on this client. Sign-offs apply optimistically;
@@ -32,7 +34,7 @@ export function createInboxStore(client: PluginClientContext) {
32
34
  let stopped = false;
33
35
  const listeners = new Set<() => void>();
34
36
  const emit = () => { version++; for (const l of listeners) l(); };
35
- const rpcList = (): Promise<List> => client.rpc(inboxListRpc, {});
37
+ const rpcList = (): Promise<List> => client.rpc(inboxListRpc, data?.etag ? { etag: data.etag } : {});
36
38
  const act = (input: RpcInput<typeof inboxActRpc>) => client.rpc(inboxActRpc, input);
37
39
 
38
40
  const poll = async () => {
@@ -44,15 +46,20 @@ export function createInboxStore(client: PluginClientContext) {
44
46
  }
45
47
  const next = await rpcList();
46
48
  if (stopped) return;
49
+ // Nothing changed since the answer this store holds: keep it, and only re-render if we were offline.
50
+ if (next.unchanged && data) { if (offlineSince !== null || failures) { offlineSince = null; failures = 0; emit(); } return; }
47
51
  data = next; offlineSince = null; failures = 0;
48
52
  // Rows signed off while offline stay hidden until the replay lands.
49
53
  emit();
50
54
  } catch {
51
55
  failures++;
52
56
  if (failures >= 2 && offlineSince === null) { offlineSince = Date.now(); emit(); }
53
- } finally { if (!stopped) timer = setTimeout(() => void poll(), pollDelay(POLL_MS, HIDDEN_POLL_MS)); }
57
+ } finally { if (!stopped) timer = whileVisible(POLL_MS, () => void poll()); }
54
58
  };
55
59
  const refresh = () => { if (timer) clearTimeout(timer); void poll(); };
60
+ let nudged: ReturnType<typeof setTimeout> | null = null;
61
+ /** Something changed in Paseo: refresh soon, coalescing a burst of agent updates into one read. */
62
+ const nudge = () => { if (nudged || stopped) return; nudged = setTimeout(() => { nudged = null; refresh(); }, 750); };
56
63
  const unsubscribe = subscribeDisplay(values => {
57
64
  const on = values.enable_inbox !== false;
58
65
  if (on !== enabled) { enabled = on; emit(); if (on) refresh(); }
@@ -97,7 +104,8 @@ export function createInboxStore(client: PluginClientContext) {
97
104
  recent: () => recent,
98
105
  clearRecent() { recent = null; emit(); },
99
106
  refresh,
100
- stop() { stopped = true; offVisible(); if (timer) clearTimeout(timer); listeners.clear(); unsubscribe(); },
107
+ nudge,
108
+ stop() { stopped = true; offVisible(); if (timer) clearTimeout(timer); if (nudged) clearTimeout(nudged); listeners.clear(); unsubscribe(); },
101
109
 
102
110
  /** Sign off now; queue for replay when the host can't be reached. */
103
111
  async signOff(requested: string[], options: { muteTurn?: boolean } = {}) {
package/client/keys.ts CHANGED
@@ -1,3 +1,6 @@
1
1
  /** React Query keys shared by every surface that reads Follow-up state. */
2
2
  export const workspaceKey = (id: string) => ["follow-through", "workspace", id];
3
3
  export const overviewKey = ["follow-through", "overview"];
4
+ /** The browser extension's connection status: one shared query for every surface (1.4.0: 15 s, was 5 s). */
5
+ export const browserKey = ["follow-through", "browser"];
6
+ export const BROWSER_POLL_MS = 15_000;
package/client/large.tsx CHANGED
@@ -1,11 +1,11 @@
1
1
  import { useEffect } from "react";
2
2
  import { Platform, Text, View } from "react-native";
3
- import { useRpc, type PluginScreenProps } from "@getpaseo/plugin/client";
4
- import { useQuery } from "@tanstack/react-query";
5
- import { getRpc } from "../shared/contracts";
3
+ import { type PluginScreenProps } from "@getpaseo/plugin/client";
4
+ import { useWorkspace } from "./workspace-data";
5
+ import type { LiveStore } from "./live";
6
6
  import { Button, Card, CardRow, errorText, text } from "./kit";
7
7
  import { Skeleton } from "./motion";
8
- import { PanelTop, WorkspaceView, useSessionFolds, workspaceKey, type PanelLinks } from "./panel";
8
+ import { PanelTop, WorkspaceView, useSessionFolds, type PanelLinks } from "./panel";
9
9
 
10
10
  export const LARGE_SCREEN = "follow-through-workspace";
11
11
 
@@ -13,12 +13,11 @@ export const LARGE_SCREEN = "follow-through-workspace";
13
13
  * The panel opened as a Paseo screen: the host supplies the page, header and close button, and the
14
14
  * layout switches to two columns. Collapse (or Esc) returns to the workspace, where the panel still is.
15
15
  */
16
- export function FollowLarge(props: PluginScreenProps & PanelLinks) {
16
+ export function FollowLarge(props: PluginScreenProps & PanelLinks & { live?: LiveStore }) {
17
17
  const { theme, layout, params, navigation } = props;
18
18
  const workspaceId = params.workspaceId ?? "";
19
19
  const c = theme.colors;
20
- const read = useRpc(getRpc);
21
- const query = useQuery({ queryKey: workspaceKey(workspaceId), queryFn: () => read({ workspaceId }), refetchInterval: 5000, enabled: !!workspaceId });
20
+ const query = useWorkspace(props.live, workspaceId);
22
21
  const folds = useSessionFolds(workspaceId);
23
22
  const back = () => navigation?.openWorkspace({ workspaceId });
24
23
 
@@ -39,10 +38,10 @@ export function FollowLarge(props: PluginScreenProps & PanelLinks) {
39
38
  return () => doc.removeEventListener("keydown", onKey);
40
39
  }, [navigation, workspaceId]);
41
40
 
42
- if (query.isPending && workspaceId) return <View accessibilityLabel="Loading Follow-up" style={{ flex: 1, backgroundColor: c.surface0, padding: 24, gap: 12, maxWidth: 1240, width: "100%", alignSelf: "center" }}>
41
+ if (query.pending && workspaceId) return <View accessibilityLabel="Loading Follow-up" style={{ flex: 1, backgroundColor: c.surface0, padding: 24, gap: 12, maxWidth: 1240, width: "100%", alignSelf: "center" }}>
43
42
  <Skeleton width="30%" height={16} color={c.surface2} /><Skeleton width="60%" height={10} color={c.surface2} /><Skeleton width="100%" height={6} color={c.surface2} radius={3} />
44
43
  </View>;
45
- const w = query.data?.workspace;
44
+ const w = query.workspace;
46
45
  if (!w) return <View style={{ flex: 1, backgroundColor: c.surface0, padding: layout.compact ? 16 : 24 }}>
47
46
  <Card theme={theme} compact={layout.compact} icon="GitPullRequest" title="Nothing to show here" style={{ marginHorizontal: 0, marginTop: 0, maxWidth: 520 }}>
48
47
  <CardRow theme={theme}>
@@ -52,7 +51,7 @@ export function FollowLarge(props: PluginScreenProps & PanelLinks) {
52
51
  </Card>
53
52
  </View>;
54
53
  return <WorkspaceView theme={theme} layout={layout} host={props.host} navigation={navigation} workspace={w} large
55
- loadError={query.error ? "Refresh failed. Showing the last saved state." : query.data?.error ?? null}
54
+ loadError={query.error ? "Refresh failed. Showing the last saved state." : query.loadError}
56
55
  openSettings={props.openSettings} openOverview={props.openOverview} folds={folds}
57
56
  top={<PanelTop theme={theme} compact={layout.compact} openOverview={props.openOverview} />}
58
57
  resize={navigation ? { icon: "Minimize2", label: "Back to the workspace (Esc)", onPress: back } : null} />;
package/client/live.tsx CHANGED
@@ -8,11 +8,10 @@ import { needsYou } from "../shared/attention";
8
8
  import { useSidebarViewActive } from "./inbox";
9
9
  import { homeCounts } from "../shared/home";
10
10
  import { useHomeModel, type HomeSources } from "./home-data";
11
- import { onVisible, pollDelay } from "./visibility";
11
+ import { onVisible, whileVisible } from "./visibility";
12
12
 
13
- const POLL_MS = 8_000;
14
- /** While the app is hidden. */
15
- const HIDDEN_POLL_MS = 60_000;
13
+ /** The backstop poll; agent changes `nudge` it sooner (1.4.0). Nothing while the app is hidden. */
14
+ const POLL_MS = 15_000;
16
15
 
17
16
  /** One shared poll of tracked workspaces for the pills, header-button dots and the sidebar count. */
18
17
  export function createLiveStore(client: PluginClientContext) {
@@ -22,6 +21,7 @@ export function createLiveStore(client: PluginClientContext) {
22
21
  let version = 0;
23
22
  const listeners = new Set<() => void>();
24
23
  let timer: ReturnType<typeof setTimeout> | null = null;
24
+ let nudged: ReturnType<typeof setTimeout> | null = null;
25
25
  let stopped = false;
26
26
  /** The worker's list revision this store holds; each poll asks only for what changed since (1.3.0-beta.4). */
27
27
  let revision: number | undefined;
@@ -41,7 +41,7 @@ export function createLiveStore(client: PluginClientContext) {
41
41
  archived = [...all.values()].filter(w => w.archived);
42
42
  emit();
43
43
  } catch { /* Keep the last answer through restarts and disconnects. */ }
44
- finally { if (!stopped) timer = setTimeout(() => void poll(), pollDelay(POLL_MS, HIDDEN_POLL_MS)); }
44
+ finally { if (!stopped) timer = whileVisible(POLL_MS, () => void poll()); }
45
45
  };
46
46
  const offVisible = onVisible(() => { if (timer) clearTimeout(timer); void poll(); });
47
47
  void poll();
@@ -52,7 +52,9 @@ export function createLiveStore(client: PluginClientContext) {
52
52
  all: () => [...workspaces.values()],
53
53
  archived: () => archived,
54
54
  refresh: () => { if (timer) clearTimeout(timer); void poll(); },
55
- stop() { stopped = true; offVisible(); if (timer) clearTimeout(timer); listeners.clear(); },
55
+ /** Paseo reported an agent change: one diff read soon, however many updates arrive together. */
56
+ nudge: () => { if (nudged || stopped) return; nudged = setTimeout(() => { nudged = null; if (timer) clearTimeout(timer); void poll(); }, 1_500); },
57
+ stop() { stopped = true; offVisible(); if (timer) clearTimeout(timer); if (nudged) clearTimeout(nudged); listeners.clear(); },
56
58
  };
57
59
  }
58
60
  export type LiveStore = ReturnType<typeof createLiveStore>;
package/client/panel.tsx CHANGED
@@ -7,7 +7,7 @@ import type { InboxStore } from "./inbox-store";
7
7
  import { useInbox } from "./inbox";
8
8
  import { BriefCard, type BriefDeps } from "./brief";
9
9
  import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
10
- import { getRpc, controlRpc, refreshRpc, browserStatusRpc, recoverRpc, sendRpc, inboxBriefRpc } from "../shared/contracts";
10
+ import { controlRpc, refreshRpc, browserStatusRpc, recoverRpc, sendRpc, inboxBriefRpc } from "../shared/contracts";
11
11
  import { summary, type Workspace } from "../shared/model";
12
12
  import { followUpObligations, recoveryBatch } from "../shared/follow-up";
13
13
  import { settledForDisplay } from "../shared/presentation";
@@ -16,6 +16,9 @@ import { Button, Card, CardRow, FoldRow, IconButton, errorText, text, useNow, ty
16
16
  import { Reveal, Skeleton } from "./motion";
17
17
  import { WorkspaceHeader } from "./header";
18
18
  import { NeedsYouCard, overviewKey, workspaceKey } from "./needs-you";
19
+ import { browserKey, BROWSER_POLL_MS } from "./keys";
20
+ import { useWorkspace } from "./workspace-data";
21
+ import type { LiveStore } from "./live";
19
22
  import { StacksCard } from "./stacks";
20
23
  import { TasksCard } from "./tasks";
21
24
  import { PrSheet } from "./pr-sheet";
@@ -27,7 +30,7 @@ import { AboutSection } from "./about";
27
30
  export { overviewKey, workspaceKey };
28
31
 
29
32
  export type PanelLinks = { openSettings: () => void; openOverview: () => void; openLarge?: (workspaceId: string) => void };
30
- type PanelProps = PluginWorkspacePanelProps & PanelLinks & { inbox?: InboxStore; briefDeps?: BriefDeps };
33
+ type PanelProps = PluginWorkspacePanelProps & PanelLinks & { inbox?: InboxStore; live?: LiveStore; briefDeps?: BriefDeps };
31
34
 
32
35
  /**
33
36
  * The workspace panel (explorer column, or a tab on the phone): this workspace only. A Home button on top, then
@@ -35,21 +38,21 @@ type PanelProps = PluginWorkspacePanelProps & PanelLinks & { inbox?: InboxStore;
35
38
  * tasks, questions, spec, activity and Details. What needs you elsewhere lives on Home.
36
39
  */
37
40
  export function FollowPanel(props: PanelProps) {
38
- const read = useRpc(getRpc);
39
- const query = useQuery({ queryKey: workspaceKey(props.workspaceId), queryFn: () => read({ workspaceId: props.workspaceId }), refetchInterval: 5000 });
41
+ // Paints from the client's live store; one small read of this workspace on open, no poll (1.4.0).
42
+ const query = useWorkspace(props.live, props.workspaceId);
40
43
  const c = props.theme.colors;
41
44
  const base = { flex: 1, backgroundColor: c.surface0 };
42
- if (query.isPending) return <PanelSkeleton theme={props.theme} compact={props.layout.compact} />;
43
- if (query.error && !query.data?.workspace) return <View style={[base, { padding: props.layout.compact ? 16 : 12 }]}>
45
+ if (query.pending) return <PanelSkeleton theme={props.theme} compact={props.layout.compact} />;
46
+ if (query.error && !query.workspace) return <View style={[base, { padding: props.layout.compact ? 16 : 12 }]}>
44
47
  <Card theme={props.theme} compact={props.layout.compact} icon="CloudOff" title="Can't reach Follow-up" style={{ marginHorizontal: 0, marginTop: 0 }}>
45
48
  <CardRow theme={props.theme}>
46
49
  <Text accessibilityRole="alert" style={[text(c).meta, { marginBottom: 10 }]}>The plugin didn't answer: {errorText(query.error)}. It may still be starting; your work is saved on the host.</Text>
47
- <Button title="Try again" icon="RefreshCw" theme={props.theme} compact={props.layout.compact} loading={query.isRefetching} onPress={() => void query.refetch()} />
50
+ <Button title="Try again" icon="RefreshCw" theme={props.theme} compact={props.layout.compact} loading={query.refetching} onPress={() => void query.refetch()} />
48
51
  </CardRow>
49
52
  </Card>
50
53
  </View>;
51
- if (!query.data?.workspace) return <NothingYet {...props} loadError={query.data?.error} />;
52
- return <PanelWorkspace {...props} workspace={query.data.workspace} loadError={query.error ? "Refresh failed. Showing the last saved state." : query.data.error} />;
54
+ if (!query.workspace) return <NothingYet {...props} loadError={query.loadError} />;
55
+ return <PanelWorkspace {...props} workspace={query.workspace} loadError={query.error ? "Refresh failed. Showing the last saved state." : query.loadError} />;
53
56
  }
54
57
 
55
58
  function PanelSkeleton({ theme, compact }: { theme: Theme; compact: boolean }) {
@@ -249,7 +252,7 @@ export function WorkspaceView({ theme, layout, workspace: w, navigation, loadErr
249
252
  const [sheet, setSheet] = useState<{ key: string; intent: "merge" | "reviewers" | null } | null>(null);
250
253
  const [question, setQuestion] = useState<string | null>(null);
251
254
  const [specOpen, setSpecOpen] = useState(false);
252
- const browser = useQuery({ queryKey: ["follow-through", "browser"], queryFn: () => browserRead({}), refetchInterval: 5000 });
255
+ const browser = useQuery({ queryKey: browserKey, queryFn: () => browserRead({}), refetchInterval: BROWSER_POLL_MS });
253
256
  const invalidated = () => { void cache.invalidateQueries({ queryKey: workspaceKey(w.id) }); void cache.invalidateQueries({ queryKey: overviewKey }); };
254
257
  const auto = useMutation({ mutationFn: (next: boolean) => control({ workspaceId: w.id, enable_auto_sends: next }), onSuccess: (_, next) => { toast.show(next ? "Auto-send on for this workspace" : "Auto-send off · repairs wait for your click"); invalidated(); }, onError: e => toast.error(errorText(e)) });
255
258
  const update = useMutation({ mutationFn: () => refresh({ workspaceId: w.id }), onSuccess: () => setTimeout(invalidated, 1200), onError: e => toast.error(errorText(e)) });
package/client/pill.tsx CHANGED
@@ -1,9 +1,11 @@
1
1
  import { useState, useSyncExternalStore } from "react";
2
+ import { browserKey, BROWSER_POLL_MS } from "./keys";
3
+ import { useWorkspace } from "./workspace-data";
2
4
  import { Pressable, Text, View } from "react-native";
3
5
  import { useQuery } from "@tanstack/react-query";
4
6
  import { useRpc, type PluginButtonContentProps, type PluginButtonIconProps, type PluginButtonRegistration, type PluginClientContext } from "@getpaseo/plugin/client";
5
7
  import { Icon } from "@getpaseo/plugin/client/ui";
6
- import { browserStatusRpc, getRpc } from "../shared/contracts";
8
+ import { browserStatusRpc } from "../shared/contracts";
7
9
  import { needsYou, type NeedItem } from "../shared/attention";
8
10
  import { briefQuestionIds, HEADLINE_ICON, HEADLINE_TONE, pillState, todoLabel, withoutBriefQuestions, type PillState } from "../shared/headline";
9
11
  import { snoozeUntil, type InboxRow } from "../shared/inbox";
@@ -14,7 +16,7 @@ import { headlineColor, withAlpha } from "./theme";
14
16
  import { useInbox } from "./inbox";
15
17
  import type { InboxStore } from "./inbox-store";
16
18
  import type { LiveStore } from "./live";
17
- import { NeedsYouList, workspaceKey } from "./needs-you";
19
+ import { NeedsYouList } from "./needs-you";
18
20
  import { PrSheet } from "./pr-sheet";
19
21
  import { QuestionSheet, QuestionStepper } from "./questions";
20
22
  import { useReviewerSettings } from "./reviewers";
@@ -137,13 +139,15 @@ export function PillPopover(props: PluginButtonContentProps & { deps: Deps }) {
137
139
  const c = props.theme.colors; const t = text(c);
138
140
  const touch = props.layout.compact;
139
141
  const { target, state, now } = useTarget(deps, agentId, props.workspaceId);
140
- const read = useRpc(getRpc); const browserRead = useRpc(browserStatusRpc);
142
+ const browserRead = useRpc(browserStatusRpc);
141
143
  const main = !!target.workspace && target.workspace.mainAgentId === agentId;
142
- const query = useQuery({ queryKey: workspaceKey(props.workspaceId), queryFn: () => read({ workspaceId: props.workspaceId }), refetchInterval: 5000, enabled: main });
143
- const browser = useQuery({ queryKey: ["follow-through", "browser"], queryFn: () => browserRead({}), refetchInterval: 5000, enabled: main });
144
+ // The live store already holds this workspace; the popover reads it once on open (Paseo can leave a stray mounted
145
+ // copy, so nothing here polls it: 1.4.0).
146
+ const query = useWorkspace(deps.live, props.workspaceId, { enabled: main });
147
+ const browser = useQuery({ queryKey: browserKey, queryFn: () => browserRead({}), refetchInterval: BROWSER_POLL_MS, enabled: main });
144
148
  const [sheet, setSheet] = useState<{ key: string; intent: "merge" | "reviewers" } | null>(null);
145
149
  const [question, setQuestion] = useState<string | null>(null);
146
- const w = main ? query.data?.workspace ?? target.workspace : null;
150
+ const w = main ? query.workspace ?? target.workspace : null;
147
151
  const row = target.row;
148
152
  const flagged = state?.mode === "flag";
149
153
  const running = !!row && ["running", "initializing"].includes(row.status);
@@ -22,7 +22,7 @@ export function PrControls({ pr, workspace, theme, compact, browserReady, intent
22
22
  const c = theme.colors; const t = text(c);
23
23
  const [plan, setPlan] = useState<ActionPlan | null>(null); const [notice, setNotice] = useState<string | null>(null);
24
24
  const statusKey = ["follow-through", "pr-controls", workspace.id, pr.key, pr.snapshot?.head];
25
- const status = useQuery({ queryKey: statusKey, queryFn: () => read({ workspaceId: workspace.id, prKey: pr.key }), refetchInterval: 5000, enabled: browserReady });
25
+ const status = useQuery({ queryKey: statusKey, queryFn: () => read({ workspaceId: workspace.id, prKey: pr.key }), refetchInterval: 10_000, enabled: browserReady });
26
26
  const invalidate = () => { void cache.invalidateQueries({ queryKey: ["follow-through", "workspace", workspace.id] }); void cache.invalidateQueries({ queryKey: ["follow-through", "pr-controls", workspace.id] }); void cache.invalidateQueries({ queryKey: ["follow-through", "overview"] }); };
27
27
  const [picking, setPicking] = useState(false);
28
28
  const reviewerSettings = useReviewerSettings();
@@ -20,5 +20,12 @@ export function onVisible(wake: () => void): () => void {
20
20
  try { doc()?.addEventListener("visibilitychange", listener); } catch { /* no DOM */ }
21
21
  return () => { subscription?.remove(); try { doc()?.removeEventListener("visibilitychange", listener); } catch { /* no DOM */ } };
22
22
  }
23
+ /**
24
+ * Schedules the next run of a background poll: after `ms` while the app is in the foreground, never while it is
25
+ * hidden (1.4.0: the stores pair this with `onVisible`, which polls once on return).
26
+ */
27
+ export function whileVisible(ms: number, run: () => void): ReturnType<typeof setTimeout> | null {
28
+ return appVisible() ? setTimeout(run, ms) : null;
29
+ }
23
30
  /** The poll interval for now: `visibleMs` in the foreground, `hiddenMs` otherwise. */
24
31
  export const pollDelay = (visibleMs: number, hiddenMs: number): number => appVisible() ? visibleMs : hiddenMs;
@@ -0,0 +1,37 @@
1
+ import { useSyncExternalStore } from "react";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useRpc } from "@getpaseo/plugin/client";
4
+ import { getRpc } from "../shared/contracts";
5
+ import type { Workspace } from "../shared/model";
6
+ import type { LiveStore } from "./live";
7
+ import { workspaceKey } from "./keys";
8
+
9
+ const none = () => () => {};
10
+ const newer = (a: Workspace | null | undefined, b: Workspace | null | undefined): Workspace | null => {
11
+ if (!a) return b ?? null; if (!b) return a;
12
+ return Date.parse(b.updatedAt) > Date.parse(a.updatedAt) ? b : a;
13
+ };
14
+
15
+ /**
16
+ * One workspace for the panel, the larger view and the pill (1.4.0). The client's shared live store already holds
17
+ * every followed workspace and keeps it current (one diff poll for the whole client, nudged by agent changes), so a
18
+ * surface paints from it at once. On open it makes one small read of its own workspace, never a poll; a mutation's
19
+ * invalidation re-reads it once. Whichever copy is newer wins.
20
+ */
21
+ export function useWorkspace(live: LiveStore | undefined, workspaceId: string, options: { enabled?: boolean; read?: boolean } = {}) {
22
+ const enabled = (options.enabled ?? true) && !!workspaceId;
23
+ const read = useRpc(getRpc);
24
+ useSyncExternalStore(live?.subscribe ?? none, live?.version ?? (() => 0), live?.version ?? (() => 0));
25
+ const cached = enabled ? live?.get(workspaceId) : undefined;
26
+ const query = useQuery({ queryKey: workspaceKey(workspaceId), queryFn: () => read({ workspaceId }), enabled: enabled && (options.read ?? true), staleTime: 15_000, refetchOnWindowFocus: false });
27
+ const workspace = enabled ? newer(cached, query.data?.workspace) : null;
28
+ return {
29
+ workspace,
30
+ /** Nothing to show yet: no live copy and the read hasn't answered. */
31
+ pending: !workspace && query.isPending && enabled && (options.read ?? true),
32
+ error: query.error,
33
+ loadError: query.data?.error ?? null,
34
+ refetching: query.isRefetching,
35
+ refetch: () => { live?.refresh(); return query.refetch(); },
36
+ };
37
+ }
package/index.client.tsx CHANGED
@@ -46,6 +46,7 @@ export default function contribute(host: PluginClientContext) {
46
46
  const paseoWorkspaces = createPaseoWorkspaces(client, { onAdd: register, onRemove: id => { headers.get(id)?.remove(); headers.delete(id); } });
47
47
  const extras = createHomeExtras(client);
48
48
  const sources = { inbox, live: store, paseo: paseoWorkspaces, extras };
49
+ const offActivity = extras.onActivity(() => { inbox.nudge(); store.nudge(); });
49
50
  // "Sign off & next" from a pill or ⌘K: the screen relays it to the host's navigation.
50
51
  let nextToken = 0;
51
52
  const openNext = (from: string | null) => client.openScreen({ screenId: OVERVIEW, params: { next: String(++nextToken), ...(from ? { from } : {}) } });
@@ -58,8 +59,8 @@ export default function contribute(host: PluginClientContext) {
58
59
  };
59
60
  const homeDeps = { sources, openSettings, openPanel, openLog, openHome: openOverview, briefDeps };
60
61
  const Overview = (props: PluginScreenProps) => <FollowHome {...props} deps={homeDeps} />;
61
- const Panel = (props: PluginWorkspacePanelProps) => <FollowPanel {...props} openSettings={openSettings} openOverview={openOverview} openLarge={openLarge} inbox={inbox} briefDeps={briefDeps} />;
62
- const Large = (props: PluginScreenProps) => <FollowLarge {...props} openSettings={openSettings} openOverview={openOverview} />;
62
+ const Panel = (props: PluginWorkspacePanelProps) => <FollowPanel {...props} openSettings={openSettings} openOverview={openOverview} openLarge={openLarge} inbox={inbox} live={store} briefDeps={briefDeps} />;
63
+ const Large = (props: PluginScreenProps) => <FollowLarge {...props} openSettings={openSettings} openOverview={openOverview} live={store} />;
63
64
  const removers: (() => unknown)[] = [
64
65
  client.addScreen({ id: OVERVIEW, title: "Follow-up", Component: Overview }),
65
66
  client.addScreen({ id: LARGE_SCREEN, title: params => store.get(params.workspaceId ?? "")?.title ?? "Follow-up", Component: Large }),
@@ -99,7 +100,7 @@ export default function contribute(host: PluginClientContext) {
99
100
 
100
101
  return async () => {
101
102
  stopped = true;
102
- visibility.dispose(); removeDisplay(); store.stop(); inbox.stop();
103
+ offActivity(); visibility.dispose(); removeDisplay(); store.stop(); inbox.stop();
103
104
  for (const r of removers) void r();
104
105
  for (const button of headers.values()) button.remove();
105
106
  await paseoWorkspaces.stop();