paseo-follow-up 2.5.0 → 2.6.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/OVERVIEW.md +1 -1
  2. package/README.md +0 -1
  3. package/client/brief-since.tsx +4 -3
  4. package/client/catch-up.tsx +56 -15
  5. package/client/header.tsx +5 -3
  6. package/client/home-data.ts +3 -1
  7. package/client/home-list.tsx +19 -11
  8. package/client/home-view.ts +8 -1
  9. package/client/home.tsx +29 -10
  10. package/client/keys.ts +2 -0
  11. package/client/kit.tsx +5 -2
  12. package/client/large.tsx +5 -3
  13. package/client/live.tsx +4 -3
  14. package/client/merge-button.tsx +3 -2
  15. package/client/messages.tsx +5 -1
  16. package/client/more-context.tsx +17 -4
  17. package/client/morning-brief-settings.tsx +5 -4
  18. package/client/needs-you.tsx +5 -4
  19. package/client/new-settings.tsx +8 -7
  20. package/client/now-lines.tsx +60 -0
  21. package/client/onboarding.tsx +55 -123
  22. package/client/paged-list.tsx +115 -0
  23. package/client/panel.tsx +24 -8
  24. package/client/pr-stats-settings.tsx +3 -2
  25. package/client/pr-stats.tsx +10 -10
  26. package/client/questions.tsx +63 -40
  27. package/client/release-notes.tsx +10 -9
  28. package/client/reviewers.tsx +8 -3
  29. package/client/row-open.ts +28 -0
  30. package/client/section-search.tsx +5 -3
  31. package/client/settings.tsx +11 -8
  32. package/client/setup-dialog.tsx +168 -0
  33. package/client/setup-gate.tsx +69 -0
  34. package/client/setup-ui.ts +27 -0
  35. package/client/shipping.tsx +5 -4
  36. package/client/stacks.tsx +11 -3
  37. package/client/tasks.tsx +5 -1
  38. package/client/your-questions.tsx +375 -0
  39. package/index.client.tsx +11 -3
  40. package/index.server.ts +162 -32
  41. package/package.json +1 -1
  42. package/server/agent-actions.ts +23 -14
  43. package/server/agent-hook.mjs +7 -5
  44. package/server/agent-parity.ts +21 -6
  45. package/server/ai-jobs.ts +26 -5
  46. package/server/brief-timeline.ts +47 -0
  47. package/server/context-requests.ts +90 -21
  48. package/server/directory.ts +6 -0
  49. package/server/discovery.ts +2 -0
  50. package/server/engine.ts +3 -0
  51. package/server/hook-source.ts +7 -5
  52. package/server/inbox-classifier.ts +17 -0
  53. package/server/inbox.ts +9 -3
  54. package/server/job-agent.ts +13 -2
  55. package/server/mcp-source.ts +23 -15
  56. package/server/mcp.mjs +23 -15
  57. package/server/obligations.ts +4 -1
  58. package/server/session-prompt.ts +30 -3
  59. package/server/turn-end.ts +133 -0
  60. package/server/wait-jobs.ts +18 -2
  61. package/server/wait.ts +17 -12
  62. package/shared/activity.ts +2 -1
  63. package/shared/agent-settings.ts +9 -8
  64. package/shared/catch-up.ts +65 -20
  65. package/shared/chat.ts +2 -2
  66. package/shared/compass.ts +5 -4
  67. package/shared/contracts.ts +52 -8
  68. package/shared/history.ts +160 -0
  69. package/shared/home-keys.ts +1 -0
  70. package/shared/home.ts +54 -8
  71. package/shared/job-rows.ts +2 -2
  72. package/shared/list.ts +4 -1
  73. package/shared/message-sender.ts +2 -0
  74. package/shared/model.ts +8 -0
  75. package/shared/new-name.ts +4 -1
  76. package/shared/now.ts +228 -0
  77. package/shared/onboarding.ts +17 -13
  78. package/shared/paged.ts +96 -0
  79. package/shared/provider-support.ts +83 -34
  80. package/shared/recommend.ts +1 -1
  81. package/shared/settings-nav.ts +3 -1
  82. package/shared/setup-popup.ts +28 -0
  83. package/shared/sort.ts +8 -1
  84. package/shared/status.ts +3 -1
  85. package/shared/wait.ts +2 -2
  86. package/shared/your-questions.ts +133 -0
  87. package/skills/follow-up/SKILL.md +1 -1
@@ -0,0 +1,375 @@
1
+ // Your questions (docs/needs-you.md#your-questions): what the developer asked an agent, and what came of it. One card,
2
+ // the same component in the workspace panel and Home's detail pane, under Needs you: the ask field, unread answers in
3
+ // full with Done · Reply · Make a task · ⋯, questions still asking, and the history. It reads the client's one store of
4
+ // questions (Home's extras, kept current by the home feed; client/more-context.tsx), so nothing polls, and every act is
5
+ // one request (`follow.question-action`, which the agent tool `question_action` also makes).
6
+ import { PagedRows } from "./paged-list";
7
+ import { useMemo, useState, useSyncExternalStore, type ReactNode } from "react";
8
+ import { Platform, View, type StyleProp, type TextStyle } from "react-native";
9
+ import { Pressable, Text } from "./text";
10
+ import { Icon, Modal, TextInput, copyText } from "@getpaseo/plugin/client/ui";
11
+ import type { ContextRequest } from "../shared/catch-up";
12
+ import { HISTORY_FILTERS, askingNow, questionCounts, questionHistory, questionOutcome, questionSource, unreadAnswer, type HistoryFilter, type QuestionAction } from "../shared/your-questions";
13
+ import { ago } from "../shared/attention";
14
+ import { errorText } from "../shared/errors";
15
+ import { Button, IconButton, SubmitScope, text, useNow, type Theme } from "./kit";
16
+ import { tint, withAlpha } from "./theme";
17
+ import { RichText } from "./rich-text";
18
+ import { Spinner } from "./motion";
19
+ import { PRIMARY_FORM } from "./dock";
20
+ import { DictationField, useCaret, type FieldPad } from "./dictation";
21
+ import { ImageField, useImageAttachments } from "./image-attach";
22
+ import type { ImageTarget, ImageUpload } from "../shared/images";
23
+ import { useContextStore } from "./more-context";
24
+ import { notice } from "./toast-store";
25
+ import type { PaseoWorkspaces } from "./home-data";
26
+
27
+ export const ASK_HINT = "The answer lands here. In a chat, /ask does the same.";
28
+ const FILTER_LABEL: Record<HistoryFilter, string> = { all: "All", open: "Open", tasks: "Tasks" };
29
+
30
+ /** This workspace's questions from the one store: unread answers and asking ones newest first, and the whole history. */
31
+ export function useWorkspaceQuestions(workspaceId: string) {
32
+ const { source, requests } = useContextStore();
33
+ return useMemo(() => {
34
+ const mine = requests.filter(r => r.workspaceId === workspaceId);
35
+ const newest = [...mine].reverse();
36
+ return { source, all: mine, unread: newest.filter(unreadAnswer), asking: newest.filter(askingNow) };
37
+ }, [source, requests, workspaceId]);
38
+ }
39
+
40
+ /** One act on a question through the store; the store shows its result at once. Throws the server's refusal. */
41
+ export function useQuestionActs() {
42
+ const { source } = useContextStore();
43
+ return {
44
+ ready: !!source?.questionAction,
45
+ act: async (id: string, action: QuestionAction, extra: { text?: string; images?: ImageUpload[] } = {}) => {
46
+ if (!source?.questionAction) throw new Error("Follow-up isn't connected yet.");
47
+ return source.questionAction({ id, action, ...(extra.text ? { text: extra.text } : {}), ...(extra.images?.length ? { images: extra.images } : {}) });
48
+ },
49
+ ask: async (input: { workspaceId: string | null; agentId?: string | null; ask: string; via: "field" | "slash" | "more"; cardKey?: string | null; card?: string; images?: ImageUpload[] }) => {
50
+ if (!source) throw new Error("Follow-up isn't connected yet.");
51
+ const { images, ...rest } = input;
52
+ return (await source.askContext({ ...rest, ...(images?.length ? { images } : {}) })).request;
53
+ },
54
+ };
55
+ }
56
+
57
+ /** The answer's state line: "Answered · 4m ago · main agent", "Answered · from its chat", "Couldn't ask". */
58
+ export function answerMeta(r: ContextRequest, now: number, mainAgentId?: string | null): string {
59
+ const who = !r.askedOf ? "" : r.askedOf === mainAgentId ? "main agent" : "another agent";
60
+ const how = r.state === "failed" ? "Couldn't ask" : r.state === "chat" ? r.answer ? "Answered · from its chat" : "Answered in its chat" : "Answered";
61
+ return [how, ago(r.settledAt ?? r.askedAt, now), who].filter(Boolean).join(" · ");
62
+ }
63
+
64
+ /** An answer's words: `code` spans in the mono face on a quiet tint (no literal backticks); the rest stays RichText (links). */
65
+ function AnswerText({ children, style, theme }: { children: string; style: StyleProp<TextStyle>; theme: Theme }) {
66
+ // Paragraphs a half line apart, not a whole blank line.
67
+ const paras = children.split(/\n\s*\n/).filter(p => p.trim());
68
+ if (paras.length > 1) return <View style={{ gap: 8 }}>{paras.map((p, i) => <AnswerText key={i} style={style} theme={theme}>{p}</AnswerText>)}</View>;
69
+ const parts = children.split(/`([^`\n]+)`/);
70
+ if (parts.length === 1) return <RichText selectable style={style}>{children}</RichText>;
71
+ const c = theme.colors;
72
+ return <Text selectable style={style}>{parts.map((p, i) => i % 2
73
+ ? <Text key={i} style={{ fontFamily: Platform.OS === "ios" ? "Menlo" : "monospace", fontSize: 13, backgroundColor: c.surface2, borderRadius: 3, ...(Platform.OS === "web" && p.length <= 40 ? { whiteSpace: "nowrap" } as object : {}) }}>{p}</Text>
74
+ : <RichText key={i} selectable>{p}</RichText>)}</Text>;
75
+ }
76
+
77
+ /** The question, then its answer quoted (or why there's none). The same on the card, Catch up's card and the history. */
78
+ export function AnswerView({ r, theme, compact, now, mainAgentId, meta = true, big = false }: { r: ContextRequest; theme: Theme; compact: boolean; now: number; mainAgentId?: string | null; meta?: boolean; big?: boolean }) {
79
+ const c = theme.colors; const t = text(c, compact);
80
+ const dot = r.state === "failed" ? c.statusDanger : c.statusWarning;
81
+ return <View style={{ gap: 8 }}>
82
+ {meta && <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
83
+ <View style={{ width: 8, height: 8, borderRadius: 4, backgroundColor: dot }} />
84
+ <Text style={[t.meta, { flex: 1 }]}>{answerMeta(r, now, mainAgentId)}</Text>
85
+ </View>}
86
+ <RichText selectable style={big ? [t.title, compact ? {} : { fontSize: 17, lineHeight: 24, fontWeight: "500" }] : [t.body, { fontSize: compact ? 15 : 14, lineHeight: compact ? 22 : 20 }]}>{r.ask}</RichText>
87
+ {r.answer ? <View style={{ borderLeftWidth: 2, borderLeftColor: withAlpha(c.foregroundMuted, 0.4), paddingLeft: 12 }}>
88
+ <AnswerText theme={theme} style={[t.body, { fontSize: compact ? 15 : 14, lineHeight: compact ? 23 : 21 }]}>{r.answer}</AnswerText>
89
+ </View>
90
+ : r.state === "chat" ? <Text style={t.meta}>The agent ended its turn without answering here. Its answer is in its chat.</Text>
91
+ : r.state === "failed" ? <Text style={[t.meta, { color: c.statusDanger }]}>{r.error ?? "The question didn't reach the agent."}</Text>
92
+ : null}
93
+ </View>;
94
+ }
95
+
96
+ /**
97
+ * What to do with an answer: Done (primary), Reply, Make a task, and ⋯ (Copy, Open in chat). Only what the server
98
+ * takes: no Make a task without an answer, Ask again in place of Reply for a failed ask. `keys`: Catch up's desktop
99
+ * card names its keys (D, W, T, O). `bar`: a phone's thumb bar (Done grows, Make a task reads "Task").
100
+ */
101
+ export function AnswerActions({ r, theme, compact, onDone, onReply, onTask, onAskAgain, openChat, busy, keys = false, bar = false, extra }: {
102
+ r: ContextRequest; theme: Theme; compact: boolean; onDone: () => void; onReply: () => void; onTask: () => void; onAskAgain: () => void; openChat?: () => void;
103
+ busy: QuestionAction | "again" | null; keys?: boolean; bar?: boolean; /** More items for ⋯ (Catch up: Skip). */ extra?: ReactNode;
104
+ }) {
105
+ const c = theme.colors; const t = text(c, compact);
106
+ const [more, setMore] = useState(false);
107
+ // A narrow row can't hold Done · Reply · Make a task · ⋯ on one line: Make a task reads "Task" there (its label stays
108
+ // whole), and narrower still (a phone's panel, ~306 pt) Done, Reply and Task drop their icons, so the row never wraps.
109
+ const [width, setWidth] = useState(0);
110
+ const narrow = width > 0 && width < (keys ? 440 : 380);
111
+ const tight = width > 0 && width < (compact ? 340 : 300);
112
+ const failed = r.state === "failed";
113
+ const k = (key: string) => keys && !compact ? ` (${key})` : "";
114
+ const copy = () => { void copyText(r.answer ? `Q: ${r.ask}\nA: ${r.answer}` : r.ask).then(() => notice("Copied the question and its answer")).catch(() => undefined); setMore(false); };
115
+ const menu = more && <View accessibilityLabel="More actions" style={{ flexDirection: "row", flexWrap: "wrap", gap: 8 }}>
116
+ {!!r.answer && <Button theme={theme} compact={compact} kind="ghost" icon="Copy" title="Copy" accessibilityLabel="Copy the question and its answer" onPress={copy} />}
117
+ {openChat && <Button theme={theme} compact={compact} kind="ghost" icon="MessageSquare" title={`Open in chat${k("O")}`} accessibilityLabel={`Open in chat${k("O")}`} onPress={() => { setMore(false); openChat(); }} />}
118
+ {extra}
119
+ </View>;
120
+ return <View style={{ gap: 8 }}>
121
+ {/* ⋯ sits outside the wrapping group, so it stays at the row's end when the buttons wrap. */}
122
+ <View onLayout={e => setWidth(e.nativeEvent.layout.width)} style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
123
+ <View style={{ flexDirection: "row", alignItems: "center", flexWrap: bar ? "nowrap" : "wrap", gap: 8, flexShrink: 1, minWidth: 0 }}>
124
+ <Button theme={theme} compact={compact} grow={bar} kind="primary" icon={tight ? undefined : "Check"} title={`Done${k("D")}`} accessibilityLabel={`Done${k("D")}`} accessibilityHint="Marks the answer read; it stays in the history" loading={busy === "done"} disabled={!!busy} onPress={onDone} />
125
+ {failed ? <Button theme={theme} compact={compact} icon="RotateCcw" title="Ask again" loading={busy === "again"} disabled={!!busy} onPress={onAskAgain} />
126
+ : <Button theme={theme} compact={compact} icon={tight ? undefined : "Reply"} title={`Reply${k("W")}`} accessibilityLabel={`Reply${k("W")}`} accessibilityHint="Asks a follow-up question in the same thread" disabled={!!busy} onPress={onReply} />}
127
+ {!!r.answer && !failed && <Button theme={theme} compact={compact} icon={tight ? undefined : "ListTodo"} title={`${bar || narrow ? "Task" : "Make a task"}${k("T")}`} accessibilityLabel={`Make a task${k("T")}`} accessibilityHint="Adds a task for the agent that answered, with this question and answer as its note" loading={busy === "task"} disabled={!!busy} onPress={onTask} />}
128
+ {!r.answer && r.state === "chat" && openChat && <Button theme={theme} compact={compact} icon="MessageSquare" title={`Open chat${k("O")}`} accessibilityLabel={`Open chat${k("O")}`} onPress={openChat} />}
129
+ </View>
130
+ <IconButton theme={theme} compact={compact} icon="Ellipsis" label={more ? "Fewer actions" : "More actions"} tooltip={!compact} onPress={() => setMore(v => !v)} />
131
+ </View>
132
+ {menu}
133
+ {!!r.answer && r.state === "chat" && <Text style={t.small}>Taken from its chat: the agent ended its turn without answering here.</Text>}
134
+ </View>;
135
+ }
136
+
137
+ /** A text field that reaches an agent: Paseo's dictation inside it, pasted images on it (every-agent-field-takes-images). */
138
+ function AgentField({ theme, compact, label, placeholder, value, onChange, disabled, autoFocus, lines = 1, img, right }: {
139
+ theme: Theme; compact: boolean; label: string; placeholder: string; value: string; onChange: (v: string) => void; disabled?: boolean; autoFocus?: boolean; lines?: number;
140
+ img: ReturnType<typeof useImageAttachments>; right?: ReactNode;
141
+ }) {
142
+ const c = theme.colors;
143
+ const caret = useCaret();
144
+ // One focus ring: the field's own border turns accent; the browser's outline stays off (as in new-settings.tsx).
145
+ const [focused, setFocused] = useState(false);
146
+ const field = (pad: FieldPad) => <TextInput accessibilityLabel={label} placeholder={placeholder} placeholderTextColor={c.foregroundMuted} value={value} onChangeText={onChange} onSelectionChange={caret.onSelectionChange}
147
+ multiline editable={!disabled} autoFocus={autoFocus} maxLength={2000} onFocus={() => setFocused(true)} onBlur={() => setFocused(false)}
148
+ style={[{ minHeight: compact ? 44 : lines > 1 ? 56 : 36, paddingHorizontal: 10, paddingVertical: 8, borderRadius: 6, borderWidth: 1, borderColor: focused ? c.accent : c.border, color: c.foreground, backgroundColor: c.surface0, fontSize: compact ? 15 : 13,
149
+ ...(Platform.OS === "web" ? { outlineStyle: "none" } as object : null) }, pad]} />;
150
+ return <ImageField model={img} theme={theme} compact={compact}><View style={{ flexDirection: "row", alignItems: "flex-end", gap: 8 }}>
151
+ <View style={{ flex: 1, minWidth: 0 }}><DictationField theme={theme} compact={compact} field={field} disabled={disabled} onText={said => onChange(caret.insert(value, said, 2000))} /></View>
152
+ {right}
153
+ </View></ImageField>;
154
+ }
155
+
156
+ /** Reply: an inline field under the answer. It asks a follow-up in the same thread, of the same agent. */
157
+ export function ReplyForm({ r, theme, compact, onSent, onCancel }: { r: ContextRequest; theme: Theme; compact: boolean; onSent: () => void; onCancel: () => void }) {
158
+ const c = theme.colors;
159
+ const acts = useQuestionActs();
160
+ const img = useImageAttachments({ target: (r.askedOf ? { kind: "agent", agentId: r.askedOf } : r.workspaceId ? { kind: "workspace", workspaceId: r.workspaceId } : null) as ImageTarget | null });
161
+ const [words, setWords] = useState("");
162
+ const [busy, setBusy] = useState(false);
163
+ const [error, setError] = useState<string | null>(null);
164
+ const send = () => {
165
+ if (!words.trim() || busy || img.blocked) return;
166
+ setBusy(true); setError(null);
167
+ acts.act(r.id, "reply", { text: words.trim(), images: img.uploads() }).then(() => { img.clear(); setWords(""); onSent(); }, e => setError(errorText(e))).finally(() => setBusy(false));
168
+ };
169
+ return <SubmitScope enabled={!!words.trim() && !busy && !img.blocked} onSubmit={send}><View {...PRIMARY_FORM} style={{ gap: 8 }}>
170
+ <AgentField theme={theme} compact={compact} label="Your reply" placeholder="Ask a follow-up…" value={words} onChange={setWords} disabled={busy} autoFocus lines={2} img={img} />
171
+ {!!error && <Text accessibilityRole="alert" style={[text(c, compact).meta, { color: c.statusDanger }]}>{error}</Text>}
172
+ <View style={{ flexDirection: "row", alignItems: "center", justifyContent: "flex-end", gap: 8 }}>
173
+ <Button theme={theme} compact={compact} kind="ghost" title="Cancel" onPress={onCancel} />
174
+ <Button theme={theme} compact={compact} grow={compact} kind="primary" icon="Send" title="Send reply" shortcut loading={busy} disabled={!words.trim() || busy || !!img.blocked} onPress={send} />
175
+ </View>
176
+ </View></SubmitScope>;
177
+ }
178
+
179
+ /** One unread answer on the card: the answer in full, its actions, and Reply's field when open. */
180
+ function AnswerItem({ r, theme, compact, now, mainAgentId, openAgent }: { r: ContextRequest; theme: Theme; compact: boolean; now: number; mainAgentId: string | null; openAgent?: (agentId: string) => void }) {
181
+ const c = theme.colors;
182
+ const acts = useQuestionActs();
183
+ const [replying, setReplying] = useState(false);
184
+ const [busy, setBusy] = useState<QuestionAction | "again" | null>(null);
185
+ const [error, setError] = useState<string | null>(null);
186
+ const run = (what: QuestionAction | "again", work: () => Promise<unknown>, done?: string) => {
187
+ setBusy(what); setError(null);
188
+ work().then(() => { if (done) notice(done); }, e => setError(errorText(e))).finally(() => setBusy(null));
189
+ };
190
+ const openChat = openAgent && r.askedOf ? () => openAgent(r.askedOf!) : undefined;
191
+ return <View {...({ dataSet: { yourQuestion: r.id } } as object)} style={{ gap: 10, paddingHorizontal: compact ? 14 : 12, paddingVertical: 12, borderTopWidth: 1, borderTopColor: c.border }}>
192
+ <AnswerView r={r} theme={theme} compact={compact} now={now} mainAgentId={mainAgentId} />
193
+ {replying ? <ReplyForm r={r} theme={theme} compact={compact} onCancel={() => setReplying(false)} onSent={() => { setReplying(false); notice("Reply sent · it shows here while the agent answers"); }} />
194
+ : <AnswerActions r={r} theme={theme} compact={compact} busy={busy} openChat={openChat}
195
+ onDone={() => run("done", () => acts.act(r.id, "done"), "Done · in History")}
196
+ onReply={() => setReplying(true)}
197
+ onTask={() => run("task", () => acts.act(r.id, "task"), "Made a task for the agent that answered")}
198
+ onAskAgain={() => run("again", async () => { await acts.ask({ workspaceId: r.workspaceId, agentId: r.cardKey ? r.agentId : r.askedOf, cardKey: r.cardKey, card: r.card || undefined, ask: r.ask, via: r.via === "slash" ? "slash" : r.cardKey ? "more" : "field" }); await acts.act(r.id, "done"); })} />}
199
+ {!!error && <Text accessibilityRole="alert" style={[text(c, compact).meta, { color: c.statusDanger }]}>{error}</Text>}
200
+ </View>;
201
+ }
202
+
203
+ /** A question still asking: spinner, when it was sent, and Withdraw (never Done: there is nothing to read yet). */
204
+ function AskingItem({ r, theme, compact, now, busyAgent }: { r: ContextRequest; theme: Theme; compact: boolean; now: number; /** The workspace is running (Paseo's directory): the question waits for the turn to end. */ busyAgent: boolean }) {
205
+ const c = theme.colors; const t = text(c, compact);
206
+ const acts = useQuestionActs();
207
+ const [busy, setBusy] = useState(false);
208
+ const [confirm, setConfirm] = useState(false);
209
+ const [error, setError] = useState<string | null>(null);
210
+ const withdraw = () => { setBusy(true); setError(null); acts.act(r.id, "withdraw").then(() => notice("Withdrawn · in History"), e => setError(errorText(e))).finally(() => { setBusy(false); setConfirm(false); }); };
211
+ const line = `Asking · ${r.deliveredAt ? `sent ${ago(r.deliveredAt, now)}` : `queued ${ago(r.askedAt, now)}`}${busyAgent ? " · the agent is mid-turn" : ""}`;
212
+ return <View {...({ dataSet: { yourQuestion: r.id } } as object)} style={{ gap: 6, paddingHorizontal: compact ? 14 : 12, paddingVertical: 10, borderTopWidth: 1, borderTopColor: c.border }}>
213
+ <View style={{ flexDirection: "row", alignItems: "center", flexWrap: "wrap", gap: 8 }}>
214
+ <Spinner color={c.foregroundMuted} size={12} label="Asking" />
215
+ <Text style={[t.meta, { flex: 1 }]}>{line}</Text>
216
+ {/* Two presses, like every other removal in Needs you: Withdraw, then Withdraw it or Keep. */}
217
+ {confirm ? <View style={{ flexDirection: "row", gap: 6 }}>
218
+ <Button theme={theme} compact={compact} kind="ghost" title="Keep" disabled={busy} onPress={() => setConfirm(false)} />
219
+ <Button theme={theme} compact={compact} kind="danger" title="Withdraw it" accessibilityLabel={`Withdraw it: ${r.ask.slice(0, 60)}`} accessibilityHint="Takes the question back; a message still queued isn't sent" loading={busy} disabled={busy} onPress={withdraw} />
220
+ </View>
221
+ : <Pressable accessibilityRole="button" accessibilityLabel={`Withdraw: ${r.ask.slice(0, 60)}`} hitSlop={compact ? 12 : 6} onPress={() => setConfirm(true)}
222
+ style={state => ({ paddingHorizontal: 8, paddingVertical: 4, borderRadius: 6, backgroundColor: (state as { hovered?: boolean }).hovered || state.pressed ? c.surface1 : "transparent" })}>
223
+ <Text style={t.meta}>Withdraw</Text>
224
+ </Pressable>}
225
+ </View>
226
+ <RichText selectable style={[t.body, { fontSize: compact ? 15 : 14, lineHeight: compact ? 22 : 20 }]}>{r.ask}</RichText>
227
+ {!!error && <Text accessibilityRole="alert" style={[t.meta, { color: c.statusDanger }]}>{error}</Text>}
228
+ </View>;
229
+ }
230
+
231
+ /** The ask field and its hint line: a free question to the workspace's main agent (follow.context-ask, no card). */
232
+ function AskField({ workspaceId, theme, compact, folded = false }: { workspaceId: string; theme: Theme; compact: boolean; /** One line until tapped (Home's phone pane, under the dock's reply field). */ folded?: boolean }) {
233
+ const c = theme.colors; const t = text(c, compact);
234
+ const [open, setOpen] = useState(!folded);
235
+ const acts = useQuestionActs();
236
+ const img = useImageAttachments({ target: { kind: "workspace", workspaceId } });
237
+ const [words, setWords] = useState("");
238
+ const [busy, setBusy] = useState(false);
239
+ const [error, setError] = useState<string | null>(null);
240
+ const send = () => {
241
+ if (!words.trim() || busy || img.blocked) return;
242
+ setBusy(true); setError(null);
243
+ // The words and images stay unless the question is recorded.
244
+ acts.ask({ workspaceId, ask: words.trim(), via: "field", images: img.uploads() }).then(() => { setWords(""); img.clear(); }, e => setError(errorText(e))).finally(() => setBusy(false));
245
+ };
246
+ const sendButton = (words.trim() || busy) ? <IconButton theme={theme} compact={compact} icon="Send" label="Ask the main agent" tooltip={!compact} spinning={busy} disabled={!words.trim() || busy || !!img.blocked} color={c.foreground} onPress={send} /> : null;
247
+ // Folded: one quiet row, so the pane shows one text field (the dock's) until you choose to ask.
248
+ if (!open && !words) return <View style={{ paddingHorizontal: compact ? 14 : 12, paddingBottom: 12 }}>
249
+ <Pressable accessibilityRole="button" accessibilityLabel="Ask the main agent" accessibilityHint="Opens a field for a question to the workspace's main agent" onPress={() => setOpen(true)}
250
+ style={({ pressed }) => ({ flexDirection: "row", alignItems: "center", gap: 8, minHeight: 44, paddingHorizontal: 10, borderRadius: 6, backgroundColor: pressed ? c.surface2 : c.surface1 })}>
251
+ <Icon name="MessageSquarePlus" size={16} color={c.foregroundMuted} />
252
+ <Text style={[t.body, { color: c.foregroundMuted, flex: 1 }]}>Ask the main agent…</Text>
253
+ </Pressable>
254
+ </View>;
255
+ return <View {...PRIMARY_FORM} style={{ gap: 6, paddingHorizontal: compact ? 14 : 12, paddingBottom: 12 }}>
256
+ <AgentField theme={theme} compact={compact} label="Ask the main agent" placeholder="Ask the main agent…" value={words} onChange={setWords} disabled={busy} autoFocus={folded} img={img} right={sendButton} />
257
+ {!!error && <Text accessibilityRole="alert" style={[t.meta, { color: c.statusDanger }]}>{error}</Text>}
258
+ <Text style={t.small}>{ASK_HINT}</Text>
259
+ </View>;
260
+ }
261
+
262
+ /** One history row: how it ended, when, where from; the question; tap to read the answer; its replies under it. */
263
+ function HistoryRow({ r, replies, theme, compact, now, depth = 0 }: { r: ContextRequest; replies: Map<string, ContextRequest[]>; theme: Theme; compact: boolean; now: number; depth?: number }) {
264
+ const c = theme.colors; const t = text(c, compact);
265
+ const [open, setOpen] = useState(false);
266
+ const unread = unreadAnswer(r);
267
+ const line = [questionOutcome(r), ago(r.settledAt ?? r.askedAt, now), questionSource(r)].filter(Boolean).join(" · ");
268
+ const kids = replies.get(r.id) ?? [];
269
+ const readable = !!r.answer || r.state === "failed";
270
+ return <View>
271
+ <Pressable accessibilityRole="button" aria-expanded={readable ? open : undefined} accessibilityState={readable ? { expanded: open } : undefined} accessibilityLabel={`${r.ask}. ${line}`} disabled={!readable} onPress={() => setOpen(v => !v)}
272
+ style={state => ({ gap: 4, paddingVertical: 10, paddingLeft: 10 + depth * 14, paddingRight: 10, borderTopWidth: depth ? 0 : 1, borderTopColor: c.border, borderRadius: depth ? 6 : 0,
273
+ backgroundColor: (state as { hovered?: boolean }).hovered && readable ? c.surface1 : "transparent" })}>
274
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
275
+ {depth > 0 && <Icon name="CornerDownRight" size={12} color={c.foregroundMuted} />}
276
+ <Text style={[t.meta, { flex: 1 }]}>{line}</Text>
277
+ {unread && <View style={{ paddingHorizontal: 8, paddingVertical: 1, borderRadius: 999, backgroundColor: tint(c.statusWarning, c) }}><Text style={[t.small, { color: c.statusWarning, fontWeight: "600" }]}>Unread</Text></View>}
278
+ {readable && <Icon name={open ? "ChevronUp" : "ChevronDown"} size={14} color={c.foregroundMuted} />}
279
+ </View>
280
+ <RichText plain style={[t.body, { fontSize: compact ? 15 : 14, lineHeight: compact ? 22 : 20 }]}>{r.ask}</RichText>
281
+ </Pressable>
282
+ {/* The answer sits below the row's tap target, so its links stay links (rich-text.tsx: no link inside a pressable row). */}
283
+ {open && readable && <View style={{ marginLeft: 22 + depth * 14, marginRight: 10, marginBottom: 10, borderLeftWidth: 2, borderLeftColor: withAlpha(c.foregroundMuted, 0.4), paddingLeft: 12 }}>
284
+ {r.answer ? <AnswerText theme={theme} style={t.body}>{r.answer}</AnswerText> : <Text style={[t.meta, { color: c.statusDanger }]}>{r.error ?? "The question didn't reach the agent."}</Text>}
285
+ </View>}
286
+ {kids.map(k => <HistoryRow key={k.id} r={k} replies={replies} theme={theme} compact={compact} now={now} depth={depth + 1} />)}
287
+ </View>;
288
+ }
289
+
290
+ /** The history: search over questions and answers, All / Open / Tasks, newest first, replies as a thread. */
291
+ export function QuestionHistory({ workspaceId, theme, compact }: { workspaceId: string; theme: Theme; compact: boolean }) {
292
+ const c = theme.colors; const t = text(c, compact);
293
+ const now = useNow(30_000);
294
+ const { all } = useWorkspaceQuestions(workspaceId);
295
+ const [query, setQuery] = useState("");
296
+ const [filter, setFilter] = useState<HistoryFilter>("all");
297
+ const counts = useMemo(() => Object.fromEntries(HISTORY_FILTERS.map(f => [f, questionHistory(all, { filter: f }).length])) as Record<HistoryFilter, number>, [all]);
298
+ const shown = questionHistory(all, { filter, query });
299
+ // A thread: a reply sits under its question when both are shown; otherwise it stands on its own.
300
+ const ids = new Set(shown.map(r => r.id));
301
+ const replies = new Map<string, ContextRequest[]>();
302
+ for (const r of [...shown].reverse()) if (r.parentId && ids.has(r.parentId)) replies.set(r.parentId, [...(replies.get(r.parentId) ?? []), r]);
303
+ const roots = shown.filter(r => !r.parentId || !ids.has(r.parentId));
304
+ return <View style={{ gap: 10 }}>
305
+ <View style={{ flexDirection: "row", alignItems: "center", gap: 8, paddingHorizontal: 10, minHeight: compact ? 44 : 34, borderRadius: 6, borderWidth: 1, borderColor: c.border, backgroundColor: c.surface0 }}>
306
+ <Icon name="Search" size={14} color={c.foregroundMuted} />
307
+ <TextInput accessibilityLabel="Search questions and answers" placeholder="Search questions and answers" placeholderTextColor={c.foregroundMuted} value={query} onChangeText={setQuery}
308
+ style={{ flex: 1, minWidth: 0, paddingVertical: 6, color: c.foreground, fontSize: compact ? 15 : 13, outlineStyle: "none" } as object} />
309
+ {!!query && <IconButton theme={theme} compact={compact} icon="X" label="Clear the search" onPress={() => setQuery("")} />}
310
+ </View>
311
+ <View accessibilityRole="radiogroup" accessibilityLabel="Show" style={{ flexDirection: "row", flexWrap: "wrap", gap: 6 }}>
312
+ {HISTORY_FILTERS.map(f => <Pressable key={f} accessibilityRole="radio" accessibilityState={{ checked: filter === f }} accessibilityLabel={`${FILTER_LABEL[f]}, ${counts[f]}`} onPress={() => setFilter(f)}
313
+ style={{ minHeight: compact ? 44 : 26, justifyContent: "center", paddingHorizontal: 10, borderRadius: 999, backgroundColor: filter === f ? c.foreground : c.surface2 }}>
314
+ <Text style={[t.meta, { color: filter === f ? c.surface0 : c.foregroundMuted, fontWeight: filter === f ? "600" : "400" }]}>{`${FILTER_LABEL[f]} ${counts[f]}`}</Text>
315
+ </Pressable>)}
316
+ </View>
317
+ <View>
318
+ {/* Pages of 25 threads (invariant pr-scale-lists-batch-not-throw, "every list pages"): 30 days of questions never draw at once. */}
319
+ <PagedRows items={roots} searching={!!query} resetKey={`${filter}|${query}`} theme={theme} compact={compact} noun="questions"
320
+ row={r => <HistoryRow key={r.id} r={r} replies={replies} theme={theme} compact={compact} now={now} />} />
321
+ {!roots.length && <Text style={[t.meta, { paddingVertical: 12 }]}>{query ? "No question or answer has those words." : filter === "open" ? "Nothing open: every question has its answer read." : filter === "tasks" ? "No answer has become a task yet." : "No questions yet. Ask one above."}</Text>}
322
+ </View>
323
+ </View>;
324
+ }
325
+
326
+ const noSubscribe = () => () => undefined;
327
+ /** Whether Paseo's directory has the workspace running: the store Home and the panel already keep, no read of its own. */
328
+ export function useWorkspaceRunning(paseo: PaseoWorkspaces | undefined, workspaceId: string): boolean {
329
+ return useSyncExternalStore(paseo?.subscribe ?? noSubscribe, () => !!paseo?.get(workspaceId)?.archive?.running, () => false);
330
+ }
331
+
332
+ /**
333
+ * The card. `openAgent` opens an agent's chat (absent where there is no navigation). Phones open the history in a
334
+ * sheet; desktop unfolds it in the card.
335
+ */
336
+ export function YourQuestionsCard({ workspaceId, mainAgentId, theme, compact, openAgent, style, running = false, foldAsk = false }: { workspaceId: string; mainAgentId: string | null; theme: Theme; compact: boolean; openAgent?: (agentId: string) => void; style?: object;
337
+ /** Paseo's directory says the workspace is running (no read of its own): asking rows add "the agent is mid-turn". */ running?: boolean;
338
+ /** The pane has a docked reply field: the ask field stays one line until tapped. */ foldAsk?: boolean }) {
339
+ const c = theme.colors; const t = text(c, compact);
340
+ const now = useNow(30_000);
341
+ const q = useWorkspaceQuestions(workspaceId);
342
+ const [history, setHistory] = useState(false);
343
+ const counts = questionCounts({ unread: q.unread, asking: q.asking });
344
+ const total = q.all.length;
345
+ const header = <View style={{ flexDirection: "row", alignItems: "center", flexWrap: "wrap", gap: 8, paddingHorizontal: compact ? 14 : 12, paddingTop: 12, paddingBottom: 10, minHeight: compact ? 44 : undefined }}>
346
+ <Icon name="MessageSquareReply" size={compact ? 16 : 14} color={c.foregroundMuted} />
347
+ <Text accessibilityRole="header" style={[t.label, { flex: 1 }]}>Your questions</Text>
348
+ {!!counts && <View accessibilityLabel={counts} style={{ flexDirection: "row", alignItems: "center", gap: 6 }}>
349
+ {!!q.unread.length && <View style={{ paddingHorizontal: 8, paddingVertical: 1, borderRadius: 999, backgroundColor: tint(c.statusWarning, c) }}><Text style={[t.meta, { color: c.statusWarning, fontWeight: "600" }]}>{`${q.unread.length} answer${q.unread.length === 1 ? "" : "s"}`}</Text></View>}
350
+ {!!q.asking.length && <Text style={t.meta}>{`${q.asking.length} asking`}</Text>}
351
+ </View>}
352
+ </View>;
353
+ const historyRow = total > 0 && <Pressable accessibilityRole="button" aria-expanded={compact ? undefined : history} accessibilityState={compact ? undefined : { expanded: history }} accessibilityLabel={`History, ${total} question${total === 1 ? "" : "s"}`} accessibilityHint="Search every question and answer, kept 30 days" onPress={() => setHistory(v => !v)}
354
+ style={state => ({ flexDirection: "row", alignItems: "center", gap: 8, paddingHorizontal: compact ? 14 : 12, minHeight: compact ? 48 : 38, borderTopWidth: 1, borderTopColor: c.border,
355
+ backgroundColor: (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
356
+ <Icon name={!compact && history ? "ChevronDown" : "ChevronRight"} size={14} color={c.foregroundMuted} />
357
+ <Text style={[t.body, { color: c.foregroundMuted }]}>{`History · ${total}`}</Text>
358
+ <View style={{ flex: 1 }} />
359
+ {!compact && <Text numberOfLines={1} style={t.small}>search, kept 30 days</Text>}
360
+ </Pressable>;
361
+ return <View {...({ dataSet: { yourQuestions: workspaceId } } as object)} style={[{ marginHorizontal: compact ? 16 : 12, marginTop: 12, borderRadius: 8, borderWidth: 1, borderColor: q.unread.length ? withAlpha(c.statusWarning, 0.45) : c.border, backgroundColor: c.surface0, overflow: "hidden" }, style]}>
362
+ {header}
363
+ <AskField workspaceId={workspaceId} theme={theme} compact={compact} folded={foldAsk} />
364
+ {q.unread.map(r => <AnswerItem key={r.id} r={r} theme={theme} compact={compact} now={now} mainAgentId={mainAgentId} openAgent={openAgent} />)}
365
+ {q.asking.map(r => <AskingItem key={r.id} r={r} theme={theme} compact={compact} now={now} busyAgent={!!running} />)}
366
+ {historyRow}
367
+ {!compact && history && <View style={{ paddingHorizontal: 12, paddingBottom: 12, paddingTop: 2 }}><QuestionHistory workspaceId={workspaceId} theme={theme} compact={false} /></View>}
368
+ {compact && <Modal title="Your questions" icon={<Icon name="MessageSquareReply" size={18} color={c.foregroundMuted} />} open={history} onOpenChange={next => { if (!next) setHistory(false); }}>
369
+ <Modal.Content contentContainerStyle={{ padding: 16 }}>
370
+ <QuestionHistory workspaceId={workspaceId} theme={theme} compact />
371
+ </Modal.Content>
372
+ </Modal>}
373
+ </View>;
374
+ }
375
+
package/index.client.tsx CHANGED
@@ -38,7 +38,8 @@ import type { SettingsCategory } from "./shared/settings-nav";
38
38
  import { openReportSheet, ReportSheetHost, setReportFallback } from "./client/report-issue";
39
39
  import { openRename, RenameHost } from "./client/rename";
40
40
  import { setReportError } from "./client/toast-store";
41
- import { reportSendRpc } from "./shared/contracts";
41
+ import { contextAskRpc, reportSendRpc } from "./shared/contracts";
42
+ import { runAction } from "./client/toast-store";
42
43
 
43
44
  /** Home. The same screen id the Overview had, so the sidebar row, ⌘K and saved links land on Home. */
44
45
  const OVERVIEW = HOME_SCREEN;
@@ -114,7 +115,7 @@ export default function contribute(host: PluginClientContext) {
114
115
  let nextToken = 0;
115
116
  const openNext = (from: string | null) => client.openScreen({ screenId: OVERVIEW, params: { next: String(++nextToken), ...(from ? { from } : {}) } });
116
117
 
117
- const removeDisplay = contributeDisplay(client, { id: "follow-up-overview", title: "Follow-up", Component: sidebarItem(sources, OVERVIEW) });
118
+ const removeDisplay = contributeDisplay(client, { id: "follow-up-overview", title: "Follow-up", Component: sidebarItem(sources, OVERVIEW, { openSettings: category => openSettings(category as SettingsCategory) }) });
118
119
  const briefDeps: BriefDeps = {
119
120
  signOff: agentId => void inbox.signOff([agentId]), openNext,
120
121
  openAgent: agentId => client.openScreen({ screenId: OVERVIEW, params: { next: String(++nextToken), open: agentId } }),
@@ -125,7 +126,7 @@ export default function contribute(host: PluginClientContext) {
125
126
  const homeDeps = { sources, openSettings, openPanel, openLog, openQueue, openCatchUp, openStats, openHome: openOverview, openItem, briefDeps, searchKey, newKey };
126
127
  const Overview = (props: PluginScreenProps) => <><FollowHome {...props} deps={homeDeps} />{reportHost(props)}</>;
127
128
  const Panel = (props: PluginWorkspacePanelProps) => <><FollowPanel {...props} openSettings={openSettings} openOverview={openOverview} openLarge={openLarge} inbox={inbox} live={store} briefDeps={briefDeps} sources={sources} />{reportHost(props)}</>;
128
- const Large = (props: PluginScreenProps) => <FollowLarge {...props} openSettings={openSettings} openOverview={openOverview} live={store} />;
129
+ const Large = (props: PluginScreenProps) => <FollowLarge {...props} openSettings={openSettings} openOverview={openOverview} live={store} paseo={paseoWorkspaces} inbox={inbox} />;
129
130
  const removers: (() => unknown)[] = [
130
131
  client.addScreen({ id: OVERVIEW, title: "Follow-up", Component: Overview }),
131
132
  client.addScreen({ id: LARGE_SCREEN, title: params => store.get(params.workspaceId ?? "")?.title ?? "Follow-up", Component: Large }),
@@ -155,6 +156,13 @@ export default function contribute(host: PluginClientContext) {
155
156
  if (args.trim()) await rpc(reportSendRpc, { kind: "bug", text: args.trim(), agentId: agent.id }).catch(() => openReportSheet({ agentId: agent.id, workspaceId: workspace.id }));
156
157
  else openReportSheet({ agentId: agent.id, workspaceId: workspace.id });
157
158
  } }),
159
+ // /ask <question> (docs/needs-you.md#your-questions): asks *this* agent; the answer lands in Your questions. A
160
+ // refusal (an untracked workspace, no words) shows its error.
161
+ client.addSlashCommand({ name: "ask", description: "Ask this agent; Follow-up keeps the answer", argumentHint: "your question", context: "agent", async onSubmit({ args, agent, workspace, rpc }) {
162
+ const ask = args.trim();
163
+ await runAction({ label: "Ask", failure: "Couldn't ask", success: "Asked · the answer lands in Follow-up's Your questions",
164
+ run: async () => { if (!ask) throw new Error("Write the question after /ask."); return rpc(contextAskRpc, { workspaceId: workspace.id, agentId: agent.id, ask, via: "slash" }); } });
165
+ } }),
158
166
  client.addSlashCommand({ name: "follow-up", description: "Open this workspace's PRs and remaining work", argumentHint: "", context: "agent", onSubmit({ openPanel }) { openPanel(PANEL, { location: location() }); } }),
159
167
  contributeChat(client),
160
168
  // Agents and workspaces an agent creates: a card that opens them, relayed through Home (timeline items get no navigation).