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

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.
@@ -0,0 +1,497 @@
1
+ // Catch up: everything in Needs you, one card at a time (docs/design/catch-up.md, docs/needs-you.md#catch-up). It
2
+ // renders the same components the panel and Home use (QuestionBody, NeedsYouList, BriefCard, the permission block), so
3
+ // the answer flow is the shared one, never a fork (one-answer-flow-for-every-question). The deck's order and every
4
+ // move are the pure session in shared/catch-up.ts (context-never-blocks-the-deck, the-card-on-screen-never-moves).
5
+ import { useEffect, useMemo, useRef, useState, useSyncExternalStore, type ReactNode } from "react";
6
+ import { PanResponder, Platform, View } from "react-native";
7
+ import { Pressable, Text } from "./text";
8
+ import { useRpc } from "@getpaseo/plugin/client";
9
+ import { Icon, ScrollView, TextInput } from "@getpaseo/plugin/client/ui";
10
+ import { useQuery } from "@tanstack/react-query";
11
+ import { inboxBriefRpc } from "../shared/contracts";
12
+ import { needsYou } from "../shared/attention";
13
+ import { liveBrief } from "../shared/brief";
14
+ import { age, snoozeUntil } from "../shared/inbox";
15
+ import { laterChoices } from "../shared/row-menu";
16
+ import { errorText } from "../shared/errors";
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";
19
+ import type { Workspace } from "../shared/model";
20
+ import type { ListWorkspace } from "../shared/list";
21
+ import { bottomInset, Button, IconButton, text, type Theme } from "./kit";
22
+ import { glyphColor } from "./home-list";
23
+ import { useHomeModel, type HomeSources } from "./home-data";
24
+ import { useInbox } from "./inbox";
25
+ import { QuestionBody } from "./questions";
26
+ import { NeedsYouList } from "./needs-you";
27
+ import { BriefCard, type BriefDeps } from "./brief";
28
+ import { SummaryLine } from "./about";
29
+ import { ReferencesLine } from "./linked";
30
+ import { openRowCopy, useWorkspace } from "./workspace-data";
31
+ import { mergedColor, withAlpha, tint } from "./theme";
32
+ import { RichText } from "./rich-text";
33
+ import { DisplaySplit, PermissionBlock, useAgentLive } from "./home";
34
+ import { DockedPane } from "./docked-pane";
35
+ import { PRIMARY_FORM } from "./dock";
36
+
37
+ /** react-native-web's data attribute, so the option-letter keys find this card's radios. */
38
+ const CARD_MARK = { dataSet: { catchUpCard: "1" } } as object;
39
+ const RAIL_MIN_PX = 240;
40
+ const CARD_MIN_PX = 480;
41
+
42
+ const isMac = () => typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test((navigator as { platform?: string }).platform ?? "");
43
+
44
+ export type CatchUpDeps = { sources: HomeSources; briefDeps: BriefDeps; openHome(): void; openPanel(workspaceId: string): void };
45
+ type Nav = { openAgent(a: { agentId: string }): void; openWorkspace(a: { workspaceId: string }): void } | undefined;
46
+
47
+ /** One card's label in the queue rail and in a More context ask: "Q1 · Retry declined cards?", "Merge #255". */
48
+ export function cardLabel(card: DeckCard, w: ListWorkspace | undefined): string {
49
+ if (card.kind === "permission") return "Permission";
50
+ if (card.kind === "question") { const q = w?.questions.find(x => x.id === card.questionId); return q ? `${q.id} · ${q.title}` : card.questionId ?? "Question"; }
51
+ if (card.kind === "item" && card.item) return card.item.title;
52
+ if (card.kind === "brief") return card.s.line || card.s.word || "Ask";
53
+ return card.s.line || "Finished";
54
+ }
55
+ /** The card's own word: a workspace row's word names its first item, the card names its own. */
56
+ function cardWord(card: DeckCard): string {
57
+ if (card.kind === "permission") return "Permission";
58
+ if (card.kind === "question") return card.item?.kind === "question" && card.item.state === "stopped" ? "Agent stopped" : "Question";
59
+ if (card.kind === "finished") return "Finished";
60
+ if (card.kind === "brief") return card.s.word ?? "Ask";
61
+ switch (card.item?.kind) {
62
+ case "merge": return "Merge"; case "reviewers": return "Add reviewers"; case "send": return "Send"; case "answer": return "Your answer";
63
+ case "hold": return "Paused"; case "retry": case "capped": case "message": return "Retry"; case "check": return "Check"; case "decision": return "Blocked";
64
+ default: return card.s.word ?? "Needs you";
65
+ }
66
+ }
67
+ const cardIcon = (card: DeckCard) => card.kind === "permission" ? "ShieldQuestion" : card.kind === "question" ? "MessageCircleQuestion"
68
+ : card.item?.kind === "merge" ? "GitMerge" : card.item?.kind === "reviewers" ? "UserPlus" : card.item?.kind === "send" ? "Send" : card.kind === "finished" ? "Flag" : card.s.icon;
69
+ /** The newest ask about this card, if any. */
70
+ const askFor = (context: readonly ContextRequest[], key: string) => [...context].reverse().find(r => r.cardKey === key) ?? null;
71
+
72
+ export function CatchUp({ theme, compact, deps, navigation, onExit }: { theme: Theme; compact: boolean; deps: CatchUpDeps; navigation: Nav; onExit: () => void }) {
73
+ const c = theme.colors; const t = text(c, compact);
74
+ const { inbox, live, extras } = deps.sources;
75
+ const model = useHomeModel(deps.sources);
76
+ const rows = useInbox(inbox, () => inbox.rows());
77
+ const version = useSyncExternalStore(live.subscribe, live.version, live.version);
78
+ const context = useSyncExternalStore(extras.subscribe, extras.context, extras.context);
79
+ // Everything comes from what the client already holds: Home's model, the inbox rows, the listed workspaces.
80
+ const liveCards = useMemo(() => deckCards({ model, rows, items: id => { const w = live.get(id); return w ? needsYou(w as unknown as Workspace) : []; } }),
81
+ [model, rows, version, live]); // eslint-disable-line react-hooks/exhaustive-deps
82
+ const byKey = useMemo(() => new Map(liveCards.map(x => [x.key, x])), [liveCards]);
83
+ // A card that left Needs you keeps its last copy, so it can say "Handled elsewhere" in place.
84
+ const seen = useRef(new Map<string, DeckCard>());
85
+ for (const card of liveCards) seen.current.set(card.key, card);
86
+ const cardOf = (k: string | undefined) => k ? byKey.get(k) ?? seen.current.get(k) ?? null : null;
87
+
88
+ const [session, setSession] = useState<Session>(() => startSession(liveCards));
89
+ const settled = (id: string) => { const r = context.find(x => x.id === id); return !r || r.state !== "asking"; };
90
+ useEffect(() => { setSession(s => s.order.length || !liveCards.length ? sync(s, liveCards, settled) : startSession(liveCards)); },
91
+ [liveCards, context]); // eslint-disable-line react-hooks/exhaustive-deps
92
+ // Opening and each move read the asks once: a 0.15 host (no feed) is never stale for long, and nothing polls.
93
+ useEffect(() => { void extras.refreshContext(); }, [session.pos]); // eslint-disable-line react-hooks/exhaustive-deps
94
+
95
+ 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
+ const key = session.order[session.pos];
104
+ const card = cardOf(key);
105
+ const gone = !!key && session.outcomes[key] === "gone";
106
+ const finished = session.pos >= session.order.length;
107
+ const settle = (outcome: Outcome) => { setMore(false); setSession(s => settleCard(s, outcome)); };
108
+ const skip = () => settle("skipped");
109
+ const back = () => { setMore(false); setSession(s => ({ ...s, pos: prevPos(s) })); };
110
+ const jump = (i: number) => { setMore(false); setSession(s => ({ ...s, pos: i })); };
111
+ const w = card?.s.workspaceId ? live.get(card.s.workspaceId) : undefined;
112
+ // The next card's workspace detail is read while this one is on screen, so it paints at once (prefetch, no poll).
113
+ const nextCard = cardOf(session.order[session.pos + 1]);
114
+ useWorkspace(live, nextCard?.s.workspaceId ?? "", { enabled: !!nextCard?.s.workspaceId });
115
+
116
+ const ask = async (target: "overseer" | "agent", words: string) => {
117
+ 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 });
119
+ setMore(false);
120
+ // context-never-blocks-the-deck: the workstream waits, the deck moves on.
121
+ if (out.request.state === "asking") setSession(s => park(s, out.request.id, card.key));
122
+ };
123
+
124
+ // Desktop keys (CATCH_UP_KEYS, catchUpKey in shared/catch-up.ts): every move has one. The card's controls are found
125
+ // by the names they already carry (option letters, Later (L), Open chat (O)), so a key does exactly what a click does.
126
+ const [keysOpen, setKeysOpen] = useState(false);
127
+ useEffect(() => {
128
+ if (Platform.OS !== "web" || compact) return;
129
+ type Ev = { key: string; metaKey: boolean; ctrlKey: boolean; altKey: boolean; shiftKey: boolean; isComposing: boolean; target: unknown; preventDefault(): void };
130
+ type El = { tagName?: string; isContentEditable?: boolean; click?(): void; focus?(): void; closest?(q: string): El | null };
131
+ type Doc = { querySelector(q: string): El | null; querySelectorAll(q: string): ArrayLike<El>; activeElement?: El | null; addEventListener(t: string, f: (e: Ev) => void): void; removeEventListener(t: string, f: (e: Ev) => void): void };
132
+ const doc = (globalThis as { document?: Doc }).document; if (!doc) return;
133
+ const mac = isMac();
134
+ const inCard = (q: string) => doc.querySelector(`[data-catch-up-card] ${q}`);
135
+ const railItems = () => Array.from(doc.querySelectorAll("[data-catch-up-rail] [role=\"button\"]"));
136
+ const onKey = (e: Ev) => {
137
+ const el = e.target as El | null;
138
+ const typing = !!el && (el.tagName === "INPUT" || el.tagName === "TEXTAREA" || !!el.isContentEditable);
139
+ const hit = catchUpKey({ key: e.key, meta: e.metaKey, ctrl: e.ctrlKey, alt: e.altKey, shift: e.shiftKey, composing: e.isComposing, mac },
140
+ { typing, inMore: !!el?.closest?.("[data-catch-up-more]"), moreOpen: more, inRail: !!el?.closest?.("[data-catch-up-rail]") });
141
+ if (!hit || finished && !["back", "keys", "leave", "rail"].includes(hit.action)) return;
142
+ const click = (q: string) => { const b = doc.querySelector(q); b?.click?.(); return !!b; };
143
+ switch (hit.action) {
144
+ case "skip": skip(); break;
145
+ case "back": back(); break;
146
+ case "more": setMore(v => !v); break;
147
+ case "keys": setKeysOpen(v => !v); break;
148
+ case "leave": onExit(); break;
149
+ case "pick": inCard(`[role="radio"][aria-label^="${hit.arg}. "]`)?.click?.(); break;
150
+ case "own": inCard('[role="radio"][aria-label^="Something else"]')?.click?.(); break;
151
+ case "send": { const b = inCard('[aria-label^="Send your"]') ?? inCard('[aria-label^="Send "]'); if (!b) return; b.click?.(); break; }
152
+ 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;
154
+ case "chat": if (!click('[aria-label="Open chat (O)"]')) return; break;
155
+ 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;
158
+ case "rail": {
159
+ const items = railItems();
160
+ if (el?.closest?.("[data-catch-up-rail]")) { (el as { blur?(): void }).blur?.(); break; }
161
+ (doc.querySelector("[data-catch-up-rail] [data-catch-up-here]") ?? items[0])?.focus?.();
162
+ break;
163
+ }
164
+ case "rail-up": case "rail-down": {
165
+ const items = railItems(); const i = items.indexOf(el as El);
166
+ items[Math.max(0, Math.min(items.length - 1, i + (hit.action === "rail-up" ? -1 : 1)))]?.focus?.();
167
+ break;
168
+ }
169
+ default: return;
170
+ }
171
+ e.preventDefault();
172
+ };
173
+ doc.addEventListener("keydown", onKey);
174
+ return () => doc.removeEventListener("keydown", onKey);
175
+ });
176
+ // Phones: swipe left to skip, right to go back. Answers are never a swipe: a stray thumb must not decide anything.
177
+ 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
181
+
182
+ const stats = statsOf(session);
183
+ const total = session.order.length;
184
+ const waitingChip = stats.waiting > 0 && <View accessibilityLabel={`${MODE.waiting(stats.waiting)}. They come back as the next card when the answer is ready; Back reaches them any time.`}
185
+ style={{ flexDirection: "row", alignItems: "center", gap: 4, paddingHorizontal: 8, height: 22, borderRadius: 11, backgroundColor: c.surface2 }}>
186
+ <Icon name="Hourglass" size={11} color={c.foregroundMuted} /><Text style={[t.small, { fontWeight: "600" }]}>{MODE.waiting(stats.waiting)}</Text>
187
+ </View>;
188
+ const progress = <View style={{ gap: 6, paddingHorizontal: compact ? 16 : 20, paddingTop: compact ? 8 : 14, paddingBottom: 10 }}>
189
+ <View style={{ flexDirection: "row", alignItems: "center", flexWrap: "wrap", gap: 8, minHeight: compact ? 44 : 32 }}>
190
+ {/* Phones: the host header's ← is the only back control (DESIGN.md "One header"). */}
191
+ {!compact && <IconButton theme={theme} compact={compact} icon="X" label={`Leave ${MODE.name} (X)`} tooltip onPress={onExit} />}
192
+ <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
+ {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>}
195
+ </View>
196
+ {/* One segment per card: done in the foreground colour, skipped hollow, waiting for context amber-tinted, the current one amber. */}
197
+ {total > 0 && <View accessibilityElementsHidden importantForAccessibility="no-hide-descendants" style={{ flexDirection: "row", gap: 3 }}>
198
+ {total > 24 ? <View style={{ flex: 1, height: 4, borderRadius: 2, backgroundColor: c.border }}><View style={{ width: `${Math.round(100 * (stats.done + stats.later + stats.gone) / total)}%`, height: 4, borderRadius: 2, backgroundColor: c.foreground }} /></View>
199
+ : session.order.map((k, i) => {
200
+ const o = session.outcomes[k];
201
+ const waiting = !o && !!session.parked[groupOf(k)];
202
+ const bg = i === session.pos && !finished ? c.statusWarning : o === "done" || o === "later" ? c.foreground : o ? withAlpha(c.foreground, 0.35) : waiting ? withAlpha(c.statusWarning, 0.4) : c.border;
203
+ return <View key={k} style={{ flex: 1, height: 4, borderRadius: 2, backgroundColor: bg }} />;
204
+ })}
205
+ </View>}
206
+ </View>;
207
+
208
+ const body = finished || !card ? <Finished theme={theme} compact={compact} stats={stats} empty={!total} onHome={onExit}
209
+ onSkipped={() => setSession(s => ({ ...s, pos: s.order.findIndex(k => s.outcomes[k] === "skipped"), lapped: true }))} />
210
+ : <CardView key={card.key} card={card} w={w} theme={theme} compact={compact} deps={deps} navigation={navigation} gone={gone} more={more} setMore={setMore}
211
+ request={askFor(context, card.key)} waiting={!!session.parked[card.s.key]} onAsk={ask}
212
+ 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")} />;
214
+
215
+ const rail = <ScrollView {...({ dataSet: { catchUpRail: "1" } } as object)} contentContainerStyle={{ paddingVertical: 8 }}>
216
+ {session.order.map((k, i) => {
217
+ const x = cardOf(k); if (!x) return null;
218
+ const xw = x.s.workspaceId ? live.get(x.s.workspaceId) : undefined;
219
+ const o = session.outcomes[k]; const here = i === session.pos;
220
+ const waiting = !o && !!session.parked[x.s.key];
221
+ const firstOfWs = i === 0 || cardOf(session.order[i - 1])?.s.key !== x.s.key;
222
+ const label = cardLabel(x, xw);
223
+ return <View key={k}>
224
+ {firstOfWs && <Text numberOfLines={1} style={[t.small, { paddingHorizontal: 16, paddingTop: i ? 10 : 2, paddingBottom: 2, fontWeight: "600" }]}>{x.s.title}</Text>}
225
+ <Pressable {...({ dataSet: here ? { catchUpHere: "1" } : {} } as object)} accessibilityRole="button" accessibilityState={{ selected: here }} accessibilityLabel={`${label}${o ? `, ${o === "gone" ? "handled elsewhere" : o}` : waiting ? ", getting context" : ""}`} onPress={() => jump(i)}
226
+ style={state => ({ flexDirection: "row", alignItems: "center", gap: 8, minHeight: 32, paddingHorizontal: 16, backgroundColor: here ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent",
227
+ borderLeftWidth: 2, borderLeftColor: here ? c.statusWarning : "transparent" })}>
228
+ <Icon name={o === "done" ? "CircleCheck" : o === "skipped" ? "CornerUpRight" : o === "later" ? "AlarmClock" : o === "gone" ? "CircleCheck" : waiting ? "Hourglass" : cardIcon(x)} size={13}
229
+ color={o === "done" || o === "gone" ? c.statusSuccess : o || waiting ? c.foregroundMuted : glyphColor(x.s, c, false)} />
230
+ <Text numberOfLines={1} style={[t.meta, { flex: 1, color: o ? c.foregroundMuted : c.foreground, textDecorationLine: o === "done" ? "line-through" : "none" }]}>{label}</Text>
231
+ </Pressable>
232
+ </View>;
233
+ })}
234
+ </ScrollView>;
235
+
236
+ const main = <View style={{ flex: 1, minWidth: 0 }} {...pan.panHandlers}>{body}</View>;
237
+ return <View style={{ flex: 1, backgroundColor: c.surface0 }}>
238
+ {progress}
239
+ <View style={{ flex: 1, borderTopWidth: 1, borderTopColor: c.border }}>
240
+ {/* Desktop: the queue rail beside the card, resizable (side-panes-are-resizable); its width is the Display field catch_up_rail_fraction. */}
241
+ {keysOpen && !compact && <KeysSheet theme={theme} onClose={() => setKeysOpen(false)} />}
242
+ {!compact && total > 0 && !finished
243
+ ? <DisplaySplit theme={theme} main={main} side={rail} field="catch_up_rail_fraction" testID="follow-up-catch-up-split" label="Resize the queue"
244
+ defaultFraction={CATCH_UP_RAIL_DEFAULT} range={[CATCH_UP_RAIL_MIN, CATCH_UP_RAIL_MAX]} minSide={RAIL_MIN_PX} minMain={CARD_MIN_PX} />
245
+ : main}
246
+ </View>
247
+ </View>;
248
+ }
249
+
250
+ /** 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 }: {
252
+ 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;
255
+ }) {
256
+ const c = theme.colors; const t = text(c, compact);
257
+ const s = card.s;
258
+ const { workspace: full } = useWorkspace(deps.sources.live, s.workspaceId ?? "");
259
+ const ws = openRowCopy<ListWorkspace>(w, full);
260
+ const overseerOn = useSyncExternalStore(deps.sources.extras.subscribe, () => deps.sources.extras.overseer()?.enabled !== false, () => true);
261
+ const [laterOpen, setLaterOpen] = useState(false);
262
+ const openChat = () => { if (!navigation) return; if (s.agentId) navigation.openAgent({ agentId: s.agentId }); else if (s.workspaceId) navigation.openWorkspace({ workspaceId: s.workspaceId }); };
263
+ const word = cardWord(card);
264
+ const color = card.item?.kind === "merge" ? mergedColor(c) : card.kind === "finished" ? c.foregroundMuted : c.statusWarning;
265
+ const q = card.kind === "question" ? ws?.questions.find(x => x.id === card.questionId) ?? null : null;
266
+ const nth = sameWorkspace.indexOf(card.key);
267
+ const agentName = s.agent ?? "the agent";
268
+
269
+ const head = <View style={{ gap: 6 }}>
270
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 6 }}>
271
+ <Icon name={cardIcon(card)} size={14} color={color} />
272
+ <Text numberOfLines={1} style={[t.meta, { flex: 1 }]}>
273
+ <Text style={{ color, fontWeight: "600" }}>{word}</Text>
274
+ {[s.at ? `${age(s.at, Date.now())} ago` : "", s.project].filter(Boolean).map(x => ` · ${x}`).join("")}
275
+ {sameWorkspace.length > 1 ? ` · ${nth + 1} of ${sameWorkspace.length} here` : ""}
276
+ </Text>
277
+ </View>
278
+ <Text accessibilityRole="header" numberOfLines={2} style={compact ? t.title : [t.title, { fontSize: 17, lineHeight: 23 }]}>{s.title}{s.agent ? <Text style={{ color: c.foregroundMuted, fontWeight: "400" }}>{` › ${s.agent}`}</Text> : null}</Text>
279
+ {ws && <SummaryLine key={ws.id} workspace={ws} theme={theme} compact={compact} />}
280
+ {full && <ReferencesLine workspace={full} theme={theme} compact={compact} />}
281
+ </View>;
282
+
283
+ const goneBanner = gone && <View accessibilityRole="alert" style={{ flexDirection: "row", alignItems: "center", gap: 8, padding: 12, borderRadius: 10, backgroundColor: c.surface1, borderWidth: 1, borderColor: c.border }}>
284
+ <Icon name="CircleCheck" size={16} color={c.statusSuccess} />
285
+ <Text style={[t.body, { flex: 1 }]}>Handled elsewhere. Nothing left to do here.</Text>
286
+ <Button theme={theme} compact={compact} kind="primary" icon="ArrowRight" title="Next" onPress={onSkip} />
287
+ </View>;
288
+
289
+ const askBlock = card.kind === "question" && q && ws
290
+ ? <View style={{ gap: 8 }}>
291
+ <RichText plain style={compact ? t.ask : [t.body, { fontSize: 15, lineHeight: 21, fontWeight: "600" }]}>{`${q.id} · ${q.title}`}</RichText>
292
+ <QuestionBody key={q.id} workspace={ws} question={q} theme={theme} compact={compact} inline={false}
293
+ openAgent={id => navigation?.openAgent({ agentId: id })} onAnswered={onDone} />
294
+ </View>
295
+ : card.kind === "item" && card.item && full
296
+ ? <View style={{ borderRadius: 10, borderWidth: 1, borderColor: withAlpha(c.statusWarning, 0.45), overflow: "hidden" }}>
297
+ <NeedsYouList workspace={full} theme={theme} compact={compact} rows={[card.item]} flush actions={{ after: onDone, openAgent: openChat } as never} />
298
+ </View>
299
+ : card.kind === "permission" ? <PermissionCard s={s} theme={theme} compact={compact} onDone={onDone} />
300
+ : card.kind === "brief" ? <BriefAsk s={s} theme={theme} compact={compact} deps={deps} />
301
+ : <View style={{ gap: 10 }}>
302
+ <Text style={compact ? t.ask : [t.body, { fontSize: 15, lineHeight: 21, fontWeight: "600" }]}>{s.line || "The agent finished its turn."}</Text>
303
+ <Text style={t.meta}>Nothing to decide. Sign it off once you've read it, or reply.</Text>
304
+ <View style={{ flexDirection: "row", gap: 8 }}><Button theme={theme} compact={compact} grow={compact} kind="primary" icon="Check" title="Sign off" onPress={() => { if (s.agentId) void deps.sources.inbox.signOff([s.agentId]); onDone(); }} /></View>
305
+ </View>;
306
+
307
+ // Add context without answering: every card that isn't a question has the agent's reply box (a question has its note).
308
+ 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} />;
311
+ 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()))} />)}
314
+ </View>;
315
+
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 }}>
319
+ <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)} />
323
+ <IconButton theme={theme} compact={compact} icon="MessageSquare" label={compact ? "Open chat" : "Open chat (O)"} tooltip={!compact} disabled={!navigation} onPress={openChat} />
324
+ {!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>}
327
+ </View>;
328
+
329
+ // 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.
331
+ return <DockedPane compact={compact}
332
+ 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>}>
334
+ {goneBanner}
335
+ {head}
336
+ {contextBlock}
337
+ <View {...CARD_MARK} style={{ gap: 16 }}>{askBlock}</View>
338
+ {reply}
339
+ {moreBlock}
340
+ {!compact && laterRow}
341
+ {!compact && moves}
342
+ </DockedPane>;
343
+ }
344
+
345
+ /** 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 }) {
347
+ const c = theme.colors; const t = text(c, compact);
348
+ const who = request.target === "overseer" ? "Overseer" : agent === "the agent" ? "The agent" : agent;
349
+ const asking = request.state === "asking";
350
+ return <View accessibilityLiveRegion="polite" style={{ gap: 8, padding: compact ? 14 : 16, borderRadius: 12, borderWidth: 1, borderColor: asking ? c.border : withAlpha(c.statusSuccess, 0.4), backgroundColor: c.surface1 }}>
351
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
352
+ <Icon name={asking ? "Hourglass" : request.state === "failed" ? "CircleAlert" : "Sparkles"} size={14} color={request.state === "failed" ? c.statusDanger : c.foregroundMuted} />
353
+ <RichText plain style={[t.small, { flex: 1 }]}>{asking ? `Asked ${who === "Overseer" ? "the Overseer" : who}${waiting ? " · this comes back as the next card when it answers. You can still act on it now" : ""}` : `${who} · you asked: ${askHeadline(request.ask)}`}</RichText>
354
+ </View>
355
+ {request.state === "answered" && request.answer && <RichText selectable style={t.body}>{request.answer}</RichText>}
356
+ {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>
359
+ </View>}
360
+ {request.state === "failed" && <Text style={t.body}>{request.error ?? "The ask didn't go through. Try again, or open the chat."}</Text>}
361
+ </View>;
362
+ }
363
+
364
+ function PermissionCard({ s, theme, compact, onDone }: { s: DeckCard["s"]; theme: Theme; compact: boolean; onDone: () => void }) {
365
+ const agent = useAgentLive(s.agentId);
366
+ const t = text(theme.colors, compact);
367
+ if (!agent.permissions.length) return <Text style={t.ask}>{s.line || "Permission"}</Text>;
368
+ return <View style={{ gap: 10 }}>{agent.permissions.map(p => <PermissionBlock key={p.id} p={p} theme={theme} compact={compact} busy={false} primary
369
+ onRespond={r => { void agent.handle?.respondToPermission({ requestId: p.id, response: r as never }); onDone(); }} />)}</View>;
370
+ }
371
+
372
+ function BriefAsk({ s, theme, compact, deps }: { s: DeckCard["s"]; theme: Theme; compact: boolean; deps: CatchUpDeps }) {
373
+ const read = useRpc(inboxBriefRpc);
374
+ const brief = useQuery({ queryKey: ["follow-up", "home-brief", s.agentId, "catch-up"], queryFn: () => read({ agentId: s.agentId! }), enabled: !!s.agentId });
375
+ const b = liveBrief(brief.data?.brief);
376
+ if (!b) return <Text style={text(theme.colors, compact).ask}>{s.line}</Text>;
377
+ return <BriefCard {...({ embedded: true, item: { data: b }, theme, layout: { compact }, agentId: s.agentId, deps: deps.briefDeps } as unknown as Parameters<typeof BriefCard>[0])} />;
378
+ }
379
+
380
+ /**
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.
384
+ */
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> }) {
386
+ const c = theme.colors; const t = text(c, compact);
387
+ const [words, setWords] = useState<string>(CONTEXT_ASKS[0].text);
388
+ const [picked, setPicked] = useState<string>(CONTEXT_ASKS[0].id);
389
+ const [busy, setBusy] = useState<"overseer" | "agent" | null>(null);
390
+ const [error, setError] = useState<string | null>(null);
391
+ const send = (target: "overseer" | "agent") => {
392
+ if (!words.trim() || busy) return;
393
+ setBusy(target); setError(null);
394
+ // The words stay unless the ask is recorded.
395
+ onAsk(target, words.trim()).catch(e => setError(errorText(e))).finally(() => setBusy(null));
396
+ };
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 }}>
399
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
400
+ <Icon name="Sparkles" size={14} color={c.foreground} />
401
+ <Text style={[t.label, { flex: 1, fontWeight: "600" }]}>More context</Text>
402
+ <IconButton theme={theme} compact={compact} icon="X" label="Close more context" onPress={onClose} />
403
+ </View>
404
+ <View accessibilityRole="radiogroup" style={{ flexDirection: "row", flexWrap: "wrap", gap: 6 }}>
405
+ {CONTEXT_ASKS.map((x, i) => <Pressable key={x.id} accessibilityLabel={compact ? x.label : `${x.label} (${i + 1})`} accessibilityRole="radio" accessibilityState={{ checked: picked === x.id }} onPress={() => { setPicked(x.id); setWords(x.text); }}
406
+ style={{ minHeight: compact ? 36 : 28, justifyContent: "center", paddingHorizontal: 10, borderRadius: 999, borderWidth: 1, borderColor: picked === x.id ? c.foreground : c.border, backgroundColor: picked === x.id ? c.surface2 : "transparent" }}>
407
+ <Text style={[t.meta, { color: picked === x.id ? c.foreground : c.foregroundMuted }]}>{x.label}</Text>
408
+ </Pressable>)}
409
+ </View>
410
+ <View {...PRIMARY_FORM} style={{ gap: 10 }}>
411
+ <TextInput accessibilityLabel="What do you want to know?" placeholder="What do you want to know?" placeholderTextColor={c.foregroundMuted} value={words} multiline
412
+ 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 }} />
414
+ {!!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>}
420
+ </View>
421
+ </View>
422
+ <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>
423
+ </View>;
424
+ }
425
+
426
+ function Finished({ theme, compact, stats, empty, onHome, onSkipped }: { theme: Theme; compact: boolean; stats: ReturnType<typeof statsOf>; empty: boolean; onHome: () => void; onSkipped: () => void }) {
427
+ const c = theme.colors; const t = text(c, compact);
428
+ // "All caught up" only when it is true: a skipped or waiting card means the developer is not, so the end says so.
429
+ const caughtUp = !stats.skipped && !stats.waiting;
430
+ const icon = caughtUp ? "Check" : stats.waiting ? "Hourglass" : "CornerUpRight";
431
+ const tone = caughtUp ? c.statusSuccess : stats.waiting ? c.statusWarning : c.foregroundMuted;
432
+ const line = [stats.done && `${stats.done} done`, stats.skipped && `${stats.skipped} skipped`, stats.later && `${stats.later} for later`, stats.gone && `${stats.gone} handled elsewhere`].filter(Boolean).join(" · ");
433
+ return <ScrollView contentContainerStyle={{ flexGrow: 1, justifyContent: "center", alignItems: "center", padding: 24, gap: 14 }}>
434
+ <View style={{ width: 56, height: 56, borderRadius: 28, alignItems: "center", justifyContent: "center", backgroundColor: tint(tone, c) }}>
435
+ <Icon name={icon} size={28} color={tone} />
436
+ </View>
437
+ <Text accessibilityRole="header" style={t.headline}>{empty ? MODE.empty : caughtUp ? MODE.finished : MODE.endOfDeck}</Text>
438
+ {!!line && <Text style={[t.body, { color: c.foregroundMuted, textAlign: "center" }]}>{line}</Text>}
439
+ {stats.waiting > 0 && <Text style={[t.body, { textAlign: "center" }]}>{`${MODE.waiting(stats.waiting)}. ${stats.waiting === 1 ? "It comes" : "They come"} back here when the answer is ready; Back reaches ${stats.waiting === 1 ? "it" : "them"} now.`}</Text>}
440
+ {stats.done > 0 && <Text style={[t.meta, { textAlign: "center", maxWidth: 420 }]}>Your answers are on their way; agents pick them up as soon as they're free. Anything new shows in Needs you and the pill.</Text>}
441
+ <View style={{ flexDirection: compact ? "column" : "row", alignSelf: compact ? "stretch" : "center", gap: 8, marginTop: 6 }}>
442
+ {stats.skipped > 0 && <Button theme={theme} compact={compact} grow={compact} kind="primary" icon="CornerUpRight" title={`Catch up on ${stats.skipped} skipped`} onPress={onSkipped} />}
443
+ <Button theme={theme} compact={compact} grow={compact} kind={stats.skipped ? "secondary" : "primary"} icon="House" title="Back to Home" onPress={onHome} />
444
+ </View>
445
+ </ScrollView>;
446
+ }
447
+
448
+ /** S: the keys, from the one list the handler reads (shared/catch-up.ts). A dialog over the card; S or its X closes it. */
449
+ export function KeysSheet({ theme, onClose }: { theme: Theme; onClose: () => void }) {
450
+ const c = theme.colors; const t = text(c, false);
451
+ const row = (k: typeof CATCH_UP_KEYS[number]) => <View key={`${k.action}-${k.key}`} style={{ flexDirection: "row", gap: 10, alignItems: "center" }}>
452
+ <View style={{ minWidth: 64 }}><Text style={[t.meta, { alignSelf: "flex-start", paddingHorizontal: 6, borderRadius: 4, borderWidth: 1, borderColor: c.border, color: c.foreground, fontVariant: ["tabular-nums"] }]}>{keyLabel(k.key, isMac())}</Text></View>
453
+ <Text style={t.meta}>{k.what}</Text>
454
+ </View>;
455
+ const section = (title: string, keys: readonly typeof CATCH_UP_KEYS[number][]) => <View style={{ gap: 6 }}>
456
+ <Text style={[t.small, { fontWeight: "600" }]}>{title}</Text>{keys.map(row)}
457
+ </View>;
458
+ return <View accessibilityRole={"dialog" as never} accessibilityLabel="Catch up keys" style={{ position: "absolute", zIndex: 10, right: 20, top: 8, width: 300, padding: 16, gap: 12, borderRadius: 10, borderWidth: 1, borderColor: c.border, backgroundColor: c.surface1, shadowColor: "#000", shadowOpacity: 0.25, shadowRadius: 12 }}>
459
+ <View style={{ flexDirection: "row", alignItems: "center" }}>
460
+ <Text style={[t.label, { flex: 1, fontWeight: "600" }]}>Keys</Text>
461
+ <IconButton theme={theme} compact={false} icon="X" label="Close the keys (S)" tooltip onPress={onClose} />
462
+ </View>
463
+ {section("On a card", CATCH_UP_KEYS.filter(k => !k.when))}
464
+ {section("In More context", CATCH_UP_KEYS.filter(k => k.when === "more"))}
465
+ {section("In the queue", CATCH_UP_KEYS.filter(k => k.when === "rail"))}
466
+ </View>;
467
+ }
468
+
469
+ /** A desktop hover title on any control (react-native-web drops `title` on a Pressable; IconButton does the same). */
470
+ function Tip({ label, children }: { label: string; children: ReactNode }) {
471
+ const ref = useRef<View>(null);
472
+ useEffect(() => { if (Platform.OS === "web") (ref.current as unknown as { setAttribute?: (k: string, v: string) => void } | null)?.setAttribute?.("title", label); }, [label]);
473
+ return Platform.OS === "web" ? <View ref={ref}>{children}</View> : <>{children}</>;
474
+ }
475
+
476
+ /**
477
+ * Home's way in. It counts cards (one per thing to act on), which can differ from Needs you's workspace count beside
478
+ * it, so its accessible name and desktop tooltip say what the number is.
479
+ */
480
+ export function CatchUpButton({ theme, compact, count, onPress }: { theme: Theme; compact: boolean; count: number; onPress: () => void }): ReactNode {
481
+ if (!count) return null;
482
+ const label = MODE.buttonLabel(count);
483
+ const button = <Button theme={theme} compact={compact} grow={compact} kind="primary" icon="Layers" title={MODE.button(count)} accessibilityLabel={label} onPress={onPress} />;
484
+ return Platform.OS === "web" && !compact ? <View {...({ dataSet: { tooltip: label }, title: label } as object)}>{button}</View> : button;
485
+ }
486
+
487
+ /** Tell the agent something with or without acting: a plain message, the detail pane's reply box in a line. */
488
+ function NoteRow({ theme, compact, agentId }: { theme: Theme; compact: boolean; agentId: string }) {
489
+ const c = theme.colors;
490
+ const agent = useAgentLive(agentId);
491
+ const [words, setWords] = useState("");
492
+ return <View {...PRIMARY_FORM} style={{ flexDirection: "row", alignItems: "flex-end", gap: 8 }}>
493
+ <TextInput accessibilityLabel="Tell the agent something" placeholder="Tell the agent something" placeholderTextColor={c.foregroundMuted} value={words} onChangeText={setWords} multiline
494
+ style={{ flex: 1, minHeight: compact ? 44 : 36, paddingHorizontal: 10, paddingVertical: 8, borderRadius: 6, borderWidth: 1, borderColor: c.border, color: c.foreground, backgroundColor: c.surface0 }} />
495
+ <IconButton theme={theme} compact={compact} icon="Send" label="Send to the agent" tooltip={!compact} disabled={!words.trim()} onPress={() => { void agent.handle?.send(words.trim()); setWords(""); }} />
496
+ </View>;
497
+ }
@@ -1,13 +1,14 @@
1
1
  import type { PluginClientContext } from "@getpaseo/plugin/client";
2
- import { displayFeed, homeFeed, overseerAskRpc, overseerRestartRpc, overseerStartRpc, overseerStatusRpc, prioritiesRpc, rankNowRpc, rankStatusRpc, usageRpc } from "../shared/contracts";
2
+ import { contextAskRpc, contextListRpc, displayFeed, homeFeed, overseerAskRpc, overseerRestartRpc, overseerStartRpc, overseerStatusRpc, prioritiesRpc, rankNowRpc, rankStatusRpc, usageRpc } from "../shared/contracts";
3
3
  import { openFeed } from "./feeds";
4
- import type { RpcOutput } from "@getpaseo/plugin";
4
+ import type { RpcInput, RpcOutput } from "@getpaseo/plugin";
5
5
  import type { Priority } from "../shared/priorities";
6
6
  import { DEFAULT_SORT, isSortMode, type SortMode } from "../shared/sort";
7
7
  import { homeSortSync } from "../shared/display";
8
8
  import type { AgentLite } from "../shared/search";
9
9
  import { NO_USAGE, USAGE_POLL_MS, type Usage } from "../shared/usage";
10
10
  import { onVisible, whileVisible } from "./visibility";
11
+ import type { ContextRequest } from "../shared/catch-up";
11
12
 
12
13
  /**
13
14
  * What Home adds on top of the inbox, live and Paseo stores (1.3.0-beta.2): the sort choice, external
@@ -41,6 +42,10 @@ export function createHomeExtras(client: PluginClientContext) {
41
42
  let usage: Usage = NO_USAGE;
42
43
  let overseer: RpcOutput<typeof overseerStatusRpc> | null = null;
43
44
  let rank: RpcOutput<typeof rankStatusRpc> | null = null;
45
+ /** Catch up's More context asks: pushed on the home feed; read when Catch up opens or moves, never on a timer of their own. */
46
+ let context: ContextRequest[] = [];
47
+ const setContext = (next: ContextRequest[]) => { if (JSON.stringify(next) === JSON.stringify(context)) return false; context = next; return true; };
48
+ const readContext = async () => setContext((await client.rpc(contextListRpc, {})).requests);
44
49
  const agents = new Map<string, AgentLite>();
45
50
  let version = 0;
46
51
  let focusToken = 0; let focusPending = false;
@@ -91,7 +96,9 @@ export function createHomeExtras(client: PluginClientContext) {
91
96
  poll(PRIORITY_POLL_MS, readRank),
92
97
  poll(15_000, async () => {
93
98
  const next = await client.rpc(overseerStatusRpc, {});
94
- if (JSON.stringify(next) === JSON.stringify(overseer)) return false;
99
+ // Without the feed, an ask still open is read on the Overseer's existing poll: no poll of its own.
100
+ const asked = context.some(r => r.state === "asking") ? await readContext().catch(() => false) : false;
101
+ if (JSON.stringify(next) === JSON.stringify(overseer)) return asked;
95
102
  overseer = next; return true;
96
103
  }),
97
104
  pollUsage(),
@@ -110,6 +117,7 @@ export function createHomeExtras(client: PluginClientContext) {
110
117
  event: event => {
111
118
  if (stopped) return;
112
119
  priorities = event.priorities; rank = event.rank; overseer = event.overseer;
120
+ if (event.context) setContext(event.context);
113
121
  if (event.usage) usage = { ...event.usage, resources: usage.resources };
114
122
  if (!event.rank.running) { for (const done of rankWaiters) done(); rankWaiters.clear(); }
115
123
  // Smart Session's files can't be watched: read the meters once a minute instead.
@@ -221,6 +229,16 @@ export function createHomeExtras(client: PluginClientContext) {
221
229
  async askOverseer(text: string) { overseer = await client.rpc(overseerAskRpc, { text }); emit(); return overseer; },
222
230
  /** Settings → Agents changed: a new Overseer on the configured agent, handed the old one's last steps. */
223
231
  async restartOverseer() { overseer = await client.rpc(overseerRestartRpc, {}); emit(); return overseer; },
232
+ /** Catch up's More context asks and their answers. */
233
+ context: () => context,
234
+ /** Reads the asks once (Catch up opening or moving on, so a 0.15 host or a dropped feed is never stale for long). */
235
+ async refreshContext() { if (await readContext().catch(() => false)) emit(); },
236
+ /** Asks the Overseer or the card's agent; the ask shows at once, its answer arrives on the feed. */
237
+ async askContext(input: RpcInput<typeof contextAskRpc>) {
238
+ const out = await client.rpc(contextAskRpc, input);
239
+ setContext([...context.filter(r => r.id !== out.request.id), out.request]); emit();
240
+ return out;
241
+ },
224
242
  agents: () => [...agents.values()],
225
243
  /** Bumped by ⌘K "Follow-up: Search" and the search key; the visible search field focuses when it changes. */
226
244
  focusToken: () => focusToken,
package/client/home.tsx CHANGED
@@ -36,6 +36,8 @@ import { withAlpha, isLight, mergedColor, type Colors } from "./theme";
36
36
  import { UpdateNotice, VersionMark } from "./updates";
37
37
  import { WhatsNewGate } from "./release-notes";
38
38
  import { ViewSync } from "./view-store";
39
+ import { CatchUp, CatchUpButton } from "./catch-up";
40
+ import { deckCards } from "../shared/catch-up";
39
41
  import { ResizableSplit } from "./split";
40
42
  import type { SearchKey } from "./search-key";
41
43
 
@@ -63,6 +65,8 @@ export type HomeDeps = {
63
65
  /** Docks the workspace's own panel in its explorer column. */
64
66
  openPanel(workspaceId: string): void;
65
67
  openLog(): void;
68
+ /** Catch up: Needs you one card at a time (`?view=catchup`). */
69
+ openCatchUp?(): void;
66
70
  openHome(): void;
67
71
  /** Phones: open one Home item as its own screen, so the host's ← (and Android back) returns to the list. */
68
72
  openItem?(key: string, extra?: { question?: string }): void;
@@ -97,7 +101,7 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
97
101
  const omnibox = useOmnibox(model, deps.sources);
98
102
  const searchKey = deps.searchKey;
99
103
  const anywhereKey = useSyncExternalStore(searchKey?.subscribe ?? noSubscribe, searchKey?.label ?? noLabel, searchKey?.label ?? noLabel);
100
- useSlashToFocus(omnibox, params.view !== "log");
104
+ useSlashToFocus(omnibox, params.view !== "log" && params.view !== "catchup");
101
105
  const [filter, setFilter] = useState<HomeGroupId | null>(null);
102
106
  const [selected, setSelected] = useState<string | null>(() => params.item ?? (params.select ? `agent:${params.select}` : null));
103
107
  const openAgentRow = useMemo(() => navigation ? (row: InboxRow) => navigation.openAgent({ agentId: row.agentId }) : undefined, [navigation]);
@@ -118,6 +122,8 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
118
122
  const current = selected ? model.byKey.get(selected) ?? (selected.startsWith("agent:") ? [...model.byKey.values()].find(x => x.agentId === selected.slice(6)) ?? null : null) : null;
119
123
  const tracked = useSyncExternalStore(deps.sources.live.subscribe, deps.sources.live.version, deps.sources.live.version);
120
124
  const rows = useInbox(inbox, () => inbox.rows());
125
+ // Go through's count is its cards (one per ask), the same deck the mode opens on.
126
+ const deckSize = useMemo(() => deckCards({ model, rows, items: id => { const w = deps.sources.live.get(id); return w ? needsYou(w as never) : []; } }).length, [model, rows, tracked, deps.sources.live]);
121
127
  const pane = useMemo(() => briefPane({ model, rows, tracked: deps.sources.live.all(), now: Date.now() }), [model, rows, tracked, deps.sources.live]);
122
128
  const rank = useSyncExternalStore(deps.sources.extras.subscribe, deps.sources.extras.rank, deps.sources.extras.rank);
123
129
  const overseerStatus = useSyncExternalStore(deps.sources.extras.subscribe, deps.sources.extras.overseer, deps.sources.extras.overseer);
@@ -185,13 +191,17 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
185
191
  <WhatsNewGate surface="home" theme={theme} compact={compact} />
186
192
  <ToastHost theme={theme} compact={compact} />
187
193
  </>;
194
+ if (params.view === "catchup") return <View style={{ flex: 1 }}>
195
+ <CatchUp theme={theme} compact={compact} deps={{ sources: deps.sources, briefDeps: deps.briefDeps, openHome: deps.openHome, openPanel: deps.openPanel }} navigation={navigation as never} onExit={deps.openHome} />
196
+ {updateSheets}
197
+ </View>;
188
198
  if (params.view === "log") return <LogView theme={theme} compact={compact} sources={deps.sources} onHome={deps.openHome} onOpen={key => { setSelected(key); deps.openHome(); }} />;
189
199
 
190
200
  const detail = selected === OVERSEER_KEY && overseer
191
201
  ? <OverseerPane theme={theme} compact={compact} o={overseer} focus={replyFocus} pending={pendingAsk} agentId={overseerStatus?.agentId ?? null} model={overseerStatus?.model ?? null} restartWith={overseerStatus?.restartWith ?? null} configured={overseerStatus?.configured ?? null} deps={deps} navigation={navigation} onBack={compact && !route ? () => setSelected(null) : undefined} />
192
202
  : current
193
203
  ? <DetailPane key={current.key} s={current} model={model} theme={theme} compact={compact} deps={deps} openFull={openFull} signOffNext={signOffNext} ask={ask?.key === current.key ? ask : null} onBack={compact && !route ? () => setSelected(null) : undefined} />
194
- : <BriefPane theme={theme} compact={compact} pane={pane} onSelect={key => route ? route(key) : setSelected(key)} openLog={deps.openLog} sources={deps.sources} />;
204
+ : <BriefPane theme={theme} compact={compact} pane={pane} catchUp={deps.openCatchUp} deckSize={deckSize} onSelect={key => route ? route(key) : setSelected(key)} openLog={deps.openLog} sources={deps.sources} />;
195
205
  // Nothing followed at all: no sort, no meters, just the empty state and its action.
196
206
  const nothing = model.groups.every(g => !g.items.length);
197
207
  // Enter on a row: its chat, as Open full does. The brief has nothing to open; the Overseer opens once it runs.
@@ -230,6 +240,7 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
230
240
  {/* No title row on phones. The strip has the row to itself, so every chip is reachable (Q51: "Sending" pushed
231
241
  Waiting, Quiet and Later behind the version); the version is at the end of the list. */}
232
242
  <StatusStrip theme={theme} model={model} filter={filter} onFilter={setFilter} touch dense />
243
+ {model.needs > 0 && deps.openCatchUp && <View style={{ paddingHorizontal: 16 }}><CatchUpButton theme={theme} compact count={deckSize} onPress={deps.openCatchUp} /></View>}
233
244
  {updateNotice}
234
245
  {model.needs === 0 && <SetupOffer theme={theme} compact view={props.onboarding} />}
235
246
  </View> : updateNotice} />;
@@ -253,24 +264,32 @@ function HomeBody(props: PluginScreenProps & { deps: HomeDeps; onboarding: Onboa
253
264
  * (side-panes-are-resizable). The pane's share is the Display setting `home_detail_fraction`, so set_display reaches it.
254
265
  */
255
266
  function HomeSplit({ theme, main, detail }: { theme: Theme; main: ReactNode; detail: ReactNode }) {
267
+ return <DisplaySplit theme={theme} main={main} side={detail} field="home_detail_fraction" testID="follow-up-home-split" label="Resize the detail pane"
268
+ defaultFraction={HOME_DETAIL_DEFAULT} range={[HOME_DETAIL_MIN, HOME_DETAIL_MAX]} minSide={HOME_DETAIL_MIN_PX} minMain={HOME_LIST_MIN_PX} />;
269
+ }
270
+
271
+ /** A resizable side pane whose share is a Display field (Home's detail pane, Catch up's queue rail). */
272
+ export function DisplaySplit({ theme, main, side, field, defaultFraction, range, minSide, minMain, label, testID }: {
273
+ theme: Theme; main: ReactNode; side: ReactNode; field: "home_detail_fraction" | "catch_up_rail_fraction";
274
+ defaultFraction: number; range: [number, number]; minSide: number; minMain: number; label: string; testID: string;
275
+ }) {
256
276
  const settings = useSettings(displayPreferences);
257
277
  const readDisplay = useRpc(displayRpc.read); const saveDisplay = useRpc(displayRpc.write);
258
278
  const toast = useToast();
259
279
  // The host's settings read paints first; the Display feed (an agent's set_display, another device) and this
260
280
  // device's own saves replace it. undefined = never set (the default); null = nothing pushed yet.
261
281
  const [pushed, setPushed] = useState<number | undefined | null>(null);
262
- useEffect(() => subscribeDisplay(values => setPushed(values.home_detail_fraction)), []);
263
- const fraction = pushed !== null ? pushed : settings.status === "ready" ? settings.values.home_detail_fraction : undefined;
282
+ useEffect(() => subscribeDisplay(values => setPushed(values[field])), [field]);
283
+ const fraction = pushed !== null ? pushed : settings.status === "ready" ? settings.values[field] : undefined;
264
284
  const commit = (next: number) => {
265
285
  setPushed(next);
266
286
  const client: DisplayClient = { rpc: (contract, input) => (contract as unknown) === displayRpc.read ? readDisplay(input as never) : saveDisplay(input as never) };
267
- void writeDisplay(client, { home_detail_fraction: next })
268
- .then(ok => { if (!ok) toast.error("Couldn't save the pane's width. It resets when Home reopens."); })
287
+ void writeDisplay(client, { [field]: next })
288
+ .then(ok => { if (!ok) toast.error("Couldn't save the pane's width. It resets when this screen reopens."); })
269
289
  .catch(e => toast.error(errorText(e)));
270
290
  };
271
- return <ResizableSplit theme={theme} main={main} side={detail} testID="follow-up-home-split" label="Resize the detail pane"
272
- fraction={fraction} defaultFraction={HOME_DETAIL_DEFAULT} range={[HOME_DETAIL_MIN, HOME_DETAIL_MAX]}
273
- minSide={HOME_DETAIL_MIN_PX} minMain={HOME_LIST_MIN_PX} onCommit={commit} />;
291
+ return <ResizableSplit theme={theme} main={main} side={side} testID={testID} label={label}
292
+ fraction={fraction} defaultFraction={defaultFraction} range={range} minSide={minSide} minMain={minMain} onCommit={commit} />;
274
293
  }
275
294
 
276
295
  /** The right pane is never narrower than this, and the list keeps at least HOME_LIST_MIN_PX (its rows keep their reason line). */
@@ -294,7 +313,7 @@ function ListHeader({ theme, compact, onSettings }: { theme: Theme; compact: boo
294
313
  type Permission = { id: string; name: string; title?: string; description?: string; detail?: Record<string, unknown>; input?: Record<string, unknown>; actions?: { id: string; label: string; behavior: "allow" | "deny"; variant?: string }[] };
295
314
 
296
315
  /** The selected agent's live state: pending permissions and status, from its own handle (never the whole list). */
297
- function useAgentLive(agentId: string | null) {
316
+ export function useAgentLive(agentId: string | null) {
298
317
  const paseo = usePaseo();
299
318
  const handle = useMemo(() => agentId ? paseo.agents.ref(agentId) : null, [paseo, agentId]);
300
319
  const [, bump] = useState(0);
@@ -658,7 +677,7 @@ function permissionText(p: Permission): string {
658
677
  return typeof v === "string" ? v : p.description ?? "";
659
678
  }
660
679
 
661
- function PermissionBlock({ p, theme, compact, busy, primary, onRespond }: { p: Permission; theme: Theme; compact: boolean; busy: boolean; primary: boolean; onRespond: (r: { behavior: "allow" | "deny"; selectedActionId?: string; message?: string }) => void }) {
680
+ export function PermissionBlock({ p, theme, compact, busy, primary, onRespond }: { p: Permission; theme: Theme; compact: boolean; busy: boolean; primary: boolean; onRespond: (r: { behavior: "allow" | "deny"; selectedActionId?: string; message?: string }) => void }) {
662
681
  const c = theme.colors; const t = text(c, compact);
663
682
  const command = permissionText(p);
664
683
  // Provider-defined choices ("Always for this session") show as extra secondaries; Allow and Deny always exist.
@@ -728,7 +747,7 @@ function ReplyBox({ theme, compact, agentName, onSend, placeholder = "Answer in
728
747
 
729
748
  // ---------- brief pane ----------
730
749
 
731
- function BriefPane({ theme, compact, pane, onSelect, openLog, sources }: { theme: Theme; compact: boolean; pane: ReturnType<typeof briefPane>; onSelect: (key: string) => void; openLog: () => void; sources: HomeSources }) {
750
+ function BriefPane({ theme, compact, pane, onSelect, openLog, sources, catchUp, deckSize = 0 }: { theme: Theme; compact: boolean; pane: ReturnType<typeof briefPane>; onSelect: (key: string) => void; openLog: () => void; sources: HomeSources; catchUp?: () => void; deckSize?: number }) {
732
751
  const c = theme.colors; const t = text(c, compact);
733
752
  useTick(30_000);
734
753
  const now = Date.now();
@@ -745,7 +764,7 @@ function BriefPane({ theme, compact, pane, onSelect, openLog, sources }: { theme
745
764
  {!compact && <Text style={t.meta}>{date} · {time}</Text>}
746
765
  <Text accessibilityRole="header" style={t.headline}>{pane.headline}</Text>
747
766
  {compact && <Text style={t.meta}>Morning brief · {date} · {time}</Text>}
748
- {pane.first && <Button theme={theme} compact={compact} grow={compact} kind="primary" icon="ArrowRight" title={`Open ${pane.first.title.length > 40 ? `${pane.first.title.slice(0, 40)}…` : pane.first.title}`} onPress={() => onSelect(pane.first!.key)} />}
767
+ {catchUp && deckSize > 0 ? <CatchUpButton theme={theme} compact={compact} count={deckSize} onPress={catchUp} /> : pane.first && <Button theme={theme} compact={compact} grow={compact} kind="primary" icon="ArrowRight" title={`Open ${pane.first.title.length > 40 ? `${pane.first.title.slice(0, 40)}…` : pane.first.title}`} onPress={() => onSelect(pane.first!.key)} />}
749
768
  {!!pane.waiting && <Text style={t.body}><Text style={{ color: c.foregroundMuted }}>Waiting on others: </Text>{pane.waiting}</Text>}
750
769
  <Text style={t.body}><Text style={{ color: c.foregroundMuted }}>Cleared since {sinceLabel(now)}: </Text>{pane.cleared ?? "nothing yet"}.</Text>
751
770
 
package/index.client.tsx CHANGED
@@ -6,6 +6,7 @@ import { openExternalUrl, type PluginClientContext, type PluginButtonRegistratio
6
6
  import { Dimensions } from "react-native";
7
7
  import { FollowSettings } from "./client/settings";
8
8
  import { FollowHome, HOME_SCREEN } from "./client/home";
9
+ import { MODE } from "./shared/catch-up";
9
10
  import { FollowPanel } from "./client/panel";
10
11
  import { createPaseoWorkspaces } from "./client/home-data";
11
12
  import { createHomeExtras } from "./client/home-view";
@@ -54,6 +55,7 @@ export default function contribute(host: PluginClientContext) {
54
55
  const openSettings = (category?: string) => { if (isCategory(category)) writeCategory(category); client.openSettings("projects"); };
55
56
  const openOverview = () => client.openScreen({ screenId: OVERVIEW });
56
57
  const openLog = () => client.openScreen({ screenId: OVERVIEW, params: { view: "log" } });
58
+ const openCatchUp = () => client.openScreen({ screenId: OVERVIEW, params: { view: "catchup", at: "0", n: String(Date.now()) } });
57
59
  const openLarge = (workspaceId: string) => client.openScreen({ screenId: LARGE_SCREEN, params: { workspaceId } });
58
60
  // "Set up Follow-up again" (Settings and ⌘K): restart the flow on the server, then open Home, which shows it.
59
61
  // `resume`: setup is already in progress, so open it where it was left instead of from the top.
@@ -91,7 +93,7 @@ export default function contribute(host: PluginClientContext) {
91
93
  noteDone: (agentId, cancel) => inbox.noteDone(agentId, cancel), endDone: agentId => inbox.endDone(agentId),
92
94
  };
93
95
  const openItem = (key: string, extra: { question?: string } = {}) => client.openScreen({ screenId: OVERVIEW, params: { item: key, ...(extra.question ? { question: extra.question } : {}) } });
94
- const homeDeps = { sources, openSettings, openPanel, openLog, openHome: openOverview, openItem, briefDeps, searchKey };
96
+ const homeDeps = { sources, openSettings, openPanel, openLog, openCatchUp, openHome: openOverview, openItem, briefDeps, searchKey };
95
97
  const Overview = (props: PluginScreenProps) => <><FollowHome {...props} deps={homeDeps} />{reportHost(props)}</>;
96
98
  const Panel = (props: PluginWorkspacePanelProps) => <><FollowPanel {...props} openSettings={openSettings} openOverview={openOverview} openLarge={openLarge} inbox={inbox} live={store} briefDeps={briefDeps} sources={sources} />{reportHost(props)}</>;
97
99
  const Large = (props: PluginScreenProps) => <FollowLarge {...props} openSettings={openSettings} openOverview={openOverview} live={store} />;
@@ -112,6 +114,7 @@ export default function contribute(host: PluginClientContext) {
112
114
  // The dialog lives in Follow-up's surfaces: open the panel, which mounts a host, then ask.
113
115
  openPanel(PANEL, { location: location() }); setTimeout(() => openRename({ workspaceId: workspace.id }), 0); } }),
114
116
  client.addCommandCenterItem({ id: "follow-up-overview", title: "Follow-up: Home", icon: "House", keywords: ["home", "workspaces", "needs you", "inbox", "attention", "brief", "overview"], context: "global", onSelect({ openScreen }) { openScreen({ screenId: OVERVIEW }); } }),
117
+ client.addCommandCenterItem({ id: "follow-up-catch-up", title: MODE.command, icon: "Layers", keywords: ["catch up", "inbox", "needs you", "triage", "answer", "questions", "one by one"], context: "global", onSelect() { openCatchUp(); } }),
115
118
  client.addCommandCenterItem({ id: "follow-up-log", title: "Follow-up: Done while you were away", icon: "History", keywords: ["log", "overnight", "away", "repairs", "activity"], context: "global", onSelect({ openScreen }) { openScreen({ screenId: OVERVIEW, params: { view: "log" } }); } }),
116
119
  client.addCommandCenterItem({ id: "follow-up-settings", title: "Follow-up: settings", icon: "Settings", keywords: ["default", "following", "project", "display", "sidebar", "pill", "header", "inbox", "questions"], context: "global", onSelect() { openSettings(); } }),
117
120
  // "Set up Follow-up again": the setup flow from the top, on Home.
package/index.server.ts CHANGED
@@ -331,6 +331,12 @@ export default function contribute(server: PluginServerContext) {
331
331
  // No card of its own: one that didn't go out (Failed, or Queued past MESSAGE_STUCK_MS) shows in its workspace's
332
332
  // Needs you with Retry and Cancel, and leaves it once sent or cancelled.
333
333
  async project(item) {
334
+ // A More context ask rides the queue under its request id: the send's settle is its delivery, a send that can't
335
+ // happen fails it (context-never-blocks-the-deck: the card comes back either way).
336
+ if (item.messageId?.startsWith("ctx-")) {
337
+ if (item.state === "sent") await contextRequests.delivered(item.messageId, item.settledAt ?? new Date().toISOString());
338
+ else if (item.state === "cancelled" || item.state === "failed" && item.gone) await contextRequests.fail(item.messageId, item.reason ?? "The ask couldn't reach the agent.");
339
+ }
334
340
  const w = (await store.snapshot()).workspaces.find(w => w.id === item.key && w.enable_tracking && !w.archived);
335
341
  if (!w) return;
336
342
  const has = w.undelivered?.find(m => m.id === item.id);
@@ -478,6 +484,17 @@ export default function contribute(server: PluginServerContext) {
478
484
  await engine.adoptBatches().catch(error => console.warn(`[follow-up] couldn't move batches onto the queue: ${error instanceof Error ? error.message : String(error)}`));
479
485
  await inbox.adoptOutbox().catch(error => console.warn(`[follow-up] couldn't move the answer outbox onto the queue: ${error instanceof Error ? error.message : String(error)}`));
480
486
  queue.start();
487
+ // An ask still open from before a restart is re-derived from the queue's record and the cached agent list: nothing
488
+ // is woken, and nothing waits on it (context-never-blocks-the-deck).
489
+ void (async () => {
490
+ const rows = await gateway.directory.read().catch(() => null);
491
+ const status = new Map((rows?.agents ?? []).map(({ agent }) => [agent.id, agent.status]));
492
+ await contextRequests.reconcile(r => {
493
+ const item = r.target === "agent" ? queue.get(`message:${r.askedOf}:${r.id}`) : null;
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
+ idle: rows ? status.get(r.askedOf!) !== "running" : false };
496
+ });
497
+ })().catch(error => console.warn(`[follow-up] couldn't re-check open context asks: ${error instanceof Error ? error.message : String(error)}`));
481
498
  })().catch(() => { loadError = "Follow-up could not start. Check its saved state and worker lock."; });
482
499
  for (const file of [store, contextRequests.persist, reviewerStore.persist, agentSettings.persist, prWorkflow.persist, inbox.store.persist]) file.health = writeHealth;
483
500
  const requireReady = async () => { if (waiting) throw new Error(waiting); await ready; if (loadError || stopped) throw new Error(loadError ?? "Follow-up is stopping"); };
@@ -944,18 +961,19 @@ export default function contribute(server: PluginServerContext) {
944
961
  const actor = actorOf(context);
945
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.");
946
963
  if (input.target === "agent" && !input.agentId) throw new Error("This card has no agent to ask. Ask the Overseer instead.");
947
- const out = await contextRequests.ask(input, actorBy(actor), input.target === "agent" ? input.agentId : (await overseerStatus().catch(() => null))?.agentId ?? null);
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);
948
966
  if (!out.fresh) return out;
949
967
  const r = out.request;
950
- if (input.target === "agent") enqueueMessage(input.agentId!, agentContextPrompt(r), r.id, "developer");
968
+ if (input.target === "agent") enqueueMessage(input.agentId!, agentContextPrompt(r), r.id, actorBy(actor));
951
969
  else {
952
970
  const paseo = (context as { paseo?: unknown }).paseo;
953
- const workspace = input.workspaceId ? (await gateway.directory.read().catch(() => null))?.workspaces.find(w => w.id === input.workspaceId)?.name ?? "a workspace" : "a workspace";
954
971
  void (async () => {
955
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";
956
974
  if (!await overseerOn()) throw new Error("The Overseer is off. Turn it on in Settings → Agents, or ask the agent.");
957
975
  const s = await overseer!.ask(paseo as unknown as OverseerPaseo, overseerContextPrompt(r, workspace));
958
- if (s.agentId) await contextRequests.setAskedOf(r.id, s.agentId);
976
+ if (s.agentId) { await contextRequests.setAskedOf(r.id, s.agentId); await contextRequests.delivered(r.id, new Date().toISOString()); }
959
977
  } catch (error) { await contextRequests.fail(r.id, error instanceof Error ? error.message : String(error)); }
960
978
  })();
961
979
  }
@@ -1505,7 +1523,6 @@ export default function contribute(server: PluginServerContext) {
1505
1523
  // handlers below read the patched rows.
1506
1524
  server.on("agent.turn_started", async event => gateway.directory.turnStarted(event.agent, event.turnId)),
1507
1525
  server.on("agent.turn_ended", async event => gateway.directory.turnEnded(event.agent, event.outcome)),
1508
- server.on("agent.turn_started", async event => contextRequests.turnStarted(event.agent.id)),
1509
1526
  server.on("agent.turn_ended", async event => contextRequests.turnEnded(event.agent.id)),
1510
1527
  server.on("agent.permission_requested", async event => gateway.directory.permissionRequested(event.agent.id, event.request as { id?: string })),
1511
1528
  server.on("agent.permission_resolved", async event => gateway.directory.permissionResolved(event.agent.id, event.requestId)),
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.2",
4
+ "version": "2.2.0-beta.3",
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": [
@@ -22,7 +22,7 @@ import { DISPLAY_TOOLS, RPC_TOOLS, type RpcTool } from "./agent-parity";
22
22
  import { waitNote, type WaitStatus } from "../shared/wait";
23
23
  import { reportInputSchema } from "./report-issue";
24
24
  import type { RenameStatus } from "../shared/rename";
25
- import { DISPLAY_KEYS, displayPreferences, HOME_DETAIL_DEFAULT } from "../shared/display";
25
+ import { DISPLAY_KEYS, displayPreferences, HOME_DETAIL_DEFAULT, CATCH_UP_RAIL_DEFAULT } from "../shared/display";
26
26
  import { DEFAULT_SEARCH_SHORTCUT, SEARCH_SHORTCUTS } from "../shared/search-key";
27
27
  import { DEFAULT_SORT, SORT_MODES } from "../shared/sort";
28
28
 
@@ -326,14 +326,14 @@ export class AgentActions {
326
326
  private async displayTool(caller: string, tool: "display_settings" | "set_display", args: Record<string, any>) {
327
327
  if (!this.d.display) throw new Error(`${tool} isn't available in this Follow-up.`);
328
328
  const current = await this.d.display.read();
329
- if (tool === "display_settings") return { values: { home_sort: DEFAULT_SORT, home_detail_fraction: HOME_DETAIL_DEFAULT, search_shortcut: DEFAULT_SEARCH_SHORTCUT, ...current.values }, sorts: SORT_MODES, search_shortcuts: SEARCH_SHORTCUTS, change: "set_display changes these, only when the developer asked. home_sort orders Home and the sidebar view. home_detail_fraction is the share of Home's width its right pane takes (0.2 to 0.8, default 0.42). search_shortcut is the key that opens Home's search from anywhere: mod-slash (⌘/ or Ctrl+/, the default), mod-shift-k, mod-shift-h or none." };
329
+ if (tool === "display_settings") return { values: { home_sort: DEFAULT_SORT, home_detail_fraction: HOME_DETAIL_DEFAULT, catch_up_rail_fraction: CATCH_UP_RAIL_DEFAULT, search_shortcut: DEFAULT_SEARCH_SHORTCUT, ...current.values }, sorts: SORT_MODES, search_shortcuts: SEARCH_SHORTCUTS, change: "set_display changes these, only when the developer asked. home_sort orders Home and the sidebar view. home_detail_fraction is the share of Home's width its right pane takes (0.2 to 0.8, default 0.42). catch_up_rail_fraction is the share of the Catch up screen its queue rail takes on a desktop (0.16 to 0.5, default 0.28). search_shortcut is the key that opens Home's search from anywhere: mod-slash (⌘/ or Ctrl+/, the default), mod-shift-k, mod-shift-h or none." };
330
330
  const values = args.values as Record<string, boolean | string | number> | undefined;
331
331
  if (!values || !Object.keys(values).length) throw new Error("set_display: give values, e.g. { enable_trust_bypass: false } or { home_sort: \"recent\" }. display_settings lists them.");
332
332
  const unknown = Object.keys(values).filter(k => !DISPLAY_KEYS.includes(k));
333
333
  if (unknown.length) throw new Error(`set_display: unknown setting ${unknown.join(", ")}. display_settings lists them.`);
334
334
  const parsed = displayPreferences.schema.safeParse({ ...current.values, ...values });
335
335
  if (!parsed.success) throw new Error(`set_display: ${parsed.error.issues.map(i => `${i.path.join(".")}: ${i.message}`).join("; ")}`);
336
- const was = (k: string) => current.values[k] ?? (k === "home_sort" ? DEFAULT_SORT : k === "home_detail_fraction" ? HOME_DETAIL_DEFAULT : k === "search_shortcut" ? DEFAULT_SEARCH_SHORTCUT : undefined);
336
+ const was = (k: string) => current.values[k] ?? (k === "home_sort" ? DEFAULT_SORT : k === "home_detail_fraction" ? HOME_DETAIL_DEFAULT : k === "catch_up_rail_fraction" ? CATCH_UP_RAIL_DEFAULT : k === "search_shortcut" ? DEFAULT_SEARCH_SHORTCUT : undefined);
337
337
  const changes = Object.entries(values).filter(([k, v]) => was(k) !== v).map(([key, to]) => ({ key, from: was(key), to }));
338
338
  const planId = changes.length ? this.plan(caller, "set_display", async () => {
339
339
  const now = await this.d.display!.read();
@@ -179,6 +179,8 @@ export const PARITY: Record<string, { tools: readonly string[]; note?: string }
179
179
  "follow.overseer-restart": { tools: ["overseer_restart"] },
180
180
  "follow.overseer-ask": { tools: ["overseer_ask"] },
181
181
  "follow.inbox-list": { tools: ["inbox_list"] },
182
+ "follow.context-ask": { tools: ["ask_context"] },
183
+ "follow.context-list": { tools: ["context_requests"] },
182
184
  "follow.inbox-brief": { tools: ["inbox_brief"] },
183
185
  "follow.queue-action": { tools: ["queue_action"] },
184
186
  "follow.inbox-act": { tools: ["sign_off", "snooze", "set_finish_flags", "inbox_act"] },
@@ -2,7 +2,7 @@ import { readFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { WriteBehind } from "./write-behind";
5
- import { CONTEXT_ANSWER_MAX, contextFileSchema, pruneContext, type ContextFile, type ContextRequest, type ContextTarget } from "../shared/catch-up";
5
+ import { CONTEXT_ANSWER_MAX, contextFileSchema, plainAnswer, pruneContext, type ContextFile, type ContextRequest, type ContextTarget } from "../shared/catch-up";
6
6
 
7
7
  export const CONTEXT_FILE = "context.json";
8
8
 
@@ -51,7 +51,7 @@ export class ContextRequests {
51
51
  if (open) return { request: open, fresh: false };
52
52
  const request: ContextRequest = {
53
53
  id: `ctx-${randomUUID()}`, ...input, askedOf, state: "asking", answer: null, error: null,
54
- askedAt: new Date(this.now()).toISOString(), settledAt: null, by,
54
+ askedAt: new Date(this.now()).toISOString(), settledAt: null, deliveredAt: null, by,
55
55
  };
56
56
  this.save([...requests, request]);
57
57
  return { request, fresh: true };
@@ -80,7 +80,7 @@ export class ContextRequests {
80
80
  const r = (await this.list()).find(x => x.id === id);
81
81
  if (!r) throw new Error(`No open context request ${id}. It may have expired; the developer can ask again.`);
82
82
  if (r.askedOf !== caller) throw new Error("This context request was asked of another agent.");
83
- const answer = text.trim().slice(0, CONTEXT_ANSWER_MAX);
83
+ const answer = plainAnswer(text).slice(0, CONTEXT_ANSWER_MAX);
84
84
  if (!answer) throw new Error("context_reply: give text, the explanation for the developer.");
85
85
  return (await this.update(id, x => ({ ...x, state: "answered", answer, error: null, settledAt: new Date(this.now()).toISOString() })))!;
86
86
  }
@@ -90,22 +90,35 @@ export class ContextRequests {
90
90
  return this.update(id, r => r.state !== "asking" ? r : { ...r, state: "failed", error: error.slice(0, 500), settledAt: new Date(this.now()).toISOString() });
91
91
  }
92
92
 
93
+ /** The ask reached its agent (the queue sent it; the Overseer took it). Earlier deliveries win: it is the first. */
94
+ delivered(id: string, at: string): Promise<ContextRequest | null> {
95
+ return this.update(id, r => r.state !== "asking" || r.deliveredAt ? r : { ...r, deliveredAt: at });
96
+ }
97
+
93
98
  /**
94
- * An asked agent's turn ended. If it started after the ask and the agent didn't reply with the tool, the answer is in
95
- * its chat: the card comes back with Open chat. Costs a lookup in a list of at most CONTEXT_MAX; no reads.
99
+ * An agent's turn ended. Every ask it owes that was delivered before now and still has no context_reply settles as
100
+ * `chat`: the answer is in its chat, and the card comes back with Open chat. Delivery, not the turn's start, is the
101
+ * test, so a prompt steered into a turn already running counts, and nothing in memory is lost on a restart. Costs a
102
+ * lookup in a list of at most CONTEXT_MAX; no reads.
96
103
  */
97
- private started = new Map<string, number>();
98
- /** An agent's turn started: remembered only while that agent owes a reply. */
99
- turnStarted(agentId: string): void {
100
- if (this.value?.requests.some(r => r.state === "asking" && r.askedOf === agentId)) this.started.set(agentId, this.now());
101
- }
102
104
  async turnEnded(agentId: string): Promise<void> {
103
- const turnStartedAt = this.started.get(agentId) ?? null;
104
- this.started.delete(agentId);
105
- if (!this.value?.requests.some(r => r.state === "asking" && r.askedOf === agentId)) return;
106
- for (const r of this.value.requests.filter(r => r.state === "asking" && r.askedOf === agentId)) {
107
- if (turnStartedAt === null || turnStartedAt < Date.parse(r.askedAt)) continue;
108
- await this.update(r.id, x => x.state !== "asking" ? x : { ...x, state: "chat", settledAt: new Date(this.now()).toISOString() });
105
+ const owed = (await this.list()).filter(r => r.state === "asking" && r.askedOf === agentId && r.deliveredAt && Date.parse(r.deliveredAt) <= this.now());
106
+ for (const r of owed) await this.update(r.id, x => x.state !== "asking" ? x : { ...x, state: "chat", settledAt: new Date(this.now()).toISOString() });
107
+ }
108
+
109
+ /**
110
+ * After a restart: anything still asking is re-derived from what the worker can read without waking anyone. `sent`
111
+ * says when the queue delivered it (null: not yet, or not a queued ask); `idle` says the agent isn't in a turn now.
112
+ * Delivered to an agent that is idle means its turn ended while the worker was down, so it settles as `chat`; a send
113
+ * that failed for good fails the ask.
114
+ */
115
+ async reconcile(look: (r: ContextRequest) => { sent: string | null; failed: string | null; idle: boolean }): Promise<void> {
116
+ for (const r of (await this.list()).filter(x => x.state === "asking" && x.askedOf)) {
117
+ const seen = look(r);
118
+ if (seen.failed) { await this.fail(r.id, seen.failed); continue; }
119
+ const at = r.deliveredAt ?? seen.sent;
120
+ if (at && !r.deliveredAt) await this.delivered(r.id, at);
121
+ if (at && seen.idle) await this.turnEnded(r.askedOf!);
109
122
  }
110
123
  }
111
124
  }
@@ -60,7 +60,7 @@ 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> };
63
+ export type Session = { order: string[]; pos: number; outcomes: Record<string, Outcome>; parked: Record<string, string>; lapped?: boolean };
64
64
 
65
65
  export const startSession = (cards: readonly Pick<DeckCard, "key">[]): Session => ({ order: cards.map(c => c.key), pos: 0, outcomes: {}, parked: {} });
66
66
 
@@ -70,14 +70,16 @@ const open = (s: Session, key: string) => { const o = s.outcomes[key]; return !o
70
70
  const landable = (s: Session, key: string) => open(s, key) && !s.parked[groupOf(key)];
71
71
 
72
72
  /**
73
- * The next card after `from`: the next landable one in order, else the first skipped one from the start (a second
74
- * pass), else `order.length` (finished). Never returns `from` itself unless it is the only one left.
73
+ * The next card after `from`: the next landable one in order, else the first skipped one from the start (one second
74
+ * pass, `lapped`), else `order.length` (finished). On the second pass a skip moves forward only, so skipping everything
75
+ * ends at the finished screen with "Catch up on N skipped" instead of going round for ever.
75
76
  */
76
- export function nextPos(s: Session, from: number): number {
77
- for (let i = from + 1; i < s.order.length; i++) if (landable(s, s.order[i]) && s.outcomes[s.order[i]] !== "skipped") return i;
78
- for (let i = 0; i < s.order.length; i++) if (i !== from && landable(s, s.order[i])) return i;
79
- return from < s.order.length && landable(s, s.order[from]) ? from : s.order.length;
77
+ export function advance(s: Session, from: number): Pick<Session, "pos" | "lapped"> {
78
+ for (let i = from + 1; i < s.order.length; i++) if (landable(s, s.order[i]) && (s.lapped || s.outcomes[s.order[i]] !== "skipped")) return { pos: i, lapped: s.lapped };
79
+ if (!s.lapped) for (let i = 0; i < s.order.length; i++) if (i !== from && landable(s, s.order[i])) return { pos: i, lapped: true };
80
+ return { pos: s.order.length, lapped: s.lapped };
80
81
  }
82
+ export const nextPos = (s: Session, from: number): number => advance(s, from).pos;
81
83
 
82
84
  /** Back: the card before, whatever happened to it (done cards show what was sent; a parked one shows it is asking). */
83
85
  export const prevPos = (s: Session): number => Math.max(0, Math.min(s.pos, s.order.length) - 1);
@@ -86,7 +88,7 @@ export const prevPos = (s: Session): number => Math.max(0, Math.min(s.pos, s.ord
86
88
  export function settle(s: Session, outcome: Outcome, key = s.order[s.pos]): Session {
87
89
  if (key === undefined) return s;
88
90
  const next = { ...s, outcomes: { ...s.outcomes, [key]: outcome } };
89
- return s.order[s.pos] === key ? { ...next, pos: nextPos(next, s.pos) } : next;
91
+ return s.order[s.pos] === key ? { ...next, ...advance(next, s.pos) } : next;
90
92
  }
91
93
 
92
94
  /**
@@ -97,7 +99,7 @@ export function settle(s: Session, outcome: Outcome, key = s.order[s.pos]): Sess
97
99
  export function park(s: Session, requestId: string, key = s.order[s.pos]): Session {
98
100
  if (key === undefined) return s;
99
101
  const next = { ...s, parked: { ...s.parked, [groupOf(key)]: requestId } };
100
- return s.order[s.pos] !== undefined && groupOf(s.order[s.pos]) === groupOf(key) ? { ...next, pos: nextPos(next, s.pos) } : next;
102
+ return s.order[s.pos] !== undefined && groupOf(s.order[s.pos]) === groupOf(key) ? { ...next, ...advance(next, s.pos) } : next;
101
103
  }
102
104
 
103
105
  /**
@@ -137,19 +139,61 @@ export function statsOf(s: Session): SessionStats {
137
139
  }
138
140
 
139
141
  /** The keys, one place, so the help line, the tooltips and the handler agree. Option letters pick; these never collide with A–H. */
140
- export const CATCH_UP_KEYS = [
141
- { key: "A–H", what: "Pick an option" },
142
- { key: "W", what: "Write your own answer" },
143
- { key: "⌘↵", what: "Send" },
144
- { key: "J / →", what: "Skip" },
145
- { key: "K / ←", what: "Back" },
146
- { key: "M", what: "More context" },
147
- { key: "N", what: "Add a note" },
148
- { key: "L", what: "Later" },
149
- { key: "O", what: "Open chat" },
150
- { key: "?", what: "Show the keys" },
151
- { key: "Esc", what: "Leave" },
152
- ] as const;
142
+ /**
143
+ * Catch up's keys (desktop web): one list that the handler (`catchUpKey`), the S sheet and the hint line read, so
144
+ * they never disagree. `combos` spell each key the way Paseo's bundle does (PASEO_BOUND, shared/search-key.ts):
145
+ * tests/catch-up-keys.test.ts fails if one is a combo Paseo binds, Home's search key, or one of the search-from-
146
+ * anywhere presets. Paseo takes Shift+? (its shortcuts dialog) and Escape (interrupt agent) when focus is outside a
147
+ * field, which is exactly when these fire, so the sheet is S and leaving is X.
148
+ */
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";
150
+ /** A key as this platform spells it: ⌘ on a Mac, Ctrl elsewhere (as the Send button's own hint reads). */
151
+ export const keyLabel = (key: string, mac: boolean) => mac ? key : key.replace("⌘", "Ctrl ");
152
+
153
+ export const CATCH_UP_KEYS: readonly { key: string; what: string; action: CatchUpAction; combos: readonly string[]; when?: "more" | "rail" }[] = [
154
+ { key: "A–H", what: "Pick an option", action: "pick", combos: ["A", "B", "C", "D", "E", "F", "G", "H"] },
155
+ { key: "W", what: "Write your own answer", action: "own", combos: ["W"] },
156
+ { key: "⌘↵", what: "Send", action: "send", combos: ["Cmd+Enter", "Ctrl+Enter"] },
157
+ { key: "J / →", what: "Skip", action: "skip", combos: ["J", "ArrowRight"] },
158
+ { key: "K / ←", what: "Back", action: "back", combos: ["K", "ArrowLeft"] },
159
+ { key: "M", what: "More context", action: "more", combos: ["M"] },
160
+ { 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" },
163
+ { key: "N", what: "Add a note", action: "note", combos: ["N"] },
164
+ { key: "L", what: "Later", action: "later", combos: ["L"] },
165
+ { key: "O", what: "Open chat", action: "chat", combos: ["O"] },
166
+ { key: "R", what: "Go to the queue, and back", action: "rail", combos: ["R"] },
167
+ { key: "↑ / ↓", what: "Move in the queue (Enter opens)", action: "rail-up", combos: ["ArrowUp", "ArrowDown"], when: "rail" },
168
+ { key: "S", what: "Show the keys", action: "keys", combos: ["S"] },
169
+ { key: "X", what: "Leave Catch up", action: "leave", combos: ["X"] },
170
+ ];
171
+
172
+ export type KeyPress = { key: string; meta: boolean; ctrl: boolean; alt: boolean; shift: boolean; composing?: boolean; mac: boolean };
173
+ /**
174
+ * What a key press does in Catch up, or null to leave it alone (Paseo's, the field's, the browser's). Pure, so the
175
+ * map is tested without a DOM. `typing`: focus is in a text field, where only the More context box's ⌘↵ and ⌘⇧↵ act
176
+ * (a card field's ⌘↵ is its own SubmitScope's). `inRail`: focus is in the queue.
177
+ */
178
+ export function catchUpKey(e: KeyPress, at: { typing: boolean; inMore: boolean; moreOpen: boolean; inRail: boolean }): { action: CatchUpAction; arg?: string } | null {
179
+ if (e.composing || e.alt) return null;
180
+ const mod = e.mac ? e.meta : e.ctrl;
181
+ 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" };
184
+ return at.typing ? null : { action: "send" };
185
+ }
186
+ if (at.typing || e.meta || e.ctrl) return null;
187
+ if (at.inRail && (e.key === "ArrowUp" || e.key === "ArrowDown")) return { action: e.key === "ArrowUp" ? "rail-up" : "rail-down" };
188
+ if (e.key === "ArrowRight") return { action: "skip" };
189
+ if (e.key === "ArrowLeft") return { action: "back" };
190
+ if (at.moreOpen && /^[1-4]$/.test(e.key)) return { action: "chip", arg: e.key };
191
+ if (e.shift || e.key.length !== 1) return null;
192
+ const k = e.key.toLowerCase();
193
+ if (/^[a-h]$/.test(k)) return { action: "pick", arg: k.toUpperCase() };
194
+ const byLetter: Record<string, CatchUpAction> = { w: "own", j: "skip", k: "back", m: "more", n: "note", l: "later", o: "chat", r: "rail", s: "keys", x: "leave" };
195
+ return byLetter[k] ? { action: byLetter[k] } : null;
196
+ }
153
197
 
154
198
  /**
155
199
  * The mode's name in every place it shows, so renaming it is one edit. Tom picked Catch up (2026-11-17: "people know
@@ -164,6 +208,8 @@ export const MODE = {
164
208
  progress: (at: number, of: number) => `Catch up ${at} of ${of}`,
165
209
  waiting: (n: number) => `${n} getting context`,
166
210
  finished: "All caught up",
211
+ /** The end of a deck with cards still skipped or waiting: not caught up, so it does not say so. */
212
+ endOfDeck: "End of the deck",
167
213
  empty: "Nothing needs you",
168
214
  } as const;
169
215
 
@@ -207,6 +253,12 @@ export const contextRequestSchema = z.object({
207
253
  error: z.string().max(500).nullable(),
208
254
  askedAt: iso,
209
255
  settledAt: iso.nullable(),
256
+ /**
257
+ * When the ask actually reached `askedOf` (the queue sent it, or the Overseer took it). The first turn end after this
258
+ * without a context_reply settles it as `chat`, so a prompt steered into a running turn counts too. Absent in files
259
+ * from before it existed.
260
+ */
261
+ deliveredAt: iso.nullable().default(null),
210
262
  /** Who asked: "developer" or "agent:<id>" (agent parity). */
211
263
  by: z.string().max(120),
212
264
  });
@@ -247,3 +299,14 @@ export function pruneContext(requests: readonly ContextRequest[], now: number):
247
299
  const young = requests.filter(r => now - Date.parse(r.askedAt) < CONTEXT_KEEP_MS);
248
300
  return young.slice(Math.max(0, young.length - CONTEXT_MAX));
249
301
  }
302
+
303
+ /**
304
+ * A context answer as the card shows it: plain words. Agents often answer in Markdown, which the card would show as
305
+ * literal ** and # marks, so emphasis, heading and quote marks go; links and line breaks stay.
306
+ */
307
+ export function plainAnswer(text: string): string {
308
+ return text.replace(/\*\*(.+?)\*\*|__(.+?)__/g, (_m, a, b) => a ?? b).replace(/^\s{0,3}(#{1,6}|>)\s+/gm, "").trim();
309
+ }
310
+
311
+ /** The ask as the card's header quotes it: its first sentence ("I don't get it."), not the whole prompt. */
312
+ export const askHeadline = (ask: string): string => (ask.match(/^.+?[.?!](?=\s|$)/)?.[0] ?? ask).slice(0, 120);
package/shared/display.ts CHANGED
@@ -7,6 +7,10 @@ import { SEARCH_SHORTCUTS } from "./search-key";
7
7
  export const HOME_DETAIL_DEFAULT = 0.42;
8
8
  export const HOME_DETAIL_MIN = 0.2;
9
9
  export const HOME_DETAIL_MAX = 0.8;
10
+ /** Catch up's queue rail on desktop (side-panes-are-resizable): its share of the width. */
11
+ export const CATCH_UP_RAIL_DEFAULT = 0.28;
12
+ export const CATCH_UP_RAIL_MIN = 0.16;
13
+ export const CATCH_UP_RAIL_MAX = 0.5;
10
14
 
11
15
  export const displayPreferences = defineSettings({
12
16
  id: "display",
@@ -36,6 +40,9 @@ export const displayPreferences = defineSettings({
36
40
  // 2.1: the share of Home's width the right pane (the brief or the selected item) takes, set by dragging the divider
37
41
  // (client/split.tsx). A fraction, so it carries across window sizes; absent means HOME_DETAIL_DEFAULT.
38
42
  home_detail_fraction: z.number().min(HOME_DETAIL_MIN).max(HOME_DETAIL_MAX).optional(),
43
+ // 2.2: the share of Catch up's width its queue rail takes on desktop (client/catch-up.tsx, client/split.tsx).
44
+ // Absent means CATCH_UP_RAIL_DEFAULT.
45
+ catch_up_rail_fraction: z.number().min(CATCH_UP_RAIL_MIN).max(CATCH_UP_RAIL_MAX).optional(),
39
46
  // 2.1: the key that opens Home with the cursor in its search from anywhere in Paseo (shared/search-key.ts).
40
47
  // Absent means DEFAULT_SEARCH_SHORTCUT (⌘/ or Ctrl+/); "none" turns it off.
41
48
  search_shortcut: z.enum(SEARCH_SHORTCUTS).optional() }),