@hanzo/studio 0.1.11 → 0.1.12

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/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
- return (_jsxs(YStack, { "data-slot": "studio-home", width: "100%", maxW: 1080, mx: "auto", gap: "$4", pt: "$4", pb: "$6", px: "$1", children: [onUpload ? (_jsxs(XStack, { role: "region", "aria-label": "Upload content to create", gap: "$2", flexWrap: "wrap", justify: "center", children: [_jsxs(XStack, { render: "button", onPress: () => onUpload('audio/*,.mp3,.wav,.flac,.m4a,.ogg,.aac', 'Build a full-blown interactive music player and 60fps audio visualizer app with EQ, waveform scrubber, and live synth pads around this track.', 'app'), items: "center", gap: "$2", px: "$3", height: 34, rounded: 999, borderWidth: 1, borderColor: "$borderColor", bg: "$hover", cursor: "pointer", hoverStyle: { opacity: 0.9 }, children: [_jsx(Music, { size: 14 }), _jsx(SizableText, { size: "$2", fontWeight: "600", children: "Upload Music \u2192 Build Music App" })] }), _jsxs(XStack, { render: "button", onPress: () => onUpload('image/*,.png,.jpg,.jpeg,.webp,.svg', 'Create a brand poster, multi-format ad campaign, and presentation slide deck featuring this visual.'), items: "center", gap: "$2", px: "$3", height: 34, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(ImageIcon, { size: 14 }), _jsx(SizableText, { size: "$2", children: "Upload Image \u2192 Poster, Ad or Visual" })] }), _jsxs(XStack, { render: "button", onPress: () => onUpload('.pdf,.docx,.pptx,.xlsx,.csv,.json,.txt,.md', 'Turn this document into an executive presentation slide deck and styled PDF report.', 'slides'), items: "center", gap: "$2", px: "$3", height: 34, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(FileText, { size: 14 }), _jsx(SizableText, { size: "$2", children: "Upload Doc / Data \u2192 Slides & PDF" })] }), _jsxs(XStack, { render: "button", onPress: () => onUpload('video/*,.mp4,.webm,.mov,image/*', 'Create a motion video clip and social ad cut from this media.', 'video'), items: "center", gap: "$2", px: "$3", height: 34, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(Clapperboard, { size: 14 }), _jsx(SizableText, { size: "$2", children: "Upload Media \u2192 Video & Ad" })] }), _jsxs(XStack, { render: "button", onPress: () => onUpload(undefined, 'Build an interactive creative app around this uploaded file.', 'app'), items: "center", gap: "$2", px: "$3", height: 34, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, children: [_jsx(Sparkles, { size: 14 }), _jsx(SizableText, { size: "$2", children: "Upload Any File" })] })] })) : null, _jsx(XStack, { role: "toolbar", "aria-label": "Categories", gap: "$2", flexWrap: "wrap", justify: "center", children: cats.map((c) => (_jsx(Pill, { on: cat === c.id, onPress: () => setCat(c.id), children: c.label }, c.id))) }), _jsx(XStack, { role: "list", "aria-label": "Starters", flexWrap: "wrap", gap: 12, children: shown.map((s, i) => (_jsx(Card, { s: s, i: i, onPress: () => onStart(s) }, s.id))) }), _jsx(Recent, {})] }));
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:5, its picture, or its title set in type; its words under it. */
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% - 6px)", $sm: { width: 'calc(25% - 9px)' }, gap: "$1.5", children: [_jsxs(YStack, { position: "relative", width: "100%", rounded: 16, overflow: "hidden", style: { aspectRatio: '4 / 5' }, 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: '14% 10%', display: 'flex', flexDirection: 'column', justifyContent: 'flex-end', textAlign: 'left' }, children: [_jsx("div", { style: { width: '28%', height: 4, background: look.colors.accent, marginBottom: 10 } }), _jsx("div", { style: { fontFamily: stack(look.display), fontWeight: look.weights.display, fontSize: 'clamp(18px, 2.4vw, 30px)', 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: "rgba(0,0,0,0.55)", items: "center", justify: "center", children: _jsx(Icon, { size: 13 }) }), _jsx(XStack, { px: "$2", height: 22, rounded: 99, bg: "rgba(0,0,0,0.55)", items: "center", children: _jsx(SizableText, { size: "$1", color: "#fff", children: RUNTIME[s.kind] }) })] }), _jsx(YStack, { render: "button", "aria-label": `${s.title}: ${s.subtitle}`, onPress: onPress, position: "absolute", t: 0, l: 0, r: 0, b: 0, rounded: 16, cursor: "pointer", hoverStyle: { bg: 'rgba(255,255,255,0.08)' }, focusVisibleStyle: { outlineWidth: 2, outlineStyle: 'solid', outlineColor: '$outlineColor' } })] }), _jsx(SizableText, { size: "$2", fontWeight: "600", numberOfLines: 1, children: s.title }), _jsx(SizableText, { size: "$1", color: "$soft", numberOfLines: 1, mt: -4, children: s.subtitle })] }));
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", onPress: () => host.go(path({ kind: 'library' })), items: "center", gap: "$1", cursor: "pointer", px: "$2", height: 28, rounded: "$3", hoverStyle: { bg: '$hover' }, children: [_jsx(SizableText, { size: "$2", color: "$soft", children: "Library" }), _jsx(ArrowRight, { size: 13 })] })] }), _jsx(XStack, { role: "list", "aria-label": "Recent conversations", gap: "$2", overflowX: "auto", pb: "$1", children: rows.slice(0, 8).map((r) => (_jsxs(YStack, { role: "listitem", render: "button", "aria-label": `${r.title}, ${STATE[r.state]}`, onPress: () => host.go(path({ kind: 'chat', id: r.id })), width: 148, shrink: 0, gap: "$1", cursor: "pointer", children: [_jsx(Cover, { wire: wire, cover: r.cover }), _jsx(SizableText, { size: "$2", numberOfLines: 1, children: r.title }), _jsxs(XStack, { items: "center", gap: "$1.5", children: [_jsx(XStack, { width: 6, height: 6, rounded: 6, bg: r.state === 'making' ? '$blue10' : r.state === 'failed' ? '$red10' : '$green10' }), _jsx(SizableText, { size: "$1", color: "$soft", children: `${STATE[r.state]} · ${r.count} made` })] })] }, r.id))) })] }));
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: 148, height: 110, style: { borderRadius: 12, objectFit: 'cover', width: 148, height: 110 } })) : (_jsx(YStack, { width: 148, height: 110, rounded: 12, bg: "$hover" }));
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
@@ -14,3 +14,4 @@ export { nav, NEW } from './nav.js';
14
14
  export { path, route } from './route.js';
15
15
  export { starters } from './starters.js';
16
16
  export { useRecent } from './live.js';
17
+ export { HANDOFF_CHAT } from './handoff.js';
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 { useEffect, useMemo, useState } from 'react';
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 { Act, download, Pill } from './ui.js';
16
- import { ask, discard, shelf } from './wire.js';
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(--white-08))", 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", flex: 1, children: title }), right] }), children] }) }));
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, [wire]);
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
- return (_jsxs(Page, { title: "Library", right: _jsxs(XStack, { items: "center", gap: "$2", height: 34, px: "$3", rounded: 999, borderWidth: 1, borderColor: "$borderColor", minW: 220, children: [_jsx(Search, { size: 14 }), _jsx("input", { "aria-label": "Search the library", placeholder: "Search", value: q, onChange: (e) => setQ(e.currentTarget.value), style: { flex: 1, border: 0, background: 'transparent', color: 'inherit', font: 'inherit', outline: 'none' } })] }), children: [_jsx(SizableText, { size: "$2", color: "$soft", children: "Saved to your Library, private to you until you share it." }), _jsxs(XStack, { gap: "$2", flexWrap: "wrap", role: "toolbar", "aria-label": "Kinds", children: [_jsx(Pill, { on: only === 'all', onPress: () => setOnly('all'), children: "All" }), kinds.map((k) => (_jsx(Pill, { on: only === k, onPress: () => setOnly(k), children: MARK[k] ? kind(MARK[k]).label : k }, k)))] }), error ? _jsx(SizableText, { color: "$red10", 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, { wire: wire, item: i, onOpen: () => host.go(path({ kind: 'chat', id: i.ref })), onGone: reload }, i.id))) })] }));
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({ wire, item, onOpen, onGone }) {
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
- return (_jsxs(YStack, { role: "listitem", width: "calc(50% - 6px)", $sm: { width: 'calc(25% - 9px)' }, gap: "$1.5", children: [_jsxs(YStack, { render: "button", "aria-label": `Open ${name} in its conversation`, onPress: onOpen, rounded: 16, overflow: "hidden", bg: "$hover", cursor: "pointer", style: { aspectRatio: '4 / 5' }, items: "center", justify: "center", position: "relative", children: [pic ? _jsx("img", { src: pic, alt: "", style: { position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover' } }) : _jsx(Icon, { size: 28 }), _jsx(XStack, { position: "absolute", t: 8, l: 8, width: 26, height: 26, rounded: 99, bg: "rgba(0,0,0,0.55)", items: "center", justify: "center", children: _jsx(Icon, { size: 13 }) })] }), _jsxs(XStack, { items: "center", gap: "$1", children: [_jsx(SizableText, { size: "$2", fontWeight: "600", numberOfLines: 1, flex: 1, children: name.replace(/\.[a-z0-9.]+$/i, '').replace(/-/g, ' ') }), _jsx(Act, { label: `Download ${name}`, onPress: () => void fetch(item.download || item.url, { credentials: 'omit' })
46
- .then((r) => r.blob())
47
- .then((b) => download(name, b)), children: _jsx(Download, { size: 13 }) }), _jsx(Act, { label: `Delete ${name}`, disabled: busy, onPress: () => {
48
- if (!window.confirm(`Delete ${name} from your Library? Its conversation keeps the record.`))
49
- return;
50
- setBusy(true);
51
- void discard(wire, item.id).finally(onGone);
52
- }, children: _jsx(Trash2, { size: 13 }) })] }), _jsx(SizableText, { size: "$1", color: "$soft", mt: -4, children: `${MARK[item.kind] ? kind(MARK[item.kind]).label : item.kind} · ${new Date(item.created).toLocaleDateString()}` })] }));
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
- return (_jsxs(Page, { title: "Explore", children: [CATEGORIES.filter((c) => c.id !== 'all').map((c) => {
60
- const list = STARTERS.filter((s) => s.category === c.id);
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: "$2", children: list.map((s) => {
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 (_jsxs(YStack, { render: "button", "aria-disabled": why ? true : undefined, onPress: () => {
66
- if (why)
67
- return;
68
- queue(s);
69
- host.go('');
70
- }, width: 250, p: "$3", gap: "$1", rounded: "$4", borderWidth: 1, borderColor: "$borderColor", opacity: why ? 0.6 : 1, cursor: why ? 'default' : 'pointer', hoverStyle: why ? undefined : { bg: '$hover' }, children: [_jsxs(XStack, { justify: "space-between", children: [_jsx(SizableText, { size: "$3", fontWeight: "600", numberOfLines: 1, children: s.title }), _jsx(SizableText, { size: "$1", color: "$soft", children: RUNTIME[s.kind] })] }), _jsx(SizableText, { size: "$2", color: "$soft", numberOfLines: 2, children: why ? 'Needs a GPU: connect one with hanzo link.' : s.subtitle })] }, s.id));
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: "$red10", 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", width: 90, children: j.status ?? 'queued' }), _jsx(SizableText, { size: "$2", 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", children: "Making now" }), !making.length ? _jsx(SizableText, { color: "$soft", children: "No conversation is working." }) : null, making.map((r) => (_jsx(XStack, { render: "button", onPress: () => host.go(path({ kind: 'chat', id: r.id })), cursor: "pointer", children: _jsx(SizableText, { size: "$2", children: r.title }) }, r.id)))] })] }));
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');