paseo-follow-up 2.2.0-beta.3 → 2.2.0-beta.4

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.
@@ -3,7 +3,7 @@
3
3
  // the answer flow is the shared one, never a fork (one-answer-flow-for-every-question). The deck's order and every
4
4
  // move are the pure session in shared/catch-up.ts (context-never-blocks-the-deck, the-card-on-screen-never-moves).
5
5
  import { useEffect, useMemo, useRef, useState, useSyncExternalStore, type ReactNode } from "react";
6
- import { PanResponder, Platform, View } from "react-native";
6
+ import { Animated, PanResponder, Platform, View } from "react-native";
7
7
  import { Pressable, Text } from "./text";
8
8
  import { useRpc } from "@getpaseo/plugin/client";
9
9
  import { Icon, ScrollView, TextInput } from "@getpaseo/plugin/client/ui";
@@ -15,14 +15,14 @@ import { age, snoozeUntil } from "../shared/inbox";
15
15
  import { laterChoices } from "../shared/row-menu";
16
16
  import { errorText } from "../shared/errors";
17
17
  import { CATCH_UP_RAIL_DEFAULT, CATCH_UP_RAIL_MAX, CATCH_UP_RAIL_MIN } from "../shared/display";
18
- import { CATCH_UP_KEYS, CONTEXT_ASKS, MODE, askHeadline, catchUpKey, keyLabel, deckCards, groupOf, park, prevPos, settle as settleCard, startSession, statsOf, sync, type ContextRequest, type DeckCard, type Outcome, type Session } from "../shared/catch-up";
18
+ import { CATCH_UP_KEYS, CONTEXT_ASKS, MODE, askHeadline, catchUpKey, keyLabel, deckCards, groupOf, nextPos, openInWorkspace, park, prevPos, skipWorkspace, swipeLock, swipeOutcome, settle as settleCard, startSession, statsOf, sync, type ContextRequest, type DeckCard, type Outcome, type Session } from "../shared/catch-up";
19
19
  import type { Workspace } from "../shared/model";
20
20
  import type { ListWorkspace } from "../shared/list";
21
- import { bottomInset, Button, IconButton, text, type Theme } from "./kit";
21
+ import { bottomInset, Button, focusSoon, IconButton, SubmitScope, text, type Theme } from "./kit";
22
22
  import { glyphColor } from "./home-list";
23
23
  import { useHomeModel, type HomeSources } from "./home-data";
24
24
  import { useInbox } from "./inbox";
25
- import { QuestionBody } from "./questions";
25
+ import { QuestionBody, type SendReady } from "./questions";
26
26
  import { NeedsYouList } from "./needs-you";
27
27
  import { BriefCard, type BriefDeps } from "./brief";
28
28
  import { SummaryLine } from "./about";
@@ -32,6 +32,7 @@ import { mergedColor, withAlpha, tint } from "./theme";
32
32
  import { RichText } from "./rich-text";
33
33
  import { DisplaySplit, PermissionBlock, useAgentLive } from "./home";
34
34
  import { DockedPane } from "./docked-pane";
35
+ import { useReducedMotion } from "./motion";
35
36
  import { PRIMARY_FORM } from "./dock";
36
37
 
37
38
  /** react-native-web's data attribute, so the option-letter keys find this card's radios. */
@@ -66,6 +67,16 @@ function cardWord(card: DeckCard): string {
66
67
  }
67
68
  const cardIcon = (card: DeckCard) => card.kind === "permission" ? "ShieldQuestion" : card.kind === "question" ? "MessageCircleQuestion"
68
69
  : card.item?.kind === "merge" ? "GitMerge" : card.item?.kind === "reviewers" ? "UserPlus" : card.item?.kind === "send" ? "Send" : card.kind === "finished" ? "Flag" : card.s.icon;
70
+ /**
71
+ * The card Skip names what it skips, so it never reads as the workspace (Tom, beta.3: "at first I thought it skips the
72
+ * workspace"): the card's kind where one word says it, else "card", the deck's own word ("N skipped" counts cards).
73
+ */
74
+ export function skipNoun(card: Pick<DeckCard, "kind" | "item">): string {
75
+ return card.kind === "question" ? "question" : card.kind === "permission" ? "permission" : card.item?.kind === "merge" ? "merge" : "card";
76
+ }
77
+ /** The card Skip's tooltip and accessible name: what it does and that the card comes back. */
78
+ export const skipCardHint = (noun: string) => `Skip this ${noun}. It comes back after the rest`;
79
+ export const skipWorkspaceHint = (n: number) => `Skip this workspace's ${n} cards. They come back after the rest`;
69
80
  /** The newest ask about this card, if any. */
70
81
  const askFor = (context: readonly ContextRequest[], key: string) => [...context].reverse().find(r => r.cardKey === key) ?? null;
71
82
 
@@ -93,19 +104,14 @@ export function CatchUp({ theme, compact, deps, navigation, onExit }: { theme: T
93
104
  useEffect(() => { void extras.refreshContext(); }, [session.pos]); // eslint-disable-line react-hooks/exhaustive-deps
94
105
 
95
106
  const [more, setMore] = useState(false);
96
- // M opens More context below the card's answers; bring it into view so the key's result is never off screen.
97
- useEffect(() => {
98
- if (!more || Platform.OS !== "web") return;
99
- const t = setTimeout(() => (globalThis as { document?: { querySelector(q: string): { scrollIntoView?(o: object): void } | null } }).document
100
- ?.querySelector("[data-catch-up-more]")?.scrollIntoView?.({ block: "nearest", behavior: "smooth" }), 50);
101
- return () => clearTimeout(t);
102
- }, [more]);
103
107
  const key = session.order[session.pos];
104
108
  const card = cardOf(key);
105
109
  const gone = !!key && session.outcomes[key] === "gone";
106
110
  const finished = session.pos >= session.order.length;
107
111
  const settle = (outcome: Outcome) => { setMore(false); setSession(s => settleCard(s, outcome)); };
108
112
  const skip = () => settle("skipped");
113
+ const skipWs = () => { setMore(false); setSession(skipWorkspace); };
114
+ const wsLeft = openInWorkspace(session).length;
109
115
  const back = () => { setMore(false); setSession(s => ({ ...s, pos: prevPos(s) })); };
110
116
  const jump = (i: number) => { setMore(false); setSession(s => ({ ...s, pos: i })); };
111
117
  const w = card?.s.workspaceId ? live.get(card.s.workspaceId) : undefined;
@@ -113,9 +119,9 @@ export function CatchUp({ theme, compact, deps, navigation, onExit }: { theme: T
113
119
  const nextCard = cardOf(session.order[session.pos + 1]);
114
120
  useWorkspace(live, nextCard?.s.workspaceId ?? "", { enabled: !!nextCard?.s.workspaceId });
115
121
 
116
- const ask = async (target: "overseer" | "agent", words: string) => {
122
+ const ask = async (words: string) => {
117
123
  if (!card) return;
118
- const out = await extras.askContext({ workspaceId: card.s.workspaceId, agentId: card.s.agentId, cardKey: card.key, card: cardLabel(card, w).slice(0, 300), target, ask: words });
124
+ const out = await extras.askContext({ workspaceId: card.s.workspaceId, agentId: card.s.agentId, cardKey: card.key, card: cardLabel(card, w).slice(0, 300), ask: words });
119
125
  setMore(false);
120
126
  // context-never-blocks-the-deck: the workstream waits, the deck moves on.
121
127
  if (out.request.state === "asking") setSession(s => park(s, out.request.id, card.key));
@@ -142,19 +148,20 @@ export function CatchUp({ theme, compact, deps, navigation, onExit }: { theme: T
142
148
  const click = (q: string) => { const b = doc.querySelector(q); b?.click?.(); return !!b; };
143
149
  switch (hit.action) {
144
150
  case "skip": skip(); break;
151
+ case "skip-workspace": if (wsLeft < 2) return; skipWs(); break;
145
152
  case "back": back(); break;
146
- case "more": setMore(v => !v); break;
153
+ case "more": if (!click('[data-catch-up-card-moves] [aria-label="More context"]')) setMore(v => !v); break;
147
154
  case "keys": setKeysOpen(v => !v); break;
148
155
  case "leave": onExit(); break;
149
156
  case "pick": inCard(`[role="radio"][aria-label^="${hit.arg}. "]`)?.click?.(); break;
150
157
  case "own": inCard('[role="radio"][aria-label^="Something else"]')?.click?.(); break;
151
158
  case "send": { const b = inCard('[aria-label^="Send your"]') ?? inCard('[aria-label^="Send "]'); if (!b) return; b.click?.(); break; }
152
159
  case "note": { const add = inCard('[aria-label^="Add a note"]'); if (add) add.click?.(); else doc.querySelector('[aria-label="Tell the agent something"]')?.focus?.(); break; }
153
- case "later": if (!click('[aria-label="Later (L)"]')) return; setTimeout(() => doc.querySelector('[data-catch-up-later] [role="button"]')?.focus?.(), 0); break;
160
+ // Its sheet or popover takes focus itself (MoveResult).
161
+ case "later": if (!click('[aria-label="Later (L)"]')) return; break;
154
162
  case "chat": if (!click('[aria-label="Open chat (O)"]')) return; break;
155
163
  case "chip": doc.querySelectorAll("[data-catch-up-more] [role=\"radio\"]")[Number(hit.arg) - 1]?.click?.(); break;
156
- case "ask-overseer": if (!click('[data-catch-up-more] [aria-label="Ask the Overseer"]')) return; break;
157
- case "ask-agent": if (!click('[data-catch-up-more] [data-ask-agent] [role="button"]')) return; break;
164
+ case "ask": if (!click('[data-catch-up-more] [data-ask-agent] [role="button"]')) return; break;
158
165
  case "rail": {
159
166
  const items = railItems();
160
167
  if (el?.closest?.("[data-catch-up-rail]")) { (el as { blur?(): void }).blur?.(); break; }
@@ -173,11 +180,48 @@ export function CatchUp({ theme, compact, deps, navigation, onExit }: { theme: T
173
180
  doc.addEventListener("keydown", onKey);
174
181
  return () => doc.removeEventListener("keydown", onKey);
175
182
  });
176
- // Phones: swipe left to skip, right to go back. Answers are never a swipe: a stray thumb must not decide anything.
183
+ // Phones: the card follows the finger (Paseo's sidebar drag): left skips this card, right goes Back, the card about to
184
+ // show peeks underneath, and a drag held halfway stays there. The direction locks in the first SWIPE_LOCK_PX, so a
185
+ // vertical scroll stays a scroll. Answers are never a swipe: a stray thumb must not decide anything. Reduced motion:
186
+ // no follow, just the move on release. Transforms only (translateX), on the native driver where there is one.
187
+ const reduced = useReducedMotion();
188
+ const drag = useRef(new Animated.Value(0)).current;
189
+ const [dragDir, setDragDir] = useState<"skip" | "back" | null>(null);
190
+ const width = useRef(390);
191
+ const lock = useRef<"x" | "y" | null>(null);
192
+ // The finger's own offset from where it went down: react-native-web's accumulated gestureState.dx runs ahead of a
193
+ // mouse drag, so the card would outrun the pointer. Every touch start passes the capture phase, so it is read there.
194
+ const origin = useRef({ x: 0, y: 0 });
195
+ type Touch = { nativeEvent: { pageX: number; pageY: number } };
196
+ const offset = (e: Touch) => ({ dx: e.nativeEvent.pageX - origin.current.x, dy: e.nativeEvent.pageY - origin.current.y });
197
+ const canBack = session.pos > 0;
177
198
  const pan = useMemo(() => PanResponder.create({
178
- onMoveShouldSetPanResponder: (_e, g) => compact && Math.abs(g.dx) > 24 && Math.abs(g.dx) > Math.abs(g.dy) * 2,
179
- onPanResponderRelease: (_e, g) => { if (g.dx < -80) skip(); else if (g.dx > 80) back(); },
180
- }), [compact, key]); // eslint-disable-line react-hooks/exhaustive-deps
199
+ onStartShouldSetPanResponderCapture: e => { origin.current = { x: e.nativeEvent.pageX, y: e.nativeEvent.pageY }; lock.current = null; return false; },
200
+ onMoveShouldSetPanResponderCapture: e => {
201
+ if (!compact || finished) return false;
202
+ const { dx, dy } = offset(e);
203
+ const l = swipeLock(dx, dy);
204
+ if (!l) return false;
205
+ lock.current ??= l;
206
+ return lock.current === "x";
207
+ },
208
+ onPanResponderTerminationRequest: () => false,
209
+ onPanResponderMove: e => {
210
+ const { dx } = offset(e);
211
+ setDragDir(dx < 0 ? "skip" : canBack ? "back" : null);
212
+ // Nothing behind the first card: the drag resists instead of revealing an empty space.
213
+ if (!reduced) drag.setValue(dx > 0 && !canBack ? dx * 0.25 : dx);
214
+ },
215
+ onPanResponderRelease: (e, g) => {
216
+ lock.current = null;
217
+ const out = swipeOutcome({ dx: offset(e).dx, vx: g.vx, width: width.current, canBack });
218
+ const act = () => { drag.setValue(0); setDragDir(null); if (out === "skip") skip(); else if (out === "back") back(); };
219
+ if (out === "stay") { setDragDir(null); if (!reduced) Animated.spring(drag, { toValue: 0, bounciness: 0, speed: 20, useNativeDriver: Platform.OS !== "web" }).start(); else drag.setValue(0); return; }
220
+ if (reduced) { act(); return; }
221
+ Animated.timing(drag, { toValue: (out === "skip" ? -1 : 1) * width.current, duration: 160, useNativeDriver: Platform.OS !== "web" }).start(act);
222
+ },
223
+ onPanResponderTerminate: () => { lock.current = null; setDragDir(null); drag.setValue(0); },
224
+ }), [compact, key, finished, canBack, reduced]); // eslint-disable-line react-hooks/exhaustive-deps
181
225
 
182
226
  const stats = statsOf(session);
183
227
  const total = session.order.length;
@@ -191,7 +235,7 @@ export function CatchUp({ theme, compact, deps, navigation, onExit }: { theme: T
191
235
  {!compact && <IconButton theme={theme} compact={compact} icon="X" label={`Leave ${MODE.name} (X)`} tooltip onPress={onExit} />}
192
236
  <Text accessibilityRole="header" style={[t.title, { flex: 1 }]}>{finished || !total ? MODE.name : <>{MODE.name} <Text style={{ color: c.foregroundMuted, fontWeight: "400", fontVariant: ["tabular-nums"] }}>{MODE.progress(session.pos + 1, total).slice(MODE.name.length + 1)}</Text></>}</Text>
193
237
  {waitingChip}
194
- {!compact && <Pressable accessibilityRole="button" accessibilityLabel="Show the keys (S)" onPress={() => setKeysOpen(v => !v)}><Text style={t.small}>{finished ? "S keys · X leave" : "J skip · K back · M more context · S keys · X leave"}</Text></Pressable>}
238
+ {!compact && <Pressable accessibilityRole="button" accessibilityLabel="Show the keys (S)" onPress={() => setKeysOpen(v => !v)}><Text style={t.small}>{finished ? "S keys · X leave" : "J skip card · ⇧J skip workspace · K back · M more context · S keys"}</Text></Pressable>}
195
239
  </View>
196
240
  {/* One segment per card: done in the foreground colour, skipped hollow, waiting for context amber-tinted, the current one amber. */}
197
241
  {total > 0 && <View accessibilityElementsHidden importantForAccessibility="no-hide-descendants" style={{ flexDirection: "row", gap: 3 }}>
@@ -210,7 +254,7 @@ export function CatchUp({ theme, compact, deps, navigation, onExit }: { theme: T
210
254
  : <CardView key={card.key} card={card} w={w} theme={theme} compact={compact} deps={deps} navigation={navigation} gone={gone} more={more} setMore={setMore}
211
255
  request={askFor(context, card.key)} waiting={!!session.parked[card.s.key]} onAsk={ask}
212
256
  sameWorkspace={session.order.filter(k => cardOf(k)?.s.key === card.s.key)}
213
- onDone={() => settle("done")} onSkip={skip} onBack={session.pos > 0 ? back : undefined} onLater={() => settle("later")} />;
257
+ onDone={() => settle("done")} onSkip={skip} onSkipWorkspace={wsLeft > 1 ? skipWs : undefined} wsLeft={wsLeft} onBack={session.pos > 0 ? back : undefined} onLater={() => settle("later")} />;
214
258
 
215
259
  const rail = <ScrollView {...({ dataSet: { catchUpRail: "1" } } as object)} contentContainerStyle={{ paddingVertical: 8 }}>
216
260
  {session.order.map((k, i) => {
@@ -233,7 +277,22 @@ export function CatchUp({ theme, compact, deps, navigation, onExit }: { theme: T
233
277
  })}
234
278
  </ScrollView>;
235
279
 
236
- const main = <View style={{ flex: 1, minWidth: 0 }} {...pan.panHandlers}>{body}</View>;
280
+ // Under the dragged card: the one the release would show, so the drag says where it goes.
281
+ const peekKey = dragDir === "skip" ? session.order[nextPos(session, session.pos)] : dragDir === "back" ? session.order[prevPos(session)] : undefined;
282
+ const peekCard = cardOf(peekKey);
283
+ const peek = compact && dragDir && <View accessibilityElementsHidden importantForAccessibility="no-hide-descendants" pointerEvents="none"
284
+ style={{ position: "absolute", top: 0, bottom: 0, left: 0, right: 0, backgroundColor: c.surface1, justifyContent: "center", alignItems: dragDir === "skip" ? "flex-end" : "flex-start", paddingHorizontal: 20 }}>
285
+ <View style={{ maxWidth: "42%", gap: 4, alignItems: dragDir === "skip" ? "flex-end" : "flex-start" }}>
286
+ <Icon name={dragDir === "skip" ? "ArrowRight" : "ChevronLeft"} size={18} color={c.foregroundMuted} />
287
+ <Text style={[t.small, { fontWeight: "600" }]}>{dragDir === "skip" ? `Skip ${card ? skipNoun(card) : "card"}` : "Back"}</Text>
288
+ <Text numberOfLines={2} style={[t.meta, { textAlign: dragDir === "skip" ? "right" : "left" }]}>{peekCard ? `${peekCard.s.title} · ${cardLabel(peekCard, peekCard.s.workspaceId ? live.get(peekCard.s.workspaceId) : undefined)}` : MODE.endOfDeck}</Text>
289
+ </View>
290
+ </View>;
291
+ const main = <View style={{ flex: 1, minWidth: 0, overflow: "hidden" }} onLayout={e => { width.current = e.nativeEvent.layout.width; }} {...pan.panHandlers}>
292
+ {peek}
293
+ <Animated.View {...({ dataSet: { catchUpDrag: "1" } } as object)} style={{ flex: 1, backgroundColor: c.surface0, transform: [{ translateX: drag }],
294
+ ...(dragDir ? { shadowColor: "#000", shadowOpacity: 0.18, shadowRadius: 12, shadowOffset: { width: 0, height: 0 } } : {}) }}>{body}</Animated.View>
295
+ </View>;
237
296
  return <View style={{ flex: 1, backgroundColor: c.surface0 }}>
238
297
  {progress}
239
298
  <View style={{ flex: 1, borderTopWidth: 1, borderTopColor: c.border }}>
@@ -248,23 +307,24 @@ export function CatchUp({ theme, compact, deps, navigation, onExit }: { theme: T
248
307
  }
249
308
 
250
309
  /** One card: who and what, the ask through its own surface's component, then the deck's moves pinned to the bottom. */
251
- function CardView({ card, w, theme, compact, deps, navigation, gone, more, setMore, request, waiting, onAsk, sameWorkspace, onDone, onSkip, onBack, onLater }: {
310
+ function CardView({ card, w, theme, compact, deps, navigation, gone, more, setMore, request, waiting, onAsk, sameWorkspace, onDone, onSkip, onSkipWorkspace, wsLeft, onBack, onLater }: {
252
311
  card: DeckCard; w: ListWorkspace | undefined; theme: Theme; compact: boolean; deps: CatchUpDeps; navigation: Nav; gone: boolean; more: boolean; setMore: (v: boolean | ((v: boolean) => boolean)) => void;
253
- request: ContextRequest | null; waiting: boolean; onAsk: (target: "overseer" | "agent", words: string) => Promise<void>;
254
- sameWorkspace: string[]; onDone: () => void; onSkip: () => void; onBack?: () => void; onLater: () => void;
312
+ request: ContextRequest | null; waiting: boolean; onAsk: (words: string) => Promise<void>;
313
+ sameWorkspace: string[]; onDone: () => void; onSkip: () => void; onSkipWorkspace?: () => void; wsLeft: number; onBack?: () => void; onLater: () => void;
255
314
  }) {
256
315
  const c = theme.colors; const t = text(c, compact);
257
316
  const s = card.s;
258
317
  const { workspace: full } = useWorkspace(deps.sources.live, s.workspaceId ?? "");
259
318
  const ws = openRowCopy<ListWorkspace>(w, full);
260
- const overseerOn = useSyncExternalStore(deps.sources.extras.subscribe, () => deps.sources.extras.overseer()?.enabled !== false, () => true);
261
319
  const [laterOpen, setLaterOpen] = useState(false);
320
+ const [ready, setReady] = useState<SendReady | null>(null);
262
321
  const openChat = () => { if (!navigation) return; if (s.agentId) navigation.openAgent({ agentId: s.agentId }); else if (s.workspaceId) navigation.openWorkspace({ workspaceId: s.workspaceId }); };
263
322
  const word = cardWord(card);
264
323
  const color = card.item?.kind === "merge" ? mergedColor(c) : card.kind === "finished" ? c.foregroundMuted : c.statusWarning;
265
324
  const q = card.kind === "question" ? ws?.questions.find(x => x.id === card.questionId) ?? null : null;
266
325
  const nth = sameWorkspace.indexOf(card.key);
267
326
  const agentName = s.agent ?? "the agent";
327
+ const noun = skipNoun(card);
268
328
 
269
329
  const head = <View style={{ gap: 6 }}>
270
330
  <View style={{ flexDirection: "row", alignItems: "center", gap: 6 }}>
@@ -290,7 +350,7 @@ function CardView({ card, w, theme, compact, deps, navigation, gone, more, setMo
290
350
  ? <View style={{ gap: 8 }}>
291
351
  <RichText plain style={compact ? t.ask : [t.body, { fontSize: 15, lineHeight: 21, fontWeight: "600" }]}>{`${q.id} · ${q.title}`}</RichText>
292
352
  <QuestionBody key={q.id} workspace={ws} question={q} theme={theme} compact={compact} inline={false}
293
- openAgent={id => navigation?.openAgent({ agentId: id })} onAnswered={onDone} />
353
+ openAgent={id => navigation?.openAgent({ agentId: id })} onAnswered={onDone} onSendReady={setReady} />
294
354
  </View>
295
355
  : card.kind === "item" && card.item && full
296
356
  ? <View style={{ borderRadius: 10, borderWidth: 1, borderColor: withAlpha(c.statusWarning, 0.45), overflow: "hidden" }}>
@@ -306,44 +366,96 @@ function CardView({ card, w, theme, compact, deps, navigation, gone, more, setMo
306
366
 
307
367
  // Add context without answering: every card that isn't a question has the agent's reply box (a question has its note).
308
368
  const reply = card.kind !== "question" && s.agentId && <NoteRow theme={theme} compact={compact} agentId={s.agentId} />;
309
- const contextBlock = request && <ContextAnswer theme={theme} compact={compact} request={request} waiting={waiting} agent={agentName} openChat={openChat} />;
310
- const moreBlock = more && <MorePanel theme={theme} compact={compact} agent={agentName} hasAgent={!!s.agentId} overseerOn={overseerOn} onClose={() => setMore(false)} onAsk={onAsk} />;
369
+ const contextBlock = request && <ContextAnswer theme={theme} compact={compact} request={request} waiting={waiting} agent={agentName} openChat={openChat} openAgent={navigation ? id => navigation.openAgent({ agentId: id }) : undefined} />;
370
+ // a-move-bar-action-opens-in-view (MOVE_OPENS): More context and Later open where the eye is, a sheet above the
371
+ // phone's bar or a popover on their button on desktop, never appended below the card.
372
+ const closeMore = () => { setMore(false); if (!compact) focusSoon("catch-up-more"); };
373
+ const moreBlock = more && <MorePanel theme={theme} compact={compact} onClose={closeMore} onAsk={onAsk} />;
311
374
  const later = (until: string) => { setLaterOpen(false); if (s.agentId) void deps.sources.inbox.snooze([s.agentId], until); onLater(); };
312
- const laterRow = laterOpen && <View {...({ dataSet: { catchUpLater: "1" } } as object)} accessibilityRole="menu" style={{ flexDirection: "row", flexWrap: "wrap", gap: 8, paddingHorizontal: compact ? 12 : 0, paddingTop: 8 }}>
313
- {laterChoices(new Date()).map(([k, label]) => <Button key={k} theme={theme} compact={compact} kind="ghost" icon="AlarmClock" title={label} onPress={() => later(snoozeUntil(k, new Date()))} />)}
375
+ const laterBlock = laterOpen && <View {...({ dataSet: { catchUpLater: "1" } } as object)} accessibilityRole="menu" accessibilityLabel="Later" style={{ gap: 8 }}>
376
+ <Text style={[t.small, { fontWeight: "600" }]}>Back in your Needs you</Text>
377
+ <View style={{ flexDirection: "row", flexWrap: "wrap", gap: 8 }}>
378
+ {laterChoices(new Date()).map(([k, label]) => <Button key={k} theme={theme} compact={compact} kind="ghost" icon="AlarmClock" title={label} onPress={() => later(snoozeUntil(k, new Date()))} />)}
379
+ </View>
314
380
  </View>;
381
+ const toggleMore = () => { setLaterOpen(false); setMore(v => !v); };
382
+ const toggleLater = () => { setMore(false); setLaterOpen(v => !v); };
383
+ const popover = (open: ReactNode, label: string, width: number) => open && <MoveResult place="popover" theme={theme} label={label} width={width}>{open}</MoveResult>;
315
384
 
316
- // The deck's moves: in thumb reach on phones, under the card on desktop. One primary lives in the card (Send,
317
- // Merge, Allow); these stay secondary. Icon-only moves carry their name for screen readers and as a desktop tooltip.
318
- const moves = <View style={{ flexDirection: "row", alignItems: "center", gap: 8, paddingHorizontal: compact ? 12 : 0, paddingTop: compact ? 10 : 4 }}>
385
+ // The deck's moves: in thumb reach on phones, under the card on desktop. Once the card has an answer to send, Send to
386
+ // agent takes the bar's primary slot: the question's own Send (onSendReady), so one click, one flow. Icon-only moves
387
+ // carry their name for screen readers and as a desktop tooltip.
388
+ const send = ready && (compact
389
+ ? <View style={{ flex: 1 }}><Button theme={theme} compact grow kind="primary" icon="Send" title="Send" accessibilityLabel="Send to agent" shortcut disabled={ready.busy} onPress={ready.send} /></View>
390
+ : <Button theme={theme} kind="primary" icon="Send" title="Send to agent" shortcut disabled={ready.busy} onPress={ready.send} />);
391
+ const moves = <View {...({ dataSet: { catchUpCardMoves: "1" } } as object)} style={{ flexDirection: "row", alignItems: "center", gap: 8, paddingHorizontal: compact ? 12 : 0, paddingTop: compact ? 10 : 4 }}>
319
392
  <IconButton theme={theme} compact={compact} icon="ChevronLeft" label={compact ? "Back" : "Back (K or ←)"} tooltip={!compact} disabled={!onBack} onPress={() => onBack?.()} />
320
- {compact ? <View style={{ flex: 1 }}><Button theme={theme} compact grow icon="Sparkles" title="Context" accessibilityLabel="More context" onPress={() => setMore(v => !v)} /></View>
321
- : <Tip label="More context (M)"><Button theme={theme} icon="Sparkles" title="More context" accessibilityHint="M" onPress={() => setMore(v => !v)} /></Tip>}
322
- <IconButton theme={theme} compact={compact} icon="AlarmClock" label={compact ? "Later" : "Later (L)"} tooltip={!compact} disabled={!s.agentId} onPress={() => setLaterOpen(v => !v)} />
393
+ {compact ? <IconButton theme={theme} compact icon="Sparkles" label="More context" onPress={toggleMore} />
394
+ : <View>{popover(moreBlock, "More context", 560)}<Tip label="More context (M)"><Button theme={theme} icon="Sparkles" title="More context" accessibilityHint="M" nativeID="catch-up-more" onPress={toggleMore} /></Tip></View>}
395
+ <View>{!compact && popover(laterBlock, "Later", 380)}<IconButton theme={theme} compact={compact} icon="AlarmClock" label={compact ? "Later" : "Later (L)"} tooltip={!compact} disabled={!s.agentId} onPress={toggleLater} /></View>
323
396
  <IconButton theme={theme} compact={compact} icon="MessageSquare" label={compact ? "Open chat" : "Open chat (O)"} tooltip={!compact} disabled={!navigation} onPress={openChat} />
324
397
  {!compact && <View style={{ flex: 1 }} />}
325
- {compact ? <View style={{ flex: 1 }}><Button theme={theme} compact grow icon="ArrowRight" title="Skip" onPress={onSkip} /></View>
326
- : <Tip label="Skip (J or →)"><Button theme={theme} icon="ArrowRight" title="Skip" accessibilityHint="J" onPress={onSkip} /></Tip>}
398
+ {/* Two skips, named apart: this card (J), and the whole workspace (⇧J), shown only while it has more than one card left. */}
399
+ {compact ? ready ? <IconButton theme={theme} compact icon="ArrowRight" label={skipCardHint(noun)} onPress={onSkip} />
400
+ : <View style={{ flex: 1 }}><Button theme={theme} compact grow icon="ArrowRight" title={`Skip ${noun}`} accessibilityLabel={skipCardHint(noun)} onPress={onSkip} /></View>
401
+ : <>
402
+ {onSkipWorkspace && <Tip label={`${skipWorkspaceHint(wsLeft)} (⇧J)`}><Button theme={theme} kind="ghost" icon="ChevronsRight" title="Skip workspace" accessibilityLabel={skipWorkspaceHint(wsLeft)} accessibilityHint="Shift+J" onPress={onSkipWorkspace} /></Tip>}
403
+ <Tip label={`${skipCardHint(noun)} (J or →)`}><Button theme={theme} icon="ArrowRight" title={`Skip ${noun}`} accessibilityLabel={skipCardHint(noun)} accessibilityHint="J" onPress={onSkip} /></Tip>
404
+ </>}
405
+ {send}
327
406
  </View>;
328
407
 
329
408
  // a-focused-field-and-its-send-stay-in-view: the phone's bar is DockedPane's dock, so while a field has focus or the
330
- // keyboard is up the bar steps aside and the field (Something else, a note, the More context ask) keeps its Send in view.
409
+ // keyboard is up the bar steps aside and the field (Something else, a note) keeps its Send in view. An open sheet
410
+ // stays (the pane stops above the keyboard), so More context's ask box and its Ask buttons stay in view too.
411
+ const sheet = compact && (moreBlock || laterBlock);
331
412
  return <DockedPane compact={compact}
332
413
  contentContainerStyle={{ padding: compact ? 16 : 28, gap: compact ? 16 : 18, ...(compact ? {} : { maxWidth: 720, width: "100%", alignSelf: "center" }) }}
333
- dock={({ yields }) => compact && !yields && <View style={[{ borderTopWidth: 1, borderTopColor: c.border, backgroundColor: c.surface0 }, bottomInset(compact)]}>{laterRow}{moves}</View>}>
414
+ dock={({ yields, typingInContent }) => compact && (sheet && !typingInContent || !yields) && <View style={[{ borderTopWidth: 1, borderTopColor: c.border, backgroundColor: c.surface0 }, bottomInset(compact)]}>
415
+ {sheet && !typingInContent && <MoveResult place="sheet" theme={theme} label={moreBlock ? "More context" : "Later"}>{sheet}</MoveResult>}
416
+ {!yields && !sheet && onSkipWorkspace && <View style={{ flexDirection: "row", justifyContent: "flex-end", paddingHorizontal: 12, paddingTop: 6 }}>
417
+ <Button theme={theme} compact kind="ghost" icon="ChevronsRight" title={`Skip workspace · ${wsLeft} cards`} accessibilityLabel={skipWorkspaceHint(wsLeft)} onPress={onSkipWorkspace} />
418
+ </View>}
419
+ {!yields && moves}
420
+ </View>}>
334
421
  {goneBanner}
335
422
  {head}
336
423
  {contextBlock}
337
424
  <View {...CARD_MARK} style={{ gap: 16 }}>{askBlock}</View>
338
425
  {reply}
339
- {moreBlock}
340
- {!compact && laterRow}
341
- {!compact && moves}
426
+ {/* Desktop: ⌘↵ anywhere on the bar sends, as the bar's Send says (its own SubmitScope). */}
427
+ {!compact && <SubmitScope enabled={!!ready && !ready.busy} onSubmit={() => ready?.send()}>{moves}</SubmitScope>}
342
428
  </DockedPane>;
343
429
  }
344
430
 
431
+ /**
432
+ * Where a move's result opens (MOVE_OPENS, a-move-bar-action-opens-in-view): a sheet in the phone's dock or a popover
433
+ * on its desktop button. Focus moves into it (its first choice), and on the web it scrolls into view the least distance.
434
+ */
435
+ function MoveResult({ place, theme, label, width, children }: { place: "sheet" | "popover"; theme: Theme; label: string; width?: number; children: ReactNode }) {
436
+ const c = theme.colors;
437
+ const ref = useRef<View>(null);
438
+ useEffect(() => {
439
+ if (Platform.OS !== "web") return;
440
+ const t = setTimeout(() => {
441
+ const node = ref.current as unknown as { querySelector?(q: string): { focus?(o?: object): void } | null; scrollIntoView?(o: object): void } | null;
442
+ node?.scrollIntoView?.({ block: "nearest" });
443
+ // The first choice: More context's suggestions ("I don't get it" leads), else Later's first time.
444
+ (node?.querySelector?.('[role="radio"]') ?? node?.querySelector?.('[role="menu"] [role="button"]'))?.focus?.({ preventScroll: true });
445
+ }, 0);
446
+ return () => clearTimeout(t);
447
+ }, []);
448
+ return <View ref={ref} {...({ dataSet: { moveResult: place } } as object)} accessibilityRole={"dialog" as never} accessibilityLabel={label}
449
+ style={[{ padding: place === "sheet" ? 14 : 16, borderRadius: 12, borderWidth: 1, borderColor: c.border, backgroundColor: c.surface1 },
450
+ place === "sheet"
451
+ ? { marginHorizontal: 12, marginTop: 12 }
452
+ : { position: "absolute", zIndex: 20, left: 0, bottom: "100%", marginBottom: 8, width, shadowColor: "#000", shadowOpacity: 0.22, shadowRadius: 16, shadowOffset: { width: 0, height: 6 } }]}>
453
+ {children}
454
+ </View>;
455
+ }
456
+
345
457
  /** What came back for this card: the answer, "answered in its chat", a failure, or (seen going Back) that it's still asking. */
346
- function ContextAnswer({ theme, compact, request, waiting, agent, openChat }: { theme: Theme; compact: boolean; request: ContextRequest; waiting: boolean; agent: string; openChat: () => void }) {
458
+ function ContextAnswer({ theme, compact, request, waiting, agent, openChat, openAgent }: { theme: Theme; compact: boolean; request: ContextRequest; waiting: boolean; agent: string; openChat: () => void; openAgent?: (agentId: string) => void }) {
347
459
  const c = theme.colors; const t = text(c, compact);
348
460
  const who = request.target === "overseer" ? "Overseer" : agent === "the agent" ? "The agent" : agent;
349
461
  const asking = request.state === "asking";
@@ -354,8 +466,11 @@ function ContextAnswer({ theme, compact, request, waiting, agent, openChat }: {
354
466
  </View>
355
467
  {request.state === "answered" && request.answer && <RichText selectable style={t.body}>{request.answer}</RichText>}
356
468
  {request.state === "chat" && <View style={{ gap: 8 }}>
357
- <Text style={t.body}>{`${who} answered in its chat.`}</Text>
358
- <View style={{ flexDirection: "row" }}><Button theme={theme} compact={compact} icon="MessageSquare" title="Open chat" onPress={openChat} /></View>
469
+ <Text style={t.body}>{who === "Overseer" ? "The Overseer answered in its own chat, not here: it can't reply on a card." : `${who} answered in its chat.`}</Text>
470
+ {/* A 2.2.0-beta.3 ask of the Overseer: its answer is in the Overseer's chat (an-ask-goes-only-to-an-agent-that-can-answer-it). */}
471
+ <View style={{ flexDirection: "row" }}>{who === "Overseer"
472
+ ? <Button theme={theme} compact={compact} icon="MessageSquare" title="Open Overseer" disabled={!request.askedOf || !openAgent} onPress={() => request.askedOf && openAgent?.(request.askedOf)} />
473
+ : <Button theme={theme} compact={compact} icon="MessageSquare" title="Open chat" onPress={openChat} />}</View>
359
474
  </View>}
360
475
  {request.state === "failed" && <Text style={t.body}>{request.error ?? "The ask didn't go through. Try again, or open the chat."}</Text>}
361
476
  </View>;
@@ -378,24 +493,23 @@ function BriefAsk({ s, theme, compact, deps }: { s: DeckCard["s"]; theme: Theme;
378
493
  }
379
494
 
380
495
  /**
381
- * More context: "I don't get it" first (most asks just need explaining), then the developer's own words. The Overseer
382
- * answers from what it already reads and wakes nobody; the card's agent knows best and may wake, because the
383
- * developer asked. Either way the deck moves on and this workspace comes back when the answer is ready.
496
+ * More context: "I don't get it" first (most asks just need explaining), then the developer's own words, to one place:
497
+ * the card's workspace's main agent, the one that can answer on the card (an-ask-goes-only-to-an-agent-that-can-answer-
498
+ * it). It may wake, because the developer asked. The deck moves on and this workspace comes back when the answer is ready.
384
499
  */
385
- function MorePanel({ theme, compact, agent, hasAgent, overseerOn, onClose, onAsk }: { theme: Theme; compact: boolean; agent: string; hasAgent: boolean; overseerOn: boolean; onClose: () => void; onAsk: (target: "overseer" | "agent", words: string) => Promise<void> }) {
500
+ function MorePanel({ theme, compact, onClose, onAsk }: { theme: Theme; compact: boolean; onClose: () => void; onAsk: (words: string) => Promise<void> }) {
386
501
  const c = theme.colors; const t = text(c, compact);
387
502
  const [words, setWords] = useState<string>(CONTEXT_ASKS[0].text);
388
503
  const [picked, setPicked] = useState<string>(CONTEXT_ASKS[0].id);
389
- const [busy, setBusy] = useState<"overseer" | "agent" | null>(null);
504
+ const [busy, setBusy] = useState(false);
390
505
  const [error, setError] = useState<string | null>(null);
391
- const send = (target: "overseer" | "agent") => {
506
+ const send = () => {
392
507
  if (!words.trim() || busy) return;
393
- setBusy(target); setError(null);
508
+ setBusy(true); setError(null);
394
509
  // The words stay unless the ask is recorded.
395
- onAsk(target, words.trim()).catch(e => setError(errorText(e))).finally(() => setBusy(null));
510
+ onAsk(words.trim()).catch(e => setError(errorText(e))).finally(() => setBusy(false));
396
511
  };
397
- const agentLabel = agent === "the agent" ? "Ask the agent" : `Ask ${agent}`;
398
- return <View {...({ dataSet: { catchUpMore: "1" } } as object)} style={{ gap: 10, padding: compact ? 14 : 16, borderRadius: 12, borderWidth: 1, borderColor: c.border, backgroundColor: c.surface1 }}>
512
+ return <View {...({ dataSet: { catchUpMore: "1" } } as object)} style={{ gap: 10 }}>
399
513
  <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
400
514
  <Icon name="Sparkles" size={14} color={c.foreground} />
401
515
  <Text style={[t.label, { flex: 1, fontWeight: "600" }]}>More context</Text>
@@ -410,13 +524,11 @@ function MorePanel({ theme, compact, agent, hasAgent, overseerOn, onClose, onAsk
410
524
  <View {...PRIMARY_FORM} style={{ gap: 10 }}>
411
525
  <TextInput accessibilityLabel="What do you want to know?" placeholder="What do you want to know?" placeholderTextColor={c.foregroundMuted} value={words} multiline
412
526
  onChangeText={v => { setWords(v); setPicked(CONTEXT_ASKS.find(x => x.text === v)?.id ?? ""); }}
413
- style={{ minHeight: compact ? 44 : 36, paddingHorizontal: 10, paddingVertical: 8, borderRadius: 6, borderWidth: 1, borderColor: c.border, color: c.foreground, backgroundColor: c.surface0 }} />
527
+ style={{ minHeight: compact ? 84 : 56, paddingHorizontal: 10, paddingVertical: 8, borderRadius: 6, borderWidth: 1, borderColor: c.border, color: c.foreground, backgroundColor: c.surface0 }} />
414
528
  {!!error && <Text accessibilityRole="alert" style={[t.meta, { color: c.statusDanger }]}>{error}</Text>}
415
- <View style={{ flexDirection: "row", flexWrap: "wrap", gap: 8 }}>
416
- {overseerOn && <Button theme={theme} compact={compact} grow={compact} kind="primary" icon="MessagesSquare" title="Ask the Overseer" loading={busy === "overseer"} disabled={!words.trim() || !!busy}
417
- accessibilityHint={compact ? "Answers from what Follow-up and the chats already hold; wakes nobody" : `Answers from what Follow-up and the chats already hold; wakes nobody. ${keyLabel("⌘↵", isMac())}`} onPress={() => send("overseer")} />}
418
- {hasAgent && <View {...({ dataSet: { askAgent: "1" } } as object)} style={compact ? { flexGrow: 1 } : null}><Button theme={theme} compact={compact} grow={compact} kind={overseerOn ? "secondary" : "primary"} icon="MessageSquareText" title={agentLabel} loading={busy === "agent"} disabled={!words.trim() || !!busy}
419
- accessibilityHint={compact ? "Sends it to the agent, which may wake it" : `Sends it to the agent, which may wake it. ${keyLabel("⌘⇧↵", isMac())}`} onPress={() => send("agent")} /></View>}
529
+ <View {...({ dataSet: { askAgent: "1" } } as object)} style={{ flexDirection: "row" }}>
530
+ <Button theme={theme} compact={compact} grow={compact} kind="primary" icon="MessageSquareText" title="Ask the agent" loading={busy} disabled={!words.trim() || busy}
531
+ accessibilityHint={compact ? "Asks this workspace's main agent, which may wake it" : `Asks this workspace's main agent, which may wake it. ${keyLabel("⌘↵", isMac())}`} onPress={send} />
420
532
  </View>
421
533
  </View>
422
534
  <Text style={t.small}>This workspace steps aside while you keep going, and comes back as your next card with the answer. Back reaches it any time.</Text>
@@ -1,7 +1,7 @@
1
1
  // The question dialog and its answer form. The layout of options with a recommendation, the
2
2
  // "what the agent does meanwhile" line and Copy are adapted from Progress
3
3
  // (@stevecastaneda/paseo-progress, MIT, © 2026 Steve Castaneda); see THIRD_PARTY_NOTICES.md.
4
- import { useEffect, useState } from "react";
4
+ import { useEffect, useRef, useState } from "react";
5
5
  import { View } from "react-native";
6
6
  import { Pressable, Text, copyable } from "./text";
7
7
  import { openExternalUrl, useRpc } from "@getpaseo/plugin/client";
@@ -92,18 +92,26 @@ export function OptionCard({ theme, letter, label, consequence, recommended, sel
92
92
 
93
93
  const inputStyle = (c: Colors, compact: boolean, lines: number) => ({ minHeight: compact ? 44 : 18 * lines + 16, paddingHorizontal: 10, paddingVertical: 8, borderRadius: 6, borderWidth: 1, borderColor: c.border, color: c.foreground, backgroundColor: c.surface1, fontSize: 13, lineHeight: 18, textAlignVertical: "top" as const });
94
94
 
95
+ /** A sendable answer, handed to a surface that also offers Send outside the form (Catch up's move bar). */
96
+ export type SendReady = { send: () => void; busy: boolean };
97
+
95
98
  /**
96
99
  * One question with its answer form. Send records the answer and messages the asking agent straight
97
100
  * away; Copy records it and puts a reply on the clipboard instead. The one answer flow every question surface draws
98
101
  * (the dialog, Needs you on Home and in the panel, the pill, phones): what its field means comes from answerDraft
99
102
  * (`one-answer-flow-for-every-question`), never from the surface.
100
103
  */
101
- export function QuestionBody({ workspace: w, question: q, theme, compact, now = Date.now(), dense = false, bodyMaxHeight, openAgent, onAnswered, onDetails, onClose, inline = false }: {
104
+ export function QuestionBody({ workspace: w, question: q, theme, compact, now = Date.now(), dense = false, bodyMaxHeight, openAgent, onAnswered, onDetails, onClose, inline = false, onSendReady }: {
102
105
  workspace: ListWorkspace; question: ListQuestion; theme: Theme; compact: boolean; now?: number; dense?: boolean; bodyMaxHeight?: number; openAgent?: (agentId: string) => void; onAnswered?: () => void; onDetails?: () => void;
103
106
  /** Inside the Needs you block: its header says the title and when it was asked, its footer what the agent does meanwhile. */
104
107
  inline?: boolean;
105
108
  /** The dialog's close: Send and Copy close it at once and report the outcome as a toast. */
106
109
  onClose?: () => void;
110
+ /**
111
+ * Catch up's move bar: told whenever this answer becomes sendable (or stops being), with this form's own Send, so a
112
+ * Send outside the card runs exactly this flow (`one-answer-flow-for-every-question`), never a copy of it.
113
+ */
114
+ onSendReady?: (send: SendReady | null) => void;
107
115
  }) {
108
116
  const c = theme.colors; const t = text(c);
109
117
  const toast = useToast(); const cache = useQueryClient();
@@ -189,6 +197,11 @@ export function QuestionBody({ workspace: w, question: q, theme, compact, now =
189
197
  });
190
198
  onClose?.(); onAnswered?.();
191
199
  };
200
+ // The footer's Send calls the latest quick through a ref, so it never sends a stale choice or words.
201
+ const quickRef = useRef(quick); quickRef.current = quick;
202
+ const sendable = open && !!answer;
203
+ useEffect(() => { onSendReady?.(sendable ? { send: () => quickRef.current("send"), busy: run.isPending } : null); }, [sendable, run.isPending]);
204
+ useEffect(() => () => onSendReady?.(null), []);
192
205
  // The body says Not sent · Retry itself, with the button; the state line stays on what the agent is doing.
193
206
  const state = meanwhile(w, q, null);
194
207
  const delivery = deliveryLine(w, q, now);
package/index.server.ts CHANGED
@@ -14,8 +14,8 @@ import { agentSetSpec, developerSetSpec } from "./server/spec";
14
14
  import type { PluginServerContext, PluginHandlerContext, PluginHookContext, PluginSessionOpenRequest } from "@getpaseo/plugin/server";
15
15
  import type { PluginRpcContract, PluginSubscriptionContract } from "@getpaseo/plugin";
16
16
  import { ValueFeed, WorkspacesFeed } from "./server/feeds";
17
- import { ContextRequests } from "./server/context-requests";
18
- import { agentContextPrompt, deckCards, overseerContextPrompt } from "./shared/catch-up";
17
+ import { ContextRequests, contextRecipient } from "./server/context-requests";
18
+ import { agentContextPrompt, deckCards } from "./shared/catch-up";
19
19
  import { buildHome } from "./shared/home";
20
20
  import { needsYou } from "./shared/attention";
21
21
  import type { SortMode } from "./shared/sort";
@@ -490,7 +490,7 @@ export default function contribute(server: PluginServerContext) {
490
490
  const rows = await gateway.directory.read().catch(() => null);
491
491
  const status = new Map((rows?.agents ?? []).map(({ agent }) => [agent.id, agent.status]));
492
492
  await contextRequests.reconcile(r => {
493
- const item = r.target === "agent" ? queue.get(`message:${r.askedOf}:${r.id}`) : null;
493
+ const item = queue.get(`message:${r.askedOf}:${r.id}`);
494
494
  return { sent: item?.state === "sent" ? item.settledAt ?? null : null, failed: item?.state === "cancelled" || item?.state === "failed" && item.gone ? item.reason ?? "The ask couldn't reach the agent." : null,
495
495
  idle: rows ? status.get(r.askedOf!) !== "running" : false };
496
496
  });
@@ -953,31 +953,19 @@ export default function contribute(server: PluginServerContext) {
953
953
  handle(rpc.overseerStatusRpc, async () => { await requireReady(); return overseerStatus(); });
954
954
  handle(rpc.overseerStartRpc, async (_input, { paseo }) => { await requireReady(); seen(paseo); await overseer!.start(paseo as unknown as OverseerPaseo); return overseerStatus(); });
955
955
  handle(rpc.overseerAskRpc, async ({ text }, { paseo }) => { await requireReady(); seen(paseo); await overseer!.ask(paseo as unknown as OverseerPaseo, text); return overseerStatus(); });
956
- // Catch up's More context: the ask is recorded and answered at once; the Overseer's send runs after the reply (it may
957
- // start the Overseer), the agent's goes through the message queue (invariant 36). Asking the card's agent may wake
958
- // it: the developer asked, the one exception to never-wake (invariant 1). The Overseer reads without waking anyone.
956
+ // Catch up's More context: the ask is recorded and answered at once, and goes through the message queue (invariant
957
+ // 36) to the card's workspace's main agent, the only role with context_reply (an-ask-goes-only-to-an-agent-that-can-
958
+ // answer-it). Asking may wake it: the developer asked, the one exception to never-wake (invariant 1).
959
959
  handle(rpc.contextAskRpc, async (input, context) => {
960
960
  await requireReady();
961
961
  const actor = actorOf(context);
962
- if (actor.kind === "agent" && input.target === "agent" && input.agentId === actor.agentId) throw new Error("ask_context asks another agent about its card for the developer; explain your own ask in your reply.");
963
- if (input.target === "agent" && !input.agentId) throw new Error("This card has no agent to ask. Ask the Overseer instead.");
964
- // Recorded at once, never waiting on Paseo (an-ack-never-waits): the Overseer's id is learnt after its send.
965
- const out = await contextRequests.ask(input, actorBy(actor), input.target === "agent" ? input.agentId : null);
966
- if (!out.fresh) return out;
967
- const r = out.request;
968
- if (input.target === "agent") enqueueMessage(input.agentId!, agentContextPrompt(r), r.id, actorBy(actor));
969
- else {
970
- const paseo = (context as { paseo?: unknown }).paseo;
971
- void (async () => {
972
- try {
973
- const workspace = input.workspaceId ? (await gateway.directory.read().catch(() => null))?.workspaces.find(w => w.id === input.workspaceId)?.name ?? "a workspace" : "a workspace";
974
- if (!await overseerOn()) throw new Error("The Overseer is off. Turn it on in Settings → Agents, or ask the agent.");
975
- const s = await overseer!.ask(paseo as unknown as OverseerPaseo, overseerContextPrompt(r, workspace));
976
- if (s.agentId) { await contextRequests.setAskedOf(r.id, s.agentId); await contextRequests.delivered(r.id, new Date().toISOString()); }
977
- } catch (error) { await contextRequests.fail(r.id, error instanceof Error ? error.message : String(error)); }
978
- })();
979
- }
980
- return out;
962
+ // The worker's own snapshot, never a daemon read (an-ack-never-waits).
963
+ const w = input.workspaceId ? (await store.snapshot()).workspaces.find(x => x.id === input.workspaceId) : undefined;
964
+ const to = contextRecipient(w, actor.kind === "agent" ? actor.agentId : null);
965
+ if ("error" in to) throw new Error(to.error);
966
+ const out = await contextRequests.ask({ ...input, target: "agent" }, actorBy(actor), to.agentId);
967
+ if (out.fresh) enqueueMessage(to.agentId, agentContextPrompt(out.request), out.request.id, actorBy(actor));
968
+ return input.target === "overseer" ? { ...out, note: "More context always asks the card's own main agent, which can answer on the card; the Overseer can't, so target is ignored." } : out;
981
969
  });
982
970
  // Built when read (a-derived-view-is-built-when-read), from state the worker holds: no daemon request but the
983
971
  // directory's cached workspace list.
@@ -997,9 +985,6 @@ export default function contribute(server: PluginServerContext) {
997
985
  handle(rpc.contextListRpc, async ({ workspaceId }) => ({ requests: await contextRequests.list(workspaceId ? { workspaceId } : {}) }));
998
986
  handle(rpc.contextReplyRpc, async ({ agentId, requestId, text }) => {
999
987
  await requireReady();
1000
- const r = (await contextRequests.list()).find(x => x.id === requestId);
1001
- // The Overseer may have been (re)started by the ask itself, so its id is checked now, not when it was asked.
1002
- if (r?.target === "overseer" && r.askedOf !== agentId && (await overseerStatus().catch(() => null))?.agentId === agentId) await contextRequests.setAskedOf(r.id, agentId);
1003
988
  await contextRequests.reply(requestId, agentId, text);
1004
989
  return { ok: true };
1005
990
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "paseo-follow-up",
3
3
  "private": false,
4
- "version": "2.2.0-beta.3",
4
+ "version": "2.2.0-beta.4",
5
5
  "description": "A Paseo plugin that follows every workspace until the work is done: one Home for what needs you, questions you answer anywhere, and repairs that send themselves.",
6
6
  "type": "module",
7
7
  "files": [
@@ -75,8 +75,9 @@ export const RPC_TOOLS: readonly RpcTool[] = [
75
75
  { name: "ask_context", rpc: "follow.context-ask", kind: "planned", before: { rpc: "follow.context-list", input: a => ({ workspaceId: a.workspaceId ?? undefined }) },
76
76
  input: z.strictObject({ workspaceId: id.nullable().optional(), agentId: id.nullable().optional(), cardKey: z.string().min(1).max(400).optional(), card: z.string().trim().min(1).max(300).optional(),
77
77
  target: z.enum(["overseer", "agent"]).optional(), ask: z.string().trim().min(1).max(2000).optional(), ...confirm }),
78
- toRpc: a => ({ workspaceId: a.workspaceId ?? null, agentId: a.agentId ?? null, cardKey: a.cardKey, card: a.card, target: a.target, ask: a.ask }),
79
- guard: (a, caller) => a.target === "agent" && a.agentId === caller ? "ask_context asks another agent about its card; explain your own ask in your reply." : null },
78
+ // target is accepted and ignored: the server sends every ask to the card's workspace main agent, and refuses an
79
+ // agent asking itself (an-ask-goes-only-to-an-agent-that-can-answer-it).
80
+ toRpc: a => ({ workspaceId: a.workspaceId ?? null, agentId: a.agentId ?? null, cardKey: a.cardKey, card: a.card, target: a.target, ask: a.ask }) },
80
81
  // Needs-you: the brief card and the inbox's other actions
81
82
  // The message queue: what waits to go to agents, and Retry or Cancel on one item (a card's Retry, Needs you's message row).
82
83
  { name: "queue_list", rpc: "follow.queue-list", kind: "read", input: z.strictObject({ workspaceId: id.optional(), agentId: id.optional() }) },
@@ -216,6 +217,6 @@ export const PARITY: Record<string, { tools: readonly string[]; note?: string }
216
217
  * note says where an agent finds what the developer found.
217
218
  */
218
219
  export const VIEW_PARITY: Record<string, { tools: readonly string[]; note: string }> = {
219
- "catch-up": { tools: ["catch_up_deck", "answer_question", "brief_action", "inbox_act", "snooze", "ask_context"], note: "Catch up deals Needs you one card at a time; moving between cards (Skip, Back) changes only the developer's view. catch_up_deck reads the same deck, and every act on a card is a tool: answer_question, brief_action, inbox_act and snooze (Later), ask_context (More context). A permission is Paseo's own respond_to_permission." },
220
+ "catch-up": { tools: ["catch_up_deck", "answer_question", "brief_action", "inbox_act", "snooze", "ask_context"], note: "Catch up deals Needs you one card at a time; moving between cards (Skip, Skip workspace, Back, the phone's drag) changes only the developer's view, so it has no server state and no tool. catch_up_deck reads the same deck, and every act on a card is a tool: answer_question, brief_action, inbox_act and snooze (Later), ask_context (More context). A permission is Paseo's own respond_to_permission." },
220
221
  "section-search": { tools: ["workspace_status", "list_prs"], note: "The panel's Pull requests, Tasks and Activity search filters lists an agent already reads whole: workspace_status returns the workspace's PRs (title, branch, failed checks), tasks with their evidence, questions with their answers, and the sends, merges and PR actions the timeline is drawn from; list_prs returns every tracked PR with its checks." },
221
222
  };
@@ -8,9 +8,22 @@ export const CONTEXT_FILE = "context.json";
8
8
 
9
9
  export type AskInput = { workspaceId: string | null; agentId: string | null; cardKey: string; card: string; target: ContextTarget; ask: string };
10
10
 
11
+ /**
12
+ * an-ask-goes-only-to-an-agent-that-can-answer-it: who a More context ask goes to. Always the card's workspace's main
13
+ * agent (CONTEXT_REPLY_ROLE), the only role that has context_reply, whoever is named on the card: a contributor's
14
+ * question, or a recovery agent's, is still the workstream's, and its main agent answers. A workspace Follow-up doesn't
15
+ * track has no main agent, so nothing there could answer on the card, and the ask is refused with a way on. A main
16
+ * agent that was closed is still asked: the queue resumes it, or fails the ask if it is gone, and the card comes back.
17
+ */
18
+ export function contextRecipient(workspace: { enable_tracking: boolean; mainAgentId: string } | undefined, caller: string | null): { agentId: string } | { error: string } {
19
+ if (!workspace?.enable_tracking || !workspace.mainAgentId) return { error: "Follow-up doesn't track this card's workspace, so no agent can answer on the card. Open its chat to ask there." };
20
+ if (caller && workspace.mainAgentId === caller) return { error: "ask_context asks another agent about its card for the developer; explain your own ask in your reply." };
21
+ return { agentId: workspace.mainAgentId };
22
+ }
23
+
11
24
  /**
12
25
  * Catch up's More context requests (docs/needs-you.md#catch-up): what the developer asked about a card, who answers
13
- * (the Overseer or the card's agent), and the answer once `context_reply` brings it. The value lives in memory and
26
+ * (the card's workspace's main agent), and the answer once `context_reply` brings it. The value lives in memory and
14
27
  * saves behind the reply (an-ack-never-waits-on-the-disk); a change calls `onChange`, which pushes Home's feed, so the
15
28
  * client learns an answer arrived without polling. Small by construction: at most CONTEXT_MAX requests, none older
16
29
  * than CONTEXT_KEEP_MS.
@@ -29,7 +42,13 @@ export class ContextRequests {
29
42
  let value: ContextFile;
30
43
  try { value = contextFileSchema.parse(JSON.parse(await readFile(join(this.directory, CONTEXT_FILE), "utf8"))); }
31
44
  catch { value = { requests: [] }; } // Lost context requests cost a re-ask, never a broken Home.
32
- this.value ??= value;
45
+ if (this.value) return this.value;
46
+ // 2.2.0-beta.3 could ask the Overseer, which has no context_reply: an ask of it still open never ends on its own.
47
+ // Its answer, if any, is in the Overseer's chat (an-ask-goes-only-to-an-agent-that-can-answer-it).
48
+ const at = new Date(this.now()).toISOString();
49
+ const stuck = value.requests.some(r => r.target === "overseer" && r.state === "asking");
50
+ this.value = stuck ? { requests: value.requests.map(r => r.target === "overseer" && r.state === "asking" ? { ...r, state: "chat" as const, settledAt: at } : r) } : value;
51
+ if (stuck) this.persist.set(this.value);
33
52
  return this.value;
34
53
  }
35
54
  private save(requests: ContextRequest[]): void {
@@ -67,11 +86,6 @@ export class ContextRequests {
67
86
  return next;
68
87
  }
69
88
 
70
- /** Who replies is learnt after the send (the Overseer's id). */
71
- setAskedOf(id: string, askedOf: string): Promise<ContextRequest | null> {
72
- return this.update(id, r => r.askedOf === askedOf ? r : { ...r, askedOf });
73
- }
74
-
75
89
  /**
76
90
  * The asked agent's answer (context_reply). Only the agent it was asked of may answer it (ownership comes from the
77
91
  * daemon, invariant 5); an answer to a settled request replaces it, so a corrected reply wins.
@@ -85,12 +99,12 @@ export class ContextRequests {
85
99
  return (await this.update(id, x => ({ ...x, state: "answered", answer, error: null, settledAt: new Date(this.now()).toISOString() })))!;
86
100
  }
87
101
 
88
- /** The send failed for good (no Overseer, the agent archived): the card comes back saying so. */
102
+ /** The send failed for good (the agent is gone): the card comes back saying so. */
89
103
  fail(id: string, error: string): Promise<ContextRequest | null> {
90
104
  return this.update(id, r => r.state !== "asking" ? r : { ...r, state: "failed", error: error.slice(0, 500), settledAt: new Date(this.now()).toISOString() });
91
105
  }
92
106
 
93
- /** The ask reached its agent (the queue sent it; the Overseer took it). Earlier deliveries win: it is the first. */
107
+ /** The ask reached its agent (the queue sent it). Earlier deliveries win: it is the first. */
94
108
  delivered(id: string, at: string): Promise<ContextRequest | null> {
95
109
  return this.update(id, r => r.state !== "asking" || r.deliveredAt ? r : { ...r, deliveredAt: at });
96
110
  }
@@ -60,7 +60,9 @@ export type SessionStats = { done: number; skipped: number; later: number; gone:
60
60
  * A Catch up session. `order` is every card key seen this session (done ones stay, so Back works); `pos` is the card
61
61
  * on screen, `order.length` once nothing is left. `parked` maps a workstream waiting for More context to its request.
62
62
  */
63
- export type Session = { order: string[]; pos: number; outcomes: Record<string, Outcome>; parked: Record<string, string>; lapped?: boolean };
63
+ export type Session = { order: string[]; pos: number; outcomes: Record<string, Outcome>; parked: Record<string, string>; lapped?: boolean;
64
+ /** Skip workspace jumped from `to` and landed on `from` (undefined: the finished screen): Back from there returns to `to`. */
65
+ back?: { to: string; from: string | undefined } };
64
66
 
65
67
  export const startSession = (cards: readonly Pick<DeckCard, "key">[]): Session => ({ order: cards.map(c => c.key), pos: 0, outcomes: {}, parked: {} });
66
68
 
@@ -81,8 +83,58 @@ export function advance(s: Session, from: number): Pick<Session, "pos" | "lapped
81
83
  }
82
84
  export const nextPos = (s: Session, from: number): number => advance(s, from).pos;
83
85
 
84
- /** Back: the card before, whatever happened to it (done cards show what was sent; a parked one shows it is asking). */
85
- export const prevPos = (s: Session): number => Math.max(0, Math.min(s.pos, s.order.length) - 1);
86
+ /**
87
+ * Back: the card before, whatever happened to it (done cards show what was sent; a parked one shows it is asking).
88
+ * Right after Skip workspace, Back returns to the card it was pressed on, not the last card of the skipped workspace.
89
+ */
90
+ export function prevPos(s: Session): number {
91
+ if (s.back && s.order[s.pos] === s.back.from) { const i = s.order.indexOf(s.back.to); if (i >= 0) return i; }
92
+ return Math.max(0, Math.min(s.pos, s.order.length) - 1);
93
+ }
94
+
95
+ /** The cards of the on-screen card's workspace still to act on, the current one included: Skip workspace shows only above one. */
96
+ export function openInWorkspace(s: Session, key = s.order[s.pos]): string[] {
97
+ if (key === undefined) return [];
98
+ const g = groupOf(key);
99
+ return s.order.filter(k => groupOf(k) === g && open(s, k));
100
+ }
101
+
102
+ /**
103
+ * Skip workspace: every card of this workspace still to act on is skipped at once (each counts as one skipped card) and
104
+ * the deck moves to the next workspace. They come back on the second pass like any skipped card; on the second pass
105
+ * itself it moves past the rest of them.
106
+ */
107
+ export function skipWorkspace(s: Session): Session {
108
+ const key = s.order[s.pos];
109
+ if (key === undefined) return s;
110
+ const g = groupOf(key);
111
+ const outcomes = { ...s.outcomes };
112
+ for (const k of openInWorkspace(s)) outcomes[k] = "skipped";
113
+ const next: Session = { ...s, outcomes };
114
+ let at = advance(next, s.pos);
115
+ while (at.pos < s.order.length && groupOf(s.order[at.pos]) === g) at = advance({ ...next, lapped: at.lapped }, at.pos);
116
+ return { ...next, ...at, back: { to: key, from: s.order[at.pos] } };
117
+ }
118
+
119
+ /** Phone drag: which way a touch is going, decided once it has moved this far, so a vertical scroll stays a scroll. */
120
+ export const SWIPE_LOCK_PX = 8;
121
+ export function swipeLock(dx: number, dy: number): "x" | "y" | null {
122
+ if (Math.max(Math.abs(dx), Math.abs(dy)) < SWIPE_LOCK_PX) return null;
123
+ return Math.abs(dx) > 1.5 * Math.abs(dy) ? "x" : "y";
124
+ }
125
+ /**
126
+ * A released drag: past `SWIPE_COMMIT` of the card's width, or flung faster than `SWIPE_FLING` px/ms the same way, left
127
+ * skips the card and right goes Back (when there is a card to go back to); anything else springs back.
128
+ */
129
+ export const SWIPE_COMMIT = 0.35;
130
+ export const SWIPE_FLING = 0.5;
131
+ export function swipeOutcome(g: { dx: number; vx: number; width: number; canBack: boolean }): "skip" | "back" | "stay" {
132
+ const far = Math.abs(g.dx) > SWIPE_COMMIT * g.width;
133
+ const fling = Math.abs(g.vx) > SWIPE_FLING && Math.sign(g.vx) === Math.sign(g.dx);
134
+ if (!far && !fling) return "stay";
135
+ if (g.dx < 0) return "skip";
136
+ return g.canBack && g.dx > 0 ? "back" : "stay";
137
+ }
86
138
 
87
139
  /** Records what happened to the card on screen and moves on. */
88
140
  export function settle(s: Session, outcome: Outcome, key = s.order[s.pos]): Session {
@@ -127,7 +179,7 @@ export function sync(s: Session, live: readonly Pick<DeckCard, "key">[], settled
127
179
  order = [...rest.slice(0, at), ...back, ...rest.slice(at)];
128
180
  pos = current === undefined ? at : order.indexOf(current);
129
181
  }
130
- return { order, pos, outcomes, parked };
182
+ return { ...s, order, pos, outcomes, parked };
131
183
  }
132
184
 
133
185
  /** The progress line's numbers: the card on screen out of every card this session, and what is waiting for context. */
@@ -146,7 +198,23 @@ export function statsOf(s: Session): SessionStats {
146
198
  * anywhere presets. Paseo takes Shift+? (its shortcuts dialog) and Escape (interrupt agent) when focus is outside a
147
199
  * field, which is exactly when these fire, so the sheet is S and leaving is X.
148
200
  */
149
- export type CatchUpAction = "pick" | "own" | "send" | "skip" | "back" | "more" | "chip" | "ask-overseer" | "ask-agent" | "note" | "later" | "chat" | "rail" | "rail-up" | "rail-down" | "keys" | "leave";
201
+ export type CatchUpAction = "pick" | "own" | "send" | "skip" | "skip-workspace" | "back" | "more" | "chip" | "ask" | "note" | "later" | "chat" | "rail" | "rail-up" | "rail-down" | "keys" | "leave";
202
+ /**
203
+ * a-move-bar-action-opens-in-view: where each move-bar action opens what it opens, so its result is where the eye
204
+ * already is and never appended below the fold. `sheet`: drawn in the phone's dock, above the bar, kept above the
205
+ * keyboard. `popover`: anchored to its button on desktop. `focus`: a field or row takes focus, and DockedPane (phone)
206
+ * or the browser (desktop) scrolls it into view. `navigates`: leaves Catch up for the chat.
207
+ */
208
+ export type MovePlace = "sheet" | "popover" | "focus" | "navigates";
209
+ export const MOVE_OPENS: Readonly<Record<"more" | "later" | "note" | "chat" | "rail", { phone: MovePlace | null; desktop: MovePlace }>> = {
210
+ more: { phone: "sheet", desktop: "popover" },
211
+ later: { phone: "sheet", desktop: "popover" },
212
+ note: { phone: "focus", desktop: "focus" },
213
+ chat: { phone: "navigates", desktop: "navigates" },
214
+ // The queue rail is desktop only.
215
+ rail: { phone: null, desktop: "focus" },
216
+ };
217
+
150
218
  /** A key as this platform spells it: ⌘ on a Mac, Ctrl elsewhere (as the Send button's own hint reads). */
151
219
  export const keyLabel = (key: string, mac: boolean) => mac ? key : key.replace("⌘", "Ctrl ");
152
220
 
@@ -154,12 +222,12 @@ export const CATCH_UP_KEYS: readonly { key: string; what: string; action: CatchU
154
222
  { key: "A–H", what: "Pick an option", action: "pick", combos: ["A", "B", "C", "D", "E", "F", "G", "H"] },
155
223
  { key: "W", what: "Write your own answer", action: "own", combos: ["W"] },
156
224
  { key: "⌘↵", what: "Send", action: "send", combos: ["Cmd+Enter", "Ctrl+Enter"] },
157
- { key: "J / →", what: "Skip", action: "skip", combos: ["J", "ArrowRight"] },
225
+ { key: "J / →", what: "Skip this card (it comes back after the rest)", action: "skip", combos: ["J", "ArrowRight"] },
226
+ { key: "⇧J", what: "Skip workspace (all its cards come back after the rest)", action: "skip-workspace", combos: ["Shift+J"] },
158
227
  { key: "K / ←", what: "Back", action: "back", combos: ["K", "ArrowLeft"] },
159
228
  { key: "M", what: "More context", action: "more", combos: ["M"] },
160
229
  { key: "1–4", what: "Pick a More context ask", action: "chip", combos: ["Digit"], when: "more" },
161
- { key: "⌘↵", what: "Ask the Overseer", action: "ask-overseer", combos: ["Cmd+Enter", "Ctrl+Enter"], when: "more" },
162
- { key: "⌘⇧↵", what: "Ask the agent", action: "ask-agent", combos: ["Cmd+Shift+Enter", "Ctrl+Shift+Enter"], when: "more" },
230
+ { key: "⌘↵", what: "Ask the agent", action: "ask", combos: ["Cmd+Enter", "Ctrl+Enter"], when: "more" },
163
231
  { key: "N", what: "Add a note", action: "note", combos: ["N"] },
164
232
  { key: "L", what: "Later", action: "later", combos: ["L"] },
165
233
  { key: "O", what: "Open chat", action: "chat", combos: ["O"] },
@@ -179,8 +247,8 @@ export function catchUpKey(e: KeyPress, at: { typing: boolean; inMore: boolean;
179
247
  if (e.composing || e.alt) return null;
180
248
  const mod = e.mac ? e.meta : e.ctrl;
181
249
  if (e.key === "Enter" && mod && (e.mac ? !e.ctrl : !e.meta)) {
182
- if (e.shift) return at.moreOpen && (!at.typing || at.inMore) ? { action: "ask-agent" } : null;
183
- if (at.moreOpen && (!at.typing || at.inMore)) return { action: "ask-overseer" };
250
+ if (e.shift) return null;
251
+ if (at.moreOpen && (!at.typing || at.inMore)) return { action: "ask" };
184
252
  return at.typing ? null : { action: "send" };
185
253
  }
186
254
  if (at.typing || e.meta || e.ctrl) return null;
@@ -188,6 +256,7 @@ export function catchUpKey(e: KeyPress, at: { typing: boolean; inMore: boolean;
188
256
  if (e.key === "ArrowRight") return { action: "skip" };
189
257
  if (e.key === "ArrowLeft") return { action: "back" };
190
258
  if (at.moreOpen && /^[1-4]$/.test(e.key)) return { action: "chip", arg: e.key };
259
+ if (e.shift && e.key.toLowerCase() === "j") return { action: "skip-workspace" };
191
260
  if (e.shift || e.key.length !== 1) return null;
192
261
  const k = e.key.toLowerCase();
193
262
  if (/^[a-h]$/.test(k)) return { action: "pick", arg: k.toUpperCase() };
@@ -215,7 +284,11 @@ export const MODE = {
215
284
 
216
285
  // More context ------------------------------------------------------------------------------------------------------
217
286
 
218
- /** Who answers: the Overseer from what it already knows (wakes no one), or the card's own agent (Tom asked, so it may wake). */
287
+ /**
288
+ * Who answered. Every ask goes to the card's workspace's main agent (`agent`; asking may wake it, because the developer
289
+ * asked). `overseer` is only read from files written by 2.2.0-beta.3, which could route an ask to the Overseer: it never
290
+ * had context_reply, so those settle as `chat` on load (an-ask-goes-only-to-an-agent-that-can-answer-it).
291
+ */
219
292
  export const CONTEXT_TARGETS = ["overseer", "agent"] as const;
220
293
  export type ContextTarget = typeof CONTEXT_TARGETS[number];
221
294
  /** asking → answered (the reply came with context_reply), chat (the agent ended its turn without it: read its chat), failed. */
@@ -246,7 +319,7 @@ export const contextRequestSchema = z.object({
246
319
  target: z.enum(CONTEXT_TARGETS),
247
320
  /** The developer's words, or a suggestion's text. */
248
321
  ask: z.string().min(1).max(2000),
249
- /** The agent that should reply (the card's agent, or the Overseer once it is known). */
322
+ /** The agent that should reply: the workspace's main agent (an Overseer's id on beta.3 files). */
250
323
  askedOf: z.string().nullable(),
251
324
  state: z.enum(CONTEXT_STATES),
252
325
  answer: z.string().max(CONTEXT_ANSWER_MAX).nullable(),
@@ -284,15 +357,12 @@ export function agentContextPrompt(r: Pick<ContextRequest, "id" | "card" | "ask"
284
357
  ].join("\n");
285
358
  }
286
359
 
287
- /** The Overseer's version: it answers from what it can read without waking anyone, and doesn't forward the ask. */
288
- export function overseerContextPrompt(r: Pick<ContextRequest, "id" | "card" | "ask">, workspace: string): string {
289
- return [
290
- `The developer is catching up on what needs them and is looking at a card from ${workspace}: ${r.card}`,
291
- `They want more context before they answer: "${r.ask}"`,
292
- `Answer from what you can read (workstreams, agent_digest) without waking agents and without forwarding this to the agent. Plain words, short (under ${CONTEXT_ANSWER_MAX} characters).`,
293
- `Reply with ${REPLY_TOOL} and requestId "${r.id}" so the answer shows on their card.`,
294
- ].join("\n");
295
- }
360
+ /**
361
+ * an-ask-goes-only-to-an-agent-that-can-answer-it: the role a More context ask is routed to. context_reply is a tool
362
+ * of this role only (server/mcp-source.ts toolList: contributors, recovery agents and untracked agents such as the
363
+ * Overseer don't get it), so an ask is only ever delivered where its answer can reach the card.
364
+ */
365
+ export const CONTEXT_REPLY_ROLE = "main" as const;
296
366
 
297
367
  /** A request older than CONTEXT_KEEP_MS goes, then the oldest past CONTEXT_MAX; an asking one is kept while it is young. */
298
368
  export function pruneContext(requests: readonly ContextRequest[], now: number): ContextRequest[] {
@@ -210,8 +210,10 @@ export const overseerAskRpc = defineRpc({ name: "follow.overseer-ask", input: z.
210
210
  // asked agent's reply. The ask answers once it is recorded; the send to the agent goes through the message queue.
211
211
  export const contextAskRpc = defineRpc({ name: "follow.context-ask", input: z.strictObject({
212
212
  workspaceId: z.string().min(1).max(200).nullable(), agentId: z.string().min(1).max(200).nullable(), cardKey: z.string().min(1).max(400),
213
- card: z.string().trim().min(1).max(300), target: z.enum(CONTEXT_TARGETS), ask: z.string().trim().min(1).max(2000) }),
214
- output: z.object({ request: contextRequestSchema, fresh: z.boolean() }) });
213
+ card: z.string().trim().min(1).max(300),
214
+ /** Ignored: every ask goes to the card's workspace's main agent. Still accepted, so older callers don't break. */
215
+ target: z.enum(CONTEXT_TARGETS).optional(), ask: z.string().trim().min(1).max(2000) }),
216
+ output: z.object({ request: contextRequestSchema, fresh: z.boolean(), note: z.string().optional() }) });
215
217
  export const contextListRpc = defineRpc({ name: "follow.context-list", input: z.strictObject({ workspaceId: z.string().max(200).optional() }), output: z.object({ requests: z.array(contextRequestSchema) }) });
216
218
  /** Catch up's deck as the developer's Home would deal it (agent parity: an agent sees what the developer goes through). */
217
219
  export const catchUpDeckRpc = defineRpc({ name: "follow.catch-up-deck", input: z.strictObject({}), output: z.object({