paseo-follow-up 0.3.6 → 0.4.0
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.
- package/OVERVIEW.md +19 -7
- package/README.md +70 -79
- package/THIRD_PARTY_NOTICES.md +33 -0
- package/assets/LICENSE.lucide +43 -0
- package/assets/icon.png +0 -0
- package/assets/icon.svg +1 -0
- package/client/button-visibility.ts +2 -1
- package/client/chat.tsx +163 -0
- package/client/display.tsx +12 -17
- package/client/header.tsx +92 -0
- package/client/keys.ts +3 -0
- package/client/kit.tsx +119 -0
- package/client/large.tsx +58 -0
- package/client/live.tsx +159 -0
- package/client/motion.tsx +93 -0
- package/client/needs-you.tsx +121 -0
- package/client/overview.tsx +111 -16
- package/client/panel.tsx +257 -68
- package/client/pr-controls.tsx +50 -33
- package/client/pr-sheet.tsx +63 -0
- package/client/questions.tsx +307 -0
- package/client/settings.tsx +55 -20
- package/client/spec.tsx +113 -0
- package/client/stacks.tsx +128 -0
- package/client/tasks.tsx +113 -22
- package/client/theme.ts +69 -0
- package/docs/screenshots/follow-up-chat.png +0 -0
- package/docs/screenshots/follow-up-hero.png +0 -0
- package/docs/screenshots/follow-up-large.png +0 -0
- package/docs/screenshots/follow-up-mobile.png +0 -0
- package/docs/screenshots/follow-up-overview.png +0 -0
- package/docs/screenshots/follow-up-pill.png +0 -0
- package/docs/screenshots/follow-up-pr.png +0 -0
- package/docs/screenshots/follow-up-questions.png +0 -0
- package/docs/screenshots/follow-up-states.png +0 -0
- package/index.client.tsx +47 -16
- package/index.server.ts +53 -0
- package/package.json +4 -2
- package/paseo-plugin.json +11 -3
- package/server/agent-hook.mjs +2 -0
- package/server/daemon.ts +37 -6
- package/server/discovery.ts +6 -3
- package/server/engine.ts +39 -0
- package/server/hook-source.ts +1 -1
- package/server/mcp-source.ts +1 -1
- package/server/mcp.mjs +12 -2
- package/server/questions.ts +112 -0
- package/server/spec.ts +102 -0
- package/shared/activity.ts +56 -0
- package/shared/attention.ts +212 -0
- package/shared/chat.ts +130 -0
- package/shared/contracts.ts +21 -0
- package/shared/display.ts +2 -1
- package/shared/errors.ts +5 -0
- package/shared/model.ts +10 -0
- package/shared/pr-actions.ts +8 -1
- package/shared/questions.ts +123 -0
- package/shared/spec.ts +46 -0
- package/skills/follow-through/SKILL.md +4 -0
- package/client/components.tsx +0 -58
- package/client/navigation.tsx +0 -23
- package/docs/screenshots/follow-up-settings.png +0 -0
- package/docs/screenshots/follow-up-workspace.png +0 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
// The question dialog and its answer form. The layout of options with a recommendation, the
|
|
2
|
+
// "what the agent does meanwhile" line and Copy are adapted from Progress
|
|
3
|
+
// (@stevecastaneda/paseo-progress, MIT, © 2026 Steve Castaneda); see THIRD_PARTY_NOTICES.md.
|
|
4
|
+
import { useEffect, useState } from "react";
|
|
5
|
+
import { Pressable, Text, View } from "react-native";
|
|
6
|
+
import { openExternalUrl, useRpc } from "@getpaseo/plugin/client";
|
|
7
|
+
import { Icon, Modal, ScrollView, TextInput, copyText, useToast } from "@getpaseo/plugin/client/ui";
|
|
8
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
9
|
+
import { answerQuestionRpc } from "../shared/contracts";
|
|
10
|
+
import type { Workspace } from "../shared/model";
|
|
11
|
+
import { isOpen, questionState, replyText, type Question } from "../shared/questions";
|
|
12
|
+
import { ago } from "../shared/attention";
|
|
13
|
+
import { activity, type ActivityTone } from "../shared/activity";
|
|
14
|
+
import { Button, Card, CardRow, Chip, FoldRow, IconButton, errorText, text, type Theme } from "./kit";
|
|
15
|
+
import { Spinner } from "./motion";
|
|
16
|
+
import { mergedColor, tint, withAlpha, type Colors } from "./theme";
|
|
17
|
+
import { overviewKey, workspaceKey } from "./keys";
|
|
18
|
+
|
|
19
|
+
const who = (w: Workspace, agentId: string | null) => !agentId || agentId === w.mainAgentId ? "the main agent" : "a root session";
|
|
20
|
+
|
|
21
|
+
/** What the agent is doing while the question is open, in the developer's terms. */
|
|
22
|
+
export function meanwhile(w: Workspace, q: Question): { icon: string; color: (c: Colors) => string; text: string } {
|
|
23
|
+
if (q.taskId && !q.options.length) return { icon: "Clock", color: c => c.foregroundMuted, text: "A task is blocked on this. The agent works on the rest." };
|
|
24
|
+
switch (questionState(q)) {
|
|
25
|
+
case "stopped": return { icon: "CirclePause", color: c => c.statusWarning, text: q.big ? `The agent stopped and waits for your answer. Big question: ${q.big}.` : "The agent stopped and waits for your answer." };
|
|
26
|
+
case "building": return { icon: "Hammer", color: c => c.foregroundMuted, text: `The agent is building ${q.recommend} while you decide. Pick another option and it undoes that first.` };
|
|
27
|
+
default: return q.big
|
|
28
|
+
? { icon: "Hand", color: c => c.statusWarning, text: `Big question: ${q.big}. The agent builds nothing this affects until you answer.` }
|
|
29
|
+
: { icon: "Clock", color: c => c.foregroundMuted, text: "The agent holds what this affects and keeps working on the rest." };
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function deliveryLine(w: Workspace, q: Question, now: number): { icon: string; tone: "success" | "warning" | "muted" | "spinner"; text: string } | null {
|
|
34
|
+
const d = q.answer?.delivery;
|
|
35
|
+
if (!d) return null;
|
|
36
|
+
switch (d.state) {
|
|
37
|
+
case "sent": return { icon: "CircleCheck", tone: "success", text: `Sent to ${who(w, d.to)} ${ago(d.at, now)}` };
|
|
38
|
+
case "sending": return { icon: "", tone: "spinner", text: "Sending to the agent…" };
|
|
39
|
+
case "queued": return { icon: "Clock", tone: "muted", text: `${d.reason ?? "Waiting for the agent."} It goes out on the next check.` };
|
|
40
|
+
case "unconfirmed": return { icon: "TriangleAlert", tone: "warning", text: d.reason ?? "Paseo didn't confirm the message. Check the agent's chat before resending." };
|
|
41
|
+
case "copied": return { icon: "Copy", tone: "muted", text: `Copied ${ago(d.at, now)}. Paste it into the agent's chat, or send it from here.` };
|
|
42
|
+
case "recorded": return { icon: "MessageSquare", tone: "muted", text: `You answered in chat; the agent recorded it ${ago(d.at, now)}.` };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function OptionCard({ theme, letter, label, consequence, recommended, selected, disabled, onPress, compact, dense = false }: { theme: Theme; letter: string; label: string; consequence?: string; recommended: boolean; selected: boolean; disabled: boolean; onPress: () => void; compact: boolean; dense?: boolean }) {
|
|
47
|
+
const c = theme.colors; const t = text(c);
|
|
48
|
+
return <Pressable accessibilityRole="radio" aria-checked={selected} accessibilityState={{ checked: selected, disabled }} accessibilityLabel={`${letter}. ${label}${recommended ? ". Recommended" : ""}${consequence ? `. ${consequence}` : ""}`}
|
|
49
|
+
disabled={disabled} onPress={onPress}
|
|
50
|
+
style={state => ({ flexDirection: "row", gap: 10, paddingHorizontal: dense ? 10 : 12, paddingVertical: compact ? 12 : dense ? 8 : 10, borderRadius: 8, borderWidth: selected ? 1.5 : 1,
|
|
51
|
+
borderColor: selected ? c.accent : c.border, margin: selected ? 0 : 0.5,
|
|
52
|
+
backgroundColor: selected ? withAlpha(c.accent, 0.08) : state.pressed ? c.surface2 : (state as { hovered?: boolean }).hovered && !disabled ? c.surface1 : "transparent" })}>
|
|
53
|
+
<View style={{ width: 18, height: 18, marginTop: 1, borderRadius: 9, borderWidth: selected ? 5 : 1.5, borderColor: selected ? c.accent : c.foregroundMuted }} />
|
|
54
|
+
<View style={{ flex: 1, minWidth: 0, gap: 2 }}>
|
|
55
|
+
<View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", columnGap: 8, rowGap: 4 }}>
|
|
56
|
+
<Text style={t.label}><Text style={{ fontVariant: ["tabular-nums"] }}>{letter}</Text>{" "}{label}</Text>
|
|
57
|
+
{recommended && <Chip theme={theme} icon="ThumbsUp" label="Recommended" color={c.foregroundMuted} />}
|
|
58
|
+
</View>
|
|
59
|
+
{!!consequence && <Text numberOfLines={dense ? 2 : undefined} style={t.meta}>{consequence}</Text>}
|
|
60
|
+
</View>
|
|
61
|
+
</Pressable>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const inputStyle = (c: Colors, compact: boolean, lines: number) => ({ minHeight: compact ? 44 : 18 * lines + 16, paddingHorizontal: 10, paddingVertical: 8, borderRadius: 6, borderWidth: 1, borderColor: c.border, color: c.foreground, backgroundColor: c.surface1, fontSize: 13, lineHeight: 18, textAlignVertical: "top" as const });
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* One question with its answer form. Send records the answer and messages the asking agent straight
|
|
68
|
+
* away; Copy records it and puts a reply on the clipboard instead. Used by the dialog and the pill.
|
|
69
|
+
*/
|
|
70
|
+
export function QuestionBody({ workspace: w, question: q, theme, compact, now = Date.now(), dense = false, bodyMaxHeight, openAgent, onAnswered, onDetails }: {
|
|
71
|
+
workspace: Workspace; question: Question; theme: Theme; compact: boolean; now?: number; dense?: boolean; bodyMaxHeight?: number; openAgent?: (agentId: string) => void; onAnswered?: () => void; onDetails?: () => void;
|
|
72
|
+
}) {
|
|
73
|
+
const c = theme.colors; const t = text(c);
|
|
74
|
+
const toast = useToast(); const cache = useQueryClient();
|
|
75
|
+
const answerRpc = useRpc(answerQuestionRpc);
|
|
76
|
+
const open = isOpen(q);
|
|
77
|
+
const [choice, setChoice] = useState<string | null>(q.answer?.choice ?? null);
|
|
78
|
+
const [words, setWords] = useState(q.answer?.words ?? "");
|
|
79
|
+
const [noteOpen, setNoteOpen] = useState(false);
|
|
80
|
+
// The pill's scrolling body: track whether more sits below the fold, so it can say so.
|
|
81
|
+
const [scroll, setScroll] = useState({ content: 0, view: 0, offset: 0 });
|
|
82
|
+
const more = scroll.content - scroll.view - scroll.offset > 4;
|
|
83
|
+
useEffect(() => { setChoice(q.answer?.choice ?? null); setWords(q.answer?.words ?? ""); }, [q.id]);
|
|
84
|
+
const refresh = () => { void cache.invalidateQueries({ queryKey: workspaceKey(w.id) }); void cache.invalidateQueries({ queryKey: overviewKey }); };
|
|
85
|
+
const free = !q.options.length;
|
|
86
|
+
const answer = free ? words.trim() : choice;
|
|
87
|
+
const note = free ? undefined : words.trim() || undefined;
|
|
88
|
+
const run = useMutation({
|
|
89
|
+
mutationFn: async (action: "send" | "copy" | "resend") => {
|
|
90
|
+
if (action === "copy") await copyText(replyText(q, q.answer?.choice ?? answer!, q.answer?.words ?? note));
|
|
91
|
+
return answerRpc({ workspaceId: w.id, questionId: q.id, choice: q.answer?.choice ?? answer!, words: q.answer?.words ?? note, action });
|
|
92
|
+
},
|
|
93
|
+
onSuccess: (result, action) => {
|
|
94
|
+
const d = result.question.answer?.delivery;
|
|
95
|
+
if (action === "copy") toast.show(`Copied the ${q.id} answer. Paste it into the agent's chat.`, { variant: "success" });
|
|
96
|
+
else if (d?.state === "sent") toast.show(`Sent your ${q.id} answer to the agent`, { variant: "success" });
|
|
97
|
+
else if (d?.state === "queued") toast.show(`Answer saved. It goes to the agent when it can take it.`, { variant: "info" });
|
|
98
|
+
else toast.show("Paseo didn't confirm the message. Check the agent's chat before resending.", { variant: "warning" });
|
|
99
|
+
refresh(); onAnswered?.();
|
|
100
|
+
},
|
|
101
|
+
onError: error => { toast.error(errorText(error)); refresh(); },
|
|
102
|
+
});
|
|
103
|
+
const state = meanwhile(w, q);
|
|
104
|
+
const delivery = deliveryLine(w, q, now);
|
|
105
|
+
const pr = q.prKey ? w.prs.find(p => p.key === q.prKey) : null;
|
|
106
|
+
const task = q.taskId ? w.obligations.find(o => o.id === q.taskId) : null;
|
|
107
|
+
const chosen = q.options.find(o => o.letter === q.answer?.choice);
|
|
108
|
+
const deliveryColor = delivery?.tone === "success" ? c.statusSuccess : delivery?.tone === "warning" ? c.statusWarning : c.foregroundMuted;
|
|
109
|
+
const context = (!!q.background || !!q.links.length || pr || task) && <View style={{ gap: 8 }}>
|
|
110
|
+
{!!q.background && <Text selectable numberOfLines={dense ? 3 : undefined} style={t.meta}>{q.background}</Text>}
|
|
111
|
+
{!dense && q.links.map((link, i) => <View key={i} style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
112
|
+
<Icon name={link.url ? "Globe" : "FileText"} size={13} color={c.foregroundMuted} />
|
|
113
|
+
{link.url ? <Pressable accessibilityRole="link" accessibilityLabel={`Open ${link.label || link.url}`} onPress={() => { void openExternalUrl(link.url!).catch(() => undefined); }} hitSlop={4}
|
|
114
|
+
style={state => ({ flexShrink: 1, opacity: state.pressed ? 0.7 : 1 })}>
|
|
115
|
+
<Text numberOfLines={1} style={[t.meta, { color: c.foreground, textDecorationLine: "underline" }]}>{link.label || link.url}{link.label ? <Text style={{ color: c.foregroundMuted, textDecorationLine: "none" }}>{` ${hostOf(link.url)}`}</Text> : null}</Text>
|
|
116
|
+
</Pressable> : <Text selectable numberOfLines={1} style={[t.meta, { flexShrink: 1, color: c.foreground }]}>{link.label ? `${link.label} ` : ""}<Text style={{ color: c.foregroundMuted, fontFamily: "monospace", fontSize: 11 }}>{link.path}</Text></Text>}
|
|
117
|
+
</View>)}
|
|
118
|
+
{!dense && pr && <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
119
|
+
<Icon name="GitPullRequest" size={13} color={pr.snapshot?.state === "MERGED" ? mergedColor(c) : c.foregroundMuted} />
|
|
120
|
+
<Text numberOfLines={1} style={[t.meta, { flexShrink: 1 }]}>About #{pr.number}{pr.snapshot?.title ? ` · ${pr.snapshot.title}` : ""}</Text>
|
|
121
|
+
</View>}
|
|
122
|
+
{!dense && task && <View style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
123
|
+
<Icon name="ListChecks" size={13} color={c.foregroundMuted} />
|
|
124
|
+
<Text numberOfLines={2} style={[t.meta, { flexShrink: 1 }]}>Task: {task.title}</Text>
|
|
125
|
+
</View>}
|
|
126
|
+
</View>;
|
|
127
|
+
// In the pill popover the answer field and actions stay pinned below a scrolling body.
|
|
128
|
+
const pinned = dense && !!bodyMaxHeight;
|
|
129
|
+
const input = <View style={{ gap: 6 }}>
|
|
130
|
+
{free && !dense && <Text style={t.meta}>No options were given. Write the decision for the agent.</Text>}
|
|
131
|
+
<TextInput accessibilityLabel={free ? `Your answer to ${q.id}` : `Note for the agent about ${q.id}, optional`} placeholder={free ? "Your answer" : "Add a note for the agent (optional)"} placeholderTextColor={c.foregroundMuted}
|
|
132
|
+
multiline value={words} editable={!run.isPending} onChangeText={setWords} maxLength={2000} autoFocus={pinned && !free && noteOpen} style={inputStyle(c, compact, free && !dense ? 3 : 2)} />
|
|
133
|
+
</View>;
|
|
134
|
+
// Context comes before the options so the developer reads why before choosing.
|
|
135
|
+
const body = <View style={{ gap: dense ? 10 : 14 }}>
|
|
136
|
+
<View style={{ gap: 6 }}>
|
|
137
|
+
<Text selectable style={[t.body, { fontSize: dense ? 13 : 15, lineHeight: dense ? 19 : 22 }]}>{q.question}</Text>
|
|
138
|
+
{open && <View style={{ flexDirection: "row", gap: 6 }}>
|
|
139
|
+
<View style={{ paddingTop: 2 }}><Icon name={state.icon} size={12} color={state.color(c)} /></View>
|
|
140
|
+
<Text style={[t.meta, { flex: 1, color: state.color(c) }]}>{state.text}</Text>
|
|
141
|
+
</View>}
|
|
142
|
+
</View>
|
|
143
|
+
{q.closed && <View style={{ flexDirection: "row", gap: 6 }}>
|
|
144
|
+
<View style={{ paddingTop: 2 }}><Icon name="MessageCircleOff" size={12} color={c.foregroundMuted} /></View>
|
|
145
|
+
<Text style={[t.meta, { flex: 1 }]}>Withdrawn {ago(q.closed.at, now)}: {q.closed.reason}</Text>
|
|
146
|
+
</View>}
|
|
147
|
+
{context}
|
|
148
|
+
{!!q.options.length && <View accessibilityRole="radiogroup" accessibilityLabel={`Options for ${q.id}`} style={{ gap: 6 }}>
|
|
149
|
+
{q.options.map(o => <OptionCard key={o.letter} theme={theme} compact={compact} dense={dense} letter={o.letter} label={o.label} consequence={o.consequence} recommended={q.recommend === o.letter}
|
|
150
|
+
selected={(open ? choice : q.answer?.choice) === o.letter} disabled={!open || run.isPending} onPress={() => setChoice(o.letter)} />)}
|
|
151
|
+
</View>}
|
|
152
|
+
{q.answer && <View style={{ gap: 6, padding: 10, borderRadius: 8, backgroundColor: tint(c.statusSuccess, c) }}>
|
|
153
|
+
<View style={{ flexDirection: "row", gap: 6 }}>
|
|
154
|
+
<View style={{ paddingTop: 2 }}><Icon name="CircleCheck" size={13} color={c.statusSuccess} /></View>
|
|
155
|
+
<Text selectable style={[t.label, { flex: 1 }]}>{q.answer.by === "agent" ? "Answered in chat: " : "You answered "}{q.answer.choice}{chosen ? ` · ${chosen.label}` : ""}</Text>
|
|
156
|
+
</View>
|
|
157
|
+
{!!q.answer.words && <Text selectable style={[t.meta, { color: c.foreground, paddingLeft: 19 }]}>{q.answer.words}</Text>}
|
|
158
|
+
{delivery && <View style={{ flexDirection: "row", gap: 6, paddingLeft: 19 }}>
|
|
159
|
+
{delivery.tone === "spinner" ? <View style={{ paddingTop: 2 }}><Spinner color={c.foregroundMuted} size={11} /></View> : <View style={{ paddingTop: 2 }}><Icon name={delivery.icon} size={11} color={deliveryColor} /></View>}
|
|
160
|
+
<Text style={[t.meta, { flex: 1, color: deliveryColor }]}>{delivery.text}</Text>
|
|
161
|
+
</View>}
|
|
162
|
+
</View>}
|
|
163
|
+
{open && !pinned && input}
|
|
164
|
+
</View>;
|
|
165
|
+
const actions = (open || q.answer && ["queued", "unconfirmed", "copied"].includes(q.answer.delivery.state)) && <View style={{ gap: 6 }}>
|
|
166
|
+
<View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 8 }}>
|
|
167
|
+
{open && <Button theme={theme} compact={compact} kind="primary" icon="Send" title="Send to agent" accessibilityLabel={`Send your ${q.id} answer to the agent`} disabled={!answer || run.isPending} loading={run.isPending && run.variables === "send"} onPress={() => run.mutate("send")} />}
|
|
168
|
+
{open && <Button theme={theme} compact={compact} icon="Copy" title="Copy" accessibilityLabel={`Copy your ${q.id} answer instead of sending it`} disabled={!answer || run.isPending} loading={run.isPending && run.variables === "copy"} onPress={() => run.mutate("copy")} />}
|
|
169
|
+
{q.answer?.delivery.state === "copied" && <Button theme={theme} compact={compact} kind="primary" icon="Send" title="Send to agent" accessibilityLabel={`Send your ${q.id} answer to the agent`} loading={run.isPending} onPress={() => run.mutate("send")} />}
|
|
170
|
+
{q.answer && ["queued", "unconfirmed"].includes(q.answer.delivery.state) && <Button theme={theme} compact={compact} icon="RotateCcw" title={q.answer.delivery.state === "queued" ? "Try now" : "Resend"} accessibilityLabel={`Send the ${q.id} answer again`} loading={run.isPending} onPress={() => run.mutate("resend")} />}
|
|
171
|
+
{q.answer && ["queued", "unconfirmed"].includes(q.answer.delivery.state) && <Button theme={theme} compact={compact} kind="ghost" icon="Copy" title="Copy" accessibilityLabel={`Copy the ${q.id} answer`} onPress={() => { void copyText(replyText(q, q.answer!.choice, q.answer!.words)).then(() => toast.show("Copied", { variant: "success" }), () => toast.error("Couldn't copy here")); }} />}
|
|
172
|
+
{q.answer?.delivery.state === "unconfirmed" && openAgent && <Button theme={theme} compact={compact} kind="ghost" icon="MessageSquare" title="Open agent" onPress={() => openAgent(q.askedBy ?? w.mainAgentId)} />}
|
|
173
|
+
{pinned && open && !free && !noteOpen && <Button theme={theme} compact={compact} kind="ghost" icon="Pencil" title="Note" accessibilityLabel={`Add a note for the agent about ${q.id}`} onPress={() => setNoteOpen(true)} />}
|
|
174
|
+
{dense && onDetails && <IconButton theme={theme} compact={compact} icon="Maximize2" label={`Open ${q.id} with its links and full context`} onPress={onDetails} />}
|
|
175
|
+
</View>
|
|
176
|
+
{open && !dense && <Text style={t.small}>Send puts your answer straight into the asking agent's chat, even mid-turn. Follow-up keeps it under {q.id}.</Text>}
|
|
177
|
+
</View>;
|
|
178
|
+
// In the pill popover the question scrolls and the answer field and actions stay put, so Send is never cut off.
|
|
179
|
+
if (pinned) {
|
|
180
|
+
const showInput = open && (free || noteOpen);
|
|
181
|
+
return <View style={{ gap: 10 }}>
|
|
182
|
+
<View>
|
|
183
|
+
<ScrollView style={{ maxHeight: bodyMaxHeight! - (showInput ? 62 : 0), flexGrow: 0 }} contentContainerStyle={{ paddingRight: 2 }} scrollEventThrottle={32}
|
|
184
|
+
onLayout={e => { const view = e.nativeEvent.layout.height; setScroll(s => ({ ...s, view })); }}
|
|
185
|
+
onContentSizeChange={(_, content) => setScroll(s => ({ ...s, content }))}
|
|
186
|
+
onScroll={e => { const offset = e.nativeEvent.contentOffset.y; setScroll(s => ({ ...s, offset })); }}>{body}</ScrollView>
|
|
187
|
+
{more && <View accessibilityElementsHidden importantForAccessibility="no-hide-descendants" style={{ flexDirection: "row", alignItems: "center", gap: 4, paddingTop: 6 }}>
|
|
188
|
+
<Icon name="ChevronDown" size={12} color={c.foregroundMuted} />
|
|
189
|
+
<Text style={t.small}>More below</Text>
|
|
190
|
+
</View>}
|
|
191
|
+
</View>
|
|
192
|
+
{showInput && input}
|
|
193
|
+
{actions}
|
|
194
|
+
</View>;
|
|
195
|
+
}
|
|
196
|
+
return <View style={{ gap: dense ? 10 : 14 }}>
|
|
197
|
+
{body}
|
|
198
|
+
{actions}
|
|
199
|
+
{!dense && <Text style={t.small}>Asked {ago(q.askedAt, now)} by {who(w, q.askedBy)}{q.taskId && !q.options.length ? " (blocked task)" : ""}</Text>}
|
|
200
|
+
</View>;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function hostOf(url: string): string {
|
|
204
|
+
try { return new URL(url).host.replace(/^www\./, ""); } catch { return ""; }
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** The question dialog: a sheet on phones, a dialog on desktop. */
|
|
208
|
+
export function QuestionSheet({ workspace: w, questionId, theme, compact, onClose, openAgent }: { workspace: Workspace; questionId: string | null; theme: Theme; compact: boolean; onClose: () => void; openAgent?: (agentId: string) => void }) {
|
|
209
|
+
const c = theme.colors;
|
|
210
|
+
const q = questionId ? w.questions.find(x => x.id === questionId) ?? null : null;
|
|
211
|
+
const color = !q ? c.foregroundMuted : q.answer ? c.statusSuccess : q.closed ? c.foregroundMuted : c.statusWarning;
|
|
212
|
+
return <Modal title={q ? `${q.id} · ${q.title}` : "Question"} icon={<Icon name={q?.answer ? "MessageCircleReply" : "MessageCircleQuestion"} size={18} color={color} />} open={!!q} onOpenChange={next => { if (!next) onClose(); }}>
|
|
213
|
+
<Modal.Content contentContainerStyle={{ padding: compact ? 16 : 20 }}>
|
|
214
|
+
{q && <QuestionBody key={q.id} workspace={w} question={q} theme={theme} compact={compact} openAgent={openAgent} />}
|
|
215
|
+
</Modal.Content>
|
|
216
|
+
</Modal>;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** The pill steps through open questions ("1 of 3") and answers them without leaving the chat. */
|
|
220
|
+
export function QuestionStepper({ workspace: w, theme, compact, openAgent, onAnswered, onDetails, bodyMaxHeight }: { workspace: Workspace; theme: Theme; compact: boolean; openAgent?: (agentId: string) => void; onAnswered?: () => void; onDetails?: (id: string) => void; bodyMaxHeight?: number }) {
|
|
221
|
+
const c = theme.colors; const t = text(c);
|
|
222
|
+
const open = w.questions.filter(isOpen).sort((a, b) => Number(questionState(b) === "stopped") - Number(questionState(a) === "stopped"));
|
|
223
|
+
const [index, setIndex] = useState(0);
|
|
224
|
+
if (!open.length) return null;
|
|
225
|
+
const at = Math.min(index, open.length - 1);
|
|
226
|
+
const q = open[at];
|
|
227
|
+
const step = (by: number) => setIndex((at + by + open.length) % open.length);
|
|
228
|
+
const arrow = (icon: string, label: string, by: number) => <Pressable accessibilityRole="button" accessibilityLabel={label} onPress={() => step(by)} hitSlop={6}
|
|
229
|
+
style={state => ({ width: compact ? 40 : 26, height: compact ? 40 : 26, borderRadius: 6, alignItems: "center", justifyContent: "center", backgroundColor: state.pressed ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
|
|
230
|
+
<Icon name={icon} size={15} color={c.foregroundMuted} />
|
|
231
|
+
</Pressable>;
|
|
232
|
+
return <View style={{ gap: 8 }}>
|
|
233
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 6, minHeight: compact ? 40 : 26 }}>
|
|
234
|
+
<Icon name={questionState(q) === "stopped" ? "CirclePause" : "MessageCircleQuestion"} size={14} color={c.statusWarning} />
|
|
235
|
+
<Text accessibilityRole="header" numberOfLines={2} style={[t.label, { flex: 1 }]}>{q.id} · {q.title}</Text>
|
|
236
|
+
{open.length > 1 && <>
|
|
237
|
+
<Text accessibilityLabel={`Question ${at + 1} of ${open.length}`} style={[t.small, { marginLeft: 4 }]}>{at + 1} of {open.length}</Text>
|
|
238
|
+
{arrow("ChevronLeft", "Previous question", -1)}{arrow("ChevronRight", "Next question", 1)}
|
|
239
|
+
</>}
|
|
240
|
+
</View>
|
|
241
|
+
<QuestionBody key={q.id} workspace={w} question={q} theme={theme} compact={compact} dense bodyMaxHeight={bodyMaxHeight} openAgent={openAgent} onAnswered={onAnswered} onDetails={onDetails ? () => onDetails(q.id) : undefined} />
|
|
242
|
+
</View>;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const toneColor = (c: Colors, tone: ActivityTone) => tone === "merged" ? mergedColor(c) : tone === "success" ? c.statusSuccess : tone === "warning" ? c.statusWarning : tone === "danger" ? c.statusDanger : c.foregroundMuted;
|
|
246
|
+
|
|
247
|
+
/** The workspace's log: a timeline of what happened, and every question under its ref. */
|
|
248
|
+
export function ActivityCard({ workspace: w, theme, compact, now, open, toggle, onOpenQuestion }: { workspace: Workspace; theme: Theme; compact: boolean; now: number; open: (key: string) => boolean; toggle: (key: string) => void; onOpenQuestion: (id: string) => void }) {
|
|
249
|
+
const c = theme.colors; const t = text(c);
|
|
250
|
+
const rows = activity(w);
|
|
251
|
+
const questions = [...w.questions].sort((a, b) => Number(isOpen(b)) - Number(isOpen(a)) || Number(b.id.slice(1)) - Number(a.id.slice(1)));
|
|
252
|
+
const [tab, setTab] = useState<"timeline" | "questions">("timeline");
|
|
253
|
+
if (!rows.length && !questions.length) return null;
|
|
254
|
+
const all = open("activity");
|
|
255
|
+
const LIMIT = 5;
|
|
256
|
+
const tabButton = (id: "timeline" | "questions", label: string, count?: number) => {
|
|
257
|
+
const selected = tab === id;
|
|
258
|
+
return <Pressable key={id} accessibilityRole="tab" aria-selected={selected} accessibilityState={{ selected }} accessibilityLabel={count !== undefined ? `${label}, ${count}` : label} onPress={() => setTab(id)} hitSlop={4}
|
|
259
|
+
style={state => ({ flexDirection: "row", alignItems: "center", gap: 5, minHeight: compact ? 36 : 24, paddingHorizontal: 9, borderRadius: 999, backgroundColor: selected ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
|
|
260
|
+
<Text style={{ color: selected ? c.foreground : c.foregroundMuted, fontSize: 12, fontWeight: "600" }}>{label}</Text>
|
|
261
|
+
{count !== undefined && <Text style={{ color: c.foregroundMuted, fontSize: 12, fontVariant: ["tabular-nums"] }}>{count}</Text>}
|
|
262
|
+
</Pressable>;
|
|
263
|
+
};
|
|
264
|
+
const list = tab === "timeline" ? rows : questions;
|
|
265
|
+
const shown = all ? list : list.slice(0, LIMIT);
|
|
266
|
+
return <Card theme={theme} compact={compact} icon="Activity" title="Activity"
|
|
267
|
+
right={questions.length ? <View accessibilityRole="tablist" style={{ flexDirection: "row", gap: 2, marginVertical: -4 }}>{tabButton("timeline", "Timeline")}{tabButton("questions", "Questions", questions.length)}</View> : undefined}>
|
|
268
|
+
{/* The timeline is drawn on the same rail as the stacks: a 2px line through 16px state nodes. */}
|
|
269
|
+
{tab === "timeline" ? <View style={{ paddingHorizontal: 12, paddingTop: 4, paddingBottom: 6, borderTopWidth: 1, borderTopColor: c.border }}>
|
|
270
|
+
{(shown as typeof rows).map((r, i, all) => {
|
|
271
|
+
const color = toneColor(c, r.tone);
|
|
272
|
+
return <View key={r.key} style={{ flexDirection: "row", gap: 10 }}>
|
|
273
|
+
<View style={{ width: 16, alignItems: "center" }}>
|
|
274
|
+
<View style={{ width: 2, height: 8, backgroundColor: i === 0 ? "transparent" : c.border }} />
|
|
275
|
+
<View style={{ width: 16, height: 16, borderRadius: 8, alignItems: "center", justifyContent: "center", backgroundColor: tint(color, c) }}><Icon name={r.icon} size={10} color={color} /></View>
|
|
276
|
+
<View style={{ width: 2, flex: 1, minHeight: 4, backgroundColor: i === all.length - 1 ? "transparent" : c.border }} />
|
|
277
|
+
</View>
|
|
278
|
+
<View style={{ flex: 1, minWidth: 0, gap: 2, paddingTop: 6, paddingBottom: 8 }}>
|
|
279
|
+
<View style={{ flexDirection: "row", alignItems: "baseline", gap: 8 }}>
|
|
280
|
+
<Text numberOfLines={2} style={[t.body, { flex: 1 }]}>{r.text}</Text>
|
|
281
|
+
<Text style={t.small}>{ago(r.at, now)}</Text>
|
|
282
|
+
</View>
|
|
283
|
+
{(r.detail || r.took) && <Text numberOfLines={2} style={t.meta}>{[r.detail, r.took ? `took ${r.took}` : null].filter(Boolean).join(" · ")}</Text>}
|
|
284
|
+
</View>
|
|
285
|
+
</View>;
|
|
286
|
+
})}
|
|
287
|
+
</View> : (shown as typeof questions).map(q => {
|
|
288
|
+
const chosen = q.options.find(o => o.letter === q.answer?.choice);
|
|
289
|
+
const status = q.answer ? `${q.answer.choice}${chosen ? ` · ${chosen.label}` : ""}` : q.closed ? `Withdrawn: ${q.closed.reason}` : "Waiting for you";
|
|
290
|
+
const icon = q.answer ? "MessageCircleReply" : q.closed ? "MessageCircleOff" : "MessageCircleQuestion";
|
|
291
|
+
const color = q.answer ? c.statusSuccess : q.closed ? c.foregroundMuted : c.statusWarning;
|
|
292
|
+
return <CardRow key={q.id} theme={theme} onPress={() => onOpenQuestion(q.id)} accessibilityLabel={`${q.id}, ${q.title}. ${status}. Open`}>
|
|
293
|
+
<View style={{ flexDirection: "row", gap: 9 }}>
|
|
294
|
+
<View style={{ paddingTop: 2 }}><Icon name={icon} size={13} color={color} /></View>
|
|
295
|
+
<View style={{ flex: 1, minWidth: 0, gap: 2 }}>
|
|
296
|
+
<View style={{ flexDirection: "row", alignItems: "baseline", gap: 8 }}>
|
|
297
|
+
<Text numberOfLines={1} style={[t.body, { flex: 1 }]}>{q.id} · {q.title}</Text>
|
|
298
|
+
<Text style={t.small}>{ago(q.answer?.at ?? q.closed?.at ?? q.askedAt, now)}</Text>
|
|
299
|
+
</View>
|
|
300
|
+
<Text numberOfLines={2} style={[t.meta, !q.answer && !q.closed ? { color: c.statusWarning } : null]}>{status}</Text>
|
|
301
|
+
</View>
|
|
302
|
+
</View>
|
|
303
|
+
</CardRow>;
|
|
304
|
+
})}
|
|
305
|
+
{list.length > LIMIT && <FoldRow theme={theme} open={all} onPress={() => toggle("activity")} icon="History" iconColor={c.foregroundMuted} label={all ? "Show less" : `Show all ${list.length}`} />}
|
|
306
|
+
</Card>;
|
|
307
|
+
}
|
package/client/settings.tsx
CHANGED
|
@@ -1,27 +1,62 @@
|
|
|
1
|
-
import { ActivityIndicator,
|
|
1
|
+
import { ActivityIndicator, ScrollView, Text } from "react-native";
|
|
2
2
|
import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
|
|
3
|
-
import { useRpc } from "@getpaseo/plugin/client";
|
|
3
|
+
import { useRpc, useSettings } from "@getpaseo/plugin/client";
|
|
4
|
+
import { SettingsAction, SettingsCard, SettingsSection, SettingsSelect, SettingsSwitch, useToast } from "@getpaseo/plugin/client/ui";
|
|
5
|
+
import { QUESTION_MODES, QUESTION_MODE_RULES, questionPreferences, type QuestionMode } from "../shared/questions";
|
|
4
6
|
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
5
7
|
import { projectSettingsRpc, setProjectTrackingRpc } from "../shared/contracts";
|
|
6
|
-
import {
|
|
8
|
+
import { errorText, text } from "./kit";
|
|
7
9
|
|
|
10
|
+
const settingsKey = ["follow-through", "project-settings"];
|
|
11
|
+
|
|
12
|
+
/** What agents do between asking a question and getting the answer. Applies to questions asked from now on. */
|
|
13
|
+
function QuestionSettings({ theme }: Pick<PluginSurfaceProps, "theme">) {
|
|
14
|
+
const c = theme.colors;
|
|
15
|
+
const settings = useSettings(questionPreferences);
|
|
16
|
+
const toast = useToast();
|
|
17
|
+
const info = "Agents ask decisions they can't make themselves in Follow-up, with lettered options and a recommendation. The mode tells the agent what to do until you answer, and applies to questions asked from now on. Big questions, ones that would reach outside this computer or that most of the work depends on, always wait.";
|
|
18
|
+
return <SettingsSection title="Questions" info={info}>
|
|
19
|
+
{settings.status === "loading" && <ActivityIndicator accessibilityLabel="Loading question settings" color={c.foregroundMuted} style={{ alignSelf: "flex-start", marginVertical: 8 }} />}
|
|
20
|
+
{(settings.status === "error" || settings.status === "invalid") && <SettingsCard>
|
|
21
|
+
<SettingsAction label="Couldn't load the question mode" hint={settings.error} actionLabel="Retry" onPress={() => void settings.reload()} />
|
|
22
|
+
{settings.status === "invalid" && <SettingsAction label="Use the default, Work around" actionLabel="Reset" disabled={settings.saving} onPress={() => void settings.reset()} />}
|
|
23
|
+
</SettingsCard>}
|
|
24
|
+
{settings.status === "ready" && <SettingsCard>
|
|
25
|
+
<SettingsSelect<QuestionMode> label="While a question is open" hint={QUESTION_MODE_RULES[settings.values.mode].hint} value={settings.values.mode} disabled={settings.saving}
|
|
26
|
+
options={QUESTION_MODES.map(mode => ({ value: mode, label: QUESTION_MODE_RULES[mode].label }))}
|
|
27
|
+
onValueChange={mode => { void settings.save({ ...settings.values, mode }, settings.revision).then(saved => { if (saved) toast.show(`Questions: ${QUESTION_MODE_RULES[mode].label}`, { variant: "success" }); }, () => undefined); }} />
|
|
28
|
+
</SettingsCard>}
|
|
29
|
+
{settings.status === "ready" && settings.saveError && <Text accessibilityRole="alert" style={{ color: c.statusDanger }}>{settings.saveError}</Text>}
|
|
30
|
+
</SettingsSection>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Per-project default tracking. Each switch is one project; the hint shows which repository it is. */
|
|
8
34
|
export function FollowSettings({ theme, layout }: PluginSurfaceProps) {
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
const c = theme.colors; const t = text(c);
|
|
36
|
+
const read = useRpc(projectSettingsRpc); const write = useRpc(setProjectTrackingRpc); const cache = useQueryClient(); const toast = useToast();
|
|
37
|
+
const query = useQuery({ queryKey: settingsKey, queryFn: () => read({}), refetchInterval: 15000 });
|
|
38
|
+
const change = useMutation({
|
|
39
|
+
mutationFn: (input: Parameters<typeof write>[0]) => write(input),
|
|
40
|
+
onSuccess: (value, input) => {
|
|
41
|
+
cache.setQueryData(settingsKey, value);
|
|
42
|
+
const project = value.projects.find(p => p.id === input.projectId);
|
|
43
|
+
toast.show(input.enable_default_tracking ? `Tracking ${project?.name ?? "the project"}'s workspaces` : `New ${project?.name ?? "project"} workspaces won't be tracked`, { variant: "success" });
|
|
44
|
+
void cache.invalidateQueries({ queryKey: ["follow-through", "overview"] }); void cache.invalidateQueries({ queryKey: ["follow-through", "workspace"] });
|
|
45
|
+
},
|
|
46
|
+
onError: error => toast.error(errorText(error)),
|
|
47
|
+
});
|
|
48
|
+
return <ScrollView style={{ flex: 1, backgroundColor: c.surface0 }} contentContainerStyle={{ padding: layout.compact ? 16 : 24, gap: 18, maxWidth: 720, width: "100%", alignSelf: "center", paddingBottom: 40 }}>
|
|
49
|
+
<QuestionSettings theme={theme} />
|
|
50
|
+
<SettingsSection title="Track by project" info="When a project is on, Follow-up tracks its existing and new workspaces as soon as each has a main agent. Turning it off stops new tracking and keeps everything already tracked. Auto-send starts off for every newly tracked workspace, and Follow-up never merges, requests reviewers or archives on its own.">
|
|
51
|
+
{query.isPending && <ActivityIndicator accessibilityLabel="Loading projects" color={c.foregroundMuted} style={{ alignSelf: "flex-start", marginVertical: 8 }} />}
|
|
52
|
+
{query.error && <SettingsCard><SettingsAction label="Couldn't load projects" hint={errorText(query.error)} actionLabel="Retry" onPress={() => void query.refetch()} /></SettingsCard>}
|
|
53
|
+
{query.data?.projects.length === 0 && <Text style={t.meta}>Projects appear here once you add them to Paseo.</Text>}
|
|
54
|
+
{!!query.data?.projects.length && <SettingsCard>
|
|
55
|
+
{query.data.projects.map(project => <SettingsSwitch key={project.id} label={project.name}
|
|
56
|
+
hint={project.key.startsWith("remote:") ? project.key.slice(7) : project.path}
|
|
57
|
+
value={project.enable_default_tracking} disabled={change.isPending}
|
|
58
|
+
onValueChange={value => change.mutate({ projectId: project.id, enable_default_tracking: value })} />)}
|
|
59
|
+
</SettingsCard>}
|
|
60
|
+
</SettingsSection>
|
|
26
61
|
</ScrollView>;
|
|
27
62
|
}
|
package/client/spec.tsx
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { Pressable, Text, View } from "react-native";
|
|
3
|
+
import { openExternalUrl, useRpc } from "@getpaseo/plugin/client";
|
|
4
|
+
import { Icon, Modal, TextInput, useToast } from "@getpaseo/plugin/client/ui";
|
|
5
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
6
|
+
import { workspaceSpecRpc } from "../shared/contracts";
|
|
7
|
+
import type { Workspace } from "../shared/model";
|
|
8
|
+
import { specLabel, validSpecUrl } from "../shared/spec";
|
|
9
|
+
import { ago } from "../shared/attention";
|
|
10
|
+
import { Button, CardRow, errorText, text, type Theme } from "./kit";
|
|
11
|
+
import { overviewKey, workspaceKey } from "./keys";
|
|
12
|
+
|
|
13
|
+
const openUrl = (url: string) => { void openExternalUrl(url).catch(() => undefined); };
|
|
14
|
+
|
|
15
|
+
export function specSource(w: Workspace): string {
|
|
16
|
+
const s = w.spec;
|
|
17
|
+
if (!s) return "";
|
|
18
|
+
if (s.source === "developer") return "Set by you";
|
|
19
|
+
if (s.source === "agent") return "Registered by the main agent";
|
|
20
|
+
return s.by && s.by !== w.mainAgentId ? "Published from a root session" : "Published by the main agent";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The header link to the workspace's spec. Calm: a quiet chip that opens the page in the browser. */
|
|
24
|
+
export function SpecChip({ workspace: w, theme, compact }: { workspace: Pick<Workspace, "spec">; theme: Theme; compact: boolean }) {
|
|
25
|
+
const c = theme.colors;
|
|
26
|
+
const url = w.spec?.url;
|
|
27
|
+
if (!url) return null;
|
|
28
|
+
const label = specLabel(w.spec!);
|
|
29
|
+
return <Pressable accessibilityRole="link" accessibilityLabel={`Open the spec: ${label}`} onPress={() => openUrl(url)} hitSlop={compact ? 0 : 6}
|
|
30
|
+
style={state => ({ flexDirection: "row", alignItems: "center", gap: 5, minHeight: compact ? 36 : 24, paddingHorizontal: compact ? 10 : 8, borderRadius: 999, borderWidth: 1, borderColor: c.border,
|
|
31
|
+
backgroundColor: state.pressed ? c.surface2 : (state as { hovered?: boolean }).hovered ? c.surface1 : "transparent" })}>
|
|
32
|
+
<Icon name="FileText" size={compact ? 14 : 12} color={c.foregroundMuted} />
|
|
33
|
+
<Text numberOfLines={1} style={{ color: c.foreground, fontSize: 12, lineHeight: 16, fontWeight: "600" }}>Spec</Text>
|
|
34
|
+
<Icon name="ArrowUpRight" size={compact ? 13 : 11} color={c.foregroundMuted} />
|
|
35
|
+
</Pressable>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** The spec row in the workspace fold: what the link is, where it came from, and Edit. */
|
|
39
|
+
export function SpecRow({ workspace: w, theme, compact, onEdit }: { workspace: Workspace; theme: Theme; compact: boolean; onEdit: () => void }) {
|
|
40
|
+
const c = theme.colors; const t = text(c);
|
|
41
|
+
const url = w.spec?.url;
|
|
42
|
+
const others = w.artifacts.filter(a => a.url !== url).length;
|
|
43
|
+
return <CardRow theme={theme}>
|
|
44
|
+
<View style={{ flexDirection: "row", alignItems: "center", gap: 10, flexWrap: "wrap" }}>
|
|
45
|
+
<View style={{ flex: 1, minWidth: 160, gap: 2 }}>
|
|
46
|
+
<Text style={t.label}>Spec</Text>
|
|
47
|
+
<Text numberOfLines={2} style={t.meta}>{url
|
|
48
|
+
? `${specLabel(w.spec!)} · ${specSource(w)}${others ? ` · ${others} other artifact${others === 1 ? "" : "s"}` : ""}`
|
|
49
|
+
: w.spec?.source === "developer" ? "You removed the link. Agents can't set it until you add one or hand it back."
|
|
50
|
+
: "No link yet. The main agent registers its spec artifact, or add one."}</Text>
|
|
51
|
+
</View>
|
|
52
|
+
<View style={{ flexDirection: "row", gap: 8 }}>
|
|
53
|
+
{url && <Button theme={theme} compact={compact} icon="ArrowUpRight" title="Open" accessibilityLabel="Open the spec" onPress={() => openUrl(url)} />}
|
|
54
|
+
<Button theme={theme} compact={compact} kind={url ? "ghost" : "secondary"} icon={url ? "Pencil" : "Link"} title={url ? "Edit" : "Add link"} accessibilityLabel={url ? "Edit the spec link" : "Add a spec link"} onPress={onEdit} />
|
|
55
|
+
</View>
|
|
56
|
+
</View>
|
|
57
|
+
</CardRow>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Set, change or remove the spec link, or pick one of the workspace's other artifacts. */
|
|
61
|
+
export function SpecSheet({ workspace: w, open, theme, compact, onClose }: { workspace: Workspace; open: boolean; theme: Theme; compact: boolean; onClose: () => void }) {
|
|
62
|
+
const c = theme.colors; const t = text(c);
|
|
63
|
+
const toast = useToast(); const cache = useQueryClient();
|
|
64
|
+
const save = useRpc(workspaceSpecRpc);
|
|
65
|
+
const [url, setUrl] = useState(w.spec?.url ?? "");
|
|
66
|
+
const [title, setTitle] = useState(w.spec?.title ?? "");
|
|
67
|
+
useEffect(() => { if (open) { setUrl(w.spec?.url ?? ""); setTitle(w.spec?.title ?? ""); } }, [open]);
|
|
68
|
+
const run = useMutation({
|
|
69
|
+
mutationFn: (input: { action: "set"; url: string; title?: string | null } | { action: "remove" } | { action: "reset" }) => save({ workspaceId: w.id, ...input }),
|
|
70
|
+
onSuccess: (_, input) => {
|
|
71
|
+
toast.show(input.action === "set" ? "Spec link saved" : input.action === "remove" ? "Spec link removed" : "Spec link handed back to the agent", { variant: "success" });
|
|
72
|
+
void cache.invalidateQueries({ queryKey: workspaceKey(w.id) }); void cache.invalidateQueries({ queryKey: overviewKey });
|
|
73
|
+
onClose();
|
|
74
|
+
},
|
|
75
|
+
onError: error => toast.error(errorText(error)),
|
|
76
|
+
});
|
|
77
|
+
const valid = validSpecUrl(url);
|
|
78
|
+
const others = w.artifacts.filter(a => a.url !== w.spec?.url);
|
|
79
|
+
const field = { minHeight: compact ? 44 : 32, paddingHorizontal: 10, borderRadius: 6, borderWidth: 1, borderColor: c.border, color: c.foreground, backgroundColor: c.surface1, fontSize: 13 };
|
|
80
|
+
return <Modal title="Spec link" icon={<Icon name="FileText" size={18} color={c.foregroundMuted} />} open={open} onOpenChange={next => { if (!next) onClose(); }}>
|
|
81
|
+
<Modal.Content contentContainerStyle={{ padding: compact ? 16 : 20, gap: 14 }}>
|
|
82
|
+
<Text style={t.meta}>The page that sums up this workspace, usually the Claude artifact the main agent keeps up to date. It shows as Spec in Follow-up's header.</Text>
|
|
83
|
+
{w.spec?.url && <Text style={t.small}>{specSource(w)} {ago(w.spec.at)}</Text>}
|
|
84
|
+
<View style={{ gap: 6 }}>
|
|
85
|
+
<Text style={t.label}>Link</Text>
|
|
86
|
+
<TextInput accessibilityLabel="Spec link" placeholder="https://claude.ai/code/artifact/…" placeholderTextColor={c.foregroundMuted} value={url} onChangeText={setUrl} autoCapitalize="none" autoCorrect={false} inputMode="url" editable={!run.isPending}
|
|
87
|
+
style={[field, url && !valid ? { borderColor: c.statusDanger } : null]} />
|
|
88
|
+
{!!url && !valid && <Text style={[t.small, { color: c.statusDanger }]}>Use a full https:// link.</Text>}
|
|
89
|
+
</View>
|
|
90
|
+
<View style={{ gap: 6 }}>
|
|
91
|
+
<Text style={t.label}>Name <Text style={{ color: c.foregroundMuted, fontWeight: "400" }}>(optional)</Text></Text>
|
|
92
|
+
<TextInput accessibilityLabel="Spec name, optional" placeholder="Invoice retry spec" placeholderTextColor={c.foregroundMuted} value={title} onChangeText={setTitle} maxLength={120} editable={!run.isPending} style={field} />
|
|
93
|
+
</View>
|
|
94
|
+
<View style={{ flexDirection: "row", flexWrap: "wrap", gap: 8 }}>
|
|
95
|
+
<Button theme={theme} compact={compact} kind="primary" icon="Check" title="Save" disabled={!valid || run.isPending} loading={run.isPending && run.variables?.action === "set"} onPress={() => run.mutate({ action: "set", url, title: title.trim() || null })} />
|
|
96
|
+
{w.spec?.url && <Button theme={theme} compact={compact} kind="danger" title="Remove link" disabled={run.isPending} onPress={() => run.mutate({ action: "remove" })} />}
|
|
97
|
+
{w.spec?.source === "developer" && <Button theme={theme} compact={compact} kind="ghost" icon="Undo2" title="Let the agent set it" accessibilityLabel="Hand the spec link back to the main agent and detection" disabled={run.isPending} onPress={() => run.mutate({ action: "reset" })} />}
|
|
98
|
+
</View>
|
|
99
|
+
{others.length > 0 && <View style={{ gap: 6, paddingTop: 12, borderTopWidth: 1, borderTopColor: c.border }}>
|
|
100
|
+
<Text style={t.label}>Other artifacts from this workspace</Text>
|
|
101
|
+
{others.map(a => <View key={a.url} style={{ flexDirection: "row", alignItems: "center", gap: 8 }}>
|
|
102
|
+
<Icon name="FileText" size={13} color={c.foregroundMuted} />
|
|
103
|
+
<View style={{ flex: 1, minWidth: 0 }}>
|
|
104
|
+
<Text numberOfLines={1} style={t.body}>{a.title ?? "Untitled artifact"}</Text>
|
|
105
|
+
<Text numberOfLines={1} style={t.small}>{a.publishes > 1 ? `Published ${a.publishes} times` : "Published once"}{a.lastAt ? ` · ${ago(a.lastAt)}` : ""}</Text>
|
|
106
|
+
</View>
|
|
107
|
+
<Button theme={theme} compact={compact} kind="ghost" icon="ArrowUpRight" title="Open" accessibilityLabel={`Open ${a.title ?? "artifact"}`} onPress={() => openUrl(a.url)} />
|
|
108
|
+
<Button theme={theme} compact={compact} title="Use" accessibilityLabel={`Use ${a.title ?? "this artifact"} as the spec`} disabled={run.isPending} onPress={() => run.mutate({ action: "set", url: a.url, title: a.title })} />
|
|
109
|
+
</View>)}
|
|
110
|
+
</View>}
|
|
111
|
+
</Modal.Content>
|
|
112
|
+
</Modal>;
|
|
113
|
+
}
|