@hanzo/studio 0.1.11 → 0.1.13
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/lib/app/director.d.ts +4 -7
- package/lib/app/director.js +278 -345
- package/lib/app/flow-run.d.ts +34 -0
- package/lib/app/flow-run.js +77 -0
- package/lib/app/flow.d.ts +5 -5
- package/lib/app/flow.js +577 -312
- package/lib/app/sections.d.ts +5 -0
- package/lib/app/sections.js +26 -0
- package/lib/attach.d.ts +2 -0
- package/lib/attach.js +7 -0
- package/lib/desk.d.ts +1 -1
- package/lib/desk.js +370 -14
- package/lib/download.d.ts +2 -0
- package/lib/download.js +11 -0
- package/lib/gpu.d.ts +13 -1
- package/lib/gpu.js +39 -16
- package/lib/handoff.d.ts +2 -0
- package/lib/handoff.js +2 -0
- package/lib/home.js +97 -8
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/kinds/image.d.ts +1 -1
- package/lib/kinds/image.js +3 -3
- package/lib/kinds/video.js +1 -1
- package/lib/places.js +184 -30
- package/lib/route.d.ts +6 -0
- package/lib/route.js +6 -0
- package/lib/talk.js +98 -33
- package/lib/ui.d.ts +18 -4
- package/lib/ui.js +50 -22
- package/lib/wire.d.ts +17 -0
- package/lib/wire.js +20 -0
- package/package.json +1 -1
package/lib/home.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
3
|
* Under the composer while a conversation is empty: the category pills, the
|
|
4
4
|
* starters that can run right now, and the last conversations. A starter
|
|
@@ -6,7 +6,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
* picture puts its words in the composer and asks for the picture.
|
|
7
7
|
*/
|
|
8
8
|
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
9
|
-
import { ArrowRight, Clapperboard, FileText, Image as ImageIcon, Music, Sparkles } from '@hanzogui/lucide-icons-2';
|
|
9
|
+
import { ArrowRight, ChevronDown, Clapperboard, FileText, Image as ImageIcon, Music, Sparkles, Upload } from '@hanzogui/lucide-icons-2';
|
|
10
|
+
import { DropdownMenu } from '@hanzo/ui';
|
|
10
11
|
import { useState } from 'react';
|
|
11
12
|
import { useHost } from './host.js';
|
|
12
13
|
import { kind } from './kinds/index.js';
|
|
@@ -15,22 +16,110 @@ import { PRESETS } from './kinds/type/system.js';
|
|
|
15
16
|
import { useChats, useWire } from './live.js';
|
|
16
17
|
import { path } from './route.js';
|
|
17
18
|
import { CATEGORIES, RUNTIME, STARTERS } from './starters.js';
|
|
18
|
-
import { Pill } from './ui.js';
|
|
19
|
+
import { Pill, RING, RING_INSET } from './ui.js';
|
|
19
20
|
import { useUrl } from './use.js';
|
|
21
|
+
const UPLOAD_ACTIONS = [
|
|
22
|
+
{
|
|
23
|
+
id: 'audio',
|
|
24
|
+
shortLabel: 'Audio',
|
|
25
|
+
label: 'Upload audio track',
|
|
26
|
+
description: 'Build a music player & 60fps visualizer app',
|
|
27
|
+
accept: 'audio/*,.mp3,.wav,.flac,.m4a,.ogg,.aac',
|
|
28
|
+
prompt: 'Build a full-blown interactive music player and 60fps audio visualizer app with EQ, waveform scrubber, and live synth pads around this track.',
|
|
29
|
+
kind: 'app',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'image',
|
|
33
|
+
shortLabel: 'Image',
|
|
34
|
+
label: 'Upload image',
|
|
35
|
+
description: 'Create a poster, ad campaign, or visual',
|
|
36
|
+
accept: 'image/*,.png,.jpg,.jpeg,.webp,.svg',
|
|
37
|
+
prompt: 'Create a brand poster, multi-format ad campaign, and presentation slide deck featuring this visual.',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'document',
|
|
41
|
+
shortLabel: 'Document',
|
|
42
|
+
label: 'Upload doc or data',
|
|
43
|
+
description: 'Turn into presentation slides & styled PDF',
|
|
44
|
+
accept: '.pdf,.docx,.pptx,.xlsx,.csv,.json,.txt,.md',
|
|
45
|
+
prompt: 'Turn this document into an executive presentation slide deck and styled PDF report.',
|
|
46
|
+
kind: 'slides',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: 'video',
|
|
50
|
+
shortLabel: 'Video',
|
|
51
|
+
label: 'Upload media',
|
|
52
|
+
description: 'Create a motion video clip & social ad cut',
|
|
53
|
+
accept: 'video/*,.mp4,.webm,.mov,image/*',
|
|
54
|
+
prompt: 'Create a motion video clip and social ad cut from this media.',
|
|
55
|
+
kind: 'video',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 'any',
|
|
59
|
+
shortLabel: 'Any file',
|
|
60
|
+
label: 'Upload any file',
|
|
61
|
+
description: 'Build an interactive creative app around it',
|
|
62
|
+
prompt: 'Build an interactive creative app around this uploaded file.',
|
|
63
|
+
kind: 'app',
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
function uploadIcon(id) {
|
|
67
|
+
switch (id) {
|
|
68
|
+
case 'audio':
|
|
69
|
+
return _jsx(Music, { size: 13, color: "$soft" });
|
|
70
|
+
case 'image':
|
|
71
|
+
return _jsx(ImageIcon, { size: 13, color: "$soft" });
|
|
72
|
+
case 'document':
|
|
73
|
+
return _jsx(FileText, { size: 13, color: "$soft" });
|
|
74
|
+
case 'video':
|
|
75
|
+
return _jsx(Clapperboard, { size: 13, color: "$soft" });
|
|
76
|
+
default:
|
|
77
|
+
return _jsx(Sparkles, { size: 13, color: "$soft" });
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const PRIMARY_CATEGORIES = ['all', 'image', 'poster', 'video', 'document', 'audio'];
|
|
20
81
|
export function Home({ available, onStart, onUpload, }) {
|
|
21
82
|
const [cat, setCat] = useState('all');
|
|
83
|
+
const [moreExpanded, setMoreExpanded] = useState(false);
|
|
22
84
|
const runs = STARTERS.filter((s) => !kind(s.kind).needs(available));
|
|
23
85
|
const shown = runs.filter((s) => cat === 'all' || s.category === cat);
|
|
24
86
|
const cats = CATEGORIES.filter((c) => c.id === 'all' || runs.some((s) => s.category === c.id));
|
|
25
|
-
|
|
87
|
+
const primaryCats = PRIMARY_CATEGORIES.map((id) => cats.find((c) => c.id === id)).filter((c) => Boolean(c));
|
|
88
|
+
const moreCats = cats.filter((c) => !PRIMARY_CATEGORIES.includes(c.id));
|
|
89
|
+
const activeMore = moreCats.find((c) => c.id === cat) ?? null;
|
|
90
|
+
const uploadItems = onUpload
|
|
91
|
+
? UPLOAD_ACTIONS.map((a) => ({
|
|
92
|
+
key: a.id,
|
|
93
|
+
label: a.label,
|
|
94
|
+
description: a.description,
|
|
95
|
+
icon: uploadIcon(a.id),
|
|
96
|
+
onSelect: () => onUpload(a.accept, a.prompt, a.kind),
|
|
97
|
+
}))
|
|
98
|
+
: [];
|
|
99
|
+
return (_jsxs(YStack, { "data-slot": "studio-home", width: "100%", maxW: 1040, minW: 0, mx: "auto", gap: "$4", pt: "$1", pb: "$2", px: "$1", $md: { px: '$2' }, children: [_jsx(XStack, { role: "toolbar", "aria-label": "Categories", width: "100%", minW: 0, overflowX: moreExpanded ? 'visible' : 'auto', flexWrap: moreExpanded ? 'wrap' : 'nowrap', py: "$1", style: { scrollbarWidth: 'none' }, children: _jsxs(XStack, { flexWrap: moreExpanded ? 'wrap' : 'nowrap', justify: "center", items: "center", gap: "$3", mx: "auto", px: "$1", shrink: moreExpanded ? 1 : 0, children: [onUpload ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenu, { minWidth: 268, trigger: _jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-label": "Upload a file to create from", items: "center", gap: "$1.5", px: "$3", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 32, height: 32 }, rounded: 999, borderWidth: 1, borderColor: "var(--border-strong)", bg: "var(--surface-card-emphasis)", cursor: "pointer", hoverStyle: { bg: '$hover', borderColor: 'var(--border-strong)' }, focusVisibleStyle: RING, shrink: 0, children: [_jsx(Upload, { size: 13, color: "$ink" }), _jsx(SizableText, { size: "$2", fontWeight: "500", color: "$ink", whiteSpace: "nowrap", children: "Upload" }), _jsx(ChevronDown, { size: 12, color: "$soft" })] }), items: uploadItems }), _jsx(XStack, { width: 1, height: 16, bg: "var(--border)", shrink: 0 })] })) : null, primaryCats.map((c) => {
|
|
100
|
+
const count = c.id === 'all' ? runs.length : runs.filter((s) => s.category === c.id).length;
|
|
101
|
+
return (_jsx(Pill, { label: c.label, on: cat === c.id, count: cat === c.id ? count : undefined, onPress: () => setCat(c.id), children: c.label }, c.id));
|
|
102
|
+
}), moreExpanded
|
|
103
|
+
? moreCats.map((c) => {
|
|
104
|
+
const count = runs.filter((s) => s.category === c.id).length;
|
|
105
|
+
return (_jsx(Pill, { label: c.label, on: cat === c.id, count: cat === c.id ? count : undefined, onPress: () => setCat(c.id), children: c.label }, c.id));
|
|
106
|
+
})
|
|
107
|
+
: activeMore
|
|
108
|
+
? (_jsx(Pill, { label: activeMore.label, on: true, count: runs.filter((s) => s.category === activeMore.id).length, onPress: () => setCat(activeMore.id), children: activeMore.label }, activeMore.id))
|
|
109
|
+
: null, moreCats.length ? (_jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-label": moreExpanded ? 'Show fewer categories' : 'Show more categories', "aria-expanded": moreExpanded, onClick: () => setMoreExpanded((v) => !v), items: "center", justify: "center", gap: "$1", px: "$3", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 32, height: 32 }, rounded: 999, borderWidth: 1, borderColor: moreExpanded ? 'var(--border-strong)' : 'var(--border)', bg: moreExpanded ? '$hover' : 'transparent', cursor: "pointer", hoverStyle: { bg: '$hover', borderColor: 'var(--border-strong)' }, focusVisibleStyle: RING, shrink: 0, children: [_jsx(SizableText, { size: "$2", fontWeight: "500", color: "$ink", whiteSpace: "nowrap", children: moreExpanded ? 'Less' : 'More' }), _jsx("span", { "aria-hidden": true, style: {
|
|
110
|
+
display: 'inline-flex',
|
|
111
|
+
alignItems: 'center',
|
|
112
|
+
transform: moreExpanded ? 'rotate(180deg)' : 'none',
|
|
113
|
+
transition: 'transform 150ms ease',
|
|
114
|
+
}, children: _jsx(ChevronDown, { size: 12, color: "$soft" }) })] })) : null] }) }), _jsx(XStack, { role: "list", "aria-label": "Starters", flexWrap: "nowrap", overflowX: "auto", gap: "$4", width: "100%", minW: 0, pb: "$1", style: { scrollbarWidth: 'none', scrollSnapType: 'x proximity' }, children: shown.map((s, i) => (_jsx(Card, { s: s, i: i, onPress: () => onStart(s) }, s.id))) }), _jsx(Recent, {})] }));
|
|
26
115
|
}
|
|
27
|
-
/** A starter's card: 4:
|
|
116
|
+
/** A starter's card: 4:3, its picture, or its title set in type; its words under it. */
|
|
28
117
|
function Card({ s, i, onPress }) {
|
|
29
118
|
const k = kind(s.kind);
|
|
30
119
|
const Icon = k.icon;
|
|
31
120
|
const look = PRESETS[i % PRESETS.length];
|
|
32
121
|
use(look.display);
|
|
33
|
-
return (_jsxs(YStack, { role: "listitem", width: "calc(50% -
|
|
122
|
+
return (_jsxs(YStack, { role: "listitem", shrink: 0, width: "calc(50% - 8px)", minW: 156, $md: { width: 'calc(33.333% - 11px)', minW: 0 }, $lg: { width: 'calc(25% - 12px)', minW: 0 }, gap: "$2", style: { scrollSnapAlign: 'start' }, children: [_jsxs(YStack, { position: "relative", width: "100%", rounded: 14, overflow: "hidden", borderWidth: 1, borderColor: "var(--border)", bg: "var(--surface-card)", style: { aspectRatio: '4 / 3' }, children: [s.thumb ? (_jsx("img", { src: s.thumb, alt: "", style: { position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover' } })) : (_jsxs("div", { "aria-hidden": true, style: { position: 'absolute', inset: 0, background: look.colors.paper, color: look.colors.ink, padding: '12% 10%', display: 'flex', flexDirection: 'column', justifyContent: 'flex-end', textAlign: 'left' }, children: [_jsx("div", { style: { width: '28%', height: 3, background: look.colors.accent, marginBottom: 8 } }), _jsx("div", { style: { fontFamily: stack(look.display), fontWeight: look.weights.display, fontSize: 'clamp(16px, 2vw, 24px)', lineHeight: look.leading.display, letterSpacing: `${look.tracking.display}em` }, children: s.title })] })), _jsxs(XStack, { "aria-hidden": true, position: "absolute", t: 8, l: 8, r: 8, justify: "space-between", items: "center", children: [_jsx(XStack, { width: 26, height: 26, rounded: 99, bg: "var(--surface-header)", borderWidth: 1, borderColor: "var(--border-strong)", boxShadow: "0 1px 4px rgba(0, 0, 0, 0.24)", items: "center", justify: "center", style: { border: '1px solid var(--border-strong)', color: 'var(--foreground)' }, "$platform-web": { color: 'var(--foreground)' }, children: _jsx(Icon, { size: 13 }) }), _jsx(XStack, { px: "$2", height: 22, rounded: 99, bg: "var(--surface-header)", borderWidth: 1, borderColor: "var(--border-strong)", boxShadow: "0 1px 4px rgba(0, 0, 0, 0.24)", style: { border: '1px solid var(--border-strong)' }, items: "center", children: _jsx(SizableText, { size: "$1", fontFamily: "$mono", fontWeight: "600", color: "$ink", children: RUNTIME[s.kind] }) })] }), _jsx(YStack, { render: _jsx("button", { type: "button" }), "aria-label": `${s.title}: ${s.subtitle}`, onClick: onPress, position: "absolute", t: 0, l: 0, r: 0, b: 0, rounded: 14, cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING_INSET })] }), _jsxs(YStack, { gap: 3, px: "$0.5", minW: 0, children: [_jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", lineHeight: 19, numberOfLines: 1, children: s.title }), _jsx(SizableText, { size: "$1", color: "$soft", lineHeight: 16, numberOfLines: 1, children: s.subtitle })] })] }));
|
|
34
123
|
}
|
|
35
124
|
const STATE = { making: 'Making', done: 'Done', failed: 'Failed' };
|
|
36
125
|
/** The last eight conversations, each with what it is doing now. */
|
|
@@ -40,9 +129,9 @@ function Recent() {
|
|
|
40
129
|
const { rows } = useChats(wire);
|
|
41
130
|
if (!rows.length)
|
|
42
131
|
return null;
|
|
43
|
-
return (_jsxs(YStack, { gap: "$2", pt: "$2", children: [_jsxs(XStack, { items: "center", justify: "space-between", children: [_jsx(SizableText, { size: "$3", fontWeight: "600", children: "Recent" }), _jsxs(XStack, { render: "button", "aria-label": "Open the library",
|
|
132
|
+
return (_jsxs(YStack, { gap: "$2", pt: "$2", minW: 0, children: [_jsxs(XStack, { items: "center", justify: "space-between", children: [_jsx(SizableText, { size: "$3", fontWeight: "600", color: "$ink", children: "Recent" }), _jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-label": "Open the library", onClick: () => host.go(path({ kind: 'library' })), items: "center", gap: "$1", cursor: "pointer", px: "$2.5", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 28, height: 28 }, rounded: "$3", borderWidth: 1, borderColor: "transparent", hoverStyle: { bg: '$hover', borderColor: 'var(--border-strong)' }, focusVisibleStyle: RING, children: [_jsx(SizableText, { size: "$2", color: "$soft", children: "Library" }), _jsx(ArrowRight, { size: 13, color: "$soft" })] })] }), _jsx(XStack, { role: "list", "aria-label": "Recent conversations", gap: "$3", overflowX: "auto", pb: "$1", width: "100%", style: { scrollbarWidth: 'none' }, children: rows.slice(0, 8).map((r) => (_jsx(YStack, { role: "listitem", width: 152, shrink: 0, children: _jsxs(YStack, { render: _jsx("button", { type: "button" }), "aria-label": `${r.title}, ${STATE[r.state]}`, onClick: () => host.go(path({ kind: 'chat', id: r.id })), width: "100%", gap: "$1.5", items: "flex-start", cursor: "pointer", rounded: "$3", focusVisibleStyle: RING, children: [_jsx(Cover, { wire: wire, cover: r.cover }), _jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", text: "left", numberOfLines: 1, children: r.title }), _jsxs(XStack, { items: "center", gap: "$1.5", children: [_jsx(XStack, { width: 6, height: 6, rounded: 6, bg: r.state === 'failed' ? 'var(--state-error)' : r.state === 'done' ? 'var(--state-success)' : '$ink' }), _jsx(SizableText, { size: "$1", color: "$soft", children: `${STATE[r.state]} · ${r.count} made` })] })] }) }, r.id))) })] }));
|
|
44
133
|
}
|
|
45
134
|
function Cover({ wire, cover }) {
|
|
46
135
|
const { src } = useUrl(wire, cover);
|
|
47
|
-
return src ? (_jsx("img", { src: src, alt: "", width:
|
|
136
|
+
return src ? (_jsx("img", { src: src, alt: "", width: 152, height: 114, style: { borderRadius: 12, objectFit: 'cover', width: 152, height: 114 } })) : (_jsx(YStack, { width: 152, height: 114, rounded: 12, bg: "var(--surface-card)", borderWidth: 1, borderColor: "var(--border)" }));
|
|
48
137
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -14,5 +14,6 @@ export { nav, NEW, type Group } from './nav.tsx';
|
|
|
14
14
|
export { path, route, type Route } from './route.ts';
|
|
15
15
|
export { starters, type Offer } from './starters.ts';
|
|
16
16
|
export { useRecent } from './live.ts';
|
|
17
|
+
export { HANDOFF_CHAT } from './handoff.ts';
|
|
17
18
|
export type { Listed } from './chat/store.ts';
|
|
18
19
|
export type { Host } from '@hanzo/build';
|
package/lib/index.js
CHANGED
package/lib/kinds/image.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare const ZEN = "zen-image";
|
|
|
25
25
|
export declare const ASPECTS: readonly ['1:1', '4:5', '3:4', '2:3', '9:16', '16:9', '3:2', '4:3', '21:9'];
|
|
26
26
|
/** Which lane a request takes: the one asked for, else Zen Image on a GPU that can run it, else the gateway. */
|
|
27
27
|
export declare function lane(model: string, fleet: Fleet | null): string;
|
|
28
|
-
/** Which lane an edit takes: the one asked for, else
|
|
28
|
+
/** Which lane an edit takes: the one asked for, else Iro Edit on a GPU that can run it, else the gateway. */
|
|
29
29
|
export declare function editing(model: string, fleet: Fleet | null): string;
|
|
30
30
|
/** What a person reads when the gateway draws no picture: never a model, a provider or the plumbing between. */
|
|
31
31
|
export declare const UNDRAWN = "Couldn't draw the picture this time.";
|
package/lib/kinds/image.js
CHANGED
|
@@ -48,14 +48,14 @@ export function lane(model, fleet) {
|
|
|
48
48
|
return model;
|
|
49
49
|
return lit(fleet, 'image.zen') ? ZEN : MODELS[0].id;
|
|
50
50
|
}
|
|
51
|
-
/** Which lane an edit takes: the one asked for, else
|
|
51
|
+
/** Which lane an edit takes: the one asked for, else Iro Edit on a GPU that can run it, else the gateway. */
|
|
52
52
|
export function editing(model, fleet) {
|
|
53
53
|
if (MODELS.some((m) => m.id === model))
|
|
54
54
|
return model;
|
|
55
55
|
if (lit(fleet, 'edit.qwen'))
|
|
56
56
|
return ZEN;
|
|
57
57
|
if (model === ZEN)
|
|
58
|
-
throw new Error('Editing on your GPU needs one that runs
|
|
58
|
+
throw new Error('Editing on your GPU needs one that runs Iro Edit; connect it with hanzo link, or edit with a gateway model.');
|
|
59
59
|
return MODELS[0].id;
|
|
60
60
|
}
|
|
61
61
|
async function size(blob) {
|
|
@@ -132,7 +132,7 @@ export async function picture(w, o) {
|
|
|
132
132
|
for (const g of got)
|
|
133
133
|
files.push(await w.keep(`edit-${files.length + 1}.png`, g.blob, await size(g.blob)));
|
|
134
134
|
}
|
|
135
|
-
return { files, by: '
|
|
135
|
+
return { files, by: 'Iro Edit (your GPU)' };
|
|
136
136
|
}
|
|
137
137
|
if (use === ZEN) {
|
|
138
138
|
const [width, height] = PIXELS[o.aspect] ?? PIXELS['1:1'];
|
package/lib/kinds/video.js
CHANGED
|
@@ -179,7 +179,7 @@ export const video = {
|
|
|
179
179
|
const upload = from ? await stage(w.wire, await read(w.wire, from.key), 'start.png') : undefined;
|
|
180
180
|
const got = await render(w.wire, 'video', { prompt, width, height, length: frames(Math.min(seconds, 5)), upload }, w.doing, w.signal);
|
|
181
181
|
blob = got[0].blob;
|
|
182
|
-
by = '
|
|
182
|
+
by = 'Koma 2.0 (your GPU)';
|
|
183
183
|
}
|
|
184
184
|
catch {
|
|
185
185
|
blob = null;
|
package/lib/places.js
CHANGED
|
@@ -5,17 +5,19 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
5
5
|
* or rendering now).
|
|
6
6
|
*/
|
|
7
7
|
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
8
|
-
import { Download, Search, Trash2 } from '@hanzogui/lucide-icons-2';
|
|
9
|
-
import {
|
|
8
|
+
import { ChevronDown, Download, Search, Trash2, X } from '@hanzogui/lucide-icons-2';
|
|
9
|
+
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, DropdownMenu, } from '@hanzo/ui';
|
|
10
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
10
11
|
import { useHost } from './host.js';
|
|
11
12
|
import { ALL, kind } from './kinds/index.js';
|
|
12
13
|
import { useAvailable, useChats, useLibrary, useWire } from './live.js';
|
|
13
14
|
import { path } from './route.js';
|
|
14
15
|
import { CATEGORIES, queue, RUNTIME, STARTERS } from './starters.js';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
16
|
+
import { download } from './download.js';
|
|
17
|
+
import { Act, Pill, RING, RING_INSET } from './ui.js';
|
|
18
|
+
import { ask, discard, fileAt, shelf } from './wire.js';
|
|
17
19
|
function Page({ title, children, right }) {
|
|
18
|
-
return (_jsx(YStack, { flex: 1, minH: 0, overflow: "scroll", bg: "var(--pane-fill, var(--sheet-1))", rounded: "var(--pane-round, var(--radius-xl))", borderWidth: 1, borderColor: "var(--pane-edge, var(--
|
|
20
|
+
return (_jsx(YStack, { flex: 1, minH: 0, overflow: "scroll", bg: "var(--pane-fill, var(--sheet-1))", rounded: "var(--pane-round, var(--radius-xl))", borderWidth: 1, borderColor: "var(--pane-edge, var(--border))", children: _jsxs(YStack, { width: "100%", maxW: 1160, mx: "auto", p: "$4", gap: "$4", children: [_jsxs(XStack, { items: "center", gap: "$3", flexWrap: "wrap", children: [_jsx(SizableText, { render: "h1", size: "$7", fontWeight: "600", color: "$ink", flex: 1, letterSpacing: -0.6, children: title }), right] }), children] }) }));
|
|
19
21
|
}
|
|
20
22
|
/* ----------------------------------------------------------------- library */
|
|
21
23
|
/** The Studio kind whose mark a Library kind wears. */
|
|
@@ -27,49 +29,201 @@ export function Library() {
|
|
|
27
29
|
const [error, setError] = useState('');
|
|
28
30
|
const [only, setOnly] = useState('all');
|
|
29
31
|
const [q, setQ] = useState('');
|
|
32
|
+
const [pendingDelete, setPendingDelete] = useState(null);
|
|
33
|
+
const [deleting, setDeleting] = useState(false);
|
|
30
34
|
useLibrary(wire);
|
|
31
|
-
const reload = () => {
|
|
35
|
+
const reload = useCallback(() => {
|
|
32
36
|
setError('');
|
|
33
37
|
shelf(wire).then(setItems, (e) => setError(e instanceof Error ? e.message : String(e)));
|
|
34
|
-
};
|
|
35
|
-
useEffect(reload, [
|
|
38
|
+
}, [wire]);
|
|
39
|
+
useEffect(reload, [reload]);
|
|
36
40
|
const kinds = useMemo(() => [...new Set((items ?? []).map((i) => i.kind))], [items]);
|
|
37
41
|
const shown = (items ?? []).filter((i) => (only === 'all' || i.kind === only) && (!q || i.name.toLowerCase().includes(q.toLowerCase())));
|
|
38
|
-
|
|
42
|
+
const confirmDelete = () => {
|
|
43
|
+
if (!pendingDelete || deleting)
|
|
44
|
+
return;
|
|
45
|
+
const target = pendingDelete;
|
|
46
|
+
setDeleting(true);
|
|
47
|
+
void discard(wire, target.id)
|
|
48
|
+
.then(() => {
|
|
49
|
+
setPendingDelete(null);
|
|
50
|
+
reload();
|
|
51
|
+
})
|
|
52
|
+
.catch((e) => {
|
|
53
|
+
setError(e instanceof Error ? e.message : String(e));
|
|
54
|
+
setPendingDelete(null);
|
|
55
|
+
})
|
|
56
|
+
.finally(() => setDeleting(false));
|
|
57
|
+
};
|
|
58
|
+
return (_jsxs(Page, { title: "Library", right: _jsxs(XStack, { items: "center", gap: "$2", minH: 44, $md: { minH: 34, height: 34 }, px: "$3", rounded: 999, borderWidth: 1, borderColor: "var(--border-strong)", bg: "var(--background)", minW: 220, children: [_jsx(Search, { size: 14, color: "$soft" }), _jsx("input", { "aria-label": "Search the library", placeholder: "Search", value: q, onChange: (e) => setQ(e.currentTarget.value), style: { flex: 1, minWidth: 0, border: 0, background: 'transparent', color: 'var(--foreground)', font: 'inherit', outline: 'none' } }), q ? (_jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-label": "Clear search", onClick: () => setQ(''), width: 22, height: 22, "$max-sm": { minW: 44, minH: 44 }, rounded: 99, items: "center", justify: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: _jsx(X, { size: 12, color: "$soft" }) })) : null] }), children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", flexWrap: "wrap", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: "Saved to your Library, private to you until you share it." }), items ? (_jsx(SizableText, { size: "$1", fontFamily: "$mono", color: "$soft", children: `${shown.length} of ${items.length} ${items.length === 1 ? 'item' : 'items'}` })) : null] }), _jsxs(XStack, { gap: "$2", flexWrap: "wrap", role: "toolbar", "aria-label": "Kinds", children: [_jsx(Pill, { label: "All", on: only === 'all', count: only === 'all' && items ? items.length : undefined, onPress: () => setOnly('all'), children: "All" }), kinds.map((k) => {
|
|
59
|
+
const label = MARK[k] ? kind(MARK[k]).label : k;
|
|
60
|
+
const count = (items ?? []).filter((i) => i.kind === k).length;
|
|
61
|
+
return (_jsx(Pill, { label: label, on: only === k, count: only === k ? count : undefined, onPress: () => setOnly(k), children: label }, k));
|
|
62
|
+
})] }), error ? _jsx(SizableText, { color: "var(--state-error)", children: error }) : null, items === null && !error ? _jsx(SizableText, { color: "$soft", children: "Reading\u2026" }) : null, items && !shown.length ? _jsx(SizableText, { color: "$soft", children: items.length ? 'Nothing matches.' : 'Nothing made yet. Start on the home page.' }) : null, _jsx(XStack, { flexWrap: "wrap", gap: 12, role: "list", "aria-label": "Made", children: shown.map((i) => (_jsx(Thing, { item: i, deleting: deleting && pendingDelete?.id === i.id, onOpen: () => host.go(path({ kind: 'chat', id: i.ref })), onRequestDelete: () => setPendingDelete(i) }, i.id))) }), _jsx(AlertDialog, { open: Boolean(pendingDelete), onOpenChange: (open) => {
|
|
63
|
+
if (!open && !deleting)
|
|
64
|
+
setPendingDelete(null);
|
|
65
|
+
}, children: _jsxs(AlertDialogContent, { borderColor: "var(--border-strong)", maxW: 420, children: [_jsxs(AlertDialogHeader, { children: [_jsx(AlertDialogTitle, { children: "Delete from Library?" }), _jsx(AlertDialogDescription, { children: pendingDelete
|
|
66
|
+
? `Delete “${pendingDelete.name.replace(/\.[a-z0-9.]+$/i, '').replace(/-/g, ' ')}” from your Library? Its conversation keeps the record.`
|
|
67
|
+
: '' })] }), _jsxs(AlertDialogFooter, { children: [_jsx(AlertDialogCancel, { disabled: deleting, borderColor: "var(--border-strong)", onPress: () => setPendingDelete(null), children: "Cancel" }), _jsx(AlertDialogAction, { variant: "destructive", bg: "var(--state-error)", disabled: deleting, onPress: confirmDelete, children: deleting ? 'Deleting…' : 'Delete' })] })] }) })] }));
|
|
39
68
|
}
|
|
40
|
-
function Thing({
|
|
69
|
+
function Thing({ item, deleting, onOpen, onRequestDelete, }) {
|
|
41
70
|
const Icon = kind(MARK[item.kind] ?? 'image').icon;
|
|
42
71
|
const pic = item.mime.startsWith('image/') ? item.url : '';
|
|
43
|
-
const [busy, setBusy] = useState(false);
|
|
44
72
|
const name = item.name;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
73
|
+
const [downloadError, setDownloadError] = useState('');
|
|
74
|
+
const handleDownload = () => {
|
|
75
|
+
const href = item.download || item.url;
|
|
76
|
+
if (!href) {
|
|
77
|
+
setDownloadError('Download unavailable for this file.');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
setDownloadError('');
|
|
81
|
+
void fileAt(href)
|
|
82
|
+
.then((b) => download(name, b))
|
|
83
|
+
.catch((e) => {
|
|
84
|
+
setDownloadError(e instanceof Error ? e.message : 'Download failed.');
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
return (_jsxs(YStack, { role: "listitem", width: "calc(50% - 6px)", $sm: { width: 'calc(25% - 9px)' }, gap: "$1.5", children: [_jsxs(YStack, { render: _jsx("button", { type: "button" }), "aria-label": `Open ${name} in its conversation`, onClick: onOpen, rounded: 16, overflow: "hidden", bg: "var(--surface-card)", borderWidth: 1, borderColor: "var(--border)", cursor: "pointer", style: { aspectRatio: '4 / 5' }, items: "center", justify: "center", position: "relative", focusVisibleStyle: RING_INSET, children: [pic ? (_jsx("img", { src: pic, alt: "", style: { position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover' } })) : (_jsx(XStack, { "$platform-web": { color: 'var(--muted-foreground)' }, children: _jsx(Icon, { size: 28 }) })), _jsx(XStack, { "aria-hidden": true, position: "absolute", t: 8, l: 8, width: 26, height: 26, rounded: 99, bg: "var(--surface-header)", borderWidth: 1, borderColor: "var(--border)", items: "center", justify: "center", "$platform-web": { color: 'var(--foreground)' }, children: _jsx(Icon, { size: 13 }) })] }), _jsxs(XStack, { items: "center", gap: "$1", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", numberOfLines: 1, flex: 1, children: name.replace(/\.[a-z0-9.]+$/i, '').replace(/-/g, ' ') }), _jsx(Act, { label: `Download ${name}`, onPress: handleDownload, children: _jsx(Download, { size: 13, color: "$ink" }) }), _jsx(Act, { label: `Delete ${name}`, disabled: deleting, onPress: onRequestDelete, children: _jsx(Trash2, { size: 13, color: "$ink" }) })] }), _jsx(SizableText, { size: "$1", color: "$soft", children: `${MARK[item.kind] ? kind(MARK[item.kind]).label : item.kind} · ${new Date(item.created).toLocaleDateString()}` }), downloadError ? (_jsx(SizableText, { role: "alert", size: "$1", color: "var(--state-error)", numberOfLines: 2, children: downloadError })) : null] }));
|
|
53
88
|
}
|
|
54
89
|
/* ----------------------------------------------------------------- explore */
|
|
90
|
+
const EXPLORE_PRIMARY_CATS = ['all', 'image', 'poster', 'video', 'document', 'audio'];
|
|
55
91
|
export function Explore() {
|
|
56
92
|
const host = useHost();
|
|
57
93
|
const wire = useWire(host);
|
|
58
94
|
const available = useAvailable(wire);
|
|
59
|
-
|
|
60
|
-
|
|
95
|
+
const [cat, setCat] = useState('all');
|
|
96
|
+
const [q, setQ] = useState('');
|
|
97
|
+
const cardRefs = useRef(new Map());
|
|
98
|
+
const normalizedQuery = q.trim().toLowerCase();
|
|
99
|
+
const filteredStarters = useMemo(() => STARTERS.filter((s) => {
|
|
100
|
+
if (cat !== 'all' && s.category !== cat)
|
|
101
|
+
return false;
|
|
102
|
+
if (!normalizedQuery)
|
|
103
|
+
return true;
|
|
104
|
+
return (s.title.toLowerCase().includes(normalizedQuery) ||
|
|
105
|
+
s.subtitle.toLowerCase().includes(normalizedQuery) ||
|
|
106
|
+
s.prompt.toLowerCase().includes(normalizedQuery));
|
|
107
|
+
}), [cat, normalizedQuery]);
|
|
108
|
+
const flatOrder = useMemo(() => {
|
|
109
|
+
const out = [];
|
|
110
|
+
for (const c of CATEGORIES) {
|
|
111
|
+
if (c.id === 'all')
|
|
112
|
+
continue;
|
|
113
|
+
for (const s of filteredStarters) {
|
|
114
|
+
if (s.category === c.id)
|
|
115
|
+
out.push(s.id);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}, [filteredStarters]);
|
|
120
|
+
const handleCardKeyDown = (id, e) => {
|
|
121
|
+
const keys = ['ArrowRight', 'ArrowLeft', 'ArrowDown', 'ArrowUp', 'Home', 'End'];
|
|
122
|
+
if (!keys.includes(e.key))
|
|
123
|
+
return;
|
|
124
|
+
const idx = flatOrder.indexOf(id);
|
|
125
|
+
if (idx === -1)
|
|
126
|
+
return;
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
if (e.key === 'Home') {
|
|
129
|
+
const firstId = flatOrder[0];
|
|
130
|
+
if (firstId)
|
|
131
|
+
cardRefs.current.get(firstId)?.focus();
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (e.key === 'End') {
|
|
135
|
+
const lastId = flatOrder[flatOrder.length - 1];
|
|
136
|
+
if (lastId)
|
|
137
|
+
cardRefs.current.get(lastId)?.focus();
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (e.key === 'ArrowRight') {
|
|
141
|
+
const nextId = flatOrder[(idx + 1) % flatOrder.length];
|
|
142
|
+
if (nextId)
|
|
143
|
+
cardRefs.current.get(nextId)?.focus();
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (e.key === 'ArrowLeft') {
|
|
147
|
+
const prevId = flatOrder[(idx - 1 + flatOrder.length) % flatOrder.length];
|
|
148
|
+
if (prevId)
|
|
149
|
+
cardRefs.current.get(prevId)?.focus();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
// Spatial row navigation for ArrowDown / ArrowUp using live bounding rects
|
|
153
|
+
const currentEl = cardRefs.current.get(id);
|
|
154
|
+
if (!currentEl)
|
|
155
|
+
return;
|
|
156
|
+
const curRect = currentEl.getBoundingClientRect();
|
|
157
|
+
const curCenterX = curRect.left + curRect.width / 2;
|
|
158
|
+
const goingDown = e.key === 'ArrowDown';
|
|
159
|
+
let bestEl = null;
|
|
160
|
+
let bestRowDelta = Number.POSITIVE_INFINITY;
|
|
161
|
+
let bestColDelta = Number.POSITIVE_INFINITY;
|
|
162
|
+
for (const otherId of flatOrder) {
|
|
163
|
+
if (otherId === id)
|
|
164
|
+
continue;
|
|
165
|
+
const el = cardRefs.current.get(otherId);
|
|
166
|
+
if (!el)
|
|
167
|
+
continue;
|
|
168
|
+
const rect = el.getBoundingClientRect();
|
|
169
|
+
const rowDelta = goingDown ? rect.top - curRect.bottom : curRect.top - rect.bottom;
|
|
170
|
+
if (rowDelta < -4)
|
|
171
|
+
continue;
|
|
172
|
+
const colDelta = Math.abs(rect.left + rect.width / 2 - curCenterX);
|
|
173
|
+
// Pick closest row band first, then closest column alignment
|
|
174
|
+
const band = Math.round(rowDelta / 32);
|
|
175
|
+
const bestBand = Math.round(bestRowDelta / 32);
|
|
176
|
+
if (band < bestBand || (band === bestBand && colDelta < bestColDelta)) {
|
|
177
|
+
bestRowDelta = rowDelta;
|
|
178
|
+
bestColDelta = colDelta;
|
|
179
|
+
bestEl = el;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (bestEl) {
|
|
183
|
+
bestEl.focus();
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
const fallback = flatOrder[goingDown ? Math.min(flatOrder.length - 1, idx + 1) : Math.max(0, idx - 1)];
|
|
187
|
+
if (fallback)
|
|
188
|
+
cardRefs.current.get(fallback)?.focus();
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
const primaryCats = EXPLORE_PRIMARY_CATS.map((id) => CATEGORIES.find((c) => c.id === id)).filter((c) => Boolean(c));
|
|
192
|
+
const moreCats = CATEGORIES.filter((c) => !EXPLORE_PRIMARY_CATS.includes(c.id));
|
|
193
|
+
const activeMore = moreCats.find((c) => c.id === cat) ?? null;
|
|
194
|
+
const moreItems = moreCats.map((c) => {
|
|
195
|
+
const count = STARTERS.filter((s) => s.category === c.id).length;
|
|
196
|
+
return {
|
|
197
|
+
key: c.id,
|
|
198
|
+
label: c.label,
|
|
199
|
+
description: `${count} ${count === 1 ? 'starter' : 'starters'}`,
|
|
200
|
+
selected: cat === c.id,
|
|
201
|
+
onSelect: () => setCat(c.id),
|
|
202
|
+
};
|
|
203
|
+
});
|
|
204
|
+
return (_jsxs(Page, { title: "Explore", right: _jsxs(XStack, { items: "center", gap: "$2", minH: 44, $md: { minH: 34, height: 34 }, px: "$3", rounded: 999, borderWidth: 1, borderColor: "var(--border-strong)", bg: "var(--background)", minW: 220, children: [_jsx(Search, { size: 14, color: "$soft" }), _jsx("input", { "aria-label": "Filter starters", placeholder: "Filter starters", value: q, onChange: (e) => setQ(e.currentTarget.value), style: { flex: 1, minWidth: 0, border: 0, background: 'transparent', color: 'var(--foreground)', font: 'inherit', outline: 'none' } }), q ? (_jsx(XStack, { render: _jsx("button", { type: "button" }), "aria-label": "Clear filter", onClick: () => setQ(''), width: 22, height: 22, "$max-sm": { minW: 44, minH: 44 }, rounded: 99, items: "center", justify: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: _jsx(X, { size: 12, color: "$soft" }) })) : null] }), children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", flexWrap: "wrap", children: [_jsxs(XStack, { role: "toolbar", "aria-label": "Explore categories", gap: "$2", overflowX: "auto", flexWrap: "nowrap", py: "$0.5", style: { scrollbarWidth: 'none' }, children: [primaryCats.map((c) => {
|
|
205
|
+
const count = c.id === 'all' ? STARTERS.length : STARTERS.filter((s) => s.category === c.id).length;
|
|
206
|
+
return (_jsx(Pill, { label: c.label, on: cat === c.id, count: cat === c.id ? count : undefined, onPress: () => setCat(c.id), children: c.label }, c.id));
|
|
207
|
+
}), moreItems.length ? (_jsx(DropdownMenu, { minWidth: 196, trigger: _jsxs(XStack, { render: _jsx("button", { type: "button" }), "aria-label": activeMore ? `${activeMore.label}, more categories` : 'More categories', "aria-pressed": Boolean(activeMore), items: "center", gap: "$1", px: "$3", minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 32, height: 32 }, rounded: 999, borderWidth: 1, borderColor: activeMore ? '$ink' : 'var(--border-strong)', bg: activeMore ? '$ink' : 'transparent', cursor: "pointer", hoverStyle: { bg: activeMore ? '$ink' : '$hover' }, focusVisibleStyle: RING, shrink: 0, children: [_jsx(SizableText, { size: "$2", fontWeight: activeMore ? '600' : '500', color: activeMore ? '$background' : '$ink', whiteSpace: "nowrap", children: activeMore ? activeMore.label : 'More' }), _jsx(ChevronDown, { size: 12, color: activeMore ? '$background' : '$soft' })] }), items: moreItems })) : null] }), _jsx(SizableText, { size: "$1", fontFamily: "$mono", color: "$soft", "aria-live": "polite", children: `${filteredStarters.length} of ${STARTERS.length} starters` })] }), !filteredStarters.length ? (_jsx(SizableText, { size: "$2", color: "$soft", children: "No starters match your filter." })) : null, CATEGORIES.filter((c) => c.id !== 'all').map((c) => {
|
|
208
|
+
const list = filteredStarters.filter((s) => s.category === c.id);
|
|
61
209
|
if (!list.length)
|
|
62
210
|
return null;
|
|
63
|
-
return (_jsxs(YStack, { gap: "$2", children: [_jsx(SizableText, { size: "$4", fontWeight: "600", children: c.label }), _jsx(XStack, { flexWrap: "wrap", gap: "$
|
|
211
|
+
return (_jsxs(YStack, { gap: "$2", children: [_jsxs(XStack, { items: "center", gap: "$2", children: [_jsx(SizableText, { size: "$4", fontWeight: "600", color: "$ink", children: c.label }), _jsx(SizableText, { size: "$1", fontFamily: "$mono", color: "$soft", children: list.length })] }), _jsx(XStack, { flexWrap: "wrap", gap: "$3", role: "list", "aria-label": c.label, children: list.map((s) => {
|
|
64
212
|
const why = kind(s.kind).needs(available);
|
|
65
|
-
return (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
213
|
+
return (_jsx(YStack, { role: "listitem", width: "100%", $sm: { width: 256 }, children: _jsxs(YStack, { ref: (node) => {
|
|
214
|
+
const el = node;
|
|
215
|
+
if (el)
|
|
216
|
+
cardRefs.current.set(s.id, el);
|
|
217
|
+
else
|
|
218
|
+
cardRefs.current.delete(s.id);
|
|
219
|
+
}, render: _jsx("button", { type: "button" }), "aria-disabled": why ? true : undefined, onKeyDown: ((e) => handleCardKeyDown(s.id, e)), onClick: () => {
|
|
220
|
+
if (why)
|
|
221
|
+
return;
|
|
222
|
+
queue(s);
|
|
223
|
+
host.go('');
|
|
224
|
+
}, width: "100%", minH: 78, p: "$3", gap: "$1.5", rounded: "$4", borderWidth: 1, borderColor: "var(--border-strong)", bg: "var(--background)", opacity: why ? 0.6 : 1, cursor: why ? 'default' : 'pointer', items: "flex-start", hoverStyle: why ? undefined : { bg: '$hover' }, focusVisibleStyle: RING, children: [_jsxs(XStack, { justify: "space-between", width: "100%", gap: "$2", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", color: "$ink", text: "left", numberOfLines: 1, flex: 1, children: s.title }), _jsx(SizableText, { size: "$1", fontFamily: "$mono", color: "$soft", shrink: 0, children: RUNTIME[s.kind] })] }), _jsx(SizableText, { size: "$1", color: "$soft", text: "left", numberOfLines: 2, children: why ? 'Needs a GPU: connect one with hanzo link.' : s.subtitle })] }) }, s.id));
|
|
71
225
|
}) })] }, c.id));
|
|
72
|
-
}), _jsxs(YStack, { gap: "$2", children: [_jsx(SizableText, { size: "$4", fontWeight: "600", children: "Kinds" }), ALL.map((k) => (_jsxs(XStack, { gap: "$3", items: "center", children: [_jsx(k.icon, { size: 15 }), _jsx(SizableText, { size: "$2", width: 120, children: k.label }), _jsx(SizableText, { size: "$2", color: "$soft", flex: 1, children: k.needs(available) ?? k.blurb })] }, k.id)))] })] }));
|
|
226
|
+
}), _jsxs(YStack, { gap: "$2", pt: "$2", borderTopWidth: 1, borderColor: "var(--border)", children: [_jsx(SizableText, { size: "$4", fontWeight: "600", color: "$ink", children: "Kinds" }), ALL.map((k) => (_jsxs(XStack, { gap: "$3", items: "center", children: [_jsx(XStack, { "$platform-web": { color: 'var(--foreground)' }, shrink: 0, children: _jsx(k.icon, { size: 15 }) }), _jsx(SizableText, { size: "$2", color: "$ink", width: 120, children: k.label }), _jsx(SizableText, { size: "$2", color: "$soft", flex: 1, children: k.needs(available) ?? k.blurb })] }, k.id)))] })] }));
|
|
73
227
|
}
|
|
74
228
|
export function Activity() {
|
|
75
229
|
const host = useHost();
|
|
@@ -89,5 +243,5 @@ export function Activity() {
|
|
|
89
243
|
};
|
|
90
244
|
}, [wire]);
|
|
91
245
|
const making = rows.filter((r) => r.state === 'making');
|
|
92
|
-
return (_jsxs(Page, { title: "Activity", children: [_jsxs(YStack, { gap: "$2", children: [_jsx(SizableText, { size: "$4", fontWeight: "600", children: "GPUs" }), _jsx(SizableText, { size: "$2", color: "$soft", children: available.fleet ? `${available.fleet.online} of ${available.fleet.total} online · ${available.fleet.state}` : available.error || 'Reading…' }), (available.fleet?.nodes ?? []).map((n) => (_jsx(SizableText, { size: "$2", children: `${n.name ?? n.identity}: ${(n.lanes ?? []).join(', ') || 'no lanes yet'}` }, n.identity)))] }), _jsxs(YStack, { gap: "$2", children: [_jsx(SizableText, { size: "$4", fontWeight: "600", children: "Rendering" }), error ? _jsx(SizableText, { color: "
|
|
246
|
+
return (_jsxs(Page, { title: "Activity", children: [_jsxs(YStack, { gap: "$2", children: [_jsx(SizableText, { size: "$4", fontWeight: "600", color: "$ink", children: "GPUs" }), _jsx(SizableText, { size: "$2", color: "$soft", children: available.fleet ? `${available.fleet.online} of ${available.fleet.total} online · ${available.fleet.state}` : available.error || 'Reading…' }), (available.fleet?.nodes ?? []).map((n) => (_jsx(SizableText, { size: "$2", color: "$ink", children: `${n.name ?? n.identity}: ${(n.lanes ?? []).join(', ') || 'no lanes yet'}` }, n.identity)))] }), _jsxs(YStack, { gap: "$2", children: [_jsx(SizableText, { size: "$4", fontWeight: "600", color: "$ink", children: "Rendering" }), error ? _jsx(SizableText, { color: "var(--state-error)", children: error }) : null, jobs && !jobs.length ? _jsx(SizableText, { color: "$soft", children: "Nothing is rendering." }) : null, (jobs ?? []).map((j) => (_jsxs(XStack, { gap: "$3", children: [_jsx(SizableText, { size: "$2", color: "$ink", width: 90, children: j.status ?? 'queued' }), _jsx(SizableText, { size: "$2", color: "$ink", flex: 1, numberOfLines: 1, children: j.prompt || j.kind || j.id }), _jsx(SizableText, { size: "$2", color: "$soft", children: j.node ?? '' })] }, j.id)))] }), _jsxs(YStack, { gap: "$2", children: [_jsx(SizableText, { size: "$4", fontWeight: "600", color: "$ink", children: "Making now" }), !making.length ? _jsx(SizableText, { color: "$soft", children: "No conversation is working." }) : null, making.map((r) => (_jsx(XStack, { render: _jsx("button", { type: "button" }), onClick: () => host.go(path({ kind: 'chat', id: r.id })), minH: 44, "$max-sm": { minH: 44 }, $md: { minH: 34 }, px: "$3", rounded: "$3", borderWidth: 1, borderColor: "var(--border-strong)", bg: "var(--background)", items: "center", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: _jsx(SizableText, { size: "$2", color: "$ink", children: r.title }) }, r.id)))] })] }));
|
|
93
247
|
}
|
package/lib/route.d.ts
CHANGED
|
@@ -43,3 +43,9 @@ export declare function starter(search: string): {
|
|
|
43
43
|
} | null;
|
|
44
44
|
/** A fresh conversation id: time-ordered, so a listing sorts by name. */
|
|
45
45
|
export declare function fresh(): string;
|
|
46
|
+
/** Whether an address is Flow's: `flow`, `flow/<section>` or the older `workflow`. */
|
|
47
|
+
export declare const inFlow: (at: string) => boolean;
|
|
48
|
+
/** Flow's own section of an address, without the `flow/` prefix. */
|
|
49
|
+
export declare const flowSection: (at: string) => string;
|
|
50
|
+
/** The address of a Flow section in the host's router: `flow/<section>`, or `flow` for none. */
|
|
51
|
+
export declare const flowAt: (section: string) => string;
|
package/lib/route.js
CHANGED
|
@@ -67,3 +67,9 @@ export function fresh() {
|
|
|
67
67
|
const r = Array.from(crypto.getRandomValues(new Uint8Array(6)), (b) => (b % 36).toString(36)).join('');
|
|
68
68
|
return `${t}${r}`;
|
|
69
69
|
}
|
|
70
|
+
/** Whether an address is Flow's: `flow`, `flow/<section>` or the older `workflow`. */
|
|
71
|
+
export const inFlow = (at) => at === 'flow' || at.startsWith('flow/') || at === 'workflow';
|
|
72
|
+
/** Flow's own section of an address, without the `flow/` prefix. */
|
|
73
|
+
export const flowSection = (at) => at.replace(/^flow\/?/, '');
|
|
74
|
+
/** The address of a Flow section in the host's router: `flow/<section>`, or `flow` for none. */
|
|
75
|
+
export const flowAt = (section) => (section ? `flow/${section.replace(/^\/+/, '')}` : 'flow');
|