paseo-plugin-genui 0.2.2 → 0.3.1
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 +5 -3
- package/README.md +15 -7
- package/assets/screenshot-chat.png +0 -0
- package/assets/screenshot-gallery.png +0 -0
- package/assets/screenshot-map.png +0 -0
- package/assets/screenshot-playground.png +0 -0
- package/client/components/content.tsx +41 -21
- package/client/components/data.tsx +18 -7
- package/client/components/dev.tsx +38 -26
- package/client/components/diagram.tsx +1 -1
- package/client/components/feedback.tsx +333 -0
- package/client/components/inputs.tsx +54 -47
- package/client/components/layout.tsx +3 -1
- package/client/components/media.tsx +2 -2
- package/client/components/project.tsx +7 -2
- package/client/components/widgets.tsx +35 -24
- package/client/gallery.tsx +7 -5
- package/client/live-ui.tsx +26 -2
- package/client/markdown.tsx +1 -5
- package/client/node-renderer.tsx +6 -1
- package/client/queue-pill.tsx +123 -0
- package/client/render.tsx +2 -0
- package/client/reply-queue.ts +82 -0
- package/client/runtime.ts +7 -0
- package/gallery/Other.ui +11 -0
- package/gallery/Plan.ui +1 -1
- package/index.client.tsx +6 -1
- package/index.server.ts +10 -0
- package/package.json +2 -2
- package/paseo-plugin.json +2 -1
- package/server/render-tool.ts +45 -0
- package/shared/actions-only.test.ts +23 -0
- package/shared/core/catalog.ts +23 -5
- package/shared/core/evaluate.ts +2 -0
- package/shared/core/markdown.ts +2 -0
- package/shared/core/types.ts +2 -1
- package/shared/diagram/markdown.test.ts +13 -0
- package/shared/diagram/markdown.ts +15 -1
- package/shared/fallback.ts +21 -1
- package/shared/hermes-syntax.test.ts +1 -1
- package/shared/instructions.ts +3 -1
- package/shared/logic/reply.test.ts +29 -0
- package/shared/logic/reply.ts +33 -0
- package/shared/logic/values.ts +1 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
// Comments, inline edits and "Other…" boxes. None of them sends anything: each
|
|
2
|
+
// writes one entry into the chat's reply queue, which the next Send carries.
|
|
3
|
+
import { Icon, TextInput } from "@getpaseo/plugin/client/react-native";
|
|
4
|
+
import React, { useState } from "react";
|
|
5
|
+
import { Pressable, StyleSheet, Text, View } from "react-native";
|
|
6
|
+
import { commentText, editText } from "../../shared/logic/reply";
|
|
7
|
+
import { optionalText, type Props } from "../../shared/logic/values";
|
|
8
|
+
import { usePersistedState, useUiRuntime } from "../runtime";
|
|
9
|
+
|
|
10
|
+
type Fields = Readonly<Record<string, string>>;
|
|
11
|
+
|
|
12
|
+
interface ItemNote {
|
|
13
|
+
readonly comment?: string;
|
|
14
|
+
readonly edits?: Fields;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type Notes = Readonly<Record<string, ItemNote>>;
|
|
18
|
+
|
|
19
|
+
function acceptNotes(stored: unknown): Notes | null {
|
|
20
|
+
return typeof stored === "object" && stored !== null && !Array.isArray(stored) ? (stored as Notes) : null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Per-item comments and edits for a list component. `fields` gives an item's
|
|
25
|
+
* text with the user's edits applied; `controls` renders its Comment and Edit
|
|
26
|
+
* actions. With neither option on, both are no-ops.
|
|
27
|
+
*/
|
|
28
|
+
export function useItemFeedback(scope: string, options: { comments: boolean; editable: boolean }) {
|
|
29
|
+
const [notes, setNotes] = usePersistedState<Notes>(`feedback:${scope}`, {}, acceptNotes);
|
|
30
|
+
const { setQueued } = useUiRuntime();
|
|
31
|
+
|
|
32
|
+
const update = (index: number, label: string, original: Fields, note: ItemNote) => {
|
|
33
|
+
setNotes((previous) => ({ ...previous, [index]: note }));
|
|
34
|
+
setQueued(`${scope}:${index}:comment`, note.comment ? commentText(label, note.comment) : null);
|
|
35
|
+
setQueued(`${scope}:${index}:edit`, note.edits ? editText(label, original, note.edits) : null);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
fields<T extends Fields>(index: number, original: T): T {
|
|
40
|
+
return { ...original, ...(notes[index]?.edits ?? {}) };
|
|
41
|
+
},
|
|
42
|
+
controls(index: number, label: string, original: Fields, leading?: React.ReactNode): React.ReactNode {
|
|
43
|
+
if (!options.comments && !options.editable) return leading ?? null;
|
|
44
|
+
return (
|
|
45
|
+
<ItemFeedback
|
|
46
|
+
note={notes[index] ?? {}}
|
|
47
|
+
original={original}
|
|
48
|
+
comments={options.comments}
|
|
49
|
+
editable={options.editable}
|
|
50
|
+
leading={leading}
|
|
51
|
+
onChange={(note) => update(index, label, original, note)}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function ItemFeedback({
|
|
59
|
+
note,
|
|
60
|
+
original,
|
|
61
|
+
comments,
|
|
62
|
+
editable,
|
|
63
|
+
leading,
|
|
64
|
+
onChange,
|
|
65
|
+
}: {
|
|
66
|
+
note: ItemNote;
|
|
67
|
+
original: Fields;
|
|
68
|
+
comments: boolean;
|
|
69
|
+
editable: boolean;
|
|
70
|
+
/** Shown first in the item's action row, as Findings' "Fix this". */
|
|
71
|
+
leading?: React.ReactNode;
|
|
72
|
+
onChange(note: ItemNote): void;
|
|
73
|
+
}) {
|
|
74
|
+
const { theme, answer, superseded } = useUiRuntime();
|
|
75
|
+
const [mode, setMode] = useState<"idle" | "comment" | "edit">("idle");
|
|
76
|
+
const [draft, setDraft] = useState("");
|
|
77
|
+
const [edits, setEdits] = useState<Fields>({});
|
|
78
|
+
const open = !answer && !superseded;
|
|
79
|
+
const edited = note.edits !== undefined && Object.keys(original).some((field) => (note.edits?.[field] ?? original[field]) !== original[field]);
|
|
80
|
+
|
|
81
|
+
if (mode === "comment") {
|
|
82
|
+
return (
|
|
83
|
+
<Editor
|
|
84
|
+
fields={{ comment: draft }}
|
|
85
|
+
multiline
|
|
86
|
+
placeholder="Comment"
|
|
87
|
+
onChange={(next) => setDraft(next.comment ?? "")}
|
|
88
|
+
onCancel={() => setMode("idle")}
|
|
89
|
+
onSave={() => {
|
|
90
|
+
const comment = draft.trim();
|
|
91
|
+
onChange({ ...note, comment: comment === "" ? undefined : comment });
|
|
92
|
+
setMode("idle");
|
|
93
|
+
}}
|
|
94
|
+
/>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
if (mode === "edit") {
|
|
98
|
+
return (
|
|
99
|
+
<Editor
|
|
100
|
+
fields={edits}
|
|
101
|
+
onChange={setEdits}
|
|
102
|
+
onCancel={() => setMode("idle")}
|
|
103
|
+
onSave={() => {
|
|
104
|
+
onChange({ ...note, edits });
|
|
105
|
+
setMode("idle");
|
|
106
|
+
}}
|
|
107
|
+
/>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const startComment = () => {
|
|
112
|
+
setDraft(note.comment ?? "");
|
|
113
|
+
setMode("comment");
|
|
114
|
+
};
|
|
115
|
+
return (
|
|
116
|
+
<View style={{ gap: 6 }}>
|
|
117
|
+
{note.comment ? (
|
|
118
|
+
<View style={{ flexDirection: "row", gap: 6, alignItems: "flex-start" }}>
|
|
119
|
+
<View style={{ paddingTop: 2 }}>
|
|
120
|
+
<Icon name="MessageSquare" size={12} color={theme.colors.foregroundMuted} />
|
|
121
|
+
</View>
|
|
122
|
+
<Pressable disabled={!open} onPress={startComment} style={{ flex: 1 }}>
|
|
123
|
+
<Text style={{ color: theme.colors.foreground, fontSize: 12 }}>{note.comment}</Text>
|
|
124
|
+
</Pressable>
|
|
125
|
+
{open ? (
|
|
126
|
+
<Pressable accessibilityRole="button" accessibilityLabel="Remove comment" onPress={() => onChange({ ...note, comment: undefined })}>
|
|
127
|
+
<Icon name="Trash2" size={12} color={theme.colors.foregroundMuted} />
|
|
128
|
+
</Pressable>
|
|
129
|
+
) : null}
|
|
130
|
+
</View>
|
|
131
|
+
) : null}
|
|
132
|
+
{open ? (
|
|
133
|
+
<View style={{ flexDirection: "row", flexWrap: "wrap", alignItems: "center", gap: 12 }}>
|
|
134
|
+
{leading}
|
|
135
|
+
{comments && !note.comment ? <QuietAction icon="MessageSquare" label="Comment" onPress={startComment} /> : null}
|
|
136
|
+
{editable ? (
|
|
137
|
+
<QuietAction
|
|
138
|
+
icon="Edit"
|
|
139
|
+
label="Edit"
|
|
140
|
+
onPress={() => {
|
|
141
|
+
setEdits({ ...original, ...(note.edits ?? {}) });
|
|
142
|
+
setMode("edit");
|
|
143
|
+
}}
|
|
144
|
+
/>
|
|
145
|
+
) : null}
|
|
146
|
+
{editable && edited ? <QuietAction label="Undo edit" onPress={() => onChange({ ...note, edits: undefined })} /> : null}
|
|
147
|
+
</View>
|
|
148
|
+
) : (
|
|
149
|
+
leading
|
|
150
|
+
)}
|
|
151
|
+
</View>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function QuietAction({ icon, label, onPress }: { icon?: string; label: string; onPress(): void }) {
|
|
156
|
+
const { theme } = useUiRuntime();
|
|
157
|
+
return (
|
|
158
|
+
<Pressable accessibilityRole="button" onPress={onPress} style={{ flexDirection: "row", alignItems: "center", gap: 4 }}>
|
|
159
|
+
{icon ? <Icon name={icon} size={12} color={theme.colors.foregroundMuted} /> : null}
|
|
160
|
+
<Text style={{ color: theme.colors.foregroundMuted, fontSize: 12 }}>{label}</Text>
|
|
161
|
+
</Pressable>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** One text box per field, with Save and Cancel. */
|
|
166
|
+
function Editor({
|
|
167
|
+
fields,
|
|
168
|
+
multiline = false,
|
|
169
|
+
placeholder,
|
|
170
|
+
onChange,
|
|
171
|
+
onSave,
|
|
172
|
+
onCancel,
|
|
173
|
+
}: {
|
|
174
|
+
fields: Fields;
|
|
175
|
+
multiline?: boolean;
|
|
176
|
+
placeholder?: string;
|
|
177
|
+
onChange(fields: Fields): void;
|
|
178
|
+
onSave(): void;
|
|
179
|
+
onCancel(): void;
|
|
180
|
+
}) {
|
|
181
|
+
const { theme } = useUiRuntime();
|
|
182
|
+
const many = Object.keys(fields).length > 1;
|
|
183
|
+
return (
|
|
184
|
+
<View style={{ gap: 6 }}>
|
|
185
|
+
{Object.entries(fields).map(([field, value]) => (
|
|
186
|
+
<TextInput
|
|
187
|
+
key={field}
|
|
188
|
+
value={value}
|
|
189
|
+
multiline={multiline || field === "detail"}
|
|
190
|
+
autoFocus={!many}
|
|
191
|
+
placeholder={placeholder ?? field}
|
|
192
|
+
placeholderTextColor={theme.colors.foregroundMuted}
|
|
193
|
+
onChangeText={(next) => onChange({ ...fields, [field]: next })}
|
|
194
|
+
style={{
|
|
195
|
+
borderRadius: 6,
|
|
196
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
197
|
+
borderColor: theme.colors.border,
|
|
198
|
+
backgroundColor: theme.colors.surface1,
|
|
199
|
+
color: theme.colors.foreground,
|
|
200
|
+
paddingHorizontal: 8,
|
|
201
|
+
paddingVertical: 6,
|
|
202
|
+
fontSize: 12.5,
|
|
203
|
+
minHeight: multiline || field === "detail" ? 56 : undefined,
|
|
204
|
+
}}
|
|
205
|
+
/>
|
|
206
|
+
))}
|
|
207
|
+
<View style={{ flexDirection: "row", gap: 8 }}>
|
|
208
|
+
<SmallButton label="Save" primary onPress={onSave} />
|
|
209
|
+
<SmallButton label="Cancel" onPress={onCancel} />
|
|
210
|
+
</View>
|
|
211
|
+
</View>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function SmallButton({ label, primary = false, onPress }: { label: string; primary?: boolean; onPress(): void }) {
|
|
216
|
+
const { theme } = useUiRuntime();
|
|
217
|
+
return (
|
|
218
|
+
<Pressable
|
|
219
|
+
accessibilityRole="button"
|
|
220
|
+
onPress={onPress}
|
|
221
|
+
style={{
|
|
222
|
+
paddingHorizontal: 10,
|
|
223
|
+
paddingVertical: 5,
|
|
224
|
+
borderRadius: 6,
|
|
225
|
+
backgroundColor: primary ? theme.colors.accent : theme.colors.surface2,
|
|
226
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
227
|
+
borderColor: primary ? theme.colors.accent : theme.colors.border,
|
|
228
|
+
}}
|
|
229
|
+
>
|
|
230
|
+
<Text style={{ color: primary ? theme.colors.accentForeground : theme.colors.foreground, fontSize: 12, fontWeight: "600" }}>
|
|
231
|
+
{label}
|
|
232
|
+
</Text>
|
|
233
|
+
</Pressable>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** "Other…": free-form feedback the agent did not offer a button for. */
|
|
238
|
+
export function Other({ props }: { props: Props }) {
|
|
239
|
+
const { theme, run, setQueued, queued: queuedText, answer, superseded } = useUiRuntime();
|
|
240
|
+
const label = optionalText(props.label) ?? "Other…";
|
|
241
|
+
const placeholder = optionalText(props.placeholder) ?? "Tell the agent something else";
|
|
242
|
+
const [open, setOpen] = useState(false);
|
|
243
|
+
const [draft, setDraft] = useState("");
|
|
244
|
+
const id = `other:${label}`;
|
|
245
|
+
const queued = queuedText(id);
|
|
246
|
+
|
|
247
|
+
if (answer || superseded) return null;
|
|
248
|
+
|
|
249
|
+
// Open or queued, the box takes the whole line of its button group.
|
|
250
|
+
if (queued !== null && !open) {
|
|
251
|
+
return (
|
|
252
|
+
<View style={{ width: "100%", flexDirection: "row", gap: 8, alignItems: "flex-start" }}>
|
|
253
|
+
<View style={{ paddingTop: 2 }}>
|
|
254
|
+
<Icon name="MessageSquare" size={12} color={theme.colors.foregroundMuted} />
|
|
255
|
+
</View>
|
|
256
|
+
<Text style={{ color: theme.colors.foreground, fontSize: 12.5, flex: 1 }}>{queued}</Text>
|
|
257
|
+
<QuietAction
|
|
258
|
+
label="Edit"
|
|
259
|
+
onPress={() => {
|
|
260
|
+
setDraft(queued);
|
|
261
|
+
setOpen(true);
|
|
262
|
+
}}
|
|
263
|
+
/>
|
|
264
|
+
<QuietAction label="Remove" onPress={() => setQueued(id, null)} />
|
|
265
|
+
</View>
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (!open) {
|
|
270
|
+
return (
|
|
271
|
+
<Pressable
|
|
272
|
+
accessibilityRole="button"
|
|
273
|
+
onPress={() => setOpen(true)}
|
|
274
|
+
style={{
|
|
275
|
+
alignSelf: "flex-start",
|
|
276
|
+
paddingHorizontal: 12,
|
|
277
|
+
paddingVertical: 7,
|
|
278
|
+
borderRadius: 8,
|
|
279
|
+
backgroundColor: theme.colors.surface2,
|
|
280
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
281
|
+
borderColor: theme.colors.border,
|
|
282
|
+
}}
|
|
283
|
+
>
|
|
284
|
+
<Text style={{ color: theme.colors.foreground, fontSize: 12.5, fontWeight: "600" }}>{label}</Text>
|
|
285
|
+
</Pressable>
|
|
286
|
+
);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const text = draft.trim();
|
|
290
|
+
return (
|
|
291
|
+
<View style={{ width: "100%", gap: 6 }}>
|
|
292
|
+
<TextInput
|
|
293
|
+
value={draft}
|
|
294
|
+
multiline
|
|
295
|
+
autoFocus
|
|
296
|
+
placeholder={placeholder}
|
|
297
|
+
placeholderTextColor={theme.colors.foregroundMuted}
|
|
298
|
+
onChangeText={setDraft}
|
|
299
|
+
style={{
|
|
300
|
+
borderRadius: 8,
|
|
301
|
+
borderWidth: StyleSheet.hairlineWidth,
|
|
302
|
+
borderColor: theme.colors.border,
|
|
303
|
+
backgroundColor: theme.colors.surface1,
|
|
304
|
+
color: theme.colors.foreground,
|
|
305
|
+
paddingHorizontal: 10,
|
|
306
|
+
paddingVertical: 8,
|
|
307
|
+
fontSize: 13,
|
|
308
|
+
minHeight: 64,
|
|
309
|
+
}}
|
|
310
|
+
/>
|
|
311
|
+
<View style={{ flexDirection: "row", gap: 8 }}>
|
|
312
|
+
<SmallButton
|
|
313
|
+
label="Send"
|
|
314
|
+
primary
|
|
315
|
+
onPress={() => {
|
|
316
|
+
if (text === "") return;
|
|
317
|
+
setQueued(id, null);
|
|
318
|
+
setOpen(false);
|
|
319
|
+
void run([{ kind: "action", type: "send", text }]);
|
|
320
|
+
}}
|
|
321
|
+
/>
|
|
322
|
+
<SmallButton
|
|
323
|
+
label="Add to reply"
|
|
324
|
+
onPress={() => {
|
|
325
|
+
setQueued(id, text === "" ? null : text);
|
|
326
|
+
setOpen(false);
|
|
327
|
+
}}
|
|
328
|
+
/>
|
|
329
|
+
<SmallButton label="Cancel" onPress={() => setOpen(false)} />
|
|
330
|
+
</View>
|
|
331
|
+
</View>
|
|
332
|
+
);
|
|
333
|
+
}
|
|
@@ -38,7 +38,8 @@ import {
|
|
|
38
38
|
type Props,
|
|
39
39
|
} from "../../shared/logic/values";
|
|
40
40
|
import { ErrorLine, RenderNodes, type GroupedButton } from "../node-renderer";
|
|
41
|
-
import { useUiRuntime } from "../runtime";
|
|
41
|
+
import { propsKey, useUiRuntime } from "../runtime";
|
|
42
|
+
import { useItemFeedback } from "./feedback";
|
|
42
43
|
import { LoadedImageView } from "./content";
|
|
43
44
|
|
|
44
45
|
function FieldLabel({ label, value }: { label: string | null; value?: string }) {
|
|
@@ -345,7 +346,7 @@ export function Radio({ props }: { props: Props }) {
|
|
|
345
346
|
padding: 10,
|
|
346
347
|
borderRadius: 8,
|
|
347
348
|
borderWidth: StyleSheet.hairlineWidth,
|
|
348
|
-
borderColor:
|
|
349
|
+
borderColor: theme.colors.border,
|
|
349
350
|
backgroundColor: theme.colors.surface2,
|
|
350
351
|
}}
|
|
351
352
|
>
|
|
@@ -421,24 +422,11 @@ export function Checklist({ props }: { props: Props }) {
|
|
|
421
422
|
paddingVertical: 8,
|
|
422
423
|
borderRadius: 8,
|
|
423
424
|
borderWidth: StyleSheet.hairlineWidth,
|
|
424
|
-
borderColor:
|
|
425
|
+
borderColor: theme.colors.border,
|
|
425
426
|
backgroundColor: theme.colors.surface2,
|
|
426
427
|
}}
|
|
427
428
|
>
|
|
428
|
-
<
|
|
429
|
-
style={{
|
|
430
|
-
width: 16,
|
|
431
|
-
height: 16,
|
|
432
|
-
borderRadius: 4,
|
|
433
|
-
borderWidth: 1.5,
|
|
434
|
-
borderColor: checked ? theme.colors.accent : theme.colors.foregroundMuted,
|
|
435
|
-
backgroundColor: checked ? theme.colors.accent : "transparent",
|
|
436
|
-
alignItems: "center",
|
|
437
|
-
justifyContent: "center",
|
|
438
|
-
}}
|
|
439
|
-
>
|
|
440
|
-
{checked ? <Icon name="Check" size={11} color={theme.colors.accentForeground} /> : null}
|
|
441
|
-
</View>
|
|
429
|
+
<CheckBox checked={checked} />
|
|
442
430
|
<Text style={{ color: theme.colors.foreground, fontSize: 13 }}>{itemText(opt)}</Text>
|
|
443
431
|
</Pressable>
|
|
444
432
|
);
|
|
@@ -616,22 +604,10 @@ export function Rating({ props }: { props: Props }) {
|
|
|
616
604
|
<Pressable
|
|
617
605
|
key={star}
|
|
618
606
|
onPress={() => setValue(binding.name, star === current ? 0 : star)}
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
paddingVertical: 5,
|
|
622
|
-
borderRadius: 6,
|
|
623
|
-
backgroundColor: active ? theme.colors.accent : theme.colors.surface2,
|
|
624
|
-
}}
|
|
607
|
+
accessibilityLabel={`${star} of ${max}`}
|
|
608
|
+
style={{ padding: 3 }}
|
|
625
609
|
>
|
|
626
|
-
<
|
|
627
|
-
style={{
|
|
628
|
-
color: active ? theme.colors.accentForeground : theme.colors.foregroundMuted,
|
|
629
|
-
fontSize: 13,
|
|
630
|
-
fontWeight: "600",
|
|
631
|
-
}}
|
|
632
|
-
>
|
|
633
|
-
★ {star}
|
|
634
|
-
</Text>
|
|
610
|
+
<Icon name="Star" size={18} color={active ? theme.colors.accent : theme.colors.foregroundMuted} />
|
|
635
611
|
</Pressable>
|
|
636
612
|
);
|
|
637
613
|
})}
|
|
@@ -642,6 +618,7 @@ export function Rating({ props }: { props: Props }) {
|
|
|
642
618
|
|
|
643
619
|
export function OptionCards({ props }: { props: Props }) {
|
|
644
620
|
const { theme, compact, setValue } = useUiRuntime();
|
|
621
|
+
const feedback = useItemFeedback(`options:${propsKey(props.options)}`, { comments: props.comments === true, editable: false });
|
|
645
622
|
const binding = isBinding(props.value) ? props.value : null;
|
|
646
623
|
if (!binding) return <ErrorLine message="OptionCards expects a $state binding" />;
|
|
647
624
|
const options = cardOptions(props.options);
|
|
@@ -659,25 +636,30 @@ export function OptionCards({ props }: { props: Props }) {
|
|
|
659
636
|
const selected = isMulti ? pickedList.includes(opt.value) : binding.value === opt.value;
|
|
660
637
|
const iconName = opt.icon ? resolveIconName(opt.icon) ?? opt.icon : null;
|
|
661
638
|
return (
|
|
662
|
-
<
|
|
639
|
+
<View
|
|
663
640
|
key={idx}
|
|
664
|
-
onPress={() => {
|
|
665
|
-
if (isMulti) {
|
|
666
|
-
setValue(binding.name, togglePick(pickedList, opt.value, allValues));
|
|
667
|
-
} else {
|
|
668
|
-
setValue(binding.name, opt.value);
|
|
669
|
-
}
|
|
670
|
-
}}
|
|
671
641
|
style={{
|
|
672
642
|
flex: compact ? undefined : 1,
|
|
673
643
|
minWidth: 150,
|
|
674
644
|
borderRadius: 10,
|
|
675
645
|
borderWidth: selected ? 1.5 : StyleSheet.hairlineWidth,
|
|
676
|
-
borderColor: selected ? theme.colors.
|
|
646
|
+
borderColor: selected ? theme.colors.foregroundMuted : theme.colors.border,
|
|
677
647
|
backgroundColor: theme.colors.surface2,
|
|
678
648
|
padding: 10,
|
|
679
649
|
gap: 6,
|
|
680
650
|
}}
|
|
651
|
+
>
|
|
652
|
+
<Pressable
|
|
653
|
+
accessibilityRole={isMulti ? "checkbox" : "radio"}
|
|
654
|
+
accessibilityState={{ checked: selected }}
|
|
655
|
+
onPress={() => {
|
|
656
|
+
if (isMulti) {
|
|
657
|
+
setValue(binding.name, togglePick(pickedList, opt.value, allValues));
|
|
658
|
+
} else {
|
|
659
|
+
setValue(binding.name, opt.value);
|
|
660
|
+
}
|
|
661
|
+
}}
|
|
662
|
+
style={{ gap: 6 }}
|
|
681
663
|
>
|
|
682
664
|
{opt.image ? <LoadedImageView src={opt.image} alt={opt.title} height={100} zoomable={false} /> : null}
|
|
683
665
|
<View style={{ flexDirection: "row", alignItems: "center", gap: 6 }}>
|
|
@@ -690,6 +672,8 @@ export function OptionCards({ props }: { props: Props }) {
|
|
|
690
672
|
<Text style={{ color: theme.colors.foregroundMuted, fontSize: 12 }}><InlineMarkdown text={opt.detail} theme={theme} /></Text>
|
|
691
673
|
) : null}
|
|
692
674
|
</Pressable>
|
|
675
|
+
{feedback.controls(idx, `option "${opt.title}"`, {})}
|
|
676
|
+
</View>
|
|
693
677
|
);
|
|
694
678
|
})}
|
|
695
679
|
</View>
|
|
@@ -724,7 +708,7 @@ export function Swatches({ props }: { props: Props }) {
|
|
|
724
708
|
paddingVertical: 5,
|
|
725
709
|
borderRadius: 8,
|
|
726
710
|
borderWidth: active ? 1.5 : StyleSheet.hairlineWidth,
|
|
727
|
-
borderColor: active ? theme.colors.
|
|
711
|
+
borderColor: active ? theme.colors.foregroundMuted : theme.colors.border,
|
|
728
712
|
backgroundColor: theme.colors.surface2,
|
|
729
713
|
}}
|
|
730
714
|
>
|
|
@@ -807,9 +791,7 @@ export function EditableTable({ props }: { props: Props }) {
|
|
|
807
791
|
onPress={() => setValue(binding.name, setCell(rows, rIdx, col.key, !cellVal))}
|
|
808
792
|
style={{ width: 130, paddingHorizontal: 8, paddingVertical: 6 }}
|
|
809
793
|
>
|
|
810
|
-
<
|
|
811
|
-
{cellVal ? "☑ Yes" : "☐ No"}
|
|
812
|
-
</Text>
|
|
794
|
+
<CheckBox checked={Boolean(cellVal)} />
|
|
813
795
|
</Pressable>
|
|
814
796
|
);
|
|
815
797
|
}
|
|
@@ -866,7 +848,7 @@ export function EditableTable({ props }: { props: Props }) {
|
|
|
866
848
|
}
|
|
867
849
|
|
|
868
850
|
export function Button({ props }: { props: Props }) {
|
|
869
|
-
const { theme, run } = useUiRuntime();
|
|
851
|
+
const { theme, run, queued } = useUiRuntime();
|
|
870
852
|
const label = text(props.label);
|
|
871
853
|
const variant = text(props.variant) || "secondary";
|
|
872
854
|
const rawIcon = optionalText(props.icon);
|
|
@@ -876,6 +858,9 @@ export function Button({ props }: { props: Props }) {
|
|
|
876
858
|
: isAction(props.action)
|
|
877
859
|
? [props.action]
|
|
878
860
|
: [{ kind: "action", type: "send", text: label }];
|
|
861
|
+
// A button whose actions only queue shows as pressed while its text is in the reply.
|
|
862
|
+
const queueTexts = actions.flatMap((action) => (action.type === "queue" ? [action.text] : []));
|
|
863
|
+
const isQueued = queueTexts.length > 0 && queueTexts.every((t) => queued(`queue:${t}`) !== null);
|
|
879
864
|
|
|
880
865
|
const bg =
|
|
881
866
|
variant === "primary"
|
|
@@ -891,6 +876,7 @@ export function Button({ props }: { props: Props }) {
|
|
|
891
876
|
return (
|
|
892
877
|
<Pressable
|
|
893
878
|
accessibilityRole="button"
|
|
879
|
+
accessibilityState={{ selected: isQueued }}
|
|
894
880
|
onPress={() => void run(actions)}
|
|
895
881
|
style={{
|
|
896
882
|
alignSelf: "flex-start",
|
|
@@ -905,7 +891,7 @@ export function Button({ props }: { props: Props }) {
|
|
|
905
891
|
borderColor: variant === "secondary" ? theme.colors.border : bg,
|
|
906
892
|
}}
|
|
907
893
|
>
|
|
908
|
-
{iconName ? <Icon name={iconName} size={14} color={fg} /> : null}
|
|
894
|
+
{isQueued ? <Icon name="Check" size={14} color={fg} /> : iconName ? <Icon name={iconName} size={14} color={fg} /> : null}
|
|
909
895
|
<Text style={{ color: fg, fontSize: 12.5, fontWeight: "600" }}>{label}</Text>
|
|
910
896
|
</Pressable>
|
|
911
897
|
);
|
|
@@ -993,3 +979,24 @@ export function FollowUps({ props }: { props: Props }) {
|
|
|
993
979
|
</View>
|
|
994
980
|
);
|
|
995
981
|
}
|
|
982
|
+
|
|
983
|
+
/** A real checkbox: the box alone shows the state, so rows around it keep neutral borders. */
|
|
984
|
+
export function CheckBox({ checked }: { checked: boolean }) {
|
|
985
|
+
const { theme } = useUiRuntime();
|
|
986
|
+
return (
|
|
987
|
+
<View
|
|
988
|
+
style={{
|
|
989
|
+
width: 16,
|
|
990
|
+
height: 16,
|
|
991
|
+
borderRadius: 4,
|
|
992
|
+
borderWidth: 1.5,
|
|
993
|
+
borderColor: checked ? theme.colors.accent : theme.colors.foregroundMuted,
|
|
994
|
+
backgroundColor: checked ? theme.colors.accent : "transparent",
|
|
995
|
+
alignItems: "center",
|
|
996
|
+
justifyContent: "center",
|
|
997
|
+
}}
|
|
998
|
+
>
|
|
999
|
+
{checked ? <Icon name="Check" size={11} color={theme.colors.accentForeground} /> : null}
|
|
1000
|
+
</View>
|
|
1001
|
+
);
|
|
1002
|
+
}
|
|
@@ -2,7 +2,7 @@ import { Icon } from "@getpaseo/plugin/client/react-native";
|
|
|
2
2
|
import React, { useContext, useState } from "react";
|
|
3
3
|
import { Pressable, ScrollView, StyleSheet, Text, View } from "react-native";
|
|
4
4
|
import { finiteNumber, list, nodes, optionalText, text, type Props } from "../../shared/logic/values";
|
|
5
|
-
import { RenderNode, RenderNodes } from "../node-renderer";
|
|
5
|
+
import { isButtonLike, RenderNode, RenderNodes } from "../node-renderer";
|
|
6
6
|
import { CardDepthContext, propsKey, usePersistedState, useUiRuntime } from "../runtime";
|
|
7
7
|
|
|
8
8
|
export function Card({ props }: { props: Props }) {
|
|
@@ -46,6 +46,8 @@ export function Card({ props }: { props: Props }) {
|
|
|
46
46
|
export function Row({ props }: { props: Props }) {
|
|
47
47
|
const { compact } = useUiRuntime();
|
|
48
48
|
const children = nodes(props.children);
|
|
49
|
+
// Equal columns suit content; a row of buttons reads as one group instead.
|
|
50
|
+
if (children.length > 0 && children.every(isButtonLike)) return <RenderNodes nodes={children} />;
|
|
49
51
|
return (
|
|
50
52
|
<View
|
|
51
53
|
style={{
|
|
@@ -396,8 +396,8 @@ export function Hotspots({ props }: { props: Props }) {
|
|
|
396
396
|
gap: 8,
|
|
397
397
|
padding: 8,
|
|
398
398
|
borderRadius: 8,
|
|
399
|
-
borderWidth: StyleSheet.hairlineWidth,
|
|
400
|
-
borderColor: isSelected ? theme.colors.
|
|
399
|
+
borderWidth: isSelected ? 1.5 : StyleSheet.hairlineWidth,
|
|
400
|
+
borderColor: isSelected ? theme.colors.foregroundMuted : theme.colors.border,
|
|
401
401
|
backgroundColor: theme.colors.surface2,
|
|
402
402
|
}}
|
|
403
403
|
>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Icon } from "@getpaseo/plugin/client/react-native";
|
|
1
2
|
import { ExternalLink } from "@getpaseo/plugin/client/ui";
|
|
2
3
|
import React, { useEffect, useMemo, useState } from "react";
|
|
3
4
|
import { Pressable, StyleSheet, Text, View } from "react-native";
|
|
@@ -408,7 +409,7 @@ export function Environments() {
|
|
|
408
409
|
style={{
|
|
409
410
|
borderRadius: 8,
|
|
410
411
|
borderWidth: StyleSheet.hairlineWidth,
|
|
411
|
-
borderColor:
|
|
412
|
+
borderColor: theme.colors.border,
|
|
412
413
|
backgroundColor: theme.colors.surface2,
|
|
413
414
|
padding: 10,
|
|
414
415
|
gap: 4,
|
|
@@ -554,14 +555,18 @@ export function Transcript({ props }: { props: Props }) {
|
|
|
554
555
|
}}
|
|
555
556
|
style={{
|
|
556
557
|
alignSelf: "flex-start",
|
|
558
|
+
flexDirection: "row",
|
|
559
|
+
alignItems: "center",
|
|
560
|
+
gap: 6,
|
|
557
561
|
paddingHorizontal: 10,
|
|
558
562
|
paddingVertical: 5,
|
|
559
563
|
borderRadius: 6,
|
|
560
564
|
backgroundColor: theme.colors.accent,
|
|
561
565
|
}}
|
|
562
566
|
>
|
|
567
|
+
<Icon name="Play" size={12} color={theme.colors.accentForeground} />
|
|
563
568
|
<Text style={{ color: theme.colors.accentForeground, fontSize: 12, fontWeight: "600" }}>
|
|
564
|
-
|
|
569
|
+
Play recording
|
|
565
570
|
</Text>
|
|
566
571
|
</Pressable>
|
|
567
572
|
) : null}
|