paseo-follow-up 2.4.0-beta.3 → 2.4.0-beta.5

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 (97) hide show
  1. package/client/brief-since.tsx +15 -5
  2. package/client/brief.tsx +30 -11
  3. package/client/catch-up.tsx +15 -7
  4. package/client/chat.tsx +1 -1
  5. package/client/compass-settings.tsx +323 -0
  6. package/client/header.tsx +1 -1
  7. package/client/home-chrome.tsx +16 -2
  8. package/client/home-data.ts +6 -2
  9. package/client/home-list.tsx +5 -2
  10. package/client/home-view.ts +2 -1
  11. package/client/home.tsx +45 -15
  12. package/client/host-slot.tsx +114 -0
  13. package/client/image-attach.tsx +276 -0
  14. package/client/list-keys.ts +11 -3
  15. package/client/messages.tsx +8 -9
  16. package/client/more-context.tsx +18 -11
  17. package/client/morning-brief-settings.tsx +2 -0
  18. package/client/needs-you.tsx +2 -1
  19. package/client/new.tsx +95 -61
  20. package/client/onboarding.tsx +4 -4
  21. package/client/panel.tsx +18 -7
  22. package/client/pending-answers.ts +25 -5
  23. package/client/pr-stats-settings.tsx +35 -10
  24. package/client/questions.tsx +24 -15
  25. package/client/rename.tsx +9 -18
  26. package/client/report-issue.tsx +16 -27
  27. package/client/row-actions.ts +23 -9
  28. package/client/row-menu.tsx +19 -2
  29. package/client/settings.tsx +2 -2
  30. package/client/tasks.tsx +18 -10
  31. package/client/theme.ts +16 -0
  32. package/client/toast-store.ts +1 -1
  33. package/client/unsent-images.ts +26 -0
  34. package/index.client.tsx +9 -14
  35. package/index.server.ts +127 -32
  36. package/package.json +3 -1
  37. package/server/agent-actions.ts +25 -10
  38. package/server/agent-hook.mjs +11 -6
  39. package/server/agent-parity.ts +24 -6
  40. package/server/ai-jobs.ts +13 -8
  41. package/server/compass.ts +320 -0
  42. package/server/daemon.ts +12 -4
  43. package/server/dispatch.ts +55 -14
  44. package/server/engine.ts +82 -16
  45. package/server/hook-source.ts +11 -6
  46. package/server/image-store.ts +100 -0
  47. package/server/image-support.ts +37 -0
  48. package/server/inbox.ts +4 -3
  49. package/server/job-guard.ts +71 -0
  50. package/server/linear-queue.ts +12 -9
  51. package/server/mcp-source.ts +19 -12
  52. package/server/mcp.mjs +19 -12
  53. package/server/message-queue.ts +41 -7
  54. package/server/overseer-prompt-source.ts +1 -1
  55. package/server/overseer-prompt.md +1 -1
  56. package/server/overseer.ts +71 -23
  57. package/server/pr-stats-gate.ts +48 -10
  58. package/server/pr-stats-sync.ts +7 -7
  59. package/server/pr-stats.ts +17 -12
  60. package/server/ranker.ts +12 -4
  61. package/server/report-issue-adapter.ts +1 -1
  62. package/server/session-prompt.ts +105 -0
  63. package/server/tasks.ts +8 -3
  64. package/shared/activity.ts +14 -1
  65. package/shared/agent-load.ts +6 -1
  66. package/shared/attention.ts +12 -10
  67. package/shared/brief-since.ts +36 -0
  68. package/shared/brief-sources.ts +3 -0
  69. package/shared/chat.ts +4 -4
  70. package/shared/compass.ts +690 -0
  71. package/shared/contracts.ts +17 -4
  72. package/shared/dispatch.ts +45 -11
  73. package/shared/headline.ts +7 -6
  74. package/shared/home.ts +5 -2
  75. package/shared/images.ts +95 -0
  76. package/shared/issue-workspace.ts +65 -0
  77. package/shared/linear-issues.ts +10 -3
  78. package/shared/linear-queue.ts +14 -1
  79. package/shared/list-keys.ts +21 -3
  80. package/shared/model.ts +27 -4
  81. package/shared/morning-brief.ts +4 -1
  82. package/shared/new-view.ts +35 -12
  83. package/shared/overseer.ts +151 -11
  84. package/shared/pr-stats-settings.ts +27 -0
  85. package/shared/priorities.ts +2 -2
  86. package/shared/questions.ts +4 -2
  87. package/shared/queue.ts +41 -3
  88. package/shared/ranker.ts +7 -3
  89. package/shared/row-menu.ts +77 -11
  90. package/shared/send-decision.ts +69 -5
  91. package/shared/send-words.ts +21 -0
  92. package/shared/sending.ts +8 -6
  93. package/shared/settings-nav.ts +1 -1
  94. package/shared/status-invariants.ts +18 -0
  95. package/shared/status.ts +5 -4
  96. package/shared/task-rows.ts +11 -7
  97. package/shared/task-view.ts +7 -1
@@ -1,10 +1,10 @@
1
1
  import { useCallback, useEffect, useRef, useState } from "react";
2
- import { View } from "react-native";
2
+ import { Platform, View } from "react-native";
3
3
  import { Pressable, Text } from "./text";
4
4
  import { useRpc } from "@getpaseo/plugin/client";
5
5
  import { Icon, ScrollView, useToast } from "@getpaseo/plugin/client/ui";
6
6
  import { dispatchActionsRpc, dispatchRpc, linearQueueRpc, sweepQueueRpc } from "../shared/contracts";
7
- import { changeChip, queueRowMeta, raisedRow, sinceBlock, type SinceChange, type SinceLine } from "../shared/brief-since";
7
+ import { changeChip, openedLine, queueRowMeta, raisedRow, sinceBlock, type SinceChange, type SinceLine } from "../shared/brief-since";
8
8
  import { actionIcon, stateIcon } from "../shared/new-view";
9
9
  import type { RaisedNeed } from "../shared/linear-queue";
10
10
  import type { QueueNeeds } from "./home-view";
@@ -25,7 +25,8 @@ import { withAlpha, type Colors } from "./theme";
25
25
  */
26
26
 
27
27
  type Workspace = { workspaceId: string; title: string } | null;
28
- type QueueIssueRow = { key: string; title: string; priority: number; state: string | null; stateType: string | null; due: string | null; url: string | null; workspace: Workspace; change: string | null };
28
+ type QueueIssueRow = { key: string; title: string; priority: number; state: string | null; stateType: string | null; due: string | null; url: string | null; workspace: Workspace; change: string | null;
29
+ createdAt?: string | null; creator?: string | null; openedByYou?: boolean | null };
29
30
  type QueueViewData = {
30
31
  status: { sweptAt: string | null; complete: boolean | null; running: boolean; total: number; stale: boolean; timeZone: string; sweepAt: string; last: { ok: boolean; error: string | null } | null };
31
32
  since: string | null;
@@ -150,20 +151,29 @@ const FILTERS: { id: Filter; label: string; count: (v: QueueViewData) => number
150
151
  { id: "changed", label: "Changed", count: v => v.counts.changed },
151
152
  ];
152
153
 
154
+ /** "opened by Dana · 12 days ago", with the exact time as the desktop tooltip (React Native Web drops `title`, so it goes on the node). */
155
+ function OpenedText({ text: words, tooltip }: { text: string; tooltip: string }) {
156
+ const ref = useRef<View | null>(null);
157
+ useEffect(() => { if (Platform.OS === "web") (ref.current as unknown as { setAttribute?: (k: string, v: string) => void } | null)?.setAttribute?.("title", tooltip); }, [tooltip]);
158
+ return <Text ref={ref as never}>{words}</Text>;
159
+ }
160
+
153
161
  function QueueRow({ i, change, c, compact, timeZone, navigation }: { i: QueueIssueRow; change: SinceChange | undefined; c: Colors; compact: boolean; timeZone: string; navigation: Nav }) {
154
162
  const t = text(c, compact);
155
163
  const now = Date.now();
156
164
  const chip = changeChip(change ?? null, now, timeZone);
157
165
  const meta = queueRowMeta(i, now, timeZone, change);
166
+ const opened = openedLine({ createdAt: i.createdAt ?? null, creator: i.creator ?? null }, i.openedByYou ?? null, now, timeZone);
158
167
  const ws = i.workspace;
159
168
  const open = ws ? () => navigation?.openWorkspace({ workspaceId: ws.workspaceId }) : () => openNew({ source: i.key });
160
- const label = `${i.key} ${i.title}. ${meta}${chip ? `. ${chip.text}` : ""}${ws ? `. In ${ws.title}` : ". No workspace"}`;
169
+ const label = `${i.key} ${i.title}. ${meta}${opened ? `. ${opened.label}` : ""}${chip ? `. ${chip.text}` : ""}${ws ? `. In ${ws.title}` : ". No workspace"}`;
161
170
  const body = <View style={{ flexDirection: "row", alignItems: "flex-start", gap: 10, flex: 1, minWidth: 0 }}>
162
171
  <View style={{ paddingTop: 2 }}><Icon name={stateIcon(i.stateType)} size={15} color={c.foregroundMuted} /></View>
163
172
  <View style={{ flex: 1, minWidth: 0, gap: 2 }}>
164
173
  <Text style={t.body}><Text style={{ color: c.foregroundMuted }}>{i.key}</Text> {i.title}</Text>
165
174
  <View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", columnGap: 8, rowGap: 4 }}>
166
- {!!meta && <Text style={t.meta}>{meta}</Text>}
175
+ {/* One run of quiet ink, so a phone wraps it word by word and never cuts the state: "Todo · due Wed · opened by Dana · 12 days ago". */}
176
+ {(!!meta || !!opened) && <Text style={t.meta}>{meta}{opened && <OpenedText text={`${meta ? " · " : ""}${opened.text}`} tooltip={opened.label} />}</Text>}
167
177
  {/* The change since the brief: a tinted chip, so the Changed filter's subjects stand out from the plain meta. */}
168
178
  {chip && <View style={{ flexDirection: "row", alignItems: "center", gap: 4, paddingHorizontal: 6, paddingVertical: 1, borderRadius: 5, backgroundColor: withAlpha(chip.warn ? c.statusWarning : c.foregroundMuted, chip.warn ? 0.12 : 0.1) }}>
169
179
  {chip.icon && <Icon name={chip.icon} size={12} color={chip.warn ? c.statusWarning : c.foregroundMuted} />}
package/client/brief.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { useMemo, useState, useSyncExternalStore } from "react";
1
+ import { useMemo, useState, useSyncExternalStore, type ReactNode } from "react";
2
2
  import { browserKey, liveBriefKey, LIVE_BRIEF_POLL_MS, workspaceKey } from "./keys";
3
3
  import { Platform, View, useWindowDimensions } from "react-native";
4
4
  import { Pressable, Text } from "./text";
@@ -14,6 +14,7 @@ import { briefKey, HEADLINE_WORD } from "../shared/headline";
14
14
  /** The card's kind word comes from the same table as the pill and the Needs-you row. */
15
15
  const word = (kind: Brief["kind"]) => HEADLINE_WORD[briefKey(kind)];
16
16
  import { answerQuestionRpc, briefActionRpc, browserStatusRpc, inboxBriefRpc } from "../shared/contracts";
17
+ import { ImageField, useImageAttachments, type ImageAttachments } from "./image-attach";
17
18
  import { errorText, mootNote } from "../shared/errors";
18
19
  import { PRIMARY_FORM } from "./dock";
19
20
  import { OTHER, OTHER_LABEL, OWN_ANSWER_HINT, briefAnswerStatus, isDoneOnly, isOpen, isOther, TASK_DONE, type Question } from "../shared/questions";
@@ -145,6 +146,11 @@ function OptionRow({ option, recommended, sending, disabled, tight, open, onTogg
145
146
  }
146
147
 
147
148
  /** "Add note" / "Remove note": a quiet text link (muted, 13px), 44 tall on phones. QuestionBody uses it too. */
149
+ /** The brief's answer or note field with the card's pasted images (client/image-attach.tsx); a read-only copy has none. */
150
+ /** `row`: whether this field draws the card's thumbnails. One set per card, so only its last open field does. */
151
+ function WithImages({ img, c, compact, row, children }: { img?: ImageAttachments; c: Colors; compact: boolean; row: boolean; children: ReactNode }) {
152
+ return img ? <ImageField model={img} theme={{ colors: c }} compact={compact} row={row}>{children}</ImageField> : <>{children}</>;
153
+ }
148
154
  export function NoteLink({ icon, label, a11y, disabled, onPress, c, compact }: { icon: string; label: string; a11y: string; disabled: boolean; onPress: () => void; c: Colors; compact: boolean }) {
149
155
  return <Pressable accessibilityRole="button" accessibilityLabel={a11y} accessibilityState={{ disabled }} disabled={disabled} onPress={onPress} hitSlop={6}
150
156
  style={({ hovered, pressed, focused }: { hovered?: boolean; pressed: boolean; focused?: boolean }) => ({ ...ring(focused, c), flexDirection: "row", alignItems: "center", gap: 6, alignSelf: "flex-start", minHeight: compact ? 44 : 28, paddingHorizontal: 4, marginLeft: -4, borderRadius: 6, opacity: disabled ? 0.5 : pressed ? 0.7 : 1, backgroundColor: hovered && !disabled ? withAlpha(c.foreground, 0.05) : "transparent" })}>
@@ -157,7 +163,9 @@ export function NoteLink({ icon, label, a11y, disabled, onPress, c, compact }: {
157
163
  * The card's body: decisions, error text, details, context, facts and links, and the agent's extra ask. Shared by the
158
164
  * open card and by a past card's read-only "Show full question", so a past question reads exactly as it was asked.
159
165
  */
160
- function BriefBody({ b, c, compact, tight, embedded, height, mode, picks, onPick, busy, onSend, words = {}, onWords, onSendOther, notes = {}, notesOpen = {}, onNote, onNoteOpen, doneIds = [] }: {
166
+ export function BriefBody({ b, c, compact, tight, embedded, height, mode, picks, onPick, busy, onSend, words = {}, onWords, onSendOther, notes = {}, notesOpen = {}, onNote, onNoteOpen, doneIds = [], img }: {
167
+ /** The card's pasted images (one model for its answer and note fields). Absent: read-only copies. */
168
+ img?: ImageAttachments;
161
169
  /** one-done-button: decisions answered by the card's Done button (an action card), drawn without option rows. */
162
170
  doneIds?: readonly string[];
163
171
  b: Brief; c: Colors; compact: boolean; tight: boolean; embedded: boolean; height: number;
@@ -179,6 +187,9 @@ function BriefBody({ b, c, compact, tight, embedded, height, mode, picks, onPick
179
187
  const extra = !!b.context || b.facts.length > 0 || b.links.length > 0;
180
188
  const showExtra = readonly || !tight || details || extrasFit(b, height);
181
189
  const numbered = b.decisions.length > 1;
190
+ // The card has one image set (its answer and note fields share it), so its thumbnails are drawn once: under the
191
+ // last decision whose answer or note field is open. Several open fields each drew them before.
192
+ const rowAt = readonly ? null : [...b.decisions].reverse().find(d => isOther(picks[d.id]) || !!notesOpen[d.id])?.id ?? null;
182
193
  return <>
183
194
  {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 }}>
184
195
  {(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>}
@@ -193,20 +204,20 @@ function BriefBody({ b, c, compact, tight, embedded, height, mode, picks, onPick
193
204
  onPress={() => onPick(d.id, OTHER)} c={c} compact={compact} />}
194
205
  {/* Something else's field with its Send answer, kept on screen together while typing (DockedPane). */}
195
206
  {!readonly && isOther(picks[d.id]) && <View {...PRIMARY_FORM} style={{ gap: 8 }}>
196
- <TextInput accessibilityLabel={`Your answer${numbered ? ` to question ${i + 1}` : ""}, required`} placeholder="Your answer (required)" placeholderTextColor={c.foregroundMuted} autoFocus multiline maxLength={2000}
207
+ <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}
197
208
  value={words[d.id] ?? ""} editable={!busy} onChangeText={t => onWords?.(d.id, t)}
198
- 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" }} />
209
+ 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>
199
210
  {mode === "send" && <View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 10 }}>
200
- <Btn shortcut label={busy === `${d.id}:${OTHER}` ? "Sending…" : "Send answer"} icon="Send" primary disabled={!words[d.id]?.trim() || !!busy} onPress={() => onSendOther?.(d.id)} c={c} compact={compact} />
211
+ <Btn shortcut label={busy === `${d.id}:${OTHER}` ? "Sending…" : "Send answer"} icon="Send" primary disabled={!words[d.id]?.trim() || !!busy || !!img?.blocked} onPress={() => onSendOther?.(d.id)} c={c} compact={compact} />
201
212
  {!words[d.id]?.trim() && <Text style={{ flexShrink: 1, color: c.foregroundMuted, fontSize: 12, lineHeight: 16 }}>{OWN_ANSWER_HINT}</Text>}
202
213
  </View>}
203
214
  </View>}
204
215
  {/* A note on a lettered pick ("A, but…"): quiet until asked for, never in the way of the one-tap answer. */}
205
216
  {!readonly && !isOther(picks[d.id]) && (notesOpen[d.id] ? <View {...PRIMARY_FORM} style={{ gap: 6, marginTop: 2 }}>
206
217
  <Text style={{ color: c.foregroundMuted, fontSize: 12, lineHeight: 16, fontWeight: "600" }}>Note</Text>
207
- <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"}
218
+ <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"}
208
219
  placeholderTextColor={c.foregroundMuted} autoFocus={focusNote === d.id} multiline maxLength={2000} value={notes[d.id] ?? ""} editable={!busy} onChangeText={t => onNote?.(d.id, t)}
209
- 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" }} />
220
+ 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>
210
221
  <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} />
211
222
  </View> : done ? null : <View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", columnGap: 14 }}>
212
223
  <NoteLink icon="MessageSquarePlus" label="Add note" a11y={numbered ? `Add note to decision ${i + 1}` : "Add note"} disabled={!!busy} onPress={() => { setFocusNote(d.id); onNoteOpen?.(d.id, true); }} c={c} compact={compact} />
@@ -386,6 +397,9 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
386
397
  const { height } = useWindowDimensions();
387
398
  const act = useRpc(briefActionRpc);
388
399
  const answerQuestion = useRpc(answerQuestionRpc);
400
+ // Pasted images on the answer or the note (every-agent-field-takes-images): they ride the answer to the brief's agent.
401
+ const img = useImageAttachments({ target: { kind: "agent", agentId } });
402
+ const withImages = () => { const images = img.uploads(); return images ? { images } : {}; };
389
403
  const browserRead = useRpc(browserStatusRpc);
390
404
  const [sending, setBusy] = useState<string | null>(null);
391
405
  // Until the server confirms this brief is the open one, every control waits ("checking" matches no button's key).
@@ -450,7 +464,7 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
450
464
  if (busy || marked) return;
451
465
  setError(null); setSent(false); setMarked(new Date().toISOString());
452
466
  const doneId = newAnswerId();
453
- 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() } : {}), action: "send" })
467
+ 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" })
454
468
  : act({ agentId, briefId: b.id, move: "done", answerId: doneId }), success: "Marked done. The agent has it.",
455
469
  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));
456
470
  // The pill's Undo is this toast's Undo: it closes the toast (so nothing is sent) and reopens the card.
@@ -516,8 +530,13 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
516
530
  type DecisionPick = { decisionId: string; choice: string; words?: string };
517
531
  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));
518
532
  const answer = async (list: DecisionPick[], answerId: string) => {
519
- if (!asQuestions(list)) return act({ agentId, briefId: b.id, answerId, ...(list.length === 1 ? list[0] : { choices: list }) });
520
- for (const x of list) await answerQuestion({ workspaceId: workspace!.id, questionId: x.decisionId, choice: x.choice, ...(x.words ? { words: x.words } : {}), action: "send" });
533
+ // The field already says why (before Send); a key or a bar's Send can't get past it either.
534
+ if (img.blocked) throw new Error(img.blocked);
535
+ const images = withImages();
536
+ if (!asQuestions(list)) { const out = await act({ agentId, briefId: b.id, answerId, ...(list.length === 1 ? list[0] : { choices: list }), ...images }); img.clear(); return out; }
537
+ // The images ride the first answer's message: one message to the agent carries them once.
538
+ 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" });
539
+ img.clear();
521
540
  void cache.invalidateQueries({ queryKey: liveBriefKey(agentId) }); void cache.invalidateQueries({ queryKey: workspaceKey(workspace!.id) });
522
541
  };
523
542
  // A tap sends the letter, with the note when one is typed; a sent answer clears the card (clearCard).
@@ -559,7 +578,7 @@ function BriefCardBody({ item, theme, layout, agentId, deps, embedded = false, s
559
578
  <BriefBody b={b} c={c} compact={compact} tight={tight} embedded={embedded} height={height} mode={multi ? "select" : "send"} picks={picks}
560
579
  onPick={(decisionId, letter) => { if (!busy) pickStore.set(b.id, decisionId, letter); }} busy={busy} onSend={sendOne}
561
580
  words={words} onWords={(decisionId, t) => wordStore.set(b.id, decisionId, t)} onSendOther={sendOther}
562
- 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] : []} />
581
+ 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} />
563
582
 
564
583
  {multi && <SendBar b={b} picks={sendable} noted={notedCount(sendable, openNotes)} busy={busy} error={error} onSend={sendAll} c={c} compact={compact} />}
565
584
 
@@ -7,6 +7,8 @@ import { Animated, PanResponder, Platform, View } from "react-native";
7
7
  import { Pressable, Text } from "./text";
8
8
  import { useRpc } from "@getpaseo/plugin/client";
9
9
  import { Icon, ScrollView, TextInput } from "@getpaseo/plugin/client/ui";
10
+ import { ImageField, useImageAttachments } from "./image-attach";
11
+ import type { ImageUpload } from "../shared/images";
10
12
  import { useQuery } from "@tanstack/react-query";
11
13
  import { inboxBriefRpc } from "../shared/contracts";
12
14
  import { needsYou } from "../shared/attention";
@@ -125,9 +127,9 @@ export function CatchUp({ theme, compact, deps, navigation, onExit }: { theme: T
125
127
  const nextCard = cardOf(session.order[session.pos + 1]);
126
128
  useWorkspace(live, nextCard?.s.workspaceId ?? "", { enabled: !!nextCard?.s.workspaceId });
127
129
 
128
- const ask = async (words: string) => {
130
+ const ask = async (words: string, images?: ImageUpload[]) => {
129
131
  if (!card) return;
130
- const out = await extras.askContext({ workspaceId: card.s.workspaceId, agentId: card.s.agentId, cardKey: card.key, card: cardLabel(card, w).slice(0, 300), ask: words });
132
+ const out = await extras.askContext({ workspaceId: card.s.workspaceId, agentId: card.s.agentId, cardKey: card.key, card: cardLabel(card, w).slice(0, 300), ask: words, ...(images?.length ? { images } : {}) });
131
133
  setMore(false);
132
134
  // context-never-blocks-the-deck: the workstream waits, the deck moves on.
133
135
  if (out.request.state === "asking") setSession(s => park(s, out.request.id, card.key));
@@ -351,7 +353,7 @@ export function CatchUp({ theme, compact, deps, navigation, onExit }: { theme: T
351
353
  /** One card: who and what, the ask through its own surface's component, then the deck's moves pinned to the bottom. */
352
354
  function CardView({ card, w, theme, compact, deps, navigation, gone, more, setMore, request, waiting, onAsk, sameWorkspace, onDone, onSkip, onSkipWorkspace, wsLeft, onBack, onLater }: {
353
355
  card: DeckCard; w: ListWorkspace | undefined; theme: Theme; compact: boolean; deps: CatchUpDeps; navigation: Nav; gone: boolean; more: boolean; setMore: (v: boolean | ((v: boolean) => boolean)) => void;
354
- request: ContextRequest | null; waiting: boolean; onAsk: (words: string) => Promise<void>;
356
+ request: ContextRequest | null; waiting: boolean; onAsk: (words: string, images?: ImageUpload[]) => Promise<void>;
355
357
  sameWorkspace: string[]; onDone: () => void; onSkip: () => void; onSkipWorkspace?: () => void; wsLeft: number; onBack?: () => void; onLater: () => void;
356
358
  }) {
357
359
  const c = theme.colors; const t = text(c, compact);
@@ -425,7 +427,7 @@ function CardView({ card, w, theme, compact, deps, navigation, gone, more, setMo
425
427
  // a-move-bar-action-opens-in-view (MOVE_OPENS): More context and Later open where the eye is, a sheet above the
426
428
  // phone's bar or a popover on their button on desktop, never appended below the card.
427
429
  const closeMore = () => { setMore(false); if (!compact) focusSoon("catch-up-more"); };
428
- const moreBlock = more && <MorePanel theme={theme} compact={compact} onClose={closeMore} onAsk={onAsk} />;
430
+ const moreBlock = more && <MorePanel theme={theme} compact={compact} onClose={closeMore} onAsk={onAsk} target={s.workspaceId ? { kind: "workspace", workspaceId: s.workspaceId } : s.agentId ? { kind: "agent", agentId: s.agentId } : null} />;
429
431
  const later = (until: string) => { setLaterOpen(false); if (s.agentId) void deps.sources.inbox.snooze([s.agentId], until); onLater(); };
430
432
  const laterBlock = laterOpen && <View {...({ dataSet: { catchUpLater: "1" } } as object)} accessibilityRole="menu" accessibilityLabel="Later" style={{ gap: 8 }}>
431
433
  <Text style={[t.small, { fontWeight: "600" }]}>Back in your Needs you</Text>
@@ -572,9 +574,15 @@ function NoteRow({ theme, compact, agentId }: { theme: Theme; compact: boolean;
572
574
  const c = theme.colors;
573
575
  const agent = useAgentLive(agentId);
574
576
  const [words, setWords] = useState("");
575
- return <View {...PRIMARY_FORM} style={{ flexDirection: "row", alignItems: "flex-end", gap: 8 }}>
577
+ // Pasted images go with the words through Paseo's own send (every-agent-field-takes-images).
578
+ const img = useImageAttachments({ target: { kind: "agent", agentId } });
579
+ const send = () => {
580
+ const images = img.uploads()?.map(i => ({ data: i.data, mimeType: i.mimeType }));
581
+ void agent.handle?.send(words.trim(), images ? { images } : undefined); setWords(""); img.clear();
582
+ };
583
+ return <ImageField model={img} theme={theme} compact={compact}><View {...PRIMARY_FORM} style={{ flexDirection: "row", alignItems: "flex-end", gap: 8 }}>
576
584
  <TextInput accessibilityLabel="Tell the agent something" placeholder="Tell the agent something" placeholderTextColor={c.foregroundMuted} value={words} onChangeText={setWords} multiline
577
585
  style={{ flex: 1, minHeight: compact ? 44 : 36, paddingHorizontal: 10, paddingVertical: 8, borderRadius: 6, borderWidth: 1, borderColor: c.border, color: c.foreground, backgroundColor: c.surface0 }} />
578
- <IconButton theme={theme} compact={compact} icon="Send" label="Send to the agent" tooltip={!compact} disabled={!words.trim()} onPress={() => { void agent.handle?.send(words.trim()); setWords(""); }} />
579
- </View>;
586
+ <IconButton theme={theme} compact={compact} icon="Send" label="Send to the agent" tooltip={!compact} disabled={!words.trim() || !!img.blocked} onPress={send} />
587
+ </View></ImageField>;
580
588
  }
package/client/chat.tsx CHANGED
@@ -82,7 +82,7 @@ function BatchCardView({ item, theme }: PluginTimelineItemProps<BatchCard>) {
82
82
  <View style={{ borderRadius: 10, borderWidth: 1, borderColor: c.border, backgroundColor: c.surface1, overflow: "hidden" }}>
83
83
  <View style={{ flexDirection: "row", alignItems: "center", gap: 8, paddingHorizontal: 12, paddingTop: 10, paddingBottom: recovery ? 10 : 6 }}>
84
84
  <Icon name={recovery ? "History" : "Send"} size={14} color={c.foregroundMuted} />
85
- <Text style={{ flex: 1, color: c.foreground, fontSize: 13, lineHeight: 18, fontWeight: "600" }}>{recovery ? "Follow-up recovery brief" : `Follow-up sent ${card.tasks.length} task${card.tasks.length === 1 ? "" : "s"}`}</Text>
85
+ <Text style={{ flex: 1, color: c.foreground, fontSize: 13, lineHeight: 18, fontWeight: "600" }}>{recovery ? "Follow-up recovery brief" : "Follow-up sent a message"}</Text>
86
86
  <Pressable accessibilityRole="button" aria-expanded={expanded} accessibilityLabel={expanded ? "Hide the full message" : "Show the full message"} onPress={() => setExpanded(v => !v)} hitSlop={6}
87
87
  style={state => ({ paddingHorizontal: 6, paddingVertical: 2, borderRadius: 4, backgroundColor: state.pressed ? c.surface2 : "transparent" })}>
88
88
  <Text style={{ color: c.foregroundMuted, fontSize: 12 }}>{expanded ? "Hide" : "Full message"}</Text>
@@ -0,0 +1,323 @@
1
+ import { useEffect, useState } from "react";
2
+ import { ActivityIndicator, TextInput, View } from "react-native";
3
+ import { useRpc } from "@getpaseo/plugin/client";
4
+ import { Icon, SettingsSection, useToast } from "@getpaseo/plugin/client/ui";
5
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
6
+ import { Pressable, Text } from "./text";
7
+ import { Button, SubmitScope, Switch, errorText, text, type Theme } from "./kit";
8
+ import { RichText } from "./rich-text";
9
+ import { raised, tint } from "./theme";
10
+ import { compassFindRpc, compassRpc, readCompassRpc, setCompassRpc } from "../shared/contracts";
11
+ import {
12
+ COMPASS, ROLES, ROLE_INFO, type CompassChange, type CompassNote, type CompassSource, type GlossaryEntry, type Place, type Preset, type PresetView, type Role, type Who,
13
+ } from "../shared/compass";
14
+
15
+ export const compassKey = ["follow-up", "compass"];
16
+
17
+ type View_ = {
18
+ settings: { sources: CompassSource[]; instructions: string; glossary: GlossaryEntry[] };
19
+ readers: { conversation: boolean; history: boolean };
20
+ presets: PresetView[];
21
+ blocked: string | null;
22
+ places: Record<string, { status: string; readAt: string | null; at: string | null; error: string | null }>;
23
+ notes: CompassNote[];
24
+ workspaces: Record<string, string>;
25
+ unplaced: number;
26
+ lastRead: { at: string; trigger: string; ok: boolean; notes: number; error: string | null } | null;
27
+ today: { extractions: number; cap: number };
28
+ running: boolean;
29
+ };
30
+ type Found = { id: string; name: string; place: Place };
31
+
32
+ const clock = (iso: string) => new Date(iso).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", hourCycle: "h23" });
33
+ const placeName = (p: Place) => p.kind === "conversation" ? (p.sub === "dm" ? `DM with ${p.name}` : `#${p.name}`) : p.name;
34
+ /** "DM with Dana" when the source is one person read in their DM; else "Dana in #planning, DM with Avi". */
35
+ const whoWhere = (s: CompassSource) => s.who.kind === "person" && s.places.length === 1 && s.places[0].kind === "conversation" && s.places[0].sub === "dm" && s.places[0].id === s.who.person.id
36
+ ? placeName(s.places[0]) : `${whoName(s.who)} in ${s.places.map(placeName).join(", ")}`;
37
+ const day = (d: string) => new Date(`${d}T12:00:00`).toLocaleDateString([], { weekday: "short", month: "short", day: "numeric" });
38
+ const whoName = (w: Who) => w.kind === "person" ? w.person.name : w.kind === "people" ? w.people.map(p => p.name).join(", ") : w.kind === "me" ? "You" : "Everyone";
39
+
40
+ /**
41
+ * Settings → Morning brief → Compass (docs/compass.md): the people and places that set the developer's priorities, how
42
+ * to read them, and the glossary. One editor for every source; presets only fill its fields. Every change goes through
43
+ * the RPC `set_compass` runs, and Read now through `read_compass`.
44
+ */
45
+ export function CompassSection({ theme, compact }: { theme: Theme; compact: boolean }) {
46
+ const c = theme.colors; const t = text(c, compact);
47
+ const read = useRpc(compassRpc); const write = useRpc(setCompassRpc); const readNow = useRpc(readCompassRpc);
48
+ const cache = useQueryClient(); const toast = useToast();
49
+ const query = useQuery({ queryKey: compassKey, queryFn: async () => await read({}) as View_, refetchInterval: q => q.state.data?.running ? 2_000 : 30_000 });
50
+ const change = useMutation({
51
+ mutationFn: async (input: CompassChange) => await write(input) as View_,
52
+ onSuccess: value => cache.setQueryData(compassKey, value),
53
+ onError: error => toast.error(errorText(error)),
54
+ });
55
+ const reading = useMutation({
56
+ mutationFn: async () => await readNow({}) as { running: boolean; view: View_ },
57
+ onSuccess: r => cache.setQueryData(compassKey, r.view),
58
+ onError: error => toast.error(errorText(error)),
59
+ });
60
+ const [editing, setEditing] = useState<string | "new" | null>(null);
61
+ const data = query.data;
62
+ const full = !!data && data.settings.sources.length >= COMPASS.sources;
63
+ return <SettingsSection title="Compass" info="The people and places that set your priorities. Follow-up reads what they say each workday morning, keeps a note of each priority with their words, and AI priority ranks your work by it. Only the people you pick are read, only through read-only tools, and a fast model with no tools reads it. Agents can set it up too.">
64
+ {query.isPending && <ActivityIndicator accessibilityLabel="Loading Compass" color={c.foregroundMuted} style={{ alignSelf: "flex-start", marginVertical: 8 }} />}
65
+ {query.error && <Text style={[t.meta, { color: c.statusWarning }]}>{`Couldn't load Compass: ${errorText(query.error)}`}</Text>}
66
+ {data?.blocked && <Line icon="TriangleAlert" tone={c.statusWarning} text={data.blocked} theme={theme} compact={compact} />}
67
+ {data && <View style={{ ...raised(c), borderRadius: 10, backgroundColor: c.surface1, overflow: "hidden" }}>
68
+ {data.settings.sources.length === 0 && editing !== "new" && <View style={{ padding: compact ? 14 : 12, gap: 4 }}>
69
+ <Text style={[t.label, { color: c.foreground }]}>Nobody sets your priorities here yet</Text>
70
+ <Text style={t.meta}>Add the person whose words decide what you work on first, like your product lead's DM. Or ask the Overseer to set it up for you.</Text>
71
+ </View>}
72
+ {data.settings.sources.map((s, i) => editing === s.id
73
+ ? <SourceEditor key={s.id} view={data} source={s} first={i === 0} busy={change.isPending} theme={theme} compact={compact} onCancel={() => setEditing(null)}
74
+ onSave={input => change.mutate(input, { onSuccess: () => setEditing(null) })} onRemove={() => change.mutate({ remove: s.id }, { onSuccess: () => setEditing(null) })} />
75
+ : <SourceRow key={s.id} view={data} source={s} first={i === 0} busy={change.isPending} theme={theme} compact={compact} onEdit={() => setEditing(s.id)}
76
+ onToggle={on => change.mutate({ source: { id: s.id, enabled: on } })} />)}
77
+ {editing === "new" && <SourceEditor view={data} first={data.settings.sources.length === 0} busy={change.isPending} theme={theme} compact={compact} onCancel={() => setEditing(null)}
78
+ onSave={input => change.mutate(input, { onSuccess: () => setEditing(null) })} />}
79
+ </View>}
80
+ {data && editing !== "new" && <View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 8 }}>
81
+ {full
82
+ ? <Text style={t.meta}>{`Compass holds ${COMPASS.sources} sources. Remove one to add another.`}</Text>
83
+ : <Button title="Add a source" icon="Plus" theme={theme} compact={compact} disabled={!!editing} onPress={() => setEditing("new")} />}
84
+ {data.settings.sources.length > 0 && <Button title="Read now" icon="RotateCcw" kind="ghost" theme={theme} compact={compact} loading={reading.isPending || data.running} disabled={!!data.blocked} onPress={() => reading.mutate()} />}
85
+ {data.settings.sources.length > 0 && <Text style={t.meta}>{statusLine(data)}</Text>}
86
+ </View>}
87
+ {data && <ReadingNotes value={data.settings.instructions} busy={change.isPending} theme={theme} compact={compact} onSave={v => change.mutate({ instructions: v })} />}
88
+ {data && <Glossary entries={data.settings.glossary} busy={change.isPending} theme={theme} compact={compact} onSave={g => change.mutate({ glossary: g })} />}
89
+ </SettingsSection>;
90
+ }
91
+
92
+ /** "Read 09:02 · 3 notes live · 1 not matched to a workspace", or why the last read failed. */
93
+ function statusLine(v: View_): string {
94
+ if (v.running) return "Reading…";
95
+ // One source already shows its count on its row; the total is news only with several.
96
+ const parts = [v.lastRead ? `Read ${clock(v.lastRead.at)}` : "Not read yet", ...(v.settings.sources.length > 1 ? [`${v.notes.length} note${v.notes.length === 1 ? "" : "s"} live`] : [])];
97
+ if (v.unplaced) parts.push(`${v.unplaced} not matched to a workspace`);
98
+ if (v.today.extractions >= v.today.cap) parts.push(`paused until tomorrow: ${v.today.cap} reads today`);
99
+ return parts.join(" · ");
100
+ }
101
+
102
+ function Line({ icon, tone, text: line, theme, compact }: { icon: string; tone: string; text: string; theme: Theme; compact: boolean }) {
103
+ const t = text(theme.colors, compact);
104
+ return <View style={{ flexDirection: "row", alignItems: "flex-start", gap: 6 }}>
105
+ <View style={{ paddingTop: compact ? 4 : 3 }}><Icon name={icon} size={12} color={tone} /></View>
106
+ <Text style={[t.meta, { color: tone, flex: 1 }]}>{line}</Text>
107
+ </View>;
108
+ }
109
+
110
+ /** One source, read-only: who, where, its roles, its reading notes' first line, how its places read. Edit opens the editor in place. */
111
+ function SourceRow({ view, source, first, busy, onEdit, onToggle, theme, compact }: { view: View_; source: CompassSource; first: boolean; busy: boolean; onEdit: () => void; onToggle: (on: boolean) => void; theme: Theme; compact: boolean }) {
112
+ const c = theme.colors; const t = text(c, compact);
113
+ const notes = view.notes.filter(n => n.source === source.id); const live = notes.length;
114
+ const [open, setOpen] = useState(false);
115
+ const bad = source.places.map(p => view.places[`${p.kind}:${p.id}`]).find(p => p && (p.status === "failed" || p.status === "paused"));
116
+ const slow = source.places.some(p => view.places[`${p.kind}:${p.id}`]?.status === "slow-path");
117
+ return <View style={{ flexDirection: "row", gap: 10, alignItems: "flex-start", padding: compact ? 14 : 12, borderTopWidth: first ? 0 : 1, borderTopColor: c.border }}>
118
+ <View style={{ flex: 1, minWidth: 0, gap: 4 }}>
119
+ <RichText plain style={[t.label, { color: source.enabled ? c.foreground : c.foregroundMuted }]}>{source.label}</RichText>
120
+ <Text style={t.meta}>{whoWhere(source)}</Text>
121
+ <View style={{ flexDirection: "row", flexWrap: "wrap", gap: 6 }}>
122
+ {source.roles.map(r => <View key={r} style={{ paddingHorizontal: 8, minHeight: 20, justifyContent: "center", borderRadius: 999, backgroundColor: c.surface2 }}>
123
+ <Text style={[t.meta, { color: c.foreground }]}>{ROLE_INFO[r].label}</Text>
124
+ </View>)}
125
+ </View>
126
+ {source.instructions ? <RichText plain numberOfLines={2} style={[t.meta, { fontStyle: "italic" }]}>{`“${source.instructions}”`}</RichText> : null}
127
+ {source.enabled && (live
128
+ ? <Pressable accessibilityRole="button" accessibilityState={{ expanded: open }} accessibilityLabel={`${open ? "Hide" : "Show"} ${live} note${live === 1 ? "" : "s"} from ${source.label}`} onPress={() => setOpen(o => !o)} hitSlop={compact ? 0 : 6}
129
+ style={{ flexDirection: "row", alignItems: "center", gap: 4, alignSelf: "flex-start", minHeight: compact ? 44 : 20 }}>
130
+ <Text style={[t.meta, { color: c.foreground }]}>{`${live} note${live === 1 ? "" : "s"} live`}</Text>
131
+ <Icon name={open ? "ChevronUp" : "ChevronDown"} size={12} color={c.foregroundMuted} />
132
+ {slow && <Text style={t.meta}>· read by search, the slower path</Text>}
133
+ </Pressable>
134
+ : <Text style={t.meta}>{["No notes live", slow ? "read by search, the slower path" : null].filter(Boolean).join(" · ")}</Text>)}
135
+ {source.enabled && open && <NoteList notes={notes} view={view} theme={theme} compact={compact} />}
136
+ {source.enabled && bad?.error && <Line icon="TriangleAlert" tone={c.statusWarning} text={bad.error} theme={theme} compact={compact} />}
137
+ <Pressable accessibilityRole="button" accessibilityLabel={`Edit ${source.label}`} onPress={onEdit} disabled={busy} hitSlop={compact ? 0 : 6}
138
+ style={{ flexDirection: "row", alignItems: "center", gap: 4, alignSelf: "flex-start", minHeight: compact ? 44 : 20 }}>
139
+ <Icon name="Pencil" size={12} color={c.accent} />
140
+ <Text style={[t.meta, { color: c.accent, fontWeight: "600" }]}>Edit</Text>
141
+ </Pressable>
142
+ </View>
143
+ <Switch theme={theme} compact={compact} label={compact ? "" : source.enabled ? "On" : "Off"} accessibilityLabel={`Read ${source.label}`} value={source.enabled} disabled={busy} onChange={onToggle} />
144
+ </View>;
145
+ }
146
+
147
+ /**
148
+ * What Compass understood from a source: each live note, the words it quotes, its date and where it went. The quote is
149
+ * the proof (a-compass-note-quotes-its-source), so it is always shown.
150
+ */
151
+ function NoteList({ notes, view, theme, compact }: { notes: CompassNote[]; view: View_; theme: Theme; compact: boolean }) {
152
+ const c = theme.colors; const t = text(c, compact);
153
+ const where = (n: CompassNote) => n.match.workspace ? view.workspaces[n.match.workspace] ?? "its workspace" : n.match.issue ? n.match.issue : "not matched to a workspace";
154
+ return <View style={{ gap: 10, paddingTop: 2 }}>
155
+ {notes.map(n => <View key={n.id} style={{ gap: 2, paddingLeft: 10, borderLeftWidth: 2, borderLeftColor: c.border }}>
156
+ <RichText plain style={[t.body, { color: c.foreground }]}>{n.what}</RichText>
157
+ {n.quote && <RichText plain numberOfLines={3} style={[t.meta, { fontStyle: "italic" }]}>{`“${n.quote}”`}</RichText>}
158
+ <Text style={[t.meta, { fontVariant: ["tabular-nums"] }]}>{[n.until ? `Until ${day(n.until)}` : null, ROLE_INFO[n.role].label, where(n)].filter(Boolean).join(" · ")}</Text>
159
+ </View>)}
160
+ </View>;
161
+ }
162
+
163
+ /**
164
+ * The one editor for adding and changing a source. A preset only fills the fields. Who and where are picked from the chat
165
+ * tool's own search (compass_find), so every place has the tool's own id; a person's DM comes with the person.
166
+ */
167
+ function SourceEditor({ view, source, first, busy, onSave, onCancel, onRemove, theme, compact }: { view: View_; source?: CompassSource; first: boolean; busy: boolean; onSave: (c: CompassChange) => void; onCancel: () => void; onRemove?: () => void; theme: Theme; compact: boolean }) {
168
+ const c = theme.colors; const t = text(c, compact);
169
+ const [preset, setPreset] = useState<Preset | null>(source ? null : view.presets.find(p => p.offered) ?? null);
170
+ const [people, setPeople] = useState<Found[]>(source ? source.who.kind === "person" ? [{ id: source.who.person.id, name: source.who.person.name, place: null! }] : source.who.kind === "people" ? source.who.people.map(p => ({ id: p.id, name: p.name, place: null! })) : [] : []);
171
+ const [me, setMe] = useState(source?.who.kind === "me" || preset?.who === "me");
172
+ const [places, setPlaces] = useState<Place[]>(source?.places ?? []);
173
+ const [roles, setRoles] = useState<Role[]>(source?.roles ?? preset?.roles ?? ["priorities"]);
174
+ const [label, setLabel] = useState(source?.label ?? "");
175
+ const [notes, setNotes] = useState(source?.instructions ?? "");
176
+ const [picking, setPicking] = useState<"people" | "channels" | null>(null);
177
+ const usePreset = (p: Preset) => { setPreset(p); setRoles(p.roles); setMe(p.who === "me"); if (p.who === "me") setPeople([]); };
178
+ const dmOnly = preset?.sub === "dm";
179
+ const addPerson = (f: Found) => {
180
+ setPicking(null);
181
+ setPeople(ps => ps.some(p => p.id === f.id) || ps.length >= COMPASS.people ? ps : [...ps, f]);
182
+ // A person's DM preset: their DM is the place.
183
+ if (dmOnly) setPlaces(ps => ps.some(p => p.id === f.id) ? ps : [...ps, f.place].slice(0, COMPASS.places));
184
+ if (!label && !source) setLabel(f.name);
185
+ };
186
+ const who: Who | null = me ? { kind: "me" } : people.length === 1 ? { kind: "person", person: { id: people[0].id, name: people[0].name } } : people.length > 1 ? { kind: "people", people: people.map(p => ({ id: p.id, name: p.name })) } : null;
187
+ const ready = !!who && places.length > 0 && roles.length > 0;
188
+ const save = () => who && onSave({ source: { ...(source ? { id: source.id } : {}), ...(label.trim() ? { label: label.trim() } : {}), who, places, roles, instructions: notes } });
189
+ const chip = (title: string, onRemoveChip: () => void, key: string) => <View key={key} style={{ flexDirection: "row", alignItems: "center", gap: 4, minHeight: compact ? 44 : 28, paddingLeft: 10, paddingRight: 4, borderRadius: 6, borderWidth: 1, borderColor: c.border, backgroundColor: c.surface0 }}>
190
+ <Text style={t.body}>{title}</Text>
191
+ <Pressable accessibilityRole="button" accessibilityLabel={`Remove ${title}`} onPress={onRemoveChip} hitSlop={6} style={{ minWidth: compact ? 36 : 22, minHeight: compact ? 36 : 22, alignItems: "center", justifyContent: "center" }}>
192
+ <Icon name="X" size={12} color={c.foregroundMuted} />
193
+ </Pressable>
194
+ </View>;
195
+ const labelCol = (s: string) => <Text style={[t.meta, { width: compact ? undefined : 96, minWidth: compact ? 64 : undefined }]}>{s}</Text>;
196
+ const row = { flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 8 } as const;
197
+ return <SubmitScope enabled={ready && !busy} onSubmit={save} style={{ padding: compact ? 14 : 12, gap: 12, borderTopWidth: first ? 0 : 1, borderTopColor: c.border, backgroundColor: c.surface1 }}>
198
+ {!source && <View style={{ gap: 6 }}>
199
+ <Text style={[t.meta, { color: c.foreground, fontWeight: "600" }]}>Start from</Text>
200
+ <View style={row}>
201
+ {view.presets.filter(p => p.offered).map(p => <Pressable key={p.id} accessibilityRole="radio" accessibilityState={{ checked: preset?.id === p.id }} onPress={() => usePreset(p)}
202
+ style={state => ({ minHeight: compact ? 44 : 30, paddingHorizontal: 12, borderRadius: 6, justifyContent: "center", borderWidth: 1, borderColor: preset?.id === p.id ? c.accent : c.border,
203
+ backgroundColor: preset?.id === p.id ? tint(c.accent, c) : (state as { hovered?: boolean }).hovered ? c.surface2 : c.surface0 })}>
204
+ <Text style={{ color: c.foreground, fontSize: 13, fontWeight: "500" }}>{p.label}</Text>
205
+ </Pressable>)}
206
+ </View>
207
+ {preset && <Text style={t.meta}>{preset.hint}</Text>}
208
+ {view.presets.some(p => !p.offered) && <Text style={t.meta}>{`Not yet: ${view.presets.filter(p => !p.offered).map(p => p.label.toLowerCase()).join(", ")}. Compass reads conversations in this release.`}</Text>}
209
+ </View>}
210
+ <View style={row}>
211
+ {labelCol("Whose words")}
212
+ {me ? <Text style={t.body}>Yours</Text> : people.map(p => chip(p.name, () => { setPeople(ps => ps.filter(x => x.id !== p.id)); if (dmOnly) setPlaces(ps => ps.filter(x => x.id !== p.id)); }, p.id))}
213
+ {!me && people.length < COMPASS.people && <Button title={people.length ? "Add a person" : "Pick a person"} icon="Plus" kind={people.length ? "ghost" : "secondary"} theme={theme} compact={compact} onPress={() => setPicking(picking === "people" ? null : "people")} />}
214
+ </View>
215
+ {picking === "people" && <FindPicker kind="people" theme={theme} compact={compact} onCancel={() => setPicking(null)} onPick={addPerson} />}
216
+ <View style={row}>
217
+ {labelCol("Where")}
218
+ {places.map(p => chip(placeName(p), () => setPlaces(ps => ps.filter(x => x !== p)), `${p.kind}:${p.id}`))}
219
+ {places.length < COMPASS.places && !dmOnly && <Button title={places.length ? "Add" : "Pick a channel"} icon="Plus" kind={places.length ? "ghost" : "secondary"} theme={theme} compact={compact} onPress={() => setPicking(picking === "channels" ? null : "channels")} />}
220
+ {dmOnly && !places.length && <Text style={t.meta}>Their DM with you, once you pick them.</Text>}
221
+ </View>
222
+ {picking === "channels" && <FindPicker kind="channels" theme={theme} compact={compact} onCancel={() => setPicking(null)} onPick={f => { setPicking(null); setPlaces(ps => ps.some(p => p.id === f.id) ? ps : [...ps, f.place]); }} />}
223
+ <View style={{ gap: 6 }}>
224
+ <Text style={[t.meta, { color: c.foreground, fontWeight: "600" }]}>What they tell you</Text>
225
+ <View style={row}>
226
+ {ROLES.map(r => { const on = roles.includes(r); return <Pressable key={r} accessibilityRole="checkbox" accessibilityState={{ checked: on }} onPress={() => setRoles(rs => on ? rs.filter(x => x !== r) : [...rs, r])}
227
+ style={state => ({ minHeight: compact ? 44 : 28, paddingHorizontal: 10, borderRadius: 999, justifyContent: "center", borderWidth: 1, borderColor: on ? c.accent : c.border,
228
+ backgroundColor: on ? tint(c.accent, c) : (state as { hovered?: boolean }).hovered ? c.surface2 : "transparent" })}>
229
+ <Text style={{ color: on ? c.foreground : c.foregroundMuted, fontSize: 12, fontWeight: "500" }}>{ROLE_INFO[r].label}</Text>
230
+ </Pressable>; })}
231
+ </View>
232
+ </View>
233
+ <View style={{ gap: 6 }}>
234
+ <Text style={[t.meta, { color: c.foreground, fontWeight: "600" }]}>How to read this</Text>
235
+ <TextInput accessibilityLabel="How to read this source" multiline value={notes} onChangeText={v => setNotes(v.slice(0, COMPASS.sourceInstructions))} placeholder="P0 means today, P1 this week. Ignore hiring talk."
236
+ placeholderTextColor={c.foregroundMuted} style={{ minHeight: 64, padding: 10, borderRadius: 6, borderWidth: 1, borderColor: c.border, color: c.foreground, fontSize: 13, backgroundColor: c.surface0, textAlignVertical: "top" }} />
237
+ <Text style={t.meta}>{`Your words for the model that reads it. They change how messages are read, never what is read. ${notes.length}/${COMPASS.sourceInstructions}`}</Text>
238
+ </View>
239
+ <View style={row}>
240
+ {labelCol("Name")}
241
+ <TextInput accessibilityLabel="Source name" value={label} onChangeText={setLabel} placeholder="Dana · product" placeholderTextColor={c.foregroundMuted}
242
+ style={{ flex: 1, minWidth: 160, minHeight: compact ? 44 : 32, paddingHorizontal: 10, borderRadius: 6, borderWidth: 1, borderColor: c.border, color: c.foreground, fontSize: 13, backgroundColor: c.surface0 }} />
243
+ </View>
244
+ <View style={[row, { justifyContent: "space-between" }]}>
245
+ <View style={row}>
246
+ <Button title={source ? "Save" : "Add source"} kind="primary" shortcut theme={theme} compact={compact} loading={busy} disabled={!ready} onPress={save} />
247
+ <Button title="Cancel" kind="ghost" theme={theme} compact={compact} onPress={onCancel} />
248
+ </View>
249
+ {onRemove && <Button title="Remove source" kind="ghost" icon="Trash2" theme={theme} compact={compact} disabled={busy} onPress={onRemove} />}
250
+ </View>
251
+ {!ready && <Text style={t.meta}>{!who ? "Pick whose words count." : !places.length ? "Pick where to read them." : "Give it at least one role."}</Text>}
252
+ </SubmitScope>;
253
+ }
254
+
255
+ /** People or channels from the chat tool's own search (compass_find): only results with the tool's own id can be picked. */
256
+ function FindPicker({ kind, onPick, onCancel, theme, compact }: { kind: "people" | "channels"; onPick: (f: Found) => void; onCancel: () => void; theme: Theme; compact: boolean }) {
257
+ const c = theme.colors; const t = text(c, compact);
258
+ const find = useRpc(compassFindRpc);
259
+ const [q, setQ] = useState(""); const [debounced, setDebounced] = useState("");
260
+ useEffect(() => { const id = setTimeout(() => setDebounced(q.trim()), 350); return () => clearTimeout(id); }, [q]);
261
+ const results = useQuery({ queryKey: ["follow-up", "compass-find", kind, debounced], enabled: debounced.length >= 2, staleTime: 60_000,
262
+ queryFn: async () => await find({ kind, query: debounced }) as { results: Found[]; error: string | null } });
263
+ return <View style={{ borderWidth: 1, borderColor: c.border, borderRadius: 8, backgroundColor: c.surface0, overflow: "hidden" }}>
264
+ <View style={{ flexDirection: "row", gap: 8, padding: 8, alignItems: "center" }}>
265
+ <TextInput autoFocus accessibilityLabel={kind === "people" ? "Search people" : "Search channels"} value={q} onChangeText={setQ} placeholder={kind === "people" ? "Search people by name" : "Search channels by name"}
266
+ placeholderTextColor={c.foregroundMuted} autoCapitalize="none" autoCorrect={false}
267
+ style={{ flex: 1, minWidth: 0, minHeight: compact ? 44 : 32, paddingHorizontal: 10, borderRadius: 6, borderWidth: 1, borderColor: c.border, color: c.foreground, fontSize: 13, backgroundColor: c.surface1 }} />
268
+ <Button title="Cancel" kind="ghost" theme={theme} compact={compact} onPress={onCancel} />
269
+ </View>
270
+ {results.isFetching && <Text style={[t.meta, { paddingHorizontal: 12, paddingBottom: 8 }]}>Searching…</Text>}
271
+ {results.data?.error && <Text style={[t.meta, { paddingHorizontal: 12, paddingBottom: 8, color: c.statusWarning }]}>{results.data.error}</Text>}
272
+ {(results.data?.results ?? []).map(r => <Pressable key={r.id} accessibilityRole="button" onPress={() => onPick(r)}
273
+ style={state => ({ minHeight: compact ? 44 : 34, paddingHorizontal: 12, justifyContent: "center", borderTopWidth: 1, borderTopColor: c.border, backgroundColor: state.pressed || (state as { hovered?: boolean }).hovered ? c.surface2 : "transparent" })}>
274
+ <Text style={t.body}>{kind === "people" ? r.name : `#${r.name}`}</Text>
275
+ </Pressable>)}
276
+ {debounced.length >= 2 && !results.isFetching && !results.data?.results.length && !results.data?.error && <Text style={[t.meta, { paddingHorizontal: 12, paddingBottom: 8 }]}>{`Nothing matches "${debounced}".`}</Text>}
277
+ </View>;
278
+ }
279
+
280
+ /** "How to read your Compass": the developer's words for every source, saved on Save. */
281
+ function ReadingNotes({ value, busy, onSave, theme, compact }: { value: string; busy: boolean; onSave: (v: string) => void; theme: Theme; compact: boolean }) {
282
+ const c = theme.colors; const t = text(c, compact);
283
+ const [draft, setDraft] = useState(value);
284
+ useEffect(() => setDraft(value), [value]);
285
+ const dirty = draft.trim() !== value.trim();
286
+ return <SubmitScope enabled={dirty && !busy} onSubmit={() => onSave(draft)} style={{ gap: 6 }}>
287
+ <Text style={[t.label, { color: c.foreground }]}>How to read your Compass</Text>
288
+ <TextInput accessibilityLabel="How to read your Compass" multiline value={draft} onChangeText={v => setDraft(v.slice(0, COMPASS.instructions))} placeholder="P0 means today. 'The renewal' is the acme renewal. Customer asks wait for the plan unless they name a date."
289
+ placeholderTextColor={c.foregroundMuted} style={{ minHeight: 72, padding: 10, borderRadius: 6, borderWidth: 1, borderColor: c.border, color: c.foreground, fontSize: 13, backgroundColor: c.surface0, textAlignVertical: "top" }} />
290
+ <View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 8 }}>
291
+ <Text style={[t.meta, { flex: 1, minWidth: 180 }]}>{`For every source. ${draft.length}/${COMPASS.instructions}`}</Text>
292
+ {dirty && <Button title="Save" kind="primary" shortcut theme={theme} compact={compact} loading={busy} onPress={() => onSave(draft)} />}
293
+ </View>
294
+ </SubmitScope>;
295
+ }
296
+
297
+ /** The glossary: your words → an issue key. Matching reads it before anything else, word for word. */
298
+ function Glossary({ entries, busy, onSave, theme, compact }: { entries: GlossaryEntry[]; busy: boolean; onSave: (g: GlossaryEntry[]) => void; theme: Theme; compact: boolean }) {
299
+ const c = theme.colors; const t = text(c, compact);
300
+ const [words, setWords] = useState(""); const [key, setKey] = useState("");
301
+ const means = (g: GlossaryEntry) => "issue" in g.means ? g.means.issue : "workspace" in g.means ? `workspace ${g.means.workspace}` : g.means.account;
302
+ const field = { minHeight: compact ? 44 : 32, paddingHorizontal: 10, borderRadius: 6, borderWidth: 1, borderColor: c.border, color: c.foreground, fontSize: 13, backgroundColor: c.surface0 } as const;
303
+ const add = () => { onSave([...entries, { words: words.trim(), means: { issue: key.trim().toUpperCase() } }]); setWords(""); setKey(""); };
304
+ return <View style={{ gap: 6 }}>
305
+ <Text style={[t.label, { color: c.foreground }]}>Glossary</Text>
306
+ <Text style={t.meta}>Your own words for your work. When a note says one, it goes to that issue's workspace.</Text>
307
+ {entries.map(g => <View key={g.words} style={{ flexDirection: "row", alignItems: "center", gap: 8, minHeight: compact ? 44 : 28 }}>
308
+ <RichText plain style={[t.body, { color: c.foreground }]}>{`“${g.words}”`}</RichText>
309
+ <Icon name="ArrowRight" size={12} color={c.foregroundMuted} />
310
+ <Text style={[t.body, { fontFamily: "ui-monospace, Menlo, monospace", fontSize: 12 }]}>{means(g)}</Text>
311
+ <Pressable accessibilityRole="button" accessibilityLabel={`Remove ${g.words}`} disabled={busy} onPress={() => onSave(entries.filter(x => x !== g))} hitSlop={6}
312
+ style={{ minWidth: compact ? 44 : 22, minHeight: compact ? 44 : 22, alignItems: "center", justifyContent: "center" }}>
313
+ <Icon name="X" size={12} color={c.foregroundMuted} />
314
+ </Pressable>
315
+ </View>)}
316
+ {entries.length < COMPASS.glossary && <View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 8 }}>
317
+ <TextInput accessibilityLabel="Word" value={words} onChangeText={setWords} placeholder="Phoenix" placeholderTextColor={c.foregroundMuted} style={[field, { flexGrow: 1, flexBasis: 120, minWidth: 0 }]} />
318
+ <Icon name="ArrowRight" size={12} color={c.foregroundMuted} />
319
+ <TextInput accessibilityLabel="Issue key" value={key} onChangeText={setKey} placeholder="ACME-40" autoCapitalize="characters" placeholderTextColor={c.foregroundMuted} style={[field, { flexGrow: 1, flexBasis: 100, minWidth: 0, fontFamily: "ui-monospace, Menlo, monospace" }]} />
320
+ <Button title="Add" icon="Plus" theme={theme} compact={compact} loading={busy} disabled={words.trim().length < 2 || key.trim().length < 3} onPress={add} />
321
+ </View>}
322
+ </View>;
323
+ }
package/client/header.tsx CHANGED
@@ -94,7 +94,7 @@ export function WorkspaceHeader({ workspace: w, theme, compact, now, onSettings,
94
94
  <Text numberOfLines={1} style={[t.small, { flexShrink: 1 }, stale ? { color: c.statusWarning } : null]}>{checked ? `Checked ${ago(checked, now)}${stale ? " · may be out of date" : ""}` : "Checks GitHub every 15s"}</Text>
95
95
  <IconButton icon="RefreshCw" label="Refresh PR status" onPress={onRefresh} theme={theme} compact={compact} disabled={refreshing} spinning={refreshing} />
96
96
  <View style={{ flex: 1 }} />
97
- <Switch theme={theme} compact={compact} label="Auto-send" accessibilityLabel="Auto-send tasks" hint="Send tasks to the main agent on its own when the agent is idle. Off means each message waits for your click."
97
+ <Switch theme={theme} compact={compact} label="Auto-send" accessibilityLabel="Auto-send repairs" hint="Send repairs to the main agent on its own when the agent is idle. Off means each message waits for your click."
98
98
  value={w.enable_auto_sends} disabled={autoPending} onChange={onAuto} />
99
99
  </View>
100
100
  </>;