paseo-follow-up 2.5.1 → 2.6.0-beta.10

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 (196) hide show
  1. package/OVERVIEW.md +2 -6
  2. package/README.md +1 -2
  3. package/client/agent-card.tsx +113 -0
  4. package/client/brief-since.tsx +6 -4
  5. package/client/brief.tsx +82 -32
  6. package/client/catch-up.tsx +82 -24
  7. package/client/compass-settings.tsx +11 -9
  8. package/client/display.tsx +25 -4
  9. package/client/dock.ts +31 -0
  10. package/client/docked-pane.tsx +10 -50
  11. package/client/field.tsx +83 -0
  12. package/client/floating-surface.tsx +79 -0
  13. package/client/fold.tsx +49 -0
  14. package/client/header.tsx +22 -9
  15. package/client/hint.tsx +60 -0
  16. package/client/home-chrome.tsx +141 -51
  17. package/client/home-data.ts +45 -2
  18. package/client/home-list.tsx +142 -42
  19. package/client/home-view.ts +35 -13
  20. package/client/home.tsx +116 -48
  21. package/client/inbox-store.ts +37 -1
  22. package/client/keyboard.tsx +159 -0
  23. package/client/keys.ts +2 -0
  24. package/client/kit.tsx +51 -20
  25. package/client/large.tsx +18 -50
  26. package/client/linked.tsx +6 -4
  27. package/client/live.tsx +45 -11
  28. package/client/merge-button.tsx +3 -2
  29. package/client/messages.tsx +8 -2
  30. package/client/more-context.tsx +26 -11
  31. package/client/morning-brief-settings.tsx +14 -11
  32. package/client/needs-you.tsx +37 -16
  33. package/client/new-settings.tsx +12 -10
  34. package/client/new.tsx +6 -4
  35. package/client/now-lines.tsx +80 -0
  36. package/client/on-screen.tsx +43 -0
  37. package/client/onboarding.tsx +58 -125
  38. package/client/open-link.ts +56 -0
  39. package/client/paged-list.tsx +115 -0
  40. package/client/pane-allowlist.ts +0 -2
  41. package/client/panel.tsx +174 -53
  42. package/client/pending-answers.ts +74 -14
  43. package/client/pill.tsx +6 -13
  44. package/client/pr-sheet.tsx +5 -3
  45. package/client/pr-stats-settings.tsx +8 -6
  46. package/client/pr-stats.tsx +10 -10
  47. package/client/question-context.tsx +64 -0
  48. package/client/questions.tsx +117 -93
  49. package/client/release-notes.tsx +13 -11
  50. package/client/rename.tsx +3 -2
  51. package/client/report-issue.tsx +27 -8
  52. package/client/review-mode.tsx +3 -2
  53. package/client/reviewers.tsx +14 -7
  54. package/client/rich-text.tsx +2 -2
  55. package/client/row-actions.ts +14 -4
  56. package/client/row-menu.tsx +7 -23
  57. package/client/row-open.ts +28 -0
  58. package/client/scroll-allowlist.ts +1 -0
  59. package/client/search-key.ts +4 -7
  60. package/client/section-search.tsx +5 -3
  61. package/client/settings-shell.tsx +9 -15
  62. package/client/settings.tsx +41 -17
  63. package/client/setup-dialog.tsx +168 -0
  64. package/client/setup-gate.tsx +69 -0
  65. package/client/setup-ui.ts +27 -0
  66. package/client/shared-read.ts +22 -0
  67. package/client/shipping.tsx +8 -6
  68. package/client/sidebar-view.tsx +24 -7
  69. package/client/spec.tsx +9 -5
  70. package/client/stacks.tsx +35 -18
  71. package/client/tasks.tsx +21 -16
  72. package/client/theme.ts +0 -8
  73. package/client/toast-store.ts +22 -0
  74. package/client/turn-view.tsx +433 -0
  75. package/client/updates.tsx +3 -2
  76. package/client/why-it-matters.tsx +5 -3
  77. package/client/workspace-data.ts +33 -4
  78. package/client/your-questions.tsx +390 -0
  79. package/docs/screenshots/follow-up-slide-1-cover.png +0 -0
  80. package/docs/screenshots/follow-up-slide-2-decision.png +0 -0
  81. package/docs/screenshots/follow-up-slide-3-overseer.png +0 -0
  82. package/docs/screenshots/follow-up-slide-4-repairs.png +0 -0
  83. package/docs/screenshots/follow-up-slide-5-deploy.png +0 -0
  84. package/docs/screenshots/follow-up-slide-6-catch-up.png +0 -0
  85. package/index.client.tsx +40 -22
  86. package/index.server.ts +255 -64
  87. package/package.json +7 -2
  88. package/paseo-plugin.json +1 -1
  89. package/scripts/build.mjs +5 -2
  90. package/scripts/inline.mjs +22 -0
  91. package/server/agent-actions.ts +69 -25
  92. package/server/agent-hook.mjs +75 -149
  93. package/server/agent-parity.ts +26 -7
  94. package/server/ai-jobs.ts +26 -5
  95. package/server/bounded-reply.ts +42 -0
  96. package/server/brief-timeline.ts +47 -0
  97. package/server/check-watches.ts +8 -7
  98. package/server/compass.ts +5 -0
  99. package/server/context-requests.ts +90 -21
  100. package/server/daemon.ts +43 -5
  101. package/server/directory.ts +9 -1
  102. package/server/discovery.ts +4 -1
  103. package/server/engine.ts +68 -10
  104. package/server/feeds.ts +25 -10
  105. package/server/github.ts +22 -7
  106. package/server/hook-source.ts +302 -149
  107. package/server/inbox-classifier.ts +17 -0
  108. package/server/inbox-directory.ts +1 -1
  109. package/server/inbox.ts +33 -3
  110. package/server/job-agent.ts +13 -2
  111. package/server/list-cache.ts +29 -11
  112. package/server/mcp-source.ts +275 -74
  113. package/server/mcp.d.mts +9 -6
  114. package/server/mcp.mjs +133 -81
  115. package/server/native-tools.ts +23 -10
  116. package/server/obligations.ts +9 -5
  117. package/server/overseer-prompt-source.ts +2 -2
  118. package/server/overseer-prompt.md +2 -2
  119. package/server/questions.ts +2 -1
  120. package/server/report-issue/index.ts +42 -11
  121. package/server/report-issue-adapter.ts +125 -5
  122. package/server/report-send.ts +3 -3
  123. package/server/scheduled-tasks.ts +10 -8
  124. package/server/session-prompt.ts +78 -25
  125. package/server/tasks.ts +2 -1
  126. package/server/transcript.ts +68 -0
  127. package/server/turn-end.ts +129 -0
  128. package/server/turn-events.ts +8 -3
  129. package/server/turn-timeline.ts +35 -11
  130. package/server/wait-jobs.ts +43 -3
  131. package/server/wait-runner-source.ts +1 -1
  132. package/server/wait-runner.sh +1 -1
  133. package/server/wait.ts +17 -12
  134. package/shared/activity.ts +4 -2
  135. package/shared/agent-settings.ts +9 -8
  136. package/shared/agent-text.d.mts +28 -0
  137. package/shared/agent-text.mjs +133 -0
  138. package/shared/ask-shape.ts +28 -0
  139. package/shared/attention.ts +8 -7
  140. package/shared/brief.ts +38 -15
  141. package/shared/catch-up.ts +65 -20
  142. package/shared/chat.ts +4 -4
  143. package/shared/check-watch.ts +18 -3
  144. package/shared/compass.ts +5 -4
  145. package/shared/contracts.ts +71 -13
  146. package/shared/dispatch.ts +19 -3
  147. package/shared/display.ts +43 -6
  148. package/shared/finished.ts +20 -0
  149. package/shared/floating.ts +38 -0
  150. package/shared/follow-up.ts +2 -1
  151. package/shared/history.ts +208 -0
  152. package/shared/home-arrange.ts +99 -0
  153. package/shared/home-keys.ts +1 -0
  154. package/shared/home.ts +71 -12
  155. package/shared/inbox.ts +11 -0
  156. package/shared/issue-workspace.ts +25 -3
  157. package/shared/job-rows.ts +2 -2
  158. package/shared/linear-queue.ts +7 -0
  159. package/shared/link-open.ts +26 -0
  160. package/shared/list-entries.ts +34 -7
  161. package/shared/list.ts +67 -3
  162. package/shared/message-sender.ts +2 -0
  163. package/shared/model.ts +36 -5
  164. package/shared/new-name.ts +4 -1
  165. package/shared/now.ts +237 -0
  166. package/shared/onboarding.ts +17 -13
  167. package/shared/optimistic-answers.ts +79 -0
  168. package/shared/overseer.ts +4 -3
  169. package/shared/paged.ts +96 -0
  170. package/shared/peek.ts +131 -0
  171. package/shared/placeholder-fit.ts +65 -0
  172. package/shared/pr-actions.ts +2 -1
  173. package/shared/pr-status.ts +61 -0
  174. package/shared/presentation.ts +3 -23
  175. package/shared/provider-support.ts +83 -34
  176. package/shared/recommend.ts +1 -1
  177. package/shared/reopen.ts +50 -0
  178. package/shared/report-send.ts +20 -1
  179. package/shared/row-menu.ts +14 -1
  180. package/shared/search.ts +13 -0
  181. package/shared/send-decision.ts +37 -4
  182. package/shared/settings-nav.ts +20 -1
  183. package/shared/setup-popup.ts +28 -0
  184. package/shared/sort.ts +14 -1
  185. package/shared/status-invariants.ts +39 -0
  186. package/shared/status.ts +3 -1
  187. package/shared/task-due.ts +9 -20
  188. package/shared/task-dup.ts +2 -1
  189. package/shared/task-status.ts +2 -1
  190. package/shared/turn-checks.d.mts +32 -0
  191. package/shared/turn-checks.mjs +91 -0
  192. package/shared/turn.ts +211 -0
  193. package/shared/wait.ts +2 -2
  194. package/shared/workspace-layout.ts +62 -0
  195. package/shared/your-questions.ts +133 -0
  196. package/skills/follow-up/SKILL.md +1 -1
package/OVERVIEW.md CHANGED
@@ -22,15 +22,11 @@ you, in one place, ranked.
22
22
  It answers, or passes your words to the agent doing the work.
23
23
  - **Catch up** after a meeting or a morning away, one card at a time, on the desktop or your phone.
24
24
  - **PR statistics** show who opens, merges and reviews PRs, and how long PRs wait for a first review.
25
- - **Any provider:** agents on Claude Code, Codex, OpenCode, Pi, Copilot, Cursor and more get Follow-up's tools.
25
+ - **Any provider:** agents on Claude Code, Codex, OpenCode, Pi, Copilot, Cursor and more get every Follow-up feature.
26
26
 
27
27
  It never merges, requests reviewers, archives, answers a question for you or wakes a resting agent on its own.
28
28
 
29
- ## Install
30
-
31
- ```sh
32
- paseo plugin install npm:paseo-follow-up
33
- ```
29
+ ## Requirements
34
30
 
35
31
  You need Paseo 0.15 or later and Node 22+ on the machine Paseo runs on. A signed-in GitHub CLI there is optional and
36
32
  turns on the PR features. Then open Follow-up in Paseo's sidebar: a two-minute setup walks you through the rest.
package/README.md CHANGED
@@ -14,7 +14,7 @@ your attention instead. The work comes to you, in one place, ranked.
14
14
 
15
15
  <img alt="Follow-up: Every agent, one inbox. Home lists every workspace by what it needs from you, with an agent's question and its lettered options open beside the list" src="https://raw.githubusercontent.com/tomgrin10/paseo-follow-up/main/docs/screenshots/follow-up-slide-1-cover.png">
16
16
 
17
- [![Follow-up in 36 seconds: Home, Catch up, automatic follow-ups, the Overseer](https://cdn.jsdelivr.net/gh/tomgrin10/paseo-follow-up@635e600d3390e23ea786492780755afda591bb45/docs/screenshots/follow-up-demo-v2-poster.png)](https://cdn.jsdelivr.net/gh/tomgrin10/paseo-follow-up@635e600d3390e23ea786492780755afda591bb45/docs/screenshots/follow-up-demo-v2.mp4)
17
+ [![Follow-up in 36 seconds: Home, Catch up, automatic follow-ups, the Overseer](https://cdn.jsdelivr.net/gh/tomgrin10/paseo-follow-up@4b3fc08b7c8176d751c83c37ca471f61db4001ec/docs/screenshots/follow-up-demo-v2-poster.png)](https://cdn.jsdelivr.net/gh/tomgrin10/paseo-follow-up@4b3fc08b7c8176d751c83c37ca471f61db4001ec/docs/screenshots/follow-up-demo-v2.mp4)
18
18
 
19
19
  36 seconds: Home, Catch up, automatic follow-ups, the Overseer.
20
20
 
@@ -131,7 +131,6 @@ Steve Castaneda (questions with lettered options; MIT, see [THIRD_PARTY_NOTICES.
131
131
 
132
132
  [Defer](https://github.com/tomgrin10/paseo-defer),
133
133
  [Send to Paseo](https://github.com/tomgrin10/send-to-paseo),
134
- [Session Guard](https://github.com/tomgrin10/paseo-session-guard),
135
134
  [Smart Session](https://github.com/tomgrin10/paseo-smart-session),
136
135
  [Transcript Search](https://github.com/tomgrin10/paseo-transcript-search),
137
136
  [Transfer](https://github.com/tomgrin10/paseo-transfer),
@@ -0,0 +1,113 @@
1
+ import { useEffect, useState } from "react";
2
+ import { View } from "react-native";
3
+ import { usePaseo } from "@getpaseo/plugin/client";
4
+ import { Text } from "./text";
5
+ import type { InboxStore } from "./inbox-store";
6
+ import { useInbox } from "./inbox";
7
+ import { AgentLines } from "./now-lines";
8
+ import { FoldButton, PANEL_FOLDS, useFold } from "./fold";
9
+ import { HintBubble, HintIcon, useHint } from "./hint";
10
+ import { ReplyBox } from "./home";
11
+ import { TurnView, useTurn } from "./turn-view";
12
+ import { useMarkTimelineOnScreen } from "./on-screen";
13
+ import { Spinner } from "./motion";
14
+ import { PrLinksProvider } from "./rich-text";
15
+ import { prLinksByNumber } from "../shared/presentation";
16
+ import { raised, runningColor } from "./theme";
17
+ import type { Theme } from "./kit";
18
+ import type { Workspace } from "../shared/model";
19
+ import type { InboxRow } from "../shared/inbox";
20
+ import { turnSource } from "../shared/turn";
21
+
22
+ /** Where the workspace view is mounted. Only two things differ by place: the head's own controls and the reply box. */
23
+ export type ViewPlace = "home" | "panel" | "tab";
24
+
25
+ const NO_INBOX = { subscribe: () => () => undefined, version: () => 0, rows: () => [] } as unknown as InboxStore;
26
+ const NO_ROWS: readonly InboxRow[] = [];
27
+
28
+ export const STEPS_HINT = "Live while shown. A resting agent's steps come from its saved transcript, so it is never woken.";
29
+ const HOME_REPLY_HINT = " Sending clears Needs you; Sign off & next moves on without a reply.";
30
+
31
+ /**
32
+ * The agent card (docs/client.md#the-workspace-view): one row per agent (client/now-lines.tsx), then Recent steps (the
33
+ * peek's rows, client/turn-view.tsx: the developer's messages, the agent's replies, steps grouped) and the reply box
34
+ * right under them, so reading and replying are one place. A row switches the steps and the box to its agent; Cmd/Ctrl
35
+ * opens its chat. Recent steps reads live while shown and an unloaded agent's saved transcript otherwise, never waking
36
+ * it (invariant 1). Its fold (the arrow on the Recent steps line) folds the steps and the box; the rows stay.
37
+ *
38
+ * The side panel (`place` "panel") sits beside the workspace's chat, so it never draws the reply box and its Recent
39
+ * steps start folded; the developer's own fold choice wins everywhere (invariant 132). Home's pane and the main tab mark
40
+ * the selected agent's timeline as on screen while its steps show, so its status-line peek stays shut.
41
+ */
42
+ export function AgentCard({ workspace: w, inbox, theme, compact, steps, now, place, openAgent, onSent, reply }: {
43
+ workspace: Workspace; inbox?: InboxStore; theme: Theme; compact: boolean;
44
+ /** How many rows of steps the layout tier shows (shared/workspace-layout.ts). */
45
+ steps: number; now: number; place: ViewPlace;
46
+ openAgent?: (agentId: string) => void;
47
+ /** After a reply went out (Home refreshes its inbox rows). */
48
+ onSent?: () => void;
49
+ /** Draw the reply box under Recent steps: never in the side panel, and not on a phone's Home, whose dock has it. */
50
+ reply: boolean;
51
+ }) {
52
+ const c = theme.colors;
53
+ const rows = useInbox(inbox ?? NO_INBOX, () => inbox?.rows() ?? NO_ROWS);
54
+ const [selected, setSelected] = useState(w.mainAgentId);
55
+ // A new main agent (Make main agent, a claim) moves the card to it.
56
+ useEffect(() => { setSelected(w.mainAgentId); }, [w.mainAgentId]);
57
+ const name = selected === w.mainAgentId ? "the main agent" : rows.find(r => r.agentId === selected)?.title?.trim() || w.taskAgents?.[selected]?.title?.trim() || "the agent";
58
+ const pick = (agentId: string, chat: boolean) => { if (chat && openAgent) openAgent(agentId); else setSelected(agentId); };
59
+ const [hintOpen, setHintOpen] = useState(false);
60
+ return <View style={[{ marginHorizontal: compact ? 16 : 12, marginTop: 12, borderRadius: 8, overflow: hintOpen ? "visible" : "hidden", zIndex: hintOpen ? 30 : undefined, backgroundColor: c.surface0 }, raised(c)]}>
61
+ <AgentLines workspace={w} inbox={inbox} theme={theme} compact={compact} now={now} openAgent={openAgent} peek={place === "panel"} bare selected={selected} onSelect={pick} />
62
+ <View style={{ borderTopWidth: 1, borderTopColor: c.border }}>
63
+ <RecentSteps agentId={selected} name={name} theme={theme} compact={compact} steps={steps} place={place} reply={reply} prs={w.prs} onSent={onSent} onHint={setHintOpen} />
64
+ </View>
65
+ </View>;
66
+ }
67
+
68
+ /**
69
+ * Recent steps for one agent, with its fold, its ? hint and (when `reply`) the reply box under it: the agent card's
70
+ * lower half, and on its own in Home's pane for a row with no workspace and for the Overseer. Never wakes the agent.
71
+ */
72
+ export function RecentSteps({ agentId, name, theme, compact, steps, place, reply, prs = [], onSent, onHint, empty }: {
73
+ agentId: string | null; name: string; theme: Theme; compact: boolean; steps: number; place: ViewPlace; reply: boolean;
74
+ prs?: Workspace["prs"]; onSent?: () => void;
75
+ /** The ? hint opened or closed (the card lets it draw past its edge). */
76
+ onHint?: (open: boolean) => void;
77
+ /** What an empty turn says; the default points at the reply box or the chat. */
78
+ empty?: string;
79
+ }) {
80
+ const c = theme.colors;
81
+ const fold = useFold(PANEL_FOLDS.steps, place !== "panel");
82
+ const open = fold.open;
83
+ useMarkTimelineOnScreen(place !== "panel" && open ? agentId : null);
84
+ const turn = useTurn(agentId, open);
85
+ const paseo = usePaseo();
86
+ const [hintOpen, setHintOpen] = useState(false);
87
+ const help = useHint(next => { setHintOpen(next); onHint?.(next); });
88
+ const caption = turn.running ? "live" : turnSource(turn);
89
+ const hint = STEPS_HINT + (place === "home" && reply ? HOME_REPLY_HINT : "");
90
+ return <View style={{ zIndex: hintOpen ? 30 : undefined }}>
91
+ <View style={{ zIndex: hintOpen ? 30 : undefined, flexDirection: "row", alignItems: "center" }}>
92
+ <FoldButton open={open} onToggle={fold.toggle} label={caption ? `Recent steps, ${caption}` : "Recent steps"} theme={theme} chevron="end"
93
+ style={(hovered, pressed) => ({ flex: 1, minWidth: 0, flexDirection: "row", alignItems: "center", gap: 7, paddingHorizontal: compact ? 14 : 12, paddingVertical: 8, minHeight: compact ? 44 : undefined, backgroundColor: pressed ? c.surface2 : hovered ? c.surface1 : "transparent" })}>
94
+ <Text numberOfLines={1} style={{ flexShrink: 0, color: c.foreground, fontSize: compact ? 13 : 12, fontWeight: "600" }}>Recent steps</Text>
95
+ <HintIcon hint={help} text={hint} theme={theme} compact={compact} />
96
+ <View style={{ flex: 1, minWidth: 0, flexDirection: "row", justifyContent: "flex-end", alignItems: "center", gap: 5 }}>
97
+ {turn.running && <View style={{ width: 6, height: 6, borderRadius: 3, backgroundColor: runningColor(c) }} />}
98
+ {!!caption && <Text numberOfLines={1} style={{ flexShrink: 1, color: c.foregroundMuted, fontSize: 12 }}>{caption}</Text>}
99
+ </View>
100
+ </FoldButton>
101
+ <HintBubble hint={help} text={hint} theme={theme} />
102
+ </View>
103
+ {open && <View style={{ paddingHorizontal: compact ? 14 : 12, paddingBottom: reply ? 0 : 12, gap: 8 }}>
104
+ {turn.error ? <Text style={{ color: c.foregroundMuted, fontSize: 12 }}>{`Couldn't read the steps: ${turn.error}`}</Text>
105
+ : !agentId ? null
106
+ : !turn.turn ? <Spinner color={c.foregroundMuted} size={12} label="Reading the agent's steps" />
107
+ : turn.turn.empty ? <Text style={{ color: c.foregroundMuted, fontSize: 12, lineHeight: 17 }}>{empty ?? (reply ? "No messages yet. Write to the agent below, or open its chat." : "No messages yet. Open its chat to write to it.")}</Text>
108
+ : <PrLinksProvider prs={prLinksByNumber(prs)}><TurnView turn={turn.turn} theme={theme} maxRows={steps} /></PrLinksProvider>}
109
+ </View>}
110
+ {open && reply && agentId && <ReplyBox theme={theme} compact={compact} agentName={name} hint={null} placeholder={`Reply to ${name}`} target={{ kind: "agent", agentId }}
111
+ onSend={async (text, images) => { await paseo.agents.ref(agentId).send(text, images?.length ? { images } : undefined); onSent?.(); }} />}
112
+ </View>;
113
+ }
@@ -1,4 +1,6 @@
1
+ import { queueMoved } from "../shared/linear-queue";
1
2
  import { useCallback, useEffect, useRef, useState } from "react";
3
+ import { PagedRows } from "./paged-list";
2
4
  import { Platform, View } from "react-native";
3
5
  import { Pressable, Text } from "./text";
4
6
  import { useRpc } from "@getpaseo/plugin/client";
@@ -119,7 +121,7 @@ export function SinceBlock({ theme, compact, openQueue, onStarted, navigation, r
119
121
  const { view, error, reload } = useQueueView({ open: true });
120
122
  // The home feed's queue revision moved (a sweep ended, or a dismissal): an open brief pane re-reads, no timer.
121
123
  const seen = useRef(revision);
122
- useEffect(() => { if (seen.current === revision) return; seen.current = revision; void reload(); }, [revision, reload]);
124
+ useEffect(() => { const moved = queueMoved(seen.current, revision); seen.current = revision; if (moved) void reload(); }, [revision, reload]);
123
125
  const actions = useActions();
124
126
  if (error && !view) return <View style={{ gap: 4, marginTop: 6 }}>
125
127
  <Text accessibilityRole="header" style={t.section}>Your Linear queue</Text>
@@ -261,7 +263,7 @@ export function QueueScreen({ theme, compact, onHome, navigation }: { theme: The
261
263
  {view && !view.groups.length && <Text style={t.meta}>{filter === "all" ? "Nothing is assigned to you in the queue's states." : filter === "changed" ? "Nothing changed since you last read the brief." : "Every issue in your queue has a workspace."}</Text>}
262
264
  {view?.groups.map(g => <View key={g.priority} style={{ gap: 0 }}>
263
265
  <Text accessibilityRole="header" style={[t.section, { marginTop: 8 }]}>{g.name} · {g.count}</Text>
264
- {g.issues.map(i => <QueueRow key={i.key} i={i} change={changes.get(i.key)} c={c} compact={compact} timeZone={tz} navigation={navigation} />)}
266
+ <PagedRows items={g.issues} resetKey={filter} theme={theme} compact={compact} noun="issues" row={i => <QueueRow key={i.key} i={i} change={changes.get(i.key)} c={c} compact={compact} timeZone={tz} navigation={navigation} />} />
265
267
  </View>)}
266
268
  </ScrollView>;
267
269
  }
@@ -281,7 +283,7 @@ export function NobodyRows({ theme, compact, data, onDismissed }: { theme: Theme
281
283
  // pushes the new list on the home feed; without the feed, onDismissed reads it once.
282
284
  const dismiss = useDismiss(onDismissed);
283
285
  const now = Date.now();
284
- return <>{data.needs.map(r => {
286
+ return <PagedRows items={data.needs} theme={theme} compact={compact} noun="issues" row={r => {
285
287
  const row = nobodyRow(r, now, data.timeZone);
286
288
  const first = r.reasons[0]!;
287
289
  const reason = <PriorityLine reason={first.line} source={first.from === "compass" ? { kind: "compass", label: first.source } : { kind: "linear", label: first.source }} c={c} size={compact ? 12 : 11} lines={compact ? 2 : 1} />;
@@ -317,5 +319,5 @@ export function NobodyRows({ theme, compact, data, onDismissed }: { theme: Theme
317
319
  </View>
318
320
  </>}
319
321
  </RevealScope>;
320
- })}</>;
322
+ }} />;
321
323
  }
package/client/brief.tsx CHANGED
@@ -1,12 +1,13 @@
1
1
  import { useMemo, useState, useSyncExternalStore, type ReactNode } from "react";
2
+ import { LinkWorkspaceProvider, openLinkQuietly } from "./open-link";
2
3
  import { browserKey, liveBriefKey, LIVE_BRIEF_POLL_MS, workspaceKey } from "./keys";
3
4
  import { Platform, View, useWindowDimensions } from "react-native";
4
5
  import { Pressable, Text } from "./text";
5
6
  import { useQuery, useQueryClient } from "@tanstack/react-query";
6
- import { openExternalUrl, useRpc, type PluginClientContext, type PluginTimelineItemProps } from "@getpaseo/plugin/client";
7
+ import { useRpc, type PluginClientContext, type PluginTimelineItemProps } from "@getpaseo/plugin/client";
7
8
  import { deliveryStatus } from "../shared/queue";
8
- import { Icon, TextInput, copyText, useToast } from "@getpaseo/plugin/client/ui";
9
- import { BRIEF_KIND, briefCardAsk, BRIEF_VERSION, askedDecisions, cardPicks, notedCount, pickedCount, briefSchema, collapsedLine, outcomeLabel, extrasFit, hasOriginal, nothingNeededLine, isTight, pastRows, pastTone, selectsFirst, sendBar, shownBrief, pastAsk, liveBrief, newAnswerId, type Brief, type BriefDecision, type BriefMove } from "../shared/brief";
9
+ import { Icon, copyText, useToast } from "@getpaseo/plugin/client/ui";
10
+ import { BRIEF_KIND, briefCardAsk, BRIEF_VERSION, askedDecisions, cardPicks, decisionQuestion, notedCount, pickedCount, briefSchema, collapsedLine, outcomeLabel, extrasFit, hasOriginal, nothingNeededLine, isTight, pastRows, pastTone, selectsFirst, sendBar, shownBrief, pastAsk, liveBrief, newAnswerId, answeredOutcome, type Brief, type BriefDecision, type BriefMove } from "../shared/brief";
10
11
  import { needsYou } from "../shared/attention";
11
12
  import { age, briefOutlived } from "../shared/inbox";
12
13
  import { noReviewReposVersion, onNoReviewRepos } from "../shared/pr-workflow";
@@ -17,6 +18,7 @@ import { answerQuestionRpc, briefActionRpc, browserStatusRpc, inboxBriefRpc } fr
17
18
  import { ImageField, useImageAttachments, type ImageAttachments } from "./image-attach";
18
19
  import { errorText, mootNote } from "../shared/errors";
19
20
  import { PRIMARY_FORM } from "./dock";
21
+ import { QuestionContextBlock } from "./question-context";
20
22
  import { OTHER, OTHER_LABEL, OWN_ANSWER_HINT, briefAnswerStatus, isDoneOnly, isOpen, isOther, TASK_DONE, type Question } from "../shared/questions";
21
23
  import type { ListQuestion, ListWorkspace } from "../shared/list";
22
24
  import { useDetailGate, useWorkspace } from "./workspace-data";
@@ -30,6 +32,8 @@ import { PrSheet } from "./pr-sheet";
30
32
  import { isLight, withAlpha, type Colors } from "./theme";
31
33
  import { dismissToast, notice, runAction, runUndoable } from "./toasts";
32
34
  import { DismissX, RevealScope, useDismiss } from "./dismiss";
35
+ import { clearPendingAnswer, confirmPendingAnswer, failPendingAnswer, markSentHere, setPendingAnswer } from "./pending-answers";
36
+ import { Field } from "./field";
33
37
 
34
38
  /**
35
39
  * The brief card (design §2): the ask in one line, decisions as option rows, only the context needed, and the one
@@ -48,6 +52,8 @@ export type BriefDeps = {
48
52
  /** Done's Undo window, so the composer pill says Done (and its Undo cancels the same toast) until it ends. */
49
53
  noteDone?(agentId: string, cancel: () => void): void;
50
54
  endDone?(agentId: string): void;
55
+ /** answering-is-optimistic: the agent's inbox row reads as answered while the card's answer is on its way; returns the rollback. */
56
+ holdAnswered?(agentId: string): () => void;
51
57
  };
52
58
 
53
59
  const mono = () => (Platform.OS === "ios" ? "Menlo" : "ui-monospace, SFMono-Regular, Menlo, monospace");
@@ -164,7 +170,12 @@ export function NoteLink({ icon, label, a11y, disabled, onPress, c, compact }: {
164
170
  * The card's body: decisions, error text, details, context, facts and links, and the agent's extra ask. Shared by the
165
171
  * open card and by a past card's read-only "Show full question", so a past question reads exactly as it was asked.
166
172
  */
167
- export function BriefBody({ b, c, compact, tight, embedded, height, mode, picks, onPick, busy, onSend, words = {}, onWords, onSendOther, notes = {}, notesOpen = {}, onNote, onNoteOpen, doneIds = [], img }: {
173
+ export function BriefBody({ b, c, compact, tight, embedded, height, mode, picks, onPick, busy, onSend, words = {}, onWords, onSendOther, notes = {}, notesOpen = {}, onNote, onNoteOpen, doneIds = [], img, workspace, openAgent }: {
174
+ /**
175
+ * The brief's workspace (list form): a decision that is a tracked question draws that question's context under it,
176
+ * as QuestionBody does (one-answer-flow-for-every-question). Absent: the card has only its own snapshot.
177
+ */
178
+ workspace?: ListWorkspace; openAgent?: (agentId: string) => void;
168
179
  /** The card's pasted images (one model for its answer and note fields). Absent: read-only copies. */
169
180
  img?: ImageAttachments;
170
181
  /** one-done-button: decisions answered by the card's Done button (an action card), drawn without option rows. */
@@ -194,6 +205,7 @@ export function BriefBody({ b, c, compact, tight, embedded, height, mode, picks,
194
205
  return <>
195
206
  {b.decisions.map((d, i) => { const done = !readonly && doneIds.includes(d.id); return <View key={d.id} accessibilityRole={mode === "select" ? "radiogroup" : undefined} accessibilityLabel={mode === "select" ? d.question : undefined} style={{ gap: 8 }}>
196
207
  {(numbered || d.question.trim() !== b.ask.trim()) && <RichText style={{ color: c.foreground, fontSize: 14, lineHeight: 20, fontWeight: numbered ? "600" : "400" }}>{`${numbered ? `${i + 1}. ` : ""}${d.question}`}</RichText>}
208
+ {(() => { const q = workspace ? decisionQuestion(b, d.id, workspace.questions) : null; return q && workspace ? <QuestionContextBlock workspace={workspace} question={q} theme={{ colors: c }} compact={compact} open={!readonly && isOpen(q)} openAgent={openAgent} /> : null; })()}
197
209
  {d.options.length > 0 && <View style={{ gap: 6 }}>
198
210
  {!done && d.options.map(o => <OptionRow key={o.letter} option={o} recommended={d.recommend === o.letter} mode={mode} answerLabel={answerLabel} selected={readonly ? d.chosen === o.letter : picks[d.id] === o.letter} answered={readonly && !!d.chosen}
199
211
  sending={busy === `${d.id}:${o.letter}`} disabled={!!busy} tight={tight && !readonly} withNote={!!notesOpen[d.id] && !!notes[d.id]?.trim()}
@@ -205,7 +217,7 @@ export function BriefBody({ b, c, compact, tight, embedded, height, mode, picks,
205
217
  onPress={() => onPick(d.id, OTHER)} c={c} compact={compact} />}
206
218
  {/* Something else's field with its Send answer, kept on screen together while typing (DockedPane). */}
207
219
  {!readonly && isOther(picks[d.id]) && <View {...PRIMARY_FORM} style={{ gap: 8 }}>
208
- <WithImages img={img} c={c} compact={compact} row={rowAt === d.id}><TextInput accessibilityLabel={`Your answer${numbered ? ` to question ${i + 1}` : ""}, required`} placeholder="Your answer (required)" placeholderTextColor={c.foregroundMuted} autoFocus multiline maxLength={2000}
220
+ <WithImages img={img} c={c} compact={compact} row={rowAt === d.id}><Field accessibilityLabel={`Your answer${numbered ? ` to question ${i + 1}` : ""}, required`} placeholder="Your answer (required)" placeholderTextColor={c.foregroundMuted} autoFocus multiline maxLength={2000}
209
221
  value={words[d.id] ?? ""} editable={!busy} onChangeText={t => onWords?.(d.id, t)}
210
222
  style={{ minHeight: compact ? 66 : 58, paddingHorizontal: 10, paddingVertical: 8, borderRadius: 8, borderWidth: 1, borderColor: words[d.id]?.trim() ? c.border : withAlpha(c.accent, 0.7), color: c.foreground, backgroundColor: c.surface0, fontSize: 14, lineHeight: 20, textAlignVertical: "top" }} /></WithImages>
211
223
  {mode === "send" && <View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 10 }}>
@@ -216,7 +228,7 @@ export function BriefBody({ b, c, compact, tight, embedded, height, mode, picks,
216
228
  {/* A note on a lettered pick ("A, but…"): quiet until asked for, never in the way of the one-tap answer. */}
217
229
  {!readonly && !isOther(picks[d.id]) && (notesOpen[d.id] ? <View {...PRIMARY_FORM} style={{ gap: 6, marginTop: 2 }}>
218
230
  <Text style={{ color: c.foregroundMuted, fontSize: 12, lineHeight: 16, fontWeight: "600" }}>Note</Text>
219
- <WithImages img={img} c={c} compact={compact} row={rowAt === d.id}><TextInput accessibilityLabel={`Note for the agent${numbered ? ` on decision ${i + 1}` : ""}, optional`} placeholder={mode === "select" ? "Sent with your pick for this decision" : "Sent with the option you tap"}
231
+ <WithImages img={img} c={c} compact={compact} row={rowAt === d.id}><Field accessibilityLabel={`Note for the agent${numbered ? ` on decision ${i + 1}` : ""}, optional`} placeholder={mode === "select" ? "Sent with your pick for this decision" : "Sent with the option you tap"}
220
232
  placeholderTextColor={c.foregroundMuted} autoFocus={focusNote === d.id} multiline maxLength={2000} value={notes[d.id] ?? ""} editable={!busy} onChangeText={t => onNote?.(d.id, t)}
221
233
  style={{ minHeight: compact ? 66 : 58, paddingHorizontal: 10, paddingVertical: 8, borderRadius: 8, borderWidth: 1, borderColor: c.border, color: c.foreground, backgroundColor: c.surface0, fontSize: 14, lineHeight: 20, textAlignVertical: "top" }} /></WithImages>
222
234
  <NoteLink icon="X" label="Remove note" a11y={`Remove the note${numbered ? ` on decision ${i + 1}` : ""}`} disabled={!!busy} onPress={() => { onNote?.(d.id, ""); onNoteOpen?.(d.id, false); setFocusNote(null); }} c={c} compact={compact} />
@@ -252,7 +264,7 @@ export function BriefBody({ b, c, compact, tight, embedded, height, mode, picks,
252
264
  <Icon name={f.icon} size={12} color={col} />
253
265
  <Text style={{ color: f.tone === "muted" || isLight(c) ? c.foreground : col, fontSize: 12, lineHeight: 16, fontWeight: "500" }}>{f.label}</Text>
254
266
  </View>; })}
255
- {b.links.map((l, i) => <Pressable key={`l${i}`} accessibilityRole={l.url ? "link" : "text"} disabled={!l.url} onPress={() => l.url && void openExternalUrl(l.url).catch(() => undefined)} hitSlop={compact ? 10 : 4}
267
+ {b.links.map((l, i) => <Pressable key={`l${i}`} accessibilityRole={l.url ? "link" : "text"} disabled={!l.url} onPress={() => l.url && openLinkQuietly(l.url, { workspaceId: b.workspaceId })} hitSlop={compact ? 10 : 4}
256
268
  style={{ flexDirection: "row", alignItems: "center", gap: 5, paddingHorizontal: 8, minHeight: 24, borderRadius: 6, backgroundColor: c.surface2 }}>
257
269
  <Icon name={l.url ? "ExternalLink" : l.pr ? "GitPullRequest" : "File"} size={12} color={c.foregroundMuted} />
258
270
  <Text selectable={!l.url} numberOfLines={1} style={{ color: c.foreground, fontSize: 12, lineHeight: 16, fontWeight: "500", maxWidth: 260 }}>{l.label}</Text>
@@ -275,6 +287,17 @@ function SendBar({ b, picks, noted = 0, busy, error, onSend, c, compact }: { b:
275
287
  </View>;
276
288
  }
277
289
 
290
+ /**
291
+ * What the card can't say itself (where to act, or why Follow-up couldn't): the desktop footer, or on phones the line
292
+ * right after the header row, always shown. A card without a line has neither (`a-source-line-says-something`).
293
+ */
294
+ function SourceLine({ b, c }: { b: { sourceLine: string }; c: Colors }) {
295
+ return <View style={{ flexDirection: "row", alignItems: "flex-start", gap: 6 }}>
296
+ <View style={{ paddingTop: 2 }}><Icon name="Info" size={12} color={c.foregroundMuted} /></View>
297
+ <Text style={{ flex: 1, color: c.foregroundMuted, fontSize: 12, lineHeight: 16 }}>{b.sourceLine}</Text>
298
+ </View>;
299
+ }
300
+
278
301
  /** "Show full question" / "Show original": a past card opens back up, read-only. */
279
302
  const CONTEXT_LINES = 4;
280
303
  /**
@@ -296,7 +319,7 @@ function Reveal({ label, openLabel, open, onPress, c, compact }: { label: string
296
319
  * A card that's no longer open keeps its question (1.4.0). Answered: the ask, each decision with what was picked, and
297
320
  * "Show full question" opens the original read-only. Superseded or signed off: the one muted line, plus "Show original".
298
321
  */
299
- function Past({ b, c, now, compact, height, pending = false, onResend, resending = false, questions = [] }: { b: Brief; c: Colors; now: number; compact: boolean; height: number; pending?: boolean; onResend?: () => void; resending?: boolean; questions?: readonly ListQuestion[] }) {
322
+ function Past({ b, c, now, compact, height, pending = false, onResend, resending = false, questions = [], workspace }: { workspace?: ListWorkspace; b: Brief; c: Colors; now: number; compact: boolean; height: number; pending?: boolean; onResend?: () => void; resending?: boolean; questions?: readonly ListQuestion[] }) {
300
323
  const [expanded, setExpanded] = useState(false);
301
324
  const answered = b.state === "answered";
302
325
  // Its questions' answers as every surface reads them (briefAnswerStatus): copied or in the message box is "not sent
@@ -325,7 +348,7 @@ function Past({ b, c, now, compact, height, pending = false, onResend, resending
325
348
  {onResend && delivery.action && <Btn label={resending ? "Sending…" : delivery.action === "retry" ? "Retry" : "Try now"} icon="RotateCcw" primary={delivery.action === "retry"} onPress={onResend} disabled={resending} c={c} compact={compact} hint={delivery.action === "retry" ? "Sends the same answer again" : "Tries sending it now"} />}
326
349
  </View>;
327
350
  const body = expanded && <View style={{ gap: 10, paddingTop: 4 }}>
328
- <BriefBody b={b} c={c} compact={compact} tight={false} embedded height={height} mode="readonly" picks={{}} onPick={() => undefined} busy={null} />
351
+ <BriefBody b={b} c={c} compact={compact} tight={false} embedded height={height} mode="readonly" picks={{}} onPick={() => undefined} busy={null} workspace={workspace} />
329
352
  </View>;
330
353
  if (!picked) return <View accessibilityLiveRegion="polite" accessibilityLabel={spoken} style={{ marginVertical: 10, gap: 6, paddingVertical: 8, paddingHorizontal: 12, borderRadius: 10, borderWidth: 1, borderColor: c.border }}>
331
354
  <View style={{ flexDirection: "row", gap: 10, alignItems: answered ? "flex-start" : "center", minHeight: 24 }}>
@@ -370,7 +393,7 @@ type BriefCardProps = PluginTimelineItemProps<Brief> & { deps: BriefDeps; embedd
370
393
  export function BriefCard(props: BriefCardProps) {
371
394
  const workspace = props.item.data.workspaceId ? props.deps.workspace(props.item.data.workspaceId) : undefined;
372
395
  const prs = useMemo(() => workspace ? prLinksByNumber(workspace.prs) : undefined, [workspace?.prs]);
373
- return <PrLinksProvider prs={prs}><BriefCardBody {...props} /></PrLinksProvider>;
396
+ return <LinkWorkspaceProvider workspaceId={props.item.data.workspaceId}><PrLinksProvider prs={prs}><BriefCardBody {...props} /></PrLinksProvider></LinkWorkspaceProvider>;
374
397
  }
375
398
 
376
399
  function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, snoozed = false, bare = false, onDismissed }: BriefCardProps) {
@@ -410,11 +433,12 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
410
433
  const busy = sending ?? (shown.actionable ? null : "checking");
411
434
  const [error, setError] = useState<string | null>(null);
412
435
  const toast = useToast();
413
- const [why, setWhy] = useState(false);
414
436
  // Done collapses the card the moment it's pressed; the server's answered brief replaces this when the send lands.
415
437
  const [marked, setMarked] = useState<string | null>(null);
416
438
  // The send landed: green at once, before the server's answered brief replaces the card.
417
439
  const [sent, setSent] = useState(false);
440
+ // A brief-only decision answered from this card: drawn answered at once, until the server's answered brief replaces it.
441
+ const [answering, setAnswering] = useState<Brief | null>(null);
418
442
  const dismiss = useDismiss();
419
443
  const picks = usePicks(b.id);
420
444
  const words = useWords(b.id);
@@ -434,9 +458,10 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
434
458
  // An add-reviewers card for a PR the agent merges itself isn't an ask: gone the moment the repository flips to No
435
459
  // review, back on Undo (invariant a-no-review-repo-never-asks-for-review-or-merge).
436
460
  if (b.state === "open" && !liveBrief(b)) return null;
437
- if (shown.brief.state !== "open") return <Past b={shown.brief} c={c} now={now} compact={compact} height={height} onResend={b.answerId ? resend : undefined} resending={sending === "resend"} questions={workspace?.questions} />;
461
+ if (shown.brief.state !== "open") return <Past b={shown.brief} c={c} now={now} compact={compact} height={height} onResend={b.answerId ? resend : undefined} resending={sending === "resend"} questions={workspace?.questions} workspace={workspace} />;
438
462
  // Muted until the send lands: the server's answered brief then replaces this, green.
439
463
  if (marked) return <Past b={{ ...b, state: "answered", outcome: "Done", outcomeAt: marked }} pending={!sent} c={c} now={now} compact={compact} height={height} />;
464
+ if (answering) return <Past b={answering} c={c} now={now} compact={compact} height={height} questions={workspace?.questions} />;
440
465
 
441
466
  const attention = c.statusWarning;
442
467
  const flaggedAct = b.flagged && ACTS.includes(b.kind);
@@ -468,11 +493,17 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
468
493
  if (busy || marked) return;
469
494
  setError(null); setSent(false); setMarked(new Date().toISOString());
470
495
  const doneId = newAnswerId();
471
- const id = runUndoable("Telling the agent it's done", { label: "Done", toast, run: async (): Promise<unknown> => doneQ && workspace ? answerQuestion({ workspaceId: workspace.id, questionId: doneQ.id, choice: TASK_DONE.letter, ...(notesOpen[doneQ.id] && notes[doneQ.id]?.trim() ? { words: notes[doneQ.id].trim() } : {}), ...withImages(), action: "send" })
496
+ // answering-is-optimistic: the action card it answers reads as answered everywhere from the click; Undo (nothing
497
+ // sent) or a failure brings it back.
498
+ const words = doneQ && notesOpen[doneQ.id] && notes[doneQ.id]?.trim() ? notes[doneQ.id].trim() : undefined;
499
+ const card = doneQ && workspace ? { wid: workspace.id, qid: doneQ.id } : null;
500
+ if (card) { setPendingAnswer(card.wid, card.qid, { choice: TASK_DONE.letter, words }); markSentHere(card.wid, card.qid); }
501
+ const undone = () => { setMarked(null); if (card) clearPendingAnswer(card.wid, card.qid); };
502
+ const id = runUndoable("Telling the agent it's done", { label: "Done", toast, run: async (): Promise<unknown> => card ? answerQuestion({ workspaceId: card.wid, questionId: card.qid, choice: TASK_DONE.letter, ...(words ? { words } : {}), ...withImages(), action: "send" })
472
503
  : act({ agentId, briefId: b.id, move: "done", answerId: doneId }), success: "Marked done. The agent has it.",
473
- failure: "Done not sent", open: () => deps.openAgent(agentId), onSuccess: () => setSent(true), onError: e => { setMarked(null); setError(errorText(e)); }, reconcile: e => { setMarked(null); reconcile(e); } }, () => setMarked(null), `done:${b.id}`, () => deps.endDone?.(agentId));
504
+ failure: "Done not sent", open: () => deps.openAgent(agentId), onSuccess: () => { setSent(true); if (card) confirmPendingAnswer(card.wid, card.qid); }, onError: e => { undone(); setError(errorText(e)); }, reconcile: e => { undone(); reconcile(e); } }, undone, `done:${b.id}`, () => deps.endDone?.(agentId));
474
505
  // The pill's Undo is this toast's Undo: it closes the toast (so nothing is sent) and reopens the card.
475
- if (id !== null) deps.noteDone?.(agentId, () => { dismissToast(id); setMarked(null); });
506
+ if (id !== null) deps.noteDone?.(agentId, () => { dismissToast(id); undone(); });
476
507
  };
477
508
  // A merge move reads what its click merges ("Merge 3 PRs"), then "Merging…".
478
509
  // An add-reviewers move that names whom it asks reads "Add reviewers", "Requesting…", then "Requested"
@@ -489,7 +520,7 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
489
520
  const one = oneClick(m);
490
521
  if (one) one.run();
491
522
  else if ((m.kind === "merge" || m.kind === "add_reviewers") && m.prKey) { if (workspace?.prs.some(p => p.key === m.prKey)) setSheet({ key: m.prKey, intent: m.kind === "merge" ? "merge" : "reviewers" }); else if (b.workspaceId) deps.openPanel(b.workspaceId); }
492
- else if (m.kind === "open_pr" && m.url) void openExternalUrl(m.url).catch(() => undefined);
523
+ else if (m.kind === "open_pr" && m.url) openLinkQuietly(m.url, { workspaceId: b.workspaceId });
493
524
  else if (m.kind === "sign_off_next") { deps.signOff(agentId); deps.openNext(agentId); }
494
525
  else if (m.kind === "retry") void run("retry", answerId => act({ agentId, briefId: b.id, move: "retry", answerId }), "Retry didn't start");
495
526
  else if (m.kind === "done") markDone();
@@ -512,7 +543,7 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
512
543
  if (b.slim) {
513
544
  // Permission: Paseo's own prompt below is the control (F9). Fallback: the paragraph is right above.
514
545
  // The label and age share the top line so the ask always gets the full width; at a narrow panel the move wraps under it.
515
- return <RevealScope accessibilityRole="summary" accessibilityLabel={`${acts ? "Needs you: " : ""}${askText}. ${b.sourceLine}`}
546
+ return <RevealScope accessibilityRole="summary" accessibilityLabel={`${acts ? "Needs you: " : ""}${askText}.${b.sourceLine ? ` ${b.sourceLine}` : ""}`}
516
547
  style={[{ marginVertical: embedded ? 0 : 10, gap: 4, paddingHorizontal: 12, paddingVertical: 10, borderRadius: 10, borderWidth: 1, borderColor: border }, bare && BARE]}>
517
548
  <View style={{ flexDirection: "row", alignItems: "center", gap: 7 }}>
518
549
  <Icon name={ICON[b.kind]} size={14} color={tone} />
@@ -540,15 +571,38 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
540
571
  // (briefQuestionsEvent). Only a decision with no tracked question goes through the brief's own action.
541
572
  type DecisionPick = { decisionId: string; choice: string; words?: string };
542
573
  const asQuestions = (list: DecisionPick[]) => !!workspace && list.length > 0 && list.every(x => b.questionIds.includes(x.decisionId) && workspace.questions.some(q => q.id === x.decisionId && !q.answer && !q.closed));
574
+ /**
575
+ * answering-is-optimistic: the card reads as answered the moment Send is pressed, and so does every other surface. A
576
+ * decision backed by a question goes in flight like any question answer (pending-answers: the overlaid workspace
577
+ * answers it, so this card's shownBrief resolves too); a brief-only decision is answered here (`answering`) and its
578
+ * inbox row is held as answered (`holdAnswered`). A failure lets both go: the card is back with its picks, words and
579
+ * images (cleared only once the server has them), the reason under it, and the toast's Retry.
580
+ */
543
581
  const answer = async (list: DecisionPick[], answerId: string) => {
544
582
  // The field already says why (before Send); a key or a bar's Send can't get past it either.
545
583
  if (img.blocked) throw new Error(img.blocked);
546
584
  const images = withImages();
547
- if (!asQuestions(list)) { const out = await act({ agentId, briefId: b.id, answerId, ...(list.length === 1 ? list[0] : { choices: list }), ...images }); img.clear(); return out; }
548
- // The images ride the first answer's message: one message to the agent carries them once.
549
- for (const [i, x] of list.entries()) await answerQuestion({ workspaceId: workspace!.id, questionId: x.decisionId, choice: x.choice, ...(x.words ? { words: x.words } : {}), ...(i === 0 ? images : {}), action: "send" });
585
+ if (!asQuestions(list)) {
586
+ const chosen = new Map(list.map(x => [x.decisionId, x]));
587
+ const decisions = b.decisions.map(d => chosen.has(d.id) ? { ...d, chosen: chosen.get(d.id)!.choice, words: chosen.get(d.id)!.words ?? null } : d);
588
+ setAnswering({ ...b, state: "answered", decisions, outcome: answeredOutcome(decisions), outcomeAt: new Date().toISOString(), delivery: { state: "sending", error: null } });
589
+ const release = deps.holdAnswered?.(agentId);
590
+ try { const out = await act({ agentId, briefId: b.id, answerId, ...(list.length === 1 ? list[0] : { choices: list }), ...images }); img.clear(); return out; }
591
+ catch (e) { setAnswering(null); release?.(); throw e; }
592
+ }
593
+ const wid = workspace!.id;
594
+ for (const x of list) { setPendingAnswer(wid, x.decisionId, { choice: x.choice, words: x.words }); markSentHere(wid, x.decisionId); }
595
+ try {
596
+ // The images ride the first answer's message: one message to the agent carries them once.
597
+ for (const [i, x] of list.entries()) { await answerQuestion({ workspaceId: wid, questionId: x.decisionId, choice: x.choice, ...(x.words ? { words: x.words } : {}), ...(i === 0 ? images : {}), action: "send" }); confirmPendingAnswer(wid, x.decisionId); }
598
+ } catch (e) {
599
+ // The questions are open again on every surface, each with what was picked and "Not sent · Retry"; this card
600
+ // carries the reason too, with its picks and words (cleared only on success).
601
+ for (const x of list) failPendingAnswer(wid, x.decisionId, errorText(e));
602
+ throw e;
603
+ }
550
604
  img.clear();
551
- void cache.invalidateQueries({ queryKey: liveBriefKey(agentId) }); void cache.invalidateQueries({ queryKey: workspaceKey(workspace!.id) });
605
+ void cache.invalidateQueries({ queryKey: liveBriefKey(agentId) }); void cache.invalidateQueries({ queryKey: workspaceKey(wid) });
552
606
  };
553
607
  // A tap sends the letter, with the note when one is typed; a sent answer clears the card (clearCard).
554
608
  const sendOne = (key: string) => { const [decisionId, choice] = key.split(":"); void run(key, async answerId => { await answer(cardPicks({ [decisionId]: choice }, {}, notesOpen[decisionId] ? notes : {}), answerId); clearCard(b.id); }); };
@@ -573,15 +627,13 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
573
627
  <View style={{ flex: 1 }} />
574
628
  {/* In Later the age would read as a second clock beside "Later until"; the pane header keeps it. */}
575
629
  {!snoozed && <Text style={{ color: c.foregroundMuted, fontSize: 12, lineHeight: 16, fontVariant: ["tabular-nums"] }}>{ageText}</Text>}
576
- {/* Phones: where the card's facts come from sits behind ⓘ instead of a footer under every card. */}
577
- {compact && <Pressable accessibilityRole="button" accessibilityLabel={why ? "Hide where this comes from" : "Where this comes from"} aria-expanded={why} accessibilityState={{ expanded: why }}
578
- onPress={() => setWhy(v => !v)} style={{ width: 44, height: 44, marginVertical: -15, marginRight: x ? -10 : -14, alignItems: "center", justifyContent: "center" }}>
579
- <Icon name="Info" size={14} color={why ? c.foreground : c.foregroundMuted} />
580
- </Pressable>}
581
630
  {/* The x is always the card's last control, in its top-right corner, on every Needs-you item. */}
582
631
  {x}
583
632
  </View>
584
- {/* The ask role on phones (react-native-web ignores hitSlop, so the ⓘ above is a real 44 box); desktop keeps 19/26. */}
633
+ {/* Phones: the card's source line, when it has one, is the element right after the header row, always shown: every
634
+ line says where to act, so hiding it would cost a tap for nothing, and a footer sits off screen on a tall card. */}
635
+ {compact && !!b.sourceLine && <SourceLine b={{ sourceLine: b.sourceLine }} c={c} />}
636
+ {/* The ask role on phones; desktop keeps 19/26. */}
585
637
  {/* Bare: a section of the Needs you block, so the same size as its question titles. */}
586
638
  <RichText accessibilityRole="header" style={compact || bare ? text(c, compact).ask : { color: c.foreground, fontSize: 19, lineHeight: 26, fontWeight: "600", letterSpacing: -0.2 }}>{askText}</RichText>
587
639
  </View>
@@ -589,7 +641,7 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
589
641
  <BriefBody b={b} c={c} compact={compact} tight={tight} embedded={embedded} height={height} mode={multi ? "select" : "send"} picks={picks}
590
642
  onPick={(decisionId, letter) => { if (!busy) pickStore.set(b.id, decisionId, letter); }} busy={busy} onSend={sendOne}
591
643
  words={words} onWords={(decisionId, t) => wordStore.set(b.id, decisionId, t)} onSendOther={sendOther}
592
- notes={notes} notesOpen={notesOpen} onNote={(decisionId, t) => noteStore.set(b.id, decisionId, t)} onNoteOpen={(decisionId, open) => noteOpenStore.set(b.id, decisionId, open ? "1" : "")} doneIds={doneQ ? [doneQ.id] : []} img={img} />
644
+ notes={notes} notesOpen={notesOpen} onNote={(decisionId, t) => noteStore.set(b.id, decisionId, t)} onNoteOpen={(decisionId, open) => noteOpenStore.set(b.id, decisionId, open ? "1" : "")} doneIds={doneQ ? [doneQ.id] : []} img={img} workspace={workspace} openAgent={deps.openAgent} />
593
645
 
594
646
  {multi && <SendBar b={b} picks={sendable} noted={notedCount(sendable, openNotes)} busy={busy} error={error} onSend={sendAll} c={c} compact={compact} />}
595
647
 
@@ -608,10 +660,8 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
608
660
  {!tight && !!b.also.context && <RichText linkColor={c.foreground} numberOfLines={3} style={{ color: c.foregroundMuted, fontSize: 13, lineHeight: 19 }}>{b.also.context}</RichText>}
609
661
  </View>}
610
662
  </SubmitScope>
611
- {(!compact || why) && <View style={{ borderTopWidth: 1, borderTopColor: c.border, paddingHorizontal: pad, paddingVertical: 8, flexDirection: "row", alignItems: "center", gap: 6 }}>
612
- <Icon name="Info" size={12} color={c.foregroundMuted} />
613
- <Text style={{ flex: 1, color: c.foregroundMuted, fontSize: 12, lineHeight: 16 }}>{b.sourceLine}</Text>
614
- </View>}
663
+ {/* Desktop: the card's source line is its footer, always shown when the card has one. */}
664
+ {!compact && !!b.sourceLine && <View style={{ borderTopWidth: 1, borderTopColor: c.border, paddingHorizontal: pad, paddingVertical: 8 }}><SourceLine b={{ sourceLine: b.sourceLine }} c={c} /></View>}
615
665
  {detail.workspace && sheet && <PrSheet workspace={detail.workspace} prKey={sheet.key} intent={sheet.intent} theme={theme} compact={compact} browserReady={browser.data?.ready ?? false} onClose={() => setSheet(null)} />}
616
666
  </RevealScope>;
617
667
  }