@agimon-ai/po-native-dashboard 0.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +149 -0
- package/README.md +5 -0
- package/dist/components/ActivityPanel.d.mts +10 -0
- package/dist/components/ActivityPanel.d.mts.map +1 -0
- package/dist/components/ActivityPanel.mjs +50 -0
- package/dist/components/ActivityPanel.mjs.map +1 -0
- package/dist/components/CaptureTray.d.mts +12 -0
- package/dist/components/CaptureTray.d.mts.map +1 -0
- package/dist/components/CaptureTray.mjs +112 -0
- package/dist/components/CaptureTray.mjs.map +1 -0
- package/dist/components/CompletionSheet.d.mts +44 -0
- package/dist/components/CompletionSheet.d.mts.map +1 -0
- package/dist/components/CompletionSheet.mjs +390 -0
- package/dist/components/CompletionSheet.mjs.map +1 -0
- package/dist/components/Composer.d.mts +47 -0
- package/dist/components/Composer.d.mts.map +1 -0
- package/dist/components/Composer.mjs +449 -0
- package/dist/components/Composer.mjs.map +1 -0
- package/dist/components/DialogSheet.d.mts +23 -0
- package/dist/components/DialogSheet.d.mts.map +1 -0
- package/dist/components/DialogSheet.mjs +115 -0
- package/dist/components/DialogSheet.mjs.map +1 -0
- package/dist/components/MessageActionsSheet.d.mts +16 -0
- package/dist/components/MessageActionsSheet.d.mts.map +1 -0
- package/dist/components/MessageActionsSheet.mjs +26 -0
- package/dist/components/MessageActionsSheet.mjs.map +1 -0
- package/dist/components/MoveSessionSheet.d.mts +17 -0
- package/dist/components/MoveSessionSheet.d.mts.map +1 -0
- package/dist/components/MoveSessionSheet.mjs +145 -0
- package/dist/components/MoveSessionSheet.mjs.map +1 -0
- package/dist/components/SessionMenus.d.mts +76 -0
- package/dist/components/SessionMenus.d.mts.map +1 -0
- package/dist/components/SessionMenus.mjs +1187 -0
- package/dist/components/SessionMenus.mjs.map +1 -0
- package/dist/components/TimelineItem.d.mts +39 -0
- package/dist/components/TimelineItem.d.mts.map +1 -0
- package/dist/components/TimelineItem.mjs +278 -0
- package/dist/components/TimelineItem.mjs.map +1 -0
- package/dist/components/sessionGroups.mjs +20 -0
- package/dist/components/sessionGroups.mjs.map +1 -0
- package/dist/components/sessionTimeline.mjs +20 -0
- package/dist/components/sessionTimeline.mjs.map +1 -0
- package/dist/components/slotProps.d.mts +23 -0
- package/dist/components/slotProps.d.mts.map +1 -0
- package/dist/components/slotProps.mjs +68 -0
- package/dist/components/slotProps.mjs.map +1 -0
- package/dist/index.d.mts +13 -0
- package/dist/index.mjs +14 -0
- package/dist/screens/SessionScreen.d.mts +56 -0
- package/dist/screens/SessionScreen.d.mts.map +1 -0
- package/dist/screens/SessionScreen.mjs +551 -0
- package/dist/screens/SessionScreen.mjs.map +1 -0
- package/dist/screens/SessionsScreen.d.mts +47 -0
- package/dist/screens/SessionsScreen.d.mts.map +1 -0
- package/dist/screens/SessionsScreen.mjs +1436 -0
- package/dist/screens/SessionsScreen.mjs.map +1 -0
- package/dist/slotProps.d.mts +2 -0
- package/dist/slotProps.mjs +3 -0
- package/package.json +92 -0
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import { View } from "react-native-unistyles/components/native/View";
|
|
2
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
3
|
+
import { ChevronRightIcon, Input, Sheet, SheetContent, SparklesIcon, Spinner, fontOf } from "@agimon-ai/po-native-components";
|
|
4
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
7
|
+
import { HOST_SLOTS, TRIGGER_CHARS, commandCompletions, fileCompletions, slotFills } from "@agimon-ai/po-web-dashboard/core";
|
|
8
|
+
import { useEffect, useEffectEvent, useState } from "react";
|
|
9
|
+
|
|
10
|
+
//#region src/components/CompletionSheet.tsx
|
|
11
|
+
/** The phone's way into `@`, `$` and `/`: what each kind is called and what it is for. */
|
|
12
|
+
const KINDS = [
|
|
13
|
+
{
|
|
14
|
+
kind: "file",
|
|
15
|
+
title: "Files",
|
|
16
|
+
hint: "Point Po at a file in this folder",
|
|
17
|
+
search: "Search files",
|
|
18
|
+
none: "No files match"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
kind: "skill",
|
|
22
|
+
title: "Skills",
|
|
23
|
+
hint: "Use one of your skills",
|
|
24
|
+
search: "Search skills",
|
|
25
|
+
none: "No skills match"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
kind: "command",
|
|
29
|
+
title: "Slash commands",
|
|
30
|
+
hint: "Run a session command",
|
|
31
|
+
search: "Search commands",
|
|
32
|
+
none: "No commands match"
|
|
33
|
+
}
|
|
34
|
+
];
|
|
35
|
+
/** The hub is a tunnel away, so wait for a pause in typing before asking it. */
|
|
36
|
+
const FILE_SEARCH_DEBOUNCE_MS = 150;
|
|
37
|
+
function textField(data, key) {
|
|
38
|
+
if (typeof data !== "object" || data === null) return void 0;
|
|
39
|
+
const value = Reflect.get(data, key);
|
|
40
|
+
return typeof value === "string" ? value : void 0;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The phone's `composer-menu` fills. The cockpit draws a fill's component as the
|
|
44
|
+
* menu row itself; a sheet has room for a page, so here `data.title` (with
|
|
45
|
+
* optional `hint` and `glyph`) is the row and the component is the page.
|
|
46
|
+
*/
|
|
47
|
+
function insertPages(sessionId) {
|
|
48
|
+
return slotFills(HOST_SLOTS.composerMenu, sessionId).flatMap(({ pluginId, id, data, component }) => {
|
|
49
|
+
const title = textField(data, "title");
|
|
50
|
+
if (!component || title === void 0) return [];
|
|
51
|
+
const hint = textField(data, "hint") ?? "";
|
|
52
|
+
const glyph = textField(data, "glyph") ?? title.charAt(0);
|
|
53
|
+
return [{
|
|
54
|
+
key: `${pluginId}:${id}`,
|
|
55
|
+
title,
|
|
56
|
+
hint,
|
|
57
|
+
glyph,
|
|
58
|
+
component
|
|
59
|
+
}];
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** The items one kind offers for a query; files come from the hub, the rest from the session's commands. */
|
|
63
|
+
function useCompletionItems(source, kind, query) {
|
|
64
|
+
const [files, setFiles] = useState();
|
|
65
|
+
const searchable = source?.searchFiles !== void 0;
|
|
66
|
+
const searchFiles = useEffectEvent((text) => source?.searchFiles(text) ?? Promise.resolve([]));
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (kind !== "file" || !searchable) return;
|
|
69
|
+
let current = true;
|
|
70
|
+
const timer = setTimeout(() => {
|
|
71
|
+
searchFiles(query).then((found) => {
|
|
72
|
+
if (current) setFiles({
|
|
73
|
+
query,
|
|
74
|
+
items: fileCompletions(found)
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}, FILE_SEARCH_DEBOUNCE_MS);
|
|
78
|
+
return () => {
|
|
79
|
+
current = false;
|
|
80
|
+
clearTimeout(timer);
|
|
81
|
+
};
|
|
82
|
+
}, [
|
|
83
|
+
kind,
|
|
84
|
+
query,
|
|
85
|
+
searchable
|
|
86
|
+
]);
|
|
87
|
+
if (source === void 0 || kind === null) return [];
|
|
88
|
+
if (kind !== "file") return commandCompletions(source.commands, kind, query);
|
|
89
|
+
return files?.query === query ? files.items : void 0;
|
|
90
|
+
}
|
|
91
|
+
/** Completion items as tappable rows: the name in mono, what it does beneath. */
|
|
92
|
+
function CompletionRows({ items, onPick }) {
|
|
93
|
+
return /* @__PURE__ */ jsx(View, {
|
|
94
|
+
style: styles.list,
|
|
95
|
+
children: items.map((item, index) => /* @__PURE__ */ jsx(Pressable, {
|
|
96
|
+
accessibilityRole: "button",
|
|
97
|
+
accessibilityLabel: item.detail ? `${item.label}, ${item.detail}` : item.label,
|
|
98
|
+
onPress: () => onPick(item),
|
|
99
|
+
style: ({ pressed }) => [
|
|
100
|
+
styles.item,
|
|
101
|
+
index > 0 && styles.divider,
|
|
102
|
+
pressed && styles.pressed
|
|
103
|
+
],
|
|
104
|
+
children: /* @__PURE__ */ jsxs(View, {
|
|
105
|
+
style: styles.flex,
|
|
106
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
107
|
+
style: styles.itemLabel,
|
|
108
|
+
numberOfLines: 1,
|
|
109
|
+
ellipsizeMode: "middle",
|
|
110
|
+
children: item.label
|
|
111
|
+
}), item.detail ? /* @__PURE__ */ jsx(Text, {
|
|
112
|
+
style: styles.meta,
|
|
113
|
+
numberOfLines: 1,
|
|
114
|
+
children: item.detail
|
|
115
|
+
}) : null]
|
|
116
|
+
})
|
|
117
|
+
}, item.insert))
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/** The magic button's sheet: choose Files, Skills, Slash commands, a plugin page or an attachment, then pick one. */
|
|
121
|
+
function CompletionSheet({ open, onOpenChange, source, onPick, defaultKind, defaultQuery = "", defaultPage, slotProps, actions = [] }) {
|
|
122
|
+
const [kind, setKind] = useState(defaultKind ?? null);
|
|
123
|
+
const [pageKey, setPageKey] = useState(defaultPage ?? null);
|
|
124
|
+
const [query, setQuery] = useState(defaultQuery);
|
|
125
|
+
const items = useCompletionItems(source, kind, query);
|
|
126
|
+
const page = KINDS.find((entry) => entry.kind === kind);
|
|
127
|
+
const pages = slotProps ? insertPages(slotProps.sessionId) : [];
|
|
128
|
+
const plugin = pages.find((entry) => entry.key === pageKey);
|
|
129
|
+
const choose = (next) => {
|
|
130
|
+
setKind(next);
|
|
131
|
+
setPageKey(null);
|
|
132
|
+
setQuery("");
|
|
133
|
+
};
|
|
134
|
+
const close = (next) => {
|
|
135
|
+
if (!next) choose(null);
|
|
136
|
+
onOpenChange(next);
|
|
137
|
+
};
|
|
138
|
+
const rows = [
|
|
139
|
+
...KINDS.map((entry) => ({
|
|
140
|
+
key: entry.kind,
|
|
141
|
+
glyph: TRIGGER_CHARS[entry.kind],
|
|
142
|
+
title: entry.title,
|
|
143
|
+
hint: entry.hint,
|
|
144
|
+
onPress: () => choose(entry.kind)
|
|
145
|
+
})),
|
|
146
|
+
...pages.map((entry) => ({
|
|
147
|
+
...entry,
|
|
148
|
+
onPress: () => setPageKey(entry.key)
|
|
149
|
+
})),
|
|
150
|
+
...actions.map((entry) => ({
|
|
151
|
+
...entry,
|
|
152
|
+
onPress: () => {
|
|
153
|
+
close(false);
|
|
154
|
+
entry.onPress();
|
|
155
|
+
}
|
|
156
|
+
}))
|
|
157
|
+
];
|
|
158
|
+
return /* @__PURE__ */ jsx(Sheet, {
|
|
159
|
+
open,
|
|
160
|
+
onOpenChange: close,
|
|
161
|
+
children: /* @__PURE__ */ jsxs(SheetContent, { children: [/* @__PURE__ */ jsxs(View, {
|
|
162
|
+
style: styles.head,
|
|
163
|
+
children: [
|
|
164
|
+
/* @__PURE__ */ jsx(Pressable, {
|
|
165
|
+
accessibilityRole: "button",
|
|
166
|
+
accessibilityLabel: "Back to insert",
|
|
167
|
+
onPress: () => choose(null),
|
|
168
|
+
disabled: page === void 0 && plugin === void 0,
|
|
169
|
+
style: [styles.back, page === void 0 && plugin === void 0 && styles.hidden],
|
|
170
|
+
children: /* @__PURE__ */ jsx(View, {
|
|
171
|
+
style: styles.flip,
|
|
172
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
173
|
+
size: 18,
|
|
174
|
+
color: "hi"
|
|
175
|
+
})
|
|
176
|
+
})
|
|
177
|
+
}),
|
|
178
|
+
/* @__PURE__ */ jsx(Text, {
|
|
179
|
+
style: styles.title,
|
|
180
|
+
accessibilityRole: "header",
|
|
181
|
+
children: page?.title ?? plugin?.title ?? "Insert"
|
|
182
|
+
}),
|
|
183
|
+
/* @__PURE__ */ jsx(View, { style: [styles.back, styles.hidden] })
|
|
184
|
+
]
|
|
185
|
+
}), plugin && slotProps ? /* @__PURE__ */ jsx(plugin.component, {
|
|
186
|
+
...slotProps,
|
|
187
|
+
appendComposerDraft: (text) => {
|
|
188
|
+
slotProps.appendComposerDraft(text);
|
|
189
|
+
close(false);
|
|
190
|
+
}
|
|
191
|
+
}) : /* @__PURE__ */ jsx(View, {
|
|
192
|
+
style: styles.body,
|
|
193
|
+
children: page === void 0 ? /* @__PURE__ */ jsx(View, {
|
|
194
|
+
style: styles.list,
|
|
195
|
+
children: rows.map((entry, index) => /* @__PURE__ */ jsxs(Pressable, {
|
|
196
|
+
accessibilityRole: "button",
|
|
197
|
+
accessibilityLabel: entry.hint ? `${entry.title}, ${entry.hint}` : entry.title,
|
|
198
|
+
onPress: entry.onPress,
|
|
199
|
+
style: ({ pressed }) => [
|
|
200
|
+
styles.item,
|
|
201
|
+
index > 0 && styles.divider,
|
|
202
|
+
pressed && styles.pressed
|
|
203
|
+
],
|
|
204
|
+
children: [
|
|
205
|
+
/* @__PURE__ */ jsx(View, {
|
|
206
|
+
style: styles.glyph,
|
|
207
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
208
|
+
style: styles.glyphText,
|
|
209
|
+
children: entry.glyph
|
|
210
|
+
})
|
|
211
|
+
}),
|
|
212
|
+
/* @__PURE__ */ jsxs(View, {
|
|
213
|
+
style: styles.flex,
|
|
214
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
215
|
+
style: styles.kindLabel,
|
|
216
|
+
children: entry.title
|
|
217
|
+
}), entry.hint ? /* @__PURE__ */ jsx(Text, {
|
|
218
|
+
style: styles.meta,
|
|
219
|
+
children: entry.hint
|
|
220
|
+
}) : null]
|
|
221
|
+
}),
|
|
222
|
+
/* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
223
|
+
size: 16,
|
|
224
|
+
color: "faint"
|
|
225
|
+
})
|
|
226
|
+
]
|
|
227
|
+
}, entry.key))
|
|
228
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(Input, {
|
|
229
|
+
value: query,
|
|
230
|
+
onChangeText: setQuery,
|
|
231
|
+
placeholder: page.search,
|
|
232
|
+
accessibilityLabel: page.search,
|
|
233
|
+
autoFocus: true,
|
|
234
|
+
autoCapitalize: "none",
|
|
235
|
+
autoCorrect: false
|
|
236
|
+
}), items === void 0 ? /* @__PURE__ */ jsx(View, {
|
|
237
|
+
style: styles.waiting,
|
|
238
|
+
children: /* @__PURE__ */ jsx(Spinner, {
|
|
239
|
+
size: "small",
|
|
240
|
+
color: "dim",
|
|
241
|
+
label: "Searching"
|
|
242
|
+
})
|
|
243
|
+
}) : items.length === 0 ? /* @__PURE__ */ jsx(Text, {
|
|
244
|
+
style: styles.none,
|
|
245
|
+
children: page.none
|
|
246
|
+
}) : /* @__PURE__ */ jsx(CompletionRows, {
|
|
247
|
+
items,
|
|
248
|
+
onPick: (item) => {
|
|
249
|
+
onPick(page.kind, item);
|
|
250
|
+
close(false);
|
|
251
|
+
}
|
|
252
|
+
})] })
|
|
253
|
+
})] })
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
/** The composer's round button that opens the sheet. */
|
|
257
|
+
function CompletionButton({ onPress }) {
|
|
258
|
+
return /* @__PURE__ */ jsx(Pressable, {
|
|
259
|
+
accessibilityRole: "button",
|
|
260
|
+
accessibilityLabel: "Insert or attach",
|
|
261
|
+
onPress,
|
|
262
|
+
hitSlop: 6,
|
|
263
|
+
style: ({ pressed }) => [styles.magic, pressed && styles.magicPressed],
|
|
264
|
+
children: /* @__PURE__ */ jsx(SparklesIcon, {
|
|
265
|
+
size: 16,
|
|
266
|
+
color: "green"
|
|
267
|
+
})
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
const styles = StyleSheet.create((theme) => {
|
|
271
|
+
const sans = fontOf(theme.fontFamily.sans);
|
|
272
|
+
const mono = fontOf(theme.fontFamily.mono);
|
|
273
|
+
const text = (size, color) => ({
|
|
274
|
+
fontFamily: sans,
|
|
275
|
+
fontSize: theme.fontSize[size],
|
|
276
|
+
lineHeight: theme.lineHeight[size],
|
|
277
|
+
color
|
|
278
|
+
});
|
|
279
|
+
return {
|
|
280
|
+
flex: {
|
|
281
|
+
flex: 1,
|
|
282
|
+
minWidth: 0
|
|
283
|
+
},
|
|
284
|
+
hidden: { opacity: 0 },
|
|
285
|
+
flip: { transform: [{ rotate: "180deg" }] },
|
|
286
|
+
head: {
|
|
287
|
+
flexDirection: "row",
|
|
288
|
+
alignItems: "center",
|
|
289
|
+
paddingHorizontal: theme.spacing(3),
|
|
290
|
+
paddingBottom: theme.spacing(2),
|
|
291
|
+
uni__dependencies: [0]
|
|
292
|
+
},
|
|
293
|
+
back: {
|
|
294
|
+
width: 36,
|
|
295
|
+
height: 36,
|
|
296
|
+
alignItems: "center",
|
|
297
|
+
justifyContent: "center"
|
|
298
|
+
},
|
|
299
|
+
title: {
|
|
300
|
+
...text("lg", theme.colors.hi),
|
|
301
|
+
fontWeight: theme.fontWeight.semibold,
|
|
302
|
+
flex: 1,
|
|
303
|
+
textAlign: "center",
|
|
304
|
+
uni__dependencies: [0]
|
|
305
|
+
},
|
|
306
|
+
body: {
|
|
307
|
+
gap: theme.spacing(3),
|
|
308
|
+
paddingHorizontal: theme.spacing(4),
|
|
309
|
+
paddingBottom: theme.spacing(4),
|
|
310
|
+
uni__dependencies: [0]
|
|
311
|
+
},
|
|
312
|
+
list: {
|
|
313
|
+
borderRadius: theme.borderRadius.lg,
|
|
314
|
+
borderWidth: 1,
|
|
315
|
+
borderColor: theme.colors["border-soft"],
|
|
316
|
+
backgroundColor: theme.colors.bg,
|
|
317
|
+
overflow: "hidden",
|
|
318
|
+
uni__dependencies: [0]
|
|
319
|
+
},
|
|
320
|
+
item: {
|
|
321
|
+
flexDirection: "row",
|
|
322
|
+
alignItems: "center",
|
|
323
|
+
gap: theme.spacing(3),
|
|
324
|
+
minHeight: 48,
|
|
325
|
+
paddingHorizontal: theme.spacing(4),
|
|
326
|
+
paddingVertical: theme.spacing(2.5),
|
|
327
|
+
uni__dependencies: [0]
|
|
328
|
+
},
|
|
329
|
+
divider: {
|
|
330
|
+
borderTopWidth: StyleSheet.hairlineWidth,
|
|
331
|
+
borderTopColor: theme.colors["border-soft"],
|
|
332
|
+
uni__dependencies: [0]
|
|
333
|
+
},
|
|
334
|
+
pressed: {
|
|
335
|
+
backgroundColor: theme.colors["tint-green"],
|
|
336
|
+
uni__dependencies: [0]
|
|
337
|
+
},
|
|
338
|
+
glyph: {
|
|
339
|
+
width: 32,
|
|
340
|
+
height: 32,
|
|
341
|
+
borderRadius: 16,
|
|
342
|
+
alignItems: "center",
|
|
343
|
+
justifyContent: "center",
|
|
344
|
+
backgroundColor: theme.colors["tint-green"],
|
|
345
|
+
uni__dependencies: [0]
|
|
346
|
+
},
|
|
347
|
+
glyphText: {
|
|
348
|
+
...text("lg", theme.colors.green),
|
|
349
|
+
fontFamily: mono,
|
|
350
|
+
fontWeight: theme.fontWeight.semibold,
|
|
351
|
+
uni__dependencies: [0]
|
|
352
|
+
},
|
|
353
|
+
kindLabel: {
|
|
354
|
+
...text("base", theme.colors.hi),
|
|
355
|
+
fontWeight: theme.fontWeight.medium,
|
|
356
|
+
uni__dependencies: [0]
|
|
357
|
+
},
|
|
358
|
+
itemLabel: {
|
|
359
|
+
...text("base", theme.colors.hi),
|
|
360
|
+
fontFamily: mono,
|
|
361
|
+
uni__dependencies: [0]
|
|
362
|
+
},
|
|
363
|
+
meta: text("sm", theme.colors.dim),
|
|
364
|
+
none: {
|
|
365
|
+
...text("base", theme.colors.dim),
|
|
366
|
+
textAlign: "center",
|
|
367
|
+
paddingVertical: theme.spacing(4),
|
|
368
|
+
uni__dependencies: [0]
|
|
369
|
+
},
|
|
370
|
+
waiting: {
|
|
371
|
+
alignItems: "center",
|
|
372
|
+
paddingVertical: theme.spacing(6),
|
|
373
|
+
uni__dependencies: [0]
|
|
374
|
+
},
|
|
375
|
+
magic: {
|
|
376
|
+
width: 32,
|
|
377
|
+
height: 32,
|
|
378
|
+
borderRadius: 16,
|
|
379
|
+
alignItems: "center",
|
|
380
|
+
justifyContent: "center",
|
|
381
|
+
backgroundColor: theme.colors["tint-green"],
|
|
382
|
+
uni__dependencies: [0]
|
|
383
|
+
},
|
|
384
|
+
magicPressed: { opacity: .7 }
|
|
385
|
+
};
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
//#endregion
|
|
389
|
+
export { CompletionButton, CompletionRows, CompletionSheet, useCompletionItems };
|
|
390
|
+
//# sourceMappingURL=CompletionSheet.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CompletionSheet.mjs","names":["WebPluginSlotProps","ChevronRightIcon","fontOf","Input","Sheet","SheetContent","SparklesIcon","Spinner","CommandInfo","CompletionItem","CompletionKind","commandCompletions","fileCompletions","HOST_SLOTS","slotFills","TRIGGER_CHARS","ComponentType","useEffect","useEffectEvent","useState","StyleSheet","KINDS","kind","title","hint","search","none","FILE_SEARCH_DEBOUNCE_MS","CompletionSource","commands","searchFiles","query","Promise","InsertPage","key","glyph","component","textField","data","undefined","value","Reflect","get","insertPages","sessionId","composerMenu","flatMap","pluginId","id","charAt","useCompletionItems","source","files","setFiles","items","searchable","text","resolve","current","timer","setTimeout","then","found","clearTimeout","CompletionRows","onPick","item","styles","list","map","index","insert","detail","label","pressed","divider","flex","itemLabel","meta","CompletionSheetProps","open","onOpenChange","defaultKind","defaultQuery","defaultPage","slotProps","actions","InsertAction","onPress","CompletionSheet","setKind","pageKey","setPageKey","setQuery","page","find","entry","pages","plugin","choose","next","close","rows","head","back","hidden","flip","appendComposerDraft","body","glyphText","kindLabel","waiting","length","CompletionButton","magic","magicPressed","create","theme","sans","fontFamily","mono","size","color","fontSize","lineHeight","minWidth","opacity","transform","rotate","flexDirection","alignItems","paddingHorizontal","spacing","paddingBottom","uni__dependencies","width","height","justifyContent","colors","hi","fontWeight","semibold","textAlign","gap","borderRadius","lg","borderWidth","borderColor","backgroundColor","bg","overflow","minHeight","paddingVertical","borderTopWidth","hairlineWidth","borderTopColor","green","medium","dim"],"sources":["../../src/components/CompletionSheet.tsx"],"sourcesContent":["import type { WebPluginSlotProps } from '@agimon-ai/po-core/web';\nimport {\n ChevronRightIcon,\n fontOf,\n Input,\n Sheet,\n SheetContent,\n SparklesIcon,\n Spinner,\n} from '@agimon-ai/po-native-components';\nimport {\n type CommandInfo,\n type CompletionItem,\n type CompletionKind,\n commandCompletions,\n fileCompletions,\n HOST_SLOTS,\n slotFills,\n TRIGGER_CHARS,\n} from '@agimon-ai/po-web-dashboard/core';\nimport { type ComponentType, useEffect, useEffectEvent, useState } from 'react';\nimport { Pressable, Text, View } from 'react-native';\nimport { StyleSheet } from 'react-native-unistyles';\n\n/** The phone's way into `@`, `$` and `/`: what each kind is called and what it is for. */\nconst KINDS: readonly { kind: CompletionKind; title: string; hint: string; search: string; none: string }[] = [\n {\n kind: 'file',\n title: 'Files',\n hint: 'Point Po at a file in this folder',\n search: 'Search files',\n none: 'No files match',\n },\n { kind: 'skill', title: 'Skills', hint: 'Use one of your skills', search: 'Search skills', none: 'No skills match' },\n {\n kind: 'command',\n title: 'Slash commands',\n hint: 'Run a session command',\n search: 'Search commands',\n none: 'No commands match',\n },\n];\n/** The hub is a tunnel away, so wait for a pause in typing before asking it. */\nconst FILE_SEARCH_DEBOUNCE_MS = 150;\n\nexport interface CompletionSource {\n commands: readonly CommandInfo[];\n searchFiles: (query: string) => Promise<string[]>;\n}\n\n/** A row a plugin adds after the three kinds, and the page it opens in this sheet. */\ninterface InsertPage {\n key: string;\n title: string;\n hint: string;\n glyph: string;\n component: ComponentType<WebPluginSlotProps>;\n}\n\nfunction textField(data: unknown, key: string): string | undefined {\n if (typeof data !== 'object' || data === null) return undefined;\n const value: unknown = Reflect.get(data, key);\n return typeof value === 'string' ? value : undefined;\n}\n\n/**\n * The phone's `composer-menu` fills. The cockpit draws a fill's component as the\n * menu row itself; a sheet has room for a page, so here `data.title` (with\n * optional `hint` and `glyph`) is the row and the component is the page.\n */\nfunction insertPages(sessionId: string | null): InsertPage[] {\n return slotFills(HOST_SLOTS.composerMenu, sessionId).flatMap(({ pluginId, id, data, component }) => {\n const title = textField(data, 'title');\n if (!component || title === undefined) return [];\n const hint = textField(data, 'hint') ?? '';\n const glyph = textField(data, 'glyph') ?? title.charAt(0);\n return [{ key: `${pluginId}:${id}`, title, hint, glyph, component }];\n });\n}\n/** The items one kind offers for a query; files come from the hub, the rest from the session's commands. */\nexport function useCompletionItems(\n source: CompletionSource | undefined,\n kind: CompletionKind | null,\n query: string,\n): CompletionItem[] | undefined {\n const [files, setFiles] = useState<{ query: string; items: CompletionItem[] }>();\n const searchable = source?.searchFiles !== undefined;\n // Hosts rebuild searchFiles every render; an effect event keeps a streaming session from restarting the debounce forever.\n const searchFiles = useEffectEvent((text: string) => source?.searchFiles(text) ?? Promise.resolve([]));\n useEffect(() => {\n if (kind !== 'file' || !searchable) return;\n let current = true;\n const timer = setTimeout(() => {\n void searchFiles(query).then((found) => {\n if (current) setFiles({ query, items: fileCompletions(found) });\n });\n }, FILE_SEARCH_DEBOUNCE_MS);\n return () => {\n current = false;\n clearTimeout(timer);\n };\n }, [kind, query, searchable]);\n if (source === undefined || kind === null) return [];\n if (kind !== 'file') return commandCompletions(source.commands, kind, query);\n // Undefined while the answer for this query is on its way.\n return files?.query === query ? files.items : undefined;\n}\n\n/** Completion items as tappable rows: the name in mono, what it does beneath. */\nexport function CompletionRows({\n items,\n onPick,\n}: {\n items: readonly CompletionItem[];\n onPick: (item: CompletionItem) => void;\n}) {\n return (\n <View style={styles.list}>\n {items.map((item, index) => (\n <Pressable\n key={item.insert}\n accessibilityRole=\"button\"\n accessibilityLabel={item.detail ? `${item.label}, ${item.detail}` : item.label}\n onPress={() => onPick(item)}\n style={({ pressed }) => [styles.item, index > 0 && styles.divider, pressed && styles.pressed]}\n >\n <View style={styles.flex}>\n <Text style={styles.itemLabel} numberOfLines={1} ellipsizeMode=\"middle\">\n {item.label}\n </Text>\n {item.detail ? (\n <Text style={styles.meta} numberOfLines={1}>\n {item.detail}\n </Text>\n ) : null}\n </View>\n </Pressable>\n ))}\n </View>\n );\n}\n\nexport interface CompletionSheetProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n source: CompletionSource;\n onPick: (kind: CompletionKind, item: CompletionItem) => void;\n /** Opens on one kind's search rather than the choice of kinds. */\n defaultKind?: CompletionKind;\n defaultQuery?: string;\n /** Opens on a plugin page, keyed `<pluginId>:<fillId>`. */\n defaultPage?: string;\n /** The session's plugin props; with them, its `composer-menu` fills join the list. */\n slotProps?: WebPluginSlotProps;\n /** Rows after the pages that close the sheet and run, such as attaching a photo or file. */\n actions?: readonly InsertAction[];\n}\n\nexport interface InsertAction {\n key: string;\n glyph: string;\n title: string;\n hint: string;\n onPress: () => void;\n}\n\n/** The magic button's sheet: choose Files, Skills, Slash commands, a plugin page or an attachment, then pick one. */\nexport function CompletionSheet({\n open,\n onOpenChange,\n source,\n onPick,\n defaultKind,\n defaultQuery = '',\n defaultPage,\n slotProps,\n actions = [],\n}: CompletionSheetProps) {\n const [kind, setKind] = useState<CompletionKind | null>(defaultKind ?? null);\n const [pageKey, setPageKey] = useState<string | null>(defaultPage ?? null);\n const [query, setQuery] = useState(defaultQuery);\n const items = useCompletionItems(source, kind, query);\n const page = KINDS.find((entry) => entry.kind === kind);\n const pages = slotProps ? insertPages(slotProps.sessionId) : [];\n const plugin = pages.find((entry) => entry.key === pageKey);\n\n const choose = (next: CompletionKind | null) => {\n setKind(next);\n setPageKey(null);\n setQuery('');\n };\n const close = (next: boolean) => {\n if (!next) choose(null);\n onOpenChange(next);\n };\n const rows = [\n ...KINDS.map((entry) => ({\n key: entry.kind,\n glyph: TRIGGER_CHARS[entry.kind],\n title: entry.title,\n hint: entry.hint,\n onPress: () => choose(entry.kind),\n })),\n ...pages.map((entry) => ({ ...entry, onPress: () => setPageKey(entry.key) })),\n ...actions.map((entry) => ({\n ...entry,\n onPress: () => {\n close(false);\n entry.onPress();\n },\n })),\n ];\n\n return (\n <Sheet open={open} onOpenChange={close}>\n <SheetContent>\n <View style={styles.head}>\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel=\"Back to insert\"\n onPress={() => choose(null)}\n disabled={page === undefined && plugin === undefined}\n style={[styles.back, page === undefined && plugin === undefined && styles.hidden]}\n >\n <View style={styles.flip}>\n <ChevronRightIcon size={18} color=\"hi\" />\n </View>\n </Pressable>\n <Text style={styles.title} accessibilityRole=\"header\">\n {page?.title ?? plugin?.title ?? 'Insert'}\n </Text>\n <View style={[styles.back, styles.hidden]} />\n </View>\n {plugin && slotProps ? (\n <plugin.component\n {...slotProps}\n appendComposerDraft={(text) => {\n slotProps.appendComposerDraft(text);\n close(false);\n }}\n />\n ) : (\n <View style={styles.body}>\n {page === undefined ? (\n <View style={styles.list}>\n {rows.map((entry, index) => (\n <Pressable\n key={entry.key}\n accessibilityRole=\"button\"\n accessibilityLabel={entry.hint ? `${entry.title}, ${entry.hint}` : entry.title}\n onPress={entry.onPress}\n style={({ pressed }) => [styles.item, index > 0 && styles.divider, pressed && styles.pressed]}\n >\n <View style={styles.glyph}>\n <Text style={styles.glyphText}>{entry.glyph}</Text>\n </View>\n <View style={styles.flex}>\n <Text style={styles.kindLabel}>{entry.title}</Text>\n {entry.hint ? <Text style={styles.meta}>{entry.hint}</Text> : null}\n </View>\n <ChevronRightIcon size={16} color=\"faint\" />\n </Pressable>\n ))}\n </View>\n ) : (\n <>\n <Input\n value={query}\n onChangeText={setQuery}\n placeholder={page.search}\n accessibilityLabel={page.search}\n autoFocus\n autoCapitalize=\"none\"\n autoCorrect={false}\n />\n {items === undefined ? (\n <View style={styles.waiting}>\n <Spinner size=\"small\" color=\"dim\" label=\"Searching\" />\n </View>\n ) : items.length === 0 ? (\n <Text style={styles.none}>{page.none}</Text>\n ) : (\n <CompletionRows\n items={items}\n onPick={(item) => {\n onPick(page.kind, item);\n close(false);\n }}\n />\n )}\n </>\n )}\n </View>\n )}\n </SheetContent>\n </Sheet>\n );\n}\n\n/** The composer's round button that opens the sheet. */\nexport function CompletionButton({ onPress }: { onPress: () => void }) {\n return (\n <Pressable\n accessibilityRole=\"button\"\n accessibilityLabel=\"Insert or attach\"\n onPress={onPress}\n hitSlop={6}\n style={({ pressed }) => [styles.magic, pressed && styles.magicPressed]}\n >\n <SparklesIcon size={16} color=\"green\" />\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create((theme) => {\n const sans = fontOf(theme.fontFamily.sans);\n const mono = fontOf(theme.fontFamily.mono);\n const text = (size: 'sm' | 'base' | 'lg', color: string) => ({\n fontFamily: sans,\n fontSize: theme.fontSize[size],\n lineHeight: theme.lineHeight[size],\n color,\n });\n return {\n flex: { flex: 1, minWidth: 0 },\n hidden: { opacity: 0 },\n flip: { transform: [{ rotate: '180deg' }] },\n head: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: theme.spacing(3),\n paddingBottom: theme.spacing(2),\n },\n back: { width: 36, height: 36, alignItems: 'center', justifyContent: 'center' },\n title: { ...text('lg', theme.colors.hi), fontWeight: theme.fontWeight.semibold, flex: 1, textAlign: 'center' },\n body: { gap: theme.spacing(3), paddingHorizontal: theme.spacing(4), paddingBottom: theme.spacing(4) },\n list: {\n borderRadius: theme.borderRadius.lg,\n borderWidth: 1,\n borderColor: theme.colors['border-soft'],\n backgroundColor: theme.colors.bg,\n overflow: 'hidden',\n },\n item: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: theme.spacing(3),\n minHeight: 48,\n paddingHorizontal: theme.spacing(4),\n paddingVertical: theme.spacing(2.5),\n },\n divider: { borderTopWidth: StyleSheet.hairlineWidth, borderTopColor: theme.colors['border-soft'] },\n pressed: { backgroundColor: theme.colors['tint-green'] },\n glyph: {\n width: 32,\n height: 32,\n borderRadius: 16,\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: theme.colors['tint-green'],\n },\n glyphText: { ...text('lg', theme.colors.green), fontFamily: mono, fontWeight: theme.fontWeight.semibold },\n kindLabel: { ...text('base', theme.colors.hi), fontWeight: theme.fontWeight.medium },\n itemLabel: { ...text('base', theme.colors.hi), fontFamily: mono },\n meta: text('sm', theme.colors.dim),\n none: { ...text('base', theme.colors.dim), textAlign: 'center', paddingVertical: theme.spacing(4) },\n waiting: { alignItems: 'center', paddingVertical: theme.spacing(6) },\n magic: {\n width: 32,\n height: 32,\n borderRadius: 16,\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: theme.colors['tint-green'],\n },\n magicPressed: { opacity: 0.7 },\n };\n});\n"],"mappings":";;;;;;;;;;;AAyBA,MAAMqB,QAAwG;CAC5G;EACEC,MAAM;EACNC,OAAO;EACPC,MAAM;EACNC,QAAQ;EACRC,MAAM;CACR;CACA;EAAEJ,MAAM;EAASC,OAAO;EAAUC,MAAM;EAA0BC,QAAQ;EAAiBC,MAAM;CAAkB;CACnH;EACEJ,MAAM;EACNC,OAAO;EACPC,MAAM;EACNC,QAAQ;EACRC,MAAM;CACR;AAAC;;AAGH,MAAMC,0BAA0B;AAgBhC,SAASU,UAAUC,MAAeJ,KAAiC;CACjE,IAAI,OAAOI,SAAS,YAAYA,SAAS,MAAM,OAAOC;CACtD,MAAMC,QAAiBC,QAAQC,IAAIJ,MAAMJ,GAAG;CAC5C,OAAO,OAAOM,UAAU,WAAWA,QAAQD;AAC7C;;;;;;AAOA,SAASI,YAAYC,WAAwC;CAC3D,OAAO9B,UAAUD,WAAWgC,cAAcD,SAAS,CAAC,CAACE,SAAS,EAAEC,UAAUC,IAAIV,MAAMF,gBAAgB;EAClG,MAAMb,QAAQc,UAAUC,MAAM,OAAO;EACrC,IAAI,CAACF,aAAab,UAAUgB,QAAW,OAAO,CAAA;EAC9C,MAAMf,OAAOa,UAAUC,MAAM,MAAM,KAAK;EACxC,MAAMH,QAAQE,UAAUC,MAAM,OAAO,KAAKf,MAAM0B,OAAO,CAAC;EACxD,OAAO,CAAC;GAAEf,KAAK,GAAGa,SAAQ,GAAIC;GAAMzB;GAAOC;GAAMW;GAAOC;EAAU,CAAC;CACrE,CAAC;AACH;;AAEA,SAAgBc,mBACdC,QACA7B,MACAS,OAC8B;CAC9B,MAAM,CAACqB,OAAOC,YAAYlC,SAAqD;CAC/E,MAAMoC,aAAaJ,QAAQrB,gBAAgBS;CAE3C,MAAMT,cAAcZ,gBAAgBsC,SAAiBL,QAAQrB,YAAY0B,IAAI,KAAKxB,QAA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AAQ;GACRQ,cAAc;GACdd,YAAY;GACZO,gBAAgB;GAChBW,iBAAiB/B,MAAMqB,OAAO;GAAaJ,mBAAA,CAAA,CAAA;EAC7C;EACAzB,WAAW;GAAE,GAAGrD,KAAK,MAAM6D,MAAMqB,OAAOkB,KAAK;GAAGrC,YAAYC;GAAMoB,YAAYvB,MAAMuB,WAAWC;GAAQP,mBAAA,CAAA,CAAA;EAAC;EACxGxB,WAAW;GAAE,GAAGtD,KAAK,QAAQ6D,MAAMqB,OAAOC,EAAE;GAAGC,YAAYvB,MAAMuB,WAAWiB;GAAMvB,mBAAA,CAAA,CAAA;EAAC;EACnFzD,WAAW;GAAE,GAAGrB,KAAK,QAAQ6D,MAAMqB,OAAOC,EAAE;GAAGpB,YAAYC;GAAIc,mBAAA,CAAA,CAAA;EAAC;EAChExD,MAAMtB,KAAK,MAAM6D,MAAMqB,OAAOoB,GAAG;EACjCpI,MAAM;GAAE,GAAG8B,KAAK,QAAQ6D,MAAMqB,OAAOoB,GAAG;GAAGhB,WAAW;GAAUU,iBAAiBnC,MAAMe,QAAQ,CAAC;GAACE,mBAAA,CAAA,CAAA;EAAC;EAClGvB,SAAS;GAAEmB,YAAY;GAAUsB,iBAAiBnC,MAAMe,QAAQ,CAAC;GAACE,mBAAA,CAAA,CAAA;EAAC;EACnEpB,OAAO;GACLqB,OAAO;GACPC,QAAQ;GACRQ,cAAc;GACdd,YAAY;GACZO,gBAAgB;GAChBW,iBAAiB/B,MAAMqB,OAAO;GAAaJ,mBAAA,CAAA,CAAA;EAC7C;EACAnB,cAAc,EAAEW,SAAS,GAAI;CAC/B;AACF,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { CompletionSource } from "./CompletionSheet.mjs";
|
|
2
|
+
import { Store } from "@tanstack/store";
|
|
3
|
+
import { ComposerCapture, WebPluginSlotProps } from "@agimon-ai/po-core/web";
|
|
4
|
+
//#region src/components/Composer.d.ts
|
|
5
|
+
export interface ComposerProps {
|
|
6
|
+
/** Returning false means it was not sent, so the draft stays. */
|
|
7
|
+
onSend: (text: string) => boolean | void;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
initialText?: string;
|
|
10
|
+
/** A session host may retain the draft while a prompt temporarily replaces this composer. */
|
|
11
|
+
value?: string;
|
|
12
|
+
onChangeText?: (text: string) => void;
|
|
13
|
+
draftStore?: Store<Record<string, string>>;
|
|
14
|
+
sessionId?: string;
|
|
15
|
+
/** Runtime controls subscribe here, outside the navigator and transcript. */
|
|
16
|
+
live?: boolean;
|
|
17
|
+
searchFiles?: (query: string) => Promise<string[]>;
|
|
18
|
+
/** Stores a picked file on the host and returns its path; without it the File option reports it is unavailable. */
|
|
19
|
+
uploadAttachment?: (sessionId: string, file: {
|
|
20
|
+
name: string;
|
|
21
|
+
mimeType: string;
|
|
22
|
+
bytes: Uint8Array<ArrayBuffer>;
|
|
23
|
+
}) => Promise<{
|
|
24
|
+
path: string;
|
|
25
|
+
mimeType: string;
|
|
26
|
+
size: number;
|
|
27
|
+
}>;
|
|
28
|
+
/** A run is in progress: Send steers it and Abort stops it. */
|
|
29
|
+
running?: boolean;
|
|
30
|
+
onAbort?: () => void;
|
|
31
|
+
/** The current major mode, shown on the options button. */
|
|
32
|
+
mode?: string;
|
|
33
|
+
onOpenOptions?: () => void;
|
|
34
|
+
/** Offers `@` files, `$` skills and `/` commands while typing and from the insert button. */
|
|
35
|
+
completion?: CompletionSource;
|
|
36
|
+
/** The session's plugin props, so plugin pages can join the insert sheet. */
|
|
37
|
+
slotProps?: WebPluginSlotProps;
|
|
38
|
+
/** Images staged for the next message, shown as thumbnails above the text box. */
|
|
39
|
+
captures?: readonly ComposerCapture[];
|
|
40
|
+
onRemoveCapture?: (capture: ComposerCapture) => void;
|
|
41
|
+
/** One outlined box holding the text and its controls, with an icon Send; absent keeps the default layout. */
|
|
42
|
+
quiet?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** The text box, then the options button and Send in one row outside it. Context and cost sit in the options sheet. */
|
|
45
|
+
export declare function Composer({ onSend, disabled, initialText, value, onChangeText, running: suppliedRunning, onAbort, mode: suppliedMode, onOpenOptions, completion: suppliedCompletion, draftStore, sessionId, live, searchFiles, uploadAttachment, slotProps, captures, onRemoveCapture, quiet }: ComposerProps): string | number | bigint | boolean | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | null | undefined;
|
|
46
|
+
//#endregion
|
|
47
|
+
//# sourceMappingURL=Composer.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Composer.d.mts","names":[],"sources":["../../src/components/Composer.tsx"],"mappings":";;;;iBAiDiB;;EAEf,SAAS;EACT;EACA;;EAEA;EACA,gBAAgB;EAChB,aAAa,MAAM;EACnB;;EAEA;EACA,eAAe,kBAAkB;;EAEjC,oBACE,mBACA;IAAQ;IAAc;IAAkB,OAAO,WAAW;QACvD;IAAU;IAAc;IAAkB;;;EAE/C;EACA;;EAEA;EACA;;EAEA,aAAa;;EAEb,YAAY;;EAEZ,oBAAoB;EACpB,mBAAmB,SAAS;;EAE5B;;;wBAkBc,WACd,QACA,UACA,aACA,OACA,cACA,SAAS,iBACT,SACA,MAAM,cACN,eACA,YAAY,oBACZ,YACA,WACA,MACA,aACA,kBACA,WACA,UACA,iBACA,SACC,qEAAa,IAAA,UAAA,yBAAA,aAAA,6DAAA,8BAAA,+CAAA,8BAAA,yBAAA"}
|